[
  {
    "path": ".gitignore",
    "content": "\n*.user\n\n*.o\n\n*.stash\n*.obj\n*.Release\n*.Debug\n*.exe\n*.pdb\n*.*.ilk\n\nexamples/build-b_blending_poisson-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-cv_augmented_reality-Desktop_Qt_5_4_2_clang_64bit-Debug/cv_augmented_reality\n\nexamples/build-b_blending_poisson-Desktop_Qt_5_4_2_clang_64bit-Debug/b_blending_poisson\n\nexamples/build-b_blending_laplacian-Desktop_Qt_5_4_2_clang_64bit-Debug/b_blending_laplacian\n\nexamples/build-b_blending_laplacian-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-cv_augmented_reality-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-cv_corners_extraction-Desktop_Qt_5_4_2_clang_64bit-Debug/cv_corners_extraction\n\nexamples/build-cv_corners_extraction-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-cv_matching-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-cv_matching-Desktop_Qt_5_4_2_clang_64bit-Debug/cv_matching\n\nexamples/build-cv_triangulation-Desktop_Qt_5_4_2_clang_64bit-Debug/cv_triangulation\n\nexamples/build-cv_triangulation-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-edge_aware_filtering-Desktop_Qt_5_4_2_clang_64bit-Debug/edge_aware_filtering\n\nexamples/build-edge_aware_filtering-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-hdr_generation-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_generation\n\nexamples/build-hdr_generation-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_generation\n\nexamples/build-hdr_generation-Desktop_Qt_5_8_0_clang_64bit-Release/main.o-02dd9f2a\n\nexamples/build-hdr_generation-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_generation\n\n*.o-02dd9f2a\n\nexamples/build-s_livewire-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-s_livewire-Desktop_Qt_5_4_2_clang_64bit-Debug/s_livewire\n\nexamples/build-s_livewire-Desktop_Qt_5_4_2_clang_64bit-Release/Makefile\n\nexamples/build-s_livewire-Desktop_Qt_5_4_2_clang_64bit-Release/s_livewire\n\nexamples/build-hdr_generation-Desktop_Qt_5_8_0_clang_64bit-Release/main.o-02dd9f2a\n\nexamples/build-hdr_generation-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_generation\n\nexamples/data/input/test.png\n\nexamples/data/output/s_livewire_multiple.png\n\nexamples/data/output/s_livewire_single.png\n\nexamples/build-hdr_generation-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_generation\n\nexamples/build-hdr_exposure_fusion-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_exposure_fusion\n\nexamples/build-hdr_exposure_fusion-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-hdr_generation-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_generation\n\nexamples/build-hdr_generation-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\n*.o-02dd9f2a\n\nexamples/build-hdr_generation_alignment-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-hdr_tone_mapping_simple-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_tone_mapping_simple\n\nexamples/build-hdr_tone_mapping-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-hdr_tone_mapping_simple-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-ip_color_transform-Desktop_Qt_5_4_2_clang_64bit-Debug/ip_color_transform\n\nexamples/build-ip_color_transform-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-ip_dct_decomposition-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-hdr_generation-Desktop_Qt_5_8_0_clang_64bit-Release/main.o-02dd9f2a\n\nexamples/build-hdr_generation-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_generation\n\nexamples/build-ip_debayering-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-hdr_generation_alignment-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_generation_alignment\n\nexamples/build-ip_deblurring-Desktop_Qt_5_4_2_clang_64bit-Release/Makefile\n\nexamples/build-ip_debayering-Desktop_Qt_5_4_2_clang_64bit-Debug/ip_debayering\n\nexamples/build-hdr_generation-Desktop_Qt_5_8_0_clang_64bit-Release/main.o-02dd9f2a\n\nexamples/build-hdr_generation-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_generation\n\nexamples/segmentation_live_wire/main.cpp\n\nexamples/segmentation_live_wire/main.cpp\n\nexamples/build-ip_deform_grid-Desktop_Qt_5_4_2_clang_64bit-Debug/ip_deform_grid\n\nexamples/build-ip_deform_grid-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/data/input/test.jpg\nexamples/build-hdr_generation-Desktop_Qt_5_8_0_clang_64bit-Debug/hdr_generation\nexamples/build-hdr_generation-Desktop_Qt_5_8_0_clang_64bit-Debug/Makefile\nexamples/build-hdr_generation-Desktop_Qt_5_8_0_clang_64bit-Release/hdr_generation\nexamples/build-hdr_generation-Desktop_Qt_5_8_0_clang_64bit-Release/Makefile\nexamples/build-ip_white_balance-Desktop_Qt_5_8_0_clang_64bit-Release/ip_white_balance\nexamples/build-ip_white_balance-Desktop_Qt_5_8_0_clang_64bit-Release/Makefile\nexamples/build-opengl_filtering-Desktop_Qt_5_8_0_clang_64bit-Debug/Makefile\nexamples/build-opengl_simple_io-Desktop_Qt_5_8_0_clang_64bit-Debug/Makefile\nexamples/build-opengl_simple_io-Desktop_Qt_5_8_0_clang_64bit-Debug/opengl_simple_io\n\nexamples/build-cv_rectification-Desktop_Qt_5_4_2_clang_64bit-Release/Makefile\n\nexamples/build-cv_rectification-Desktop_Qt_5_4_2_clang_64bit-Release/cv_rectification\n\nexamples/build-edge_aware_filtering-Desktop_Qt_5_4_2_clang_64bit-Release/edge_aware_filtering\n\nexamples/build-edge_aware_filtering-Desktop_Qt_5_4_2_clang_64bit-Release/Makefile\n\nexamples/build-hdr_generation_alignment-Desktop_Qt_5_4_2_clang_64bit-Release/hdr_generation_alignment\n\nexamples/build-hdr_generation_alignment-Desktop_Qt_5_4_2_clang_64bit-Release/Makefile\n\nexamples/build-hdr_generation-Desktop_Qt_5_4_2_clang_64bit-Release/hdr_generation\n\nexamples/build-hdr_generation-Desktop_Qt_5_4_2_clang_64bit-Release/Makefile\n\nexamples/build-ip_deblurring-Desktop_Qt_5_4_2_clang_64bit-Release/ip_deblurring\n\nexamples/build-ip_deblurring-Desktop_Qt_5_4_2_clang_64bit-Release/ip_deblurring\n\nexamples/build-ip_deblurring-Desktop_Qt_5_4_2_clang_64bit-Release/ip_deblurring\n\nexamples/build-linear_filters-Desktop_Qt_5_4_2_clang_64bit-Debug/linear_filters\n\n*.jpg\n\n*.png\n\n*.bmp\n\nexamples/build-ip_deblurring-Desktop_Qt_5_4_2_clang_64bit-Release/ip_deblurring\n\nexamples/build-ip_deblurring-Desktop_Qt_5_4_2_clang_64bit-Release/ip_deblurring\n\nexamples/build-ip_deblurring-Desktop_Qt_5_4_2_clang_64bit-Release/ip_deblurring\n\nexamples/build-ip_deblurring-Desktop_Qt_5_4_2_clang_64bit-Release/ip_deblurring\n\nexamples/build-linear_filters-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-linear_filters-Desktop_Qt_5_4_2_clang_64bit-Release/linear_filters\n\nexamples/build-linear_filters-Desktop_Qt_5_4_2_clang_64bit-Release/Makefile\n\nexamples/build-opengl_convolution_2D-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-opengl_convolution_2D-Desktop_Qt_5_4_2_clang_64bit-Debug/opengl_convolution_2D\n\nexamples/build-opengl_deform_grid-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-opengl_deform_grid-Desktop_Qt_5_4_2_clang_64bit-Debug/opengl_deform_grid\n\nexamples/build-opengl_filtering-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-opengl_filtering-Desktop_Qt_5_4_2_clang_64bit-Debug/opengl_filtering\n\nexamples/build-opengl_push_pull-Desktop_Qt_5_4_2_clang_64bit-Debug/opengl_push_pull\n\n*.tmp\n\nexamples/build-s_kmeans-Desktop_Qt_5_4_2_clang_64bit-Debug/s_kmeans\n\nexamples/build-opengl_tone_mapping-Desktop_Qt_5_4_2_clang_64bit-Debug/opengl_tone_mapping\n\nexamples/build-opengl_tone_mapping-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\n*.png\n\nexamples/data/input/features/checker_board_photo.png\n\n*.hdr\n\nexamples/data/input/features/checker_board_photo.png\n\nexamples/build-u_polynomials-Desktop_Qt_5_4_2_clang_64bit-Debug/s_kmeans\n\nexamples/build-u_polynomials-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\n\nexamples/build-u_polynomials-Desktop_Qt_5_4_2_clang_64bit-Debug/main-aed74e84.o.tmp\n\nexamples/build-s_kmeans-Desktop_Qt_5_4_2_clang_64bit-Debug/s_kmeans\n\nexamples/build-opengl_push_pull-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\nexamples_jni/build-s_livewire-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\nexamples_jni/build-cv_find_checker_board-Desktop_Qt_5_4_2_clang_64bit-Release/cv_find_checker_board\nexamples_jni/build-cv_find_checker_board-Desktop_Qt_5_4_2_clang_64bit-Release/Makefile\nexamples_jni/build-ip_white_balance-Desktop_Qt_5_4_2_clang_64bit-Debug/ip_white_balance\nexamples_jni/build-ip_white_balance-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\nexamples_jni/build-s_livewire-Desktop_Qt_5_4_2_clang_64bit-Debug/s_livewire\nexamples/build-hdr_tone_mapping-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_tone_mapping\nexamples/build-hdr_tone_mapping-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_tone_mapping\nexamples/build-hdr_tone_mapping-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_tone_mapping\nexamples/build-hdr_tone_mapping-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_tone_mapping\nexamples/build-ip_io-Desktop_Qt_5_10_0_MSVC2017_64bit-Debug/Makefile\n*.ilk\nexamples/build-opengl_simple_io-Desktop_Qt_5_10_0_MSVC2017_64bit-Debug/Makefile\nexamples/build-opengl_filtering-Desktop_Qt_5_10_0_MSVC2017_64bit-Release/Makefile\nexamples/build-opengl_filtering-Desktop_Qt_5_10_0_MSVC2017_64bit-Debug/Makefile\nexamples/build-opengl_convolution_2D-Desktop_Qt_5_10_0_MSVC2017_64bit-Debug/Makefile\nexamples/build-ip_io-Desktop_Qt_5_10_0_MSVC2017_64bit-Release/Makefile\nexamples/build-simple_qt-Desktop_Qt_5_10_0_MSVC2017_64bit-Debug/debug/moc_predefs.h\nexamples/build-simple_qt-Desktop_Qt_5_10_0_MSVC2017_64bit-Debug/debug/moc_window.cpp\nexamples/build-simple_qt-Desktop_Qt_5_10_0_MSVC2017_64bit-Debug/debug/qrc_resources.cpp\nexamples/build-simple_qt-Desktop_Qt_5_10_0_MSVC2017_64bit-Debug/Makefile\nexamples/build-metrics_test-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\nexamples/build-metrics_test-Desktop_Qt_5_4_2_clang_64bit-Debug/simple_gray_scale\nexamples/build-hdr_tone_mapping-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_tone_mapping\nexamples/build-ip_metrics-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\nexamples/build-hdr_tone_mapping-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_tone_mapping\nexamples/build-ip_metrics-Desktop_Qt_5_4_2_clang_64bit-Debug/ip_metrics\nexamples/build-hdr_tone_mapping-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_tone_mapping\nexamples/build-opengl_exposure_fusion-Desktop_Qt_5_4_2_clang_64bit-Debug/opengl_exposure_fusion\nexamples/build-opengl_exposure_fusion-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\nexamples/build-b_push_pull-Desktop_Qt_5_10_0_MSVC2017_64bit-Debug/Makefile\nexamples/build-b_push_pull-Desktop_Qt_5_4_2_clang_64bit-Debug/b_push_pull\nexamples/build-b_push_pull-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\nexamples/build-hdr_exposure_fusion_stack-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\nexamples/build-hdr_exposure_fusion_stack-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_exposure_fusion_stack\nexamples/build-hdr_metrics-Desktop_Qt_5_4_2_clang_64bit-Debug/hdr_metrics\nexamples/build-hdr_metrics-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\nexamples/build-s_kmeans_colors-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\nexamples/build-s_kmeans_colors-Desktop_Qt_5_4_2_clang_64bit-Debug/s_kmeans_colors\nexamples/data/output/singapore_ssim_map.pfm\nexamples/build-hdr_metrics-Desktop_Qt_5_4_2_clang_64bit-Debug/ip_metrics\nexamples/data/output/bottles_ssim_map_pu.pfm\nexamples/data/output/bottles_ssim_map_lin.pfm\nexamples/build-hdr_tone_mapping-Desktop_Qt_5_8_0_clang_64bit-Debug/Makefile\nexamples/build-hdr_tone_mapping-Desktop_Qt_5_8_0_clang_64bit-Debug/hdr_tone_mapping\nexamples/build-hdr_exposure_fusion_stack-Desktop_Qt_5_4_2_clang_64bit-Release/hdr_exposure_fusion_stack\nexamples/build-hdr_exposure_fusion_stack-Desktop_Qt_5_4_2_clang_64bit-Release/Makefile\nexamples/build-hdr_exposure_fusion-Desktop_Qt_5_4_2_clang_64bit-Release/hdr_exposure_fusion\nexamples/build-hdr_exposure_fusion-Desktop_Qt_5_4_2_clang_64bit-Release/Makefile\nexamples/build-ip_io-Desktop_Qt_5_8_0_clang_64bit-Debug/ip_io\nexamples/build-ip_io-Desktop_Qt_5_8_0_clang_64bit-Debug/Makefile\nexamples/data/output/image.exr\nexamples/data/output/image.pfm\nexamples/data/output/image.pgm\nexamples/data/output/image.ppm\nexamples/data/output/image.tga\nexamples/build-hdr_generation_alignment-Desktop_Qt_5_8_0_clang_64bit-Release/hdr_generation_alignment\nexamples/build-hdr_generation_alignment-Desktop_Qt_5_8_0_clang_64bit-Release/Makefile\nexamples/build-s_kmeans-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\ninclude/io/stb.hpp.autosave\ninclude/io/stb.hpp.autosave\nexamples/build-s_kmeans_colors-Desktop_Qt_5_4_2_clang_64bit-Release/Makefile\nexamples/build-s_kmeans_colors-Desktop_Qt_5_4_2_clang_64bit-Release/s_kmeans_colors\nexamples/build-s_otsu-Desktop_Qt_5_4_2_clang_64bit-Debug/Makefile\nexamples/build-s_otsu-Desktop_Qt_5_4_2_clang_64bit-Debug/s_livewire\n.DS_Store\n"
  },
  {
    "path": "README.md",
    "content": "PICCANTE\n========\n\nThe hottest hdr imaging library\n\nPICCANTE is a C++11 image processing library aimed to provide structures and functionalities for enabling both High Dynamic Range (HDR) and standard imaging.\n\nDEPENDENCIES:\n==============\nPiccante uses STB image library for reading and writing PNG and JPEG files.\nSTB can be downloaded here:\nhttps://github.com/nothings/stb\n\nBy default this library is needed to run all examples, and needs to be localed\nas follow:\n``` C\n-folder\n+___\"piccante\"\n+___\"stb\"\n```\n\nIf you have STB in the system path you can disable the local path include system\nby adding the following define before including piccante.hpp:\n``` C\n#define PIC_DISABLE_STB\n```\n\n\nTo disable the use of STB, you can add the following define before including piccante.hpp:\n ``` C\n#define PIC_DISABLE_STB_LOCAL\n ```\n\n\nHOW TO INSTALL:\n===============\n\n1) Unzip the file .zip in a FOLDER on your machine\n\n2) Add piccante include directory in your include path\n\n3) Include \"piccante.hpp\" in your project\n\n\nNOTE ON CODE USE:\n=================\nWhen you use parts or the full source code of this project in your own project, please remember to cite this project both in your project webpage and in its source code. This SHOULD be done even when you convert this code into another programming language.\n\nBe kind.\n\nNOTE ON PULL REQUESTS:\n=====================\nPlease, send your pull requests to the develop branch.\n\nTEAM:\n=====\n\nFrancesco Banterle\n\nLuca Benedetti\n\nLICENSE:\n========\nPiccante is distributed under the MPL 2.0 license: https://www.mozilla.org/MPL/2.0/\n\nREFERENCE:\n==========\n\nIf you use PICCANTE in your work, please cite it using this reference:\n\n```\n@misc{banterle:pic:2014,\n Author = {Francesco Banterle and Luca Benedetti},\n Title = {{PICCANTE: An Open and Portable Library for HDR Imaging}},\n Year  = {2014},\n Howpublished = {\\url{ http://vcg.isti.cnr.it/piccante }}\n }\n```\n \nFREQUENTLY ASKED QUESTIONS (FAQs):\n==================================\n\n\n**Question:** Can I disable OpenGL?\n\n**Answer:** Yes, you can do it. You need to add this line of code before\nincluding piccante.hpp in your project:\n``` C\n#define PIC_DISABLE_OPENGL\n#include \"piccante.hpp\"\n```\n\n##\n**Question:** Can I use my version of Eigen instead of the one in the bundle?\n\n**Answer:** Yes, you can do it. You just need to add this line of code before\nincluding piccante.hpp in your project:\n``` C\n#define PIC_EIGEN_NOT_BUNDLED\n#include \"piccante.hpp\"\n```\n\n##\n**Question:** Can I use OpenEXR instead of TinyEXR?\n\n**Answer:**  Yes, you can do it. You just need to add these two lines of code before\nincluding piccante.hpp in your project:\n``` C\n#define PIC_DISABLE_TINY_EXR\n#define PIC_ENABLE_OPEN_EXR\n#include \"piccante.hpp\"\n```\n\nSCREENSHOTS:\n============\nPiccante can be used for generating HDR images starting from a stack of classic 8-bit\nimages.\n\n![HDR Generation](http://vcg.isti.cnr.it/piccante/img/hdr_generation.png?raw=true \"HDR Generation\")\n\nPiccante can manage different color spaces, and new ones can be added to its core with ease. \n\n![Color Spaces](http://vcg.isti.cnr.it/piccante/img/color_spaces.png?raw=true \"Color Spaces\")\n\nPiccante provides algorithms for tone mapping HDR images in order to be visualized on traditional displays.\n\n![Tone Mapping](http://vcg.isti.cnr.it/piccante/img/tone_mapping.png?raw=true \"Tone Mapping\")\n\nPiccante can filter images using a high quality selection of linear and non linear filters.\n\n![Filtering](http://vcg.isti.cnr.it/piccante/img/filtering.png?raw=true \"Filtering\")\n\nPiccante can extract local features for different tasks such as image alignments, classification, 3D reconstruction, etc.\n\n![Local Features](http://vcg.isti.cnr.it/piccante/img/local_features.png?raw=true \"Local Features\")\n"
  },
  {
    "path": "citation.bib",
    "content": "@misc{banterle:pic:2014,\n Author = {Francesco Banterle and Luca Benedetti},\n Title = {{PICCANTE: An Open and Portable Library for HDR Imaging}},\n Year  = {2014},\n Howpublished = {\\url{http://vcg.isti.cnr.it/piccante}\n }\n"
  },
  {
    "path": "doc/Doxyfile",
    "content": "# Doxyfile 1.8.6\n\n# This file describes the settings to be used by the documentation system\n# doxygen (www.doxygen.org) for a project.\n#\n# All text after a double hash (##) is considered a comment and is placed in\n# front of the TAG it is preceding.\n#\n# All text after a single hash (#) is considered a comment and will be ignored.\n# The format is:\n# TAG = value [value, ...]\n# For lists, items can also be appended using:\n# TAG += value [value, ...]\n# Values that contain spaces should be placed between quotes (\\\" \\\").\n\n#---------------------------------------------------------------------------\n# Project related configuration options\n#---------------------------------------------------------------------------\n\n# This tag specifies the encoding used for all characters in the config file\n# that follow. The default is UTF-8 which is also the encoding used for all text\n# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv\n# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv\n# for the list of possible encodings.\n# The default value is: UTF-8.\n\nDOXYFILE_ENCODING      = UTF-8\n\n# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by\n# double-quotes, unless you are using Doxywizard) that should identify the\n# project for which the documentation is generated. This name is used in the\n# title of most generated pages and in a few other places.\n# The default value is: My Project.\n\nPROJECT_NAME           = PICCANTE\n\n# The PROJECT_NUMBER tag can be used to enter a project or revision number. This\n# could be handy for archiving the generated documentation or if some version\n# control system is used.\n\nPROJECT_NUMBER         = 0.4\n\n# Using the PROJECT_BRIEF tag one can provide an optional one line description\n# for a project that appears at the top of each page and should give viewer a\n# quick idea about the purpose of the project. Keep the description short.\n\nPROJECT_BRIEF          = \"The hottest HDR imaging library!\"\n\n# With the PROJECT_LOGO tag one can specify an logo or icon that is included in\n# the documentation. The maximum height of the logo should not exceed 55 pixels\n# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo\n# to the output directory.\n\nPROJECT_LOGO           = logo_79_180.png\n\n# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path\n# into which the generated documentation will be written. If a relative path is\n# entered, it will be relative to the location where doxygen was started. If\n# left blank the current directory will be used.\n\nOUTPUT_DIRECTORY       = .\n\n# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-\n# directories (in 2 levels) under the output directory of each output format and\n# will distribute the generated files over these directories. Enabling this\n# option can be useful when feeding doxygen a huge amount of source files, where\n# putting all generated files in the same directory would otherwise causes\n# performance problems for the file system.\n# The default value is: NO.\n\nCREATE_SUBDIRS         = YES\n\n# The OUTPUT_LANGUAGE tag is used to specify the language in which all\n# documentation generated by doxygen is written. Doxygen will use this\n# information to generate all constant output in the proper language.\n# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,\n# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),\n# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,\n# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),\n# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,\n# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,\n# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,\n# Ukrainian and Vietnamese.\n# The default value is: English.\n\nOUTPUT_LANGUAGE        = English\n\n# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member\n# descriptions after the members that are listed in the file and class\n# documentation (similar to Javadoc). Set to NO to disable this.\n# The default value is: YES.\n\nBRIEF_MEMBER_DESC      = YES\n\n# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief\n# description of a member or function before the detailed description\n#\n# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the\n# brief descriptions will be completely suppressed.\n# The default value is: YES.\n\nREPEAT_BRIEF           = YES\n\n# This tag implements a quasi-intelligent brief description abbreviator that is\n# used to form the text in various listings. Each string in this list, if found\n# as the leading text of the brief description, will be stripped from the text\n# and the result, after processing the whole list, is used as the annotated\n# text. Otherwise, the brief description is used as-is. If left blank, the\n# following values are used ($name is automatically replaced with the name of\n# the entity):The $name class, The $name widget, The $name file, is, provides,\n# specifies, contains, represents, a, an and the.\n\nABBREVIATE_BRIEF       = \"The $name class\" \\\n                         \"The $name widget\" \\\n                         \"The $name file\" \\\n                         is \\\n                         provides \\\n                         specifies \\\n                         contains \\\n                         represents \\\n                         a \\\n                         an \\\n                         the\n\n# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then\n# doxygen will generate a detailed section even if there is only a brief\n# description.\n# The default value is: NO.\n\nALWAYS_DETAILED_SEC    = NO\n\n# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all\n# inherited members of a class in the documentation of that class as if those\n# members were ordinary class members. Constructors, destructors and assignment\n# operators of the base classes will not be shown.\n# The default value is: NO.\n\nINLINE_INHERITED_MEMB  = NO\n\n# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path\n# before files name in the file list and in the header files. If set to NO the\n# shortest path that makes the file name unique will be used\n# The default value is: YES.\n\nFULL_PATH_NAMES        = YES\n\n# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.\n# Stripping is only done if one of the specified strings matches the left-hand\n# part of the path. The tag can be used to show relative paths in the file list.\n# If left blank the directory from which doxygen is run is used as the path to\n# strip.\n#\n# Note that you can specify absolute paths here, but also relative paths, which\n# will be relative from the directory where doxygen is started.\n# This tag requires that the tag FULL_PATH_NAMES is set to YES.\n\nSTRIP_FROM_PATH        = \n\n# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the\n# path mentioned in the documentation of a class, which tells the reader which\n# header file to include in order to use a class. If left blank only the name of\n# the header file containing the class definition is used. Otherwise one should\n# specify the list of include paths that are normally passed to the compiler\n# using the -I flag.\n\nSTRIP_FROM_INC_PATH    = \n\n# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but\n# less readable) file names. This can be useful is your file systems doesn't\n# support long names like on DOS, Mac, or CD-ROM.\n# The default value is: NO.\n\nSHORT_NAMES            = NO\n\n# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the\n# first line (until the first dot) of a Javadoc-style comment as the brief\n# description. If set to NO, the Javadoc-style will behave just like regular Qt-\n# style comments (thus requiring an explicit @brief command for a brief\n# description.)\n# The default value is: NO.\n\nJAVADOC_AUTOBRIEF      = NO\n\n# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first\n# line (until the first dot) of a Qt-style comment as the brief description. If\n# set to NO, the Qt-style will behave just like regular Qt-style comments (thus\n# requiring an explicit \\brief command for a brief description.)\n# The default value is: NO.\n\nQT_AUTOBRIEF           = NO\n\n# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a\n# multi-line C++ special comment block (i.e. a block of //! or /// comments) as\n# a brief description. This used to be the default behavior. The new default is\n# to treat a multi-line C++ comment block as a detailed description. Set this\n# tag to YES if you prefer the old behavior instead.\n#\n# Note that setting this tag to YES also means that rational rose comments are\n# not recognized any more.\n# The default value is: NO.\n\nMULTILINE_CPP_IS_BRIEF = NO\n\n# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the\n# documentation from any documented member that it re-implements.\n# The default value is: YES.\n\nINHERIT_DOCS           = YES\n\n# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a\n# new page for each member. If set to NO, the documentation of a member will be\n# part of the file/class/namespace that contains it.\n# The default value is: NO.\n\nSEPARATE_MEMBER_PAGES  = NO\n\n# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen\n# uses this value to replace tabs by spaces in code fragments.\n# Minimum value: 1, maximum value: 16, default value: 4.\n\nTAB_SIZE               = 4\n\n# This tag can be used to specify a number of aliases that act as commands in\n# the documentation. An alias has the form:\n# name=value\n# For example adding\n# \"sideeffect=@par Side Effects:\\n\"\n# will allow you to put the command \\sideeffect (or @sideeffect) in the\n# documentation, which will result in a user-defined paragraph with heading\n# \"Side Effects:\". You can put \\n's in the value part of an alias to insert\n# newlines.\n\nALIASES                = \n\n# This tag can be used to specify a number of word-keyword mappings (TCL only).\n# A mapping has the form \"name=value\". For example adding \"class=itcl::class\"\n# will allow you to use the command class in the itcl::class meaning.\n\nTCL_SUBST              = \n\n# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources\n# only. Doxygen will then generate output that is more tailored for C. For\n# instance, some of the names that are used will be different. The list of all\n# members will be omitted, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_FOR_C  = NO\n\n# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or\n# Python sources only. Doxygen will then generate output that is more tailored\n# for that language. For instance, namespaces will be presented as packages,\n# qualified scopes will look different, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_JAVA   = NO\n\n# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran\n# sources. Doxygen will then generate output that is tailored for Fortran.\n# The default value is: NO.\n\nOPTIMIZE_FOR_FORTRAN   = NO\n\n# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL\n# sources. Doxygen will then generate output that is tailored for VHDL.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_VHDL   = NO\n\n# Doxygen selects the parser to use depending on the extension of the files it\n# parses. With this tag you can assign which parser to use for a given\n# extension. Doxygen has a built-in mapping, but you can override or extend it\n# using this tag. The format is ext=language, where ext is a file extension, and\n# language is one of the parsers supported by doxygen: IDL, Java, Javascript,\n# C#, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL. For instance to make\n# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C\n# (default is Fortran), use: inc=Fortran f=C.\n#\n# Note For files without extension you can use no_extension as a placeholder.\n#\n# Note that for custom extensions you also need to set FILE_PATTERNS otherwise\n# the files are not read by doxygen.\n\nEXTENSION_MAPPING      = \n\n# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments\n# according to the Markdown format, which allows for more readable\n# documentation. See http://daringfireball.net/projects/markdown/ for details.\n# The output of markdown processing is further processed by doxygen, so you can\n# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in\n# case of backward compatibilities issues.\n# The default value is: YES.\n\nMARKDOWN_SUPPORT       = YES\n\n# When enabled doxygen tries to link words that correspond to documented\n# classes, or namespaces to their corresponding documentation. Such a link can\n# be prevented in individual cases by by putting a % sign in front of the word\n# or globally by setting AUTOLINK_SUPPORT to NO.\n# The default value is: YES.\n\nAUTOLINK_SUPPORT       = YES\n\n# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want\n# to include (a tag file for) the STL sources as input, then you should set this\n# tag to YES in order to let doxygen match functions declarations and\n# definitions whose arguments contain STL classes (e.g. func(std::string);\n# versus func(std::string) {}). This also make the inheritance and collaboration\n# diagrams that involve STL classes more complete and accurate.\n# The default value is: NO.\n\nBUILTIN_STL_SUPPORT    = NO\n\n# If you use Microsoft's C++/CLI language, you should set this option to YES to\n# enable parsing support.\n# The default value is: NO.\n\nCPP_CLI_SUPPORT        = NO\n\n# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:\n# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen\n# will parse them like normal C++ but will assume all classes use public instead\n# of private inheritance when no explicit protection keyword is present.\n# The default value is: NO.\n\nSIP_SUPPORT            = NO\n\n# For Microsoft's IDL there are propget and propput attributes to indicate\n# getter and setter methods for a property. Setting this option to YES will make\n# doxygen to replace the get and set methods by a property in the documentation.\n# This will only work if the methods are indeed getting or setting a simple\n# type. If this is not the case, or you want to show the methods anyway, you\n# should set this option to NO.\n# The default value is: YES.\n\nIDL_PROPERTY_SUPPORT   = YES\n\n# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC\n# tag is set to YES, then doxygen will reuse the documentation of the first\n# member in the group (if any) for the other members of the group. By default\n# all members of a group must be documented explicitly.\n# The default value is: NO.\n\nDISTRIBUTE_GROUP_DOC   = NO\n\n# Set the SUBGROUPING tag to YES to allow class member groups of the same type\n# (for instance a group of public functions) to be put as a subgroup of that\n# type (e.g. under the Public Functions section). Set it to NO to prevent\n# subgrouping. Alternatively, this can be done per class using the\n# \\nosubgrouping command.\n# The default value is: YES.\n\nSUBGROUPING            = YES\n\n# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions\n# are shown inside the group in which they are included (e.g. using \\ingroup)\n# instead of on a separate page (for HTML and Man pages) or section (for LaTeX\n# and RTF).\n#\n# Note that this feature does not work in combination with\n# SEPARATE_MEMBER_PAGES.\n# The default value is: NO.\n\nINLINE_GROUPED_CLASSES = NO\n\n# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions\n# with only public data fields or simple typedef fields will be shown inline in\n# the documentation of the scope in which they are defined (i.e. file,\n# namespace, or group documentation), provided this scope is documented. If set\n# to NO, structs, classes, and unions are shown on a separate page (for HTML and\n# Man pages) or section (for LaTeX and RTF).\n# The default value is: NO.\n\nINLINE_SIMPLE_STRUCTS  = NO\n\n# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or\n# enum is documented as struct, union, or enum with the name of the typedef. So\n# typedef struct TypeS {} TypeT, will appear in the documentation as a struct\n# with name TypeT. When disabled the typedef will appear as a member of a file,\n# namespace, or class. And the struct will be named TypeS. This can typically be\n# useful for C code in case the coding convention dictates that all compound\n# types are typedef'ed and only the typedef is referenced, never the tag name.\n# The default value is: NO.\n\nTYPEDEF_HIDES_STRUCT   = NO\n\n# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This\n# cache is used to resolve symbols given their name and scope. Since this can be\n# an expensive process and often the same symbol appears multiple times in the\n# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small\n# doxygen will become slower. If the cache is too large, memory is wasted. The\n# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range\n# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536\n# symbols. At the end of a run doxygen will report the cache usage and suggest\n# the optimal cache size from a speed point of view.\n# Minimum value: 0, maximum value: 9, default value: 0.\n\nLOOKUP_CACHE_SIZE      = 0\n\n#---------------------------------------------------------------------------\n# Build related configuration options\n#---------------------------------------------------------------------------\n\n# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in\n# documentation are documented, even if no documentation was available. Private\n# class members and static file members will be hidden unless the\n# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.\n# Note: This will also disable the warnings about undocumented members that are\n# normally produced when WARNINGS is set to YES.\n# The default value is: NO.\n\nEXTRACT_ALL            = YES\n\n# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will\n# be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PRIVATE        = NO\n\n# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal\n# scope will be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PACKAGE        = NO\n\n# If the EXTRACT_STATIC tag is set to YES all static members of a file will be\n# included in the documentation.\n# The default value is: NO.\n\nEXTRACT_STATIC         = NO\n\n# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined\n# locally in source files will be included in the documentation. If set to NO\n# only classes defined in header files are included. Does not have any effect\n# for Java sources.\n# The default value is: YES.\n\nEXTRACT_LOCAL_CLASSES  = YES\n\n# This flag is only useful for Objective-C code. When set to YES local methods,\n# which are defined in the implementation section but not in the interface are\n# included in the documentation. If set to NO only methods in the interface are\n# included.\n# The default value is: NO.\n\nEXTRACT_LOCAL_METHODS  = NO\n\n# If this flag is set to YES, the members of anonymous namespaces will be\n# extracted and appear in the documentation as a namespace called\n# 'anonymous_namespace{file}', where file will be replaced with the base name of\n# the file that contains the anonymous namespace. By default anonymous namespace\n# are hidden.\n# The default value is: NO.\n\nEXTRACT_ANON_NSPACES   = NO\n\n# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all\n# undocumented members inside documented classes or files. If set to NO these\n# members will be included in the various overviews, but no documentation\n# section is generated. This option has no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_MEMBERS     = NO\n\n# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all\n# undocumented classes that are normally visible in the class hierarchy. If set\n# to NO these classes will be included in the various overviews. This option has\n# no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_CLASSES     = NO\n\n# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend\n# (class|struct|union) declarations. If set to NO these declarations will be\n# included in the documentation.\n# The default value is: NO.\n\nHIDE_FRIEND_COMPOUNDS  = NO\n\n# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any\n# documentation blocks found inside the body of a function. If set to NO these\n# blocks will be appended to the function's detailed documentation block.\n# The default value is: NO.\n\nHIDE_IN_BODY_DOCS      = NO\n\n# The INTERNAL_DOCS tag determines if documentation that is typed after a\n# \\internal command is included. If the tag is set to NO then the documentation\n# will be excluded. Set it to YES to include the internal documentation.\n# The default value is: NO.\n\nINTERNAL_DOCS          = NO\n\n# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file\n# names in lower-case letters. If set to YES upper-case letters are also\n# allowed. This is useful if you have classes or files whose names only differ\n# in case and if your file system supports case sensitive file names. Windows\n# and Mac users are advised to set this option to NO.\n# The default value is: system dependent.\n\nCASE_SENSE_NAMES       = NO\n\n# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with\n# their full class and namespace scopes in the documentation. If set to YES the\n# scope will be hidden.\n# The default value is: NO.\n\nHIDE_SCOPE_NAMES       = NO\n\n# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of\n# the files that are included by a file in the documentation of that file.\n# The default value is: YES.\n\nSHOW_INCLUDE_FILES     = YES\n\n\nSHOW_GROUPED_MEMB_INC  = NO\n\n# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include\n# files with double quotes in the documentation rather than with sharp brackets.\n# The default value is: NO.\n\nFORCE_LOCAL_INCLUDES   = NO\n\n# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the\n# documentation for inline members.\n# The default value is: YES.\n\nINLINE_INFO            = YES\n\n# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the\n# (detailed) documentation of file and class members alphabetically by member\n# name. If set to NO the members will appear in declaration order.\n# The default value is: YES.\n\nSORT_MEMBER_DOCS       = YES\n\n# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief\n# descriptions of file, namespace and class members alphabetically by member\n# name. If set to NO the members will appear in declaration order. Note that\n# this will also influence the order of the classes in the class list.\n# The default value is: NO.\n\nSORT_BRIEF_DOCS        = NO\n\n# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the\n# (brief and detailed) documentation of class members so that constructors and\n# destructors are listed first. If set to NO the constructors will appear in the\n# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.\n# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief\n# member documentation.\n# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting\n# detailed member documentation.\n# The default value is: NO.\n\nSORT_MEMBERS_CTORS_1ST = NO\n\n# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy\n# of group names into alphabetical order. If set to NO the group names will\n# appear in their defined order.\n# The default value is: NO.\n\nSORT_GROUP_NAMES       = NO\n\n# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by\n# fully-qualified names, including namespaces. If set to NO, the class list will\n# be sorted only by class name, not including the namespace part.\n# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.\n# Note: This option applies only to the class list, not to the alphabetical\n# list.\n# The default value is: NO.\n\nSORT_BY_SCOPE_NAME     = NO\n\n# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper\n# type resolution of all parameters of a function it will reject a match between\n# the prototype and the implementation of a member function even if there is\n# only one candidate or it is obvious which candidate to choose by doing a\n# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still\n# accept a match between prototype and implementation in such cases.\n# The default value is: NO.\n\nSTRICT_PROTO_MATCHING  = NO\n\n# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the\n# todo list. This list is created by putting \\todo commands in the\n# documentation.\n# The default value is: YES.\n\nGENERATE_TODOLIST      = YES\n\n# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the\n# test list. This list is created by putting \\test commands in the\n# documentation.\n# The default value is: YES.\n\nGENERATE_TESTLIST      = YES\n\n# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug\n# list. This list is created by putting \\bug commands in the documentation.\n# The default value is: YES.\n\nGENERATE_BUGLIST       = YES\n\n# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO)\n# the deprecated list. This list is created by putting \\deprecated commands in\n# the documentation.\n# The default value is: YES.\n\nGENERATE_DEPRECATEDLIST= YES\n\n# The ENABLED_SECTIONS tag can be used to enable conditional documentation\n# sections, marked by \\if <section_label> ... \\endif and \\cond <section_label>\n# ... \\endcond blocks.\n\nENABLED_SECTIONS       = \n\n# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the\n# initial value of a variable or macro / define can have for it to appear in the\n# documentation. If the initializer consists of more lines than specified here\n# it will be hidden. Use a value of 0 to hide initializers completely. The\n# appearance of the value of individual variables and macros / defines can be\n# controlled using \\showinitializer or \\hideinitializer command in the\n# documentation regardless of this setting.\n# Minimum value: 0, maximum value: 10000, default value: 30.\n\nMAX_INITIALIZER_LINES  = 30\n\n# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at\n# the bottom of the documentation of classes and structs. If set to YES the list\n# will mention the files that were used to generate the documentation.\n# The default value is: YES.\n\nSHOW_USED_FILES        = YES\n\n# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This\n# will remove the Files entry from the Quick Index and from the Folder Tree View\n# (if specified).\n# The default value is: YES.\n\nSHOW_FILES             = YES\n\n# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces\n# page. This will remove the Namespaces entry from the Quick Index and from the\n# Folder Tree View (if specified).\n# The default value is: YES.\n\nSHOW_NAMESPACES        = YES\n\n# The FILE_VERSION_FILTER tag can be used to specify a program or script that\n# doxygen should invoke to get the current version for each file (typically from\n# the version control system). Doxygen will invoke the program by executing (via\n# popen()) the command command input-file, where command is the value of the\n# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided\n# by doxygen. Whatever the program writes to standard output is used as the file\n# version. For an example see the documentation.\n\nFILE_VERSION_FILTER    = \n\n# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed\n# by doxygen. The layout file controls the global structure of the generated\n# output files in an output format independent way. To create the layout file\n# that represents doxygen's defaults, run doxygen with the -l option. You can\n# optionally specify a file name after the option, if omitted DoxygenLayout.xml\n# will be used as the name of the layout file.\n#\n# Note that if you run doxygen from a directory containing a file called\n# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE\n# tag is left empty.\n\nLAYOUT_FILE            = \n\n# The CITE_BIB_FILES tag can be used to specify one or more bib files containing\n# the reference definitions. This must be a list of .bib files. The .bib\n# extension is automatically appended if omitted. This requires the bibtex tool\n# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.\n# For LaTeX the style of the bibliography can be controlled using\n# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the\n# search path. Do not use file names with spaces, bibtex cannot handle them. See\n# also \\cite for info how to create references.\n\nCITE_BIB_FILES         = \n\n#---------------------------------------------------------------------------\n# Configuration options related to warning and progress messages\n#---------------------------------------------------------------------------\n\n# The QUIET tag can be used to turn on/off the messages that are generated to\n# standard output by doxygen. If QUIET is set to YES this implies that the\n# messages are off.\n# The default value is: NO.\n\nQUIET                  = NO\n\n# The WARNINGS tag can be used to turn on/off the warning messages that are\n# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES\n# this implies that the warnings are on.\n#\n# Tip: Turn warnings on while writing the documentation.\n# The default value is: YES.\n\nWARNINGS               = YES\n\n# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate\n# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag\n# will automatically be disabled.\n# The default value is: YES.\n\nWARN_IF_UNDOCUMENTED   = YES\n\n# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for\n# potential errors in the documentation, such as not documenting some parameters\n# in a documented function, or documenting parameters that don't exist or using\n# markup commands wrongly.\n# The default value is: YES.\n\nWARN_IF_DOC_ERROR      = YES\n\n# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that\n# are documented, but have no documentation for their parameters or return\n# value. If set to NO doxygen will only warn about wrong or incomplete parameter\n# documentation, but not about the absence of documentation.\n# The default value is: NO.\n\nWARN_NO_PARAMDOC       = NO\n\n# The WARN_FORMAT tag determines the format of the warning messages that doxygen\n# can produce. The string should contain the $file, $line, and $text tags, which\n# will be replaced by the file and line number from which the warning originated\n# and the warning text. Optionally the format may contain $version, which will\n# be replaced by the version of the file (if it could be obtained via\n# FILE_VERSION_FILTER)\n# The default value is: $file:$line: $text.\n\nWARN_FORMAT            = \"$file:$line: $text\"\n\n# The WARN_LOGFILE tag can be used to specify a file to which warning and error\n# messages should be written. If left blank the output is written to standard\n# error (stderr).\n\nWARN_LOGFILE           = doxy_warn.log\n\n#---------------------------------------------------------------------------\n# Configuration options related to the input files\n#---------------------------------------------------------------------------\n\n# The INPUT tag is used to specify the files and/or directories that contain\n# documented source files. You may enter file names like myfile.cpp or\n# directories like /usr/src/myproject. Separate the files or directories with\n# spaces.\n# Note: If this tag is empty the current directory is searched.\n\nINPUT                  = ../include\n\n# This tag can be used to specify the character encoding of the source files\n# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses\n# libiconv (or the iconv built into libc) for the transcoding. See the libiconv\n# documentation (see: http://www.gnu.org/software/libiconv) for the list of\n# possible encodings.\n# The default value is: UTF-8.\n\nINPUT_ENCODING         = UTF-8\n\n# If the value of the INPUT tag contains directories, you can use the\n# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and\n# *.h) to filter out the source-files in the directories. If left blank the\n# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,\n# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,\n# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,\n# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,\n# *.qsf, *.as and *.js.\n\nFILE_PATTERNS          = *.c \\\n                         *.cc \\\n                         *.cxx \\\n                         *.cpp \\\n                         *.c++ \\\n                         *.d \\\n                         *.java \\\n                         *.ii \\\n                         *.ixx \\\n                         *.ipp \\\n                         *.i++ \\\n                         *.inl \\\n                         *.h \\\n                         *.hh \\\n                         *.hxx \\\n                         *.hpp \\\n                         *.h++ \\\n                         *.idl \\\n                         *.odl \\\n                         *.cs \\\n                         *.php \\\n                         *.php3 \\\n                         *.inc \\\n                         *.m \\\n                         *.markdown \\\n                         *.md \\\n                         *.mm \\\n                         *.dox \\\n                         *.py \\\n                         *.f90 \\\n                         *.f \\\n                         *.for \\\n                         *.vhd \\\n                         *.vhdl\n\n# The RECURSIVE tag can be used to specify whether or not subdirectories should\n# be searched for input files as well.\n# The default value is: NO.\n\nRECURSIVE              = YES\n\n# The EXCLUDE tag can be used to specify files and/or directories that should be\n# excluded from the INPUT source files. This way you can easily exclude a\n# subdirectory from a directory tree whose root is specified with the INPUT tag.\n#\n# Note that relative paths are relative to the directory from which doxygen is\n# run.\n\nEXCLUDE                = ../include/externals\n\n# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or\n# directories that are symbolic links (a Unix file system feature) are excluded\n# from the input.\n# The default value is: NO.\n\nEXCLUDE_SYMLINKS       = NO\n\n# If the value of the INPUT tag contains directories, you can use the\n# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude\n# certain files from those directories.\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories for example use the pattern */test/*\n\nEXCLUDE_PATTERNS       = \n\n# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names\n# (namespaces, classes, functions, etc.) that should be excluded from the\n# output. The symbol name can be a fully qualified name, a word, or if the\n# wildcard * is used, a substring. Examples: ANamespace, AClass,\n# AClass::ANamespace, ANamespace::*Test\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories use the pattern */test/*\n\nEXCLUDE_SYMBOLS        = Eigen\n\n# The EXAMPLE_PATH tag can be used to specify one or more files or directories\n# that contain example code fragments that are included (see the \\include\n# command).\n\nEXAMPLE_PATH           = \n\n# If the value of the EXAMPLE_PATH tag contains directories, you can use the\n# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and\n# *.h) to filter out the source-files in the directories. If left blank all\n# files are included.\n\nEXAMPLE_PATTERNS       = \n\n# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be\n# searched for input files to be used with the \\include or \\dontinclude commands\n# irrespective of the value of the RECURSIVE tag.\n# The default value is: NO.\n\nEXAMPLE_RECURSIVE      = NO\n\n# The IMAGE_PATH tag can be used to specify one or more files or directories\n# that contain images that are to be included in the documentation (see the\n# \\image command).\n\nIMAGE_PATH             = \n\n# The INPUT_FILTER tag can be used to specify a program that doxygen should\n# invoke to filter for each input file. Doxygen will invoke the filter program\n# by executing (via popen()) the command:\n#\n# <filter> <input-file>\n#\n# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the\n# name of an input file. Doxygen will then use the output that the filter\n# program writes to standard output. If FILTER_PATTERNS is specified, this tag\n# will be ignored.\n#\n# Note that the filter must not add or remove lines; it is applied before the\n# code is scanned, but not when the output code is generated. If lines are added\n# or removed, the anchors will not be placed correctly.\n\nINPUT_FILTER           = \n\n# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern\n# basis. Doxygen will compare the file name with each pattern and apply the\n# filter if there is a match. The filters are a list of the form: pattern=filter\n# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how\n# filters are used. If the FILTER_PATTERNS tag is empty or if none of the\n# patterns match the file name, INPUT_FILTER is applied.\n\nFILTER_PATTERNS        = \n\n# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using\n# INPUT_FILTER ) will also be used to filter the input files that are used for\n# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).\n# The default value is: NO.\n\nFILTER_SOURCE_FILES    = NO\n\n# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file\n# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and\n# it is also possible to disable source filtering for a specific pattern using\n# *.ext= (so without naming a filter).\n# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.\n\nFILTER_SOURCE_PATTERNS = \n\n# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that\n# is part of the input, its contents will be placed on the main page\n# (index.html). This can be useful if you have a project on for instance GitHub\n# and want to reuse the introduction page also for the doxygen output.\n\nUSE_MDFILE_AS_MAINPAGE = \n\n#---------------------------------------------------------------------------\n# Configuration options related to source browsing\n#---------------------------------------------------------------------------\n\n# If the SOURCE_BROWSER tag is set to YES then a list of source files will be\n# generated. Documented entities will be cross-referenced with these sources.\n#\n# Note: To get rid of all source code in the generated output, make sure that\n# also VERBATIM_HEADERS is set to NO.\n# The default value is: NO.\n\nSOURCE_BROWSER         = NO\n\n# Setting the INLINE_SOURCES tag to YES will include the body of functions,\n# classes and enums directly into the documentation.\n# The default value is: NO.\n\nINLINE_SOURCES         = NO\n\n# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any\n# special comment blocks from generated source code fragments. Normal C, C++ and\n# Fortran comments will always remain visible.\n# The default value is: YES.\n\nSTRIP_CODE_COMMENTS    = YES\n\n# If the REFERENCED_BY_RELATION tag is set to YES then for each documented\n# function all documented functions referencing it will be listed.\n# The default value is: NO.\n\nREFERENCED_BY_RELATION = NO\n\n# If the REFERENCES_RELATION tag is set to YES then for each documented function\n# all documented entities called/used by that function will be listed.\n# The default value is: NO.\n\nREFERENCES_RELATION    = NO\n\n# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set\n# to YES, then the hyperlinks from functions in REFERENCES_RELATION and\n# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will\n# link to the documentation.\n# The default value is: YES.\n\nREFERENCES_LINK_SOURCE = YES\n\n# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the\n# source code will show a tooltip with additional information such as prototype,\n# brief description and links to the definition and documentation. Since this\n# will make the HTML file larger and loading of large files a bit slower, you\n# can opt to disable this feature.\n# The default value is: YES.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nSOURCE_TOOLTIPS        = YES\n\n# If the USE_HTAGS tag is set to YES then the references to source code will\n# point to the HTML generated by the htags(1) tool instead of doxygen built-in\n# source browser. The htags tool is part of GNU's global source tagging system\n# (see http://www.gnu.org/software/global/global.html). You will need version\n# 4.8.6 or higher.\n#\n# To use it do the following:\n# - Install the latest version of global\n# - Enable SOURCE_BROWSER and USE_HTAGS in the config file\n# - Make sure the INPUT points to the root of the source tree\n# - Run doxygen as normal\n#\n# Doxygen will invoke htags (and that will in turn invoke gtags), so these\n# tools must be available from the command line (i.e. in the search path).\n#\n# The result: instead of the source browser generated by doxygen, the links to\n# source code will now point to the output of htags.\n# The default value is: NO.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nUSE_HTAGS              = NO\n\n# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a\n# verbatim copy of the header file for each class for which an include is\n# specified. Set to NO to disable this.\n# See also: Section \\class.\n# The default value is: YES.\n\nVERBATIM_HEADERS       = YES\n\n# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the\n# clang parser (see: http://clang.llvm.org/) for more acurate parsing at the\n# cost of reduced performance. This can be particularly helpful with template\n# rich C++ code for which doxygen's built-in parser lacks the necessary type\n# information.\n# Note: The availability of this option depends on whether or not doxygen was\n# compiled with the --with-libclang option.\n# The default value is: NO.\n\nCLANG_ASSISTED_PARSING = NO\n\n# If clang assisted parsing is enabled you can provide the compiler with command\n# line options that you would normally use when invoking the compiler. Note that\n# the include paths will already be set by doxygen for the files and directories\n# specified with INPUT and INCLUDE_PATH.\n# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.\n\nCLANG_OPTIONS          = \n\n#---------------------------------------------------------------------------\n# Configuration options related to the alphabetical class index\n#---------------------------------------------------------------------------\n\n# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all\n# compounds will be generated. Enable this if the project contains a lot of\n# classes, structs, unions or interfaces.\n# The default value is: YES.\n\nALPHABETICAL_INDEX     = YES\n\n# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in\n# which the alphabetical index list will be split.\n# Minimum value: 1, maximum value: 20, default value: 5.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nCOLS_IN_ALPHA_INDEX    = 5\n\n# In case all classes in a project start with a common prefix, all classes will\n# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag\n# can be used to specify a prefix (or a list of prefixes) that should be ignored\n# while generating the index headers.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nIGNORE_PREFIX          = \n\n#---------------------------------------------------------------------------\n# Configuration options related to the HTML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output\n# The default value is: YES.\n\nGENERATE_HTML          = YES\n\n# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_OUTPUT            = html\n\n# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each\n# generated HTML page (for example: .htm, .php, .asp).\n# The default value is: .html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FILE_EXTENSION    = .html\n\n# The HTML_HEADER tag can be used to specify a user-defined HTML header file for\n# each generated HTML page. If the tag is left blank doxygen will generate a\n# standard header.\n#\n# To get valid HTML the header file that includes any scripts and style sheets\n# that doxygen needs, which is dependent on the configuration options used (e.g.\n# the setting GENERATE_TREEVIEW). It is highly recommended to start with a\n# default header using\n# doxygen -w html new_header.html new_footer.html new_stylesheet.css\n# YourConfigFile\n# and then modify the file new_header.html. See also section \"Doxygen usage\"\n# for information on how to generate the default header that doxygen normally\n# uses.\n# Note: The header is subject to change so you typically have to regenerate the\n# default header when upgrading to a newer version of doxygen. For a description\n# of the possible markers and block names see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_HEADER            = \n\n# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each\n# generated HTML page. If the tag is left blank doxygen will generate a standard\n# footer. See HTML_HEADER for more information on how to generate a default\n# footer and what special commands can be used inside the footer. See also\n# section \"Doxygen usage\" for information on how to generate the default footer\n# that doxygen normally uses.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FOOTER            = \n\n# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style\n# sheet that is used by each HTML page. It can be used to fine-tune the look of\n# the HTML output. If left blank doxygen will generate a default style sheet.\n# See also section \"Doxygen usage\" for information on how to generate the style\n# sheet that doxygen normally uses.\n# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as\n# it is more robust and this tag (HTML_STYLESHEET) will in the future become\n# obsolete.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_STYLESHEET        = \n\n# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user-\n# defined cascading style sheet that is included after the standard style sheets\n# created by doxygen. Using this option one can overrule certain style aspects.\n# This is preferred over using HTML_STYLESHEET since it does not replace the\n# standard style sheet and is therefor more robust against future updates.\n# Doxygen will copy the style sheet file to the output directory. For an example\n# see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_STYLESHEET  = \n\n# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the HTML output directory. Note\n# that these files will be copied to the base HTML output directory. Use the\n# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these\n# files. In the HTML_STYLESHEET file, use the file name only. Also note that the\n# files will be copied as-is; there are no commands or markers available.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_FILES       = \n\n# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen\n# will adjust the colors in the stylesheet and background images according to\n# this color. Hue is specified as an angle on a colorwheel, see\n# http://en.wikipedia.org/wiki/Hue for more information. For instance the value\n# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300\n# purple, and 360 is red again.\n# Minimum value: 0, maximum value: 359, default value: 220.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_HUE    = 220\n\n# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors\n# in the HTML output. For a value of 0 the output will use grayscales only. A\n# value of 255 will produce the most vivid colors.\n# Minimum value: 0, maximum value: 255, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_SAT    = 100\n\n# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the\n# luminance component of the colors in the HTML output. Values below 100\n# gradually make the output lighter, whereas values above 100 make the output\n# darker. The value divided by 100 is the actual gamma applied, so 80 represents\n# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not\n# change the gamma.\n# Minimum value: 40, maximum value: 240, default value: 80.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_GAMMA  = 80\n\n# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML\n# page will contain the date and time when the page was generated. Setting this\n# to NO can help when comparing the output of multiple runs.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_TIMESTAMP         = YES\n\n# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML\n# documentation will contain sections that can be hidden and shown after the\n# page has loaded.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_DYNAMIC_SECTIONS  = NO\n\n# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries\n# shown in the various tree structured indices initially; the user can expand\n# and collapse entries dynamically later on. Doxygen will expand the tree to\n# such a level that at most the specified number of entries are visible (unless\n# a fully collapsed tree already exceeds this amount). So setting the number of\n# entries 1 will produce a full collapsed tree by default. 0 is a special value\n# representing an infinite number of entries and will result in a full expanded\n# tree by default.\n# Minimum value: 0, maximum value: 9999, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_INDEX_NUM_ENTRIES = 100\n\n# If the GENERATE_DOCSET tag is set to YES, additional index files will be\n# generated that can be used as input for Apple's Xcode 3 integrated development\n# environment (see: http://developer.apple.com/tools/xcode/), introduced with\n# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a\n# Makefile in the HTML output directory. Running make will produce the docset in\n# that directory and running make install will install the docset in\n# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at\n# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html\n# for more information.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_DOCSET        = NO\n\n# This tag determines the name of the docset feed. A documentation feed provides\n# an umbrella under which multiple documentation sets from a single provider\n# (such as a company or product suite) can be grouped.\n# The default value is: Doxygen generated docs.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_FEEDNAME        = \"Doxygen generated docs\"\n\n# This tag specifies a string that should uniquely identify the documentation\n# set bundle. This should be a reverse domain-name style string, e.g.\n# com.mycompany.MyDocSet. Doxygen will append .docset to the name.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_BUNDLE_ID       = org.doxygen.Project\n\n# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify\n# the documentation publisher. This should be a reverse domain-name style\n# string, e.g. com.mycompany.MyDocSet.documentation.\n# The default value is: org.doxygen.Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_ID    = org.doxygen.Publisher\n\n# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.\n# The default value is: Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_NAME  = Publisher\n\n# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three\n# additional HTML index files: index.hhp, index.hhc, and index.hhk. The\n# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop\n# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on\n# Windows.\n#\n# The HTML Help Workshop contains a compiler that can convert all HTML output\n# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML\n# files are now used as the Windows 98 help format, and will replace the old\n# Windows help format (.hlp) on all Windows platforms in the future. Compressed\n# HTML files also contain an index, a table of contents, and you can search for\n# words in the documentation. The HTML workshop also contains a viewer for\n# compressed HTML files.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_HTMLHELP      = NO\n\n# The CHM_FILE tag can be used to specify the file name of the resulting .chm\n# file. You can add a path in front of the file if the result should not be\n# written to the html output directory.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_FILE               = \n\n# The HHC_LOCATION tag can be used to specify the location (absolute path\n# including file name) of the HTML help compiler ( hhc.exe). If non-empty\n# doxygen will try to run the HTML help compiler on the generated index.hhp.\n# The file has to be specified with full path.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nHHC_LOCATION           = \n\n# The GENERATE_CHI flag controls if a separate .chi index file is generated (\n# YES) or that it should be included in the master .chm file ( NO).\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nGENERATE_CHI           = NO\n\n# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc)\n# and project file content.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_INDEX_ENCODING     = \n\n# The BINARY_TOC flag controls whether a binary table of contents is generated (\n# YES) or a normal table of contents ( NO) in the .chm file.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nBINARY_TOC             = NO\n\n# The TOC_EXPAND flag can be set to YES to add extra items for group members to\n# the table of contents of the HTML help documentation and to the tree view.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nTOC_EXPAND             = NO\n\n# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and\n# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that\n# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help\n# (.qch) of the generated HTML documentation.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_QHP           = NO\n\n# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify\n# the file name of the resulting .qch file. The path specified is relative to\n# the HTML output folder.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQCH_FILE               = \n\n# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help\n# Project output. For more information please see Qt Help Project / Namespace\n# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_NAMESPACE          = org.doxygen.Project\n\n# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt\n# Help Project output. For more information please see Qt Help Project / Virtual\n# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-\n# folders).\n# The default value is: doc.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_VIRTUAL_FOLDER     = doc\n\n# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom\n# filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_NAME   = \n\n# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the\n# custom filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_ATTRS  = \n\n# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this\n# project's filter section matches. Qt Help Project / Filter Attributes (see:\n# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_SECT_FILTER_ATTRS  = \n\n# The QHG_LOCATION tag can be used to specify the location of Qt's\n# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the\n# generated .qhp file.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHG_LOCATION           = \n\n# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be\n# generated, together with the HTML files, they form an Eclipse help plugin. To\n# install this plugin and make it available under the help contents menu in\n# Eclipse, the contents of the directory containing the HTML and XML files needs\n# to be copied into the plugins directory of eclipse. The name of the directory\n# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.\n# After copying Eclipse needs to be restarted before the help appears.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_ECLIPSEHELP   = NO\n\n# A unique identifier for the Eclipse help plugin. When installing the plugin\n# the directory name containing the HTML and XML files should also have this\n# name. Each documentation set should have its own identifier.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.\n\nECLIPSE_DOC_ID         = org.doxygen.Project\n\n# If you want full control over the layout of the generated HTML pages it might\n# be necessary to disable the index and replace it with your own. The\n# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top\n# of each HTML page. A value of NO enables the index and the value YES disables\n# it. Since the tabs in the index contain the same information as the navigation\n# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nDISABLE_INDEX          = NO\n\n# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index\n# structure should be generated to display hierarchical information. If the tag\n# value is set to YES, a side panel will be generated containing a tree-like\n# index structure (just like the one that is generated for HTML Help). For this\n# to work a browser that supports JavaScript, DHTML, CSS and frames is required\n# (i.e. any modern browser). Windows users are probably better off using the\n# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can\n# further fine-tune the look of the index. As an example, the default style\n# sheet generated by doxygen has an example that shows how to put an image at\n# the root of the tree instead of the PROJECT_NAME. Since the tree basically has\n# the same information as the tab index, you could consider setting\n# DISABLE_INDEX to YES when enabling this option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_TREEVIEW      = NO\n\n# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that\n# doxygen will group on one line in the generated HTML documentation.\n#\n# Note that a value of 0 will completely suppress the enum values from appearing\n# in the overview section.\n# Minimum value: 0, maximum value: 20, default value: 4.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nENUM_VALUES_PER_LINE   = 4\n\n# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used\n# to set the initial width (in pixels) of the frame in which the tree is shown.\n# Minimum value: 0, maximum value: 1500, default value: 250.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nTREEVIEW_WIDTH         = 250\n\n# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to\n# external symbols imported via tag files in a separate window.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nEXT_LINKS_IN_WINDOW    = NO\n\n# Use this tag to change the font size of LaTeX formulas included as images in\n# the HTML documentation. When you change the font size after a successful\n# doxygen run you need to manually remove any form_*.png images from the HTML\n# output directory to force them to be regenerated.\n# Minimum value: 8, maximum value: 50, default value: 10.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_FONTSIZE       = 10\n\n# Use the FORMULA_TRANPARENT tag to determine whether or not the images\n# generated for formulas are transparent PNGs. Transparent PNGs are not\n# supported properly for IE 6.0, but are supported on all modern browsers.\n#\n# Note that when changing this option you need to delete any form_*.png files in\n# the HTML output directory before the changes have effect.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_TRANSPARENT    = YES\n\n# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see\n# http://www.mathjax.org) which uses client side Javascript for the rendering\n# instead of using prerendered bitmaps. Use this if you do not have LaTeX\n# installed or if you want to formulas look prettier in the HTML output. When\n# enabled you may also need to install MathJax separately and configure the path\n# to it using the MATHJAX_RELPATH option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nUSE_MATHJAX            = NO\n\n# When MathJax is enabled you can set the default output format to be used for\n# the MathJax output. See the MathJax site (see:\n# http://docs.mathjax.org/en/latest/output.html) for more details.\n# Possible values are: HTML-CSS (which is slower, but has the best\n# compatibility), NativeMML (i.e. MathML) and SVG.\n# The default value is: HTML-CSS.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_FORMAT         = HTML-CSS\n\n# When MathJax is enabled you need to specify the location relative to the HTML\n# output directory using the MATHJAX_RELPATH option. The destination directory\n# should contain the MathJax.js script. For instance, if the mathjax directory\n# is located at the same level as the HTML output directory, then\n# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax\n# Content Delivery Network so you can quickly see the result without installing\n# MathJax. However, it is strongly recommended to install a local copy of\n# MathJax from http://www.mathjax.org before deployment.\n# The default value is: http://cdn.mathjax.org/mathjax/latest.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest\n\n# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax\n# extension names that should be enabled during MathJax rendering. For example\n# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_EXTENSIONS     = \n\n# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces\n# of code that will be used on startup of the MathJax code. See the MathJax site\n# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an\n# example see the documentation.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_CODEFILE       = \n\n# When the SEARCHENGINE tag is enabled doxygen will generate a search box for\n# the HTML output. The underlying search engine uses javascript and DHTML and\n# should work on any modern browser. Note that when using HTML help\n# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)\n# there is already a search function so this one should typically be disabled.\n# For large projects the javascript based search engine can be slow, then\n# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to\n# search using the keyboard; to jump to the search box use <access key> + S\n# (what the <access key> is depends on the OS and browser, but it is typically\n# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down\n# key> to jump into the search results window, the results can be navigated\n# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel\n# the search. The filter options can be selected when the cursor is inside the\n# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>\n# to select a filter and <Enter> or <escape> to activate or cancel the filter\n# option.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nSEARCHENGINE           = YES\n\n# When the SERVER_BASED_SEARCH tag is enabled the search engine will be\n# implemented using a web server instead of a web client using Javascript. There\n# are two flavours of web server based searching depending on the\n# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for\n# searching and an index file used by the script. When EXTERNAL_SEARCH is\n# enabled the indexing and searching needs to be provided by external tools. See\n# the section \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSERVER_BASED_SEARCH    = NO\n\n# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP\n# script for searching. Instead the search results are written to an XML file\n# which needs to be processed by an external indexer. Doxygen will invoke an\n# external search engine pointed to by the SEARCHENGINE_URL option to obtain the\n# search results.\n#\n# Doxygen ships with an example indexer ( doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/).\n#\n# See the section \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH        = NO\n\n# The SEARCHENGINE_URL should point to a search engine hosted by a web server\n# which will return the search results when EXTERNAL_SEARCH is enabled.\n#\n# Doxygen ships with an example indexer ( doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/). See the section \"External Indexing and\n# Searching\" for details.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHENGINE_URL       = \n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed\n# search data is written to a file for indexing by an external tool. With the\n# SEARCHDATA_FILE tag the name of this file can be specified.\n# The default file is: searchdata.xml.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHDATA_FILE        = searchdata.xml\n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the\n# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is\n# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple\n# projects and redirect the results back to the right project.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH_ID     = \n\n# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen\n# projects other than the one defined by this configuration file, but that are\n# all added to the same external search index. Each project needs to have a\n# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of\n# to a relative location where the documentation can be found. The format is:\n# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTRA_SEARCH_MAPPINGS  = \n\n#---------------------------------------------------------------------------\n# Configuration options related to the LaTeX output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output.\n# The default value is: YES.\n\nGENERATE_LATEX         = NO\n\n# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_OUTPUT           = latex\n\n# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be\n# invoked.\n#\n# Note that when enabling USE_PDFLATEX this option is only used for generating\n# bitmaps for formulas in the HTML output, but not in the Makefile that is\n# written to the output directory.\n# The default file is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_CMD_NAME         = latex\n\n# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate\n# index for LaTeX.\n# The default file is: makeindex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nMAKEINDEX_CMD_NAME     = makeindex\n\n# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nCOMPACT_LATEX          = NO\n\n# The PAPER_TYPE tag can be used to set the paper type that is used by the\n# printer.\n# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x\n# 14 inches) and executive (7.25 x 10.5 inches).\n# The default value is: a4.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPAPER_TYPE             = a4\n\n# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names\n# that should be included in the LaTeX output. To get the times font for\n# instance you can specify\n# EXTRA_PACKAGES=times\n# If left blank no extra packages will be included.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nEXTRA_PACKAGES         = \n\n# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the\n# generated LaTeX document. The header should contain everything until the first\n# chapter. If it is left blank doxygen will generate a standard header. See\n# section \"Doxygen usage\" for information on how to let doxygen write the\n# default header to a separate file.\n#\n# Note: Only use a user-defined header if you know what you are doing! The\n# following commands have a special meaning inside the header: $title,\n# $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will\n# replace them by respectively the title of the page, the current date and time,\n# only the current date, the version number of doxygen, the project name (see\n# PROJECT_NAME), or the project number (see PROJECT_NUMBER).\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HEADER           = \n\n# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the\n# generated LaTeX document. The footer should contain everything after the last\n# chapter. If it is left blank doxygen will generate a standard footer.\n#\n# Note: Only use a user-defined footer if you know what you are doing!\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_FOOTER           = \n\n# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the LATEX_OUTPUT output\n# directory. Note that the files will be copied as-is; there are no commands or\n# markers available.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_EXTRA_FILES      = \n\n# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is\n# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will\n# contain links (just like the HTML output) instead of page references. This\n# makes the output suitable for online browsing using a PDF viewer.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPDF_HYPERLINKS         = YES\n\n# If the LATEX_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate\n# the PDF file directly from the LaTeX files. Set this option to YES to get a\n# higher quality PDF documentation.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nUSE_PDFLATEX           = YES\n\n# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode\n# command to the generated LaTeX files. This will instruct LaTeX to keep running\n# if errors occur, instead of asking the user for help. This option is also used\n# when generating formulas in HTML.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BATCHMODE        = NO\n\n# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the\n# index chapters (such as File Index, Compound Index, etc.) in the output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HIDE_INDICES     = NO\n\n# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source\n# code with syntax highlighting in the LaTeX output.\n#\n# Note that which sources are shown also depends on other settings such as\n# SOURCE_BROWSER.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_SOURCE_CODE      = NO\n\n# The LATEX_BIB_STYLE tag can be used to specify the style to use for the\n# bibliography, e.g. plainnat, or ieeetr. See\n# http://en.wikipedia.org/wiki/BibTeX and \\cite for more info.\n# The default value is: plain.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BIB_STYLE        = plain\n\n#---------------------------------------------------------------------------\n# Configuration options related to the RTF output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The\n# RTF output is optimized for Word 97 and may not look too pretty with other RTF\n# readers/editors.\n# The default value is: NO.\n\nGENERATE_RTF           = NO\n\n# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: rtf.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_OUTPUT             = rtf\n\n# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nCOMPACT_RTF            = NO\n\n# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will\n# contain hyperlink fields. The RTF file will contain links (just like the HTML\n# output) instead of page references. This makes the output suitable for online\n# browsing using Word or some other Word compatible readers that support those\n# fields.\n#\n# Note: WordPad (write) and others do not support links.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_HYPERLINKS         = NO\n\n# Load stylesheet definitions from file. Syntax is similar to doxygen's config\n# file, i.e. a series of assignments. You only have to provide replacements,\n# missing definitions are set to their default value.\n#\n# See also section \"Doxygen usage\" for information on how to generate the\n# default style sheet that doxygen normally uses.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_STYLESHEET_FILE    = \n\n# Set optional variables used in the generation of an RTF document. Syntax is\n# similar to doxygen's config file. A template extensions file can be generated\n# using doxygen -e rtf extensionFile.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_EXTENSIONS_FILE    = \n\n#---------------------------------------------------------------------------\n# Configuration options related to the man page output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for\n# classes and files.\n# The default value is: NO.\n\nGENERATE_MAN           = NO\n\n# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it. A directory man3 will be created inside the directory specified by\n# MAN_OUTPUT.\n# The default directory is: man.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_OUTPUT             = man\n\n# The MAN_EXTENSION tag determines the extension that is added to the generated\n# man pages. In case the manual section does not start with a number, the number\n# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is\n# optional.\n# The default value is: .3.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_EXTENSION          = .3\n\n# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it\n# will generate one additional man file for each entity documented in the real\n# man page(s). These additional files only source the real man page, but without\n# them the man command would be unable to find the correct page.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_LINKS              = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the XML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that\n# captures the structure of the code including all documentation.\n# The default value is: NO.\n\nGENERATE_XML           = NO\n\n# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: xml.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_OUTPUT             = xml\n\n# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a\n# validating XML parser to check the syntax of the XML files.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_SCHEMA             = \n\n# The XML_DTD tag can be used to specify a XML DTD, which can be used by a\n# validating XML parser to check the syntax of the XML files.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_DTD                = \n\n# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program\n# listings (including syntax highlighting and cross-referencing information) to\n# the XML output. Note that enabling this will significantly increase the size\n# of the XML output.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_PROGRAMLISTING     = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to the DOCBOOK output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files\n# that can be used to generate PDF.\n# The default value is: NO.\n\nGENERATE_DOCBOOK       = NO\n\n# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.\n# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in\n# front of it.\n# The default directory is: docbook.\n# This tag requires that the tag GENERATE_DOCBOOK is set to YES.\n\nDOCBOOK_OUTPUT         = docbook\n\n#---------------------------------------------------------------------------\n# Configuration options for the AutoGen Definitions output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen\n# Definitions (see http://autogen.sf.net) file that captures the structure of\n# the code including all documentation. Note that this feature is still\n# experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_AUTOGEN_DEF   = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the Perl module output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module\n# file that captures the structure of the code including all documentation.\n#\n# Note that this feature is still experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_PERLMOD       = NO\n\n# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary\n# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI\n# output from the Perl module output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_LATEX          = NO\n\n# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely\n# formatted so it can be parsed by a human reader. This is useful if you want to\n# understand what is going on. On the other hand, if this tag is set to NO the\n# size of the Perl module output will be much smaller and Perl will parse it\n# just the same.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_PRETTY         = YES\n\n# The names of the make variables in the generated doxyrules.make file are\n# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful\n# so different doxyrules.make files included by the same Makefile don't\n# overwrite each other's variables.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_MAKEVAR_PREFIX = \n\n#---------------------------------------------------------------------------\n# Configuration options related to the preprocessor\n#---------------------------------------------------------------------------\n\n# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all\n# C-preprocessor directives found in the sources and include files.\n# The default value is: YES.\n\nENABLE_PREPROCESSING   = YES\n\n# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names\n# in the source code. If set to NO only conditional compilation will be\n# performed. Macro expansion can be done in a controlled way by setting\n# EXPAND_ONLY_PREDEF to YES.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nMACRO_EXPANSION        = NO\n\n# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then\n# the macro expansion is limited to the macros specified with the PREDEFINED and\n# EXPAND_AS_DEFINED tags.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_ONLY_PREDEF     = NO\n\n# If the SEARCH_INCLUDES tag is set to YES the includes files in the\n# INCLUDE_PATH will be searched if a #include is found.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSEARCH_INCLUDES        = YES\n\n# The INCLUDE_PATH tag can be used to specify one or more directories that\n# contain include files that are not input files but should be processed by the\n# preprocessor.\n# This tag requires that the tag SEARCH_INCLUDES is set to YES.\n\nINCLUDE_PATH           = ../include \\\n                         /usr/local/Qt4.8/mkspecs/macx-g++ \\\n                         /usr/include \\\n                         /Library/Frameworks/QtCore.framework/Versions/4/Headers \\\n                         /Library/Frameworks/QtGui.framework/Versions/4/Headers \\\n                         /Library/Frameworks/QtOpenGL.framework/Versions/4/Headers \\\n                         ../../../../vcglib/eigenlib \\\n                         /Users/lugh/QtSDK/Madde/toolchains/arm-2009q3-67-arm-none-linux-gnueabi-i686-apple-darwin10/arm-2009q3-67/arm-none-linux-gnueabi/include/c++/4.4.1/tr1/\n\n# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard\n# patterns (like *.h and *.hpp) to filter out the header-files in the\n# directories. If left blank, the patterns specified with FILE_PATTERNS will be\n# used.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nINCLUDE_FILE_PATTERNS  = \n\n# The PREDEFINED tag can be used to specify one or more macro names that are\n# defined before the preprocessor is started (similar to the -D option of e.g.\n# gcc). The argument of the tag is a list of macros of the form: name or\n# name=definition (no spaces). If the definition and the \"=\" are omitted, \"=1\"\n# is assumed. To prevent a macro definition from being undefined via #undef or\n# recursively expanded use the := operator instead of the = operator.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nPREDEFINED             = \n\n# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this\n# tag can be used to specify a list of macro names that should be expanded. The\n# macro definition that is found in the sources will be used. Use the PREDEFINED\n# tag if you want to use a different macro definition that overrules the\n# definition found in the source code.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_AS_DEFINED      = \n\n# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will\n# remove all refrences to function-like macros that are alone on a line, have an\n# all uppercase name, and do not end with a semicolon. Such function macros are\n# typically used for boiler-plate code, and will confuse the parser if not\n# removed.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSKIP_FUNCTION_MACROS   = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to external references\n#---------------------------------------------------------------------------\n\n# The TAGFILES tag can be used to specify one or more tag files. For each tag\n# file the location of the external documentation should be added. The format of\n# a tag file without this location is as follows:\n# TAGFILES = file1 file2 ...\n# Adding location for the tag files is done as follows:\n# TAGFILES = file1=loc1 \"file2 = loc2\" ...\n# where loc1 and loc2 can be relative or absolute paths or URLs. See the\n# section \"Linking to external documentation\" for more information about the use\n# of tag files.\n# Note: Each tag file must have an unique name (where the name does NOT include\n# the path). If a tag file is not located in the directory in which doxygen is\n# run, you must also specify the path to the tagfile here.\n\nTAGFILES               = \n\n# When a file name is specified after GENERATE_TAGFILE, doxygen will create a\n# tag file that is based on the input files it reads. See section \"Linking to\n# external documentation\" for more information about the usage of tag files.\n\nGENERATE_TAGFILE       = \n\n# If the ALLEXTERNALS tag is set to YES all external class will be listed in the\n# class index. If set to NO only the inherited external classes will be listed.\n# The default value is: NO.\n\nALLEXTERNALS           = NO\n\n# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in\n# the modules index. If set to NO, only the current project's groups will be\n# listed.\n# The default value is: YES.\n\nEXTERNAL_GROUPS        = YES\n\n# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in\n# the related pages index. If set to NO, only the current project's pages will\n# be listed.\n# The default value is: YES.\n\nEXTERNAL_PAGES         = YES\n\n# The PERL_PATH should be the absolute path and name of the perl script\n# interpreter (i.e. the result of 'which perl').\n# The default file (with absolute path) is: /usr/bin/perl.\n\nPERL_PATH              = /usr/bin/perl\n\n#---------------------------------------------------------------------------\n# Configuration options related to the dot tool\n#---------------------------------------------------------------------------\n\n# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram\n# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to\n# NO turns the diagrams off. Note that this option also works with HAVE_DOT\n# disabled, but it is recommended to install and use dot, since it yields more\n# powerful graphs.\n# The default value is: YES.\n\nCLASS_DIAGRAMS         = YES\n\n# You can define message sequence charts within doxygen comments using the \\msc\n# command. Doxygen will then run the mscgen tool (see:\n# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the\n# documentation. The MSCGEN_PATH tag allows you to specify the directory where\n# the mscgen tool resides. If left empty the tool is assumed to be found in the\n# default search path.\n\nMSCGEN_PATH            = \n\n# You can include diagrams made with dia in doxygen documentation. Doxygen will\n# then run dia to produce the diagram and insert it in the documentation. The\n# DIA_PATH tag allows you to specify the directory where the dia binary resides.\n# If left empty dia is assumed to be found in the default search path.\n\nDIA_PATH               = \n\n# If set to YES, the inheritance and collaboration graphs will hide inheritance\n# and usage relations if the target is undocumented or is not a class.\n# The default value is: YES.\n\nHIDE_UNDOC_RELATIONS   = YES\n\n# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is\n# available from the path. This tool is part of Graphviz (see:\n# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent\n# Bell Labs. The other options in this section have no effect if this option is\n# set to NO\n# The default value is: NO.\n\nHAVE_DOT               = NO\n\n# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed\n# to run in parallel. When set to 0 doxygen will base this on the number of\n# processors available in the system. You can set it explicitly to a value\n# larger than 0 to get control over the balance between CPU load and processing\n# speed.\n# Minimum value: 0, maximum value: 32, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_NUM_THREADS        = 0\n\n# When you want a differently looking font n the dot files that doxygen\n# generates you can specify the font name using DOT_FONTNAME. You need to make\n# sure dot is able to find the font, which can be done by putting it in a\n# standard location or by setting the DOTFONTPATH environment variable or by\n# setting DOT_FONTPATH to the directory containing the font.\n# The default value is: Helvetica.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTNAME           = Helvetica\n\n# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of\n# dot graphs.\n# Minimum value: 4, maximum value: 24, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTSIZE           = 10\n\n# By default doxygen will tell dot to use the default font as specified with\n# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set\n# the path where dot can find it using this tag.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTPATH           = \n\n# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for\n# each documented class showing the direct and indirect inheritance relations.\n# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCLASS_GRAPH            = YES\n\n# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a\n# graph for each documented class showing the direct and indirect implementation\n# dependencies (inheritance, containment, and class references variables) of the\n# class with other documented classes.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCOLLABORATION_GRAPH    = YES\n\n# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for\n# groups, showing the direct groups dependencies.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGROUP_GRAPHS           = YES\n\n# If the UML_LOOK tag is set to YES doxygen will generate inheritance and\n# collaboration diagrams in a style similar to the OMG's Unified Modeling\n# Language.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LOOK               = NO\n\n# If the UML_LOOK tag is enabled, the fields and methods are shown inside the\n# class node. If there are many fields or methods and many nodes the graph may\n# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the\n# number of items for each type to make the size more manageable. Set this to 0\n# for no limit. Note that the threshold may be exceeded by 50% before the limit\n# is enforced. So when you set the threshold to 10, up to 15 fields may appear,\n# but if the number exceeds 15, the total amount of fields shown is limited to\n# 10.\n# Minimum value: 0, maximum value: 100, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LIMIT_NUM_FIELDS   = 10\n\n# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and\n# collaboration graphs will show the relations between templates and their\n# instances.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nTEMPLATE_RELATIONS     = NO\n\n# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to\n# YES then doxygen will generate a graph for each documented file showing the\n# direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDE_GRAPH          = YES\n\n# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are\n# set to YES then doxygen will generate a graph for each documented file showing\n# the direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDED_BY_GRAPH      = YES\n\n# If the CALL_GRAPH tag is set to YES then doxygen will generate a call\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable call graphs for selected\n# functions only using the \\callgraph command.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALL_GRAPH             = NO\n\n# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable caller graphs for selected\n# functions only using the \\callergraph command.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALLER_GRAPH           = NO\n\n# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical\n# hierarchy of all classes instead of a textual one.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGRAPHICAL_HIERARCHY    = YES\n\n# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the\n# dependencies a directory has on other directories in a graphical way. The\n# dependency relations are determined by the #include relations between the\n# files in the directories.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDIRECTORY_GRAPH        = YES\n\n# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images\n# generated by dot.\n# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order\n# to make the SVG files visible in IE 9+ (other browsers do not have this\n# requirement).\n# Possible values are: png, jpg, gif and svg.\n# The default value is: png.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_IMAGE_FORMAT       = png\n\n# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to\n# enable generation of interactive SVG images that allow zooming and panning.\n#\n# Note that this requires a modern browser other than Internet Explorer. Tested\n# and working are Firefox, Chrome, Safari, and Opera.\n# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make\n# the SVG files visible. Older versions of IE do not have SVG support.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINTERACTIVE_SVG        = NO\n\n# The DOT_PATH tag can be used to specify the path where the dot tool can be\n# found. If left blank, it is assumed the dot tool can be found in the path.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_PATH               = \n\n# The DOTFILE_DIRS tag can be used to specify one or more directories that\n# contain dot files that are included in the documentation (see the \\dotfile\n# command).\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOTFILE_DIRS           = \n\n# The MSCFILE_DIRS tag can be used to specify one or more directories that\n# contain msc files that are included in the documentation (see the \\mscfile\n# command).\n\nMSCFILE_DIRS           = \n\n# The DIAFILE_DIRS tag can be used to specify one or more directories that\n# contain dia files that are included in the documentation (see the \\diafile\n# command).\n\nDIAFILE_DIRS           = \n\n# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes\n# that will be shown in the graph. If the number of nodes in a graph becomes\n# larger than this value, doxygen will truncate the graph, which is visualized\n# by representing a node as a red box. Note that doxygen if the number of direct\n# children of the root node in a graph is already larger than\n# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that\n# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.\n# Minimum value: 0, maximum value: 10000, default value: 50.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_GRAPH_MAX_NODES    = 50\n\n# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs\n# generated by dot. A depth value of 3 means that only nodes reachable from the\n# root by following a path via at most 3 edges will be shown. Nodes that lay\n# further from the root node will be omitted. Note that setting this option to 1\n# or 2 may greatly reduce the computation time needed for large code bases. Also\n# note that the size of a graph can be further restricted by\n# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.\n# Minimum value: 0, maximum value: 1000, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nMAX_DOT_GRAPH_DEPTH    = 0\n\n# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent\n# background. This is disabled by default, because dot on Windows does not seem\n# to support this out of the box.\n#\n# Warning: Depending on the platform used, enabling this option may lead to\n# badly anti-aliased labels on the edges of a graph (i.e. they become hard to\n# read).\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_TRANSPARENT        = NO\n\n# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output\n# files in one run (i.e. multiple -o and -T options on the command line). This\n# makes dot run faster, but since only newer versions of dot (>1.8.10) support\n# this, this feature is disabled by default.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_MULTI_TARGETS      = NO\n\n# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page\n# explaining the meaning of the various boxes and arrows in the dot generated\n# graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGENERATE_LEGEND        = YES\n\n# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot\n# files that are used to generate the various graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_CLEANUP            = YES\n"
  },
  {
    "path": "examples/blending_laplacian/b_blending_laplacian.pro",
    "content": "# PICCANTE Examples\n# The hottest examples of Piccante:\n# http://vcg.isti.cnr.it/piccante\n#\n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n#\n# This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU General Public License as published by\n#    the Free Software Foundation, either version 3.0 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU General Public License for more details.\n#\n#    See the GNU Lesser General Public License\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n#\n\nTARGET = b_blending_laplacian\n\nQT       += core\n#TEMPLATE = app\n#CONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/blending_laplacian/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img0_str, img1_str, img2_str;\n\n    if(argc == 4) {\n        img0_str = argv[1];\n        img1_str = argv[2];\n        img2_str = argv[3];\n    } else {\n        img0_str = \"../data/input/laplacian/target.png\";\n        img1_str = \"../data/input/laplacian/source.png\";\n        img2_str = \"../data/input/laplacian/mask.png\";\n    }\n\n    printf(\"Reading images...\");\n\n    pic::Image img_source, img_target, mask_target;\n    img_target.Read(img0_str, pic::LT_NOR);\n    img_source.Read(img1_str, pic::LT_NOR);\n    mask_target.Read(img2_str,pic::LT_NOR);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Are images valid? \");\n    if( img_source.isValid() && img_target.isValid() && mask_target.isValid()) {\n        printf(\"OK\\n\");\n\n        pic::Image mask_source(mask_target.width, mask_target.height, mask_target.channels);\n        mask_source = 1.0f;\n        mask_source -= mask_target;\n\n        //Creating Laplacian pyramids\n        pic::Pyramid pyr_target(&img_target, true, 4);\n        pic::Pyramid pyr_source(&img_source, true, 4);\n\n        //Creating Gaussian pyramids\n        pic::Pyramid pyr_mask_target(&mask_target, false, 4);\n        pic::Pyramid pyr_mask_source(&mask_source, false, 4);\n\n        //Blending\n        pyr_target.mul(&pyr_mask_target);\n        pyr_source.mul(&pyr_mask_source);\n\n        pyr_target.add(&pyr_source);\n\n        pic::Image *imgOut = pyr_target.reconstruct();\n\n        imgOut->Write(\"../data/output/laplacian_blending_result.png\", pic::LT_NOR);\n\n    } else {\n        printf(\"All images are not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/blending_poisson/b_blending_poisson.pro",
    "content": "# PICCANTE Examples\n# The hottest examples of Piccante:\n# http://vcg.isti.cnr.it/piccante\n#\n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n#\n# This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU General Public License as published by\n#    the Free Software Foundation, either version 3.0 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU General Public License for more details.\n#\n#    See the GNU Lesser General Public License\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n#\n\nTARGET = b_blending_poisson\n\nQT       += core\n#TEMPLATE = app\n#CONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/blending_poisson/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img0_str, img1_str, img2_str;\n\n    if(argc == 4) {\n        img0_str = argv[1];\n        img1_str = argv[2];\n        img2_str = argv[3];\n    } else {\n        img0_str = \"../data/input/poisson/target.png\";\n        img1_str = \"../data/input/poisson/source.png\";\n        img2_str = \"../data/input/poisson/mask.png\";\n    }\n\n    printf(\"Reading images...\");\n\n    pic::Image img_target, img_source, mask_source;\n    img_target.Read(img0_str,pic::LT_NOR);\n    img_source.Read(img1_str, pic::LT_NOR);\n    mask_source.Read(img2_str, pic::LT_NOR);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Are images valid? \");\n    if( img_target.isValid() && img_source.isValid() && mask_source.isValid()) {\n        printf(\"OK\\n\");\n\n        float color[] = {1.0f, 1.0f, 1.0f};\n        bool *mask = mask_source.convertToMask(color, 0.1f, false, NULL);\n\n        pic::Image *imgOut = pic::computePoissonImageEditing(&img_source, &img_target, mask);\n\n        imgOut->Write(\"../data/output/poisson_blending_result.png\", pic::LT_NOR);\n    } else {\n        printf(\"Images are not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/blending_push_pull/b_push_pull.pro",
    "content": "# PICCANTE Examples\n# The hottest examples of Piccante:\n# http://vcg.isti.cnr.it/piccante\n#\n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n#\n# This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU General Public License as published by\n#    the Free Software Foundation, either version 3.0 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU General Public License for more details.\n#\n#    See the GNU Lesser General Public License\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n#\n\nTARGET = b_push_pull\n\nQT       += core\n#TEMPLATE = app\n#CONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/blending_push_pull/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    printf(\"Reading an HDR file...\");\n\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/bottles.hdr\";\n    }\n\n    pic::Image img;\n    img.Read(img_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        pic::Image img_black(1, 32, 32, 3);\n        img_black.setZero();\n\n        //add a hole in the image\n        srand (time(NULL));\n        img.copySubImage(&img_black, (rand() % img.width) - 32, (rand() % img.height) - 32);\n\n        auto name = pic::getFileNameOnly(img_str);\n        auto ext = pic::getExtension(img_str);\n\n        printf(\"%s %s\\n\", name.c_str(), ext.c_str());\n\n        img.Write(\"../data/output/\" + name + \"_pp_black_pixels.\" + ext);\n\n        //recover black pixels with push-pull\n        pic::PushPull pp;\n\n        pic::Image *imgOut = pp.execute(&img, NULL, 0.0f);\n\n        printf(\"Writing recovered result using Push-Pull... \");\n\n        bool bWritten = imgOut->Write(\"../data/output/\" + name + \"_pp_reconstruction.\" + ext);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/common_code/gl_core_4_0.c",
    "content": "#include <stdlib.h>\n#include <string.h>\n#include <stddef.h>\n#include \"gl_core_4_0.h\"\n\n#if defined(__APPLE__)\n#include <mach-o/dyld.h>\n\nstatic void* AppleGLGetProcAddress (const GLubyte *name)\n{\n  static const struct mach_header* image = NULL;\n  NSSymbol symbol;\n  char* symbolName;\n  if (NULL == image)\n  {\n    image = NSAddImage(\"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL\", NSADDIMAGE_OPTION_RETURN_ON_ERROR);\n  }\n  /* prepend a '_' for the Unix C symbol mangling convention */\n  symbolName = malloc(strlen((const char*)name) + 2);\n  strcpy(symbolName+1, (const char*)name);\n  symbolName[0] = '_';\n  symbol = NULL;\n  /* if (NSIsSymbolNameDefined(symbolName))\n\t symbol = NSLookupAndBindSymbol(symbolName); */\n  symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL;\n  free(symbolName);\n  return symbol ? NSAddressOfSymbol(symbol) : NULL;\n}\n#endif /* __APPLE__ */\n\n#if defined(__sgi) || defined (__sun)\n#include <dlfcn.h>\n#include <stdio.h>\n\nstatic void* SunGetProcAddress (const GLubyte* name)\n{\n  static void* h = NULL;\n  static void* gpa;\n\n  if (h == NULL)\n  {\n    if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL;\n    gpa = dlsym(h, \"glXGetProcAddress\");\n  }\n\n  if (gpa != NULL)\n    return ((void*(*)(const GLubyte*))gpa)(name);\n  else\n    return dlsym(h, (const char*)name);\n}\n#endif /* __sgi || __sun */\n\n#if defined(_WIN32)\n\n#ifdef _MSC_VER\n#pragma warning(disable: 4055)\n#pragma warning(disable: 4054)\n#endif\n\nstatic int TestPointer(const PROC pTest)\n{\n\tptrdiff_t iTest;\n\tif(!pTest) return 0;\n\tiTest = (ptrdiff_t)pTest;\n\t\n\tif(iTest == 1 || iTest == 2 || iTest == 3 || iTest == -1) return 0;\n\t\n\treturn 1;\n}\n\nstatic PROC WinGetProcAddress(const char *name)\n{\n\tHMODULE glMod = NULL;\n\tPROC pFunc = wglGetProcAddress((LPCSTR)name);\n\tif(TestPointer(pFunc))\n\t{\n\t\treturn pFunc;\n\t}\n\tglMod = GetModuleHandleA(\"OpenGL32.dll\");\n\treturn (PROC)GetProcAddress(glMod, (LPCSTR)name);\n}\n\t\n#define IntGetProcAddress(name) WinGetProcAddress(name)\n#else\n\t#if defined(__APPLE__)\n\t\t#define IntGetProcAddress(name) AppleGLGetProcAddress(name)\n\t#else\n\t\t#if defined(__sgi) || defined(__sun)\n\t\t\t#define IntGetProcAddress(name) SunGetProcAddress(name)\n\t\t#else /* GLX */\n\t\t    #include <GL/glx.h>\n\n\t\t\t#define IntGetProcAddress(name) (*glXGetProcAddressARB)((const GLubyte*)name)\n\t\t#endif\n\t#endif\n#endif\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFinish)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFlush)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *) = NULL;\nGLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *) = NULL;\nconst GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum, GLenum, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum, GLenum, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum, GLenum, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum, GLenum, GLvoid **) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum, GLintptr, GLsizeiptr, GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint, GLenum, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum, GLenum, GLint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint) = NULL;\nvoid * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum, GLenum) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint, GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint) = NULL;\nGLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)() = NULL;\nGLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei, const GLenum *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint, GLenum, GLint *) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint, GLint, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint, GLint, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint, GLenum, GLvoid **) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint, GLenum, GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint, GLenum, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint, GLenum, GLint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint, GLsizei, const GLchar *const*, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint, GLsizei, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint, GLsizei, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint, GLsizei, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint, GLsizei, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint, GLsizei, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint, GLint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint, GLsizei, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint, GLsizei, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint, GLint, GLint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint, GLsizei, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint, GLshort) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint, GLshort, GLshort) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint, GLdouble, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint, GLshort, GLshort, GLshort) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint, const GLbyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint, const GLubyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint, const GLushort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint, const GLbyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint, GLshort, GLshort, GLshort, GLshort) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint, const GLubyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint, const GLushort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint, GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum) = NULL;\nGLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum, GLint, GLfloat, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum, GLint, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum, GLint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum, GLint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum, GLenum, GLenum, GLuint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum, GLuint, GLboolean *) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum, GLuint, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *) = NULL;\nconst GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum, GLenum, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint, GLint, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum, GLuint) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint) = NULL;\nvoid * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum, GLenum, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum, GLenum, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar *const*, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint, GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint, GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint, GLuint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint, GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint, GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint, GLint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint, GLuint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint, const GLbyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint, const GLubyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint, const GLushort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *) = NULL;\nGLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint, GLsizei, const GLchar *const*, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum, GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint, GLuint, GLuint) = NULL;\n\nGLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync, GLbitfield, GLuint64) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint) = NULL;\nGLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum, GLbitfield) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum, GLenum, GLuint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum, GLuint, GLint64 *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum, GLint64 *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum, GLuint, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint, GLbitfield) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync, GLbitfield, GLuint64) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint, GLuint, GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei, GLuint *) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint, GLenum, GLint64 *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint, GLenum, GLuint64 *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint, GLenum, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint, GLenum, GLint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint, GLenum, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint, GLenum, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint, GLenum, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint, GLenum, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint, GLenum, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint, GLenum, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint, GLenum, GLboolean, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint, GLenum, GLboolean, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint, GLenum, GLboolean, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint, GLenum, GLboolean, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBeginQueryIndexed)(GLenum, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindTransformFeedback)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparatei)(GLuint, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendEquationi)(GLuint, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparatei)(GLuint, GLenum, GLenum, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendFunci)(GLuint, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteTransformFeedbacks)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawArraysIndirect)(GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElementsIndirect)(GLenum, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawTransformFeedback)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawTransformFeedbackStream)(GLenum, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEndQueryIndexed)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenTransformFeedbacks)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineName)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineUniformName)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineUniformiv)(GLuint, GLenum, GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetProgramStageiv)(GLuint, GLenum, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryIndexediv)(GLenum, GLuint, GLenum, GLint *) = NULL;\nGLuint (CODEGEN_FUNCPTR *_ptrc_glGetSubroutineIndex)(GLuint, GLenum, const GLchar *) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetSubroutineUniformLocation)(GLuint, GLenum, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformSubroutineuiv)(GLenum, GLint, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformdv)(GLuint, GLint, GLdouble *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTransformFeedback)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glMinSampleShading)(GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPatchParameterfv)(GLenum, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPatchParameteri)(GLenum, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPauseTransformFeedback)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glResumeTransformFeedback)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1d)(GLint, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1dv)(GLint, GLsizei, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2d)(GLint, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2dv)(GLint, GLsizei, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3d)(GLint, GLdouble, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3dv)(GLint, GLsizei, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4d)(GLint, GLdouble, GLdouble, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4dv)(GLint, GLsizei, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformSubroutinesuiv)(GLenum, GLsizei, const GLuint *) = NULL;\n\nstatic int Load_Version_4_0()\n{\n\tint numFailed = 0;\n\t_ptrc_glBlendFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glBlendFunc\");\n\tif(!_ptrc_glBlendFunc) numFailed++;\n\t_ptrc_glClear = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress(\"glClear\");\n\tif(!_ptrc_glClear) numFailed++;\n\t_ptrc_glClearColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glClearColor\");\n\tif(!_ptrc_glClearColor) numFailed++;\n\t_ptrc_glClearDepth = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress(\"glClearDepth\");\n\tif(!_ptrc_glClearDepth) numFailed++;\n\t_ptrc_glClearStencil = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress(\"glClearStencil\");\n\tif(!_ptrc_glClearStencil) numFailed++;\n\t_ptrc_glColorMask = (void (CODEGEN_FUNCPTR *)(GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress(\"glColorMask\");\n\tif(!_ptrc_glColorMask) numFailed++;\n\t_ptrc_glCullFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glCullFace\");\n\tif(!_ptrc_glCullFace) numFailed++;\n\t_ptrc_glDepthFunc = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glDepthFunc\");\n\tif(!_ptrc_glDepthFunc) numFailed++;\n\t_ptrc_glDepthMask = (void (CODEGEN_FUNCPTR *)(GLboolean))IntGetProcAddress(\"glDepthMask\");\n\tif(!_ptrc_glDepthMask) numFailed++;\n\t_ptrc_glDepthRange = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress(\"glDepthRange\");\n\tif(!_ptrc_glDepthRange) numFailed++;\n\t_ptrc_glDisable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glDisable\");\n\tif(!_ptrc_glDisable) numFailed++;\n\t_ptrc_glDrawBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glDrawBuffer\");\n\tif(!_ptrc_glDrawBuffer) numFailed++;\n\t_ptrc_glEnable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glEnable\");\n\tif(!_ptrc_glEnable) numFailed++;\n\t_ptrc_glFinish = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glFinish\");\n\tif(!_ptrc_glFinish) numFailed++;\n\t_ptrc_glFlush = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glFlush\");\n\tif(!_ptrc_glFlush) numFailed++;\n\t_ptrc_glFrontFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glFrontFace\");\n\tif(!_ptrc_glFrontFace) numFailed++;\n\t_ptrc_glGetBooleanv = (void (CODEGEN_FUNCPTR *)(GLenum, GLboolean *))IntGetProcAddress(\"glGetBooleanv\");\n\tif(!_ptrc_glGetBooleanv) numFailed++;\n\t_ptrc_glGetDoublev = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble *))IntGetProcAddress(\"glGetDoublev\");\n\tif(!_ptrc_glGetDoublev) numFailed++;\n\t_ptrc_glGetError = (GLenum (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glGetError\");\n\tif(!_ptrc_glGetError) numFailed++;\n\t_ptrc_glGetFloatv = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat *))IntGetProcAddress(\"glGetFloatv\");\n\tif(!_ptrc_glGetFloatv) numFailed++;\n\t_ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress(\"glGetIntegerv\");\n\tif(!_ptrc_glGetIntegerv) numFailed++;\n\t_ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glGetString\");\n\tif(!_ptrc_glGetString) numFailed++;\n\t_ptrc_glGetTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLenum, GLvoid *))IntGetProcAddress(\"glGetTexImage\");\n\tif(!_ptrc_glGetTexImage) numFailed++;\n\t_ptrc_glGetTexLevelParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLfloat *))IntGetProcAddress(\"glGetTexLevelParameterfv\");\n\tif(!_ptrc_glGetTexLevelParameterfv) numFailed++;\n\t_ptrc_glGetTexLevelParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint *))IntGetProcAddress(\"glGetTexLevelParameteriv\");\n\tif(!_ptrc_glGetTexLevelParameteriv) numFailed++;\n\t_ptrc_glGetTexParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress(\"glGetTexParameterfv\");\n\tif(!_ptrc_glGetTexParameterfv) numFailed++;\n\t_ptrc_glGetTexParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetTexParameteriv\");\n\tif(!_ptrc_glGetTexParameteriv) numFailed++;\n\t_ptrc_glHint = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glHint\");\n\tif(!_ptrc_glHint) numFailed++;\n\t_ptrc_glIsEnabled = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glIsEnabled\");\n\tif(!_ptrc_glIsEnabled) numFailed++;\n\t_ptrc_glLineWidth = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress(\"glLineWidth\");\n\tif(!_ptrc_glLineWidth) numFailed++;\n\t_ptrc_glLogicOp = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glLogicOp\");\n\tif(!_ptrc_glLogicOp) numFailed++;\n\t_ptrc_glPixelStoref = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress(\"glPixelStoref\");\n\tif(!_ptrc_glPixelStoref) numFailed++;\n\t_ptrc_glPixelStorei = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress(\"glPixelStorei\");\n\tif(!_ptrc_glPixelStorei) numFailed++;\n\t_ptrc_glPointSize = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress(\"glPointSize\");\n\tif(!_ptrc_glPointSize) numFailed++;\n\t_ptrc_glPolygonMode = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glPolygonMode\");\n\tif(!_ptrc_glPolygonMode) numFailed++;\n\t_ptrc_glReadBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glReadBuffer\");\n\tif(!_ptrc_glReadBuffer) numFailed++;\n\t_ptrc_glReadPixels = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *))IntGetProcAddress(\"glReadPixels\");\n\tif(!_ptrc_glReadPixels) numFailed++;\n\t_ptrc_glScissor = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glScissor\");\n\tif(!_ptrc_glScissor) numFailed++;\n\t_ptrc_glStencilFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLuint))IntGetProcAddress(\"glStencilFunc\");\n\tif(!_ptrc_glStencilFunc) numFailed++;\n\t_ptrc_glStencilMask = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glStencilMask\");\n\tif(!_ptrc_glStencilMask) numFailed++;\n\t_ptrc_glStencilOp = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum))IntGetProcAddress(\"glStencilOp\");\n\tif(!_ptrc_glStencilOp) numFailed++;\n\t_ptrc_glTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexImage1D\");\n\tif(!_ptrc_glTexImage1D) numFailed++;\n\t_ptrc_glTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexImage2D\");\n\tif(!_ptrc_glTexImage2D) numFailed++;\n\t_ptrc_glTexParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress(\"glTexParameterf\");\n\tif(!_ptrc_glTexParameterf) numFailed++;\n\t_ptrc_glTexParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress(\"glTexParameterfv\");\n\tif(!_ptrc_glTexParameterfv) numFailed++;\n\t_ptrc_glTexParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress(\"glTexParameteri\");\n\tif(!_ptrc_glTexParameteri) numFailed++;\n\t_ptrc_glTexParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress(\"glTexParameteriv\");\n\tif(!_ptrc_glTexParameteriv) numFailed++;\n\t_ptrc_glViewport = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glViewport\");\n\tif(!_ptrc_glViewport) numFailed++;\n\t_ptrc_glBindTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindTexture\");\n\tif(!_ptrc_glBindTexture) numFailed++;\n\t_ptrc_glCopyTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint))IntGetProcAddress(\"glCopyTexImage1D\");\n\tif(!_ptrc_glCopyTexImage1D) numFailed++;\n\t_ptrc_glCopyTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint))IntGetProcAddress(\"glCopyTexImage2D\");\n\tif(!_ptrc_glCopyTexImage2D) numFailed++;\n\t_ptrc_glCopyTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei))IntGetProcAddress(\"glCopyTexSubImage1D\");\n\tif(!_ptrc_glCopyTexSubImage1D) numFailed++;\n\t_ptrc_glCopyTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glCopyTexSubImage2D\");\n\tif(!_ptrc_glCopyTexSubImage2D) numFailed++;\n\t_ptrc_glDeleteTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteTextures\");\n\tif(!_ptrc_glDeleteTextures) numFailed++;\n\t_ptrc_glDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei))IntGetProcAddress(\"glDrawArrays\");\n\tif(!_ptrc_glDrawArrays) numFailed++;\n\t_ptrc_glDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *))IntGetProcAddress(\"glDrawElements\");\n\tif(!_ptrc_glDrawElements) numFailed++;\n\t_ptrc_glGenTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenTextures\");\n\tif(!_ptrc_glGenTextures) numFailed++;\n\t_ptrc_glIsTexture = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsTexture\");\n\tif(!_ptrc_glIsTexture) numFailed++;\n\t_ptrc_glPolygonOffset = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress(\"glPolygonOffset\");\n\tif(!_ptrc_glPolygonOffset) numFailed++;\n\t_ptrc_glTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexSubImage1D\");\n\tif(!_ptrc_glTexSubImage1D) numFailed++;\n\t_ptrc_glTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexSubImage2D\");\n\tif(!_ptrc_glTexSubImage2D) numFailed++;\n\t_ptrc_glBlendColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glBlendColor\");\n\tif(!_ptrc_glBlendColor) numFailed++;\n\t_ptrc_glBlendEquation = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glBlendEquation\");\n\tif(!_ptrc_glBlendEquation) numFailed++;\n\t_ptrc_glCopyTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glCopyTexSubImage3D\");\n\tif(!_ptrc_glCopyTexSubImage3D) numFailed++;\n\t_ptrc_glDrawRangeElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))IntGetProcAddress(\"glDrawRangeElements\");\n\tif(!_ptrc_glDrawRangeElements) numFailed++;\n\t_ptrc_glTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexImage3D\");\n\tif(!_ptrc_glTexImage3D) numFailed++;\n\t_ptrc_glTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexSubImage3D\");\n\tif(!_ptrc_glTexSubImage3D) numFailed++;\n\t_ptrc_glActiveTexture = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glActiveTexture\");\n\tif(!_ptrc_glActiveTexture) numFailed++;\n\t_ptrc_glCompressedTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexImage1D\");\n\tif(!_ptrc_glCompressedTexImage1D) numFailed++;\n\t_ptrc_glCompressedTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexImage2D\");\n\tif(!_ptrc_glCompressedTexImage2D) numFailed++;\n\t_ptrc_glCompressedTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexImage3D\");\n\tif(!_ptrc_glCompressedTexImage3D) numFailed++;\n\t_ptrc_glCompressedTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexSubImage1D\");\n\tif(!_ptrc_glCompressedTexSubImage1D) numFailed++;\n\t_ptrc_glCompressedTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexSubImage2D\");\n\tif(!_ptrc_glCompressedTexSubImage2D) numFailed++;\n\t_ptrc_glCompressedTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexSubImage3D\");\n\tif(!_ptrc_glCompressedTexSubImage3D) numFailed++;\n\t_ptrc_glGetCompressedTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLvoid *))IntGetProcAddress(\"glGetCompressedTexImage\");\n\tif(!_ptrc_glGetCompressedTexImage) numFailed++;\n\t_ptrc_glSampleCoverage = (void (CODEGEN_FUNCPTR *)(GLfloat, GLboolean))IntGetProcAddress(\"glSampleCoverage\");\n\tif(!_ptrc_glSampleCoverage) numFailed++;\n\t_ptrc_glBlendFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress(\"glBlendFuncSeparate\");\n\tif(!_ptrc_glBlendFuncSeparate) numFailed++;\n\t_ptrc_glMultiDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *, const GLsizei *, GLsizei))IntGetProcAddress(\"glMultiDrawArrays\");\n\tif(!_ptrc_glMultiDrawArrays) numFailed++;\n\t_ptrc_glMultiDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei))IntGetProcAddress(\"glMultiDrawElements\");\n\tif(!_ptrc_glMultiDrawElements) numFailed++;\n\t_ptrc_glPointParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress(\"glPointParameterf\");\n\tif(!_ptrc_glPointParameterf) numFailed++;\n\t_ptrc_glPointParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress(\"glPointParameterfv\");\n\tif(!_ptrc_glPointParameterfv) numFailed++;\n\t_ptrc_glPointParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress(\"glPointParameteri\");\n\tif(!_ptrc_glPointParameteri) numFailed++;\n\t_ptrc_glPointParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress(\"glPointParameteriv\");\n\tif(!_ptrc_glPointParameteriv) numFailed++;\n\t_ptrc_glBeginQuery = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBeginQuery\");\n\tif(!_ptrc_glBeginQuery) numFailed++;\n\t_ptrc_glBindBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindBuffer\");\n\tif(!_ptrc_glBindBuffer) numFailed++;\n\t_ptrc_glBufferData = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const GLvoid *, GLenum))IntGetProcAddress(\"glBufferData\");\n\tif(!_ptrc_glBufferData) numFailed++;\n\t_ptrc_glBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, const GLvoid *))IntGetProcAddress(\"glBufferSubData\");\n\tif(!_ptrc_glBufferSubData) numFailed++;\n\t_ptrc_glDeleteBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteBuffers\");\n\tif(!_ptrc_glDeleteBuffers) numFailed++;\n\t_ptrc_glDeleteQueries = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteQueries\");\n\tif(!_ptrc_glDeleteQueries) numFailed++;\n\t_ptrc_glEndQuery = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glEndQuery\");\n\tif(!_ptrc_glEndQuery) numFailed++;\n\t_ptrc_glGenBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenBuffers\");\n\tif(!_ptrc_glGenBuffers) numFailed++;\n\t_ptrc_glGenQueries = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenQueries\");\n\tif(!_ptrc_glGenQueries) numFailed++;\n\t_ptrc_glGetBufferParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetBufferParameteriv\");\n\tif(!_ptrc_glGetBufferParameteriv) numFailed++;\n\t_ptrc_glGetBufferPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLvoid **))IntGetProcAddress(\"glGetBufferPointerv\");\n\tif(!_ptrc_glGetBufferPointerv) numFailed++;\n\t_ptrc_glGetBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, GLvoid *))IntGetProcAddress(\"glGetBufferSubData\");\n\tif(!_ptrc_glGetBufferSubData) numFailed++;\n\t_ptrc_glGetQueryObjectiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetQueryObjectiv\");\n\tif(!_ptrc_glGetQueryObjectiv) numFailed++;\n\t_ptrc_glGetQueryObjectuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress(\"glGetQueryObjectuiv\");\n\tif(!_ptrc_glGetQueryObjectuiv) numFailed++;\n\t_ptrc_glGetQueryiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetQueryiv\");\n\tif(!_ptrc_glGetQueryiv) numFailed++;\n\t_ptrc_glIsBuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsBuffer\");\n\tif(!_ptrc_glIsBuffer) numFailed++;\n\t_ptrc_glIsQuery = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsQuery\");\n\tif(!_ptrc_glIsQuery) numFailed++;\n\t_ptrc_glMapBuffer = (void * (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glMapBuffer\");\n\tif(!_ptrc_glMapBuffer) numFailed++;\n\t_ptrc_glUnmapBuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glUnmapBuffer\");\n\tif(!_ptrc_glUnmapBuffer) numFailed++;\n\t_ptrc_glAttachShader = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glAttachShader\");\n\tif(!_ptrc_glAttachShader) numFailed++;\n\t_ptrc_glBindAttribLocation = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, const GLchar *))IntGetProcAddress(\"glBindAttribLocation\");\n\tif(!_ptrc_glBindAttribLocation) numFailed++;\n\t_ptrc_glBlendEquationSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glBlendEquationSeparate\");\n\tif(!_ptrc_glBlendEquationSeparate) numFailed++;\n\t_ptrc_glCompileShader = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glCompileShader\");\n\tif(!_ptrc_glCompileShader) numFailed++;\n\t_ptrc_glCreateProgram = (GLuint (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glCreateProgram\");\n\tif(!_ptrc_glCreateProgram) numFailed++;\n\t_ptrc_glCreateShader = (GLuint (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glCreateShader\");\n\tif(!_ptrc_glCreateShader) numFailed++;\n\t_ptrc_glDeleteProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glDeleteProgram\");\n\tif(!_ptrc_glDeleteProgram) numFailed++;\n\t_ptrc_glDeleteShader = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glDeleteShader\");\n\tif(!_ptrc_glDeleteShader) numFailed++;\n\t_ptrc_glDetachShader = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glDetachShader\");\n\tif(!_ptrc_glDetachShader) numFailed++;\n\t_ptrc_glDisableVertexAttribArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glDisableVertexAttribArray\");\n\tif(!_ptrc_glDisableVertexAttribArray) numFailed++;\n\t_ptrc_glDrawBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLenum *))IntGetProcAddress(\"glDrawBuffers\");\n\tif(!_ptrc_glDrawBuffers) numFailed++;\n\t_ptrc_glEnableVertexAttribArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glEnableVertexAttribArray\");\n\tif(!_ptrc_glEnableVertexAttribArray) numFailed++;\n\t_ptrc_glGetActiveAttrib = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *))IntGetProcAddress(\"glGetActiveAttrib\");\n\tif(!_ptrc_glGetActiveAttrib) numFailed++;\n\t_ptrc_glGetActiveUniform = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *))IntGetProcAddress(\"glGetActiveUniform\");\n\tif(!_ptrc_glGetActiveUniform) numFailed++;\n\t_ptrc_glGetAttachedShaders = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLuint *))IntGetProcAddress(\"glGetAttachedShaders\");\n\tif(!_ptrc_glGetAttachedShaders) numFailed++;\n\t_ptrc_glGetAttribLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetAttribLocation\");\n\tif(!_ptrc_glGetAttribLocation) numFailed++;\n\t_ptrc_glGetProgramInfoLog = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetProgramInfoLog\");\n\tif(!_ptrc_glGetProgramInfoLog) numFailed++;\n\t_ptrc_glGetProgramiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetProgramiv\");\n\tif(!_ptrc_glGetProgramiv) numFailed++;\n\t_ptrc_glGetShaderInfoLog = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetShaderInfoLog\");\n\tif(!_ptrc_glGetShaderInfoLog) numFailed++;\n\t_ptrc_glGetShaderSource = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetShaderSource\");\n\tif(!_ptrc_glGetShaderSource) numFailed++;\n\t_ptrc_glGetShaderiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetShaderiv\");\n\tif(!_ptrc_glGetShaderiv) numFailed++;\n\t_ptrc_glGetUniformLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetUniformLocation\");\n\tif(!_ptrc_glGetUniformLocation) numFailed++;\n\t_ptrc_glGetUniformfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLfloat *))IntGetProcAddress(\"glGetUniformfv\");\n\tif(!_ptrc_glGetUniformfv) numFailed++;\n\t_ptrc_glGetUniformiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint *))IntGetProcAddress(\"glGetUniformiv\");\n\tif(!_ptrc_glGetUniformiv) numFailed++;\n\t_ptrc_glGetVertexAttribPointerv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLvoid **))IntGetProcAddress(\"glGetVertexAttribPointerv\");\n\tif(!_ptrc_glGetVertexAttribPointerv) numFailed++;\n\t_ptrc_glGetVertexAttribdv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLdouble *))IntGetProcAddress(\"glGetVertexAttribdv\");\n\tif(!_ptrc_glGetVertexAttribdv) numFailed++;\n\t_ptrc_glGetVertexAttribfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat *))IntGetProcAddress(\"glGetVertexAttribfv\");\n\tif(!_ptrc_glGetVertexAttribfv) numFailed++;\n\t_ptrc_glGetVertexAttribiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetVertexAttribiv\");\n\tif(!_ptrc_glGetVertexAttribiv) numFailed++;\n\t_ptrc_glIsProgram = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsProgram\");\n\tif(!_ptrc_glIsProgram) numFailed++;\n\t_ptrc_glIsShader = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsShader\");\n\tif(!_ptrc_glIsShader) numFailed++;\n\t_ptrc_glLinkProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glLinkProgram\");\n\tif(!_ptrc_glLinkProgram) numFailed++;\n\t_ptrc_glShaderSource = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, const GLint *))IntGetProcAddress(\"glShaderSource\");\n\tif(!_ptrc_glShaderSource) numFailed++;\n\t_ptrc_glStencilFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint, GLuint))IntGetProcAddress(\"glStencilFuncSeparate\");\n\tif(!_ptrc_glStencilFuncSeparate) numFailed++;\n\t_ptrc_glStencilMaskSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glStencilMaskSeparate\");\n\tif(!_ptrc_glStencilMaskSeparate) numFailed++;\n\t_ptrc_glStencilOpSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress(\"glStencilOpSeparate\");\n\tif(!_ptrc_glStencilOpSeparate) numFailed++;\n\t_ptrc_glUniform1f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat))IntGetProcAddress(\"glUniform1f\");\n\tif(!_ptrc_glUniform1f) numFailed++;\n\t_ptrc_glUniform1fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform1fv\");\n\tif(!_ptrc_glUniform1fv) numFailed++;\n\t_ptrc_glUniform1i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress(\"glUniform1i\");\n\tif(!_ptrc_glUniform1i) numFailed++;\n\t_ptrc_glUniform1iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform1iv\");\n\tif(!_ptrc_glUniform1iv) numFailed++;\n\t_ptrc_glUniform2f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat))IntGetProcAddress(\"glUniform2f\");\n\tif(!_ptrc_glUniform2f) numFailed++;\n\t_ptrc_glUniform2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform2fv\");\n\tif(!_ptrc_glUniform2fv) numFailed++;\n\t_ptrc_glUniform2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress(\"glUniform2i\");\n\tif(!_ptrc_glUniform2i) numFailed++;\n\t_ptrc_glUniform2iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform2iv\");\n\tif(!_ptrc_glUniform2iv) numFailed++;\n\t_ptrc_glUniform3f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glUniform3f\");\n\tif(!_ptrc_glUniform3f) numFailed++;\n\t_ptrc_glUniform3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform3fv\");\n\tif(!_ptrc_glUniform3fv) numFailed++;\n\t_ptrc_glUniform3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress(\"glUniform3i\");\n\tif(!_ptrc_glUniform3i) numFailed++;\n\t_ptrc_glUniform3iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform3iv\");\n\tif(!_ptrc_glUniform3iv) numFailed++;\n\t_ptrc_glUniform4f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glUniform4f\");\n\tif(!_ptrc_glUniform4f) numFailed++;\n\t_ptrc_glUniform4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform4fv\");\n\tif(!_ptrc_glUniform4fv) numFailed++;\n\t_ptrc_glUniform4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint))IntGetProcAddress(\"glUniform4i\");\n\tif(!_ptrc_glUniform4i) numFailed++;\n\t_ptrc_glUniform4iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform4iv\");\n\tif(!_ptrc_glUniform4iv) numFailed++;\n\t_ptrc_glUniformMatrix2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix2fv\");\n\tif(!_ptrc_glUniformMatrix2fv) numFailed++;\n\t_ptrc_glUniformMatrix3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix3fv\");\n\tif(!_ptrc_glUniformMatrix3fv) numFailed++;\n\t_ptrc_glUniformMatrix4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix4fv\");\n\tif(!_ptrc_glUniformMatrix4fv) numFailed++;\n\t_ptrc_glUseProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glUseProgram\");\n\tif(!_ptrc_glUseProgram) numFailed++;\n\t_ptrc_glValidateProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glValidateProgram\");\n\tif(!_ptrc_glValidateProgram) numFailed++;\n\t_ptrc_glVertexAttrib1d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble))IntGetProcAddress(\"glVertexAttrib1d\");\n\tif(!_ptrc_glVertexAttrib1d) numFailed++;\n\t_ptrc_glVertexAttrib1dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib1dv\");\n\tif(!_ptrc_glVertexAttrib1dv) numFailed++;\n\t_ptrc_glVertexAttrib1f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat))IntGetProcAddress(\"glVertexAttrib1f\");\n\tif(!_ptrc_glVertexAttrib1f) numFailed++;\n\t_ptrc_glVertexAttrib1fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib1fv\");\n\tif(!_ptrc_glVertexAttrib1fv) numFailed++;\n\t_ptrc_glVertexAttrib1s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort))IntGetProcAddress(\"glVertexAttrib1s\");\n\tif(!_ptrc_glVertexAttrib1s) numFailed++;\n\t_ptrc_glVertexAttrib1sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib1sv\");\n\tif(!_ptrc_glVertexAttrib1sv) numFailed++;\n\t_ptrc_glVertexAttrib2d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble))IntGetProcAddress(\"glVertexAttrib2d\");\n\tif(!_ptrc_glVertexAttrib2d) numFailed++;\n\t_ptrc_glVertexAttrib2dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib2dv\");\n\tif(!_ptrc_glVertexAttrib2dv) numFailed++;\n\t_ptrc_glVertexAttrib2f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat))IntGetProcAddress(\"glVertexAttrib2f\");\n\tif(!_ptrc_glVertexAttrib2f) numFailed++;\n\t_ptrc_glVertexAttrib2fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib2fv\");\n\tif(!_ptrc_glVertexAttrib2fv) numFailed++;\n\t_ptrc_glVertexAttrib2s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort))IntGetProcAddress(\"glVertexAttrib2s\");\n\tif(!_ptrc_glVertexAttrib2s) numFailed++;\n\t_ptrc_glVertexAttrib2sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib2sv\");\n\tif(!_ptrc_glVertexAttrib2sv) numFailed++;\n\t_ptrc_glVertexAttrib3d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble))IntGetProcAddress(\"glVertexAttrib3d\");\n\tif(!_ptrc_glVertexAttrib3d) numFailed++;\n\t_ptrc_glVertexAttrib3dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib3dv\");\n\tif(!_ptrc_glVertexAttrib3dv) numFailed++;\n\t_ptrc_glVertexAttrib3f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glVertexAttrib3f\");\n\tif(!_ptrc_glVertexAttrib3f) numFailed++;\n\t_ptrc_glVertexAttrib3fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib3fv\");\n\tif(!_ptrc_glVertexAttrib3fv) numFailed++;\n\t_ptrc_glVertexAttrib3s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort))IntGetProcAddress(\"glVertexAttrib3s\");\n\tif(!_ptrc_glVertexAttrib3s) numFailed++;\n\t_ptrc_glVertexAttrib3sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib3sv\");\n\tif(!_ptrc_glVertexAttrib3sv) numFailed++;\n\t_ptrc_glVertexAttrib4Nbv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress(\"glVertexAttrib4Nbv\");\n\tif(!_ptrc_glVertexAttrib4Nbv) numFailed++;\n\t_ptrc_glVertexAttrib4Niv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttrib4Niv\");\n\tif(!_ptrc_glVertexAttrib4Niv) numFailed++;\n\t_ptrc_glVertexAttrib4Nsv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib4Nsv\");\n\tif(!_ptrc_glVertexAttrib4Nsv) numFailed++;\n\t_ptrc_glVertexAttrib4Nub = (void (CODEGEN_FUNCPTR *)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte))IntGetProcAddress(\"glVertexAttrib4Nub\");\n\tif(!_ptrc_glVertexAttrib4Nub) numFailed++;\n\t_ptrc_glVertexAttrib4Nubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress(\"glVertexAttrib4Nubv\");\n\tif(!_ptrc_glVertexAttrib4Nubv) numFailed++;\n\t_ptrc_glVertexAttrib4Nuiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttrib4Nuiv\");\n\tif(!_ptrc_glVertexAttrib4Nuiv) numFailed++;\n\t_ptrc_glVertexAttrib4Nusv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress(\"glVertexAttrib4Nusv\");\n\tif(!_ptrc_glVertexAttrib4Nusv) numFailed++;\n\t_ptrc_glVertexAttrib4bv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress(\"glVertexAttrib4bv\");\n\tif(!_ptrc_glVertexAttrib4bv) numFailed++;\n\t_ptrc_glVertexAttrib4d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress(\"glVertexAttrib4d\");\n\tif(!_ptrc_glVertexAttrib4d) numFailed++;\n\t_ptrc_glVertexAttrib4dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib4dv\");\n\tif(!_ptrc_glVertexAttrib4dv) numFailed++;\n\t_ptrc_glVertexAttrib4f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glVertexAttrib4f\");\n\tif(!_ptrc_glVertexAttrib4f) numFailed++;\n\t_ptrc_glVertexAttrib4fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib4fv\");\n\tif(!_ptrc_glVertexAttrib4fv) numFailed++;\n\t_ptrc_glVertexAttrib4iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttrib4iv\");\n\tif(!_ptrc_glVertexAttrib4iv) numFailed++;\n\t_ptrc_glVertexAttrib4s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort, GLshort))IntGetProcAddress(\"glVertexAttrib4s\");\n\tif(!_ptrc_glVertexAttrib4s) numFailed++;\n\t_ptrc_glVertexAttrib4sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib4sv\");\n\tif(!_ptrc_glVertexAttrib4sv) numFailed++;\n\t_ptrc_glVertexAttrib4ubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress(\"glVertexAttrib4ubv\");\n\tif(!_ptrc_glVertexAttrib4ubv) numFailed++;\n\t_ptrc_glVertexAttrib4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttrib4uiv\");\n\tif(!_ptrc_glVertexAttrib4uiv) numFailed++;\n\t_ptrc_glVertexAttrib4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress(\"glVertexAttrib4usv\");\n\tif(!_ptrc_glVertexAttrib4usv) numFailed++;\n\t_ptrc_glVertexAttribPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *))IntGetProcAddress(\"glVertexAttribPointer\");\n\tif(!_ptrc_glVertexAttribPointer) numFailed++;\n\t_ptrc_glUniformMatrix2x3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix2x3fv\");\n\tif(!_ptrc_glUniformMatrix2x3fv) numFailed++;\n\t_ptrc_glUniformMatrix2x4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix2x4fv\");\n\tif(!_ptrc_glUniformMatrix2x4fv) numFailed++;\n\t_ptrc_glUniformMatrix3x2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix3x2fv\");\n\tif(!_ptrc_glUniformMatrix3x2fv) numFailed++;\n\t_ptrc_glUniformMatrix3x4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix3x4fv\");\n\tif(!_ptrc_glUniformMatrix3x4fv) numFailed++;\n\t_ptrc_glUniformMatrix4x2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix4x2fv\");\n\tif(!_ptrc_glUniformMatrix4x2fv) numFailed++;\n\t_ptrc_glUniformMatrix4x3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix4x3fv\");\n\tif(!_ptrc_glUniformMatrix4x3fv) numFailed++;\n\t_ptrc_glBeginConditionalRender = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress(\"glBeginConditionalRender\");\n\tif(!_ptrc_glBeginConditionalRender) numFailed++;\n\t_ptrc_glBeginTransformFeedback = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glBeginTransformFeedback\");\n\tif(!_ptrc_glBeginTransformFeedback) numFailed++;\n\t_ptrc_glBindBufferBase = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint))IntGetProcAddress(\"glBindBufferBase\");\n\tif(!_ptrc_glBindBufferBase) numFailed++;\n\t_ptrc_glBindBufferRange = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr))IntGetProcAddress(\"glBindBufferRange\");\n\tif(!_ptrc_glBindBufferRange) numFailed++;\n\t_ptrc_glBindFragDataLocation = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, const GLchar *))IntGetProcAddress(\"glBindFragDataLocation\");\n\tif(!_ptrc_glBindFragDataLocation) numFailed++;\n\t_ptrc_glBindFramebuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindFramebuffer\");\n\tif(!_ptrc_glBindFramebuffer) numFailed++;\n\t_ptrc_glBindRenderbuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindRenderbuffer\");\n\tif(!_ptrc_glBindRenderbuffer) numFailed++;\n\t_ptrc_glBindVertexArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glBindVertexArray\");\n\tif(!_ptrc_glBindVertexArray) numFailed++;\n\t_ptrc_glBlitFramebuffer = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum))IntGetProcAddress(\"glBlitFramebuffer\");\n\tif(!_ptrc_glBlitFramebuffer) numFailed++;\n\t_ptrc_glCheckFramebufferStatus = (GLenum (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glCheckFramebufferStatus\");\n\tif(!_ptrc_glCheckFramebufferStatus) numFailed++;\n\t_ptrc_glClampColor = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glClampColor\");\n\tif(!_ptrc_glClampColor) numFailed++;\n\t_ptrc_glClearBufferfi = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLfloat, GLint))IntGetProcAddress(\"glClearBufferfi\");\n\tif(!_ptrc_glClearBufferfi) numFailed++;\n\t_ptrc_glClearBufferfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLfloat *))IntGetProcAddress(\"glClearBufferfv\");\n\tif(!_ptrc_glClearBufferfv) numFailed++;\n\t_ptrc_glClearBufferiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLint *))IntGetProcAddress(\"glClearBufferiv\");\n\tif(!_ptrc_glClearBufferiv) numFailed++;\n\t_ptrc_glClearBufferuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLuint *))IntGetProcAddress(\"glClearBufferuiv\");\n\tif(!_ptrc_glClearBufferuiv) numFailed++;\n\t_ptrc_glColorMaski = (void (CODEGEN_FUNCPTR *)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress(\"glColorMaski\");\n\tif(!_ptrc_glColorMaski) numFailed++;\n\t_ptrc_glDeleteFramebuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteFramebuffers\");\n\tif(!_ptrc_glDeleteFramebuffers) numFailed++;\n\t_ptrc_glDeleteRenderbuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteRenderbuffers\");\n\tif(!_ptrc_glDeleteRenderbuffers) numFailed++;\n\t_ptrc_glDeleteVertexArrays = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteVertexArrays\");\n\tif(!_ptrc_glDeleteVertexArrays) numFailed++;\n\t_ptrc_glDisablei = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glDisablei\");\n\tif(!_ptrc_glDisablei) numFailed++;\n\t_ptrc_glEnablei = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glEnablei\");\n\tif(!_ptrc_glEnablei) numFailed++;\n\t_ptrc_glEndConditionalRender = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glEndConditionalRender\");\n\tif(!_ptrc_glEndConditionalRender) numFailed++;\n\t_ptrc_glEndTransformFeedback = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glEndTransformFeedback\");\n\tif(!_ptrc_glEndTransformFeedback) numFailed++;\n\t_ptrc_glFlushMappedBufferRange = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr))IntGetProcAddress(\"glFlushMappedBufferRange\");\n\tif(!_ptrc_glFlushMappedBufferRange) numFailed++;\n\t_ptrc_glFramebufferRenderbuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint))IntGetProcAddress(\"glFramebufferRenderbuffer\");\n\tif(!_ptrc_glFramebufferRenderbuffer) numFailed++;\n\t_ptrc_glFramebufferTexture1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress(\"glFramebufferTexture1D\");\n\tif(!_ptrc_glFramebufferTexture1D) numFailed++;\n\t_ptrc_glFramebufferTexture2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress(\"glFramebufferTexture2D\");\n\tif(!_ptrc_glFramebufferTexture2D) numFailed++;\n\t_ptrc_glFramebufferTexture3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress(\"glFramebufferTexture3D\");\n\tif(!_ptrc_glFramebufferTexture3D) numFailed++;\n\t_ptrc_glFramebufferTextureLayer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress(\"glFramebufferTextureLayer\");\n\tif(!_ptrc_glFramebufferTextureLayer) numFailed++;\n\t_ptrc_glGenFramebuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenFramebuffers\");\n\tif(!_ptrc_glGenFramebuffers) numFailed++;\n\t_ptrc_glGenRenderbuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenRenderbuffers\");\n\tif(!_ptrc_glGenRenderbuffers) numFailed++;\n\t_ptrc_glGenVertexArrays = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenVertexArrays\");\n\tif(!_ptrc_glGenVertexArrays) numFailed++;\n\t_ptrc_glGenerateMipmap = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glGenerateMipmap\");\n\tif(!_ptrc_glGenerateMipmap) numFailed++;\n\t_ptrc_glGetBooleani_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLboolean *))IntGetProcAddress(\"glGetBooleani_v\");\n\tif(!_ptrc_glGetBooleani_v) numFailed++;\n\t_ptrc_glGetFragDataLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetFragDataLocation\");\n\tif(!_ptrc_glGetFragDataLocation) numFailed++;\n\t_ptrc_glGetFramebufferAttachmentParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetFramebufferAttachmentParameteriv\");\n\tif(!_ptrc_glGetFramebufferAttachmentParameteriv) numFailed++;\n\t_ptrc_glGetIntegeri_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLint *))IntGetProcAddress(\"glGetIntegeri_v\");\n\tif(!_ptrc_glGetIntegeri_v) numFailed++;\n\t_ptrc_glGetRenderbufferParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetRenderbufferParameteriv\");\n\tif(!_ptrc_glGetRenderbufferParameteriv) numFailed++;\n\t_ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glGetStringi\");\n\tif(!_ptrc_glGetStringi) numFailed++;\n\t_ptrc_glGetTexParameterIiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetTexParameterIiv\");\n\tif(!_ptrc_glGetTexParameterIiv) numFailed++;\n\t_ptrc_glGetTexParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint *))IntGetProcAddress(\"glGetTexParameterIuiv\");\n\tif(!_ptrc_glGetTexParameterIuiv) numFailed++;\n\t_ptrc_glGetTransformFeedbackVarying = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *))IntGetProcAddress(\"glGetTransformFeedbackVarying\");\n\tif(!_ptrc_glGetTransformFeedbackVarying) numFailed++;\n\t_ptrc_glGetUniformuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLuint *))IntGetProcAddress(\"glGetUniformuiv\");\n\tif(!_ptrc_glGetUniformuiv) numFailed++;\n\t_ptrc_glGetVertexAttribIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetVertexAttribIiv\");\n\tif(!_ptrc_glGetVertexAttribIiv) numFailed++;\n\t_ptrc_glGetVertexAttribIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress(\"glGetVertexAttribIuiv\");\n\tif(!_ptrc_glGetVertexAttribIuiv) numFailed++;\n\t_ptrc_glIsEnabledi = (GLboolean (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glIsEnabledi\");\n\tif(!_ptrc_glIsEnabledi) numFailed++;\n\t_ptrc_glIsFramebuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsFramebuffer\");\n\tif(!_ptrc_glIsFramebuffer) numFailed++;\n\t_ptrc_glIsRenderbuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsRenderbuffer\");\n\tif(!_ptrc_glIsRenderbuffer) numFailed++;\n\t_ptrc_glIsVertexArray = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsVertexArray\");\n\tif(!_ptrc_glIsVertexArray) numFailed++;\n\t_ptrc_glMapBufferRange = (void * (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, GLbitfield))IntGetProcAddress(\"glMapBufferRange\");\n\tif(!_ptrc_glMapBufferRange) numFailed++;\n\t_ptrc_glRenderbufferStorage = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLsizei, GLsizei))IntGetProcAddress(\"glRenderbufferStorage\");\n\tif(!_ptrc_glRenderbufferStorage) numFailed++;\n\t_ptrc_glRenderbufferStorageMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))IntGetProcAddress(\"glRenderbufferStorageMultisample\");\n\tif(!_ptrc_glRenderbufferStorageMultisample) numFailed++;\n\t_ptrc_glTexParameterIiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress(\"glTexParameterIiv\");\n\tif(!_ptrc_glTexParameterIiv) numFailed++;\n\t_ptrc_glTexParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLuint *))IntGetProcAddress(\"glTexParameterIuiv\");\n\tif(!_ptrc_glTexParameterIuiv) numFailed++;\n\t_ptrc_glTransformFeedbackVaryings = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, GLenum))IntGetProcAddress(\"glTransformFeedbackVaryings\");\n\tif(!_ptrc_glTransformFeedbackVaryings) numFailed++;\n\t_ptrc_glUniform1ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint))IntGetProcAddress(\"glUniform1ui\");\n\tif(!_ptrc_glUniform1ui) numFailed++;\n\t_ptrc_glUniform1uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform1uiv\");\n\tif(!_ptrc_glUniform1uiv) numFailed++;\n\t_ptrc_glUniform2ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint))IntGetProcAddress(\"glUniform2ui\");\n\tif(!_ptrc_glUniform2ui) numFailed++;\n\t_ptrc_glUniform2uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform2uiv\");\n\tif(!_ptrc_glUniform2uiv) numFailed++;\n\t_ptrc_glUniform3ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glUniform3ui\");\n\tif(!_ptrc_glUniform3ui) numFailed++;\n\t_ptrc_glUniform3uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform3uiv\");\n\tif(!_ptrc_glUniform3uiv) numFailed++;\n\t_ptrc_glUniform4ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glUniform4ui\");\n\tif(!_ptrc_glUniform4ui) numFailed++;\n\t_ptrc_glUniform4uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform4uiv\");\n\tif(!_ptrc_glUniform4uiv) numFailed++;\n\t_ptrc_glVertexAttribI1i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint))IntGetProcAddress(\"glVertexAttribI1i\");\n\tif(!_ptrc_glVertexAttribI1i) numFailed++;\n\t_ptrc_glVertexAttribI1iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI1iv\");\n\tif(!_ptrc_glVertexAttribI1iv) numFailed++;\n\t_ptrc_glVertexAttribI1ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI1ui\");\n\tif(!_ptrc_glVertexAttribI1ui) numFailed++;\n\t_ptrc_glVertexAttribI1uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI1uiv\");\n\tif(!_ptrc_glVertexAttribI1uiv) numFailed++;\n\t_ptrc_glVertexAttribI2i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint))IntGetProcAddress(\"glVertexAttribI2i\");\n\tif(!_ptrc_glVertexAttribI2i) numFailed++;\n\t_ptrc_glVertexAttribI2iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI2iv\");\n\tif(!_ptrc_glVertexAttribI2iv) numFailed++;\n\t_ptrc_glVertexAttribI2ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI2ui\");\n\tif(!_ptrc_glVertexAttribI2ui) numFailed++;\n\t_ptrc_glVertexAttribI2uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI2uiv\");\n\tif(!_ptrc_glVertexAttribI2uiv) numFailed++;\n\t_ptrc_glVertexAttribI3i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint))IntGetProcAddress(\"glVertexAttribI3i\");\n\tif(!_ptrc_glVertexAttribI3i) numFailed++;\n\t_ptrc_glVertexAttribI3iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI3iv\");\n\tif(!_ptrc_glVertexAttribI3iv) numFailed++;\n\t_ptrc_glVertexAttribI3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI3ui\");\n\tif(!_ptrc_glVertexAttribI3ui) numFailed++;\n\t_ptrc_glVertexAttribI3uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI3uiv\");\n\tif(!_ptrc_glVertexAttribI3uiv) numFailed++;\n\t_ptrc_glVertexAttribI4bv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress(\"glVertexAttribI4bv\");\n\tif(!_ptrc_glVertexAttribI4bv) numFailed++;\n\t_ptrc_glVertexAttribI4i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint, GLint))IntGetProcAddress(\"glVertexAttribI4i\");\n\tif(!_ptrc_glVertexAttribI4i) numFailed++;\n\t_ptrc_glVertexAttribI4iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI4iv\");\n\tif(!_ptrc_glVertexAttribI4iv) numFailed++;\n\t_ptrc_glVertexAttribI4sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttribI4sv\");\n\tif(!_ptrc_glVertexAttribI4sv) numFailed++;\n\t_ptrc_glVertexAttribI4ubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress(\"glVertexAttribI4ubv\");\n\tif(!_ptrc_glVertexAttribI4ubv) numFailed++;\n\t_ptrc_glVertexAttribI4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI4ui\");\n\tif(!_ptrc_glVertexAttribI4ui) numFailed++;\n\t_ptrc_glVertexAttribI4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI4uiv\");\n\tif(!_ptrc_glVertexAttribI4uiv) numFailed++;\n\t_ptrc_glVertexAttribI4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress(\"glVertexAttribI4usv\");\n\tif(!_ptrc_glVertexAttribI4usv) numFailed++;\n\t_ptrc_glVertexAttribIPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress(\"glVertexAttribIPointer\");\n\tif(!_ptrc_glVertexAttribIPointer) numFailed++;\n\t_ptrc_glCopyBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr))IntGetProcAddress(\"glCopyBufferSubData\");\n\tif(!_ptrc_glCopyBufferSubData) numFailed++;\n\t_ptrc_glDrawArraysInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glDrawArraysInstanced\");\n\tif(!_ptrc_glDrawArraysInstanced) numFailed++;\n\t_ptrc_glDrawElementsInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei))IntGetProcAddress(\"glDrawElementsInstanced\");\n\tif(!_ptrc_glDrawElementsInstanced) numFailed++;\n\t_ptrc_glGetActiveUniformBlockName = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetActiveUniformBlockName\");\n\tif(!_ptrc_glGetActiveUniformBlockName) numFailed++;\n\t_ptrc_glGetActiveUniformBlockiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetActiveUniformBlockiv\");\n\tif(!_ptrc_glGetActiveUniformBlockiv) numFailed++;\n\t_ptrc_glGetActiveUniformName = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetActiveUniformName\");\n\tif(!_ptrc_glGetActiveUniformName) numFailed++;\n\t_ptrc_glGetActiveUniformsiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLuint *, GLenum, GLint *))IntGetProcAddress(\"glGetActiveUniformsiv\");\n\tif(!_ptrc_glGetActiveUniformsiv) numFailed++;\n\t_ptrc_glGetUniformBlockIndex = (GLuint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetUniformBlockIndex\");\n\tif(!_ptrc_glGetUniformBlockIndex) numFailed++;\n\t_ptrc_glGetUniformIndices = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, GLuint *))IntGetProcAddress(\"glGetUniformIndices\");\n\tif(!_ptrc_glGetUniformIndices) numFailed++;\n\t_ptrc_glPrimitiveRestartIndex = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glPrimitiveRestartIndex\");\n\tif(!_ptrc_glPrimitiveRestartIndex) numFailed++;\n\t_ptrc_glTexBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint))IntGetProcAddress(\"glTexBuffer\");\n\tif(!_ptrc_glTexBuffer) numFailed++;\n\t_ptrc_glUniformBlockBinding = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress(\"glUniformBlockBinding\");\n\tif(!_ptrc_glUniformBlockBinding) numFailed++;\n\t_ptrc_glClientWaitSync = (GLenum (CODEGEN_FUNCPTR *)(GLsync, GLbitfield, GLuint64))IntGetProcAddress(\"glClientWaitSync\");\n\tif(!_ptrc_glClientWaitSync) numFailed++;\n\t_ptrc_glDeleteSync = (void (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress(\"glDeleteSync\");\n\tif(!_ptrc_glDeleteSync) numFailed++;\n\t_ptrc_glDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLint))IntGetProcAddress(\"glDrawElementsBaseVertex\");\n\tif(!_ptrc_glDrawElementsBaseVertex) numFailed++;\n\t_ptrc_glDrawElementsInstancedBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint))IntGetProcAddress(\"glDrawElementsInstancedBaseVertex\");\n\tif(!_ptrc_glDrawElementsInstancedBaseVertex) numFailed++;\n\t_ptrc_glDrawRangeElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint))IntGetProcAddress(\"glDrawRangeElementsBaseVertex\");\n\tif(!_ptrc_glDrawRangeElementsBaseVertex) numFailed++;\n\t_ptrc_glFenceSync = (GLsync (CODEGEN_FUNCPTR *)(GLenum, GLbitfield))IntGetProcAddress(\"glFenceSync\");\n\tif(!_ptrc_glFenceSync) numFailed++;\n\t_ptrc_glFramebufferTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLint))IntGetProcAddress(\"glFramebufferTexture\");\n\tif(!_ptrc_glFramebufferTexture) numFailed++;\n\t_ptrc_glGetBufferParameteri64v = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint64 *))IntGetProcAddress(\"glGetBufferParameteri64v\");\n\tif(!_ptrc_glGetBufferParameteri64v) numFailed++;\n\t_ptrc_glGetInteger64i_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLint64 *))IntGetProcAddress(\"glGetInteger64i_v\");\n\tif(!_ptrc_glGetInteger64i_v) numFailed++;\n\t_ptrc_glGetInteger64v = (void (CODEGEN_FUNCPTR *)(GLenum, GLint64 *))IntGetProcAddress(\"glGetInteger64v\");\n\tif(!_ptrc_glGetInteger64v) numFailed++;\n\t_ptrc_glGetMultisamplefv = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLfloat *))IntGetProcAddress(\"glGetMultisamplefv\");\n\tif(!_ptrc_glGetMultisamplefv) numFailed++;\n\t_ptrc_glGetSynciv = (void (CODEGEN_FUNCPTR *)(GLsync, GLenum, GLsizei, GLsizei *, GLint *))IntGetProcAddress(\"glGetSynciv\");\n\tif(!_ptrc_glGetSynciv) numFailed++;\n\t_ptrc_glIsSync = (GLboolean (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress(\"glIsSync\");\n\tif(!_ptrc_glIsSync) numFailed++;\n\t_ptrc_glMultiDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *))IntGetProcAddress(\"glMultiDrawElementsBaseVertex\");\n\tif(!_ptrc_glMultiDrawElementsBaseVertex) numFailed++;\n\t_ptrc_glProvokingVertex = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glProvokingVertex\");\n\tif(!_ptrc_glProvokingVertex) numFailed++;\n\t_ptrc_glSampleMaski = (void (CODEGEN_FUNCPTR *)(GLuint, GLbitfield))IntGetProcAddress(\"glSampleMaski\");\n\tif(!_ptrc_glSampleMaski) numFailed++;\n\t_ptrc_glTexImage2DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean))IntGetProcAddress(\"glTexImage2DMultisample\");\n\tif(!_ptrc_glTexImage2DMultisample) numFailed++;\n\t_ptrc_glTexImage3DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean))IntGetProcAddress(\"glTexImage3DMultisample\");\n\tif(!_ptrc_glTexImage3DMultisample) numFailed++;\n\t_ptrc_glWaitSync = (void (CODEGEN_FUNCPTR *)(GLsync, GLbitfield, GLuint64))IntGetProcAddress(\"glWaitSync\");\n\tif(!_ptrc_glWaitSync) numFailed++;\n\t_ptrc_glBindFragDataLocationIndexed = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, const GLchar *))IntGetProcAddress(\"glBindFragDataLocationIndexed\");\n\tif(!_ptrc_glBindFragDataLocationIndexed) numFailed++;\n\t_ptrc_glBindSampler = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glBindSampler\");\n\tif(!_ptrc_glBindSampler) numFailed++;\n\t_ptrc_glDeleteSamplers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteSamplers\");\n\tif(!_ptrc_glDeleteSamplers) numFailed++;\n\t_ptrc_glGenSamplers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenSamplers\");\n\tif(!_ptrc_glGenSamplers) numFailed++;\n\t_ptrc_glGetFragDataIndex = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetFragDataIndex\");\n\tif(!_ptrc_glGetFragDataIndex) numFailed++;\n\t_ptrc_glGetQueryObjecti64v = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint64 *))IntGetProcAddress(\"glGetQueryObjecti64v\");\n\tif(!_ptrc_glGetQueryObjecti64v) numFailed++;\n\t_ptrc_glGetQueryObjectui64v = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint64 *))IntGetProcAddress(\"glGetQueryObjectui64v\");\n\tif(!_ptrc_glGetQueryObjectui64v) numFailed++;\n\t_ptrc_glGetSamplerParameterIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetSamplerParameterIiv\");\n\tif(!_ptrc_glGetSamplerParameterIiv) numFailed++;\n\t_ptrc_glGetSamplerParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress(\"glGetSamplerParameterIuiv\");\n\tif(!_ptrc_glGetSamplerParameterIuiv) numFailed++;\n\t_ptrc_glGetSamplerParameterfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat *))IntGetProcAddress(\"glGetSamplerParameterfv\");\n\tif(!_ptrc_glGetSamplerParameterfv) numFailed++;\n\t_ptrc_glGetSamplerParameteriv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetSamplerParameteriv\");\n\tif(!_ptrc_glGetSamplerParameteriv) numFailed++;\n\t_ptrc_glIsSampler = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsSampler\");\n\tif(!_ptrc_glIsSampler) numFailed++;\n\t_ptrc_glQueryCounter = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress(\"glQueryCounter\");\n\tif(!_ptrc_glQueryCounter) numFailed++;\n\t_ptrc_glSamplerParameterIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLint *))IntGetProcAddress(\"glSamplerParameterIiv\");\n\tif(!_ptrc_glSamplerParameterIiv) numFailed++;\n\t_ptrc_glSamplerParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLuint *))IntGetProcAddress(\"glSamplerParameterIuiv\");\n\tif(!_ptrc_glSamplerParameterIuiv) numFailed++;\n\t_ptrc_glSamplerParameterf = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat))IntGetProcAddress(\"glSamplerParameterf\");\n\tif(!_ptrc_glSamplerParameterf) numFailed++;\n\t_ptrc_glSamplerParameterfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLfloat *))IntGetProcAddress(\"glSamplerParameterfv\");\n\tif(!_ptrc_glSamplerParameterfv) numFailed++;\n\t_ptrc_glSamplerParameteri = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint))IntGetProcAddress(\"glSamplerParameteri\");\n\tif(!_ptrc_glSamplerParameteri) numFailed++;\n\t_ptrc_glSamplerParameteriv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLint *))IntGetProcAddress(\"glSamplerParameteriv\");\n\tif(!_ptrc_glSamplerParameteriv) numFailed++;\n\t_ptrc_glVertexAttribDivisor = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glVertexAttribDivisor\");\n\tif(!_ptrc_glVertexAttribDivisor) numFailed++;\n\t_ptrc_glVertexAttribP1ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP1ui\");\n\tif(!_ptrc_glVertexAttribP1ui) numFailed++;\n\t_ptrc_glVertexAttribP1uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP1uiv\");\n\tif(!_ptrc_glVertexAttribP1uiv) numFailed++;\n\t_ptrc_glVertexAttribP2ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP2ui\");\n\tif(!_ptrc_glVertexAttribP2ui) numFailed++;\n\t_ptrc_glVertexAttribP2uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP2uiv\");\n\tif(!_ptrc_glVertexAttribP2uiv) numFailed++;\n\t_ptrc_glVertexAttribP3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP3ui\");\n\tif(!_ptrc_glVertexAttribP3ui) numFailed++;\n\t_ptrc_glVertexAttribP3uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP3uiv\");\n\tif(!_ptrc_glVertexAttribP3uiv) numFailed++;\n\t_ptrc_glVertexAttribP4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP4ui\");\n\tif(!_ptrc_glVertexAttribP4ui) numFailed++;\n\t_ptrc_glVertexAttribP4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP4uiv\");\n\tif(!_ptrc_glVertexAttribP4uiv) numFailed++;\n\t_ptrc_glBeginQueryIndexed = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint))IntGetProcAddress(\"glBeginQueryIndexed\");\n\tif(!_ptrc_glBeginQueryIndexed) numFailed++;\n\t_ptrc_glBindTransformFeedback = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindTransformFeedback\");\n\tif(!_ptrc_glBindTransformFeedback) numFailed++;\n\t_ptrc_glBlendEquationSeparatei = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLenum))IntGetProcAddress(\"glBlendEquationSeparatei\");\n\tif(!_ptrc_glBlendEquationSeparatei) numFailed++;\n\t_ptrc_glBlendEquationi = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress(\"glBlendEquationi\");\n\tif(!_ptrc_glBlendEquationi) numFailed++;\n\t_ptrc_glBlendFuncSeparatei = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLenum, GLenum, GLenum))IntGetProcAddress(\"glBlendFuncSeparatei\");\n\tif(!_ptrc_glBlendFuncSeparatei) numFailed++;\n\t_ptrc_glBlendFunci = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLenum))IntGetProcAddress(\"glBlendFunci\");\n\tif(!_ptrc_glBlendFunci) numFailed++;\n\t_ptrc_glDeleteTransformFeedbacks = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteTransformFeedbacks\");\n\tif(!_ptrc_glDeleteTransformFeedbacks) numFailed++;\n\t_ptrc_glDrawArraysIndirect = (void (CODEGEN_FUNCPTR *)(GLenum, const GLvoid *))IntGetProcAddress(\"glDrawArraysIndirect\");\n\tif(!_ptrc_glDrawArraysIndirect) numFailed++;\n\t_ptrc_glDrawElementsIndirect = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glDrawElementsIndirect\");\n\tif(!_ptrc_glDrawElementsIndirect) numFailed++;\n\t_ptrc_glDrawTransformFeedback = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glDrawTransformFeedback\");\n\tif(!_ptrc_glDrawTransformFeedback) numFailed++;\n\t_ptrc_glDrawTransformFeedbackStream = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint))IntGetProcAddress(\"glDrawTransformFeedbackStream\");\n\tif(!_ptrc_glDrawTransformFeedbackStream) numFailed++;\n\t_ptrc_glEndQueryIndexed = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glEndQueryIndexed\");\n\tif(!_ptrc_glEndQueryIndexed) numFailed++;\n\t_ptrc_glGenTransformFeedbacks = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenTransformFeedbacks\");\n\tif(!_ptrc_glGenTransformFeedbacks) numFailed++;\n\t_ptrc_glGetActiveSubroutineName = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetActiveSubroutineName\");\n\tif(!_ptrc_glGetActiveSubroutineName) numFailed++;\n\t_ptrc_glGetActiveSubroutineUniformName = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetActiveSubroutineUniformName\");\n\tif(!_ptrc_glGetActiveSubroutineUniformName) numFailed++;\n\t_ptrc_glGetActiveSubroutineUniformiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetActiveSubroutineUniformiv\");\n\tif(!_ptrc_glGetActiveSubroutineUniformiv) numFailed++;\n\t_ptrc_glGetProgramStageiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetProgramStageiv\");\n\tif(!_ptrc_glGetProgramStageiv) numFailed++;\n\t_ptrc_glGetQueryIndexediv = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetQueryIndexediv\");\n\tif(!_ptrc_glGetQueryIndexediv) numFailed++;\n\t_ptrc_glGetSubroutineIndex = (GLuint (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLchar *))IntGetProcAddress(\"glGetSubroutineIndex\");\n\tif(!_ptrc_glGetSubroutineIndex) numFailed++;\n\t_ptrc_glGetSubroutineUniformLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLchar *))IntGetProcAddress(\"glGetSubroutineUniformLocation\");\n\tif(!_ptrc_glGetSubroutineUniformLocation) numFailed++;\n\t_ptrc_glGetUniformSubroutineuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLuint *))IntGetProcAddress(\"glGetUniformSubroutineuiv\");\n\tif(!_ptrc_glGetUniformSubroutineuiv) numFailed++;\n\t_ptrc_glGetUniformdv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLdouble *))IntGetProcAddress(\"glGetUniformdv\");\n\tif(!_ptrc_glGetUniformdv) numFailed++;\n\t_ptrc_glIsTransformFeedback = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsTransformFeedback\");\n\tif(!_ptrc_glIsTransformFeedback) numFailed++;\n\t_ptrc_glMinSampleShading = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress(\"glMinSampleShading\");\n\tif(!_ptrc_glMinSampleShading) numFailed++;\n\t_ptrc_glPatchParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress(\"glPatchParameterfv\");\n\tif(!_ptrc_glPatchParameterfv) numFailed++;\n\t_ptrc_glPatchParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress(\"glPatchParameteri\");\n\tif(!_ptrc_glPatchParameteri) numFailed++;\n\t_ptrc_glPauseTransformFeedback = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glPauseTransformFeedback\");\n\tif(!_ptrc_glPauseTransformFeedback) numFailed++;\n\t_ptrc_glResumeTransformFeedback = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glResumeTransformFeedback\");\n\tif(!_ptrc_glResumeTransformFeedback) numFailed++;\n\t_ptrc_glUniform1d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble))IntGetProcAddress(\"glUniform1d\");\n\tif(!_ptrc_glUniform1d) numFailed++;\n\t_ptrc_glUniform1dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLdouble *))IntGetProcAddress(\"glUniform1dv\");\n\tif(!_ptrc_glUniform1dv) numFailed++;\n\t_ptrc_glUniform2d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble, GLdouble))IntGetProcAddress(\"glUniform2d\");\n\tif(!_ptrc_glUniform2d) numFailed++;\n\t_ptrc_glUniform2dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLdouble *))IntGetProcAddress(\"glUniform2dv\");\n\tif(!_ptrc_glUniform2dv) numFailed++;\n\t_ptrc_glUniform3d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble, GLdouble, GLdouble))IntGetProcAddress(\"glUniform3d\");\n\tif(!_ptrc_glUniform3d) numFailed++;\n\t_ptrc_glUniform3dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLdouble *))IntGetProcAddress(\"glUniform3dv\");\n\tif(!_ptrc_glUniform3dv) numFailed++;\n\t_ptrc_glUniform4d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress(\"glUniform4d\");\n\tif(!_ptrc_glUniform4d) numFailed++;\n\t_ptrc_glUniform4dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLdouble *))IntGetProcAddress(\"glUniform4dv\");\n\tif(!_ptrc_glUniform4dv) numFailed++;\n\t_ptrc_glUniformMatrix2dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix2dv\");\n\tif(!_ptrc_glUniformMatrix2dv) numFailed++;\n\t_ptrc_glUniformMatrix2x3dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix2x3dv\");\n\tif(!_ptrc_glUniformMatrix2x3dv) numFailed++;\n\t_ptrc_glUniformMatrix2x4dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix2x4dv\");\n\tif(!_ptrc_glUniformMatrix2x4dv) numFailed++;\n\t_ptrc_glUniformMatrix3dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix3dv\");\n\tif(!_ptrc_glUniformMatrix3dv) numFailed++;\n\t_ptrc_glUniformMatrix3x2dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix3x2dv\");\n\tif(!_ptrc_glUniformMatrix3x2dv) numFailed++;\n\t_ptrc_glUniformMatrix3x4dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix3x4dv\");\n\tif(!_ptrc_glUniformMatrix3x4dv) numFailed++;\n\t_ptrc_glUniformMatrix4dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix4dv\");\n\tif(!_ptrc_glUniformMatrix4dv) numFailed++;\n\t_ptrc_glUniformMatrix4x2dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix4x2dv\");\n\tif(!_ptrc_glUniformMatrix4x2dv) numFailed++;\n\t_ptrc_glUniformMatrix4x3dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix4x3dv\");\n\tif(!_ptrc_glUniformMatrix4x3dv) numFailed++;\n\t_ptrc_glUniformSubroutinesuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLuint *))IntGetProcAddress(\"glUniformSubroutinesuiv\");\n\tif(!_ptrc_glUniformSubroutinesuiv) numFailed++;\n\treturn numFailed;\n}\n\ntypedef int (*PFN_LOADFUNCPOINTERS)();\ntypedef struct ogl_StrToExtMap_s\n{\n\tchar *extensionName;\n\tint *extensionVariable;\n\tPFN_LOADFUNCPOINTERS LoadExtension;\n} ogl_StrToExtMap;\n\nstatic ogl_StrToExtMap ExtensionMap[1] = {\n\t{\"\", NULL, NULL},\n};\n\nstatic int g_extensionMapSize = 0;\n\nstatic ogl_StrToExtMap *FindExtEntry(const char *extensionName)\n{\n\tint loop;\n\togl_StrToExtMap *currLoc = ExtensionMap;\n\tfor(loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc)\n\t{\n\t\tif(strcmp(extensionName, currLoc->extensionName) == 0)\n\t\t\treturn currLoc;\n\t}\n\t\n\treturn NULL;\n}\n\nstatic void ClearExtensionVars()\n{\n}\n\n\nstatic void LoadExtByName(const char *extensionName)\n{\n\togl_StrToExtMap *entry = NULL;\n\tentry = FindExtEntry(extensionName);\n\tif(entry)\n\t{\n\t\tif(entry->LoadExtension)\n\t\t{\n\t\t\tint numFailed = entry->LoadExtension();\n\t\t\tif(numFailed == 0)\n\t\t\t{\n\t\t\t\t*(entry->extensionVariable) = ogl_LOAD_SUCCEEDED;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t*(entry->extensionVariable) = ogl_LOAD_SUCCEEDED + numFailed;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t*(entry->extensionVariable) = ogl_LOAD_SUCCEEDED;\n\t\t}\n\t}\n}\n\n\nstatic void ProcExtsFromExtList()\n{\n\tGLint iLoop;\n\tGLint iNumExtensions = 0;\n\t_ptrc_glGetIntegerv(GL_NUM_EXTENSIONS, &iNumExtensions);\n\n\tfor(iLoop = 0; iLoop < iNumExtensions; iLoop++)\n\t{\n\t\tconst char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop);\n\t\tLoadExtByName(strExtensionName);\n\t}\n}\n\nint ogl_LoadFunctions()\n{\n\tint numFailed = 0;\n\tClearExtensionVars();\n\t\n\t_ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress(\"glGetIntegerv\");\n\tif(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED;\n\t_ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glGetStringi\");\n\tif(!_ptrc_glGetStringi) return ogl_LOAD_FAILED;\n\t\n\tProcExtsFromExtList();\n\tnumFailed = Load_Version_4_0();\n\t\n\tif(numFailed == 0)\n\t\treturn ogl_LOAD_SUCCEEDED;\n\telse\n\t\treturn ogl_LOAD_SUCCEEDED + numFailed;\n}\n\nstatic int g_major_version = 0;\nstatic int g_minor_version = 0;\n\nstatic void GetGLVersion()\n{\n\tglGetIntegerv(GL_MAJOR_VERSION, &g_major_version);\n\tglGetIntegerv(GL_MINOR_VERSION, &g_minor_version);\n}\n\nint ogl_GetMajorVersion()\n{\n\tif(g_major_version == 0)\n\t\tGetGLVersion();\n\treturn g_major_version;\n}\n\nint ogl_GetMinorVersion()\n{\n\tif(g_major_version == 0) //Yes, check the major version to get the minor one.\n\t\tGetGLVersion();\n\treturn g_minor_version;\n}\n\nint ogl_IsVersionGEQ(int majorVersion, int minorVersion)\n{\n\tif(g_major_version == 0)\n\t\tGetGLVersion();\n\t\t\n\tif(majorVersion > g_major_version) return 1;\n\tif(majorVersion < g_major_version) return 0;\n\tif(minorVersion >= g_minor_version) return 1;\n\treturn 0;\n}\n\n"
  },
  {
    "path": "examples/common_code/gl_core_4_0.h",
    "content": "#ifndef POINTER_C_GENERATED_HEADER_OPENGL_H\n#define POINTER_C_GENERATED_HEADER_OPENGL_H\n\n#if defined(__glew_h__) || defined(__GLEW_H__)\n#error Attempt to include auto-generated header after including glew.h\n#endif\n#if defined(__gl_h_) || defined(__GL_H__)\n#error Attempt to include auto-generated header after including gl.h\n#endif\n#if defined(__glext_h_) || defined(__GLEXT_H_)\n#error Attempt to include auto-generated header after including glext.h\n#endif\n#if defined(__gltypes_h_)\n#error Attempt to include auto-generated header after gltypes.h\n#endif\n#if defined(__gl_ATI_h_)\n#error Attempt to include auto-generated header after including glATI.h\n#endif\n\n#define __glew_h__\n#define __GLEW_H__\n#define __gl_h_\n#define __GL_H__\n#define __glext_h_\n#define __GLEXT_H_\n#define __gltypes_h_\n#define __gl_ATI_h_\n\n#ifndef APIENTRY\n\t#if defined(__MINGW32__)\n\t\t#ifndef WIN32_LEAN_AND_MEAN\n\t\t\t#define WIN32_LEAN_AND_MEAN 1\n\t\t#endif\n\t\t#ifndef NOMINMAX\n\t\t\t#define NOMINMAX\n\t\t#endif\n\t\t#include <windows.h>\n\t#elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__)\n\t\t#ifndef WIN32_LEAN_AND_MEAN\n\t\t\t#define WIN32_LEAN_AND_MEAN 1\n\t\t#endif\n\t\t#ifndef NOMINMAX\n\t\t\t#define NOMINMAX\n\t\t#endif\n\t\t#include <windows.h>\n\t#else\n\t\t#define APIENTRY\n\t#endif\n#endif /*APIENTRY*/\n\n#ifndef CODEGEN_FUNCPTR\n\t#define CODEGEN_REMOVE_FUNCPTR\n\t#if defined(_WIN32)\n\t\t#define CODEGEN_FUNCPTR APIENTRY\n\t#else\n\t\t#define CODEGEN_FUNCPTR\n\t#endif\n#endif /*CODEGEN_FUNCPTR*/\n\n#ifndef GLAPI\n\t#define GLAPI extern\n#endif\n\n\n#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n\n\n#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/\n\n\n#include <stddef.h>\n#ifndef GLEXT_64_TYPES_DEFINED\n/* This code block is duplicated in glxext.h, so must be protected */\n#define GLEXT_64_TYPES_DEFINED\n/* Define int32_t, int64_t, and uint64_t types for UST/MSC */\n/* (as used in the GL_EXT_timer_query extension). */\n#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n#include <inttypes.h>\n#elif defined(__sun__) || defined(__digital__)\n#include <inttypes.h>\n#if defined(__STDC__)\n#if defined(__arch64__) || defined(_LP64)\ntypedef long int int64_t;\ntypedef unsigned long int uint64_t;\n#else\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#endif /* __arch64__ */\n#endif /* __STDC__ */\n#elif defined( __VMS ) || defined(__sgi)\n#include <inttypes.h>\n#elif defined(__SCO__) || defined(__USLC__)\n#include <stdint.h>\n#elif defined(__UNIXOS2__) || defined(__SOL64__)\ntypedef long int int32_t;\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#elif defined(_WIN32) && defined(__GNUC__)\n#include <stdint.h>\n#elif defined(_WIN32)\ntypedef __int32 int32_t;\ntypedef __int64 int64_t;\ntypedef unsigned __int64 uint64_t;\n#else\n/* Fallback if nothing above works */\n#include <inttypes.h>\n#endif\n#endif\n\ttypedef unsigned int GLenum;\n\ttypedef unsigned char GLboolean;\n\ttypedef unsigned int GLbitfield;\n\ttypedef void GLvoid;\n\ttypedef signed char GLbyte;\n\ttypedef short GLshort;\n\ttypedef int GLint;\n\ttypedef unsigned char GLubyte;\n\ttypedef unsigned short GLushort;\n\ttypedef unsigned int GLuint;\n\ttypedef int GLsizei;\n\ttypedef float GLfloat;\n\ttypedef float GLclampf;\n\ttypedef double GLdouble;\n\ttypedef double GLclampd;\n\ttypedef char GLchar;\n\ttypedef char GLcharARB;\n\t#ifdef __APPLE__\ntypedef void *GLhandleARB;\n#else\ntypedef unsigned int GLhandleARB;\n#endif\n\t\ttypedef unsigned short GLhalfARB;\n\t\ttypedef unsigned short GLhalf;\n\t\ttypedef GLint GLfixed;\n\t\ttypedef ptrdiff_t GLintptr;\n\t\ttypedef ptrdiff_t GLsizeiptr;\n\t\ttypedef int64_t GLint64;\n\t\ttypedef uint64_t GLuint64;\n\t\ttypedef ptrdiff_t GLintptrARB;\n\t\ttypedef ptrdiff_t GLsizeiptrARB;\n\t\ttypedef int64_t GLint64EXT;\n\t\ttypedef uint64_t GLuint64EXT;\n\t\ttypedef struct __GLsync *GLsync;\n\t\tstruct _cl_context;\n\t\tstruct _cl_event;\n\t\ttypedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);\n\t\ttypedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);\n\t\ttypedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);\n\t\ttypedef unsigned short GLhalfNV;\n\t\ttypedef GLintptr GLvdpauSurfaceNV;\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /*__cplusplus*/\n\n#define GL_ALPHA 0x1906\n#define GL_ALWAYS 0x0207\n#define GL_AND 0x1501\n#define GL_AND_INVERTED 0x1504\n#define GL_AND_REVERSE 0x1502\n#define GL_BACK 0x0405\n#define GL_BACK_LEFT 0x0402\n#define GL_BACK_RIGHT 0x0403\n#define GL_BLEND 0x0BE2\n#define GL_BLEND_DST 0x0BE0\n#define GL_BLEND_SRC 0x0BE1\n#define GL_BLUE 0x1905\n#define GL_BYTE 0x1400\n#define GL_CCW 0x0901\n#define GL_CLEAR 0x1500\n#define GL_COLOR 0x1800\n#define GL_COLOR_BUFFER_BIT 0x00004000\n#define GL_COLOR_CLEAR_VALUE 0x0C22\n#define GL_COLOR_LOGIC_OP 0x0BF2\n#define GL_COLOR_WRITEMASK 0x0C23\n#define GL_COPY 0x1503\n#define GL_COPY_INVERTED 0x150C\n#define GL_CULL_FACE 0x0B44\n#define GL_CULL_FACE_MODE 0x0B45\n#define GL_CW 0x0900\n#define GL_DECR 0x1E03\n#define GL_DEPTH 0x1801\n#define GL_DEPTH_BUFFER_BIT 0x00000100\n#define GL_DEPTH_CLEAR_VALUE 0x0B73\n#define GL_DEPTH_COMPONENT 0x1902\n#define GL_DEPTH_FUNC 0x0B74\n#define GL_DEPTH_RANGE 0x0B70\n#define GL_DEPTH_TEST 0x0B71\n#define GL_DEPTH_WRITEMASK 0x0B72\n#define GL_DITHER 0x0BD0\n#define GL_DONT_CARE 0x1100\n#define GL_DOUBLE 0x140A\n#define GL_DOUBLEBUFFER 0x0C32\n#define GL_DRAW_BUFFER 0x0C01\n#define GL_DST_ALPHA 0x0304\n#define GL_DST_COLOR 0x0306\n#define GL_EQUAL 0x0202\n#define GL_EQUIV 0x1509\n#define GL_EXTENSIONS 0x1F03\n#define GL_FALSE 0\n#define GL_FASTEST 0x1101\n#define GL_FILL 0x1B02\n#define GL_FLOAT 0x1406\n#define GL_FRONT 0x0404\n#define GL_FRONT_AND_BACK 0x0408\n#define GL_FRONT_FACE 0x0B46\n#define GL_FRONT_LEFT 0x0400\n#define GL_FRONT_RIGHT 0x0401\n#define GL_GEQUAL 0x0206\n#define GL_GREATER 0x0204\n#define GL_GREEN 0x1904\n#define GL_INCR 0x1E02\n#define GL_INT 0x1404\n#define GL_INVALID_ENUM 0x0500\n#define GL_INVALID_OPERATION 0x0502\n#define GL_INVALID_VALUE 0x0501\n#define GL_INVERT 0x150A\n#define GL_KEEP 0x1E00\n#define GL_LEFT 0x0406\n#define GL_LEQUAL 0x0203\n#define GL_LESS 0x0201\n#define GL_LINE 0x1B01\n#define GL_LINEAR 0x2601\n#define GL_LINEAR_MIPMAP_LINEAR 0x2703\n#define GL_LINEAR_MIPMAP_NEAREST 0x2701\n#define GL_LINES 0x0001\n#define GL_LINE_LOOP 0x0002\n#define GL_LINE_SMOOTH 0x0B20\n#define GL_LINE_SMOOTH_HINT 0x0C52\n#define GL_LINE_STRIP 0x0003\n#define GL_LINE_WIDTH 0x0B21\n#define GL_LINE_WIDTH_GRANULARITY 0x0B23\n#define GL_LINE_WIDTH_RANGE 0x0B22\n#define GL_LOGIC_OP_MODE 0x0BF0\n#define GL_MAX_TEXTURE_SIZE 0x0D33\n#define GL_MAX_VIEWPORT_DIMS 0x0D3A\n#define GL_NAND 0x150E\n#define GL_NEAREST 0x2600\n#define GL_NEAREST_MIPMAP_LINEAR 0x2702\n#define GL_NEAREST_MIPMAP_NEAREST 0x2700\n#define GL_NEVER 0x0200\n#define GL_NICEST 0x1102\n#define GL_NONE 0\n#define GL_NOOP 0x1505\n#define GL_NOR 0x1508\n#define GL_NOTEQUAL 0x0205\n#define GL_NO_ERROR 0\n#define GL_ONE 1\n#define GL_ONE_MINUS_DST_ALPHA 0x0305\n#define GL_ONE_MINUS_DST_COLOR 0x0307\n#define GL_ONE_MINUS_SRC_ALPHA 0x0303\n#define GL_ONE_MINUS_SRC_COLOR 0x0301\n#define GL_OR 0x1507\n#define GL_OR_INVERTED 0x150D\n#define GL_OR_REVERSE 0x150B\n#define GL_OUT_OF_MEMORY 0x0505\n#define GL_PACK_ALIGNMENT 0x0D05\n#define GL_PACK_LSB_FIRST 0x0D01\n#define GL_PACK_ROW_LENGTH 0x0D02\n#define GL_PACK_SKIP_PIXELS 0x0D04\n#define GL_PACK_SKIP_ROWS 0x0D03\n#define GL_PACK_SWAP_BYTES 0x0D00\n#define GL_POINT 0x1B00\n#define GL_POINTS 0x0000\n#define GL_POINT_SIZE 0x0B11\n#define GL_POINT_SIZE_GRANULARITY 0x0B13\n#define GL_POINT_SIZE_RANGE 0x0B12\n#define GL_POLYGON_MODE 0x0B40\n#define GL_POLYGON_OFFSET_FACTOR 0x8038\n#define GL_POLYGON_OFFSET_FILL 0x8037\n#define GL_POLYGON_OFFSET_LINE 0x2A02\n#define GL_POLYGON_OFFSET_POINT 0x2A01\n#define GL_POLYGON_OFFSET_UNITS 0x2A00\n#define GL_POLYGON_SMOOTH 0x0B41\n#define GL_POLYGON_SMOOTH_HINT 0x0C53\n#define GL_PROXY_TEXTURE_1D 0x8063\n#define GL_PROXY_TEXTURE_2D 0x8064\n#define GL_QUADS 0x0007\n#define GL_R3_G3_B2 0x2A10\n#define GL_READ_BUFFER 0x0C02\n#define GL_RED 0x1903\n#define GL_RENDERER 0x1F01\n#define GL_REPEAT 0x2901\n#define GL_REPLACE 0x1E01\n#define GL_RGB 0x1907\n#define GL_RGB10 0x8052\n#define GL_RGB10_A2 0x8059\n#define GL_RGB12 0x8053\n#define GL_RGB16 0x8054\n#define GL_RGB4 0x804F\n#define GL_RGB5 0x8050\n#define GL_RGB5_A1 0x8057\n#define GL_RGB8 0x8051\n#define GL_RGBA 0x1908\n#define GL_RGBA12 0x805A\n#define GL_RGBA16 0x805B\n#define GL_RGBA2 0x8055\n#define GL_RGBA4 0x8056\n#define GL_RGBA8 0x8058\n#define GL_RIGHT 0x0407\n#define GL_SCISSOR_BOX 0x0C10\n#define GL_SCISSOR_TEST 0x0C11\n#define GL_SET 0x150F\n#define GL_SHORT 0x1402\n#define GL_SRC_ALPHA 0x0302\n#define GL_SRC_ALPHA_SATURATE 0x0308\n#define GL_SRC_COLOR 0x0300\n#define GL_STENCIL 0x1802\n#define GL_STENCIL_BUFFER_BIT 0x00000400\n#define GL_STENCIL_CLEAR_VALUE 0x0B91\n#define GL_STENCIL_FAIL 0x0B94\n#define GL_STENCIL_FUNC 0x0B92\n#define GL_STENCIL_INDEX 0x1901\n#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95\n#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96\n#define GL_STENCIL_REF 0x0B97\n#define GL_STENCIL_TEST 0x0B90\n#define GL_STENCIL_VALUE_MASK 0x0B93\n#define GL_STENCIL_WRITEMASK 0x0B98\n#define GL_STEREO 0x0C33\n#define GL_SUBPIXEL_BITS 0x0D50\n#define GL_TEXTURE 0x1702\n#define GL_TEXTURE_1D 0x0DE0\n#define GL_TEXTURE_2D 0x0DE1\n#define GL_TEXTURE_ALPHA_SIZE 0x805F\n#define GL_TEXTURE_BINDING_1D 0x8068\n#define GL_TEXTURE_BINDING_2D 0x8069\n#define GL_TEXTURE_BLUE_SIZE 0x805E\n#define GL_TEXTURE_BORDER_COLOR 0x1004\n#define GL_TEXTURE_GREEN_SIZE 0x805D\n#define GL_TEXTURE_HEIGHT 0x1001\n#define GL_TEXTURE_INTERNAL_FORMAT 0x1003\n#define GL_TEXTURE_MAG_FILTER 0x2800\n#define GL_TEXTURE_MIN_FILTER 0x2801\n#define GL_TEXTURE_RED_SIZE 0x805C\n#define GL_TEXTURE_WIDTH 0x1000\n#define GL_TEXTURE_WRAP_S 0x2802\n#define GL_TEXTURE_WRAP_T 0x2803\n#define GL_TRIANGLES 0x0004\n#define GL_TRIANGLE_FAN 0x0006\n#define GL_TRIANGLE_STRIP 0x0005\n#define GL_TRUE 1\n#define GL_UNPACK_ALIGNMENT 0x0CF5\n#define GL_UNPACK_LSB_FIRST 0x0CF1\n#define GL_UNPACK_ROW_LENGTH 0x0CF2\n#define GL_UNPACK_SKIP_PIXELS 0x0CF4\n#define GL_UNPACK_SKIP_ROWS 0x0CF3\n#define GL_UNPACK_SWAP_BYTES 0x0CF0\n#define GL_UNSIGNED_BYTE 0x1401\n#define GL_UNSIGNED_INT 0x1405\n#define GL_UNSIGNED_SHORT 0x1403\n#define GL_VENDOR 0x1F00\n#define GL_VERSION 0x1F02\n#define GL_VIEWPORT 0x0BA2\n#define GL_XOR 0x1506\n#define GL_ZERO 0\n\n#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E\n#define GL_BGR 0x80E0\n#define GL_BGRA 0x80E1\n#define GL_CLAMP_TO_EDGE 0x812F\n#define GL_MAX_3D_TEXTURE_SIZE 0x8073\n#define GL_MAX_ELEMENTS_INDICES 0x80E9\n#define GL_MAX_ELEMENTS_VERTICES 0x80E8\n#define GL_PACK_IMAGE_HEIGHT 0x806C\n#define GL_PACK_SKIP_IMAGES 0x806B\n#define GL_PROXY_TEXTURE_3D 0x8070\n#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23\n#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22\n#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13\n#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12\n#define GL_TEXTURE_3D 0x806F\n#define GL_TEXTURE_BASE_LEVEL 0x813C\n#define GL_TEXTURE_BINDING_3D 0x806A\n#define GL_TEXTURE_DEPTH 0x8071\n#define GL_TEXTURE_MAX_LEVEL 0x813D\n#define GL_TEXTURE_MAX_LOD 0x813B\n#define GL_TEXTURE_MIN_LOD 0x813A\n#define GL_TEXTURE_WRAP_R 0x8072\n#define GL_UNPACK_IMAGE_HEIGHT 0x806E\n#define GL_UNPACK_SKIP_IMAGES 0x806D\n#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362\n#define GL_UNSIGNED_BYTE_3_3_2 0x8032\n#define GL_UNSIGNED_INT_10_10_10_2 0x8036\n#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368\n#define GL_UNSIGNED_INT_8_8_8_8 0x8035\n#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367\n#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366\n#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033\n#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365\n#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034\n#define GL_UNSIGNED_SHORT_5_6_5 0x8363\n#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364\n\n#define GL_ACTIVE_TEXTURE 0x84E0\n#define GL_CLAMP_TO_BORDER 0x812D\n#define GL_COMPRESSED_RGB 0x84ED\n#define GL_COMPRESSED_RGBA 0x84EE\n#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C\n#define GL_MULTISAMPLE 0x809D\n#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2\n#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B\n#define GL_SAMPLES 0x80A9\n#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE 0x809F\n#define GL_SAMPLE_BUFFERS 0x80A8\n#define GL_SAMPLE_COVERAGE 0x80A0\n#define GL_SAMPLE_COVERAGE_INVERT 0x80AB\n#define GL_SAMPLE_COVERAGE_VALUE 0x80AA\n#define GL_TEXTURE0 0x84C0\n#define GL_TEXTURE1 0x84C1\n#define GL_TEXTURE10 0x84CA\n#define GL_TEXTURE11 0x84CB\n#define GL_TEXTURE12 0x84CC\n#define GL_TEXTURE13 0x84CD\n#define GL_TEXTURE14 0x84CE\n#define GL_TEXTURE15 0x84CF\n#define GL_TEXTURE16 0x84D0\n#define GL_TEXTURE17 0x84D1\n#define GL_TEXTURE18 0x84D2\n#define GL_TEXTURE19 0x84D3\n#define GL_TEXTURE2 0x84C2\n#define GL_TEXTURE20 0x84D4\n#define GL_TEXTURE21 0x84D5\n#define GL_TEXTURE22 0x84D6\n#define GL_TEXTURE23 0x84D7\n#define GL_TEXTURE24 0x84D8\n#define GL_TEXTURE25 0x84D9\n#define GL_TEXTURE26 0x84DA\n#define GL_TEXTURE27 0x84DB\n#define GL_TEXTURE28 0x84DC\n#define GL_TEXTURE29 0x84DD\n#define GL_TEXTURE3 0x84C3\n#define GL_TEXTURE30 0x84DE\n#define GL_TEXTURE31 0x84DF\n#define GL_TEXTURE4 0x84C4\n#define GL_TEXTURE5 0x84C5\n#define GL_TEXTURE6 0x84C6\n#define GL_TEXTURE7 0x84C7\n#define GL_TEXTURE8 0x84C8\n#define GL_TEXTURE9 0x84C9\n#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514\n#define GL_TEXTURE_COMPRESSED 0x86A1\n#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0\n#define GL_TEXTURE_COMPRESSION_HINT 0x84EF\n#define GL_TEXTURE_CUBE_MAP 0x8513\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519\n\n#define GL_BLEND_COLOR 0x8005\n#define GL_BLEND_DST_ALPHA 0x80CA\n#define GL_BLEND_DST_RGB 0x80C8\n#define GL_BLEND_EQUATION 0x8009\n#define GL_BLEND_SRC_ALPHA 0x80CB\n#define GL_BLEND_SRC_RGB 0x80C9\n#define GL_CONSTANT_ALPHA 0x8003\n#define GL_CONSTANT_COLOR 0x8001\n#define GL_DECR_WRAP 0x8508\n#define GL_DEPTH_COMPONENT16 0x81A5\n#define GL_DEPTH_COMPONENT24 0x81A6\n#define GL_DEPTH_COMPONENT32 0x81A7\n#define GL_FUNC_ADD 0x8006\n#define GL_FUNC_REVERSE_SUBTRACT 0x800B\n#define GL_FUNC_SUBTRACT 0x800A\n#define GL_INCR_WRAP 0x8507\n#define GL_MAX 0x8008\n#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD\n#define GL_MIN 0x8007\n#define GL_MIRRORED_REPEAT 0x8370\n#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004\n#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002\n#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128\n#define GL_TEXTURE_COMPARE_FUNC 0x884D\n#define GL_TEXTURE_COMPARE_MODE 0x884C\n#define GL_TEXTURE_DEPTH_SIZE 0x884A\n#define GL_TEXTURE_LOD_BIAS 0x8501\n\n#define GL_ARRAY_BUFFER 0x8892\n#define GL_ARRAY_BUFFER_BINDING 0x8894\n#define GL_BUFFER_ACCESS 0x88BB\n#define GL_BUFFER_MAPPED 0x88BC\n#define GL_BUFFER_MAP_POINTER 0x88BD\n#define GL_BUFFER_SIZE 0x8764\n#define GL_BUFFER_USAGE 0x8765\n#define GL_CURRENT_QUERY 0x8865\n#define GL_DYNAMIC_COPY 0x88EA\n#define GL_DYNAMIC_DRAW 0x88E8\n#define GL_DYNAMIC_READ 0x88E9\n#define GL_ELEMENT_ARRAY_BUFFER 0x8893\n#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895\n#define GL_QUERY_COUNTER_BITS 0x8864\n#define GL_QUERY_RESULT 0x8866\n#define GL_QUERY_RESULT_AVAILABLE 0x8867\n#define GL_READ_ONLY 0x88B8\n#define GL_READ_WRITE 0x88BA\n#define GL_SAMPLES_PASSED 0x8914\n#define GL_SRC1_ALPHA 0x8589\n#define GL_STATIC_COPY 0x88E6\n#define GL_STATIC_DRAW 0x88E4\n#define GL_STATIC_READ 0x88E5\n#define GL_STREAM_COPY 0x88E2\n#define GL_STREAM_DRAW 0x88E0\n#define GL_STREAM_READ 0x88E1\n#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F\n#define GL_WRITE_ONLY 0x88B9\n\n#define GL_ACTIVE_ATTRIBUTES 0x8B89\n#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A\n#define GL_ACTIVE_UNIFORMS 0x8B86\n#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87\n#define GL_ATTACHED_SHADERS 0x8B85\n#define GL_BLEND_EQUATION_ALPHA 0x883D\n#define GL_BLEND_EQUATION_RGB 0x8009\n#define GL_BOOL 0x8B56\n#define GL_BOOL_VEC2 0x8B57\n#define GL_BOOL_VEC3 0x8B58\n#define GL_BOOL_VEC4 0x8B59\n#define GL_COMPILE_STATUS 0x8B81\n#define GL_CURRENT_PROGRAM 0x8B8D\n#define GL_CURRENT_VERTEX_ATTRIB 0x8626\n#define GL_DELETE_STATUS 0x8B80\n#define GL_DRAW_BUFFER0 0x8825\n#define GL_DRAW_BUFFER1 0x8826\n#define GL_DRAW_BUFFER10 0x882F\n#define GL_DRAW_BUFFER11 0x8830\n#define GL_DRAW_BUFFER12 0x8831\n#define GL_DRAW_BUFFER13 0x8832\n#define GL_DRAW_BUFFER14 0x8833\n#define GL_DRAW_BUFFER15 0x8834\n#define GL_DRAW_BUFFER2 0x8827\n#define GL_DRAW_BUFFER3 0x8828\n#define GL_DRAW_BUFFER4 0x8829\n#define GL_DRAW_BUFFER5 0x882A\n#define GL_DRAW_BUFFER6 0x882B\n#define GL_DRAW_BUFFER7 0x882C\n#define GL_DRAW_BUFFER8 0x882D\n#define GL_DRAW_BUFFER9 0x882E\n#define GL_FLOAT_MAT2 0x8B5A\n#define GL_FLOAT_MAT3 0x8B5B\n#define GL_FLOAT_MAT4 0x8B5C\n#define GL_FLOAT_VEC2 0x8B50\n#define GL_FLOAT_VEC3 0x8B51\n#define GL_FLOAT_VEC4 0x8B52\n#define GL_FRAGMENT_SHADER 0x8B30\n#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B\n#define GL_INFO_LOG_LENGTH 0x8B84\n#define GL_INT_VEC2 0x8B53\n#define GL_INT_VEC3 0x8B54\n#define GL_INT_VEC4 0x8B55\n#define GL_LINK_STATUS 0x8B82\n#define GL_LOWER_LEFT 0x8CA1\n#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D\n#define GL_MAX_DRAW_BUFFERS 0x8824\n#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49\n#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872\n#define GL_MAX_VARYING_FLOATS 0x8B4B\n#define GL_MAX_VERTEX_ATTRIBS 0x8869\n#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C\n#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A\n#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0\n#define GL_SAMPLER_1D 0x8B5D\n#define GL_SAMPLER_1D_SHADOW 0x8B61\n#define GL_SAMPLER_2D 0x8B5E\n#define GL_SAMPLER_2D_SHADOW 0x8B62\n#define GL_SAMPLER_3D 0x8B5F\n#define GL_SAMPLER_CUBE 0x8B60\n#define GL_SHADER_SOURCE_LENGTH 0x8B88\n#define GL_SHADER_TYPE 0x8B4F\n#define GL_SHADING_LANGUAGE_VERSION 0x8B8C\n#define GL_STENCIL_BACK_FAIL 0x8801\n#define GL_STENCIL_BACK_FUNC 0x8800\n#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802\n#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803\n#define GL_STENCIL_BACK_REF 0x8CA3\n#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4\n#define GL_STENCIL_BACK_WRITEMASK 0x8CA5\n#define GL_UPPER_LEFT 0x8CA2\n#define GL_VALIDATE_STATUS 0x8B83\n#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622\n#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A\n#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645\n#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623\n#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624\n#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625\n#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642\n#define GL_VERTEX_SHADER 0x8B31\n\n#define GL_COMPRESSED_SRGB 0x8C48\n#define GL_COMPRESSED_SRGB_ALPHA 0x8C49\n#define GL_FLOAT_MAT2x3 0x8B65\n#define GL_FLOAT_MAT2x4 0x8B66\n#define GL_FLOAT_MAT3x2 0x8B67\n#define GL_FLOAT_MAT3x4 0x8B68\n#define GL_FLOAT_MAT4x2 0x8B69\n#define GL_FLOAT_MAT4x3 0x8B6A\n#define GL_PIXEL_PACK_BUFFER 0x88EB\n#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED\n#define GL_PIXEL_UNPACK_BUFFER 0x88EC\n#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF\n#define GL_SRGB 0x8C40\n#define GL_SRGB8 0x8C41\n#define GL_SRGB8_ALPHA8 0x8C43\n#define GL_SRGB_ALPHA 0x8C42\n\n#define GL_BGRA_INTEGER 0x8D9B\n#define GL_BGR_INTEGER 0x8D9A\n#define GL_BLUE_INTEGER 0x8D96\n#define GL_BUFFER_ACCESS_FLAGS 0x911F\n#define GL_BUFFER_MAP_LENGTH 0x9120\n#define GL_BUFFER_MAP_OFFSET 0x9121\n#define GL_CLAMP_READ_COLOR 0x891C\n#define GL_CLIP_DISTANCE0 0x3000\n#define GL_CLIP_DISTANCE1 0x3001\n#define GL_CLIP_DISTANCE2 0x3002\n#define GL_CLIP_DISTANCE3 0x3003\n#define GL_CLIP_DISTANCE4 0x3004\n#define GL_CLIP_DISTANCE5 0x3005\n#define GL_CLIP_DISTANCE6 0x3006\n#define GL_CLIP_DISTANCE7 0x3007\n#define GL_COLOR_ATTACHMENT0 0x8CE0\n#define GL_COLOR_ATTACHMENT1 0x8CE1\n#define GL_COLOR_ATTACHMENT10 0x8CEA\n#define GL_COLOR_ATTACHMENT11 0x8CEB\n#define GL_COLOR_ATTACHMENT12 0x8CEC\n#define GL_COLOR_ATTACHMENT13 0x8CED\n#define GL_COLOR_ATTACHMENT14 0x8CEE\n#define GL_COLOR_ATTACHMENT15 0x8CEF\n#define GL_COLOR_ATTACHMENT2 0x8CE2\n#define GL_COLOR_ATTACHMENT3 0x8CE3\n#define GL_COLOR_ATTACHMENT4 0x8CE4\n#define GL_COLOR_ATTACHMENT5 0x8CE5\n#define GL_COLOR_ATTACHMENT6 0x8CE6\n#define GL_COLOR_ATTACHMENT7 0x8CE7\n#define GL_COLOR_ATTACHMENT8 0x8CE8\n#define GL_COLOR_ATTACHMENT9 0x8CE9\n#define GL_COMPARE_REF_TO_TEXTURE 0x884E\n#define GL_COMPRESSED_RED 0x8225\n#define GL_COMPRESSED_RED_RGTC1 0x8DBB\n#define GL_COMPRESSED_RG 0x8226\n#define GL_COMPRESSED_RG_RGTC2 0x8DBD\n#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC\n#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE\n#define GL_CONTEXT_FLAGS 0x821E\n#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001\n#define GL_DEPTH24_STENCIL8 0x88F0\n#define GL_DEPTH32F_STENCIL8 0x8CAD\n#define GL_DEPTH_ATTACHMENT 0x8D00\n#define GL_DEPTH_COMPONENT32F 0x8CAC\n#define GL_DEPTH_STENCIL 0x84F9\n#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A\n#define GL_DRAW_FRAMEBUFFER 0x8CA9\n#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6\n#define GL_FIXED_ONLY 0x891D\n#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD\n#define GL_FRAMEBUFFER 0x8D40\n#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215\n#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214\n#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210\n#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211\n#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216\n#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0\n#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212\n#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2\n#define GL_FRAMEBUFFER_BINDING 0x8CA6\n#define GL_FRAMEBUFFER_COMPLETE 0x8CD5\n#define GL_FRAMEBUFFER_DEFAULT 0x8218\n#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6\n#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB\n#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56\n#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC\n#define GL_FRAMEBUFFER_SRGB 0x8DB9\n#define GL_FRAMEBUFFER_UNDEFINED 0x8219\n#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD\n#define GL_GREEN_INTEGER 0x8D95\n#define GL_HALF_FLOAT 0x140B\n#define GL_INTERLEAVED_ATTRIBS 0x8C8C\n#define GL_INT_SAMPLER_1D 0x8DC9\n#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE\n#define GL_INT_SAMPLER_2D 0x8DCA\n#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF\n#define GL_INT_SAMPLER_3D 0x8DCB\n#define GL_INT_SAMPLER_CUBE 0x8DCC\n#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506\n#define GL_MAJOR_VERSION 0x821B\n#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010\n#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008\n#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004\n#define GL_MAP_READ_BIT 0x0001\n#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020\n#define GL_MAP_WRITE_BIT 0x0002\n#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF\n#define GL_MAX_CLIP_DISTANCES 0x0D32\n#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF\n#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905\n#define GL_MAX_RENDERBUFFER_SIZE 0x84E8\n#define GL_MAX_SAMPLES 0x8D57\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80\n#define GL_MAX_VARYING_COMPONENTS 0x8B4B\n#define GL_MINOR_VERSION 0x821C\n#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904\n#define GL_NUM_EXTENSIONS 0x821D\n#define GL_PRIMITIVES_GENERATED 0x8C87\n#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19\n#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B\n#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16\n#define GL_QUERY_BY_REGION_WAIT 0x8E15\n#define GL_QUERY_NO_WAIT 0x8E14\n#define GL_QUERY_WAIT 0x8E13\n#define GL_R11F_G11F_B10F 0x8C3A\n#define GL_R16 0x822A\n#define GL_R16F 0x822D\n#define GL_R16I 0x8233\n#define GL_R16UI 0x8234\n#define GL_R32F 0x822E\n#define GL_R32I 0x8235\n#define GL_R32UI 0x8236\n#define GL_R8 0x8229\n#define GL_R8I 0x8231\n#define GL_R8UI 0x8232\n#define GL_RASTERIZER_DISCARD 0x8C89\n#define GL_READ_FRAMEBUFFER 0x8CA8\n#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA\n#define GL_RED_INTEGER 0x8D94\n#define GL_RENDERBUFFER 0x8D41\n#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53\n#define GL_RENDERBUFFER_BINDING 0x8CA7\n#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52\n#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54\n#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51\n#define GL_RENDERBUFFER_HEIGHT 0x8D43\n#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44\n#define GL_RENDERBUFFER_RED_SIZE 0x8D50\n#define GL_RENDERBUFFER_SAMPLES 0x8CAB\n#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55\n#define GL_RENDERBUFFER_WIDTH 0x8D42\n#define GL_RG 0x8227\n#define GL_RG16 0x822C\n#define GL_RG16F 0x822F\n#define GL_RG16I 0x8239\n#define GL_RG16UI 0x823A\n#define GL_RG32F 0x8230\n#define GL_RG32I 0x823B\n#define GL_RG32UI 0x823C\n#define GL_RG8 0x822B\n#define GL_RG8I 0x8237\n#define GL_RG8UI 0x8238\n#define GL_RGB16F 0x881B\n#define GL_RGB16I 0x8D89\n#define GL_RGB16UI 0x8D77\n#define GL_RGB32F 0x8815\n#define GL_RGB32I 0x8D83\n#define GL_RGB32UI 0x8D71\n#define GL_RGB8I 0x8D8F\n#define GL_RGB8UI 0x8D7D\n#define GL_RGB9_E5 0x8C3D\n#define GL_RGBA16F 0x881A\n#define GL_RGBA16I 0x8D88\n#define GL_RGBA16UI 0x8D76\n#define GL_RGBA32F 0x8814\n#define GL_RGBA32I 0x8D82\n#define GL_RGBA32UI 0x8D70\n#define GL_RGBA8I 0x8D8E\n#define GL_RGBA8UI 0x8D7C\n#define GL_RGBA_INTEGER 0x8D99\n#define GL_RGB_INTEGER 0x8D98\n#define GL_RG_INTEGER 0x8228\n#define GL_SAMPLER_1D_ARRAY 0x8DC0\n#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3\n#define GL_SAMPLER_2D_ARRAY 0x8DC1\n#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4\n#define GL_SAMPLER_CUBE_SHADOW 0x8DC5\n#define GL_SEPARATE_ATTRIBS 0x8C8D\n#define GL_STENCIL_ATTACHMENT 0x8D20\n#define GL_STENCIL_INDEX1 0x8D46\n#define GL_STENCIL_INDEX16 0x8D49\n#define GL_STENCIL_INDEX4 0x8D47\n#define GL_STENCIL_INDEX8 0x8D48\n#define GL_TEXTURE_1D_ARRAY 0x8C18\n#define GL_TEXTURE_2D_ARRAY 0x8C1A\n#define GL_TEXTURE_ALPHA_TYPE 0x8C13\n#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C\n#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D\n#define GL_TEXTURE_BLUE_TYPE 0x8C12\n#define GL_TEXTURE_DEPTH_TYPE 0x8C16\n#define GL_TEXTURE_GREEN_TYPE 0x8C11\n#define GL_TEXTURE_RED_TYPE 0x8C10\n#define GL_TEXTURE_SHARED_SIZE 0x8C3F\n#define GL_TEXTURE_STENCIL_SIZE 0x88F1\n#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88\n#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83\n#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76\n#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B\n#define GL_UNSIGNED_INT_24_8 0x84FA\n#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E\n#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1\n#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6\n#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2\n#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7\n#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3\n#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4\n#define GL_UNSIGNED_INT_VEC2 0x8DC6\n#define GL_UNSIGNED_INT_VEC3 0x8DC7\n#define GL_UNSIGNED_INT_VEC4 0x8DC8\n#define GL_UNSIGNED_NORMALIZED 0x8C17\n#define GL_VERTEX_ARRAY_BINDING 0x85B5\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD\n\n#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36\n#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35\n#define GL_COPY_READ_BUFFER 0x8F36\n#define GL_COPY_WRITE_BUFFER 0x8F37\n#define GL_INT_SAMPLER_2D_RECT 0x8DCD\n#define GL_INT_SAMPLER_BUFFER 0x8DD0\n#define GL_INVALID_INDEX 0xFFFFFFFF\n#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33\n#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E\n#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31\n#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8\n#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B\n#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30\n#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F\n#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B\n#define GL_PRIMITIVE_RESTART 0x8F9D\n#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E\n#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7\n#define GL_R16_SNORM 0x8F98\n#define GL_R8_SNORM 0x8F94\n#define GL_RG16_SNORM 0x8F99\n#define GL_RG8_SNORM 0x8F95\n#define GL_RGB16_SNORM 0x8F9A\n#define GL_RGB8_SNORM 0x8F96\n#define GL_RGBA16_SNORM 0x8F9B\n#define GL_RGBA8_SNORM 0x8F97\n#define GL_SAMPLER_2D_RECT 0x8B63\n#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64\n#define GL_SAMPLER_BUFFER 0x8DC2\n#define GL_SIGNED_NORMALIZED 0x8F9C\n#define GL_TEXTURE_BINDING_BUFFER 0x8C2C\n#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6\n#define GL_TEXTURE_BUFFER 0x8C2A\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D\n#define GL_TEXTURE_RECTANGLE 0x84F5\n#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43\n#define GL_UNIFORM_BLOCK_BINDING 0x8A3F\n#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40\n#define GL_UNIFORM_BLOCK_INDEX 0x8A3A\n#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44\n#define GL_UNIFORM_BUFFER 0x8A11\n#define GL_UNIFORM_BUFFER_BINDING 0x8A28\n#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34\n#define GL_UNIFORM_BUFFER_SIZE 0x8A2A\n#define GL_UNIFORM_BUFFER_START 0x8A29\n#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E\n#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D\n#define GL_UNIFORM_NAME_LENGTH 0x8A39\n#define GL_UNIFORM_OFFSET 0x8A3B\n#define GL_UNIFORM_SIZE 0x8A38\n#define GL_UNIFORM_TYPE 0x8A37\n#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8\n\n#define GL_ALREADY_SIGNALED 0x911A\n#define GL_CONDITION_SATISFIED 0x911C\n#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002\n#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001\n#define GL_CONTEXT_PROFILE_MASK 0x9126\n#define GL_DEPTH_CLAMP 0x864F\n#define GL_FIRST_VERTEX_CONVENTION 0x8E4D\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8\n#define GL_GEOMETRY_INPUT_TYPE 0x8917\n#define GL_GEOMETRY_OUTPUT_TYPE 0x8918\n#define GL_GEOMETRY_SHADER 0x8DD9\n#define GL_GEOMETRY_VERTICES_OUT 0x8916\n#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109\n#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C\n#define GL_LAST_VERTEX_CONVENTION 0x8E4E\n#define GL_LINES_ADJACENCY 0x000A\n#define GL_LINE_STRIP_ADJACENCY 0x000B\n#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E\n#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F\n#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125\n#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123\n#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF\n#define GL_MAX_INTEGER_SAMPLES 0x9110\n#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59\n#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111\n#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122\n#define GL_OBJECT_TYPE 0x9112\n#define GL_PROGRAM_POINT_SIZE 0x8642\n#define GL_PROVOKING_VERTEX 0x8E4F\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103\n#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C\n#define GL_SAMPLER_2D_MULTISAMPLE 0x9108\n#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B\n#define GL_SAMPLE_MASK 0x8E51\n#define GL_SAMPLE_MASK_VALUE 0x8E52\n#define GL_SAMPLE_POSITION 0x8E50\n#define GL_SIGNALED 0x9119\n#define GL_SYNC_CONDITION 0x9113\n#define GL_SYNC_FENCE 0x9116\n#define GL_SYNC_FLAGS 0x9115\n#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001\n#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117\n#define GL_SYNC_STATUS 0x9114\n#define GL_TEXTURE_2D_MULTISAMPLE 0x9100\n#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105\n#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F\n#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107\n#define GL_TEXTURE_SAMPLES 0x9106\n#define GL_TIMEOUT_EXPIRED 0x911B\n#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF\n#define GL_TRIANGLES_ADJACENCY 0x000C\n#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D\n#define GL_UNSIGNALED 0x9118\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D\n#define GL_WAIT_FAILED 0x911D\n\n#define GL_ANY_SAMPLES_PASSED 0x8C2F\n#define GL_INT_2_10_10_10_REV 0x8D9F\n#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC\n#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB\n#define GL_ONE_MINUS_SRC1_COLOR 0x88FA\n#define GL_RGB10_A2UI 0x906F\n#define GL_SAMPLER_BINDING 0x8919\n#define GL_SRC1_COLOR 0x88F9\n#define GL_TEXTURE_SWIZZLE_A 0x8E45\n#define GL_TEXTURE_SWIZZLE_B 0x8E44\n#define GL_TEXTURE_SWIZZLE_G 0x8E43\n#define GL_TEXTURE_SWIZZLE_R 0x8E42\n#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46\n#define GL_TIMESTAMP 0x8E28\n#define GL_TIME_ELAPSED 0x88BF\n#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE\n\n#define GL_ACTIVE_SUBROUTINES 0x8DE5\n#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48\n#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6\n#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47\n#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49\n#define GL_COMPATIBLE_SUBROUTINES 0x8E4B\n#define GL_DOUBLE_MAT2 0x8F46\n#define GL_DOUBLE_MAT2x3 0x8F49\n#define GL_DOUBLE_MAT2x4 0x8F4A\n#define GL_DOUBLE_MAT3 0x8F47\n#define GL_DOUBLE_MAT3x2 0x8F4B\n#define GL_DOUBLE_MAT3x4 0x8F4C\n#define GL_DOUBLE_MAT4 0x8F48\n#define GL_DOUBLE_MAT4x2 0x8F4D\n#define GL_DOUBLE_MAT4x3 0x8F4E\n#define GL_DOUBLE_VEC2 0x8FFC\n#define GL_DOUBLE_VEC3 0x8FFD\n#define GL_DOUBLE_VEC4 0x8FFE\n#define GL_DRAW_INDIRECT_BUFFER 0x8F3F\n#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43\n#define GL_FRACTIONAL_EVEN 0x8E7C\n#define GL_FRACTIONAL_ODD 0x8E7B\n#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D\n#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F\n#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E\n#define GL_ISOLINES 0x8E7A\n#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E\n#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F\n#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C\n#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A\n#define GL_MAX_PATCH_VERTICES 0x8E7D\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F\n#define GL_MAX_SUBROUTINES 0x8DE7\n#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8\n#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C\n#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83\n#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81\n#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85\n#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89\n#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F\n#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D\n#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86\n#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82\n#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A\n#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80\n#define GL_MAX_TESS_GEN_LEVEL 0x8E7E\n#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84\n#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70\n#define GL_MAX_VERTEX_STREAMS 0x8E71\n#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B\n#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E\n#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37\n#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A\n#define GL_PATCHES 0x000E\n#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73\n#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74\n#define GL_PATCH_VERTICES 0x8E72\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B\n#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C\n#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D\n#define GL_SAMPLE_SHADING 0x8C36\n#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75\n#define GL_TESS_CONTROL_SHADER 0x8E88\n#define GL_TESS_EVALUATION_SHADER 0x8E87\n#define GL_TESS_GEN_MODE 0x8E76\n#define GL_TESS_GEN_POINT_MODE 0x8E79\n#define GL_TESS_GEN_SPACING 0x8E77\n#define GL_TESS_GEN_VERTEX_ORDER 0x8E78\n#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A\n#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009\n#define GL_TRANSFORM_FEEDBACK 0x8E22\n#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25\n#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24\n#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1\n#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum);\n#define glBlendFunc _ptrc_glBlendFunc\nextern void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield);\n#define glClear _ptrc_glClear\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat);\n#define glClearColor _ptrc_glClearColor\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble);\n#define glClearDepth _ptrc_glClearDepth\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint);\n#define glClearStencil _ptrc_glClearStencil\nextern void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean);\n#define glColorMask _ptrc_glColorMask\nextern void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum);\n#define glCullFace _ptrc_glCullFace\nextern void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum);\n#define glDepthFunc _ptrc_glDepthFunc\nextern void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean);\n#define glDepthMask _ptrc_glDepthMask\nextern void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble, GLdouble);\n#define glDepthRange _ptrc_glDepthRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum);\n#define glDisable _ptrc_glDisable\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum);\n#define glDrawBuffer _ptrc_glDrawBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum);\n#define glEnable _ptrc_glEnable\nextern void (CODEGEN_FUNCPTR *_ptrc_glFinish)();\n#define glFinish _ptrc_glFinish\nextern void (CODEGEN_FUNCPTR *_ptrc_glFlush)();\n#define glFlush _ptrc_glFlush\nextern void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum);\n#define glFrontFace _ptrc_glFrontFace\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *);\n#define glGetBooleanv _ptrc_glGetBooleanv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *);\n#define glGetDoublev _ptrc_glGetDoublev\nextern GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)();\n#define glGetError _ptrc_glGetError\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *);\n#define glGetFloatv _ptrc_glGetFloatv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *);\n#define glGetIntegerv _ptrc_glGetIntegerv\nextern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum);\n#define glGetString _ptrc_glGetString\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *);\n#define glGetTexImage _ptrc_glGetTexImage\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *);\n#define glGetTexLevelParameterfv _ptrc_glGetTexLevelParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *);\n#define glGetTexLevelParameteriv _ptrc_glGetTexLevelParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum, GLenum, GLfloat *);\n#define glGetTexParameterfv _ptrc_glGetTexParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint *);\n#define glGetTexParameteriv _ptrc_glGetTexParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum);\n#define glHint _ptrc_glHint\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum);\n#define glIsEnabled _ptrc_glIsEnabled\nextern void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat);\n#define glLineWidth _ptrc_glLineWidth\nextern void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum);\n#define glLogicOp _ptrc_glLogicOp\nextern void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat);\n#define glPixelStoref _ptrc_glPixelStoref\nextern void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint);\n#define glPixelStorei _ptrc_glPixelStorei\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat);\n#define glPointSize _ptrc_glPointSize\nextern void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum);\n#define glPolygonMode _ptrc_glPolygonMode\nextern void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum);\n#define glReadBuffer _ptrc_glReadBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);\n#define glReadPixels _ptrc_glReadPixels\nextern void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei);\n#define glScissor _ptrc_glScissor\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint);\n#define glStencilFunc _ptrc_glStencilFunc\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint);\n#define glStencilMask _ptrc_glStencilMask\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum);\n#define glStencilOp _ptrc_glStencilOp\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *);\n#define glTexImage1D _ptrc_glTexImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);\n#define glTexImage2D _ptrc_glTexImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum, GLenum, GLfloat);\n#define glTexParameterf _ptrc_glTexParameterf\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum, GLenum, const GLfloat *);\n#define glTexParameterfv _ptrc_glTexParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint);\n#define glTexParameteri _ptrc_glTexParameteri\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *);\n#define glTexParameteriv _ptrc_glTexParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei);\n#define glViewport _ptrc_glViewport\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint);\n#define glBindTexture _ptrc_glBindTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);\n#define glCopyTexImage1D _ptrc_glCopyTexImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);\n#define glCopyTexImage2D _ptrc_glCopyTexImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei);\n#define glCopyTexSubImage1D _ptrc_glCopyTexSubImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);\n#define glCopyTexSubImage2D _ptrc_glCopyTexSubImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *);\n#define glDeleteTextures _ptrc_glDeleteTextures\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei);\n#define glDrawArrays _ptrc_glDrawArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *);\n#define glDrawElements _ptrc_glDrawElements\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *);\n#define glGenTextures _ptrc_glGenTextures\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint);\n#define glIsTexture _ptrc_glIsTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat);\n#define glPolygonOffset _ptrc_glPolygonOffset\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);\n#define glTexSubImage1D _ptrc_glTexSubImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);\n#define glTexSubImage2D _ptrc_glTexSubImage2D\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat);\n#define glBlendColor _ptrc_glBlendColor\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum);\n#define glBlendEquation _ptrc_glBlendEquation\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);\n#define glCopyTexSubImage3D _ptrc_glCopyTexSubImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);\n#define glDrawRangeElements _ptrc_glDrawRangeElements\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);\n#define glTexImage3D _ptrc_glTexImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);\n#define glTexSubImage3D _ptrc_glTexSubImage3D\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum);\n#define glActiveTexture _ptrc_glActiveTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);\n#define glCompressedTexImage1D _ptrc_glCompressedTexImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);\n#define glCompressedTexImage2D _ptrc_glCompressedTexImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);\n#define glCompressedTexImage3D _ptrc_glCompressedTexImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);\n#define glCompressedTexSubImage1D _ptrc_glCompressedTexSubImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);\n#define glCompressedTexSubImage2D _ptrc_glCompressedTexSubImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);\n#define glCompressedTexSubImage3D _ptrc_glCompressedTexSubImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *);\n#define glGetCompressedTexImage _ptrc_glGetCompressedTexImage\nextern void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean);\n#define glSampleCoverage _ptrc_glSampleCoverage\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum);\n#define glBlendFuncSeparate _ptrc_glBlendFuncSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei);\n#define glMultiDrawArrays _ptrc_glMultiDrawArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei);\n#define glMultiDrawElements _ptrc_glMultiDrawElements\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum, GLfloat);\n#define glPointParameterf _ptrc_glPointParameterf\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum, const GLfloat *);\n#define glPointParameterfv _ptrc_glPointParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint);\n#define glPointParameteri _ptrc_glPointParameteri\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *);\n#define glPointParameteriv _ptrc_glPointParameteriv\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint);\n#define glBeginQuery _ptrc_glBeginQuery\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum, GLuint);\n#define glBindBuffer _ptrc_glBindBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum);\n#define glBufferData _ptrc_glBufferData\nextern void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid *);\n#define glBufferSubData _ptrc_glBufferSubData\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei, const GLuint *);\n#define glDeleteBuffers _ptrc_glDeleteBuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei, const GLuint *);\n#define glDeleteQueries _ptrc_glDeleteQueries\nextern void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum);\n#define glEndQuery _ptrc_glEndQuery\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei, GLuint *);\n#define glGenBuffers _ptrc_glGenBuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei, GLuint *);\n#define glGenQueries _ptrc_glGenQueries\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum, GLenum, GLint *);\n#define glGetBufferParameteriv _ptrc_glGetBufferParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum, GLenum, GLvoid **);\n#define glGetBufferPointerv _ptrc_glGetBufferPointerv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum, GLintptr, GLsizeiptr, GLvoid *);\n#define glGetBufferSubData _ptrc_glGetBufferSubData\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint, GLenum, GLint *);\n#define glGetQueryObjectiv _ptrc_glGetQueryObjectiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint, GLenum, GLuint *);\n#define glGetQueryObjectuiv _ptrc_glGetQueryObjectuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum, GLenum, GLint *);\n#define glGetQueryiv _ptrc_glGetQueryiv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint);\n#define glIsBuffer _ptrc_glIsBuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint);\n#define glIsQuery _ptrc_glIsQuery\nextern void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum, GLenum);\n#define glMapBuffer _ptrc_glMapBuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum);\n#define glUnmapBuffer _ptrc_glUnmapBuffer\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint, GLuint);\n#define glAttachShader _ptrc_glAttachShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint, GLuint, const GLchar *);\n#define glBindAttribLocation _ptrc_glBindAttribLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum, GLenum);\n#define glBlendEquationSeparate _ptrc_glBlendEquationSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint);\n#define glCompileShader _ptrc_glCompileShader\nextern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)();\n#define glCreateProgram _ptrc_glCreateProgram\nextern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum);\n#define glCreateShader _ptrc_glCreateShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint);\n#define glDeleteProgram _ptrc_glDeleteProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint);\n#define glDeleteShader _ptrc_glDeleteShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint, GLuint);\n#define glDetachShader _ptrc_glDetachShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint);\n#define glDisableVertexAttribArray _ptrc_glDisableVertexAttribArray\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei, const GLenum *);\n#define glDrawBuffers _ptrc_glDrawBuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint);\n#define glEnableVertexAttribArray _ptrc_glEnableVertexAttribArray\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);\n#define glGetActiveAttrib _ptrc_glGetActiveAttrib\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);\n#define glGetActiveUniform _ptrc_glGetActiveUniform\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *);\n#define glGetAttachedShaders _ptrc_glGetAttachedShaders\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint, const GLchar *);\n#define glGetAttribLocation _ptrc_glGetAttribLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetProgramInfoLog _ptrc_glGetProgramInfoLog\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint, GLenum, GLint *);\n#define glGetProgramiv _ptrc_glGetProgramiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetShaderInfoLog _ptrc_glGetShaderInfoLog\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetShaderSource _ptrc_glGetShaderSource\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint, GLenum, GLint *);\n#define glGetShaderiv _ptrc_glGetShaderiv\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint, const GLchar *);\n#define glGetUniformLocation _ptrc_glGetUniformLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint, GLint, GLfloat *);\n#define glGetUniformfv _ptrc_glGetUniformfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint, GLint, GLint *);\n#define glGetUniformiv _ptrc_glGetUniformiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint, GLenum, GLvoid **);\n#define glGetVertexAttribPointerv _ptrc_glGetVertexAttribPointerv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint, GLenum, GLdouble *);\n#define glGetVertexAttribdv _ptrc_glGetVertexAttribdv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint, GLenum, GLfloat *);\n#define glGetVertexAttribfv _ptrc_glGetVertexAttribfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint, GLenum, GLint *);\n#define glGetVertexAttribiv _ptrc_glGetVertexAttribiv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint);\n#define glIsProgram _ptrc_glIsProgram\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint);\n#define glIsShader _ptrc_glIsShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint);\n#define glLinkProgram _ptrc_glLinkProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint, GLsizei, const GLchar *const*, const GLint *);\n#define glShaderSource _ptrc_glShaderSource\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint);\n#define glStencilFuncSeparate _ptrc_glStencilFuncSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum, GLuint);\n#define glStencilMaskSeparate _ptrc_glStencilMaskSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum);\n#define glStencilOpSeparate _ptrc_glStencilOpSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint, GLfloat);\n#define glUniform1f _ptrc_glUniform1f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint, GLsizei, const GLfloat *);\n#define glUniform1fv _ptrc_glUniform1fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint, GLint);\n#define glUniform1i _ptrc_glUniform1i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint, GLsizei, const GLint *);\n#define glUniform1iv _ptrc_glUniform1iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint, GLfloat, GLfloat);\n#define glUniform2f _ptrc_glUniform2f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint, GLsizei, const GLfloat *);\n#define glUniform2fv _ptrc_glUniform2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint, GLint, GLint);\n#define glUniform2i _ptrc_glUniform2i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint, GLsizei, const GLint *);\n#define glUniform2iv _ptrc_glUniform2iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint, GLfloat, GLfloat, GLfloat);\n#define glUniform3f _ptrc_glUniform3f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint, GLsizei, const GLfloat *);\n#define glUniform3fv _ptrc_glUniform3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint, GLint, GLint, GLint);\n#define glUniform3i _ptrc_glUniform3i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint, GLsizei, const GLint *);\n#define glUniform3iv _ptrc_glUniform3iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);\n#define glUniform4f _ptrc_glUniform4f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint, GLsizei, const GLfloat *);\n#define glUniform4fv _ptrc_glUniform4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint, GLint, GLint, GLint, GLint);\n#define glUniform4i _ptrc_glUniform4i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint, GLsizei, const GLint *);\n#define glUniform4iv _ptrc_glUniform4iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix2fv _ptrc_glUniformMatrix2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix3fv _ptrc_glUniformMatrix3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix4fv _ptrc_glUniformMatrix4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint);\n#define glUseProgram _ptrc_glUseProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint);\n#define glValidateProgram _ptrc_glValidateProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint, GLdouble);\n#define glVertexAttrib1d _ptrc_glVertexAttrib1d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint, const GLdouble *);\n#define glVertexAttrib1dv _ptrc_glVertexAttrib1dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint, GLfloat);\n#define glVertexAttrib1f _ptrc_glVertexAttrib1f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint, const GLfloat *);\n#define glVertexAttrib1fv _ptrc_glVertexAttrib1fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint, GLshort);\n#define glVertexAttrib1s _ptrc_glVertexAttrib1s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint, const GLshort *);\n#define glVertexAttrib1sv _ptrc_glVertexAttrib1sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint, GLdouble, GLdouble);\n#define glVertexAttrib2d _ptrc_glVertexAttrib2d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint, const GLdouble *);\n#define glVertexAttrib2dv _ptrc_glVertexAttrib2dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint, GLfloat, GLfloat);\n#define glVertexAttrib2f _ptrc_glVertexAttrib2f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint, const GLfloat *);\n#define glVertexAttrib2fv _ptrc_glVertexAttrib2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint, GLshort, GLshort);\n#define glVertexAttrib2s _ptrc_glVertexAttrib2s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint, const GLshort *);\n#define glVertexAttrib2sv _ptrc_glVertexAttrib2sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint, GLdouble, GLdouble, GLdouble);\n#define glVertexAttrib3d _ptrc_glVertexAttrib3d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint, const GLdouble *);\n#define glVertexAttrib3dv _ptrc_glVertexAttrib3dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat);\n#define glVertexAttrib3f _ptrc_glVertexAttrib3f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint, const GLfloat *);\n#define glVertexAttrib3fv _ptrc_glVertexAttrib3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint, GLshort, GLshort, GLshort);\n#define glVertexAttrib3s _ptrc_glVertexAttrib3s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint, const GLshort *);\n#define glVertexAttrib3sv _ptrc_glVertexAttrib3sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint, const GLbyte *);\n#define glVertexAttrib4Nbv _ptrc_glVertexAttrib4Nbv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint, const GLint *);\n#define glVertexAttrib4Niv _ptrc_glVertexAttrib4Niv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint, const GLshort *);\n#define glVertexAttrib4Nsv _ptrc_glVertexAttrib4Nsv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte);\n#define glVertexAttrib4Nub _ptrc_glVertexAttrib4Nub\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint, const GLubyte *);\n#define glVertexAttrib4Nubv _ptrc_glVertexAttrib4Nubv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint, const GLuint *);\n#define glVertexAttrib4Nuiv _ptrc_glVertexAttrib4Nuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint, const GLushort *);\n#define glVertexAttrib4Nusv _ptrc_glVertexAttrib4Nusv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint, const GLbyte *);\n#define glVertexAttrib4bv _ptrc_glVertexAttrib4bv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble);\n#define glVertexAttrib4d _ptrc_glVertexAttrib4d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint, const GLdouble *);\n#define glVertexAttrib4dv _ptrc_glVertexAttrib4dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat);\n#define glVertexAttrib4f _ptrc_glVertexAttrib4f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint, const GLfloat *);\n#define glVertexAttrib4fv _ptrc_glVertexAttrib4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint, const GLint *);\n#define glVertexAttrib4iv _ptrc_glVertexAttrib4iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint, GLshort, GLshort, GLshort, GLshort);\n#define glVertexAttrib4s _ptrc_glVertexAttrib4s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint, const GLshort *);\n#define glVertexAttrib4sv _ptrc_glVertexAttrib4sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint, const GLubyte *);\n#define glVertexAttrib4ubv _ptrc_glVertexAttrib4ubv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint, const GLuint *);\n#define glVertexAttrib4uiv _ptrc_glVertexAttrib4uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint, const GLushort *);\n#define glVertexAttrib4usv _ptrc_glVertexAttrib4usv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);\n#define glVertexAttribPointer _ptrc_glVertexAttribPointer\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix2x3fv _ptrc_glUniformMatrix2x3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix2x4fv _ptrc_glUniformMatrix2x4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix3x2fv _ptrc_glUniformMatrix3x2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix3x4fv _ptrc_glUniformMatrix3x4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix4x2fv _ptrc_glUniformMatrix4x2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix4x3fv _ptrc_glUniformMatrix4x3fv\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint, GLenum);\n#define glBeginConditionalRender _ptrc_glBeginConditionalRender\nextern void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum);\n#define glBeginTransformFeedback _ptrc_glBeginTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum, GLuint, GLuint);\n#define glBindBufferBase _ptrc_glBindBufferBase\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr);\n#define glBindBufferRange _ptrc_glBindBufferRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint, GLuint, const GLchar *);\n#define glBindFragDataLocation _ptrc_glBindFragDataLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum, GLuint);\n#define glBindFramebuffer _ptrc_glBindFramebuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum, GLuint);\n#define glBindRenderbuffer _ptrc_glBindRenderbuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint);\n#define glBindVertexArray _ptrc_glBindVertexArray\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);\n#define glBlitFramebuffer _ptrc_glBlitFramebuffer\nextern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum);\n#define glCheckFramebufferStatus _ptrc_glCheckFramebufferStatus\nextern void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum, GLenum);\n#define glClampColor _ptrc_glClampColor\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum, GLint, GLfloat, GLint);\n#define glClearBufferfi _ptrc_glClearBufferfi\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum, GLint, const GLfloat *);\n#define glClearBufferfv _ptrc_glClearBufferfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum, GLint, const GLint *);\n#define glClearBufferiv _ptrc_glClearBufferiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum, GLint, const GLuint *);\n#define glClearBufferuiv _ptrc_glClearBufferuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean);\n#define glColorMaski _ptrc_glColorMaski\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei, const GLuint *);\n#define glDeleteFramebuffers _ptrc_glDeleteFramebuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei, const GLuint *);\n#define glDeleteRenderbuffers _ptrc_glDeleteRenderbuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei, const GLuint *);\n#define glDeleteVertexArrays _ptrc_glDeleteVertexArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum, GLuint);\n#define glDisablei _ptrc_glDisablei\nextern void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum, GLuint);\n#define glEnablei _ptrc_glEnablei\nextern void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)();\n#define glEndConditionalRender _ptrc_glEndConditionalRender\nextern void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)();\n#define glEndTransformFeedback _ptrc_glEndTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr);\n#define glFlushMappedBufferRange _ptrc_glFlushMappedBufferRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint);\n#define glFramebufferRenderbuffer _ptrc_glFramebufferRenderbuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, GLint);\n#define glFramebufferTexture1D _ptrc_glFramebufferTexture1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint);\n#define glFramebufferTexture2D _ptrc_glFramebufferTexture2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum, GLenum, GLenum, GLuint, GLint, GLint);\n#define glFramebufferTexture3D _ptrc_glFramebufferTexture3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint);\n#define glFramebufferTextureLayer _ptrc_glFramebufferTextureLayer\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei, GLuint *);\n#define glGenFramebuffers _ptrc_glGenFramebuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei, GLuint *);\n#define glGenRenderbuffers _ptrc_glGenRenderbuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei, GLuint *);\n#define glGenVertexArrays _ptrc_glGenVertexArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum);\n#define glGenerateMipmap _ptrc_glGenerateMipmap\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum, GLuint, GLboolean *);\n#define glGetBooleani_v _ptrc_glGetBooleani_v\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint, const GLchar *);\n#define glGetFragDataLocation _ptrc_glGetFragDataLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *);\n#define glGetFramebufferAttachmentParameteriv _ptrc_glGetFramebufferAttachmentParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum, GLuint, GLint *);\n#define glGetIntegeri_v _ptrc_glGetIntegeri_v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *);\n#define glGetRenderbufferParameteriv _ptrc_glGetRenderbufferParameteriv\nextern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum, GLuint);\n#define glGetStringi _ptrc_glGetStringi\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum, GLenum, GLint *);\n#define glGetTexParameterIiv _ptrc_glGetTexParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum, GLenum, GLuint *);\n#define glGetTexParameterIuiv _ptrc_glGetTexParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *);\n#define glGetTransformFeedbackVarying _ptrc_glGetTransformFeedbackVarying\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint, GLint, GLuint *);\n#define glGetUniformuiv _ptrc_glGetUniformuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint, GLenum, GLint *);\n#define glGetVertexAttribIiv _ptrc_glGetVertexAttribIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *);\n#define glGetVertexAttribIuiv _ptrc_glGetVertexAttribIuiv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum, GLuint);\n#define glIsEnabledi _ptrc_glIsEnabledi\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint);\n#define glIsFramebuffer _ptrc_glIsFramebuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint);\n#define glIsRenderbuffer _ptrc_glIsRenderbuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint);\n#define glIsVertexArray _ptrc_glIsVertexArray\nextern void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield);\n#define glMapBufferRange _ptrc_glMapBufferRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei);\n#define glRenderbufferStorage _ptrc_glRenderbufferStorage\nextern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei);\n#define glRenderbufferStorageMultisample _ptrc_glRenderbufferStorageMultisample\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum, GLenum, const GLint *);\n#define glTexParameterIiv _ptrc_glTexParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum, GLenum, const GLuint *);\n#define glTexParameterIuiv _ptrc_glTexParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar *const*, GLenum);\n#define glTransformFeedbackVaryings _ptrc_glTransformFeedbackVaryings\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint, GLuint);\n#define glUniform1ui _ptrc_glUniform1ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint, GLsizei, const GLuint *);\n#define glUniform1uiv _ptrc_glUniform1uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint, GLuint, GLuint);\n#define glUniform2ui _ptrc_glUniform2ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint, GLsizei, const GLuint *);\n#define glUniform2uiv _ptrc_glUniform2uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint, GLuint, GLuint, GLuint);\n#define glUniform3ui _ptrc_glUniform3ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint, GLsizei, const GLuint *);\n#define glUniform3uiv _ptrc_glUniform3uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint);\n#define glUniform4ui _ptrc_glUniform4ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint, GLsizei, const GLuint *);\n#define glUniform4uiv _ptrc_glUniform4uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint, GLint);\n#define glVertexAttribI1i _ptrc_glVertexAttribI1i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint, const GLint *);\n#define glVertexAttribI1iv _ptrc_glVertexAttribI1iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint, GLuint);\n#define glVertexAttribI1ui _ptrc_glVertexAttribI1ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint, const GLuint *);\n#define glVertexAttribI1uiv _ptrc_glVertexAttribI1uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint, GLint, GLint);\n#define glVertexAttribI2i _ptrc_glVertexAttribI2i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint, const GLint *);\n#define glVertexAttribI2iv _ptrc_glVertexAttribI2iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint, GLuint, GLuint);\n#define glVertexAttribI2ui _ptrc_glVertexAttribI2ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint, const GLuint *);\n#define glVertexAttribI2uiv _ptrc_glVertexAttribI2uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint, GLint, GLint, GLint);\n#define glVertexAttribI3i _ptrc_glVertexAttribI3i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint, const GLint *);\n#define glVertexAttribI3iv _ptrc_glVertexAttribI3iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint, GLuint, GLuint, GLuint);\n#define glVertexAttribI3ui _ptrc_glVertexAttribI3ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint, const GLuint *);\n#define glVertexAttribI3uiv _ptrc_glVertexAttribI3uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint, const GLbyte *);\n#define glVertexAttribI4bv _ptrc_glVertexAttribI4bv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint);\n#define glVertexAttribI4i _ptrc_glVertexAttribI4i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint, const GLint *);\n#define glVertexAttribI4iv _ptrc_glVertexAttribI4iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint, const GLshort *);\n#define glVertexAttribI4sv _ptrc_glVertexAttribI4sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint, const GLubyte *);\n#define glVertexAttribI4ubv _ptrc_glVertexAttribI4ubv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint);\n#define glVertexAttribI4ui _ptrc_glVertexAttribI4ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint, const GLuint *);\n#define glVertexAttribI4uiv _ptrc_glVertexAttribI4uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint, const GLushort *);\n#define glVertexAttribI4usv _ptrc_glVertexAttribI4usv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *);\n#define glVertexAttribIPointer _ptrc_glVertexAttribIPointer\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr);\n#define glCopyBufferSubData _ptrc_glCopyBufferSubData\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei);\n#define glDrawArraysInstanced _ptrc_glDrawArraysInstanced\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei);\n#define glDrawElementsInstanced _ptrc_glDrawElementsInstanced\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetActiveUniformBlockName _ptrc_glGetActiveUniformBlockName\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *);\n#define glGetActiveUniformBlockiv _ptrc_glGetActiveUniformBlockiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetActiveUniformName _ptrc_glGetActiveUniformName\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *);\n#define glGetActiveUniformsiv _ptrc_glGetActiveUniformsiv\nextern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint, const GLchar *);\n#define glGetUniformBlockIndex _ptrc_glGetUniformBlockIndex\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint, GLsizei, const GLchar *const*, GLuint *);\n#define glGetUniformIndices _ptrc_glGetUniformIndices\nextern void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint);\n#define glPrimitiveRestartIndex _ptrc_glPrimitiveRestartIndex\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum, GLenum, GLuint);\n#define glTexBuffer _ptrc_glTexBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint, GLuint, GLuint);\n#define glUniformBlockBinding _ptrc_glUniformBlockBinding\n\nextern GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync, GLbitfield, GLuint64);\n#define glClientWaitSync _ptrc_glClientWaitSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync);\n#define glDeleteSync _ptrc_glDeleteSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLint);\n#define glDrawElementsBaseVertex _ptrc_glDrawElementsBaseVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint);\n#define glDrawElementsInstancedBaseVertex _ptrc_glDrawElementsInstancedBaseVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint);\n#define glDrawRangeElementsBaseVertex _ptrc_glDrawRangeElementsBaseVertex\nextern GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum, GLbitfield);\n#define glFenceSync _ptrc_glFenceSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum, GLenum, GLuint, GLint);\n#define glFramebufferTexture _ptrc_glFramebufferTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *);\n#define glGetBufferParameteri64v _ptrc_glGetBufferParameteri64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum, GLuint, GLint64 *);\n#define glGetInteger64i_v _ptrc_glGetInteger64i_v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum, GLint64 *);\n#define glGetInteger64v _ptrc_glGetInteger64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum, GLuint, GLfloat *);\n#define glGetMultisamplefv _ptrc_glGetMultisamplefv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *);\n#define glGetSynciv _ptrc_glGetSynciv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync);\n#define glIsSync _ptrc_glIsSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *);\n#define glMultiDrawElementsBaseVertex _ptrc_glMultiDrawElementsBaseVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum);\n#define glProvokingVertex _ptrc_glProvokingVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint, GLbitfield);\n#define glSampleMaski _ptrc_glSampleMaski\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean);\n#define glTexImage2DMultisample _ptrc_glTexImage2DMultisample\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean);\n#define glTexImage3DMultisample _ptrc_glTexImage3DMultisample\nextern void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync, GLbitfield, GLuint64);\n#define glWaitSync _ptrc_glWaitSync\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint, GLuint, GLuint, const GLchar *);\n#define glBindFragDataLocationIndexed _ptrc_glBindFragDataLocationIndexed\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint, GLuint);\n#define glBindSampler _ptrc_glBindSampler\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei, const GLuint *);\n#define glDeleteSamplers _ptrc_glDeleteSamplers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei, GLuint *);\n#define glGenSamplers _ptrc_glGenSamplers\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint, const GLchar *);\n#define glGetFragDataIndex _ptrc_glGetFragDataIndex\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint, GLenum, GLint64 *);\n#define glGetQueryObjecti64v _ptrc_glGetQueryObjecti64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint, GLenum, GLuint64 *);\n#define glGetQueryObjectui64v _ptrc_glGetQueryObjectui64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint, GLenum, GLint *);\n#define glGetSamplerParameterIiv _ptrc_glGetSamplerParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint, GLenum, GLuint *);\n#define glGetSamplerParameterIuiv _ptrc_glGetSamplerParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *);\n#define glGetSamplerParameterfv _ptrc_glGetSamplerParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint, GLenum, GLint *);\n#define glGetSamplerParameteriv _ptrc_glGetSamplerParameteriv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint);\n#define glIsSampler _ptrc_glIsSampler\nextern void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint, GLenum);\n#define glQueryCounter _ptrc_glQueryCounter\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint, GLenum, const GLint *);\n#define glSamplerParameterIiv _ptrc_glSamplerParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint, GLenum, const GLuint *);\n#define glSamplerParameterIuiv _ptrc_glSamplerParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint, GLenum, GLfloat);\n#define glSamplerParameterf _ptrc_glSamplerParameterf\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint, GLenum, const GLfloat *);\n#define glSamplerParameterfv _ptrc_glSamplerParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint, GLenum, GLint);\n#define glSamplerParameteri _ptrc_glSamplerParameteri\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint, GLenum, const GLint *);\n#define glSamplerParameteriv _ptrc_glSamplerParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint, GLuint);\n#define glVertexAttribDivisor _ptrc_glVertexAttribDivisor\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint, GLenum, GLboolean, GLuint);\n#define glVertexAttribP1ui _ptrc_glVertexAttribP1ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint, GLenum, GLboolean, const GLuint *);\n#define glVertexAttribP1uiv _ptrc_glVertexAttribP1uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint, GLenum, GLboolean, GLuint);\n#define glVertexAttribP2ui _ptrc_glVertexAttribP2ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint, GLenum, GLboolean, const GLuint *);\n#define glVertexAttribP2uiv _ptrc_glVertexAttribP2uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint, GLenum, GLboolean, GLuint);\n#define glVertexAttribP3ui _ptrc_glVertexAttribP3ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint, GLenum, GLboolean, const GLuint *);\n#define glVertexAttribP3uiv _ptrc_glVertexAttribP3uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint, GLenum, GLboolean, GLuint);\n#define glVertexAttribP4ui _ptrc_glVertexAttribP4ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint, GLenum, GLboolean, const GLuint *);\n#define glVertexAttribP4uiv _ptrc_glVertexAttribP4uiv\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBeginQueryIndexed)(GLenum, GLuint, GLuint);\n#define glBeginQueryIndexed _ptrc_glBeginQueryIndexed\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindTransformFeedback)(GLenum, GLuint);\n#define glBindTransformFeedback _ptrc_glBindTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparatei)(GLuint, GLenum, GLenum);\n#define glBlendEquationSeparatei _ptrc_glBlendEquationSeparatei\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationi)(GLuint, GLenum);\n#define glBlendEquationi _ptrc_glBlendEquationi\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparatei)(GLuint, GLenum, GLenum, GLenum, GLenum);\n#define glBlendFuncSeparatei _ptrc_glBlendFuncSeparatei\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendFunci)(GLuint, GLenum, GLenum);\n#define glBlendFunci _ptrc_glBlendFunci\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteTransformFeedbacks)(GLsizei, const GLuint *);\n#define glDeleteTransformFeedbacks _ptrc_glDeleteTransformFeedbacks\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysIndirect)(GLenum, const GLvoid *);\n#define glDrawArraysIndirect _ptrc_glDrawArraysIndirect\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsIndirect)(GLenum, GLenum, const GLvoid *);\n#define glDrawElementsIndirect _ptrc_glDrawElementsIndirect\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawTransformFeedback)(GLenum, GLuint);\n#define glDrawTransformFeedback _ptrc_glDrawTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawTransformFeedbackStream)(GLenum, GLuint, GLuint);\n#define glDrawTransformFeedbackStream _ptrc_glDrawTransformFeedbackStream\nextern void (CODEGEN_FUNCPTR *_ptrc_glEndQueryIndexed)(GLenum, GLuint);\n#define glEndQueryIndexed _ptrc_glEndQueryIndexed\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenTransformFeedbacks)(GLsizei, GLuint *);\n#define glGenTransformFeedbacks _ptrc_glGenTransformFeedbacks\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineName)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetActiveSubroutineName _ptrc_glGetActiveSubroutineName\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineUniformName)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetActiveSubroutineUniformName _ptrc_glGetActiveSubroutineUniformName\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineUniformiv)(GLuint, GLenum, GLuint, GLenum, GLint *);\n#define glGetActiveSubroutineUniformiv _ptrc_glGetActiveSubroutineUniformiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramStageiv)(GLuint, GLenum, GLenum, GLint *);\n#define glGetProgramStageiv _ptrc_glGetProgramStageiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryIndexediv)(GLenum, GLuint, GLenum, GLint *);\n#define glGetQueryIndexediv _ptrc_glGetQueryIndexediv\nextern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetSubroutineIndex)(GLuint, GLenum, const GLchar *);\n#define glGetSubroutineIndex _ptrc_glGetSubroutineIndex\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetSubroutineUniformLocation)(GLuint, GLenum, const GLchar *);\n#define glGetSubroutineUniformLocation _ptrc_glGetSubroutineUniformLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformSubroutineuiv)(GLenum, GLint, GLuint *);\n#define glGetUniformSubroutineuiv _ptrc_glGetUniformSubroutineuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformdv)(GLuint, GLint, GLdouble *);\n#define glGetUniformdv _ptrc_glGetUniformdv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTransformFeedback)(GLuint);\n#define glIsTransformFeedback _ptrc_glIsTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glMinSampleShading)(GLfloat);\n#define glMinSampleShading _ptrc_glMinSampleShading\nextern void (CODEGEN_FUNCPTR *_ptrc_glPatchParameterfv)(GLenum, const GLfloat *);\n#define glPatchParameterfv _ptrc_glPatchParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glPatchParameteri)(GLenum, GLint);\n#define glPatchParameteri _ptrc_glPatchParameteri\nextern void (CODEGEN_FUNCPTR *_ptrc_glPauseTransformFeedback)();\n#define glPauseTransformFeedback _ptrc_glPauseTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glResumeTransformFeedback)();\n#define glResumeTransformFeedback _ptrc_glResumeTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1d)(GLint, GLdouble);\n#define glUniform1d _ptrc_glUniform1d\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1dv)(GLint, GLsizei, const GLdouble *);\n#define glUniform1dv _ptrc_glUniform1dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2d)(GLint, GLdouble, GLdouble);\n#define glUniform2d _ptrc_glUniform2d\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2dv)(GLint, GLsizei, const GLdouble *);\n#define glUniform2dv _ptrc_glUniform2dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3d)(GLint, GLdouble, GLdouble, GLdouble);\n#define glUniform3d _ptrc_glUniform3d\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3dv)(GLint, GLsizei, const GLdouble *);\n#define glUniform3dv _ptrc_glUniform3dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4d)(GLint, GLdouble, GLdouble, GLdouble, GLdouble);\n#define glUniform4d _ptrc_glUniform4d\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4dv)(GLint, GLsizei, const GLdouble *);\n#define glUniform4dv _ptrc_glUniform4dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix2dv _ptrc_glUniformMatrix2dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix2x3dv _ptrc_glUniformMatrix2x3dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix2x4dv _ptrc_glUniformMatrix2x4dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix3dv _ptrc_glUniformMatrix3dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix3x2dv _ptrc_glUniformMatrix3x2dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix3x4dv _ptrc_glUniformMatrix3x4dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix4dv _ptrc_glUniformMatrix4dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix4x2dv _ptrc_glUniformMatrix4x2dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix4x3dv _ptrc_glUniformMatrix4x3dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformSubroutinesuiv)(GLenum, GLsizei, const GLuint *);\n#define glUniformSubroutinesuiv _ptrc_glUniformSubroutinesuiv\n\nenum ogl_LoadStatus\n{\n\togl_LOAD_FAILED = 0,\n\togl_LOAD_SUCCEEDED = 1,\n};\n\nint ogl_LoadFunctions();\n\nint ogl_GetMinorVersion();\nint ogl_GetMajorVersion();\nint ogl_IsVersionGEQ(int majorVersion, int minorVersion);\n\n#ifdef __cplusplus\n}\n#endif /*__cplusplus*/\n\n#endif //POINTER_C_GENERATED_HEADER_OPENGL_H\n\n"
  },
  {
    "path": "examples/common_code/gl_include.hpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n#ifndef PIC_INIT_GL_HPP\n#define PIC_INIT_GL_HPP\n\n#ifdef _MSC_VER\n    #define PIC_INCLUDE_GL\n#endif\n\n#ifdef __unix__\n    #define PIC_INCLUDE_GL\n#endif\n\n#ifdef PIC_INCLUDE_GL\n    #define PIC_DISABLE_OPENGL_NON_CORE\n    #include \"../common_code/gl_core_4_0.h\"\n#endif\n\n#ifndef PIC_INCLUDE_GL\n    #include <QOpenGLFunctions>\n#endif\n\n#endif /* PIC_INIT_GL_HPP */\n\n"
  },
  {
    "path": "examples/common_code/image_qimage_interop.hpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n#ifndef IMAGE_QIMAGE_INTEROP_HPP\n#define IMAGE_QIMAGE_INTEROP_HPP\n\n#include \"qt_includes.hpp\"\n\n#include \"piccante.hpp\"\n\n#ifdef PIC_QT\n\n/**\n * @brief ConvertFromQImage converts a QImage into an Image.\n * @param img is a QImage.\n * @param typeLoad is a converting option for LDR images:\n * LT_NOR means that the input image values will be normalized in [0,1].\n * LT_NOR_GAMMA means that the input image values will be normalized in [0,1], and\n * gamma correction 2.2 will be removed.\n * LT_NONE means that image values are not modified.\n * @param readerCounter.\n */\nPIC_INLINE pic::Image *ImageConvertFromQImage(QImage *imgIn,\n                                   pic::Image *imgOut,\n                                   pic::LDR_type typeLoad = pic::LT_NONE,\n                                   int readerCounter = 0)\n{\n    bool bAlpha = imgIn->hasAlphaChannel();\n\n    int channels;\n\n    if(imgIn->depth() == 1) {\n        channels = 1;\n    } else {\n        channels = imgIn->depth() / 8;\n    }\n\n    int width = imgIn->width();\n    int height = imgIn->height();\n\n    //compute channels\n    if(!bAlpha) {\n        if(imgIn->depth() == 32 ) {\n            channels = 3;\n        }\n    }\n\n    if(imgOut == NULL) {\n        imgOut = new pic::Image(width, height, channels);\n    } else {\n        imgOut->allocate(width, height, channels, 1);\n    }\n\n    int frames = imgOut->frames;\n\n    int tmpInd = imgOut->tstride * (readerCounter % frames);\n\n    if(imgOut->dataUC != NULL) {\n        delete[] imgOut->dataUC;\n    }\n\n    unsigned int n = width * height * channels;\n    imgOut->dataUC = new unsigned char[n];\n\n    //NOTE: this code works but it is slow!\n    int shiftG = 0;\n    int shiftB = 0;\n    int shiftA = 1;\n\n    if(channels == 3 || channels == 4) {\n        shiftG = 1;\n        shiftB = 2;\n        shiftA = 3;\n    }\n\n    for(int i = 0; i < height; i++) {\n        for(int j = 0; j < width; j++) {\n            QRgb col = imgIn->pixel(j, i);\n\n            int A = (col & 0xFF000000) >> 24;\n            int R = (col & 0x00FF0000) >> 16;\n            int G = (col & 0x0000FF00) >> 8;\n            int B = (col & 0x000000FF);\n            int ind = tmpInd + i * imgOut->ystride + j * imgOut->xstride;\n\n            imgOut->dataUC[ind         ] = R;\n            imgOut->dataUC[ind + shiftG] = G;\n            imgOut->dataUC[ind + shiftB] = B;\n\n            if(bAlpha) {\n                imgOut->dataUC[ind + shiftA] = A;\n            }\n        }\n     }\n\n    pic::convertLDR2HDR(imgOut->dataUC, &imgOut->data[tmpInd], n, typeLoad);\n\n    return imgOut;\n}\n\n/**\n * @brief ImageConvertToQImage\n * @param image\n * @param typeLoad is an option for LDR images only:\n * LT_NOR means that the input image values will be normalized in [0,1].\n * LT_NOR_GAMMA means that the input image values will be normalized in [0,1], and\n * gamma correction 2.2 will be removed.\n * LT_NONE means that image values are not modified.\n * @param writerCounter.\n * @param gamma.\n * @return\n */\nPIC_INLINE QImage *ImageConvertToQImage(pic::Image *imgIn,\n                             QImage *imgOut = NULL,\n                             pic::LDR_type type = pic::LT_NOR_GAMMA,\n                             int writerCoutner = 0, float gamma = 2.2f)\n{\n    if(imgIn == NULL) {\n        return imgOut;\n    }\n\n    QImage *ret = NULL;\n    bool bAllocate = false;\n\n    int width = imgIn->width;\n    int height = imgIn->height;\n    int channels = imgIn->channels;\n    int frames = imgIn->frames;\n\n    if(imgOut != NULL) {\n        bAllocate = (imgOut->width() != width || imgOut->height() != height);\n    } else {\n        bAllocate = true;\n    }\n\n    if(bAllocate) {\n        ret = new QImage(width, height, QImage::Format_ARGB32);\n    } else {\n        ret = imgOut;\n    }\n\n    float *tmpData = &imgIn->data[writerCoutner % frames];\n\n    imgIn->dataUC = pic::convertHDR2LDR(tmpData, imgIn->dataUC, width * height * channels, type, gamma);\n\n    int shifter[2];\n    shifter[0] = 1;\n    shifter[1] = 2;\n\n    switch(channels) {\n    case 1: {\n        shifter[0] = 0;\n        shifter[1] = 0;\n    }\n    break;\n\n    case 2: {\n        shifter[0] = 1;\n        shifter[1] = 1;\n    }\n    break;\n    }\n\n    for(int i = 0; i < height; i++) {\n        int ind = i * width;\n\n        for(int j = 0; j < width; j++) {\n            int c = (ind + j) * channels;\n            ret->setPixel(j, i, qRgb(imgIn->dataUC[c],\n                                     imgIn->dataUC[c + shifter[0]],\n                                     imgIn->dataUC[c + shifter[1]]));\n        }\n    }\n\n    return ret;\n}\n\n/**\n * @brief ImageWrite\n * @param imgIn\n * @param nameFile\n * @param typeWrite\n * @return\n */\nPIC_INLINE bool ImageWrite(pic::Image *imgIn, std::string nameFile, pic::LDR_type typeWrite = pic::LT_NOR_GAMMA)\n{\n    if(imgIn == NULL) {\n        return false;\n    }\n\n    bool bWrite = imgIn->Write(nameFile, typeWrite, 0);\n\n    if(!bWrite) {\n        QImage *tmpImg = ImageConvertToQImage(imgIn, NULL, typeWrite);\n        tmpImg->save(nameFile.c_str());\n\n        if(tmpImg != NULL) {\n            delete tmpImg;\n        }\n\n        return true;\n    } else {\n        return bWrite;\n    }\n}\n\n/**\n * @brief ImageRead\n * @param nameFile\n * @param typeLoad\n * @return\n */\nPIC_INLINE pic::Image *ImageRead(std::string nameFile, pic::Image *imgOut, pic::LDR_type typeLoad = pic::LT_NOR_GAMMA)\n{\n    if(imgOut != NULL) {\n        bool bRead = imgOut->Read(nameFile, typeLoad);\n\n        if(!bRead) {\n            QImage imgIn;\n            imgIn.load(nameFile.c_str());\n            imgOut = ImageConvertFromQImage(&imgIn, imgOut, typeLoad);\n        }\n    }\n\n    return imgOut;\n}\n\n#endif /* PIC_QT */\n\n\n#endif /* IMAGE_QIMAGE_INTEROP_HPP */\n"
  },
  {
    "path": "examples/common_code/qt_includes.hpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n\n/**\n  Check if QT is not disabled, and includes the necessary headers.\n  Works with QT version 4 or version 5\n  */\n\n#ifndef PIC_QT_HPP\n#define PIC_QT_HPP\n\n\n#include <QtCore/QtGlobal>\n\n#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))\n\n/* not ready for future versions */\n\n#elif (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))\n/* we got Qt 5 */\n#define PIC_QT\n\n/*\n#include <QtCore/qstring.h>\n#include <QtCore/qstringlist.h>\n#include <QtCore/qfile.h>\n#include <QtCore/qtimer.h>\n#include <QtCore/qvariant.h>\n\n#include <QtCore/qdir.h>\n#include <QtCore/QTextStream>\n\n#include <QtGui/QColor>*/\n\n#include <QtGui/QImage>\n\n#elif (QT_VERSION >= QT_VERSION_CHECK(4, 0, 0))\n/* we got Qt 4 */\n#define PIC_QT\n\n#include <QString>\n#include <QStringList>\n#include <QFile>\n#include <QTimer>\n#include <QVariant.h>\n#include <QColor>\n#include <QDir.h>\n#include <QTextStream>\n#include <QTime>\n#include <QImage>\n#include <QDebug>\n\n#else /* unsupported qt version */\n\n/* we got Qt 3 or below, unsupported */\n\n#endif /* qt version selection */\n\n#ifndef PIC_DISABLE_OPENGL\n    #include <QtGui/QOpenGLFunctions>\n    #include <QtGui/QOpenGLContext>\n    #include <QtGui/QOpenGLPaintDevice>\n#endif\n\n#endif /* PIC_QT_HPP */\n\n"
  },
  {
    "path": "examples/common_code/readme.txt",
    "content": "This code provides an OpenGL 4.0 extension loader (.h and .c files) created\nusing glLoadGen: https://bitbucket.org/alfonse/glloadgen/wiki/Home\n\nThis code is not part of Piccante, and it is meant for only the examples."
  },
  {
    "path": "examples/computer_vision_augmented_reality/cv_augmented_reality.pro",
    "content": "# PICCANTE Examples\n# The hottest examples of Piccante:\n# http://vcg.isti.cnr.it/piccante\n#\n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n#\n# This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU General Public License as published by\n#    the Free Software Foundation, either version 3.0 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU General Public License for more details.\n#\n#    See the GNU Lesser General Public License\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n#\n\nTARGET = cv_augmented_reality\n\nQT       += core\n#TEMPLATE = app\n#CONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/computer_vision_augmented_reality/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#define EIGEN_DONT_VECTORIZE\n\n#define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img0_str, img1_str;\n\n    if(argc == 3) {\n        img0_str = argv[1];\n        img1_str = argv[2];\n    } else {\n        img0_str = \"../data/input/features/balcony_0.png\";\n        img1_str = \"../data/input/augmented_reality/desk.png\";\n    }\n\n    //computing K matrix from manufacturer data\n    double fx = pic::getFocalLengthPixels(3.3, 3.8, 2592.0);\n    double fy = pic::getFocalLengthPixels(3.3, 2.9, 1936.0);\n    Eigen::Matrix3d K = pic::getIntrinsicsMatrix(fx, fy, 2592.0 / 2.0, 1936.0 / 2.0);\n\n    printf(\"Reading LDR images...\");\n    pic::Image img0, img1;\n    img0.Read(img0_str, pic::LT_NOR);\n    img1.Read(img1_str, pic::LT_NOR);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Are they both valid? \");\n    if(img0.isValid() && img1.isValid()) {\n        printf(\"OK\\n\");\n\n        //output corners\n        std::vector< Eigen::Vector2f > corners_from_img0;\n        std::vector< Eigen::Vector2f > corners_from_img1;\n\n        //compute the luminance images\n        pic::Image *L0 = pic::FilterLuminance::execute(&img0, NULL, pic::LT_CIE_LUMINANCE);\n        pic::Image *L1 = pic::FilterLuminance::execute(&img1, NULL, pic::LT_CIE_LUMINANCE);\n\n        //get corners\n        printf(\"Extracting corners...\\n\");\n        pic::HarrisCornerDetector hcd(2.5f, 5);\n        hcd.execute(L0, &corners_from_img0);\n        hcd.execute(L1, &corners_from_img1);\n\n        //compute ORB descriptors for each corner and image\n        //compute luminance images\n        pic::Image *L0_flt = pic::FilterGaussian2D::execute(L0, NULL, 2.5f);\n        pic::Image *L1_flt = pic::FilterGaussian2D::execute(L1, NULL, 2.5f);\n\n        printf(\"Computing ORB descriptors...\\n\");\n\n        //pic::PoissonDescriptor b_desc(16);\n        pic::ORBDescriptor b_desc(31, 512);\n\n        std::vector< pic::uint* > descs0;\n        b_desc.getAll(L0_flt, corners_from_img0 , descs0);\n\n        std::vector< pic::uint* > descs1;\n        b_desc.getAll(L1_flt, corners_from_img1 , descs1);\n\n        printf(\"Matching ORB descriptors...\\n\");\n        int n = b_desc.getDescriptorSize();\n\n        pic::BinaryFeatureBruteForceMatcher bfm(&descs1, n);\n\n        printf(\"Descriptor size: %d\\n\", n);\n\n        printf(\"Matching...\");\n        std::vector< Eigen::Vector3i > matches;\n        bfm.getAllMatches(descs0, matches);\n        printf(\" we found %d matches \", int(matches.size()));\n        printf(\"Ok\\n\");\n\n        //filter\n        std::vector< Eigen::Vector2f > m0, m1;\n        pic::FeatureMatcher<pic::uint>::filterMatches(corners_from_img0, corners_from_img1, matches, m0, m1);\n\n        printf(\"Estimating a homography matrix H from the matches...\");\n\n        std::vector< pic::uint > inliers;\n        Eigen::Matrix3d H = pic::estimateHomographyWithNonLinearRefinement(m0, m1, inliers, 10000, 2.5f, 1, 10000, 1e-5f);\n\n        Eigen::Matrix34d cam = pic::getCameraMatrixFromHomography(H, K);\n\n        img1 *= 0.25f;\n\n        //augmentation: drawing a 3D grid\n        int res = 10;\n        for(int i=1;i<(res + 1);i++) {\n            float u = float(i) / 50.0f;\n\n            for(int j=1;j<(res + 1);j++) {\n                float v = float(j) / 50.0f;\n\n                Eigen::Vector4d point(u, v, 0.0f, 1.0f);\n                Eigen::Vector2i coord = pic::cameraMatrixProject(cam, point);\n\n                float *tmp = img1(coord[0], coord[1]);\n                tmp[0] = 1.0f;\n                tmp[1] = 0.25f;\n                tmp[2] = 0.25f;\n            }\n\n        }\n\n        //augmentation: drawing 3D axis\n        Eigen::Vector4d p0(0.0, 0.0, 0.0, 1.0);\n        Eigen::Vector2i coord0 = pic::cameraMatrixProject(cam, p0);\n\n        Eigen::Vector4d p1(0.2, 0.0, 0.0, 1.0);\n        Eigen::Vector2i coord1 = pic::cameraMatrixProject(cam, p1);\n\n        Eigen::Vector4d p2(0.0, 0.2, 0.0, 1.0);\n        Eigen::Vector2i coord2 = pic::cameraMatrixProject(cam, p2);\n\n        Eigen::Vector4d p3(0.0, 0.0, 0.2, 1.0);\n        Eigen::Vector2i coord3 = pic::cameraMatrixProject(cam, p3);\n\n        float color[]={0.25f, 1.0f, 0.25f};\n        pic::drawLine(&img1, pic::convertFromEigenToVec(coord0), pic::convertFromEigenToVec(coord1), color);\n        pic::drawLine(&img1, pic::convertFromEigenToVec(coord0), pic::convertFromEigenToVec(coord2), color);\n        pic::drawLine(&img1, pic::convertFromEigenToVec(coord0), pic::convertFromEigenToVec(coord3), color);\n\n        img1.Write(\"../data/output/simple_augmented_reality.png\", pic::LT_NOR);\n\n    } else {\n        printf(\"No, there is at least an invalid file!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/computer_vision_corners_extraction/cv_corners_extraction.pro",
    "content": "# PICCANTE Examples\n# The hottest examples of Piccante:\n# http://vcg.isti.cnr.it/piccante\n#\n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n#\n# This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU General Public License as published by\n#    the Free Software Foundation, either version 3.0 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU General Public License for more details.\n#\n#    See the GNU Lesser General Public License\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n#\n\nTARGET = cv_corners_extraction\n\nQT       += core\n#TEMPLATE = app\n#CONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/computer_vision_corners_extraction/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/features/balcony_0.png\";\n    }\n\n    printf(\"Reading an LDR file...\");\n\n    pic::Image img;\n\n    img.Read(img_str, pic::LT_NOR);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        bool bWritten = true;\n\n        //FAST corners\n        std::vector< Eigen::Vector2f > corners_fast;\n        pic::FastCornerDetector fcd;\n        fcd.update(1.0f, 5);\n        fcd.execute(&img, &corners_fast);\n\n        printf(\"\\nFAST Corner Detector Test:\\n\");\n        for(unsigned int i = 0; i < corners_fast.size(); i++) {\n            printf(\"X: %3.2f Y: %3.2f\\n\", corners_fast[i][0], corners_fast[i][1]);\n        }\n\n        printf(\"\\n\");\n\n        pic::Image *imgCorners_fast = fcd.getCornersImage(&corners_fast, NULL, img.width, img.height, true);\n\n        bWritten = imgCorners_fast->Write(\"../data/output/corner_fast_output.png\", pic::LT_NOR);\n\n        //Harris corners\n        std::vector< Eigen::Vector2f > corners_harris;\n        pic::HarrisCornerDetector hcd;\n        hcd.update(1.0f, 5, -1024.0f, 0.04f, pic::CD_HARRIS);\n        hcd.execute(&img, &corners_harris);\n\n        printf(\"\\nHarris Corner Detector Test:\\n\");\n        for(unsigned int i = 0; i < corners_harris.size(); i++) {\n            printf(\"X: %3.2f Y: %3.2f\\n\", corners_harris[i][0], corners_harris[i][1]);\n        }\n        printf(\"\\n\");\n\n        pic::Image *imgCorners_harris = hcd.getCornersImage(&corners_harris, NULL, img.width, img.height, true);\n        bWritten = imgCorners_harris->Write(\"../data/output/corner_harris_output.png\", pic::LT_NOR);\n\n        //Noble corners\n        corners_harris.clear();\n        hcd.update(1.0f, 5, -1024.0f, 0.04f, pic::CD_NOBLE);\n        hcd.execute(&img, &corners_harris);\n\n        printf(\"\\nNoble-Harris Corner Detector Test:\\n\");\n        for(unsigned int i = 0; i < corners_harris.size(); i++) {\n            printf(\"X: %3.2f Y: %3.2f\\n\", corners_harris[i][0], corners_harris[i][1]);\n        }\n        printf(\"\\n\");\n\n        imgCorners_harris->setZero();\n        imgCorners_harris = hcd.getCornersImage(&corners_harris, imgCorners_harris, img.width, img.height, true);\n        bWritten = imgCorners_harris->Write(\"../data/output/corner_noble_output.png\", pic::LT_NOR);\n\n        //Shi-Tomasi corners\n        corners_harris.clear();\n        hcd.update(1.0f, 5, -1024.0f, 0.04f, pic::CD_SHI_TOMASI);\n        hcd.execute(&img, &corners_harris);\n\n        printf(\"\\nShi-Tomasi Corner Detector Test:\\n\");\n        for(unsigned int i = 0; i < corners_harris.size(); i++) {\n            printf(\"X: %3.2f Y: %3.2f\\n\", corners_harris[i][0], corners_harris[i][1]);\n        }\n        printf(\"\\n\");\n\n        imgCorners_harris->setZero();\n        imgCorners_harris = hcd.getCornersImage(&corners_harris, imgCorners_harris, img.width, img.height, true);\n        bWritten = imgCorners_harris->Write(\"../data/output/corner_shi_tomasi_output.png\", pic::LT_NOR);\n\n\n        //SUSAN corners\n        std::vector< Eigen::Vector2f > corners_susan;\n        pic::SusanCornerDetector scd;\n        scd.execute(&img, &corners_susan);\n\n        printf(\"\\nSUSAN Corner Detector Test:\\n\");\n        for(unsigned int i = 0; i < corners_susan.size(); i++) {\n            printf(\"X: %3.2f Y: %3.2f\\n\", corners_susan[i][0], corners_susan[i][1]);\n        }\n        printf(\"\\n\");\n\n        pic::Image *imgCorners_susan = scd.getCornersImage(&corners_susan, NULL, img.width, img.height, true);\n        bWritten = imgCorners_susan->Write(\"../data/output/corner_susan_output.png\", pic::LT_NOR);\n\n        printf(\"\\n\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/computer_vision_estimate_camera_matrix/cv_estimate_camera_matrix.pro",
    "content": "# PICCANTE Examples\r\n# The hottest examples of Piccante:\r\n# http://vcg.isti.cnr.it/piccante\r\n#\r\n# Copyright (C) 2014\r\n# Visual Computing Laboratory - ISTI CNR\r\n# http://vcg.isti.cnr.it\r\n# First author: Francesco Banterle\r\n#\r\n# This program is free software: you can redistribute it and/or modify\r\n#    it under the terms of the GNU General Public License as published by\r\n#    the Free Software Foundation, either version 3.0 of the License, or\r\n#    (at your option) any later version.\r\n#\r\n#    This program is distributed in the hope that it will be useful,\r\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\n#    GNU General Public License for more details.\r\n#\r\n#    See the GNU Lesser General Public License\r\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\r\n#\r\n\r\nTARGET = cv_estimate_camera_matrix\r\n\r\nQT       += core\r\n#TEMPLATE = app\r\n#CONFIG   += console\r\nCONFIG   -= app_bundle\r\nCONFIG   += C++11\r\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\r\n\r\nINCLUDEPATH += ../../include\r\n\r\nSOURCES += main.cpp\r\n\r\nwin32-msvc*{\r\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\r\n}\r\n\r\nwin32{\r\n    DEFINES += NOMINMAX\r\n}\r\n\r\nlinux-g++*{\r\n    QMAKE_CXXFLAGS += -fopenmp -pthread\r\n    QMAKE_LFLAGS += -fopenmp\r\n}\r\n"
  },
  {
    "path": "examples/computer_vision_estimate_camera_matrix/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#define EIGEN_DONT_VECTORIZE\n\n#define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{   \n    printf(\"Reading an LDR images...\");\n\n    double focal_length;\n    double sensor_size_x_mm, sensor_size_y_mm;\n    double sensor_pixel_resolution_x, sensor_pixel_resolution_y;\n    std::string name0, name1;\n\n    if(argc == 8) {\n        name0 = argv[1];\n        name1 = argv[2];\n        focal_length = atof(argv[3]);\n        sensor_size_x_mm = atof(argv[4]);\n        sensor_size_y_mm = atof(argv[5]);\n        sensor_pixel_resolution_x = atof(argv[6]);\n        sensor_pixel_resolution_y = atof(argv[7]);\n    } else {\n        name0 = \"../data/input/triangulation/campo_s_stefano_l.jpg\";\n        name1 = \"../data/input/triangulation/campo_s_stefano_r.jpg\";\n        focal_length = 18.0;\n        sensor_size_x_mm = 22.3;\n        sensor_size_y_mm = 14.9;\n        sensor_pixel_resolution_x = 2592.0;\n        sensor_pixel_resolution_y = 1728.0;\n    }\n    \n    //estimate K matrix from camera manufacturer's data\n    double fx = pic::getFocalLengthPixels(focal_length, sensor_size_x_mm, sensor_pixel_resolution_x);\n    double fy = pic::getFocalLengthPixels(focal_length, sensor_size_y_mm, sensor_pixel_resolution_y);\n    Eigen::Matrix3d K = pic::getIntrinsicsMatrix(fx, fy,\n                                                 sensor_pixel_resolution_x / 2.0,\n                                                 sensor_pixel_resolution_y / 2.0);\n    \n    pic::Image img0, img1;\n    img0.Read(name0, pic::LT_NOR);\n    img1.Read(name1, pic::LT_NOR);\n    \n    printf(\"Ok\\n\");\n    \n    printf(\"Are they both valid? \");\n    if(img0.isValid() && img1.isValid()) {\n        printf(\"OK\\n\");\n        \n        std::vector< Eigen::Vector2f > m0, m1;\n        std::vector< unsigned int > inliers;\n\n        auto F = pic::estimateFundamentalFromImages(&img0, &img1, m0, m1, inliers);\n                \n        //decompose E into R and t\n        std::vector< Eigen::Vector2f > m0f, m1f;\n        pic::filterInliers(m0, inliers, m0f);\n        pic::filterInliers(m1, inliers, m1f);\n\n        //compute essential matrix decomposition\n        Eigen::Matrix3d E = pic::computeEssentialMatrix(F, K);\n\n        Eigen::Matrix3d R;\n        Eigen::Vector3d t;\n        pic::decomposeEssentialMatrixWithConfiguration(E, K, K, m0f, m1f, R, t);\n        \n        //triangulation                \n        Eigen::Matrix34d M0 = pic::getCameraMatrixIdentity(K);\n        Eigen::Matrix34d M1 = pic::getCameraMatrix(K, R, t);\n        \n        printf(\"Camera Matrix0:\\n\");\n        pic::printfMat34d(M0);\n\n        printf(\"Camera Matrix1:\\n\");\n        pic::printfMat34d(M1);\n\n        pic::writeMatrix34dToFile(\"../data/output/\" + pic::getFileNameOnly(name0) + \"_cam.txt\", M0);\n        pic::writeMatrix34dToFile(\"../data/output/\" + pic::getFileNameOnly(name1) + \"_cam.txt\", M1);\n    } else {\n        printf(\"No there is at least an invalid file!\\n\");\n    }\n    \n    return 0;\n}\n"
  },
  {
    "path": "examples/computer_vision_find_checker_board/cv_find_checker_board.pro",
    "content": "# PICCANTE Examples\n# The hottest examples of Piccante:\n# http://vcg.isti.cnr.it/piccante\n#\n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n#\n# This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU General Public License as published by\n#    the Free Software Foundation, either version 3.0 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU General Public License for more details.\n#\n#    See the GNU Lesser General Public License\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n#\n\nTARGET = cv_find_checker_board\n\nQT       += core\n#TEMPLATE = app\n#CONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/computer_vision_find_checker_board/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/features/checker_board_photo.png\";\n    }\n\n    printf(\"Reading images...\");\n    pic::Image img(img_str, pic::LT_NOR_GAMMA);\n    printf(\"Is the image valid? \");\n\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        std::vector< Eigen::Vector2f > corners;\n        pic::findCheckerBoard(&img, corners);\n\n        Eigen::Vector2f p0, p1;\n        float length = pic::estimateLengthOfCheckers(corners, p0, p1);\n\n        printf(\"The checkers' length is %3.3f pixels.\\n\", length);\n\n        float *color = pic::estimateWhitePointFromCheckerBoard(&img, corners);\n\n        pic::Image *img_wb = pic::FilterWhiteBalance::execute(&img, color, NULL);\n\n        std::string name = pic::removeExtension(img_str);\n        name = pic::removeLocalPath(name);\n        img_wb->Write(\"../data/output/\" + name + \"_wb.png\");\n\n\n    } else {\n        printf(\"No there is at least an invalid file!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/computer_vision_image_rectification/cv_rectification.pro",
    "content": "# PICCANTE Examples\r\n# The hottest examples of Piccante:\r\n# http://vcg.isti.cnr.it/piccante\r\n#\r\n# Copyright (C) 2014\r\n# Visual Computing Laboratory - ISTI CNR\r\n# http://vcg.isti.cnr.it\r\n# First author: Francesco Banterle\r\n#\r\n# This program is free software: you can redistribute it and/or modify\r\n#    it under the terms of the GNU General Public License as published by\r\n#    the Free Software Foundation, either version 3.0 of the License, or\r\n#    (at your option) any later version.\r\n#\r\n#    This program is distributed in the hope that it will be useful,\r\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\n#    GNU General Public License for more details.\r\n#\r\n#    See the GNU Lesser General Public License\r\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\r\n#\r\n\r\nTARGET = cv_rectification\r\n\r\nQT       += core\r\n#TEMPLATE = app\r\n#CONFIG   += console\r\nCONFIG   -= app_bundle\r\nCONFIG   += C++11\r\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\r\n\r\nINCLUDEPATH += ../../include\r\n\r\nSOURCES += main.cpp\r\n\r\nwin32-msvc*{\r\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\r\n}\r\n\r\nwin32{\r\n    DEFINES += NOMINMAX\r\n}\r\n\r\nlinux-g++*{\r\n    QMAKE_CXXFLAGS += -fopenmp -pthread\r\n    QMAKE_LFLAGS += -fopenmp\r\n}\r\n"
  },
  {
    "path": "examples/computer_vision_image_rectification/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#define EIGEN_DONT_VECTORIZE\n\n#define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{   \n    printf(\"Reading an LDR images...\");\n\n    Eigen::Matrix34d P0, P1;\n    pic::Image img0, img1;\n    std::string name0, name1;\n\n    if(argc != 5) {\n        name0 = \"../data/input/triangulation/campo_s_stefano_l.jpg\";\n        name1 = \"../data/input/triangulation/campo_s_stefano_r.jpg\";\n        P0 = pic::readMatrix34dFromFile(\"../data/input/triangulation/campo_s_stefano_l_cam.txt\");\n        P1 = pic::readMatrix34dFromFile(\"../data/input/triangulation/campo_s_stefano_r_cam.txt\");\n    } else {\n        name0 = argv[1];\n        name1 = argv[2];\n        P0 = pic::readMatrix34dFromFile(argv[3]);\n        P1 = pic::readMatrix34dFromFile(argv[4]);\n    }\n\n    img0.Read(name0, pic::LT_NOR);\n    img1.Read(name1, pic::LT_NOR);\n\n    printf(\"Ok\\n\");\n    \n    printf(\"Are images both valid? \");\n    if(img0.isValid() && img1.isValid()) {\n        printf(\"OK\\n\");\n        \n        pic::ImageVec *out = pic::computeImageRectification(&img0, &img1, P0, P1, NULL, true);\n\n        name0 = pic::getFileNameOnly(name0);\n        name1 = pic::getFileNameOnly(name1);\n\n        out->at(0)->Write(\"../data/output/\" + name0 + \"_rectified.png\", pic::LT_NOR);\n        out->at(1)->Write(\"../data/output/\" + name1 + \"_rectified.png\", pic::LT_NOR);\n    } else {\n        printf(\"No there is at least an invalid file!\\n\");\n    }\n    \n    return 0;\n}\n"
  },
  {
    "path": "examples/computer_vision_matching/cv_matching.pro",
    "content": "# PICCANTE Examples\n# The hottest examples of Piccante:\n# http://vcg.isti.cnr.it/piccante\n#\n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n#\n# This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU General Public License as published by\n#    the Free Software Foundation, either version 3.0 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU General Public License for more details.\n#\n#    See the GNU Lesser General Public License\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n#\n\nTARGET = cv_matching\n\nQT       += core\n#TEMPLATE = app\n#CONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/computer_vision_matching/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img0_str, img1_str;\n\n    if(argc == 3) {\n        img0_str = argv[1];\n        img1_str = argv[2];\n    } else {\n        img0_str = \"../data/input/features/balcony_0.png\";\n        img1_str = \"../data/input/features/balcony_1.png\";\n    }\n\n    pic::Image img0, img1;\n    img0.Read(img0_str, pic::LT_NOR);\n    img1.Read(img1_str, pic::LT_NOR);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Are they both valid? \");\n    if(img0.isValid() && img1.isValid()) {\n        printf(\"OK\\n\");\n\n        auto H = pic::getHomographyMatrixFromTwoImage(&img0, &img1);\n\n        printf(\"\\nHomography matrix:\\n\");\n        pic::printfMat(H);\n\n        printf(\"Applying H to the first image..\");\n        pic::Image *img0_H = pic::FilterWarp2D::execute(&img0, NULL, pic::MatrixConvert(H), true, false);\n        img0_H->Write(\"../data/output/simple_matching_img_0_H_applied.png\", pic::LT_NOR);\n        printf(\"Ok.\\n\");\n    } else {\n        printf(\"No there is at least an invalid file!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/computer_vision_stereo/cv_stereo.pro",
    "content": "# PICCANTE Examples\n# The hottest examples of Piccante:\n# http://vcg.isti.cnr.it/piccante\n#\n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n#\n# This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU General Public License as published by\n#    the Free Software Foundation, either version 3.0 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU General Public License for more details.\n#\n#    See the GNU Lesser General Public License\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n#\n\nTARGET = cv_stereo\n\nQT       += core\n#TEMPLATE = app\n#CONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nQMAKE_MAC_SDK = macosx10.14\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/computer_vision_stereo/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img0_str, img1_str;\n\n    if(argc == 3) {\n        img0_str = argv[1];\n        img1_str = argv[2];\n    } else {\n        img0_str = \"../data/input/view0.png\";\n        img1_str = \"../data/input/view6.png\";\n    }\n\n    pic::Image img0, img1;\n    img0.Read(img0_str, pic::LT_NOR);\n    img1.Read(img1_str, pic::LT_NOR);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Are they both valid? \");\n    if(img0.isValid() && img1.isValid()) {\n        printf(\"OK\\n\");\n\n        pic::Stereo stereo(5, 250, 4);\n\n        pic::Image disp0, disp1;\n\n        stereo.execute(&img0, &img1, &disp0, &disp1);\n\n        disp0.Write(\"../data/output/disp0.pfm\");\n        disp1.Write(\"../data/output/disp1.pfm\");\n\n    } else {\n        printf(\"No there is at least an invalid file!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/computer_vision_triangulation/cv_triangulation.pro",
    "content": "# PICCANTE Examples\r\n# The hottest examples of Piccante:\r\n# http://vcg.isti.cnr.it/piccante\r\n#\r\n# Copyright (C) 2014\r\n# Visual Computing Laboratory - ISTI CNR\r\n# http://vcg.isti.cnr.it\r\n# First author: Francesco Banterle\r\n#\r\n# This program is free software: you can redistribute it and/or modify\r\n#    it under the terms of the GNU General Public License as published by\r\n#    the Free Software Foundation, either version 3.0 of the License, or\r\n#    (at your option) any later version.\r\n#\r\n#    This program is distributed in the hope that it will be useful,\r\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\n#    GNU General Public License for more details.\r\n#\r\n#    See the GNU Lesser General Public License\r\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\r\n#\r\n\r\nTARGET = cv_triangulation\r\n\r\nQT       += core\r\n#TEMPLATE = app\r\n#CONFIG   += console\r\nCONFIG   -= app_bundle\r\nCONFIG   += C++11\r\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\r\n\r\nINCLUDEPATH += ../../include\r\n\r\nSOURCES += main.cpp\r\n\r\nwin32-msvc*{\r\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\r\n}\r\n\r\nwin32{\r\n    DEFINES += NOMINMAX\r\n}\r\n\r\nlinux-g++*{\r\n    QMAKE_CXXFLAGS += -fopenmp -pthread\r\n    QMAKE_LFLAGS += -fopenmp\r\n}\r\n"
  },
  {
    "path": "examples/computer_vision_triangulation/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#define EIGEN_DONT_VECTORIZE\n\n#define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{   \n    std::string name0, name1;\n    double focal_length;\n    double sensor_x_mm, sensor_y_mm;\n    \n    //estimating K matrix from camera\n    if(argc == 3) {\n        name0 = argv[1];\n        name1 = argv[2];\n        focal_length = atof(argv[3]);\n        sensor_x_mm = atof(argv[4]);\n        sensor_y_mm = atof(argv[5]);\n    } else {\n        name0 = \"../data/input/triangulation/campo_s_stefano_l.jpg\";\n        name1 = \"../data/input/triangulation/campo_s_stefano_r.jpg\";\n        focal_length = 18.0;\n        sensor_x_mm = 22.3;\n        sensor_y_mm = 14.9;\n    }\n\n    printf(\"Reading an LDR images...\");\n    pic::Image img0, img1;\n    img0.Read(name0, pic::LT_NOR);\n    img1.Read(name1, pic::LT_NOR);\n    \n    printf(\"Ok\\n\");\n    \n    printf(\"Are they both valid? \");\n    if(img0.isValid() && img1.isValid()) {        \n        printf(\"OK\\n\");\n\n        auto fx0 = pic::getFocalLengthPixels(focal_length, sensor_x_mm, img0.widthf);\n        auto fy0 = pic::getFocalLengthPixels(focal_length, sensor_y_mm, img0.heightf);\n        Eigen::Matrix3d K0 = pic::getIntrinsicsMatrix(fx0, fy0, img0.widthf / 2.0, img0.heightf / 2.0);\n\n        auto fx1 = pic::getFocalLengthPixels(focal_length, sensor_x_mm, img1.widthf);\n        auto fy1 = pic::getFocalLengthPixels(focal_length, sensor_y_mm, img1.heightf);\n        Eigen::Matrix3d K1 = pic::getIntrinsicsMatrix(fx1, fy1, img1.widthf / 2.0, img1.heightf / 2.0);\n\n        //compute fundamental matrix\n        std::vector< Eigen::Vector2f > m0, m1;\n        std::vector< unsigned int > inliers;\n        auto F = pic::estimateFundamentalFromImages(&img0, &img1, m0, m1, inliers);\n        \n        printf(\"\\nFoundamental matrix: \\n\");\n        pic::MatrixConvert(F).print();\n        \n        //compute essential matrix decomposition\n        Eigen::Matrix3d E = pic::computeEssentialMatrix(F, K0, K1);\n                \n        //decompose E into R and t\n        std::vector< Eigen::Vector2f > m0f, m1f;\n        pic::filterInliers(m0, inliers, m0f);\n        pic::filterInliers(m1, inliers, m1f);\n\n        Eigen::Matrix3d R;\n        Eigen::Vector3d t;\n        pic::decomposeEssentialMatrixWithConfiguration(E, K0, K1, m0f, m1f, R, t);\n        \n        //triangulation        \n        std::vector<Eigen::Vector3d> points_3d;\n        \n        Eigen::Matrix34d M0 = pic::getCameraMatrixIdentity(K0);\n        Eigen::Matrix34d M1 = pic::getCameraMatrix(K1, R, t);\n        \n        printf(\"Camera Matrix0:\\n\");\n        pic::printfMat34d(M0);\n\n        printf(\"Camera Matrix1:\\n\");\n        pic::printfMat34d(M1);\n        printf(\"\\n\");\n\n        std::vector< unsigned char> colors;\n        pic::triangulationPoints(M0, M1, m0f, m1f, points_3d, colors, &img0, &img1, true);\n\n        pic::writeSimplePLY(\"../data/output/triangulation.ply\", points_3d, colors);\n\n        //compute distortion parameters\n        pic::NelderMeadOptRadialDistortion nmRD(M0, M1, &m0f, &m1f, &points_3d);\n        \n        float lambda = 0.0f;\n        float lambda_out;\n        nmRD.run(&lambda, 1, 1e-12f, 100000, &lambda_out);\n        printf(\"Radial distortion lambda: %f\\n\", lambda_out);\n        \n        //error images\n        pic::Image imgOut0(1, img0.width, img0.height, 3);\n        imgOut0.setZero();\n\n        pic::Image imgOut1(1, img1.width, img1.height, 3);\n        imgOut1.setZero();\n\n        double cx0 = img0.widthf / 2.0;\n        double cy0 = img0.heightf / 2.0;\n\n        double cx1 = img1.widthf / 2.0;\n        double cy1 = img1.heightf / 2.0;\n\n        for(unsigned int i = 0; i < m0f.size(); i++) {\n            //first image\n            Eigen::Vector2i proj0 = pic::cameraMatrixProjection(M0, points_3d[i], cx0, cy0, fx0, fy0, lambda_out);\n            float *tmp;\n            \n            tmp = imgOut0(int(m0f[i][0]), int(m0f[i][1]));\n            tmp[1] = 1.0f;\n            \n            tmp = imgOut0(proj0[0], proj0[1]);\n            tmp[0] = 1.0f;\n            \n            //second image\n            Eigen::Vector2i proj1 = pic::cameraMatrixProjection(M1, points_3d[i], cx1, cy1, fx1, fy1, lambda_out);\n            \n            tmp = imgOut1(int(m1f[i][0]), int(m1f[i][1]));\n            tmp[1] = 1.0f;\n            \n            tmp = imgOut1(proj1[0], proj1[1]);\n            tmp[0] = 1.0f;\n        }\n        \n        //write reprojection images\n        imgOut0.Write(\"../data/output/triangulation_reprojection_l.png\", pic::LT_NOR);\n        imgOut1.Write(\"../data/output/triangulation_reprojection_r.png\", pic::LT_NOR);\n\n    } else {\n        printf(\"No there is at least an invalid file!\\n\");\n    }\n    \n    return 0;\n}\n"
  },
  {
    "path": "examples/data/input/triangulation/campo_s_stefano_l_cam.txt",
    "content": "2092.197309 0.000000 1296.000000 0.000000 \n0.000000 2087.516779 864.000000 0.000000 \n0.000000 0.000000 1.000000 0.000000 "
  },
  {
    "path": "examples/data/input/triangulation/campo_s_stefano_r_cam.txt",
    "content": "2263.687389 -107.985109 959.668799 1609.943763 \n208.168630 2058.521445 907.401555 -358.098465 \n0.152242 -0.031125 0.987853 -0.297181 "
  },
  {
    "path": "examples/data/output/readme.txt",
    "content": "The results of samples go in this directory."
  },
  {
    "path": "examples/filtering_edge_aware/edge_aware_filtering.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = edge_aware_filtering\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/filtering_edge_aware/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/tommaseo_statue.png\";\n    }\n\n    printf(\"Reading an image...\");\n    pic::Image img;\n    img.Read(img_str, pic::LT_NOR_GAMMA);\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"Ok\\n\");\n\n        printf(\"Estimated noise:\\n\");\n        float *noise = pic::FilterNoiseEstimation::getNoiseEstimation(&img, NULL);\n        for(int i = 0; i < img.channels; i++) {\n            printf(\"Channel i-th: %f\\n\", noise[i]);\n        }\n\n        pic::ImageVec input = pic::Single(&img);\n        pic::Image *output = NULL;\n\n        bool bWritten;\n\n        std::string name = pic::removeExtension(img_str);\n        name = pic::removeLocalPath(name);\n\n        //the bilateral filter\n        printf(\"Filtering the image with a Fast Bilateral filter;\\n\");\n        printf(\"this has sigma_s = 4.0 and sigma_r = 0.05 ... \");\n\n        pic::FilterBilateral2DS flt(8.0f, 0.05f);\n        output = flt.Process(input, output);\n\n        //output = pic::FilterBilateral2DAS::execute(&img, output, 8.0f, 0.05f);\n\n        printf(\"Ok!\\n\");\n\n        printf(\"Writing the file to disk...\");\n\n        bWritten = output->Write(\"../data/output/\" + name + \"_filtered_bilateral.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        //the median filter\n        printf(\"Filtering the image with the Median filter (radius of 3);\\n\");\n\n        pic::FilterMed fltM(7);\n        output = fltM.Process(input, output);\n\n        printf(\"Ok!\\n\");\n\n        printf(\"Writing the file to disk...\");\n\n        bWritten = output->Write(\"../data/output/\" + name + \"_filtered_median.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        //the vector median filter\n        printf(\"Filtering the image with the Vector Median filter (radius of 3);\\n\");\n\n        pic::FilterMedVec fltMV(7);\n        output = fltMV.Process(input, output);\n\n        printf(\"Ok!\\n\");\n\n        printf(\"Writing the file to disk...\");\n\n        bWritten = output->Write(\"../data/output/\" + name + \"filtered_median_vec.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        //the Anisotropic Diffusion\n        printf(\"Filtering the image with the Anisotropic Diffusion;\\n\");\n        printf(\"this has sigma_s = 4.0 and sigma_r = 0.05 ... \");\n        output = pic::FilterAnsiotropicDiffusion::execute(input, output, 8.0f, 0.05f);\n        printf(\"Ok!\\n\");\n\n        printf(\"Writing the file to disk...\");\n        bWritten = output->Write(\"../data/output/\" + name + \"_filtered_anisotropic_diffusion.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        //the Guided Filter\n        printf(\"Filtering the image with the Guided filter...\");\n        pic::FilterGuided fltG;\n        output = fltG.Process(input, output);//filtering the image\n\n        printf(\"Writing the file to disk...\");\n        bWritten = output->Write(\"../data/output/\" + name + \"_filtered_guided.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        //WLS\n        printf(\"Filtering the image with the WLS filter...\");\n        pic::FilterWLS fltWLS;//creating the filter\n        output = fltWLS.Process(input, output);\n        printf(\"Ok!\\n\");\n\n        printf(\"Writing the file to disk...\");\n        bWritten = output->Write(\"../data/output/\" + name + \"_filtered_wls.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        //Kuwahara\n        printf(\"Filtering the image with the Kuwahara filter...\");\n        pic::FilterKuwahara fltK(11);\n        output = fltK.Process(input, output);\n\n        printf(\"Writing the file to disk...\");\n        bWritten = output->Write(\"../data/output/\" + name + \"filtered_kuwahara.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n    } else {\n        printf(\"No it is not a valid file!\\n\");\n    }\n}\n"
  },
  {
    "path": "examples/filtering_linear_filters/linear_filters.pro",
    "content": "# PICCANTE Examples\n# The hottest examples of Piccante:\n# http://vcg.isti.cnr.it/piccante\n#\n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n#\n# This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU General Public License as published by\n#    the Free Software Foundation, either version 3.0 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU General Public License for more details.\n#\n#    See the GNU Lesser General Public License\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n#\n\nTARGET = linear_filters\n\nQT       += core\n#TEMPLATE = app\n#CONFIG   += console\nCONFIG   += c++11\nCONFIG   -= app_bundle\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/filtering_linear_filters/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string name_str = \"../data/input/bottles.hdr\";\n    if(argc == 2) {\n        name_str = argv[1];\n    }\n\n    printf(\"Reading an HDR file...\");\n\n    pic::Image img;\n    img.Read(name_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"Ok\\n\");\n\n        printf(\"Filtering the image with a Gaussian filter with sigma = 4.0...\");\n        pic::Image *output = pic::FilterGaussian2D::execute(&img, NULL, 4.0f);\n\n        printf(\"Ok!\\n\");\n\n        auto name = pic::getFileNameOnly(name_str);\n\n        printf(\"Writing the file to disk...\");\n        bool bWritten = output->Write(\"../data/output/\" + name + \"_filtered_gaussian_4_0.hdr\");\n\n        printf(\"Filtering the image with a LoG filter with sigma = 2.0...\");\n        pic::Image *L = pic::FilterLuminance::execute(&img, NULL, pic::LT_CIE_LUMINANCE);\n        pic::Image *L_log = pic::FilterLoG2D::execute(L, NULL, 4.0f);\n\n        printf(\"Ok!\\n\");\n\n        printf(\"Writing the file to disk...\");\n        bWritten = L_log->Write(\"../data/output/\" + name + \"_filtered_log_2_0.hdr\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        pic::Image *edges = pic::FilterZeroCrossing::execute(L_log, NULL);\n        bWritten = edges->Write(\"../data/output/\" + name + \"filtered_log_2_0_edges.hdr\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        pic::Image *sampling_map = pic::FilterSamplingMap::execute(&img, NULL, 8.0f);\n        bWritten = sampling_map->Write(\"../data/output/\" + name + \"_sampling_map.hdr\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/filtering_remove_nuked/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n//This means we do not use QT for I/O\n#define PIC_DISABLE_QT\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    if(argc == 2) {\n        img0_str = argv[1];\n    } else {\n        img0_str = \"../data/input/cornellbox_mat_pt.pfm\";\n    }\n    printf(\"Reading an HDR file...\");\n\n    pic::Image img;\n    img.Read(img0_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"Ok\\n\");\n\n        printf(\"Filtering the image with a Gaussian filter with sigma_s = 4.0...\");\n\n        pic::Image *output = pic::FilterRemoveInfNaN::Execute(&img, NULL);\n        pic::Image *output2 = pic::FilterRemoveNuked::Execute(output, NULL, 0.95f);\n\n        printf(\"Ok!\\n\");\n\n        printf(\"Writing the file to disk...\");\n        bool bWritten = output2->Write(\"../data/output/filtered_nuked_removed.pfm\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/filtering_remove_nuked/remove_nuked.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = remove_nuked\n\nQT       += core\nTEMPLATE = app\nCONFIG   += c++11\nCONFIG   += console\nCONFIG   -= app_bundle\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/hdr_exposure_fusion/hdr_exposure_fusion.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = hdr_exposure_fusion\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/hdr_exposure_fusion/main.cpp",
    "content": " /*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/bottles.hdr\";\n    }\n\n    printf(\"Reading an HDR file...\");\n\n    pic::Image img;\n    img.Read(img_str, pic::LT_NOR);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        printf(\"Tone mapping using Exposure Fusion...\");\n\n        pic::Image *img_ef = pic::ExposureFusion::execute(&img, NULL);\n        printf(\"Ok\\n\");\n\n        printf(\"Writing the tone mapped image to disk...\\n\");\n\n        std::string name = pic::removeLocalPath(img_str);\n\n        bool bWritten = img_ef->Write(\"../data/output/\"+ pic::removeExtension(name)  + \"_ef.png\", pic::LT_NOR);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        printf(\"Tone mapping using Raman Fusion Operator...\");\n\n        pic::Image *img_rf = pic::RamanTMO::execute(&img, NULL);\n\n        bWritten = img_rf->Write(\"../data/output/\"+ pic::removeExtension(name)  + \"_rf.png\", pic::LT_NOR);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n    } else {\n        printf(\"No it is not a valid file!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/hdr_exposure_fusion_stack/hdr_exposure_fusion_stack.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = hdr_exposure_fusion_stack\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/hdr_exposure_fusion_stack/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    printf(\"Reading a stack of LDR images...\");\n    //reading images and storing them with normalized values in [0,1]\n    pic::Image img[3];\n    img[0].Read(\"../data/input/stack_alignment/IMG_4209.jpg\", pic::LT_NOR);\n    img[1].Read(\"../data/input/stack_alignment/IMG_4210.jpg\", pic::LT_NOR);\n    img[2].Read(\"../data/input/stack_alignment/IMG_4211.jpg\", pic::LT_NOR);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Are these images valid? \");\n    if(img[0].isValid() && img[1].isValid() && img[2].isValid()) {\n        printf(\"Ok\\n\");\n\n        printf(\"Aligning bright and dark exposure images to the well-exposed one... \");\n        pic::Vec2i shift_dark;\n        pic::Image *img_dark = pic::WardAlignment::execute(&img[0], &img[1], shift_dark);\n        img_dark->Write(\"../data/output/stack_aligned_dark.png\", pic::LT_NOR);\n\n        pic::Vec2i shift_bright;\n        pic::Image *img_bright = pic::WardAlignment::execute(&img[0], &img[2], shift_bright);\n        img_bright->Write(\"../data/output/stack_aligned_bright.png\", pic::LT_NOR);\n        printf(\"Ok\\n\");\n\n        printf(\"Fusing the aligned images... \");\n        auto image_vec = pic::Triple(img_bright, &img[0], img_dark);\n        pic::Image *imgOut1 = pic::ExposureFusion::executeStack(image_vec, NULL);\n\n        if(imgOut1 != NULL) {\n            imgOut1->Write(\"../data/output/stack_aligned_exposure_fusion.png\", pic::LT_NOR);\n        }\n\n        pic::Image *imgOut2 = pic::RamanTMO::executeStack(image_vec, NULL);\n\n        if(imgOut2 != NULL) {\n            imgOut2->Write(\"../data/output/stack_aligned_raman.png\", pic::LT_NOR);\n        }\n\n        printf(\"Ok\\n\");\n\n    } else {\n        printf(\"No, the files are not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/hdr_generation/hdr_generation.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = hdr_generation\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/hdr_generation/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    printf(\"Adding file names to the merger...\");\n    pic::HDRMerger merger;\n\n    for(int i = 0; i < 7; i++) {\n        std::string name = \"../data/input/stack/stack_room_exp_\" + pic::fromNumberToString(i) + \".jpg\";\n        merger.addFile(name);\n    }\n\n    printf(\"\\nOk\\n\");\n\n    printf(\"Merging LDR images into an HDR image...\");\n    pic::Image *imgOut = merger.execute(NULL);\n    printf(\"\\nOk\\n\");\n\n    if(imgOut != NULL) {\n        if(imgOut->isValid()) {\n            imgOut->Write(\"../data/output/image_debevec_crf.hdr\");\n            pic::Image *imgTmo = pic::ReinhardTMO::executeGlobal1(imgOut, NULL);\n            imgTmo->Write(\"../data/output/image_debevec_crf_tmo.png\", pic::LT_NOR_GAMMA);\n            delete imgTmo;\n            delete imgOut;\n        }\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/hdr_generation_alignment/hdr_generation_alignment.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = hdr_generation_alignment\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/hdr_generation_alignment/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    printf(\"Adding file names to the merger... \");\n    pic::HDRMerger merger;\n    merger.addFile(\"../data/input/stack_alignment/IMG_4209.jpg\");\n    merger.addFile(\"../data/input/stack_alignment/IMG_4210.jpg\");\n    merger.addFile(\"../data/input/stack_alignment/IMG_4211.jpg\");\n    printf(\"Ok\\n\");\n\n    merger.update(pic::CW_DEB97, pic::HRD_LOG, pic::HA_MTB, NULL);\n\n    printf(\"Merging LDR images into an HDR image... \");\n    pic::Image *imgOut = merger.execute(NULL);\n    printf(\"Ok\\n\");\n\n    if(imgOut != NULL) {\n        if(imgOut->isValid()) {\n            imgOut->Write(\"../data/output/image_aligned.hdr\");\n            pic::Image *imgTmo = pic::ReinhardTMO::executeGlobal1(imgOut, NULL);\n            imgTmo->Write(\"../data/output/image_aligned_tmo.png\", pic::LT_NOR_GAMMA);\n            delete imgTmo;\n            delete imgOut;\n        }\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/hdr_metrics/hdr_metrics.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = hdr_metrics\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n    DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/hdr_metrics/main.cpp",
    "content": "//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img0_str, img1_str;\n    bool bCreate = false;\n\n    if(argc == 3) {\n        img0_str = argv[1];\n        img1_str = argv[2];\n    } else {\n        img0_str = \"../data/input/bottles.hdr\";\n        bCreate = true;\n    }\n\n    pic::Image img0, img1;\n    img0.Read(img0_str);\n\n    bool bLoaded = false;\n    if(!bCreate) {\n        bLoaded = img1.Read(img1_str);\n    }\n\n    printf(\"Is it valid? \");\n    if(img0.isValid() && (bCreate || bLoaded)) {\n        printf(\"OK\\n\");\n\n        std::string name = pic::removeLocalPath(img0_str);\n        auto name_ext = pic::getExtension(name);\n        name = pic::removeExtension(name);\n\n        pic::Image *tmp;\n        if(bCreate) {\n            printf(\"Filtering the input image (blurring)...\");\n            tmp = pic::FilterGaussian2D::execute(&img0, NULL, 4.0f);\n            printf(\"Ok\\n\");\n            tmp->Write(\"../data/output/\" + name + \"_flt.\" + name_ext);\n        } else {\n            tmp = &img1;\n        }\n\n        float ssim_index, ssim_index_pu;\n        pic::SSIMIndex ssim;\n        pic::Image *ssim_map = ssim.execute(Double(&img0, tmp), ssim_index, NULL);\n        printf(\"Ok\\n\");\n\n        if(ssim_map != NULL) {\n            ssim_map->Write(\"../data/output/\" + name + \"_ssim_map_lin.pfm\");\n        }\n\n        ssim.update(-1.0f, -1.0f, -1.0f, -1.0f, true, pic::MD_PU08);\n        ssim_map = ssim.execute(Double(&img0, tmp), ssim_index_pu, ssim_map);\n\n        if(ssim_map != NULL) {\n            ssim_map->Write(\"../data/output/\" + name + \"_ssim_map_pu.pfm\");\n        }\n\n        printf(\"SSIM (classic): %3.3f \\t  SSIM (PU-encoding): %3.3f\\n\",\n               ssim_index, ssim_index_pu);\n\n        printf(\"MSE (classic): %3.3f \\t  MSE (PU-encoding): %3.3f\\n\",\n               pic::MSE(&img0, tmp, false, pic::MD_LIN),\n               pic::MSE(&img0, tmp, false, pic::MD_PU08));\n\n        printf(\"RMSE (classic): %3.3f \\t  RMSE (PU-encoding): %3.3f\\n\",\n        pic::RMSE(&img0, tmp, false, pic::MD_LIN),\n        pic::RMSE(&img0, tmp, false, pic::MD_PU08));\n\n        printf(\"PSNR (classic): %3.3f \\t PSNR (PU-encoding): %3.3f\\n\",\n               pic::PSNR(&img0, tmp, -1.0f, false, pic::MD_LIN ),\n               pic::PSNR(&img0, tmp, -1.0f, false, pic::MD_PU08 ));\n\n        printf(\"MAE (classic): %3.3f \\t MAE (PU-encoding): %3.3f\\n\",\n               pic::MAE(&img0, tmp, false, pic::MD_LIN),\n               pic::MAE(&img0, tmp, false, pic::MD_PU08));\n\n        printf(\"Relative Error (classic): %3.3f \\t Relative Error (PU-encoding): %3.3f\\n\",\n               pic::RelativeError(&img0, tmp, false, pic::MD_LIN),\n               pic::RelativeError(&img0, tmp, false, pic::MD_PU08));\n\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/hdr_tmqi/hdr_tmqi.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = hdr_metrics\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/hdr_tmqi/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img0_str, img1_str;\n    bool bCreate = false;\n\n    if(argc == 3) {\n        img0_str = argv[1];\n        img1_str = argv[2];\n    } else {\n        img0_str = \"../data/input/bottles.hdr\";\n        bCreate = true;\n    }\n\n    pic::Image img0, img1;\n    img0.Read(img0_str, pic::LT_NOR);\n\n    bool bLoaded = false;\n    if(!bCreate) {\n        //this an LDR image with values in [0,255]!\n        bLoaded = img1.Read(img1_str, pic::LT_NONE);\n    }\n\n    printf(\"Is it valid? \");\n    if(img0.isValid() && (bCreate || bLoaded)) {\n        printf(\"OK\\n\");\n\n        std::string name = pic::removeLocalPath(img0_str);\n        name = pic::removeExtension(name);\n\n        pic::Image *tmp = NULL;\n        if(bCreate) {\n            printf(\"Tone mapping the input image...\");\n            pic::DragoTMO dtmo;\n            tmp = dtmo.Process(Single(&img0), tmp);\n            printf(\"Ok\\n\");\n            tmp->Write(\"../data/output/\" + name + \"_flt.png\");\n\n            tmp->applyFunction(pic::simple8bitWithGamma);\n        } else {\n            tmp = &img1;\n        }        \n\n        float Q, N, S;\n        pic::TMQI tmqi;\n        tmqi.execute(pic::Double(&img0, tmp), Q, N, S, NULL);\n        printf(\"TMQI -- Q: %f N: %f S: %f\\n\", Q, N, S);\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/hdr_tone_color_correction/hdr_tone_mapping_color_correction.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = hdr_tone_mapping_color_correction\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/hdr_tone_color_correction/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n#include <QCoreApplication>\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/bottles.hdr\";\n    }\n\n    printf(\"Reading an HDR file...\");\n\n    pic::Image img;\n    img.Read(img_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        std::string nameOut = pic::getFileNameOnly(img_str);\n\n        bool bWritten;\n        pic::Image *image_tmo = NULL;\n\n        printf(\"Tone mapping using global Reinhard et al.'s TMO...\");\n        image_tmo = pic::ReinhardTMO::executeGlobal1(&img, image_tmo);\n        image_tmo->clamp(0.0f, 1.0f);\n\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::ReinhardTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_reinhard_gtmo1_cc_without.png\", pic::LT_NOR_GAMMA);\n\n        //Color Correction using Pouli et al.'s method\n\n        pic::Image *image_tmo_cc = pic::FilterColorCorrectionPouli::execute(&img, image_tmo, NULL);\n        bWritten = image_tmo_cc->Write(\"../data/output/\" + nameOut + \"_reinhard_gtmo1_cc.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/hdr_tone_mappers/hdr_tone_mapping.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = hdr_tone_mapping\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/hdr_tone_mappers/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n#include <QCoreApplication>\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/bottles.hdr\";\n    }\n\n    printf(\"Reading an HDR file...\");\n\n    pic::Image img;\n    img.Read(img_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        std::string nameOut = pic::getFileNameOnly(img_str);\n\n        bool bWritten;\n        pic::Image *image_tmo = NULL;\n\n        printf(\"Tone mapping using Schlick 1994 TMO...\");\n        image_tmo = pic::SchlickTMO::execute(&img, image_tmo);\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::Schlick tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_schlick_tmo.png\", pic::LT_NOR_GAMMA);\n\n\n        printf(\"Tone mapping using Ferwerda et al. 1996 TMO...\");\n        image_tmo = pic::FerwerdaTMO::execute(&img, image_tmo);\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::FerwerdaTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_ferwerda_tmo.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        printf(\"Tone mapping using global Reinhard et al.'s TMO...\");\n        image_tmo = pic::ReinhardTMO::executeGlobal1(&img, image_tmo);\n\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::ReinhardTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_reinhard_gtmo1.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        printf(\"Tone mapping using global Reinhard et al.'s TMO...\");\n        image_tmo = pic::ReinhardTMO::executeGlobal2(&img, image_tmo);\n\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::ReinhardTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_reinhard_gtmo2.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        printf(\"Tone mapping using local Reinhard et al.'s TMO...\");\n        image_tmo = pic::ReinhardTMO::executeLocal1(&img, image_tmo);\n\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::ReinhardTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_reinhard_ltmo1.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        printf(\"Tone mapping using local Reinhard et al.'s TMO...\");\n        image_tmo = pic::ReinhardTMO::executeLocal2(&img, image_tmo);\n\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::ReinhardTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_reinhard_ltmo2.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        printf(\"Tone mapping using Durand and Dorsey's TMO...\");\n        image_tmo = pic::DurandTMO::execute(&img, image_tmo);\n\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::DurandTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_durand_tmo.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n\n        printf(\"Tone mapping using Drago et al.'s TMO...\");\n        image_tmo = pic::DragoTMO::execute(&img, image_tmo);\n\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::DragoTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_drago_tmo.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        printf(\"Tone mapping using Ward Histogram Adjustment TMO...\");\n        image_tmo = pic::WardHistogramTMO::execute(&img, image_tmo);\n\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::WardTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_ward_tmo.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        printf(\"Tone mapping using Lischinski et al. 2006 automatic TMO...\");\n        image_tmo = pic::LischinskiTMO::execute(&img, image_tmo);\n\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::LischinskiTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_lischinski_tmo.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        printf(\"Tone mapping using Tumblin et al. 1999 TMO...\");\n        image_tmo = pic::TumblinTMO::execute(&img, image_tmo);\n\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::LischinskiTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_tumblin_tmo.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        printf(\"Tone mapping using Ward Global TMO...\");\n        image_tmo = pic::WardGlobalTMO::execute(&img, image_tmo);\n\n        /*pic::LT_NOR_GAMMA implies that when we save the image,\n          this is quantized at 8-bit and gamma is applied.\n          Note that pic::WardGlobalTMO tone maps an HDR image\n          but it does not apply gamma.*/\n        bWritten = image_tmo->Write(\"../data/output/\" + nameOut + \"_ward_global_tmo.png\", pic::LT_NOR_GAMMA);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/hdr_tone_mapping_simple/hdr_tone_mapping_simple.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = hdr_tone_mapping_simple\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/hdr_tone_mapping_simple/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n//This means we do not use QT for I/O\n#define PIC_DISABLE_QT\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/bottles.hdr\";\n    }\n\n    printf(\"Reading an HDR file...\");\n\n    pic::Image img;\n    img.Read(img_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        //we estimate the best exposure for this HDR image\n        float fstop = pic::findBestExposureHistogram(&img);\n\n        printf(\"The best exposure value (histogram-based) is: %f f-stops\\n\", fstop);\n\n        pic::FilterSimpleTMO fltSimpleTMO(2.2f, fstop);\n\n        pic::Image *img_histo_tmo = fltSimpleTMO.Process(Single(&img), NULL);\n\n        /*pic::LT_NOR implies that when we save the image\n          we just convert it to 8-bit withou applying gamma.\n          In this case, this is fine, because gamma was already applied\n          in the pic::FilterSimpleTMO*/\n        bool bWritten = img_histo_tmo->Write(\"../data/output/simple_exp_histo_tmo.bmp\", pic::LT_NOR);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        //\n        //\n        //\n\n        //we estimate the best exposure for this HDR image\n        fstop = pic::findBestExposureMean(&img, false);\n\n        printf(\"The best exposure value (mean-based) is: %f f-stops\\n\", fstop);\n\n        fltSimpleTMO.update(2.2f, fstop);\n\n        pic::Image *img_mean_tmo = fltSimpleTMO.Process(Single(&img), NULL);\n\n        /*pic::LT_NOR implies that when we save the image\n          we just convert it to 8-bit withou applying gamma.\n          In this case, this is fine, because gamma was already applied\n          in the pic::FilterSimpleTMO*/\n        bWritten = img_mean_tmo->Write(\"../data/output/simple_exp_mean_tmo.bmp\", pic::LT_NOR);\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n    } else {\n        printf(\"No it is not a valid file!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_binarization/ip_binarization.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_binarization\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_binarization/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/singapore.png\";\n    }\n\n    printf(\"Reading an LDR file...\");\n\n    pic::Image img(img_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        bool bWritten;\n        std::string name = pic::getFileNameOnly(img_str);\n\n        pic::Image *img_out = pic::binarization(&img, NULL, false);\n\n\n        bWritten = img_out->Write(\"../data/output/\" + name + \"_global_bin.png\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        img_out = pic::binarization(&img, img_out, true);\n\n        bWritten = img_out->Write(\"../data/output/\" + name + \"_adaptive_bin.png\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_color_matrix/ip_color_matrix.pro",
    "content": "## PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_color_matrix\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_color_matrix/main.cpp",
    "content": " /*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    //RGB primaries in xyY color space\n    float r[] = {0.64f, 0.33f, 0.216f};\n    float g[] = {0.3f, 0.6f, 0.7152f};\n    float b[] = {0.15f, 0.06f, 0.0722f};\n\n    //conversion of the primaries from xyY to XYZ\n    float rXYZ[3];\n    float gXYZ[3];\n    float bXYZ[3];\n    pic::ColorConvXYZtoxyY conv;\n    conv.inverse(r, rXYZ);\n    conv.inverse(g, gXYZ);\n    conv.inverse(b, bXYZ);\n\n    //compute the conversion matrix from XYZ to RGB\n    float *mtx = pic::createMatrixFromPrimaries(rXYZ, gXYZ, bXYZ, NULL, NULL);\n\n    printf(\"Matrix from XYZ to sRGB (linear) matrix:\\n\");\n    for(int i = 0; i < 3; i++) {\n        for(int j = 0; j < 3; j++) {\n            printf(\"%f \", mtx[i * 3 + j]);\n        }\n        printf(\"\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_color_transform/ip_color_transform.pro",
    "content": "## PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_color_transform\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_color_transform/main.cpp",
    "content": " /*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/singapore.png\";\n    }\n\n    printf(\"Reading an LDR file...\");\n\n    pic::Image img;\n    img.Read(img_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        //from RGB to CIE Lab\n        pic::Image *img_CIE_Lab = pic::FilterColorConv::fromRGBtoCIELAB(&img, NULL);\n\n        //from CIE Lab to RGB\n        pic::Image *img_RGB = pic::FilterColorConv::fromCIELABtoRGB2(img_CIE_Lab, NULL);\n\n        printf(\"Writing the file to disk...\");\n        bool bWritten = img_CIE_Lab->Write(\"../data/output/singapore_CIE_Lab.pfm\");\n        bWritten = bWritten && img_RGB->Write(\"../data/output/singapore_RGB.png\");\n\n        if(bWritten) {\n            printf(\" Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_dct_decomposition/ip_dct_decomposition.pro",
    "content": "## PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_dct_decomposition\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_dct_decomposition/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/singapore.png\";\n    }\n\n    printf(\"Reading an LDR file...\");\n\n    pic::Image img;\n    img.Read(img_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        printf(\"DCT transform...\");\n        pic::Image *img_dct = pic::FilterDCT2D::Transform(&img, NULL, 8);\n        printf(\" Ok\\n\");\n\n        printf(\"Removing small coefficients...\");\n        for(int i = 0; i < img_dct->size(); i++) {\n            if(fabsf(img_dct->data[i]) < 0.025f) {\n                img_dct->data[i] = 0.0f;\n            }\n        }\n        printf(\" Ok\\n\");\n\n        pic::Image *imgOut = pic::FilterDCT2D::Inverse(img_dct, NULL, 8);\n\n        printf(\"Writing the file to disk...\");\n        bool bWritten = imgOut->Write(\"../data/output/ip_simple_dct.png\");\n\n        if(bWritten) {\n            printf(\" Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_debayering/ip_debayering.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_debayering\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n        DEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_debayering/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n#include <QCoreApplication>\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/yellow_flowers.png\";\n    }\n\n    printf(\"Reading an HDR file...\");\n\n    pic::Image img;\n    img.Read(img_str);\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n\n        printf(\"OK\\n\");\n\n        printf(\"Creating an image with bayering RGGB...\");\n        pic::Image *img_RGGB = pic::FilterMosaic::execute(&img, NULL);\n        printf(\"Ok\\n\");\n\n        printf(\"Debayering the image...\");\n        pic::Image out(1, img.width, img.height, img.channels);\n        pic::FilterDemosaic::execute(img_RGGB, &out);\n        printf(\"Ok\\n\");\n\n        printf(\"Computing the difference image...\");\n        img -= out;\n        img.applyFunction(fabsf);\n        printf(\"Ok\\n\");\n\n        printf(\"Writing results...\");\n        img_RGGB->Write(\"../data/output/img_mosaiced.png\");\n        out.Write(\"../data/output/img_demosaiced.png\");\n        img.Write(\"../data/output/img_demosaiced_difference.png\");\n        printf(\"Ok\\n\");\n\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_deblurring/ip_deblurring.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_deblurring\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_deblurring/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str, psf_str;\n\n    if(argc == 3) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/bottles.hdr\";\n        psf_str = \"../data/input/kernel_psf.png\";\n    }\n\n    printf(\"Reading images...\");\n\n    pic::Image img;\n    img.Read(img_str);\n\n    pic::Image psf;\n    psf.Read(psf_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid() && psf.isValid()) {\n        printf(\"Ok\\n\");\n\n        //normalization of the PSF\n        psf /= psf.getSumVal(NULL, NULL)[0];\n\n        pic::Image *conv = pic::FilterConv2D::execute(&img, &psf, NULL);\n        conv->Write(\"../data/output/image_conv_kernel_psf.png\");\n\n        printf(\"Ok!\\n\");\n\n        printf(\"Deconvolving the image with the PSF read from file...\");\n        pic::Image *deconv = pic::FilterDeconvolution::execute(conv, &psf, NULL, 1000);\n\n        printf(\"Ok!\\n\");\n\n        printf(\"Writing the file to disk...\");\n        bool bWritten = deconv->Write(\"../data/output/image_deconv_kernel_psf.png\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_deform_grid/ip_deform_grid.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_deform_grid\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\n\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_deform_grid/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/grid.png\";\n    }\n\n    printf(\"Reading an image...\");\n    pic::Image img;\n    img.Read(img_str, pic::LT_NOR);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        pic::Image *grid_move = pic::FilterDeformGrid::getUniformGrid(17, 17);\n        float *grid = (*grid_move)(4, 4);\n        grid[0] += 1 / 32.0f;\n        grid[1] += 1 / 32.0f;\n\n        pic::FilterDeformGrid flt_dg(grid_move);\n\n        pic::Image *out = flt_dg.Process(Single(&img), NULL);\n\n        bool bWrite = out->Write(\"../data/output/img_deformation.png\", pic::LT_NOR);\n\n        if(bWrite) {\n            printf(\"The output was written sucessfully!\\n\");\n        } else {\n            printf(\"The output was not written\\n\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_edge/ip_edge.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_edge\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_edge/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/features/checker_board_photo_2.png\";\n    }\n\n    printf(\"Reading an LDR file...\");\n\n    pic::Image img(img_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        bool bWritten;\n        std::string name = pic::getFileNameOnly(img_str);\n\n        pic::CannyEdgeDetector ced;\n\n        pic::Image *img_edges = ced.execute(&img, NULL);\n\n        bWritten = img_edges->Write(\"../data/output/\" + name + \"_edges.png\");\n\n        bool *mask = img_edges->convertToMask(NULL, 0.5f, true, NULL);\n\n        bool *mask_thin = pic::Mask::thinning(NULL, mask, img.width, img.height);\n\n        img_edges->convertFromMask(mask_thin, img.width, img.height);\n\n        bWritten = img_edges->Write(\"../data/output/\" + name + \"_edges_thin.png\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_gray_scale/ip_gray_scale.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_gray_scale\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_gray_scale/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/singapore.png\";\n    }\n\n    printf(\"Reading an LDR file...\");\n\n    pic::Image img(img_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        bool bWritten;\n\n        //Computing grey scale by computing the mean of color channels\n        printf(\"Computing a gray scale image by computing the mean of color channels...\");\n        pic::Image *img_mean = pic::FilterLuminance::Execute(&img, NULL, pic::LT_MEAN);\n\n        bWritten = img_mean->Write(\"../data/output/singapore_mean.png\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        //Computing grey scale by computing the weighted average following CIE weights for Y\n        printf(\"Computing a gray scale image by computing the weighted mean of color channels using CIE weights for Y...\");\n        pic::Image *img_cie_y = pic::FilterLuminance::Execute(&img, NULL, pic::LT_CIE_LUMINANCE);\n\n        bWritten = img_cie_y->Write(\"../data/output/singapore_cie_y.png\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n\n        //Computing grey scale by using Exposure Fusion\n        printf(\"Computing a gray scale image by using Exposure Fusion...\");\n        pic::Image *img_cg_ef = pic::colorToGray(&img, NULL);\n\n        bWritten = img_cg_ef->Write(\"../data/output/singapore_cg_ef.png\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_histogram_matching/ip_histogram_matching.pro",
    "content": "## PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_histogram_matching\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_histogram_matching/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    printf(\"Reading source and target images...\");\n\n    pic::Image img_source, img_target;\n\n    std::string img_source_str, img_target_str, img_out_str;\n\n    if(argc == 4) {\n        img_source_str = argv[1];\n        img_target_str = argv[2];\n        img_out_str = argv[3];\n    } else {\n        img_source_str = \"../data/input/histogram_matching/source.png\";\n        img_target_str = \"../data/input/histogram_matching/target.png\";\n        img_out_str = \"../data/output/histogram_matching.png\";\n    }\n\n    img_source.Read(img_source_str, pic::LT_NOR_GAMMA);\n    img_target.Read(img_target_str, pic::LT_NOR_GAMMA);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Are these valid? \");\n    if(img_source.isValid() && img_target.isValid()) {\n\n        pic::Image *out = pic::HistogramMatching::execute(&img_source, &img_target, NULL);\n        out->Write(img_out_str);\n\n        auto name = pic::removeExtension(img_out_str);\n\n        pic::Image *out_eq_1 = pic::HistogramMatching::executeEqualization(&img_source);\n        out_eq_1->Write(name + \"_source_equalization.png\");\n\n        pic::Image *out_eq_2 = pic::HistogramMatching::executeEqualization(&img_target);\n        out_eq_2->Write(name + \"_target_equalization.png\");\n\n        pic::Image *out_eq_1_local = pic::FilerCLAHE::execute(&img_source, NULL, 128);\n        out_eq_1_local->Write(name + \"_target_clahe.png\");\n\n    } else {\n        printf(\"No, the files are not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_image_transform/ip_image_transform.pro",
    "content": "## PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_image_transform\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_image_transform/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n//This means we do not use QT for I/O\n#define PIC_DISABLE_QT\n\n#include \"piccante.hpp\"\n\n#include<chrono>\n#include<ctime>\n\nint main(int argc, char *argv[])\n{\n    printf(\"Reading an HDR file...\");\n\n    pic::Image img;\n    img.Read(\"../data/input/tommaseo_statue.png\");\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        bool bSameSize = true; //the output image is going to be the sames size of the input one\n\n        //setting up a (64,64) pixels translation matrix\n        printf(\"\\nTranslating the image of 64,64 pixels...\");\n        pic::Matrix3x3 h;\n        h.setTranslationMatrix(64.0f, 64.0f);\n\n        pic::Image *imgOut_tra = pic::FilterWarp2D::execute(&img, NULL, h, bSameSize);\n        printf(\"Ok\\n\");\n\n        printf(\"Writing the output...\");\n        bool bWritten = imgOut_tra->Write(\"../data/output/ip_translated_64_64_pixels.bmp\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        //set up a 45 degree rotation matrix\n        printf(\"\\nRotating the image of 45 degrees...\");\n        h.setRotationMatrix(pic::Deg2Rad(45.0f));\n\n        pic::Image *imgOut_rot = pic::FilterWarp2D::execute(&img, NULL, h, bSameSize, true);\n        printf(\"Ok\\n\");\n\n        printf(\"Writing the output...\");\n        bWritten = imgOut_rot->Write(\"../data/output/ip_rotated_45_degrees.bmp\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        //set up a shear degree rotation matrix\n        printf(\"\\nApplying shear transform to the image...\");\n        h.setShearMatrix(0.2f, 0.1f);\n        pic::Image *imgOut_sheared = pic::FilterWarp2D::execute(&img, NULL, h, bSameSize, true);\n\n        printf(\"Ok\\n\");\n\n        printf(\"Writing the output...\");\n        bWritten = imgOut_sheared->Write(\"../data/output/ip_shear_transform.bmp\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n\n        //set up a scaling matrix\n        printf(\"\\nApplying a scaling transform to the image...\");\n        h.setScaleMatrix(0.5f, 0.75f);\n        pic::Image *imgOut_scaled = pic::FilterWarp2D::execute(&img, NULL, h, bSameSize, true);\n\n        printf(\"Ok\\n\");\n\n        printf(\"Writing the output...\");\n        bWritten = imgOut_scaled->Write(\"../data/output/ip_scaled.bmp\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_io/ip_io.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_io\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_io/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n#define PIC_DISABLE_EIGEN\n#define PIC_ENABLE_INLINING\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str = \"\";\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/bottles.hdr\";\n    }\n\n    printf(\"Reading a .hdr file...\");\n\n    pic::Image img;\n    img.Read(img_str);\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        //test native writing formats\n        pic::StringVec outputFormats;\n        outputFormats.push_back(\"bmp\");\n        outputFormats.push_back(\"tga\");\n        outputFormats.push_back(\"ppm\");\n        outputFormats.push_back(\"pgm\");\n        outputFormats.push_back(\"pfm\");\n        outputFormats.push_back(\"hdr\");\n        outputFormats.push_back(\"exr\");\n\n        for(unsigned int i = 0; i < outputFormats.size(); i++) {\n            std::string text = \"Writing the file to disk as \" + outputFormats[i] + \" file... \";\n            printf(\"%s\", text.c_str());\n            bool bWritten = img.Write(\"../data/output/image.\" + outputFormats[i]);\n\n            if(bWritten) {\n                printf(\"Ok\\n\");\n            } else {\n                printf(\"Writing had some issues!\\n\");\n            }\n        }\n\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_metrics/ip_metrics.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_metrics\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n    DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_metrics/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img0_str, img1_str;\n    bool bCreate = false;\n\n    if(argc == 3) {\n        img0_str = argv[1];\n        img1_str = argv[2];\n    } else {\n        img0_str = \"../data/input/singapore.png\";\n        bCreate = true;\n    }\n\n    //Image values are loaded and normalized in [0, 1];\n    //NOTE: gamma removal or CRF linearization are NOT applied.\n    pic::Image img0, img1;\n    img0.Read(img0_str, pic::LT_NOR);\n\n    bool bLoaded = false;\n    if(!bCreate) {\n        bLoaded = img1.Read(img1_str, pic::LT_NOR);\n    }\n\n    printf(\"Is it valid? \");\n    if(img0.isValid() && (bCreate || bLoaded)) {\n        printf(\"OK\\n\");\n\n        std::string name = pic::removeLocalPath(img0_str);\n        auto name_ext = pic::getExtension(name);\n        name = pic::removeExtension(name);\n\n        pic::Image *tmp;\n        if(bCreate) {\n            printf(\"Filtering the input image (blurring)...\");\n            tmp = pic::FilterGaussian2D::execute(&img0, NULL, 16.0f);\n            printf(\"Ok\\n\");\n            tmp->Write(\"../data/output/\" + name + \"_flt.\" + name_ext);\n        } else {\n            tmp = &img1;\n        }\n\n        float ssim_index;\n        pic::SSIMIndex ssim;\n        pic::Image *ssim_map = ssim.execute(Double(&img0, tmp), ssim_index, NULL);\n        printf(\"Ok\\n\");\n\n        if(ssim_map != NULL) {\n            ssim_map->Write(\"../data/output/\" + name + \"_ssim_map.pfm\");\n        }\n\n        printf(\"SSIM index: %3.3f\\n\", ssim_index);\n        printf(\"MSE: %3.3f\\n\", pic::MSE(&img0, tmp, false));\n        printf(\"RMSE: %3.3f\\n\", pic::RMSE(&img0, tmp));\n        printf(\"PSNR: %3.3f\\n\", pic::PSNR(&img0, tmp, -1.0f, false, pic::MD_PU ));\n        printf(\"MAE: %3.3f\\n\", pic::MAE(&img0, tmp, false));\n        printf(\"Relative Error: %f\\n\", pic::RelativeError(&img0, tmp));\n\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_sampling/ip_sampling.pro",
    "content": "## PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_sampling\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_sampling/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n//This means we do not use QT for I/O\n#define PIC_DISABLE_QT\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    printf(\"Reading an HDR file...\");\n\n    pic::Image img;\n    img.Read(\"../data/input/bottles.hdr\");\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        pic::ImageSamplerGaussian is_lc;\n        pic::Image *out_d = pic::FilterDownSampler2D::Execute(&img, NULL, 0.5f);\n        if(out_d != NULL) {\n            out_d->Write(\"../data/output/bottles_half_gaussian.hdr\");\n        }\n\n        pic::ImageSamplerNearest is_near;\n        pic::Image *out = pic::FilterSampler2D::Execute(&img, NULL, 2.0f, &is_near);\n\n        if(out != NULL) {\n            out->Write(\"../data/output/bottles_2x_nearest.hdr\");\n        }\n\n        pic::ImageSamplerBilinear is_bil;\n        out = pic::FilterSampler2D::Execute(&img, out, 2.0f, &is_bil);\n\n        if(out != NULL) {\n            out->Write(\"../data/output/bottles_2x_bilinear.hdr\");\n        }\n\n        pic::ImageSamplerCatmullRom is_cr;\n        out = pic::FilterSampler2D::Execute(&img, out, 2.0f, &is_cr);\n\n        if(out != NULL) {\n            out->Write(\"../data/output/bottles_2x_catmull_rom.hdr\");\n        }\n\n        pic::ImageSamplerBicubic is_bic;\n        out = pic::FilterSampler2D::Execute(&img, out, 2.0f, &is_bic);\n\n        if(out != NULL) {\n            out->Write(\"../data/output/bottles_2x_bicubic.hdr\");\n        }\n\n        pic::ImageSamplerLanczos is_lan;\n        out = pic::FilterSampler2D::Execute(&img, out, 2.0f, &is_lan);\n\n        if(out != NULL) {\n            out->Write(\"../data/output/bottles_2x_lanczos.hdr\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/image_processing_white_balance/ip_white_balance.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_white_balance\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/image_processing_white_balance/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/tommaseo_statue.png\";\n    }\n\n    printf(\"Reading images...\");\n    pic::Image img(img_str, pic::LT_NOR_GAMMA);\n    printf(\"Is the image valid? \");\n\n    if(img.isValid()) {\n        pic::Image *out = pic::FilterWhiteBalance::execute(&img, 200, 200, true);\n\n        std::string name = pic::removeExtension(img_str);\n        name = pic::removeLocalPath(name);\n\n        bool bWrite = out->Write(\"../data/output/\" + name + \"_wb.png\", pic::LT_NOR_GAMMA, 0);\n\n        if(!bWrite) {\n            printf(\"The image could not be written.\\n\");\n        }\n\n        if(out != NULL) {\n            delete out;\n        }\n\n        return bWrite ? 1 : 0;\n    } else {\n        printf(\"The image could not be read.\\n\");\n        return 0;\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/jni_computer_vision_find_checker_board/cv_find_checker_board.pro",
    "content": "# PICCANTE Examples\n# The hottest examples of Piccante:\n# http://vcg.isti.cnr.it/piccante\n#\n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n#\n# This program is free software: you can redistribute it and/or modify\n#    it under the terms of the GNU General Public License as published by\n#    the Free Software Foundation, either version 3.0 of the License, or\n#    (at your option) any later version.\n#\n#    This program is distributed in the hope that it will be useful,\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#    GNU General Public License for more details.\n#\n#    See the GNU Lesser General Public License\n#    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n#\n\nTARGET = cv_find_checker_board\n\nQT       += core\n#TEMPLATE = app\n#CONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/jni_computer_vision_find_checker_board/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n//#define PIC_DEBUG\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/checkerboards/checker_board_photo_2.png\";\n    }\n\n    auto start = std::chrono::system_clock::now();\n\n    std::vector<int> ret = pic::extractCheckerBoardJNI(img_str, \"../data/output/checker_board_photo_wb.png\");\n\n    auto end = std::chrono::system_clock::now();\n    std::chrono::duration<double> elapsed_seconds = end - start;\n     std::time_t end_time = std::chrono::system_clock::to_time_t(end);\n\n     std::cout << \"finished computation at \" << std::ctime(&end_time)\n               << \"elapsed time: \" << elapsed_seconds.count() << \"s\\n\";\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/jni_image_processing_white_balance/ip_white_balance.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = ip_white_balance\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/jni_image_processing_white_balance/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/features/tommaseo_statue.png\";\n    }\n\n    pic::applyWhiteBalanceJNI(\"../data/input/tommaseo_statue.png\", \"../data/output/tommaseo_statue_wb.png\", 200, 200, true);\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/jni_segmentation_live_wire/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/tommaseo_statue.png\";\n    }\n\n    pic::Image img(img_str);\n\n    std::vector< pic::Vec2i > out, out2;\n    pic::Vec2i pS(227, 206);\n    pic::Vec2i pE(221, 351);\n\n    std::vector< pic::Vec2i > cp_s;\n    cp_s.push_back(pS);\n    cp_s.push_back(pE);\n\n    std::vector< int > cp_jni_s;\n    pic::transferFromVecToPlain(cp_s, cp_jni_s);\n\n    auto start = std::chrono::system_clock::now();\n\n    auto out_single_jni = pic::executeLiveWireMultipleJNI(img_str, cp_jni_s, false);\n\n    auto end = std::chrono::system_clock::now();\n    std::chrono::duration<double> elapsed_seconds = end - start;\n     std::time_t end_time = std::chrono::system_clock::to_time_t(end);\n\n     std::cout << \"finished computation at \" << std::ctime(&end_time)\n               << \"elapsed time: \" << elapsed_seconds.count() << \"s\\n\";\n\n\n    for(unsigned int i = 0; i < out_single_jni.size(); i+=2) {\n\n        float *tmp = img(out_single_jni[i], out_single_jni[i + 1]);\n\n        printf(\"X: %d Y:%d\\n\", out_single_jni[i], out_single_jni[i + 1]);\n        tmp[0] = 0.0f;\n        tmp[1] = 1.0f;\n        tmp[2] = 0.0f;\n    }\n\n    img.Write(\"../data/output/s_livewire_single.png\", pic::LT_NOR_GAMMA);\n\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/jni_segmentation_live_wire/s_livewire.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = s_livewire\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/license_lgpl_3_0.txt",
    "content": "                   GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n\n  This version of the GNU Lesser General Public License incorporates\nthe terms and conditions of version 3 of the GNU General Public\nLicense, supplemented by the additional permissions listed below.\n\n  0. Additional Definitions.\n\n  As used herein, \"this License\" refers to version 3 of the GNU Lesser\nGeneral Public License, and the \"GNU GPL\" refers to version 3 of the GNU\nGeneral Public License.\n\n  \"The Library\" refers to a covered work governed by this License,\nother than an Application or a Combined Work as defined below.\n\n  An \"Application\" is any work that makes use of an interface provided\nby the Library, but which is not otherwise based on the Library.\nDefining a subclass of a class defined by the Library is deemed a mode\nof using an interface provided by the Library.\n\n  A \"Combined Work\" is a work produced by combining or linking an\nApplication with the Library.  The particular version of the Library\nwith which the Combined Work was made is also called the \"Linked\nVersion\".\n\n  The \"Minimal Corresponding Source\" for a Combined Work means the\nCorresponding Source for the Combined Work, excluding any source code\nfor portions of the Combined Work that, considered in isolation, are\nbased on the Application, and not on the Linked Version.\n\n  The \"Corresponding Application Code\" for a Combined Work means the\nobject code and/or source code for the Application, including any data\nand utility programs needed for reproducing the Combined Work from the\nApplication, but excluding the System Libraries of the Combined Work.\n\n  1. Exception to Section 3 of the GNU GPL.\n\n  You may convey a covered work under sections 3 and 4 of this License\nwithout being bound by section 3 of the GNU GPL.\n\n  2. Conveying Modified Versions.\n\n  If you modify a copy of the Library, and, in your modifications, a\nfacility refers to a function or data to be supplied by an Application\nthat uses the facility (other than as an argument passed when the\nfacility is invoked), then you may convey a copy of the modified\nversion:\n\n   a) under this License, provided that you make a good faith effort to\n   ensure that, in the event an Application does not supply the\n   function or data, the facility still operates, and performs\n   whatever part of its purpose remains meaningful, or\n\n   b) under the GNU GPL, with none of the additional permissions of\n   this License applicable to that copy.\n\n  3. Object Code Incorporating Material from Library Header Files.\n\n  The object code form of an Application may incorporate material from\na header file that is part of the Library.  You may convey such object\ncode under terms of your choice, provided that, if the incorporated\nmaterial is not limited to numerical parameters, data structure\nlayouts and accessors, or small macros, inline functions and templates\n(ten or fewer lines in length), you do both of the following:\n\n   a) Give prominent notice with each copy of the object code that the\n   Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the object code with a copy of the GNU GPL and this license\n   document.\n\n  4. Combined Works.\n\n  You may convey a Combined Work under terms of your choice that,\ntaken together, effectively do not restrict modification of the\nportions of the Library contained in the Combined Work and reverse\nengineering for debugging such modifications, if you also do each of\nthe following:\n\n   a) Give prominent notice with each copy of the Combined Work that\n   the Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the Combined Work with a copy of the GNU GPL and this license\n   document.\n\n   c) For a Combined Work that displays copyright notices during\n   execution, include the copyright notice for the Library among\n   these notices, as well as a reference directing the user to the\n   copies of the GNU GPL and this license document.\n\n   d) Do one of the following:\n\n       0) Convey the Minimal Corresponding Source under the terms of this\n       License, and the Corresponding Application Code in a form\n       suitable for, and under terms that permit, the user to\n       recombine or relink the Application with a modified version of\n       the Linked Version to produce a modified Combined Work, in the\n       manner specified by section 6 of the GNU GPL for conveying\n       Corresponding Source.\n\n       1) Use a suitable shared library mechanism for linking with the\n       Library.  A suitable mechanism is one that (a) uses at run time\n       a copy of the Library already present on the user's computer\n       system, and (b) will operate properly with a modified version\n       of the Library that is interface-compatible with the Linked\n       Version.\n\n   e) Provide Installation Information, but only if you would otherwise\n   be required to provide such information under section 6 of the\n   GNU GPL, and only to the extent that such information is\n   necessary to install and execute a modified version of the\n   Combined Work produced by recombining or relinking the\n   Application with a modified version of the Linked Version. (If\n   you use option 4d0, the Installation Information must accompany\n   the Minimal Corresponding Source and Corresponding Application\n   Code. If you use option 4d1, you must provide the Installation\n   Information in the manner specified by section 6 of the GNU GPL\n   for conveying Corresponding Source.)\n\n  5. Combined Libraries.\n\n  You may place library facilities that are a work based on the\nLibrary side by side in a single library together with other library\nfacilities that are not Applications and are not covered by this\nLicense, and convey such a combined library under terms of your\nchoice, if you do both of the following:\n\n   a) Accompany the combined library with a copy of the same work based\n   on the Library, uncombined with any other library facilities,\n   conveyed under the terms of this License.\n\n   b) Give prominent notice with the combined library that part of it\n   is a work based on the Library, and explaining where to find the\n   accompanying uncombined form of the same work.\n\n  6. Revised Versions of the GNU Lesser General Public License.\n\n  The Free Software Foundation may publish revised and/or new versions\nof the GNU Lesser General Public License from time to time. Such new\nversions will be similar in spirit to the present version, but may\ndiffer in detail to address new problems or concerns.\n\n  Each version is given a distinguishing version number. If the\nLibrary as you received it specifies that a certain numbered version\nof the GNU Lesser General Public License \"or any later version\"\napplies to it, you have the option of following the terms and\nconditions either of that published version or of any later version\npublished by the Free Software Foundation. If the Library as you\nreceived it does not specify a version number of the GNU Lesser\nGeneral Public License, you may choose any version of the GNU Lesser\nGeneral Public License ever published by the Free Software Foundation.\n\n  If the Library as you received it specifies that a proxy can decide\nwhether future versions of the GNU Lesser General Public License shall\napply, that proxy's public statement of acceptance of any version is\npermanent authorization for you to choose that version for the\nLibrary.\n"
  },
  {
    "path": "examples/opengl_convolution_2D/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n/**\n * NOTE: if you do not want to use this OpenGL functions loader,\n * please change it with your favorite one. This is just\n * a suggestion for running examples.\n*/\n\n#include \"../common_code/gl_include.hpp\"\n\n#include <QKeyEvent>\n#include <QtCore/QCoreApplication>\n#include <QtOpenGL/QGLWidget>\n#include <QApplication>\n#include <QVBoxLayout>\n#include <QLabel>\n\n#include \"piccante.hpp\"\n\nclass GLWidget : public QGLWidget\n        #ifndef PIC_INCLUDE_GL\n        , protected QOpenGLFunctions\n        #endif\n{  \nprotected:\n    pic::FilterGLConv2D *conv2D;\n    pic::ImageGL img, weights, *imgRec;\n    pic::DisplayGL *display;\n    int method;\n\n    /**\n     * @brief initializeGL sets variables up.\n     */\n    void initializeGL(){\n\n    #ifndef PIC_INCLUDE_GL\n        initializeOpenGLFunctions();\n    #endif\n\n    #ifdef PIC_INCLUDE_GL\n        if(ogl_LoadFunctions() == ogl_LOAD_FAILED) {\n            printf(\"OpenGL functions are not loaded!\\n\");\n        }\n    #endif\n\n        glClearColor(0.0f, 0.0f, 0.0f, 0.0f );\n\n        //read an input image\n        img.Read(\"../data/input/bottles.hdr\");\n        img.generateTextureGL();\n\n        //read weights\n        weights.Read(\"../data/input/star.bmp\", pic::LT_NOR);\n        weights.generateTextureGL();\n\n        float *sum = weights.getSumVal();\n\n        if(sum != NULL) {\n            pic::Arrayf sump(sum, weights.channels, true);\n            weights /= sump;\n        }\n\n        conv2D = new pic::FilterGLConv2D(GL_TEXTURE_2D);\n\n        //create a screen aligned quad\n        display = new pic::DisplayGL();\n    }\n\n    /**\n     * @brief resizeGL\n     * @param w\n     * @param h\n     */\n    void resizeGL( int w, int h ){\n        const qreal retinaScale = devicePixelRatio();\n        glViewport(0, 0, w * retinaScale, h * retinaScale);\n    }\n\n    /**\n     * @brief paintGL\n     */\n    void paintGL(){\n        if(parentWidget() != NULL) {\n            if(!parentWidget()->isVisible()) {\n                return;\n            }\n        }\n\n        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\n\n        //simple tone mapping: gamma + exposure correction\n        pic::ImageGL *img_out;\n        if(method == 1) {\n            imgRec = conv2D->Process(DoubleGL(&img, &weights), imgRec);\n            img_out = imgRec;\n        } else {\n            img_out = &img;\n        }\n\n        //visualization\n        display->Process(img_out);\n    }\n\npublic:\n\n    /**\n     * @brief GLWidget\n     * @param format\n     * @param parent\n     */\n    GLWidget( const QGLFormat& format, QWidget* parent = 0 ): QGLWidget(format, parent, 0)\n    {\n        setFixedWidth(912);\n        setFixedHeight(684);\n\n        method = 0;\n\n        imgRec = NULL;\n    }\n\n    /**\n     * @brief update\n     */\n    void update()\n    {\n        method = (method + 1) % 2;\n    }\n};\n\nclass Window : public QWidget\n{\nprotected:\n\n    GLWidget *window_gl;\n    QVBoxLayout *layout;\n    QLabel *label;\n\npublic:\n\n    /**\n     * @brief Window\n     * @param format\n     */\n    Window(const QGLFormat &format)\n    {\n        resize(912, 684 + 64);\n\n        window_gl = new GLWidget(format, this);\n\n        layout = new QVBoxLayout();\n\n        layout->addWidget(window_gl);\n\n        label = new QLabel(\n        \"Pease hit the space bar in order to filter the image with a 2D filter; i.e., a star-lie shape.\", this);\n        label->setFixedWidth(912);\n        label->setFixedHeight(64);\n\n        layout->addWidget(label);\n\n        setLayout(layout);\n\n        setWindowTitle(tr(\"Push-Pull Example\"));\n    }\n\n    ~Window()\n    {\n        delete window_gl;\n        delete layout;\n        delete label;\n    }\n\n    /**\n     * @brief keyPressEvent\n     * @param e\n     */\n    void keyPressEvent( QKeyEvent* e ){\n        if(e->type() == QEvent::KeyPress) {\n            if(e->key() == Qt::Key_Space) {\n                window_gl->update();\n                window_gl->updateGL();\n            }\n        }\n    }\n};\n\nint main(int argc, char **argv)\n{\n    QApplication app( argc, argv );\n\n    QGLFormat glFormat;\n    glFormat.setVersion( 4, 0 );\n    glFormat.setProfile( QGLFormat::CoreProfile );\n    glFormat.setSampleBuffers( true );\n\n    //Creating a window with OpenGL 4.0 Core profile\n    Window w( glFormat );\n    w.show();\n\n    app.installEventFilter(&w);\n\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/opengl_convolution_2D/opengl_convolution_2D.pro",
    "content": "TARGET = opengl_convolution_2D\n\nQT += core\nQT += gui\nQT += opengl\nQT += widgets\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\n\nSOURCES += main.cpp\n\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n\nwin32{\n        DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n"
  },
  {
    "path": "examples/opengl_deform_grid/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n/**\n * NOTE: if you do not want to use this OpenGL functions loader,\n * please change it with your favorite one. This is just\n * a suggestion for running examples.\n*/\n\n#include \"../common_code/gl_include.hpp\"\n\n#include <QKeyEvent>\n#include <QtCore/QCoreApplication>\n#include <QtOpenGL/QGLWidget>\n#include <QApplication>\n#include <QVBoxLayout>\n#include <QLabel>\n\n#include \"piccante.hpp\"\n\nclass GLWidget : public QGLWidget\n        #ifndef PIC_INCLUDE_GL\n        , protected QOpenGLFunctions\n        #endif\n{\nprotected:\n    pic::FilterGLDeformGrid *fltDeformGrid;\n    pic::DisplayGL *display;\n    pic::ImageGL *img, *img_flt;\n\n    int method;\n\n    /**\n     * @brief initializeGL sets variables up.\n     */\n    void initializeGL(){\n\n    #ifndef PIC_INCLUDE_GL\n        initializeOpenGLFunctions();\n    #endif\n\n    #ifdef PIC_INCLUDE_GL\n        if(ogl_LoadFunctions() == ogl_LOAD_FAILED) {\n            printf(\"OpenGL functions are not loaded!\\n\");\n        }\n    #endif\n\n        glClearColor(0.0f, 0.0f, 0.0f, 0.0f );\n\n        //read an input image\n        img = new pic::ImageGL();\n        img->Read(\"../data/input/grid.png\");\n        img->generateTextureGL();\n\n        //create a screen aligned quad\n        display = new pic::DisplayGL();\n\n        //allocate a new deform grid filter\n        pic::Image *grid_move = pic::FilterDeformGrid::getUniformGrid(17, 17);\n\n        float *grid_values = (*grid_move)(4, 4);\n        grid_values[0] += 1.0f / 32.0f;\n        grid_values[1] += 1.0f / 32.0f;\n\n        fltDeformGrid = new pic::FilterGLDeformGrid(grid_move);\n    }\n\n    /**\n     * @brief resizeGL\n     * @param w\n     * @param h\n     */\n    void resizeGL( int w, int h ){\n        const qreal retinaScale = devicePixelRatio();\n        glViewport(0, 0, w * retinaScale, h * retinaScale);\n    }\n\n    /**\n     * @brief paintGL\n     */\n    void paintGL(){\n        if(parentWidget() != NULL) {\n            if(!parentWidget()->isVisible()) {\n                return;\n            }\n        }\n\n        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\n\n        pic::ImageGL *img_out;\n        if(method == 1) {\n            //apply the deformation filter\n            img_flt = fltDeformGrid->Process(SingleGL(img), img_flt);\n            img_out = img_flt;\n        } else {\n            img_out = img;\n        }\n\n        //visualization\n        display->Process(img_out);\n    }\n\npublic:\n\n    /**\n     * @brief GLWidget\n     * @param format\n     * @param parent\n     */\n    GLWidget( const QGLFormat& format, QWidget* parent = 0 ): QGLWidget(format, parent, 0)\n    {\n        setFixedWidth(512);\n        setFixedHeight(512);\n\n        img_flt = NULL;\n        method = 0;\n    }\n\n    /**\n     * @brief update\n     */\n    void update()\n    {\n        method = (method + 1) % 2;\n    }\n};\n\nclass Window : public QWidget\n{\nprotected:\n    GLWidget *window_gl;\n    QVBoxLayout *layout;\n    QLabel *label;\n\npublic:\n\n    /**\n     * @brief Window\n     * @param format\n     */\n    Window(const QGLFormat &format)\n    {\n        resize(512, 512 + 64);\n\n        window_gl = new GLWidget(format, this);\n\n        layout = new QVBoxLayout();\n\n        layout->addWidget(window_gl);\n\n        label = new QLabel(\"Please hit the space bar for applying the deformation grid.\",\n                           this);\n        label->setAlignment(Qt::AlignHCenter);\n        label->setFixedWidth(512);\n        label->setFixedHeight(64);\n\n        layout->addWidget(label);\n\n        setLayout(layout);\n\n        setWindowTitle(tr(\"Deform Grid Example\"));\n    }\n\n    ~Window()\n    {\n        delete window_gl;\n        delete layout;\n        delete label;\n    }\n\n    /**\n     * @brief keyPressEvent\n     * @param e\n     */\n    void keyPressEvent( QKeyEvent* e ){\n        if(e->type() == QEvent::KeyPress) {\n            if(e->key() == Qt::Key_Space) {\n                window_gl->update();\n                window_gl->updateGL();\n            }\n        }\n    }\n};\n\nint main(int argc, char **argv)\n{\n    QApplication app( argc, argv );\n\n    QGLFormat glFormat;\n    glFormat.setVersion( 4, 0 );\n    glFormat.setProfile( QGLFormat::CoreProfile );\n    glFormat.setSampleBuffers( true );\n\n    //Creating a window with OpenGL 4.0 Core profile\n    Window w( glFormat );\n    w.show();\n\n    app.installEventFilter(&w);\n\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/opengl_deform_grid/opengl_deform_grid.pro",
    "content": "TARGET = opengl_deform_grid\n\nQT += core\nQT += gui\nQT += opengl\nQT += widgets\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\n\nSOURCES += main.cpp\n\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n\nwin32{\n        DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n"
  },
  {
    "path": "examples/opengl_exposure_fusion/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n/**\n * NOTE: if you do not want to use this OpenGL functions loader,\n * please change it with your favorite one. This is just\n * a suggestion for running examples.\n*/\n\n#include \"../common_code/gl_include.hpp\"\n\n#include <QKeyEvent>\n#include <QtCore/QCoreApplication>\n#include <QtOpenGL/QGLWidget>\n#include <QApplication>\n#include <QVBoxLayout>\n#include <QLabel>\n\n#include \"piccante.hpp\"\n\nclass GLWidget : public QGLWidget\n        #ifndef PIC_INCLUDE_GL\n        , protected QOpenGLFunctions\n        #endif\n{\nprotected:\n    pic::QuadGL *quad;\n    pic::ExposureFusionGL *ef;\n    pic::FilterGLSimpleTMO *tmo;\n    pic::ImageGL img, *img_tmo;\n    pic::ImageGLVec img_vec;\n    pic::TechniqueGL technique;\n\n    unsigned int    method;\n\n    /**\n     * @brief initializeGL sets variables up.\n     */\n    void initializeGL(){\n\n    #ifndef PIC_INCLUDE_GL\n        initializeOpenGLFunctions();\n    #endif\n\n    #ifdef PIC_INCLUDE_GL\n        if(ogl_LoadFunctions() == ogl_LOAD_FAILED) {\n            printf(\"OpenGL functions are not loaded!\\n\");\n        }\n    #endif\n\n        glClearColor(0.0f, 0.0f, 0.0f, 0.0f );\n\n        //read an input image\n        img.Read(\"../data/input/bottles.hdr\");\n        img.generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n\n        //create a screen aligned quad\n        pic::QuadGL::getTechnique(technique,\n                                pic::QuadGL::getVertexProgramV3(),\n                                pic::QuadGL::getFragmentProgramForView());\n\n        quad = new pic::QuadGL(true);\n\n        //allocate an exposure fusion instance\n        ef = new pic::ExposureFusionGL();\n\n        //compute a stack of LDR images from an HDR image\n        img_vec = pic::getAllExposuresImagesGL(&img, 2.2f);\n\n        //allocate a new filter for simple tone mapping\n        tmo = new pic::FilterGLSimpleTMO();\n    }\n\n    /**\n     * @brief resizeGL\n     * @param w\n     * @param h\n     */\n    void resizeGL( int w, int h ){\n        const qreal retinaScale = devicePixelRatio();\n        glViewport(0, 0, w * retinaScale, h * retinaScale);\n    }\n\n    /**\n     * @brief paintGL\n     */\n    void paintGL(){\n        if(parentWidget() != NULL) {\n            if(!parentWidget()->isVisible()) {\n                return;\n            }\n        }\n\n        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\n\n        if(method == 0) {\n            //compute exposure fusion for the stack (img_vec)\n            img_tmo = ef->ProcessStack(img_vec, img_tmo);\n        } else {\n            //simple tone mapping: gamma + exposure correction\n            img_tmo = tmo->Process(SingleGL(&img), img_tmo);\n        }\n\n        //visualization\n        quad->Render(technique, img_tmo->getTexture());\n    }\n\npublic:\n\n    /**\n     * @brief GLWidget\n     * @param format\n     * @param parent\n     */\n    GLWidget( const QGLFormat& format, QWidget* parent = 0 ): QGLWidget(format, parent, 0)\n    {\n        setFixedWidth(912);\n        setFixedHeight(684);\n\n        ef = NULL;\n        img_tmo = NULL;\n        tmo = NULL;\n        method = 0;\n    }\n\n    /**\n     * @brief update\n     */\n    void update()\n    {\n        method = (method + 1) % 2;\n    }\n};\n\nclass Window : public QWidget\n{\nprotected:\n    GLWidget *window_gl;\n    QVBoxLayout *layout;\n    QLabel *label;\n\npublic:\n\n    /**\n     * @brief Window\n     * @param format\n     */\n    Window(const QGLFormat &format)\n    {\n        resize(912, 684 + 64);\n\n        window_gl = new GLWidget(format, this);\n\n        layout = new QVBoxLayout();\n\n        layout->addWidget(window_gl);\n\n        label = new QLabel(\n                    \"Please hit the space bar in order to switch from fused image to the original one.\",\n                    this);\n        label->setAlignment(Qt::AlignHCenter);\n        label->setFixedWidth(912);\n        label->setFixedHeight(64);\n\n        layout->addWidget(label);\n\n        setLayout(layout);\n\n        setWindowTitle(tr(\"Exposure Fusion Example\"));\n    }\n\n    ~Window()\n    {\n        delete window_gl;\n        delete layout;\n        delete label;\n    }\n\n    /**\n     * @brief keyPressEvent\n     * @param e\n     */\n    void keyPressEvent( QKeyEvent* e ){\n        if(e->type() == QEvent::KeyPress) {\n            if(e->key() == Qt::Key_Space) {\n                window_gl->update();\n                window_gl->updateGL();\n            }\n        }\n    }\n};\n\nint main(int argc, char **argv)\n{\n    QApplication app( argc, argv );\n\n    QGLFormat glFormat;\n    glFormat.setVersion( 4, 0 );\n    glFormat.setProfile( QGLFormat::CoreProfile );\n    glFormat.setSampleBuffers( true );\n\n    //create a window with OpenGL 4.0 Core profile\n    Window w( glFormat );\n    w.show();\n\n    app.installEventFilter(&w);\n\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/opengl_exposure_fusion/opengl_exposure_fusion.pro",
    "content": "TARGET = opengl_exposure_fusion\n\nQT += core\nQT += gui\nQT += opengl\nQT += widgets\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\n\nSOURCES += main.cpp\n\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n\nwin32{\n    DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n"
  },
  {
    "path": "examples/opengl_filtering/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n/**\n * NOTE: if you do not want to use this OpenGL functions loader,\n * please change it with your favorite one. This is just\n * a suggestion for running examples.\n*/\n\n#include \"../common_code/gl_include.hpp\"\n\n#include <QKeyEvent>\n#include <QtCore/QCoreApplication>\n#include <QtOpenGL/QGLWidget>\n#include <QApplication>\n#include <QVBoxLayout>\n#include <QLabel>\n\n#include \"piccante.hpp\"\n\nclass GLWidget : public QGLWidget\n        #ifndef PIC_INCLUDE_GL\n        , protected QOpenGLFunctions\n        #endif\n{\nprotected:\n    pic::FilterGLBilateral2DF *fltBilF;\n    pic::FilterGLBilateral2DG *fltBilG;\n    pic::FilterGLBilateral2DSP *fltBilSP;\n    pic::FilterGLBilateral2DS *fltBilS;\n    pic::FilterGLBilateral2DAS *fltBilAS;\n    pic::FilterGLGaussian2D *fltGauss;\n    pic::FilterGLAnisotropicDiffusion *fltAD;\n\n    pic::DisplayGL *display;\n    pic::ImageGL *img, *img_flt;\n\n    int method;\n\n    /**\n     * @brief initializeGL sets variables up.\n     */\n    void initializeGL(){\n\n    #ifndef PIC_INCLUDE_GL\n        initializeOpenGLFunctions();\n    #endif\n\n    #ifdef PIC_INCLUDE_GL\n        if(ogl_LoadFunctions() == ogl_LOAD_FAILED) {\n            printf(\"OpenGL functions are not loaded!\\n\");\n        }\n    #endif\n\n        glClearColor(0.0f, 0.0f, 0.0f, 0.0f );\n\n        //read an input image\n        img = new pic::ImageGL();\n        img->Read(\"../data/input/yellow_flowers.png\", pic::LT_NOR_GAMMA);\n        img->generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n\n        float sigma_s = 16.0f;\n        float sigma_r = 0.1f;\n\n        fltGauss = new pic::FilterGLGaussian2D(sigma_s);\n\n        //allocate a new bilateral filter\n        fltBilG = new pic::FilterGLBilateral2DG(sigma_s, sigma_r);\n\n        //allocate a new bilateral filter\n        fltBilSP = new pic::FilterGLBilateral2DSP(sigma_s, sigma_r);\n\n        //allocate a new bilateral filter\n        fltBilS = new pic::FilterGLBilateral2DS(sigma_s, sigma_r);\n\n        //allocate a new bilateral filter\n        fltBilAS = new pic::FilterGLBilateral2DAS(sigma_s, sigma_r);\n\n        //allocate a new bilateral filter\n        fltBilF = new pic::FilterGLBilateral2DF(sigma_s, sigma_r);\n\n        //allocate a new anisotropic diffusion filter\n        fltAD = new pic::FilterGLAnisotropicDiffusion(sigma_s, sigma_r);\n        img_flt = NULL;\n\n        display = new pic::DisplayGL();\n    }\n\n    /**\n     * @brief resizeGL\n     * @param w\n     * @param h\n     */\n    void resizeGL( int w, int h ){\n        const qreal retinaScale = devicePixelRatio();\n        glViewport(0, 0, w * retinaScale, h * retinaScale);\n    }\n\n    /**\n     * @brief paintGL\n     */\n    void paintGL(){\n        if(parentWidget() != NULL) {\n            if(!parentWidget()->isVisible()) {\n                return;\n            }\n        }\n\n        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\n\n        pic::ImageGL *img_out = NULL;\n        switch(method)\n        {\n            case 0:\n                //input image\n                img_out = img;\n                window_ext->setWindowTitle(tr(\"Filtering Example: Original Image\"));\n\n            break;\n\n            case 1:\n                //apply the gaussian filter\n                img_flt = fltGauss->Process(SingleGL(img), img_flt);\n                img_out = img_flt;\n                window_ext->setWindowTitle(tr(\"Filtering Example: Guassian Filter\"));\n\n            break;\n\n            case 2:\n                //apply the sampling bilateral filter\n                img_flt = fltBilF->Process(SingleGL(img), img_flt);\n                img_out = img_flt;\n                window_ext->setWindowTitle(tr(\"Filtering Example: Full Bilateral\"));\n\n            break;\n\n            case 3:\n                //apply the bilateral grid filter\n                img_flt = fltBilG->Process(SingleGL(img), img_flt);\n                img_out = img_flt;\n                window_ext->setWindowTitle(tr(\"Filtering Example: Bilateral Grid\"));\n\n            break;\n\n            case 4:\n                //apply the separate bilateral filter\n                img_flt = fltBilSP->Process(SingleGL(img), img_flt);\n                img_out = img_flt;\n                window_ext->setWindowTitle(tr(\"Filtering Example: Separate Bilateral\"));\n\n            break;\n\n            case 5:\n                //apply the sampling bilateral filter\n                img_flt = fltBilS->Process(SingleGL(img), img_flt);\n                img_out = img_flt;\n                window_ext->setWindowTitle(tr(\"Filtering Example: Sub-Sampled Bilateral\"));\n            break;\n\n            case 6:\n                //apply the sampling bilateral filter\n                img_flt = fltBilAS->Process(SingleGL(img), img_flt);\n                img_out = img_flt;\n                window_ext->setWindowTitle(tr(\"Filtering Example: Sub-Sampled Adaptive Bilateral\"));\n            break;\n\n            case 7:\n                //apply the anisotropic diffusion filter\n                img_flt = fltAD->AnisotropicDiffusion(SingleGL(img), img_flt);\n                img_out = img_flt;\n                window_ext->setWindowTitle(tr(\"Filtering Example: Anisotropic Diffusion\"));\n\n            break;\n\n        default:\n            img_out = img;\n            break;\n        }\n\n        display->Process(img_out);\n    }\n\npublic:\n\n    QWidget *window_ext;\n\n    /**\n     * @brief GLWidget\n     * @param format\n     * @param parent\n     */\n    GLWidget( const QGLFormat& format, QWidget* parent = 0 ): QGLWidget(format, parent, 0)\n    {\n        setFixedWidth(800);\n        setFixedHeight(533);\n\n        img_flt = NULL;\n        method = 0;\n    }\n\n    /**\n     * @brief update\n     */\n    void update()\n    {\n        method = (method + 1) % 8;\n    }\n};\n\nclass Window : public QWidget\n{\nprotected:\n    GLWidget *window_gl;\n    QVBoxLayout *layout;\n    QLabel *label;\n\npublic:\n\n    /**\n     * @brief Window\n     * @param format\n     */\n    Window(const QGLFormat &format)\n    {\n        resize(800, 533 + 64);\n\n        window_gl = new GLWidget(format, this);\n        window_gl->window_ext = this;\n\n        layout = new QVBoxLayout();\n\n        layout->addWidget(window_gl);\n\n        label = new QLabel(\n        \"Pease hit the space bar in order to switch from the original one to the filtered one using different filters.\", this);\n        label->setAlignment(Qt::AlignHCenter);\n        label->setFixedWidth(800);\n        label->setFixedHeight(64);\n\n        layout->addWidget(label);\n\n        setLayout(layout);\n\n        setWindowTitle(tr(\"Filtering Example\"));\n    }\n\n    ~Window()\n    {\n        delete window_gl;\n        delete layout;\n        delete label;\n    }\n\n    /**\n     * @brief keyPressEvent\n     * @param e\n     */\n    void keyPressEvent( QKeyEvent* e ){\n        if(e->type() == QEvent::KeyPress) {\n            if(e->key() == Qt::Key_Space) {\n                window_gl->update();\n                window_gl->updateGL();\n            }\n        }\n    }\n};\n\nint main(int argc, char **argv)\n{\n    QApplication app( argc, argv );\n\n    QGLFormat glFormat;\n    glFormat.setVersion( 4, 0 );\n    glFormat.setProfile( QGLFormat::CoreProfile );\n    glFormat.setSampleBuffers( true );\n\n    //Creating a window with OpenGL 4.0 Core profile\n    Window w( glFormat );\n    w.show();\n\n    app.installEventFilter(&w);\n\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/opengl_filtering/opengl_filtering.pro",
    "content": "TARGET = opengl_filtering\n\nQT += core\nQT += gui\nQT += opengl\nQT += widgets\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\n\nSOURCES += main.cpp\n\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n\nwin32{\n        DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n"
  },
  {
    "path": "examples/opengl_grow_cut/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n/**\n * NOTE: if you do not want to use this OpenGL functions loader,\n * please change it with your favorite one. This is just\n * a suggestion for running examples.\n*/\n\n#include \"../common_code/gl_include.hpp\"\n\n#include <QKeyEvent>\n#include <QtCore/QCoreApplication>\n#include <QtOpenGL/QGLWidget>\n#include <QApplication>\n#include <QVBoxLayout>\n#include <QLabel>\n\n#define PIC_DEBUG\n#include \"piccante.hpp\"\n\nclass GLWidget : public QGLWidget\n        #ifndef PIC_INCLUDE_GL\n        , protected QOpenGLFunctions\n        #endif\n{\nprotected:\n    pic::DisplayGL *display;\n    pic::ImageGL *img, *img_strokes, *seeds, *imgGC, *img_seeds;\n    int method;\n    pic::GrowCutGL *gcGL;\n\n    /**\n     * @brief initializeGL sets variables up.\n     */\n    void initializeGL(){\n\n    #ifndef PIC_INCLUDE_GL\n        initializeOpenGLFunctions();\n    #endif\n\n    #ifdef PIC_INCLUDE_GL\n        if(ogl_LoadFunctions() == ogl_LOAD_FAILED) {\n            printf(\"OpenGL functions are not loaded!\\n\");\n        }\n    #endif\n\n        glClearColor(0.0f, 0.0f, 0.0f, 0.0f );\n\n        //read an input image\n        img = new pic::ImageGL();\n        img->Read(\"../data/input/yellow_flowers.png\", pic::LT_NOR_GAMMA);\n        img->generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n\n        //read the strokes\n        img_strokes = new pic::ImageGL();\n        img_strokes->Read(\"../data/input/yellow_flowers_segmentation_strokes.png\", pic::LT_NOR_GAMMA);\n        img_strokes->generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n\n        //create a screen aligned quad\n        display = new pic::DisplayGL();\n\n        //create a GrowCut\n        gcGL = new pic::GrowCutGL();\n\n        imgGC = NULL;\n        img_seeds = NULL;\n\n        method = 0;\n    }\n\n    /**\n     * @brief resizeGL\n     * @param w\n     * @param h\n     */\n    void resizeGL( int w, int h ){\n        const qreal retinaScale = devicePixelRatio();\n        glViewport(0, 0, w * retinaScale, h * retinaScale);\n    }\n\n    /**\n     * @brief paintGL\n     */\n    void paintGL(){\n        if(parentWidget() != NULL) {\n            if(!parentWidget()->isVisible()) {\n                return;\n            }\n        }\n\n        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\n\n        //simple tone mapping: gamma + exposure correction\n        pic::ImageGL *img_out = NULL;\n\n        switch(method)\n        {\n        case 0:\n        {\n            img_out = img;\n            window_ext->setWindowTitle(tr(\"GrowCut Example: Input Image\"));\n        } break;\n\n        case 1:\n        {\n            img_out = img_strokes;\n            window_ext->setWindowTitle(tr(\"GrowCut Example: Strokes\"));\n        } break;\n\n        case 2:\n        {\n            img_seeds = gcGL->fromStrokeImageToSeeds(img_strokes, img_seeds);\n            img_out = img_seeds;\n            window_ext->setWindowTitle(tr(\"GrowCut Example: Seeds images\"));\n        } break;\n\n        case 3:\n        {\n            img_seeds = gcGL->fromStrokeImageToSeeds(img_strokes, img_seeds);\n\n            imgGC = gcGL->Process(pic::DoubleGL(img, img_seeds), imgGC);\n            img_out = imgGC;\n            window_ext->setWindowTitle(tr(\"GrowCut Example: Segmentation\"));\n        } break;\n        }\n\n        display->Process(img_out);\n    }\n\npublic:\n    QWidget *window_ext;\n\n    /**\n     * @brief GLWidget\n     * @param format\n     * @param parent\n     */\n    GLWidget( const QGLFormat& format, QWidget* parent = 0 ): QGLWidget(format, parent, 0)\n    {\n        setFixedWidth(800);\n        setFixedHeight(533);\n\n        method = 0;\n    }\n\n    /**\n     * @brief update\n     */\n    void update()\n    {\n        method = (method + 1) % 4;\n    }\n};\n\nclass Window : public QWidget\n{\nprotected:\n\n    GLWidget *window_gl;\n    QVBoxLayout *layout;\n    QLabel *label;\n\npublic:\n\n    /**\n     * @brief Window\n     * @param format\n     */\n    Window(const QGLFormat &format)\n    {\n        resize(800, 533 + 64);\n\n        window_gl = new GLWidget(format, this);\n        window_gl->window_ext = this;\n\n        layout = new QVBoxLayout();\n\n        layout->addWidget(window_gl);\n\n        label = new QLabel(\n                    \"Please hit the space bar in order to switch from the original \"\n                    \"image to the segmentation strokes, and to the segmented mask.\",\n                    this);\n        label->setFixedWidth(800);\n        label->setFixedHeight(64);\n\n        layout->addWidget(label);\n\n        setLayout(layout);\n\n        setWindowTitle(tr(\"Grow-Cut Example\"));\n    }\n\n    ~Window()\n    {\n        delete window_gl;\n        delete layout;\n        delete label;\n    }\n\n    /**\n     * @brief keyPressEvent\n     * @param e\n     */\n    void keyPressEvent( QKeyEvent* e ){\n        if(e->type() == QEvent::KeyPress) {\n            if(e->key() == Qt::Key_Space) {\n                window_gl->update();\n                window_gl->updateGL();\n            }\n        }\n    }\n};\n\nint main(int argc, char **argv)\n{\n    QApplication app( argc, argv );\n\n    QGLFormat glFormat;\n    glFormat.setVersion( 4, 0 );\n    glFormat.setProfile( QGLFormat::CoreProfile );\n    glFormat.setSampleBuffers( true );\n\n    //Creating a window with OpenGL 4.0 Core profile\n    Window w( glFormat );\n    w.show();\n\n    app.installEventFilter(&w);\n\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/opengl_grow_cut/opengl_grow_cut.pro",
    "content": "TARGET = opengl_grow_cut\n\nQT += core\nQT += gui\nQT += opengl\nQT += widgets\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\n\nSOURCES += main.cpp\n\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n\nwin32{\n        DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n"
  },
  {
    "path": "examples/opengl_image_transform/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n/**\n * NOTE: if you do not want to use this OpenGL functions loader,\n * please change it with your favorite one. This is just\n * a suggestion for running examples.\n*/\n\n#include \"../common_code/gl_include.hpp\"\n\n#include <QKeyEvent>\n#include <QtCore/QCoreApplication>\n#include <QtOpenGL/QGLWidget>\n#include <QApplication>\n#include <QVBoxLayout>\n#include <QLabel>\n\n#include \"piccante.hpp\"\n\nclass GLWidget : public QGLWidget\n        #ifndef PIC_INCLUDE_GL\n        , protected QOpenGLFunctions\n        #endif\n{\nprotected:\n    pic::QuadGL *quad;\n    pic::FilterGLSimpleTMO *flt_tmo;\n    pic::FilterGLWarp2D *flt_warp;\n    pic::ImageGL img, *img_flt, *img_flt_tmo;\n    pic::TechniqueGL technique;\n    pic::Matrix3x3 h;\n\n    int degrees;\n\n    /**\n     * @brief initializeGL sets variables up.\n     */\n    void initializeGL(){\n\n    #ifndef PIC_INCLUDE_GL\n        initializeOpenGLFunctions();\n    #endif\n\n    #ifdef PIC_INCLUDE_GL\n        if(ogl_LoadFunctions() == ogl_LOAD_FAILED) {\n            printf(\"OpenGL functions are not loaded!\\n\");\n        }\n    #endif\n\n        glClearColor(0.0f, 0.0f, 0.0f, 0.0f );\n\n        //reading an input image\n        img.Read(\"../data/input/bottles.hdr\");\n        img.generateTextureGL();\n\n        //creating a screen aligned quad\n        pic::QuadGL::getTechnique(technique,\n                                pic::QuadGL::getVertexProgramV3(),\n                                pic::QuadGL::getFragmentProgramForView());\n\n        quad = new pic::QuadGL(true);\n\n        //creating a rotation matrix\n        h.setRotationMatrix(pic::Deg2Rad(float(degrees)));\n\n        //allocating the warping filter\n        flt_warp = new pic::FilterGLWarp2D();\n        flt_warp->update(h, true, true);\n\n         //allocating a new filter for simple tone mapping\n        flt_tmo = new pic::FilterGLSimpleTMO();\n    }\n\n    /**\n     * @brief resizeGL\n     * @param w\n     * @param h\n     */\n    void resizeGL( int w, int h ){\n        const qreal retinaScale = devicePixelRatio();\n        glViewport(0, 0, w * retinaScale, h * retinaScale);\n    }\n\n    /**\n     * @brief paintGL\n     */\n    void paintGL(){\n        if(parentWidget() != NULL) {\n            if(!parentWidget()->isVisible()) {\n                return;\n            }\n        }\n\n        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\n\n        //applying the warping filter\n        h.setRotationMatrix(pic::Deg2Rad(float(degrees)));\n        flt_warp->update(h, true, true);\n\n        img_flt = flt_warp->Process(SingleGL(&img), img_flt);\n\n        //simple tone mapping: gamma + exposure correction\n        img_flt_tmo = flt_tmo->Process(SingleGL(img_flt), img_flt_tmo);\n\n        //visualization\n        quad->Render(technique, img_flt_tmo->getTexture());\n    }\n\npublic:\n\n    /**\n     * @brief GLWidget\n     * @param format\n     * @param parent\n     */\n    GLWidget( const QGLFormat& format, QWidget* parent = 0 ): QGLWidget(format, parent, 0)\n    {\n        setFixedWidth(912);\n        setFixedHeight(684);\n\n        degrees = 45;\n\n        flt_tmo = NULL;\n        flt_warp = NULL;\n        img_flt = NULL;\n        img_flt_tmo = NULL;\n    }\n\n    /**\n     * @brief update\n     */\n    void update()\n    {\n        degrees = (degrees + 1) % 360;\n    }\n};\n\nclass Window : public QWidget\n{\nprotected:\n    GLWidget *window_gl;\n    QVBoxLayout *layout;\n    QLabel *label;\n\npublic:\n\n    /**\n     * @brief Window\n     * @param format\n     */\n    Window(const QGLFormat &format)\n    {\n        resize(912, 684 + 64);\n\n        window_gl = new GLWidget(format, this);\n\n        layout = new QVBoxLayout();\n\n        layout->addWidget(window_gl);\n\n        label = new QLabel(\n        \"Pease hit the space bar in order to increase of one degree the image's rotation.\", this);\n        label->setAlignment(Qt::AlignHCenter);\n        label->setFixedWidth(912);\n        label->setFixedHeight(64);\n\n        layout->addWidget(label);\n\n        setLayout(layout);\n\n        setWindowTitle(tr(\"Image Transform Example\"));\n    }\n\n    ~Window()\n    {\n        delete window_gl;\n        delete layout;\n        delete label;\n    }\n\n    /**\n     * @brief keyPressEvent\n     * @param e\n     */\n    void keyPressEvent( QKeyEvent* e ){\n        if(e->type() == QEvent::KeyPress) {\n            if(e->key() == Qt::Key_Space) {\n                window_gl->update();\n                window_gl->updateGL();\n            }\n        }\n    }\n};\n\nint main(int argc, char **argv)\n{\n    QApplication app( argc, argv );\n\n    QGLFormat glFormat;\n    glFormat.setVersion( 4, 0 );\n    glFormat.setProfile( QGLFormat::CoreProfile );\n    glFormat.setSampleBuffers( true );\n\n    //Creating a window with OpenGL 4.0 Core profile\n    Window w( glFormat );\n    w.show();\n\n    app.installEventFilter(&w);\n\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/opengl_image_transform/opengl_image_transform.pro",
    "content": "TARGET = opengl_image_transform\n\nQT += core\nQT += gui\nQT += opengl\nQT += widgets\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\n\nSOURCES += main.cpp\n\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n\nwin32{\n        DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n"
  },
  {
    "path": "examples/opengl_operators/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n/**\n * NOTE: if you do not want to use this OpenGL functions loader,\n * please change it with your favorite one. This is just\n * a suggestion for running examples.\n*/\n\n#include \"../common_code/gl_include.hpp\"\n\n#include \"piccante.hpp\"\n#include <QOpenGLFunctions>\n\n#include <QKeyEvent>\n#include <QtCore/QCoreApplication>\n#include <QtOpenGL/QGLWidget>\n#include <QApplication>\n#include <QVBoxLayout>\n#include <QLabel>\n\nclass GLWidget : public QGLWidget\n        #ifndef PIC_INCLUDE_GL\n        , protected QOpenGLFunctions\n        #endif\n{\nprotected:\n    pic::DisplayGL *display;\n    pic::ImageGL img, *imgRand;\n    pic::TechniqueGL technique;\n\n    int method;\n\n    /**\n     * @brief initializeGL sets variables up.\n     */\n    void initializeGL(){\n\n        #ifndef PIC_INCLUDE_GL\n            initializeOpenGLFunctions();\n        #endif\n\n        #ifdef PIC_INCLUDE_GL\n            if(ogl_LoadFunctions() == ogl_LOAD_FAILED) {\n                printf(\"OpenGL functions are not loaded!\\n\");\n            }\n        #endif\n\n        glClearColor(0.0f, 0.0f, 0.0f, 0.0f );\n\n        //read an input image\n        img.Read(\"../data/input/bottles.hdr\");\n        img.generateTextureGL();\n\n        //create a random image\n        imgRand = new pic::ImageGL(img.frames, img.width, img.height, 1, pic::IMG_CPU_GPU, GL_TEXTURE_2D);\n        imgRand->setRand();\n        imgRand->loadFromMemory();\n        *imgRand *= 0.1f;\n\n        //create a display\n        display = new pic::DisplayGL();\n    }\n\n    /**\n     * @brief resizeGL\n     * @param w\n     * @param h\n     */\n    void resizeGL( int w, int h ){\n        const qreal retinaScale = devicePixelRatio();\n        glViewport(0, 0, w * retinaScale, h * retinaScale);\n    }\n\n    /**\n     * @brief paintGL\n     */\n    void paintGL(){\n        if(parentWidget() != NULL) {\n            if(!parentWidget()->isVisible()) {\n                return;\n            }\n        }\n\n        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\n\n        display->Process(&img);\n    }\n\npublic:\n\n    /**\n     * @brief GLWidget\n     * @param format\n     * @param parent\n     */\n    GLWidget( const QGLFormat& format, QWidget* parent = 0 ): QGLWidget(format, parent, 0)\n    {\n        setFixedWidth(912);\n        setFixedHeight(684);\n        method = 0;\n    }\n\n    /**\n     * @brief update\n     */\n    void update()\n    {\n        method = (method + 1) % 2;\n        img += *imgRand;\n    }\n};\n\nclass Window : public QWidget\n{\nprotected:\n    GLWidget *window_gl;\n    QVBoxLayout *layout;\n    QLabel *label;\n\npublic:\n\n    /**\n     * @brief Window\n     * @param format\n     */\n    Window(const QGLFormat &format)\n    {\n        resize(912, 684 + 64);\n\n        window_gl = new GLWidget(format, this);\n\n        layout = new QVBoxLayout();\n\n        layout->addWidget(window_gl);\n\n        label = new QLabel(\n        \"Pease hit the space bar in order to add random grey noise to the original image.\", this);\n        label->setAlignment(Qt::AlignHCenter);\n        label->setFixedWidth(912);\n        label->setFixedHeight(64);\n\n        layout->addWidget(label);\n\n        setLayout(layout);\n\n        setWindowTitle(tr(\"Operators Example\"));\n    }\n\n    ~Window()\n    {\n        delete window_gl;\n        delete layout;\n        delete label;\n    }\n\n    /**\n     * @brief keyPressEvent\n     * @param e\n     */\n    void keyPressEvent( QKeyEvent* e ){\n        if(e->type() == QEvent::KeyPress) {\n            if(e->key() == Qt::Key_Space) {\n                window_gl->update();\n                window_gl->updateGL();\n            }\n        }\n    }\n};\n\nint main(int argc, char **argv)\n{\n    QApplication app( argc, argv );\n\n    QGLFormat glFormat;\n    glFormat.setVersion( 4, 0 );\n    glFormat.setProfile( QGLFormat::CoreProfile );\n    glFormat.setSampleBuffers( true );\n\n    //Creating a window with OpenGL 4.0 Core profile\n    Window w( glFormat );\n    w.show();\n\n    app.installEventFilter(&w);\n\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/opengl_operators/opengl_operators.pro",
    "content": "TARGET = opengl_operators\n\nQT += core\nQT += gui\nQT += opengl\nQT += widgets\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\n\nSOURCES += main.cpp\n\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n\nwin32{\n        DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n"
  },
  {
    "path": "examples/opengl_push_pull/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n/**\n * NOTE: if you do not want to use this OpenGL functions loader,\n * please change it with your favorite one. This is just\n * a suggestion for running examples.\n*/\n\n#include \"../common_code/gl_include.hpp\"\n\n#include <QKeyEvent>\n#include <QtCore/QCoreApplication>\n#include <QtOpenGL/QGLWidget>\n#include <QApplication>\n#include <QVBoxLayout>\n#include <QLabel>\n\n#include \"piccante.hpp\"\n\nclass GLWidget : public QGLWidget\n        #ifndef PIC_INCLUDE_GL\n        , protected QOpenGLFunctions\n        #endif\n{\nprotected:\n    pic::DisplayGL *display;\n    pic::ImageGL img, *imgRec;\n    int method;\n    pic::PushPullGL *pp;\n\n    /**\n     * @brief initializeGL sets variables up.\n     */\n    void initializeGL(){\n\n    #ifndef PIC_INCLUDE_GL\n        initializeOpenGLFunctions();\n    #endif\n\n    #ifdef PIC_INCLUDE_GL\n        if(ogl_LoadFunctions() == ogl_LOAD_FAILED) {\n            printf(\"OpenGL functions are not loaded!\\n\");\n        }\n    #endif\n\n        glClearColor(0.0f, 0.0f, 0.0f, 0.0f );\n\n        //read an input image\n        img.Read(\"../data/input/bottles.hdr\");\n\n        pic::Image img_black(1, 32, 32, 3);\n        img_black.setZero();\n\n        //add a hole in the image\n        img.copySubImage(&img_black, 292, 130);\n\n        img.generateTextureGL();\n\n        //create a screen aligned quad\n        display = new pic::DisplayGL();\n\n        //create push pull method\n        pp = new pic::PushPullGL();\n    }\n\n    /**\n     * @brief resizeGL\n     * @param w\n     * @param h\n     */\n    void resizeGL( int w, int h ){\n        const qreal retinaScale = devicePixelRatio();\n        glViewport(0, 0, w * retinaScale, h * retinaScale);\n    }\n\n    /**\n     * @brief paintGL\n     */\n    void paintGL(){\n        if(parentWidget() != NULL) {\n            if(!parentWidget()->isVisible()) {\n                return;\n            }\n        }\n\n        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\n\n        //simple tone mapping: gamma + exposure correction\n        pic::ImageGL *img_out;\n        if(method == 1) {\n            pp->update(pic::Arrayf::zeros(img.channels), 1e-4f);\n\n            imgRec = pp->Process(&img, imgRec);\n\n            img_out = imgRec;\n            window_ext->setWindowTitle(tr(\"PushPull Example: Reconstructed Image\"));\n\n        } else {\n            window_ext->setWindowTitle(tr(\"PushPull Example: Input Image with a Hole (black square)\"));\n            img_out = &img;\n        }\n\n        display->Process(img_out);\n    }\n\npublic:\n    QWidget *window_ext;\n\n    /**\n     * @brief GLWidget\n     * @param format\n     * @param parent\n     */\n    GLWidget( const QGLFormat& format, QWidget* parent = 0 ): QGLWidget(format, parent, 0)\n    {\n        setFixedWidth(912);\n        setFixedHeight(684);\n\n        method = 0;\n        imgRec = NULL;\n    }\n\n    /**\n     * @brief update\n     */\n    void update()\n    {\n        method = (method + 1) % 2;\n    }\n};\n\nclass Window : public QWidget\n{\nprotected:\n\n    GLWidget *window_gl;\n    QVBoxLayout *layout;\n    QLabel *label;\n\npublic:\n\n    /**\n     * @brief Window\n     * @param format\n     */\n    Window(const QGLFormat &format)\n    {\n        resize(912, 684 + 64);\n\n        window_gl = new GLWidget(format, this);\n        window_gl->window_ext = this;\n\n        layout = new QVBoxLayout();\n\n        layout->addWidget(window_gl);\n\n        label = new QLabel(\n                    \"Please hit the space bar in order to switch from the original \"\n                    \"image (with a black hole) to the reconstructed one using Push-Pull.\",\n                    this);\n        label->setFixedWidth(912);\n        label->setFixedHeight(64);\n\n        layout->addWidget(label);\n\n        setLayout(layout);\n\n        setWindowTitle(tr(\"Push-Pull Example\"));\n    }\n\n    ~Window()\n    {\n        delete window_gl;\n        delete layout;\n        delete label;\n    }\n\n    /**\n     * @brief keyPressEvent\n     * @param e\n     */\n    void keyPressEvent( QKeyEvent* e ){\n        if(e->type() == QEvent::KeyPress) {\n            if(e->key() == Qt::Key_Space) {\n                window_gl->update();\n                window_gl->updateGL();\n            }\n        }\n    }\n};\n\nint main(int argc, char **argv)\n{\n    QApplication app( argc, argv );\n\n    QGLFormat glFormat;\n    glFormat.setVersion( 4, 0 );\n    glFormat.setProfile( QGLFormat::CoreProfile );\n    glFormat.setSampleBuffers( true );\n\n    //Creating a window with OpenGL 4.0 Core profile\n    Window w( glFormat );\n    w.show();\n\n    app.installEventFilter(&w);\n\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/opengl_push_pull/opengl_push_pull.pro",
    "content": "TARGET = opengl_push_pull\n\nQT += core\nQT += gui\nQT += opengl\nQT += widgets\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\n\nSOURCES += main.cpp\n\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n\nwin32{\n        DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n"
  },
  {
    "path": "examples/opengl_simple_io/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n/**\n * NOTE: if you do not want to use this OpenGL functions loader,\n * please change it with your favorite one. This is just\n * a suggestion for running examples.\n*/\n\n#include \"../common_code/gl_include.hpp\"\n\n#include <QKeyEvent>\n#include <QtCore/QCoreApplication>\n#include <QtOpenGL/QGLWidget>\n#include <QApplication>\n#include <QVBoxLayout>\n#include <QLabel>\n\n#include \"piccante.hpp\"\n\nclass GLWidget : public QGLWidget\n        #ifndef PIC_INCLUDE_GL\n        , protected QOpenGLFunctions\n        #endif\n{\nprotected:\n    pic::ImageGL img;\n    pic::DisplayGL *display;\n\n    /**\n     * @brief initializeGL sets variables up.\n     */\n    void initializeGL(){\n\n    #ifndef PIC_INCLUDE_GL\n        initializeOpenGLFunctions();\n    #endif\n\n    #ifdef PIC_INCLUDE_GL\n        if(ogl_LoadFunctions() == ogl_LOAD_FAILED) {\n            printf(\"OpenGL functions are not loaded!\\n\");\n        }\n    #endif\n\n        glClearColor(0.0f, 0.0f, 0.0f, 0.0f );\n\n        //read an input image\n        img.Read(\"../data/input/bottles.hdr\");\n        img.generateTextureGL();\n\n        //create a screen aligned quad\n        display = new pic::DisplayGL();\n    }\n\n    /**\n     * @brief resizeGL\n     * @param w\n     * @param h\n     */\n    void resizeGL( int w, int h ){\n        const qreal retinaScale = devicePixelRatio();\n        glViewport(0, 0, w * retinaScale, h * retinaScale);\n    }\n\n    /**\n     * @brief paintGL\n     */\n    void paintGL(){\n        if(parentWidget() != NULL) {\n            if(!parentWidget()->isVisible()) {\n                return;\n            }\n        }\n\n        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\n\n        //simple tone mapping: gamma + exposure correction\n        display->Process(&img);\n    }\n\npublic:\n\n    /**\n     * @brief GLWidget\n     * @param format\n     * @param parent\n     */\n    GLWidget( const QGLFormat& format, QWidget* parent = 0 ): QGLWidget(format, parent, 0)\n    {\n        setFixedWidth(912);\n        setFixedHeight(684);\n    }\n};\n\nclass Window : public QWidget\n{\nprotected:\n\n    GLWidget *window_gl;\n    QVBoxLayout *layout;\n    QLabel *label;\n\npublic:\n\n    /**\n     * @brief Window\n     * @param format\n     */\n    Window(const QGLFormat &format)\n    {\n        resize(912, 684 + 64);\n\n        window_gl = new GLWidget(format, this);\n\n        layout = new QVBoxLayout();\n\n        layout->addWidget(window_gl);\n        label = new QLabel(\n                    \"This example opens an HDR image and shows it using OpenGL.\",\n                    this);\n        label->setFixedWidth(912);\n        label->setFixedHeight(64);\n        label->setAlignment(Qt::AlignHCenter);\n\n        layout->addWidget(label);\n\n        setLayout(layout);\n\n        setWindowTitle(tr(\"Simple OpenGL I/O\"));\n    }\n\n    ~Window()\n    {\n        delete window_gl;\n        delete layout;\n        delete label;\n    }\n};\n\nint main(int argc, char **argv)\n{\n    QApplication app( argc, argv );\n\n    QGLFormat glFormat;\n    glFormat.setVersion( 4, 0 );\n    glFormat.setProfile( QGLFormat::CoreProfile );\n    glFormat.setSampleBuffers( true );\n\n    //create a window with OpenGL 4.0 Core profile\n    Window w( glFormat );\n    w.show();\n\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/opengl_simple_io/opengl_simple_io.pro",
    "content": "TARGET = opengl_simple_io\n\nQT += core\nQT += gui\nQT += opengl\nQT += widgets\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\n\nSOURCES += main.cpp\n\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n\nwin32{\n    DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n"
  },
  {
    "path": "examples/opengl_tone_mapping/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n/**\n * NOTE: if you do not want to use this OpenGL functions loader,\n * please change it with your favorite one. This is just\n * a suggestion for running examples.\n*/\n\n#include \"../common_code/gl_include.hpp\"\n\n#include <QKeyEvent>\n#include <QtCore/QCoreApplication>\n#include <QtOpenGL/QGLWidget>\n#include <QApplication>\n#include <QVBoxLayout>\n#include <QLabel>\n\n#include \"piccante.hpp\"\n\nclass GLWidget : public QGLWidget\n        #ifndef PIC_INCLUDE_GL\n        , protected QOpenGLFunctions\n        #endif\n{\nprotected:\n    pic::DragoTMOGL *drago_tmo;\n    pic::ReinhardTMOGL *reinhard_tmo;\n    pic::DurandTMOGL *durand_tmo;\n    pic::DisplayGL *display;\n    pic::ImageGL img, *img_tmo;\n\n    int method;\n\n    /**\n     * @brief initializeGL sets variables up.\n     */\n    void initializeGL(){\n\n    #ifndef PIC_INCLUDE_GL\n        initializeOpenGLFunctions();\n    #endif\n\n    #ifdef PIC_INCLUDE_GL\n        if(ogl_LoadFunctions() == ogl_LOAD_FAILED) {\n            printf(\"OpenGL functions are not loaded!\\n\");\n        }\n    #endif\n\n        glClearColor(0.0f, 0.0f, 0.0f, 0.0f );\n\n        img_tmo = NULL;\n\n        //read an input image\n        img.Read(\"../data/input/bottles.hdr\");\n        img.generateTextureGL();\n\n        //create a screen aligned quad\n        display = new pic::DisplayGL();\n\n        //allocate Drago et al.'s TMO\n        drago_tmo = new pic::DragoTMOGL();\n\n        //allocate Reinhard et al.'s TMO\n        reinhard_tmo = new pic::ReinhardTMOGL();\n\n        //allocate Durand et al.'s TMO\n        durand_tmo = new pic::DurandTMOGL();\n    }\n\n    /**\n     * @brief resizeGL\n     * @param w\n     * @param h\n     */\n    void resizeGL( int w, int h ){\n        const qreal retinaScale = devicePixelRatio();\n        glViewport(0, 0, w * retinaScale, h * retinaScale);\n    }\n\n    /**\n     * @brief paintGL\n     */\n    void paintGL(){\n        if(parentWidget() != NULL) {\n            if(!parentWidget()->isVisible()) {\n                return;\n            }\n        }\n\n        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\n\n        switch(method) {\n        case 0: {\n            //apply Reinhard et al.'s TMO (local version)\n            reinhard_tmo->update(-1.0f, -1.0f, false);\n            img_tmo = reinhard_tmo->execute(&img, img_tmo);\n        } break;\n\n        case 1: {\n            //apply Reinhard et al.'s TMO (global version)\n            reinhard_tmo->update(-1.0f, -1.0f, true);\n            img_tmo = reinhard_tmo->execute(&img, img_tmo);\n        } break;\n\n        case 2: {\n            //apply Drago et al.'s TMO\n            img_tmo = drago_tmo->execute(&img, img_tmo);\n        } break;\n\n        case 3: {\n            //apply Durand et al.'s TMO\n            img_tmo = durand_tmo->execute(&img, img_tmo);\n        } break;\n        }\n\n        display->Process(img_tmo);\n    }\n\npublic:\n\n    /**\n     * @brief GLWidget\n     * @param format\n     * @param parent\n     */\n    GLWidget( const QGLFormat& format, QWidget* parent = 0 ): QGLWidget(format, parent, 0)\n    {\n        setFixedWidth(912);\n        setFixedHeight(684);\n\n        img_tmo = NULL;\n        method = 0;\n    }\n\n    /**\n     * @brief update\n     */\n    void update()\n    {\n        method = (method + 1) % 4;\n    }\n};\n\nclass Window : public QWidget\n{\nprotected:\n\n    GLWidget *window_gl;\n    QVBoxLayout *layout;\n    QLabel *label;\n\npublic:\n\n    /**\n     * @brief Window\n     * @param format\n     */\n    Window(const QGLFormat &format)\n    {\n        resize(912, 684 + 64);\n\n        window_gl = new GLWidget(format, this);\n\n        layout = new QVBoxLayout();\n\n        layout->addWidget(window_gl);\n\n        label = new QLabel(\n                    \"Please hit the space bar in order to switch to different tone mapping images.\",\n                    this);\n        label->setFixedWidth(912);\n        label->setFixedHeight(64);\n        label->setAlignment(Qt::AlignHCenter);\n\n        layout->addWidget(label);\n\n        setLayout(layout);\n\n        setWindowTitle(tr(\"Tone Mapping Example\"));\n    }\n\n    ~Window()\n    {\n        delete window_gl;\n        delete layout;\n        delete label;\n    }\n\n    /**\n     * @brief keyPressEvent\n     * @param e\n     */\n    void keyPressEvent( QKeyEvent* e ){\n        if(e->type() == QEvent::KeyPress) {\n            if(e->key() == Qt::Key_Space) {\n                window_gl->update();\n                window_gl->updateGL();\n            }\n        }\n    }\n};\n\nint main(int argc, char **argv)\n{\n    QApplication app( argc, argv );\n\n    QGLFormat glFormat;\n    glFormat.setVersion( 4, 0 );\n    glFormat.setProfile( QGLFormat::CoreProfile );\n    glFormat.setSampleBuffers( true );\n\n    //create a window with OpenGL 4.0 Core profile\n    Window w( glFormat );\n    w.show();\n\n    app.installEventFilter(&w);\n\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/opengl_tone_mapping/opengl_tone_mapping.pro",
    "content": "TARGET = opengl_tone_mapping\n\nQT += core\nQT += gui\nQT += opengl\nQT += widgets\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\n\nSOURCES += main.cpp\n\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n\nwin32{\n        DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n"
  },
  {
    "path": "examples/opengl_tone_mapping_color_correction/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n/**\n * NOTE: if you do not want to use this OpenGL functions loader,\n * please change it with your favorite one. This is just\n * a suggestion for running examples.\n*/\n\n#include \"../common_code/gl_include.hpp\"\n\n#include <QKeyEvent>\n#include <QtCore/QCoreApplication>\n#include <QtOpenGL/QGLWidget>\n#include <QApplication>\n#include <QVBoxLayout>\n#include <QLabel>\n#include <ctime>\n#define PIC_STB_DISABLE\n\n#include \"piccante.hpp\"\n\nclass GLWidget : public QGLWidget\n        #ifndef PIC_INCLUDE_GL\n        , protected QOpenGLFunctions\n        #endif\n{\nprotected:\n    pic::FilterGLColorCorrectionPouli *fltCC;\n    pic::ReinhardTMOGL *reinhard_tmo;\n    pic::DisplayGL *display;\n    pic::ImageGL img, *img_tmo, *img_tmo_cc;\n\n    int method;\n\n    /**\n     * @brief initializeGL sets variables up.\n     */\n    void initializeGL(){\n\n    #ifndef PIC_INCLUDE_GL\n        initializeOpenGLFunctions();\n    #endif\n\n    #ifdef PIC_INCLUDE_GL\n        if(ogl_LoadFunctions() == ogl_LOAD_FAILED) {\n            printf(\"OpenGL functions are not loaded!\\n\");\n        }\n    #endif\n\n        glClearColor(0.0f, 0.0f, 0.0f, 0.0f );\n\n        img_tmo = NULL;\n        img_tmo_cc = NULL;\n\n        //read an input image\n        img.Read(\"../data/input/bottles.hdr\");\n\n        img.generateTextureGL();\n\n        //create a screen aligned quad\n        display = new pic::DisplayGL();\n\n        //allocate Reinhard et al.'s TMO\n        reinhard_tmo = new pic::ReinhardTMOGL(0.5f, -1.0f, true, true);\n\n        //allocate the color correction filter\n        fltCC = new pic::FilterGLColorCorrectionPouli();\n    }\n\n    /**\n     * @brief resizeGL\n     * @param w\n     * @param h\n     */\n    void resizeGL( int w, int h ){\n        const qreal retinaScale = devicePixelRatio();\n        glViewport(0, 0, w * retinaScale, h * retinaScale);\n    }\n\n    /**\n     * @brief paintGL\n     */\n    void paintGL(){\n        if(parentWidget() != NULL) {\n            if(!parentWidget()->isVisible()) {\n                return;\n            }\n        }\n\n        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\n        //apply Reinhard et al.'s TMO (local version)\n        img_tmo = reinhard_tmo->execute(&img, img_tmo);\n        img_tmo->clamp(0.0f, 1.0f);\n\n        switch(method) {\n        case 0: {\n            display->Process(img_tmo);\n        } break;\n\n        case 1: {\n            //apply Pouli et al.'s color correction\n            img_tmo_cc = pic::FilterGLColorCorrectionPouli::execute(fltCC, &img, img_tmo, img_tmo_cc);\n\n            display->Process(img_tmo_cc);\n        } break;\n        }\n\n    }\n\npublic:\n\n    /**\n     * @brief GLWidget\n     * @param format\n     * @param parent\n     */\n    GLWidget( const QGLFormat& format, QWidget* parent = 0 ): QGLWidget(format, parent, 0)\n    {\n        setFixedWidth(912);\n        setFixedHeight(684);\n\n        img_tmo = NULL;\n        img_tmo_cc = NULL;\n        method = 0;\n    }\n\n    /**\n     * @brief update\n     */\n    void update()\n    {\n        method = (method + 1) % 2;\n    }\n};\n\nclass Window : public QWidget\n{\nprotected:\n\n    GLWidget *window_gl;\n    QVBoxLayout *layout;\n    QLabel *label;\n\npublic:\n\n    /**\n     * @brief Window\n     * @param format\n     */\n    Window(const QGLFormat &format)\n    {\n        resize(912, 684 + 64);\n\n        window_gl = new GLWidget(format, this);\n\n        layout = new QVBoxLayout();\n\n        layout->addWidget(window_gl);\n\n        label = new QLabel(\n                    \"Please hit the space bar in order to switch to different tone mapping images.\",\n                    this);\n        label->setFixedWidth(912);\n        label->setFixedHeight(64);\n        label->setAlignment(Qt::AlignHCenter);\n\n        layout->addWidget(label);\n\n        setLayout(layout);\n\n        setWindowTitle(tr(\"Tone Mapping Example\"));\n    }\n\n    ~Window()\n    {\n        delete window_gl;\n        delete layout;\n        delete label;\n    }\n\n    /**\n     * @brief keyPressEvent\n     * @param e\n     */\n    void keyPressEvent( QKeyEvent* e ){\n        if(e->type() == QEvent::KeyPress) {\n            if(e->key() == Qt::Key_Space) {\n                window_gl->update();\n                window_gl->updateGL();\n            }\n        }\n    }\n};\n\nint main(int argc, char **argv)\n{\n    QApplication app( argc, argv );\n\n    QGLFormat glFormat;\n    glFormat.setVersion( 4, 0 );\n    glFormat.setProfile( QGLFormat::CoreProfile );\n    glFormat.setSampleBuffers( true );\n\n    //create a window with OpenGL 4.0 Core profile\n    Window w( glFormat );\n    w.show();\n\n    app.installEventFilter(&w);\n\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/opengl_tone_mapping_color_correction/opengl_tone_mapping.pro",
    "content": "TARGET = opengl_tone_mapping_color_correction\n\nQT += core\nQT += gui\nQT += opengl\nQT += widgets\n\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\n\nSOURCES += main.cpp\n\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n\nwin32{\n        DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n    SOURCES += ../common_code/gl_core_4_0.c\n}\n"
  },
  {
    "path": "examples/panorama_rotate/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/cs_warwick.hdr\";\n    }\n\n    printf(\"Reading a 360 panoramic image file...\");\n\n    pic::Image img(img_str);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"OK\\n\");\n\n        bool bWritten;\n        std::string name = pic::getFileNameOnly(img_str);\n\n        pic::Image *img_rot_simple = pic::FilterRotation::execute(&img, NULL, pic::Deg2Rad(0.0f), pic::Deg2Rad(90.0f));\n        bWritten = img_rot_simple->Write(\"../data/output/\" + name + \"_rot_phi_90.hdr\");\n\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/panorama_rotate/pn_rotate.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = pn_rotate\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/qt_gui_example/main.cpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nPICCANTE is free software; you can redistribute it and/or modify\nunder the terms of the GNU Lesser General Public License as\npublished by the Free Software Foundation; either version 3.0 of\nthe License, or (at your option) any later version.\n\nPICCANTE is distributed in the hope that it will be useful, but\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU Lesser General Public License\n( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\n*/\n\n#include <QApplication>\n\n#include \"window.hpp\"\n\nint main(int argc, char *argv[])\n{\n    Q_INIT_RESOURCE(resources);\n\n    QApplication app(argc, argv);\n    Window window;\n    window.resize(800, 600);\n    window.show();\n    return app.exec();\n}\n"
  },
  {
    "path": "examples/qt_gui_example/resources.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/\">\n        <file>filesaveas.ico</file>\n        <file>fileopen.ico</file>\n        <file>exit.ico</file>\n        <file>zoom_out.ico</file>\n        <file>zoom_original.ico</file>\n        <file>zoom_in.ico</file>\n        <file>zoom_fit_best.ico</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "examples/qt_gui_example/simple_qt.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = simple_qt\n\nQT += widgets\nTEMPLATE = app\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nHEADERS += window.hpp\n\nSOURCES += main.cpp \\\n    window.cpp\n\nRESOURCES += resources.qrc\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/qt_gui_example/window.cpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nPICCANTE is free software; you can redistribute it and/or modify\nunder the terms of the GNU Lesser General Public License as\npublished by the Free Software Foundation; either version 3.0 of\nthe License, or (at your option) any later version.\n\nPICCANTE is distributed in the hope that it will be useful, but\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU Lesser General Public License\n( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\n*/\n\n#include \"window.hpp\"\n\n#include <QtWidgets>\n\n#include <QFileDialog>\n#include <QImage>\n\n//This means that OpenGL acceleration layer is disable\n#define PIC_DISABLE_OPENGL\n\n#include \"../common_code/image_qimage_interop.hpp\"\n\n#include \"piccante.hpp\"\n\nWindow::Window(QMainWindow *parent) :\n    QMainWindow(parent),\n    image(NULL),\n    last_filename(NULL)\n{\n    image_label = new QLabel;\n    image_label->setBackgroundRole(QPalette::Base);\n    image_label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);\n    image_label->setScaledContents(true);\n\n    scroll_area = new QScrollArea;\n    scroll_area->setBackgroundRole(QPalette::Dark);\n    scroll_area->setWidget(image_label);\n    setCentralWidget(scroll_area);\n\n\n    create_actions();\n    create_menus();\n    create_toolbars();\n\n    setWindowTitle(\"Simple QT\");\n}\n\nWindow::~Window()\n{\n    if(image != NULL){\n        delete image;\n    }\n    if(last_filename != NULL){\n        delete last_filename;\n    }\n}\n\nvoid Window::open()\n{\n    QString fileName = QFileDialog::getOpenFileName(this,\n                                                    tr(\"Open File\"),\n                                                    QDir::currentPath());\n    if(fileName.isEmpty()) {\n        return;\n    }\n\n    pic::Image *pic_im = new pic::Image;\n    ImageRead(fileName.toStdString(), pic_im);\n\n    if(!pic_im->isValid()) {\n        QMessageBox::information(this, tr(\"Simple QT\"),\n                                 tr(\"Cannot load %1.\").arg(fileName));\n        delete pic_im;\n        save_as_action->setEnabled(false);\n        zoom_fit_action->setEnabled(false);\n        zoom_in_action->setEnabled(false);\n        zoom_out_action->setEnabled(false);\n        zoom_original_action->setEnabled(false);\n        gaussian_blur_action->setEnabled(false);\n        scale_factor = 1.0;\n        return;\n    }\n\n    if(last_filename != NULL) {\n        delete last_filename;\n    }\n\n    last_filename = new QString(fileName);\n    if(image != NULL) {\n        delete image;\n    }\n    image = pic_im;\n\n    update_pixmap();\n\n    save_as_action->setEnabled(true);\n    zoom_fit_action->setEnabled(true);\n    gaussian_blur_action->setEnabled(true);\n    scale_factor = 1.0;\n    update_actions();\n\n    if (!zoom_fit_action->isChecked())\n        image_label->adjustSize();\n}\n\nvoid Window::save_as()\n{\n    QString fileName = QFileDialog::getSaveFileName(this,\n                                                    tr(\"Save File\"),\n                                                    *last_filename,\n                                                    tr(\"Images (*.bmp *.tga *.ppm *.pgm *.pfm *.hdr)\"));\n\n    bool success = ImageWrite(image, fileName.toStdString());\n\n    if(!success) {\n        QMessageBox::information(this, tr(\"Simple QT\"),\n                                 tr(\"Cannot save %1.\").arg(fileName));\n        return;\n    }\n}\n\nvoid Window::closeEvent(QCloseEvent *event)\n{\n    event->accept();\n}\n\nvoid Window::create_actions()\n{\n    open_action = new QAction(QIcon(\":/fileopen.ico\"), tr(\"Open\"), this);\n    open_action->setShortcuts(QKeySequence::Open);\n    connect(open_action, SIGNAL(triggered()), this, SLOT(open()));\n\n    save_as_action = new QAction(QIcon(\":/filesaveas.ico\"), tr(\"Save As\"), this);\n    save_as_action->setShortcuts(QKeySequence::SaveAs);\n    connect(save_as_action, SIGNAL(triggered()), this, SLOT(save_as()));\n    save_as_action->setEnabled(false);\n\n    exit_action = new QAction(QIcon(\":/exit.ico\"), tr(\"Quit\"), this);\n    exit_action->setShortcuts(QKeySequence::Quit);\n    connect(exit_action, SIGNAL(triggered()), this, SLOT(close()));\n\n    zoom_in_action = new QAction(QIcon(\":/zoom_in.ico\"),tr(\"Zoom &In (25%)\"), this);\n    zoom_in_action->setShortcuts(QList<QKeySequence>() << QKeySequence::ZoomIn << QKeySequence(tr(\"Ctrl++\")));\n    zoom_in_action->setEnabled(false);\n    connect(zoom_in_action, SIGNAL(triggered()), this, SLOT(zoom_in()));\n\n    zoom_out_action = new QAction(QIcon(\":/zoom_out.ico\"),tr(\"Zoom &Out (25%)\"), this);\n    zoom_out_action->setShortcuts(QList<QKeySequence>() << QKeySequence::ZoomOut << QKeySequence(tr(\"Ctrl+-\")));\n    zoom_out_action->setEnabled(false);\n    connect(zoom_out_action, SIGNAL(triggered()), this, SLOT(zoom_out()));\n\n    zoom_original_action = new QAction(QIcon(\":/zoom_original.ico\"),tr(\"&Normal Size\"), this);\n    zoom_original_action->setShortcut(tr(\"Ctrl+S\"));\n    zoom_original_action->setEnabled(false);\n    connect(zoom_original_action, SIGNAL(triggered()), this, SLOT(zoom_original()));\n\n    zoom_fit_action = new QAction(QIcon(\":/zoom_fit_best.ico\"),tr(\"&Fit to Window\"), this);\n    zoom_fit_action->setShortcut(tr(\"Ctrl+F\"));\n    zoom_fit_action->setEnabled(false);\n    zoom_fit_action->setCheckable(true);\n    connect(zoom_fit_action, SIGNAL(triggered()), this, SLOT(zoom_fit()));\n\n    gaussian_blur_action = new QAction(tr(\"Gaussian blur\"), this);\n    gaussian_blur_action->setShortcut(tr(\"Ctrl+g\"));\n    gaussian_blur_action->setEnabled(false);\n    connect(gaussian_blur_action, SIGNAL(triggered()), this, SLOT(gaussian_blur()));\n}\n\nvoid Window::create_menus()\n{\n    file_menu = new QMenu(tr(\"&File\"), this);\n    file_menu->addAction(open_action);\n    file_menu->addAction(save_as_action);\n    file_menu->addSeparator();\n    file_menu->addAction(exit_action);\n\n    view_menu = new QMenu(tr(\"&View\"), this);\n    view_menu->addAction(zoom_in_action);\n    view_menu->addAction(zoom_out_action);\n    view_menu->addAction(zoom_original_action);\n    view_menu->addSeparator();\n    view_menu->addAction(zoom_fit_action);\n\n    edit_menu = new QMenu(tr(\"&Edit\"), this);\n    edit_menu->addAction(gaussian_blur_action);\n\n    menuBar()->addMenu(file_menu);\n    menuBar()->addMenu(view_menu);\n    menuBar()->addMenu(edit_menu);\n}\n\nvoid Window::create_toolbars()\n{\n    file_toolbar = addToolBar(tr(\"File\"));\n    file_toolbar->addAction(open_action);\n    file_toolbar->addAction(save_as_action);\n    file_toolbar->addSeparator();\n    file_toolbar->addAction(exit_action);\n\n    view_toolbar = addToolBar(tr(\"View\"));\n    view_toolbar->addAction(zoom_in_action);\n    view_toolbar->addAction(zoom_out_action);\n    view_toolbar->addAction(zoom_original_action);\n    view_toolbar->addSeparator();\n    view_toolbar->addAction(zoom_fit_action);\n\n    edit_toolbar = addToolBar(tr(\"Edit\"));\n    edit_toolbar->addAction(gaussian_blur_action);\n}\n\n\nvoid Window::update_actions()\n{\n    zoom_in_action->setEnabled(!zoom_fit_action->isChecked());\n    zoom_out_action->setEnabled(!zoom_fit_action->isChecked());\n    zoom_original_action->setEnabled(!zoom_fit_action->isChecked());\n}\n\nvoid Window::zoom_in()\n{\n    scale_image(1.25);\n}\n\nvoid Window::zoom_out()\n{\n    scale_image(0.8);\n}\n\nvoid Window::zoom_original()\n{\n    image_label->adjustSize();\n    scale_factor = 1.0;\n}\n\nvoid Window::zoom_fit()\n{\n    bool fitToWindow = zoom_fit_action->isChecked();\n    scroll_area->setWidgetResizable(fitToWindow);\n    if (!fitToWindow) {\n        zoom_original();\n    }\n    update_actions();\n}\n\nvoid Window::gaussian_blur()\n{\n    pic::Image *output = pic::FilterGaussian2D::execute(image, NULL, 4.0f);\n    delete image;\n    image = output;\n    update_pixmap();\n}\n\nvoid Window::scale_image(double factor)\n{\n    scale_factor *= factor;\n    image_label->resize(scale_factor * image_label->pixmap()->size());\n\n    adjust_scrollbar(scroll_area->horizontalScrollBar(), factor);\n    adjust_scrollbar(scroll_area->verticalScrollBar(), factor);\n\n    zoom_in_action->setEnabled(scale_factor < 3.0);\n    zoom_out_action->setEnabled(scale_factor > 0.333);\n}\n\nvoid Window::adjust_scrollbar(QScrollBar *scrollbar, double factor)\n{\n    scrollbar->setValue(int(factor * scrollbar->value() + ((factor - 1) * scrollbar->pageStep()/2)));\n}\n\nvoid Window::update_pixmap()\n{\n    image_label->clear();\n\n    if(image == NULL) {\n        return;\n    }\n\n    *image /=(image->getMeanVal()[0] * 4.0f);\n\n    QImage *qimage = ImageConvertToQImage(image);\n\n    if(qimage->isNull()) {\n        exit(EXIT_FAILURE);\n    }\n\n    image_label->setPixmap(QPixmap::fromImage(*qimage));\n    delete qimage;\n}\n"
  },
  {
    "path": "examples/qt_gui_example/window.hpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n#ifndef WINDOW_HPP\n#define WINDOW_HPP\n\n#include <QMainWindow>\n\nQT_BEGIN_NAMESPACE\nclass QLabel;\nclass QToolBar;\nclass QMenu;\nclass QAction;\nclass QScrollArea;\nclass QScrollBar;\nQT_END_NAMESPACE\n\nnamespace pic{\nclass Image;\n}\n\nclass Window : public QMainWindow\n{\n    Q_OBJECT\npublic:\n    explicit Window(QMainWindow *parent = 0);\n    virtual ~Window();\nprotected slots:\n    void open();\n    void save_as();\n    void zoom_in();\n    void zoom_out();\n    void zoom_original();\n    void zoom_fit();\n    void gaussian_blur();\n\nprotected:\n    void closeEvent(QCloseEvent *event);\n    void create_actions();\n    void create_menus();\n    void create_toolbars();\n    void update_actions();\n    void scale_image(double factor);\n    void adjust_scrollbar(QScrollBar *scrollbar, double factor);\n    void update_pixmap();\n\n    pic::Image *image;\n    QString *last_filename;\n\n    QLabel *image_label;\n    QScrollArea *scroll_area;\n    double scale_factor;\n\n    QAction *open_action;\n    QAction *save_as_action;\n    QAction *exit_action;\n\n    QAction *zoom_fit_action;\n    QAction *zoom_original_action;\n    QAction *zoom_out_action;\n    QAction *zoom_in_action;\n\n    QAction *gaussian_blur_action;\n\n    QMenu *file_menu;\n    QMenu *view_menu;\n    QMenu *edit_menu;\n\n    QToolBar *file_toolbar;\n    QToolBar *view_toolbar;\n    QToolBar *edit_toolbar;\n\n};\n\n#endif // WINDOW_HPP\n"
  },
  {
    "path": "examples/segmentation_classify_pottery/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nfloat data_pottery_mu_c[] = {0.7323f, 0.5415f, 0.3707f};\n\nfloat data_pottery_var_distance = 0.0067f;\n\nfloat data_pottery_colors[] = {\n     0.905880f, 0.551079f, 0.324502f,\n     0.763653f, 0.595515f, 0.439585f,\n     0.622630f, 0.364378f, 0.257991f,\n     0.590748f, 0.313685f, 0.185474f,\n     0.824251f, 0.601703f, 0.450050f,\n     0.794906f, 0.619364f, 0.436753f,\n     0.821792f, 0.675837f, 0.498416f,\n     0.707608f, 0.449535f, 0.341534f,\n     0.855996f, 0.623774f, 0.422128f,\n     0.870602f, 0.637404f, 0.384643f,\n     0.644414f, 0.568198f, 0.417752f,\n     0.622106f, 0.533768f, 0.396989f,\n     0.583980f, 0.510922f, 0.375564f,\n     0.814296f, 0.679109f, 0.491677f,\n     0.482260f, 0.345150f, 0.228758f,\n     0.629664f, 0.518320f, 0.394790f,\n     0.596400f, 0.447404f, 0.256758f,\n     0.560073f, 0.463912f, 0.306148f,\n     0.529985f, 0.430025f, 0.264095f,\n     0.755730f, 0.662055f, 0.535680f,\n     0.616141f, 0.445908f, 0.297837f,\n     0.659471f, 0.481760f, 0.317175f,\n     0.833966f, 0.753722f, 0.520149f,\n     0.631097f, 0.489354f, 0.341120f,\n     0.526288f, 0.455893f, 0.355562f,\n     0.629198f, 0.517534f, 0.383627f,\n     0.713235f, 0.547767f, 0.383766f,\n     0.665671f, 0.559135f, 0.420191f,\n     0.836172f, 0.632880f, 0.456998f,\n     0.873670f, 0.769964f, 0.608476f,\n     0.906808f, 0.784524f, 0.657299f,\n     0.766953f, 0.639195f, 0.511362f,\n     0.755353f, 0.667762f, 0.556958f,\n     0.873414f, 0.740157f, 0.553530f,\n     0.687956f, 0.616581f, 0.497425f,\n     0.727101f, 0.576612f, 0.476035f,\n     0.781689f, 0.635009f, 0.545383f,\n     0.665089f, 0.505783f, 0.392420f,\n     0.733842f, 0.552824f, 0.404788f,\n     0.766402f, 0.583544f, 0.449300f,\n     0.779055f, 0.603955f, 0.475617f,\n     0.515715f, 0.392771f, 0.270234f,\n     0.562040f, 0.455849f, 0.334098f,\n     0.432367f, 0.362063f, 0.275770f,\n     0.820558f, 0.501371f, 0.279049f,\n     0.703572f, 0.466650f, 0.279772f,\n     0.756817f, 0.508563f, 0.307656f,\n     0.690162f, 0.457518f, 0.293599f,\n     0.780417f, 0.518715f, 0.334374f,\n     0.573641f, 0.404990f, 0.282097f,\n     0.655341f, 0.419693f, 0.261571f,\n     0.654784f, 0.433438f, 0.287802f,\n     0.706187f, 0.462480f, 0.316167f,\n     0.695337f, 0.478736f, 0.327183f,\n     0.728882f, 0.487880f, 0.306745f,\n     0.726695f, 0.495772f, 0.330402f,\n     0.712120f, 0.493872f, 0.318577f,\n     0.596444f, 0.354997f, 0.221728f,\n     0.674294f, 0.465968f, 0.375128f,\n     0.767637f, 0.599584f, 0.428771f,\n     0.760421f, 0.524806f, 0.384579f,\n     0.769023f, 0.533266f, 0.366673f,\n     0.652649f, 0.402764f, 0.239002f,\n     0.669948f, 0.497725f, 0.297398f,\n     0.864794f, 0.697683f, 0.442756f,\n     0.692026f, 0.505735f, 0.343322f,\n     0.717008f, 0.512693f, 0.311160f,\n     0.719711f, 0.541340f, 0.376563f,\n     0.749569f, 0.515989f, 0.325290f,\n     0.753319f, 0.491545f, 0.314442f,\n     0.783242f, 0.536050f, 0.333573f,\n     0.676031f, 0.460068f, 0.303192f,\n     0.592480f, 0.451014f, 0.281046f,\n     0.692530f, 0.569825f, 0.365165f,\n     0.963594f, 0.624278f, 0.230820f,\n     0.888652f, 0.546586f, 0.257259f,\n     0.890909f, 0.534012f, 0.273106f,\n     0.834008f, 0.538457f, 0.306348f,\n     0.659635f, 0.506418f, 0.374847f,\n     0.667339f, 0.518752f, 0.338996f,\n     0.678887f, 0.491503f, 0.290518f,\n     0.686869f, 0.528855f, 0.314364f,\n     0.725494f, 0.469987f, 0.296856f,\n     0.764626f, 0.531834f, 0.403452f,\n     0.711875f, 0.514270f, 0.383985f,\n     0.633652f, 0.372839f, 0.212571f,\n     0.859792f, 0.499931f, 0.321176f,\n     0.798168f, 0.522912f, 0.389133f,\n     0.862585f, 0.506567f, 0.311798f,\n     0.688454f, 0.526415f, 0.366411f,\n     0.780315f, 0.554559f, 0.361056f,\n     0.755042f, 0.600079f, 0.441551f,\n     0.712283f, 0.583090f, 0.445270f,\n     0.743296f, 0.597892f, 0.444955f,\n     0.836638f, 0.567583f, 0.316427f,\n     0.756260f, 0.471527f, 0.308210f,\n     0.708007f, 0.563116f, 0.375907f,\n     0.760332f, 0.491914f, 0.305653f,\n     0.684718f, 0.423006f, 0.281000f,\n     0.824254f, 0.571622f, 0.437942f,\n     0.812088f, 0.627018f, 0.488890f,\n     0.767457f, 0.631865f, 0.412610f,\n     0.702364f, 0.566919f, 0.394636f,\n     0.835935f, 0.808427f, 0.569948f,\n     0.840687f, 0.647521f, 0.451695f,\n     0.757705f, 0.645234f, 0.438983f,\n     0.753995f, 0.536740f, 0.422004f,\n     0.793717f, 0.694344f, 0.479166f,\n     0.691007f, 0.600893f, 0.575436f,\n     0.796568f, 0.608328f, 0.376709f,\n     0.790251f, 0.593221f, 0.395209f,\n     0.659157f, 0.478309f, 0.320786f,\n     0.700998f, 0.610203f, 0.430669f,\n     0.833097f, 0.591283f, 0.405894f,\n     0.823696f, 0.589574f, 0.364761f,\n     0.724031f, 0.524344f, 0.360316f,\n     0.688033f, 0.469742f, 0.318249f,\n     0.707864f, 0.500870f, 0.332724f,\n     0.722441f, 0.480724f, 0.321314f,\n     0.663607f, 0.521701f, 0.418351f,\n     0.721152f, 0.585068f, 0.417684f,\n     0.718179f, 0.483824f, 0.270235f,\n     0.600823f, 0.464321f, 0.325956f,\n     0.730693f, 0.541168f, 0.397530f,\n     0.598295f, 0.396023f, 0.293850f,\n     0.745034f, 0.488612f, 0.335355f,\n     0.705249f, 0.481905f, 0.330481f,\n     0.670851f, 0.625477f, 0.488647f,\n     0.808199f, 0.553863f, 0.367883f,\n     0.841836f, 0.698494f, 0.412466f,\n     0.575360f, 0.414156f, 0.306605f,\n     0.687219f, 0.538317f, 0.350663f,\n     0.718699f, 0.438491f, 0.294296f,\n     0.673970f, 0.418290f, 0.310875f,\n     0.704020f, 0.429756f, 0.318432f,\n     0.788929f, 0.579650f, 0.373385f,\n     0.704772f, 0.504252f, 0.323225f,\n     0.718221f, 0.453715f, 0.294117f,\n     0.751163f, 0.500053f, 0.317387f,\n     0.759800f, 0.488985f, 0.345410f,\n     0.725358f, 0.584621f, 0.430615f,\n     0.705827f, 0.567039f, 0.419231f,\n     0.570291f, 0.337304f, 0.232464f,\n     0.750234f, 0.447538f, 0.275323f,\n     0.565289f, 0.360465f, 0.255439f,\n     0.656323f, 0.430128f, 0.294309f,\n     0.673637f, 0.440270f, 0.305129f,\n     0.688219f, 0.606699f, 0.442338f,\n     0.769524f, 0.524712f, 0.370449f,\n     0.820324f, 0.543587f, 0.365516f,\n     0.678666f, 0.521523f, 0.379170f,\n     0.606721f, 0.386053f, 0.271043f,\n     0.784671f, 0.721454f, 0.585207f,\n     0.726181f, 0.476962f, 0.292561f,\n     0.623600f, 0.566590f, 0.460150f,\n     0.710883f, 0.568604f, 0.429637f,\n     0.764222f, 0.533366f, 0.354165f,\n     0.724621f, 0.567116f, 0.390913f,\n     0.625083f, 0.451748f, 0.316139f,\n     0.621494f, 0.395761f, 0.277835f,\n     0.759817f, 0.605538f, 0.430626f,\n     0.807997f, 0.748994f, 0.570144f,\n     0.820408f, 0.693392f, 0.449494f,\n     0.807488f, 0.659545f, 0.344929f,\n     0.817591f, 0.674640f, 0.373004f,\n     0.910433f, 0.801914f, 0.431528f,\n     0.851552f, 0.661569f, 0.337149f,\n     0.912385f, 0.710592f, 0.480525f,\n     0.889140f, 0.656206f, 0.468313f,\n     0.867347f, 0.668786f, 0.477773f,\n     0.902716f, 0.702486f, 0.495801f,\n     0.903408f, 0.707121f, 0.467009f,\n     0.758545f, 0.524321f, 0.312592f,\n     0.851895f, 0.580750f, 0.331892f,\n     0.737622f, 0.527599f, 0.372707f,\n     0.932369f, 0.614163f, 0.285938f,\n     0.886393f, 0.648476f, 0.365666f};\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/features/checker_board_photo_2.png\";\n    }\n\n    printf(\"Reading an image...\");\n    pic::Image img;\n    img.Read(img_str, pic::LT_NOR);\n    printf(\"Ok\\n\");\n\n    if(img.isValid()) {\n        float *white_pixel = img(82, 126);\n\n        pic::Histogram h;\n        h.calculate(&img);\n        float val = h.getOtsu();\n        printf(\"%f\\n\", val);\n        pic::Image *img_thr = pic::FilterThreshold::execute(&img, NULL, val, false);\n        img_thr->Write(\"../data/output/segmentation_otsu.png\");\n\n        bool *mask = pic::computeColorClassification(&img, white_pixel, data_pottery_colors, 171, 3,  data_pottery_var_distance);\n\n        pic::Image *opt = new pic::Image();\n        opt->convertFromMask(mask, img.width, img.height);\n        opt->Write(\"../data/output/classify_pottery_opt.png\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/segmentation_classify_pottery/s_classify_pottery.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = s_classify_pottery\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/segmentation_connected_components/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that we disable Eigen; some functionalities cannot be used.\n//For example, estimating the camera response function\n#define PIC_DISABLE_EIGEN\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_name_str;\n\n    if(argc > 1) {\n        img_name_str = argv[1];\n    } else {\n        img_name_str = \"../data/input/connected_test.png\";\n    }\n\n    printf(\"Reading an LDR file...\");\n\n    pic::Image img;\n    img.Read(img_name_str, pic::LT_NOR);\n\n    printf(\"Ok\\n\");\n\n    printf(\"Is it valid? \");\n    if(img.isValid()) {\n        printf(\"Ok\\n\");\n\n        printf(\"Computing connected components...\");\n\n        std::vector<pic::LabelOutput> ret;\n        pic::ConnectedComponents cc;\n\n        float color[] = {0.0f, 0.0f, 0.0f};\n        auto mask = img.convertToMask(color, 0.0f, true, NULL);\n\n        pic::Image tmp;\n        tmp.convertFromMask(mask, img.width, img.height);\n\n        auto img_cc = cc.execute(mask, img.width, img.height, NULL, ret);\n\n        printf(\"Ok!\\n\");\n\n        unsigned int areaMin = img.nPixels();\n        for(unsigned int i = 0; i < ret.size(); i++) {\n            unsigned int areaTmp = ret[i].coords.size();\n            if(areaMin > areaTmp) {\n                areaMin = areaTmp;\n            }\n        }\n\n        std::string out = \"The size of the smallest circle is: \" + pic::fromNumberToString(areaMin) + \" pixels.\\n\";\n        printf(\"%s\", out.c_str());\n\n        printf(\"Writing the connected component labeling results to a file on the disk...\");\n\n        pic::Image *comp = pic::ConnectedComponents::convertFromIntegerToImage(img_cc, NULL, img.width, img.height);\n        bool bWritten = comp->Write(\"../data/output/connected_components.hdr\");\n\n        if(bWritten) {\n            printf(\"Ok\\n\");\n        } else {\n            printf(\"Writing had some issues!\\n\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/segmentation_connected_components/s_connected_components.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = s_connected_components\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/segmentation_grow_cut/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    printf(\"Reading an image...\");\n\n    pic::Image img, strokes;\n\n    std::string img_str, strokes_str;\n\n    if(argc == 3) {\n        img_str = argv[1];\n        strokes_str = argv[2];\n    } else {\n        img_str = \"../data/input/yellow_flowers.png\";\n        strokes_str = \"../data/input/yellow_flowers_segmentation_strokes.png\";\n    }\n\n    img.Read(img_str);\n    strokes.Read(strokes_str);\n\n    printf(\"OK\\n\");\n\n    printf(\"Are input images valid? \");\n    if(img.isValid() && strokes.isValid()) {\n        printf(\"OK\\n\");\n\n        pic::GrowCut gc;\n\n        pic::Image *seeds = pic::GrowCut::fromStrokeImageToSeeds(&strokes, NULL);\n\n        if(seeds != NULL) {\n            pic::Image *gc_seg = gc.execute(&img, seeds, NULL);\n\n            std::string name = pic::getFileNameOnly(img_str);\n\n            gc_seg->Write(\"../data/output/\" + name + \"_status.pfm\");\n\n            pic::Image *gc_mask = pic::GrowCut::getMaskAsImage(gc_seg, NULL);\n\n            gc_mask->Write(\"../data/output/\" + name + \"_mask.png\");\n        }\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/segmentation_grow_cut/s_grow_cut.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = s_grow_cut\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n        DEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/segmentation_k_means/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    int n;\n\n    if(argc == 2) {\n        n = atoi(argv[1]);\n    } else {\n        n = 100000;\n    }\n    std::mt19937 m;\n\n    int nDim = 2;\n    float *points = new float[nDim * n];\n    for(int i = 0; i< n; i++) {\n        pic::Vec2f tmp = pic::randomPoint<2>(&m);\n        points[i * 2    ] = tmp[0];\n        points[i * 2 + 1] = tmp[1];\n    }\n\n    std::vector< std::set<pic::uint> *> labels;\n\n    int k = 3;\n\n    pic::KMeans<float> km(k, 100);\n\n    float *centers = km.Process(points, n, nDim, NULL, labels);\n\n//     = pic::kMeans<float>(points, n, nDim, k, NULL, labels, 100);\n\n    if(centers != NULL) {\n        printf(\"K-Means ok!\\n\");\n\n        pic::Image img(512, 512, 3);\n\n        float colors[] = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};\n        for(unsigned int i = 0; i < labels.size(); i++) {\n\n            float r = colors[i * 3    ];\n            float g = colors[i * 3 + 1];\n            float b = colors[i * 3 + 2];\n\n            printf(\"Label size: %ld\\n\", labels[i]->size());\n\n            for (std::set<unsigned int>::iterator it=labels[i]->begin(); it!=labels[i]->end(); it++) {\n                unsigned int index = *it;\n                int x = points[index * 2    ] * 255 + 256;\n                int y = points[index * 2 + 1] * 255 + 256;\n                float *data = img(x, y);\n                data[0] = r;\n                data[1] = g;\n                data[2] = b;\n            }\n        }\n\n        img.Write(\"../data/output/s_kmeans.png\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/segmentation_k_means/s_kmeans.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = s_kmeans\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/segmentation_k_means_colors/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n#include \"util/k_means_plusplus.hpp\"\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/tommaseo_statue.png\";\n    }\n\n    printf(\"Reading an image...\");\n    pic::Image img;\n    img.Read(img_str);\n\n    printf(\"Ok\\n\");\n\n    if(img.isValid()) {\n        int nSamples = 0;\n\n        pic::Image *img_lab_ori = pic::FilterColorConv::fromRGBtoCIELAB(&img, NULL);\n\n        pic::Image * out = pic::FilterBilateral2DF::execute(&img, NULL, 4.0f, 0.05f);\n        pic::Image *img_lab = pic::FilterColorConv::fromRGBtoCIELAB(out, NULL);\n        float *samples = img_lab->getColorSamples(NULL, nSamples, 0.125f);\n\n        std::vector< std::set<pic::uint> *> labels;\n        int channels = img.channels;\n        pic::uint k = 8;\n\n        float *centers = pic::KMeansPlusPlus<float>::execute(samples, nSamples, channels, NULL, k, labels, 100);\n\n        printf(\"The number of k is: %d\\n\", k);\n\n        if(centers != NULL) {\n            printf(\"The number of k is: %d\\n\", k);\n\n            int n = img.size();\n\n            for(int i = 0; i < n; i+= channels) {\n                float *data_i = &img_lab_ori->data[i];\n                float *data_c = NULL;\n                float dist = FLT_MAX;\n\n                for(pic::uint j = 0; j < k; j++) {\n                    float *data_j = &centers[j * channels];\n                    float tmp_dist = pic::Arrayf::distanceSq(data_i, data_j, channels);\n\n                    if(tmp_dist < dist) {\n                        dist = tmp_dist;\n                        data_c = data_j;\n                    }\n                }\n\n                pic::Arrayf::assign(data_c, channels, data_i);\n            }\n\n            pic::FilterColorConv::fromCIELABtoRGB(img_lab_ori, &img);\n\n\n            bool bWrite = img.Write(\"../data/output/s_kmeans_colors.png\");\n            if(bWrite) {\n                printf(\"s_kmeans_colors.png was written with success!\\n\");\n            }\n        }\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/segmentation_k_means_colors/s_kmeans_colors.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = s_kmeans_colors\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/segmentation_live_wire/s_livewire.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = s_livewire\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/segmentation_otsu/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/features/checker_board_photo_2.png\";\n    }\n\n    printf(\"Reading images...\");\n    pic::Image img(img_str, pic::LT_NOR_GAMMA);\n    printf(\"Is the image valid? \");\n\n    if(img.isValid()) {\n        pic::Image *imgOut = pic::FilterThreshold::Otsu(&img, NULL);\n\n        std::string name = pic::getFileNameOnly(img_str);\n        imgOut->Write(\"../data/output/\" + name + \"_otsu.png\", pic::LT_NOR_GAMMA);\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/segmentation_otsu/s_otsu.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = s_livewire\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/segmentation_super_pixels/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    std::string img_str;\n    if(argc == 2) {\n        img_str = argv[1];\n    } else {\n        img_str = \"../data/input/tommaseo_statue.png\";\n    }\n\n    pic::Image img;\n    img.Read(img_str);\n\n    if(img.isValid()) {\n        pic::Slic slic(&img, 128);\n        pic::Image *output = slic.getMeanImage(NULL);\n\n        output->Write(\"../data/output/s_slic.png\");\n\n    } else {\n        printf(\"No, the file is not valid!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/segmentation_super_pixels/s_super_pixels.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = s_super_pixels\n\nQT       += core\nTEMPLATE = app\nCONFIG   += c++11\nCONFIG   += console\nCONFIG   -= app_bundle\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "examples/util_polynomials/main.cpp",
    "content": "/*\n\nPICCANTE Examples\nThe hottest examples of Piccante:\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3.0 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    See the GNU Lesser General Public License\n    ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n*/\n\n//This means that OpenGL acceleration layer is disabled\n#define PIC_DISABLE_OPENGL\n\n#include \"piccante.hpp\"\n\nint main(int argc, char *argv[])\n{\n    //check fit\n    printf(\"Polynomial fit test:\\n\");\n    std::vector<float> x, y;\n\n    for(int i = 0; i < 10; i++) {\n        float p_x = float(i);\n        float p_y = 3.0f * p_x * p_x + 2.0f * p_x + 1.0f;\n        x.push_back(p_x);\n        y.push_back(p_y);\n    }\n\n    pic::Polynomial poly;\n    poly.fit(x, y, 2);\n\n    poly.print();\n\n    printf(\"p(4.0f) = %f\\n\", poly.eval(4.0f));\n\n    float roots[2];\n    bool bReal = poly.getAllRoots(roots);\n\n    if(bReal) {\n        printf(\"Roots: %f %f\\n\", roots[0], roots[1]);\n    } else {\n        printf(\"No Real roots!\\n\");\n    }\n\n    printf(\"\\n\\n\");\n\n    printf(\"Second order polynomial test:\\n\");\n    float tmp[] = {1.0f, -3.0f, 0.5f};\n    pic::Polynomial poly2(tmp, 3);\n    poly2.print();\n\n    printf(\"p(0.0f) = %f\\n\", poly2.eval(0.0f));\n    printf(\"dp(1.0f) = %f\\n\", poly2.dEval(1.0f));\n\n    bReal = poly2.getRoots(roots);\n\n    if(bReal) {\n        printf(\"Roots: %f %f\\n\", roots[0], roots[1]);\n    } else {\n        printf(\"No Real roots!\\n\");\n    }\n\n    printf(\"\\n\\n\");\n\n    printf(\"Third order polynomial test:\\n\");\n    float tmp3[] = {-6.0f, 11.0f, -6.0f, 1.0f};\n    pic::Polynomial poly3(tmp3, 4);\n    poly3.print();\n\n    float r;\n    auto poly3_2 = poly3.horner(3.0f, r);    \n    printf(\"H: %s R: %f\\n\", poly3_2.toString().c_str(), r);;\n\n    printf(\"p(1.0f) = %f\\n\", poly3.eval(1.0f));\n    printf(\"dp(1.0f) = %f\\n\", poly3.dEval(1.0f));\n\n    float roots3[3];\n    bReal = poly3.getAllRoots(roots3);\n\n    if(bReal) {\n        printf(\"Roots: %f %f %f\\n\", roots3[0], roots3[1], roots3[2]);\n    } else {\n        printf(\"No Real roots!\\n\");\n    }\n\n    printf(\"\\n\\n\");\n\n    printf(\"Foruth order polynomial test:\\n\");\n    float tmp4[] = {24, -50.0f, 35.0f, -10.0f, 1.0f};\n    pic::Polynomial poly4(tmp4, 5);\n    poly4.print();\n\n    auto poly4_2 = poly4.horner(3.0f, r);\n    printf(\"H: %s R: %f\\n\", poly4_2.toString().c_str(), r);;\n\n    printf(\"p(1.0f) = %f\\n\", poly4.eval(1.0f));\n    printf(\"dp(1.0f) = %f\\n\", poly4.dEval(1.0f));\n\n    float roots4[4];\n    bReal = poly4.getAllRoots(roots4);\n\n    if(bReal) {\n        printf(\"Roots: %f %f %f %f\\n\", roots4[0], roots4[1], roots4[2], roots4[3]);\n    } else {\n        printf(\"No Real roots!\\n\");\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "examples/util_polynomials/u_polynomials.pro",
    "content": "# PICCANTE\n# The hottest HDR imaging library!\n# http://vcg.isti.cnr.it/piccante\n# \n# Copyright (C) 2014\n# Visual Computing Laboratory - ISTI CNR\n# http://vcg.isti.cnr.it\n# First author: Francesco Banterle\n# \n# PICCANTE is free software; you can redistribute it and/or modify\n# under the terms of the GNU Lesser General Public License as\n# published by the Free Software Foundation; either version 3.0 of\n# the License, or (at your option) any later version.\n# \n# PICCANTE is distributed in the hope that it will be useful, but\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the GNU Lesser General Public License\n# ( http://www.gnu.org/licenses/lgpl-3.0.html ) for more details.\n\nTARGET = u_polynomials\n\nQT       += core\nTEMPLATE = app\nCONFIG   += console\nCONFIG   -= app_bundle\nCONFIG   += C++11\nQMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7\n\nINCLUDEPATH += ../../include\n\nSOURCES += main.cpp\n\nwin32-msvc*{\n    DEFINES += _CRT_SECURE_NO_DEPRECATE\n}\n\nwin32{\n\tDEFINES += NOMINMAX\n}\n\nlinux-g++*{\n    QMAKE_CXXFLAGS += -fopenmp -pthread\n    QMAKE_LFLAGS += -fopenmp\n}\n"
  },
  {
    "path": "how_to_install.txt",
    "content": "How to install Piccante:\n========================\n\nBefore starting:\n================\nPiccante is a header based library, which means that\nyou do not need to compile it, and there are no\nplatform dependencies. \n\nInstructions:\n=============\n1) Unzip the file .zip in your favorite location on \nyour machine drive;\n\n2) Using your favorite IDE, please add the “piccante/include”\ndirectory in the INCLUDE path of the project where you want\nto use Piccante;\n\n3) Include \"piccante.hpp\" in your project in the source file\nwhere you need it."
  },
  {
    "path": "include/JNI/find_checker_board.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_JNI_FIND_CHECKER_BOARD_HPP\n#define PIC_JNI_FIND_CHECKER_BOARD_HPP\n\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_downsampler_2d.hpp\"\n#include \"../filtering/filter_white_balance.hpp\"\n\n#include \"../computer_vision/iterative_closest_point_2D.hpp\"\n#include \"../computer_vision/nelder_mead_opt_ICP_2D.hpp\"\n\n#include \"../features_matching/orb_descriptor.hpp\"\n\n#include \"../computer_vision/find_checker_board.hpp\"\n\n#include \"../algorithms/binarization.hpp\"\n#include \"../util/mask.hpp\"\n#include \"../features_matching/canny_edge_detector.hpp\"\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief extractCheckerBoardJNI\n * @param imageInPath is the path for the input image\n * @param imageOutPath is the path for the output image\n * @return\n */\nPIC_INLINE std::vector<int> extractCheckerBoardJNI(std::string imageInPath, std::string imageOutPath)\n{\n    Image in;\n    bool bRead = in.Read(imageInPath, LT_NOR_GAMMA);\n\n    std::vector<int> ret;\n    ret.clear();\n\n    Image *work;\n\n    if(bRead) {\n\n        bool bScale = false;\n        float scale = 1.0f;\n\n        if(in.nPixels() > 1000000) {\n\n            int maxLength = MAX(in.width, in.height);\n\n            scale = 1000.0f / float(maxLength);\n\n#ifdef PIC_DEBUG\n            printf(\"Down scale factor: %f\\n\", scale);\n#endif\n\n            work = FilterDownSampler2D::execute(&in, NULL, scale);\n\n            bScale = true;\n        } else {\n            work = &in;\n        }\n\n        std::vector< Eigen::Vector2f > corners;\n        pic::findCheckerBoard(work, corners);\n\n        //\n        //scale\n        //\n        Eigen::Vector2f p0, p1;\n\n#ifdef PIC_DEBUG\n        float pixel_length = pic::estimateLengthOfCheckers(corners, p0, p1);\n        printf(\"Pixel length: %f\\n\", pixel_length);\n#endif\n\n        ret.push_back(int(p0[0] / scale));\n        ret.push_back(int(p0[1] / scale));\n        ret.push_back(int(p1[0] / scale));\n        ret.push_back(int(p1[1] / scale));\n\n        //\n        //white balance\n        //\n        Eigen::Vector2f pw = pic::estimateCoordinatesWhitePointFromCheckerBoard(work, corners, 4, 6);\n\n        ret.push_back(int(pw[0] / scale));\n        ret.push_back(int(pw[1] / scale));\n\n        Image* img_wb;\n        if(bScale) {\n            int patchSize = 5;\n            BBox patch(int(pw[0]) - patchSize, \n                       int(pw[0]) + patchSize,\n                       int(pw[1]) - patchSize,\n                       int(pw[1]) + patchSize);\n            float *white_color = work->getMeanVal(&patch, NULL);\n            img_wb = FilterWhiteBalance::execute(&in, white_color, NULL);\n        } else {\n            img_wb = FilterWhiteBalance::execute(&in, int(pw[0]), int(pw[1]), true, NULL);\n        }\n\n        if(img_wb != NULL) {\n            bool bWrite = img_wb->Write(imageOutPath.c_str(), LT_NOR_GAMMA, 0);\n\n            if(!bWrite) {\n                printf(\"extractCheckerBoardJNI: the image could not be written.\\n\");\n            }\n\n            delete img_wb;\n        }\n    }\n\n    return ret;\n}\n\n#endif\n\n} // end namespace pic\n\n#endif // PIC_JNI_FIND_CHECKER_BOARD_HPP\n"
  },
  {
    "path": "include/JNI/live_wire.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_JNI_LIVE_WIRE_HPP\n#define PIC_JNI_LIVE_WIRE_HPP\n\n#include <functional>\n#include <vector>\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gradient.hpp\"\n#include \"../filtering/filter_log_2d_opt.hpp\"\n#include \"../filtering/filter_channel.hpp\"\n#include \"../filtering/filter_sampler_2d.hpp\"\n#include \"../util/vec.hpp\"\n#include \"../util/polyline.hpp\"\n\n#include \"../algorithms/live_wire.hpp\"\n\nnamespace pic {\n\n/**\n * @brief executeLiveWireMultipleJNI\n * @param imageInPath\n * @param controPoints\n * @param bDownsample\n * @return\n */\nPIC_INLINE std::vector< int > executeLiveWireMultipleJNI(std::string imageInPath, std::vector< int > controlPoints, bool bDownsample)\n{\n    std::vector< int > out;\n\n    Image in;\n    bool bRead = in.Read(imageInPath, LT_NOR_GAMMA);\n\n    if(bRead) {\n        LiveWire *lw ;\n        Image *in_sub = NULL;\n\n        if(bDownsample) {\n            ImageSamplerBilinear isb;\n            in_sub = FilterSampler2D::execute(&in, NULL, 0.25f, &isb);\n            lw = new LiveWire(in_sub);\n        } else {\n            lw = new LiveWire(&in);\n        }\n\n        std::vector< Vec2i > out_tmp;\n\n        int n = int(controlPoints.size()) >> 1;\n        for(auto i = 0; i < (n - 1); i++) {\n            int indexS = i << 1;\n            int indexE = (i + 1) << 1;\n            Vec2i pS(controlPoints[indexS], controlPoints[indexS + 1]);\n            Vec2i pE(controlPoints[indexE], controlPoints[indexE + 1]);\n\n            if(bDownsample) {\n                pS[0] = pS[0] >> 2;\n                pS[1] = pS[1] >> 2;\n\n                pE[0] = pE[0] >> 2;\n                pE[1] = pE[1] >> 2;\n            }\n\n            lw->execute(pS, pE, out_tmp, true, true);\n        }\n\n\n        Polyline2i pl(out_tmp);\n        pl.simplify(32);\n\n        for(uint i = 0; i < pl.points.size(); i++) {\n            auto point = pl.points.at(i);\n\n            if(bDownsample) {\n                point[0] = point[0] << 2;\n                point[1] = point[1] << 2;\n            }\n\n            out.push_back(point[0]);\n            out.push_back(point[1]);\n        }\n\n        delete lw;\n    }\n\n    return out;\n}\n\n} // end namespace pic\n\n#endif /* PIC_JNI_LIVE_WIRE_HPP */\n\n"
  },
  {
    "path": "include/JNI/white_balance.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_JNI_WHITE_BALANCE_HPP\n#define PIC_JNI_WHITE_BALANCE_HPP\n\n#include \"../base.hpp\"\n\n#include \"../filtering/filter_white_balance.hpp\"\n\nnamespace pic {\n\n/**\n * @brief applyWhiteBalanceJNI\n * @param imageInPath\n * @param imageOutPath\n * @param x\n * @param y\n * @param bRobust\n * @return\n */\nPIC_INLINE int applyWhiteBalanceJNI(std::string imageInPath, std::string imageOutPath, int x, int y, bool bRobust = false)\n{\n    if(x < 0 || y < 0) {\n        return 0;\n    }\n\n    Image in;\n    bool bRead = in.Read(imageInPath, LT_NOR_GAMMA);\n\n    if(bRead) {\n        Image *out = FilterWhiteBalance::execute(&in, x, y, bRobust);\n\n        bool bWrite = out->Write(imageOutPath.c_str(), LT_NOR_GAMMA, 0);\n\n        if(!bWrite) {\n            printf(\"applyWhiteBalanceJNI: the image could not be written.\\n\");\n        }\n\n        delete out;\n\n        return bWrite ? 1 : 0;\n    } else {\n        printf(\"applyWhiteBalanceJNI: the image could not be read.\\n\");\n        return 0;\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_JNI_WHITE_BALANCE_HPP */\n\n"
  },
  {
    "path": "include/JNI.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_JNI_HPP\n#define PIC_JNI_HPP\n\n#include \"JNI/white_balance.hpp\"\n#include \"JNI/live_wire.hpp\"\n#include \"JNI/find_checker_board.hpp\"\n\n#endif /* PIC_JNI_HPP */\n\n"
  },
  {
    "path": "include/algorithms/bilateral_separation.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_BILATERAL_SEPARATION_HPP\n#define PIC_ALGORITHMS_BILATERAL_SEPARATION_HPP\n\n#include \"../image.hpp\"\n#include \"../filtering/filter_bilateral_2ds.hpp\"\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/**\n * @brief bilateralSeparation\n * @param imgIn\n * @param out\n * @param sigma_s\n * @param sigma_r\n * @param bLogDomain\n */\nPIC_INLINE void bilateralSeparation(Image *imgIn, ImageVec &out,\n                                         float sigma_s = -1.0f,\n                                         float sigma_r = 0.4f,\n                                         bool bLogDomain = false)\n{\n    if(imgIn == NULL) {\n        return;\n    }\n\n    if(!imgIn->isValid()) {\n        return;\n    }\n\n    if(out.size() < 2) {\n        out.push_back(NULL);\n        out.push_back(NULL);\n    }\n\n    if(sigma_s <= 0.0f) {\n        sigma_s = MAX(imgIn->widthf, imgIn->heightf) * 0.02f;\n    }\n\n    if(sigma_r <= 0.0f) {\n        sigma_r = 0.4f;\n    }\n\n    Image *img_tmp = imgIn->clone();\n\n    img_tmp->applyFunction(log10fPlusEpsilon);\n\n    Image *img_flt = FilterBilateral2DS::execute(img_tmp, NULL, sigma_s, sigma_r);\n\n    if(!bLogDomain) {\n        img_flt->applyFunction(powf10fMinusEpsilon);\n    }\n\n    Image *img_detail = img_tmp;\n\n    if(bLogDomain) {\n        *img_detail -= *img_flt;\n    } else {\n        *img_detail = imgIn;\n        *img_detail /= *img_flt;\n        img_detail->removeSpecials();\n    }\n\n    out[0] = img_flt;\n    out[1] = img_detail;\n}\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_BILATERAL_SEPARATION_HPP */\n\n"
  },
  {
    "path": "include/algorithms/binarization.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_BINARIZATION_HPP\n#define PIC_ALGORITHMS_BINARIZATION_HPP\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n#include \"../filtering/filter_threshold.hpp\"\n\nnamespace pic {\n\n/**\n * @brief binarization\n * @param imgIn\n * @param bAdaptive\n * @return\n */\nPIC_INLINE Image *binarization(Image *imgIn, Image *imgOut = NULL, bool bAdaptive = false)\n{\n    if(imgIn == NULL) {\n        return NULL;\n    }\n\n    Image *imgIn_lum = FilterLuminance::execute(imgIn, NULL);\n\n    if(bAdaptive) {\n        FilterThreshold flt_thr(0.0f, true);\n\n        FilterGaussian2D flt_gauss(MIN(imgIn->widthf, imgIn->heightf) * 0.2f);\n        Image *imgIn_lum_flt = flt_gauss.Process(Single(imgIn_lum), NULL);\n\n        imgOut = flt_thr.Process(Double(imgIn_lum, imgIn_lum_flt), imgOut);\n\n        delete imgIn_lum_flt;\n    } else {\n        float mean_lum;\n\n        imgIn_lum->getMeanVal(NULL, &mean_lum);\n\n        FilterThreshold flt_thr(mean_lum, false);\n\n        imgOut = flt_thr.Process(Single(imgIn_lum), imgOut);\n    }\n\n    return imgOut;\n}\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_BINARIZATION_HPP */\n\n"
  },
  {
    "path": "include/algorithms/camera_response_function.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014-2016\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_CAMERA_RESPONSE_FUNCTION_HPP\n#define PIC_ALGORITHMS_CAMERA_RESPONSE_FUNCTION_HPP\n\n#include <algorithm>\n\n#include \"../image.hpp\"\n#include \"../point_samplers/sampler_random.hpp\"\n#include \"../histogram.hpp\"\n#include \"../filtering/filter_mean.hpp\"\n#include \"../util/polynomial.hpp\"\n#include \"../util/std_util.hpp\"\n\n#include \"../algorithms/sub_sample_stack.hpp\"\n#include \"../algorithms/weight_function.hpp\"\n#include \"../algorithms/mitsunaga_nayar_crf.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n    #ifndef PIC_EIGEN_NOT_BUNDLED\n        #include \"../externals/Eigen/SVD\"\n    #else\n        #include <Eigen/SVD>\n    #endif\n#endif\n\nnamespace pic {\n\nenum IMG_LIN {IL_LIN, IL_2_2, IL_LUT_8_BIT, IL_POLYNOMIAL};\n\n/**\n * @brief The CameraResponseFunction class\n */\nclass CameraResponseFunction\n{\nprotected:\n\n    /**\n    * \\brief gsolve computes the inverse CRF of a camera.\n    */\n    float *gsolve(int *samples, std::vector< float > &log_exposure, float lambda, int nSamples)\n    {\n        #ifndef PIC_DISABLE_EIGEN\n\n        int nExposure = int(log_exposure.size());\n\n        int n = 256;\n        int rows = nSamples * nExposure + n + 1;\n        int cols = n + nSamples;\n\n        #ifdef PIC_DEBUG\n            printf(\"Matrix size: (%d, %d)\\n\", rows, cols);\n        #endif\n\n        Eigen::MatrixXf A = Eigen::MatrixXf::Zero(rows, cols);\n        Eigen::VectorXf b = Eigen::VectorXf::Zero(rows);\n\n        int k = 0;\n\n        for(int i = 0; i < nSamples; i++) {\n            for(int j = 0; j < nExposure; j++) {\n                int tmp = samples[i * nExposure + j];\n\n                float w_ij = w[tmp];\n\n                A.coeffRef(k, tmp) =  w_ij;\n                A.coeffRef(k, n + i) = -w_ij;\n                \n                b[k] =  w_ij * log_exposure[j];\n\n                k++;\n            }\n        }\n\n        A.coeffRef(k, 128) = 1.0f;\n        k++;\n\n        //smoothness term\n        for(int i = 0; i < (n - 2); i++) {\n            float w_l = lambda * w[i + 1];\n            A.coeffRef(k, i)     =         w_l;\n            A.coeffRef(k, i + 1) = -2.0f * w_l;\n            A.coeffRef(k, i + 2) =         w_l;\n            k++;\n        }\n\n        //solve the linear system\n        Eigen::JacobiSVD< Eigen::MatrixXf > svd(A, Eigen::ComputeThinU | Eigen::ComputeThinV);\n\n        Eigen::VectorXf x = svd.solve(b);\n\n        float *ret = new float[n];\n\n        for(int i = 0; i < n; i++) {\n            ret[i] = expf(x[i]);\n        }\n\n        #else\n            float *ret = NULL;\n        #endif\n\n        return ret;\n    }\n\n    /**\n     * @brief release frees memory.\n     */\n    void release()\n    {\n        stackOut.release();\n\n        stdVectorClear(icrf);\n        stdVectorClear(crf);\n\n        icrf.clear();\n        crf.clear();\n        poly.clear();\n    }\n\n    /**\n     * @brief createTabledICRF\n     */\n    void createTabledICRF()\n    {\n        if(type_linearization != IL_POLYNOMIAL) {\n            return;\n        }\n\n        for(unsigned int i = 0; i < icrf.size(); i++) {\n            if(icrf[i] != NULL) {\n                delete[] icrf[i];\n            }\n        }\n\n        icrf.clear();\n\n        for(unsigned int i = 0; i < poly.size(); i++) {\n            float *tmp = new float[256];\n\n            for(int j = 0; j < 256; j++) {\n                float x = float(j) / 255.0f;\n\n                tmp[j] = poly[i].eval(x);\n            }\n\n            crf.push_back(tmp);\n        }\n    }\n\n    SubSampleStack stackOut;\n    IMG_LIN type_linearization;\n    float w[256];\n\npublic:\n\n    std::vector<float *> icrf;\n    std::vector<float *> crf;\n\n    std::vector< Polynomial > poly;\n    \n    /**\n     * @brief CameraResponseFunction\n     */\n    CameraResponseFunction()\n    {\n        type_linearization = IL_LIN;\n    }\n\n    ~CameraResponseFunction()\n    {\n        release();\n    }\n\n    /**\n     * @brief remove linearizes a camera value using the inverse CRF.\n     * @param x is an intensity value in [0,1].\n     * @param channel\n     * @return It returns x in the linear domain.\n     */\n    inline float remove(float x, int channel)\n    {\n        switch(type_linearization) {\n            case IL_LIN: {\n                return x;\n            }\n            break;\n\n            case IL_LUT_8_BIT: {\n                int index =  CLAMP(int(round(x * 255.0f)), 256);\n                return icrf.at(channel)[index];\n            }\n            break;\n\n            case IL_2_2: {\n                return powf(x, 2.2f);\n            }\n            break;\n\n            case IL_POLYNOMIAL: {\n                return poly[channel].eval(x);\n            }\n            break;\n\n            default:\n                break;\n        }\n\n        return x;\n    }\n\n    /**\n     * @brief apply\n     * @param x a value in [0, 1]\n     * @param channel\n     * @return\n     */\n    inline float apply(float x, int channel)\n    {\n        switch(type_linearization) {\n            case IL_LIN: {\n                return x;\n            }\n            break;\n\n            case IL_LUT_8_BIT: {\n                float *ptr = std::lower_bound(&icrf[channel][0], &icrf[channel][255], x);\n                int offset = CLAMPi((int)(ptr - icrf[channel]), 0, 255);\n\n                return float(offset) / 255.0f;\n            }\n            break;\n\n            case IL_2_2: {\n               #ifdef PIC_WIN32\n                  float inv_gamma = 1.0f / 2.2f;\n               #else\n                  constexpr float inv_gamma = 1.0f / 2.2f;\n               #endif\n\n               return powf(x, inv_gamma);\n            }\n            break;\n\n            case IL_POLYNOMIAL: {\n                float *ptr = std::lower_bound(&icrf[channel][0], &icrf[channel][255], x);\n                int offset = CLAMPi((int)(ptr - icrf[channel]), 0, 255);\n\n                return float(offset) / 255.0f;\n            }\n            break;\n\n            default:\n                break;\n        }\n\n        return x;\n    }\n\n    /**\n     * @brief setCRFtoGamma2_2\n     */\n    void setCRFtoGamma2_2()\n    {\n        type_linearization = IL_2_2;\n    }\n\n    /**\n     * @brief setCRFtoLinear\n     */\n    void setCRFtoLinear()\n    {\n        type_linearization = IL_LIN;\n    }\n\n    /**\n     * @brief FromRAWJPEG computes the CRF by exploiting the couple RAW/JPEG from cameras.\n     * @param img_raw is a RAW image.\n     * @param img_jpg is a JPEG compressed image.\n     * @param filteringSize\n     */\n    void fromRAWJPEG(Image *img_raw, Image *img_jpg, int filteringSize = 11)\n    {\n        if((img_raw == NULL) || (img_jpg == NULL))\n            return;\n\n        if(!img_raw->isSimilarType(img_jpg))\n            return;\n        \n        icrf.clear();\n\n        int width    = img_raw->width;\n        int height   = img_raw->height;\n        int channels = img_raw->channels;\n\n        int crf_size = 256 * 256 * channels;\n        unsigned int *crf = new unsigned int[crf_size];\n\n        for(int i=0;i<crf_size;i++) {\n            crf[i] = 0;\n        }\n               \n        for(int i=0; i<height; i++) {\n            for(int j=0; j<width; j++) {\n\n                float *data_raw = (*img_raw)(j, i);\n                float *data_jpg = (*img_jpg)(j, i);               \n\n                for(int k=0;k<channels;k++) {\n                    int i_raw = CLAMPi(int(255.0f * data_raw[k]), 0, 255);\n                    int i_jpg = CLAMPi(int(255.0f * data_jpg[k]), 0, 255);\n\n                    int addr = (i_raw * 256 + i_jpg ) * channels;\n\n                    crf[addr + k ]++;\n                }\n            }\n        }\n       \n        //compute the result\n        std::vector< int > coords;\n\n        for(int k=0;k<channels;k++) {\n\n            float *ret_c = new float[256];\n\n            for(int j=0;j<256;j++) {\n                coords.clear();\n\n                for(int i=0;i<256;i++) {\n\n                    int addr = (i * 256 + j ) * channels + k;\n\n                    if(crf[addr] > 0) {\n                        coords.push_back(i);                        \n                    }\n\n                }\n\n                if(!coords.empty()) {//get the median value\n                    std::sort (coords.begin(), coords.end());  \n                    ret_c[j] = float(coords[coords.size() >> 1]) / 255.0f;\n                }\n            }\n            \n            if(filteringSize > 0) {\n                Image toBeFiltered(1, 256, 1, 1, ret_c);\n\n                Image *filtered = FilterMean::execute(&toBeFiltered, NULL, filteringSize);\n                \n                icrf.push_back(filtered->data);\n\n            } else {\n                icrf.push_back(ret_c);\n            }\n        }\n    }\n\n    /**\n     * @brief DebevecMalik computes the CRF of a camera using multiple exposures value following Debevec and Malik\n    1997's method.\n     * @param stack\n     * @param exposure\n     * @param type\n     * @param nSamples\n     * @param lambda\n     */\n    void DebevecMalik(ImageVec stack, CRF_WEIGHT type = CW_DEB97, int nSamples = 256, float lambda = 20.0f)\n    {\n        release();\n\n        if(!ImageVecCheckSimilarType(stack)) {\n            return;\n        }\n\n        if(nSamples < 1) {\n            nSamples = 256;\n        }\n\n        this->type_linearization = IL_LUT_8_BIT;\n\n        //subsample the image stack\n        stackOut.execute(stack, nSamples);\n\n        int *samples = stackOut.get();\n        nSamples = stackOut.getNSamples();\n        \n        //compute CRF using Debevec and Malik\n        int channels = stack[0]->channels;\n\n        //pre-compute the weight function\n        for(int i = 0; i < 256; i++) {\n            w[i] = weightFunction(float(i) / 255.0f, type);\n        }\n\n        int nExposure = int(stack.size());\n\n        //log domain exposure time        \n        std::vector< float > log_exposures;\n        ImageVecGetExposureTimesAsArray(stack, log_exposures, true);\n\n        #ifdef PIC_DEBUG\n            printf(\"nSamples: %d\\n\", nSamples);\n        #endif\n\n        int stride = nSamples * nExposure;\n        for(int i = 0; i < channels; i++) {\n            float *icrf_channel = gsolve(&samples[i * stride], log_exposures, lambda, nSamples);\n\n            icrf.push_back(icrf_channel);\n        }\n    }\n\n    /**\n     * @brief MitsunagaNayar computes the inverse CRF of a camera as a polynomial function.\n     * @param stack             Array of images with associated exposure. Note that this array will be sorted with increasing exposure.\n     * @param polynomial_degree Degree of the polynomial. If negative, the best degree will be selected in [1, -polynomial_degree] for each channel.\n     * @param nSamples          Number of samples to extract from each image.\n     * @param full              true for computing all exposure ratios (as in book \"High Dynamic Range Imaging\", second edition, Reinhard et al.),\n     *                          false as in the original paper (only among successive exposures).\n     * @param alpha             Threshold for removing samples with values not in [alpha, 1-alpha].\n     * @param computeRatios     false if exact exposures are passed, true to approximate exposure ratios as in the paper.\n     * @param eps               Threshold on the difference among successive approximations for stopping the computation.\n     * @param max_iterations    Stop the computation after this number of iterations.\n     * @return true if successfully computed, false otherwise.\n     */\n    bool MitsunagaNayar(ImageVec &stack, int polynomial_degree = -3, int nSamples = 256, const bool full = false,\n                        const float alpha = 0.04f, const bool computeRatios = false, const float eps = 0.0001f,\n                        const std::size_t max_iterations = 100)\n    {\n        release();\n\n        if(!ImageVecCheckSimilarType(stack)) {\n            return false;\n        }\n\n        if(nSamples < 1) {\n            nSamples = 256;\n        }\n\n        type_linearization = IL_POLYNOMIAL;\n\n        //sort the array by exposure\n        ImageVecSortByExposureTime(stack);\n\n        //subsample the image stack\n        stackOut.execute(stack, nSamples, alpha);\n        int *samples = stackOut.get();\n        nSamples = stackOut.getNSamples();\n\n        if (nSamples < 1) {\n            return false;\n        }\n\n        //compute the CRF using Mitsunaga and Nayar\n        int channels = stack[0]->channels;\n\n        std::size_t nExposures = stack.size();\n\n        std::vector< float > exposures;\n        ImageVecGetExposureTimesAsArray(stack, exposures, false);\n\n        int stride = nSamples * int(nExposures);\n\n        float error = std::numeric_limits<float>::infinity();\n        std::vector<float> R(nExposures - 1);\n        std::vector<std::vector<float>> RR(nExposures - 1, std::vector<float>(nExposures - 1));\n\n        poly.resize(channels);\n\n        if (polynomial_degree > 0) {\n            error = 0.f;\n            for (int i = 0; i < channels; ++i) {\n                poly[i].coeff.assign(polynomial_degree + 1, 0.f);\n                if (full) {\n                    error += MitsunagaNayarFull(&samples[i * stride], nSamples, exposures, poly[i].coeff, computeRatios, RR, eps, max_iterations);\n                } else {\n                    error += MitsunagaNayarClassic(&samples[i * stride], nSamples, exposures, poly[i].coeff, computeRatios, R, eps, max_iterations);\n                }\n            }\n        } else if (polynomial_degree < 0) {\n            error = std::numeric_limits<float>::infinity();\n            std::vector<Polynomial> tmpCoefficients(channels);\n            for (int degree = 1; degree <= -polynomial_degree; ++degree) {\n                float tmpError = 0.f;\n                for (int i = 0; i < channels; ++i) {\n                    tmpCoefficients[i].coeff.resize(degree + 1);\n                    if (full) {\n                        tmpError += MitsunagaNayarFull(&samples[i * stride], nSamples, exposures, tmpCoefficients[i].coeff, computeRatios, RR, eps, max_iterations);\n                    } else {\n                        tmpError += MitsunagaNayarClassic(&samples[i * stride], nSamples, exposures, tmpCoefficients[i].coeff, computeRatios, R, eps, max_iterations);\n                    }\n                }\n\n                if (tmpError < error) {\n                    error = tmpError;\n                    poly = std::move(tmpCoefficients);\n                    tmpCoefficients.resize(channels);\n                }\n            }\n        }\n\n        bool bOk = error < std::numeric_limits<float>::infinity();\n\n        if(bOk) {\n            createTabledICRF();\n        }\n\n        return bOk;\n    }\n\n    /**\n     * @brief Robertson computes the CRF of a camera using all multiple exposures value Robertson et al\n       1999's method (Dynamic range improvement through multiple exposures).\n     * @param stack\n     * @param maxIterations\n     */\n    void Robertson(ImageVec &stack, const size_t maxIterations = 50)\n    {\n        release();\n\n        if(!ImageVecCheckSimilarType(stack)) {\n            return;\n        }\n\n        this->type_linearization = IL_LUT_8_BIT;\n\n        const int channels   = stack[0]->channels;\n        const int pixelcount = stack[0]->nPixels();\n\n        // precompute robertson weighting function\n        for (size_t i=0; i<256; i++) {\n            this->w[i] = weightFunction(float(i) / 255.0f, CW_ROBERTSON);\n        }\n\n        // avoid saturation\n        int minM = 0;\n        int maxM = 255;\n        for (int m = 0; m < 256; m++) {\n            if (this->w[m] > 0) {\n                minM = m;\n                break;\n            }\n        }\n\n        for (int m=255; m>=0; m--) {\n            if (this->w[m] > 0) {\n                maxM = m;\n                break;\n            }\n        }\n\n        // avoid ghosting (for each exposure get the index for the immediately higher and lower exposure)\n        int *lower = new int [stack.size()];\n        int *higher = new int[stack.size()];\n\n        for (size_t i=0; i<stack.size(); i++) {\n            lower[i]  = -1;\n            higher[i] = -1;\n            float t = stack[i]->exposure;\n            float tHigh = stack[0]->exposure;\n            float tLow  = tHigh;\n\n            for (size_t j=0; j<stack.size(); j++) {\n                if (i != j) {\n                    float tj = stack[j]->exposure;\n\n                    if (tj > t && tj < tHigh) {\n                        tHigh = tj;\n                        higher[i] = int(j);\n                    }\n                    if (tj < t && tj > tLow) {\n                        tLow = tj;\n                        lower[i] = int(j);\n                    }\n                }\n            }\n\n            if (lower[i]  == -1) {\n                lower[i]  = int(i);\n            }\n\n            if (higher[i] == -1) {\n                higher[i] = int(i);\n            }\n        }\n\n        // create initial inv response function\n        {\n            float * lin = new float[256];\n            for (int i=0; i<256; i++) {\n                lin[i] = float(2.0 * i / 255.0);\n            }\n            this->icrf.push_back(lin);\n\n            for (int i=1; i<channels; i++) {\n                float * col = new float[256];\n                Buffer<float>::assign(col, lin, 256);\n                this->icrf.push_back(col);\n            }\n        }\n\n        // create quantized stack\n        std::vector<unsigned char *> qstack;\n        for (Image * slice : stack) {\n            assert(slice->frames == 1);\n            unsigned char * q = convertHDR2LDR(slice->data, NULL, slice->size(), LT_NOR);\n            qstack.push_back(q);\n        }\n\n        // iterative gauss-seidel\n        for (int ch=0; ch<channels; ch++) {\n            float * fun = this->icrf[ch];\n            float funPrev[256];\n            Buffer<float>::assign(funPrev, fun, 256);\n\n            std::vector<float> x(pixelcount);\n\n            float prevDelta = 0.0f;\n            for (size_t iter=0; iter<maxIterations; iter++) {\n                // Normalize inv crf to midpoint\n                {\n                    // find min max\n                    size_t minIdx, maxIdx;\n                    for (minIdx = 0   ; minIdx < 255 && fun[minIdx]==0 ; minIdx++);\n                    for (maxIdx = 255 ; maxIdx > 0   && fun[maxIdx]==0 ; maxIdx--);\n\n                    size_t midIdx = minIdx+(maxIdx-minIdx)/2;\n                    float  mid = fun[midIdx];\n\n                    if (mid == 0.0f) {\n                        // find first non-zero middle response\n                        while (midIdx < maxIdx && fun[midIdx] == 0.0f) {\n                            midIdx++;\n                        }\n                        mid = fun[midIdx];\n                    }\n\n                    if (mid != 0.0f) {\n                        Buffer<float>::div(fun, 256, mid);\n                    }\n                }\n\n                // Update x\n                for (int i=0; i<pixelcount; i++) {\n                    float sum     = 0.0f;\n                    float divisor = 0.0f;\n\n                    float maxt = -1.0f;\n                    float mint = FLT_MAX;\n\n                    int ind = i * channels + ch;\n\n                    for (size_t s=0; s<qstack.size(); s++) {\n                        unsigned char * qslice = qstack[s];\n                        const float     t      = stack[s]->exposure;\n\n                        int m = qslice[ind];\n\n                        // compute max/min time for under/over exposed pixels\n                        if (m > maxM) {\n                            mint = std::min(mint, t);\n                        }\n\n                        if (m < minM) {\n                            maxt = std::max(maxt, t);\n                        }\n\n                        // to avoid ghosting\n                        int mLow  = qstack[lower [s]][ind];\n                        int mHigh = qstack[higher[s]][ind];\n                        if (mLow > m || mHigh < m) {\n                            continue;\n                        }\n\n                        const float wm = this->w[m];\n\n                        sum     += wm * t * fun[m];\n                        divisor += wm * t * t;\n                    }\n\n                    if (divisor == 0.0f) {\n                        // avoid saturation\n                        if (maxt > -1.0f) {\n                            x[i] = fun[minM] / maxt;\n                        }\n\n                        if (mint < FLT_MAX) {\n                            x[i] = fun[maxM] / mint;\n                        }\n                    } else if (divisor < 1e-4f) {\n                        x[i] = -1.0f;\n                    } else {\n                        x[i] = sum / divisor;\n                    }\n                }\n\n                // Update inv crf\n                {\n                    size_t cardEm[256] = { 0 };\n                    float  sum[256]    = { 0.0f };\n                    float minSatTime = FLT_MAX;\n                    for (size_t s=0; s<qstack.size(); s++) {\n                        unsigned char * qslice = qstack[s];\n                        const float     t      = stack[s]->exposure;\n\n                        for (int i=0; i<pixelcount; i++) {\n                            if (x[i] < 0.0f) {\n                                continue;\n                            }\n\n                            const int m = int(qslice[i*channels+ch]);\n\n                            if (m == 255) {\n                                if (t < minSatTime) {\n                                    minSatTime = t;\n                                    sum[m] = t * x[i];\n                                    cardEm[m] = 1;\n                                }\n                                else if (t == minSatTime)\n                                {\n                                    sum[m] = std::min(sum[m], t * x[i]);\n                                }\n                            } else {\n                                sum[m] += t * x[i];\n                                cardEm[m]++;\n                            }\n                        }\n                    }\n\n                    // compute average and fill undefined values with previous one\n                    float prev = 0.0f;\n                    for (int m=0; m<256; m++) {\n                        if (cardEm[m] != 0) {\n                            fun[m] = prev = sum[m] / cardEm[m];\n                        } else {\n                            fun[m] = prev;\n                        }\n                    }\n                }\n\n                // check residuals\n                {\n                    static const float MaxDelta = 1e-7f;\n\n                    float delta = 0.0f;\n                    int count   = 0;\n                    for (int m=0; m<256; m++) {\n                        if( fun[m] != 0.0f ) {\n                            float diff = fun[m] - funPrev[m];\n                            delta += diff * diff;\n                            funPrev[m] = fun[m];\n                            count++;\n                        }\n                    }\n                    delta /= count;\n\n                    if (delta < MaxDelta) {\n                        break;\n                    }\n\n                    prevDelta = delta;\n                }\n            }\n        }\n        // estimation complete!\n\n        // normalize response function keeping relative scale between colors\n        float maxV = -1.0f;\n        for (int ch=0; ch<channels; ch++) {\n            int ind;\n            maxV = std::max(Arrayf::getMax(this->icrf[ch], 256, ind), maxV);\n        }\n\n        for (int ch=0; ch<channels; ch++) {\n            Buffer<float>::div(this->icrf[ch], 256, maxV);\n            this->icrf[ch][255] = 1.0f;\n        }\n\n        // clean quantized stack\n        for (unsigned char * qslice : qstack) {\n            delete qslice;\n        }\n\n        delete[] lower;\n        delete[] higher;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_CAMERA_RESPONSE_FUNCTION_HPP */\n\n"
  },
  {
    "path": "include/algorithms/color_classification.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_COLOR_CLASSIFICATION_HPP\n#define PIC_ALGORITHMS_COLOR_CLASSIFICATION_HPP\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n\n#include \"../image.hpp\"\n#include \"../filtering/filter_radial_basis_function.hpp\"\n#include \"../filtering/filter_white_balance.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../algorithms/lischinski_minimization.hpp\"\n#include \"../util/mask.hpp\"\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief computeColorClassification\n * @param img\n * @param white_pixel\n * @param color_samples\n * @param nSamples\n * @param nDim\n * @param variance_colors\n * @return\n */\nPIC_INLINE bool *computeColorClassification(Image *img, float *white_pixel, float *color_samples, int nSamples, int nDim, float variance)\n{\n    if(color_samples == NULL || nSamples < 1 || nDim < 1 || variance <= 0.0f) {\n        return NULL;\n    }\n\n    RadialBasisFunction rbf;\n    rbf.update(color_samples, nSamples, nDim, variance);\n\n    FilterRadialBasisFunction flt_rbf;\n    flt_rbf.update(&rbf);\n\n    FilterWhiteBalance flt_wb;\n    flt_wb.update(white_pixel, img->channels, true);\n\n    Image *img_wb = NULL;\n\n    bool bFlag = true;\n    if(white_pixel != NULL) {\n       img_wb = FilterWhiteBalance::execute(img, white_pixel, NULL);\n    } else {\n        img_wb = img;\n        bFlag = false;\n    }\n\n    #ifdef PIC_DEBUG\n        img_wb->Write(\"../data/output/s_input_wb.bmp\");\n    #endif\n\n    Image *img_wb_rbf = flt_rbf.Process(Single(img_wb), NULL);\n\n    img_wb_rbf->clamp(0.0f, 1.0f);\n\n    Image *img_L = FilterLuminance::execute(img, NULL);\n\n    Image *opt = LischinskiMinimization(img_L, img_wb_rbf);\n\n    float value = 1.0f;\n    bool *mask = opt->convertToMask(&value, 0.25f, false, NULL);\n\n    int width = opt->width;\n    int height = opt->height;\n    bool *tmp;\n    tmp = Mask::dilate(NULL, mask, width, height, 3);\n    Mask::dilate(mask, tmp, width, height, 3);\n    Mask::dilate(tmp, mask, width, height, 3);\n    Mask::dilate(mask, tmp, width, height, 3);\n\n    Mask::removeIsolatedPixels(tmp, mask, width, height);\n\n    Mask::erode(mask, tmp, width, height, 3);\n    Mask::erode(tmp, mask, width, height, 3);\n    Mask::erode(mask, tmp, width, height, 3);\n\n    #ifdef PIC_DEBUG\n        opt->convertFromMask(mask, width, height);\n        opt->Write(\"../data/output/opt.bmp\");\n    #endif\n\n    if(tmp != mask) {\n        delete[] tmp;\n    }\n\n    delete opt;\n    delete img_L;\n    delete img_wb_rbf;\n\n    if(bFlag) {\n        delete img_wb;\n    }\n\n    return mask;\n}\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_COLOR_CLASSIFICATION_HPP */\n"
  },
  {
    "path": "include/algorithms/color_to_gray.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_COLOR_TO_GRAY_HPP\n#define PIC_ALGORITHMS_COLOR_TO_GRAY_HPP\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../image_vec.hpp\"\n#include \"../filtering/filter_channel.hpp\"\n#include \"../tone_mapping/exposure_fusion.hpp\"\n\nnamespace pic {\n\n\nclass ColorToGray\n{\nprotected:\n    ExposureFusion ef;\n    FilterChannel *flt;\n\npublic:\n\n    ColorToGray()\n    {\n        ef.update(1.0f, 1.0f, 0.0f);\n        flt = new FilterChannel(SingleInt(0));\n    }\n\n    ~ColorToGray()\n    {\n        delete_s(flt);\n    }\n\n    Image* Process(Image *imgIn, Image *imgOut)\n    {\n        if(imgIn == NULL){\n            return imgOut;\n        }\n\n        if(imgOut == NULL){\n            imgOut = new Image(1, imgIn->width, imgIn->height, 1);\n        }\n\n        ImageVec img_vec;\n        ImageVec input = Single(imgIn);\n\n        int channels = imgIn->channels;\n        for(int i = 0; i < channels; i++) {\n            img_vec.push_back(flt->Process(input, NULL));\n            flt->update(SingleInt(i + 1));\n        }\n\n        imgOut = ef.Process(img_vec, imgOut);\n\n        for(int i = 0; i < channels; i++) {\n            delete img_vec[i];\n        }\n\n        stdVectorClear<Image>(img_vec);\n\n        return imgOut;\n    }\n\n    static Image* execute(Image* imgIn, Image *imgOut)\n    {\n        ColorToGray c2g;\n        imgOut = c2g.Process(imgIn, imgOut);\n\n        return imgOut;\n    }\n};\n\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_COLOR_TO_GRAY_HPP */\n\n"
  },
  {
    "path": "include/algorithms/compute_divergence.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_COMPUTE_DIVERGENCE_HPP\n#define PIC_ALGORITHMS_COMPUTE_DIVERGENCE_HPP\n\n#include \"../base.hpp\"\n\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter_conv_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief DivergenceOperator calculates divergence of the gradient of an image.\n * @param img is an input image.\n * @param div is the output divergence of the gradient of img; i.e. Laplacian.\n * @return\n */\nclass DivergenceOperator\n{\nprotected:\n    FilterConv1D flt;\n    float kernelGrad[3];\n    float kernelDiv[3];\n    Image *img_dx, *img_dy;\n\npublic:\n\n    /**\n     * @brief DivergenceOperator\n     */\n    DivergenceOperator()\n    {\n        kernelGrad[0] = -0.5f;\n        kernelGrad[1] =  0.0f;\n        kernelGrad[2] =  0.5f;\n\n        kernelDiv[0] = -1.0f;\n        kernelDiv[1] =  1.0f;\n        kernelDiv[2] =  0.0f;\n\n        img_dx = NULL;\n        img_dy = NULL;\n    }\n\n    ~DivergenceOperator()\n    {\n        delete_s(img_dx);\n        delete_s(img_dy);\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(Image *imgIn, Image *imgOut)\n    {\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = imgIn->clone();\n        } else {\n            if(!imgOut->isSimilarType(imgIn)) {\n                imgOut = imgIn->allocateSimilarOne();\n            }\n        }\n\n        //compute gradient dx\n        flt.update(kernelGrad, 3, true);\n        img_dx = flt.Process(Single(imgIn), img_dx);\n\n        //compute gradient dy\n        flt.update(kernelGrad, 3, false);\n        img_dy = flt.Process(Single(imgIn), img_dy);\n\n        //compute the divergence using backward differences\n        flt.update(kernelDiv, 3, true);\n        imgOut = flt.Process(Single(img_dx), imgOut);\n\n        flt.update(kernelDiv, 3, false);\n        auto img_dy2 = flt.Process(Single(img_dy), img_dx);\n\n        *imgOut += *img_dy2;\n\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        DivergenceOperator divOp;\n        return divOp.Process(imgIn, imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_COMPUTE_DIVERGENCE_HPP */\n\n"
  },
  {
    "path": "include/algorithms/connected_components.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_CONNECTED_COMPONENTS_HPP\n#define PIC_ALGORITHMS_CONNECTED_COMPONENTS_HPP\n\n#include <vector>\n#include <set>\n#include <map>\n#include <utility>\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n\n#include \"../util/buffer.hpp\"\n\nnamespace pic {\n\nstruct LabelInfo\n{\n    uint id;\n    uint minLabel;\n\n    friend bool operator<(LabelInfo const &a, LabelInfo const &b)\n    {\n        return a.id < b.id;\n    }\n};\n\nclass LabelOutput\n{\npublic:\n    uint id;\n    std::vector< int > coords;\n    std::set< int > neighbors;\n    bool bValid;\n\n    LabelOutput()\n    {\n        id = 0;\n        bValid = true;\n    }\n\n    LabelOutput(uint id, int i)\n    {\n        this->id = id;\n        coords.push_back(i);\n        bValid = true;\n    }\n\n    void push_back(int i)\n    {\n        coords.push_back(i);\n    }\n\n    friend bool operator<(LabelOutput const &a, LabelOutput const &b)\n    {\n        return a.id < b.id;\n    }\n};\n\nclass ConnectedComponents\n{\nprotected:\n    float thr;\n\n    /**\n     * @brief secondPass\n     * @param imgOut\n     * @param labelEq\n     */\n    void secondPass(uint *imgOut, std::vector<LabelOutput> &ret, std::set<LabelInfo> &labelEq, int n)\n    {\n        //Label Search\n        LabelInfo tmpLI;\n        std::set<LabelInfo> labelEq_new;\n\n        for(auto it2 = labelEq.begin() ; it2 != labelEq.end(); it2++) {\n            auto minVal = it2->minLabel;\n            bool test = true;\n\n            while(test) {\n                test = false;\n                tmpLI.id = minVal;\n                auto it = labelEq.find(tmpLI);\n\n                if(it != labelEq.end()) {\n                    auto tmpMinLabel = (*it).minLabel;\n\n                    if(minVal > tmpMinLabel) {\n                        minVal = tmpMinLabel;\n                        test = true;\n                    }\n                }\n            }\n\n            LabelInfo tmp_it;\n            tmp_it.id = it2->id;\n            tmp_it.minLabel = minVal;\n            labelEq_new.insert(tmp_it);\n        }\n\n        //Second pass: using tracked neighbors\n        //for assigning the correct labels\n        //TO DO: optimizing outside this loop\n        std::set<uint> unique;\n        //std::set<uint>::iterator uniqueIt;\n        std::map<uint, int> mapping;\n\n        int counter = 0;\n\n        for(int i = 0; i < n; i++) {\n            tmpLI.id = imgOut[i];\n            auto it = labelEq_new.find(tmpLI);\n\n            if(it != labelEq_new.end()) {\n                imgOut[i] = it->minLabel;\n            }\n\n            //store coordiantes of the connected components\n            auto id = imgOut[i];\n            auto uniqueIt = unique.find(id);\n\n            if(uniqueIt != unique.end()) {\n                ret[mapping[id]].push_back(i);\n            } else {\n                std::pair<uint, int> tmp = std::make_pair(id, counter);\n                mapping.insert(tmp);\n\n                LabelOutput tmpRet(id, i);\n                ret.push_back(tmpRet);\n\n                unique.insert(id);\n                counter++;\n            }\n        }\n    }\n\n    void track(uint *imgOut, uint &label, std::set<LabelInfo> &labelEq,\n               int neighbors[2], int nNeighbors, int ind)\n    {\n        std::set<LabelInfo>::iterator it;\n        //No neighbors?\n        if(nNeighbors == 0) {\n            imgOut[ind] = label;\n            label++;\n        }\n\n        if(nNeighbors == 1) {\n            imgOut[ind] = imgOut[neighbors[0]];\n        }\n\n        if(nNeighbors == 2) {\n            //Assign the label of neighbors\n            uint minVal, t1, t2;\n            t1 = imgOut[neighbors[0]];\n            t2 = imgOut[neighbors[1]];\n            minVal = MIN(t1, t2);\n\n            //Track neighbors\n            LabelInfo tmpLI;\n            bool test = true;\n\n            while(test) {\n                test = false;\n                tmpLI.id = minVal;\n                it = labelEq.find(tmpLI);\n\n                if(it != labelEq.end()) {\n                    uint tmpMinLabel = it->minLabel;\n\n                    if(minVal > tmpMinLabel) {\n                        minVal = tmpMinLabel;\n                        test = true;\n                    }\n                }\n            }\n\n            imgOut[ind] = minVal;\n\n            //Track T1\n            test = true;\n            tmpLI.id = t1;\n            it = labelEq.find(tmpLI);\n\n            if(it != labelEq.end()) {\n                LabelInfo tmp_it;\n                tmp_it.id = it->id;\n                tmp_it.minLabel = minVal;\n\n                labelEq.erase(it);\n                labelEq.insert(tmp_it);\n            } else {\n                LabelInfo tmpLabelInfo;\n                tmpLabelInfo.id = t1;\n                tmpLabelInfo.minLabel = minVal;\n                labelEq.insert(tmpLabelInfo);\n            }\n\n            //Track T2\n            tmpLI.id = t2;\n            it = labelEq.find(tmpLI);\n\n            if(it != labelEq.end()) {\n                LabelInfo tmp_it;\n                tmp_it.id = it->id;\n                tmp_it.minLabel = minVal;\n\n                labelEq.erase(it);\n                labelEq.insert(tmp_it);\n            } else {\n                LabelInfo tmpLabelInfo;\n                tmpLabelInfo.id = t2;\n                tmpLabelInfo.minLabel = minVal;\n                labelEq.insert(tmpLabelInfo);\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief ConnectedComponents\n     * @param thr\n     */\n    ConnectedComponents(float thr = 0.05f)\n    {\n        this->thr  = thr > 0.0f ? thr : 0.05f;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param ret\n     */\n    uint *execute(Image *imgIn, uint *imgOut, std::vector<LabelOutput> &ret)\n    {\n        //Check input paramters\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        float *data  = imgIn->data;\n        int width    = imgIn->width;\n        int height   = imgIn->height;\n        int channels = imgIn->channels;\n\n        int n = width * height;\n\n        if(imgOut == NULL) {\n            imgOut = new uint[n];\n        }\n\n        Buffer<uint>::assign(imgOut, n, 0);\n\n        //First pass:\n        // 1) assign basics labels\n        // 2) generate the list of neighbors\n        uint label = 1;\n        std::set<LabelInfo> labelEq;\n        for(int j = 0; j < height; j++) {\n            int indY = j * width;\n\n            for(int i = 0; i < width; i++) {\n                int ind = (indY + i);\n\n                int ind_img = ind * channels;\n\n                //neighbors\n                int neighbors[2];\n                int nNeighbors = 0;\n\n                if((i - 1) > -1) {\n                    int ind_img_prev = ind_img - channels;\n\n                    float n1 = Arrayf::norm(&data[ind_img], channels);\n                    float n2 = Arrayf::norm(&data[ind_img_prev], channels);\n                    float dist = sqrtf(Arrayf::distanceSq(&data[ind_img], &data[ind_img_prev], channels));\n\n                    if(dist <= (thr * MAX(n1, n2))) {\n                        neighbors[0] = ind - 1;\n                        nNeighbors++;\n                    }\n                }\n\n                if((j - 1) > -1) {\n                    int ind_img_prev = ind_img - (width * channels);\n\n                    float n1 = Arrayf::norm(&data[ind_img], channels);\n                    float n2 = Arrayf::norm(&data[ind_img_prev], channels);\n                    float dist = sqrtf(Arrayf::distanceSq(&data[ind_img], &data[ind_img_prev], channels));\n\n                    if(dist <= (thr * MAX(n1, n2))) {\n                        neighbors[nNeighbors] = ind - width;\n                        nNeighbors++;\n                    }\n                }\n\n                track(imgOut, label, labelEq, neighbors, nNeighbors, ind);\n            }\n        }\n\n        secondPass(imgOut, ret, labelEq, n);\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param imgOut\n     * @param ret\n     * @return\n     */\n    template<typename T>\n    uint *execute(T *imgIn, int width, int height, uint *imgOut, std::vector<LabelOutput> &ret)\n    {\n        //Check input paramters\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        int n = width * height;\n\n        if(imgOut == NULL) {\n            imgOut = new uint[n];\n        }\n\n        Buffer<uint>::assign(imgOut, n, 0);\n\n        T *data = imgIn;\n        //First pass:\n        // 1) assign basics labels\n        // 2) generate the list of neighbors\n        uint label = 1;\n        std::set<LabelInfo> labelEq;\n        for(int j = 0; j < height; j++) {\n            int indY = j * width;\n\n            for(int i = 0; i < width; i++) {\n                int ind = (indY + i);\n\n                //neighbors\n                int neighbors[2];\n                int nNeighbors = 0;\n\n                if((i - 1) > -1) {\n                    int ind_prev = ind - 1;\n                    if(data[ind] == data[ind_prev]) {\n                        neighbors[0] = ind_prev;\n                        nNeighbors++;\n                    }\n                }\n\n                if((j - 1) > -1) {\n                    int ind_prev = ind - width;\n                    if(data[ind] == data[ind_prev]) {\n                        neighbors[nNeighbors] = ind_prev;\n                        nNeighbors++;\n                    }\n                }\n\n                track(imgOut, label, labelEq, neighbors, nNeighbors, ind);\n            }\n        }\n\n        secondPass(imgOut, ret, labelEq, n);\n        return imgOut;\n    }\n\n    /**\n     * @brief reCount\n     * @param imgLabel\n     * @param ret\n     * @return\n     */\n    static uint *reCount(uint *imgLabel, std::vector<LabelOutput> &labelsList)\n    {\n        if(imgLabel == NULL) {\n            return NULL;\n        }\n\n        uint c = 0;\n        for(uint i = 0; i < labelsList.size(); i++) {\n            if(labelsList[i].bValid) {\n                labelsList[i].id = c;\n                IndexedArrayui::assign(imgLabel, labelsList[i].coords, c);\n                c++;\n            }\n        }\n\n        return imgLabel;\n    }\n\n    /**\n     * @brief convertFromIntegerToImage\n     * @param imgLabel\n     * @param imgOut\n     * @param width\n     * @param height\n     * @return\n     */\n    static Image* convertFromIntegerToImage(uint *imgLabel, Image *imgOut, int width, int height)\n    {\n        if(imgLabel == NULL) {\n            return imgOut;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = new Image(1, width, height, 1);\n        }\n\n        int n = width * height;\n        for(int i = 0; i < n; i++) {\n            imgOut->data[i] = float(imgLabel[i]);\n        }\n\n        return imgOut;\n    }\n\n    /**\n     * @brief computeLabelsList\n     * @param labels\n     * @param n\n     * @param labelsList\n     */\n    static void computeLabelsListFromImageLabels(uint *labels, int n,  std::vector<LabelOutput> &labelsList)\n    {\n        if(labels == NULL || n < 1) {\n            return;\n        }\n\n        labelsList.clear();\n\n        std::set<uint> labels_tracker;\n\n        std::map<uint, int> labels_map;\n\n        int c = 0;\n        for(int i = 0; i < n; i++) {\n            uint j = labels[i];\n            auto search = labels_tracker.find(j);\n            if (search != labels_tracker.end()) {\n                labels_tracker.insert(j);\n                labels_map[j] = c;\n\n                LabelOutput tmp;\n                tmp.id = j;\n                labelsList.push_back(tmp);\n\n                c++;\n            }\n\n            labelsList[labels_map[j]].push_back(i);\n        }\n    }\n\n    /**\n     * @brief computeImageLabelsFromLabelsList\n     * @param labelsList\n     * @param labels\n     * @param n\n     * @return\n     */\n    static uint *computeImageLabelsFromLabelsList(std::vector<LabelOutput> &labelsList, uint *labels, int n)\n    {\n        if(n < 1 || labelsList.empty()) {\n            return labels;\n        }\n\n        if(labels == NULL) {\n            labels = new uint[n];\n        }\n\n        for(uint i = 0; i < labelsList.size(); i++) {\n            if(labelsList[i].bValid) {\n                for(uint j = 0; j < labelsList[i].coords.size(); j++) {\n                    int k = labelsList[i].coords[j];\n                    labels[k] = labelsList[i].id;\n                }\n            }\n        }\n\n        return labels;\n    }\n\n\n    /**\n     * @brief getMappingLabelsList\n     * @param labelsList\n     * @param labels_map\n     */\n    static void getMappingLabelsList(std::vector<LabelOutput> &labelsList, std::map<uint, int> &labels_map)\n    {\n        for(uint i = 0; i < labelsList.size(); i++) {\n            labels_map[labelsList[i].id] = i;\n        }\n    }\n\n    /**\n     * @brief computeNeighbors\n     * @param labels\n     * @param width\n     * @param height\n     * @param labelsList\n     */\n    static void computeNeighbors(uint *labels, int width, int height, std::vector<LabelOutput> &labelsList)\n    {\n        std::map<uint, int> labels_map;\n        getMappingLabelsList(labelsList, labels_map);\n\n        int width_m_1 = width - 1;\n        int height_m_1 = height - 1;\n\n        for(int i = 0; i < height; i++) {\n            int shift = i * width;\n\n            for(int j = 0; j < width; j++) {\n                int ind = shift + j;\n\n                uint l_ind = labels[ind];\n                int ind2 = labels_map[l_ind];\n\n                if(i > 0) {\n                    if(l_ind != labels[ind - width]) {\n                        labelsList[ind2].neighbors.insert(labels[ind - width]);\n                    }\n                }\n\n                if(j > 0) {\n                    if(l_ind != labels[ind - 1]) {\n                        labelsList[ind2].neighbors.insert(labels[ind - 1]);\n                    }\n                }\n\n                if(i < height_m_1) {\n                    if(l_ind != labels[ind + width]) {\n                        labelsList[ind2].neighbors.insert(labels[ind + width]);\n                    }\n                }\n\n                if(j < width_m_1) {\n                    if(l_ind != labels[ind + 1]) {\n                        labelsList[ind2].neighbors.insert(labels[ind + 1]);\n                    }\n                }\n\n            }\n        }\n    }\n\n    /**\n     * @brief mergeIsolatedAreasWithThreshold\n     * @param labels\n     * @param width\n     * @param height\n     * @param labelsList\n     * @param threshold\n     */\n    static void mergeIsolatedAreasWithThreshold(uint *labels, int width, int height, std::vector<LabelOutput> &labelsList, int threshold = 1)\n    {\n        if(threshold < 1 || labels == NULL || labelsList.empty()) {\n            return;\n        }\n\n        if(labelsList[0].neighbors.empty()) {\n            computeNeighbors(labels, width, height, labelsList);\n        }\n\n        std::map<uint, int> labels_map;\n        getMappingLabelsList(labelsList, labels_map);\n\n        for(uint i = 0; i < labelsList.size(); i++) {\n            if(!labelsList[i].bValid || labelsList[i].neighbors.empty()) {\n                continue;\n            }\n\n            if(labelsList[i].neighbors.size() == 1) {\n                uint id = *labelsList[i].neighbors.begin();\n                int index = labels_map[id];\n\n                if(labelsList[index].bValid) {\n\n                    if(labelsList[i].coords.size() > labelsList[index].coords.size()) {\n                        labelsList[index].bValid = false;\n\n                        //update coordinates\n                        labelsList[i].coords.insert(labelsList[i].coords.begin(),\n                                                    labelsList[index].coords.begin(),\n                                                    labelsList[index].coords.end());\n\n                        //update neighbors\n                        if(labelsList[index].neighbors.size() > 1) {\n                            labelsList[i].neighbors.insert(labelsList[index].neighbors.begin(), labelsList[index].neighbors.end());\n\n                            //update all neighbors removing index and adding i!\n                            for (auto it = labelsList[index].neighbors.begin(); it != labelsList[index].neighbors.end(); it++) {\n                                uint id2 = *it;\n                                int index2 = labels_map[id2];\n\n                                labelsList[index2].neighbors.erase(index);\n                                labelsList[index2].neighbors.insert(i);\n                            }\n                        }\n                    } else {\n                        labelsList[i].bValid = false;\n\n                        //update coordinates\n                        labelsList[index].coords.insert(labelsList[index].coords.begin(),\n                                                        labelsList[i].coords.begin(),\n                                                        labelsList[i].coords.end());\n\n                        //it does not have anymore this neighbor because it has been merged\n                        labelsList[index].neighbors.erase(i);\n                    }\n                }\n            }\n        }\n\n        computeImageLabelsFromLabelsList(labelsList, labels, width * height);\n    }\n\n};\n\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_CONNECTED_COMPONENTS_HPP */\n\n"
  },
  {
    "path": "include/algorithms/discrete_cosine_transform.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_DISCRETE_COSINE_TRANSFORM_HPP\n#define PIC_ALGORITHMS_DISCRETE_COSINE_TRANSFORM_HPP\n\n#include \"../image.hpp\"\n#include \"../util/tile_list.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The DCT class provides a reference\n * implementation for Discret Cosine Transform.\n */\nclass DCT\n{\npublic:\n\n    /**\n     * @brief DCT\n     */\n    DCT()\n    {\n    }\n\n    /**\n     * @brief transform computes the forward DCT transformation.\n     * @param imgIn is an input image.\n     * @param imgOut is an output image; i.e. imgIn in the DCT domain.\n     * @param size is the size of blocks (size * size) for computing the DCT.\n     * @return\n     */\n    static Image *transform(Image *imgIn, Image *imgOut, int size = 8)\n    {\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = imgIn->allocateSimilarOne();\n        }\n\n        if(size < 1) {\n            size = 8;\n        }\n\n        float size2 = float(size * 2);\n        float squareRoot2 = sqrtf(2.0f);\n        float squareRoot = sqrtf(2.0f / float(size));\n        float squareRootPow2 = squareRoot * squareRoot;\n\n        int channels = imgIn->channels;\n\n        TileList tiles(size, imgOut->width, imgOut->height);\n\n        for(unsigned int t = 0; t < tiles.tiles.size(); t++) {\n            BBox box = tiles.getBBox(t);\n\n            for(int v = box.y0; v < box.y1; v++) {\n                int vr = v % size;\n\n                for(int u = box.x0; u < box.x1; u++) {\n                    int ur = u % size;\n\n                    float *dataOut = (*imgOut)(u, v);\n\n                    for(int p = 0; p < channels; p++) {\n                        dataOut[p] = 0.0f;\n                    }\n\n                    for(int y = 0; y < size; y++) {\n                        int yi\t\t=  y + box.y0;\n                        int\tval\t\t= vr * (2 * y + 1);\n                        float cosU\t= cosf(C_PI * float(val) / size2);\n\n                        for(int x = 0; x < size; x++) {\n                            int xi\t\t=  x + box.x0;\n                            val\t\t\t= ur * (2 * x + 1);\n                            float tot\t= cosU * cosf(C_PI * float(val) / size2);\n\n                            float *dataIn = (*imgIn)(xi, yi);\n\n                            for(int p = 0; p < channels; p++) {\n                                dataOut[p] += tot * dataIn[p];\n                            }\n                        }\n                    }\n\n                    if(ur == 0) {\n                        for(int p = 0; p < channels; p++) {\n                            dataOut[p] /= squareRoot2;\n                        }\n                    }\n\n                    if(vr == 0) {\n                        for(int p = 0; p < channels; p++) {\n                            dataOut[p] /= squareRoot2;\n                        }\n                    }\n\n                    for(int p = 0; p < channels; p++) {\n                        dataOut[p] *= squareRootPow2;\n                    }\n                }\n            }\n        }\n\n        return imgOut;\n    }\n\n    /**\n     * @brief inverse computes the inverse DCT transformation.\n     * @param imgIn is an input image in the DCT domain.\n     * @param imgOut is an output image; i.e. imgIn in spatial domain.\n     * @param size is the size of blocks (size * size) for computing the DCT.\n     * @return\n     */\n    static Image *inverse(Image *imgIn, Image *imgOut, int size = 8)\n    {\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = imgIn->allocateSimilarOne();\n        }\n\n        if(size < 1) {\n            size = 8;\n        }\n\n        float size2 = float(size * 2);\n        float squareRoot2 = sqrtf(2.0f);\n        float squareRoot = sqrtf(2.0f / float(size));\n        float squareRootPow2 = squareRoot * squareRoot;\n\n        int channels = imgIn->channels;\n\n        TileList tiles(size, imgOut->width, imgOut->height);\n\n        for(unsigned int t = 0; t < tiles.tiles.size(); t++) {\n            BBox box = tiles.getBBox(t);\n\n            for(int y = box.y0; y < box.y1; y++) {\n                int yr = y % size;\n\n                for(int x = box.x0; x < box.x1; x++) {\n                    int xr = x % size;\n\n                    float *dataOut = (*imgOut)(x, y);\n\n                    for(int p = 0; p < channels; p++) {\n                        dataOut[p] = 0.0f;\n                    }\n\n                    for(int v = 0; v < size; v++) {\n                        int vi\t\t= box.y0 + v;\n                        int\tval\t\t= v * (2 * yr + 1);\n                        float cosU\t= cosf(C_PI * float(val) / size2);\n\n                        if(v == 0) {\n                            cosU /= squareRoot2;\n                        }\n\n                        for(int u = 0; u < size; u++) {\n                            int ui\t\t= box.x0 + u;\n                            val\t\t\t= u * (2 * xr + 1);\n                            float tot\t= cosU * cosf(C_PI * float(val) / size2);\n\n                            if(u == 0) {\n                                tot /= squareRoot2;\n                            }\n\n                            float *dataIn = (*imgIn)(ui, vi);\n\n                            for(int p = 0; p < channels; p++) {\n                                dataOut[p] += tot * dataIn[p];\n                            }\n                        }\n                    }\n\n                    for(int p = 0; p < channels; p++) {\n                        dataOut[p] *= squareRootPow2;\n                    }\n                }\n            }\n        }\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_DISCRETE_COSINE_TRANSFORM_HPP */\n\n"
  },
  {
    "path": "include/algorithms/grow_cut.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_GROW_CUT_HPP\n#define PIC_ALGORITHMS_GROW_CUT_HPP\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n#include \"../image_vec.hpp\"\n\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter_max.hpp\"\n#include \"../filtering/filter_grow_cut.hpp\"\n#include \"../filtering/filter_channel.hpp\"\n\nnamespace pic {\n\nclass GrowCut\n{\nprotected:\n    FilterGrowCut flt;\n    FilterMax *fltMax;\n    Image *img_max, *state_next;\n\npublic:\n\n    /**\n     * @brief GrowCut\n     */\n    GrowCut()\n    {\n        state_next = NULL;\n        img_max = NULL;\n\n        fltMax = new FilterMax(5);\n    }\n\n    ~GrowCut()\n    {\n        delete_s(img_max);\n        delete_s(fltMax);\n        delete_s(state_next);\n    }\n\n    /**\n     * @brief checkImage\n     * @param img\n     * @param width\n     * @param height\n     * @param channels\n     * @return\n     */\n    static bool checkImage(Image *img, int width, int height, int channels)\n    {\n        return (img->channels != channels) ||\n               (img->width    != width) ||\n               (img->height   != height);\n    }\n\n    /**\n     * @brief fromStrokeImageToSeeds\n     * @param strokes\n     * @param out\n     * @return\n     */\n    static Image *fromStrokeImageToSeeds(Image *strokes, Image *out)\n    {\n        if(strokes == NULL) {\n            return out;\n        }\n\n        if(strokes->channels < 3) {\n            return out;\n        }\n\n        if(out == NULL) {\n            out = new Image(1, strokes->width, strokes->height, 1);\n        } else {\n            if(checkImage(out, strokes->width, strokes->height, 1)) {\n                out = new Image(1, strokes->width, strokes->height, 1);\n            }\n        }\n\n        //red  --> +1\n        //blue --> -1\n        float red[]  = {1.0f, 0.0f, 0.0f};\n        float blue[] = {0.0f, 0.0f, 1.0f};\n\n        for(int i = 0; i < strokes->nPixels(); i++) {\n            int ind = i * strokes->channels;\n\n            float d_red  = sqrtf(Arrayf::distanceSq(red,  &strokes->data[ind], 3));\n            float d_blue = sqrtf(Arrayf::distanceSq(blue, &strokes->data[ind], 3));\n\n            out->data[i] = 0.0f;\n\n            out->data[i] = d_red  < 0.5f ?  1.0f : out->data[i];\n            out->data[i] = d_blue < 0.5f ? -1.0f : out->data[i];\n        }\n\n        return out;\n    }\n\n    /**\n     * @brief getMaskAsImage\n     * @param state\n     * @return\n     */\n    static Image* getMaskAsImage(Image *state, Image *out)\n    {\n        if(state == NULL) {\n            return out;\n        }\n\n        if(out == NULL) {\n            out = new Image(1, state->width, state->height, 1);\n        }\n\n        return FilterChannel::execute(state, out, 0);\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut)\n    {\n        if(!ImageVecCheck(imgIn, 2)) {\n            return imgOut;\n        }\n\n        auto img = imgIn[0];\n        auto seeds = imgIn[1];\n\n        if(imgOut == NULL) {\n            imgOut = new Image(img->width, img->height, 2);\n        } else {\n            if(checkImage(imgOut, img->width, img->height, 2)) {\n                imgOut = new Image(img->width, img->height, 2);\n            }\n        }\n\n        auto state_cur = imgOut;\n\n        if(state_next == NULL) {\n            state_next = state_cur->allocateSimilarOne();\n        } else {\n            if(checkImage(state_cur, img->width, img->height, 2)) {\n                state_next = state_cur->allocateSimilarOne();\n            }\n        }\n\n        //compute max\n        img_max = fltMax->Process(Single(img), img_max);\n\n        for(int i = 0; i < state_cur->nPixels(); i++) {\n            //init state_cur\n            int j  = i * state_cur->channels;\n            int j_seeds = i * seeds->channels;\n            state_cur->data[j] = seeds->data[j_seeds];\n            state_cur->data[j + 1] = fabsf(seeds->data[j_seeds]) > 0.0f ? 1.0f : 0.0f;\n\n            //fix max\n            j = i * img_max->channels;\n            img_max->data[j] = Arrayf::norm_sq(&img_max->data[j], img_max->channels);\n        }\n\n        //iterative filtering...\n        int iterations = int(img->getDiagonalSize());\n\n        if((iterations % 2) == 1) {\n            iterations++;\n        }\n\n        ImageVec input = Triple(state_cur, img, img_max);\n        Image *output = state_next;\n\n        for(int i = 0; i < iterations; i++) {\n            output = flt.Process(input, output);\n            Image *tmp = input[0];\n            input[0] = output;\n            output = tmp;\n        }\n\n        return imgOut;\n    }\n\n    static Image *execute(Image *img, Image *seeds, Image *imgOut)\n    {\n        GrowCut gc;\n        return gc.Process(Double(img, seeds), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_GROW_CUT_HPP */\n\n"
  },
  {
    "path": "include/algorithms/hdr_merger.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_HDR_MERGER_HPP\n#define PIC_ALGORITHMS_HDR_MERGER_HPP\n\n#include <vector>\n#include <string>\n\n#include \"../base.hpp\"\n#include \"../util/vec.hpp\"\n#include \"../algorithms.hpp\"\n#include \"../algorithms/camera_response_function.hpp\"\n#include \"../features_matching/ward_alignment.hpp\"\n#include \"../filtering/filter_assemble_hdr.hpp\"\n\nnamespace pic {\n\nenum HDRAlign{HA_NONE, HA_MTB, HA_FEATURES};\n\nclass HDRMerger\n{\nprotected:\n    CameraResponseFunction *crf;\n    FilterAssembleHDR merger;\n    HDRAlign hdra;\n\n    CRF_WEIGHT weight;\n    HDR_REC_DOMAIN domain;\n\n    std::vector<std::string> file_name_vec;\n    std::vector<float> exposure_time_vec;\n\n    /**\n     * @brief incrementalAlignment\n     * @param stack\n     * @param s_vec\n     */\n    void incrementalAlignment(ImageVec &stack, std::vector<Vec2i> &s_vec)\n    {\n        int n = int(stack.size());\n\n        for(int i = 0; i < (n - 1); i++) {\n            Vec2i s_i = WardAlignment::execute(stack[i + 1], stack[i]);\n            s_vec.push_back(s_i);\n        }\n\n        int n2 = int(s_vec.size());\n        for(int i = 0; i < (n2 - 1); i++) {\n            Vec2i n_i = s_vec[i];\n\n            for(int j = (i + 1); j < n2; j++) {\n                n_i += s_vec[j];\n            }\n\n            s_vec[i] = n_i;\n        }\n    }\n\npublic:\n\n    /**\n     * @brief HDRMerger\n     */\n    HDRMerger()\n    {\n        domain = HRD_LOG;\n        weight = CW_DEB97;\n        hdra = HA_NONE;\n\n        crf = NULL;\n    }\n\n    ~HDRMerger()\n    {\n        release();\n    }\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n    }\n\n    /**\n     * @brief update\n     * @param weight\n     * @param domain\n     * @param crf\n     */\n    void update(CRF_WEIGHT weight, HDR_REC_DOMAIN domain,\n                HDRAlign hdra,\n                CameraResponseFunction *crf = NULL)\n    {\n        this->hdra = hdra;\n        this->weight = weight;\n        this->domain = domain;\n        this->crf = crf;\n    }\n\n    /**\n     * @brief addFile\n     * @param file_name\n     * @param exposure_time\n     */\n    void addFile(std::string file_name, float exposure_time = -1.0f)\n    {\n        file_name_vec.push_back(file_name);\n        exposure_time_vec.push_back(exposure_time);\n    }\n\n    /**\n     * @brief execute\n     * @param imgOut\n     * @return\n     */\n    Image *execute(Image *imgOut = NULL)\n    {\n        ImageVec stack;\n\n        bool bValid = true;\n        int n = int(file_name_vec.size());\n\n        for(int i = 0; i < n; i++) {\n            Image *img = new Image();\n            img->Read(file_name_vec[i], LT_NOR);\n            stack.push_back(img);\n            bValid = bValid && img->isValid();\n        }\n\n        if(!bValid) {\n            return imgOut;\n        }\n\n        ImageVec stack_aligned;\n        ImageVec stack_aligned_track;\n\n        //align images\n        if(hdra != HA_NONE && (n > 1)) {\n            ImageVecSortByExposureTime(stack);\n\n            if(hdra == HA_MTB) {\n                std::vector<Vec2i> shifts;\n                incrementalAlignment(stack, shifts);\n\n                stack_aligned.push_back(stack[n - 1]);\n\n                for(int i = 0; i < int(shifts.size()); i++) {\n                    auto s_i = shifts[i];\n                    if(s_i[0] == 0 && s_i[1] == 0) {\n                        stack_aligned.push_back(stack[i]);\n                    } else {\n                        auto tmp_i = WardAlignment::shiftImage(stack[i], shifts[i], NULL);\n                        stack_aligned.push_back(tmp_i);\n                        stack_aligned_track.push_back(tmp_i);\n                    }\n                }\n            }\n        }\n\n        //compute CRF\n        if(crf == NULL) {\n            crf = new CameraResponseFunction();\n            crf->DebevecMalik(stack, weight, 256, 20.0f);\n        }\n\n        //merge all exposure images\n        merger.update(crf, weight, domain);\n\n        if(hdra != HA_NONE) {\n            imgOut = merger.Process(stack_aligned, imgOut);\n        } else {\n            imgOut = merger.Process(stack, imgOut);\n        }\n\n        stdVectorClear(stack);\n        stdVectorClear(stack_aligned_track);\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_WEIGHT_FUNCTION_HPP */\n\n"
  },
  {
    "path": "include/algorithms/histogram_matching.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_HISTOGRAM_MATCHING_HPP\n#define PIC_ALGORITHMS_HISTOGRAM_MATCHING_HPP\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n#include \"../image_vec.hpp\"\n#include \"../histogram.hpp\"\n\n#include \"../util/std_util.hpp\"\n\nnamespace pic {\n\nclass HistogramMatching\n{\nprotected:\n    int nBin;\n    bool bClipping;\n    float clip_value;\n\n    /**\n     * @brief computeHistograms\n     * @param img_s\n     * @param img_t\n     * @param hist_s\n     * @param hist_t\n     */\n    void computeHistograms(Image *img_s, Image *img_t,\n                           Histogram *hist_s, Histogram *hist_t)\n    {\n\n        if(img_s == NULL) {\n            return;\n        }\n\n        int channels = img_s->channels;\n        uint clip_value_ui = uint(clip_value * float(img_s->nPixels() / nBin));\n\n        for(int i = 0; i < channels; i++) {\n            hist_s[i].calculate(img_s, VS_LIN, nBin, NULL, i);\n\n            if(img_t != NULL) {\n                hist_t[i].calculate(img_t, VS_LIN, nBin, NULL, i);\n            } else {\n                uint value = MAX(img_s->nPixels() / nBin, 1);\n\n                hist_t[i].uniform(hist_s[i].getfMin(),\n                                  hist_s[i].getfMax(),\n                                  value, VS_LIN, nBin);\n            }\n            if(bClipping) {\n                hist_s[i].clip(clip_value_ui);\n                hist_t[i].clip(clip_value_ui);\n            }\n        }\n    }\n\n    /**\n     * @brief computeLUT\n     * @param hist_s\n     * @param hist_t\n     * @param channels\n     * @param lut\n     */\n    void computeLUT(Histogram *hist_s, Histogram *hist_t, int channels, std::vector<int *> &lut)\n    {\n        for(int i = 0 ; i < channels; i++) {\n            hist_s[i].cumulativef(true);\n            hist_t[i].cumulativef(true);\n\n            float *c_s = hist_s[i].getCumulativef();\n            float *c_t = hist_t[i].getCumulativef();\n\n            int *tmp_lut = new int[nBin];\n\n            for(int j = 0; j < nBin; j++) {\n                float x = c_s[j];\n                float *ptr = std::upper_bound(c_t, c_t + nBin, x);\n                tmp_lut[j] = MAX((int)(ptr - c_t), 0);\n            }\n\n            lut.push_back(tmp_lut);\n        }\n    }\n\npublic:\n\n    /**\n     * @brief HistogramMatching\n     */\n    HistogramMatching()\n    {\n        update(256, -1.0f);\n    }\n\n    /**\n     * @brief update\n     * @param nBin\n     * @param clip_value\n     */\n    void update(int nBin, float clip_value = 1.0f)\n    {\n        this->nBin = nBin > 1 ? nBin : 256;\n        this->clip_value = clip_value;\n        bClipping = clip_value > 0.0f;\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut = NULL)\n    {\n        Image *img_source = NULL; //imgIn[0]\n        Image *img_target = NULL; //imgIn[1]\n\n        int count = 0;\n        if(ImageVecCheck(imgIn, 1)) {\n            img_source = imgIn[0];\n            count = 1;\n        }\n\n        if(ImageVecCheck(imgIn, 2)) {\n            img_target = imgIn[1];\n\n            if(imgIn[0]->channels != imgIn[1]->channels) {\n                return imgOut;\n            }\n            count = 2;\n        }\n\n        if(count == 0) {\n            return imgOut;\n        }\n\n        count--;\n\n        if(imgOut == NULL) {\n            imgOut = imgIn[count]->clone();\n        } else {\n            if(!imgOut->isSimilarType(imgIn[count])) {\n                imgOut = imgIn[count]->allocateSimilarOne();\n            }\n        }\n\n        int channels = img_source->channels;\n\n        Histogram *h_source = new Histogram[channels];\n        Histogram *h_target = new Histogram[channels];\n\n\n        computeHistograms(img_source, img_target, h_source, h_target);\n        std::vector<int *> lut;\n        computeLUT(h_source, h_target, channels, lut);\n\n        for(int i = 0; i < imgOut->size(); i += channels) {\n\n            for(int j = 0; j < channels; j++) {\n                int k = i + j;\n\n                int ind_source = h_source[j].project(img_source->data[k]);\n\n                int ind_target = lut[j][ind_source];\n\n                imgOut->data[k] = h_target[j].unproject(ind_target);\n            }\n        }\n\n        delete[] h_source;\n        delete[] h_target;\n\n        stdVectorArrayClear(lut);\n\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param img_source\n     * @param img_target\n     * @param imgOut\n     * @return\n     */\n    static Image* execute(Image *img_source, Image *img_target, Image *imgOut = NULL)\n    {\n        HistogramMatching hm;\n        imgOut = hm.Process(Double(img_source, img_target), imgOut);\n        return imgOut;\n    }\n\n    /**\n     * @brief executeEqualization\n     * @param img\n     * @param imgOut\n     * @param clip_value\n     * @return\n     */\n    static Image* executeEqualization(Image *img, Image *imgOut = NULL, float clip_value = 0.9f)\n    {\n        HistogramMatching hm;\n        hm.update(256, clip_value);\n        imgOut = hm.Process(Double(img, NULL), imgOut);\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_HISTOGRAM_MATCHING_HPP */\n\n"
  },
  {
    "path": "include/algorithms/lischinski_minimization.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_LISCHINSKI_MINIMIZATION_HPP\n#define PIC_ALGORITHMS_LISCHINSKI_MINIMIZATION_HPP\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Sparse\"\n    #include \"../externals/Eigen/src/SparseCore/SparseMatrix.h\"\n#else\n    #include <Eigen/Sparse>\n    #include <Eigen/src/SparseCore/SparseMatrix.h>\n#endif\n\n#endif\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n\nnamespace pic {\n/**\n*\n*\tparam[0] --> alpha\n*\tparam[1] --> lambda\n*\n**/\n\n/**\n * @brief LischinskiFunction\n * @param Lcur\n * @param Lref\n * @param param\n * @param LISCHINSKI_EPSILON\n * @return\n */\ninline float LischinskiFunction(float Lcur, float Lref, float param[2],\n                                float LISCHINSKI_EPSILON = 0.0001f)\n{\n    return -param[1] / (powf(fabsf(Lcur - Lref), param[0]) + LISCHINSKI_EPSILON);\n}\n\n/**\n * @brief LischinskiFunctionGauss\n * @param Lcur\n * @param Lref\n * @param param\n * @return\n */\ninline float LischinskiFunctionGauss(float Lcur, float Lref, float param[2])\n{\n    return expf(-powf(Lcur - Lref, 2.0f) * 10.0f);\n}\n\n/**\n * @brief LischinskiMinimization\n * @param L\n * @param g\n * @param omega\n * @param omega_global\n * @param gOut\n * @param alpha\n * @param lambda\n * @param LISCHINSKI_EPSILON\n * @return\n */\nPIC_INLINE Image *LischinskiMinimization(Image *L,\n                              Image *g,\n                              Image *omega = NULL,\n                              float omega_global = 1.0f,\n                              Image *gOut = NULL,\n                              float alpha = 1.0f,\n                              float lambda = 0.4f,\n                              float LISCHINSKI_EPSILON = 1e-4f)\n{\n    if(L == NULL || g == NULL) {\n        return gOut;\n    }\n\n#ifndef PIC_DISABLE_EIGEN\n    bool bOmega = (omega == NULL);\n\n    int width = L->width;\n    int height = L->height;\n    int tot = height * width;\n\n    float param[2];\n    param[0] = alpha;\n    param[1] = lambda;\n\n    Eigen::VectorXd b, x;\n    b = Eigen::VectorXd::Zero(tot);\n\n    #ifdef PIC_DEBUG\n        printf(\"Init matrix...\");\n    #endif\n\n    std::vector< Eigen::Triplet< double > > tL;\n\n    for(int i = 0; i < height; i++) {\n        int tmpInd = i * width;\n\n        for(int j = 0; j < width; j++) {\n\n            float sum = 0.0f;\n            float tmp;\n            int indJ;\n            int indI = tmpInd + j;\n            float Lref = L->data[indI];\n\n            float omega_val;\n            if(bOmega) {\n                omega_val = omega_global;\n            } else {\n                omega_val = omega->data[indI];\n            }\n\n            b[indI] = omega_val * g->data[indI];\n\n            if((i - 1) >= 0) {\n                indJ = indI - width;\n                tmp = LischinskiFunction(L->data[indJ], Lref, param, LISCHINSKI_EPSILON);\n                tL.push_back(Eigen::Triplet< double > (indI, indJ, tmp));\n                sum += tmp;\n            }\n\n            if((i + 1) < height) {\n                indJ = indI + width;\n                tmp = LischinskiFunction(L->data[indJ], Lref, param, LISCHINSKI_EPSILON);\n                tL.push_back(Eigen::Triplet< double > (indI, indJ, tmp));\n                sum += tmp;\n            }\n\n            if((j - 1) >= 0) {\n                indJ = indI - 1;\n                tmp = LischinskiFunction(L->data[indJ], Lref, param, LISCHINSKI_EPSILON);\n                tL.push_back(Eigen::Triplet< double > (indI, indJ, tmp));\n                sum += tmp;\n            }\n\n            if((j + 1) < width) {\n                indJ = indI + 1;\n                tmp = LischinskiFunction(L->data[indJ], Lref, param, LISCHINSKI_EPSILON);\n                tL.push_back(Eigen::Triplet< double > (indI, indJ, tmp));\n                sum += tmp;\n            }\n\n            tL.push_back(Eigen::Triplet< double > (indI, indI, omega_val - sum));\n        }\n    }\n\n    #ifdef PIC_DEBUG\n        printf(\"Ok\\n\");\n    #endif\n\n    Eigen::SparseMatrix<double> A = Eigen::SparseMatrix<double>(tot, tot);\n    A.setFromTriplets(tL.begin(), tL.end());\n\n    Eigen::SimplicialCholesky<Eigen::SparseMatrix<double> > solver(A);\n    x = solver.solve(b);\n\n    if(solver.info() != Eigen::Success) {\n        #ifdef PIC_DEBUG\n            printf(\"SOLVER FAILED!\\n\");\n        #endif\n        return NULL;\n    }\n\n    #ifdef PIC_DEBUG\n        printf(\"SOLVER SUCCESS!\\n\");\n    #endif\n\n    if(gOut == NULL) {\n        gOut = g->allocateSimilarOne();\n    } else {\n        if(!gOut->isSimilarType(g)) {\n            gOut = g->allocateSimilarOne();\n        }\n    }\n\n    for(int i = 0; i < height; i++) {\n        int counter = i * width;\n\n        for(int j = 0; j < width; j++) {\n            (*gOut)(j, i)[0] = float(x(counter + j));\n        }\n    }\n\n    return gOut;\n#else\n    return gOut;\n#endif\n}\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_LISCHINSKI_MINIMIZATION_HPP */\n\n"
  },
  {
    "path": "include/algorithms/live_wire.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_LIVE_WIRE_HPP\n#define PIC_ALGORITHMS_LIVE_WIRE_HPP\n\n#include <functional>\n#include <vector>\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gradient.hpp\"\n#include \"../filtering/filter_log_2d_opt.hpp\"\n#include \"../filtering/filter_channel.hpp\"\n#include \"../filtering/filter_sampler_2d.hpp\"\n#include \"../util/vec.hpp\"\n#include \"../util/std_util.hpp\"\n\nnamespace pic {\n\nclass LiveWire\n{\nprotected:\n    float fD_const;\n\n    float *fG_min, *fG_max;\n\n    Image *img_G, *fZ, *g;\n    int *pointers;\n    bool *e;\n\n    /**\n     * @brief getCost\n     * @param x\n     * @param y\n     * @return\n     */\n    float getCost(Vec2i &p, Vec2i &q)\n    {\n        float out;\n        float *tmp;\n\n        //fZ cost\n        tmp = (*fZ)(q[0], q[1]);\n        out = 0.43f * tmp[0];\n\n        //fG cost\n        tmp = (*img_G)(q[0], q[1]);\n\n        float fG = 1.0f - (tmp[2] - fG_min[2]) / fG_max[2];\n        float dist_qp = sqrtf(float(q.distanceSq(p)));\n        out += 0.14f * fG / dist_qp;\n\n        //fD cost\n\n        //D_p\n        tmp = (*img_G)(p[0], p[1]);\n        Vec2f D_p(tmp[1], -tmp[0]);\n        float n_D_p_sq = D_p.lengthSq();\n        if(n_D_p_sq > 0.0f) {\n            D_p /= sqrtf(n_D_p_sq);\n        }\n\n        //D_q\n        tmp = (*img_G)(q[0], q[1]);\n        Vec2f D_q(tmp[1], -tmp[0]);\n        float n_D_q_sq = D_q.lengthSq();\n        if(n_D_q_sq > 0.0f) {\n            D_q /= sqrtf(n_D_q_sq);\n        }\n\n        //Delta_qp\n        Vec2f delta_qp(float(q[0] - p[0]), float(q[1] - p[1]));\n\n        Vec2f L;\n        if(D_p.dot(delta_qp) >= 0.0f) {\n            L = delta_qp;\n        } else {\n            L = -delta_qp;\n        }\n\n        float n_L_sq = L.lengthSq();\n        if(n_L_sq > 0.0f) {\n            L /= sqrtf(n_L_sq);\n        }\n\n        float dp_pq = D_p.dot(L);\n        float dq_pq = L.dot(D_q);\n\n        float fD = (acosf(dp_pq) + acosf(dq_pq)) * fD_const;\n\n        out +=  0.43f * fD;\n\n        return out;\n    }\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        img_G = delete_s(img_G);\n        fZ = delete_s(fZ);\n        g = delete_s(g);\n        e = delete_s(e);\n        pointers = delete_s(pointers);\n    }\n\n    /**\n     * @brief f1minusx\n     * @param x\n     * @return\n     */\n    static float f1minusx(float x)\n    {\n        return 1.0f - x;\n    }\n\npublic:\n\n    LiveWire(Image *img)\n    {\n        fD_const = 2.0f / (C_PI * 3.0f);\n\n        img_G = NULL;\n        fZ = NULL;\n        g = NULL;\n        e = NULL;\n        pointers = NULL;\n\n        set(img);\n    }\n\n    ~LiveWire()\n    {\n        release();\n    }\n\n    /**\n     * @brief set\n     * @param img\n     */\n    void set(Image *img)\n    {\n        release();\n\n        Image *img_L = FilterLuminance::execute(img, NULL);\n\n        //compute fG\n        img_G = FilterGradient::execute(img_L, img_G);\n        fG_min = img_G->getMinVal(NULL, NULL);\n        fG_max = img_G->getMaxVal(NULL, NULL);\n\n        //compute fZ\n        fZ = FilterLoG2DOpt::execute(img_L, fZ, 1.0f);\n        fZ->applyFunction(f1minusx);\n\n        //aux buffers\n        g = img_L;\n\n        e = new bool[img_L->nPixels()];\n\n        pointers = new int[img_L->nPixels()];\n    }\n\n    /**\n     * @brief execute\n     * @param pS\n     * @param pE\n     * @param out\n     * @param bConstrained\n     * @param bMultiple\n     */\n    void execute(Vec2i pS, Vec2i pE, std::vector< Vec2i > &out, bool bConstrained = false, bool bMultiple = false)\n    {\n        float *tmp;\n\n        e = Buffer<bool>::assign(e, g->nPixels(), false);\n        //*g = FLT_MAX;\n        //pointers = Buffer<int>::assign(pointers, g->nPixels(), 0);\n\n        int width  = g->width;\n        int height = g->height;\n\n        int nx[] = {-1, 0, 1, -1, 1, -1,  0, 1};\n        int ny[] = { 1, 1, 1,  0, 0, -1, -1, -1};\n\n        int bX[2], bY[2];\n\n        if(!bConstrained) {\n            bX[0] = -1;\n            bX[1] = width;\n\n            bY[0] = -1;\n            bY[1] = height;\n        } else {\n            int boundSize = 11;\n\n            bX[0] = MAX(MIN(pS[0], pE[0]) - boundSize, -1);\n            bX[1] = MIN(MAX(pS[0], pE[0]) + boundSize, width);\n\n            bY[0] = MAX(MIN(pS[1], pE[1]) - boundSize, -1);\n            bY[1] = MIN(MAX(pS[1], pE[1]) + boundSize, height);\n        }\n\n        tmp = (*g)(pS[0], pS[1]);\n        tmp[0] = 0.0f;\n\n        std::vector< Vec2i > list;\n        list.push_back(pS);\n\n        while(!list.empty()) { //get the best\n            std::vector< Vec2i >::iterator index;\n            Vec2i q;\n\n            float g_q = FLT_MAX;\n            bool bCheck = false;\n            for(auto it = list.begin(); it != list.end(); it++) {\n                float g_it = (*g)((*it)[0], (*it)[1])[0];\n                if(g_it < g_q) {\n                    g_q = g_it;\n                    index = it;\n                    bCheck = true;\n                }\n            }\n\n            if(!bCheck) {\n                break;\n            }\n\n            q[0] = (*index)[0];\n            q[1] = (*index)[1];\n\n            list.erase(index);\n\n            //update\n            int index_q = q[1] * width + q[0];\n            e[index_q] = true;\n\n            for(int i = 0; i < 8; i++) {\n                Vec2i r(q[0] + nx[i], q[1] + ny[i]);\n\n                if((r[0] > bX[0]) && (r[0] < bX[1]) &&\n                   (r[1] > bY[0]) && (r[1] < bY[1])) {\n\n                    if(!e[r[1] * width + r[0]]) {\n                        float g_tmp = g_q + getCost(q, r);\n\n                        //check list\n                        bool bFlag = false;\n                        for(auto it = list.begin(); it != list.end(); it++) {\n                            if(r.equal(*it)) {\n                                index = it;\n                                bFlag = true;\n                            }\n                        }\n\n                        if(bFlag && (g_tmp < g_q)) {\n                            list.erase(index);\n                        }\n\n                        if(!bFlag) {\n                            tmp = (*g)(r[0], r[1]);\n                            tmp[0] = g_tmp;\n\n                            int index = (r[1] * width + r[0]);\n                            pointers[index] = index_q;\n                            list.push_back(r);\n                        }\n\n                    }\n\n                }\n\n            }\n        }\n\n        //forward pass -- tracking\n        if(!bMultiple) {\n            out.clear();\n        }\n\n        out.push_back(pE);\n        Vec2i m = pE;\n        Vec2i prev(-1, -1);\n\n        int maxIter = (width * height);\n        int i = 0;\n\n        while((!prev.equal(m)) && (i < maxIter)) {\n            prev = m;\n\n            if(m.equal(pS)) {\n                break;\n            }\n\n            int index = (m[1] * width + m[0]);\n            int t_x = pointers[index] % width;\n            int t_y = pointers[index] / width;\n            Vec2i t(t_x, t_y);\n\n            out.push_back(t);\n            m = t;\n\n            i++;\n        }\n\n    }\n\n    /**\n     * @brief executeLiveWireSingle\n     * @param in\n     * @param pS\n     * @param pE\n     * @param out\n     */\n    static void executeLiveWireSingle(Image *in, Vec2i pS, Vec2i pE, std::vector< Vec2i > &out)\n    {\n        if(in != NULL) {\n            pic::LiveWire *lw = new pic::LiveWire(in);\n\n            lw->execute(pS, pE, out, true, false);\n\n            delete lw;\n        }\n    }\n\n    /**\n     * @brief executeLiveWireMultiple\n     * @param in\n     * @param controlPoint\n     * @param out\n     */\n    static void executeLiveWireMultiple(Image *in, std::vector< Vec2i > &controlPoints, std::vector< Vec2i > &out)\n    {\n        if(in != NULL) {\n            pic::LiveWire *lw = new pic::LiveWire(in);\n\n            for(uint i = 0; i < (controlPoints.size() - 1); i++) {\n                lw->execute(controlPoints.at(i), controlPoints.at(i + 1), out, true, true);\n            }\n\n            delete lw;\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_LIVE_WIRE_HPP */\n\n"
  },
  {
    "path": "include/algorithms/mitsunaga_nayar_crf.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014-2016\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nLibrary author: Francesco Banterle\nThis file author: Giorgio Marcias\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_MITSUNAGA_NAYAR_CRF_HPP\n#define PIC_ALGORITHMS_MITSUNAGA_NAYAR_CRF_HPP\n\n#include<algorithm>\n#include<limits>\n#include<vector>\n\n#include \"../base.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/LU\"\n#else\n    #include <Eigen/LU>\n#endif\n\n#endif\n\nnamespace pic {\n\n/**\n * @brief MitsunagaNayarClassic computes the inverse CRF of a camera as a polynomial function.\n * @param samples           Sample array of size nSamples x #exposures.\n * @param nSamples          Number of samples, for each exposure.\n * @param exposures         Array of exposure timings (size: #exposures = 'Q' as in the Mitsunaga & Nayar paper).\n * @param coefficients      The output coefficients ('c' in the paper) resulting from the computation.\n * @param computeRatios     false if exact exposures are passed, true to approximate exposure ratios as in the paper.\n * @param R                 The output estimated exposure ratios, i.e. R[q1][q2] = 'R_{q1,q2}' as in the book.\n * @param eps               Threshold for stopping the approximation process.\n * @param max_iterations    Maximum number of iterations.\n * @return The error as in the paper.\n */\nPIC_INLINE float MitsunagaNayarClassic(int *samples, const std::size_t nSamples, const std::vector<float> &exposures,\n                                   std::vector<float> &coefficients, const bool computeRatios, std::vector<float> &R,\n                                   const float eps, const std::size_t max_iterations)\n{\n#ifndef PIC_DISABLE_EIGEN\n    float eval, val, tmp1, tmp2;\n    const std::size_t Q = exposures.size();\n    const std::size_t N = coefficients.size() - 1;\n\n    const float Mmax = 1.f;\n\n    for (float &_c : coefficients) {\n        _c = 0.f;\n    }\n\n    if (!samples || Q < 2 || coefficients.size() < 2) {\n        return std::numeric_limits<float>::infinity();\n    }\n\n    R.assign(Q < 2 ? 0 : Q - 1, 1.f);\n    for (unsigned int q = 0; q < R.size(); ++q) {\n        R[q] = exposures[q] / exposures[q+1];\n    }\n\n    //Check valid samples\n    std::vector<std::vector<float>> g(nSamples, std::vector<float>(Q, 0.f));\n    std::size_t P = 0;\n    for (std::size_t p = 0; p < nSamples; ++p) {\n        bool valid = false;\n        for (std::size_t q = 0; q < Q-1; ++q) {\n            if (samples[p * Q + q] >= 0 && samples[p * Q + q+1] >= 0) {\n                valid = true;\n                break;\n            }\n        }\n        if (valid) {\n            for (std::size_t q = 0; q < Q; ++q) {\n                if (samples[p * Q + q] >= 0) {\n                    g[P][q] = samples[p * Q + q] / 255.f;\n                } else {\n                    g[P][q] = -1.f;\n                }\n            }\n            ++P;\n        }\n    }\n    g.resize(P);\n\n    if (g.empty()) {\n        return std::numeric_limits<float>::infinity();\n    }\n\n    //Precompute test with exponentials\n    std::vector<Eigen::VectorXf> test;\n    if (computeRatios) {\n        test.assign(256, Eigen::VectorXf::Zero(N+1));\n        for (std::size_t i = 0; i < 256; ++i) {\n            test[i][0] = 1.f;\n            for (std::size_t n = 1; n <= N; ++n) {\n                test[i][n] = (i / 255.f) * test[i][n-1];\n            }\n        }\n    }\n\n    //Precompute M with exponentials\n    std::vector<std::vector<std::vector<float>>> M(P,\n                                                   std::vector<std::vector<float>>(Q,\n                                                                                   std::vector<float>(N+1, 0.f)));\n    for (std::size_t p = 0; p < P; ++p) {\n        for (std::size_t q = 0; q < Q; ++q) {\n            M[p][q][0] = 1.f;\n            for (std::size_t n = 1; n <= N; ++n) {\n                M[p][q][n] = g[p][q] * M[p][q][n-1];\n            }\n        }\n    }\n\n    std::vector<std::vector<std::vector<float>>> d(P,\n                                                   std::vector<std::vector<float>>(Q-1,\n                                                                                   std::vector<float>(N+1, 1.f)));\n    Eigen::MatrixXf A = Eigen::MatrixXf::Zero(N, N);\n    Eigen::VectorXf x, b = Eigen::VectorXf::Zero(N);\n    Eigen::VectorXf c(N+1), prev_c = Eigen::VectorXf::Zero(N+1);\n\n    std::size_t iter = 0;\n\n    do {\n        //Compute d\n        for (std::size_t p = 0; p < P; ++p) {\n            for (std::size_t q = 0; q < Q-1; ++q) {\n                if (g[p][q] >= 0.f && g[p][q+1] >= 0.f) {\n                    for (std::size_t n = 0; n <= N; ++n) {\n                        d[p][q][n] = M[p][q][n] - R[q] * M[p][q+1][n];\n                    }\n                } else {\n                    d[p][q].assign(N+1, 0.f);\n                }\n            }\n        }\n\n        //Build the matrix A of the linear system\n        A.setZero(N, N);\n        for (std::size_t i = 0; i < N; ++i) {\n            for (std::size_t j = 0; j < N; ++j) {\n                for (std::size_t p = 0; p < P; ++p) {\n                    for (std::size_t q = 0; q < Q - 1; ++q) {\n                        A(i, j) += d[p][q][i] * (d[p][q][j] - d[p][q][N]);\n                    }\n                }\n            }\n        }\n\n        //Build the vector of knowns b\n        b.setZero(N);\n        for (std::size_t i = 0; i < N; ++i) {\n            for (std::size_t p = 0; p < P; ++p) {\n                for (std::size_t q = 0; q < Q - 1; ++q) {\n                    b(i) -= Mmax * d[p][q][i] * d[p][q][N];\n                }\n            }\n        }\n\n        //Solve the linear system\n        x = A.partialPivLu().solve(b);\n        c << x, Mmax - x.sum();\n\n        if (computeRatios) {\n            //Evaluate approximation increment\n            eval = std::numeric_limits<float>::lowest();\n            for (const Eigen::VectorXf &_M : test) {\n                val = std::abs((c - prev_c).dot(_M));\n                if (val > eval) {\n                    eval = val;\n                }\n            }\n\n            //Update R\n            for (std::size_t q = 0; q < Q-1; ++q) {\n                R[q] = 0.f;\n                tmp1 = 0.f;\n                tmp2 = 0.f;\n                for (std::size_t p = 0; p < P; ++p) {\n                    if (g[p][q] >= 0.f && g[p][q+1] >= 0.f) {\n                        for (std::size_t n = 0; n <= N; ++n) {\n                            tmp1 += c[n] * M[p][q][n];\n                            tmp2 += c[n] * M[p][q+1][n];\n                        }\n                    }\n                }\n                R[q] += tmp1 / tmp2;\n            }\n\n            ++iter;\n        }\n    } while (computeRatios && eval > eps && iter < max_iterations);\n\n    for (std::size_t n = 0; n <= N; ++n) {\n        coefficients[n] = c[n];\n    }\n\n    //Evaluate error\n    eval = 0.f;\n    for (std::size_t q = 0; q < Q-1; ++q) {\n        for (std::size_t p = 0; p < P; ++p) {\n            if (g[p][q] >= 0.f && g[p][q+1] >= 0.f) {\n                val = 0.f;\n                for (std::size_t n = 0; n <= N; ++n) {\n                    val += coefficients[n] * (M[p][q][n] - R[q] * M[p][q+1][n]);\n                }\n                eval += val * val;\n            }\n        }\n    }\n\n    return eval;\n#else\n    return -1.0f;\n#endif\n}\n\n/**\n * @brief MitsunagaNayarFull computes the inverse CRF of a camera as a polynomial function, using all exposure ratios.\n * @param samples           Sample array of size nSamples x #exposures.\n * @param nSamples          Number of samples, for each exposure.\n * @param exposures         Array of exposure timings (size: #exposures = 'Q' as in the Mitsunaga & Nayar paper).\n * @param coefficients      The output coefficients ('c' in the paper) resulting from the computation.\n * @param computeRatios     false if exact exposures are passed, true to approximate exposure ratios as in the paper.\n * @param R                 The output estimated exposure ratios, i.e. R[q1][q2] = 'R_{q1,q2}' as in the book.\n * @param eps               Threshold for stopping the approximation process.\n * @param max_iterations    Maximum number of iterations.\n * @return The error as in the paper.\n */\nPIC_INLINE float MitsunagaNayarFull(int *samples, const std::size_t nSamples, const std::vector<float> &exposures,\n                                std::vector<float> &coefficients, bool computeRatios, std::vector<std::vector<float>> &R,\n                                const float eps, const std::size_t max_iterations)\n{\n#ifndef PIC_DISABLE_EIGEN\n    float eval, val, tmp1, tmp2;\n    const std::size_t Q = exposures.size();\n    const std::size_t N = coefficients.size() - 1;\n\n    const float Mmax = 1.f;\n\n    for (float &_c : coefficients) {\n        _c = 0.f;\n    }\n    R.assign(Q < 2 ? 0 : Q, std::vector<float>(Q < 2 ? 0 : Q, 1.f));\n    for (uint q1 = 0; q1 < R.size(); ++q1) {\n        for (uint q2 = 0; q2 < R[q1].size(); ++q2) {\n            if (q2 == q1) {\n                R[q1][q2] = 1.f;\n            } else {\n                R[q1][q2] = exposures[q1] / exposures[q2];\n            }\n        }\n    }\n    if (!samples || Q < 2 || coefficients.size() < 2) {\n        return std::numeric_limits<float>::infinity();\n    }\n\n    //Check valid samples\n    std::vector<std::vector<float>> g(nSamples, std::vector<float>(Q, 0.f));\n    std::size_t P = 0;\n    for (std::size_t p = 0; p < nSamples; ++p) {\n        std::size_t valid = 0;\n        for (std::size_t q = 0; q < Q; ++q) {\n            if (samples[p * Q + q] >= 0) {\n                ++valid;\n            }\n        }\n        if (valid > 1) {\n            for (std::size_t q = 0; q < Q; ++q) {\n                if (samples[p * Q + q] >= 0) {\n                    g[P][q] = samples[p * Q + q] / 255.f;\n                } else {\n                    g[P][q] = -1.f;\n                }\n            }\n            ++P;\n        }\n    }\n    g.resize(P);\n\n    if (g.empty()) {\n        return std::numeric_limits<float>::infinity();\n    }\n\n    //Precompute test with exponentials\n    std::vector<Eigen::VectorXf> test;\n    if (computeRatios) {\n        test.assign(256, Eigen::VectorXf::Zero(N+1));\n        for (std::size_t i = 0; i < 256; ++i) {\n            test[i][0] = 1.f;\n            for (std::size_t n = 1; n <= N; ++n) {\n                test[i][n] = (i / 255.f) * test[i][n-1];\n            }\n        }\n    }\n\n    //Precompute M with exponentials\n    std::vector<std::vector<std::vector<float>>> M(P,\n                                                   std::vector<std::vector<float>>(Q,\n                                                                                   std::vector<float>(N+1, 0.f)));\n    for (std::size_t p = 0; p < P; ++p) {\n        for (std::size_t q = 0; q < Q; ++q) {\n            M[p][q][0] = 1.f;\n            for (std::size_t n = 1; n <= N; ++n) {\n                M[p][q][n] = g[p][q] * M[p][q][n-1];\n            }\n        }\n    }\n\n    std::vector<std::vector<std::vector<std::vector<float>>>> d(P,\n                                                                std::vector<std::vector<std::vector<float>>>(Q,\n                                                                            std::vector<std::vector<float>>(Q,\n                                                                                        std::vector<float>(N+1, 1.f))));\n    Eigen::MatrixXf A = Eigen::MatrixXf::Zero(N, N);\n    Eigen::VectorXf x, b = Eigen::VectorXf::Zero(N);\n    Eigen::VectorXf c(N+1), prev_c = Eigen::VectorXf::Zero(N+1);\n\n    std::size_t iter = 0;\n\n    do {\n        //Compute d\n        for (std::size_t p = 0; p < P; ++p) {\n            for (std::size_t q1 = 0; q1 < Q; ++q1) {\n                for (std::size_t q2 = 0; q2 < Q; ++q2) {\n                    d[p][q1][q2].assign(N+1, 0.f);\n                    if (q2 != q1) {\n                        for (std::size_t n = 0; n <= N; ++n) {\n                            if (g[p][q1] >= 0.f && g[p][q2] >= 0.f) {\n                                d[p][q1][q2][n] = M[p][q1][n] - R[q1][q2] * M[p][q2][n];\n                            } else {\n                                d[p][q1][q2][n] = 0.f;\n                            }\n                        }\n                    }\n                }\n            }\n        }\n\n        //Build the matrix A of the linear system\n        A.setZero(N, N);\n        for (std::size_t i = 0; i < N; ++i) {\n            for (std::size_t j = 0; j < N; ++j) {\n                for (std::size_t p = 0; p < P; ++p) {\n                    for (std::size_t q1 = 0; q1 < Q; ++q1) {\n                        for (std::size_t q2 = 0; q2 < Q; ++q2) {\n                            if (q2 != q1) {\n                                A(i, j) += d[p][q1][q2][i] * (d[p][q1][q2][j] - d[p][q1][q2][N]);\n                            }\n                        }\n                    }\n                }\n            }\n        }\n\n        //Build the vector of knowns b\n        b.setZero(N);\n        for (std::size_t i = 0; i < N; ++i) {\n            for (std::size_t p = 0; p < P; ++p) {\n                for (std::size_t q1 = 0; q1 < Q; ++q1) {\n                    for (std::size_t q2 = 0; q2 < Q; ++q2) {\n                        if (q2 != q1) {\n                            b(i) -= Mmax * d[p][q1][q2][i] * d[p][q1][q2][N];\n                        }\n                    }\n                }\n            }\n        }\n\n        //Solve the linear system\n        x = A.partialPivLu().solve(b);\n        c << x, Mmax - x.sum();\n\n        if (computeRatios) {\n            //Evaluate approximation increment\n            eval = std::numeric_limits<float>::lowest();\n            for (const Eigen::VectorXf &_M : test) {\n                val = std::abs((c - prev_c).dot(_M));\n                if (val > eval) {\n                    eval = val;\n                }\n            }\n\n            //Update R\n            for (std::size_t q1 = 0; q1 < Q; ++q1) {\n                for (std::size_t q2 = 0; q2 < Q; ++q2) {\n                    R[q1][q2] = 0.f;\n                    tmp1 = 0.f;\n                    tmp2 = 0.f;\n                    for (std::size_t p = 0; p < P; ++p) {\n                        if (g[p][q1] >= 0.f && g[p][q2] >= 0.f) {\n                            for (std::size_t n = 0; n <= N; ++n) {\n                                tmp1 += c[n] * M[p][q1][n];\n                                tmp2 += c[n] * M[p][q2][n];\n                            }\n                        }\n                    }\n                    R[q1][q2] += tmp1 / tmp2;\n                }\n            }\n\n            ++iter;\n        }\n    } while (computeRatios && eval > eps && iter < max_iterations);\n\n    for (std::size_t n = 0; n <= N; ++n) {\n        coefficients[n] = c[n];\n    }\n\n    //Evaluate error\n    eval = 0.f;\n    for (std::size_t q1 = 0; q1 < Q; ++q1) {\n        for (std::size_t q2 = 0; q2 < Q; ++q2) {\n            if (q2 != q1) {\n                for (std::size_t p = 0; p < P; ++p) {\n                    if (g[p][q1] >= 0.f && g[p][q2] >= 0.f) {\n                        val = 0.f;\n                        for (std::size_t n = 0; n <= N; ++n) {\n                            val += coefficients[n] * (M[p][q1][n] - R[q1][q2] * M[p][q2][n]);\n                        }\n                        eval += val * val;\n                    }\n                }\n            }\n        }\n    }\n\n    return eval;\n#else\n    return -1.0f;\n#endif\n}\n\n}\n\n#endif // PIC_ALGORITHMS_MITSUNAGA_NAYAR_CRF_HPP\n"
  },
  {
    "path": "include/algorithms/multi_resolution_operator.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_MULTI_RESOLUTION_OPERATOR_HPP\n#define PIC_ALGORITHMS_MULTI_RESOLUTION_OPERATOR_HPP\n\n#include \"../util/math.hpp\"\n#include \"../image.hpp\"\n#include \"../image_vec.hpp\"\n#include \"../algorithms/pyramid.hpp\"\n\nnamespace pic {\n\nclass MultiResolutionOperator\n{\nprotected:\n    int pyramid_limit;\n\npublic:\n\n    MultiResolutionOperator()\n    {\n        pyramid_limit = 4;\n    }\n\n    /**\n     * @brief setup\n     * @param imgIn\n     * @param pIn\n     * @param imgOut\n     * @return\n     */\n    virtual Image *setup(ImageVec imgIn, std::vector<Pyramid *> pIn, Image *imgOut)\n    {\n        return imgOut;\n    }\n\n    /**\n     * @brief f\n     * @param imgIn\n     * @param imgOut\n     * @param level\n     * @return\n     */\n    virtual Image* f(ImageVec imgIn, Image *imgOut, int level)\n    {\n        return imgOut;\n    }\n\n    virtual Image* upsample(ImageVec imgIn, Image *imgOut)\n    {\n        return imgOut;\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut)\n    {\n        std::vector<Pyramid *> pIn;\n\n        int n = (1 << 30) - 1;\n        for(uint i = 0; i < imgIn.size(); i++) {\n            Pyramid *s_i = new Pyramid(imgIn[i], false, pyramid_limit);\n            pIn.push_back(s_i);\n\n            n = MIN(n, s_i->size());\n        }\n\n        imgOut = setup(imgIn, pIn, imgOut);\n\n        bool bFirst = true;\n\n        for(int i = (n - 1); i >= 0; i--) {\n\n            ImageVec imgIn_i;\n            for(uint j = 0; j < pIn.size(); j++) {\n                imgIn_i.push_back(pIn[j]->get(i));\n            }\n\n            if(!bFirst) {\n                #ifdef PIC_DEBUG\n                    printf(\"Upsampling..\");\n                #endif\n\n                imgOut = upsample(imgIn_i, imgOut);\n\n                #ifdef PIC_DEBUG\n                    printf(\"ok\\n\");\n                #endif\n            }\n\n            int level = n - i;\n            #ifdef PIC_DEBUG\n                printf(\"Level: %d\\n\", level);\n            #endif\n\n            imgOut = f(imgIn, imgOut, level);\n        }\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_MULTI_RESOLUTION_OPERATOR_HPP */\n\n"
  },
  {
    "path": "include/algorithms/nelder_mead_opt_gray_match.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_NELDER_MEAD_OPT_GRAY_MATCH_HPP\n#define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_GRAY_MATCH_HPP\n\n#include \"../util/std_util.hpp\"\n#include \"../util/nelder_mead_opt_base.hpp\"\n#include \"../util/array.hpp\"\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\nclass NelderMeadOptGrayMatch: public NelderMeadOptBase<float>\n{\npublic:\n\n    float *col0, *col1, *tmp;\n    int channels;\n\n    /**\n     * @brief NelderMeadOptGrayMatch\n     * @param m0\n     * @param m1\n     * @param inliers\n     */\n    NelderMeadOptGrayMatch(float *col0, float * col1, int channels) : NelderMeadOptBase()\n    {\n        this->col0 = new float[channels];\n        this->col1 = new float[channels];\n\n        tmp = new float[channels];\n\n        this->channels = channels;\n\n        memcpy(this->col0, col0, sizeof(float) * channels);\n        memcpy(this->col1, col1, sizeof(float) * channels);\n\n        Arrayf::normalize(col0, channels);\n    }\n\n    ~NelderMeadOptGrayMatch()\n    {\n        delete_vec_s(col0);\n        delete_vec_s(col1);\n        delete_vec_s(tmp);\n    }\n\n    /**\n     * @brief function\n     * @param x\n     * @param n\n     * @return\n     */\n    float function(float *x, unsigned int n)\n    {\n        Arrayf::mul(x, channels, tmp);\n        Arrayf::normalize(tmp, channels);\n        return Arrayf::distanceSq(col0, tmp, channels);\n    }\n};\n#endif\n\n}\n\n#endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_GRAY_MATCH_HPP\n"
  },
  {
    "path": "include/algorithms/poisson_filling.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_POISSON_FILLING_HPP\n#define PIC_ALGORITHMS_POISSON_FILLING_HPP\n\n#include \"../util/std_util.hpp\"\n#include \"../util/buffer.hpp\"\n#include \"../util/mask.hpp\"\n#include \"../util/array.hpp\"\n#include \"../util/math.hpp\"\n#include \"../image.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The PoissonFilling class\n */\nclass PoissonFilling\n{\nprotected:\n    int maxIter;\n    float threshold, value;\n\n    bool *mask, *maskPoisson;\n    Image *imgTmp;\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        mask = delete_vec_s(mask);\n        maskPoisson = delete_vec_s(maskPoisson);\n        imgTmp = delete_s(imgTmp);\n    }\n\n    /**\n     * @brief update\n     * @param imgOut\n     * @param imgIn\n     */\n    void update(Image *imgOut, Image *imgIn)\n    {\n        imgOut->assign(imgIn);\n\n        #pragma omp parallel for\n\n        for(int i = 0; i < imgIn->height; i++) {\n            for(int j = 0; j < imgIn->width; j++) {\n                float *src = (*imgIn)(j, i);\n                float *n0  = (*imgIn)(j + 1, i);\n                float *n1  = (*imgIn)(j - 1, i);\n                float *n2  = (*imgIn)(j, i + 1);\n                float *n3  = (*imgIn)(j, i - 1);\n\n                int ind = i * imgIn->width + j;\n\n                float *out = (*imgOut)(j, i);\n\n                for(int k = 0; k < imgIn->channels; k++) {\n\n                    if(equalf(src[k], value)) {\n                        int div = 0;\n\n                        out[k] = 0.0f;\n\n                        if(!equalf(n0[k], value)) {\n                            out[k] += n0[k];\n                            div++;\n                        }\n\n                        if(!equalf(n1[k], value)) {\n                            out[k] += n1[k];\n                            div++;\n                        }\n\n                        if(!equalf(n2[k], value)) {\n                            out[k] += n2[k];\n                            div++;\n                        }\n\n                        if(!equalf(n3[k], value)) {\n                            out[k] += n3[k];\n                            div++;\n                        }\n\n                        if(div > 0) {\n                            out[k] = out[k] / float(div);\n                            mask[ind] = false;\n                        }\n                    } else { //Poisson solver\n                        if(maskPoisson[ind]) {\n                            int div = 0;\n                            float tmp = 0.0f;\n\n                            if(!equalf(n0[k], value)) {\n                                tmp += -src[k] + n0[k];\n                                div++;\n                            }\n\n                            if(!equalf(n1[k], value)) {\n                                tmp += -src[k] + n1[k];\n                                div++;\n                            }\n\n                            if(!equalf(n2[k], value)) {\n                                tmp += -src[k] + n2[k];\n                                div++;\n                            }\n\n                            if(!equalf(n3[k], value)) {\n                                tmp += -src[k] + n3[k];\n                                div++;\n                            }\n\n                            out[k] = src[k] + tmp / float(div);\n                        }\n                    }\n                }\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief PoissonFilling\n     */\n    PoissonFilling(float value)\n    {\n        imgTmp = NULL;\n        mask = NULL;\n        maskPoisson = NULL;\n\n        this->value = value;\n        threshold = 1e-4f;\n\n        maxIter = 1000;\n    }\n\n    ~PoissonFilling()\n    {\n        release();\n    }\n\n    /**\n     * @brief setup\n     * @param value\n     */\n    void setup(float value)\n    {\n        this->value = value;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param mask\n     * @return\n     */\n    Image *execute(Image *imgIn, Image *imgOut, bool *mask = NULL)\n    {\n        if(imgIn == NULL) {\n            return NULL;\n        }\n\n        if(!imgIn->isValid()) {\n            return NULL;\n        }\n\n        if(imgTmp != NULL) {\n            if(!imgTmp->isSimilarType(imgIn)) {\n                release();\n                imgTmp = imgIn->clone();\n            }\n        } else {\n            imgTmp = imgIn->clone();\n        }\n\n        if(imgOut == NULL) {\n            imgOut = imgIn->clone();\n        } else {\n            imgOut->assign(imgIn);\n        }\n\n        if(mask == NULL) {\n            float *color = Arrayf::genValue(value, 3, NULL);\n\n            mask = imgIn->convertToMask(color, threshold, false, NULL);\n\n            delete_vec_s(color);\n        }\n\n        maskPoisson = Mask::clone(maskPoisson, mask, imgIn->nPixels(), 1);\n\n        Image *work[2];\n        work[0] = imgTmp;\n        work[1] = imgOut;\n\n        int i = 0;\n\n        while(!Mask::empty(mask, imgIn->width, imgIn->height)) {\n            update(work[i % 2], work[(i + 1) % 2]);\n            i++;\n\n            if(i > maxIter) {\n                break;\n            }\n        }\n\n        if((i % 2) == 1) {\n            imgOut->assign(imgTmp);\n        }\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_POISSON_FILLING_HPP */\n\n"
  },
  {
    "path": "include/algorithms/poisson_image_editing.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_POISSON_IMAGE_EDITING_HPP\n#define PIC_ALGORITHMS_POISSON_IMAGE_EDITING_HPP\n\n#include <vector>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../filtering/filter_laplacian.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Sparse\"\n    #include \"../externals/Eigen/src/SparseCore/SparseMatrix.h\"\n#else\n    #include <Eigen/Sparse>\n    #include <Eigen/src/SparseCore/SparseMatrix.h>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n/**\n * @brief computePoissonImageEditing\n * @param source\n * @param target\n * @param mask\n * @param ret\n * @return\n */\nPIC_INLINE Image *computePoissonImageEditing(Image *source, Image *target, bool *mask, Image *ret = NULL)\n{\n    if((source == NULL) || (target == NULL) || (mask == NULL)) {\n        return NULL;\n    }\n\n    //allocate the output\n    if(ret == NULL) {\n        ret = target->clone();\n    }\n\n    int width  = target->width;\n    int height = target->height;\n\n    #ifdef PIC_DEBUG\n        printf(\"Init matrix...\");\n    #endif\n\n    Image *lap_source = FilterLaplacian::execute(source, NULL);\n\n    std::vector< Eigen::Triplet< double > > tL;\n\n    //indices pass\n    int *index = new int[width * height];\n    int count = 0;\n    for(int i = 0; i < height; i++) {\n        int tmpI = i * width;\n\n        for(int j = 0; j < width; j++) {\n            int indI = tmpI + j;\n\n            if(mask[indI]) {\n                index[indI] = count;\n                count++;\n            } else {\n                index[indI] = 0;\n            }\n        }\n    }\n\n    //matrix A pass\n    count = 0;\n    for(int i = 0; i < height; i++) {\n        int tmpI = i * width;\n\n        for(int j = 0; j < width; j++) {\n            int indI = tmpI + j;\n\n            if(mask[indI]) {\n                if((j + 1) < (width - 1)) {\n                    if(mask[indI + 1]) {\n                        tL.push_back(Eigen::Triplet< double > (count, index[indI + 1], -1.0));\n                    }\n                }\n\n                if((j - 1) > -1) {\n                    if(mask[indI - 1]) {\n                        tL.push_back(Eigen::Triplet< double > (count, index[indI - 1], -1.0));\n                    }\n                }\n\n                if((i + 1) < (height - 1)) {\n                    if(mask[indI + width]) {\n                        tL.push_back(Eigen::Triplet< double > (count, index[indI + width], -1.0));\n                    }\n                }\n\n                if((i - 1) > -1) {\n                    if(mask[indI - width]) {\n                        tL.push_back(Eigen::Triplet< double > (count, index[indI - width], -1.0));\n                    }\n                }\n\n                tL.push_back(Eigen::Triplet< double > (count, count , 4.0));\n\n                count++;\n            }\n        }\n    }\n\n    int tot = count;\n    Eigen::SparseMatrix<double> A = Eigen::SparseMatrix<double>(tot, tot);\n    A.setFromTriplets(tL.begin(), tL.end());\n\n    #ifdef PIC_DEBUG\n        printf(\"Ok\\n\");\n    #endif\n\n    //solve the linear system for each color channel\n    Eigen::SimplicialCholesky<Eigen::SparseMatrix<double> > solver(A);\n\n    for(int k=0; k< target->channels; k++) {\n\n        Eigen::VectorXd b, x;\n        b = Eigen::VectorXd::Zero(tot);\n\n        //assign values to b\n        int count = 0;\n        for(int i = 0; i < height; i++) {\n            int tmpI = i * width;\n\n            for(int j = 0; j < width; j++) {\n                int indI = (tmpI + j);\n\n                if(mask[indI]) {\n\n                    b[count] = -(*lap_source)(j, i)[k];\n\n                    if((j + 1) < (width - 1)) {\n                        if(!mask[indI + 1]) {\n                            b[count] += (*target)(j + 1, i)[k];\n                        }\n                    }\n\n                    if((j - 1) > -1) {\n                        if(!mask[indI - 1]) {\n                            b[count] += (*target)(j - 1, i)[k];\n                        }\n                    }                        \n\n                    if((i + 1) < (height - 1)) {\n                        if(!mask[indI + width]) {\n                            b[count] += (*target)(j, i + 1)[k];\n                        }\n                    }\n\n                    if((i - 1) > -1) {\n                        if(!mask[indI - width]) {\n                           b[count] += (*target)(j, i - 1)[k];\n                        }\n                    }\n\n                    count++;\n                }\n            }\n        }\n\n        x = solver.solve(b);\n\n        if(solver.info() != Eigen::Success) {\n            #ifdef PIC_DEBUG\n                printf(\"SOLVER FAILED!\\n\");\n            #endif\n\n            return NULL;\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"SOLVER SUCCESS!\\n\");\n        #endif\n\n        count = 0;\n        for(int i = 0; i < height; i++) {\n            int tmpI = i * width;\n\n            for(int j = 0; j < width; j++) {\n                int indI = (tmpI + j);\n\n                if(mask[indI]) {\n                    float val = float(x(count));\n                    (*ret)(j, i)[k] = val > 0.0f ? val : 0.0f;\n                    count++;\n                }\n            }\n        }\n    }\n\n    delete_s(lap_source);\n    delete_vec_s(index);\n\n    return ret;\n}\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_POISSON_IMAGE_EDITING_HPP */\n\n"
  },
  {
    "path": "include/algorithms/poisson_solver.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_POISSON_SOLVER_HPP\n#define PIC_ALGORITHMS_POISSON_SOLVER_HPP\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Sparse\"\n    #include \"../externals/Eigen/src/SparseCore/SparseMatrix.h\"\n#else\n    #include <Eigen/Sparse>\n    #include <Eigen/src/SparseCore/SparseMatrix.h>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief computePoissonSolver\n * @param f\n * @param ret\n * @return\n */\nPIC_INLINE Image *computePoissonSolver(Image *f, Image *ret = NULL)\n{\n    if(f == NULL) {\n        return NULL;\n    }\n\n    //allocate the output\n    if(ret == NULL) {\n        ret = f->allocateSimilarOne();\n    }\n\n    int width = f->width;\n    int height = f->height;\n    int tot = height * width;\n\n    #ifdef PIC_DEBUG\n        printf(\"Init matrix...\");\n    #endif\n\n    std::vector< Eigen::Triplet< double > > tL;\n\n    for(int i = 0; i < height; i++) {\n        int tmpI = i * width;\n\n        for(int j = 0; j < width; j++) {\n            int indI = tmpI + j;\n\n            tL.push_back(Eigen::Triplet< double > (indI, indI, 4.0f));\n\n            if(((indI + 1) < tot) &&\n               ((indI % width) != (width - 1))) {\n\n                tL.push_back(Eigen::Triplet< double > (indI, indI + 1, -1.0f));\n                tL.push_back(Eigen::Triplet< double > (indI + 1, indI, -1.0f));\n            }\n        }\n    }\n\n    for(int i = 0; i < (tot - width); i++) {\n        tL.push_back(Eigen::Triplet< double > (i + width, i         , -1.0f));\n        tL.push_back(Eigen::Triplet< double > (i        , i +  width, -1.0f));\n    }\n\n    #ifdef PIC_DEBUG\n        printf(\"Ok\\n\");\n    #endif\n\n    //solve the linear system for each color channel\n    Eigen::SparseMatrix<double> A = Eigen::SparseMatrix<double>(tot, tot);\n    A.setFromTriplets(tL.begin(), tL.end());\n    Eigen::SimplicialCholesky<Eigen::SparseMatrix<double> > solver(A);\n\n    for(int k = 0; k < f->channels; k++) {\n\n        Eigen::VectorXd b, x;\n        b = Eigen::VectorXd::Zero(tot);\n\n        //copy values from f to b\n        for(int i = 0; i < height; i++) {\n            int tmpI = i * width;\n            for(int j = 0; j < width; j++) {\n                int indI = (tmpI + j);\n                b[indI] = - f->data[indI * f->channels + k];\n            }\n        }\n\n        x = solver.solve(b);\n\n        if(solver.info() != Eigen::Success) {\n            #ifdef PIC_DEBUG\n                printf(\"SOLVER FAILED!\\n\");\n            #endif\n\n            return ret;\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"SOLVER SUCCESS!\\n\");\n        #endif\n\n        for(int i = 0; i < height; i++) {\n            int tmpI = i * width;\n\n            for(int j = 0; j < width; j++) {\n                (*ret)(j, i)[k] = float(x(tmpI + j));\n            }\n        }\n    }\n\n    return ret;\n}\n\n#endif\n\n/**\n * @brief computePoissonSolverIterative\n * @param img\n * @param laplacian\n * @param coords\n * @param maxSteps\n * @return\n */\nPIC_INLINE Image *computePoissonSolverIterative(Image *img, Image *laplacian,\n                              std::vector<int> coords,\n                              int maxSteps = 100)\n{\n    #ifdef PIC_DEBUG\n        printf(\"Iterative Poisson solver... \");\n    #endif\n\n    if(maxSteps < 1) {\n        maxSteps = 100;\n    }\n\n    Image *tmpImg = img->clone();\n    Image *tmpSwap = NULL;\n\n    int c, x, y;\n\n    for(int i = 0; i < maxSteps; i++) {\n        for(unsigned int j = 0; j < coords.size(); j++) {\n            int coord = coords[j];\n            img->reverseAddress(coord, x, y);\n\n            float workValue = -laplacian->data[coord];\n\n            c = img->getAddress(x + 1, y);\n            workValue += img->data[c];\n\n            c = img->getAddress(x - 1, y);\n            workValue += img->data[c];\n\n            c = img->getAddress(x, y + 1);\n            workValue += img->data[c];\n\n            c = img->getAddress(x, y - 1);\n            workValue += img->data[c];\n\n            tmpImg->data[coord] = workValue / 4.0f;\n        }\n\n        tmpSwap = img;\n        img     = tmpImg;\n        tmpImg  = tmpSwap;\n    }\n\n    #ifdef PIC_DEBUG\n        printf(\"done.\\n\");\n    #endif\n\n    return img;\n}\n\n} // end namespace pic\n\n\n#endif /* PIC_ALGORITHMS_POISSON_SOLVER_HPP */\n\n"
  },
  {
    "path": "include/algorithms/pushpull.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_PUSHPULL_HPP\n#define PIC_ALGORITHMS_PUSHPULL_HPP\n\n#include \"../image.hpp\"\n#include \"../image_samplers/image_sampler_bsplines.hpp\"\n#include \"../filtering/filter_down_pp.hpp\"\n#include \"../filtering/filter_up_pp.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The PushPull class\n */\nclass PushPull\n{\nprotected:\n\n    FilterDownPP *flt_down;\n    FilterUpPP *flt_up;\n    ImageVec stack;\n\n    /**\n     * @brief release\n     */\n    void release() {\n        for(unsigned int i = 1; i < stack.size(); i++) {\n            delete stack[i];\n        }\n\n        stack.clear();\n    }\n\npublic:\n\n    /**\n     * @brief PushPull\n     */\n    PushPull()\n    {\n\n    }\n\n    ~PushPull()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param value\n     * @param threshold\n     */\n    void update(float *value, float threshold)\n    {\n        if(flt_down == NULL) {\n            flt_down = new FilterDownPP(value, threshold);\n        } else {\n            flt_down->update(value, threshold);\n        }\n\n        if(flt_up == NULL) {\n            flt_up = new FilterUpPP(value, threshold);\n        } else {\n            flt_up->update(value, threshold);\n        }\n    }\n\n    /**\n     * @brief process computes push-pull.\n     * @param img\n     * @param imgOut\n     * @return\n     */\n    Image *Process(Image *imgIn, Image *imgOut)\n    {\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = imgIn->clone();\n        } else {\n            *imgOut = *imgIn;\n        }\n\n        Image *work = imgOut;\n\n        if(stack.empty()) { //create the pyramid: Pull\n            stack.push_back(imgOut);\n\n            while(MIN(work->width, work->height) > 1) {\n                Image *tmp = flt_down->Process(Single(work), NULL);\n\n                if(tmp != NULL) {\n                    stack.push_back(tmp);\n                    work = tmp;\n                }\n            }\n        } else { //update previously created pyramid: Pull\n            int c = 1;\n            while(MIN(work->width, work->height) > 1) {\n                flt_down->Process(Double(work, stack[c]), stack[c]);\n                work = stack[c];\n                c++;\n            }\n        }\n\n        //sample from the pyramid (stack): Push\n        int n = int(stack.size()) - 2;\n\n        for(int i = n; i >= 0; i--) {\n            flt_up->Process(Double(stack[i + 1], stack[i]), stack[i]);\n        }\n\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param img\n     * @param imgOut\n     * @param value\n     * @return\n     */\n    static Image *execute(Image *img, Image *imgOut, float value)\n    {\n        PushPull pp;\n\n        float *tmp_value = new float[img->channels];\n        for(int i = 0; i < img->channels; i++) {\n            tmp_value[i] = value;\n        }\n\n        pp.update(tmp_value, 1e-4f);\n        imgOut = pp.Process(img, imgOut);\n\n        delete[] tmp_value;\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_PUSHPULL_HPP */\n\n"
  },
  {
    "path": "include/algorithms/pyramid.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_PYRAMID_HPP\n#define PIC_ALGORITHMS_PYRAMID_HPP\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../image_vec.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n#include \"../filtering/filter_sampler_2d.hpp\"\n#include \"../filtering/filter_sampler_2dsub.hpp\"\n#include \"../filtering/filter_sampler_2dadd.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The Pyramid class\n */\nclass Pyramid\n{\nprotected:\n    bool lapGauss, bCreated;\n    int limitLevel;\n\n    FilterGaussian2D *flt_gauss;\n    FilterSampler2D *flt_sampler;\n    FilterSampler2DSub *flt_sub;\n    FilterSampler2DAdd *flt_add;\n    std::vector< Filter* > filters;\n\n    ImageVec trackerRec, trackerUp;\n\n    /**\n     * @brief initFilters\n     */\n    void initFilters();\n\n    /**\n     * @brief create\n     * @param img\n     * @param width\n     * @param height\n     * @param channels\n     * @param lapGauss\n     * @param limitLevel\n     */\n    void create(Image *img, bool lapGauss, int limitLevel);\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        stdVectorClear<Image>(trackerUp);\n        stdVectorClear<Image>(trackerRec);\n        stdVectorClear<Image>(stack);\n        stdVectorClear<Filter>(filters);\n    }\n\npublic:\n\n    ImageVec stack;\n\n    /**\n     * @brief Pyramid\n     * @param img\n     * @param lapGauss is a boolean parameter. If it is true, a Laplacian pyramid\n     * will be created, otherwise a Gaussian one.\n     * @param limitLevel\n     */\n    Pyramid(Image *img, bool lapGauss, int limitLevel);\n\n    /**\n     * @brief Pyramid\n     * @param width\n     * @param height\n     * @param channels\n     * @param lapGauss is a boolean parameter. If it is true, a Laplacian pyramid\n     * will be created, otherwise a Gaussian one.\n     * @param limitLevel\n     */\n    Pyramid(int width, int height, int channels, bool lapGauss, int limitLevel);\n\n    ~Pyramid();\n\n    /**\n     * @brief setLapGauss\n     * @param lapGauss is a boolean parameter. If it is true, a Laplacian pyramid\n     * will be created, otherwise a Gaussian one.\n     */\n    void setLapGauss(bool lapGauss)\n    {\n        this->lapGauss = lapGauss;\n    }\n\n    /**\n     * @brief update recomputes the pyramid given a compatible image, img.\n     * @param img\n     */\n    void update(Image *img);\n\n    /**\n     * @brief SetValue\n     * @param value\n     */\n    void setValue(float value);\n\n    /**\n     * @brief mul is the mul operator ( *= ) between pyramids.\n     * @param pyr\n     */\n    void mul(const Pyramid *pyr);\n\n    /**\n     * @brief add is the add operator ( += ) between pyramids.\n     * @param pyr\n     */\n    void add(const Pyramid *pyr);\n\n    /**\n     * @brief reconstruct evaluates a Gaussian/Laplacian pyramid.\n     * @param imgOut\n     * @return\n     */\n    Image *reconstruct(Image *imgOut);\n\n    /**\n     * @brief blend\n     * @param pyr\n     * @param weight\n     */\n    void blend(Pyramid *pyr, Pyramid *weight);\n\n    /**\n     * @brief size\n     * @return\n     */\n    int size()\n    {\n        return int(stack.size());\n    }\n\n    /**\n     * @brief get\n     * @param index\n     * @return\n     */\n    Image *get(int index)\n    {\n        return stack[index % stack.size()];\n    }\n\n    /**\n     * @brief setNULL\n     */\n    void setNULL()\n    {\n        release();\n\n        flt_gauss = NULL;\n        flt_sampler = NULL;\n        flt_sub = NULL;\n        flt_add = NULL;\n\n        bCreated = false;\n    }\n};\n\nPIC_INLINE Pyramid::Pyramid(Image *img, bool lapGauss, int limitLevel = 1)\n{\n    setNULL();\n\n    create(img, lapGauss, limitLevel);\n}\n\nPIC_INLINE Pyramid::Pyramid(int width, int height, int channels, bool lapGauss, int limitLevel = 1)\n{\n    setNULL();\n\n    Image *img = new Image(1, width, height, channels);\n    *img = 0.0f;\n\n    create(img, lapGauss, limitLevel);\n\n    delete img;\n}\n\nPIC_INLINE Pyramid::~Pyramid()\n{\n    release();\n}\n\nPIC_INLINE void Pyramid::initFilters()\n{\n    if(!bCreated) {\n        flt_gauss = new FilterGaussian2D(1.0f);\n        filters.push_back(flt_gauss);\n\n        flt_sampler = new FilterSampler2D(0.5f);\n        filters.push_back(flt_sampler);\n\n        flt_sub = new FilterSampler2DSub(NULL);\n        filters.push_back(flt_sub);\n\n        flt_add = new FilterSampler2DAdd(NULL);\n        filters.push_back(flt_add);\n\n        bCreated = true;\n    }\n}\n\nPIC_INLINE void Pyramid::create(Image *img, bool lapGauss, int limitLevel = 1)\n{\n    if(img == NULL) {\n        return;\n    }\n\n    if(!img->isValid()) {\n        return;\n    }\n\n    limitLevel = MAX(limitLevel, 0);\n\n    this->limitLevel = limitLevel;\n    this->lapGauss  = lapGauss;\n\n    initFilters();\n\n    int levels = log2(MIN(img->width, img->height)) - limitLevel;\n\n    Image *tmpImg = img;\n    Image *tmpG = NULL;\n    Image *tmpD = NULL;\n\n    for(int i = 0; i < levels; i++) {\n        tmpG = flt_gauss->Process(Single(tmpImg), NULL);\n        tmpD = flt_sampler->Process(Single(tmpG), NULL);\n\n        if(lapGauss) { //Laplacian Pyramid\n            flt_sub->Process(Double(tmpImg, tmpD), tmpG);\n            stack.push_back(tmpG);\n        } else { //Gaussian Pyramid\n            *tmpG = *tmpImg;\n            stack.push_back(tmpG);\n        }\n\n        if(i < (levels - 1)) {\n            trackerUp.push_back(tmpD);\n        }\n\n        tmpImg = tmpD;\n    }\n\n    if(tmpD != NULL) {\n        stack.push_back(tmpD);\n    }\n\n#ifdef PIC_DEBUG\n    printf(\"Pyramid size: %zu\\n\", stack.size());\n#endif\n}\n\nPIC_INLINE void Pyramid::update(Image *img)\n{\n    if(img == NULL) {\n        return;\n    }\n\n    if(stack.empty() || !img->isValid()) {\n        return;\n    }\n\n    if(!stack[0]->isSimilarType(img)) {\n        return;\n    }\n\n    Image *tmpG = NULL;\n    Image *tmpD = NULL;\n    Image *tmpImg = img;\n\n    int levels = MAX(log2(MIN(img->width, img->height)) - limitLevel, 1);\n\n    for(int i = 0; i < levels; i++) {\n\n        tmpG = flt_gauss->Process(Single(tmpImg), stack[i]);\n\n        if(i == (levels - 1)) {\n            tmpD = flt_sampler->Process(Double(tmpG, stack[i + 1]), stack[i + 1]);\n        } else {\n            tmpD = flt_sampler->Process(Double(tmpG, trackerUp[i]), trackerUp[i]);\n        }\n\n        if(lapGauss) {\t//Laplacian Pyramid\n            flt_sub->Process(Double(tmpImg, tmpD), tmpG);\n        } else { //Gaussian Pyramid\n            *tmpG = *tmpImg;\n        }\n\n        tmpImg = tmpD;\n    }\n}\n\nPIC_INLINE Image *Pyramid::reconstruct(Image *imgOut = NULL)\n{\n    if(stack.size() < 2) {\n        return imgOut;\n    }\n\n    int n = int(stack.size()) - 1;\n    Image *tmp = stack[n];\n\n    if(trackerRec.empty()) {\n        for(int i = n; i >= 2; i--) {\n            Image *tmp2 = flt_add->Process(Double(stack[i - 1], tmp), NULL);\n            trackerRec.push_back(tmp2);\n            tmp = tmp2;\n        }\n    } else {\n        int c = 0;\n\n        for(int i = n; i >= 2; i--) {\n            flt_add->Process(Double(stack[i - 1], tmp), trackerRec[c]);\n            tmp = trackerRec[c];\n            c++;\n        }\n    }    \n\n    imgOut = flt_add->Process(Double(stack[0], tmp), imgOut);\n\n    return imgOut;\n}\n\nPIC_INLINE void Pyramid::setValue(float value)\n{\n    for(unsigned int i = 0; i < stack.size(); i++) {\n        *stack[i] = value;\n    }\n}\n\nPIC_INLINE void Pyramid::mul(const Pyramid *pyr)\n{\n    if(stack.size() != pyr->stack.size()) {\n        return;\n    }\n\n    for(unsigned int i = 0; i < stack.size(); i++) {\n        *stack[i] *= *pyr->stack[i];\n    }\n}\n\nPIC_INLINE void Pyramid::add(const Pyramid *pyr)\n{\n    if(stack.size() != pyr->stack.size()) {\n        return;\n    }\n\n    for(unsigned int i = 0; i < stack.size(); i++) {\n        *stack[i] += *pyr->stack[i];\n    }\n}\n\nPIC_INLINE void Pyramid::blend(Pyramid *pyr, Pyramid *weight)\n{\n    if(stack.size() != pyr->stack.size() ||\n       stack.size() != weight->stack.size()) {\n        return;\n    }\n\n    for(unsigned int i = 0; i < stack.size(); i++) {\n        stack[i]->blend(pyr->stack[i], weight->stack[i]);\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_PYRAMID_HPP */\n\n"
  },
  {
    "path": "include/algorithms/quadtree.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_QUADTREE_HPP\n#define PIC_ALGORITHMS_QUADTREE_HPP\n\n#include <set>\n\nnamespace pic {\n\n/**\n * @brief The Quadtree class\n */\nclass Quadtree\n{\nprotected:\n    bool leaf;\n    std::set<int> list;\n    Quadtree *children[4];\n\n    //bounding box\n    int bmax[2], bmin[2];\n\n    /**\n     * @brief findAux\n     * @param pos\n     * @param radius2\n     * @param out\n     */\n    void findAux(int *pos, int radius2, std::set<int> &out)\n    {\n        if(leaf) {\n            out.insert(list.begin(), list.end());\n        } else {\n            for(int i = 0; i < 4; i++) {\n                if(children[i] != NULL) {\n                    if(checkCircleBBox(children[i]->bmax, children[i]->bmin, pos, radius2)) {\n                        children[i]->findAux(pos, radius2, out);\n                    }\n                }\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief Quadtree\n     * @param bmax\n     * @param bmin\n     */\n    Quadtree(int *bmax, int *bmin)\n    {\n        for(int i = 0; i < 2; i++) {\n            this->bmax[i] = bmax[i];\n            this->bmin[i] = bmin[i];\n        }\n\n        leaf = false;\n\n        for(int i = 0; i < 4; i++) {\n            children[i] = NULL;\n        }\n    }\n\n    ~Quadtree()\n    {\n        for(int i = 0; i < 4; i++) {\n            delete children[i];\n        }\n    }\n\n    /**\n     * @brief checkPointBBox\n     * @param p\n     * @param bmin\n     * @param bmax\n     * @return\n     */\n    static bool checkPointBBox(int *p, int *bmin, int *bmax)\n    {\n        return((p[0] >= bmin[0])\n               && (p[1] >= bmin[1])\n               && (p[0] < bmax[0])\n               && (p[1] < bmax[1]));\n    }\n\n    /**\n     * @brief checkCircleBBox\n     * @param bmax\n     * @param bmin\n     * @param center\n     * @param radius2\n     * @return\n     */\n    static bool checkCircleBBox(int *bmax, int *bmin, int *center, int radius2)\n    {\n        int dmin = 0;\n\n        for(int i = 0; i < 2; i++) {\n            if(center[i] < bmin[i]) {\n                int tmp = center[i] - bmin[i];\n                dmin += tmp * tmp;\n            } else {\n                if(center[i] > bmax[i]) {\n                    int tmp = center[i] - bmax[i];\n                    dmin += tmp * tmp;\n                }\n            }\n        }\n\n        return (dmin <= radius2);\n    }\n\n    /**\n     * @brief getQuadrant\n     * @param bmax\n     * @param bmin\n     * @param pMax\n     * @param pMin\n     * @param i\n     */\n    static void getQuadrant(int *bmax, int *bmin, int *pMax, int *pMin, int i)\n    {\n        int half[2];\n\n        for(int j = 0; j < 2; j++) {\n            half[j] = (bmax[j] + bmin[j]);\n\n            if((half[j] % 2) == 0) {\n                half[j] = half[j] >> 1;\n            } else {\n                half[j] = (half[j] >> 1) + 1;\n            }\n        }\n\n        switch(i) {\n        case 0: {\n            pMin[0] = bmin[0];\n            pMin[1] = bmin[1];\n\n            pMax[0] = half[0];\n            pMax[1] = half[1];\n        }\n        break;\n\n        case 1: {\n            pMin[0] = half[0];\n            pMin[1] = bmin[1];\n\n            pMax[0] = bmax[0];\n            pMax[1] = half[1];\n        }\n        break;\n\n        case 2: {\n            pMin[0] = bmin[0];\n            pMin[1] = half[1];\n\n            pMax[0] = half[0];\n            pMax[1] = bmax[1];\n        }\n        break;\n\n        case 3: {\n            pMin[0] = half[0];\n            pMin[1] = half[1];\n\n            pMax[0] = bmax[0];\n            pMax[1] = bmax[1];\n        }\n        break;\n        }\n    }\n\n    /**\n     * @brief insert\n     * @param pos\n     * @param value\n     * @param MAX_OCTREE_LEVEL\n     * @param level\n     */\n    void insert(int *pos, int value, int MAX_OCTREE_LEVEL, int level = 0)\n    {\n        if(level == MAX_OCTREE_LEVEL) {\n            list.insert(value);\n            leaf = true;\n        } else {\n            int pMax[2], pMin[2];\n\n            for(int i = 0; i < 4; i++) {\n                getQuadrant(bmax, bmin, pMax, pMin, i);\n\n                if(checkPointBBox(pos, pMin, pMax)) {\n                    if(children[i] == NULL) {\n                        children[i] = new Quadtree(pMax, pMin);\n                    }\n\n                    children[i]->insert(pos, value, MAX_OCTREE_LEVEL, level + 1);\n                    break;\n                }\n            }\n        }\n    }\n\n    /**\n     * @brief find\n     * @param x\n     * @param y\n     * @param radius\n     * @param out\n     */\n    void find(float x, float y, float radius, std::set<int> &out)\n    {\n\n        int pos[2];\n        pos[0] = int(x);\n        pos[1] = int(y);\n        int radius2 = int(ceilf(radius * radius));\n\n        if(checkPointBBox(pos, bmin, bmax)) {\n            findAux(pos, radius2, out);\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_QUADTREE_HPP */\n\n"
  },
  {
    "path": "include/algorithms/radial_basis_function.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_RADIAL_BASIS_FUNCTION\n#define PIC_ALGORITHMS_RADIAL_BASIS_FUNCTION\n\n#include <math.h>\n\n#include \"../util/std_util.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The RadialBasisFunction class\n */\nclass RadialBasisFunction\n{\npublic:\n    float *centers, var;\n    int nDim, nCenters;\n\n    /**\n     * @brief RadialBasisFunction\n     */\n    RadialBasisFunction()\n    {\n        var = 0.0f;\n        centers = NULL;\n        nDim = 0;\n        nCenters = 0;\n    }\n\n    ~RadialBasisFunction()\n    {\n        this->centers = delete_vec_s(this->centers);\n    }\n\n    /**\n     * @brief update\n     * @param centers\n     * @param nCenters\n     * @param nDim\n     * @param var\n     */\n    void update(float *centers, int nCenters, int nDim, float var)\n    {\n        this->nDim = nDim;\n        this->nCenters = nCenters;\n        this->var = var;\n\n        if(centers != NULL) {\n            this->centers = delete_vec_s(this->centers);\n            this->centers = new float[nCenters * nDim];\n            memcpy(this->centers, centers, sizeof(float) * nCenters * nDim);\n        }\n    }\n\n    /**\n     * @brief eval\n     * @param value\n     * @return\n     */\n    float eval(float *value)\n    {\n        float ret = 0.0f;\n\n        float sigma_sq_2 = var * 2.0f;\n        for(int i = 0; i < nCenters; i++) {\n            int index_i = i * nDim;\n\n            float d_sq = 0.0f;\n            for(int j = 0; j < nDim; j++) {\n                int index_j = index_i + j;\n\n                float d_j = (centers[index_j] - value[j]);\n                d_sq += d_j * d_j;\n            }\n\n            ret += expf(-d_sq / sigma_sq_2);\n        }\n\n        return ret;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_RADIAL_BASIS_FUNCTIONS */\n\n"
  },
  {
    "path": "include/algorithms/region_border.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_REGION_BORDER_HPP\n#define PIC_ALGORITHMS_REGION_BORDER_HPP\n\n#include <set>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n\nnamespace pic {\n\n/**\n * @brief setBorder\n * @param img\n * @param coordsBorder\n * @return\n */\nPIC_INLINE std::set<int> *setBorder(Image *img, std::set<int> *coordsBorder)\n{\n    //second border\n    int ind, c, x, y;\n    std::set<int> *ret = new std::set<int>;\n    std::set<int>::iterator it;\n\n    for(it = coordsBorder->begin(); it != coordsBorder->end(); it++) {\n        ind = *it;\n        img->reverseAddress(ind, x, y);\n\n        c = img->getAddress(x + 1, y);\n\n        if(img->data[c] > 1.0f &&\n           coordsBorder->find(c) == coordsBorder->end()) {\n            ret->insert(c);\n        }\n\n        c = img->getAddress(x - 1, y);\n\n        if(img->data[c] > 1.0f &&\n           coordsBorder->find(c) == coordsBorder->end()) {\n            ret->insert(c);\n        }\n\n        c = img->getAddress(x, y + 1);\n\n        if(img->data[c] > 1.0f &&\n           coordsBorder->find(c) == coordsBorder->end()) {\n            ret->insert(c);\n        }\n\n        c = img->getAddress(x, y - 1);\n\n        if(img->data[c] > 1.0f &&\n           coordsBorder->find(c) == coordsBorder->end()) {\n            ret->insert(c);\n        }\n    }\n\n    return ret;\n}\n\n/**\n * @brief setBorderNth\n * @param img\n * @param coordsBorder\n * @param widthBorder\n * @return\n */\nPIC_INLINE std::set<int> *setBorderNth(Image *img, std::set<int> *coordsBorder,\n                            int widthBorder)\n{\n    std::set<int> *ret = new std::set<int>;\n\n    //insert initial border\n    ret->insert(coordsBorder->begin(), coordsBorder->end());\n\n    for(int i = 0; i < widthBorder; i++) {\n        std::set<int> *tmpBorder = setBorder(img, ret);\n        ret->insert(tmpBorder->begin(), tmpBorder->end());\n    }\n\n    return ret;\n}\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_REGION_BORDER_HPP */\n\n"
  },
  {
    "path": "include/algorithms/segmentation_tmo_approx.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_SEGMENTATION_TMO_APPROX_HPP\n#define PIC_ALGORITHMS_SEGMENTATION_TMO_APPROX_HPP\n\n#include \"../util/array.hpp\"\n#include \"../util/std_util.hpp\"\n\n#include \"../algorithms/superpixels_slic.hpp\"\n\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_iterative.hpp\"\n#include \"../filtering/filter_bilateral_2ds.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The Segmentation class\n */\nclass Segmentation\n{\nprotected:\n    FilterIterative *fltIt;\n    FilterBilateral2DS *fltBil;\n    Image *L, *imgIn_flt;\n\n    float perCent;\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param bBilateral\n     * @param nSuperPixels\n     * @return\n     */\n    Image *ProcessAux(Image *imgIn, bool bBilateral, int nSuperPixels = 4096)\n    {\n        if(bBilateral) {\n            float minVal, maxVal;\n            imgIn->getMinVal(NULL, &minVal);\n            imgIn->getMaxVal(NULL, &maxVal);\n\n            float nLevels = log10f(maxVal) - log10f(minVal) + 1.0f;\n            float nLayer = ((maxVal - minVal) / nLevels) / 4.0f;\n            float area = imgIn->widthf * imgIn->heightf * perCent;\n            int iterations = MAX(int(sqrtf(area)) / 2, 1);\n\n            //create filters\n            if(fltIt == NULL) {\n                fltBil = new FilterBilateral2DS(1.0f, nLayer);\n                fltIt  = new FilterIterative(fltBil, iterations);\n            }\n\n    #ifdef PIC_DEBUG\n            printf(\"Layer: %f iterations: %d\\n\", nLayer, iterations);\n    #endif\n            //Iterative bilateral filtering\n            Image *imgOut = fltIt->Process(Single(imgIn), imgIn_flt);\n\n            return imgOut;\n        } else {\n            Slic sp;\n            sp.execute(imgIn, nSuperPixels);\n            Image *imgOut = sp.getMeanImage(NULL);\n            return imgOut;\n        }\n    }\n\npublic:\n\n    /**\n     * @brief Segmentation\n     */\n    Segmentation()\n    {\n        fltBil = NULL;\n        fltIt  = NULL;\n        L = NULL;\n        imgIn_flt = NULL;\n\n        perCent  = 0.005f;\n    }\n\n    ~Segmentation()\n    {\n        delete_s(imgIn_flt);\n        delete_s(L);\n        delete_s(fltIt);\n        delete_s(fltBil);\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(Image *imgIn, Image *imgOut)\n    {\n        if(imgIn == NULL) {\n            return NULL;\n        }\n\n        if(!imgIn->isValid() || (imgIn->channels != 3)) {\n            return NULL;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = new Image(1, imgIn->width, imgIn->height, 1);\n        }\n\n        //compute luminance\n        FilterLuminance::execute(imgIn, imgOut, LT_CIE_LUMINANCE);\n\n        Image *imgIn_flt = ProcessAux(imgIn, true, 4096);\n\n        //threshold\n        float *data = imgIn_flt->data;\n        int channels = imgIn_flt->channels;\n\n        float *weights = FilterLuminance::computeWeights(LT_CIE_LUMINANCE, channels, NULL);\n\n        #pragma omp parallel for\n        for(int i = 0; i < imgIn_flt->size(); i += channels) {\n            float L = Arrayf::dot(weights, &data[i], channels) + 1e-7f;\n            imgOut->data[i / 3] = floorf(log10f(L));\n        }\n\n        delete_vec_s<float>(weights);\n\n        #ifdef PIC_DEBUG\n            imgOut->Write(\"Segmentation.pfm\");\n        #endif\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_SEGMENTATION_TMO_APPROX_HPP */\n\n"
  },
  {
    "path": "include/algorithms/sub_sample_stack.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_SUB_SAMPLE_STACK_HPP\n#define PIC_ALGORITHMS_SUB_SAMPLE_STACK_HPP\n\n#include \"../util/math.hpp\"\n#include \"../util/std_util.hpp\"\n\n#include \"../image.hpp\"\n#include \"../image_vec.hpp\"\n#include \"../point_samplers/sampler_random.hpp\"\n#include \"../histogram.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The SubSampleStack class\n */\nclass SubSampleStack\n{\nprotected:\n\n    /**\n    * \\brief sampleGrossberg creates a low resolution version of the stack using Grossberg and Nayar sampling.\n    * \\param stack is a stack of Image* at different exposures\n    */\n    void sampleGrossberg(ImageVec &stack)\n    {\n        #ifdef PIC_DEBUG\n            printf(\"Computing histograms...\");\n        #endif\n\n        Histogram *h = new Histogram[exposures * channels];\n\n        int c = 0;\n        for(int j = 0; j < channels; j++) {\n            for(int i = 0; i < exposures; i++) {\n                h[c].calculate(stack[i], VS_LDR, 256, NULL, j);\n                h[c].cumulativef(true);\n                c++;\n            }\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"Ok\\n\");\n        #endif\n\n        total = this->nSamples * this->channels * this->exposures;\n        samples = new int[total];\n\n        #ifdef PIC_DEBUG\n            printf(\"Sampling...\");\n        #endif\n\n        float div = float(nSamples - 1);\n        c = 0;\n        for(int k = 0; k < channels; k++) {\n            for(int i = 0; i < nSamples; i++) {\n\n                float u = float(i) / div;\n\n                for(int j = 0; j < exposures; j++) {\n\n                    int ind = k * exposures + j;\n\n                    float *bin_c = h[ind].getCumulativef();\n\n                    float *ptr = std::upper_bound(&bin_c[0], &bin_c[0]+256, u);\n\n                    samples[c] = CLAMPi((int)(ptr - bin_c), 0, 255);\n                    c++;\n                }\n            }\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"Ok\\n\");\n        #endif\n\n        delete[] h;\n    }\n\n    /**\n     * @brief sampleSpatial creates a low resolution version of the stack.\n     * @param stack is a stack of Image* at different exposures\n     * @param sub_type\n     */\n    void sampleSpatial(ImageVec &stack, SAMPLER_TYPE sub_type = ST_MONTECARLO_S)\n    {\n        int width    = stack[0]->width;\n        int height   = stack[0]->height;\n\n        Vec<2, int> vec(width, height);\n\n        RandomSampler<2> *sampler = new RandomSampler<2>(sub_type, vec, nSamples, 1, 0);\n\n        #ifdef PIC_DEBUG\n            int oldNSamples = nSamples;\n        #endif\n\n        this->nSamples = sampler->getSamplesPerLevel(0);\n\n        total = this->nSamples * this->channels * this->exposures;\n        samples = new int[total];\n\n        #ifdef PIC_DEBUG\n            printf(\"--subSample samples: %d \\t \\t old samples: %d\\n\", nSamples, oldNSamples);\n        #endif\n\n        int c = 0;\n\n        for(int k = 0; k < channels; k++) {\n            for(int i = 0; i < nSamples; i++) {\n\n                int x, y;\n                sampler->getSampleAt(0, i, x, y);\n\n                for(int j = 0; j < exposures; j++) {\n                    float fetched = (*stack[j])(x, y)[k];\n                    float tmp = lround(fetched * 255.0f);\n                    samples[c] = CLAMPi(int(tmp), 0, 255);\n                    c++;\n                }\n            }\n        }\n\n        delete sampler;\n    }\n\n    int exposures;\n    int channels;\n    int nSamples;\n    int total;\n    int *samples;\n\npublic:\n    \n    /**\n     * @brief SubSampleStack\n     */\n    SubSampleStack()\n    {\n        total = 0;\n        exposures = 0;\n        channels = 0;\n        nSamples = 0;\n        samples = NULL;\n    }\n\n    ~SubSampleStack()\n    {\n        release();\n    }\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        exposures = 0;\n        channels = 0;\n        nSamples = 0;\n        total = 0;\n\n        samples = delete_s(samples);\n    }\n\n    /**\n     * @brief execute\n     * @param stack\n     * @param nSamples output number of samples\n     * @param bSpatial\n     * @param sub_type\n     */\n    void execute(ImageVec &stack, int nSamples, float alpha = 0.f, bool bSpatial = false, SAMPLER_TYPE sub_type = ST_MONTECARLO_S)\n    {\n        release();\n\n        if(!((stack.size() > 1 && (nSamples > 1)))) {\n            return;\n        }\n\n        this->nSamples = nSamples;\n        this->channels  = stack[0]->channels;\n        this->exposures = int(stack.size());\n\n        if(bSpatial) {\n            sampleSpatial(stack, sub_type);\n        } else {\n            sampleGrossberg(stack);\n        }\n\n        if (alpha < 0.f || alpha > 1.f)\n            alpha = 0.f;\n        else if (alpha > 0.5f)\n            alpha = 1.f - alpha;\n\n        if(alpha > 0.f && alpha <= 0.5f) {\n            float t_min_f = alpha;\n            float t_max_f = 1.0f - t_min_f;\n\n            int t_min = int(t_min_f * 255.0f);\n            int t_max = int(t_max_f * 255.0f);\n\n            for(int i = 0; i < total; i++) {\n                if(samples[i] < t_min || samples[i] > t_max) {\n                    samples[i] = -1;\n                }\n            }\n        }\n    }\n\n    /**\n     * @brief get\n     * @return\n     */\n    int *get()\n    {\n        return samples;\n    }\n\n    /**\n     * @brief getNSamples\n     * @return\n     */\n    int getNSamples() const\n    {\n        return nSamples;\n    }\n\n    /**\n     * @brief print\n     */\n    void print()\n    {\n        for(int i = 0; i < total; i++) {\n           printf(\"%d\\n\", samples[i]);\n        }\n\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_SUB_SAMPLE_STACK_HPP */\n\n"
  },
  {
    "path": "include/algorithms/superpixels_oracle.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_SUPERPIXELS_ORACLE_HPP\n#define PIC_ALGORITHMS_SUPERPIXELS_ORACLE_HPP\n\n#include <vector>\n#include <set>\n\n#include \"../algorithms/quadtree.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The SuperPixelsOracle class\n */\nclass SuperPixelsOracle\n{\nprotected:\n\n    int\t\t\t\t\t*buffer;\n    int\t\t\t\t\twidth, height;\n    std::vector<int>\tunique;\n\n    Quadtree\t\t\t*root;\n\n    /**\n     * @brief init\n     */\n    void init()\n    {\n        int size = width * height;\n\n        std::set<int> keys;\n\n        for(int i = 0; i < size; i++) {\n            keys.insert(buffer[i]);\n        }\n\n        unique.insert(unique.begin(), keys.begin(), keys.end());\n\n        int bmin[2], bmax[2];\n        bmin[0] = 0;\n        bmin[1] = 0;\n\n        bmax[0] = width;\n        bmax[1] = height;\n\n        int tmp_max_level = width > height ? height : width;\n        int max_level = int(ceilf(logf(float(tmp_max_level)) / logf(2.0f)));\n\n        printf(\"Max Level: %d\\n\", max_level);\n        root = new Quadtree(bmax, bmin);\n\n        for(int i = 0; i < height; i++) {\n            int pos[2];\n            int ind = i * width;\n            pos[1] = i;\n\n            for(int j = 0; j < width; j++) {\n                pos[0] = j;\n                root->insert(pos, buffer[ind + j], max_level);\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief SuperPixelsOracle\n     * @param buffer\n     * @param width\n     * @param height\n     */\n    SuperPixelsOracle(int *buffer, int width, int height)\n    {\n        if((buffer == NULL) || (width < 1) || (height < 1)) {\n            return;\n        }\n\n        this->buffer = buffer;\n        this->width  = width;\n        this->height = height;\n        init();\n    }\n\n    ~SuperPixelsOracle()\n    {\n        delete root;\n    }\n\n    /**\n     * @brief query\n     * @param x\n     * @param y\n     * @param r\n     * @param out\n     */\n    void query(float x, float y, float r, std::set<int> &out)\n    {\n        root->find(x, y, r, out);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_SUPERPIXELS_ORACLE_HPP */\n\n"
  },
  {
    "path": "include/algorithms/superpixels_slic.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_SUPERPIXELS_SLIC_HPP\n#define PIC_ALGORITHMS_SUPERPIXELS_SLIC_HPP\n\n#include \"../image.hpp\"\n#include \"../filtering/filter_laplacian.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The SlicoCenter struct\n */\nstruct SlicoCenter {\n    float\t\t\t*value;\n    unsigned int\tx, y;\n};\n\n/**\n * @brief The Slic class\n */\nclass Slic\n{\nprotected:\n\n    int             nSuperPixels;\n    Image           *labels_distance, *lap_img;\n    SlicoCenter     *centers;\n    unsigned int    *prevX, *prevY, *counter;\n    float           *col_values, *mPixel;\n    int             width, height, channels;\n\n    /**\n     * @brief distanceC\n     * @param a1\n     * @param a2\n     * @param channels\n     * @return\n     */\n    inline float distanceC(float *a1, float *a2, int channels)\n    {\n        float acc = 0.0f;\n\n        for(int i = 0; i < channels; i++) {\n            float tmp = (a1[i] - a2[i]);\n            acc += tmp * tmp;\n        }\n\n        return acc;\n    }\n\n    /**\n     * @brief distanceS\n     * @param x1\n     * @param y1\n     * @param x2\n     * @param y2\n     * @return\n     */\n    inline int distanceS(int x1, int y1, int x2, int y2)\n    {\n        int tx = x1 - x2;\n        int ty = y1 - y2;\n        return tx * tx + ty * ty;\n    }\n\n    /**\n     * @brief pass\n     * @param img\n     * @param S\n     * @return\n     */\n    bool pass(Image *img, int S)\n    {\n        float Sf = float(S);\n        float Sf2 = Sf * Sf;\n\n        for(int i = 0; i < nSuperPixels; i++) {\n            prevX[i] = centers[i].x;\n            prevY[i] = centers[i].y;\n        }\n\n        //for each cluster\n        for(int i = 0; i < nSuperPixels; i++) {\n            float i_f = float(i);\n\n            //Search in Sx2 radius\n            for(int j = -S; j < S; j++) {\n                int vY = centers[i].y + j;\n\n                for(int k = -S; k < S; k++) {\n                    int vX = centers[i].x + k;\n\n                    float *pixel = (*img)(vX, vY);\n                    float *l_d   = (*labels_distance)(vX, vY);\n\n                    float dS = float(distanceS(vX, vY, centers[i].x, centers[i].y)) / Sf2;\n                    float dC = distanceC(pixel, centers[i].value, img->channels) / mPixel[i];\n                    float D = dC + dS;\n\n                    if(D < l_d[1]) {\n                        l_d[0] = i_f;\n                        l_d[1] = D;\n                        l_d[2] = dC;\n                    }\n                }\n            }\n        }\n\n        //update mPixel\n        for(int i = 0; i < labels_distance->size(); i += labels_distance->channels) {\n            int label = int(labels_distance->data[i]);\n\n            if(label < 0) {\n                continue;\n            }\n\n            if(mPixel[label] < labels_distance->data[i + 2]) {\n                mPixel[label] = labels_distance->data[i + 2];\n            }\n        }\n\n        //update clusters\n        for(int i = 0; i < nSuperPixels; i++) {\n            centers[i].x = 0;\n            centers[i].y = 0;\n            counter[i]   = 0;\n\n            int ind = i * img->channels;\n\n            for(int j = 0; j < img->channels; j++) {\n                col_values[ind + j] = 0.0f;\n            }\n        }\n\n        for(int j = 0; j < img->height; j++) {\n            for(int k = 0; k < img->width; k++) {\n                float *l_d = (*labels_distance)(k, j);\n                int label = int(l_d[0]);\n\n                if(label > -1) {\n                    centers[label].x += k;\n                    centers[label].y += j;\n                    counter[label]++;\n\n                    int ind = label * img->channels;\n                    float *col = (*img)(k, j);\n\n                    for(int p = 0; p < img->channels; p++) {\n                        col_values[ind + p] += col[p];\n                    }\n                }\n            }\n        }\n\n        float E = 0.0f;\n\n        for(int i = 0; i < nSuperPixels; i++) {\n            if(counter[i] <= 0) {\n                continue;\n            }\n\n            centers[i].x /= counter[i];\n            centers[i].y /= counter[i];\n            int ind = i * img->channels;\n\n            for(int j = 0; j < img->channels; j++) {\n                centers[i].value[j] = col_values[ind + j] / float(counter[i]);\n            }\n\n            //Error\n            int tx = prevX[i] - centers[i].x;\n            int ty = prevY[i] - centers[i].y;\n            float tmpErr = sqrtf(float(tx * tx + ty * ty));\n            E += tmpErr;\n        }\n\n        return (E > (0.0001f * float(nSuperPixels)));\n    }\n\n\n\n    /**\n     * @brief allocate\n     * @param nSuperPixels\n     * @param channels\n     */\n    void allocate(int nSuperPixels, int channels)\n    {\n\n        this->nSuperPixels = nSuperPixels;\n\n        release();\n\n        centers\t\t= new SlicoCenter[nSuperPixels];\n        prevX\t\t= new unsigned int [nSuperPixels];\n        prevY\t\t= new unsigned int [nSuperPixels];\n        counter\t\t= new unsigned int [nSuperPixels];\n        mPixel\t\t= new float [nSuperPixels];\n        col_values\t= new float [nSuperPixels * channels];\n    }\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        delete lap_img;\n        delete labels_distance;\n        delete[] centers;\n        delete[] prevX;\n        delete[] prevY;\n        delete[] counter;\n        delete[] col_values;\n        delete[] mPixel;\n    }\n\npublic:\n\n    /**\n     * @brief Slic\n     */\n    Slic()\n    {\n        lap_img = NULL;\n        labels_distance = NULL;\n        centers = NULL;\n        prevX = NULL;\n        prevY = NULL;\n        counter = NULL;\n        col_values = NULL;\n        mPixel = NULL;\n    }\n\n    /**\n     * @brief Slic\n     * @param img\n     * @param nSuperPixels\n     */\n    Slic(Image *img, int nSuperPixels = 64)\n    {\n        lap_img = NULL;\n        labels_distance = NULL;\n        centers = NULL;\n        prevX = NULL;\n        prevY = NULL;\n        counter = NULL;\n        col_values = NULL;\n        mPixel = NULL;\n\n        execute(img, nSuperPixels);\n    }\n\n    ~Slic()\n    {\n        release();\n    }\n    \n    /**\n     * @brief execute\n     * @param img\n     * @param nSuperPixels\n     */\n    void execute(Image *img, int nSuperPixels = 64)\n    {\n        if(img == NULL) {\n            return;\n        }\n\n        //Init\n        int S = int(sqrtf(img->widthf * img->heightf) / float(nSuperPixels));\n\n        if(S < 1) {\n            return;\n        }\n\n        nSuperPixels = (img->width / S) * (img->height / S);\n\n        allocate(nSuperPixels, img->channels);\n\n        if(labels_distance == NULL) {\n            labels_distance = new Image(1, img->width, img->height, 3);\n        }\n\n        for(int i = 0; i < labels_distance->size(); i += labels_distance->channels) {\n            labels_distance->data[i    ] = -1.0f;\n            labels_distance->data[i + 1] = FLT_MAX;\n            labels_distance->data[i + 2] = FLT_MAX;\n        }\n\n        width = img->width;\n        height = img->height;\n        channels = img->channels;\n\n        FilterLaplacian lap;\n        lap_img = lap.Process(Single(img), lap_img);\n\n        for(int i = 0; i < nSuperPixels; i++) {\n            mPixel[i] = 0.35f * 0.35f;    //10.0f*10.0f;\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"nSuperPixels: %d S: %d\\n\", nSuperPixels, S);\n        #endif\n        \n        int ind = 0;\n        int S_half = S >> 1;\n\n        for(int i = S_half; i < (img->height - S_half + 1); i += S) {\n            for(int j = S_half; j < (img->width - S_half + 1); j += S) {\n\n                float bValue = FLT_MAX;\n                int bX, bY;\n\n                for(int y = -1; y <= 1; y++) {\n                    for(int x = -1; x <= 1; x++) {\n                        int ix = (j + x);\n                        int iy = (i + y);\n                        float *data = (*lap_img)(ix, iy);\n\n                        float acc = 0.0f;\n\n                        for(int c = 0; c < img->channels; c++) {\n                            acc += fabsf(data[c]);\n                        }\n\n                        if(acc < bValue) {\n                            bValue = acc;\n                            bX = ix;\n                            bY = iy;\n                        }\n                    }\n                }\n\n                centers[ind].x = bX;\n                centers[ind].y = bY;\n                centers[ind].value = new float [img->channels];\n\n                BBox box(centers[ind].x - S_half, centers[ind].x + S_half + 1,\n                         centers[ind].y - S_half, centers[ind].y + S_half + 1);\n\n                img->getMeanVal(&box, centers[ind].value);\n                ind++;\n            }\n        }\n\n        //For each pass\n        int iter = 0;\n        bool bCheck = true;\n\n        while(bCheck) {\n            bCheck = pass(img, S);\n\n            if(!bCheck && iter <= 10) {\n                bCheck = true;\n            }\n\n            iter++;\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"Iterations: %d\\n\", iter);\n        #endif\n    }\n\n    /**\n     * @brief getLabelsBuffer\n     * @param out\n     * @return\n     */\n    int *getLabelsBuffer(int *out = NULL)\n    {\n        if(labels_distance == NULL) {\n            return NULL;\n        }\n\n        int size = labels_distance->width * labels_distance->height;\n\n        if(size < 1) {\n            return NULL;\n        }\n\n        if(out == NULL) {\n            out = new int[size];\n        }\n\n        for(int i = 0; i < size; i++) {\n            out[i] = int(labels_distance->data[i << 1]);\n        }\n\n        return out;\n    }\n\n    /**\n     * @brief getMeanImage\n     * @param imgOut\n     * @return\n     */\n    Image *getMeanImage(Image *imgOut)\n    {\n        if(imgOut == NULL) {\n            imgOut = new Image(1, width, height, channels);\n        }\n\n        for(int i = 0; i < height; i++) {\n            for(int j = 0; j < width; j++) {\n                float *pixel = (*imgOut)(j, i);\n                float *l_d   = (*labels_distance)(j, i);\n\n                int label = int(l_d[0]);\n\n                if(label > -1) {\n                    for(int k = 0; k < channels; k++) {\n                        pixel[k] = centers[label].value[k];\n                    }\n                }\n            }\n        }\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_SUPERPIXELS_SLIC_HPP */\n\n"
  },
  {
    "path": "include/algorithms/weight_function.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_WEIGHT_FUNCTION_HPP\n#define PIC_ALGORITHMS_WEIGHT_FUNCTION_HPP\n\n#include \"../base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The CRF_WEIGHT enum\n */\nenum CRF_WEIGHT {CW_ALL, CW_IDENTITY, CW_REVERSE, CW_HAT, CW_DEB97, CW_DEB97p01, CW_ROBERTSON};\n\n/**\n * @brief weightFunction computes weight functions for x in [0,1].\n * @param x is an input value in [0, 1].\n * @param type is the type of the function.\n * @return It returns a weight for x.\n */\nPIC_INLINE float weightFunction(float x, CRF_WEIGHT type)\n{\n    switch(type) {\n\n    case CW_ROBERTSON: {\n        // w(x) = exp(-4*(x*255 - 127.5)^2/(127.5)^2) = exp(-16.0 * (x - 0.5)^2)\n        // (according to the paper it should be scaled and shifted s.t. w(0) = w(255) = 0 and w(127.5) = 1)\n        static const double shift    = exp(-4);\n        static const double scaleDiv = (1.0 - shift);\n        const double t = x - 0.5;\n        return float((exp(-16.0 * (t * t) ) - shift) / scaleDiv);\n    }\n    break;\n\n    case CW_HAT: {\n        float val = (2.0f * x - 1.0f);\n        float val_squared = val * val;\n        float val_quartic = val_squared * val_squared;\n        return (1.0f - val_quartic * val_quartic * val_quartic);\n    }\n    break;\n            \n    case CW_IDENTITY:\n    {\n        return x;\n    }\n    break;\n\n    case CW_REVERSE:\n    {\n        return 1.0f - x;\n    }\n    break;\n            \n    case CW_DEB97: {\n        static const float Zmin = 0.0f;\n        static const float Zmax = 1.0f;\n        static const float tr = (Zmin + Zmax) / 2.0f;\n\n        if(x <= tr) {\n            return x - Zmin;\n        } else {\n            return Zmax - x;\n        }\n    }\n    break;\n\n    case CW_DEB97p01: {\n        static const float Zmin = 0.01f;\n        static const float Zmax = 0.99f;\n        float tr = (Zmin + Zmax) / 2.0f;\n\n        if(x <= tr) {\n            return CLAMPi(x - Zmin, 0.0f, 1.0f);\n        } else {\n            return CLAMPi(Zmax - x, 0.0f, 1.0f);\n        }\n    }\n    break;\n\n    default: {\n        return 1.0f;\n    }\n    break;\n    }\n\n    return 1.0f;\n}\n\n} // end namespace pic\n\n#endif /* PIC_ALGORITHMS_WEIGHT_FUNCTION_HPP */\n\n"
  },
  {
    "path": "include/algorithms.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_ALGORITHMS_HPP\n#define PIC_ALGORITHMS_HPP\n\n#include \"algorithms/compute_divergence.hpp\"\n#include \"algorithms/nelder_mead_opt_gray_match.hpp\"\n#include \"algorithms/camera_response_function.hpp\"\n#include \"algorithms/hdr_merger.hpp\"\n#include \"algorithms/connected_components.hpp\"\n#include \"algorithms/discrete_cosine_transform.hpp\"\n#include \"algorithms/poisson_filling.hpp\"\n#include \"algorithms/poisson_solver.hpp\"\n#include \"algorithms/poisson_image_editing.hpp\"\n#include \"algorithms/pushpull.hpp\"\n#include \"algorithms/pyramid.hpp\"\n#include \"algorithms/multi_resolution_operator.hpp\"\n#include \"algorithms/quadtree.hpp\"\n#include \"algorithms/region_border.hpp\"\n#include \"algorithms/superpixels_oracle.hpp\"\n#include \"algorithms/superpixels_slic.hpp\"\n#include \"algorithms/color_to_gray.hpp\"\n#include \"algorithms/histogram_matching.hpp\"\n#include \"algorithms/bilateral_separation.hpp\"\n#include \"algorithms/grow_cut.hpp\"\n#include \"algorithms/live_wire.hpp\"\n#include \"algorithms/radial_basis_function.hpp\"\n#include \"algorithms/color_classification.hpp\"\n#include \"algorithms/binarization.hpp\"\n#include \"algorithms/segmentation_tmo_approx.hpp\"\n#include \"algorithms/lischinski_minimization.hpp\"\n\n#endif /* PIC_ALGORITHMS_HPP */\n\n"
  },
  {
    "path": "include/base.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_BASE_HPP\n#define PIC_BASE_HPP\n\nnamespace pic {\n\ntypedef unsigned int uint;\ntypedef unsigned char uchar;\n\ntypedef uint* puint;\ntypedef uchar* puchar;\n\n\n#ifndef PIC_DISABLE_INLINING\n\n#ifndef PIC_INLINE\n    #define PIC_INLINE inline\n#endif\n\n#else\n\n#ifndef PIC_INLINE\n    #define PIC_INLINE\n#endif\n\n#endif /* PIC_ENABLE_INLINING */\n\n}\n\n#endif /* PIC_BASE_HPP */\n\n"
  },
  {
    "path": "include/colors/color.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_HPP\n#define PIC_COLORS_COLOR_HPP\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n#include \"../util/vec.hpp\"\n\nnamespace pic {\n\n/**\n * @brief scaleTau\n * @param in\n * @param tau\n */\ntemplate<uint N>\nvoid scaleTau(Vec<N, float> &in, const Vec<N, float> &tau)\n{\n    for (int i = 0; i < N; i++) {\n        in.data[i] *= expf(-tau.data[i]);\n    }\n}\n\n/**\n * @brief scaleTau\n * @param in\n * @param sigma_t\n * @param tau\n */\ntemplate<uint N>\nvoid scaleTau(Vec<N, float> &in, const Vec<N, float> &sigma_t, const Vec<N, float> &tau)\n{\n    for (int i = 0; i < N; i++) {\n        in.data[i] *= expf(-tau.data[i] * sigma_t.data[i]);\n    }\n}\n\n/**\n * @brief scaleTau\n * @param in\n * @param sigma_t\n * @param t\n */\ntemplate<uint N>\nvoid scaleTau(Vec<N, float> &in, const Vec<N, float> &sigma_t, float t)\n{\n    for (int i = 0; i < N; i++) {\n        in.data[i] *= expf(-sigma_t.data[i] * t);\n    }\n}\n\n/**\n * @brief colorLuminance\n * @param in\n * @return\n */\ntemplate<uint N>\nfloat colorLuminance(Vec<N, float> &in)\n{\n    return  0.213f * in.data[0] +\n            0.715f * in.data[1] +\n            0.072f * in.data[2];\n}\n\n/**\n * @brief colorSaturate\n * @param in\n */\ntemplate<uint N>\nvoid colorSaturate(Vec<N, float> &in)\n{\n    for (int i = 0; i < N; i++) {\n        in.data[i] = in.data[i] * 0.5f + 0.5f;\n    }\n}\n\n/**\n * @brief importanceSampling\n * @param in\n * @param e\n * @param channel\n * @param pdf\n */\ntemplate<uint N>\nvoid importanceSampling(Vec<N, float> &in, float e, int &channel, float &pdf)\n{\n    float sum = 0.0f;\n    for(uint i = 0; i < N; i++) {\n        sum += in.data[i];\n    }\n\n    if(sum > 0.0f) {\n        float CDF[N];\n        CDF[0] = in.data[0] / sum;\n        for(uint i = 1; i < (N - 1); i++) {\n            CDF[i] = (CDF[i - 1] + in.data[i]) / sum;\n        }\n        CDF[N - 1] = 1.0f; // sanity check\n\n        for(uint i = 0; i < N; i++) {\n            if(e <= CDF[i]) {\n                channel = i;\n                pdf = in.data[i] / sum;\n            }\n        }\n    } else {\n        channel = int(e * float(N - 1));\n        pdf = 1.0f / float(N);\n    }\n}\n\n/**\n * @brief convertToLDR\n * @param in\n * @param exposure\n * @param gammaCor\n * @param maxVal\n * @return\n */\ntemplate<uint N>\nVec<N, float> convertToLDR(Vec<N, float> &in, float exposure = 1.0f, float gammaCor = 2.2f, float maxVal = 255.0f)\n{\n    Vec<N, float> ret = in.clone();\n    ret *= exposure;\n\n    vecGamma(ret, 1.0f / gammaCor);\n    ret *= maxVal;\n    ret.clamp(0.0f, maxVal);\n\n    return ret;\n}\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_HPP */\n\n"
  },
  {
    "path": "include/colors/color_3.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_3_HPP\n#define PIC_COLORS_COLOR_3_HPP\n\n//typedef float float;\n#include \"../colors/color.hpp\"\n\nnamespace pic {\n\n/**\n * @brief Color3\n */\ntypedef Vec<3, float> Color3;\n\n//basic colors\nconst Color3 RED    = Color3(1.0f, 0.0f, 0.0f);\nconst Color3 GREEN  = Color3(0.0f, 1.0f, 0.0f);\nconst Color3 BLUE   = Color3(0.0f, 0.0f, 1.0f);\n\nconst Color3 BLACK  = Color3(0.0f, 0.0f, 0.0f);\nconst Color3 WHITE  = Color3(1.0f, 1.0f, 1.0f);\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_3_HPP */\n\n"
  },
  {
    "path": "include/colors/color_conv.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_HPP\n#define PIC_COLORS_COLOR_CONV_HPP\n\n#include \"../util/matrix_3_x_3.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConv class\n */\nclass ColorConv\n{\nprotected:\n    bool linear;\n\n    float mtx[9], mtx_inv[9];\n\n    /**\n     * @brief computeInverse\n     */\n    void computeInverse()\n    {\n        Matrix3x3 tmp;\n        tmp.set(mtx);\n\n        Matrix3x3 tmp_inv;\n        tmp.inverse(&tmp_inv);\n\n        memcpy(mtx_inv, tmp_inv.data, 9 * sizeof(float));\n    }\n\npublic:\n\n    /**\n     * @brief ColorConv\n     */\n    ColorConv()\n    {\n        linear = true;\n    }\n\n    /**\n    * @brief direct converts from a color space to another one.\n    * \\param colIn a pointer to the input color to be converted.\n    * \\param colOut a pointer to the output color.\n    */\n    virtual void direct(float *colIn, float *colOut)\n    {\n        apply(mtx, colIn, colOut);\n    }\n\n    /**\n    * @brief inverse is the inverse of direct.\n    * \\param colIn a pointer to the input color to be converted.\n    * \\param colOut a pointer to the output color.\n    */\n    virtual void inverse(float *colIn, float *colOut)\n    {\n        apply(mtx_inv, colIn, colOut);\n    }\n\n    /**\n     * @brief transform\n     * @param colIn\n     * @param colOut\n     * @param bDirection\n     */\n    void transform(float *colIn, float *colOut, bool bDirection) {\n        if(bDirection) {\n            direct(colIn, colOut);\n        } else {\n            inverse(colIn, colOut);\n        }\n    }\n\n    /**\n     * @brief apply\n     * @param mtx\n     * @param colIn\n     * @param colOut\n     */\n    static void apply(const float *mtx, float *colIn, float *colOut)\n    {\n        //working copy\n        float tmp[3];\n        tmp[0] = colIn[0];\n        tmp[1] = colIn[1];\n        tmp[2] = colIn[2];\n\n        //conversion\n        colOut[0] = tmp[0] * mtx[0] + tmp[1] * mtx[1] + tmp[2] * mtx[2];\n        colOut[1] = tmp[0] * mtx[3] + tmp[1] * mtx[4] + tmp[2] * mtx[5];\n        colOut[2] = tmp[0] * mtx[6] + tmp[1] * mtx[7] + tmp[2] * mtx[8];\n    }\n\n    /**\n     * @brief apply_s a safe apply\n     * @param mtx\n     * @param colIn\n     * @param colOut\n     */\n    static void apply_s(const float *mtx, float *colIn, float *colOut)\n    {\n        if(mtx == NULL || colIn == NULL || colOut == NULL) {\n            printf(\"Error in ColorSpaceLinear::ConvertLinearSpace_s\");\n            return;\n        }\n\n        apply(mtx, colIn, colOut);\n    }\n\n    /**\n     * @brief getMatrix\n     * @return\n     */\n    float *getMatrix()\n    {\n        return mtx;\n    }\n\n    /**\n     * @brief getMatrixInverse\n     * @return\n     */\n    float *getMatrixInverse()\n    {\n        return mtx_inv;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_CONV_HPP */\n\n"
  },
  {
    "path": "include/colors/color_conv_ipt_to_ich.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_IPT_TO_ICH_HPP\n#define PIC_COLORS_COLOR_CONV_IPT_TO_ICH_HPP\n\n#include \"../colors/color_conv.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvIPTtoICH class\n */\nclass ColorConvIPTtoICH: public ColorConv\n{\nprotected:\n    float epsilon;\n\npublic:\n\n    /**\n     * @brief ColorConvIPTtoICH\n     */\n    ColorConvIPTtoICH()\n    {\n        linear = false;\n        epsilon = 1.0f;\n    }\n\n    /**\n     * @brief direct from XYZ to CIE LUV\n     * @param colIn\n     * @param colOut\n     */\n    void direct(float *colIn, float *colOut)\n    {\n        colOut[0] = colIn[0];\n\n        colOut[1] = sqrtf(colIn[1] * colIn[1] + colIn[2] * colIn[2]);\n        colOut[2] = atan2f(colIn[1], colIn[2]);\n    }\n\n    /**\n     * @brief inverse from CIE LUV to XYZ\n     * @param colIn\n     * @param colOut\n     */\n    void inverse(float *colIn, float *colOut)\n    {\n        colOut[0] = colIn[0];\n\n        colOut[1] = colIn[1] * sinf(colIn[2]);\n        colOut[2] = colIn[1] * cosf(colIn[2]);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_CONV_IPT_TO_ICH_HPP */\n\n"
  },
  {
    "path": "include/colors/color_conv_lms_to_ipt.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_LMS_TO_IPT_HPP\n#define PIC_COLORS_COLOR_CONV_LMS_TO_IPT_HPP\n\n#include \"../colors/color_conv.hpp\"\n\nnamespace pic {\n\n\n\nconst float mtxLMStoIPT[] = { 0.4f,     0.4f,     0.2f,\n                              4.455f,  -4.851f,   0.396f,\n                              0.8056f,  0.3572f, -1.1628f\n                            };\n\nconst float mtxIPTtoLMS[] = {  1.0f,  0.0976f,  0.2052f,\n                               1.0f, -0.1139f,  0.1332f,\n                               1.0f,  0.0326f, -0.6769f\n                             };\n\n/**\n * @brief The ColorConvXYZtoLMS class\n */\nclass ColorConvLMStoIPT: public ColorConv\n{\nprotected:\n    /**\n     * @brief LMSNonLinearityFunction\n     * @param x\n     * @return\n     */\n    float nonLinearityFunction(float x, float g)\n    {\n        if(x >= 0.0f) {\n            return powf(x, g);\n        } else {\n            return -powf(-x, g);\n        }\n\n    }\npublic:\n\n    /**\n     * @brief ColorConvLMStoIPT\n     */\n    ColorConvLMStoIPT() : ColorConv()\n    {\n        memcpy(mtx, mtxLMStoIPT, 9 * sizeof(float));\n        memcpy(mtx_inv, mtxIPTtoLMS, 9 * sizeof(float));\n    }\n\n    /**\n    * @brief direct converts from a color space to another one.\n    * \\param colIn a pointer to the input color to be converted.\n    * \\param colOut a pointer to the output color.\n    */\n    void direct(float *colIn, float *colOut)\n    {\n        float tmp[3];\n        for(int i = 0; i < 3; i++) {\n            tmp[i] = nonLinearityFunction(colIn[i], 0.43f);\n        }\n\n        apply(mtx, tmp, colOut);\n    }\n\n    /**\n    * @brief inverse is the inverse of direct.\n    * \\param colIn a pointer to the input color to be converted.\n    * \\param colOut a pointer to the output color.\n    */\n    void inverse(float *colIn, float *colOut)\n    {\n        float tmp[3];\n        apply(mtx_inv, colIn, tmp);\n\n        for(int i = 0; i < 3; i++) {\n            colOut[i] = nonLinearityFunction(tmp[i], 1.0f / 0.43f);\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_CONV_LMS_TO_IPT_HPP */\n"
  },
  {
    "path": "include/colors/color_conv_lms_to_lalphabeta.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_LMS_TO_L_ALPHA_BETA_HPP\n#define PIC_COLORS_COLOR_CONV_LMS_TO_L_ALPHA_BETA_HPP\n\n#include \"../colors/color_conv.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvLMStoLAlphaBeta class\n */\nclass ColorConvLMStoLAlphaBeta: public ColorConv\n{\npublic:\n\n    /**\n     * @brief ColorConvLMStoLAlphaBeta\n     */\n    ColorConvLMStoLAlphaBeta() : ColorConv()\n    {\n        float c1 = 1.0f / sqrtf(3.0f);\n        float c2 = 1.0f / sqrtf(6.0f);\n        float c3 = 1.0f / sqrtf(2.0f);\n        float c4 = -c2 * 2.0f;\n        \n        float mtxLMStoLalphabeta[] = { c1, c1, c1,\n                                       c2, c2, c4,\n                                       c3, -c3, 0.0f};\n\n        float mtxLalphabetatoLMS[] = { c1, c2,  c3,\n                                       c1, c2, -c3,\n                                       c1, c4, 0.0f};\n\n        memcpy(mtx, mtxLMStoLalphabeta, 9 * sizeof(float));\n        memcpy(mtx_inv, mtxLalphabetatoLMS, 9 * sizeof(float));\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_SPACE_XYZ_HPP */\n"
  },
  {
    "path": "include/colors/color_conv_rgb_to_lms.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_RGB_TO_LMS_HPP\n#define PIC_COLORS_COLOR_CONV_RGB_TO_LMS_HPP\n\n#include \"../util/matrix_3_x_3.hpp\"\n#include \"../colors/color_conv.hpp\"\n#include \"../colors/color_conv_rgb_to_xyz.hpp\"\n#include \"../colors/color_conv_xyz_to_lms.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvRGBtoLMS class\n */\nclass ColorConvRGBtoLMS: public ColorConv\n{\npublic:\n\n    /**\n     * @brief ColorConvRGBtoLMS\n     */\n    ColorConvRGBtoLMS() : ColorConv()\n    {\n        Matrix3x3 A, B, C;\n        A.set(mtxRGBtoXYZ);\n        B.set(mtxXYZtoLMS);\n        //RGB --> LMS\n        C = B.mul(A);\n\n        memcpy(mtx, C.data, 9 * sizeof(float));\n        computeInverse();\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_CONV_RGB_TO_LMS_HPP */\n\n"
  },
  {
    "path": "include/colors/color_conv_rgb_to_srgb.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_RGB_TO_SRGB_HPP\n#define PIC_COLORS_COLOR_CONV_RGB_TO_SRGB_HPP\n\n#include \"../colors/color_conv.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvRGBtosRGB class\n */\nclass ColorConvRGBtosRGB: public ColorConv\n{\nprotected:\n\n    float a, a_plus_1, gamma, gamma_inv;\n\npublic:\n\n    /**\n     * @brief ColorConvRGBtosRGB\n     */\n    ColorConvRGBtosRGB()\n    {\n        linear = false;\n\n        gamma = 2.4f;\n        gamma_inv = 1.0f / gamma;\n        a = 0.055f;\n        a_plus_1 = 1.0f + a;\n    }\n\n    /**\n     * @brief direct\n     * @param colIn\n     * @param colOut\n     */\n    void direct(float *colIn, float *colOut)\n    {\n        for(int i = 0; i < 3; i++) {\n            if(colIn[i] > 0.0031308f) {\n                colOut[i] = a_plus_1 * powf(colIn[i], gamma_inv) - a;\n            } else {\n                colOut[i] = 12.92f * colIn[i];\n            }\n        }\n    }\n\n    /**\n     * @brief inverse\n     * @param colIn\n     * @param colOut\n     */\n    void inverse(float *colIn, float *colOut)\n    {\n        for(int i = 0; i < 3; i++) {\n            if(colIn[i] > 0.04045f) {\n                colOut[i] = powf((colIn[i] + a) / a_plus_1, gamma);\n            } else {\n                colOut[i] = colIn[i] / 12.92f;\n            }\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_SPACE_XYZ_HPP */\n\n"
  },
  {
    "path": "include/colors/color_conv_rgb_to_xyz.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_RGB_TO_XYZ_HPP\n#define PIC_COLORS_COLOR_CONV_RGB_TO_XYZ_HPP\n\n#include \"../colors/color_conv.hpp\"\n\nnamespace pic {\n\nconst float mtxRGBtoXYZ[] = {\t0.4124f, 0.3576f, 0.1805f,\n                                0.2126f, 0.7152f, 0.0722f,\n                                0.0193f, 0.1192f, 0.9505f\n                            };\n\nconst float mtxXYZtoRGB[] = {\t3.2406f,   -1.5372f,   -0.4986f,\n                               -0.9689f,    1.8758f,    0.0415f,\n                                0.0557f,   -0.2040f,    1.0570f\n                            };\n\n/**\n * @brief The ColorConvRGBtoXYZ class\n */\nclass ColorConvRGBtoXYZ: public ColorConv\n{\npublic:\n\n    /**\n     * @brief ColorConvRGBtoXYZ\n     */\n    ColorConvRGBtoXYZ() : ColorConv()\n    {\n        memcpy(mtx, mtxRGBtoXYZ, 9 * sizeof(float));\n        memcpy(mtx_inv, mtxXYZtoRGB, 9 * sizeof(float));\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_SPACE_XYZ_HPP */\n\n"
  },
  {
    "path": "include/colors/color_conv_xyz_to_cielab.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_XYZ_TO_CIELAB_HPP\n#define PIC_COLORS_COLOR_CONV_XYZ_TO_CIELAB_HPP\n\n#include \"../colors/color_conv.hpp\"\n\nnamespace pic {\n\nconst float C_SIX_OVER_TWENTY_NINE          = 0.20689655172413793103448275862069f;\nconst float C_SIX_OVER_TWENTY_NINE_CUBIC    = 0.00885645167903563081717167575546f;\n// (29/6)^2 / 3\nconst float C_CIELAB_C1                     = 7.787037037037037037037037037037f;\n// (6/29)^2 * 3\nconst float C_CIELAB_C1_INV                 = 0.12841854934601664684898929845422f;\nconst float C_FOUR_OVER_TWENTY_NINE         = 0.13793103448275862068965517241379f;\n\n/**\n * @brief The ColorConvXYZtoCIELAB class\n */\nclass ColorConvXYZtoCIELAB: public ColorConv\n{\nprotected:\n\n    float white_point[3];\n\npublic:\n\n    /**\n     * @brief ColorConvXYZtoCIELAB\n     */\n    ColorConvXYZtoCIELAB()\n    {\n        linear = false;\n        white_point[0] = 1.0f;\n        white_point[1] = 1.0f;\n        white_point[2] = 1.0f;\n    }\n\n    /**\n     * @brief direct\n     * @param colIn\n     * @param colOut\n     */\n    void direct(float *colIn, float *colOut)\n    {\n        float fY_Yn = f(colIn[1] / white_point[1]);\n\n        colOut[0] = 116.0f * fY_Yn - 16.0f;\n        colOut[1] = 500.0f * (f(colIn[0] / white_point[0]) - fY_Yn);\n        colOut[2] = 200.0f * (fY_Yn - f(colIn[2] / white_point[2]));\n    }\n\n    /**\n     * @brief inverse\n     * @param colIn\n     * @param colOut\n     */\n    void inverse(float *colIn, float *colOut)\n    {\n        float tmp = (colIn[0] + 16.0f) / 116.0f;\n\n        colOut[1] = white_point[1] * f_inv(tmp);\n        colOut[0] = white_point[0] * f_inv(tmp + colIn[1] / 500.0f);\n        colOut[2] = white_point[2] * f_inv(tmp - colIn[2] / 200.0f);\n    }\n\n    /**\n     * @brief f\n     * @param t\n     * @return\n     */\n    static float f(float t)\n    {\n        if(t > C_SIX_OVER_TWENTY_NINE_CUBIC) {\n            return powf(t, 1.0f / 3.0f);\n        } else {\n            return C_CIELAB_C1 * t +\n                   C_FOUR_OVER_TWENTY_NINE;\n        }\n    }\n\n    /**\n     * @brief f_inv\n     * @param t\n     * @return\n     */\n    static float f_inv(float t)\n    {\n        if(t > C_SIX_OVER_TWENTY_NINE ) {\n            return powf(t, 3.0f);\n        } else {\n            return (t - C_FOUR_OVER_TWENTY_NINE) * C_CIELAB_C1_INV;\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_SPACE_CIELAB_HPP */\n\n"
  },
  {
    "path": "include/colors/color_conv_xyz_to_cieluv.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_XYZ_TO_CIELUV_HPP\n#define PIC_COLORS_COLOR_CONV_XYZ_TO_CIELUV_HPP\n\n#include \"../colors/color_conv.hpp\"\n\nnamespace pic {\n\nclass ColorConvXYZtoCIELUV: public ColorConv\n{\nprotected:\n\n    float white_point[3];\n\npublic:\n\n    ColorConvXYZtoCIELUV()\n    {\n        linear = false;\n        white_point[0] = 1.0f;\n        white_point[1] = 1.0f;\n        white_point[2] = 1.0f;\n    }\n\n    //from XYZ to CIE LUV\n    void direct(float *colIn, float *colOut)\n    {\n\n    }\n\n    //from CIE LUV to XYZ\n    void inverse(float *colIn, float *colOut)\n    {\n\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_SPACE_CIELUV_HPP */\n\n"
  },
  {
    "path": "include/colors/color_conv_xyz_to_hdrlab.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_XYZ_TO_HDRLAB_HPP\n#define PIC_COLORS_COLOR_CONV_XYZ_TO_HDRLAB_HPP\n\n#include <math.h>\n\n#include \"../colors/color_conv.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvXYZtoHDRLAB class\n */\nclass ColorConvXYZtoHDRLAB: public ColorConv\n{\nprotected:\n\n    float Yabs, Ys, two_e, epsilon;\n    float whitePoint[3];\n\npublic:\n\n    /**\n     * @brief ColorConvXYZtoHDRLAB\n     */\n    ColorConvXYZtoHDRLAB()\n    {\n        linear = false;\n\n        whitePoint[0] = 1.0f;\n        whitePoint[1] = 1.0f;\n        whitePoint[2] = 1.0f;\n\n        Ys = 0.5f;\n        Yabs = 1.0f;\n\n        two_e = powf(2.0f, computeEpsilon(Ys, Yabs));\n    }\n\n    /**\n     * @brief ColorConvXYZtoHDRLAB\n     * @param Yabs\n     * @param whitePoint\n     */\n    ColorConvXYZtoHDRLAB(float Yabs, float *whitePoint)\n    {\n        this->Yabs = Yabs;\n        this->whitePoint[0] = whitePoint[0];\n        this->whitePoint[1] = whitePoint[1];\n        this->whitePoint[2] = whitePoint[2];\n\n        Ys = 0.5f;\n\n        epsilon = computeEpsilon(Ys, Yabs);\n        two_e = powf(2.0f, epsilon);\n    }\n\n    /**\n     * @brief direct from XYZ to HDR-CIELAB\n     * @param colIn\n     * @param colOut\n     */\n    void direct(float *colIn, float *colOut)\n    {\n        //L_hdr\n        colOut[0]  = f(colIn[1] / whitePoint[1]);\n\n        //a_hdr\n        colOut[1] = 5.0f * (f(colIn[0] / whitePoint[0]) - f(colIn[1] / whitePoint[1]));\n\n        //b_hdr\n        colOut[2] = 2.0f * (f(colIn[1] / whitePoint[1]) - f(colIn[2] / whitePoint[2]));\n    }\n\n    /**\n     * @brief inverse from HDR-CIELAB to XYZ\n     * @param colIn\n     * @param colOut\n     */\n    void inverse(float *colIn, float *colOut)\n    {\n        colOut[1] = whitePoint[1] * f_inv( colIn[0] );\n        colOut[0] = whitePoint[0] * f_inv( colIn[0] + colIn[1]/5.0f );\n        colOut[2] = whitePoint[2] * f_inv( colIn[0] - colIn[2]/2.0f );\n    }\n\n    /**\n     * @brief WhitePointD65\n     * @param whitePoint\n     * @return\n     */\n    float *WhitePointD65(float *whitePoint)\n    {\n        if(whitePoint == NULL) {\n            whitePoint = new float[3];\n        }\n\n        whitePoint[0] = 95.047f;\n        whitePoint[1] = 100.0f;\n        whitePoint[2] = 108.883f;\n\n        return whitePoint;\n    }\n\n    /**\n     * @brief f\n     * @param omega\n     * @return\n     */\n    float f(float omega)\n    {\n        float omega_e = powf(omega, epsilon);\n        return (247.0f * omega_e) / (omega_e + two_e) + 0.02f;\n    }\n\n    /**\n     * @brief f_inv\n     * @param x\n     * @return\n     */\n    float f_inv(float x)\n    {\n        float omega_e = ( (x - 0.02f) * two_e ) / (247.0f + 0.02f - x);\n        return powf(omega_e, 1.0f / epsilon);\n    }\n\n    /**\n     * @brief computeEpsilon\n     * @param Ys\n     * @param Yabs\n     * @return\n     */\n    static float computeEpsilon(float Ys, float Yabs)\n    {\n        if(Yabs <= 0.0f) {\n            Yabs = 1.0f;\n        }\n\n        if(Ys < 0.0f || Ys > 1.0f) {\n            Ys = 0.5f;\n        }\n\n        float sf = 1.25f - 0.25f * (Ys / 0.184f);\n\n        float lf = logf(318.0f) / logf(Yabs);\n\n        return 0.58f / (sf * lf);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_SPACE_HDRLAB_HPP */\n\n"
  },
  {
    "path": "include/colors/color_conv_xyz_to_lms.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_XYZ_TO_LMS_HPP\n#define PIC_COLORS_COLOR_CONV_XYZ_TO_LMS_HPP\n\n#include \"../colors/color_conv.hpp\"\n\nnamespace pic {\n\nconst float mtxXYZtoLMS[] = {\t0.3897f, 0.6890f, -0.0787f,\n                               -0.2298f, 1.1834f, 0.0464f,\n                                0.0f,    0.0f,    1.0f\n                            };\n\nconst float mtxLMStoXYZ[] = {   1.9102f, -1.112f,   0.2019f,\n                                0.3709f,  0.6291f,  5.1332e-6f,\n                                0.0f,     0.0f,     1.0f\n                            };\n\n/**\n * @brief The ColorConvXYZtoLMS class\n */\nclass ColorConvXYZtoLMS: public ColorConv\n{\npublic:\n\n    /**\n     * @brief ColorConvXYZtoLMS\n     */\n    ColorConvXYZtoLMS() : ColorConv()\n    {\n        memcpy(mtx, mtxXYZtoLMS, 9 * sizeof(float));\n        memcpy(mtx_inv, mtxLMStoXYZ, 9 * sizeof(float));\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_SPACE_XYZ_HPP */\n"
  },
  {
    "path": "include/colors/color_conv_xyz_to_logluv.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_XYZ_TO_LOGLUV_HPP\n#define PIC_COLORS_COLOR_CONV_XYZ_TO_LOGLUV_HPP\n\n#include \"../colors/color_conv.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvXYZtoLogLuv class\n */\nclass ColorConvXYZtoLogLuv: public ColorConv\n{\nprotected:\n    float epsilon;\n\npublic:\n\n    /**\n     * @brief ColorConvXYZtoLogLuv\n     */\n    ColorConvXYZtoLogLuv()\n    {\n        linear = false;\n        epsilon = 1.0f;\n    }\n\n    /**\n     * @brief direct from XYZ to CIE LUV\n     * @param colIn\n     * @param colOut\n     */\n    void direct(float *colIn, float *colOut)\n    {\n\n        colOut[0] = logf(colIn[1] + epsilon);\n\n        float norm = colIn[0] + colIn[1] + colIn[2];\n        float x = colIn[0] / norm;\n        float y = colIn[1] / norm;\n\n        float norm_uv = -2.0f * x + 12.0f * y + 3.0f;\n        float u_prime =  4.0f * x / norm_uv;\n        float v_prime =  9.0f * y / norm_uv;\n\n        colOut[1] = u_prime;\n        colOut[2] = v_prime;\n    }\n\n    /**\n     * @brief inverse from CIE LUV to XYZ\n     * @param colIn\n     * @param colOut\n     */\n    void inverse(float *colIn, float *colOut)\n    {\n        float norm = 6.0f * colIn[1] - 16.0f * colIn[2] + 12.0f;\n\n        float x = 9.0f * colIn[1] / norm;\n        float y = 4.0f * colIn[2] / norm;\n        float z = 1.0f - x - y;\n\n        float Y = MAX(expf(colIn[0]) - epsilon, 0.0f);\n        norm = Y / y;\n\n        colOut[0] = x * norm;\n        colOut[1] = Y;\n        colOut[2] = z * norm;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_SPACE_LOGLUV_HPP */\n\n"
  },
  {
    "path": "include/colors/color_conv_xyz_xyY.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_COLOR_CONV_XYZ_TO_xyY_HPP\n#define PIC_COLORS_COLOR_CONV_XYZ_TO_xyY_HPP\n\n#include \"../colors/color_conv.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvXYZtoxyY class\n */\nclass ColorConvXYZtoxyY: public ColorConv\n{\npublic:\n\n    ColorConvXYZtoxyY()\n    {\n        linear = false;\n    }\n\n    /**\n     * @brief direct\n     * @param colIn\n     * @param colOut\n     */\n    void direct(float *colIn, float *colOut)\n    {\n        float XYZ = colIn[0] + colIn[1] + colIn[2];\n\n        if(XYZ > 0.0f) {\n            colOut[0] = colIn[0] / XYZ;\n            colOut[1] = colIn[1] / XYZ;\n            colOut[2] = colIn[2];\n        } else {\n            colOut[0] = -1.0f;\n            colOut[1] = -1.0f;\n            colOut[2] = -1.0f;\n        }\n    }\n\n    /**\n     * @brief inverse\n     * @param colIn\n     * @param colOut\n     */\n    void inverse(float *colIn, float *colOut)\n    {\n        if(colIn[0] != 0.0f) {\n            float ratio = colIn[2] / colIn[1];\n            float z = CLAMPi(1.0f - colIn[0] - colIn[1], 0.0f, 1.0f);\n\n            colOut[0] = colIn[0] * ratio;\n            colOut[1] = colIn[2];\n            colOut[2] = z * ratio;\n        } else {\n            colOut[0] = -1.0f;\n            colOut[1] = -1.0f;\n            colOut[2] = -1.0f;\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_COLOR_SPACE_CIELAB_HPP */\n\n"
  },
  {
    "path": "include/colors/matrix_from_primaries.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_MATRIX_FORM_PRIMARIES_HPP\n#define PIC_COLORS_MATRIX_FORM_PRIMARIES_HPP\n\n#include \"../base.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n    #ifndef PIC_EIGEN_NOT_BUNDLED\n        #include \"../externals/Eigen/Dense\"\n        #include \"../externals/Eigen/QR\"\n    #else\n        #include <Eigen/Dense>\n        #include <Eigen/QR>\n    #endif\n#endif\n\nnamespace pic {\n\n/**\n * @brief createMatrixFromPrimaries computes a matrix for converting XYZ values into the\n * defined color space (i.e., by defining the three primaries: red, green, and blue).\n * @param red_XYZ is the XYZ values of the red primary\n * @param green_XYZ is the XYZ values of the green primary\n * @param blue_XYZ is the XYZ values of the blue primary\n * @param white_point_XYZ is the XYZ values of the white point primary\n * @return It returns a 3x3 matrix for converting XYZ values into the defined color space\n */\nPIC_INLINE float *createMatrixFromPrimaries(float *red_XYZ,\n                                 float *green_XYZ,\n                                 float *blue_XYZ,\n                                 float *white_point_XYZ,\n                                 float *ret = NULL\n                                 )\n{\n    if(red_XYZ == NULL || green_XYZ == NULL || blue_XYZ == NULL) {\n        return ret;\n    }\n\n    if(ret == NULL) {\n        ret = new float[9];\n    }\n\n#ifndef PIC_DISABLE_EIGEN\n\n    int w = 0;\n    if(white_point_XYZ != NULL) {\n        w = 3;\n    }\n\n    //set up a liner system A x = b\n    int nRow = 9 + w;\n    Eigen::MatrixXf A(nRow, 9);\n    Eigen::VectorXf b(nRow);\n\n    //A matrix\n    A.setZero();\n\n    //red\n    for(int j = 0; j < 3; j++) {\n        for(int i = 0 ; i < 3; i++) {\n            A(j, j * 3 + i) = red_XYZ[i];\n        }\n    }\n\n    //green`\n    for(int j = 0; j < 3; j++) {\n        for(int i = 0 ; i < 3; i++) {\n            A(j + 3, j * 3 + i) = green_XYZ[i];\n        }\n    }\n\n    //blue`\n    for(int j = 0; j < 3; j++) {\n        for(int i = 0 ; i < 3; i++) {\n            A(j + 6, j * 3 + i) = blue_XYZ[i];\n        }\n    }\n\n    //white\n    if(w == 3) {\n        for(int j = 0; j < 3; j++) {\n            for(int i = 0 ; i < 3; i++) {\n                A(j + 9, j * 3 + i) = white_point_XYZ[i];\n            }\n        }\n    }\n\n    //b vector\n    b(0) = 1.0f;\n    b(1) = 0.0f;\n    b(2) = 0.0f;\n\n    b(3) = 0.0f;\n    b(4) = 1.0f;\n    b(5) = 0.0f;\n\n    b(6) = 0.0f;\n    b(7) = 0.0f;\n    b(8) = 1.0f;\n\n    if(w == 3) {\n        b(9) = 1.0f;\n        b(10) = 1.0f;\n        b(11) = 1.0f;\n    }\n\n    //solve Ax=b\n    Eigen::VectorXf x = A.colPivHouseholderQr().solve(b);\n\n    for(int i = 0; i < 9; i++) {\n        ret[i] = x(i);\n    }\n#endif\n    return ret;\n}\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_MATRIX_FORM_PRIMARIES_HPP */\n\n"
  },
  {
    "path": "include/colors/rgbe.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_RGBE_HPP\n#define PIC_COLORS_RGBE_HPP\n\n/**\n*\n*\tNote:\n*\t- colFloat has to be an array of 3 floats\n*\t- colRGBE has to be an array of 4 unsigned char\n*\n**/\n\n#include \"../base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief fromFloatToRGBE\n * @param colFloat\n * @param colRGBE\n */\nPIC_INLINE void fromFloatToRGBE(float *colFloat, unsigned char *colRGBE)\n{\n    float v;\n    int e;\n\n    v = *colFloat;\n\n    if(v < * (colFloat + 1)) {\n        v = *(colFloat + 1);\n    }\n\n    if(v < * (colFloat + 2)) {\n        v = *(colFloat + 2);\n    }\n\n    if(v < 1e-32f) { //is it too small?\n        *(colRGBE) = 0;\n        *(colRGBE + 1) = 0;\n        *(colRGBE + 2) = 0;\n        *(colRGBE + 3) = 0;\n        return;\n    }\n\n    v = frexp(v, &e) * 256.0f / v;\n\n    *(colRGBE) = int((*(colFloat)) * v);\n    *(colRGBE + 1) = int((*(colFloat + 1)) * v);\n    *(colRGBE + 2) = int((*(colFloat + 2)) * v);\n    *(colRGBE + 3) = (e + 128);\n}\n\n/**\n * @brief fromSingleFloatToRGBE\n * @param colFloat\n * @param colRGBE\n */\nPIC_INLINE void fromSingleFloatToRGBE(float *colFloat, unsigned char *colRGBE)\n{\n    float v;\n    int e;\n\n    v = *colFloat;\n\n    if(v < 1e-32f) { //is it too small?\n        *(colRGBE) = 0;\n        *(colRGBE + 1) = 0;\n        *(colRGBE + 2) = 0;\n        *(colRGBE + 3) = 0;\n        return;\n    }\n\n    v = frexp(v, &e) * 256.0f / v;\n\n    *(colRGBE) = int((*(colFloat)) * v);\n    *(colRGBE + 1) = *colRGBE;\n    *(colRGBE + 2) = *colRGBE;\n    *(colRGBE + 3) = (e + 128);\n}\n\n/**\n * @brief fromRGBEToFloat\n * @param colRGBE\n * @param colFloat\n */\nPIC_INLINE void fromRGBEToFloat(unsigned char *colRGBE, float *colFloat)\n{\n\n    if((*(colRGBE) == 0) && (*(colRGBE + 1) == 0) &&\n       (*(colRGBE + 2) == 0)) { //if it is small\n        *(colFloat) = 0;\n        *(colFloat + 1) = 0;\n        *(colFloat + 2) = 0;\n        return;\n    }\n\n    int E;\n    float f;\n\n    E = *(colRGBE + 3) - 128 - 8;\n    f = ldexpf(1.0f, E);\n\n    *(colFloat) = (float(*(colRGBE)) + 0.5f) * f;\n    *(colFloat + 1) = (float(*(colRGBE + 1)) + 0.5f) * f;\n    *(colFloat + 2) = (float(*(colRGBE + 2)) + 0.5f) * f;\n}\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_RGBE_HPP */\n\n"
  },
  {
    "path": "include/colors/saturation.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_SATURATION_HPP\n#define PIC_COLORS_SATURATION_HPP\n\nnamespace pic {\n\n#include \"../base.hpp\"\n#include \"../util/math.hpp\"\n#include \"../util/array.hpp\"\n\n/**\n * @brief computeSaturation\n * @param data\n * @param channels\n * @return\n */\nPIC_INLINE float computeSaturation(float *data, int channels = 3)\n{\n    if(channels > 1) {\n        return sqrtf_s(Arrayf::getVariance(data, channels));\n    } else {\n        return 0.0f;\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_COLORS_SATURATION_HPP */\n"
  },
  {
    "path": "include/colors.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COLORS_HPP\n#define PIC_COLORS_HPP\n\n#include \"colors/color.hpp\"\n\n#include \"colors/color_3.hpp\"\n\n#include \"colors/matrix_from_primaries.hpp\"\n\n#include \"colors/color_conv.hpp\"\n#include \"colors/color_conv_rgb_to_srgb.hpp\"\n#include \"colors/color_conv_rgb_to_xyz.hpp\"\n#include \"colors/color_conv_rgb_to_lms.hpp\"\n#include \"colors/color_conv_lms_to_ipt.hpp\"\n#include \"colors/color_conv_xyz_to_cieluv.hpp\"\n#include \"colors/color_conv_xyz_to_logluv.hpp\"\n#include \"colors/color_conv_xyz_xyY.hpp\"\n#include \"colors/color_conv_xyz_to_lms.hpp\"\n#include \"colors/color_conv_lms_to_lalphabeta.hpp\"\n#include \"colors/color_conv_ipt_to_ich.hpp\"\n\n#include \"colors/color_conv_xyz_to_cielab.hpp\"\n#include \"colors/color_conv_xyz_to_hdrlab.hpp\"\n\n#include \"colors/saturation.hpp\"\n\n#include \"colors/rgbe.hpp\"\n\n#endif /* PIC_COLORS_HPP */\n\n"
  },
  {
    "path": "include/computer_vision/camera_matrix.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_CAMERA_MARTIX_HPP\n#define PIC_COMPUTER_VISION_CAMERA_MARTIX_HPP\n\n#include <vector>\n#include <random>\n#include <stdlib.h>\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n#include \"../util/eigen_util.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n    #include \"../externals/Eigen/SVD\"\n    #include \"../externals/Eigen/Geometry\"\n    #include \"../externals/Eigen/Geometry\"\n    #include \"../externals/Eigen/QR\"\n#else\n    #include <Eigen/Dense>\n    #include <Eigen/SVD>\n    #include <Eigen/Geometry>\n    #include <Eigen/QR>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief computeEpipole computes the epipole of a fundamental matrix F.\n * @param F is a fundamental matrix.\n * @return It returns the epipole of F.\n */\nPIC_INLINE Eigen::Vector3d computeEpipole(Eigen::Matrix3d &F)\n{\n    Eigen::JacobiSVD< Eigen::Matrix3d > svdF(F, Eigen::ComputeFullV);\n    Eigen::Matrix3d V = svdF.matrixV();\n\n    Eigen::Vector3d e;\n\n    e[0] = V(0, 2);\n    e[1] = V(1, 2);\n    e[2] = V(2, 2);\n\n    return e;\n}\n\n/**\n * @brief getCameraMatrixFromHomography\n * @param H is 3x3 homography matrix.\n * @param K\n * @return\n */\nPIC_INLINE Eigen::Matrix34d getCameraMatrixFromHomography(Eigen::Matrix3d &H, Eigen::Matrix3d &K)\n{\n    Eigen::Matrix34d m;\n    m.setZero();\n\n    Eigen::Matrix3d K_inv = K.inverse();\n\n    Eigen::Matrix3d H_p = K_inv * H;\n\n    Eigen::Vector3d r_0(H_p(0, 0), H_p(1, 0), H_p(2, 0));\n    Eigen::Vector3d r_1(H_p(0, 1), H_p(1, 1), H_p(2, 1));\n\n    r_0.normalize();\n    r_1.normalize();\n    Eigen::Vector3d r_2 = r_0.cross(r_1);\n\n    Eigen::Vector3d t(H_p(0, 2), H_p(1, 2), H_p(2, 2));\n\n    m(0, 0) = r_0[0];\n    m(1, 0) = r_0[1];\n    m(2, 0) = r_0[2];\n\n    m(0, 1) = r_1[0];\n    m(1, 1) = r_1[1];\n    m(2, 1) = r_1[2];\n\n    m(0, 2) = r_2[0];\n    m(1, 2) = r_2[1];\n    m(2, 2) = r_2[2];\n\n    m(0 , 3) = t[0];\n    m(1 , 3) = t[1];\n    m(2 , 3) = t[2];\n\n    return K * m;\n}\n\n/**\n * @brief getCameraMatrixIdentity\n * @param K\n * @return\n */\nPIC_INLINE Eigen::Matrix34d getCameraMatrixIdentity(Eigen::Matrix3d &K)\n{\n    Eigen::Matrix34d m;\n    m.setIdentity();\n    return K * m;\n}\n\n/**\n * @brief getCameraMatrix\n * @param K\n * @param R\n * @param t\n * @return\n */\nPIC_INLINE Eigen::Matrix34d getCameraMatrix(Eigen::Matrix3d &K, Eigen::Matrix3d &R, Eigen::Vector3d &t)\n{\n    Eigen::Matrix34d m;\n\n    m(0, 0) = R(0, 0);\n    m(1, 0) = R(1, 0);\n    m(2, 0) = R(2, 0);\n\n    m(0, 1) = R(0, 1);\n    m(1, 1) = R(1, 1);\n    m(2, 1) = R(2, 1);\n\n    m(0, 2) = R(0, 2);\n    m(1, 2) = R(1, 2);\n    m(2, 2) = R(2, 2);\n\n    m(0, 3) = t[0];\n    m(1, 3) = t[1];\n    m(2, 3) = t[2];\n\n    return K * m;\n}\n\n/**\n * @brief decomposeCameraMatrix\n * @param P\n * @param K\n * @param R\n * @param t\n */\nPIC_INLINE void decomposeCameraMatrix(Eigen::Matrix34d &P,\n                                      Eigen::Matrix3d  &K,\n                                      Eigen::Matrix3d  &R,\n                                      Eigen::Vector3d  &t)\n{\n    Eigen::Matrix3d matrix = P.block<3, 3>(0, 0).inverse();\n\n\n    //QR decomposition\n    Eigen::HouseholderQR<Eigen::Matrix3d> qr(matrix.rows(), matrix.cols());\n    qr.compute(matrix);\n\n    Eigen::Matrix3d Q = qr.householderQ();\n    Eigen::Matrix3d U = qr.matrixQR().triangularView<Eigen::Upper>();\n\n    auto U_d = getDiagonalFromMatrix(U);\n    Eigen::Vector3d d = U_d;\n    for(int i = 0; i < 3; i++) {\n        if(d[i] != 0.0) {\n            d[i] = U_d[i] > 0.0 ? 1.0 : -1.0;\n        }\n    }\n    auto D = DiagonalMatrix(d);\n\n    Q = Q * D;\n    U = D * U;\n\n    //compute K, R, and t\n    auto Q_t = Eigen::Transpose< Eigen::Matrix3d >(Q);\n    auto s = Q.determinant();\n\n    R = s * Q_t;\n    t = s * U * P.col(3);\n\n    if(U(2, 2) > 0.0) {\n        U /= U(2, 2);\n    }\n\n    K = U.inverse();\n}\n\n/**\n * @brief cameraMatrixProject projects a point, p, using the camera\n * matrix, M.\n * @param M\n * @param p is a 3D point encoded in homogenous coordinate (4D vector)\n * @return\n */\nPIC_INLINE Eigen::Vector2i cameraMatrixProject(Eigen::Matrix34d &M, Eigen::Vector4d &p)\n{\n    Eigen::Vector3d proj = M * p;\n    proj[0] /= proj[2];\n    proj[1] /= proj[2];\n\n    return Eigen::Vector2i(int(proj[0]), int(proj[1]));\n}\n\n/**\n * @brief cameraMatrixProject projects a point, p, using the camera\n * matrix, M.\n * @param M\n * @param p is a 3D point (3D vector)\n * @return\n */\nPIC_INLINE Eigen::Vector2i cameraMatrixProject(Eigen::Matrix34d &M, Eigen::Vector3d &p)\n{\n    Eigen::Vector4d p4d(p[0], p[1], p[2], 1.0);\n    return cameraMatrixProject(M, p4d);\n}\n\n/**\n * @brief cameraMatrixProjection\n * @param M\n * @param p\n * @param cx\n * @param cy\n * @param fx\n * @param fy\n * @param lambda\n * @return\n */\nPIC_INLINE Eigen::Vector2i cameraMatrixProjection(Eigen::Matrix34d &M, Eigen::Vector3d &p, double cx, double cy, double fx, double fy, double lambda)\n{\n    Eigen::Vector4d p_t = Eigen::Vector4d(p[0], p[1], p[2], 1.0);\n    Eigen::Vector2i out;\n    Eigen::Vector3d proj = M * p_t;\n    proj[0] /= proj[2];\n    proj[1] /= proj[2];\n\n    double x_cx =  (proj[0] - cx);\n    double y_cy =  (proj[1] - cy);\n\n    double dx = x_cx / fx;\n    double dy = y_cy / fy;\n    double rho_sq = dx * dx + dy * dy;\n\n    double factor = 1.0 / (1.0 + rho_sq * lambda);\n\n    proj[0] = x_cx * factor + cx;\n    proj[1] = y_cy * factor + cy;\n\n    out[0] = int(proj[0]);\n    out[1] = int(proj[1]);\n\n    return out;\n}\n\n/**\n * @brief getOpticalCenter\n * @param P the camera matrix of a view\n * @return it returns the camera center of P\n */\nPIC_INLINE Eigen::Vector3d getOpticalCenter(Eigen::Matrix34d &P)\n{\n    Eigen::Matrix3d Q = P.block<3, 3>(0, 0);\n    auto Q_inv = Q.inverse();\n    return - Q_inv * P.col(3);\n}\n\n/**\n * @brief cameraRectify\n * @param K0 intrisic matrix of view0\n * @param R0 rotation matrix of view0\n * @param t0 translation vector of view0\n * @param K1 intrisic matrix of view1\n * @param R1 rotation matrix of view1\n * @param t1 translation vector of view1\n * @param P0 new camera matrix of view0\n * @param P1 new camera matrix of view1\n * @param T0 transformation matrix for view0\n * @param T1 transformation matrix for view1\n */\nPIC_INLINE void cameraRectify(Eigen::Matrix3d &K0, Eigen::Matrix3d &R0, Eigen::Vector3d &t0,\n                              Eigen::Matrix3d &K1, Eigen::Matrix3d &R1, Eigen::Vector3d &t1,\n                              Eigen::Matrix34d &P0_out, Eigen::Matrix34d &P1_out,\n                              Eigen::Matrix3d &T0, Eigen::Matrix3d &T1)\n{\n    auto P0_in = getCameraMatrix(K0, R0, t0);\n    auto P1_in = getCameraMatrix(K1, R1, t1);\n\n    /*\n    auto K0_i = K0.inverse();\n    auto K1_i = K1.inverse();\n\n    auto R0_t = Eigen::Transpose< Eigen::Matrix3d >(R0);\n    auto R1_t = Eigen::Transpose< Eigen::Matrix3d >(R1);\n    auto c0 = -R0_t * K0_i * P0t.col(3);\n    auto c1 = -R1_t * K1_i * P1t.col(3);\n    */\n\n    //compute optical centers\n\n    auto c0 = getOpticalCenter(P0_in);\n    auto c1 = getOpticalCenter(P1_in);\n\n    //compute new rotation matrix\n    Eigen::Vector3d x_axis = c1 - c0;\n    Eigen::Vector3d tmp = R1.row(2);\n    Eigen::Vector3d y_axis = tmp.cross(x_axis);\n    Eigen::Vector3d z_axis = x_axis.cross(y_axis);\n\n    x_axis.normalize();\n    y_axis.normalize();\n    z_axis.normalize();\n\n    Eigen::Matrix3d R;\n\n    R(0, 0) = x_axis[0];\n    R(0, 1) = x_axis[1];\n    R(0, 2) = x_axis[2];\n\n    R(1, 0) = y_axis[0];\n    R(1, 1) = y_axis[1];\n    R(1, 2) = y_axis[2];\n\n    R(2, 0) = z_axis[0];\n    R(2, 1) = z_axis[1];\n    R(2, 2) = z_axis[2];\n\n    //new camera matrices\n    Eigen::Matrix3d K;\n    K.setZero();\n    K(0, 0) = K0(0, 0);\n    K(1, 1) = K0(1, 1);\n    K(0, 2) = (K0(0, 2) + K1(0, 2)) * 0.5;\n    K(1, 2) = (K0(1, 2) + K1(1, 2)) * 0.5;\n    K(2, 2) = 1.0;\n\n    Eigen::Vector3d t0n = -R * c0;\n    P0_out = getCameraMatrix(K, R, t0n);\n\n    Eigen::Vector3d t1n = -R * c1;\n    P1_out = getCameraMatrix(K, R, t1n);\n\n    //transformations\n    auto Q0o = P0_in.block<3, 3>(0, 0);\n    auto Q0n = P0_out.block<3, 3>(0, 0);\n    T0 = Q0n * Q0o.inverse();\n\n    auto Q1o = P1_in.block<3, 3>(0, 0);\n    auto Q1n = P1_out.block<3, 3>(0, 0);\n    T1 = Q1n * Q1o.inverse();\n}\n\n/**\n * @brief cameraRectify\n * @param P0_in\n * @param P1_in\n * @param P0_out\n * @param P1_out\n * @param T0\n * @param T1\n */\nPIC_INLINE void cameraRectify(Eigen::Matrix34d &P0_in, Eigen::Matrix34d &P1_in,\n                              Eigen::Matrix34d &P0_out, Eigen::Matrix34d &P1_out,\n                              Eigen::Matrix3d &T0, Eigen::Matrix3d &T1)\n{\n    Eigen::Matrix3d K0, K1, R0, R1;\n    Eigen::Vector3d t0, t1;\n\n    decomposeCameraMatrix(P0_in, K0, R0, t0);\n\n    decomposeCameraMatrix(P1_in, K1, R1, t1);\n\n    cameraRectify(K0, R0, t0,\n                  K1, R1, t1,\n                  P0_out, P1_out,\n                  T0, T1);\n}\n\n#endif // PIC_DISABLE_EIGEN\n\n} // end namespace pic\n\n#endif // PIC_COMPUTER_VISION_CAMERA_MARTIX_HPP\n"
  },
  {
    "path": "include/computer_vision/essential_matrix.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_ESSENTIAL_MATRIX_HPP\n#define PIC_COMPUTER_VISION_ESSENTIAL_MATRIX_HPP\n\n#include <vector>\n#include <random>\n#include <stdlib.h>\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n#include \"../util/eigen_util.hpp\"\n\n#include \"../computer_vision/triangulation.hpp\"\n#include \"../computer_vision/camera_matrix.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n    #include \"../externals/Eigen/SVD\"\n    #include \"../externals/Eigen/Geometry\"\n#else\n    #include <Eigen/Dense>\n    #include <Eigen/SVD>\n    #include <Eigen/Geometry>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief computeEssentialMatrix computes the essential matrix, E, from the fundamental\n * matrix, F12, and the two intrics matrices K1 and K2\n * @param F is the fundamental matrix which maps points from camera 1 into camera 2\n * @param K1 is the camera 1 intrics matrix\n * @param K2 is the camera 2 intrics matrix\n * @return\n */\nPIC_INLINE Eigen::Matrix3d computeEssentialMatrix(Eigen::Matrix3d &F, Eigen::Matrix3d &K1, Eigen::Matrix3d &K2)\n{\n    Eigen::Matrix3d K2t = Eigen::Transpose<Eigen::Matrix3d>(K2);\n    return K2t * F * K1;\n}\n\n/**\n * @brief computeEssentialMatrix computes the essential matrix, E, from the fundamental\n * matrix, F, and a single instrics camera, K.\n * @param F\n * @param K\n * @return\n */\nPIC_INLINE Eigen::Matrix3d computeEssentialMatrix(Eigen::Matrix3d &F, Eigen::Matrix3d &K)\n{\n    return computeEssentialMatrix(F, K, K);\n}\n\n/**\n * @brief decomposeEssentialMatrix decomposes an essential matrix E.\n * @param E is the essential matrix. Input.\n * Note1: E = S * R\n * Note2: S = [t]_x\n * Note3: there are four possible cases:\n * 1:     [R1 |  t]\n * 2:     [R1 | -t]\n * 3:     [R2 |  t]\n * 4:     [R2 | -t]\n * @param R1 is one possible rotation matrix. Output.\n * @param R2 is one possible rotation matrix. Output.\n * @param t is the translation vector which is not normalized. Output.\n */\nPIC_INLINE void decomposeEssentialMatrix(Eigen::Matrix3d &E, Eigen::Matrix3d &R1, Eigen::Matrix3d &R2, Eigen::Vector3d &t)\n{\n    //Solving the linear system\n    Eigen::JacobiSVD< Eigen::MatrixXd > svd(E, Eigen::ComputeThinU | Eigen::ComputeThinV);\n    Eigen::Matrix3d U = svd.matrixU();\n    Eigen::Matrix3d V = svd.matrixV();\n\n    //Z matrix\n    Eigen::Matrix3d Z;\n    Z.setZero();\n    Z(0, 1) =  1.0;\n    Z(1, 0) = -1.0;\n\n    //W matrix\n    Eigen::Matrix3d W;\n    W.setZero();\n    W(0, 1) = -1.0;\n    W(1, 0) =  1.0;\n    W(2, 2) =  1.0;\n\n    //Rotation matrices R1 and R2\n    Eigen::Matrix3d Vt = Eigen::Transpose<Eigen::Matrix3d>(V);\n    Eigen::Matrix3d Wt = Eigen::Transpose<Eigen::Matrix3d>(W);\n\n    Eigen::Matrix3d  UVt = U * Vt;\n    double detUVt = UVt.determinant();\n\n    R1 = detUVt * U * W  * Vt;\n    R2 = detUVt * U * Wt * Vt;\n\n    R1 = RotationMatrixRefinement(R1);\n    R2 = RotationMatrixRefinement(R2);\n\n    //Translation vector\n    Eigen::Matrix3d Ut = Eigen::Transpose<Eigen::Matrix3d>(U);\n    Eigen::Matrix3d S = U * Z * Ut;\n\n    t[0] = S(2, 1);\n    t[1] = S(0, 2);\n    t[2] = S(1, 0);\n\n    t.normalize();\n}\n\n/**\n * @brief decomposeEssentialMatrixWithConfiguration decomposes an essential matrix E.\n * @param E is the essential matrix.\n * @param K0\n * @param K1\n * @param points0\n * @param points1\n * @param R\n * @param t\n * @return\n */\nPIC_INLINE bool decomposeEssentialMatrixWithConfiguration(Eigen::Matrix3d &E, Eigen::Matrix3d &K0, Eigen::Matrix3d &K1,\n                                               std::vector< Eigen::Vector2f > &points0, std::vector< Eigen::Vector2f > &points1,\n                                               Eigen::Matrix3d &R, Eigen::Vector3d &t)\n{\n    if(points0.size() != points1.size()) {\n        return false;\n    }\n\n    Eigen::Matrix3d R0, R1;\n    Eigen::Vector3d T;\n    decomposeEssentialMatrix(E, R0, R1, T);\n\n    //for each configuration (R0, -T), (R0, T), (R1, -T), (R1, T)\n    //the sign of reconstructed points is checked\n    int type = -1;\n    int counter = -1;\n\n    for(unsigned int j = 0; j < 4; j++) {\n\n        Eigen::Matrix3d tmp_R = (j < 2) ? R0 : R1;\n        Eigen::Vector3d tmp_T;\n\n        if((j % 2) == 0) {\n            tmp_T = T;\n        } else {\n            tmp_T = -T;\n        }\n\n        Eigen::Matrix34d M0 = getCameraMatrixIdentity(K0);\n        Eigen::Matrix34d M1 = getCameraMatrix(K1, tmp_R, tmp_T);\n\n        int tmp_counter = 0;\n        for(unsigned int i = 0; i < points0.size(); i++) {\n            //homogeneous coordinates\n            Eigen::Vector3d point_0 = Eigen::Vector3d(points0[i][0], points0[i][1], 1.0);\n            Eigen::Vector3d point_1 = Eigen::Vector3d(points1[i][0], points1[i][1], 1.0);\n\n            Eigen::Vector4d p0 = triangulationHartleySturm(point_0, point_1, M0, M1);\n            Eigen::Vector3d p0_euc = Eigen::Vector3d(p0[0], p0[1], p0[2]);\n            Eigen::Vector3d p1 = rigidTransform(p0_euc, tmp_R, tmp_T);\n\n            if((p0[2] >= 0.0) && (p1[2] >= 0.0)) {\n                tmp_counter++;\n            }\n\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"Front: %d %d\\n\",tmp_counter,j);\n        #endif\n\n        if(tmp_counter > counter) {\n            type = j;\n            counter = tmp_counter;\n        }\n    }\n\n    if(type > -1) {\n\n        R = (type < 2) ? R0 : R1;\n\n        if((type % 2) == 0) {\n            t = T;\n        } else {\n            t = -T;\n        }\n\n        return true;\n\n    } else {\n        R.setZero();\n        t.setZero();\n\n        return false;\n    }\n}\n\n#endif // PIC_DISABLE_EIGEN\n\n} // end namespace pic\n\n#endif // PIC_COMPUTER_VISION_ESSENTIAL_MATRIX_HPP\n"
  },
  {
    "path": "include/computer_vision/find_checker_board.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_FIND_CHECKER_BOARD_HPP\n#define PIC_COMPUTER_VISION_FIND_CHECKER_BOARD_HPP\n\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_bilateral_2ds.hpp\"\n\n#include \"../computer_vision/iterative_closest_point_2D.hpp\"\n#include \"../computer_vision/nelder_mead_opt_ICP_2D.hpp\"\n\n#include \"../features_matching/harris_corner_detector.hpp\"\n#include \"../features_matching/orb_descriptor.hpp\"\n\n#include \"../util/rasterizer.hpp\"\n#include \"../util/eigen_util.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n    #include \"../externals/Eigen/SVD\"\n    #include \"../externals/Eigen/Geometry\"\n#else\n    #include <Eigen/Dense>\n    #include <Eigen/SVD>\n    #include <Eigen/Geometry>\n#endif\n\n#endif\n\nnamespace pic {\n\n/**\n * @brief getMinDistance\n * @param points\n * @return\n */\n#ifndef PIC_DISABLE_EIGEN\n\nPIC_INLINE float getMinDistance(std::vector< Eigen::Vector2f > &points)\n{\n    float ret = FLT_MAX;\n    for(unsigned int i = 0; i < points.size(); i++) {\n\n        auto p_i = points[i];\n\n        for(unsigned int j = 0; j < points.size(); j++) {\n            if(j == i) {\n                continue;\n            }\n\n            auto delta_ij = p_i - points[j];\n            float dist = delta_ij.norm();\n\n            if(dist < ret) {\n                ret = dist;\n            }\n        }\n    }\n\n    return ret;\n}\n\n/**\n * @brief estimateCheckerBoardSize\n * @param points\n * @return\n */\nPIC_INLINE float estimateCheckerBoardSize(std::vector< Eigen::Vector2f > &points)\n{\n    if(points.size() < 2) {\n        return -1.0f;\n    }\n\n    float ret = 0.0f;\n\n    int n = int(points.size());\n\n    std::vector<float> m_d;\n    for(int i = 0; i < n; i++) {\n        auto p_i = points[i];\n\n        float closest = FLT_MAX;\n\n        for(int j = 0; j < n; j++) {\n            if(j == i) {\n                continue;\n            }\n\n            auto delta_ij = p_i - points[j];\n\n            float dist = delta_ij.norm();\n\n            if(dist < closest) {\n                closest = dist;\n            }\n        }\n\n        if(closest < FLT_MAX) {\n            m_d.push_back(closest);\n        }\n    }\n\n    if(!m_d.empty()) {\n        std::sort(m_d.begin(), m_d.end());\n\n        ret = m_d[m_d.size() / 2];\n    }\n\n    return ret;\n}\n\n/**\n * @brief estimateCheckerBoardSizeCross\n * @param points\n * @return\n */\nPIC_INLINE float estimateCheckerBoardSizeCross(std::vector< Eigen::Vector2f > &points)\n{\n    if(points.size() < 2) {\n        return -1.0f;\n    }\n\n    float ret = 0.0f;\n\n    int n = int(points.size());\n\n    std::vector<float> m_d;\n    for(int i = 0; i < n; i++) {\n        auto p_i = points[i];\n\n        float c[] = {FLT_MAX, FLT_MAX, FLT_MAX};\n        int ci[] = {-1, -1, -1};\n\n        for(int j = 0; j < n; j++) {\n            if(j == i) {\n                continue;\n            }\n\n            auto delta_ij = p_i - points[j];\n\n            float dist = delta_ij.norm();\n\n            if(dist < c[0]) {\n                c[0] = dist;\n                ci[0] = j;\n            } else {\n                if(dist < c[1]) {\n                    c[1] = dist;\n                    ci[1] = j;\n                } else {\n                    if(dist < c[2]) {\n                        c[2] = dist;\n                        ci[2] = j;\n                    }\n                }\n            }\n        }\n\n        Eigen::Vector2f v0 = (points[ci[0]] - p_i) / c[0];\n        Eigen::Vector2f v1 = (points[ci[1]] - p_i) / c[1];\n        Eigen::Vector2f v2 = (points[ci[2]] - p_i) / c[2];\n\n        float v01 = fabsf(v0.dot(v1));\n        float v02 = fabsf(v0.dot(v2));\n        float v12 = fabsf(v1.dot(v2));\n\n        if((v01 < 0.1f) || (v02 < 0.1f) || (v12 < 0.1f))\n        {\n            m_d.push_back(c[0]);\n        }\n    }\n\n    if(!m_d.empty()) {\n        std::sort(m_d.begin(), m_d.end());\n\n        ret = m_d[m_d.size() / 2];\n    }\n\n    return ret;\n}\n\n/**\n * @brief getCheckerBoardModel\n * @param chekers_x\n * @param checkers_y\n * @param checkers_size\n * @param out\n * @return\n */\nPIC_INLINE Image *getCheckerBoardModel(int checkers_x, int checkers_y, int checkers_size, std::vector< Eigen::Vector2f > &out)\n{\n    Image *ret = new Image(1, (checkers_x + 1) * checkers_size, (checkers_y + 1) * checkers_size, 1);\n    *ret = 1.0f;\n\n    for(int i = 1; i <= checkers_y; i++) {\n        Eigen::Vector2f point;\n\n        int y = i * checkers_size;\n        point[1] = float(y);\n\n        for(int j = 1; j <= checkers_x; j++) {\n\n            int x = j * checkers_size;\n            point[0] = float(x);\n\n            bool bDraw = false;\n            if(j < checkers_x) {\n                if(((j % 2) == 0) && ((i % 2) == 0)) {\n                    bDraw = true;\n                }\n            }\n\n            if(i < checkers_y) {\n                if(((j % 2) == 1) && ((i % 2) == 1)) {\n                    bDraw = true;\n                }\n            }\n\n            if(bDraw) {\n                for(int yy = y; yy < (y + checkers_size); yy++) {\n                    for(int xx = x; xx < (x + checkers_size); xx++) {\n                        float *pixel_value = (*ret)(xx, yy);\n                        pixel_value[0] = 0.0f;\n                    }\n                }\n            }\n\n            out.push_back(point);\n        }\n    }\n\n    return ret;\n}\n\n/**\n * @brief findCheckerBoard\n * @param img\n * @param corners_model\n * @param checkerBoardSizeX\n * @param checkerBoardSizeY\n */\nPIC_INLINE void findCheckerBoard(Image *img, std::vector< Eigen::Vector2f > &corners_model, int checkerBoardSizeX = 4, int checkerBoardSizeY = 7)\n{\n     corners_model.clear();\n\n    //get corners\n#ifdef PIC_DEBUG\n    printf(\"Extracting corners...\\n\");\n#endif\n\n    //compute the luminance images\n    HarrisCornerDetector hcd(2.5f, 5);\n    std::vector< Eigen::Vector2f > corners_from_img;\n    hcd.execute(img, &corners_from_img);\n\n    #ifdef PIC_DEBUG\n        //automatic white balance\n        float *col_mu = img->getMeanVal(NULL, NULL);\n        float *scaling = FilterWhiteBalance::getScalingFactors(col_mu, img->channels);\n        FilterWhiteBalance fwb(scaling, img->channels, true);\n\n        Image *img_wb = fwb.Process(Single(img), NULL);\n\n        float red[] = {1.0f, 0.0f, 0.0f};\n        float green[] = {0.0f, 1.0f, 0.0f};\n        float blue[] = {1.0f, 0.0f, 1.0f};\n        float yellow[] = {1.0f, 1.0f, 0.0f};\n\n        (*img_wb) *= 0.125f;\n    #endif\n\n    std::vector< Eigen::Vector2f > cfi_out;\n    GeneralCornerDetector::removeClosestCorners(&corners_from_img, &cfi_out, 16.0f, 64);\n\n    //compute checkerboard size\n    float checker_size = estimateCheckerBoardSize(corners_from_img);\n\n    #ifdef PIC_DEBUG\n        //drawPoints(img_wb, cfi_out, blue);\n    #endif\n\n    //\n    // remove very closed points\n    //\n\n    std::vector< Eigen::Vector2f > cfi_valid2;\n    auto n =  cfi_out.size();\n    for(unsigned int i = 0; i < n; i++) {\n        auto p_i = cfi_out[i];\n\n        bool bFlag = true;\n\n        for(unsigned int j = 0; j < n; j++) {\n            if(j != i) {\n                auto delta_ij = p_i - cfi_out[j];\n                float dist = delta_ij.norm();\n\n                if(dist < (checker_size)) {\n                    bFlag = false;\n                    break;\n                }\n            }\n        }\n\n        if(bFlag) {\n            cfi_valid2.push_back(p_i);\n        }\n    }\n\n    //\n    // remove very far away points\n    //\n\n    std::vector< Eigen::Vector2f > cfi_valid;\n    n =  cfi_valid2.size();\n    for(unsigned int i = 0; i < n; i++) {\n        auto p_i = cfi_valid2[i];\n\n        float dist = 1e32f;\n        for(unsigned int j = 0; j < n; j++) {\n            if(j != i) {\n                auto delta_ij = p_i - cfi_valid2[j];\n                float t_dist = delta_ij.norm();\n\n                if(t_dist < dist) {\n                    dist = t_dist;\n                }\n            }\n        }\n\n        if(dist < (checker_size * 3)) {\n            cfi_valid.push_back(p_i);\n        }\n    }\n\n    #ifdef PIC_DEBUG\n        printf(\"Checker size: %f\\n\", checker_size);\n        drawPoints(img_wb, cfi_valid, green);\n    #endif\n\n    checker_size = estimateCheckerBoardSizeCross(cfi_valid);\n\n#ifdef PIC_DEBUG\n    printf(\"Re-fit Checker size: %f\\n\", checker_size);\n#endif\n    //pattern image\n\n    int checkers_size = 32;\n    Image *img_pattern = getCheckerBoardModel(checkerBoardSizeX, checkerBoardSizeY, checkers_size, corners_model);\n//    corners_model.erase(corners_model.begin() + 3);\n//    corners_model.erase(corners_model.begin());\n\n    ORBDescriptor b_desc(checkers_size, 256);\n\n    std::vector< unsigned int *> descs_model, descs_cfi_valid;\n    b_desc.getAll(img_pattern, corners_model, descs_model);\n    b_desc.getAll(img, cfi_valid, descs_cfi_valid);\n\n    //scale the model using the checker size\n    float min_dist = getMinDistance(corners_model);\n    float scaling_factor = checker_size / min_dist;\n\n    ICP2DTransform t_init;\n    t_init.scale = scaling_factor;\n    t_init.applyC(corners_model);\n\n    //run 2D ICP\n    iterativeClosestPoints2D(corners_model, cfi_valid, descs_model, descs_cfi_valid, b_desc.getDescriptorSize(), 3000);\n\n#ifdef PIC_DEBUG\n    drawPoints(img_wb, corners_model, red);\n#endif\n\n    //At this point, the rotation may be wrong so\n    //this brute-force trick does the job.\n    NelderMeadOptICP2D opt(corners_model, cfi_valid);\n\n    float prev_err = FLT_MAX;\n    float *x = new float[3];\n    int nSample = 72;\n\n    float *tmp = new float[4];\n    for(float i = 0; i < nSample; i++) {\n        float angle = float(i) * C_PI_2 / float(nSample);\n        float start[] = {0.0f, 0.0f, angle};\n        opt.run(start, 3, 1e-9f, 100, tmp);\n\n        if(opt.output_error < prev_err) {\n            memcpy(x, tmp, sizeof(float) * 3);\n            prev_err = opt.output_error;\n        }\n    }\n\n    #ifdef PIC_DEBUG\n        for(int i = 0; i < 4; i++) {\n            printf(\"%f\\n\", x[i]);\n        }\n    #endif\n\n    float start[] = {x[0], x[1], x[2], 1.0f};\n    opt.run(start, 4, 1e-12f, 100, tmp);\n    ICP2DTransform t2(tmp[0], tmp[1], tmp[2], tmp[3]);\n\n    #ifdef PIC_DEBUG\n        for(int i = 0; i < 4; i++) {\n            printf(\"%f\\n\", tmp[i]);\n        }\n    #endif\n\n    t2.applyC(corners_model);\n\n    #ifdef PIC_DEBUG\n        drawPoints(img_wb, corners_model, yellow);\n        img_wb->Write(\"../data/output/img_wb.bmp\");\n        delete img_wb;\n    #endif\n}\n\n/**\n * @brief estimateLengthInPixelOfCheckers\n * @param corners_model\n * @param p0\n * @param p1\n * @return\n */\nPIC_INLINE float estimateLengthOfCheckers(std::vector< Eigen::Vector2f > &corners_model, Eigen::Vector2f &p0, Eigen::Vector2f &p1)\n{\n    if(corners_model.size() < 8) {\n        return -1.0f;\n    }\n\n    int selected = 5;\n    auto p_0 = corners_model[selected];\n\n    int closest = -1;\n    float ret = FLT_MAX;\n    for(uint j = 0; j < corners_model.size(); j++) {\n        if(j != selected) {\n            auto delta_ij = p_0 - corners_model[j];\n            float dist = delta_ij.norm();\n\n            if(dist < ret) {\n                ret = dist;\n                closest = j;\n            }\n        }\n    }\n\n    p0 = p_0;\n    p1 = corners_model[closest];\n\n    return ret;\n}\n\n/**\n * @brief estimateCoordinatesWhitePointFromCheckerBoard\n * @param img\n * @param corners_model\n * @param checkerBoardSizeX\n * @param checkerBoardSizeY\n * @return\n */\nPIC_INLINE Eigen::Vector2f estimateCoordinatesWhitePointFromCheckerBoard(Image *img, std::vector< Eigen::Vector2f > &corners_model, int checkerBoardSizeX = 4, int checkerBoardSizeY = 6)\n{\n    Eigen::Vector2f ret(-1.0f, -1.0f);\n\n    if(img == NULL || corners_model.empty()) {\n        return ret;\n    }\n\n    float maxVal = 0.0f;\n\n    for(int i = 0; i < (checkerBoardSizeY -1) ; i++) {\n        for(int j = 0; j < (checkerBoardSizeX - 1); j++) {\n\n            int ind0 = (i * checkerBoardSizeX) + j;\n            int ind1 = (i + 1) * checkerBoardSizeX + j + 1;\n\n            auto p0 = corners_model[ind0];\n            auto p1 = corners_model[ind1];\n\n            auto pMid = (p0 + p1) / 2.0f;\n\n            int x = int(pMid[0]);\n            int y = int(pMid[1]);\n            float *color = (*img)(x, y);\n\n            float meanColor = 0.0f;\n            for(auto c = 0; c < img->channels; c++) {\n                meanColor += color[c];\n            }\n\n            if(meanColor > maxVal) {\n                maxVal = meanColor;\n                ret = pMid;\n            }\n        }\n    }\n\n    return ret;\n}\n\n/**\n * @brief estimateWhitePointFromCheckerBoard\n * @param img\n * @param corners_model\n * @param checkerBoardSizeX\n * @param checkerBoardSizeY\n * @return\n */\nPIC_INLINE float *estimateWhitePointFromCheckerBoard(Image *img, std::vector< Eigen::Vector2f > &corners_model, int checkerBoardSizeX = 4, int checkerBoardSizeY = 6)\n{\n    Eigen::Vector2f point = estimateCoordinatesWhitePointFromCheckerBoard(img, corners_model, checkerBoardSizeX, checkerBoardSizeY);\n\n    if(point[0] >= 0.0f && point[1] >= 0.0f) {\n\n        float *ret = new float[img->channels];\n        float *color = (*img)(int(point[0]), int(point[1]));\n        memcpy(ret, color, img->channels * sizeof(float));\n\n        return ret;\n    } else {\n        return NULL;\n    }\n}\n\n#endif\n\n} // end namespace pic\n\n#endif // PIC_COMPUTER_VISION_FIND_CHECKER_BOARD_HPP\n"
  },
  {
    "path": "include/computer_vision/fundamental_matrix.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_FUNDAMENTAL_HPP\n#define PIC_COMPUTER_VISION_FUNDAMENTAL_HPP\n\n#include <vector>\n#include <random>\n#include <stdlib.h>\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n\n#include \"../util/math.hpp\"\n#include \"../util/eigen_util.hpp\"\n\n#include \"../features_matching/orb_descriptor.hpp\"\n#include \"../features_matching/feature_matcher.hpp\"\n#include \"../features_matching/binary_feature_lsh_matcher.hpp\"\n#include \"../computer_vision/nelder_mead_opt_fundamental.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n    #include \"../externals/Eigen/SVD\"\n    #include \"../externals/Eigen/Geometry\"\n#else\n    #include <Eigen/Dense>\n    #include <Eigen/SVD>\n    #include <Eigen/Geometry>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief estimateFundamental estimates the foundamental matrix between image 1 to image 2\n * @param points0 is an array of points computed from image 1.\n * @param points1 is an array of points computed from image 2.\n * @return It returns the fundamental matrix, F_{1,2}.\n */\nPIC_INLINE Eigen::Matrix3d estimateFundamental(std::vector< Eigen::Vector2f > &points0,\n                                    std::vector< Eigen::Vector2f > &points1)\n{\n    Eigen::Matrix3d F;\n\n    if((points0.size() != points1.size()) || (points0.size() < 8)) {\n        F.setZero();\n        return F;\n    }\n\n    //shift and scale points for numerical stability\n    Eigen::Vector3f transform_0 = ComputeNormalizationTransform(points0);\n    Eigen::Vector3f transform_1 = ComputeNormalizationTransform(points1);\n\n    Eigen::Matrix3d mat_0 = getShiftScaleMatrix(transform_0);\n    Eigen::Matrix3d mat_1 = getShiftScaleMatrix(transform_1);\n\n    Eigen::MatrixXd A(points0.size(), 9);\n\n    //set up the linear system\n    for(unsigned int i = 0; i < points0.size(); i++) {\n\n        //transform coordinates for increasing stability of the system\n        Eigen::Vector2f p0 = points0[i];\n        Eigen::Vector2f p1 = points1[i];\n\n        p0[0] = (p0[0] - transform_0[0]) / transform_0[2];\n        p0[1] = (p0[1] - transform_0[1]) / transform_0[2];\n\n        p1[0] = (p1[0] - transform_1[0]) / transform_1[2];\n        p1[1] = (p1[1] - transform_1[1]) / transform_1[2];\n\n        A(i, 0) = p0[0] * p1[0];\n        A(i, 1) = p0[0] * p1[1];\n        A(i, 2) = p0[0];\n        A(i, 3) = p0[1] * p1[0];\n        A(i, 4) = p0[1] * p1[1];\n        A(i, 5) = p0[1];\n        A(i, 6) = p1[0];\n        A(i, 7) = p1[1];\n        A(i, 8) = 1.0;\n    }\n\n    //solve the linear system\n    Eigen::JacobiSVD< Eigen::MatrixXd > svd(A, Eigen::ComputeFullV);\n    Eigen::MatrixXd V = svd.matrixV();\n\n    int n = int(V.cols()) - 1;\n\n    F(0, 0) = V(0, n);\n    F(1, 0) = V(1, n);\n    F(2, 0) = V(2, n);\n\n    F(0, 1) = V(3, n);\n    F(1, 1) = V(4, n);\n    F(2, 1) = V(5, n);\n\n    F(0, 2) = V(6, n);\n    F(1, 2) = V(7, n);\n    F(2, 2) = V(8, n);\n\n    //compute the final F matrix\n    Eigen::Matrix3d mat_1_t = Eigen::Transpose< Eigen::Matrix3d >(mat_1);\n    F = mat_1_t * F * mat_0;\n\n    //enforce singularity\n    Eigen::JacobiSVD< Eigen::MatrixXd > svdF(F, Eigen::ComputeThinU | Eigen::ComputeThinV);\n    Eigen::Matrix3d Uf = svdF.matrixU();\n    Eigen::Matrix3d Vf = svdF.matrixV();\n    Eigen::Vector3d Df = svdF.singularValues();\n    Df[2] = 0.0;\n\n    Eigen::Matrix3d F_new = Uf * DiagonalMatrix(Df) * Eigen::Transpose< Eigen::Matrix3d >(Vf);\n\n    double norm = MAX(Df[0], Df[1]);\n    return F_new / norm;\n}\n\n/**\n * @brief estimateFundamentalRansac\n * @param points0\n * @param points1\n * @param inliers\n * @param maxIterations\n * @return\n */\nPIC_INLINE Eigen::Matrix3d estimateFundamentalRansac(std::vector< Eigen::Vector2f > &points0,\n                                          std::vector< Eigen::Vector2f > &points1,\n                                          std::vector< unsigned int > &inliers,\n                                          unsigned int maxIterations = 100,\n                                          double threshold = 0.01,\n                                          unsigned int seed = 1)\n{\n    if(points0.size() < 9) {\n        return estimateFundamental(points0, points1);\n    }\n\n    Eigen::Matrix3d F;\n    int nSubSet = 8;\n\n    std::mt19937 m(seed);\n\n    unsigned int n = int(points0.size());\n\n    unsigned int *subSet = new unsigned int [nSubSet];\n\n    inliers.clear();\n\n    for(unsigned int i = 0; i < maxIterations; i++) {\n        getRandomPermutation(m, subSet, nSubSet, n);\n\n        std::vector< Eigen::Vector2f > sub_points0;\n        std::vector< Eigen::Vector2f > sub_points1;\n\n        for(int j = 0; j < nSubSet; j++) {\n            unsigned int k = subSet[j];\n            sub_points0.push_back(points0[k]);\n            sub_points1.push_back(points1[k]);\n        }\n\n        Eigen::Matrix3d tmpF = estimateFundamental(sub_points0, sub_points1);\n\n        //is it a good one?\n        std::vector< unsigned int > tmp_inliers;\n\n        for(unsigned int j = 0; j < n; j++) {\n            Eigen::Vector3d p0 = Eigen::Vector3d(points0[j][0], points0[j][1], 1.0);\n            Eigen::Vector3d p1 = Eigen::Vector3d(points1[j][0], points1[j][1], 1.0);\n\n            Eigen::Vector3d tmpF_p0 = tmpF * p0;\n            double n0 = sqrt(tmpF_p0[0] * tmpF_p0[0] + tmpF_p0[1] * tmpF_p0[1]);\n            if(n0 >  0.0) {\n                tmpF_p0 /= n0;\n            }\n\n            double err = fabs(tmpF_p0.dot(p1));\n\n            if(err < threshold){\n                tmp_inliers.push_back(j);\n            }\n        }\n\n        //get the inliers\n        if(tmp_inliers.size() > inliers.size()) {\n            F = tmpF;\n            inliers.clear();\n            inliers.assign(tmp_inliers.begin(), tmp_inliers.end());\n        }\n    }\n\n    //improve estimate with inliers only\n    if(inliers.size() > 7) {\n\n        #ifdef PIC_DEBUG\n            printf(\"Better estimate using inliers only.\\n\");\n        #endif\n\n        std::vector< Eigen::Vector2f > sub_points0;\n        std::vector< Eigen::Vector2f > sub_points1;\n\n        for(unsigned int i = 0; i < inliers.size(); i++) {\n            sub_points0.push_back(points0[inliers[i]]);\n            sub_points1.push_back(points1[inliers[i]]);\n        }\n\n        F = estimateFundamental(sub_points0, sub_points1);\n    }\n\n    return F;\n}\n    \n/**\n * @brief estimateFundamentalWithNonLinearRefinement\n * @param F\n * @return\n */\nPIC_INLINE Eigen::Matrix3d estimateFundamentalWithNonLinearRefinement(std::vector< Eigen::Vector2f > &points0,\n                                                           std::vector< Eigen::Vector2f > &points1,\n                                                           std::vector< unsigned int >    &inliers,\n                                                           unsigned int maxIterationsRansac = 100,\n                                                           double thresholdRansac = 0.01,\n                                                           unsigned int seed = 1,\n                                                           unsigned int maxIterationsNonLinear = 10000,\n                                                           float thresholdNonLinear = 1e-4f\n                                                           )\n{\n    Eigen::Matrix3d F = estimateFundamentalRansac(points0, points1, inliers, maxIterationsRansac, thresholdRansac, seed);\n\n    //non-linear refinement using Nelder-Mead\n    NelderMeadOptFundamental nmf(points0, points1, inliers);\n        \n    float F_data_opt[9];\n    nmf.run(getLinearArrayFromMatrix(F), 9, thresholdNonLinear, maxIterationsNonLinear, &F_data_opt[0]);\n    F = getMatrixdFromLinearArray(F_data_opt, 3, 3);\n\n    return F;\n}\n\n/**\n * @brief noramalizeFundamentalMatrix\n * @param F\n * @return\n */\nPIC_INLINE Eigen::Matrix3d noramalizeFundamentalMatrix(Eigen::Matrix3d F)\n{\n    Eigen::JacobiSVD< Eigen::Matrix3d > svdF(F, Eigen::ComputeThinU | Eigen::ComputeThinV);\n    Eigen::Matrix3d Uf = svdF.matrixU();\n    Eigen::Matrix3d Vf = svdF.matrixV();\n    Eigen::Vector3d Df = svdF.singularValues();\n    Df[2] = 0.0;\n\n    Eigen::Matrix3d F_new = Uf * DiagonalMatrix(Df) * Eigen::Transpose< Eigen::Matrix3d >(Vf);\n\n    double norm = MAX(Df[0], Df[1]);\n    return F_new / norm;\n}\n\n/**\n * @brief extractFundamentalMatrix\n * @param M0\n * @param M1\n * @param e0\n * @param e1\n * @return\n */\nPIC_INLINE Eigen::Matrix3d extractFundamentalMatrix(Eigen::Matrix34d &M0, Eigen::Matrix34d &M1, Eigen::VectorXd &e0, Eigen::VectorXd &e1) {\n\n    Eigen::Matrix3d M0_3 = getSquareMatrix(M0);\n    Eigen::Matrix3d M1_3 = getSquareMatrix(M1);\n\n\n    Eigen::Matrix3d M0_inv = M0_3.inverse();\n    Eigen::Vector3d c0 = - M0_inv * getLastColumn(M0);\n    e1 = M1 * addOne(c0);\n\n    Eigen::Matrix3d M1_inv = M1_3.inverse();\n    Eigen::Vector3d c1 = - M1_inv * getLastColumn(M1);\n    e0 = M0 * addOne(c1);\n\n    Eigen::Matrix3d F;\n\n    F(0, 0) =  0.0;\n    F(0, 1) = -e1(2);\n    F(0, 2) =  e1(1);\n\n    F(1, 0) =  e1(2);\n    F(1, 1) =  0.0;\n    F(1, 2) = -e1(0);\n\n    F(2, 0) = -e1(1);\n    F(2, 1) =  e1(0);\n    F(2, 2) =  0.0;\n\n    F = F * M1_3 * M0_inv;\n\n    Eigen::JacobiSVD< Eigen::Matrix3d > svdF(F, Eigen::ComputeThinU | Eigen::ComputeThinV);\n    Eigen::Vector3d Df = svdF.singularValues();\n\n    double norm = MAX(Df[0], MAX(Df[1], Df[2]));\n    return F / norm;\n}\n\n/**\n * @brief estimateFundamentalFromImages\n * @param img0\n * @param img1\n * @return\n */\nPIC_INLINE  Eigen::Matrix3d estimateFundamentalFromImages(Image *img0,\n                                                          Image *img1,\n                                                          std::vector< Eigen::Vector2f > &m0,\n                                                          std::vector< Eigen::Vector2f > &m1,\n                                                          std::vector< unsigned int > &inliers)\n{\n    Eigen::Matrix3d F;\n    if(img0 == NULL || img1 == NULL) {\n        return F;\n    }\n\n    m0.clear();\n    m1.clear();\n    inliers.clear();\n\n    //corners\n    std::vector< Eigen::Vector2f > corners_from_img0;\n    std::vector< Eigen::Vector2f > corners_from_img1;\n\n    //compute the luminance images\n    Image *L0 = FilterLuminance::execute(img0, NULL, LT_CIE_LUMINANCE);\n    Image *L1 = FilterLuminance::execute(img1, NULL, LT_CIE_LUMINANCE);\n\n    //extract corners\n    HarrisCornerDetector hcd(2.5f, 5);\n    hcd.execute(L0, &corners_from_img0);\n    hcd.execute(L1, &corners_from_img1);\n\n    //compute ORB descriptors for each corner and image\n\n    //apply a gaussian filter to luminance images\n    Image *L0_flt = FilterGaussian2D::execute(L0, NULL, 2.5f);\n    Image *L1_flt = FilterGaussian2D::execute(L1, NULL, 2.5f);\n\n    //compute ORB descriptor\n    ORBDescriptor b_desc(31, 512);\n\n    std::vector< unsigned int *> descs0;\n    b_desc.getAll(L0_flt, corners_from_img0, descs0);\n\n    std::vector< unsigned int *> descs1;\n    b_desc.getAll(L1_flt, corners_from_img1, descs1);\n\n    //match ORB descriptors\n    std::vector< Eigen::Vector3i > matches;\n    int n = b_desc.getDescriptorSize();\n\n    //BinaryFeatureBruteForceMatcher bffm_bin(&descs1, n);\n    BinaryFeatureLSHMatcher bffm_bin(&descs1, n, 64);\n    bffm_bin.getAllMatches(descs0, matches);\n\n    //get matches\n    FeatureMatcher<unsigned int>::filterMatches(corners_from_img0, corners_from_img1, matches, m0, m1);\n\n    //estimate the fundamental matrix\n    F = estimateFundamentalWithNonLinearRefinement(m0, m1, inliers, 1000, 0.5, 1, 1000, 1e-4f);\n\n    delete L0;\n    delete L1;\n    delete L0_flt;\n    delete L1_flt;\n\n    return F;\n}\n    \n#endif // PIC_DISABLE_EIGEN\n\n} // end namespace pic\n\n#endif // PIC_COMPUTER_VISION_FUNDAMENTAL_HPP\n"
  },
  {
    "path": "include/computer_vision/homography_matrix.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_HOMOGRAPHY_HPP\n#define PIC_COMPUTER_VISION_HOMOGRAPHY_HPP\n\n#include <vector>\n#include <random>\n#include <stdlib.h>\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n#include \"../util/eigen_util.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n    #include \"../externals/Eigen/SVD\"\n    #include \"../externals/Eigen/Geometry\"\n#else\n    #include <Eigen/Dense>\n    #include <Eigen/SVD>\n    #include <Eigen/Geometry>\n#endif\n\n#endif\n\n#include \"../computer_vision/nelder_mead_opt_homography.hpp\"\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief estimateHomography estimates an homography matrix H between image 1 to image 2\n * @param points0 is an array of points computed from image 1.\n * @param points1 is an array of points computed from image 2.\n * @return It returns the homography matrix H.\n */\nPIC_INLINE Eigen::Matrix3d estimateHomography(std::vector< Eigen::Vector2f > &points0,\n                                   std::vector< Eigen::Vector2f > &points1)\n{\n    Eigen::Matrix3d  H;\n\n    if((points0.size() != points1.size()) || (points0.size() < 4)) {\n        H.setZero();\n        return H;\n    }\n\n    Eigen::Vector3f transform_0 = ComputeNormalizationTransform(points0);\n    Eigen::Vector3f transform_1 = ComputeNormalizationTransform(points1);\n\n    Eigen::Matrix3d mat_0 = getShiftScaleMatrix(transform_0);\n    Eigen::Matrix3d mat_1 = getShiftScaleMatrix(transform_1);\n\n    int n = int(points0.size());\n    Eigen::MatrixXd A(n * 2, 9);\n\n    //set up the linear system\n    for(int i = 0; i < n; i++) {\n        //transform coordinates for increasing stability of the system\n        Eigen::Vector2f p0 = points0[i];\n        Eigen::Vector2f p1 = points1[i];\n\n        p0[0] = (p0[0] - transform_0[0]) / transform_0[2];\n        p0[1] = (p0[1] - transform_0[1]) / transform_0[2];\n\n        p1[0] = (p1[0] - transform_1[0]) / transform_1[2];\n        p1[1] = (p1[1] - transform_1[1]) / transform_1[2];\n\n        int j = i * 2;\n        A(j, 0) = 0.0;\n        A(j, 1) = 0.0;\n        A(j, 2) = 0.0;\n        A(j, 3) = p0[0];\n        A(j, 4) = p0[1];\n        A(j, 5) = 1.0;\n        A(j, 6) = -p1[1] * p0[0];\n        A(j, 7) = -p1[1] * p0[1];\n        A(j, 8) = -p1[1];\n\n        j++;\n\n        A(j, 0) = p0[0];\n        A(j, 1) = p0[1];\n        A(j, 2) = 1.0;\n        A(j, 3) = 0.0;\n        A(j, 4) = 0.0;\n        A(j, 5) = 0.0;\n        A(j, 6) = -p1[0] * p0[0];\n        A(j, 7) = -p1[0] * p0[1];\n        A(j, 8) = -p1[0];\n    }\n\n    //solve the linear system\n    Eigen::JacobiSVD< Eigen::MatrixXd > svd(A, Eigen::ComputeFullV);\n    Eigen::MatrixXd V = svd.matrixV();\n\n    n = int(V.cols()) - 1;\n\n    //assign and transpose\n    H(0, 0) = V(0, n);\n    H(0, 1) = V(1, n);\n    H(0, 2) = V(2, n);\n\n    H(1, 0) = V(3, n);\n    H(1, 1) = V(4, n);\n    H(1, 2) = V(5, n);\n\n    H(2, 0) = V(6, n);\n    H(2, 1) = V(7, n);\n    H(2, 2) = V(8, n);\n\n    H = mat_1.inverse() * H * mat_0;\n    return H / H(2, 2);\n}\n\n/**\n * @brief estimateHomographyRansac computes the homography such that: points1 = H * points0\n * @param points0\n * @param points1\n * @param inliers\n * @param maxIterations\n * @return\n */\nPIC_INLINE Eigen::Matrix3d estimateHomographyRansac(std::vector< Eigen::Vector2f > &points0,\n                                         std::vector< Eigen::Vector2f > &points1,\n                                         std::vector< unsigned int > &inliers,\n                                         unsigned int maxIterations = 100,\n                                         double threshold = 4.0,\n                                         unsigned int seed = 1)\n{\n    if(points0.size() < 5) {\n        return estimateHomography(points0, points1);\n    }\n\n    Eigen::Matrix3d H;\n    int nSubSet = 4;\n\n    std::mt19937 m(seed);\n\n    unsigned int n = int(points0.size());\n\n    unsigned int *subSet = new unsigned int [nSubSet];\n\n    inliers.clear();\n\n    for(unsigned int i = 0; i < maxIterations; i++) {       \n\n        getRandomPermutation(m, subSet, nSubSet, n);\n\n        std::vector< Eigen::Vector2f > sub_points0;\n        std::vector< Eigen::Vector2f > sub_points1;\n\n        for(int j = 0; j < nSubSet; j++) {\n            sub_points0.push_back(points0[subSet[j]]);\n            sub_points1.push_back(points1[subSet[j]]);\n        }\n\n        Eigen::Matrix3d tmpH = estimateHomography(sub_points0, sub_points1);\n\n        //is it a good one?\n        std::vector< unsigned int > tmp_inliers;\n\n        for(unsigned int j = 0; j < n; j++) {\n            Eigen::Vector3d point_hom = Eigen::Vector3d(points0[j][0], points0[j][1], 1.0);\n            Eigen::Vector3d pp = tmpH * point_hom;\n            pp /= pp[2];\n\n            double dx = points1[j][0] - pp[0];\n            double dy = points1[j][1] - pp[1];\n            double squared_diff = (dx * dx) + (dy * dy);\n\n            if(squared_diff < threshold) {\n                tmp_inliers.push_back(j);\n            }\n        }\n\n        //get the inliers\n        if(tmp_inliers.size() > inliers.size()) {\n            H = tmpH;\n            inliers.clear();\n            inliers.assign(tmp_inliers.begin(), tmp_inliers.end());\n        }\n    }\n\n    //improve estimate with inliers only\n    if(inliers.size() > 3) {\n        #ifdef PIC_DEBUG\n            printf(\"Better estimate using inliers only.\\n\");\n        #endif\n\n        std::vector< Eigen::Vector2f > sub_points0;\n        std::vector< Eigen::Vector2f > sub_points1;\n\n        for(unsigned int i = 0; i < inliers.size(); i++) {\n            sub_points0.push_back(points0[inliers[i]]);\n            sub_points1.push_back(points1[inliers[i]]);\n        }\n\n        H = estimateHomography(sub_points0, sub_points1);\n    }\n\n    return H;\n}\n    \n/**\n* @brief estimateHomographyRansac computes the homography such that: points1 = H * points0\n* @param points0\n* @param points1\n* @param inliers\n* @param maxIterations\n* @return\n*/\nPIC_INLINE Eigen::Matrix3d estimateHomographyWithNonLinearRefinement(\n                                         std::vector< Eigen::Vector2f > &points0,\n                                         std::vector< Eigen::Vector2f > &points1,\n                                         std::vector< unsigned int > &inliers,\n                                         unsigned int maxIterationsRansac = 10000,\n                                         double thresholdRansac = 2.5,\n                                         unsigned int seedRansac = 1,\n                                         unsigned int maxIterationsNonLinear = 10000,\n                                         float thresholdNonLinear = 1e-5f\n                                                          ) {\n    \n    Eigen::Matrix3d H = estimateHomographyRansac(points0, points1, inliers,\n                                                 maxIterationsRansac, thresholdRansac,\n                                                 seedRansac);\n\n    NelderMeadOptHomography nmoh(points0, points1, inliers);\n    float *H_array = getLinearArrayFromMatrix(H);\n    nmoh.run(H_array, 8, thresholdNonLinear, maxIterationsNonLinear, H_array);\n    H = getMatrix3dFromLinearArray(H_array);\n    return H;\n}\n\n#endif // PIC_DISABLE_EIGEN\n\n} // end namespace pic\n\n#endif // PIC_COMPUTER_VISION_HOMOGRAPHY_HPP\n"
  },
  {
    "path": "include/computer_vision/image_alignment.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_IMAGE_ALIGNMENT_HPP\n#define PIC_COMPUTER_VISION_IMAGE_ALIGNMENT_HPP\n\n#include <vector>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../features_matching/orb_descriptor.hpp\"\n#include \"../features_matching/harris_corner_detector.hpp\"\n#include \"../features_matching/binary_feature_brute_force_matcher.hpp\"\n#include \"../computer_vision/homography_matrix.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n#include \"../filtering/filter_warp_2d.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n#ifndef PIC_EIGEN_NOT_BUNDLED\n   #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief getHomographyMatrixFromTwoImage\n * @param img0\n * @param img1\n * @return\n */\nPIC_INLINE Eigen::Matrix3d getHomographyMatrixFromTwoImage(Image *img0, Image *img1)\n{\n    //output corners\n    std::vector< Eigen::Vector2f > corners_from_img0;\n    std::vector< Eigen::Vector2f > corners_from_img1;\n\n    //get corners\n    HarrisCornerDetector hcd(2.5f, 5);\n    hcd.execute(img0, &corners_from_img0);\n    hcd.execute(img1, &corners_from_img1);\n\n    //compute ORB descriptors for each corner and image\n    ORBDescriptor b_desc(31, 512);\n\n    std::vector< pic::uint* > descs0;\n    b_desc.getAll(img0, corners_from_img0, descs0);\n\n    std::vector< pic::uint* > descs1;\n    b_desc.getAll(img1, corners_from_img1, descs1);\n\n    //match descriptors\n    int n = b_desc.getDescriptorSize();\n    BinaryFeatureBruteForceMatcher bfm(&descs1, n);\n\n    std::vector< Eigen::Vector3i > matches;\n    bfm.getAllMatches(descs0, matches);\n\n    //filter matches\n    std::vector< Eigen::Vector2f > m0, m1;\n    FeatureMatcher<uint>::filterMatches(corners_from_img0, corners_from_img1, matches, m0, m1);\n\n    //estimate a homography matrix H from the matches\n    std::vector< uint > inliers;\n    Eigen::Matrix3d H = estimateHomographyWithNonLinearRefinement(m0, m1, inliers, 10000, 2.5f, 1, 10000, 1e-5f);\n\n    return H;\n}\n\n/**\n * @brief imageAlignmentWithORB\n * @param img0\n * @param img1\n * @param imgOut\n * @return\n */\nPIC_INLINE Image* imageAlignmentWithORB(Image *img0, Image *img1, Image *imgOut)\n{\n    auto H = getHomographyMatrixFromTwoImage(img0, img1);\n\n    FilterWarp2D flt;\n    flt.update(pic::MatrixConvert(H), true, false);\n    imgOut = flt.Process(Single(img0), imgOut);\n\n    return imgOut;\n}\n\n#endif\n\n}\n\n#endif // PIC_COMPUTER_VISION_IMAGE_ALIGNMENT_HPP\n"
  },
  {
    "path": "include/computer_vision/intrisics_matrix.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_INTRISICS_MATRIX_HPP\n#define PIC_COMPUTER_VISION_INTRISICS_MATRIX_HPP\n\n#include <vector>\n#include <random>\n#include <stdlib.h>\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n    #ifndef PIC_EIGEN_NOT_BUNDLED\n        #include \"../externals/Eigen/Dense\"\n        #include \"../externals/Eigen/Geometry\"\n    #else\n        #include <Eigen/Dense>\n        #include <Eigen/Geometry>\n    #endif\n\n#endif\n\nnamespace pic {\n\n/**\n * @brief getFocalLengthFromFOVAngle\n * @param fovy is an angle in radians.\n * @return\n */\nPIC_INLINE double getFocalLengthFromFOVAngle(double fovy)\n{\n    return 1.0 / tan(fovy / 2.0);\n}\n\n/**\n * @brief getFOVAngleFromFocalSensor\n * @param f is the focal length in mm\n * @param x is the sensor width in mm\n * @param y is the sensor height in mm\n * @return\n */\nPIC_INLINE double getFOVAngleFromFocalSensor(double f, double x, double y)\n{\n    double d = sqrt(x * x + y * y);\n    return 2.0 * atan(d /  (2.0 * f));\n}\n\n/**\n * @brief getFocalLengthPixels\n * @param focal_length_mm\n * @param sensor_size_mm\n * @param sensor_size_px\n * @return\n */\nPIC_INLINE double getFocalLengthPixels(double focal_length_mm, double sensor_size_mm, double sensor_size_px)\n{\n    return (focal_length_mm * sensor_size_px) / sensor_size_mm;\n}\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief getIntrinsicsMatrix\n * @param focal_length\n * @param m_x\n * @param m_y\n * @param opitical_center_x\n * @param opitical_center_y\n * @return\n */\nPIC_INLINE Eigen::Matrix3d getIntrinsicsMatrix(double focal_length, double m_x, double m_y, double opitical_center_x, double opitical_center_y)\n{\n    Eigen::Matrix3d K;\n    K.setZero();\n    K(0, 0) = focal_length * m_x;\n    K(1, 1) = focal_length * m_y;\n    K(2, 2) = 1.0;\n\n    K(0, 2) = opitical_center_x;\n    K(1, 2) = opitical_center_y;\n\n    return K;\n}\n\n/**\n * @brief getIntrinsicsMatrix\n * @param focal_length_x\n * @param focal_length_y\n * @param opitical_center_y\n * @return\n */\nPIC_INLINE Eigen::Matrix3d getIntrinsicsMatrix(double focal_length_x, double focal_length_y, double opitical_center_x, double opitical_center_y)\n{\n    Eigen::Matrix3d K;\n    K.setZero();\n    K(0, 0) = focal_length_x;\n    K(1, 1) = focal_length_y;\n    K(2, 2) = 1.0;\n\n    K(0, 2) = opitical_center_x;\n    K(1, 2) = opitical_center_y;\n\n    return K;\n}\n\n/**\n * @brief removeLensDistortion\n * @param point\n * @param K\n * @return\n */\nPIC_INLINE Eigen::Vector2d removeLensDistortion(Eigen::Vector2d &p, double k[5])\n{\n    Eigen::Vector2d ret;\n\n    double r_2 = p[0] * p[0] + p[1] * p[1];\n    double r_4 = r_2 * r_2;\n\n    double c = 1.0 + k[0] * r_2 + k[1] * r_4 + k[4] * r_4 *r_2;\n\n    Eigen::Vector2d dx;\n    dx[0] = 2 * k[2] * p[0] * p[1] + k[3] * (r_2 + 2.0 * p[0] * p[0]);\n    dx[1] = k[2] * (r_2 + 2 * p[1] * p[1]) + 2.0 * k[3] * p[0] * p[1];\n\n    ret = p * c + dx;\n\n    return ret;\n}\n\n#endif // PIC_DISABLE_EIGEN\n\n} // end namespace pic\n\n#endif // PIC_COMPUTER_VISION_INTRISICS_MATRIX_HPP\n"
  },
  {
    "path": "include/computer_vision/iterative_closest_point_2D.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_ITERATIVE_CLOSEST_POINT_2D_HPP\n#define PIC_COMPUTER_VISION_ITERATIVE_CLOSEST_POINT_2D_HPP\n\n#include <vector>\n#include <random>\n#include <stdlib.h>\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n\n#include \"../features_matching/brief_descriptor.hpp\"\n\n#include \"../util/eigen_util.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n    #ifndef PIC_EIGEN_NOT_BUNDLED\n        #include \"../externals/Eigen/Dense\"\n        #include \"../externals/Eigen/SVD\"\n        #include \"../externals/Eigen/Geometry\"\n    #else\n        #include <Eigen/Dense>\n        #include <Eigen/SVD>\n        #include <Eigen/Geometry>\n    #endif\n#endif\n\nnamespace pic {\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief getMean\n * @param p\n * @return\n */\nPIC_INLINE Eigen::Vector2f getMeanVector2f(std::vector< Eigen::Vector2f > &p)\n{\n    auto c = p[0];\n    for(unsigned int i = 1; i < p.size(); i++) {\n        c += p[i];\n    }\n    c /= float(p.size());\n\n    return c;\n}\n\n/**\n * @brief getMedianVector2f\n * @param p\n * @return\n */\nPIC_INLINE Eigen::Vector2f getMedianVector2f(std::vector< Eigen::Vector2f > &p)\n{\n    auto n = p.size();\n    float *x = new float[n];\n    float *y = new float[n];\n\n    for(unsigned int i = 0; i < n; i++) {\n        x[i] = p[i][0];\n        y[i] = p[i][1];\n    }\n\n    std::sort(x, x + n);\n    std::sort(y, y + n);\n\n    Eigen::Vector2f med;\n\n    med[0] = x[n >> 1];\n    med[1] = y[n >> 1];\n\n#ifdef PIC_DEBUG\n    printf(\"%f %f\\n\", med[0], med[1]);\n#endif\n\n    delete[] x;\n    delete[] y;\n    return med;\n}\n\nclass ICP2DTransform\n{\npublic:\n    Eigen::Matrix2f R;\n    Eigen::Vector2f t;\n    float scale;\n\n    ICP2DTransform()\n    {\n        R.setIdentity();\n\n        t.setZero();\n\n        scale = 1.0f;\n    }\n\n    ICP2DTransform(float tx, float ty, float angle, float scale)\n    {\n        this->scale = scale;\n        t[0] = tx;\n        t[1] = ty;\n\n        float cos_a = cosf(angle);\n        float sin_a = sinf(angle);\n\n        R(0, 0) =  cos_a;\n        R(0, 1) = -sin_a;\n        R(1, 0) =  sin_a;\n        R(1, 1) =  cos_a;\n    }\n\n    void print()\n    {\n        printf(\"R:\\n %f %f\\n %f %f\\n\", R(0,0), R(0,1), R(1,0), R(1,1));\n\n        printf(\"T: %f %f\\n\", t[0], t[1]);\n\n        printf(\"S: %f\\n\\n\", scale);\n    }\n\n    void apply(std::vector< Eigen::Vector2f > &points) {\n        //apply transform\n        for(unsigned int i  = 0; i < points.size(); i++) {\n            Eigen::Vector2f tmp = points[i];\n            points[i] = ((R * tmp) + t) * scale;\n        }\n    }\n\n    void apply(std::vector< Eigen::Vector2f > &points,\n               std::vector< Eigen::Vector2f > &out) {\n        //apply transform\n        for(unsigned int i  = 0; i < points.size(); i++) {\n            Eigen::Vector2f tmp = ((R * points[i]) + t) * scale;\n            out.push_back(tmp);\n        }\n    }\n\n    //\n    //\n    //\n\n    void applyC(std::vector< Eigen::Vector2f > &points) {\n\n        //compute centroid to points\n        Eigen::Vector2f c = getMeanVector2f(points);\n        auto shift = c + t;\n\n        //apply transform\n        for(unsigned int i  = 0; i < points.size(); i++) {\n            Eigen::Vector2f tmp = points[i] - c;\n            points[i] = (R * tmp) * scale + shift;\n        }\n    }\n\n    void applyC(std::vector< Eigen::Vector2f > &points,\n               std::vector< Eigen::Vector2f > &out) {\n\n        //compute centroid to points\n        Eigen::Vector2f c = getMeanVector2f(points);\n        auto shift = c + t;\n\n        //apply transform\n        for(unsigned int i  = 0; i < points.size(); i++) {\n            Eigen::Vector2f tmp = points[i] - c;\n            Eigen::Vector2f tmp2 = (R * tmp) * scale + shift;\n            out.push_back(tmp2);\n        }\n    }\n};\n\n/**\n * @brief estimateRotatioMatrixAndTranslation\n * @param p0\n * @param p1\n * @param p0_descs\n * @param p1_descs\n * @param ind\n * @return\n */\nPIC_INLINE ICP2DTransform estimateRotatioMatrixAndTranslation(std::vector< Eigen::Vector2f > &p0,\n                                                   std::vector< Eigen::Vector2f > &p1,\n                                                   std::vector< unsigned int *> &p0_descs,\n                                                   std::vector< unsigned int *> &p1_descs,\n                                                   int size_descs,\n                                                   int *ind = NULL)\n{\n    ICP2DTransform ret;\n\n    if(p0.size() < 2 || p1.size() < 2) {\n        return ret;\n    }\n\n    bool bFlag = false;\n    if(ind == NULL) {\n        ind = new int[p1.size()];\n        bFlag = true;\n    }\n\n    //compute c0\n    Eigen::Vector2f c1 = getMeanVector2f(p1);\n\n    //compute c1\n    Eigen::Vector2f c0;\n    c0.setZero();\n    int n = 0;\n\n#ifdef PIC_DEBUG\n    printf(\"Size: %d\\n\", size_descs);\n#endif\n\n    for(uint i = 0; i < p1.size(); i++) {\n        auto p_i = p1[i];\n\n        float d_min = FLT_MAX;\n        int index = -1;\n        for(uint j = 0; j < p0.size(); j++) {\n            auto delta_ij = p_i - p0[j];\n            float d_tmp = delta_ij.norm();\n\n            int value = BRIEFDescriptor::match(p0_descs[j], p1_descs[i], size_descs);\n            d_tmp += float(size_descs * 32) - float(value);\n\n            if(d_tmp < d_min) {\n                d_min = d_tmp;\n                index = j;\n            }\n\n        }\n\n        if(index > -1) {\n            ind[i] = index;\n            c0 += p0[index];\n            n++;\n        }\n    }\n    c0 /= float(n);\n\n\n    //compute R\n    Eigen::Matrix2f H;\n    H.setZero();\n\n    for(unsigned int i = 0; i < p1.size(); i++) {\n        int j = ind[i];\n\n        auto t0 = p0[j] - c0;\n        auto t1 = p1[i] - c1;\n\n        Eigen::RowVector2f t1r = t1;\n        Eigen::Matrix2f tmp = t0 * t1r;\n\n/*      tmp(0, 0) = t0(0) * t1(0);\n        tmp(0, 1) = t0(0) * t1(1);\n        tmp(1, 0) = t0(1) * t1(0);\n        tmp(1, 1) = t0(1) * t1(1);*/\n        H += tmp;\n    }\n\n    //SVD decomposition\n    Eigen::JacobiSVD< Eigen::Matrix2f > svd(H, Eigen::ComputeFullV | Eigen::ComputeFullU);\n    Eigen::Matrix2f U = svd.matrixU();\n    Eigen::Matrix2f V = svd.matrixV();\n\n    Eigen::Matrix2f U_t = U.transpose();\n    Eigen::Matrix2f R = V * U_t;\n\n    if(R.determinant() < 0.0f) {\n        for(auto i = 0; i < V.rows(); i++) {\n            V(i, 1) = -V(i, 1);\n        }\n\n        R = V * U_t;\n    }\n\n    ret.R = R;\n    ret.t = c0 - (ret.R * c1);\n\n    if(bFlag) {\n        delete[] ind;\n    }\n\n    return ret;\n}\n\n/**\n * @brief getErrorPointsList\n * @param p0\n * @param p1\n * @return\n */\nPIC_INLINE float getErrorPointsList(std::vector< Eigen::Vector2f > &p0,\n                         std::vector< Eigen::Vector2f > &p1)\n{\n    float err = 0.0f;\n    for(unsigned int i = 0; i < p0.size(); i++) {\n        auto p_i = p0[i];\n\n        float tmp_err = FLT_MAX;\n        for(unsigned int j = 0; j < p1.size(); j++) {\n            auto delta_ij = p_i - p1[j];\n            float dist = delta_ij.norm();\n\n            if(dist < tmp_err) {\n                tmp_err = dist;\n            }\n        }\n\n        err += tmp_err;\n    }\n\n    return err / float(p0.size());\n}\n\n/**\n * @brief iterativeClosestPoints2D\n * @param points_pattern\n * @param points\n * @param points_pattern_descs\n * @param points_descs\n * @param thresholdErr\n * @param maxIterations\n */\nPIC_INLINE void iterativeClosestPoints2D(std::vector<Eigen::Vector2f> &points_pattern,\n                              std::vector<Eigen::Vector2f> &points,\n                              std::vector< unsigned int *> &points_pattern_descs,\n                              std::vector< unsigned int *> &points_descs,\n                              int size_descs,\n                              int maxIterations = 1000)\n{\n    ICP2DTransform t_init;\n    t_init.t = getMedianVector2f(points) - getMeanVector2f(points_pattern);\n    t_init.apply(points_pattern);\n\n    float err = getErrorPointsList(points_pattern, points);;\n    float prev_err = 1e32f;\n    int iter = 0;\n    while(iter < maxIterations) {\n        prev_err = err;\n        ICP2DTransform t = estimateRotatioMatrixAndTranslation(points, points_pattern,\n                                                               points_descs, points_pattern_descs,\n                                                               size_descs);\n\n#ifdef PIC_DEBUG\n        t.print();\n#endif\n\n//        std::vector< Eigen::Vector2f > points_pattern_tmp;\n        t.apply(points_pattern);\n\n        err = getErrorPointsList(points_pattern, points);\n\n        /*\n        if(err < prev_err) {\n            points_pattern.clear();\n            std::copy(points_pattern_tmp.begin(), points_pattern_tmp.end(),\n                      std::back_inserter(points_pattern));\n        } else {\n            iter = maxIterations;\n        }\n        */\n\n        #ifdef PIC_DEBUG\n            printf(\"Error: %f %f\\n\", err, prev_err);\n        #endif\n\n        iter++;\n    }\n}\n\n#endif\n} // end namespace pic\n\n#endif // PIC_COMPUTER_VISION_ITERATIVE_CLOSEST_POINT_2D_HPP\n"
  },
  {
    "path": "include/computer_vision/nelder_mead_opt_ICP_2D.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_NELDER_MEAD_OPT_ICP_2D_HPP\n#define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_ICP_2D_HPP\n\n#include \"../util/eigen_util.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../util/matrix_3_x_3.hpp\"\n#include \"../util/nelder_mead_opt_base.hpp\"\n\n#include \"../computer_vision/iterative_closest_point_2D.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n#ifndef PIC_EIGEN_NOT_BUNDLED\n   #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\nclass NelderMeadOptICP2D: public NelderMeadOptBase<float>\n{\npublic:\n    std::vector< Eigen::Vector2f > points_pattern, points;\n\n    /**\n     * @brief NelderMeadOptICP2D\n     * @param points_pattern\n     * @param points\n     */\n    NelderMeadOptICP2D(std::vector< Eigen::Vector2f > &points_pattern,\n                       std::vector< Eigen::Vector2f > &points) : NelderMeadOptBase()\n    {\n        std::copy(points_pattern.begin(), points_pattern.end(),\n                  std::back_inserter(this->points_pattern));\n\n        std::copy(points.begin(), points.end(),\n                  std::back_inserter(this->points));\n    }\n\n    /**\n     * @brief function\n     * @param x\n     * @param n\n     * @return\n     */\n    float function(float *x, unsigned int n)\n    {\n        float scale = 1.0f;\n        if(n == 4) {\n            if(x[3] < 1.0f) {\n                return FLT_MAX;\n            }\n\n            scale = x[3];\n        }\n\n        ICP2DTransform t(x[0], x[1], x[2], scale);\n\n        std::vector< Eigen::Vector2f > out;\n        t.applyC(points_pattern, out);\n\n        return getErrorPointsList(out, points);\n    }\n};\n#endif\n\n}\n\n#endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_ICP_2D_HPP\n"
  },
  {
    "path": "include/computer_vision/nelder_mead_opt_fundamental.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_NELDER_MEAD_OPT_FUNDAMENTAL_HPP\n#define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_FUNDAMENTAL_HPP\n\n#include \"../util/eigen_util.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../util/matrix_3_x_3.hpp\"\n#include \"../util/nelder_mead_opt_base.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n#ifndef PIC_EIGEN_NOT_BUNDLED\n   #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\nclass NelderMeadOptFundamental: public NelderMeadOptBase<float>\n{\npublic:\n    std::vector< Eigen::Vector2f > m0, m1;\n\n    /**\n     * @brief NelderMeadOptFundamental\n     * @param m0\n     * @param m1\n     * @param inliers\n     */\n    NelderMeadOptFundamental(std::vector< Eigen::Vector2f > &m0,\n                             std::vector< Eigen::Vector2f > &m1,\n                             std::vector< unsigned int> inliers) : NelderMeadOptBase()\n    {\n        filterInliers(m0, inliers, this->m0);\n        filterInliers(m1, inliers, this->m1);\n    }\n\n    /**\n     * @brief Fundamental\n     * @param F\n     * @param p\n     * @return\n     */\n    double FundamentalDistance(Eigen::Matrix3d &F, Eigen::Vector3d &p0, Eigen::Vector3d  &p1)\n    {        \n        Eigen::Vector3d F_p0 = F * p0;\n\n        double norm = F_p0[0] * F_p0[0] + F_p0[1] * F_p0[1];\n        if(norm > 0.0) {\n            norm = sqrt(norm);\n            F_p0 /= norm;\n        }\n\n        //computing distance\n\n        return F_p0.dot(p1);\n    }\n\n    /**\n     * @brief function\n     * @param x\n     * @param n\n     * @return\n     */\n    float function(float *x, unsigned int n)\n    {\n        Eigen::Matrix3d F = getMatrixdFromLinearArray(x, 3, 3);\n        Eigen::Matrix3d F_t = Eigen::Transpose<Eigen::Matrix3d>(F);\n\n        double err = 0.0;\n        for(unsigned int i = 0; i < m0.size(); i++) {\n\n            Eigen::Vector3d p0 = Eigen::Vector3d(m0[i][0], m0[i][1], 1.0);\n            Eigen::Vector3d p1 = Eigen::Vector3d(m1[i][0], m1[i][1], 1.0);\n\n            double tmp_err;\n\n            // | p1^t F p0 | error           \n            tmp_err = FundamentalDistance(F, p0, p1);\n            err += tmp_err * tmp_err;\n\n            // | p0^t F^t p1 | error\n            tmp_err = FundamentalDistance(F_t, p1, p0);\n            err += tmp_err * tmp_err;\n        }\n\n        return float(err);\n    }\n};\n#endif\n\n}\n\n#endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_FUNDAMENTAL_HPP\n"
  },
  {
    "path": "include/computer_vision/nelder_mead_opt_gordon_lowe.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_NELDER_MEAD_OPT_GORDON_LOWE_HPP\n#define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_GORDON_LOWE_HPP\n\n#include \"../util/matrix_3_x_3.hpp\"\n#include \"../util/nelder_mead_opt_base.hpp\"\n#include \"../computer_vision/camera_matrix.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n#ifndef PIC_EIGEN_NOT_BUNDLED\n   #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n#define GL_PACKED_CAMERA_SIZE 11\n#define GL_3D_POINT_SIZE 3\n\nclass NelderMeadOptGordonLowe: public NelderMeadOptBase<double>\n{\npublic:\n    std::vector< std::vector< Vec<2, float> > > m;\n\n    /**\n     * @brief NelderMeadOptGordonLowe\n     * @param m0\n     * @param m1\n     */\n    NelderMeadOptGordonLowe(std::vector< Vec<2, float> > m0, std::vector< Vec<2, float> > m1) : NelderMeadOptBase()\n    {\n        this->m.push_back(m0);\n        this->m.push_back(m1);\n    }    \n\n    static Eigen::Matrix34d parseCameraMatrix(float *x, unsigned int index)\n    {\n        Eigen::Matrix3d K, R;\n        Eigen::Vector3d t;\n\n        //offset of the matrix\n        unsigned int c = index * 11;\n\n        Eigen::Quaternion<double> reg;\n        reg.x() = x[c]; c++;\n        reg.y() = x[c]; c++;\n        reg.z() = x[c]; c++;\n        reg.w() = x[c]; c++;\n        R = reg.toRotationMatrix();\n\n        t[0] = x[c]; c++;\n        t[1] = x[c]; c++;\n        t[2] = x[c]; c++;\n\n        K.setZero();\n        K(0, 0) = x[c]; c++;\n        K(1, 1) = x[c]; c++;\n        K(0, 2) = x[c]; c++;\n        K(1, 2) = x[c];\n        K(2, 2) = 1.0;\n\n        return getCameraMatrix(K, R, t);\n    }\n\n    /**\n     * @brief ProjectionError\n     * @param x\n     * @param index\n     * @return\n     */\n    double ProjectionError(float *x, unsigned int index) {\n\n       double err = 0.0;\n\n       Eigen::Matrix34d P = parseCameraMatrix(x, index);\n\n       //offset of vertices\n       int c = GL_PACKED_CAMERA_SIZE * int(m.size());\n\n       Eigen::Vector4d point;\n       for(uint i = 0; i < m[index].size(); i++) {\n           point = Eigen::Vector4d(x[c], x[c + 1], x[c + 2], 1.0);\n\n           Eigen::Vector3d point_proj = P * point;\n           point_proj /= point_proj[2];\n\n           double dx = point_proj[0] - m[index][i][0];\n           double dy = point_proj[1] - m[index][i][1];\n\n           err += dx * dx + dy * dy;\n\n           c += 3;\n       }\n\n\n       return err;\n    }\n\n    /**\n     * @brief function\n     * @param x\n     * @param n\n     * @return\n     */\n    float function(float *x, unsigned int n)\n    {       \n        int n2 = int(m.size() * m[0].size());\n        double err = sqrt((ProjectionError(x, 0) + ProjectionError(x, 1)) / double(n2));\n\n        return float(err);\n    }\n\n\n    /**\n     * @brief init3DPoints\n     * @param K\n     * @param m\n     * @param x\n     * @param distance\n     */\n    static void init3DPoints(Eigen::Matrix3d K, std::vector< Vec<2, float> > &m, std::vector< Eigen::Vector3d > &x, float distance = 20.0f)\n    {\n        Eigen::Matrix3d K_inv = K.inverse();\n    \\\n        printf(\"Points: %zd\\n\", m.size());\n\n        for(unsigned int i = 0; i < m.size(); i++) {\n            Eigen::Vector3d point = Eigen::Vector3d (m[i][0], m[i][1], 1.0);\n\n            point = K_inv * point;\n\n            point *= distance;\n\n            x.push_back(point);\n        }\n    }\n\n    /**\n     * @brief prepareInputData\n     * @param K\n     * @param R\n     * @param t\n     * @param x\n     * @param ret_size\n     * @return\n     */\n    static double *prepareInputData(std::vector< Eigen::Matrix3d > &K, std::vector< Eigen::Matrix3d > &R, std::vector< Eigen::Vector3d > &t, std::vector< Eigen::Vector3d > &x, unsigned int &ret_size)\n    {\n        if(R.size() != t.size()) {\n            return NULL;\n        }\n\n        if(x.empty()) {\n            return NULL;\n        }\n\n        int n = int (R.size());\n        ret_size = GL_PACKED_CAMERA_SIZE * n + GL_3D_POINT_SIZE * int(x.size());\n        double *ret = new double[ret_size];\n\n        int c = 0;\n        for(int i = 0; i < n; i++) {\n\n            Eigen::Quaternion<double> reg(R[i]);\n\n            ret[c] = reg.x(); c++;\n            ret[c] = reg.y(); c++;\n            ret[c] = reg.z(); c++;\n            ret[c] = reg.w(); c++;\n\n            ret[c] = t[i][0]; c++;\n            ret[c] = t[i][1]; c++;\n            ret[c] = t[i][2]; c++;\n\n            ret[c] = K[i](0, 0); c++;\n            ret[c] = K[i](1, 1); c++;\n            ret[c] = K[i](0, 2); c++;\n            ret[c] = K[i](1, 2); c++;\n        }\n\n        for(size_t i = 0; i < x.size(); i++) {\n            ret[c] = x[i][0]; c++;\n            ret[c] = x[i][1]; c++;\n            ret[c] = x[i][2]; c++;\n        }\n\n        return ret;\n    }\n};\n\n#endif\n\n}\n\n#endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_GORDON_LOWE_HPP\n"
  },
  {
    "path": "include/computer_vision/nelder_mead_opt_homography.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_NELDER_MEAD_OPT_HOMOGRAPHY_HPP\n#define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_HOMOGRAPHY_HPP\n\n#include \"../util/nelder_mead_opt_base.hpp\"\n#include \"../util/std_util.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n#ifndef PIC_EIGEN_NOT_BUNDLED\n   #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\nclass NelderMeadOptHomography: public NelderMeadOptBase<float>\n{\npublic:\n    std::vector< Eigen::Vector2f > m0, m1;\n\n    /**\n     * @brief NelderMeadOptHomography\n     * @param m0\n     * @param m1\n     * @param inliers\n     */\n    NelderMeadOptHomography(std::vector< Eigen::Vector2f > &m0,\n                            std::vector< Eigen::Vector2f > &m1,\n                            std::vector< unsigned int > inliers) : NelderMeadOptBase()\n    {\n        filterInliers(m0, inliers, this->m0);\n        filterInliers(m1, inliers, this->m1);\n    }\n\n    /**\n     * @brief Homography\n     * @param H\n     * @param p\n     * @return\n     */\n    Eigen::Vector2f Homography(Eigen::Matrix3f &H, Eigen::Vector2f &p)\n    {\n        Eigen::Vector3f ret = H * Eigen::Vector3f(p[0], p[1], 1.0f);\n\n        return Eigen::Vector2f(ret[0] / ret[2], ret[1] / ret[2]);\n    }\n\n    /**\n     * @brief function\n     * @param x\n     * @param n\n     * @return\n     */\n    float function(float *x, unsigned int n)\n    {\n        float err = 0.0f;\n\n        Eigen::Matrix3f H = getMatrixfFromLinearArray(x, 3, 3);\n        H(2, 2) = 1.0f;\n\n        Eigen::Matrix3f H_inv = H.inverse();\n\n        for(unsigned int i = 0; i < m0.size(); i++) {\n            float dU, dV;\n\n            // | H p0 - p1 | error\n            Eigen::Vector2f p0_H = Homography(H, m0[i]);\n\n            dU = m1[i][0] - p0_H[0];\n            dV = m1[i][1] - p0_H[1];\n\n            err += dU * dU + dV * dV;\n\n            // | H p1 - p0 | error\n            Eigen::Vector2f p1_H = Homography(H_inv, m1[i]);\n\n            dU = m0[i][0] - p1_H[0];\n            dV = m0[i][1] - p1_H[1];\n\n            err += dU * dU + dV * dV;\n\n        }\n\n        return err;\n    }\n\n    /**\n     * @brief run\n     * @param x_start\n     * @param n\n     * @param epsilon\n     * @param x\n     * @return\n     */\n    float *run(float *x_start, unsigned int n, float epsilon = 1e-4f, int max_iterations = 1000, float *x = NULL)\n    {\n        if(n != 8) {\n            return x_start;\n        }\n\n        if(x == NULL) {\n            x = new float[n + 1];\n        }\n\n        x = run_aux(x_start, n, epsilon, max_iterations, x);\n        x[8] = 1.0f;\n\n        return x;\n    }\n};\n\n#endif\n\n}\n\n#endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_HOMOGRAPHY_HPP\n"
  },
  {
    "path": "include/computer_vision/nelder_mead_opt_radial_distortion.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_NELDER_MEAD_OPT_RADIAL_DISTORTION_HPP\n#define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_RADIAL_DISTORTION_HPP\n\n#include \"../util/matrix_3_x_3.hpp\"\n#include \"../util/nelder_mead_opt_base.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n#ifndef PIC_EIGEN_NOT_BUNDLED\n   #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\nclass NelderMeadOptRadialDistortion: public NelderMeadOptBase<float>\n{\npublic:\n\n    std::vector< Eigen::Matrix34d > M;\n    std::vector< Eigen::Vector3d >  *p3d;\n    std::vector< std::vector< Eigen::Vector2f > * > p2d;\n\n    /**\n     * @brief NelderMeadOptRadialDistortion\n     * @param M0\n     * @param M1\n     */\n    NelderMeadOptRadialDistortion(Eigen::Matrix34d &M0, Eigen::Matrix34d &M1,\n                               std::vector< Eigen::Vector2f > *p2d_0,\n                               std::vector< Eigen::Vector2f > *p2d_1,\n                               std::vector< Eigen::Vector3d > *p3d) : NelderMeadOptBase()\n    {\n        this->M.push_back(M0);\n        this->M.push_back(M1);\n\n        this->p2d.push_back(p2d_0);\n        this->p2d.push_back(p2d_1);\n        this->p3d = p3d;\n    }\n\n    /**\n     * @brief function\n     * @param x\n     * @param n\n     * @return\n     */\n    float function(float *x, unsigned int n)\n    {\n        float lambda = x[0];\n\n        double err = 0.0;\n\n        double cx = M[0](0,2);\n        double cy = M[0](1,2);\n        double fx = M[0](0, 0);\n        double fy = M[0](1, 1);\n\n        for(unsigned int i = 0; i < M.size(); i++) {\n            for(unsigned int j = 0; j < p3d->size(); j++) {\n                Eigen::Vector3d tmp = p3d->at(j);\n                Eigen::Vector4d point = Eigen::Vector4d(tmp[0], tmp[1], tmp[2], 1.0);\n                Eigen::Vector3d proj = M[i] * point;\n\n                proj[0] /= proj[2];\n                proj[1] /= proj[2];\n\n                double x_cx =  (proj[0] - cx);\n                double y_cy =  (proj[1] - cy);\n\n                double dx = x_cx / fx;\n                double dy = y_cy / fy;\n                double rho_sq = dx * dx + dy * dy;\n\n\n                double factor = 1.0 / (1.0 + rho_sq * lambda);\n\n                proj[0] = x_cx * factor + cx;\n                proj[1] = y_cy * factor + cy;\n\n                Eigen::Vector2f tmp2d = p2d[i]->at(j);\n                double d_err_x = tmp2d[0] - proj[0];\n                double d_err_y = tmp2d[1] - proj[1];\n\n                err += d_err_x * d_err_x + d_err_y * d_err_y;\n            }\n        }\n\n        err /= p3d->size();\n\n        //err += 10.0f * lambda * lambda;\n\n        return float(err);\n    }\n};\n\n#endif\n\n}\n\n#endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_RADIAL_DISTORTION_HPP\n"
  },
  {
    "path": "include/computer_vision/nelder_mead_opt_triangulation.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_NELDER_MEAD_OPT_TRIANGULATION_HPP\n#define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_TRIANGULATION_HPP\n\n#include \"../util/matrix_3_x_3.hpp\"\n#include \"../util/nelder_mead_opt_base.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n#ifndef PIC_EIGEN_NOT_BUNDLED\n   #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\nclass NelderMeadOptTriangulation: public NelderMeadOptBase<double>\n{\npublic:\n\n    std::vector< Eigen::Matrix34d > M;\n    std::vector< Eigen::Vector2f > p;\n\n    /**\n     * @brief NelderMeadOptTriangulation\n     * @param M0\n     * @param M1\n     */\n    NelderMeadOptTriangulation(Eigen::Matrix34d &M0, Eigen::Matrix34d &M1) : NelderMeadOptBase()\n    {\n        this->M.push_back(M0);\n        this->M.push_back(M1);\n    }\n\n    /**\n     * @brief NelderMeadOptTriangulation\n     * @param M0\n     * @param M1\n     */\n    NelderMeadOptTriangulation(std::vector< Eigen::Matrix34d> &M) : NelderMeadOptBase()\n    {\n        this->M.assign(M.begin(), M.end());\n    }\n\n    /**\n     * @brief update\n     * @param p0\n     * @param p1\n     */\n    void update(Eigen::Vector2f &p0, Eigen::Vector2f &p1)\n    {\n        this->p.clear();\n        this->p.push_back(p0);\n        this->p.push_back(p1);\n    }\n\n    /**\n     * @brief update\n     * @param p0\n     * @param p1\n     */\n    void update(std::vector< Eigen::Vector2f> &p)\n    {\n        this->p.clear();\n        this->p.assign(p.begin(), p.end());\n    }\n\n    /**\n     * @brief function\n     * @param x\n     * @param n\n     * @return\n     */\n    double function(double *x, unsigned int n)\n    {\n        Eigen::Vector4d point(x[0], x[1], x[2], 1.0);\n\n        double err = 0.0;\n        for(unsigned int i = 0; i < M.size(); i++) {\n            Eigen::Vector3d proj = M[i] * point;\n\n            proj[0] /= proj[2];\n            proj[1] /= proj[2];\n\n            double dx = p[i][0] - proj[0];\n            double dy = p[i][1] - proj[1];\n\n            err += (dx * dx) + (dy * dy);\n        }\n\n        return err;\n    }\n};\n\n#endif\n\n}\n\n#endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_TRIANGULATION_HPP\n"
  },
  {
    "path": "include/computer_vision/rectification.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_RECTIFICATION_HPP\n#define PIC_COMPUTER_VISION_RECTIFICATION_HPP\n\n#include <vector>\n#include <cmath>\n#include <stdlib.h>\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n\n#include \"../image_vec.hpp\"\n\n#include \"../filtering/filter_warp_2d.hpp\"\n#include \"../filtering/filter_rotation.hpp\"\n\n#include \"../computer_vision/camera_matrix.hpp\"\n\n#include \"../util/eigen_util.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n    #include \"../externals/Eigen/SVD\"\n    #include \"../externals/Eigen/Geometry\"\n#else\n    #include <Eigen/Dense>\n    #include <Eigen/SVD>\n    #include <Eigen/Geometry>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief computeImageRectificationWarp\n * @param img0 is the first image to rectify\n * @param img1 is the second image to rectify\n * @param T0 is the homography for img0\n * @param T1 is the homography for img0\n * @param out is the output as an ImageVec with two images; i.e., rectified versions of img0 and img1\n * @return\n */\nPIC_INLINE ImageVec *computeImageRectificationWarp(Image *img0,\n                                                   Image *img1,\n                                                   Eigen::Matrix3d &T0,\n                                                   Eigen::Matrix3d &T1,\n                                                   ImageVec *out,\n                                                   bool bPartial = true)\n{\n    if(img0 == NULL || img1 == NULL) {\n        return out;\n    }\n\n    if(out == NULL) {\n        out = new ImageVec();\n    }\n\n    auto H0 = MatrixConvert(T0);\n    auto H1 = MatrixConvert(T1);\n    FilterWarp2D warp0(H0);\n    FilterWarp2D warp1(H1);\n\n    int bmin0[2], bmin1[2], bmax0[2], bmax1[2];\n\n    FilterWarp2D::computeBoundingBox(H0, warp0.getBCentroid(), img0->widthf, img0->heightf, bmin0, bmax0);\n    FilterWarp2D::computeBoundingBox(H1, warp1.getBCentroid(), img1->widthf, img1->heightf, bmin1, bmax1);\n\n    if(bPartial) {\n        bmin0[1] = MIN(bmin0[1], bmin1[1]);\n        bmax0[1] = MAX(bmax0[1], bmax1[1]);\n\n        bmin1[1] = bmin0[1];\n        bmax1[1] = bmax0[1];\n    } else {\n        for(int i = 0; i < 2; i++) {\n            bmin0[i] = MIN(bmin0[i], bmin1[i]);\n            bmin1[i] = bmin0[i];\n\n            bmax0[i] = MAX(bmax0[i], bmax1[i]);\n            bmax1[i] = bmax0[i];\n        }\n    }\n\n    warp0.setBoundingBox(bmin0, bmax0);\n    warp1.setBoundingBox(bmin1, bmax1);\n\n    Image *img0_r = NULL;\n    Image *img1_r = NULL;\n\n    bool bTest = out->size() == 2;\n    if(bTest) {\n        img0_r = out->at(0);\n        img1_r = out->at(1);\n    }\n\n    img0_r = warp0.Process(Single(img0), img0_r);\n    img1_r = warp1.Process(Single(img1), img1_r);\n\n    if(!bTest) {\n        out->push_back(img0_r);\n        out->push_back(img1_r);\n    }\n\n    return out;\n}\n\n/**\n * @brief computeImageRectification this function rectifies two images\n * @param img0 is the first image to rectify\n * @param img1 is the second image to rectify\n * @param M0 is the camera matrix (3x4) of img0\n * @param M1 is the camera matrix (3x4) of img1\n * @param out is the output as an ImageVec with two images; i.e., rectified versions of img0 and img1\n * @return is the output as an ImageVec with two images; i.e., rectified versions of img0 and img1\n\n */\nPIC_INLINE ImageVec *computeImageRectification(Image *img0,\n                                               Image *img1,\n                                               Eigen::Matrix34d &M0,\n                                               Eigen::Matrix34d &M1,\n                                               ImageVec *out = NULL,\n                                               bool bPartial = true)\n{\n    //NOTE: we should check that img0 and img1 are valid...\n    if(img0 == NULL || img1 == NULL) {\n        return out;\n    }\n\n    if(out == NULL) {\n        out = new ImageVec();\n    }\n\n    Eigen::Matrix34d M0_r, M1_r;\n    Eigen::Matrix3d T0, T1;\n\n    cameraRectify(M0, M1, M0_r, M1_r, T0, T1);\n\n    //check if the trasform is correct!\n    Eigen::Vector3d corners[4], corners_T0[4];\n    corners[0] = Eigen::Vector3d(0.0, 0.0, 1.0);\n    corners[1] = Eigen::Vector3d(img0->widthf, 0.0, 1.0);\n    corners[2] = Eigen::Vector3d(img0->widthf, img0->heightf, 1.0);\n    corners[3] = Eigen::Vector3d(img0->heightf, 0.0, 1.0);\n\n    for(int i = 0; i < 4; i ++) {\n        corners_T0[i] = T0 * corners[i];\n        corners_T0[i] /= corners_T0[i][2];\n    }\n\n    auto d_c   = corners[2] - corners[0];\n    auto d_c_T0 = corners_T0[2] - corners_T0[0];\n\n    bool b_x = std::signbit(d_c[0]) == std::signbit(d_c_T0[0]);\n    bool b_y = std::signbit(d_c[1]) == std::signbit(d_c_T0[1]);\n\n    double f_x = b_x ? 1.0 : -1.0;\n    double f_y = b_y ? 1.0 : -1.0;\n\n\n    auto H = DiagonalMatrix(Eigen::Vector3d(f_x, f_y, 1));\n    T0 = H * T0;\n    T1 = H * T1;\n\n    out = computeImageRectificationWarp(img0, img1, T0, T1, out, bPartial);\n\n    return out;\n}\n\n/**\n * @brief computeImageRectification this function rectifies two images\n * @param img0 is the first image to rectify\n * @param img1 is the second image to rectify\n * @param K0 is the intrisic matrix of img0\n * @param R0 is the rotation matrix of img0\n * @param t0 is the translation vector of img0\n * @param K1 is the intrisic matrix of im1\n * @param R1 is the rotation matrix of img1\n * @param t1 is the translation vector of img1\n * @param out is the output as an ImageVec with two images; i.e., rectified versions of img0 and img1\n * @return is the output as an ImageVec with two images; i.e., rectified versions of img0 and img1\n */\nPIC_INLINE ImageVec *computeImageRectification(Image *img0,\n                                               Image *img1,\n                                               Eigen::Matrix3d &K0,\n                                               Eigen::Matrix3d &R0,\n                                               Eigen::Vector3d &t0,\n                                               Eigen::Matrix3d &K1,\n                                               Eigen::Matrix3d &R1,\n                                               Eigen::Vector3d &t1,\n                                               ImageVec *out = NULL,\n                                               bool bPartial = true)\n{\n    //NOTE: we should check that img0 and img1 are valid...\n    if(img0 == NULL || img1 == NULL) {\n        return out;\n    }\n\n    if(out == NULL) {\n        out = new ImageVec();\n    }\n\n    Eigen::Matrix34d M0_r, M1_r;\n    Eigen::Matrix3d T0, T1;\n\n    cameraRectify(K0, R0, t0, K1, R1, t1, M0_r, M1_r, T0, T1);\n\n    out = computeImageRectificationWarp(img0, img1, T0, T1, out, bPartial);\n\n    return out;\n}\n\n/**\n * @brief alignPanoramicLL\n * @param R0\n * @param t0\n * @param R1\n * @param t1\n * @param R01\n * @param t01\n */\nPIC_INLINE void alignPanoramicLL(Eigen::Matrix3d &R0, Eigen::Vector3d &t0,\n                                 Eigen::Matrix3d &R1, Eigen::Vector3d &t1,\n                                 Eigen::Matrix3d &R01, Eigen::Vector3d &t01)\n{\n    t01 = t1 - t0;\n    Eigen::Matrix3d R0_t = Eigen::Transpose< Eigen::Matrix3d >(R0);\n\n    //R0 --> I\n    //t0 --> 0\n\n    R01 = R0_t * R1;\n    t01 = R0_t * t01;\n}\n\n/**\n * @brief computeImageRectificationPanoramicLL\n * @param img0\n * @param img1\n * @param R01\n * @param t01\n * @param out\n * @return\n */\nPIC_INLINE ImageVec *computeImageRectificationPanoramicLL(\n                                               Image *img0,\n                                               Image *img1,\n                                               Eigen::Matrix3d &R01,\n                                               Eigen::Vector3d &t01,\n                                               ImageVec *out = NULL)\n{\n    //NOTE: we should check that img0 and img1 are valid...\n    if(img0 == NULL || img1 == NULL) {\n        return out;\n    }\n\n    if(out == NULL) {\n        out = new ImageVec();\n    }\n\n    //rotation 1\n    Eigen::Matrix3d R01_t = Eigen::Transpose< Eigen::Matrix3d >(R01);\n\n    //rotation 2\n    Eigen::Vector3d X(0.0, 1.0, 0.0);\n    Eigen::Vector3d n;\n    n = t01.cross(X);\n    n.normalize();\n\n    double alpha = std::acos(t01.dot(X));\n    Eigen::Matrix3d rot, rotation1;\n\n    rot = Eigen::AngleAxisd(alpha, n);\n    rotation1 = rot * R01_t;\n\n    Eigen::Matrix3f rotation0f, rotation1f;\n    rotation0f = rot.cast<float>();\n    rotation1f = rotation1.cast<float>();\n\n    out->push_back(FilterRotation::execute(img0, NULL, rotation0f));\n    out->push_back(FilterRotation::execute(img1, NULL, rotation1f));\n    return out;\n}\n\n#endif // PIC_DISABLE_EIGEN\n\n} // end namespace pic\n\n#endif // PIC_COMPUTER_VISION_RECTIFICATION_HPP\n"
  },
  {
    "path": "include/computer_vision/simple_ply.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_SIMPLE_PLY_HPP\n#define PIC_COMPUTER_VISION_SIMPLE_PLY_HPP\n\n#include <vector>\n#include <random>\n#include <stdlib.h>\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n\n#include \"../util/eigen_util.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n    #include \"../externals/Eigen/SVD\"\n    #include \"../externals/Eigen/Geometry\"\n#else\n    #include <Eigen/Dense>\n    #include <Eigen/SVD>\n    #include <Eigen/Geometry>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\nPIC_INLINE bool writeSimplePLY(std::string name,\n                               std::vector< Eigen::Vector3d > &points_3d,\n                               std::vector< unsigned char > &colors)\n{\n    //write a PLY file\n    FILE *file = fopen(name.c_str(), \"w\");\n\n    if (file == NULL) {\n        return false;\n    }\n\n    bool bColor = colors.size() == (points_3d.size() * 3);\n\n    fprintf(file,\"ply\\n\");\n    fprintf(file,\"format ascii 1.0\\n\");\n    fprintf(file,\"element vertex %d\\n\", int(points_3d.size()));\n\n    fprintf(file,\"property float x\\n\");\n    fprintf(file,\"property float y\\n\");\n    fprintf(file,\"property float z\\n\");\n\n    if(bColor) {\n        fprintf(file,\"property uchar red\\n\");\n        fprintf(file,\"property uchar green\\n\");\n        fprintf(file,\"property uchar blue\\n\");\n        fprintf(file,\"property uchar alpha\\n\");\n    }\n    fprintf(file,\"end_header\\n\");\n\n    for(unsigned int i = 0; i < points_3d.size(); i++) {\n        //write position information\n        fprintf(file, \"%3.4f %3.4f %3.4f \", points_3d[i][0], points_3d[i][1], points_3d[i][2]);\n\n        //write color information\n        if(bColor) {\n            auto k = i * 3;\n            fprintf(file, \" %d %d %d 255\\n\", colors[k], colors[k + 1], colors[k + 2]);\n        }\n    }\n\n    fclose(file);\n    return true;\n}\n\n#endif // PIC_DISABLE_EIGEN\n\n} // end namespace pic\n\n#endif // PIC_COMPUTER_VISION_SIMPLE_PLY_HPP\n"
  },
  {
    "path": "include/computer_vision/stereo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_STEREO_HPP\n#define PIC_COMPUTER_VISION_STEREO_HPP\n\n#include <vector>\n#include <random>\n#include <stdlib.h>\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n\n#include \"../filtering/filter_disparity.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gradient.hpp\"\n\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The Stereo class\n */\nclass Stereo\n{\nprotected:\n    FilterLuminance flt_lum;\n    FilterGradient  flt_grad;\n    FilterDisparity flt_disp;\n\n    int kernel_size, max_disparity, max_cross_check;\n\npublic:\n\n    /**\n     * @brief Stereo\n     */\n    Stereo()\n    {\n        init(7, 200, 8);\n    }\n\n    /**\n     * @brief Stereo\n     */\n    Stereo(int kernel_size, int max_disparity, int max_cross_check)\n    {\n        init(kernel_size, max_disparity, max_cross_check);\n    }\n\n    /**\n     * @brief init\n     * @param kernel_size\n     * @param max_disparity\n     * @param max_cross_check\n     */\n    void init(int kernel_size, int max_disparity, int max_cross_check)\n    {\n        kernel_size = kernel_size > 0 ? kernel_size : 7;\n        max_cross_check = max_cross_check > 0 ? max_cross_check : 4;\n\n        this->kernel_size = kernel_size;\n        this->max_disparity = max_disparity;\n        this->max_cross_check = max_cross_check;\n\n        flt_disp.update(max_disparity, kernel_size, 0.05f);\n    }\n\n    /**\n     * @brief crossCheck\n     * @param disp_left\n     * @param disp_right\n     */\n    void crossCheck(Image *disp_left, Image *disp_right)\n    {\n        for(int i = 0; i < disp_left->height; i++) {\n\n            for(int j = 0; j < disp_left->width; j++) {\n\n                float *dL = (*disp_left)(j, i);\n\n                if(dL[1] > 0.0f) { // if it is valid\n\n                    int j_forward = int(dL[0]);\n                    float *dR = (*disp_right)(j_forward, i);\n\n                    if(dR[1] > 0.0f) { // if it is valid\n                        int j_e = int(dR[0]);\n\n                        if(std::abs(j - j_e) > max_cross_check) {\n                            dL[0] = 0.0f;\n                            dL[1] = -1.0f;\n                        }\n                    }\n                }\n            }\n        }\n    }\n\n    /**\n      * @brief computeLocalDisparity\n      * @param disp\n      */\n    static void computeLocalDisparity(Image *disp)\n    {\n        for(int i = 0; i < disp->height; i++) {\n\n            for(int j = 0; j < disp->width; j++) {\n                float *tmp = (*disp)(j, i);\n\n                tmp[0] -= float(j);\n            }\n        }\n    }\n\n    /**\n     * @brief execute\n     * @param img_left\n     * @param img_right\n     * @param disp_left\n     * @param disp_right\n     */\n    void execute(Image *img_left, Image *img_right,\n                 Image *disp_left, Image *disp_right)\n    {\n        if(img_left == NULL || img_right == NULL ||\n           disp_left == NULL || disp_right == NULL) {\n            return;\n        }\n\n        if(max_disparity < 0) {\n            max_disparity = MIN(img_left->width, img_right->width) >> 1;\n        }\n\n        auto i_l_l = flt_lum.Process(Single(img_left), NULL);\n        auto i_r_l = flt_lum.Process(Single(img_right), NULL);\n\n        auto i_l_g = flt_grad.Process(Single(i_l_l), NULL);\n        auto i_r_g = flt_grad.Process(Single(i_r_l), NULL);\n\n        disp_left  = flt_disp.Process(Quad(img_left, img_right, i_l_g, i_r_g), disp_left);\n        disp_right = flt_disp.Process(Quad(img_right, img_left, i_r_g, i_l_g), disp_right);\n\n        crossCheck(disp_left, disp_right);\n        crossCheck(disp_right, disp_left);\n\n        computeLocalDisparity(disp_left);\n        computeLocalDisparity(disp_right);\n    }\n};\n\n} // end namespace pic\n\n#endif // PIC_COMPUTER_VISION_STEREO_HPP\n"
  },
  {
    "path": "include/computer_vision/triangulation.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_TRIANGULATION_HPP\n#define PIC_COMPUTER_VISION_TRIANGULATION_HPP\n\n#include <vector>\n#include <random>\n#include <stdlib.h>\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n\n#include \"../util/math.hpp\"\n\n#include \"../util/eigen_util.hpp\"\n\n#include \"../computer_vision/nelder_mead_opt_triangulation.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief triangulationLonguetHiggins computes triangulation using Longuet-Higgins equations.\n * @param point_0 is the point from the first view that matches point_1\n * @param point_1 is the point from the second view that matches point_0\n * @param R is the rotation matrix between the two views.\n * @param t is the translation matrix between the two views.\n * @return\n */\nPIC_INLINE Eigen::Vector3d triangulationLonguetHiggins(Eigen::Vector3d &point_0, Eigen::Vector3d &point_1, Eigen::Matrix3d &R, Eigen::Vector3d &t)\n{\n    Eigen::Vector3d ret;\n\n    Eigen::Vector3d r_0 = Eigen::Vector3d(R(0, 0), R(0, 1), R(0, 2));\n    Eigen::Vector3d r_2 = Eigen::Vector3d(R(2, 0), R(2, 1), R(2, 2));\n\n    Eigen::Vector3d tmp = r_0 - point_1[0] * r_2;\n\n    ret[2] = tmp.dot(t) / tmp.dot(point_0);\n\n    ret[0] = point_0[0] * ret[2];\n    ret[1] = point_0[1] * ret[2];\n\n    return ret;\n}\n\n/**\n * @brief triangulationHartl\n * Sturm\n * @param point_0\n * @param point_1\n * @param R\n * @param t\n * @return\n */\nPIC_INLINE Eigen::Vector4d triangulationHartleySturm(Eigen::Vector3d &point_0, Eigen::Vector3d &point_1,\n                                          Eigen::Matrix34d &M0, Eigen::Matrix34d &M1, int maxIter = 100)\n{\n    Eigen::Vector4d M0_row[3], M1_row[3];\n\n    for(int i = 0; i < 3; i++) {\n        M0_row[i] = Eigen::Vector4d(M0(i, 0), M0(i, 1), M0(i, 2), M0(i, 3));\n        M1_row[i] = Eigen::Vector4d(M1(i, 0), M1(i, 1), M1(i, 2), M1(i, 3));\n    }\n\n    Eigen::Vector4d x;\n    double weight0 = 1.0;\n    double weight0_prev = 1.0;\n\n    double weight1 = 1.0;\n    double weight1_prev = 1.0;\n\n    int j = 0;\n    while(j < maxIter) {\n        Eigen::Vector4d A0 = (M0_row[0] - point_0[0] * M0_row[2]) / weight0;\n        Eigen::Vector4d A1 = (M0_row[1] - point_0[1] * M0_row[2]) / weight0;\n\n        Eigen::Vector4d A2 = (M1_row[0] - point_1[0] * M1_row[2]) / weight1;\n        Eigen::Vector4d A3 = (M1_row[1] - point_1[1] * M1_row[2]) / weight1;\n\n        Eigen::MatrixXd A(4, 4);\n        for(int i = 0; i < 4; i++) {\n            A(0, i) = A0[i];\n            A(1, i) = A1[i];\n            A(2, i) = A2[i];\n            A(3, i) = A3[i];\n        }\n\n        Eigen::JacobiSVD< Eigen::MatrixXd > svdA(A, Eigen::ComputeFullV);\n        Eigen::MatrixXd V = svdA.matrixV();\n        int n = int(V.cols()) - 1;\n\n        x[0] = V(0, n);\n        x[1] = V(1, n);\n        x[2] = V(2, n);\n        x[3] = V(3, n);\n        x /= x[3];\n\n        weight0_prev = weight0;\n        weight1_prev = weight1;\n\n        weight0 = x.dot(M0_row[2]);\n        weight1 = x.dot(M1_row[2]);\n\n        double d0 = weight0_prev - weight0;\n        double d1 = weight1_prev - weight1;\n        double err = sqrt(d0 * d0 + d1 * d1);\n\n        if(err < 1e-12){\n            break;\n        }\n\n        j++;\n    }\n\n    #ifdef PIC_DEBUG\n        printf(\"triangulationHartleySturm's Iterations: %d\\n\",j);\n    #endif\n\n    return x;\n}\n\n/**\n * @brief triangulationPoints\n * @param M0\n * @param M1\n * @param m0f\n * @param m1f\n * @param points_3d\n * @param colors\n * @param bColor\n */\nPIC_INLINE void triangulationPoints(Eigen::Matrix34d &M0,\n                                    Eigen::Matrix34d &M1,\n                                    std::vector< Eigen::Vector2f > &m0f,\n                                    std::vector< Eigen::Vector2f > &m1f,\n                                    std::vector< Eigen::Vector3d > &points_3d,\n                                    std::vector< unsigned char > &colors,\n                                    Image *img0 = NULL,\n                                    Image *img1 = NULL,\n                                    bool bColor = false\n                                  )\n{\n    if(m0f.size() != m1f.size()) {\n        return;\n    }\n\n    NelderMeadOptTriangulation nmTri(M0, M1);\n    for(unsigned int i = 0; i < m0f.size(); i++) {\n        //normalized coordinates\n        Eigen::Vector3d p0 = Eigen::Vector3d(m0f[i][0], m0f[i][1], 1.0);\n        Eigen::Vector3d p1 = Eigen::Vector3d(m1f[i][0], m1f[i][1], 1.0);\n\n        //triangulation\n        Eigen::Vector4d point = triangulationHartleySturm(p0, p1, M0, M1);\n\n        //non-linear refinement\n        nmTri.update(m0f[i], m1f[i]);\n        double tmpp[] = {point[0], point[1], point[2]};\n        double out[3];\n        nmTri.run(tmpp, 3, 1e-9f, 10000, &out[0]);\n\n        //output\n        points_3d.push_back(Eigen::Vector3d(out[0], out[1], out[2]));\n\n        if(bColor) {\n            float *color0 = (*img0)(int(m0f[i][0]), int(m0f[i][1]));\n            float *color1 = (*img1)(int(m1f[i][0]), int(m1f[i][1]));\n\n            for(int j = 0; j < img0->channels; j++) {\n                float c_mean = (color0[j] + color1[j]) * 0.5f;\n                c_mean = CLAMPi(c_mean, 0.0f, 1.0f);\n                unsigned char c = int(c_mean * 255.0f);\n                colors.push_back(c);\n            }\n        }\n    }\n}\n\n#endif // PIC_DISABLE_EIGEN\n\n} // end namespace pic\n\n#endif // PIC_COMPUTER_VISION_TRIANGULATION_HPP\n"
  },
  {
    "path": "include/computer_vision.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_HPP\n#define PIC_COMPUTER_VISION_HPP\n\n#include \"computer_vision/homography_matrix.hpp\"\n#include \"computer_vision/fundamental_matrix.hpp\"\n#include \"computer_vision/triangulation.hpp\"\n#include \"computer_vision/essential_matrix.hpp\"\n#include \"computer_vision/intrisics_matrix.hpp\"\n#include \"computer_vision/camera_matrix.hpp\"\n\n#include \"computer_vision/rectification.hpp\"\n\n#include \"computer_vision/stereo.hpp\"\n\n#include \"computer_vision/nelder_mead_opt_homography.hpp\"\n#include \"computer_vision/nelder_mead_opt_fundamental.hpp\"\n#include \"computer_vision/nelder_mead_opt_triangulation.hpp\"\n#include \"computer_vision/nelder_mead_opt_gordon_lowe.hpp\"\n#include \"computer_vision/nelder_mead_opt_radial_distortion.hpp\"\n\n#include \"computer_vision/iterative_closest_point_2D.hpp\"\n#include \"computer_vision/nelder_mead_opt_ICP_2D.hpp\"\n#include \"computer_vision/find_checker_board.hpp\"\n\n#include \"computer_vision/image_alignment.hpp\"\n\n#include \"computer_vision/simple_ply.hpp\"\n\n\n#endif /* PIC_COMPUTER_VISION_HPP */\n\n"
  },
  {
    "path": "include/externals/Eigen/CMakeLists.txt",
    "content": "include(RegexUtils)\ntest_escape_string_as_regex()\n\nfile(GLOB Eigen_directory_files \"*\")\n\nescape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\")\n\nforeach(f ${Eigen_directory_files})\n  if(NOT f MATCHES \"\\\\.txt\" AND NOT f MATCHES \"${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+\" AND NOT f MATCHES \"${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src\")\n    list(APPEND Eigen_directory_files_to_install ${f})\n  endif()\nendforeach(f ${Eigen_directory_files})\n\ninstall(FILES\n  ${Eigen_directory_files_to_install}\n  DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel\n  )\n\ninstall(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel FILES_MATCHING PATTERN \"*.h\")\n"
  },
  {
    "path": "include/externals/Eigen/Cholesky",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CHOLESKY_MODULE_H\n#define EIGEN_CHOLESKY_MODULE_H\n\n#include \"Core\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n/** \\defgroup Cholesky_Module Cholesky module\n  *\n  *\n  *\n  * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices.\n  * Those decompositions are also accessible via the following methods:\n  *  - MatrixBase::llt()\n  *  - MatrixBase::ldlt()\n  *  - SelfAdjointView::llt()\n  *  - SelfAdjointView::ldlt()\n  *\n  * \\code\n  * #include <Eigen/Cholesky>\n  * \\endcode\n  */\n\n#include \"src/Cholesky/LLT.h\"\n#include \"src/Cholesky/LDLT.h\"\n#ifdef EIGEN_USE_LAPACKE\n#include \"src/misc/lapacke.h\"\n#include \"src/Cholesky/LLT_LAPACKE.h\"\n#endif\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_CHOLESKY_MODULE_H\n/* vim: set filetype=cpp et sw=2 ts=2 ai: */\n"
  },
  {
    "path": "include/externals/Eigen/CholmodSupport",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CHOLMODSUPPORT_MODULE_H\n#define EIGEN_CHOLMODSUPPORT_MODULE_H\n\n#include \"SparseCore\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\nextern \"C\" {\n  #include <cholmod.h>\n}\n\n/** \\ingroup Support_modules\n  * \\defgroup CholmodSupport_Module CholmodSupport module\n  *\n  * This module provides an interface to the Cholmod library which is part of the <a href=\"http://www.suitesparse.com\">suitesparse</a> package.\n  * It provides the two following main factorization classes:\n  * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization.\n  * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial).\n  *\n  * For the sake of completeness, this module also propose the two following classes:\n  * - class CholmodSimplicialLLT\n  * - class CholmodSimplicialLDLT\n  * Note that these classes does not bring any particular advantage compared to the built-in\n  * SimplicialLLT and SimplicialLDLT factorization classes.\n  *\n  * \\code\n  * #include <Eigen/CholmodSupport>\n  * \\endcode\n  *\n  * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies.\n  * The dependencies depend on how cholmod has been compiled.\n  * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task.\n  *\n  */\n\n#include \"src/CholmodSupport/CholmodSupport.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_CHOLMODSUPPORT_MODULE_H\n\n"
  },
  {
    "path": "include/externals/Eigen/Core",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2007-2011 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CORE_H\n#define EIGEN_CORE_H\n\n// first thing Eigen does: stop the compiler from committing suicide\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n// Handle NVCC/CUDA/SYCL\n#if defined(__CUDACC__) || defined(__SYCL_DEVICE_ONLY__)\n  // Do not try asserts on CUDA and SYCL!\n  #ifndef EIGEN_NO_DEBUG\n  #define EIGEN_NO_DEBUG\n  #endif\n\n  #ifdef EIGEN_INTERNAL_DEBUGGING\n  #undef EIGEN_INTERNAL_DEBUGGING\n  #endif\n\n  #ifdef EIGEN_EXCEPTIONS\n  #undef EIGEN_EXCEPTIONS\n  #endif\n\n  // All functions callable from CUDA code must be qualified with __device__\n  #ifdef __CUDACC__\n    // Do not try to vectorize on CUDA and SYCL!\n    #ifndef EIGEN_DONT_VECTORIZE\n    #define EIGEN_DONT_VECTORIZE\n    #endif\n\n    #define EIGEN_DEVICE_FUNC __host__ __device__\n    // We need math_functions.hpp to ensure that that EIGEN_USING_STD_MATH macro\n    // works properly on the device side\n    #include <math_functions.hpp>\n  #else\n    #define EIGEN_DEVICE_FUNC\n  #endif\n\n#else\n  #define EIGEN_DEVICE_FUNC\n\n#endif\n\n// When compiling CUDA device code with NVCC, pull in math functions from the\n// global namespace.  In host mode, and when device doee with clang, use the\n// std versions.\n#if defined(__CUDA_ARCH__) && defined(__NVCC__)\n  #define EIGEN_USING_STD_MATH(FUNC) using ::FUNC;\n#else\n  #define EIGEN_USING_STD_MATH(FUNC) using std::FUNC;\n#endif\n\n#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(__CUDA_ARCH__) && !defined(EIGEN_EXCEPTIONS) && !defined(EIGEN_USE_SYCL)\n  #define EIGEN_EXCEPTIONS\n#endif\n\n#ifdef EIGEN_EXCEPTIONS\n  #include <new>\n#endif\n\n// then include this file where all our macros are defined. It's really important to do it first because\n// it's where we do all the alignment settings (platform detection and honoring the user's will if he\n// defined e.g. EIGEN_DONT_ALIGN) so it needs to be done before we do anything with vectorization.\n#include \"src/Core/util/Macros.h\"\n\n// Disable the ipa-cp-clone optimization flag with MinGW 6.x or newer (enabled by default with -O3)\n// See http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556 for details.\n#if EIGEN_COMP_MINGW && EIGEN_GNUC_AT_LEAST(4,6)\n  #pragma GCC optimize (\"-fno-ipa-cp-clone\")\n#endif\n\n#include <complex>\n\n// this include file manages BLAS and MKL related macros\n// and inclusion of their respective header files\n#include \"src/Core/util/MKL_support.h\"\n\n// if alignment is disabled, then disable vectorization. Note: EIGEN_MAX_ALIGN_BYTES is the proper check, it takes into\n// account both the user's will (EIGEN_MAX_ALIGN_BYTES,EIGEN_DONT_ALIGN) and our own platform checks\n#if EIGEN_MAX_ALIGN_BYTES==0\n  #ifndef EIGEN_DONT_VECTORIZE\n    #define EIGEN_DONT_VECTORIZE\n  #endif\n#endif\n\n#if EIGEN_COMP_MSVC\n  #include <malloc.h> // for _aligned_malloc -- need it regardless of whether vectorization is enabled\n  #if (EIGEN_COMP_MSVC >= 1500) // 2008 or later\n    // Remember that usage of defined() in a #define is undefined by the standard.\n    // a user reported that in 64-bit mode, MSVC doesn't care to define _M_IX86_FP.\n    #if (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || EIGEN_ARCH_x86_64\n      #define EIGEN_SSE2_ON_MSVC_2008_OR_LATER\n    #endif\n  #endif\n#else\n  // Remember that usage of defined() in a #define is undefined by the standard\n  #if (defined __SSE2__) && ( (!EIGEN_COMP_GNUC) || EIGEN_COMP_ICC || EIGEN_GNUC_AT_LEAST(4,2) )\n    #define EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC\n  #endif\n#endif\n\n#ifndef EIGEN_DONT_VECTORIZE\n\n  #if defined (EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC) || defined(EIGEN_SSE2_ON_MSVC_2008_OR_LATER)\n\n    // Defines symbols for compile-time detection of which instructions are\n    // used.\n    // EIGEN_VECTORIZE_YY is defined if and only if the instruction set YY is used\n    #define EIGEN_VECTORIZE\n    #define EIGEN_VECTORIZE_SSE\n    #define EIGEN_VECTORIZE_SSE2\n\n    // Detect sse3/ssse3/sse4:\n    // gcc and icc defines __SSE3__, ...\n    // there is no way to know about this on msvc. You can define EIGEN_VECTORIZE_SSE* if you\n    // want to force the use of those instructions with msvc.\n    #ifdef __SSE3__\n      #define EIGEN_VECTORIZE_SSE3\n    #endif\n    #ifdef __SSSE3__\n      #define EIGEN_VECTORIZE_SSSE3\n    #endif\n    #ifdef __SSE4_1__\n      #define EIGEN_VECTORIZE_SSE4_1\n    #endif\n    #ifdef __SSE4_2__\n      #define EIGEN_VECTORIZE_SSE4_2\n    #endif\n    #ifdef __AVX__\n      #define EIGEN_VECTORIZE_AVX\n      #define EIGEN_VECTORIZE_SSE3\n      #define EIGEN_VECTORIZE_SSSE3\n      #define EIGEN_VECTORIZE_SSE4_1\n      #define EIGEN_VECTORIZE_SSE4_2\n    #endif\n    #ifdef __AVX2__\n      #define EIGEN_VECTORIZE_AVX2\n    #endif\n    #ifdef __FMA__\n      #define EIGEN_VECTORIZE_FMA\n    #endif\n    #if defined(__AVX512F__) && defined(EIGEN_ENABLE_AVX512)\n      #define EIGEN_VECTORIZE_AVX512\n      #define EIGEN_VECTORIZE_AVX2\n      #define EIGEN_VECTORIZE_AVX\n      #define EIGEN_VECTORIZE_FMA\n      #ifdef __AVX512DQ__\n        #define EIGEN_VECTORIZE_AVX512DQ\n      #endif\n    #endif\n\n    // include files\n\n    // This extern \"C\" works around a MINGW-w64 compilation issue\n    // https://sourceforge.net/tracker/index.php?func=detail&aid=3018394&group_id=202880&atid=983354\n    // In essence, intrin.h is included by windows.h and also declares intrinsics (just as emmintrin.h etc. below do).\n    // However, intrin.h uses an extern \"C\" declaration, and g++ thus complains of duplicate declarations\n    // with conflicting linkage.  The linkage for intrinsics doesn't matter, but at that stage the compiler doesn't know;\n    // so, to avoid compile errors when windows.h is included after Eigen/Core, ensure intrinsics are extern \"C\" here too.\n    // notice that since these are C headers, the extern \"C\" is theoretically needed anyways.\n    extern \"C\" {\n      // In theory we should only include immintrin.h and not the other *mmintrin.h header files directly.\n      // Doing so triggers some issues with ICC. However old gcc versions seems to not have this file, thus:\n      #if EIGEN_COMP_ICC >= 1110\n        #include <immintrin.h>\n      #else\n        #include <mmintrin.h>\n        #include <emmintrin.h>\n        #include <xmmintrin.h>\n        #ifdef  EIGEN_VECTORIZE_SSE3\n        #include <pmmintrin.h>\n        #endif\n        #ifdef EIGEN_VECTORIZE_SSSE3\n        #include <tmmintrin.h>\n        #endif\n        #ifdef EIGEN_VECTORIZE_SSE4_1\n        #include <smmintrin.h>\n        #endif\n        #ifdef EIGEN_VECTORIZE_SSE4_2\n        #include <nmmintrin.h>\n        #endif\n        #if defined(EIGEN_VECTORIZE_AVX) || defined(EIGEN_VECTORIZE_AVX512)\n        #include <immintrin.h>\n        #endif\n      #endif\n    } // end extern \"C\"\n  #elif defined __VSX__\n    #define EIGEN_VECTORIZE\n    #define EIGEN_VECTORIZE_VSX\n    #include <altivec.h>\n    // We need to #undef all these ugly tokens defined in <altivec.h>\n    // => use __vector instead of vector\n    #undef bool\n    #undef vector\n    #undef pixel\n  #elif defined __ALTIVEC__\n    #define EIGEN_VECTORIZE\n    #define EIGEN_VECTORIZE_ALTIVEC\n    #include <altivec.h>\n    // We need to #undef all these ugly tokens defined in <altivec.h>\n    // => use __vector instead of vector\n    #undef bool\n    #undef vector\n    #undef pixel\n  #elif (defined  __ARM_NEON) || (defined __ARM_NEON__)\n    #define EIGEN_VECTORIZE\n    #define EIGEN_VECTORIZE_NEON\n    #include <arm_neon.h>\n  #elif (defined __s390x__ && defined __VEC__)\n    #define EIGEN_VECTORIZE\n    #define EIGEN_VECTORIZE_ZVECTOR\n    #include <vecintrin.h>\n  #endif\n#endif\n\n#if defined(__F16C__) && !defined(EIGEN_COMP_CLANG)\n  // We can use the optimized fp16 to float and float to fp16 conversion routines\n  #define EIGEN_HAS_FP16_C\n#endif\n\n#if defined __CUDACC__\n  #define EIGEN_VECTORIZE_CUDA\n  #include <vector_types.h>\n  #if defined __CUDACC_VER__ && __CUDACC_VER__ >= 70500\n    #define EIGEN_HAS_CUDA_FP16\n  #endif\n#endif\n\n#if defined EIGEN_HAS_CUDA_FP16\n  #include <host_defines.h>\n  #include <cuda_fp16.h>\n#endif\n\n#if (defined _OPENMP) && (!defined EIGEN_DONT_PARALLELIZE)\n  #define EIGEN_HAS_OPENMP\n#endif\n\n#ifdef EIGEN_HAS_OPENMP\n#include <omp.h>\n#endif\n\n// MSVC for windows mobile does not have the errno.h file\n#if !(EIGEN_COMP_MSVC && EIGEN_OS_WINCE) && !EIGEN_COMP_ARM\n#define EIGEN_HAS_ERRNO\n#endif\n\n#ifdef EIGEN_HAS_ERRNO\n#include <cerrno>\n#endif\n#include <cstddef>\n#include <cstdlib>\n#include <cmath>\n#include <cassert>\n#include <functional>\n#include <iosfwd>\n#include <cstring>\n#include <string>\n#include <limits>\n#include <climits> // for CHAR_BIT\n// for min/max:\n#include <algorithm>\n\n// for std::is_nothrow_move_assignable\n#ifdef EIGEN_INCLUDE_TYPE_TRAITS\n#include <type_traits>\n#endif\n\n// for outputting debug info\n#ifdef EIGEN_DEBUG_ASSIGN\n#include <iostream>\n#endif\n\n// required for __cpuid, needs to be included after cmath\n#if EIGEN_COMP_MSVC && EIGEN_ARCH_i386_OR_x86_64 && !EIGEN_OS_WINCE\n  #include <intrin.h>\n#endif\n\n/** \\brief Namespace containing all symbols from the %Eigen library. */\nnamespace Eigen {\n\ninline static const char *SimdInstructionSetsInUse(void) {\n#if defined(EIGEN_VECTORIZE_AVX512)\n  return \"AVX512, FMA, AVX2, AVX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2\";\n#elif defined(EIGEN_VECTORIZE_AVX)\n  return \"AVX SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2\";\n#elif defined(EIGEN_VECTORIZE_SSE4_2)\n  return \"SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2\";\n#elif defined(EIGEN_VECTORIZE_SSE4_1)\n  return \"SSE, SSE2, SSE3, SSSE3, SSE4.1\";\n#elif defined(EIGEN_VECTORIZE_SSSE3)\n  return \"SSE, SSE2, SSE3, SSSE3\";\n#elif defined(EIGEN_VECTORIZE_SSE3)\n  return \"SSE, SSE2, SSE3\";\n#elif defined(EIGEN_VECTORIZE_SSE2)\n  return \"SSE, SSE2\";\n#elif defined(EIGEN_VECTORIZE_ALTIVEC)\n  return \"AltiVec\";\n#elif defined(EIGEN_VECTORIZE_VSX)\n  return \"VSX\";\n#elif defined(EIGEN_VECTORIZE_NEON)\n  return \"ARM NEON\";\n#elif defined(EIGEN_VECTORIZE_ZVECTOR)\n  return \"S390X ZVECTOR\";\n#else\n  return \"None\";\n#endif\n}\n\n} // end namespace Eigen\n\n#if defined EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS || defined EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API || defined EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS || defined EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API || defined EIGEN2_SUPPORT\n// This will generate an error message:\n#error Eigen2-support is only available up to version 3.2. Please go to \"http://eigen.tuxfamily.org/index.php?title=Eigen2\" for further information\n#endif\n\nnamespace Eigen {\n\n// we use size_t frequently and we'll never remember to prepend it with std:: everytime just to\n// ensure QNX/QCC support\nusing std::size_t;\n// gcc 4.6.0 wants std:: for ptrdiff_t\nusing std::ptrdiff_t;\n\n}\n\n/** \\defgroup Core_Module Core module\n  * This is the main module of Eigen providing dense matrix and vector support\n  * (both fixed and dynamic size) with all the features corresponding to a BLAS library\n  * and much more...\n  *\n  * \\code\n  * #include <Eigen/Core>\n  * \\endcode\n  */\n\n#include \"src/Core/util/Constants.h\"\n#include \"src/Core/util/Meta.h\"\n#include \"src/Core/util/ForwardDeclarations.h\"\n#include \"src/Core/util/StaticAssert.h\"\n#include \"src/Core/util/XprHelper.h\"\n#include \"src/Core/util/Memory.h\"\n\n#include \"src/Core/NumTraits.h\"\n#include \"src/Core/MathFunctions.h\"\n#include \"src/Core/GenericPacketMath.h\"\n#include \"src/Core/MathFunctionsImpl.h\"\n\n#if defined EIGEN_VECTORIZE_AVX512\n  #include \"src/Core/arch/SSE/PacketMath.h\"\n  #include \"src/Core/arch/AVX/PacketMath.h\"\n  #include \"src/Core/arch/AVX512/PacketMath.h\"\n  #include \"src/Core/arch/AVX512/MathFunctions.h\"\n#elif defined EIGEN_VECTORIZE_AVX\n  // Use AVX for floats and doubles, SSE for integers\n  #include \"src/Core/arch/SSE/PacketMath.h\"\n  #include \"src/Core/arch/SSE/Complex.h\"\n  #include \"src/Core/arch/SSE/MathFunctions.h\"\n  #include \"src/Core/arch/AVX/PacketMath.h\"\n  #include \"src/Core/arch/AVX/MathFunctions.h\"\n  #include \"src/Core/arch/AVX/Complex.h\"\n  #include \"src/Core/arch/AVX/TypeCasting.h\"\n#elif defined EIGEN_VECTORIZE_SSE\n  #include \"src/Core/arch/SSE/PacketMath.h\"\n  #include \"src/Core/arch/SSE/MathFunctions.h\"\n  #include \"src/Core/arch/SSE/Complex.h\"\n  #include \"src/Core/arch/SSE/TypeCasting.h\"\n#elif defined(EIGEN_VECTORIZE_ALTIVEC) || defined(EIGEN_VECTORIZE_VSX)\n  #include \"src/Core/arch/AltiVec/PacketMath.h\"\n  #include \"src/Core/arch/AltiVec/MathFunctions.h\"\n  #include \"src/Core/arch/AltiVec/Complex.h\"\n#elif defined EIGEN_VECTORIZE_NEON\n  #include \"src/Core/arch/NEON/PacketMath.h\"\n  #include \"src/Core/arch/NEON/MathFunctions.h\"\n  #include \"src/Core/arch/NEON/Complex.h\"\n#elif defined EIGEN_VECTORIZE_ZVECTOR\n  #include \"src/Core/arch/ZVector/PacketMath.h\"\n  #include \"src/Core/arch/ZVector/MathFunctions.h\"\n  #include \"src/Core/arch/ZVector/Complex.h\"\n#endif\n\n// Half float support\n#include \"src/Core/arch/CUDA/Half.h\"\n#include \"src/Core/arch/CUDA/PacketMathHalf.h\"\n#include \"src/Core/arch/CUDA/TypeCasting.h\"\n\n#if defined EIGEN_VECTORIZE_CUDA\n  #include \"src/Core/arch/CUDA/PacketMath.h\"\n  #include \"src/Core/arch/CUDA/MathFunctions.h\"\n#endif\n\n#include \"src/Core/arch/Default/Settings.h\"\n\n#include \"src/Core/functors/TernaryFunctors.h\"\n#include \"src/Core/functors/BinaryFunctors.h\"\n#include \"src/Core/functors/UnaryFunctors.h\"\n#include \"src/Core/functors/NullaryFunctors.h\"\n#include \"src/Core/functors/StlFunctors.h\"\n#include \"src/Core/functors/AssignmentFunctors.h\"\n\n// Specialized functors to enable the processing of complex numbers\n// on CUDA devices\n#include \"src/Core/arch/CUDA/Complex.h\"\n\n#include \"src/Core/IO.h\"\n#include \"src/Core/DenseCoeffsBase.h\"\n#include \"src/Core/DenseBase.h\"\n#include \"src/Core/MatrixBase.h\"\n#include \"src/Core/EigenBase.h\"\n\n#include \"src/Core/Product.h\"\n#include \"src/Core/CoreEvaluators.h\"\n#include \"src/Core/AssignEvaluator.h\"\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874\n                                // at least confirmed with Doxygen 1.5.5 and 1.5.6\n  #include \"src/Core/Assign.h\"\n#endif\n\n#include \"src/Core/ArrayBase.h\"\n#include \"src/Core/util/BlasUtil.h\"\n#include \"src/Core/DenseStorage.h\"\n#include \"src/Core/NestByValue.h\"\n\n// #include \"src/Core/ForceAlignedAccess.h\"\n\n#include \"src/Core/ReturnByValue.h\"\n#include \"src/Core/NoAlias.h\"\n#include \"src/Core/PlainObjectBase.h\"\n#include \"src/Core/Matrix.h\"\n#include \"src/Core/Array.h\"\n#include \"src/Core/CwiseTernaryOp.h\"\n#include \"src/Core/CwiseBinaryOp.h\"\n#include \"src/Core/CwiseUnaryOp.h\"\n#include \"src/Core/CwiseNullaryOp.h\"\n#include \"src/Core/CwiseUnaryView.h\"\n#include \"src/Core/SelfCwiseBinaryOp.h\"\n#include \"src/Core/Dot.h\"\n#include \"src/Core/StableNorm.h\"\n#include \"src/Core/Stride.h\"\n#include \"src/Core/MapBase.h\"\n#include \"src/Core/Map.h\"\n#include \"src/Core/Ref.h\"\n#include \"src/Core/Block.h\"\n#include \"src/Core/VectorBlock.h\"\n#include \"src/Core/Transpose.h\"\n#include \"src/Core/DiagonalMatrix.h\"\n#include \"src/Core/Diagonal.h\"\n#include \"src/Core/DiagonalProduct.h\"\n#include \"src/Core/Redux.h\"\n#include \"src/Core/Visitor.h\"\n#include \"src/Core/Fuzzy.h\"\n#include \"src/Core/Swap.h\"\n#include \"src/Core/CommaInitializer.h\"\n#include \"src/Core/GeneralProduct.h\"\n#include \"src/Core/Solve.h\"\n#include \"src/Core/Inverse.h\"\n#include \"src/Core/SolverBase.h\"\n#include \"src/Core/PermutationMatrix.h\"\n#include \"src/Core/Transpositions.h\"\n#include \"src/Core/TriangularMatrix.h\"\n#include \"src/Core/SelfAdjointView.h\"\n#include \"src/Core/products/GeneralBlockPanelKernel.h\"\n#include \"src/Core/products/Parallelizer.h\"\n#include \"src/Core/ProductEvaluators.h\"\n#include \"src/Core/products/GeneralMatrixVector.h\"\n#include \"src/Core/products/GeneralMatrixMatrix.h\"\n#include \"src/Core/SolveTriangular.h\"\n#include \"src/Core/products/GeneralMatrixMatrixTriangular.h\"\n#include \"src/Core/products/SelfadjointMatrixVector.h\"\n#include \"src/Core/products/SelfadjointMatrixMatrix.h\"\n#include \"src/Core/products/SelfadjointProduct.h\"\n#include \"src/Core/products/SelfadjointRank2Update.h\"\n#include \"src/Core/products/TriangularMatrixVector.h\"\n#include \"src/Core/products/TriangularMatrixMatrix.h\"\n#include \"src/Core/products/TriangularSolverMatrix.h\"\n#include \"src/Core/products/TriangularSolverVector.h\"\n#include \"src/Core/BandMatrix.h\"\n#include \"src/Core/CoreIterators.h\"\n#include \"src/Core/ConditionEstimator.h\"\n\n#include \"src/Core/BooleanRedux.h\"\n#include \"src/Core/Select.h\"\n#include \"src/Core/VectorwiseOp.h\"\n#include \"src/Core/Random.h\"\n#include \"src/Core/Replicate.h\"\n#include \"src/Core/Reverse.h\"\n#include \"src/Core/ArrayWrapper.h\"\n\n#ifdef EIGEN_USE_BLAS\n#include \"src/Core/products/GeneralMatrixMatrix_BLAS.h\"\n#include \"src/Core/products/GeneralMatrixVector_BLAS.h\"\n#include \"src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h\"\n#include \"src/Core/products/SelfadjointMatrixMatrix_BLAS.h\"\n#include \"src/Core/products/SelfadjointMatrixVector_BLAS.h\"\n#include \"src/Core/products/TriangularMatrixMatrix_BLAS.h\"\n#include \"src/Core/products/TriangularMatrixVector_BLAS.h\"\n#include \"src/Core/products/TriangularSolverMatrix_BLAS.h\"\n#endif // EIGEN_USE_BLAS\n\n#ifdef EIGEN_USE_MKL_VML\n#include \"src/Core/Assign_MKL.h\"\n#endif\n\n#include \"src/Core/GlobalFunctions.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_CORE_H\n"
  },
  {
    "path": "include/externals/Eigen/Dense",
    "content": "#include \"Core\"\n#include \"LU\"\n#include \"Cholesky\"\n#include \"QR\"\n#include \"SVD\"\n#include \"Geometry\"\n#include \"Eigenvalues\"\n"
  },
  {
    "path": "include/externals/Eigen/Eigen",
    "content": "#include \"Dense\"\n#include \"Sparse\"\n"
  },
  {
    "path": "include/externals/Eigen/Eigenvalues",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_EIGENVALUES_MODULE_H\n#define EIGEN_EIGENVALUES_MODULE_H\n\n#include \"Core\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n#include \"Cholesky\"\n#include \"Jacobi\"\n#include \"Householder\"\n#include \"LU\"\n#include \"Geometry\"\n\n/** \\defgroup Eigenvalues_Module Eigenvalues module\n  *\n  *\n  *\n  * This module mainly provides various eigenvalue solvers.\n  * This module also provides some MatrixBase methods, including:\n  *  - MatrixBase::eigenvalues(),\n  *  - MatrixBase::operatorNorm()\n  *\n  * \\code\n  * #include <Eigen/Eigenvalues>\n  * \\endcode\n  */\n\n#include \"src/misc/RealSvd2x2.h\"\n#include \"src/Eigenvalues/Tridiagonalization.h\"\n#include \"src/Eigenvalues/RealSchur.h\"\n#include \"src/Eigenvalues/EigenSolver.h\"\n#include \"src/Eigenvalues/SelfAdjointEigenSolver.h\"\n#include \"src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h\"\n#include \"src/Eigenvalues/HessenbergDecomposition.h\"\n#include \"src/Eigenvalues/ComplexSchur.h\"\n#include \"src/Eigenvalues/ComplexEigenSolver.h\"\n#include \"src/Eigenvalues/RealQZ.h\"\n#include \"src/Eigenvalues/GeneralizedEigenSolver.h\"\n#include \"src/Eigenvalues/MatrixBaseEigenvalues.h\"\n#ifdef EIGEN_USE_LAPACKE\n#include \"src/misc/lapacke.h\"\n#include \"src/Eigenvalues/RealSchur_LAPACKE.h\"\n#include \"src/Eigenvalues/ComplexSchur_LAPACKE.h\"\n#include \"src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h\"\n#endif\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_EIGENVALUES_MODULE_H\n/* vim: set filetype=cpp et sw=2 ts=2 ai: */\n"
  },
  {
    "path": "include/externals/Eigen/Geometry",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_GEOMETRY_MODULE_H\n#define EIGEN_GEOMETRY_MODULE_H\n\n#include \"Core\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n#include \"SVD\"\n#include \"LU\"\n#include <limits>\n\n/** \\defgroup Geometry_Module Geometry module\n  *\n  * This module provides support for:\n  *  - fixed-size homogeneous transformations\n  *  - translation, scaling, 2D and 3D rotations\n  *  - \\link Quaternion quaternions \\endlink\n  *  - cross products (\\ref MatrixBase::cross, \\ref MatrixBase::cross3)\n  *  - orthognal vector generation (\\ref MatrixBase::unitOrthogonal)\n  *  - some linear components: \\link ParametrizedLine parametrized-lines \\endlink and \\link Hyperplane hyperplanes \\endlink\n  *  - \\link AlignedBox axis aligned bounding boxes \\endlink\n  *  - \\link umeyama least-square transformation fitting \\endlink\n  *\n  * \\code\n  * #include <Eigen/Geometry>\n  * \\endcode\n  */\n\n#include \"src/Geometry/OrthoMethods.h\"\n#include \"src/Geometry/EulerAngles.h\"\n\n#include \"src/Geometry/Homogeneous.h\"\n#include \"src/Geometry/RotationBase.h\"\n#include \"src/Geometry/Rotation2D.h\"\n#include \"src/Geometry/Quaternion.h\"\n#include \"src/Geometry/AngleAxis.h\"\n#include \"src/Geometry/Transform.h\"\n#include \"src/Geometry/Translation.h\"\n#include \"src/Geometry/Scaling.h\"\n#include \"src/Geometry/Hyperplane.h\"\n#include \"src/Geometry/ParametrizedLine.h\"\n#include \"src/Geometry/AlignedBox.h\"\n#include \"src/Geometry/Umeyama.h\"\n\n// Use the SSE optimized version whenever possible. At the moment the\n// SSE version doesn't compile when AVX is enabled\n#if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX\n#include \"src/Geometry/arch/Geometry_SSE.h\"\n#endif\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_GEOMETRY_MODULE_H\n/* vim: set filetype=cpp et sw=2 ts=2 ai: */\n\n"
  },
  {
    "path": "include/externals/Eigen/Householder",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_HOUSEHOLDER_MODULE_H\n#define EIGEN_HOUSEHOLDER_MODULE_H\n\n#include \"Core\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n/** \\defgroup Householder_Module Householder module\n  * This module provides Householder transformations.\n  *\n  * \\code\n  * #include <Eigen/Householder>\n  * \\endcode\n  */\n\n#include \"src/Householder/Householder.h\"\n#include \"src/Householder/HouseholderSequence.h\"\n#include \"src/Householder/BlockHouseholder.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_HOUSEHOLDER_MODULE_H\n/* vim: set filetype=cpp et sw=2 ts=2 ai: */\n"
  },
  {
    "path": "include/externals/Eigen/IterativeLinearSolvers",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H\n#define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H\n\n#include \"SparseCore\"\n#include \"OrderingMethods\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n/** \n  * \\defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module\n  *\n  * This module currently provides iterative methods to solve problems of the form \\c A \\c x = \\c b, where \\c A is a squared matrix, usually very large and sparse.\n  * Those solvers are accessible via the following classes:\n  *  - ConjugateGradient for selfadjoint (hermitian) matrices,\n  *  - LeastSquaresConjugateGradient for rectangular least-square problems,\n  *  - BiCGSTAB for general square matrices.\n  *\n  * These iterative solvers are associated with some preconditioners:\n  *  - IdentityPreconditioner - not really useful\n  *  - DiagonalPreconditioner - also called Jacobi preconditioner, work very well on diagonal dominant matrices.\n  *  - IncompleteLUT - incomplete LU factorization with dual thresholding\n  *\n  * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport.\n  *\n    \\code\n    #include <Eigen/IterativeLinearSolvers>\n    \\endcode\n  */\n\n#include \"src/IterativeLinearSolvers/SolveWithGuess.h\"\n#include \"src/IterativeLinearSolvers/IterativeSolverBase.h\"\n#include \"src/IterativeLinearSolvers/BasicPreconditioners.h\"\n#include \"src/IterativeLinearSolvers/ConjugateGradient.h\"\n#include \"src/IterativeLinearSolvers/LeastSquareConjugateGradient.h\"\n#include \"src/IterativeLinearSolvers/BiCGSTAB.h\"\n#include \"src/IterativeLinearSolvers/IncompleteLUT.h\"\n#include \"src/IterativeLinearSolvers/IncompleteCholesky.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/Jacobi",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_JACOBI_MODULE_H\n#define EIGEN_JACOBI_MODULE_H\n\n#include \"Core\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n/** \\defgroup Jacobi_Module Jacobi module\n  * This module provides Jacobi and Givens rotations.\n  *\n  * \\code\n  * #include <Eigen/Jacobi>\n  * \\endcode\n  *\n  * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation:\n  *  - MatrixBase::applyOnTheLeft()\n  *  - MatrixBase::applyOnTheRight().\n  */\n\n#include \"src/Jacobi/Jacobi.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_JACOBI_MODULE_H\n/* vim: set filetype=cpp et sw=2 ts=2 ai: */\n\n"
  },
  {
    "path": "include/externals/Eigen/LU",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_LU_MODULE_H\n#define EIGEN_LU_MODULE_H\n\n#include \"Core\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n/** \\defgroup LU_Module LU module\n  * This module includes %LU decomposition and related notions such as matrix inversion and determinant.\n  * This module defines the following MatrixBase methods:\n  *  - MatrixBase::inverse()\n  *  - MatrixBase::determinant()\n  *\n  * \\code\n  * #include <Eigen/LU>\n  * \\endcode\n  */\n\n#include \"src/misc/Kernel.h\"\n#include \"src/misc/Image.h\"\n#include \"src/LU/FullPivLU.h\"\n#include \"src/LU/PartialPivLU.h\"\n#ifdef EIGEN_USE_LAPACKE\n#include \"src/misc/lapacke.h\"\n#include \"src/LU/PartialPivLU_LAPACKE.h\"\n#endif\n#include \"src/LU/Determinant.h\"\n#include \"src/LU/InverseImpl.h\"\n\n// Use the SSE optimized version whenever possible. At the moment the\n// SSE version doesn't compile when AVX is enabled\n#if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX\n  #include \"src/LU/arch/Inverse_SSE.h\"\n#endif\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_LU_MODULE_H\n/* vim: set filetype=cpp et sw=2 ts=2 ai: */\n"
  },
  {
    "path": "include/externals/Eigen/MetisSupport",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_METISSUPPORT_MODULE_H\n#define EIGEN_METISSUPPORT_MODULE_H\n\n#include \"SparseCore\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\nextern \"C\" {\n#include <metis.h>\n}\n\n\n/** \\ingroup Support_modules\n  * \\defgroup MetisSupport_Module MetisSupport module\n  *\n  * \\code\n  * #include <Eigen/MetisSupport>\n  * \\endcode\n  * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). \n  * It can be used just as any other built-in method as explained in \\link OrderingMethods_Module here. \\endlink\n  */\n\n\n#include \"src/MetisSupport/MetisSupport.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_METISSUPPORT_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/OrderingMethods",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ORDERINGMETHODS_MODULE_H\n#define EIGEN_ORDERINGMETHODS_MODULE_H\n\n#include \"SparseCore\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n/** \n  * \\defgroup OrderingMethods_Module OrderingMethods module\n  *\n  * This module is currently for internal use only\n  * \n  * It defines various built-in and external ordering methods for sparse matrices. \n  * They are typically used to reduce the number of elements during \n  * the sparse matrix decomposition (LLT, LU, QR).\n  * Precisely, in a preprocessing step, a permutation matrix P is computed using \n  * those ordering methods and applied to the columns of the matrix. \n  * Using for instance the sparse Cholesky decomposition, it is expected that \n  * the nonzeros elements in LLT(A*P) will be much smaller than that in LLT(A).\n  * \n  * \n  * Usage : \n  * \\code\n  * #include <Eigen/OrderingMethods>\n  * \\endcode\n  * \n  * A simple usage is as a template parameter in the sparse decomposition classes : \n  * \n  * \\code \n  * SparseLU<MatrixType, COLAMDOrdering<int> > solver;\n  * \\endcode \n  * \n  * \\code \n  * SparseQR<MatrixType, COLAMDOrdering<int> > solver;\n  * \\endcode\n  * \n  * It is possible as well to call directly a particular ordering method for your own purpose, \n  * \\code \n  * AMDOrdering<int> ordering;\n  * PermutationMatrix<Dynamic, Dynamic, int> perm;\n  * SparseMatrix<double> A; \n  * //Fill the matrix ...\n  * \n  * ordering(A, perm); // Call AMD\n  * \\endcode\n  * \n  * \\note Some of these methods (like AMD or METIS), need the sparsity pattern \n  * of the input matrix to be symmetric. When the matrix is structurally unsymmetric, \n  * Eigen computes internally the pattern of \\f$A^T*A\\f$ before calling the method.\n  * If your matrix is already symmetric (at leat in structure), you can avoid that\n  * by calling the method with a SelfAdjointView type.\n  * \n  * \\code\n  *  // Call the ordering on the pattern of the lower triangular matrix A\n  * ordering(A.selfadjointView<Lower>(), perm);\n  * \\endcode\n  */\n\n#ifndef EIGEN_MPL2_ONLY\n#include \"src/OrderingMethods/Amd.h\"\n#endif\n\n#include \"src/OrderingMethods/Ordering.h\"\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_ORDERINGMETHODS_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/PaStiXSupport",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PASTIXSUPPORT_MODULE_H\n#define EIGEN_PASTIXSUPPORT_MODULE_H\n\n#include \"SparseCore\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\nextern \"C\" {\n#include <pastix_nompi.h>\n#include <pastix.h>\n}\n\n#ifdef complex\n#undef complex\n#endif\n\n/** \\ingroup Support_modules\n  * \\defgroup PaStiXSupport_Module PaStiXSupport module\n  * \n  * This module provides an interface to the <a href=\"http://pastix.gforge.inria.fr/\">PaSTiX</a> library.\n  * PaSTiX is a general \\b supernodal, \\b parallel and \\b opensource sparse solver.\n  * It provides the two following main factorization classes:\n  * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization.\n  * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization.\n  * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern).\n  * \n  * \\code\n  * #include <Eigen/PaStiXSupport>\n  * \\endcode\n  *\n  * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies.\n  * The dependencies depend on how PaSTiX has been compiled.\n  * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task.\n  *\n  */\n\n#include \"src/PaStiXSupport/PaStiXSupport.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_PASTIXSUPPORT_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/PardisoSupport",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PARDISOSUPPORT_MODULE_H\n#define EIGEN_PARDISOSUPPORT_MODULE_H\n\n#include \"SparseCore\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n#include <mkl_pardiso.h>\n\n/** \\ingroup Support_modules\n  * \\defgroup PardisoSupport_Module PardisoSupport module\n  *\n  * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers.\n  *\n  * \\code\n  * #include <Eigen/PardisoSupport>\n  * \\endcode\n  *\n  * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies.\n  * See this \\ref TopicUsingIntelMKL \"page\" for more information on MKL-Eigen integration.\n  * \n  */\n\n#include \"src/PardisoSupport/PardisoSupport.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_PARDISOSUPPORT_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/QR",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_QR_MODULE_H\n#define EIGEN_QR_MODULE_H\n\n#include \"Core\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n#include \"Cholesky\"\n#include \"Jacobi\"\n#include \"Householder\"\n\n/** \\defgroup QR_Module QR module\n  *\n  *\n  *\n  * This module provides various QR decompositions\n  * This module also provides some MatrixBase methods, including:\n  *  - MatrixBase::householderQr()\n  *  - MatrixBase::colPivHouseholderQr()\n  *  - MatrixBase::fullPivHouseholderQr()\n  *\n  * \\code\n  * #include <Eigen/QR>\n  * \\endcode\n  */\n\n#include \"src/QR/HouseholderQR.h\"\n#include \"src/QR/FullPivHouseholderQR.h\"\n#include \"src/QR/ColPivHouseholderQR.h\"\n#include \"src/QR/CompleteOrthogonalDecomposition.h\"\n#ifdef EIGEN_USE_LAPACKE\n#include \"src/misc/lapacke.h\"\n#include \"src/QR/HouseholderQR_LAPACKE.h\"\n#include \"src/QR/ColPivHouseholderQR_LAPACKE.h\"\n#endif\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_QR_MODULE_H\n/* vim: set filetype=cpp et sw=2 ts=2 ai: */\n"
  },
  {
    "path": "include/externals/Eigen/QtAlignedMalloc",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_QTMALLOC_MODULE_H\n#define EIGEN_QTMALLOC_MODULE_H\n\n#include \"Core\"\n\n#if (!EIGEN_MALLOC_ALREADY_ALIGNED)\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\nvoid *qMalloc(std::size_t size)\n{\n  return Eigen::internal::aligned_malloc(size);\n}\n\nvoid qFree(void *ptr)\n{\n  Eigen::internal::aligned_free(ptr);\n}\n\nvoid *qRealloc(void *ptr, std::size_t size)\n{\n  void* newPtr = Eigen::internal::aligned_malloc(size);\n  memcpy(newPtr, ptr, size);\n  Eigen::internal::aligned_free(ptr);\n  return newPtr;\n}\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif\n\n#endif // EIGEN_QTMALLOC_MODULE_H\n/* vim: set filetype=cpp et sw=2 ts=2 ai: */\n"
  },
  {
    "path": "include/externals/Eigen/SPQRSupport",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPQRSUPPORT_MODULE_H\n#define EIGEN_SPQRSUPPORT_MODULE_H\n\n#include \"SparseCore\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n#include \"SuiteSparseQR.hpp\"\n\n/** \\ingroup Support_modules\n  * \\defgroup SPQRSupport_Module SuiteSparseQR module\n  * \n  * This module provides an interface to the SPQR library, which is part of the <a href=\"http://www.suitesparse.com\">suitesparse</a> package.\n  *\n  * \\code\n  * #include <Eigen/SPQRSupport>\n  * \\endcode\n  *\n  * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...).\n  * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules\n  *\n  */\n\n#include \"src/CholmodSupport/CholmodSupport.h\"\n#include \"src/SPQRSupport/SuiteSparseQRSupport.h\"\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/SVD",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SVD_MODULE_H\n#define EIGEN_SVD_MODULE_H\n\n#include \"QR\"\n#include \"Householder\"\n#include \"Jacobi\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n/** \\defgroup SVD_Module SVD module\n  *\n  *\n  *\n  * This module provides SVD decomposition for matrices (both real and complex).\n  * Two decomposition algorithms are provided:\n  *  - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very slow for larger ones.\n  *  - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast for large problems.\n  * These decompositions are accessible via the respective classes and following MatrixBase methods:\n  *  - MatrixBase::jacobiSvd()\n  *  - MatrixBase::bdcSvd()\n  *\n  * \\code\n  * #include <Eigen/SVD>\n  * \\endcode\n  */\n\n#include \"src/misc/RealSvd2x2.h\"\n#include \"src/SVD/UpperBidiagonalization.h\"\n#include \"src/SVD/SVDBase.h\"\n#include \"src/SVD/JacobiSVD.h\"\n#include \"src/SVD/BDCSVD.h\"\n#if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT)\n#include \"src/misc/lapacke.h\"\n#include \"src/SVD/JacobiSVD_LAPACKE.h\"\n#endif\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_SVD_MODULE_H\n/* vim: set filetype=cpp et sw=2 ts=2 ai: */\n"
  },
  {
    "path": "include/externals/Eigen/Sparse",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_MODULE_H\n#define EIGEN_SPARSE_MODULE_H\n\n/** \\defgroup Sparse_Module Sparse meta-module\n  *\n  * Meta-module including all related modules:\n  * - \\ref SparseCore_Module\n  * - \\ref OrderingMethods_Module\n  * - \\ref SparseCholesky_Module\n  * - \\ref SparseLU_Module\n  * - \\ref SparseQR_Module\n  * - \\ref IterativeLinearSolvers_Module\n  *\n    \\code\n    #include <Eigen/Sparse>\n    \\endcode\n  */\n\n#include \"SparseCore\"\n#include \"OrderingMethods\"\n#ifndef EIGEN_MPL2_ONLY\n#include \"SparseCholesky\"\n#endif\n#include \"SparseLU\"\n#include \"SparseQR\"\n#include \"IterativeLinearSolvers\"\n\n#endif // EIGEN_SPARSE_MODULE_H\n\n"
  },
  {
    "path": "include/externals/Eigen/SparseCholesky",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2013 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSECHOLESKY_MODULE_H\n#define EIGEN_SPARSECHOLESKY_MODULE_H\n\n#include \"SparseCore\"\n#include \"OrderingMethods\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n/** \n  * \\defgroup SparseCholesky_Module SparseCholesky module\n  *\n  * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices.\n  * Those decompositions are accessible via the following classes:\n  *  - SimplicialLLt,\n  *  - SimplicialLDLt\n  *\n  * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module.\n  *\n  * \\code\n  * #include <Eigen/SparseCholesky>\n  * \\endcode\n  */\n\n#ifdef EIGEN_MPL2_ONLY\n#error The SparseCholesky module has nothing to offer in MPL2 only mode\n#endif\n\n#include \"src/SparseCholesky/SimplicialCholesky.h\"\n\n#ifndef EIGEN_MPL2_ONLY\n#include \"src/SparseCholesky/SimplicialCholesky_impl.h\"\n#endif\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_SPARSECHOLESKY_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/SparseCore",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSECORE_MODULE_H\n#define EIGEN_SPARSECORE_MODULE_H\n\n#include \"Core\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n#include <vector>\n#include <map>\n#include <cstdlib>\n#include <cstring>\n#include <algorithm>\n\n/** \n  * \\defgroup SparseCore_Module SparseCore module\n  *\n  * This module provides a sparse matrix representation, and basic associated matrix manipulations\n  * and operations.\n  *\n  * See the \\ref TutorialSparse \"Sparse tutorial\"\n  *\n  * \\code\n  * #include <Eigen/SparseCore>\n  * \\endcode\n  *\n  * This module depends on: Core.\n  */\n\n#include \"src/SparseCore/SparseUtil.h\"\n#include \"src/SparseCore/SparseMatrixBase.h\"\n#include \"src/SparseCore/SparseAssign.h\"\n#include \"src/SparseCore/CompressedStorage.h\"\n#include \"src/SparseCore/AmbiVector.h\"\n#include \"src/SparseCore/SparseCompressedBase.h\"\n#include \"src/SparseCore/SparseMatrix.h\"\n#include \"src/SparseCore/SparseMap.h\"\n#include \"src/SparseCore/MappedSparseMatrix.h\"\n#include \"src/SparseCore/SparseVector.h\"\n#include \"src/SparseCore/SparseRef.h\"\n#include \"src/SparseCore/SparseCwiseUnaryOp.h\"\n#include \"src/SparseCore/SparseCwiseBinaryOp.h\"\n#include \"src/SparseCore/SparseTranspose.h\"\n#include \"src/SparseCore/SparseBlock.h\"\n#include \"src/SparseCore/SparseDot.h\"\n#include \"src/SparseCore/SparseRedux.h\"\n#include \"src/SparseCore/SparseView.h\"\n#include \"src/SparseCore/SparseDiagonalProduct.h\"\n#include \"src/SparseCore/ConservativeSparseSparseProduct.h\"\n#include \"src/SparseCore/SparseSparseProductWithPruning.h\"\n#include \"src/SparseCore/SparseProduct.h\"\n#include \"src/SparseCore/SparseDenseProduct.h\"\n#include \"src/SparseCore/SparseSelfAdjointView.h\"\n#include \"src/SparseCore/SparseTriangularView.h\"\n#include \"src/SparseCore/TriangularSolver.h\"\n#include \"src/SparseCore/SparsePermutation.h\"\n#include \"src/SparseCore/SparseFuzzy.h\"\n#include \"src/SparseCore/SparseSolverBase.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_SPARSECORE_MODULE_H\n\n"
  },
  {
    "path": "include/externals/Eigen/SparseLU",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n// Copyright (C) 2012 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSELU_MODULE_H\n#define EIGEN_SPARSELU_MODULE_H\n\n#include \"SparseCore\"\n\n/** \n  * \\defgroup SparseLU_Module SparseLU module\n  * This module defines a supernodal factorization of general sparse matrices.\n  * The code is fully optimized for supernode-panel updates with specialized kernels.\n  * Please, see the documentation of the SparseLU class for more details.\n  */\n\n// Ordering interface\n#include \"OrderingMethods\"\n\n#include \"src/SparseLU/SparseLU_gemm_kernel.h\"\n\n#include \"src/SparseLU/SparseLU_Structs.h\"\n#include \"src/SparseLU/SparseLU_SupernodalMatrix.h\"\n#include \"src/SparseLU/SparseLUImpl.h\"\n#include \"src/SparseCore/SparseColEtree.h\"\n#include \"src/SparseLU/SparseLU_Memory.h\"\n#include \"src/SparseLU/SparseLU_heap_relax_snode.h\"\n#include \"src/SparseLU/SparseLU_relax_snode.h\"\n#include \"src/SparseLU/SparseLU_pivotL.h\"\n#include \"src/SparseLU/SparseLU_panel_dfs.h\"\n#include \"src/SparseLU/SparseLU_kernel_bmod.h\"\n#include \"src/SparseLU/SparseLU_panel_bmod.h\"\n#include \"src/SparseLU/SparseLU_column_dfs.h\"\n#include \"src/SparseLU/SparseLU_column_bmod.h\"\n#include \"src/SparseLU/SparseLU_copy_to_ucol.h\"\n#include \"src/SparseLU/SparseLU_pruneL.h\"\n#include \"src/SparseLU/SparseLU_Utils.h\"\n#include \"src/SparseLU/SparseLU.h\"\n\n#endif // EIGEN_SPARSELU_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/SparseQR",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSEQR_MODULE_H\n#define EIGEN_SPARSEQR_MODULE_H\n\n#include \"SparseCore\"\n#include \"OrderingMethods\"\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n/** \\defgroup SparseQR_Module SparseQR module\n  * \\brief Provides QR decomposition for sparse matrices\n  * \n  * This module provides a simplicial version of the left-looking Sparse QR decomposition. \n  * The columns of the input matrix should be reordered to limit the fill-in during the \n  * decomposition. Built-in methods (COLAMD, AMD) or external  methods (METIS) can be used to this end.\n  * See the \\link OrderingMethods_Module OrderingMethods\\endlink module for the list \n  * of built-in and external ordering methods.\n  * \n  * \\code\n  * #include <Eigen/SparseQR>\n  * \\endcode\n  * \n  * \n  */\n\n#include \"OrderingMethods\"\n#include \"src/SparseCore/SparseColEtree.h\"\n#include \"src/SparseQR/SparseQR.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/StdDeque",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_STDDEQUE_MODULE_H\n#define EIGEN_STDDEQUE_MODULE_H\n\n#include \"Core\"\n#include <deque>\n\n#if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */\n\n#define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...)\n\n#else\n\n#include \"src/StlSupport/StdDeque.h\"\n\n#endif\n\n#endif // EIGEN_STDDEQUE_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/StdList",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_STDLIST_MODULE_H\n#define EIGEN_STDLIST_MODULE_H\n\n#include \"Core\"\n#include <list>\n\n#if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */\n\n#define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...)\n\n#else\n\n#include \"src/StlSupport/StdList.h\"\n\n#endif\n\n#endif // EIGEN_STDLIST_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/StdVector",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_STDVECTOR_MODULE_H\n#define EIGEN_STDVECTOR_MODULE_H\n\n#include \"Core\"\n#include <vector>\n\n#if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */\n\n#define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...)\n\n#else\n\n#include \"src/StlSupport/StdVector.h\"\n\n#endif\n\n#endif // EIGEN_STDVECTOR_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/SuperLUSupport",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SUPERLUSUPPORT_MODULE_H\n#define EIGEN_SUPERLUSUPPORT_MODULE_H\n\n#include \"SparseCore\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\n#ifdef EMPTY\n#define EIGEN_EMPTY_WAS_ALREADY_DEFINED\n#endif\n\ntypedef int int_t;\n#include <slu_Cnames.h>\n#include <supermatrix.h>\n#include <slu_util.h>\n\n// slu_util.h defines a preprocessor token named EMPTY which is really polluting,\n// so we remove it in favor of a SUPERLU_EMPTY token.\n// If EMPTY was already defined then we don't undef it.\n\n#if defined(EIGEN_EMPTY_WAS_ALREADY_DEFINED)\n# undef EIGEN_EMPTY_WAS_ALREADY_DEFINED\n#elif defined(EMPTY)\n# undef EMPTY\n#endif\n\n#define SUPERLU_EMPTY (-1)\n\nnamespace Eigen { struct SluMatrix; }\n\n/** \\ingroup Support_modules\n  * \\defgroup SuperLUSupport_Module SuperLUSupport module\n  *\n  * This module provides an interface to the <a href=\"http://crd-legacy.lbl.gov/~xiaoye/SuperLU/\">SuperLU</a> library.\n  * It provides the following factorization class:\n  * - class SuperLU: a supernodal sequential LU factorization.\n  * - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative methods).\n  *\n  * \\warning This wrapper requires at least versions 4.0 of SuperLU. The 3.x versions are not supported.\n  *\n  * \\warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined because it is too polluting.\n  *\n  * \\code\n  * #include <Eigen/SuperLUSupport>\n  * \\endcode\n  *\n  * In order to use this module, the superlu headers must be accessible from the include paths, and your binary must be linked to the superlu library and its dependencies.\n  * The dependencies depend on how superlu has been compiled.\n  * For a cmake based project, you can use our FindSuperLU.cmake module to help you in this task.\n  *\n  */\n\n#include \"src/SuperLUSupport/SuperLUSupport.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_SUPERLUSUPPORT_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/UmfPackSupport",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_UMFPACKSUPPORT_MODULE_H\n#define EIGEN_UMFPACKSUPPORT_MODULE_H\n\n#include \"SparseCore\"\n\n#include \"src/Core/util/DisableStupidWarnings.h\"\n\nextern \"C\" {\n#include <umfpack.h>\n}\n\n/** \\ingroup Support_modules\n  * \\defgroup UmfPackSupport_Module UmfPackSupport module\n  *\n  * This module provides an interface to the UmfPack library which is part of the <a href=\"http://www.suitesparse.com\">suitesparse</a> package.\n  * It provides the following factorization class:\n  * - class UmfPackLU: a multifrontal sequential LU factorization.\n  *\n  * \\code\n  * #include <Eigen/UmfPackSupport>\n  * \\endcode\n  *\n  * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies.\n  * The dependencies depend on how umfpack has been compiled.\n  * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task.\n  *\n  */\n\n#include \"src/UmfPackSupport/UmfPackSupport.h\"\n\n#include \"src/Core/util/ReenableStupidWarnings.h\"\n\n#endif // EIGEN_UMFPACKSUPPORT_MODULE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Cholesky/LDLT.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2011 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Keir Mierle <mierle@gmail.com>\n// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2011 Timothy E. Holy <tim.holy@gmail.com >\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_LDLT_H\n#define EIGEN_LDLT_H\n\nnamespace Eigen {\n\nnamespace internal {\n  template<typename MatrixType, int UpLo> struct LDLT_Traits;\n\n  // PositiveSemiDef means positive semi-definite and non-zero; same for NegativeSemiDef\n  enum SignMatrix { PositiveSemiDef, NegativeSemiDef, ZeroSign, Indefinite };\n}\n\n/** \\ingroup Cholesky_Module\n  *\n  * \\class LDLT\n  *\n  * \\brief Robust Cholesky decomposition of a matrix with pivoting\n  *\n  * \\tparam _MatrixType the type of the matrix of which to compute the LDL^T Cholesky decomposition\n  * \\tparam _UpLo the triangular part that will be used for the decompositon: Lower (default) or Upper.\n  *             The other triangular part won't be read.\n  *\n  * Perform a robust Cholesky decomposition of a positive semidefinite or negative semidefinite\n  * matrix \\f$ A \\f$ such that \\f$ A =  P^TLDL^*P \\f$, where P is a permutation matrix, L\n  * is lower triangular with a unit diagonal and D is a diagonal matrix.\n  *\n  * The decomposition uses pivoting to ensure stability, so that L will have\n  * zeros in the bottom right rank(A) - n submatrix. Avoiding the square root\n  * on D also stabilizes the computation.\n  *\n  * Remember that Cholesky decompositions are not rank-revealing. Also, do not use a Cholesky\n  * decomposition to determine whether a system of equations has a solution.\n  *\n  * This class supports the \\link InplaceDecomposition inplace decomposition \\endlink mechanism.\n  * \n  * \\sa MatrixBase::ldlt(), SelfAdjointView::ldlt(), class LLT\n  */\ntemplate<typename _MatrixType, int _UpLo> class LDLT\n{\n  public:\n    typedef _MatrixType MatrixType;\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,\n      UpLo = _UpLo\n    };\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef Matrix<Scalar, RowsAtCompileTime, 1, 0, MaxRowsAtCompileTime, 1> TmpMatrixType;\n\n    typedef Transpositions<RowsAtCompileTime, MaxRowsAtCompileTime> TranspositionType;\n    typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> PermutationType;\n\n    typedef internal::LDLT_Traits<MatrixType,UpLo> Traits;\n\n    /** \\brief Default Constructor.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via LDLT::compute(const MatrixType&).\n      */\n    LDLT()\n      : m_matrix(),\n        m_transpositions(),\n        m_sign(internal::ZeroSign),\n        m_isInitialized(false)\n    {}\n\n    /** \\brief Default Constructor with memory preallocation\n      *\n      * Like the default constructor but with preallocation of the internal data\n      * according to the specified problem \\a size.\n      * \\sa LDLT()\n      */\n    explicit LDLT(Index size)\n      : m_matrix(size, size),\n        m_transpositions(size),\n        m_temporary(size),\n        m_sign(internal::ZeroSign),\n        m_isInitialized(false)\n    {}\n\n    /** \\brief Constructor with decomposition\n      *\n      * This calculates the decomposition for the input \\a matrix.\n      *\n      * \\sa LDLT(Index size)\n      */\n    template<typename InputType>\n    explicit LDLT(const EigenBase<InputType>& matrix)\n      : m_matrix(matrix.rows(), matrix.cols()),\n        m_transpositions(matrix.rows()),\n        m_temporary(matrix.rows()),\n        m_sign(internal::ZeroSign),\n        m_isInitialized(false)\n    {\n      compute(matrix.derived());\n    }\n\n    /** \\brief Constructs a LDLT factorization from a given matrix\n      *\n      * This overloaded constructor is provided for \\link InplaceDecomposition inplace decomposition \\endlink when \\c MatrixType is a Eigen::Ref.\n      *\n      * \\sa LDLT(const EigenBase&)\n      */\n    template<typename InputType>\n    explicit LDLT(EigenBase<InputType>& matrix)\n      : m_matrix(matrix.derived()),\n        m_transpositions(matrix.rows()),\n        m_temporary(matrix.rows()),\n        m_sign(internal::ZeroSign),\n        m_isInitialized(false)\n    {\n      compute(matrix.derived());\n    }\n\n    /** Clear any existing decomposition\n     * \\sa rankUpdate(w,sigma)\n     */\n    void setZero()\n    {\n      m_isInitialized = false;\n    }\n\n    /** \\returns a view of the upper triangular matrix U */\n    inline typename Traits::MatrixU matrixU() const\n    {\n      eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n      return Traits::getU(m_matrix);\n    }\n\n    /** \\returns a view of the lower triangular matrix L */\n    inline typename Traits::MatrixL matrixL() const\n    {\n      eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n      return Traits::getL(m_matrix);\n    }\n\n    /** \\returns the permutation matrix P as a transposition sequence.\n      */\n    inline const TranspositionType& transpositionsP() const\n    {\n      eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n      return m_transpositions;\n    }\n\n    /** \\returns the coefficients of the diagonal matrix D */\n    inline Diagonal<const MatrixType> vectorD() const\n    {\n      eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n      return m_matrix.diagonal();\n    }\n\n    /** \\returns true if the matrix is positive (semidefinite) */\n    inline bool isPositive() const\n    {\n      eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n      return m_sign == internal::PositiveSemiDef || m_sign == internal::ZeroSign;\n    }\n\n    /** \\returns true if the matrix is negative (semidefinite) */\n    inline bool isNegative(void) const\n    {\n      eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n      return m_sign == internal::NegativeSemiDef || m_sign == internal::ZeroSign;\n    }\n\n    /** \\returns a solution x of \\f$ A x = b \\f$ using the current decomposition of A.\n      *\n      * This function also supports in-place solves using the syntax <tt>x = decompositionObject.solve(x)</tt> .\n      *\n      * \\note_about_checking_solutions\n      *\n      * More precisely, this method solves \\f$ A x = b \\f$ using the decomposition \\f$ A = P^T L D L^* P \\f$\n      * by solving the systems \\f$ P^T y_1 = b \\f$, \\f$ L y_2 = y_1 \\f$, \\f$ D y_3 = y_2 \\f$,\n      * \\f$ L^* y_4 = y_3 \\f$ and \\f$ P x = y_4 \\f$ in succession. If the matrix \\f$ A \\f$ is singular, then\n      * \\f$ D \\f$ will also be singular (all the other matrices are invertible). In that case, the\n      * least-square solution of \\f$ D y_3 = y_2 \\f$ is computed. This does not mean that this function\n      * computes the least-square solution of \\f$ A x = b \\f$ is \\f$ A \\f$ is singular.\n      *\n      * \\sa MatrixBase::ldlt(), SelfAdjointView::ldlt()\n      */\n    template<typename Rhs>\n    inline const Solve<LDLT, Rhs>\n    solve(const MatrixBase<Rhs>& b) const\n    {\n      eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n      eigen_assert(m_matrix.rows()==b.rows()\n                && \"LDLT::solve(): invalid number of rows of the right hand side matrix b\");\n      return Solve<LDLT, Rhs>(*this, b.derived());\n    }\n\n    template<typename Derived>\n    bool solveInPlace(MatrixBase<Derived> &bAndX) const;\n\n    template<typename InputType>\n    LDLT& compute(const EigenBase<InputType>& matrix);\n\n    /** \\returns an estimate of the reciprocal condition number of the matrix of\n     *  which \\c *this is the LDLT decomposition.\n     */\n    RealScalar rcond() const\n    {\n      eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n      return internal::rcond_estimate_helper(m_l1_norm, *this);\n    }\n\n    template <typename Derived>\n    LDLT& rankUpdate(const MatrixBase<Derived>& w, const RealScalar& alpha=1);\n\n    /** \\returns the internal LDLT decomposition matrix\n      *\n      * TODO: document the storage layout\n      */\n    inline const MatrixType& matrixLDLT() const\n    {\n      eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n      return m_matrix;\n    }\n\n    MatrixType reconstructedMatrix() const;\n\n    /** \\returns the adjoint of \\c *this, that is, a const reference to the decomposition itself as the underlying matrix is self-adjoint.\n      *\n      * This method is provided for compatibility with other matrix decompositions, thus enabling generic code such as:\n      * \\code x = decomposition.adjoint().solve(b) \\endcode\n      */\n    const LDLT& adjoint() const { return *this; };\n\n    inline Index rows() const { return m_matrix.rows(); }\n    inline Index cols() const { return m_matrix.cols(); }\n\n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful,\n      *          \\c NumericalIssue if the matrix.appears to be negative.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n      return m_info;\n    }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename RhsType, typename DstType>\n    EIGEN_DEVICE_FUNC\n    void _solve_impl(const RhsType &rhs, DstType &dst) const;\n    #endif\n\n  protected:\n\n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n    }\n\n    /** \\internal\n      * Used to compute and store the Cholesky decomposition A = L D L^* = U^* D U.\n      * The strict upper part is used during the decomposition, the strict lower\n      * part correspond to the coefficients of L (its diagonal is equal to 1 and\n      * is not stored), and the diagonal entries correspond to D.\n      */\n    MatrixType m_matrix;\n    RealScalar m_l1_norm;\n    TranspositionType m_transpositions;\n    TmpMatrixType m_temporary;\n    internal::SignMatrix m_sign;\n    bool m_isInitialized;\n    ComputationInfo m_info;\n};\n\nnamespace internal {\n\ntemplate<int UpLo> struct ldlt_inplace;\n\ntemplate<> struct ldlt_inplace<Lower>\n{\n  template<typename MatrixType, typename TranspositionType, typename Workspace>\n  static bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, SignMatrix& sign)\n  {\n    using std::abs;\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    typedef typename TranspositionType::StorageIndex IndexType;\n    eigen_assert(mat.rows()==mat.cols());\n    const Index size = mat.rows();\n    bool found_zero_pivot = false;\n    bool ret = true;\n\n    if (size <= 1)\n    {\n      transpositions.setIdentity();\n      if (numext::real(mat.coeff(0,0)) > static_cast<RealScalar>(0) ) sign = PositiveSemiDef;\n      else if (numext::real(mat.coeff(0,0)) < static_cast<RealScalar>(0)) sign = NegativeSemiDef;\n      else sign = ZeroSign;\n      return true;\n    }\n\n    for (Index k = 0; k < size; ++k)\n    {\n      // Find largest diagonal element\n      Index index_of_biggest_in_corner;\n      mat.diagonal().tail(size-k).cwiseAbs().maxCoeff(&index_of_biggest_in_corner);\n      index_of_biggest_in_corner += k;\n\n      transpositions.coeffRef(k) = IndexType(index_of_biggest_in_corner);\n      if(k != index_of_biggest_in_corner)\n      {\n        // apply the transposition while taking care to consider only\n        // the lower triangular part\n        Index s = size-index_of_biggest_in_corner-1; // trailing size after the biggest element\n        mat.row(k).head(k).swap(mat.row(index_of_biggest_in_corner).head(k));\n        mat.col(k).tail(s).swap(mat.col(index_of_biggest_in_corner).tail(s));\n        std::swap(mat.coeffRef(k,k),mat.coeffRef(index_of_biggest_in_corner,index_of_biggest_in_corner));\n        for(Index i=k+1;i<index_of_biggest_in_corner;++i)\n        {\n          Scalar tmp = mat.coeffRef(i,k);\n          mat.coeffRef(i,k) = numext::conj(mat.coeffRef(index_of_biggest_in_corner,i));\n          mat.coeffRef(index_of_biggest_in_corner,i) = numext::conj(tmp);\n        }\n        if(NumTraits<Scalar>::IsComplex)\n          mat.coeffRef(index_of_biggest_in_corner,k) = numext::conj(mat.coeff(index_of_biggest_in_corner,k));\n      }\n\n      // partition the matrix:\n      //       A00 |  -  |  -\n      // lu  = A10 | A11 |  -\n      //       A20 | A21 | A22\n      Index rs = size - k - 1;\n      Block<MatrixType,Dynamic,1> A21(mat,k+1,k,rs,1);\n      Block<MatrixType,1,Dynamic> A10(mat,k,0,1,k);\n      Block<MatrixType,Dynamic,Dynamic> A20(mat,k+1,0,rs,k);\n\n      if(k>0)\n      {\n        temp.head(k) = mat.diagonal().real().head(k).asDiagonal() * A10.adjoint();\n        mat.coeffRef(k,k) -= (A10 * temp.head(k)).value();\n        if(rs>0)\n          A21.noalias() -= A20 * temp.head(k);\n      }\n\n      // In some previous versions of Eigen (e.g., 3.2.1), the scaling was omitted if the pivot\n      // was smaller than the cutoff value. However, since LDLT is not rank-revealing\n      // we should only make sure that we do not introduce INF or NaN values.\n      // Remark that LAPACK also uses 0 as the cutoff value.\n      RealScalar realAkk = numext::real(mat.coeffRef(k,k));\n      bool pivot_is_valid = (abs(realAkk) > RealScalar(0));\n\n      if(k==0 && !pivot_is_valid)\n      {\n        // The entire diagonal is zero, there is nothing more to do\n        // except filling the transpositions, and checking whether the matrix is zero.\n        sign = ZeroSign;\n        for(Index j = 0; j<size; ++j)\n        {\n          transpositions.coeffRef(j) = IndexType(j);\n          ret = ret && (mat.col(j).tail(size-j-1).array()==Scalar(0)).all();\n        }\n        return ret;\n      }\n\n      if((rs>0) && pivot_is_valid)\n        A21 /= realAkk;\n\n      if(found_zero_pivot && pivot_is_valid) ret = false; // factorization failed\n      else if(!pivot_is_valid) found_zero_pivot = true;\n\n      if (sign == PositiveSemiDef) {\n        if (realAkk < static_cast<RealScalar>(0)) sign = Indefinite;\n      } else if (sign == NegativeSemiDef) {\n        if (realAkk > static_cast<RealScalar>(0)) sign = Indefinite;\n      } else if (sign == ZeroSign) {\n        if (realAkk > static_cast<RealScalar>(0)) sign = PositiveSemiDef;\n        else if (realAkk < static_cast<RealScalar>(0)) sign = NegativeSemiDef;\n      }\n    }\n\n    return ret;\n  }\n\n  // Reference for the algorithm: Davis and Hager, \"Multiple Rank\n  // Modifications of a Sparse Cholesky Factorization\" (Algorithm 1)\n  // Trivial rearrangements of their computations (Timothy E. Holy)\n  // allow their algorithm to work for rank-1 updates even if the\n  // original matrix is not of full rank.\n  // Here only rank-1 updates are implemented, to reduce the\n  // requirement for intermediate storage and improve accuracy\n  template<typename MatrixType, typename WDerived>\n  static bool updateInPlace(MatrixType& mat, MatrixBase<WDerived>& w, const typename MatrixType::RealScalar& sigma=1)\n  {\n    using numext::isfinite;\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n\n    const Index size = mat.rows();\n    eigen_assert(mat.cols() == size && w.size()==size);\n\n    RealScalar alpha = 1;\n\n    // Apply the update\n    for (Index j = 0; j < size; j++)\n    {\n      // Check for termination due to an original decomposition of low-rank\n      if (!(isfinite)(alpha))\n        break;\n\n      // Update the diagonal terms\n      RealScalar dj = numext::real(mat.coeff(j,j));\n      Scalar wj = w.coeff(j);\n      RealScalar swj2 = sigma*numext::abs2(wj);\n      RealScalar gamma = dj*alpha + swj2;\n\n      mat.coeffRef(j,j) += swj2/alpha;\n      alpha += swj2/dj;\n\n\n      // Update the terms of L\n      Index rs = size-j-1;\n      w.tail(rs) -= wj * mat.col(j).tail(rs);\n      if(gamma != 0)\n        mat.col(j).tail(rs) += (sigma*numext::conj(wj)/gamma)*w.tail(rs);\n    }\n    return true;\n  }\n\n  template<typename MatrixType, typename TranspositionType, typename Workspace, typename WType>\n  static bool update(MatrixType& mat, const TranspositionType& transpositions, Workspace& tmp, const WType& w, const typename MatrixType::RealScalar& sigma=1)\n  {\n    // Apply the permutation to the input w\n    tmp = transpositions * w;\n\n    return ldlt_inplace<Lower>::updateInPlace(mat,tmp,sigma);\n  }\n};\n\ntemplate<> struct ldlt_inplace<Upper>\n{\n  template<typename MatrixType, typename TranspositionType, typename Workspace>\n  static EIGEN_STRONG_INLINE bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, SignMatrix& sign)\n  {\n    Transpose<MatrixType> matt(mat);\n    return ldlt_inplace<Lower>::unblocked(matt, transpositions, temp, sign);\n  }\n\n  template<typename MatrixType, typename TranspositionType, typename Workspace, typename WType>\n  static EIGEN_STRONG_INLINE bool update(MatrixType& mat, TranspositionType& transpositions, Workspace& tmp, WType& w, const typename MatrixType::RealScalar& sigma=1)\n  {\n    Transpose<MatrixType> matt(mat);\n    return ldlt_inplace<Lower>::update(matt, transpositions, tmp, w.conjugate(), sigma);\n  }\n};\n\ntemplate<typename MatrixType> struct LDLT_Traits<MatrixType,Lower>\n{\n  typedef const TriangularView<const MatrixType, UnitLower> MatrixL;\n  typedef const TriangularView<const typename MatrixType::AdjointReturnType, UnitUpper> MatrixU;\n  static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); }\n  static inline MatrixU getU(const MatrixType& m) { return MatrixU(m.adjoint()); }\n};\n\ntemplate<typename MatrixType> struct LDLT_Traits<MatrixType,Upper>\n{\n  typedef const TriangularView<const typename MatrixType::AdjointReturnType, UnitLower> MatrixL;\n  typedef const TriangularView<const MatrixType, UnitUpper> MatrixU;\n  static inline MatrixL getL(const MatrixType& m) { return MatrixL(m.adjoint()); }\n  static inline MatrixU getU(const MatrixType& m) { return MatrixU(m); }\n};\n\n} // end namespace internal\n\n/** Compute / recompute the LDLT decomposition A = L D L^* = U^* D U of \\a matrix\n  */\ntemplate<typename MatrixType, int _UpLo>\ntemplate<typename InputType>\nLDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::compute(const EigenBase<InputType>& a)\n{\n  check_template_parameters();\n\n  eigen_assert(a.rows()==a.cols());\n  const Index size = a.rows();\n\n  m_matrix = a.derived();\n\n  // Compute matrix L1 norm = max abs column sum.\n  m_l1_norm = RealScalar(0);\n  // TODO move this code to SelfAdjointView\n  for (Index col = 0; col < size; ++col) {\n    RealScalar abs_col_sum;\n    if (_UpLo == Lower)\n      abs_col_sum = m_matrix.col(col).tail(size - col).template lpNorm<1>() + m_matrix.row(col).head(col).template lpNorm<1>();\n    else\n      abs_col_sum = m_matrix.col(col).head(col).template lpNorm<1>() + m_matrix.row(col).tail(size - col).template lpNorm<1>();\n    if (abs_col_sum > m_l1_norm)\n      m_l1_norm = abs_col_sum;\n  }\n\n  m_transpositions.resize(size);\n  m_isInitialized = false;\n  m_temporary.resize(size);\n  m_sign = internal::ZeroSign;\n\n  m_info = internal::ldlt_inplace<UpLo>::unblocked(m_matrix, m_transpositions, m_temporary, m_sign) ? Success : NumericalIssue;\n\n  m_isInitialized = true;\n  return *this;\n}\n\n/** Update the LDLT decomposition:  given A = L D L^T, efficiently compute the decomposition of A + sigma w w^T.\n * \\param w a vector to be incorporated into the decomposition.\n * \\param sigma a scalar, +1 for updates and -1 for \"downdates,\" which correspond to removing previously-added column vectors. Optional; default value is +1.\n * \\sa setZero()\n  */\ntemplate<typename MatrixType, int _UpLo>\ntemplate<typename Derived>\nLDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Derived>& w, const typename LDLT<MatrixType,_UpLo>::RealScalar& sigma)\n{\n  typedef typename TranspositionType::StorageIndex IndexType;\n  const Index size = w.rows();\n  if (m_isInitialized)\n  {\n    eigen_assert(m_matrix.rows()==size);\n  }\n  else\n  {\n    m_matrix.resize(size,size);\n    m_matrix.setZero();\n    m_transpositions.resize(size);\n    for (Index i = 0; i < size; i++)\n      m_transpositions.coeffRef(i) = IndexType(i);\n    m_temporary.resize(size);\n    m_sign = sigma>=0 ? internal::PositiveSemiDef : internal::NegativeSemiDef;\n    m_isInitialized = true;\n  }\n\n  internal::ldlt_inplace<UpLo>::update(m_matrix, m_transpositions, m_temporary, w, sigma);\n\n  return *this;\n}\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename _MatrixType, int _UpLo>\ntemplate<typename RhsType, typename DstType>\nvoid LDLT<_MatrixType,_UpLo>::_solve_impl(const RhsType &rhs, DstType &dst) const\n{\n  eigen_assert(rhs.rows() == rows());\n  // dst = P b\n  dst = m_transpositions * rhs;\n\n  // dst = L^-1 (P b)\n  matrixL().solveInPlace(dst);\n\n  // dst = D^-1 (L^-1 P b)\n  // more precisely, use pseudo-inverse of D (see bug 241)\n  using std::abs;\n  const typename Diagonal<const MatrixType>::RealReturnType vecD(vectorD());\n  // In some previous versions, tolerance was set to the max of 1/highest and the maximal diagonal entry * epsilon\n  // as motivated by LAPACK's xGELSS:\n  // RealScalar tolerance = numext::maxi(vecD.array().abs().maxCoeff() * NumTraits<RealScalar>::epsilon(),RealScalar(1) / NumTraits<RealScalar>::highest());\n  // However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the highest\n  // diagonal element is not well justified and leads to numerical issues in some cases.\n  // Moreover, Lapack's xSYTRS routines use 0 for the tolerance.\n  RealScalar tolerance = RealScalar(1) / NumTraits<RealScalar>::highest();\n\n  for (Index i = 0; i < vecD.size(); ++i)\n  {\n    if(abs(vecD(i)) > tolerance)\n      dst.row(i) /= vecD(i);\n    else\n      dst.row(i).setZero();\n  }\n\n  // dst = L^-T (D^-1 L^-1 P b)\n  matrixU().solveInPlace(dst);\n\n  // dst = P^-1 (L^-T D^-1 L^-1 P b) = A^-1 b\n  dst = m_transpositions.transpose() * dst;\n}\n#endif\n\n/** \\internal use x = ldlt_object.solve(x);\n  *\n  * This is the \\em in-place version of solve().\n  *\n  * \\param bAndX represents both the right-hand side matrix b and result x.\n  *\n  * \\returns true always! If you need to check for existence of solutions, use another decomposition like LU, QR, or SVD.\n  *\n  * This version avoids a copy when the right hand side matrix b is not\n  * needed anymore.\n  *\n  * \\sa LDLT::solve(), MatrixBase::ldlt()\n  */\ntemplate<typename MatrixType,int _UpLo>\ntemplate<typename Derived>\nbool LDLT<MatrixType,_UpLo>::solveInPlace(MatrixBase<Derived> &bAndX) const\n{\n  eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n  eigen_assert(m_matrix.rows() == bAndX.rows());\n\n  bAndX = this->solve(bAndX);\n\n  return true;\n}\n\n/** \\returns the matrix represented by the decomposition,\n * i.e., it returns the product: P^T L D L^* P.\n * This function is provided for debug purpose. */\ntemplate<typename MatrixType, int _UpLo>\nMatrixType LDLT<MatrixType,_UpLo>::reconstructedMatrix() const\n{\n  eigen_assert(m_isInitialized && \"LDLT is not initialized.\");\n  const Index size = m_matrix.rows();\n  MatrixType res(size,size);\n\n  // P\n  res.setIdentity();\n  res = transpositionsP() * res;\n  // L^* P\n  res = matrixU() * res;\n  // D(L^*P)\n  res = vectorD().real().asDiagonal() * res;\n  // L(DL^*P)\n  res = matrixL() * res;\n  // P^T (LDL^*P)\n  res = transpositionsP().transpose() * res;\n\n  return res;\n}\n\n/** \\cholesky_module\n  * \\returns the Cholesky decomposition with full pivoting without square root of \\c *this\n  * \\sa MatrixBase::ldlt()\n  */\ntemplate<typename MatrixType, unsigned int UpLo>\ninline const LDLT<typename SelfAdjointView<MatrixType, UpLo>::PlainObject, UpLo>\nSelfAdjointView<MatrixType, UpLo>::ldlt() const\n{\n  return LDLT<PlainObject,UpLo>(m_matrix);\n}\n\n/** \\cholesky_module\n  * \\returns the Cholesky decomposition with full pivoting without square root of \\c *this\n  * \\sa SelfAdjointView::ldlt()\n  */\ntemplate<typename Derived>\ninline const LDLT<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::ldlt() const\n{\n  return LDLT<PlainObject>(derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_LDLT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Cholesky/LLT.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_LLT_H\n#define EIGEN_LLT_H\n\nnamespace Eigen {\n\nnamespace internal{\ntemplate<typename MatrixType, int UpLo> struct LLT_Traits;\n}\n\n/** \\ingroup Cholesky_Module\n  *\n  * \\class LLT\n  *\n  * \\brief Standard Cholesky decomposition (LL^T) of a matrix and associated features\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the LL^T Cholesky decomposition\n  * \\tparam _UpLo the triangular part that will be used for the decompositon: Lower (default) or Upper.\n  *             The other triangular part won't be read.\n  *\n  * This class performs a LL^T Cholesky decomposition of a symmetric, positive definite\n  * matrix A such that A = LL^* = U^*U, where L is lower triangular.\n  *\n  * While the Cholesky decomposition is particularly useful to solve selfadjoint problems like  D^*D x = b,\n  * for that purpose, we recommend the Cholesky decomposition without square root which is more stable\n  * and even faster. Nevertheless, this standard Cholesky decomposition remains useful in many other\n  * situations like generalised eigen problems with hermitian matrices.\n  *\n  * Remember that Cholesky decompositions are not rank-revealing. This LLT decomposition is only stable on positive definite matrices,\n  * use LDLT instead for the semidefinite case. Also, do not use a Cholesky decomposition to determine whether a system of equations\n  * has a solution.\n  *\n  * Example: \\include LLT_example.cpp\n  * Output: \\verbinclude LLT_example.out\n  *\n  * This class supports the \\link InplaceDecomposition inplace decomposition \\endlink mechanism.\n  *\n  * \\sa MatrixBase::llt(), SelfAdjointView::llt(), class LDLT\n  */\n /* HEY THIS DOX IS DISABLED BECAUSE THERE's A BUG EITHER HERE OR IN LDLT ABOUT THAT (OR BOTH)\n  * Note that during the decomposition, only the upper triangular part of A is considered. Therefore,\n  * the strict lower part does not have to store correct values.\n  */\ntemplate<typename _MatrixType, int _UpLo> class LLT\n{\n  public:\n    typedef _MatrixType MatrixType;\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n    typedef typename MatrixType::StorageIndex StorageIndex;\n\n    enum {\n      PacketSize = internal::packet_traits<Scalar>::size,\n      AlignmentMask = int(PacketSize)-1,\n      UpLo = _UpLo\n    };\n\n    typedef internal::LLT_Traits<MatrixType,UpLo> Traits;\n\n    /**\n      * \\brief Default Constructor.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via LLT::compute(const MatrixType&).\n      */\n    LLT() : m_matrix(), m_isInitialized(false) {}\n\n    /** \\brief Default Constructor with memory preallocation\n      *\n      * Like the default constructor but with preallocation of the internal data\n      * according to the specified problem \\a size.\n      * \\sa LLT()\n      */\n    explicit LLT(Index size) : m_matrix(size, size),\n                    m_isInitialized(false) {}\n\n    template<typename InputType>\n    explicit LLT(const EigenBase<InputType>& matrix)\n      : m_matrix(matrix.rows(), matrix.cols()),\n        m_isInitialized(false)\n    {\n      compute(matrix.derived());\n    }\n\n    /** \\brief Constructs a LDLT factorization from a given matrix\n      *\n      * This overloaded constructor is provided for \\link InplaceDecomposition inplace decomposition \\endlink when\n      * \\c MatrixType is a Eigen::Ref.\n      *\n      * \\sa LLT(const EigenBase&)\n      */\n    template<typename InputType>\n    explicit LLT(EigenBase<InputType>& matrix)\n      : m_matrix(matrix.derived()),\n        m_isInitialized(false)\n    {\n      compute(matrix.derived());\n    }\n\n    /** \\returns a view of the upper triangular matrix U */\n    inline typename Traits::MatrixU matrixU() const\n    {\n      eigen_assert(m_isInitialized && \"LLT is not initialized.\");\n      return Traits::getU(m_matrix);\n    }\n\n    /** \\returns a view of the lower triangular matrix L */\n    inline typename Traits::MatrixL matrixL() const\n    {\n      eigen_assert(m_isInitialized && \"LLT is not initialized.\");\n      return Traits::getL(m_matrix);\n    }\n\n    /** \\returns the solution x of \\f$ A x = b \\f$ using the current decomposition of A.\n      *\n      * Since this LLT class assumes anyway that the matrix A is invertible, the solution\n      * theoretically exists and is unique regardless of b.\n      *\n      * Example: \\include LLT_solve.cpp\n      * Output: \\verbinclude LLT_solve.out\n      *\n      * \\sa solveInPlace(), MatrixBase::llt(), SelfAdjointView::llt()\n      */\n    template<typename Rhs>\n    inline const Solve<LLT, Rhs>\n    solve(const MatrixBase<Rhs>& b) const\n    {\n      eigen_assert(m_isInitialized && \"LLT is not initialized.\");\n      eigen_assert(m_matrix.rows()==b.rows()\n                && \"LLT::solve(): invalid number of rows of the right hand side matrix b\");\n      return Solve<LLT, Rhs>(*this, b.derived());\n    }\n\n    template<typename Derived>\n    void solveInPlace(MatrixBase<Derived> &bAndX) const;\n\n    template<typename InputType>\n    LLT& compute(const EigenBase<InputType>& matrix);\n\n    /** \\returns an estimate of the reciprocal condition number of the matrix of\n      *  which \\c *this is the Cholesky decomposition.\n      */\n    RealScalar rcond() const\n    {\n      eigen_assert(m_isInitialized && \"LLT is not initialized.\");\n      eigen_assert(m_info == Success && \"LLT failed because matrix appears to be negative\");\n      return internal::rcond_estimate_helper(m_l1_norm, *this);\n    }\n\n    /** \\returns the LLT decomposition matrix\n      *\n      * TODO: document the storage layout\n      */\n    inline const MatrixType& matrixLLT() const\n    {\n      eigen_assert(m_isInitialized && \"LLT is not initialized.\");\n      return m_matrix;\n    }\n\n    MatrixType reconstructedMatrix() const;\n\n\n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful,\n      *          \\c NumericalIssue if the matrix.appears to be negative.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"LLT is not initialized.\");\n      return m_info;\n    }\n\n    /** \\returns the adjoint of \\c *this, that is, a const reference to the decomposition itself as the underlying matrix is self-adjoint.\n      *\n      * This method is provided for compatibility with other matrix decompositions, thus enabling generic code such as:\n      * \\code x = decomposition.adjoint().solve(b) \\endcode\n      */\n    const LLT& adjoint() const { return *this; };\n\n    inline Index rows() const { return m_matrix.rows(); }\n    inline Index cols() const { return m_matrix.cols(); }\n\n    template<typename VectorType>\n    LLT rankUpdate(const VectorType& vec, const RealScalar& sigma = 1);\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename RhsType, typename DstType>\n    EIGEN_DEVICE_FUNC\n    void _solve_impl(const RhsType &rhs, DstType &dst) const;\n    #endif\n\n  protected:\n\n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n    }\n\n    /** \\internal\n      * Used to compute and store L\n      * The strict upper part is not used and even not initialized.\n      */\n    MatrixType m_matrix;\n    RealScalar m_l1_norm;\n    bool m_isInitialized;\n    ComputationInfo m_info;\n};\n\nnamespace internal {\n\ntemplate<typename Scalar, int UpLo> struct llt_inplace;\n\ntemplate<typename MatrixType, typename VectorType>\nstatic Index llt_rank_update_lower(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma)\n{\n  using std::sqrt;\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename MatrixType::RealScalar RealScalar;\n  typedef typename MatrixType::ColXpr ColXpr;\n  typedef typename internal::remove_all<ColXpr>::type ColXprCleaned;\n  typedef typename ColXprCleaned::SegmentReturnType ColXprSegment;\n  typedef Matrix<Scalar,Dynamic,1> TempVectorType;\n  typedef typename TempVectorType::SegmentReturnType TempVecSegment;\n\n  Index n = mat.cols();\n  eigen_assert(mat.rows()==n && vec.size()==n);\n\n  TempVectorType temp;\n\n  if(sigma>0)\n  {\n    // This version is based on Givens rotations.\n    // It is faster than the other one below, but only works for updates,\n    // i.e., for sigma > 0\n    temp = sqrt(sigma) * vec;\n\n    for(Index i=0; i<n; ++i)\n    {\n      JacobiRotation<Scalar> g;\n      g.makeGivens(mat(i,i), -temp(i), &mat(i,i));\n\n      Index rs = n-i-1;\n      if(rs>0)\n      {\n        ColXprSegment x(mat.col(i).tail(rs));\n        TempVecSegment y(temp.tail(rs));\n        apply_rotation_in_the_plane(x, y, g);\n      }\n    }\n  }\n  else\n  {\n    temp = vec;\n    RealScalar beta = 1;\n    for(Index j=0; j<n; ++j)\n    {\n      RealScalar Ljj = numext::real(mat.coeff(j,j));\n      RealScalar dj = numext::abs2(Ljj);\n      Scalar wj = temp.coeff(j);\n      RealScalar swj2 = sigma*numext::abs2(wj);\n      RealScalar gamma = dj*beta + swj2;\n\n      RealScalar x = dj + swj2/beta;\n      if (x<=RealScalar(0))\n        return j;\n      RealScalar nLjj = sqrt(x);\n      mat.coeffRef(j,j) = nLjj;\n      beta += swj2/dj;\n\n      // Update the terms of L\n      Index rs = n-j-1;\n      if(rs)\n      {\n        temp.tail(rs) -= (wj/Ljj) * mat.col(j).tail(rs);\n        if(gamma != 0)\n          mat.col(j).tail(rs) = (nLjj/Ljj) * mat.col(j).tail(rs) + (nLjj * sigma*numext::conj(wj)/gamma)*temp.tail(rs);\n      }\n    }\n  }\n  return -1;\n}\n\ntemplate<typename Scalar> struct llt_inplace<Scalar, Lower>\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  template<typename MatrixType>\n  static Index unblocked(MatrixType& mat)\n  {\n    using std::sqrt;\n\n    eigen_assert(mat.rows()==mat.cols());\n    const Index size = mat.rows();\n    for(Index k = 0; k < size; ++k)\n    {\n      Index rs = size-k-1; // remaining size\n\n      Block<MatrixType,Dynamic,1> A21(mat,k+1,k,rs,1);\n      Block<MatrixType,1,Dynamic> A10(mat,k,0,1,k);\n      Block<MatrixType,Dynamic,Dynamic> A20(mat,k+1,0,rs,k);\n\n      RealScalar x = numext::real(mat.coeff(k,k));\n      if (k>0) x -= A10.squaredNorm();\n      if (x<=RealScalar(0))\n        return k;\n      mat.coeffRef(k,k) = x = sqrt(x);\n      if (k>0 && rs>0) A21.noalias() -= A20 * A10.adjoint();\n      if (rs>0) A21 /= x;\n    }\n    return -1;\n  }\n\n  template<typename MatrixType>\n  static Index blocked(MatrixType& m)\n  {\n    eigen_assert(m.rows()==m.cols());\n    Index size = m.rows();\n    if(size<32)\n      return unblocked(m);\n\n    Index blockSize = size/8;\n    blockSize = (blockSize/16)*16;\n    blockSize = (std::min)((std::max)(blockSize,Index(8)), Index(128));\n\n    for (Index k=0; k<size; k+=blockSize)\n    {\n      // partition the matrix:\n      //       A00 |  -  |  -\n      // lu  = A10 | A11 |  -\n      //       A20 | A21 | A22\n      Index bs = (std::min)(blockSize, size-k);\n      Index rs = size - k - bs;\n      Block<MatrixType,Dynamic,Dynamic> A11(m,k,   k,   bs,bs);\n      Block<MatrixType,Dynamic,Dynamic> A21(m,k+bs,k,   rs,bs);\n      Block<MatrixType,Dynamic,Dynamic> A22(m,k+bs,k+bs,rs,rs);\n\n      Index ret;\n      if((ret=unblocked(A11))>=0) return k+ret;\n      if(rs>0) A11.adjoint().template triangularView<Upper>().template solveInPlace<OnTheRight>(A21);\n      if(rs>0) A22.template selfadjointView<Lower>().rankUpdate(A21,typename NumTraits<RealScalar>::Literal(-1)); // bottleneck\n    }\n    return -1;\n  }\n\n  template<typename MatrixType, typename VectorType>\n  static Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma)\n  {\n    return Eigen::internal::llt_rank_update_lower(mat, vec, sigma);\n  }\n};\n\ntemplate<typename Scalar> struct llt_inplace<Scalar, Upper>\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n\n  template<typename MatrixType>\n  static EIGEN_STRONG_INLINE Index unblocked(MatrixType& mat)\n  {\n    Transpose<MatrixType> matt(mat);\n    return llt_inplace<Scalar, Lower>::unblocked(matt);\n  }\n  template<typename MatrixType>\n  static EIGEN_STRONG_INLINE Index blocked(MatrixType& mat)\n  {\n    Transpose<MatrixType> matt(mat);\n    return llt_inplace<Scalar, Lower>::blocked(matt);\n  }\n  template<typename MatrixType, typename VectorType>\n  static Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma)\n  {\n    Transpose<MatrixType> matt(mat);\n    return llt_inplace<Scalar, Lower>::rankUpdate(matt, vec.conjugate(), sigma);\n  }\n};\n\ntemplate<typename MatrixType> struct LLT_Traits<MatrixType,Lower>\n{\n  typedef const TriangularView<const MatrixType, Lower> MatrixL;\n  typedef const TriangularView<const typename MatrixType::AdjointReturnType, Upper> MatrixU;\n  static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); }\n  static inline MatrixU getU(const MatrixType& m) { return MatrixU(m.adjoint()); }\n  static bool inplace_decomposition(MatrixType& m)\n  { return llt_inplace<typename MatrixType::Scalar, Lower>::blocked(m)==-1; }\n};\n\ntemplate<typename MatrixType> struct LLT_Traits<MatrixType,Upper>\n{\n  typedef const TriangularView<const typename MatrixType::AdjointReturnType, Lower> MatrixL;\n  typedef const TriangularView<const MatrixType, Upper> MatrixU;\n  static inline MatrixL getL(const MatrixType& m) { return MatrixL(m.adjoint()); }\n  static inline MatrixU getU(const MatrixType& m) { return MatrixU(m); }\n  static bool inplace_decomposition(MatrixType& m)\n  { return llt_inplace<typename MatrixType::Scalar, Upper>::blocked(m)==-1; }\n};\n\n} // end namespace internal\n\n/** Computes / recomputes the Cholesky decomposition A = LL^* = U^*U of \\a matrix\n  *\n  * \\returns a reference to *this\n  *\n  * Example: \\include TutorialLinAlgComputeTwice.cpp\n  * Output: \\verbinclude TutorialLinAlgComputeTwice.out\n  */\ntemplate<typename MatrixType, int _UpLo>\ntemplate<typename InputType>\nLLT<MatrixType,_UpLo>& LLT<MatrixType,_UpLo>::compute(const EigenBase<InputType>& a)\n{\n  check_template_parameters();\n\n  eigen_assert(a.rows()==a.cols());\n  const Index size = a.rows();\n  m_matrix.resize(size, size);\n  m_matrix = a.derived();\n\n  // Compute matrix L1 norm = max abs column sum.\n  m_l1_norm = RealScalar(0);\n  // TODO move this code to SelfAdjointView\n  for (Index col = 0; col < size; ++col) {\n    RealScalar abs_col_sum;\n    if (_UpLo == Lower)\n      abs_col_sum = m_matrix.col(col).tail(size - col).template lpNorm<1>() + m_matrix.row(col).head(col).template lpNorm<1>();\n    else\n      abs_col_sum = m_matrix.col(col).head(col).template lpNorm<1>() + m_matrix.row(col).tail(size - col).template lpNorm<1>();\n    if (abs_col_sum > m_l1_norm)\n      m_l1_norm = abs_col_sum;\n  }\n\n  m_isInitialized = true;\n  bool ok = Traits::inplace_decomposition(m_matrix);\n  m_info = ok ? Success : NumericalIssue;\n\n  return *this;\n}\n\n/** Performs a rank one update (or dowdate) of the current decomposition.\n  * If A = LL^* before the rank one update,\n  * then after it we have LL^* = A + sigma * v v^* where \\a v must be a vector\n  * of same dimension.\n  */\ntemplate<typename _MatrixType, int _UpLo>\ntemplate<typename VectorType>\nLLT<_MatrixType,_UpLo> LLT<_MatrixType,_UpLo>::rankUpdate(const VectorType& v, const RealScalar& sigma)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorType);\n  eigen_assert(v.size()==m_matrix.cols());\n  eigen_assert(m_isInitialized);\n  if(internal::llt_inplace<typename MatrixType::Scalar, UpLo>::rankUpdate(m_matrix,v,sigma)>=0)\n    m_info = NumericalIssue;\n  else\n    m_info = Success;\n\n  return *this;\n}\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename _MatrixType,int _UpLo>\ntemplate<typename RhsType, typename DstType>\nvoid LLT<_MatrixType,_UpLo>::_solve_impl(const RhsType &rhs, DstType &dst) const\n{\n  dst = rhs;\n  solveInPlace(dst);\n}\n#endif\n\n/** \\internal use x = llt_object.solve(x);\n  *\n  * This is the \\em in-place version of solve().\n  *\n  * \\param bAndX represents both the right-hand side matrix b and result x.\n  *\n  * This version avoids a copy when the right hand side matrix b is not needed anymore.\n  *\n  * \\sa LLT::solve(), MatrixBase::llt()\n  */\ntemplate<typename MatrixType, int _UpLo>\ntemplate<typename Derived>\nvoid LLT<MatrixType,_UpLo>::solveInPlace(MatrixBase<Derived> &bAndX) const\n{\n  eigen_assert(m_isInitialized && \"LLT is not initialized.\");\n  eigen_assert(m_matrix.rows()==bAndX.rows());\n  matrixL().solveInPlace(bAndX);\n  matrixU().solveInPlace(bAndX);\n}\n\n/** \\returns the matrix represented by the decomposition,\n * i.e., it returns the product: L L^*.\n * This function is provided for debug purpose. */\ntemplate<typename MatrixType, int _UpLo>\nMatrixType LLT<MatrixType,_UpLo>::reconstructedMatrix() const\n{\n  eigen_assert(m_isInitialized && \"LLT is not initialized.\");\n  return matrixL() * matrixL().adjoint().toDenseMatrix();\n}\n\n/** \\cholesky_module\n  * \\returns the LLT decomposition of \\c *this\n  * \\sa SelfAdjointView::llt()\n  */\ntemplate<typename Derived>\ninline const LLT<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::llt() const\n{\n  return LLT<PlainObject>(derived());\n}\n\n/** \\cholesky_module\n  * \\returns the LLT decomposition of \\c *this\n  * \\sa SelfAdjointView::llt()\n  */\ntemplate<typename MatrixType, unsigned int UpLo>\ninline const LLT<typename SelfAdjointView<MatrixType, UpLo>::PlainObject, UpLo>\nSelfAdjointView<MatrixType, UpLo>::llt() const\n{\n  return LLT<PlainObject,UpLo>(m_matrix);\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_LLT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Cholesky/LLT_LAPACKE.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to LAPACKe\n *     LLt decomposition based on LAPACKE_?potrf function.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_LLT_LAPACKE_H\n#define EIGEN_LLT_LAPACKE_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Scalar> struct lapacke_llt;\n\n#define EIGEN_LAPACKE_LLT(EIGTYPE, BLASTYPE, LAPACKE_PREFIX) \\\ntemplate<> struct lapacke_llt<EIGTYPE> \\\n{ \\\n  template<typename MatrixType> \\\n  static inline Index potrf(MatrixType& m, char uplo) \\\n  { \\\n    lapack_int matrix_order; \\\n    lapack_int size, lda, info, StorageOrder; \\\n    EIGTYPE* a; \\\n    eigen_assert(m.rows()==m.cols()); \\\n    /* Set up parameters for ?potrf */ \\\n    size = convert_index<lapack_int>(m.rows()); \\\n    StorageOrder = MatrixType::Flags&RowMajorBit?RowMajor:ColMajor; \\\n    matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \\\n    a = &(m.coeffRef(0,0)); \\\n    lda = convert_index<lapack_int>(m.outerStride()); \\\n\\\n    info = LAPACKE_##LAPACKE_PREFIX##potrf( matrix_order, uplo, size, (BLASTYPE*)a, lda ); \\\n    info = (info==0) ? -1 : info>0 ? info-1 : size; \\\n    return info; \\\n  } \\\n}; \\\ntemplate<> struct llt_inplace<EIGTYPE, Lower> \\\n{ \\\n  template<typename MatrixType> \\\n  static Index blocked(MatrixType& m) \\\n  { \\\n    return lapacke_llt<EIGTYPE>::potrf(m, 'L'); \\\n  } \\\n  template<typename MatrixType, typename VectorType> \\\n  static Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \\\n  { return Eigen::internal::llt_rank_update_lower(mat, vec, sigma); } \\\n}; \\\ntemplate<> struct llt_inplace<EIGTYPE, Upper> \\\n{ \\\n  template<typename MatrixType> \\\n  static Index blocked(MatrixType& m) \\\n  { \\\n    return lapacke_llt<EIGTYPE>::potrf(m, 'U'); \\\n  } \\\n  template<typename MatrixType, typename VectorType> \\\n  static Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \\\n  { \\\n    Transpose<MatrixType> matt(mat); \\\n    return llt_inplace<EIGTYPE, Lower>::rankUpdate(matt, vec.conjugate(), sigma); \\\n  } \\\n};\n\nEIGEN_LAPACKE_LLT(double, double, d)\nEIGEN_LAPACKE_LLT(float, float, s)\nEIGEN_LAPACKE_LLT(dcomplex, lapack_complex_double, z)\nEIGEN_LAPACKE_LLT(scomplex, lapack_complex_float, c)\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_LLT_LAPACKE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/CholmodSupport/CholmodSupport.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CHOLMODSUPPORT_H\n#define EIGEN_CHOLMODSUPPORT_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Scalar> struct cholmod_configure_matrix;\n\ntemplate<> struct cholmod_configure_matrix<double> {\n  template<typename CholmodType>\n  static void run(CholmodType& mat) {\n    mat.xtype = CHOLMOD_REAL;\n    mat.dtype = CHOLMOD_DOUBLE;\n  }\n};\n\ntemplate<> struct cholmod_configure_matrix<std::complex<double> > {\n  template<typename CholmodType>\n  static void run(CholmodType& mat) {\n    mat.xtype = CHOLMOD_COMPLEX;\n    mat.dtype = CHOLMOD_DOUBLE;\n  }\n};\n\n// Other scalar types are not yet suppotred by Cholmod\n// template<> struct cholmod_configure_matrix<float> {\n//   template<typename CholmodType>\n//   static void run(CholmodType& mat) {\n//     mat.xtype = CHOLMOD_REAL;\n//     mat.dtype = CHOLMOD_SINGLE;\n//   }\n// };\n//\n// template<> struct cholmod_configure_matrix<std::complex<float> > {\n//   template<typename CholmodType>\n//   static void run(CholmodType& mat) {\n//     mat.xtype = CHOLMOD_COMPLEX;\n//     mat.dtype = CHOLMOD_SINGLE;\n//   }\n// };\n\n} // namespace internal\n\n/** Wraps the Eigen sparse matrix \\a mat into a Cholmod sparse matrix object.\n  * Note that the data are shared.\n  */\ntemplate<typename _Scalar, int _Options, typename _StorageIndex>\ncholmod_sparse viewAsCholmod(Ref<SparseMatrix<_Scalar,_Options,_StorageIndex> > mat)\n{\n  cholmod_sparse res;\n  res.nzmax   = mat.nonZeros();\n  res.nrow    = mat.rows();\n  res.ncol    = mat.cols();\n  res.p       = mat.outerIndexPtr();\n  res.i       = mat.innerIndexPtr();\n  res.x       = mat.valuePtr();\n  res.z       = 0;\n  res.sorted  = 1;\n  if(mat.isCompressed())\n  {\n    res.packed  = 1;\n    res.nz = 0;\n  }\n  else\n  {\n    res.packed  = 0;\n    res.nz = mat.innerNonZeroPtr();\n  }\n\n  res.dtype   = 0;\n  res.stype   = -1;\n  \n  if (internal::is_same<_StorageIndex,int>::value)\n  {\n    res.itype = CHOLMOD_INT;\n  }\n  else if (internal::is_same<_StorageIndex,long>::value)\n  {\n    res.itype = CHOLMOD_LONG;\n  }\n  else\n  {\n    eigen_assert(false && \"Index type not supported yet\");\n  }\n\n  // setup res.xtype\n  internal::cholmod_configure_matrix<_Scalar>::run(res);\n  \n  res.stype = 0;\n  \n  return res;\n}\n\ntemplate<typename _Scalar, int _Options, typename _Index>\nconst cholmod_sparse viewAsCholmod(const SparseMatrix<_Scalar,_Options,_Index>& mat)\n{\n  cholmod_sparse res = viewAsCholmod(Ref<SparseMatrix<_Scalar,_Options,_Index> >(mat.const_cast_derived()));\n  return res;\n}\n\ntemplate<typename _Scalar, int _Options, typename _Index>\nconst cholmod_sparse viewAsCholmod(const SparseVector<_Scalar,_Options,_Index>& mat)\n{\n  cholmod_sparse res = viewAsCholmod(Ref<SparseMatrix<_Scalar,_Options,_Index> >(mat.const_cast_derived()));\n  return res;\n}\n\n/** Returns a view of the Eigen sparse matrix \\a mat as Cholmod sparse matrix.\n  * The data are not copied but shared. */\ntemplate<typename _Scalar, int _Options, typename _Index, unsigned int UpLo>\ncholmod_sparse viewAsCholmod(const SparseSelfAdjointView<const SparseMatrix<_Scalar,_Options,_Index>, UpLo>& mat)\n{\n  cholmod_sparse res = viewAsCholmod(Ref<SparseMatrix<_Scalar,_Options,_Index> >(mat.matrix().const_cast_derived()));\n  \n  if(UpLo==Upper) res.stype =  1;\n  if(UpLo==Lower) res.stype = -1;\n\n  return res;\n}\n\n/** Returns a view of the Eigen \\b dense matrix \\a mat as Cholmod dense matrix.\n  * The data are not copied but shared. */\ntemplate<typename Derived>\ncholmod_dense viewAsCholmod(MatrixBase<Derived>& mat)\n{\n  EIGEN_STATIC_ASSERT((internal::traits<Derived>::Flags&RowMajorBit)==0,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);\n  typedef typename Derived::Scalar Scalar;\n\n  cholmod_dense res;\n  res.nrow   = mat.rows();\n  res.ncol   = mat.cols();\n  res.nzmax  = res.nrow * res.ncol;\n  res.d      = Derived::IsVectorAtCompileTime ? mat.derived().size() : mat.derived().outerStride();\n  res.x      = (void*)(mat.derived().data());\n  res.z      = 0;\n\n  internal::cholmod_configure_matrix<Scalar>::run(res);\n\n  return res;\n}\n\n/** Returns a view of the Cholmod sparse matrix \\a cm as an Eigen sparse matrix.\n  * The data are not copied but shared. */\ntemplate<typename Scalar, int Flags, typename StorageIndex>\nMappedSparseMatrix<Scalar,Flags,StorageIndex> viewAsEigen(cholmod_sparse& cm)\n{\n  return MappedSparseMatrix<Scalar,Flags,StorageIndex>\n         (cm.nrow, cm.ncol, static_cast<StorageIndex*>(cm.p)[cm.ncol],\n          static_cast<StorageIndex*>(cm.p), static_cast<StorageIndex*>(cm.i),static_cast<Scalar*>(cm.x) );\n}\n\nenum CholmodMode {\n  CholmodAuto, CholmodSimplicialLLt, CholmodSupernodalLLt, CholmodLDLt\n};\n\n\n/** \\ingroup CholmodSupport_Module\n  * \\class CholmodBase\n  * \\brief The base class for the direct Cholesky factorization of Cholmod\n  * \\sa class CholmodSupernodalLLT, class CholmodSimplicialLDLT, class CholmodSimplicialLLT\n  */\ntemplate<typename _MatrixType, int _UpLo, typename Derived>\nclass CholmodBase : public SparseSolverBase<Derived>\n{\n  protected:\n    typedef SparseSolverBase<Derived> Base;\n    using Base::derived;\n    using Base::m_isInitialized;\n  public:\n    typedef _MatrixType MatrixType;\n    enum { UpLo = _UpLo };\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    typedef MatrixType CholMatrixType;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    enum {\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n\n  public:\n\n    CholmodBase()\n      : m_cholmodFactor(0), m_info(Success), m_factorizationIsOk(false), m_analysisIsOk(false)\n    {\n      EIGEN_STATIC_ASSERT((internal::is_same<double,RealScalar>::value), CHOLMOD_SUPPORTS_DOUBLE_PRECISION_ONLY);\n      m_shiftOffset[0] = m_shiftOffset[1] = 0.0;\n      cholmod_start(&m_cholmod);\n    }\n\n    explicit CholmodBase(const MatrixType& matrix)\n      : m_cholmodFactor(0), m_info(Success), m_factorizationIsOk(false), m_analysisIsOk(false)\n    {\n      EIGEN_STATIC_ASSERT((internal::is_same<double,RealScalar>::value), CHOLMOD_SUPPORTS_DOUBLE_PRECISION_ONLY);\n      m_shiftOffset[0] = m_shiftOffset[1] = 0.0;\n      cholmod_start(&m_cholmod);\n      compute(matrix);\n    }\n\n    ~CholmodBase()\n    {\n      if(m_cholmodFactor)\n        cholmod_free_factor(&m_cholmodFactor, &m_cholmod);\n      cholmod_finish(&m_cholmod);\n    }\n    \n    inline StorageIndex cols() const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n); }\n    inline StorageIndex rows() const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n); }\n    \n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful,\n      *          \\c NumericalIssue if the matrix.appears to be negative.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return m_info;\n    }\n\n    /** Computes the sparse Cholesky decomposition of \\a matrix */\n    Derived& compute(const MatrixType& matrix)\n    {\n      analyzePattern(matrix);\n      factorize(matrix);\n      return derived();\n    }\n    \n    /** Performs a symbolic decomposition on the sparsity pattern of \\a matrix.\n      *\n      * This function is particularly useful when solving for several problems having the same structure.\n      * \n      * \\sa factorize()\n      */\n    void analyzePattern(const MatrixType& matrix)\n    {\n      if(m_cholmodFactor)\n      {\n        cholmod_free_factor(&m_cholmodFactor, &m_cholmod);\n        m_cholmodFactor = 0;\n      }\n      cholmod_sparse A = viewAsCholmod(matrix.template selfadjointView<UpLo>());\n      m_cholmodFactor = cholmod_analyze(&A, &m_cholmod);\n      \n      this->m_isInitialized = true;\n      this->m_info = Success;\n      m_analysisIsOk = true;\n      m_factorizationIsOk = false;\n    }\n    \n    /** Performs a numeric decomposition of \\a matrix\n      *\n      * The given matrix must have the same sparsity pattern as the matrix on which the symbolic decomposition has been performed.\n      *\n      * \\sa analyzePattern()\n      */\n    void factorize(const MatrixType& matrix)\n    {\n      eigen_assert(m_analysisIsOk && \"You must first call analyzePattern()\");\n      cholmod_sparse A = viewAsCholmod(matrix.template selfadjointView<UpLo>());\n      cholmod_factorize_p(&A, m_shiftOffset, 0, 0, m_cholmodFactor, &m_cholmod);\n\n      // If the factorization failed, minor is the column at which it did. On success minor == n.\n      this->m_info = (m_cholmodFactor->minor == m_cholmodFactor->n ? Success : NumericalIssue);\n      m_factorizationIsOk = true;\n    }\n    \n    /** Returns a reference to the Cholmod's configuration structure to get a full control over the performed operations.\n     *  See the Cholmod user guide for details. */\n    cholmod_common& cholmod() { return m_cholmod; }\n    \n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** \\internal */\n    template<typename Rhs,typename Dest>\n    void _solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &dest) const\n    {\n      eigen_assert(m_factorizationIsOk && \"The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()\");\n      const Index size = m_cholmodFactor->n;\n      EIGEN_UNUSED_VARIABLE(size);\n      eigen_assert(size==b.rows());\n      \n      // Cholmod needs column-major stoarge without inner-stride, which corresponds to the default behavior of Ref.\n      Ref<const Matrix<typename Rhs::Scalar,Dynamic,Dynamic,ColMajor> > b_ref(b.derived());\n\n      cholmod_dense b_cd = viewAsCholmod(b_ref);\n      cholmod_dense* x_cd = cholmod_solve(CHOLMOD_A, m_cholmodFactor, &b_cd, &m_cholmod);\n      if(!x_cd)\n      {\n        this->m_info = NumericalIssue;\n        return;\n      }\n      // TODO optimize this copy by swapping when possible (be careful with alignment, etc.)\n      dest = Matrix<Scalar,Dest::RowsAtCompileTime,Dest::ColsAtCompileTime>::Map(reinterpret_cast<Scalar*>(x_cd->x),b.rows(),b.cols());\n      cholmod_free_dense(&x_cd, &m_cholmod);\n    }\n    \n    /** \\internal */\n    template<typename RhsDerived, typename DestDerived>\n    void _solve_impl(const SparseMatrixBase<RhsDerived> &b, SparseMatrixBase<DestDerived> &dest) const\n    {\n      eigen_assert(m_factorizationIsOk && \"The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()\");\n      const Index size = m_cholmodFactor->n;\n      EIGEN_UNUSED_VARIABLE(size);\n      eigen_assert(size==b.rows());\n\n      // note: cs stands for Cholmod Sparse\n      Ref<SparseMatrix<typename RhsDerived::Scalar,ColMajor,typename RhsDerived::StorageIndex> > b_ref(b.const_cast_derived());\n      cholmod_sparse b_cs = viewAsCholmod(b_ref);\n      cholmod_sparse* x_cs = cholmod_spsolve(CHOLMOD_A, m_cholmodFactor, &b_cs, &m_cholmod);\n      if(!x_cs)\n      {\n        this->m_info = NumericalIssue;\n        return;\n      }\n      // TODO optimize this copy by swapping when possible (be careful with alignment, etc.)\n      dest.derived() = viewAsEigen<typename DestDerived::Scalar,ColMajor,typename DestDerived::StorageIndex>(*x_cs);\n      cholmod_free_sparse(&x_cs, &m_cholmod);\n    }\n    #endif // EIGEN_PARSED_BY_DOXYGEN\n    \n    \n    /** Sets the shift parameter that will be used to adjust the diagonal coefficients during the numerical factorization.\n      *\n      * During the numerical factorization, an offset term is added to the diagonal coefficients:\\n\n      * \\c d_ii = \\a offset + \\c d_ii\n      *\n      * The default is \\a offset=0.\n      *\n      * \\returns a reference to \\c *this.\n      */\n    Derived& setShift(const RealScalar& offset)\n    {\n      m_shiftOffset[0] = double(offset);\n      return derived();\n    }\n    \n    /** \\returns the determinant of the underlying matrix from the current factorization */\n    Scalar determinant() const\n    {\n      using std::exp;\n      return exp(logDeterminant());\n    }\n\n    /** \\returns the log determinant of the underlying matrix from the current factorization */\n    Scalar logDeterminant() const\n    {\n      using std::log;\n      using numext::real;\n      eigen_assert(m_factorizationIsOk && \"The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()\");\n\n      RealScalar logDet = 0;\n      Scalar *x = static_cast<Scalar*>(m_cholmodFactor->x);\n      if (m_cholmodFactor->is_super)\n      {\n        // Supernodal factorization stored as a packed list of dense column-major blocs,\n        // as described by the following structure:\n\n        // super[k] == index of the first column of the j-th super node\n        StorageIndex *super = static_cast<StorageIndex*>(m_cholmodFactor->super);\n        // pi[k] == offset to the description of row indices\n        StorageIndex *pi = static_cast<StorageIndex*>(m_cholmodFactor->pi);\n        // px[k] == offset to the respective dense block\n        StorageIndex *px = static_cast<StorageIndex*>(m_cholmodFactor->px);\n\n        Index nb_super_nodes = m_cholmodFactor->nsuper;\n        for (Index k=0; k < nb_super_nodes; ++k)\n        {\n          StorageIndex ncols = super[k + 1] - super[k];\n          StorageIndex nrows = pi[k + 1] - pi[k];\n\n          Map<const Array<Scalar,1,Dynamic>, 0, InnerStride<> > sk(x + px[k], ncols, InnerStride<>(nrows+1));\n          logDet += sk.real().log().sum();\n        }\n      }\n      else\n      {\n        // Simplicial factorization stored as standard CSC matrix.\n        StorageIndex *p = static_cast<StorageIndex*>(m_cholmodFactor->p);\n        Index size = m_cholmodFactor->n;\n        for (Index k=0; k<size; ++k)\n          logDet += log(real( x[p[k]] ));\n      }\n      if (m_cholmodFactor->is_ll)\n        logDet *= 2.0;\n      return logDet;\n    };\n\n    template<typename Stream>\n    void dumpMemory(Stream& /*s*/)\n    {}\n    \n  protected:\n    mutable cholmod_common m_cholmod;\n    cholmod_factor* m_cholmodFactor;\n    double m_shiftOffset[2];\n    mutable ComputationInfo m_info;\n    int m_factorizationIsOk;\n    int m_analysisIsOk;\n};\n\n/** \\ingroup CholmodSupport_Module\n  * \\class CholmodSimplicialLLT\n  * \\brief A simplicial direct Cholesky (LLT) factorization and solver based on Cholmod\n  *\n  * This class allows to solve for A.X = B sparse linear problems via a simplicial LL^T Cholesky factorization\n  * using the Cholmod library.\n  * This simplicial variant is equivalent to Eigen's built-in SimplicialLLT class. Therefore, it has little practical interest.\n  * The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices\n  * X and B can be either dense or sparse.\n  *\n  * \\tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  * \\tparam _UpLo the triangular part that will be used for the computations. It can be Lower\n  *               or Upper. Default is Lower.\n  *\n  * \\implsparsesolverconcept\n  *\n  * This class supports all kind of SparseMatrix<>: row or column major; upper, lower, or both; compressed or non compressed.\n  *\n  * \\warning Only double precision real and complex scalar types are supported by Cholmod.\n  *\n  * \\sa \\ref TutorialSparseSolverConcept, class CholmodSupernodalLLT, class SimplicialLLT\n  */\ntemplate<typename _MatrixType, int _UpLo = Lower>\nclass CholmodSimplicialLLT : public CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLLT<_MatrixType, _UpLo> >\n{\n    typedef CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLLT> Base;\n    using Base::m_cholmod;\n    \n  public:\n    \n    typedef _MatrixType MatrixType;\n    \n    CholmodSimplicialLLT() : Base() { init(); }\n\n    CholmodSimplicialLLT(const MatrixType& matrix) : Base()\n    {\n      init();\n      this->compute(matrix);\n    }\n\n    ~CholmodSimplicialLLT() {}\n  protected:\n    void init()\n    {\n      m_cholmod.final_asis = 0;\n      m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;\n      m_cholmod.final_ll = 1;\n    }\n};\n\n\n/** \\ingroup CholmodSupport_Module\n  * \\class CholmodSimplicialLDLT\n  * \\brief A simplicial direct Cholesky (LDLT) factorization and solver based on Cholmod\n  *\n  * This class allows to solve for A.X = B sparse linear problems via a simplicial LDL^T Cholesky factorization\n  * using the Cholmod library.\n  * This simplicial variant is equivalent to Eigen's built-in SimplicialLDLT class. Therefore, it has little practical interest.\n  * The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices\n  * X and B can be either dense or sparse.\n  *\n  * \\tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  * \\tparam _UpLo the triangular part that will be used for the computations. It can be Lower\n  *               or Upper. Default is Lower.\n  *\n  * \\implsparsesolverconcept\n  *\n  * This class supports all kind of SparseMatrix<>: row or column major; upper, lower, or both; compressed or non compressed.\n  *\n  * \\warning Only double precision real and complex scalar types are supported by Cholmod.\n  *\n  * \\sa \\ref TutorialSparseSolverConcept, class CholmodSupernodalLLT, class SimplicialLDLT\n  */\ntemplate<typename _MatrixType, int _UpLo = Lower>\nclass CholmodSimplicialLDLT : public CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLDLT<_MatrixType, _UpLo> >\n{\n    typedef CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLDLT> Base;\n    using Base::m_cholmod;\n    \n  public:\n    \n    typedef _MatrixType MatrixType;\n    \n    CholmodSimplicialLDLT() : Base() { init(); }\n\n    CholmodSimplicialLDLT(const MatrixType& matrix) : Base()\n    {\n      init();\n      this->compute(matrix);\n    }\n\n    ~CholmodSimplicialLDLT() {}\n  protected:\n    void init()\n    {\n      m_cholmod.final_asis = 1;\n      m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;\n    }\n};\n\n/** \\ingroup CholmodSupport_Module\n  * \\class CholmodSupernodalLLT\n  * \\brief A supernodal Cholesky (LLT) factorization and solver based on Cholmod\n  *\n  * This class allows to solve for A.X = B sparse linear problems via a supernodal LL^T Cholesky factorization\n  * using the Cholmod library.\n  * This supernodal variant performs best on dense enough problems, e.g., 3D FEM, or very high order 2D FEM.\n  * The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices\n  * X and B can be either dense or sparse.\n  *\n  * \\tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  * \\tparam _UpLo the triangular part that will be used for the computations. It can be Lower\n  *               or Upper. Default is Lower.\n  *\n  * \\implsparsesolverconcept\n  *\n  * This class supports all kind of SparseMatrix<>: row or column major; upper, lower, or both; compressed or non compressed.\n  *\n  * \\warning Only double precision real and complex scalar types are supported by Cholmod.\n  *\n  * \\sa \\ref TutorialSparseSolverConcept\n  */\ntemplate<typename _MatrixType, int _UpLo = Lower>\nclass CholmodSupernodalLLT : public CholmodBase<_MatrixType, _UpLo, CholmodSupernodalLLT<_MatrixType, _UpLo> >\n{\n    typedef CholmodBase<_MatrixType, _UpLo, CholmodSupernodalLLT> Base;\n    using Base::m_cholmod;\n    \n  public:\n    \n    typedef _MatrixType MatrixType;\n    \n    CholmodSupernodalLLT() : Base() { init(); }\n\n    CholmodSupernodalLLT(const MatrixType& matrix) : Base()\n    {\n      init();\n      this->compute(matrix);\n    }\n\n    ~CholmodSupernodalLLT() {}\n  protected:\n    void init()\n    {\n      m_cholmod.final_asis = 1;\n      m_cholmod.supernodal = CHOLMOD_SUPERNODAL;\n    }\n};\n\n/** \\ingroup CholmodSupport_Module\n  * \\class CholmodDecomposition\n  * \\brief A general Cholesky factorization and solver based on Cholmod\n  *\n  * This class allows to solve for A.X = B sparse linear problems via a LL^T or LDL^T Cholesky factorization\n  * using the Cholmod library. The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices\n  * X and B can be either dense or sparse.\n  *\n  * This variant permits to change the underlying Cholesky method at runtime.\n  * On the other hand, it does not provide access to the result of the factorization.\n  * The default is to let Cholmod automatically choose between a simplicial and supernodal factorization.\n  *\n  * \\tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  * \\tparam _UpLo the triangular part that will be used for the computations. It can be Lower\n  *               or Upper. Default is Lower.\n  *\n  * \\implsparsesolverconcept\n  *\n  * This class supports all kind of SparseMatrix<>: row or column major; upper, lower, or both; compressed or non compressed.\n  *\n  * \\warning Only double precision real and complex scalar types are supported by Cholmod.\n  *\n  * \\sa \\ref TutorialSparseSolverConcept\n  */\ntemplate<typename _MatrixType, int _UpLo = Lower>\nclass CholmodDecomposition : public CholmodBase<_MatrixType, _UpLo, CholmodDecomposition<_MatrixType, _UpLo> >\n{\n    typedef CholmodBase<_MatrixType, _UpLo, CholmodDecomposition> Base;\n    using Base::m_cholmod;\n    \n  public:\n    \n    typedef _MatrixType MatrixType;\n    \n    CholmodDecomposition() : Base() { init(); }\n\n    CholmodDecomposition(const MatrixType& matrix) : Base()\n    {\n      init();\n      this->compute(matrix);\n    }\n\n    ~CholmodDecomposition() {}\n    \n    void setMode(CholmodMode mode)\n    {\n      switch(mode)\n      {\n        case CholmodAuto:\n          m_cholmod.final_asis = 1;\n          m_cholmod.supernodal = CHOLMOD_AUTO;\n          break;\n        case CholmodSimplicialLLt:\n          m_cholmod.final_asis = 0;\n          m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;\n          m_cholmod.final_ll = 1;\n          break;\n        case CholmodSupernodalLLt:\n          m_cholmod.final_asis = 1;\n          m_cholmod.supernodal = CHOLMOD_SUPERNODAL;\n          break;\n        case CholmodLDLt:\n          m_cholmod.final_asis = 1;\n          m_cholmod.supernodal = CHOLMOD_SIMPLICIAL;\n          break;\n        default:\n          break;\n      }\n    }\n  protected:\n    void init()\n    {\n      m_cholmod.final_asis = 1;\n      m_cholmod.supernodal = CHOLMOD_AUTO;\n    }\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_CHOLMODSUPPORT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Array.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ARRAY_H\n#define EIGEN_ARRAY_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>\nstruct traits<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > : traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >\n{\n  typedef ArrayXpr XprKind;\n  typedef ArrayBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > XprBase;\n};\n}\n\n/** \\class Array\n  * \\ingroup Core_Module\n  *\n  * \\brief General-purpose arrays with easy API for coefficient-wise operations\n  *\n  * The %Array class is very similar to the Matrix class. It provides\n  * general-purpose one- and two-dimensional arrays. The difference between the\n  * %Array and the %Matrix class is primarily in the API: the API for the\n  * %Array class provides easy access to coefficient-wise operations, while the\n  * API for the %Matrix class provides easy access to linear-algebra\n  * operations.\n  *\n  * See documentation of class Matrix for detailed information on the template parameters\n  * storage layout.\n  *\n  * This class can be extended with the help of the plugin mechanism described on the page\n  * \\ref TopicCustomizing_Plugins by defining the preprocessor symbol \\c EIGEN_ARRAY_PLUGIN.\n  *\n  * \\sa \\blank \\ref TutorialArrayClass, \\ref TopicClassHierarchy\n  */\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>\nclass Array\n  : public PlainObjectBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >\n{\n  public:\n\n    typedef PlainObjectBase<Array> Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(Array)\n\n    enum { Options = _Options };\n    typedef typename Base::PlainObject PlainObject;\n\n  protected:\n    template <typename Derived, typename OtherDerived, bool IsVector>\n    friend struct internal::conservative_resize_like_impl;\n\n    using Base::m_storage;\n\n  public:\n\n    using Base::base;\n    using Base::coeff;\n    using Base::coeffRef;\n\n    /**\n      * The usage of\n      *   using Base::operator=;\n      * fails on MSVC. Since the code below is working with GCC and MSVC, we skipped\n      * the usage of 'using'. This should be done only for operator=.\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Array& operator=(const EigenBase<OtherDerived> &other)\n    {\n      return Base::operator=(other);\n    }\n\n    /** Set all the entries to \\a value.\n      * \\sa DenseBase::setConstant(), DenseBase::fill()\n      */\n    /* This overload is needed because the usage of\n      *   using Base::operator=;\n      * fails on MSVC. Since the code below is working with GCC and MSVC, we skipped\n      * the usage of 'using'. This should be done only for operator=.\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Array& operator=(const Scalar &value)\n    {\n      Base::setConstant(value);\n      return *this;\n    }\n\n    /** Copies the value of the expression \\a other into \\c *this with automatic resizing.\n      *\n      * *this might be resized to match the dimensions of \\a other. If *this was a null matrix (not already initialized),\n      * it will be initialized.\n      *\n      * Note that copying a row-vector into a vector (and conversely) is allowed.\n      * The resizing, if any, is then done in the appropriate way so that row-vectors\n      * remain row-vectors and vectors remain vectors.\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Array& operator=(const DenseBase<OtherDerived>& other)\n    {\n      return Base::_set(other);\n    }\n\n    /** This is a special case of the templated operator=. Its purpose is to\n      * prevent a default operator= from hiding the templated operator=.\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Array& operator=(const Array& other)\n    {\n      return Base::_set(other);\n    }\n    \n    /** Default constructor.\n      *\n      * For fixed-size matrices, does nothing.\n      *\n      * For dynamic-size matrices, creates an empty matrix of size 0. Does not allocate any array. Such a matrix\n      * is called a null matrix. This constructor is the unique way to create null matrices: resizing\n      * a matrix to 0 is not supported.\n      *\n      * \\sa resize(Index,Index)\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Array() : Base()\n    {\n      Base::_check_template_params();\n      EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED\n    }\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    // FIXME is it still needed ??\n    /** \\internal */\n    EIGEN_DEVICE_FUNC\n    Array(internal::constructor_without_unaligned_array_assert)\n      : Base(internal::constructor_without_unaligned_array_assert())\n    {\n      Base::_check_template_params();\n      EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED\n    }\n#endif\n\n#if EIGEN_HAS_RVALUE_REFERENCES\n    EIGEN_DEVICE_FUNC\n    Array(Array&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_constructible<Scalar>::value)\n      : Base(std::move(other))\n    {\n      Base::_check_template_params();\n      if (RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic)\n        Base::_set_noalias(other);\n    }\n    EIGEN_DEVICE_FUNC\n    Array& operator=(Array&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable<Scalar>::value)\n    {\n      other.swap(*this);\n      return *this;\n    }\n#endif\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename T>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE explicit Array(const T& x)\n    {\n      Base::_check_template_params();\n      Base::template _init1<T>(x);\n    }\n\n    template<typename T0, typename T1>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Array(const T0& val0, const T1& val1)\n    {\n      Base::_check_template_params();\n      this->template _init2<T0,T1>(val0, val1);\n    }\n    #else\n    /** \\brief Constructs a fixed-sized array initialized with coefficients starting at \\a data */\n    EIGEN_DEVICE_FUNC explicit Array(const Scalar *data);\n    /** Constructs a vector or row-vector with given dimension. \\only_for_vectors\n      *\n      * Note that this is only useful for dynamic-size vectors. For fixed-size vectors,\n      * it is redundant to pass the dimension here, so it makes more sense to use the default\n      * constructor Array() instead.\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE explicit Array(Index dim);\n    /** constructs an initialized 1x1 Array with the given coefficient */\n    Array(const Scalar& value);\n    /** constructs an uninitialized array with \\a rows rows and \\a cols columns.\n      *\n      * This is useful for dynamic-size arrays. For fixed-size arrays,\n      * it is redundant to pass these parameters, so one should use the default constructor\n      * Array() instead. */\n    Array(Index rows, Index cols);\n    /** constructs an initialized 2D vector with given coefficients */\n    Array(const Scalar& val0, const Scalar& val1);\n    #endif\n\n    /** constructs an initialized 3D vector with given coefficients */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2)\n    {\n      Base::_check_template_params();\n      EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 3)\n      m_storage.data()[0] = val0;\n      m_storage.data()[1] = val1;\n      m_storage.data()[2] = val2;\n    }\n    /** constructs an initialized 4D vector with given coefficients */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2, const Scalar& val3)\n    {\n      Base::_check_template_params();\n      EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 4)\n      m_storage.data()[0] = val0;\n      m_storage.data()[1] = val1;\n      m_storage.data()[2] = val2;\n      m_storage.data()[3] = val3;\n    }\n\n    /** Copy constructor */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Array(const Array& other)\n            : Base(other)\n    { }\n\n  private:\n    struct PrivateType {};\n  public:\n\n    /** \\sa MatrixBase::operator=(const EigenBase<OtherDerived>&) */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Array(const EigenBase<OtherDerived> &other,\n                              typename internal::enable_if<internal::is_convertible<typename OtherDerived::Scalar,Scalar>::value,\n                                                           PrivateType>::type = PrivateType())\n      : Base(other.derived())\n    { }\n\n    EIGEN_DEVICE_FUNC inline Index innerStride() const { return 1; }\n    EIGEN_DEVICE_FUNC inline Index outerStride() const { return this->innerSize(); }\n\n    #ifdef EIGEN_ARRAY_PLUGIN\n    #include EIGEN_ARRAY_PLUGIN\n    #endif\n\n  private:\n\n    template<typename MatrixType, typename OtherDerived, bool SwapPointers>\n    friend struct internal::matrix_swap_impl;\n};\n\n/** \\defgroup arraytypedefs Global array typedefs\n  * \\ingroup Core_Module\n  *\n  * Eigen defines several typedef shortcuts for most common 1D and 2D array types.\n  *\n  * The general patterns are the following:\n  *\n  * \\c ArrayRowsColsType where \\c Rows and \\c Cols can be \\c 2,\\c 3,\\c 4 for fixed size square matrices or \\c X for dynamic size,\n  * and where \\c Type can be \\c i for integer, \\c f for float, \\c d for double, \\c cf for complex float, \\c cd\n  * for complex double.\n  *\n  * For example, \\c Array33d is a fixed-size 3x3 array type of doubles, and \\c ArrayXXf is a dynamic-size matrix of floats.\n  *\n  * There are also \\c ArraySizeType which are self-explanatory. For example, \\c Array4cf is\n  * a fixed-size 1D array of 4 complex floats.\n  *\n  * \\sa class Array\n  */\n\n#define EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix)   \\\n/** \\ingroup arraytypedefs */                                    \\\ntypedef Array<Type, Size, Size> Array##SizeSuffix##SizeSuffix##TypeSuffix;  \\\n/** \\ingroup arraytypedefs */                                    \\\ntypedef Array<Type, Size, 1>    Array##SizeSuffix##TypeSuffix;\n\n#define EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, Size)         \\\n/** \\ingroup arraytypedefs */                                    \\\ntypedef Array<Type, Size, Dynamic> Array##Size##X##TypeSuffix;  \\\n/** \\ingroup arraytypedefs */                                    \\\ntypedef Array<Type, Dynamic, Size> Array##X##Size##TypeSuffix;\n\n#define EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \\\nEIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 2, 2) \\\nEIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 3, 3) \\\nEIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 4, 4) \\\nEIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \\\nEIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \\\nEIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \\\nEIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 4)\n\nEIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(int,                  i)\nEIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(float,                f)\nEIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(double,               d)\nEIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<float>,  cf)\nEIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)\n\n#undef EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES\n#undef EIGEN_MAKE_ARRAY_TYPEDEFS\n\n#undef EIGEN_MAKE_ARRAY_TYPEDEFS_LARGE\n\n#define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \\\nusing Eigen::Matrix##SizeSuffix##TypeSuffix; \\\nusing Eigen::Vector##SizeSuffix##TypeSuffix; \\\nusing Eigen::RowVector##SizeSuffix##TypeSuffix;\n\n#define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(TypeSuffix) \\\nEIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \\\nEIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \\\nEIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \\\nEIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \\\n\n#define EIGEN_USING_ARRAY_TYPEDEFS \\\nEIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(i) \\\nEIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(f) \\\nEIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(d) \\\nEIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cf) \\\nEIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cd)\n\n} // end namespace Eigen\n\n#endif // EIGEN_ARRAY_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/ArrayBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ARRAYBASE_H\n#define EIGEN_ARRAYBASE_H\n\nnamespace Eigen { \n\ntemplate<typename ExpressionType> class MatrixWrapper;\n\n/** \\class ArrayBase\n  * \\ingroup Core_Module\n  *\n  * \\brief Base class for all 1D and 2D array, and related expressions\n  *\n  * An array is similar to a dense vector or matrix. While matrices are mathematical\n  * objects with well defined linear algebra operators, an array is just a collection\n  * of scalar values arranged in a one or two dimensionnal fashion. As the main consequence,\n  * all operations applied to an array are performed coefficient wise. Furthermore,\n  * arrays support scalar math functions of the c++ standard library (e.g., std::sin(x)), and convenient\n  * constructors allowing to easily write generic code working for both scalar values\n  * and arrays.\n  *\n  * This class is the base that is inherited by all array expression types.\n  *\n  * \\tparam Derived is the derived type, e.g., an array or an expression type.\n  *\n  * This class can be extended with the help of the plugin mechanism described on the page\n  * \\ref TopicCustomizing_Plugins by defining the preprocessor symbol \\c EIGEN_ARRAYBASE_PLUGIN.\n  *\n  * \\sa class MatrixBase, \\ref TopicClassHierarchy\n  */\ntemplate<typename Derived> class ArrayBase\n  : public DenseBase<Derived>\n{\n  public:\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** The base class for a given storage type. */\n    typedef ArrayBase StorageBaseType;\n\n    typedef ArrayBase Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl;\n\n    typedef typename internal::traits<Derived>::StorageKind StorageKind;\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    typedef typename internal::packet_traits<Scalar>::type PacketScalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n\n    typedef DenseBase<Derived> Base;\n    using Base::RowsAtCompileTime;\n    using Base::ColsAtCompileTime;\n    using Base::SizeAtCompileTime;\n    using Base::MaxRowsAtCompileTime;\n    using Base::MaxColsAtCompileTime;\n    using Base::MaxSizeAtCompileTime;\n    using Base::IsVectorAtCompileTime;\n    using Base::Flags;\n    \n    using Base::derived;\n    using Base::const_cast_derived;\n    using Base::rows;\n    using Base::cols;\n    using Base::size;\n    using Base::coeff;\n    using Base::coeffRef;\n    using Base::lazyAssign;\n    using Base::operator=;\n    using Base::operator+=;\n    using Base::operator-=;\n    using Base::operator*=;\n    using Base::operator/=;\n\n    typedef typename Base::CoeffReturnType CoeffReturnType;\n\n#endif // not EIGEN_PARSED_BY_DOXYGEN\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    typedef typename Base::PlainObject PlainObject;\n\n    /** \\internal Represents a matrix with all coefficients equal to one another*/\n    typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,PlainObject> ConstantReturnType;\n#endif // not EIGEN_PARSED_BY_DOXYGEN\n\n#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase\n#define EIGEN_DOC_UNARY_ADDONS(X,Y)\n#   include \"../plugins/CommonCwiseUnaryOps.h\"\n#   include \"../plugins/MatrixCwiseUnaryOps.h\"\n#   include \"../plugins/ArrayCwiseUnaryOps.h\"\n#   include \"../plugins/CommonCwiseBinaryOps.h\"\n#   include \"../plugins/MatrixCwiseBinaryOps.h\"\n#   include \"../plugins/ArrayCwiseBinaryOps.h\"\n#   ifdef EIGEN_ARRAYBASE_PLUGIN\n#     include EIGEN_ARRAYBASE_PLUGIN\n#   endif\n#undef EIGEN_CURRENT_STORAGE_BASE_CLASS\n#undef EIGEN_DOC_UNARY_ADDONS\n\n    /** Special case of the template operator=, in order to prevent the compiler\n      * from generating a default operator= (issue hit with g++ 4.1)\n      */\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator=(const ArrayBase& other)\n    {\n      internal::call_assignment(derived(), other.derived());\n      return derived();\n    }\n    \n    /** Set all the entries to \\a value.\n      * \\sa DenseBase::setConstant(), DenseBase::fill() */\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator=(const Scalar &value)\n    { Base::setConstant(value); return derived(); }\n\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator+=(const Scalar& scalar);\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator-=(const Scalar& scalar);\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator+=(const ArrayBase<OtherDerived>& other);\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator-=(const ArrayBase<OtherDerived>& other);\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator*=(const ArrayBase<OtherDerived>& other);\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator/=(const ArrayBase<OtherDerived>& other);\n\n  public:\n    EIGEN_DEVICE_FUNC\n    ArrayBase<Derived>& array() { return *this; }\n    EIGEN_DEVICE_FUNC\n    const ArrayBase<Derived>& array() const { return *this; }\n\n    /** \\returns an \\link Eigen::MatrixBase Matrix \\endlink expression of this array\n      * \\sa MatrixBase::array() */\n    EIGEN_DEVICE_FUNC\n    MatrixWrapper<Derived> matrix() { return MatrixWrapper<Derived>(derived()); }\n    EIGEN_DEVICE_FUNC\n    const MatrixWrapper<const Derived> matrix() const { return MatrixWrapper<const Derived>(derived()); }\n\n//     template<typename Dest>\n//     inline void evalTo(Dest& dst) const { dst = matrix(); }\n\n  protected:\n    EIGEN_DEVICE_FUNC\n    ArrayBase() : Base() {}\n\n  private:\n    explicit ArrayBase(Index);\n    ArrayBase(Index,Index);\n    template<typename OtherDerived> explicit ArrayBase(const ArrayBase<OtherDerived>&);\n  protected:\n    // mixing arrays and matrices is not legal\n    template<typename OtherDerived> Derived& operator+=(const MatrixBase<OtherDerived>& )\n    {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}\n    // mixing arrays and matrices is not legal\n    template<typename OtherDerived> Derived& operator-=(const MatrixBase<OtherDerived>& )\n    {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}\n};\n\n/** replaces \\c *this by \\c *this - \\a other.\n  *\n  * \\returns a reference to \\c *this\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &\nArrayBase<Derived>::operator-=(const ArrayBase<OtherDerived> &other)\n{\n  call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\n/** replaces \\c *this by \\c *this + \\a other.\n  *\n  * \\returns a reference to \\c *this\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &\nArrayBase<Derived>::operator+=(const ArrayBase<OtherDerived>& other)\n{\n  call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\n/** replaces \\c *this by \\c *this * \\a other coefficient wise.\n  *\n  * \\returns a reference to \\c *this\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &\nArrayBase<Derived>::operator*=(const ArrayBase<OtherDerived>& other)\n{\n  call_assignment(derived(), other.derived(), internal::mul_assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\n/** replaces \\c *this by \\c *this / \\a other coefficient wise.\n  *\n  * \\returns a reference to \\c *this\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &\nArrayBase<Derived>::operator/=(const ArrayBase<OtherDerived>& other)\n{\n  call_assignment(derived(), other.derived(), internal::div_assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_ARRAYBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/ArrayWrapper.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ARRAYWRAPPER_H\n#define EIGEN_ARRAYWRAPPER_H\n\nnamespace Eigen { \n\n/** \\class ArrayWrapper\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of a mathematical vector or matrix as an array object\n  *\n  * This class is the return type of MatrixBase::array(), and most of the time\n  * this is the only way it is use.\n  *\n  * \\sa MatrixBase::array(), class MatrixWrapper\n  */\n\nnamespace internal {\ntemplate<typename ExpressionType>\nstruct traits<ArrayWrapper<ExpressionType> >\n  : public traits<typename remove_all<typename ExpressionType::Nested>::type >\n{\n  typedef ArrayXpr XprKind;\n  // Let's remove NestByRefBit\n  enum {\n    Flags0 = traits<typename remove_all<typename ExpressionType::Nested>::type >::Flags,\n    LvalueBitFlag = is_lvalue<ExpressionType>::value ? LvalueBit : 0,\n    Flags = (Flags0 & ~(NestByRefBit | LvalueBit)) | LvalueBitFlag\n  };\n};\n}\n\ntemplate<typename ExpressionType>\nclass ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >\n{\n  public:\n    typedef ArrayBase<ArrayWrapper> Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper)\n    typedef typename internal::remove_all<ExpressionType>::type NestedExpression;\n\n    typedef typename internal::conditional<\n                       internal::is_lvalue<ExpressionType>::value,\n                       Scalar,\n                       const Scalar\n                     >::type ScalarWithConstIfNotLvalue;\n\n    typedef typename internal::ref_selector<ExpressionType>::non_const_type NestedExpressionType;\n\n    using Base::coeffRef;\n\n    EIGEN_DEVICE_FUNC\n    explicit EIGEN_STRONG_INLINE ArrayWrapper(ExpressionType& matrix) : m_expression(matrix) {}\n\n    EIGEN_DEVICE_FUNC\n    inline Index rows() const { return m_expression.rows(); }\n    EIGEN_DEVICE_FUNC\n    inline Index cols() const { return m_expression.cols(); }\n    EIGEN_DEVICE_FUNC\n    inline Index outerStride() const { return m_expression.outerStride(); }\n    EIGEN_DEVICE_FUNC\n    inline Index innerStride() const { return m_expression.innerStride(); }\n\n    EIGEN_DEVICE_FUNC\n    inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }\n    EIGEN_DEVICE_FUNC\n    inline const Scalar* data() const { return m_expression.data(); }\n\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index rowId, Index colId) const\n    {\n      return m_expression.coeffRef(rowId, colId);\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index index) const\n    {\n      return m_expression.coeffRef(index);\n    }\n\n    template<typename Dest>\n    EIGEN_DEVICE_FUNC\n    inline void evalTo(Dest& dst) const { dst = m_expression; }\n\n    const typename internal::remove_all<NestedExpressionType>::type& \n    EIGEN_DEVICE_FUNC\n    nestedExpression() const \n    {\n      return m_expression;\n    }\n\n    /** Forwards the resizing request to the nested expression\n      * \\sa DenseBase::resize(Index)  */\n    EIGEN_DEVICE_FUNC\n    void resize(Index newSize) { m_expression.resize(newSize); }\n    /** Forwards the resizing request to the nested expression\n      * \\sa DenseBase::resize(Index,Index)*/\n    EIGEN_DEVICE_FUNC\n    void resize(Index rows, Index cols) { m_expression.resize(rows,cols); }\n\n  protected:\n    NestedExpressionType m_expression;\n};\n\n/** \\class MatrixWrapper\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of an array as a mathematical vector or matrix\n  *\n  * This class is the return type of ArrayBase::matrix(), and most of the time\n  * this is the only way it is use.\n  *\n  * \\sa MatrixBase::matrix(), class ArrayWrapper\n  */\n\nnamespace internal {\ntemplate<typename ExpressionType>\nstruct traits<MatrixWrapper<ExpressionType> >\n : public traits<typename remove_all<typename ExpressionType::Nested>::type >\n{\n  typedef MatrixXpr XprKind;\n  // Let's remove NestByRefBit\n  enum {\n    Flags0 = traits<typename remove_all<typename ExpressionType::Nested>::type >::Flags,\n    LvalueBitFlag = is_lvalue<ExpressionType>::value ? LvalueBit : 0,\n    Flags = (Flags0 & ~(NestByRefBit | LvalueBit)) | LvalueBitFlag\n  };\n};\n}\n\ntemplate<typename ExpressionType>\nclass MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >\n{\n  public:\n    typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)\n    typedef typename internal::remove_all<ExpressionType>::type NestedExpression;\n\n    typedef typename internal::conditional<\n                       internal::is_lvalue<ExpressionType>::value,\n                       Scalar,\n                       const Scalar\n                     >::type ScalarWithConstIfNotLvalue;\n\n    typedef typename internal::ref_selector<ExpressionType>::non_const_type NestedExpressionType;\n\n    using Base::coeffRef;\n\n    EIGEN_DEVICE_FUNC\n    explicit inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {}\n\n    EIGEN_DEVICE_FUNC\n    inline Index rows() const { return m_expression.rows(); }\n    EIGEN_DEVICE_FUNC\n    inline Index cols() const { return m_expression.cols(); }\n    EIGEN_DEVICE_FUNC\n    inline Index outerStride() const { return m_expression.outerStride(); }\n    EIGEN_DEVICE_FUNC\n    inline Index innerStride() const { return m_expression.innerStride(); }\n\n    EIGEN_DEVICE_FUNC\n    inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }\n    EIGEN_DEVICE_FUNC\n    inline const Scalar* data() const { return m_expression.data(); }\n\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index rowId, Index colId) const\n    {\n      return m_expression.derived().coeffRef(rowId, colId);\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index index) const\n    {\n      return m_expression.coeffRef(index);\n    }\n\n    EIGEN_DEVICE_FUNC\n    const typename internal::remove_all<NestedExpressionType>::type& \n    nestedExpression() const \n    {\n      return m_expression;\n    }\n\n    /** Forwards the resizing request to the nested expression\n      * \\sa DenseBase::resize(Index)  */\n    EIGEN_DEVICE_FUNC\n    void resize(Index newSize) { m_expression.resize(newSize); }\n    /** Forwards the resizing request to the nested expression\n      * \\sa DenseBase::resize(Index,Index)*/\n    EIGEN_DEVICE_FUNC\n    void resize(Index rows, Index cols) { m_expression.resize(rows,cols); }\n\n  protected:\n    NestedExpressionType m_expression;\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_ARRAYWRAPPER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Assign.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2007 Michael Olbrich <michael.olbrich@gmx.net>\n// Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ASSIGN_H\n#define EIGEN_ASSIGN_H\n\nnamespace Eigen {\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_STRONG_INLINE Derived& DenseBase<Derived>\n  ::lazyAssign(const DenseBase<OtherDerived>& other)\n{\n  enum{\n    SameType = internal::is_same<typename Derived::Scalar,typename OtherDerived::Scalar>::value\n  };\n\n  EIGEN_STATIC_ASSERT_LVALUE(Derived)\n  EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)\n  EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)\n\n  eigen_assert(rows() == other.rows() && cols() == other.cols());\n  internal::call_assignment_no_alias(derived(),other.derived());\n  \n  return derived();\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase<OtherDerived>& other)\n{\n  internal::call_assignment(derived(), other.derived());\n  return derived();\n}\n\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase& other)\n{\n  internal::call_assignment(derived(), other.derived());\n  return derived();\n}\n\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const MatrixBase& other)\n{\n  internal::call_assignment(derived(), other.derived());\n  return derived();\n}\n\ntemplate<typename Derived>\ntemplate <typename OtherDerived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const DenseBase<OtherDerived>& other)\n{\n  internal::call_assignment(derived(), other.derived());\n  return derived();\n}\n\ntemplate<typename Derived>\ntemplate <typename OtherDerived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const EigenBase<OtherDerived>& other)\n{\n  internal::call_assignment(derived(), other.derived());\n  return derived();\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)\n{\n  other.derived().evalTo(derived());\n  return derived();\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_ASSIGN_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/AssignEvaluator.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2011-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2011-2012 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ASSIGN_EVALUATOR_H\n#define EIGEN_ASSIGN_EVALUATOR_H\n\nnamespace Eigen {\n\n// This implementation is based on Assign.h\n\nnamespace internal {\n  \n/***************************************************************************\n* Part 1 : the logic deciding a strategy for traversal and unrolling       *\n***************************************************************************/\n\n// copy_using_evaluator_traits is based on assign_traits\n\ntemplate <typename DstEvaluator, typename SrcEvaluator, typename AssignFunc>\nstruct copy_using_evaluator_traits\n{\n  typedef typename DstEvaluator::XprType Dst;\n  typedef typename Dst::Scalar DstScalar;\n  \n  enum {\n    DstFlags = DstEvaluator::Flags,\n    SrcFlags = SrcEvaluator::Flags\n  };\n  \npublic:\n  enum {\n    DstAlignment = DstEvaluator::Alignment,\n    SrcAlignment = SrcEvaluator::Alignment,\n    DstHasDirectAccess = DstFlags & DirectAccessBit,\n    JointAlignment = EIGEN_PLAIN_ENUM_MIN(DstAlignment,SrcAlignment)\n  };\n\nprivate:\n  enum {\n    InnerSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::SizeAtCompileTime)\n              : int(DstFlags)&RowMajorBit ? int(Dst::ColsAtCompileTime)\n              : int(Dst::RowsAtCompileTime),\n    InnerMaxSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::MaxSizeAtCompileTime)\n              : int(DstFlags)&RowMajorBit ? int(Dst::MaxColsAtCompileTime)\n              : int(Dst::MaxRowsAtCompileTime),\n    OuterStride = int(outer_stride_at_compile_time<Dst>::ret),\n    MaxSizeAtCompileTime = Dst::SizeAtCompileTime\n  };\n\n  // TODO distinguish between linear traversal and inner-traversals\n  typedef typename find_best_packet<DstScalar,Dst::SizeAtCompileTime>::type LinearPacketType;\n  typedef typename find_best_packet<DstScalar,InnerSize>::type InnerPacketType;\n\n  enum {\n    LinearPacketSize = unpacket_traits<LinearPacketType>::size,\n    InnerPacketSize = unpacket_traits<InnerPacketType>::size\n  };\n\npublic:\n  enum {\n    LinearRequiredAlignment = unpacket_traits<LinearPacketType>::alignment,\n    InnerRequiredAlignment = unpacket_traits<InnerPacketType>::alignment\n  };\n\nprivate:\n  enum {\n    DstIsRowMajor = DstFlags&RowMajorBit,\n    SrcIsRowMajor = SrcFlags&RowMajorBit,\n    StorageOrdersAgree = (int(DstIsRowMajor) == int(SrcIsRowMajor)),\n    MightVectorize = bool(StorageOrdersAgree)\n                  && (int(DstFlags) & int(SrcFlags) & ActualPacketAccessBit)\n                  && bool(functor_traits<AssignFunc>::PacketAccess),\n    MayInnerVectorize  = MightVectorize\n                       && int(InnerSize)!=Dynamic && int(InnerSize)%int(InnerPacketSize)==0\n                       && int(OuterStride)!=Dynamic && int(OuterStride)%int(InnerPacketSize)==0\n                       && (EIGEN_UNALIGNED_VECTORIZE  || int(JointAlignment)>=int(InnerRequiredAlignment)),\n    MayLinearize = bool(StorageOrdersAgree) && (int(DstFlags) & int(SrcFlags) & LinearAccessBit),\n    MayLinearVectorize = bool(MightVectorize) && MayLinearize && DstHasDirectAccess\n                       && (EIGEN_UNALIGNED_VECTORIZE || (int(DstAlignment)>=int(LinearRequiredAlignment)) || MaxSizeAtCompileTime == Dynamic),\n      /* If the destination isn't aligned, we have to do runtime checks and we don't unroll,\n         so it's only good for large enough sizes. */\n    MaySliceVectorize  = bool(MightVectorize) && bool(DstHasDirectAccess)\n                       && (int(InnerMaxSize)==Dynamic || int(InnerMaxSize)>=(EIGEN_UNALIGNED_VECTORIZE?InnerPacketSize:(3*InnerPacketSize)))\n      /* slice vectorization can be slow, so we only want it if the slices are big, which is\n         indicated by InnerMaxSize rather than InnerSize, think of the case of a dynamic block\n         in a fixed-size matrix\n         However, with EIGEN_UNALIGNED_VECTORIZE and unrolling, slice vectorization is still worth it */\n  };\n\npublic:\n  enum {\n    Traversal = int(MayLinearVectorize) && (LinearPacketSize>InnerPacketSize) ? int(LinearVectorizedTraversal)\n              : int(MayInnerVectorize)   ? int(InnerVectorizedTraversal)\n              : int(MayLinearVectorize)  ? int(LinearVectorizedTraversal)\n              : int(MaySliceVectorize)   ? int(SliceVectorizedTraversal)\n              : int(MayLinearize)        ? int(LinearTraversal)\n                                         : int(DefaultTraversal),\n    Vectorized = int(Traversal) == InnerVectorizedTraversal\n              || int(Traversal) == LinearVectorizedTraversal\n              || int(Traversal) == SliceVectorizedTraversal\n  };\n\n  typedef typename conditional<int(Traversal)==LinearVectorizedTraversal, LinearPacketType, InnerPacketType>::type PacketType;\n\nprivate:\n  enum {\n    ActualPacketSize    = int(Traversal)==LinearVectorizedTraversal ? LinearPacketSize\n                        : Vectorized ? InnerPacketSize\n                        : 1,\n    UnrollingLimit      = EIGEN_UNROLLING_LIMIT * ActualPacketSize,\n    MayUnrollCompletely = int(Dst::SizeAtCompileTime) != Dynamic\n                       && int(Dst::SizeAtCompileTime) * (int(DstEvaluator::CoeffReadCost)+int(SrcEvaluator::CoeffReadCost)) <= int(UnrollingLimit),\n    MayUnrollInner      = int(InnerSize) != Dynamic\n                       && int(InnerSize) * (int(DstEvaluator::CoeffReadCost)+int(SrcEvaluator::CoeffReadCost)) <= int(UnrollingLimit)\n  };\n\npublic:\n  enum {\n    Unrolling = (int(Traversal) == int(InnerVectorizedTraversal) || int(Traversal) == int(DefaultTraversal))\n                ? (\n                    int(MayUnrollCompletely) ? int(CompleteUnrolling)\n                  : int(MayUnrollInner)      ? int(InnerUnrolling)\n                                             : int(NoUnrolling)\n                  )\n              : int(Traversal) == int(LinearVectorizedTraversal)\n                ? ( bool(MayUnrollCompletely) && ( EIGEN_UNALIGNED_VECTORIZE || (int(DstAlignment)>=int(LinearRequiredAlignment)))\n                          ? int(CompleteUnrolling)\n                          : int(NoUnrolling) )\n              : int(Traversal) == int(LinearTraversal)\n                ? ( bool(MayUnrollCompletely) ? int(CompleteUnrolling) \n                                              : int(NoUnrolling) )\n#if EIGEN_UNALIGNED_VECTORIZE\n              : int(Traversal) == int(SliceVectorizedTraversal)\n                ? ( bool(MayUnrollInner) ? int(InnerUnrolling)\n                                         : int(NoUnrolling) )\n#endif\n              : int(NoUnrolling)\n  };\n\n#ifdef EIGEN_DEBUG_ASSIGN\n  static void debug()\n  {\n    std::cerr << \"DstXpr: \" << typeid(typename DstEvaluator::XprType).name() << std::endl;\n    std::cerr << \"SrcXpr: \" << typeid(typename SrcEvaluator::XprType).name() << std::endl;\n    std::cerr.setf(std::ios::hex, std::ios::basefield);\n    std::cerr << \"DstFlags\" << \" = \" << DstFlags << \" (\" << demangle_flags(DstFlags) << \" )\" << std::endl;\n    std::cerr << \"SrcFlags\" << \" = \" << SrcFlags << \" (\" << demangle_flags(SrcFlags) << \" )\" << std::endl;\n    std::cerr.unsetf(std::ios::hex);\n    EIGEN_DEBUG_VAR(DstAlignment)\n    EIGEN_DEBUG_VAR(SrcAlignment)\n    EIGEN_DEBUG_VAR(LinearRequiredAlignment)\n    EIGEN_DEBUG_VAR(InnerRequiredAlignment)\n    EIGEN_DEBUG_VAR(JointAlignment)\n    EIGEN_DEBUG_VAR(InnerSize)\n    EIGEN_DEBUG_VAR(InnerMaxSize)\n    EIGEN_DEBUG_VAR(LinearPacketSize)\n    EIGEN_DEBUG_VAR(InnerPacketSize)\n    EIGEN_DEBUG_VAR(ActualPacketSize)\n    EIGEN_DEBUG_VAR(StorageOrdersAgree)\n    EIGEN_DEBUG_VAR(MightVectorize)\n    EIGEN_DEBUG_VAR(MayLinearize)\n    EIGEN_DEBUG_VAR(MayInnerVectorize)\n    EIGEN_DEBUG_VAR(MayLinearVectorize)\n    EIGEN_DEBUG_VAR(MaySliceVectorize)\n    std::cerr << \"Traversal\" << \" = \" << Traversal << \" (\" << demangle_traversal(Traversal) << \")\" << std::endl;\n    EIGEN_DEBUG_VAR(SrcEvaluator::CoeffReadCost)\n    EIGEN_DEBUG_VAR(UnrollingLimit)\n    EIGEN_DEBUG_VAR(MayUnrollCompletely)\n    EIGEN_DEBUG_VAR(MayUnrollInner)\n    std::cerr << \"Unrolling\" << \" = \" << Unrolling << \" (\" << demangle_unrolling(Unrolling) << \")\" << std::endl;\n    std::cerr << std::endl;\n  }\n#endif\n};\n\n/***************************************************************************\n* Part 2 : meta-unrollers\n***************************************************************************/\n\n/************************\n*** Default traversal ***\n************************/\n\ntemplate<typename Kernel, int Index, int Stop>\nstruct copy_using_evaluator_DefaultTraversal_CompleteUnrolling\n{\n  // FIXME: this is not very clean, perhaps this information should be provided by the kernel?\n  typedef typename Kernel::DstEvaluatorType DstEvaluatorType;\n  typedef typename DstEvaluatorType::XprType DstXprType;\n  \n  enum {\n    outer = Index / DstXprType::InnerSizeAtCompileTime,\n    inner = Index % DstXprType::InnerSizeAtCompileTime\n  };\n\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    kernel.assignCoeffByOuterInner(outer, inner);\n    copy_using_evaluator_DefaultTraversal_CompleteUnrolling<Kernel, Index+1, Stop>::run(kernel);\n  }\n};\n\ntemplate<typename Kernel, int Stop>\nstruct copy_using_evaluator_DefaultTraversal_CompleteUnrolling<Kernel, Stop, Stop>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel&) { }\n};\n\ntemplate<typename Kernel, int Index_, int Stop>\nstruct copy_using_evaluator_DefaultTraversal_InnerUnrolling\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel, Index outer)\n  {\n    kernel.assignCoeffByOuterInner(outer, Index_);\n    copy_using_evaluator_DefaultTraversal_InnerUnrolling<Kernel, Index_+1, Stop>::run(kernel, outer);\n  }\n};\n\ntemplate<typename Kernel, int Stop>\nstruct copy_using_evaluator_DefaultTraversal_InnerUnrolling<Kernel, Stop, Stop>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel&, Index) { }\n};\n\n/***********************\n*** Linear traversal ***\n***********************/\n\ntemplate<typename Kernel, int Index, int Stop>\nstruct copy_using_evaluator_LinearTraversal_CompleteUnrolling\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel& kernel)\n  {\n    kernel.assignCoeff(Index);\n    copy_using_evaluator_LinearTraversal_CompleteUnrolling<Kernel, Index+1, Stop>::run(kernel);\n  }\n};\n\ntemplate<typename Kernel, int Stop>\nstruct copy_using_evaluator_LinearTraversal_CompleteUnrolling<Kernel, Stop, Stop>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel&) { }\n};\n\n/**************************\n*** Inner vectorization ***\n**************************/\n\ntemplate<typename Kernel, int Index, int Stop>\nstruct copy_using_evaluator_innervec_CompleteUnrolling\n{\n  // FIXME: this is not very clean, perhaps this information should be provided by the kernel?\n  typedef typename Kernel::DstEvaluatorType DstEvaluatorType;\n  typedef typename DstEvaluatorType::XprType DstXprType;\n  typedef typename Kernel::PacketType PacketType;\n  \n  enum {\n    outer = Index / DstXprType::InnerSizeAtCompileTime,\n    inner = Index % DstXprType::InnerSizeAtCompileTime,\n    SrcAlignment = Kernel::AssignmentTraits::SrcAlignment,\n    DstAlignment = Kernel::AssignmentTraits::DstAlignment\n  };\n\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    kernel.template assignPacketByOuterInner<DstAlignment, SrcAlignment, PacketType>(outer, inner);\n    enum { NextIndex = Index + unpacket_traits<PacketType>::size };\n    copy_using_evaluator_innervec_CompleteUnrolling<Kernel, NextIndex, Stop>::run(kernel);\n  }\n};\n\ntemplate<typename Kernel, int Stop>\nstruct copy_using_evaluator_innervec_CompleteUnrolling<Kernel, Stop, Stop>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel&) { }\n};\n\ntemplate<typename Kernel, int Index_, int Stop, int SrcAlignment, int DstAlignment>\nstruct copy_using_evaluator_innervec_InnerUnrolling\n{\n  typedef typename Kernel::PacketType PacketType;\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel, Index outer)\n  {\n    kernel.template assignPacketByOuterInner<DstAlignment, SrcAlignment, PacketType>(outer, Index_);\n    enum { NextIndex = Index_ + unpacket_traits<PacketType>::size };\n    copy_using_evaluator_innervec_InnerUnrolling<Kernel, NextIndex, Stop, SrcAlignment, DstAlignment>::run(kernel, outer);\n  }\n};\n\ntemplate<typename Kernel, int Stop, int SrcAlignment, int DstAlignment>\nstruct copy_using_evaluator_innervec_InnerUnrolling<Kernel, Stop, Stop, SrcAlignment, DstAlignment>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &, Index) { }\n};\n\n/***************************************************************************\n* Part 3 : implementation of all cases\n***************************************************************************/\n\n// dense_assignment_loop is based on assign_impl\n\ntemplate<typename Kernel,\n         int Traversal = Kernel::AssignmentTraits::Traversal,\n         int Unrolling = Kernel::AssignmentTraits::Unrolling>\nstruct dense_assignment_loop;\n\n/************************\n*** Default traversal ***\n************************/\n\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, DefaultTraversal, NoUnrolling>\n{\n  EIGEN_DEVICE_FUNC static void EIGEN_STRONG_INLINE run(Kernel &kernel)\n  {\n    for(Index outer = 0; outer < kernel.outerSize(); ++outer) {\n      for(Index inner = 0; inner < kernel.innerSize(); ++inner) {\n        kernel.assignCoeffByOuterInner(outer, inner);\n      }\n    }\n  }\n};\n\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, DefaultTraversal, CompleteUnrolling>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    typedef typename Kernel::DstEvaluatorType::XprType DstXprType;\n    copy_using_evaluator_DefaultTraversal_CompleteUnrolling<Kernel, 0, DstXprType::SizeAtCompileTime>::run(kernel);\n  }\n};\n\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, DefaultTraversal, InnerUnrolling>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    typedef typename Kernel::DstEvaluatorType::XprType DstXprType;\n\n    const Index outerSize = kernel.outerSize();\n    for(Index outer = 0; outer < outerSize; ++outer)\n      copy_using_evaluator_DefaultTraversal_InnerUnrolling<Kernel, 0, DstXprType::InnerSizeAtCompileTime>::run(kernel, outer);\n  }\n};\n\n/***************************\n*** Linear vectorization ***\n***************************/\n\n\n// The goal of unaligned_dense_assignment_loop is simply to factorize the handling\n// of the non vectorizable beginning and ending parts\n\ntemplate <bool IsAligned = false>\nstruct unaligned_dense_assignment_loop\n{\n  // if IsAligned = true, then do nothing\n  template <typename Kernel>\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel&, Index, Index) {}\n};\n\ntemplate <>\nstruct unaligned_dense_assignment_loop<false>\n{\n  // MSVC must not inline this functions. If it does, it fails to optimize the\n  // packet access path.\n  // FIXME check which version exhibits this issue\n#if EIGEN_COMP_MSVC\n  template <typename Kernel>\n  static EIGEN_DONT_INLINE void run(Kernel &kernel,\n                                    Index start,\n                                    Index end)\n#else\n  template <typename Kernel>\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel,\n                                      Index start,\n                                      Index end)\n#endif\n  {\n    for (Index index = start; index < end; ++index)\n      kernel.assignCoeff(index);\n  }\n};\n\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, LinearVectorizedTraversal, NoUnrolling>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    const Index size = kernel.size();\n    typedef typename Kernel::Scalar Scalar;\n    typedef typename Kernel::PacketType PacketType;\n    enum {\n      requestedAlignment = Kernel::AssignmentTraits::LinearRequiredAlignment,\n      packetSize = unpacket_traits<PacketType>::size,\n      dstIsAligned = int(Kernel::AssignmentTraits::DstAlignment)>=int(requestedAlignment),\n      dstAlignment = packet_traits<Scalar>::AlignedOnScalar ? int(requestedAlignment)\n                                                            : int(Kernel::AssignmentTraits::DstAlignment),\n      srcAlignment = Kernel::AssignmentTraits::JointAlignment\n    };\n    const Index alignedStart = dstIsAligned ? 0 : internal::first_aligned<requestedAlignment>(kernel.dstDataPtr(), size);\n    const Index alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize;\n\n    unaligned_dense_assignment_loop<dstIsAligned!=0>::run(kernel, 0, alignedStart);\n\n    for(Index index = alignedStart; index < alignedEnd; index += packetSize)\n      kernel.template assignPacket<dstAlignment, srcAlignment, PacketType>(index);\n\n    unaligned_dense_assignment_loop<>::run(kernel, alignedEnd, size);\n  }\n};\n\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, LinearVectorizedTraversal, CompleteUnrolling>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    typedef typename Kernel::DstEvaluatorType::XprType DstXprType;\n    typedef typename Kernel::PacketType PacketType;\n    \n    enum { size = DstXprType::SizeAtCompileTime,\n           packetSize =unpacket_traits<PacketType>::size,\n           alignedSize = (size/packetSize)*packetSize };\n\n    copy_using_evaluator_innervec_CompleteUnrolling<Kernel, 0, alignedSize>::run(kernel);\n    copy_using_evaluator_DefaultTraversal_CompleteUnrolling<Kernel, alignedSize, size>::run(kernel);\n  }\n};\n\n/**************************\n*** Inner vectorization ***\n**************************/\n\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, InnerVectorizedTraversal, NoUnrolling>\n{\n  typedef typename Kernel::PacketType PacketType;\n  enum {\n    SrcAlignment = Kernel::AssignmentTraits::SrcAlignment,\n    DstAlignment = Kernel::AssignmentTraits::DstAlignment\n  };\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    const Index innerSize = kernel.innerSize();\n    const Index outerSize = kernel.outerSize();\n    const Index packetSize = unpacket_traits<PacketType>::size;\n    for(Index outer = 0; outer < outerSize; ++outer)\n      for(Index inner = 0; inner < innerSize; inner+=packetSize)\n        kernel.template assignPacketByOuterInner<DstAlignment, SrcAlignment, PacketType>(outer, inner);\n  }\n};\n\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, InnerVectorizedTraversal, CompleteUnrolling>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    typedef typename Kernel::DstEvaluatorType::XprType DstXprType;\n    copy_using_evaluator_innervec_CompleteUnrolling<Kernel, 0, DstXprType::SizeAtCompileTime>::run(kernel);\n  }\n};\n\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, InnerVectorizedTraversal, InnerUnrolling>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    typedef typename Kernel::DstEvaluatorType::XprType DstXprType;\n    typedef typename Kernel::AssignmentTraits Traits;\n    const Index outerSize = kernel.outerSize();\n    for(Index outer = 0; outer < outerSize; ++outer)\n      copy_using_evaluator_innervec_InnerUnrolling<Kernel, 0, DstXprType::InnerSizeAtCompileTime,\n                                                   Traits::SrcAlignment, Traits::DstAlignment>::run(kernel, outer);\n  }\n};\n\n/***********************\n*** Linear traversal ***\n***********************/\n\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, LinearTraversal, NoUnrolling>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    const Index size = kernel.size();\n    for(Index i = 0; i < size; ++i)\n      kernel.assignCoeff(i);\n  }\n};\n\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, LinearTraversal, CompleteUnrolling>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    typedef typename Kernel::DstEvaluatorType::XprType DstXprType;\n    copy_using_evaluator_LinearTraversal_CompleteUnrolling<Kernel, 0, DstXprType::SizeAtCompileTime>::run(kernel);\n  }\n};\n\n/**************************\n*** Slice vectorization ***\n***************************/\n\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, SliceVectorizedTraversal, NoUnrolling>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    typedef typename Kernel::Scalar Scalar;\n    typedef typename Kernel::PacketType PacketType;\n    enum {\n      packetSize = unpacket_traits<PacketType>::size,\n      requestedAlignment = int(Kernel::AssignmentTraits::InnerRequiredAlignment),\n      alignable = packet_traits<Scalar>::AlignedOnScalar || int(Kernel::AssignmentTraits::DstAlignment)>=sizeof(Scalar),\n      dstIsAligned = int(Kernel::AssignmentTraits::DstAlignment)>=int(requestedAlignment),\n      dstAlignment = alignable ? int(requestedAlignment)\n                               : int(Kernel::AssignmentTraits::DstAlignment)\n    };\n    const Scalar *dst_ptr = kernel.dstDataPtr();\n    if((!bool(dstIsAligned)) && (UIntPtr(dst_ptr) % sizeof(Scalar))>0)\n    {\n      // the pointer is not aligend-on scalar, so alignment is not possible\n      return dense_assignment_loop<Kernel,DefaultTraversal,NoUnrolling>::run(kernel);\n    }\n    const Index packetAlignedMask = packetSize - 1;\n    const Index innerSize = kernel.innerSize();\n    const Index outerSize = kernel.outerSize();\n    const Index alignedStep = alignable ? (packetSize - kernel.outerStride() % packetSize) & packetAlignedMask : 0;\n    Index alignedStart = ((!alignable) || bool(dstIsAligned)) ? 0 : internal::first_aligned<requestedAlignment>(dst_ptr, innerSize);\n\n    for(Index outer = 0; outer < outerSize; ++outer)\n    {\n      const Index alignedEnd = alignedStart + ((innerSize-alignedStart) & ~packetAlignedMask);\n      // do the non-vectorizable part of the assignment\n      for(Index inner = 0; inner<alignedStart ; ++inner)\n        kernel.assignCoeffByOuterInner(outer, inner);\n\n      // do the vectorizable part of the assignment\n      for(Index inner = alignedStart; inner<alignedEnd; inner+=packetSize)\n        kernel.template assignPacketByOuterInner<dstAlignment, Unaligned, PacketType>(outer, inner);\n\n      // do the non-vectorizable part of the assignment\n      for(Index inner = alignedEnd; inner<innerSize ; ++inner)\n        kernel.assignCoeffByOuterInner(outer, inner);\n\n      alignedStart = numext::mini((alignedStart+alignedStep)%packetSize, innerSize);\n    }\n  }\n};\n\n#if EIGEN_UNALIGNED_VECTORIZE\ntemplate<typename Kernel>\nstruct dense_assignment_loop<Kernel, SliceVectorizedTraversal, InnerUnrolling>\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel)\n  {\n    typedef typename Kernel::DstEvaluatorType::XprType DstXprType;\n    typedef typename Kernel::PacketType PacketType;\n\n    enum { size = DstXprType::InnerSizeAtCompileTime,\n           packetSize =unpacket_traits<PacketType>::size,\n           vectorizableSize = (size/packetSize)*packetSize };\n\n    for(Index outer = 0; outer < kernel.outerSize(); ++outer)\n    {\n      copy_using_evaluator_innervec_InnerUnrolling<Kernel, 0, vectorizableSize, 0, 0>::run(kernel, outer);\n      copy_using_evaluator_DefaultTraversal_InnerUnrolling<Kernel, vectorizableSize, size>::run(kernel, outer);\n    }\n  }\n};\n#endif\n\n\n/***************************************************************************\n* Part 4 : Generic dense assignment kernel\n***************************************************************************/\n\n// This class generalize the assignment of a coefficient (or packet) from one dense evaluator\n// to another dense writable evaluator.\n// It is parametrized by the two evaluators, and the actual assignment functor.\n// This abstraction level permits to keep the evaluation loops as simple and as generic as possible.\n// One can customize the assignment using this generic dense_assignment_kernel with different\n// functors, or by completely overloading it, by-passing a functor.\ntemplate<typename DstEvaluatorTypeT, typename SrcEvaluatorTypeT, typename Functor, int Version = Specialized>\nclass generic_dense_assignment_kernel\n{\nprotected:\n  typedef typename DstEvaluatorTypeT::XprType DstXprType;\n  typedef typename SrcEvaluatorTypeT::XprType SrcXprType;\npublic:\n  \n  typedef DstEvaluatorTypeT DstEvaluatorType;\n  typedef SrcEvaluatorTypeT SrcEvaluatorType;\n  typedef typename DstEvaluatorType::Scalar Scalar;\n  typedef copy_using_evaluator_traits<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor> AssignmentTraits;\n  typedef typename AssignmentTraits::PacketType PacketType;\n  \n  \n  EIGEN_DEVICE_FUNC generic_dense_assignment_kernel(DstEvaluatorType &dst, const SrcEvaluatorType &src, const Functor &func, DstXprType& dstExpr)\n    : m_dst(dst), m_src(src), m_functor(func), m_dstExpr(dstExpr)\n  {\n    #ifdef EIGEN_DEBUG_ASSIGN\n    AssignmentTraits::debug();\n    #endif\n  }\n  \n  EIGEN_DEVICE_FUNC Index size() const        { return m_dstExpr.size(); }\n  EIGEN_DEVICE_FUNC Index innerSize() const   { return m_dstExpr.innerSize(); }\n  EIGEN_DEVICE_FUNC Index outerSize() const   { return m_dstExpr.outerSize(); }\n  EIGEN_DEVICE_FUNC Index rows() const        { return m_dstExpr.rows(); }\n  EIGEN_DEVICE_FUNC Index cols() const        { return m_dstExpr.cols(); }\n  EIGEN_DEVICE_FUNC Index outerStride() const { return m_dstExpr.outerStride(); }\n  \n  EIGEN_DEVICE_FUNC DstEvaluatorType& dstEvaluator() { return m_dst; }\n  EIGEN_DEVICE_FUNC const SrcEvaluatorType& srcEvaluator() const { return m_src; }\n  \n  /// Assign src(row,col) to dst(row,col) through the assignment functor.\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(Index row, Index col)\n  {\n    m_functor.assignCoeff(m_dst.coeffRef(row,col), m_src.coeff(row,col));\n  }\n  \n  /// \\sa assignCoeff(Index,Index)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(Index index)\n  {\n    m_functor.assignCoeff(m_dst.coeffRef(index), m_src.coeff(index));\n  }\n  \n  /// \\sa assignCoeff(Index,Index)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeffByOuterInner(Index outer, Index inner)\n  {\n    Index row = rowIndexByOuterInner(outer, inner); \n    Index col = colIndexByOuterInner(outer, inner); \n    assignCoeff(row, col);\n  }\n  \n  \n  template<int StoreMode, int LoadMode, typename PacketType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignPacket(Index row, Index col)\n  {\n    m_functor.template assignPacket<StoreMode>(&m_dst.coeffRef(row,col), m_src.template packet<LoadMode,PacketType>(row,col));\n  }\n  \n  template<int StoreMode, int LoadMode, typename PacketType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignPacket(Index index)\n  {\n    m_functor.template assignPacket<StoreMode>(&m_dst.coeffRef(index), m_src.template packet<LoadMode,PacketType>(index));\n  }\n  \n  template<int StoreMode, int LoadMode, typename PacketType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignPacketByOuterInner(Index outer, Index inner)\n  {\n    Index row = rowIndexByOuterInner(outer, inner); \n    Index col = colIndexByOuterInner(outer, inner);\n    assignPacket<StoreMode,LoadMode,PacketType>(row, col);\n  }\n  \n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Index rowIndexByOuterInner(Index outer, Index inner)\n  {\n    typedef typename DstEvaluatorType::ExpressionTraits Traits;\n    return int(Traits::RowsAtCompileTime) == 1 ? 0\n      : int(Traits::ColsAtCompileTime) == 1 ? inner\n      : int(DstEvaluatorType::Flags)&RowMajorBit ? outer\n      : inner;\n  }\n\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Index colIndexByOuterInner(Index outer, Index inner)\n  {\n    typedef typename DstEvaluatorType::ExpressionTraits Traits;\n    return int(Traits::ColsAtCompileTime) == 1 ? 0\n      : int(Traits::RowsAtCompileTime) == 1 ? inner\n      : int(DstEvaluatorType::Flags)&RowMajorBit ? inner\n      : outer;\n  }\n\n  EIGEN_DEVICE_FUNC const Scalar* dstDataPtr() const\n  {\n    return m_dstExpr.data();\n  }\n  \nprotected:\n  DstEvaluatorType& m_dst;\n  const SrcEvaluatorType& m_src;\n  const Functor &m_functor;\n  // TODO find a way to avoid the needs of the original expression\n  DstXprType& m_dstExpr;\n};\n\n/***************************************************************************\n* Part 5 : Entry point for dense rectangular assignment\n***************************************************************************/\n\ntemplate<typename DstXprType,typename SrcXprType, typename Functor>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid resize_if_allowed(DstXprType &dst, const SrcXprType& src, const Functor &/*func*/)\n{\n  EIGEN_ONLY_USED_FOR_DEBUG(dst);\n  EIGEN_ONLY_USED_FOR_DEBUG(src);\n  eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());\n}\n\ntemplate<typename DstXprType,typename SrcXprType, typename T1, typename T2>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid resize_if_allowed(DstXprType &dst, const SrcXprType& src, const internal::assign_op<T1,T2> &/*func*/)\n{\n  Index dstRows = src.rows();\n  Index dstCols = src.cols();\n  if(((dst.rows()!=dstRows) || (dst.cols()!=dstCols)))\n    dst.resize(dstRows, dstCols);\n  eigen_assert(dst.rows() == dstRows && dst.cols() == dstCols);\n}\n\ntemplate<typename DstXprType, typename SrcXprType, typename Functor>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_dense_assignment_loop(DstXprType& dst, const SrcXprType& src, const Functor &func)\n{\n  typedef evaluator<DstXprType> DstEvaluatorType;\n  typedef evaluator<SrcXprType> SrcEvaluatorType;\n\n  SrcEvaluatorType srcEvaluator(src);\n\n  // NOTE To properly handle A = (A*A.transpose())/s with A rectangular,\n  // we need to resize the destination after the source evaluator has been created.\n  resize_if_allowed(dst, src, func);\n\n  DstEvaluatorType dstEvaluator(dst);\n    \n  typedef generic_dense_assignment_kernel<DstEvaluatorType,SrcEvaluatorType,Functor> Kernel;\n  Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived());\n\n  dense_assignment_loop<Kernel>::run(kernel);\n}\n\ntemplate<typename DstXprType, typename SrcXprType>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_dense_assignment_loop(DstXprType& dst, const SrcXprType& src)\n{\n  call_dense_assignment_loop(dst, src, internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar>());\n}\n\n/***************************************************************************\n* Part 6 : Generic assignment\n***************************************************************************/\n\n// Based on the respective shapes of the destination and source,\n// the class AssignmentKind determine the kind of assignment mechanism.\n// AssignmentKind must define a Kind typedef.\ntemplate<typename DstShape, typename SrcShape> struct AssignmentKind;\n\n// Assignement kind defined in this file:\nstruct Dense2Dense {};\nstruct EigenBase2EigenBase {};\n\ntemplate<typename,typename> struct AssignmentKind { typedef EigenBase2EigenBase Kind; };\ntemplate<> struct AssignmentKind<DenseShape,DenseShape> { typedef Dense2Dense Kind; };\n    \n// This is the main assignment class\ntemplate< typename DstXprType, typename SrcXprType, typename Functor,\n          typename Kind = typename AssignmentKind< typename evaluator_traits<DstXprType>::Shape , typename evaluator_traits<SrcXprType>::Shape >::Kind,\n          typename EnableIf = void>\nstruct Assignment;\n\n\n// The only purpose of this call_assignment() function is to deal with noalias() / \"assume-aliasing\" and automatic transposition.\n// Indeed, I (Gael) think that this concept of \"assume-aliasing\" was a mistake, and it makes thing quite complicated.\n// So this intermediate function removes everything related to \"assume-aliasing\" such that Assignment\n// does not has to bother about these annoying details.\n\ntemplate<typename Dst, typename Src>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid call_assignment(Dst& dst, const Src& src)\n{\n  call_assignment(dst, src, internal::assign_op<typename Dst::Scalar,typename Src::Scalar>());\n}\ntemplate<typename Dst, typename Src>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid call_assignment(const Dst& dst, const Src& src)\n{\n  call_assignment(dst, src, internal::assign_op<typename Dst::Scalar,typename Src::Scalar>());\n}\n                     \n// Deal with \"assume-aliasing\"\ntemplate<typename Dst, typename Src, typename Func>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid call_assignment(Dst& dst, const Src& src, const Func& func, typename enable_if< evaluator_assume_aliasing<Src>::value, void*>::type = 0)\n{\n  typename plain_matrix_type<Src>::type tmp(src);\n  call_assignment_no_alias(dst, tmp, func);\n}\n\ntemplate<typename Dst, typename Src, typename Func>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid call_assignment(Dst& dst, const Src& src, const Func& func, typename enable_if<!evaluator_assume_aliasing<Src>::value, void*>::type = 0)\n{\n  call_assignment_no_alias(dst, src, func);\n}\n\n// by-pass \"assume-aliasing\"\n// When there is no aliasing, we require that 'dst' has been properly resized\ntemplate<typename Dst, template <typename> class StorageBase, typename Src, typename Func>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid call_assignment(NoAlias<Dst,StorageBase>& dst, const Src& src, const Func& func)\n{\n  call_assignment_no_alias(dst.expression(), src, func);\n}\n\n\ntemplate<typename Dst, typename Src, typename Func>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid call_assignment_no_alias(Dst& dst, const Src& src, const Func& func)\n{\n  enum {\n    NeedToTranspose = (    (int(Dst::RowsAtCompileTime) == 1 && int(Src::ColsAtCompileTime) == 1)\n                        || (int(Dst::ColsAtCompileTime) == 1 && int(Src::RowsAtCompileTime) == 1)\n                      ) && int(Dst::SizeAtCompileTime) != 1\n  };\n\n  typedef typename internal::conditional<NeedToTranspose, Transpose<Dst>, Dst>::type ActualDstTypeCleaned;\n  typedef typename internal::conditional<NeedToTranspose, Transpose<Dst>, Dst&>::type ActualDstType;\n  ActualDstType actualDst(dst);\n  \n  // TODO check whether this is the right place to perform these checks:\n  EIGEN_STATIC_ASSERT_LVALUE(Dst)\n  EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(ActualDstTypeCleaned,Src)\n  EIGEN_CHECK_BINARY_COMPATIBILIY(Func,typename ActualDstTypeCleaned::Scalar,typename Src::Scalar);\n  \n  Assignment<ActualDstTypeCleaned,Src,Func>::run(actualDst, src, func);\n}\ntemplate<typename Dst, typename Src>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid call_assignment_no_alias(Dst& dst, const Src& src)\n{\n  call_assignment_no_alias(dst, src, internal::assign_op<typename Dst::Scalar,typename Src::Scalar>());\n}\n\ntemplate<typename Dst, typename Src, typename Func>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid call_assignment_no_alias_no_transpose(Dst& dst, const Src& src, const Func& func)\n{\n  // TODO check whether this is the right place to perform these checks:\n  EIGEN_STATIC_ASSERT_LVALUE(Dst)\n  EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Dst,Src)\n  EIGEN_CHECK_BINARY_COMPATIBILIY(Func,typename Dst::Scalar,typename Src::Scalar);\n\n  Assignment<Dst,Src,Func>::run(dst, src, func);\n}\ntemplate<typename Dst, typename Src>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid call_assignment_no_alias_no_transpose(Dst& dst, const Src& src)\n{\n  call_assignment_no_alias_no_transpose(dst, src, internal::assign_op<typename Dst::Scalar,typename Src::Scalar>());\n}\n\n// forward declaration\ntemplate<typename Dst, typename Src> void check_for_aliasing(const Dst &dst, const Src &src);\n\n// Generic Dense to Dense assignment\n// Note that the last template argument \"Weak\" is needed to make it possible to perform\n// both partial specialization+SFINAE without ambiguous specialization\ntemplate< typename DstXprType, typename SrcXprType, typename Functor, typename Weak>\nstruct Assignment<DstXprType, SrcXprType, Functor, Dense2Dense, Weak>\n{\n  EIGEN_DEVICE_FUNC\n  static EIGEN_STRONG_INLINE void run(DstXprType &dst, const SrcXprType &src, const Functor &func)\n  {\n#ifndef EIGEN_NO_DEBUG\n    internal::check_for_aliasing(dst, src);\n#endif\n    \n    call_dense_assignment_loop(dst, src, func);\n  }\n};\n\n// Generic assignment through evalTo.\n// TODO: not sure we have to keep that one, but it helps porting current code to new evaluator mechanism.\n// Note that the last template argument \"Weak\" is needed to make it possible to perform\n// both partial specialization+SFINAE without ambiguous specialization\ntemplate< typename DstXprType, typename SrcXprType, typename Functor, typename Weak>\nstruct Assignment<DstXprType, SrcXprType, Functor, EigenBase2EigenBase, Weak>\n{\n  EIGEN_DEVICE_FUNC\n  static EIGEN_STRONG_INLINE void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n\n    eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());\n    src.evalTo(dst);\n  }\n\n  // NOTE The following two functions are templated to avoid their instanciation if not needed\n  //      This is needed because some expressions supports evalTo only and/or have 'void' as scalar type.\n  template<typename SrcScalarType>\n  EIGEN_DEVICE_FUNC\n  static EIGEN_STRONG_INLINE void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op<typename DstXprType::Scalar,SrcScalarType> &/*func*/)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n\n    eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());\n    src.addTo(dst);\n  }\n\n  template<typename SrcScalarType>\n  EIGEN_DEVICE_FUNC\n  static EIGEN_STRONG_INLINE void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op<typename DstXprType::Scalar,SrcScalarType> &/*func*/)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n\n    eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());\n    src.subTo(dst);\n  }\n};\n\n} // namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_ASSIGN_EVALUATOR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Assign_MKL.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n \n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to Intel(R) MKL\n *   MKL VML support for coefficient-wise unary Eigen expressions like a=b.sin()\n ********************************************************************************\n*/\n\n#ifndef EIGEN_ASSIGN_VML_H\n#define EIGEN_ASSIGN_VML_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Dst, typename Src>\nclass vml_assign_traits\n{\n  private:\n    enum {\n      DstHasDirectAccess = Dst::Flags & DirectAccessBit,\n      SrcHasDirectAccess = Src::Flags & DirectAccessBit,\n      StorageOrdersAgree = (int(Dst::IsRowMajor) == int(Src::IsRowMajor)),\n      InnerSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::SizeAtCompileTime)\n                : int(Dst::Flags)&RowMajorBit ? int(Dst::ColsAtCompileTime)\n                : int(Dst::RowsAtCompileTime),\n      InnerMaxSize  = int(Dst::IsVectorAtCompileTime) ? int(Dst::MaxSizeAtCompileTime)\n                    : int(Dst::Flags)&RowMajorBit ? int(Dst::MaxColsAtCompileTime)\n                    : int(Dst::MaxRowsAtCompileTime),\n      MaxSizeAtCompileTime = Dst::SizeAtCompileTime,\n\n      MightEnableVml = StorageOrdersAgree && DstHasDirectAccess && SrcHasDirectAccess && Src::InnerStrideAtCompileTime==1 && Dst::InnerStrideAtCompileTime==1,\n      MightLinearize = MightEnableVml && (int(Dst::Flags) & int(Src::Flags) & LinearAccessBit),\n      VmlSize = MightLinearize ? MaxSizeAtCompileTime : InnerMaxSize,\n      LargeEnough = VmlSize==Dynamic || VmlSize>=EIGEN_MKL_VML_THRESHOLD\n    };\n  public:\n    enum {\n      EnableVml = MightEnableVml && LargeEnough,\n      Traversal = MightLinearize ? LinearTraversal : DefaultTraversal\n    };\n};\n\n#define EIGEN_PP_EXPAND(ARG) ARG\n#if !defined (EIGEN_FAST_MATH) || (EIGEN_FAST_MATH != 1)\n#define EIGEN_VMLMODE_EXPAND_LA , VML_HA\n#else\n#define EIGEN_VMLMODE_EXPAND_LA , VML_LA\n#endif\n\n#define EIGEN_VMLMODE_EXPAND__ \n\n#define EIGEN_VMLMODE_PREFIX_LA vm\n#define EIGEN_VMLMODE_PREFIX__  v\n#define EIGEN_VMLMODE_PREFIX(VMLMODE) EIGEN_CAT(EIGEN_VMLMODE_PREFIX_,VMLMODE)\n\n#define EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, VMLOP, EIGENTYPE, VMLTYPE, VMLMODE)                                           \\\n  template< typename DstXprType, typename SrcXprNested>                                                                         \\\n  struct Assignment<DstXprType, CwiseUnaryOp<scalar_##EIGENOP##_op<EIGENTYPE>, SrcXprNested>, assign_op<EIGENTYPE,EIGENTYPE>,   \\\n                   Dense2Dense, typename enable_if<vml_assign_traits<DstXprType,SrcXprNested>::EnableVml>::type> {              \\\n    typedef CwiseUnaryOp<scalar_##EIGENOP##_op<EIGENTYPE>, SrcXprNested> SrcXprType;                                            \\\n    static void run(DstXprType &dst, const SrcXprType &src, const assign_op<EIGENTYPE,EIGENTYPE> &/*func*/) {                   \\\n      eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());                                                       \\\n      if(vml_assign_traits<DstXprType,SrcXprNested>::Traversal==LinearTraversal) {                                              \\\n        VMLOP(dst.size(), (const VMLTYPE*)src.nestedExpression().data(),                                                        \\\n              (VMLTYPE*)dst.data() EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_##VMLMODE) );                                           \\\n      } else {                                                                                                                  \\\n        const Index outerSize = dst.outerSize();                                                                                \\\n        for(Index outer = 0; outer < outerSize; ++outer) {                                                                      \\\n          const EIGENTYPE *src_ptr = src.IsRowMajor ? &(src.nestedExpression().coeffRef(outer,0)) :                             \\\n                                                      &(src.nestedExpression().coeffRef(0, outer));                             \\\n          EIGENTYPE *dst_ptr = dst.IsRowMajor ? &(dst.coeffRef(outer,0)) : &(dst.coeffRef(0, outer));                           \\\n          VMLOP( dst.innerSize(), (const VMLTYPE*)src_ptr,                                                                      \\\n                (VMLTYPE*)dst_ptr EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_##VMLMODE));                                             \\\n        }                                                                                                                       \\\n      }                                                                                                                         \\\n    }                                                                                                                           \\\n  };                                                                                                                            \\\n\n\n#define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(EIGENOP, VMLOP, VMLMODE)                                                         \\\n  EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE),s##VMLOP), float, float, VMLMODE)           \\\n  EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE),d##VMLOP), double, double, VMLMODE)\n\n#define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_CPLX(EIGENOP, VMLOP, VMLMODE)                                                         \\\n  EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE),c##VMLOP), scomplex, MKL_Complex8, VMLMODE) \\\n  EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE),z##VMLOP), dcomplex, MKL_Complex16, VMLMODE)\n  \n#define EIGEN_MKL_VML_DECLARE_UNARY_CALLS(EIGENOP, VMLOP, VMLMODE)                                                              \\\n  EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(EIGENOP, VMLOP, VMLMODE)                                                               \\\n  EIGEN_MKL_VML_DECLARE_UNARY_CALLS_CPLX(EIGENOP, VMLOP, VMLMODE)\n\n  \nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(sin,   Sin,   LA)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(asin,  Asin,  LA)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(sinh,  Sinh,  LA)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(cos,   Cos,   LA)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(acos,  Acos,  LA)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(cosh,  Cosh,  LA)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(tan,   Tan,   LA)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(atan,  Atan,  LA)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(tanh,  Tanh,  LA)\n// EIGEN_MKL_VML_DECLARE_UNARY_CALLS(abs,   Abs,    _)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(exp,   Exp,   LA)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(log,   Ln,    LA)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(log10, Log10, LA)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS(sqrt,  Sqrt,  _)\n\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(square, Sqr,   _)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS_CPLX(arg, Arg,      _)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(round, Round,  _)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(floor, Floor,  _)\nEIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(ceil,  Ceil,   _)\n\n#define EIGEN_MKL_VML_DECLARE_POW_CALL(EIGENOP, VMLOP, EIGENTYPE, VMLTYPE, VMLMODE)                                           \\\n  template< typename DstXprType, typename SrcXprNested, typename Plain>                                                       \\\n  struct Assignment<DstXprType, CwiseBinaryOp<scalar_##EIGENOP##_op<EIGENTYPE,EIGENTYPE>, SrcXprNested,                       \\\n                    const CwiseNullaryOp<internal::scalar_constant_op<EIGENTYPE>,Plain> >, assign_op<EIGENTYPE,EIGENTYPE>,    \\\n                   Dense2Dense, typename enable_if<vml_assign_traits<DstXprType,SrcXprNested>::EnableVml>::type> {            \\\n    typedef CwiseBinaryOp<scalar_##EIGENOP##_op<EIGENTYPE,EIGENTYPE>, SrcXprNested,                                           \\\n                    const CwiseNullaryOp<internal::scalar_constant_op<EIGENTYPE>,Plain> > SrcXprType;                         \\\n    static void run(DstXprType &dst, const SrcXprType &src, const assign_op<EIGENTYPE,EIGENTYPE> &/*func*/) {                 \\\n      eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());                                                     \\\n      VMLTYPE exponent = reinterpret_cast<const VMLTYPE&>(src.rhs().functor().m_other);                                       \\\n      if(vml_assign_traits<DstXprType,SrcXprNested>::Traversal==LinearTraversal)                                              \\\n      {                                                                                                                       \\\n        VMLOP( dst.size(), (const VMLTYPE*)src.lhs().data(), exponent,                                                        \\\n              (VMLTYPE*)dst.data() EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_##VMLMODE) );                                         \\\n      } else {                                                                                                                \\\n        const Index outerSize = dst.outerSize();                                                                              \\\n        for(Index outer = 0; outer < outerSize; ++outer) {                                                                    \\\n          const EIGENTYPE *src_ptr = src.IsRowMajor ? &(src.lhs().coeffRef(outer,0)) :                                        \\\n                                                      &(src.lhs().coeffRef(0, outer));                                        \\\n          EIGENTYPE *dst_ptr = dst.IsRowMajor ? &(dst.coeffRef(outer,0)) : &(dst.coeffRef(0, outer));                         \\\n          VMLOP( dst.innerSize(), (const VMLTYPE*)src_ptr, exponent,                                                          \\\n                 (VMLTYPE*)dst_ptr EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_##VMLMODE));                                          \\\n        }                                                                                                                     \\\n      }                                                                                                                       \\\n    }                                                                                                                         \\\n  };\n  \nEIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmsPowx, float,    float,         LA)\nEIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmdPowx, double,   double,        LA)\nEIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmcPowx, scomplex, MKL_Complex8,  LA)\nEIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmzPowx, dcomplex, MKL_Complex16, LA)\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_ASSIGN_VML_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/BandMatrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_BANDMATRIX_H\n#define EIGEN_BANDMATRIX_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Derived>\nclass BandMatrixBase : public EigenBase<Derived>\n{\n  public:\n\n    enum {\n      Flags = internal::traits<Derived>::Flags,\n      CoeffReadCost = internal::traits<Derived>::CoeffReadCost,\n      RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,\n      ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,\n      MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,\n      Supers = internal::traits<Derived>::Supers,\n      Subs   = internal::traits<Derived>::Subs,\n      Options = internal::traits<Derived>::Options\n    };\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    typedef Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime> DenseMatrixType;\n    typedef typename DenseMatrixType::StorageIndex StorageIndex;\n    typedef typename internal::traits<Derived>::CoefficientsType CoefficientsType;\n    typedef EigenBase<Derived> Base;\n\n  protected:\n    enum {\n      DataRowsAtCompileTime = ((Supers!=Dynamic) && (Subs!=Dynamic))\n                            ? 1 + Supers + Subs\n                            : Dynamic,\n      SizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime,ColsAtCompileTime)\n    };\n\n  public:\n    \n    using Base::derived;\n    using Base::rows;\n    using Base::cols;\n\n    /** \\returns the number of super diagonals */\n    inline Index supers() const { return derived().supers(); }\n\n    /** \\returns the number of sub diagonals */\n    inline Index subs() const { return derived().subs(); }\n    \n    /** \\returns an expression of the underlying coefficient matrix */\n    inline const CoefficientsType& coeffs() const { return derived().coeffs(); }\n    \n    /** \\returns an expression of the underlying coefficient matrix */\n    inline CoefficientsType& coeffs() { return derived().coeffs(); }\n\n    /** \\returns a vector expression of the \\a i -th column,\n      * only the meaningful part is returned.\n      * \\warning the internal storage must be column major. */\n    inline Block<CoefficientsType,Dynamic,1> col(Index i)\n    {\n      EIGEN_STATIC_ASSERT((Options&RowMajor)==0,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);\n      Index start = 0;\n      Index len = coeffs().rows();\n      if (i<=supers())\n      {\n        start = supers()-i;\n        len = (std::min)(rows(),std::max<Index>(0,coeffs().rows() - (supers()-i)));\n      }\n      else if (i>=rows()-subs())\n        len = std::max<Index>(0,coeffs().rows() - (i + 1 - rows() + subs()));\n      return Block<CoefficientsType,Dynamic,1>(coeffs(), start, i, len, 1);\n    }\n\n    /** \\returns a vector expression of the main diagonal */\n    inline Block<CoefficientsType,1,SizeAtCompileTime> diagonal()\n    { return Block<CoefficientsType,1,SizeAtCompileTime>(coeffs(),supers(),0,1,(std::min)(rows(),cols())); }\n\n    /** \\returns a vector expression of the main diagonal (const version) */\n    inline const Block<const CoefficientsType,1,SizeAtCompileTime> diagonal() const\n    { return Block<const CoefficientsType,1,SizeAtCompileTime>(coeffs(),supers(),0,1,(std::min)(rows(),cols())); }\n\n    template<int Index> struct DiagonalIntReturnType {\n      enum {\n        ReturnOpposite = (Options&SelfAdjoint) && (((Index)>0 && Supers==0) || ((Index)<0 && Subs==0)),\n        Conjugate = ReturnOpposite && NumTraits<Scalar>::IsComplex,\n        ActualIndex = ReturnOpposite ? -Index : Index,\n        DiagonalSize = (RowsAtCompileTime==Dynamic || ColsAtCompileTime==Dynamic)\n                     ? Dynamic\n                     : (ActualIndex<0\n                     ? EIGEN_SIZE_MIN_PREFER_DYNAMIC(ColsAtCompileTime, RowsAtCompileTime + ActualIndex)\n                     : EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime, ColsAtCompileTime - ActualIndex))\n      };\n      typedef Block<CoefficientsType,1, DiagonalSize> BuildType;\n      typedef typename internal::conditional<Conjugate,\n                 CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>,BuildType >,\n                 BuildType>::type Type;\n    };\n\n    /** \\returns a vector expression of the \\a N -th sub or super diagonal */\n    template<int N> inline typename DiagonalIntReturnType<N>::Type diagonal()\n    {\n      return typename DiagonalIntReturnType<N>::BuildType(coeffs(), supers()-N, (std::max)(0,N), 1, diagonalLength(N));\n    }\n\n    /** \\returns a vector expression of the \\a N -th sub or super diagonal */\n    template<int N> inline const typename DiagonalIntReturnType<N>::Type diagonal() const\n    {\n      return typename DiagonalIntReturnType<N>::BuildType(coeffs(), supers()-N, (std::max)(0,N), 1, diagonalLength(N));\n    }\n\n    /** \\returns a vector expression of the \\a i -th sub or super diagonal */\n    inline Block<CoefficientsType,1,Dynamic> diagonal(Index i)\n    {\n      eigen_assert((i<0 && -i<=subs()) || (i>=0 && i<=supers()));\n      return Block<CoefficientsType,1,Dynamic>(coeffs(), supers()-i, std::max<Index>(0,i), 1, diagonalLength(i));\n    }\n\n    /** \\returns a vector expression of the \\a i -th sub or super diagonal */\n    inline const Block<const CoefficientsType,1,Dynamic> diagonal(Index i) const\n    {\n      eigen_assert((i<0 && -i<=subs()) || (i>=0 && i<=supers()));\n      return Block<const CoefficientsType,1,Dynamic>(coeffs(), supers()-i, std::max<Index>(0,i), 1, diagonalLength(i));\n    }\n    \n    template<typename Dest> inline void evalTo(Dest& dst) const\n    {\n      dst.resize(rows(),cols());\n      dst.setZero();\n      dst.diagonal() = diagonal();\n      for (Index i=1; i<=supers();++i)\n        dst.diagonal(i) = diagonal(i);\n      for (Index i=1; i<=subs();++i)\n        dst.diagonal(-i) = diagonal(-i);\n    }\n\n    DenseMatrixType toDenseMatrix() const\n    {\n      DenseMatrixType res(rows(),cols());\n      evalTo(res);\n      return res;\n    }\n\n  protected:\n\n    inline Index diagonalLength(Index i) const\n    { return i<0 ? (std::min)(cols(),rows()+i) : (std::min)(rows(),cols()-i); }\n};\n\n/**\n  * \\class BandMatrix\n  * \\ingroup Core_Module\n  *\n  * \\brief Represents a rectangular matrix with a banded storage\n  *\n  * \\tparam _Scalar Numeric type, i.e. float, double, int\n  * \\tparam _Rows Number of rows, or \\b Dynamic\n  * \\tparam _Cols Number of columns, or \\b Dynamic\n  * \\tparam _Supers Number of super diagonal\n  * \\tparam _Subs Number of sub diagonal\n  * \\tparam _Options A combination of either \\b #RowMajor or \\b #ColMajor, and of \\b #SelfAdjoint\n  *                  The former controls \\ref TopicStorageOrders \"storage order\", and defaults to\n  *                  column-major. The latter controls whether the matrix represents a selfadjoint\n  *                  matrix in which case either Supers of Subs have to be null.\n  *\n  * \\sa class TridiagonalMatrix\n  */\n\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Supers, int _Subs, int _Options>\nstruct traits<BandMatrix<_Scalar,_Rows,_Cols,_Supers,_Subs,_Options> >\n{\n  typedef _Scalar Scalar;\n  typedef Dense StorageKind;\n  typedef Eigen::Index StorageIndex;\n  enum {\n    CoeffReadCost = NumTraits<Scalar>::ReadCost,\n    RowsAtCompileTime = _Rows,\n    ColsAtCompileTime = _Cols,\n    MaxRowsAtCompileTime = _Rows,\n    MaxColsAtCompileTime = _Cols,\n    Flags = LvalueBit,\n    Supers = _Supers,\n    Subs = _Subs,\n    Options = _Options,\n    DataRowsAtCompileTime = ((Supers!=Dynamic) && (Subs!=Dynamic)) ? 1 + Supers + Subs : Dynamic\n  };\n  typedef Matrix<Scalar,DataRowsAtCompileTime,ColsAtCompileTime,Options&RowMajor?RowMajor:ColMajor> CoefficientsType;\n};\n\ntemplate<typename _Scalar, int Rows, int Cols, int Supers, int Subs, int Options>\nclass BandMatrix : public BandMatrixBase<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Options> >\n{\n  public:\n\n    typedef typename internal::traits<BandMatrix>::Scalar Scalar;\n    typedef typename internal::traits<BandMatrix>::StorageIndex StorageIndex;\n    typedef typename internal::traits<BandMatrix>::CoefficientsType CoefficientsType;\n\n    explicit inline BandMatrix(Index rows=Rows, Index cols=Cols, Index supers=Supers, Index subs=Subs)\n      : m_coeffs(1+supers+subs,cols),\n        m_rows(rows), m_supers(supers), m_subs(subs)\n    {\n    }\n\n    /** \\returns the number of columns */\n    inline Index rows() const { return m_rows.value(); }\n\n    /** \\returns the number of rows */\n    inline Index cols() const { return m_coeffs.cols(); }\n\n    /** \\returns the number of super diagonals */\n    inline Index supers() const { return m_supers.value(); }\n\n    /** \\returns the number of sub diagonals */\n    inline Index subs() const { return m_subs.value(); }\n\n    inline const CoefficientsType& coeffs() const { return m_coeffs; }\n    inline CoefficientsType& coeffs() { return m_coeffs; }\n\n  protected:\n\n    CoefficientsType m_coeffs;\n    internal::variable_if_dynamic<Index, Rows>   m_rows;\n    internal::variable_if_dynamic<Index, Supers> m_supers;\n    internal::variable_if_dynamic<Index, Subs>   m_subs;\n};\n\ntemplate<typename _CoefficientsType,int _Rows, int _Cols, int _Supers, int _Subs,int _Options>\nclass BandMatrixWrapper;\n\ntemplate<typename _CoefficientsType,int _Rows, int _Cols, int _Supers, int _Subs,int _Options>\nstruct traits<BandMatrixWrapper<_CoefficientsType,_Rows,_Cols,_Supers,_Subs,_Options> >\n{\n  typedef typename _CoefficientsType::Scalar Scalar;\n  typedef typename _CoefficientsType::StorageKind StorageKind;\n  typedef typename _CoefficientsType::StorageIndex StorageIndex;\n  enum {\n    CoeffReadCost = internal::traits<_CoefficientsType>::CoeffReadCost,\n    RowsAtCompileTime = _Rows,\n    ColsAtCompileTime = _Cols,\n    MaxRowsAtCompileTime = _Rows,\n    MaxColsAtCompileTime = _Cols,\n    Flags = LvalueBit,\n    Supers = _Supers,\n    Subs = _Subs,\n    Options = _Options,\n    DataRowsAtCompileTime = ((Supers!=Dynamic) && (Subs!=Dynamic)) ? 1 + Supers + Subs : Dynamic\n  };\n  typedef _CoefficientsType CoefficientsType;\n};\n\ntemplate<typename _CoefficientsType,int _Rows, int _Cols, int _Supers, int _Subs,int _Options>\nclass BandMatrixWrapper : public BandMatrixBase<BandMatrixWrapper<_CoefficientsType,_Rows,_Cols,_Supers,_Subs,_Options> >\n{\n  public:\n\n    typedef typename internal::traits<BandMatrixWrapper>::Scalar Scalar;\n    typedef typename internal::traits<BandMatrixWrapper>::CoefficientsType CoefficientsType;\n    typedef typename internal::traits<BandMatrixWrapper>::StorageIndex StorageIndex;\n\n    explicit inline BandMatrixWrapper(const CoefficientsType& coeffs, Index rows=_Rows, Index cols=_Cols, Index supers=_Supers, Index subs=_Subs)\n      : m_coeffs(coeffs),\n        m_rows(rows), m_supers(supers), m_subs(subs)\n    {\n      EIGEN_UNUSED_VARIABLE(cols);\n      //internal::assert(coeffs.cols()==cols() && (supers()+subs()+1)==coeffs.rows());\n    }\n\n    /** \\returns the number of columns */\n    inline Index rows() const { return m_rows.value(); }\n\n    /** \\returns the number of rows */\n    inline Index cols() const { return m_coeffs.cols(); }\n\n    /** \\returns the number of super diagonals */\n    inline Index supers() const { return m_supers.value(); }\n\n    /** \\returns the number of sub diagonals */\n    inline Index subs() const { return m_subs.value(); }\n\n    inline const CoefficientsType& coeffs() const { return m_coeffs; }\n\n  protected:\n\n    const CoefficientsType& m_coeffs;\n    internal::variable_if_dynamic<Index, _Rows>   m_rows;\n    internal::variable_if_dynamic<Index, _Supers> m_supers;\n    internal::variable_if_dynamic<Index, _Subs>   m_subs;\n};\n\n/**\n  * \\class TridiagonalMatrix\n  * \\ingroup Core_Module\n  *\n  * \\brief Represents a tridiagonal matrix with a compact banded storage\n  *\n  * \\tparam Scalar Numeric type, i.e. float, double, int\n  * \\tparam Size Number of rows and cols, or \\b Dynamic\n  * \\tparam Options Can be 0 or \\b SelfAdjoint\n  *\n  * \\sa class BandMatrix\n  */\ntemplate<typename Scalar, int Size, int Options>\nclass TridiagonalMatrix : public BandMatrix<Scalar,Size,Size,Options&SelfAdjoint?0:1,1,Options|RowMajor>\n{\n    typedef BandMatrix<Scalar,Size,Size,Options&SelfAdjoint?0:1,1,Options|RowMajor> Base;\n    typedef typename Base::StorageIndex StorageIndex;\n  public:\n    explicit TridiagonalMatrix(Index size = Size) : Base(size,size,Options&SelfAdjoint?0:1,1) {}\n\n    inline typename Base::template DiagonalIntReturnType<1>::Type super()\n    { return Base::template diagonal<1>(); }\n    inline const typename Base::template DiagonalIntReturnType<1>::Type super() const\n    { return Base::template diagonal<1>(); }\n    inline typename Base::template DiagonalIntReturnType<-1>::Type sub()\n    { return Base::template diagonal<-1>(); }\n    inline const typename Base::template DiagonalIntReturnType<-1>::Type sub() const\n    { return Base::template diagonal<-1>(); }\n  protected:\n};\n\n\nstruct BandShape {};\n\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Supers, int _Subs, int _Options>\nstruct evaluator_traits<BandMatrix<_Scalar,_Rows,_Cols,_Supers,_Subs,_Options> >\n  : public evaluator_traits_base<BandMatrix<_Scalar,_Rows,_Cols,_Supers,_Subs,_Options> >\n{\n  typedef BandShape Shape;\n};\n\ntemplate<typename _CoefficientsType,int _Rows, int _Cols, int _Supers, int _Subs,int _Options>\nstruct evaluator_traits<BandMatrixWrapper<_CoefficientsType,_Rows,_Cols,_Supers,_Subs,_Options> >\n  : public evaluator_traits_base<BandMatrixWrapper<_CoefficientsType,_Rows,_Cols,_Supers,_Subs,_Options> >\n{\n  typedef BandShape Shape;\n};\n\ntemplate<> struct AssignmentKind<DenseShape,BandShape> { typedef EigenBase2EigenBase Kind; };\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_BANDMATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Block.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_BLOCK_H\n#define EIGEN_BLOCK_H\n\nnamespace Eigen { \n\nnamespace internal {\ntemplate<typename XprType, int BlockRows, int BlockCols, bool InnerPanel>\nstruct traits<Block<XprType, BlockRows, BlockCols, InnerPanel> > : traits<XprType>\n{\n  typedef typename traits<XprType>::Scalar Scalar;\n  typedef typename traits<XprType>::StorageKind StorageKind;\n  typedef typename traits<XprType>::XprKind XprKind;\n  typedef typename ref_selector<XprType>::type XprTypeNested;\n  typedef typename remove_reference<XprTypeNested>::type _XprTypeNested;\n  enum{\n    MatrixRows = traits<XprType>::RowsAtCompileTime,\n    MatrixCols = traits<XprType>::ColsAtCompileTime,\n    RowsAtCompileTime = MatrixRows == 0 ? 0 : BlockRows,\n    ColsAtCompileTime = MatrixCols == 0 ? 0 : BlockCols,\n    MaxRowsAtCompileTime = BlockRows==0 ? 0\n                         : RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime)\n                         : int(traits<XprType>::MaxRowsAtCompileTime),\n    MaxColsAtCompileTime = BlockCols==0 ? 0\n                         : ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime)\n                         : int(traits<XprType>::MaxColsAtCompileTime),\n\n    XprTypeIsRowMajor = (int(traits<XprType>::Flags)&RowMajorBit) != 0,\n    IsRowMajor = (MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1\n               : (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0\n               : XprTypeIsRowMajor,\n    HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor),\n    InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),\n    InnerStrideAtCompileTime = HasSameStorageOrderAsXprType\n                             ? int(inner_stride_at_compile_time<XprType>::ret)\n                             : int(outer_stride_at_compile_time<XprType>::ret),\n    OuterStrideAtCompileTime = HasSameStorageOrderAsXprType\n                             ? int(outer_stride_at_compile_time<XprType>::ret)\n                             : int(inner_stride_at_compile_time<XprType>::ret),\n\n    // FIXME, this traits is rather specialized for dense object and it needs to be cleaned further\n    FlagsLvalueBit = is_lvalue<XprType>::value ? LvalueBit : 0,\n    FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0,\n    Flags = (traits<XprType>::Flags & (DirectAccessBit | (InnerPanel?CompressedAccessBit:0))) | FlagsLvalueBit | FlagsRowMajorBit,\n    // FIXME DirectAccessBit should not be handled by expressions\n    // \n    // Alignment is needed by MapBase's assertions\n    // We can sefely set it to false here. Internal alignment errors will be detected by an eigen_internal_assert in the respective evaluator\n    Alignment = 0\n  };\n};\n\ntemplate<typename XprType, int BlockRows=Dynamic, int BlockCols=Dynamic, bool InnerPanel = false,\n         bool HasDirectAccess = internal::has_direct_access<XprType>::ret> class BlockImpl_dense;\n         \n} // end namespace internal\n\ntemplate<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, typename StorageKind> class BlockImpl;\n\n/** \\class Block\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of a fixed-size or dynamic-size block\n  *\n  * \\tparam XprType the type of the expression in which we are taking a block\n  * \\tparam BlockRows the number of rows of the block we are taking at compile time (optional)\n  * \\tparam BlockCols the number of columns of the block we are taking at compile time (optional)\n  * \\tparam InnerPanel is true, if the block maps to a set of rows of a row major matrix or\n  *         to set of columns of a column major matrix (optional). The parameter allows to determine\n  *         at compile time whether aligned access is possible on the block expression.\n  *\n  * This class represents an expression of either a fixed-size or dynamic-size block. It is the return\n  * type of DenseBase::block(Index,Index,Index,Index) and DenseBase::block<int,int>(Index,Index) and\n  * most of the time this is the only way it is used.\n  *\n  * However, if you want to directly maniputate block expressions,\n  * for instance if you want to write a function returning such an expression, you\n  * will need to use this class.\n  *\n  * Here is an example illustrating the dynamic case:\n  * \\include class_Block.cpp\n  * Output: \\verbinclude class_Block.out\n  *\n  * \\note Even though this expression has dynamic size, in the case where \\a XprType\n  * has fixed size, this expression inherits a fixed maximal size which means that evaluating\n  * it does not cause a dynamic memory allocation.\n  *\n  * Here is an example illustrating the fixed-size case:\n  * \\include class_FixedBlock.cpp\n  * Output: \\verbinclude class_FixedBlock.out\n  *\n  * \\sa DenseBase::block(Index,Index,Index,Index), DenseBase::block(Index,Index), class VectorBlock\n  */\ntemplate<typename XprType, int BlockRows, int BlockCols, bool InnerPanel> class Block\n  : public BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, typename internal::traits<XprType>::StorageKind>\n{\n    typedef BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, typename internal::traits<XprType>::StorageKind> Impl;\n  public:\n    //typedef typename Impl::Base Base;\n    typedef Impl Base;\n    EIGEN_GENERIC_PUBLIC_INTERFACE(Block)\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)\n    \n    typedef typename internal::remove_all<XprType>::type NestedExpression;\n  \n    /** Column or Row constructor\n      */\n    EIGEN_DEVICE_FUNC\n    inline Block(XprType& xpr, Index i) : Impl(xpr,i)\n    {\n      eigen_assert( (i>=0) && (\n          ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && i<xpr.rows())\n        ||((BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) && i<xpr.cols())));\n    }\n\n    /** Fixed-size constructor\n      */\n    EIGEN_DEVICE_FUNC\n    inline Block(XprType& xpr, Index startRow, Index startCol)\n      : Impl(xpr, startRow, startCol)\n    {\n      EIGEN_STATIC_ASSERT(RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE)\n      eigen_assert(startRow >= 0 && BlockRows >= 0 && startRow + BlockRows <= xpr.rows()\n             && startCol >= 0 && BlockCols >= 0 && startCol + BlockCols <= xpr.cols());\n    }\n\n    /** Dynamic-size constructor\n      */\n    EIGEN_DEVICE_FUNC\n    inline Block(XprType& xpr,\n          Index startRow, Index startCol,\n          Index blockRows, Index blockCols)\n      : Impl(xpr, startRow, startCol, blockRows, blockCols)\n    {\n      eigen_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows)\n          && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols));\n      eigen_assert(startRow >= 0 && blockRows >= 0 && startRow  <= xpr.rows() - blockRows\n          && startCol >= 0 && blockCols >= 0 && startCol <= xpr.cols() - blockCols);\n    }\n};\n         \n// The generic default implementation for dense block simplu forward to the internal::BlockImpl_dense\n// that must be specialized for direct and non-direct access...\ntemplate<typename XprType, int BlockRows, int BlockCols, bool InnerPanel>\nclass BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, Dense>\n  : public internal::BlockImpl_dense<XprType, BlockRows, BlockCols, InnerPanel>\n{\n    typedef internal::BlockImpl_dense<XprType, BlockRows, BlockCols, InnerPanel> Impl;\n    typedef typename XprType::StorageIndex StorageIndex;\n  public:\n    typedef Impl Base;\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl)\n    EIGEN_DEVICE_FUNC inline BlockImpl(XprType& xpr, Index i) : Impl(xpr,i) {}\n    EIGEN_DEVICE_FUNC inline BlockImpl(XprType& xpr, Index startRow, Index startCol) : Impl(xpr, startRow, startCol) {}\n    EIGEN_DEVICE_FUNC\n    inline BlockImpl(XprType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)\n      : Impl(xpr, startRow, startCol, blockRows, blockCols) {}\n};\n\nnamespace internal {\n\n/** \\internal Internal implementation of dense Blocks in the general case. */\ntemplate<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool HasDirectAccess> class BlockImpl_dense\n  : public internal::dense_xpr_base<Block<XprType, BlockRows, BlockCols, InnerPanel> >::type\n{\n    typedef Block<XprType, BlockRows, BlockCols, InnerPanel> BlockType;\n    typedef typename internal::ref_selector<XprType>::non_const_type XprTypeNested;\n  public:\n\n    typedef typename internal::dense_xpr_base<BlockType>::type Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(BlockType)\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl_dense)\n\n    // class InnerIterator; // FIXME apparently never used\n\n    /** Column or Row constructor\n      */\n    EIGEN_DEVICE_FUNC\n    inline BlockImpl_dense(XprType& xpr, Index i)\n      : m_xpr(xpr),\n        // It is a row if and only if BlockRows==1 and BlockCols==XprType::ColsAtCompileTime,\n        // and it is a column if and only if BlockRows==XprType::RowsAtCompileTime and BlockCols==1,\n        // all other cases are invalid.\n        // The case a 1x1 matrix seems ambiguous, but the result is the same anyway.\n        m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0),\n        m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),\n        m_blockRows(BlockRows==1 ? 1 : xpr.rows()),\n        m_blockCols(BlockCols==1 ? 1 : xpr.cols())\n    {}\n\n    /** Fixed-size constructor\n      */\n    EIGEN_DEVICE_FUNC\n    inline BlockImpl_dense(XprType& xpr, Index startRow, Index startCol)\n      : m_xpr(xpr), m_startRow(startRow), m_startCol(startCol),\n                    m_blockRows(BlockRows), m_blockCols(BlockCols)\n    {}\n\n    /** Dynamic-size constructor\n      */\n    EIGEN_DEVICE_FUNC\n    inline BlockImpl_dense(XprType& xpr,\n          Index startRow, Index startCol,\n          Index blockRows, Index blockCols)\n      : m_xpr(xpr), m_startRow(startRow), m_startCol(startCol),\n                    m_blockRows(blockRows), m_blockCols(blockCols)\n    {}\n\n    EIGEN_DEVICE_FUNC inline Index rows() const { return m_blockRows.value(); }\n    EIGEN_DEVICE_FUNC inline Index cols() const { return m_blockCols.value(); }\n\n    EIGEN_DEVICE_FUNC\n    inline Scalar& coeffRef(Index rowId, Index colId)\n    {\n      EIGEN_STATIC_ASSERT_LVALUE(XprType)\n      return m_xpr.coeffRef(rowId + m_startRow.value(), colId + m_startCol.value());\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index rowId, Index colId) const\n    {\n      return m_xpr.derived().coeffRef(rowId + m_startRow.value(), colId + m_startCol.value());\n    }\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index rowId, Index colId) const\n    {\n      return m_xpr.coeff(rowId + m_startRow.value(), colId + m_startCol.value());\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline Scalar& coeffRef(Index index)\n    {\n      EIGEN_STATIC_ASSERT_LVALUE(XprType)\n      return m_xpr.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),\n                            m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index index) const\n    {\n      return m_xpr.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),\n                            m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline const CoeffReturnType coeff(Index index) const\n    {\n      return m_xpr.coeff(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),\n                         m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));\n    }\n\n    template<int LoadMode>\n    inline PacketScalar packet(Index rowId, Index colId) const\n    {\n      return m_xpr.template packet<Unaligned>(rowId + m_startRow.value(), colId + m_startCol.value());\n    }\n\n    template<int LoadMode>\n    inline void writePacket(Index rowId, Index colId, const PacketScalar& val)\n    {\n      m_xpr.template writePacket<Unaligned>(rowId + m_startRow.value(), colId + m_startCol.value(), val);\n    }\n\n    template<int LoadMode>\n    inline PacketScalar packet(Index index) const\n    {\n      return m_xpr.template packet<Unaligned>\n              (m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),\n               m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));\n    }\n\n    template<int LoadMode>\n    inline void writePacket(Index index, const PacketScalar& val)\n    {\n      m_xpr.template writePacket<Unaligned>\n         (m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),\n          m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0), val);\n    }\n\n    #ifdef EIGEN_PARSED_BY_DOXYGEN\n    /** \\sa MapBase::data() */\n    EIGEN_DEVICE_FUNC inline const Scalar* data() const;\n    EIGEN_DEVICE_FUNC inline Index innerStride() const;\n    EIGEN_DEVICE_FUNC inline Index outerStride() const;\n    #endif\n\n    EIGEN_DEVICE_FUNC\n    const typename internal::remove_all<XprTypeNested>::type& nestedExpression() const\n    { \n      return m_xpr; \n    }\n\n    EIGEN_DEVICE_FUNC\n    XprType& nestedExpression() { return m_xpr; }\n      \n    EIGEN_DEVICE_FUNC\n    StorageIndex startRow() const\n    { \n      return m_startRow.value(); \n    }\n      \n    EIGEN_DEVICE_FUNC\n    StorageIndex startCol() const\n    { \n      return m_startCol.value(); \n    }\n\n  protected:\n\n    XprTypeNested m_xpr;\n    const internal::variable_if_dynamic<StorageIndex, (XprType::RowsAtCompileTime == 1 && BlockRows==1) ? 0 : Dynamic> m_startRow;\n    const internal::variable_if_dynamic<StorageIndex, (XprType::ColsAtCompileTime == 1 && BlockCols==1) ? 0 : Dynamic> m_startCol;\n    const internal::variable_if_dynamic<StorageIndex, RowsAtCompileTime> m_blockRows;\n    const internal::variable_if_dynamic<StorageIndex, ColsAtCompileTime> m_blockCols;\n};\n\n/** \\internal Internal implementation of dense Blocks in the direct access case.*/\ntemplate<typename XprType, int BlockRows, int BlockCols, bool InnerPanel>\nclass BlockImpl_dense<XprType,BlockRows,BlockCols, InnerPanel,true>\n  : public MapBase<Block<XprType, BlockRows, BlockCols, InnerPanel> >\n{\n    typedef Block<XprType, BlockRows, BlockCols, InnerPanel> BlockType;\n    typedef typename internal::ref_selector<XprType>::non_const_type XprTypeNested;\n    enum {\n      XprTypeIsRowMajor = (int(traits<XprType>::Flags)&RowMajorBit) != 0\n    };\n  public:\n\n    typedef MapBase<BlockType> Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(BlockType)\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl_dense)\n\n    /** Column or Row constructor\n      */\n    EIGEN_DEVICE_FUNC\n    inline BlockImpl_dense(XprType& xpr, Index i)\n      : Base(xpr.data() + i * (    ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && (!XprTypeIsRowMajor)) \n                                || ((BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) && ( XprTypeIsRowMajor)) ? xpr.innerStride() : xpr.outerStride()),\n             BlockRows==1 ? 1 : xpr.rows(),\n             BlockCols==1 ? 1 : xpr.cols()),\n        m_xpr(xpr),\n        m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0),\n        m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0)\n    {\n      init();\n    }\n\n    /** Fixed-size constructor\n      */\n    EIGEN_DEVICE_FUNC\n    inline BlockImpl_dense(XprType& xpr, Index startRow, Index startCol)\n      : Base(xpr.data()+xpr.innerStride()*(XprTypeIsRowMajor?startCol:startRow) + xpr.outerStride()*(XprTypeIsRowMajor?startRow:startCol)),\n        m_xpr(xpr), m_startRow(startRow), m_startCol(startCol)\n    {\n      init();\n    }\n\n    /** Dynamic-size constructor\n      */\n    EIGEN_DEVICE_FUNC\n    inline BlockImpl_dense(XprType& xpr,\n          Index startRow, Index startCol,\n          Index blockRows, Index blockCols)\n      : Base(xpr.data()+xpr.innerStride()*(XprTypeIsRowMajor?startCol:startRow) + xpr.outerStride()*(XprTypeIsRowMajor?startRow:startCol), blockRows, blockCols),\n        m_xpr(xpr), m_startRow(startRow), m_startCol(startCol)\n    {\n      init();\n    }\n\n    EIGEN_DEVICE_FUNC\n    const typename internal::remove_all<XprTypeNested>::type& nestedExpression() const\n    { \n      return m_xpr; \n    }\n\n    EIGEN_DEVICE_FUNC\n    XprType& nestedExpression() { return m_xpr; }\n      \n    /** \\sa MapBase::innerStride() */\n    EIGEN_DEVICE_FUNC\n    inline Index innerStride() const\n    {\n      return internal::traits<BlockType>::HasSameStorageOrderAsXprType\n             ? m_xpr.innerStride()\n             : m_xpr.outerStride();\n    }\n\n    /** \\sa MapBase::outerStride() */\n    EIGEN_DEVICE_FUNC\n    inline Index outerStride() const\n    {\n      return m_outerStride;\n    }\n\n    EIGEN_DEVICE_FUNC\n    StorageIndex startRow() const\n    {\n      return m_startRow.value();\n    }\n\n    EIGEN_DEVICE_FUNC\n    StorageIndex startCol() const\n    {\n      return m_startCol.value();\n    }\n\n  #ifndef __SUNPRO_CC\n  // FIXME sunstudio is not friendly with the above friend...\n  // META-FIXME there is no 'friend' keyword around here. Is this obsolete?\n  protected:\n  #endif\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** \\internal used by allowAligned() */\n    EIGEN_DEVICE_FUNC\n    inline BlockImpl_dense(XprType& xpr, const Scalar* data, Index blockRows, Index blockCols)\n      : Base(data, blockRows, blockCols), m_xpr(xpr)\n    {\n      init();\n    }\n    #endif\n\n  protected:\n    EIGEN_DEVICE_FUNC\n    void init()\n    {\n      m_outerStride = internal::traits<BlockType>::HasSameStorageOrderAsXprType\n                    ? m_xpr.outerStride()\n                    : m_xpr.innerStride();\n    }\n\n    XprTypeNested m_xpr;\n    const internal::variable_if_dynamic<StorageIndex, (XprType::RowsAtCompileTime == 1 && BlockRows==1) ? 0 : Dynamic> m_startRow;\n    const internal::variable_if_dynamic<StorageIndex, (XprType::ColsAtCompileTime == 1 && BlockCols==1) ? 0 : Dynamic> m_startCol;\n    Index m_outerStride;\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_BLOCK_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/BooleanRedux.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ALLANDANY_H\n#define EIGEN_ALLANDANY_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Derived, int UnrollCount>\nstruct all_unroller\n{\n  typedef typename Derived::ExpressionTraits Traits;\n  enum {\n    col = (UnrollCount-1) / Traits::RowsAtCompileTime,\n    row = (UnrollCount-1) % Traits::RowsAtCompileTime\n  };\n\n  static inline bool run(const Derived &mat)\n  {\n    return all_unroller<Derived, UnrollCount-1>::run(mat) && mat.coeff(row, col);\n  }\n};\n\ntemplate<typename Derived>\nstruct all_unroller<Derived, 0>\n{\n  static inline bool run(const Derived &/*mat*/) { return true; }\n};\n\ntemplate<typename Derived>\nstruct all_unroller<Derived, Dynamic>\n{\n  static inline bool run(const Derived &) { return false; }\n};\n\ntemplate<typename Derived, int UnrollCount>\nstruct any_unroller\n{\n  typedef typename Derived::ExpressionTraits Traits;\n  enum {\n    col = (UnrollCount-1) / Traits::RowsAtCompileTime,\n    row = (UnrollCount-1) % Traits::RowsAtCompileTime\n  };\n  \n  static inline bool run(const Derived &mat)\n  {\n    return any_unroller<Derived, UnrollCount-1>::run(mat) || mat.coeff(row, col);\n  }\n};\n\ntemplate<typename Derived>\nstruct any_unroller<Derived, 0>\n{\n  static inline bool run(const Derived & /*mat*/) { return false; }\n};\n\ntemplate<typename Derived>\nstruct any_unroller<Derived, Dynamic>\n{\n  static inline bool run(const Derived &) { return false; }\n};\n\n} // end namespace internal\n\n/** \\returns true if all coefficients are true\n  *\n  * Example: \\include MatrixBase_all.cpp\n  * Output: \\verbinclude MatrixBase_all.out\n  *\n  * \\sa any(), Cwise::operator<()\n  */\ntemplate<typename Derived>\ninline bool DenseBase<Derived>::all() const\n{\n  typedef internal::evaluator<Derived> Evaluator;\n  enum {\n    unroll = SizeAtCompileTime != Dynamic\n          && SizeAtCompileTime * (Evaluator::CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT\n  };\n  Evaluator evaluator(derived());\n  if(unroll)\n    return internal::all_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic>::run(evaluator);\n  else\n  {\n    for(Index j = 0; j < cols(); ++j)\n      for(Index i = 0; i < rows(); ++i)\n        if (!evaluator.coeff(i, j)) return false;\n    return true;\n  }\n}\n\n/** \\returns true if at least one coefficient is true\n  *\n  * \\sa all()\n  */\ntemplate<typename Derived>\ninline bool DenseBase<Derived>::any() const\n{\n  typedef internal::evaluator<Derived> Evaluator;\n  enum {\n    unroll = SizeAtCompileTime != Dynamic\n          && SizeAtCompileTime * (Evaluator::CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT\n  };\n  Evaluator evaluator(derived());\n  if(unroll)\n    return internal::any_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic>::run(evaluator);\n  else\n  {\n    for(Index j = 0; j < cols(); ++j)\n      for(Index i = 0; i < rows(); ++i)\n        if (evaluator.coeff(i, j)) return true;\n    return false;\n  }\n}\n\n/** \\returns the number of coefficients which evaluate to true\n  *\n  * \\sa all(), any()\n  */\ntemplate<typename Derived>\ninline Eigen::Index DenseBase<Derived>::count() const\n{\n  return derived().template cast<bool>().template cast<Index>().sum();\n}\n\n/** \\returns true is \\c *this contains at least one Not A Number (NaN).\n  *\n  * \\sa allFinite()\n  */\ntemplate<typename Derived>\ninline bool DenseBase<Derived>::hasNaN() const\n{\n#if EIGEN_COMP_MSVC || (defined __FAST_MATH__)\n  return derived().array().isNaN().any();\n#else\n  return !((derived().array()==derived().array()).all());\n#endif\n}\n\n/** \\returns true if \\c *this contains only finite numbers, i.e., no NaN and no +/-INF values.\n  *\n  * \\sa hasNaN()\n  */\ntemplate<typename Derived>\ninline bool DenseBase<Derived>::allFinite() const\n{\n#if EIGEN_COMP_MSVC || (defined __FAST_MATH__)\n  return derived().array().isFinite().all();\n#else\n  return !((derived()-derived()).hasNaN());\n#endif\n}\n    \n} // end namespace Eigen\n\n#endif // EIGEN_ALLANDANY_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/CommaInitializer.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COMMAINITIALIZER_H\n#define EIGEN_COMMAINITIALIZER_H\n\nnamespace Eigen { \n\n/** \\class CommaInitializer\n  * \\ingroup Core_Module\n  *\n  * \\brief Helper class used by the comma initializer operator\n  *\n  * This class is internally used to implement the comma initializer feature. It is\n  * the return type of MatrixBase::operator<<, and most of the time this is the only\n  * way it is used.\n  *\n  * \\sa \\blank \\ref MatrixBaseCommaInitRef \"MatrixBase::operator<<\", CommaInitializer::finished()\n  */\ntemplate<typename XprType>\nstruct CommaInitializer\n{\n  typedef typename XprType::Scalar Scalar;\n\n  EIGEN_DEVICE_FUNC\n  inline CommaInitializer(XprType& xpr, const Scalar& s)\n    : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1)\n  {\n    m_xpr.coeffRef(0,0) = s;\n  }\n\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC\n  inline CommaInitializer(XprType& xpr, const DenseBase<OtherDerived>& other)\n    : m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows())\n  {\n    m_xpr.block(0, 0, other.rows(), other.cols()) = other;\n  }\n\n  /* Copy/Move constructor which transfers ownership. This is crucial in \n   * absence of return value optimization to avoid assertions during destruction. */\n  // FIXME in C++11 mode this could be replaced by a proper RValue constructor\n  EIGEN_DEVICE_FUNC\n  inline CommaInitializer(const CommaInitializer& o)\n  : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) {\n    // Mark original object as finished. In absence of R-value references we need to const_cast:\n    const_cast<CommaInitializer&>(o).m_row = m_xpr.rows();\n    const_cast<CommaInitializer&>(o).m_col = m_xpr.cols();\n    const_cast<CommaInitializer&>(o).m_currentBlockRows = 0;\n  }\n\n  /* inserts a scalar value in the target matrix */\n  EIGEN_DEVICE_FUNC\n  CommaInitializer& operator,(const Scalar& s)\n  {\n    if (m_col==m_xpr.cols())\n    {\n      m_row+=m_currentBlockRows;\n      m_col = 0;\n      m_currentBlockRows = 1;\n      eigen_assert(m_row<m_xpr.rows()\n        && \"Too many rows passed to comma initializer (operator<<)\");\n    }\n    eigen_assert(m_col<m_xpr.cols()\n      && \"Too many coefficients passed to comma initializer (operator<<)\");\n    eigen_assert(m_currentBlockRows==1);\n    m_xpr.coeffRef(m_row, m_col++) = s;\n    return *this;\n  }\n\n  /* inserts a matrix expression in the target matrix */\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC\n  CommaInitializer& operator,(const DenseBase<OtherDerived>& other)\n  {\n    if (m_col==m_xpr.cols() && (other.cols()!=0 || other.rows()!=m_currentBlockRows))\n    {\n      m_row+=m_currentBlockRows;\n      m_col = 0;\n      m_currentBlockRows = other.rows();\n      eigen_assert(m_row+m_currentBlockRows<=m_xpr.rows()\n        && \"Too many rows passed to comma initializer (operator<<)\");\n    }\n    eigen_assert((m_col + other.cols() <= m_xpr.cols())\n      && \"Too many coefficients passed to comma initializer (operator<<)\");\n    eigen_assert(m_currentBlockRows==other.rows());\n    m_xpr.template block<OtherDerived::RowsAtCompileTime, OtherDerived::ColsAtCompileTime>\n                    (m_row, m_col, other.rows(), other.cols()) = other;\n    m_col += other.cols();\n    return *this;\n  }\n\n  EIGEN_DEVICE_FUNC\n  inline ~CommaInitializer()\n#if defined VERIFY_RAISES_ASSERT && (!defined EIGEN_NO_ASSERTION_CHECKING) && defined EIGEN_EXCEPTIONS\n  EIGEN_EXCEPTION_SPEC(Eigen::eigen_assert_exception)\n#endif\n  {\n      finished();\n  }\n\n  /** \\returns the built matrix once all its coefficients have been set.\n    * Calling finished is 100% optional. Its purpose is to write expressions\n    * like this:\n    * \\code\n    * quaternion.fromRotationMatrix((Matrix3f() << axis0, axis1, axis2).finished());\n    * \\endcode\n    */\n  EIGEN_DEVICE_FUNC\n  inline XprType& finished() {\n      eigen_assert(((m_row+m_currentBlockRows) == m_xpr.rows() || m_xpr.cols() == 0)\n           && m_col == m_xpr.cols()\n           && \"Too few coefficients passed to comma initializer (operator<<)\");\n      return m_xpr;\n  }\n\n  XprType& m_xpr;           // target expression\n  Index m_row;              // current row id\n  Index m_col;              // current col id\n  Index m_currentBlockRows; // current block height\n};\n\n/** \\anchor MatrixBaseCommaInitRef\n  * Convenient operator to set the coefficients of a matrix.\n  *\n  * The coefficients must be provided in a row major order and exactly match\n  * the size of the matrix. Otherwise an assertion is raised.\n  *\n  * Example: \\include MatrixBase_set.cpp\n  * Output: \\verbinclude MatrixBase_set.out\n  * \n  * \\note According the c++ standard, the argument expressions of this comma initializer are evaluated in arbitrary order.\n  *\n  * \\sa CommaInitializer::finished(), class CommaInitializer\n  */\ntemplate<typename Derived>\ninline CommaInitializer<Derived> DenseBase<Derived>::operator<< (const Scalar& s)\n{\n  return CommaInitializer<Derived>(*static_cast<Derived*>(this), s);\n}\n\n/** \\sa operator<<(const Scalar&) */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\ninline CommaInitializer<Derived>\nDenseBase<Derived>::operator<<(const DenseBase<OtherDerived>& other)\n{\n  return CommaInitializer<Derived>(*static_cast<Derived *>(this), other);\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_COMMAINITIALIZER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/ConditionEstimator.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2016 Rasmus Munk Larsen (rmlarsen@google.com)\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CONDITIONESTIMATOR_H\n#define EIGEN_CONDITIONESTIMATOR_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate <typename Vector, typename RealVector, bool IsComplex>\nstruct rcond_compute_sign {\n  static inline Vector run(const Vector& v) {\n    const RealVector v_abs = v.cwiseAbs();\n    return (v_abs.array() == static_cast<typename Vector::RealScalar>(0))\n            .select(Vector::Ones(v.size()), v.cwiseQuotient(v_abs));\n  }\n};\n\n// Partial specialization to avoid elementwise division for real vectors.\ntemplate <typename Vector>\nstruct rcond_compute_sign<Vector, Vector, false> {\n  static inline Vector run(const Vector& v) {\n    return (v.array() < static_cast<typename Vector::RealScalar>(0))\n           .select(-Vector::Ones(v.size()), Vector::Ones(v.size()));\n  }\n};\n\n/**\n  * \\returns an estimate of ||inv(matrix)||_1 given a decomposition of\n  * \\a matrix that implements .solve() and .adjoint().solve() methods.\n  *\n  * This function implements Algorithms 4.1 and 5.1 from\n  *   http://www.maths.manchester.ac.uk/~higham/narep/narep135.pdf\n  * which also forms the basis for the condition number estimators in\n  * LAPACK. Since at most 10 calls to the solve method of dec are\n  * performed, the total cost is O(dims^2), as opposed to O(dims^3)\n  * needed to compute the inverse matrix explicitly.\n  *\n  * The most common usage is in estimating the condition number\n  * ||matrix||_1 * ||inv(matrix)||_1. The first term ||matrix||_1 can be\n  * computed directly in O(n^2) operations.\n  *\n  * Supports the following decompositions: FullPivLU, PartialPivLU, LDLT, and\n  * LLT.\n  *\n  * \\sa FullPivLU, PartialPivLU, LDLT, LLT.\n  */\ntemplate <typename Decomposition>\ntypename Decomposition::RealScalar rcond_invmatrix_L1_norm_estimate(const Decomposition& dec)\n{\n  typedef typename Decomposition::MatrixType MatrixType;\n  typedef typename Decomposition::Scalar Scalar;\n  typedef typename Decomposition::RealScalar RealScalar;\n  typedef typename internal::plain_col_type<MatrixType>::type Vector;\n  typedef typename internal::plain_col_type<MatrixType, RealScalar>::type RealVector;\n  const bool is_complex = (NumTraits<Scalar>::IsComplex != 0);\n\n  eigen_assert(dec.rows() == dec.cols());\n  const Index n = dec.rows();\n  if (n == 0)\n    return 0;\n\n  // Disable Index to float conversion warning\n#ifdef __INTEL_COMPILER\n  #pragma warning push\n  #pragma warning ( disable : 2259 )\n#endif\n  Vector v = dec.solve(Vector::Ones(n) / Scalar(n));\n#ifdef __INTEL_COMPILER\n  #pragma warning pop\n#endif\n\n  // lower_bound is a lower bound on\n  //   ||inv(matrix)||_1  = sup_v ||inv(matrix) v||_1 / ||v||_1\n  // and is the objective maximized by the (\"super-\") gradient ascent\n  // algorithm below.\n  RealScalar lower_bound = v.template lpNorm<1>();\n  if (n == 1)\n    return lower_bound;\n\n  // Gradient ascent algorithm follows: We know that the optimum is achieved at\n  // one of the simplices v = e_i, so in each iteration we follow a\n  // super-gradient to move towards the optimal one.\n  RealScalar old_lower_bound = lower_bound;\n  Vector sign_vector(n);\n  Vector old_sign_vector;\n  Index v_max_abs_index = -1;\n  Index old_v_max_abs_index = v_max_abs_index;\n  for (int k = 0; k < 4; ++k)\n  {\n    sign_vector = internal::rcond_compute_sign<Vector, RealVector, is_complex>::run(v);\n    if (k > 0 && !is_complex && sign_vector == old_sign_vector) {\n      // Break if the solution stagnated.\n      break;\n    }\n    // v_max_abs_index = argmax |real( inv(matrix)^T * sign_vector )|\n    v = dec.adjoint().solve(sign_vector);\n    v.real().cwiseAbs().maxCoeff(&v_max_abs_index);\n    if (v_max_abs_index == old_v_max_abs_index) {\n      // Break if the solution stagnated.\n      break;\n    }\n    // Move to the new simplex e_j, where j = v_max_abs_index.\n    v = dec.solve(Vector::Unit(n, v_max_abs_index));  // v = inv(matrix) * e_j.\n    lower_bound = v.template lpNorm<1>();\n    if (lower_bound <= old_lower_bound) {\n      // Break if the gradient step did not increase the lower_bound.\n      break;\n    }\n    if (!is_complex) {\n      old_sign_vector = sign_vector;\n    }\n    old_v_max_abs_index = v_max_abs_index;\n    old_lower_bound = lower_bound;\n  }\n  // The following calculates an independent estimate of ||matrix||_1 by\n  // multiplying matrix by a vector with entries of slowly increasing\n  // magnitude and alternating sign:\n  //   v_i = (-1)^{i} (1 + (i / (dim-1))), i = 0,...,dim-1.\n  // This improvement to Hager's algorithm above is due to Higham. It was\n  // added to make the algorithm more robust in certain corner cases where\n  // large elements in the matrix might otherwise escape detection due to\n  // exact cancellation (especially when op and op_adjoint correspond to a\n  // sequence of backsubstitutions and permutations), which could cause\n  // Hager's algorithm to vastly underestimate ||matrix||_1.\n  Scalar alternating_sign(RealScalar(1));\n  for (Index i = 0; i < n; ++i) {\n    // The static_cast is needed when Scalar is a complex and RealScalar implements expression templates\n    v[i] = alternating_sign * static_cast<RealScalar>(RealScalar(1) + (RealScalar(i) / (RealScalar(n - 1))));\n    alternating_sign = -alternating_sign;\n  }\n  v = dec.solve(v);\n  const RealScalar alternate_lower_bound = (2 * v.template lpNorm<1>()) / (3 * RealScalar(n));\n  return numext::maxi(lower_bound, alternate_lower_bound);\n}\n\n/** \\brief Reciprocal condition number estimator.\n  *\n  * Computing a decomposition of a dense matrix takes O(n^3) operations, while\n  * this method estimates the condition number quickly and reliably in O(n^2)\n  * operations.\n  *\n  * \\returns an estimate of the reciprocal condition number\n  * (1 / (||matrix||_1 * ||inv(matrix)||_1)) of matrix, given ||matrix||_1 and\n  * its decomposition. Supports the following decompositions: FullPivLU,\n  * PartialPivLU, LDLT, and LLT.\n  *\n  * \\sa FullPivLU, PartialPivLU, LDLT, LLT.\n  */\ntemplate <typename Decomposition>\ntypename Decomposition::RealScalar\nrcond_estimate_helper(typename Decomposition::RealScalar matrix_norm, const Decomposition& dec)\n{\n  typedef typename Decomposition::RealScalar RealScalar;\n  eigen_assert(dec.rows() == dec.cols());\n  if (dec.rows() == 0)              return RealScalar(1);\n  if (matrix_norm == RealScalar(0)) return RealScalar(0);\n  if (dec.rows() == 1)              return RealScalar(1);\n  const RealScalar inverse_matrix_norm = rcond_invmatrix_L1_norm_estimate(dec);\n  return (inverse_matrix_norm == RealScalar(0) ? RealScalar(0)\n                                               : (RealScalar(1) / inverse_matrix_norm) / matrix_norm);\n}\n\n}  // namespace internal\n\n}  // namespace Eigen\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/CoreEvaluators.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2011-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2011-2012 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n\n#ifndef EIGEN_COREEVALUATORS_H\n#define EIGEN_COREEVALUATORS_H\n\nnamespace Eigen {\n  \nnamespace internal {\n\n// This class returns the evaluator kind from the expression storage kind.\n// Default assumes index based accessors\ntemplate<typename StorageKind>\nstruct storage_kind_to_evaluator_kind {\n  typedef IndexBased Kind;\n};\n\n// This class returns the evaluator shape from the expression storage kind.\n// It can be Dense, Sparse, Triangular, Diagonal, SelfAdjoint, Band, etc.\ntemplate<typename StorageKind> struct storage_kind_to_shape;\n\ntemplate<> struct storage_kind_to_shape<Dense>                  { typedef DenseShape Shape;           };\ntemplate<> struct storage_kind_to_shape<SolverStorage>          { typedef SolverShape Shape;           };\ntemplate<> struct storage_kind_to_shape<PermutationStorage>     { typedef PermutationShape Shape;     };\ntemplate<> struct storage_kind_to_shape<TranspositionsStorage>  { typedef TranspositionsShape Shape;  };\n\n// Evaluators have to be specialized with respect to various criteria such as:\n//  - storage/structure/shape\n//  - scalar type\n//  - etc.\n// Therefore, we need specialization of evaluator providing additional template arguments for each kind of evaluators.\n// We currently distinguish the following kind of evaluators:\n// - unary_evaluator    for expressions taking only one arguments (CwiseUnaryOp, CwiseUnaryView, Transpose, MatrixWrapper, ArrayWrapper, Reverse, Replicate)\n// - binary_evaluator   for expression taking two arguments (CwiseBinaryOp)\n// - ternary_evaluator   for expression taking three arguments (CwiseTernaryOp)\n// - product_evaluator  for linear algebra products (Product); special case of binary_evaluator because it requires additional tags for dispatching.\n// - mapbase_evaluator  for Map, Block, Ref\n// - block_evaluator    for Block (special dispatching to a mapbase_evaluator or unary_evaluator)\n\ntemplate< typename T,\n          typename Arg1Kind   = typename evaluator_traits<typename T::Arg1>::Kind,\n          typename Arg2Kind   = typename evaluator_traits<typename T::Arg2>::Kind,\n          typename Arg3Kind   = typename evaluator_traits<typename T::Arg3>::Kind,\n          typename Arg1Scalar = typename traits<typename T::Arg1>::Scalar,\n          typename Arg2Scalar = typename traits<typename T::Arg2>::Scalar,\n          typename Arg3Scalar = typename traits<typename T::Arg3>::Scalar> struct ternary_evaluator;\n\ntemplate< typename T,\n          typename LhsKind   = typename evaluator_traits<typename T::Lhs>::Kind,\n          typename RhsKind   = typename evaluator_traits<typename T::Rhs>::Kind,\n          typename LhsScalar = typename traits<typename T::Lhs>::Scalar,\n          typename RhsScalar = typename traits<typename T::Rhs>::Scalar> struct binary_evaluator;\n\ntemplate< typename T,\n          typename Kind   = typename evaluator_traits<typename T::NestedExpression>::Kind,\n          typename Scalar = typename T::Scalar> struct unary_evaluator;\n          \n// evaluator_traits<T> contains traits for evaluator<T> \n\ntemplate<typename T>\nstruct evaluator_traits_base\n{\n  // by default, get evaluator kind and shape from storage\n  typedef typename storage_kind_to_evaluator_kind<typename traits<T>::StorageKind>::Kind Kind;\n  typedef typename storage_kind_to_shape<typename traits<T>::StorageKind>::Shape Shape;\n};\n\n// Default evaluator traits\ntemplate<typename T>\nstruct evaluator_traits : public evaluator_traits_base<T>\n{\n};\n\ntemplate<typename T, typename Shape = typename evaluator_traits<T>::Shape >\nstruct evaluator_assume_aliasing {\n  static const bool value = false;\n};\n\n// By default, we assume a unary expression:\ntemplate<typename T>\nstruct evaluator : public unary_evaluator<T>\n{\n  typedef unary_evaluator<T> Base;\n  EIGEN_DEVICE_FUNC explicit evaluator(const T& xpr) : Base(xpr) {}\n};\n\n\n// TODO: Think about const-correctness\ntemplate<typename T>\nstruct evaluator<const T>\n  : evaluator<T>\n{\n  EIGEN_DEVICE_FUNC\n  explicit evaluator(const T& xpr) : evaluator<T>(xpr) {}\n};\n\n// ---------- base class for all evaluators ----------\n\ntemplate<typename ExpressionType>\nstruct evaluator_base : public noncopyable\n{\n  // TODO that's not very nice to have to propagate all these traits. They are currently only needed to handle outer,inner indices.\n  typedef traits<ExpressionType> ExpressionTraits;\n  \n  enum {\n    Alignment = 0\n  };\n};\n\n// -------------------- Matrix and Array --------------------\n//\n// evaluator<PlainObjectBase> is a common base class for the\n// Matrix and Array evaluators.\n// Here we directly specialize evaluator. This is not really a unary expression, and it is, by definition, dense,\n// so no need for more sophisticated dispatching.\n\ntemplate<typename Derived>\nstruct evaluator<PlainObjectBase<Derived> >\n  : evaluator_base<Derived>\n{\n  typedef PlainObjectBase<Derived> PlainObjectType;\n  typedef typename PlainObjectType::Scalar Scalar;\n  typedef typename PlainObjectType::CoeffReturnType CoeffReturnType;\n\n  enum {\n    IsRowMajor = PlainObjectType::IsRowMajor,\n    IsVectorAtCompileTime = PlainObjectType::IsVectorAtCompileTime,\n    RowsAtCompileTime = PlainObjectType::RowsAtCompileTime,\n    ColsAtCompileTime = PlainObjectType::ColsAtCompileTime,\n    \n    CoeffReadCost = NumTraits<Scalar>::ReadCost,\n    Flags = traits<Derived>::EvaluatorFlags,\n    Alignment = traits<Derived>::Alignment\n  };\n  \n  EIGEN_DEVICE_FUNC evaluator()\n    : m_data(0),\n      m_outerStride(IsVectorAtCompileTime  ? 0 \n                                           : int(IsRowMajor) ? ColsAtCompileTime \n                                           : RowsAtCompileTime)\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n  \n  EIGEN_DEVICE_FUNC explicit evaluator(const PlainObjectType& m)\n    : m_data(m.data()), m_outerStride(IsVectorAtCompileTime ? 0 : m.outerStride()) \n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  {\n    if (IsRowMajor)\n      return m_data[row * m_outerStride.value() + col];\n    else\n      return m_data[row + col * m_outerStride.value()];\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    return m_data[index];\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index row, Index col)\n  {\n    if (IsRowMajor)\n      return const_cast<Scalar*>(m_data)[row * m_outerStride.value() + col];\n    else\n      return const_cast<Scalar*>(m_data)[row + col * m_outerStride.value()];\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index index)\n  {\n    return const_cast<Scalar*>(m_data)[index];\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index row, Index col) const\n  {\n    if (IsRowMajor)\n      return ploadt<PacketType, LoadMode>(m_data + row * m_outerStride.value() + col);\n    else\n      return ploadt<PacketType, LoadMode>(m_data + row + col * m_outerStride.value());\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index index) const\n  {\n    return ploadt<PacketType, LoadMode>(m_data + index);\n  }\n\n  template<int StoreMode,typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index row, Index col, const PacketType& x)\n  {\n    if (IsRowMajor)\n      return pstoret<Scalar, PacketType, StoreMode>\n\t            (const_cast<Scalar*>(m_data) + row * m_outerStride.value() + col, x);\n    else\n      return pstoret<Scalar, PacketType, StoreMode>\n                    (const_cast<Scalar*>(m_data) + row + col * m_outerStride.value(), x);\n  }\n\n  template<int StoreMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index index, const PacketType& x)\n  {\n    return pstoret<Scalar, PacketType, StoreMode>(const_cast<Scalar*>(m_data) + index, x);\n  }\n\nprotected:\n  const Scalar *m_data;\n\n  // We do not need to know the outer stride for vectors\n  variable_if_dynamic<Index, IsVectorAtCompileTime  ? 0 \n                                                    : int(IsRowMajor) ? ColsAtCompileTime \n                                                    : RowsAtCompileTime> m_outerStride;\n};\n\ntemplate<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>\nstruct evaluator<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> >\n  : evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > >\n{\n  typedef Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType;\n  \n  EIGEN_DEVICE_FUNC evaluator() {}\n\n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& m)\n    : evaluator<PlainObjectBase<XprType> >(m) \n  { }\n};\n\ntemplate<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>\nstruct evaluator<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> >\n  : evaluator<PlainObjectBase<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > >\n{\n  typedef Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType;\n\n  EIGEN_DEVICE_FUNC evaluator() {}\n  \n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& m)\n    : evaluator<PlainObjectBase<XprType> >(m) \n  { }\n};\n\n// -------------------- Transpose --------------------\n\ntemplate<typename ArgType>\nstruct unary_evaluator<Transpose<ArgType>, IndexBased>\n  : evaluator_base<Transpose<ArgType> >\n{\n  typedef Transpose<ArgType> XprType;\n  \n  enum {\n    CoeffReadCost = evaluator<ArgType>::CoeffReadCost,    \n    Flags = evaluator<ArgType>::Flags ^ RowMajorBit,\n    Alignment = evaluator<ArgType>::Alignment\n  };\n\n  EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& t) : m_argImpl(t.nestedExpression()) {}\n\n  typedef typename XprType::Scalar Scalar;\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  {\n    return m_argImpl.coeff(col, row);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    return m_argImpl.coeff(index);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index row, Index col)\n  {\n    return m_argImpl.coeffRef(col, row);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  typename XprType::Scalar& coeffRef(Index index)\n  {\n    return m_argImpl.coeffRef(index);\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index row, Index col) const\n  {\n    return m_argImpl.template packet<LoadMode,PacketType>(col, row);\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index index) const\n  {\n    return m_argImpl.template packet<LoadMode,PacketType>(index);\n  }\n\n  template<int StoreMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index row, Index col, const PacketType& x)\n  {\n    m_argImpl.template writePacket<StoreMode,PacketType>(col, row, x);\n  }\n\n  template<int StoreMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index index, const PacketType& x)\n  {\n    m_argImpl.template writePacket<StoreMode,PacketType>(index, x);\n  }\n\nprotected:\n  evaluator<ArgType> m_argImpl;\n};\n\n// -------------------- CwiseNullaryOp --------------------\n// Like Matrix and Array, this is not really a unary expression, so we directly specialize evaluator.\n// Likewise, there is not need to more sophisticated dispatching here.\n\ntemplate<typename Scalar,typename NullaryOp,\n         bool has_nullary = has_nullary_operator<NullaryOp>::value,\n         bool has_unary   = has_unary_operator<NullaryOp>::value,\n         bool has_binary  = has_binary_operator<NullaryOp>::value>\nstruct nullary_wrapper\n{\n  template <typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j) const { return op(i,j); }\n  template <typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const { return op(i); }\n\n  template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j) const { return op.template packetOp<T>(i,j); }\n  template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i) const { return op.template packetOp<T>(i); }\n};\n\ntemplate<typename Scalar,typename NullaryOp>\nstruct nullary_wrapper<Scalar,NullaryOp,true,false,false>\n{\n  template <typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType=0, IndexType=0) const { return op(); }\n  template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType=0, IndexType=0) const { return op.template packetOp<T>(); }\n};\n\ntemplate<typename Scalar,typename NullaryOp>\nstruct nullary_wrapper<Scalar,NullaryOp,false,false,true>\n{\n  template <typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j=0) const { return op(i,j); }\n  template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j=0) const { return op.template packetOp<T>(i,j); }\n};\n\n// We need the following specialization for vector-only functors assigned to a runtime vector,\n// for instance, using linspace and assigning a RowVectorXd to a MatrixXd or even a row of a MatrixXd.\n// In this case, i==0 and j is used for the actual iteration.\ntemplate<typename Scalar,typename NullaryOp>\nstruct nullary_wrapper<Scalar,NullaryOp,false,true,false>\n{\n  template <typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j) const {\n    eigen_assert(i==0 || j==0);\n    return op(i+j);\n  }\n  template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j) const {\n    eigen_assert(i==0 || j==0);\n    return op.template packetOp<T>(i+j);\n  }\n\n  template <typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const { return op(i); }\n  template <typename T, typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i) const { return op.template packetOp<T>(i); }\n};\n\ntemplate<typename Scalar,typename NullaryOp>\nstruct nullary_wrapper<Scalar,NullaryOp,false,false,false> {};\n\n#if 0 && EIGEN_COMP_MSVC>0\n// Disable this ugly workaround. This is now handled in traits<Ref>::match,\n// but this piece of code might still become handly if some other weird compilation\n// erros pop up again.\n\n// MSVC exhibits a weird compilation error when\n// compiling:\n//    Eigen::MatrixXf A = MatrixXf::Random(3,3);\n//    Ref<const MatrixXf> R = 2.f*A;\n// and that has_*ary_operator<scalar_constant_op<float>> have not been instantiated yet.\n// The \"problem\" is that evaluator<2.f*A> is instantiated by traits<Ref>::match<2.f*A>\n// and at that time has_*ary_operator<T> returns true regardless of T.\n// Then nullary_wrapper is badly instantiated as nullary_wrapper<.,.,true,true,true>.\n// The trick is thus to defer the proper instantiation of nullary_wrapper when coeff(),\n// and packet() are really instantiated as implemented below:\n\n// This is a simple wrapper around Index to enforce the re-instantiation of\n// has_*ary_operator when needed.\ntemplate<typename T> struct nullary_wrapper_workaround_msvc {\n  nullary_wrapper_workaround_msvc(const T&);\n  operator T()const;\n};\n\ntemplate<typename Scalar,typename NullaryOp>\nstruct nullary_wrapper<Scalar,NullaryOp,true,true,true>\n{\n  template <typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j) const {\n    return nullary_wrapper<Scalar,NullaryOp,\n    has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n    has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n    has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().operator()(op,i,j);\n  }\n  template <typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const {\n    return nullary_wrapper<Scalar,NullaryOp,\n    has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n    has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n    has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().operator()(op,i);\n  }\n\n  template <typename T, typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j) const {\n    return nullary_wrapper<Scalar,NullaryOp,\n    has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n    has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n    has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().template packetOp<T>(op,i,j);\n  }\n  template <typename T, typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i) const {\n    return nullary_wrapper<Scalar,NullaryOp,\n    has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n    has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n    has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().template packetOp<T>(op,i);\n  }\n};\n#endif // MSVC workaround\n\ntemplate<typename NullaryOp, typename PlainObjectType>\nstruct evaluator<CwiseNullaryOp<NullaryOp,PlainObjectType> >\n  : evaluator_base<CwiseNullaryOp<NullaryOp,PlainObjectType> >\n{\n  typedef CwiseNullaryOp<NullaryOp,PlainObjectType> XprType;\n  typedef typename internal::remove_all<PlainObjectType>::type PlainObjectTypeCleaned;\n  \n  enum {\n    CoeffReadCost = internal::functor_traits<NullaryOp>::Cost,\n    \n    Flags = (evaluator<PlainObjectTypeCleaned>::Flags\n          &  (  HereditaryBits\n              | (functor_has_linear_access<NullaryOp>::ret  ? LinearAccessBit : 0)\n              | (functor_traits<NullaryOp>::PacketAccess    ? PacketAccessBit : 0)))\n          | (functor_traits<NullaryOp>::IsRepeatable ? 0 : EvalBeforeNestingBit),\n    Alignment = AlignedMax\n  };\n\n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& n)\n    : m_functor(n.functor()), m_wrapper()\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  template <typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(IndexType row, IndexType col) const\n  {\n    return m_wrapper(m_functor, row, col);\n  }\n\n  template <typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(IndexType index) const\n  {\n    return m_wrapper(m_functor,index);\n  }\n\n  template<int LoadMode, typename PacketType, typename IndexType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(IndexType row, IndexType col) const\n  {\n    return m_wrapper.template packetOp<PacketType>(m_functor, row, col);\n  }\n\n  template<int LoadMode, typename PacketType, typename IndexType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(IndexType index) const\n  {\n    return m_wrapper.template packetOp<PacketType>(m_functor, index);\n  }\n\nprotected:\n  const NullaryOp m_functor;\n  const internal::nullary_wrapper<CoeffReturnType,NullaryOp> m_wrapper;\n};\n\n// -------------------- CwiseUnaryOp --------------------\n\ntemplate<typename UnaryOp, typename ArgType>\nstruct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased >\n  : evaluator_base<CwiseUnaryOp<UnaryOp, ArgType> >\n{\n  typedef CwiseUnaryOp<UnaryOp, ArgType> XprType;\n  \n  enum {\n    CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<UnaryOp>::Cost,\n    \n    Flags = evaluator<ArgType>::Flags\n          & (HereditaryBits | LinearAccessBit | (functor_traits<UnaryOp>::PacketAccess ? PacketAccessBit : 0)),\n    Alignment = evaluator<ArgType>::Alignment\n  };\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  explicit unary_evaluator(const XprType& op)\n    : m_functor(op.functor()), \n      m_argImpl(op.nestedExpression()) \n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<UnaryOp>::Cost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  {\n    return m_functor(m_argImpl.coeff(row, col));\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    return m_functor(m_argImpl.coeff(index));\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index row, Index col) const\n  {\n    return m_functor.packetOp(m_argImpl.template packet<LoadMode, PacketType>(row, col));\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index index) const\n  {\n    return m_functor.packetOp(m_argImpl.template packet<LoadMode, PacketType>(index));\n  }\n\nprotected:\n  const UnaryOp m_functor;\n  evaluator<ArgType> m_argImpl;\n};\n\n// -------------------- CwiseTernaryOp --------------------\n\n// this is a ternary expression\ntemplate<typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>\nstruct evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >\n  : public ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >\n{\n  typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;\n  typedef ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > Base;\n  \n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr) {}\n};\n\ntemplate<typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>\nstruct ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>, IndexBased, IndexBased>\n  : evaluator_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >\n{\n  typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;\n  \n  enum {\n    CoeffReadCost = evaluator<Arg1>::CoeffReadCost + evaluator<Arg2>::CoeffReadCost + evaluator<Arg3>::CoeffReadCost + functor_traits<TernaryOp>::Cost,\n    \n    Arg1Flags = evaluator<Arg1>::Flags,\n    Arg2Flags = evaluator<Arg2>::Flags,\n    Arg3Flags = evaluator<Arg3>::Flags,\n    SameType = is_same<typename Arg1::Scalar,typename Arg2::Scalar>::value && is_same<typename Arg1::Scalar,typename Arg3::Scalar>::value,\n    StorageOrdersAgree = (int(Arg1Flags)&RowMajorBit)==(int(Arg2Flags)&RowMajorBit) && (int(Arg1Flags)&RowMajorBit)==(int(Arg3Flags)&RowMajorBit),\n    Flags0 = (int(Arg1Flags) | int(Arg2Flags) | int(Arg3Flags)) & (\n        HereditaryBits\n        | (int(Arg1Flags) & int(Arg2Flags) & int(Arg3Flags) &\n           ( (StorageOrdersAgree ? LinearAccessBit : 0)\n           | (functor_traits<TernaryOp>::PacketAccess && StorageOrdersAgree && SameType ? PacketAccessBit : 0)\n           )\n        )\n     ),\n    Flags = (Flags0 & ~RowMajorBit) | (Arg1Flags & RowMajorBit),\n    Alignment = EIGEN_PLAIN_ENUM_MIN(\n        EIGEN_PLAIN_ENUM_MIN(evaluator<Arg1>::Alignment, evaluator<Arg2>::Alignment),\n        evaluator<Arg3>::Alignment)\n  };\n\n  EIGEN_DEVICE_FUNC explicit ternary_evaluator(const XprType& xpr)\n    : m_functor(xpr.functor()),\n      m_arg1Impl(xpr.arg1()), \n      m_arg2Impl(xpr.arg2()), \n      m_arg3Impl(xpr.arg3())  \n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<TernaryOp>::Cost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  {\n    return m_functor(m_arg1Impl.coeff(row, col), m_arg2Impl.coeff(row, col), m_arg3Impl.coeff(row, col));\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    return m_functor(m_arg1Impl.coeff(index), m_arg2Impl.coeff(index), m_arg3Impl.coeff(index));\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index row, Index col) const\n  {\n    return m_functor.packetOp(m_arg1Impl.template packet<LoadMode,PacketType>(row, col),\n                              m_arg2Impl.template packet<LoadMode,PacketType>(row, col),\n                              m_arg3Impl.template packet<LoadMode,PacketType>(row, col));\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index index) const\n  {\n    return m_functor.packetOp(m_arg1Impl.template packet<LoadMode,PacketType>(index),\n                              m_arg2Impl.template packet<LoadMode,PacketType>(index),\n                              m_arg3Impl.template packet<LoadMode,PacketType>(index));\n  }\n\nprotected:\n  const TernaryOp m_functor;\n  evaluator<Arg1> m_arg1Impl;\n  evaluator<Arg2> m_arg2Impl;\n  evaluator<Arg3> m_arg3Impl;\n};\n\n// -------------------- CwiseBinaryOp --------------------\n\n// this is a binary expression\ntemplate<typename BinaryOp, typename Lhs, typename Rhs>\nstruct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >\n  : public binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >\n{\n  typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;\n  typedef binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > Base;\n  \n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr) {}\n};\n\ntemplate<typename BinaryOp, typename Lhs, typename Rhs>\nstruct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBased>\n  : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >\n{\n  typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;\n  \n  enum {\n    CoeffReadCost = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + functor_traits<BinaryOp>::Cost,\n    \n    LhsFlags = evaluator<Lhs>::Flags,\n    RhsFlags = evaluator<Rhs>::Flags,\n    SameType = is_same<typename Lhs::Scalar,typename Rhs::Scalar>::value,\n    StorageOrdersAgree = (int(LhsFlags)&RowMajorBit)==(int(RhsFlags)&RowMajorBit),\n    Flags0 = (int(LhsFlags) | int(RhsFlags)) & (\n        HereditaryBits\n      | (int(LhsFlags) & int(RhsFlags) &\n           ( (StorageOrdersAgree ? LinearAccessBit : 0)\n           | (functor_traits<BinaryOp>::PacketAccess && StorageOrdersAgree && SameType ? PacketAccessBit : 0)\n           )\n        )\n     ),\n    Flags = (Flags0 & ~RowMajorBit) | (LhsFlags & RowMajorBit),\n    Alignment = EIGEN_PLAIN_ENUM_MIN(evaluator<Lhs>::Alignment,evaluator<Rhs>::Alignment)\n  };\n\n  EIGEN_DEVICE_FUNC explicit binary_evaluator(const XprType& xpr)\n    : m_functor(xpr.functor()),\n      m_lhsImpl(xpr.lhs()), \n      m_rhsImpl(xpr.rhs())  \n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  {\n    return m_functor(m_lhsImpl.coeff(row, col), m_rhsImpl.coeff(row, col));\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    return m_functor(m_lhsImpl.coeff(index), m_rhsImpl.coeff(index));\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index row, Index col) const\n  {\n    return m_functor.packetOp(m_lhsImpl.template packet<LoadMode,PacketType>(row, col),\n                              m_rhsImpl.template packet<LoadMode,PacketType>(row, col));\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index index) const\n  {\n    return m_functor.packetOp(m_lhsImpl.template packet<LoadMode,PacketType>(index),\n                              m_rhsImpl.template packet<LoadMode,PacketType>(index));\n  }\n\nprotected:\n  const BinaryOp m_functor;\n  evaluator<Lhs> m_lhsImpl;\n  evaluator<Rhs> m_rhsImpl;\n};\n\n// -------------------- CwiseUnaryView --------------------\n\ntemplate<typename UnaryOp, typename ArgType>\nstruct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType>, IndexBased>\n  : evaluator_base<CwiseUnaryView<UnaryOp, ArgType> >\n{\n  typedef CwiseUnaryView<UnaryOp, ArgType> XprType;\n  \n  enum {\n    CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<UnaryOp>::Cost,\n    \n    Flags = (evaluator<ArgType>::Flags & (HereditaryBits | LinearAccessBit | DirectAccessBit)),\n    \n    Alignment = 0 // FIXME it is not very clear why alignment is necessarily lost...\n  };\n\n  EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& op)\n    : m_unaryOp(op.functor()), \n      m_argImpl(op.nestedExpression()) \n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<UnaryOp>::Cost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n\n  typedef typename XprType::Scalar Scalar;\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  {\n    return m_unaryOp(m_argImpl.coeff(row, col));\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    return m_unaryOp(m_argImpl.coeff(index));\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index row, Index col)\n  {\n    return m_unaryOp(m_argImpl.coeffRef(row, col));\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index index)\n  {\n    return m_unaryOp(m_argImpl.coeffRef(index));\n  }\n\nprotected:\n  const UnaryOp m_unaryOp;\n  evaluator<ArgType> m_argImpl;\n};\n\n// -------------------- Map --------------------\n\n// FIXME perhaps the PlainObjectType could be provided by Derived::PlainObject ?\n// but that might complicate template specialization\ntemplate<typename Derived, typename PlainObjectType>\nstruct mapbase_evaluator;\n\ntemplate<typename Derived, typename PlainObjectType>\nstruct mapbase_evaluator : evaluator_base<Derived>\n{\n  typedef Derived  XprType;\n  typedef typename XprType::PointerType PointerType;\n  typedef typename XprType::Scalar Scalar;\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n  \n  enum {\n    IsRowMajor = XprType::RowsAtCompileTime,\n    ColsAtCompileTime = XprType::ColsAtCompileTime,\n    CoeffReadCost = NumTraits<Scalar>::ReadCost\n  };\n\n  EIGEN_DEVICE_FUNC explicit mapbase_evaluator(const XprType& map)\n    : m_data(const_cast<PointerType>(map.data())),\n      m_innerStride(map.innerStride()),\n      m_outerStride(map.outerStride())\n  {\n    EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(evaluator<Derived>::Flags&PacketAccessBit, internal::inner_stride_at_compile_time<Derived>::ret==1),\n                        PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  {\n    return m_data[col * colStride() + row * rowStride()];\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    return m_data[index * m_innerStride.value()];\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index row, Index col)\n  {\n    return m_data[col * colStride() + row * rowStride()];\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index index)\n  {\n    return m_data[index * m_innerStride.value()];\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index row, Index col) const\n  {\n    PointerType ptr = m_data + row * rowStride() + col * colStride();\n    return internal::ploadt<PacketType, LoadMode>(ptr);\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index index) const\n  {\n    return internal::ploadt<PacketType, LoadMode>(m_data + index * m_innerStride.value());\n  }\n\n  template<int StoreMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index row, Index col, const PacketType& x)\n  {\n    PointerType ptr = m_data + row * rowStride() + col * colStride();\n    return internal::pstoret<Scalar, PacketType, StoreMode>(ptr, x);\n  }\n\n  template<int StoreMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index index, const PacketType& x)\n  {\n    internal::pstoret<Scalar, PacketType, StoreMode>(m_data + index * m_innerStride.value(), x);\n  }\nprotected:\n  EIGEN_DEVICE_FUNC\n  inline Index rowStride() const { return XprType::IsRowMajor ? m_outerStride.value() : m_innerStride.value(); }\n  EIGEN_DEVICE_FUNC\n  inline Index colStride() const { return XprType::IsRowMajor ? m_innerStride.value() : m_outerStride.value(); }\n\n  PointerType m_data;\n  const internal::variable_if_dynamic<Index, XprType::InnerStrideAtCompileTime> m_innerStride;\n  const internal::variable_if_dynamic<Index, XprType::OuterStrideAtCompileTime> m_outerStride;\n};\n\ntemplate<typename PlainObjectType, int MapOptions, typename StrideType> \nstruct evaluator<Map<PlainObjectType, MapOptions, StrideType> >\n  : public mapbase_evaluator<Map<PlainObjectType, MapOptions, StrideType>, PlainObjectType>\n{\n  typedef Map<PlainObjectType, MapOptions, StrideType> XprType;\n  typedef typename XprType::Scalar Scalar;\n  // TODO: should check for smaller packet types once we can handle multi-sized packet types\n  typedef typename packet_traits<Scalar>::type PacketScalar;\n  \n  enum {\n    InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0\n                             ? int(PlainObjectType::InnerStrideAtCompileTime)\n                             : int(StrideType::InnerStrideAtCompileTime),\n    OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0\n                             ? int(PlainObjectType::OuterStrideAtCompileTime)\n                             : int(StrideType::OuterStrideAtCompileTime),\n    HasNoInnerStride = InnerStrideAtCompileTime == 1,\n    HasNoOuterStride = StrideType::OuterStrideAtCompileTime == 0,\n    HasNoStride = HasNoInnerStride && HasNoOuterStride,\n    IsDynamicSize = PlainObjectType::SizeAtCompileTime==Dynamic,\n    \n    PacketAccessMask = bool(HasNoInnerStride) ? ~int(0) : ~int(PacketAccessBit),\n    LinearAccessMask = bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime) ? ~int(0) : ~int(LinearAccessBit),\n    Flags = int( evaluator<PlainObjectType>::Flags) & (LinearAccessMask&PacketAccessMask),\n    \n    Alignment = int(MapOptions)&int(AlignedMask)\n  };\n\n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& map)\n    : mapbase_evaluator<XprType, PlainObjectType>(map) \n  { }\n};\n\n// -------------------- Ref --------------------\n\ntemplate<typename PlainObjectType, int RefOptions, typename StrideType> \nstruct evaluator<Ref<PlainObjectType, RefOptions, StrideType> >\n  : public mapbase_evaluator<Ref<PlainObjectType, RefOptions, StrideType>, PlainObjectType>\n{\n  typedef Ref<PlainObjectType, RefOptions, StrideType> XprType;\n  \n  enum {\n    Flags = evaluator<Map<PlainObjectType, RefOptions, StrideType> >::Flags,\n    Alignment = evaluator<Map<PlainObjectType, RefOptions, StrideType> >::Alignment\n  };\n\n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& ref)\n    : mapbase_evaluator<XprType, PlainObjectType>(ref) \n  { }\n};\n\n// -------------------- Block --------------------\n\ntemplate<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel,\n         bool HasDirectAccess = internal::has_direct_access<ArgType>::ret> struct block_evaluator;\n         \ntemplate<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel> \nstruct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel> >\n  : block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel>\n{\n  typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;\n  typedef typename XprType::Scalar Scalar;\n  // TODO: should check for smaller packet types once we can handle multi-sized packet types\n  typedef typename packet_traits<Scalar>::type PacketScalar;\n  \n  enum {\n    CoeffReadCost = evaluator<ArgType>::CoeffReadCost,\n    \n    RowsAtCompileTime = traits<XprType>::RowsAtCompileTime,\n    ColsAtCompileTime = traits<XprType>::ColsAtCompileTime,\n    MaxRowsAtCompileTime = traits<XprType>::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = traits<XprType>::MaxColsAtCompileTime,\n    \n    ArgTypeIsRowMajor = (int(evaluator<ArgType>::Flags)&RowMajorBit) != 0,\n    IsRowMajor = (MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1) ? 1\n               : (MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1) ? 0\n               : ArgTypeIsRowMajor,\n    HasSameStorageOrderAsArgType = (IsRowMajor == ArgTypeIsRowMajor),\n    InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),\n    InnerStrideAtCompileTime = HasSameStorageOrderAsArgType\n                             ? int(inner_stride_at_compile_time<ArgType>::ret)\n                             : int(outer_stride_at_compile_time<ArgType>::ret),\n    OuterStrideAtCompileTime = HasSameStorageOrderAsArgType\n                             ? int(outer_stride_at_compile_time<ArgType>::ret)\n                             : int(inner_stride_at_compile_time<ArgType>::ret),\n    MaskPacketAccessBit = (InnerStrideAtCompileTime == 1) ? PacketAccessBit : 0,\n    \n    FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1 || (InnerPanel && (evaluator<ArgType>::Flags&LinearAccessBit))) ? LinearAccessBit : 0,    \n    FlagsRowMajorBit = XprType::Flags&RowMajorBit,\n    Flags0 = evaluator<ArgType>::Flags & ( (HereditaryBits & ~RowMajorBit) |\n                                           DirectAccessBit |\n                                           MaskPacketAccessBit),\n    Flags = Flags0 | FlagsLinearAccessBit | FlagsRowMajorBit,\n    \n    PacketAlignment = unpacket_traits<PacketScalar>::alignment,\n    Alignment0 = (InnerPanel && (OuterStrideAtCompileTime!=Dynamic) && (((OuterStrideAtCompileTime * int(sizeof(Scalar))) % int(PacketAlignment)) == 0)) ? int(PacketAlignment) : 0,\n    Alignment = EIGEN_PLAIN_ENUM_MIN(evaluator<ArgType>::Alignment, Alignment0)\n  };\n  typedef block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel> block_evaluator_type;\n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& block) : block_evaluator_type(block)\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n};\n\n// no direct-access => dispatch to a unary evaluator\ntemplate<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>\nstruct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /*HasDirectAccess*/ false>\n  : unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel> >\n{\n  typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;\n\n  EIGEN_DEVICE_FUNC explicit block_evaluator(const XprType& block)\n    : unary_evaluator<XprType>(block) \n  {}\n};\n\ntemplate<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>\nstruct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBased>\n  : evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel> >\n{\n  typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;\n\n  EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& block)\n    : m_argImpl(block.nestedExpression()), \n      m_startRow(block.startRow()), \n      m_startCol(block.startCol()) \n  { }\n \n  typedef typename XprType::Scalar Scalar;\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  enum {\n    RowsAtCompileTime = XprType::RowsAtCompileTime\n  };\n \n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  { \n    return m_argImpl.coeff(m_startRow.value() + row, m_startCol.value() + col); \n  }\n  \n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  { \n    return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index row, Index col)\n  { \n    return m_argImpl.coeffRef(m_startRow.value() + row, m_startCol.value() + col); \n  }\n  \n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index index)\n  { \n    return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);\n  }\n \n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index row, Index col) const \n  { \n    return m_argImpl.template packet<LoadMode,PacketType>(m_startRow.value() + row, m_startCol.value() + col); \n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index index) const \n  { \n    return packet<LoadMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,\n                                       RowsAtCompileTime == 1 ? index : 0);\n  }\n  \n  template<int StoreMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index row, Index col, const PacketType& x) \n  {\n    return m_argImpl.template writePacket<StoreMode,PacketType>(m_startRow.value() + row, m_startCol.value() + col, x); \n  }\n  \n  template<int StoreMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index index, const PacketType& x) \n  {\n    return writePacket<StoreMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,\n                                             RowsAtCompileTime == 1 ? index : 0,\n                                             x);\n  }\n \nprotected:\n  evaluator<ArgType> m_argImpl;\n  const variable_if_dynamic<Index, (ArgType::RowsAtCompileTime == 1 && BlockRows==1) ? 0 : Dynamic> m_startRow;\n  const variable_if_dynamic<Index, (ArgType::ColsAtCompileTime == 1 && BlockCols==1) ? 0 : Dynamic> m_startCol;\n};\n\n// TODO: This evaluator does not actually use the child evaluator; \n// all action is via the data() as returned by the Block expression.\n\ntemplate<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel> \nstruct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /* HasDirectAccess */ true>\n  : mapbase_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>,\n                      typename Block<ArgType, BlockRows, BlockCols, InnerPanel>::PlainObject>\n{\n  typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;\n  typedef typename XprType::Scalar Scalar;\n\n  EIGEN_DEVICE_FUNC explicit block_evaluator(const XprType& block)\n    : mapbase_evaluator<XprType, typename XprType::PlainObject>(block) \n  {\n    // TODO: for the 3.3 release, this should be turned to an internal assertion, but let's keep it as is for the beta lifetime\n    eigen_assert(((internal::UIntPtr(block.data()) % EIGEN_PLAIN_ENUM_MAX(1,evaluator<XprType>::Alignment)) == 0) && \"data is not aligned\");\n  }\n};\n\n\n// -------------------- Select --------------------\n// NOTE shall we introduce a ternary_evaluator?\n\n// TODO enable vectorization for Select\ntemplate<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>\nstruct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >\n  : evaluator_base<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >\n{\n  typedef Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> XprType;\n  enum {\n    CoeffReadCost = evaluator<ConditionMatrixType>::CoeffReadCost\n                  + EIGEN_PLAIN_ENUM_MAX(evaluator<ThenMatrixType>::CoeffReadCost,\n                                         evaluator<ElseMatrixType>::CoeffReadCost),\n\n    Flags = (unsigned int)evaluator<ThenMatrixType>::Flags & evaluator<ElseMatrixType>::Flags & HereditaryBits,\n    \n    Alignment = EIGEN_PLAIN_ENUM_MIN(evaluator<ThenMatrixType>::Alignment, evaluator<ElseMatrixType>::Alignment)\n  };\n\n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& select)\n    : m_conditionImpl(select.conditionMatrix()),\n      m_thenImpl(select.thenMatrix()),\n      m_elseImpl(select.elseMatrix())\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n \n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  {\n    if (m_conditionImpl.coeff(row, col))\n      return m_thenImpl.coeff(row, col);\n    else\n      return m_elseImpl.coeff(row, col);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    if (m_conditionImpl.coeff(index))\n      return m_thenImpl.coeff(index);\n    else\n      return m_elseImpl.coeff(index);\n  }\n \nprotected:\n  evaluator<ConditionMatrixType> m_conditionImpl;\n  evaluator<ThenMatrixType> m_thenImpl;\n  evaluator<ElseMatrixType> m_elseImpl;\n};\n\n\n// -------------------- Replicate --------------------\n\ntemplate<typename ArgType, int RowFactor, int ColFactor> \nstruct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor> >\n  : evaluator_base<Replicate<ArgType, RowFactor, ColFactor> >\n{\n  typedef Replicate<ArgType, RowFactor, ColFactor> XprType;\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n  enum {\n    Factor = (RowFactor==Dynamic || ColFactor==Dynamic) ? Dynamic : RowFactor*ColFactor\n  };\n  typedef typename internal::nested_eval<ArgType,Factor>::type ArgTypeNested;\n  typedef typename internal::remove_all<ArgTypeNested>::type ArgTypeNestedCleaned;\n  \n  enum {\n    CoeffReadCost = evaluator<ArgTypeNestedCleaned>::CoeffReadCost,\n    LinearAccessMask = XprType::IsVectorAtCompileTime ? LinearAccessBit : 0,\n    Flags = (evaluator<ArgTypeNestedCleaned>::Flags & (HereditaryBits|LinearAccessMask) & ~RowMajorBit) | (traits<XprType>::Flags & RowMajorBit),\n    \n    Alignment = evaluator<ArgTypeNestedCleaned>::Alignment\n  };\n\n  EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& replicate)\n    : m_arg(replicate.nestedExpression()),\n      m_argImpl(m_arg),\n      m_rows(replicate.nestedExpression().rows()),\n      m_cols(replicate.nestedExpression().cols())\n  {}\n \n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  {\n    // try to avoid using modulo; this is a pure optimization strategy\n    const Index actual_row = internal::traits<XprType>::RowsAtCompileTime==1 ? 0\n                           : RowFactor==1 ? row\n                           : row % m_rows.value();\n    const Index actual_col = internal::traits<XprType>::ColsAtCompileTime==1 ? 0\n                           : ColFactor==1 ? col\n                           : col % m_cols.value();\n    \n    return m_argImpl.coeff(actual_row, actual_col);\n  }\n  \n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    // try to avoid using modulo; this is a pure optimization strategy\n    const Index actual_index = internal::traits<XprType>::RowsAtCompileTime==1\n                                  ? (ColFactor==1 ?  index : index%m_cols.value())\n                                  : (RowFactor==1 ?  index : index%m_rows.value());\n    \n    return m_argImpl.coeff(actual_index);\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index row, Index col) const\n  {\n    const Index actual_row = internal::traits<XprType>::RowsAtCompileTime==1 ? 0\n                           : RowFactor==1 ? row\n                           : row % m_rows.value();\n    const Index actual_col = internal::traits<XprType>::ColsAtCompileTime==1 ? 0\n                           : ColFactor==1 ? col\n                           : col % m_cols.value();\n\n    return m_argImpl.template packet<LoadMode,PacketType>(actual_row, actual_col);\n  }\n  \n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index index) const\n  {\n    const Index actual_index = internal::traits<XprType>::RowsAtCompileTime==1\n                                  ? (ColFactor==1 ?  index : index%m_cols.value())\n                                  : (RowFactor==1 ?  index : index%m_rows.value());\n\n    return m_argImpl.template packet<LoadMode,PacketType>(actual_index);\n  }\n \nprotected:\n  const ArgTypeNested m_arg;\n  evaluator<ArgTypeNestedCleaned> m_argImpl;\n  const variable_if_dynamic<Index, ArgType::RowsAtCompileTime> m_rows;\n  const variable_if_dynamic<Index, ArgType::ColsAtCompileTime> m_cols;\n};\n\n\n// -------------------- PartialReduxExpr --------------------\n\ntemplate< typename ArgType, typename MemberOp, int Direction>\nstruct evaluator<PartialReduxExpr<ArgType, MemberOp, Direction> >\n  : evaluator_base<PartialReduxExpr<ArgType, MemberOp, Direction> >\n{\n  typedef PartialReduxExpr<ArgType, MemberOp, Direction> XprType;\n  typedef typename internal::nested_eval<ArgType,1>::type ArgTypeNested;\n  typedef typename internal::remove_all<ArgTypeNested>::type ArgTypeNestedCleaned;\n  typedef typename ArgType::Scalar InputScalar;\n  typedef typename XprType::Scalar Scalar;\n  enum {\n    TraversalSize = Direction==int(Vertical) ? int(ArgType::RowsAtCompileTime) :  int(ArgType::ColsAtCompileTime)\n  };\n  typedef typename MemberOp::template Cost<InputScalar,int(TraversalSize)> CostOpType;\n  enum {\n    CoeffReadCost = TraversalSize==Dynamic ? HugeCost\n                  : TraversalSize * evaluator<ArgType>::CoeffReadCost + int(CostOpType::value),\n    \n    Flags = (traits<XprType>::Flags&RowMajorBit) | (evaluator<ArgType>::Flags&(HereditaryBits&(~RowMajorBit))) | LinearAccessBit,\n    \n    Alignment = 0 // FIXME this will need to be improved once PartialReduxExpr is vectorized\n  };\n\n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType xpr)\n    : m_arg(xpr.nestedExpression()), m_functor(xpr.functor())\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(TraversalSize==Dynamic ? HugeCost : int(CostOpType::value));\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  const Scalar coeff(Index i, Index j) const\n  {\n    if (Direction==Vertical)\n      return m_functor(m_arg.col(j));\n    else\n      return m_functor(m_arg.row(i));\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  const Scalar coeff(Index index) const\n  {\n    if (Direction==Vertical)\n      return m_functor(m_arg.col(index));\n    else\n      return m_functor(m_arg.row(index));\n  }\n\nprotected:\n  typename internal::add_const_on_value_type<ArgTypeNested>::type m_arg;\n  const MemberOp m_functor;\n};\n\n\n// -------------------- MatrixWrapper and ArrayWrapper --------------------\n//\n// evaluator_wrapper_base<T> is a common base class for the\n// MatrixWrapper and ArrayWrapper evaluators.\n\ntemplate<typename XprType>\nstruct evaluator_wrapper_base\n  : evaluator_base<XprType>\n{\n  typedef typename remove_all<typename XprType::NestedExpressionType>::type ArgType;\n  enum {\n    CoeffReadCost = evaluator<ArgType>::CoeffReadCost,\n    Flags = evaluator<ArgType>::Flags,\n    Alignment = evaluator<ArgType>::Alignment\n  };\n\n  EIGEN_DEVICE_FUNC explicit evaluator_wrapper_base(const ArgType& arg) : m_argImpl(arg) {}\n\n  typedef typename ArgType::Scalar Scalar;\n  typedef typename ArgType::CoeffReturnType CoeffReturnType;\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  {\n    return m_argImpl.coeff(row, col);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    return m_argImpl.coeff(index);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index row, Index col)\n  {\n    return m_argImpl.coeffRef(row, col);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index index)\n  {\n    return m_argImpl.coeffRef(index);\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index row, Index col) const\n  {\n    return m_argImpl.template packet<LoadMode,PacketType>(row, col);\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index index) const\n  {\n    return m_argImpl.template packet<LoadMode,PacketType>(index);\n  }\n\n  template<int StoreMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index row, Index col, const PacketType& x)\n  {\n    m_argImpl.template writePacket<StoreMode>(row, col, x);\n  }\n\n  template<int StoreMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index index, const PacketType& x)\n  {\n    m_argImpl.template writePacket<StoreMode>(index, x);\n  }\n\nprotected:\n  evaluator<ArgType> m_argImpl;\n};\n\ntemplate<typename TArgType>\nstruct unary_evaluator<MatrixWrapper<TArgType> >\n  : evaluator_wrapper_base<MatrixWrapper<TArgType> >\n{\n  typedef MatrixWrapper<TArgType> XprType;\n\n  EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& wrapper)\n    : evaluator_wrapper_base<MatrixWrapper<TArgType> >(wrapper.nestedExpression())\n  { }\n};\n\ntemplate<typename TArgType>\nstruct unary_evaluator<ArrayWrapper<TArgType> >\n  : evaluator_wrapper_base<ArrayWrapper<TArgType> >\n{\n  typedef ArrayWrapper<TArgType> XprType;\n\n  EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& wrapper)\n    : evaluator_wrapper_base<ArrayWrapper<TArgType> >(wrapper.nestedExpression())\n  { }\n};\n\n\n// -------------------- Reverse --------------------\n\n// defined in Reverse.h:\ntemplate<typename PacketType, bool ReversePacket> struct reverse_packet_cond;\n\ntemplate<typename ArgType, int Direction>\nstruct unary_evaluator<Reverse<ArgType, Direction> >\n  : evaluator_base<Reverse<ArgType, Direction> >\n{\n  typedef Reverse<ArgType, Direction> XprType;\n  typedef typename XprType::Scalar Scalar;\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  enum {\n    IsRowMajor = XprType::IsRowMajor,\n    IsColMajor = !IsRowMajor,\n    ReverseRow = (Direction == Vertical)   || (Direction == BothDirections),\n    ReverseCol = (Direction == Horizontal) || (Direction == BothDirections),\n    ReversePacket = (Direction == BothDirections)\n                    || ((Direction == Vertical)   && IsColMajor)\n                    || ((Direction == Horizontal) && IsRowMajor),\n                    \n    CoeffReadCost = evaluator<ArgType>::CoeffReadCost,\n    \n    // let's enable LinearAccess only with vectorization because of the product overhead\n    // FIXME enable DirectAccess with negative strides?\n    Flags0 = evaluator<ArgType>::Flags,\n    LinearAccess = ( (Direction==BothDirections) && (int(Flags0)&PacketAccessBit) )\n                  || ((ReverseRow && XprType::ColsAtCompileTime==1) || (ReverseCol && XprType::RowsAtCompileTime==1))\n                 ? LinearAccessBit : 0,\n\n    Flags = int(Flags0) & (HereditaryBits | PacketAccessBit | LinearAccess),\n    \n    Alignment = 0 // FIXME in some rare cases, Alignment could be preserved, like a Vector4f.\n  };\n\n  EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& reverse)\n    : m_argImpl(reverse.nestedExpression()),\n      m_rows(ReverseRow ? reverse.nestedExpression().rows() : 1),\n      m_cols(ReverseCol ? reverse.nestedExpression().cols() : 1)\n  { }\n \n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index col) const\n  {\n    return m_argImpl.coeff(ReverseRow ? m_rows.value() - row - 1 : row,\n                           ReverseCol ? m_cols.value() - col - 1 : col);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    return m_argImpl.coeff(m_rows.value() * m_cols.value() - index - 1);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index row, Index col)\n  {\n    return m_argImpl.coeffRef(ReverseRow ? m_rows.value() - row - 1 : row,\n                              ReverseCol ? m_cols.value() - col - 1 : col);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index index)\n  {\n    return m_argImpl.coeffRef(m_rows.value() * m_cols.value() - index - 1);\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index row, Index col) const\n  {\n    enum {\n      PacketSize = unpacket_traits<PacketType>::size,\n      OffsetRow  = ReverseRow && IsColMajor ? PacketSize : 1,\n      OffsetCol  = ReverseCol && IsRowMajor ? PacketSize : 1\n    };\n    typedef internal::reverse_packet_cond<PacketType,ReversePacket> reverse_packet;\n    return reverse_packet::run(m_argImpl.template packet<LoadMode,PacketType>(\n                                  ReverseRow ? m_rows.value() - row - OffsetRow : row,\n                                  ReverseCol ? m_cols.value() - col - OffsetCol : col));\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  PacketType packet(Index index) const\n  {\n    enum { PacketSize = unpacket_traits<PacketType>::size };\n    return preverse(m_argImpl.template packet<LoadMode,PacketType>(m_rows.value() * m_cols.value() - index - PacketSize));\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index row, Index col, const PacketType& x)\n  {\n    // FIXME we could factorize some code with packet(i,j)\n    enum {\n      PacketSize = unpacket_traits<PacketType>::size,\n      OffsetRow  = ReverseRow && IsColMajor ? PacketSize : 1,\n      OffsetCol  = ReverseCol && IsRowMajor ? PacketSize : 1\n    };\n    typedef internal::reverse_packet_cond<PacketType,ReversePacket> reverse_packet;\n    m_argImpl.template writePacket<LoadMode>(\n                                  ReverseRow ? m_rows.value() - row - OffsetRow : row,\n                                  ReverseCol ? m_cols.value() - col - OffsetCol : col,\n                                  reverse_packet::run(x));\n  }\n\n  template<int LoadMode, typename PacketType>\n  EIGEN_STRONG_INLINE\n  void writePacket(Index index, const PacketType& x)\n  {\n    enum { PacketSize = unpacket_traits<PacketType>::size };\n    m_argImpl.template writePacket<LoadMode>\n      (m_rows.value() * m_cols.value() - index - PacketSize, preverse(x));\n  }\n \nprotected:\n  evaluator<ArgType> m_argImpl;\n\n  // If we do not reverse rows, then we do not need to know the number of rows; same for columns\n  // Nonetheless, in this case it is important to set to 1 such that the coeff(index) method works fine for vectors.\n  const variable_if_dynamic<Index, ReverseRow ? ArgType::RowsAtCompileTime : 1> m_rows;\n  const variable_if_dynamic<Index, ReverseCol ? ArgType::ColsAtCompileTime : 1> m_cols;\n};\n\n\n// -------------------- Diagonal --------------------\n\ntemplate<typename ArgType, int DiagIndex>\nstruct evaluator<Diagonal<ArgType, DiagIndex> >\n  : evaluator_base<Diagonal<ArgType, DiagIndex> >\n{\n  typedef Diagonal<ArgType, DiagIndex> XprType;\n  \n  enum {\n    CoeffReadCost = evaluator<ArgType>::CoeffReadCost,\n    \n    Flags = (unsigned int)(evaluator<ArgType>::Flags & (HereditaryBits | DirectAccessBit) & ~RowMajorBit) | LinearAccessBit,\n    \n    Alignment = 0\n  };\n\n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& diagonal)\n    : m_argImpl(diagonal.nestedExpression()),\n      m_index(diagonal.index())\n  { }\n \n  typedef typename XprType::Scalar Scalar;\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index row, Index) const\n  {\n    return m_argImpl.coeff(row + rowOffset(), row + colOffset());\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  CoeffReturnType coeff(Index index) const\n  {\n    return m_argImpl.coeff(index + rowOffset(), index + colOffset());\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index row, Index)\n  {\n    return m_argImpl.coeffRef(row + rowOffset(), row + colOffset());\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  Scalar& coeffRef(Index index)\n  {\n    return m_argImpl.coeffRef(index + rowOffset(), index + colOffset());\n  }\n\nprotected:\n  evaluator<ArgType> m_argImpl;\n  const internal::variable_if_dynamicindex<Index, XprType::DiagIndex> m_index;\n\nprivate:\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rowOffset() const { return m_index.value() > 0 ? 0 : -m_index.value(); }\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index colOffset() const { return m_index.value() > 0 ? m_index.value() : 0; }\n};\n\n\n//----------------------------------------------------------------------\n// deprecated code\n//----------------------------------------------------------------------\n\n// -------------------- EvalToTemp --------------------\n\n// expression class for evaluating nested expression to a temporary\n\ntemplate<typename ArgType> class EvalToTemp;\n\ntemplate<typename ArgType>\nstruct traits<EvalToTemp<ArgType> >\n  : public traits<ArgType>\n{ };\n\ntemplate<typename ArgType>\nclass EvalToTemp\n  : public dense_xpr_base<EvalToTemp<ArgType> >::type\n{\n public:\n \n  typedef typename dense_xpr_base<EvalToTemp>::type Base;\n  EIGEN_GENERIC_PUBLIC_INTERFACE(EvalToTemp)\n \n  explicit EvalToTemp(const ArgType& arg)\n    : m_arg(arg)\n  { }\n \n  const ArgType& arg() const\n  {\n    return m_arg;\n  }\n\n  Index rows() const \n  {\n    return m_arg.rows();\n  }\n\n  Index cols() const \n  {\n    return m_arg.cols();\n  }\n\n private:\n  const ArgType& m_arg;\n};\n \ntemplate<typename ArgType>\nstruct evaluator<EvalToTemp<ArgType> >\n  : public evaluator<typename ArgType::PlainObject>\n{\n  typedef EvalToTemp<ArgType>                   XprType;\n  typedef typename ArgType::PlainObject         PlainObject;\n  typedef evaluator<PlainObject> Base;\n  \n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr)\n    : m_result(xpr.arg())\n  {\n    ::new (static_cast<Base*>(this)) Base(m_result);\n  }\n\n  // This constructor is used when nesting an EvalTo evaluator in another evaluator\n  EIGEN_DEVICE_FUNC evaluator(const ArgType& arg)\n    : m_result(arg)\n  {\n    ::new (static_cast<Base*>(this)) Base(m_result);\n  }\n\nprotected:\n  PlainObject m_result;\n};\n\n} // namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_COREEVALUATORS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/CoreIterators.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COREITERATORS_H\n#define EIGEN_COREITERATORS_H\n\nnamespace Eigen { \n\n/* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core\n */\n\nnamespace internal {\n\ntemplate<typename XprType, typename EvaluatorKind>\nclass inner_iterator_selector;\n\n}\n\n/** \\class InnerIterator\n  * \\brief An InnerIterator allows to loop over the element of any matrix expression.\n  * \n  * \\warning To be used with care because an evaluator is constructed every time an InnerIterator iterator is constructed.\n  * \n  * TODO: add a usage example\n  */\ntemplate<typename XprType>\nclass InnerIterator\n{\nprotected:\n  typedef internal::inner_iterator_selector<XprType, typename internal::evaluator_traits<XprType>::Kind> IteratorType;\n  typedef internal::evaluator<XprType> EvaluatorType;\n  typedef typename internal::traits<XprType>::Scalar Scalar;\npublic:\n  /** Construct an iterator over the \\a outerId -th row or column of \\a xpr */\n  InnerIterator(const XprType &xpr, const Index &outerId)\n    : m_eval(xpr), m_iter(m_eval, outerId, xpr.innerSize())\n  {}\n  \n  /// \\returns the value of the current coefficient.\n  EIGEN_STRONG_INLINE Scalar value() const          { return m_iter.value(); }\n  /** Increment the iterator \\c *this to the next non-zero coefficient.\n    * Explicit zeros are not skipped over. To skip explicit zeros, see class SparseView\n    */\n  EIGEN_STRONG_INLINE InnerIterator& operator++()   { m_iter.operator++(); return *this; }\n  /// \\returns the column or row index of the current coefficient.\n  EIGEN_STRONG_INLINE Index index() const           { return m_iter.index(); }\n  /// \\returns the row index of the current coefficient.\n  EIGEN_STRONG_INLINE Index row() const             { return m_iter.row(); }\n  /// \\returns the column index of the current coefficient.\n  EIGEN_STRONG_INLINE Index col() const             { return m_iter.col(); }\n  /// \\returns \\c true if the iterator \\c *this still references a valid coefficient.\n  EIGEN_STRONG_INLINE operator bool() const         { return m_iter; }\n  \nprotected:\n  EvaluatorType m_eval;\n  IteratorType m_iter;\nprivate:\n  // If you get here, then you're not using the right InnerIterator type, e.g.:\n  //   SparseMatrix<double,RowMajor> A;\n  //   SparseMatrix<double>::InnerIterator it(A,0);\n  template<typename T> InnerIterator(const EigenBase<T>&,Index outer);\n};\n\nnamespace internal {\n\n// Generic inner iterator implementation for dense objects\ntemplate<typename XprType>\nclass inner_iterator_selector<XprType, IndexBased>\n{\nprotected:\n  typedef evaluator<XprType> EvaluatorType;\n  typedef typename traits<XprType>::Scalar Scalar;\n  enum { IsRowMajor = (XprType::Flags&RowMajorBit)==RowMajorBit };\n  \npublic:\n  EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &innerSize)\n    : m_eval(eval), m_inner(0), m_outer(outerId), m_end(innerSize)\n  {}\n\n  EIGEN_STRONG_INLINE Scalar value() const\n  {\n    return (IsRowMajor) ? m_eval.coeff(m_outer, m_inner)\n                        : m_eval.coeff(m_inner, m_outer);\n  }\n\n  EIGEN_STRONG_INLINE inner_iterator_selector& operator++() { m_inner++; return *this; }\n\n  EIGEN_STRONG_INLINE Index index() const { return m_inner; }\n  inline Index row() const { return IsRowMajor ? m_outer : index(); }\n  inline Index col() const { return IsRowMajor ? index() : m_outer; }\n\n  EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; }\n\nprotected:\n  const EvaluatorType& m_eval;\n  Index m_inner;\n  const Index m_outer;\n  const Index m_end;\n};\n\n// For iterator-based evaluator, inner-iterator is already implemented as\n// evaluator<>::InnerIterator\ntemplate<typename XprType>\nclass inner_iterator_selector<XprType, IteratorBased>\n : public evaluator<XprType>::InnerIterator\n{\nprotected:\n  typedef typename evaluator<XprType>::InnerIterator Base;\n  typedef evaluator<XprType> EvaluatorType;\n  \npublic:\n  EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &/*innerSize*/)\n    : Base(eval, outerId)\n  {}  \n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_COREITERATORS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/CwiseBinaryOp.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CWISE_BINARY_OP_H\n#define EIGEN_CWISE_BINARY_OP_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate<typename BinaryOp, typename Lhs, typename Rhs>\nstruct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >\n{\n  // we must not inherit from traits<Lhs> since it has\n  // the potential to cause problems with MSVC\n  typedef typename remove_all<Lhs>::type Ancestor;\n  typedef typename traits<Ancestor>::XprKind XprKind;\n  enum {\n    RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime,\n    ColsAtCompileTime = traits<Ancestor>::ColsAtCompileTime,\n    MaxRowsAtCompileTime = traits<Ancestor>::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = traits<Ancestor>::MaxColsAtCompileTime\n  };\n\n  // even though we require Lhs and Rhs to have the same scalar type (see CwiseBinaryOp constructor),\n  // we still want to handle the case when the result type is different.\n  typedef typename result_of<\n                     BinaryOp(\n                       const typename Lhs::Scalar&,\n                       const typename Rhs::Scalar&\n                     )\n                   >::type Scalar;\n  typedef typename cwise_promote_storage_type<typename traits<Lhs>::StorageKind,\n                                              typename traits<Rhs>::StorageKind,\n                                              BinaryOp>::ret StorageKind;\n  typedef typename promote_index_type<typename traits<Lhs>::StorageIndex,\n                                      typename traits<Rhs>::StorageIndex>::type StorageIndex;\n  typedef typename Lhs::Nested LhsNested;\n  typedef typename Rhs::Nested RhsNested;\n  typedef typename remove_reference<LhsNested>::type _LhsNested;\n  typedef typename remove_reference<RhsNested>::type _RhsNested;\n  enum {\n    Flags = cwise_promote_storage_order<typename traits<Lhs>::StorageKind,typename traits<Rhs>::StorageKind,_LhsNested::Flags & RowMajorBit,_RhsNested::Flags & RowMajorBit>::value\n  };\n};\n} // end namespace internal\n\ntemplate<typename BinaryOp, typename Lhs, typename Rhs, typename StorageKind>\nclass CwiseBinaryOpImpl;\n\n/** \\class CwiseBinaryOp\n  * \\ingroup Core_Module\n  *\n  * \\brief Generic expression where a coefficient-wise binary operator is applied to two expressions\n  *\n  * \\tparam BinaryOp template functor implementing the operator\n  * \\tparam LhsType the type of the left-hand side\n  * \\tparam RhsType the type of the right-hand side\n  *\n  * This class represents an expression  where a coefficient-wise binary operator is applied to two expressions.\n  * It is the return type of binary operators, by which we mean only those binary operators where\n  * both the left-hand side and the right-hand side are Eigen expressions.\n  * For example, the return type of matrix1+matrix2 is a CwiseBinaryOp.\n  *\n  * Most of the time, this is the only way that it is used, so you typically don't have to name\n  * CwiseBinaryOp types explicitly.\n  *\n  * \\sa MatrixBase::binaryExpr(const MatrixBase<OtherDerived> &,const CustomBinaryOp &) const, class CwiseUnaryOp, class CwiseNullaryOp\n  */\ntemplate<typename BinaryOp, typename LhsType, typename RhsType>\nclass CwiseBinaryOp : \n  public CwiseBinaryOpImpl<\n          BinaryOp, LhsType, RhsType,\n          typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,\n                                                        typename internal::traits<RhsType>::StorageKind,\n                                                        BinaryOp>::ret>,\n  internal::no_assignment_operator\n{\n  public:\n    \n    typedef typename internal::remove_all<BinaryOp>::type Functor;\n    typedef typename internal::remove_all<LhsType>::type Lhs;\n    typedef typename internal::remove_all<RhsType>::type Rhs;\n\n    typedef typename CwiseBinaryOpImpl<\n        BinaryOp, LhsType, RhsType,\n        typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,\n                                                      typename internal::traits<Rhs>::StorageKind,\n                                                      BinaryOp>::ret>::Base Base;\n    EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp)\n\n    typedef typename internal::ref_selector<LhsType>::type LhsNested;\n    typedef typename internal::ref_selector<RhsType>::type RhsNested;\n    typedef typename internal::remove_reference<LhsNested>::type _LhsNested;\n    typedef typename internal::remove_reference<RhsNested>::type _RhsNested;\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE CwiseBinaryOp(const Lhs& aLhs, const Rhs& aRhs, const BinaryOp& func = BinaryOp())\n      : m_lhs(aLhs), m_rhs(aRhs), m_functor(func)\n    {\n      EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,typename Lhs::Scalar,typename Rhs::Scalar);\n      // require the sizes to match\n      EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs, Rhs)\n      eigen_assert(aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols());\n    }\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Index rows() const {\n      // return the fixed size type if available to enable compile time optimizations\n      if (internal::traits<typename internal::remove_all<LhsNested>::type>::RowsAtCompileTime==Dynamic)\n        return m_rhs.rows();\n      else\n        return m_lhs.rows();\n    }\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Index cols() const {\n      // return the fixed size type if available to enable compile time optimizations\n      if (internal::traits<typename internal::remove_all<LhsNested>::type>::ColsAtCompileTime==Dynamic)\n        return m_rhs.cols();\n      else\n        return m_lhs.cols();\n    }\n\n    /** \\returns the left hand side nested expression */\n    EIGEN_DEVICE_FUNC\n    const _LhsNested& lhs() const { return m_lhs; }\n    /** \\returns the right hand side nested expression */\n    EIGEN_DEVICE_FUNC\n    const _RhsNested& rhs() const { return m_rhs; }\n    /** \\returns the functor representing the binary operation */\n    EIGEN_DEVICE_FUNC\n    const BinaryOp& functor() const { return m_functor; }\n\n  protected:\n    LhsNested m_lhs;\n    RhsNested m_rhs;\n    const BinaryOp m_functor;\n};\n\n// Generic API dispatcher\ntemplate<typename BinaryOp, typename Lhs, typename Rhs, typename StorageKind>\nclass CwiseBinaryOpImpl\n  : public internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type\n{\npublic:\n  typedef typename internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type Base;\n};\n\n/** replaces \\c *this by \\c *this - \\a other.\n  *\n  * \\returns a reference to \\c *this\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_STRONG_INLINE Derived &\nMatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other)\n{\n  call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\n/** replaces \\c *this by \\c *this + \\a other.\n  *\n  * \\returns a reference to \\c *this\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_STRONG_INLINE Derived &\nMatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)\n{\n  call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_CWISE_BINARY_OP_H\n\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/CwiseNullaryOp.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CWISE_NULLARY_OP_H\n#define EIGEN_CWISE_NULLARY_OP_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate<typename NullaryOp, typename PlainObjectType>\nstruct traits<CwiseNullaryOp<NullaryOp, PlainObjectType> > : traits<PlainObjectType>\n{\n  enum {\n    Flags = traits<PlainObjectType>::Flags & RowMajorBit\n  };\n};\n\n} // namespace internal\n\n/** \\class CwiseNullaryOp\n  * \\ingroup Core_Module\n  *\n  * \\brief Generic expression of a matrix where all coefficients are defined by a functor\n  *\n  * \\tparam NullaryOp template functor implementing the operator\n  * \\tparam PlainObjectType the underlying plain matrix/array type\n  *\n  * This class represents an expression of a generic nullary operator.\n  * It is the return type of the Ones(), Zero(), Constant(), Identity() and Random() methods,\n  * and most of the time this is the only way it is used.\n  *\n  * However, if you want to write a function returning such an expression, you\n  * will need to use this class.\n  *\n  * The functor NullaryOp must expose one of the following method:\n    <table class=\"manual\">\n    <tr            ><td>\\c operator()() </td><td>if the procedural generation does not depend on the coefficient entries (e.g., random numbers)</td></tr>\n    <tr class=\"alt\"><td>\\c operator()(Index i)</td><td>if the procedural generation makes sense for vectors only and that it depends on the coefficient index \\c i (e.g., linspace) </td></tr>\n    <tr            ><td>\\c operator()(Index i,Index j)</td><td>if the procedural generation depends on the matrix coordinates \\c i, \\c j (e.g., to generate a checkerboard with 0 and 1)</td></tr>\n    </table>\n  * It is also possible to expose the last two operators if the generation makes sense for matrices but can be optimized for vectors.\n  *\n  * See DenseBase::NullaryExpr(Index,const CustomNullaryOp&) for an example binding\n  * C++11 random number generators.\n  *\n  * A nullary expression can also be used to implement custom sophisticated matrix manipulations\n  * that cannot be covered by the existing set of natively supported matrix manipulations.\n  * See this \\ref TopicCustomizing_NullaryExpr \"page\" for some examples and additional explanations\n  * on the behavior of CwiseNullaryOp.\n  *\n  * \\sa class CwiseUnaryOp, class CwiseBinaryOp, DenseBase::NullaryExpr\n  */\ntemplate<typename NullaryOp, typename PlainObjectType>\nclass CwiseNullaryOp : public internal::dense_xpr_base< CwiseNullaryOp<NullaryOp, PlainObjectType> >::type, internal::no_assignment_operator\n{\n  public:\n\n    typedef typename internal::dense_xpr_base<CwiseNullaryOp>::type Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp)\n\n    EIGEN_DEVICE_FUNC\n    CwiseNullaryOp(Index rows, Index cols, const NullaryOp& func = NullaryOp())\n      : m_rows(rows), m_cols(cols), m_functor(func)\n    {\n      eigen_assert(rows >= 0\n            && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)\n            &&  cols >= 0\n            && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));\n    }\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Index rows() const { return m_rows.value(); }\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Index cols() const { return m_cols.value(); }\n\n    /** \\returns the functor representing the nullary operation */\n    EIGEN_DEVICE_FUNC\n    const NullaryOp& functor() const { return m_functor; }\n\n  protected:\n    const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_rows;\n    const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_cols;\n    const NullaryOp m_functor;\n};\n\n\n/** \\returns an expression of a matrix defined by a custom functor \\a func\n  *\n  * The parameters \\a rows and \\a cols are the number of rows and of columns of\n  * the returned matrix. Must be compatible with this MatrixBase type.\n  *\n  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,\n  * it is redundant to pass \\a rows and \\a cols as arguments, so Zero() should be used\n  * instead.\n  *\n  * The template parameter \\a CustomNullaryOp is the type of the functor.\n  *\n  * \\sa class CwiseNullaryOp\n  */\ntemplate<typename Derived>\ntemplate<typename CustomNullaryOp>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>\nDenseBase<Derived>::NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func)\n{\n  return CwiseNullaryOp<CustomNullaryOp, PlainObject>(rows, cols, func);\n}\n\n/** \\returns an expression of a matrix defined by a custom functor \\a func\n  *\n  * The parameter \\a size is the size of the returned vector.\n  * Must be compatible with this MatrixBase type.\n  *\n  * \\only_for_vectors\n  *\n  * This variant is meant to be used for dynamic-size vector types. For fixed-size types,\n  * it is redundant to pass \\a size as argument, so Zero() should be used\n  * instead.\n  *\n  * The template parameter \\a CustomNullaryOp is the type of the functor.\n  *\n  * Here is an example with C++11 random generators: \\include random_cpp11.cpp\n  * Output: \\verbinclude random_cpp11.out\n  * \n  * \\sa class CwiseNullaryOp\n  */\ntemplate<typename Derived>\ntemplate<typename CustomNullaryOp>\nEIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>\nDenseBase<Derived>::NullaryExpr(Index size, const CustomNullaryOp& func)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  if(RowsAtCompileTime == 1) return CwiseNullaryOp<CustomNullaryOp, PlainObject>(1, size, func);\n  else return CwiseNullaryOp<CustomNullaryOp, PlainObject>(size, 1, func);\n}\n\n/** \\returns an expression of a matrix defined by a custom functor \\a func\n  *\n  * This variant is only for fixed-size DenseBase types. For dynamic-size types, you\n  * need to use the variants taking size arguments.\n  *\n  * The template parameter \\a CustomNullaryOp is the type of the functor.\n  *\n  * \\sa class CwiseNullaryOp\n  */\ntemplate<typename Derived>\ntemplate<typename CustomNullaryOp>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>\nDenseBase<Derived>::NullaryExpr(const CustomNullaryOp& func)\n{\n  return CwiseNullaryOp<CustomNullaryOp, PlainObject>(RowsAtCompileTime, ColsAtCompileTime, func);\n}\n\n/** \\returns an expression of a constant matrix of value \\a value\n  *\n  * The parameters \\a rows and \\a cols are the number of rows and of columns of\n  * the returned matrix. Must be compatible with this DenseBase type.\n  *\n  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,\n  * it is redundant to pass \\a rows and \\a cols as arguments, so Zero() should be used\n  * instead.\n  *\n  * The template parameter \\a CustomNullaryOp is the type of the functor.\n  *\n  * \\sa class CwiseNullaryOp\n  */\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType\nDenseBase<Derived>::Constant(Index rows, Index cols, const Scalar& value)\n{\n  return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_constant_op<Scalar>(value));\n}\n\n/** \\returns an expression of a constant matrix of value \\a value\n  *\n  * The parameter \\a size is the size of the returned vector.\n  * Must be compatible with this DenseBase type.\n  *\n  * \\only_for_vectors\n  *\n  * This variant is meant to be used for dynamic-size vector types. For fixed-size types,\n  * it is redundant to pass \\a size as argument, so Zero() should be used\n  * instead.\n  *\n  * The template parameter \\a CustomNullaryOp is the type of the functor.\n  *\n  * \\sa class CwiseNullaryOp\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType\nDenseBase<Derived>::Constant(Index size, const Scalar& value)\n{\n  return DenseBase<Derived>::NullaryExpr(size, internal::scalar_constant_op<Scalar>(value));\n}\n\n/** \\returns an expression of a constant matrix of value \\a value\n  *\n  * This variant is only for fixed-size DenseBase types. For dynamic-size types, you\n  * need to use the variants taking size arguments.\n  *\n  * The template parameter \\a CustomNullaryOp is the type of the functor.\n  *\n  * \\sa class CwiseNullaryOp\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType\nDenseBase<Derived>::Constant(const Scalar& value)\n{\n  EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)\n  return DenseBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_constant_op<Scalar>(value));\n}\n\n/** \\deprecated because of accuracy loss. In Eigen 3.3, it is an alias for LinSpaced(Index,const Scalar&,const Scalar&)\n  *\n  * \\sa LinSpaced(Index,Scalar,Scalar), setLinSpaced(Index,const Scalar&,const Scalar&)\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType\nDenseBase<Derived>::LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar,PacketScalar>(low,high,size));\n}\n\n/** \\deprecated because of accuracy loss. In Eigen 3.3, it is an alias for LinSpaced(const Scalar&,const Scalar&)\n  *\n  * \\sa LinSpaced(Scalar,Scalar)\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType\nDenseBase<Derived>::LinSpaced(Sequential_t, const Scalar& low, const Scalar& high)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)\n  return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar,PacketScalar>(low,high,Derived::SizeAtCompileTime));\n}\n\n/**\n  * \\brief Sets a linearly spaced vector.\n  *\n  * The function generates 'size' equally spaced values in the closed interval [low,high].\n  * When size is set to 1, a vector of length 1 containing 'high' is returned.\n  *\n  * \\only_for_vectors\n  *\n  * Example: \\include DenseBase_LinSpaced.cpp\n  * Output: \\verbinclude DenseBase_LinSpaced.out\n  *\n  * For integer scalar types, an even spacing is possible if and only if the length of the range,\n  * i.e., \\c high-low is a scalar multiple of \\c size-1, or if \\c size is a scalar multiple of the\n  * number of values \\c high-low+1 (meaning each value can be repeated the same number of time).\n  * If one of these two considions is not satisfied, then \\c high is lowered to the largest value\n  * satisfying one of this constraint.\n  * Here are some examples:\n  *\n  * Example: \\include DenseBase_LinSpacedInt.cpp\n  * Output: \\verbinclude DenseBase_LinSpacedInt.out\n  *\n  * \\sa setLinSpaced(Index,const Scalar&,const Scalar&), CwiseNullaryOp\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType\nDenseBase<Derived>::LinSpaced(Index size, const Scalar& low, const Scalar& high)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar,PacketScalar>(low,high,size));\n}\n\n/**\n  * \\copydoc DenseBase::LinSpaced(Index, const Scalar&, const Scalar&)\n  * Special version for fixed size types which does not require the size parameter.\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType\nDenseBase<Derived>::LinSpaced(const Scalar& low, const Scalar& high)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)\n  return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar,PacketScalar>(low,high,Derived::SizeAtCompileTime));\n}\n\n/** \\returns true if all coefficients in this matrix are approximately equal to \\a val, to within precision \\a prec */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC bool DenseBase<Derived>::isApproxToConstant\n(const Scalar& val, const RealScalar& prec) const\n{\n  typename internal::nested_eval<Derived,1>::type self(derived());\n  for(Index j = 0; j < cols(); ++j)\n    for(Index i = 0; i < rows(); ++i)\n      if(!internal::isApprox(self.coeff(i, j), val, prec))\n        return false;\n  return true;\n}\n\n/** This is just an alias for isApproxToConstant().\n  *\n  * \\returns true if all coefficients in this matrix are approximately equal to \\a value, to within precision \\a prec */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC bool DenseBase<Derived>::isConstant\n(const Scalar& val, const RealScalar& prec) const\n{\n  return isApproxToConstant(val, prec);\n}\n\n/** Alias for setConstant(): sets all coefficients in this expression to \\a val.\n  *\n  * \\sa setConstant(), Constant(), class CwiseNullaryOp\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void DenseBase<Derived>::fill(const Scalar& val)\n{\n  setConstant(val);\n}\n\n/** Sets all coefficients in this expression to value \\a val.\n  *\n  * \\sa fill(), setConstant(Index,const Scalar&), setConstant(Index,Index,const Scalar&), setZero(), setOnes(), Constant(), class CwiseNullaryOp, setZero(), setOnes()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setConstant(const Scalar& val)\n{\n  return derived() = Constant(rows(), cols(), val);\n}\n\n/** Resizes to the given \\a size, and sets all coefficients in this expression to the given value \\a val.\n  *\n  * \\only_for_vectors\n  *\n  * Example: \\include Matrix_setConstant_int.cpp\n  * Output: \\verbinclude Matrix_setConstant_int.out\n  *\n  * \\sa MatrixBase::setConstant(const Scalar&), setConstant(Index,Index,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&\nPlainObjectBase<Derived>::setConstant(Index size, const Scalar& val)\n{\n  resize(size);\n  return setConstant(val);\n}\n\n/** Resizes to the given size, and sets all coefficients in this expression to the given value \\a val.\n  *\n  * \\param rows the new number of rows\n  * \\param cols the new number of columns\n  * \\param val the value to which all coefficients are set\n  *\n  * Example: \\include Matrix_setConstant_int_int.cpp\n  * Output: \\verbinclude Matrix_setConstant_int_int.out\n  *\n  * \\sa MatrixBase::setConstant(const Scalar&), setConstant(Index,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&\nPlainObjectBase<Derived>::setConstant(Index rows, Index cols, const Scalar& val)\n{\n  resize(rows, cols);\n  return setConstant(val);\n}\n\n/**\n  * \\brief Sets a linearly spaced vector.\n  *\n  * The function generates 'size' equally spaced values in the closed interval [low,high].\n  * When size is set to 1, a vector of length 1 containing 'high' is returned.\n  *\n  * \\only_for_vectors\n  *\n  * Example: \\include DenseBase_setLinSpaced.cpp\n  * Output: \\verbinclude DenseBase_setLinSpaced.out\n  *\n  * For integer scalar types, do not miss the explanations on the definition\n  * of \\link LinSpaced(Index,const Scalar&,const Scalar&) even spacing \\endlink.\n  *\n  * \\sa LinSpaced(Index,const Scalar&,const Scalar&), CwiseNullaryOp\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(Index newSize, const Scalar& low, const Scalar& high)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return derived() = Derived::NullaryExpr(newSize, internal::linspaced_op<Scalar,PacketScalar>(low,high,newSize));\n}\n\n/**\n  * \\brief Sets a linearly spaced vector.\n  *\n  * The function fills \\c *this with equally spaced values in the closed interval [low,high].\n  * When size is set to 1, a vector of length 1 containing 'high' is returned.\n  *\n  * \\only_for_vectors\n  *\n  * For integer scalar types, do not miss the explanations on the definition\n  * of \\link LinSpaced(Index,const Scalar&,const Scalar&) even spacing \\endlink.\n  *\n  * \\sa LinSpaced(Index,const Scalar&,const Scalar&), setLinSpaced(Index, const Scalar&, const Scalar&), CwiseNullaryOp\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(const Scalar& low, const Scalar& high)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return setLinSpaced(size(), low, high);\n}\n\n// zero:\n\n/** \\returns an expression of a zero matrix.\n  *\n  * The parameters \\a rows and \\a cols are the number of rows and of columns of\n  * the returned matrix. Must be compatible with this MatrixBase type.\n  *\n  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,\n  * it is redundant to pass \\a rows and \\a cols as arguments, so Zero() should be used\n  * instead.\n  *\n  * Example: \\include MatrixBase_zero_int_int.cpp\n  * Output: \\verbinclude MatrixBase_zero_int_int.out\n  *\n  * \\sa Zero(), Zero(Index)\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType\nDenseBase<Derived>::Zero(Index rows, Index cols)\n{\n  return Constant(rows, cols, Scalar(0));\n}\n\n/** \\returns an expression of a zero vector.\n  *\n  * The parameter \\a size is the size of the returned vector.\n  * Must be compatible with this MatrixBase type.\n  *\n  * \\only_for_vectors\n  *\n  * This variant is meant to be used for dynamic-size vector types. For fixed-size types,\n  * it is redundant to pass \\a size as argument, so Zero() should be used\n  * instead.\n  *\n  * Example: \\include MatrixBase_zero_int.cpp\n  * Output: \\verbinclude MatrixBase_zero_int.out\n  *\n  * \\sa Zero(), Zero(Index,Index)\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType\nDenseBase<Derived>::Zero(Index size)\n{\n  return Constant(size, Scalar(0));\n}\n\n/** \\returns an expression of a fixed-size zero matrix or vector.\n  *\n  * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you\n  * need to use the variants taking size arguments.\n  *\n  * Example: \\include MatrixBase_zero.cpp\n  * Output: \\verbinclude MatrixBase_zero.out\n  *\n  * \\sa Zero(Index), Zero(Index,Index)\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType\nDenseBase<Derived>::Zero()\n{\n  return Constant(Scalar(0));\n}\n\n/** \\returns true if *this is approximately equal to the zero matrix,\n  *          within the precision given by \\a prec.\n  *\n  * Example: \\include MatrixBase_isZero.cpp\n  * Output: \\verbinclude MatrixBase_isZero.out\n  *\n  * \\sa class CwiseNullaryOp, Zero()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC bool DenseBase<Derived>::isZero(const RealScalar& prec) const\n{\n  typename internal::nested_eval<Derived,1>::type self(derived());\n  for(Index j = 0; j < cols(); ++j)\n    for(Index i = 0; i < rows(); ++i)\n      if(!internal::isMuchSmallerThan(self.coeff(i, j), static_cast<Scalar>(1), prec))\n        return false;\n  return true;\n}\n\n/** Sets all coefficients in this expression to zero.\n  *\n  * Example: \\include MatrixBase_setZero.cpp\n  * Output: \\verbinclude MatrixBase_setZero.out\n  *\n  * \\sa class CwiseNullaryOp, Zero()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setZero()\n{\n  return setConstant(Scalar(0));\n}\n\n/** Resizes to the given \\a size, and sets all coefficients in this expression to zero.\n  *\n  * \\only_for_vectors\n  *\n  * Example: \\include Matrix_setZero_int.cpp\n  * Output: \\verbinclude Matrix_setZero_int.out\n  *\n  * \\sa DenseBase::setZero(), setZero(Index,Index), class CwiseNullaryOp, DenseBase::Zero()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&\nPlainObjectBase<Derived>::setZero(Index newSize)\n{\n  resize(newSize);\n  return setConstant(Scalar(0));\n}\n\n/** Resizes to the given size, and sets all coefficients in this expression to zero.\n  *\n  * \\param rows the new number of rows\n  * \\param cols the new number of columns\n  *\n  * Example: \\include Matrix_setZero_int_int.cpp\n  * Output: \\verbinclude Matrix_setZero_int_int.out\n  *\n  * \\sa DenseBase::setZero(), setZero(Index), class CwiseNullaryOp, DenseBase::Zero()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&\nPlainObjectBase<Derived>::setZero(Index rows, Index cols)\n{\n  resize(rows, cols);\n  return setConstant(Scalar(0));\n}\n\n// ones:\n\n/** \\returns an expression of a matrix where all coefficients equal one.\n  *\n  * The parameters \\a rows and \\a cols are the number of rows and of columns of\n  * the returned matrix. Must be compatible with this MatrixBase type.\n  *\n  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,\n  * it is redundant to pass \\a rows and \\a cols as arguments, so Ones() should be used\n  * instead.\n  *\n  * Example: \\include MatrixBase_ones_int_int.cpp\n  * Output: \\verbinclude MatrixBase_ones_int_int.out\n  *\n  * \\sa Ones(), Ones(Index), isOnes(), class Ones\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType\nDenseBase<Derived>::Ones(Index rows, Index cols)\n{\n  return Constant(rows, cols, Scalar(1));\n}\n\n/** \\returns an expression of a vector where all coefficients equal one.\n  *\n  * The parameter \\a newSize is the size of the returned vector.\n  * Must be compatible with this MatrixBase type.\n  *\n  * \\only_for_vectors\n  *\n  * This variant is meant to be used for dynamic-size vector types. For fixed-size types,\n  * it is redundant to pass \\a size as argument, so Ones() should be used\n  * instead.\n  *\n  * Example: \\include MatrixBase_ones_int.cpp\n  * Output: \\verbinclude MatrixBase_ones_int.out\n  *\n  * \\sa Ones(), Ones(Index,Index), isOnes(), class Ones\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType\nDenseBase<Derived>::Ones(Index newSize)\n{\n  return Constant(newSize, Scalar(1));\n}\n\n/** \\returns an expression of a fixed-size matrix or vector where all coefficients equal one.\n  *\n  * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you\n  * need to use the variants taking size arguments.\n  *\n  * Example: \\include MatrixBase_ones.cpp\n  * Output: \\verbinclude MatrixBase_ones.out\n  *\n  * \\sa Ones(Index), Ones(Index,Index), isOnes(), class Ones\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType\nDenseBase<Derived>::Ones()\n{\n  return Constant(Scalar(1));\n}\n\n/** \\returns true if *this is approximately equal to the matrix where all coefficients\n  *          are equal to 1, within the precision given by \\a prec.\n  *\n  * Example: \\include MatrixBase_isOnes.cpp\n  * Output: \\verbinclude MatrixBase_isOnes.out\n  *\n  * \\sa class CwiseNullaryOp, Ones()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC bool DenseBase<Derived>::isOnes\n(const RealScalar& prec) const\n{\n  return isApproxToConstant(Scalar(1), prec);\n}\n\n/** Sets all coefficients in this expression to one.\n  *\n  * Example: \\include MatrixBase_setOnes.cpp\n  * Output: \\verbinclude MatrixBase_setOnes.out\n  *\n  * \\sa class CwiseNullaryOp, Ones()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setOnes()\n{\n  return setConstant(Scalar(1));\n}\n\n/** Resizes to the given \\a newSize, and sets all coefficients in this expression to one.\n  *\n  * \\only_for_vectors\n  *\n  * Example: \\include Matrix_setOnes_int.cpp\n  * Output: \\verbinclude Matrix_setOnes_int.out\n  *\n  * \\sa MatrixBase::setOnes(), setOnes(Index,Index), class CwiseNullaryOp, MatrixBase::Ones()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&\nPlainObjectBase<Derived>::setOnes(Index newSize)\n{\n  resize(newSize);\n  return setConstant(Scalar(1));\n}\n\n/** Resizes to the given size, and sets all coefficients in this expression to one.\n  *\n  * \\param rows the new number of rows\n  * \\param cols the new number of columns\n  *\n  * Example: \\include Matrix_setOnes_int_int.cpp\n  * Output: \\verbinclude Matrix_setOnes_int_int.out\n  *\n  * \\sa MatrixBase::setOnes(), setOnes(Index), class CwiseNullaryOp, MatrixBase::Ones()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&\nPlainObjectBase<Derived>::setOnes(Index rows, Index cols)\n{\n  resize(rows, cols);\n  return setConstant(Scalar(1));\n}\n\n// Identity:\n\n/** \\returns an expression of the identity matrix (not necessarily square).\n  *\n  * The parameters \\a rows and \\a cols are the number of rows and of columns of\n  * the returned matrix. Must be compatible with this MatrixBase type.\n  *\n  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,\n  * it is redundant to pass \\a rows and \\a cols as arguments, so Identity() should be used\n  * instead.\n  *\n  * Example: \\include MatrixBase_identity_int_int.cpp\n  * Output: \\verbinclude MatrixBase_identity_int_int.out\n  *\n  * \\sa Identity(), setIdentity(), isIdentity()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType\nMatrixBase<Derived>::Identity(Index rows, Index cols)\n{\n  return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_identity_op<Scalar>());\n}\n\n/** \\returns an expression of the identity matrix (not necessarily square).\n  *\n  * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you\n  * need to use the variant taking size arguments.\n  *\n  * Example: \\include MatrixBase_identity.cpp\n  * Output: \\verbinclude MatrixBase_identity.out\n  *\n  * \\sa Identity(Index,Index), setIdentity(), isIdentity()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType\nMatrixBase<Derived>::Identity()\n{\n  EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)\n  return MatrixBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_identity_op<Scalar>());\n}\n\n/** \\returns true if *this is approximately equal to the identity matrix\n  *          (not necessarily square),\n  *          within the precision given by \\a prec.\n  *\n  * Example: \\include MatrixBase_isIdentity.cpp\n  * Output: \\verbinclude MatrixBase_isIdentity.out\n  *\n  * \\sa class CwiseNullaryOp, Identity(), Identity(Index,Index), setIdentity()\n  */\ntemplate<typename Derived>\nbool MatrixBase<Derived>::isIdentity\n(const RealScalar& prec) const\n{\n  typename internal::nested_eval<Derived,1>::type self(derived());\n  for(Index j = 0; j < cols(); ++j)\n  {\n    for(Index i = 0; i < rows(); ++i)\n    {\n      if(i == j)\n      {\n        if(!internal::isApprox(self.coeff(i, j), static_cast<Scalar>(1), prec))\n          return false;\n      }\n      else\n      {\n        if(!internal::isMuchSmallerThan(self.coeff(i, j), static_cast<RealScalar>(1), prec))\n          return false;\n      }\n    }\n  }\n  return true;\n}\n\nnamespace internal {\n\ntemplate<typename Derived, bool Big = (Derived::SizeAtCompileTime>=16)>\nstruct setIdentity_impl\n{\n  EIGEN_DEVICE_FUNC\n  static EIGEN_STRONG_INLINE Derived& run(Derived& m)\n  {\n    return m = Derived::Identity(m.rows(), m.cols());\n  }\n};\n\ntemplate<typename Derived>\nstruct setIdentity_impl<Derived, true>\n{\n  EIGEN_DEVICE_FUNC\n  static EIGEN_STRONG_INLINE Derived& run(Derived& m)\n  {\n    m.setZero();\n    const Index size = numext::mini(m.rows(), m.cols());\n    for(Index i = 0; i < size; ++i) m.coeffRef(i,i) = typename Derived::Scalar(1);\n    return m;\n  }\n};\n\n} // end namespace internal\n\n/** Writes the identity expression (not necessarily square) into *this.\n  *\n  * Example: \\include MatrixBase_setIdentity.cpp\n  * Output: \\verbinclude MatrixBase_setIdentity.out\n  *\n  * \\sa class CwiseNullaryOp, Identity(), Identity(Index,Index), isIdentity()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity()\n{\n  return internal::setIdentity_impl<Derived>::run(derived());\n}\n\n/** \\brief Resizes to the given size, and writes the identity expression (not necessarily square) into *this.\n  *\n  * \\param rows the new number of rows\n  * \\param cols the new number of columns\n  *\n  * Example: \\include Matrix_setIdentity_int_int.cpp\n  * Output: \\verbinclude Matrix_setIdentity_int_int.out\n  *\n  * \\sa MatrixBase::setIdentity(), class CwiseNullaryOp, MatrixBase::Identity()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity(Index rows, Index cols)\n{\n  derived().resize(rows, cols);\n  return setIdentity();\n}\n\n/** \\returns an expression of the i-th unit (basis) vector.\n  *\n  * \\only_for_vectors\n  *\n  * \\sa MatrixBase::Unit(Index), MatrixBase::UnitX(), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(Index newSize, Index i)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return BasisReturnType(SquareMatrixType::Identity(newSize,newSize), i);\n}\n\n/** \\returns an expression of the i-th unit (basis) vector.\n  *\n  * \\only_for_vectors\n  *\n  * This variant is for fixed-size vector only.\n  *\n  * \\sa MatrixBase::Unit(Index,Index), MatrixBase::UnitX(), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(Index i)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return BasisReturnType(SquareMatrixType::Identity(),i);\n}\n\n/** \\returns an expression of the X axis unit vector (1{,0}^*)\n  *\n  * \\only_for_vectors\n  *\n  * \\sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitX()\n{ return Derived::Unit(0); }\n\n/** \\returns an expression of the Y axis unit vector (0,1{,0}^*)\n  *\n  * \\only_for_vectors\n  *\n  * \\sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitY()\n{ return Derived::Unit(1); }\n\n/** \\returns an expression of the Z axis unit vector (0,0,1{,0}^*)\n  *\n  * \\only_for_vectors\n  *\n  * \\sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitZ()\n{ return Derived::Unit(2); }\n\n/** \\returns an expression of the W axis unit vector (0,0,0,1)\n  *\n  * \\only_for_vectors\n  *\n  * \\sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitW()\n{ return Derived::Unit(3); }\n\n} // end namespace Eigen\n\n#endif // EIGEN_CWISE_NULLARY_OP_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/CwiseTernaryOp.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2016 Eugene Brevdo <ebrevdo@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CWISE_TERNARY_OP_H\n#define EIGEN_CWISE_TERNARY_OP_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>\nstruct traits<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > {\n  // we must not inherit from traits<Arg1> since it has\n  // the potential to cause problems with MSVC\n  typedef typename remove_all<Arg1>::type Ancestor;\n  typedef typename traits<Ancestor>::XprKind XprKind;\n  enum {\n    RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime,\n    ColsAtCompileTime = traits<Ancestor>::ColsAtCompileTime,\n    MaxRowsAtCompileTime = traits<Ancestor>::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = traits<Ancestor>::MaxColsAtCompileTime\n  };\n\n  // even though we require Arg1, Arg2, and Arg3 to have the same scalar type\n  // (see CwiseTernaryOp constructor),\n  // we still want to handle the case when the result type is different.\n  typedef typename result_of<TernaryOp(\n      const typename Arg1::Scalar&, const typename Arg2::Scalar&,\n      const typename Arg3::Scalar&)>::type Scalar;\n\n  typedef typename internal::traits<Arg1>::StorageKind StorageKind;\n  typedef typename internal::traits<Arg1>::StorageIndex StorageIndex;\n\n  typedef typename Arg1::Nested Arg1Nested;\n  typedef typename Arg2::Nested Arg2Nested;\n  typedef typename Arg3::Nested Arg3Nested;\n  typedef typename remove_reference<Arg1Nested>::type _Arg1Nested;\n  typedef typename remove_reference<Arg2Nested>::type _Arg2Nested;\n  typedef typename remove_reference<Arg3Nested>::type _Arg3Nested;\n  enum { Flags = _Arg1Nested::Flags & RowMajorBit };\n};\n}  // end namespace internal\n\ntemplate <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3,\n          typename StorageKind>\nclass CwiseTernaryOpImpl;\n\n/** \\class CwiseTernaryOp\n  * \\ingroup Core_Module\n  *\n  * \\brief Generic expression where a coefficient-wise ternary operator is\n * applied to two expressions\n  *\n  * \\tparam TernaryOp template functor implementing the operator\n  * \\tparam Arg1Type the type of the first argument\n  * \\tparam Arg2Type the type of the second argument\n  * \\tparam Arg3Type the type of the third argument\n  *\n  * This class represents an expression where a coefficient-wise ternary\n * operator is applied to three expressions.\n  * It is the return type of ternary operators, by which we mean only those\n * ternary operators where\n  * all three arguments are Eigen expressions.\n  * For example, the return type of betainc(matrix1, matrix2, matrix3) is a\n * CwiseTernaryOp.\n  *\n  * Most of the time, this is the only way that it is used, so you typically\n * don't have to name\n  * CwiseTernaryOp types explicitly.\n  *\n  * \\sa MatrixBase::ternaryExpr(const MatrixBase<Argument2> &, const\n * MatrixBase<Argument3> &, const CustomTernaryOp &) const, class CwiseBinaryOp,\n * class CwiseUnaryOp, class CwiseNullaryOp\n  */\ntemplate <typename TernaryOp, typename Arg1Type, typename Arg2Type,\n          typename Arg3Type>\nclass CwiseTernaryOp : public CwiseTernaryOpImpl<\n                           TernaryOp, Arg1Type, Arg2Type, Arg3Type,\n                           typename internal::traits<Arg1Type>::StorageKind>,\n                       internal::no_assignment_operator\n{\n public:\n  typedef typename internal::remove_all<Arg1Type>::type Arg1;\n  typedef typename internal::remove_all<Arg2Type>::type Arg2;\n  typedef typename internal::remove_all<Arg3Type>::type Arg3;\n\n  typedef typename CwiseTernaryOpImpl<\n      TernaryOp, Arg1Type, Arg2Type, Arg3Type,\n      typename internal::traits<Arg1Type>::StorageKind>::Base Base;\n  EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseTernaryOp)\n\n  typedef typename internal::ref_selector<Arg1Type>::type Arg1Nested;\n  typedef typename internal::ref_selector<Arg2Type>::type Arg2Nested;\n  typedef typename internal::ref_selector<Arg3Type>::type Arg3Nested;\n  typedef typename internal::remove_reference<Arg1Nested>::type _Arg1Nested;\n  typedef typename internal::remove_reference<Arg2Nested>::type _Arg2Nested;\n  typedef typename internal::remove_reference<Arg3Nested>::type _Arg3Nested;\n\n  EIGEN_DEVICE_FUNC\n  EIGEN_STRONG_INLINE CwiseTernaryOp(const Arg1& a1, const Arg2& a2,\n                                     const Arg3& a3,\n                                     const TernaryOp& func = TernaryOp())\n      : m_arg1(a1), m_arg2(a2), m_arg3(a3), m_functor(func) {\n    // require the sizes to match\n    EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Arg1, Arg2)\n    EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Arg1, Arg3)\n\n    // The index types should match\n    EIGEN_STATIC_ASSERT((internal::is_same<\n                         typename internal::traits<Arg1Type>::StorageKind,\n                         typename internal::traits<Arg2Type>::StorageKind>::value),\n                        STORAGE_KIND_MUST_MATCH)\n    EIGEN_STATIC_ASSERT((internal::is_same<\n                         typename internal::traits<Arg1Type>::StorageKind,\n                         typename internal::traits<Arg3Type>::StorageKind>::value),\n                        STORAGE_KIND_MUST_MATCH)\n\n    eigen_assert(a1.rows() == a2.rows() && a1.cols() == a2.cols() &&\n                 a1.rows() == a3.rows() && a1.cols() == a3.cols());\n  }\n\n  EIGEN_DEVICE_FUNC\n  EIGEN_STRONG_INLINE Index rows() const {\n    // return the fixed size type if available to enable compile time\n    // optimizations\n    if (internal::traits<typename internal::remove_all<Arg1Nested>::type>::\n                RowsAtCompileTime == Dynamic &&\n        internal::traits<typename internal::remove_all<Arg2Nested>::type>::\n                RowsAtCompileTime == Dynamic)\n      return m_arg3.rows();\n    else if (internal::traits<typename internal::remove_all<Arg1Nested>::type>::\n                     RowsAtCompileTime == Dynamic &&\n             internal::traits<typename internal::remove_all<Arg3Nested>::type>::\n                     RowsAtCompileTime == Dynamic)\n      return m_arg2.rows();\n    else\n      return m_arg1.rows();\n  }\n  EIGEN_DEVICE_FUNC\n  EIGEN_STRONG_INLINE Index cols() const {\n    // return the fixed size type if available to enable compile time\n    // optimizations\n    if (internal::traits<typename internal::remove_all<Arg1Nested>::type>::\n                ColsAtCompileTime == Dynamic &&\n        internal::traits<typename internal::remove_all<Arg2Nested>::type>::\n                ColsAtCompileTime == Dynamic)\n      return m_arg3.cols();\n    else if (internal::traits<typename internal::remove_all<Arg1Nested>::type>::\n                     ColsAtCompileTime == Dynamic &&\n             internal::traits<typename internal::remove_all<Arg3Nested>::type>::\n                     ColsAtCompileTime == Dynamic)\n      return m_arg2.cols();\n    else\n      return m_arg1.cols();\n  }\n\n  /** \\returns the first argument nested expression */\n  EIGEN_DEVICE_FUNC\n  const _Arg1Nested& arg1() const { return m_arg1; }\n  /** \\returns the first argument nested expression */\n  EIGEN_DEVICE_FUNC\n  const _Arg2Nested& arg2() const { return m_arg2; }\n  /** \\returns the third argument nested expression */\n  EIGEN_DEVICE_FUNC\n  const _Arg3Nested& arg3() const { return m_arg3; }\n  /** \\returns the functor representing the ternary operation */\n  EIGEN_DEVICE_FUNC\n  const TernaryOp& functor() const { return m_functor; }\n\n protected:\n  Arg1Nested m_arg1;\n  Arg2Nested m_arg2;\n  Arg3Nested m_arg3;\n  const TernaryOp m_functor;\n};\n\n// Generic API dispatcher\ntemplate <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3,\n          typename StorageKind>\nclass CwiseTernaryOpImpl\n    : public internal::generic_xpr_base<\n          CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >::type {\n public:\n  typedef typename internal::generic_xpr_base<\n      CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >::type Base;\n};\n\n}  // end namespace Eigen\n\n#endif  // EIGEN_CWISE_TERNARY_OP_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/CwiseUnaryOp.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CWISE_UNARY_OP_H\n#define EIGEN_CWISE_UNARY_OP_H\n\nnamespace Eigen { \n\nnamespace internal {\ntemplate<typename UnaryOp, typename XprType>\nstruct traits<CwiseUnaryOp<UnaryOp, XprType> >\n : traits<XprType>\n{\n  typedef typename result_of<\n                     UnaryOp(const typename XprType::Scalar&)\n                   >::type Scalar;\n  typedef typename XprType::Nested XprTypeNested;\n  typedef typename remove_reference<XprTypeNested>::type _XprTypeNested;\n  enum {\n    Flags = _XprTypeNested::Flags & RowMajorBit \n  };\n};\n}\n\ntemplate<typename UnaryOp, typename XprType, typename StorageKind>\nclass CwiseUnaryOpImpl;\n\n/** \\class CwiseUnaryOp\n  * \\ingroup Core_Module\n  *\n  * \\brief Generic expression where a coefficient-wise unary operator is applied to an expression\n  *\n  * \\tparam UnaryOp template functor implementing the operator\n  * \\tparam XprType the type of the expression to which we are applying the unary operator\n  *\n  * This class represents an expression where a unary operator is applied to an expression.\n  * It is the return type of all operations taking exactly 1 input expression, regardless of the\n  * presence of other inputs such as scalars. For example, the operator* in the expression 3*matrix\n  * is considered unary, because only the right-hand side is an expression, and its\n  * return type is a specialization of CwiseUnaryOp.\n  *\n  * Most of the time, this is the only way that it is used, so you typically don't have to name\n  * CwiseUnaryOp types explicitly.\n  *\n  * \\sa MatrixBase::unaryExpr(const CustomUnaryOp &) const, class CwiseBinaryOp, class CwiseNullaryOp\n  */\ntemplate<typename UnaryOp, typename XprType>\nclass CwiseUnaryOp : public CwiseUnaryOpImpl<UnaryOp, XprType, typename internal::traits<XprType>::StorageKind>, internal::no_assignment_operator\n{\n  public:\n\n    typedef typename CwiseUnaryOpImpl<UnaryOp, XprType,typename internal::traits<XprType>::StorageKind>::Base Base;\n    EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryOp)\n    typedef typename internal::ref_selector<XprType>::type XprTypeNested;\n    typedef typename internal::remove_all<XprType>::type NestedExpression;\n\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    explicit CwiseUnaryOp(const XprType& xpr, const UnaryOp& func = UnaryOp())\n      : m_xpr(xpr), m_functor(func) {}\n\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Index rows() const { return m_xpr.rows(); }\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Index cols() const { return m_xpr.cols(); }\n\n    /** \\returns the functor representing the unary operation */\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    const UnaryOp& functor() const { return m_functor; }\n\n    /** \\returns the nested expression */\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    const typename internal::remove_all<XprTypeNested>::type&\n    nestedExpression() const { return m_xpr; }\n\n    /** \\returns the nested expression */\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    typename internal::remove_all<XprTypeNested>::type&\n    nestedExpression() { return m_xpr; }\n\n  protected:\n    XprTypeNested m_xpr;\n    const UnaryOp m_functor;\n};\n\n// Generic API dispatcher\ntemplate<typename UnaryOp, typename XprType, typename StorageKind>\nclass CwiseUnaryOpImpl\n  : public internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type\n{\npublic:\n  typedef typename internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type Base;\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_CWISE_UNARY_OP_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/CwiseUnaryView.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CWISE_UNARY_VIEW_H\n#define EIGEN_CWISE_UNARY_VIEW_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate<typename ViewOp, typename MatrixType>\nstruct traits<CwiseUnaryView<ViewOp, MatrixType> >\n : traits<MatrixType>\n{\n  typedef typename result_of<\n                     ViewOp(const typename traits<MatrixType>::Scalar&)\n                   >::type Scalar;\n  typedef typename MatrixType::Nested MatrixTypeNested;\n  typedef typename remove_all<MatrixTypeNested>::type _MatrixTypeNested;\n  enum {\n    FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,\n    Flags = traits<_MatrixTypeNested>::Flags & (RowMajorBit | FlagsLvalueBit | DirectAccessBit), // FIXME DirectAccessBit should not be handled by expressions\n    MatrixTypeInnerStride =  inner_stride_at_compile_time<MatrixType>::ret,\n    // need to cast the sizeof's from size_t to int explicitly, otherwise:\n    // \"error: no integral type can represent all of the enumerator values\n    InnerStrideAtCompileTime = MatrixTypeInnerStride == Dynamic\n                             ? int(Dynamic)\n                             : int(MatrixTypeInnerStride) * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar)),\n    OuterStrideAtCompileTime = outer_stride_at_compile_time<MatrixType>::ret == Dynamic\n                             ? int(Dynamic)\n                             : outer_stride_at_compile_time<MatrixType>::ret * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar))\n  };\n};\n}\n\ntemplate<typename ViewOp, typename MatrixType, typename StorageKind>\nclass CwiseUnaryViewImpl;\n\n/** \\class CwiseUnaryView\n  * \\ingroup Core_Module\n  *\n  * \\brief Generic lvalue expression of a coefficient-wise unary operator of a matrix or a vector\n  *\n  * \\tparam ViewOp template functor implementing the view\n  * \\tparam MatrixType the type of the matrix we are applying the unary operator\n  *\n  * This class represents a lvalue expression of a generic unary view operator of a matrix or a vector.\n  * It is the return type of real() and imag(), and most of the time this is the only way it is used.\n  *\n  * \\sa MatrixBase::unaryViewExpr(const CustomUnaryOp &) const, class CwiseUnaryOp\n  */\ntemplate<typename ViewOp, typename MatrixType>\nclass CwiseUnaryView : public CwiseUnaryViewImpl<ViewOp, MatrixType, typename internal::traits<MatrixType>::StorageKind>\n{\n  public:\n\n    typedef typename CwiseUnaryViewImpl<ViewOp, MatrixType,typename internal::traits<MatrixType>::StorageKind>::Base Base;\n    EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryView)\n    typedef typename internal::ref_selector<MatrixType>::non_const_type MatrixTypeNested;\n    typedef typename internal::remove_all<MatrixType>::type NestedExpression;\n\n    explicit inline CwiseUnaryView(MatrixType& mat, const ViewOp& func = ViewOp())\n      : m_matrix(mat), m_functor(func) {}\n\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryView)\n\n    EIGEN_STRONG_INLINE Index rows() const { return m_matrix.rows(); }\n    EIGEN_STRONG_INLINE Index cols() const { return m_matrix.cols(); }\n\n    /** \\returns the functor representing unary operation */\n    const ViewOp& functor() const { return m_functor; }\n\n    /** \\returns the nested expression */\n    const typename internal::remove_all<MatrixTypeNested>::type&\n    nestedExpression() const { return m_matrix; }\n\n    /** \\returns the nested expression */\n    typename internal::remove_reference<MatrixTypeNested>::type&\n    nestedExpression() { return m_matrix.const_cast_derived(); }\n\n  protected:\n    MatrixTypeNested m_matrix;\n    ViewOp m_functor;\n};\n\n// Generic API dispatcher\ntemplate<typename ViewOp, typename XprType, typename StorageKind>\nclass CwiseUnaryViewImpl\n  : public internal::generic_xpr_base<CwiseUnaryView<ViewOp, XprType> >::type\n{\npublic:\n  typedef typename internal::generic_xpr_base<CwiseUnaryView<ViewOp, XprType> >::type Base;\n};\n\ntemplate<typename ViewOp, typename MatrixType>\nclass CwiseUnaryViewImpl<ViewOp,MatrixType,Dense>\n  : public internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type\n{\n  public:\n\n    typedef CwiseUnaryView<ViewOp, MatrixType> Derived;\n    typedef typename internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type Base;\n\n    EIGEN_DENSE_PUBLIC_INTERFACE(Derived)\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryViewImpl)\n    \n    EIGEN_DEVICE_FUNC inline Scalar* data() { return &(this->coeffRef(0)); }\n    EIGEN_DEVICE_FUNC inline const Scalar* data() const { return &(this->coeff(0)); }\n\n    EIGEN_DEVICE_FUNC inline Index innerStride() const\n    {\n      return derived().nestedExpression().innerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar);\n    }\n\n    EIGEN_DEVICE_FUNC inline Index outerStride() const\n    {\n      return derived().nestedExpression().outerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar);\n    }\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_CWISE_UNARY_VIEW_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/DenseBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_DENSEBASE_H\n#define EIGEN_DENSEBASE_H\n\nnamespace Eigen {\n\nnamespace internal {\n  \n// The index type defined by EIGEN_DEFAULT_DENSE_INDEX_TYPE must be a signed type.\n// This dummy function simply aims at checking that at compile time.\nstatic inline void check_DenseIndex_is_signed() {\n  EIGEN_STATIC_ASSERT(NumTraits<DenseIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE); \n}\n\n} // end namespace internal\n  \n/** \\class DenseBase\n  * \\ingroup Core_Module\n  *\n  * \\brief Base class for all dense matrices, vectors, and arrays\n  *\n  * This class is the base that is inherited by all dense objects (matrix, vector, arrays,\n  * and related expression types). The common Eigen API for dense objects is contained in this class.\n  *\n  * \\tparam Derived is the derived type, e.g., a matrix type or an expression.\n  *\n  * This class can be extended with the help of the plugin mechanism described on the page\n  * \\ref TopicCustomizing_Plugins by defining the preprocessor symbol \\c EIGEN_DENSEBASE_PLUGIN.\n  *\n  * \\sa \\blank \\ref TopicClassHierarchy\n  */\ntemplate<typename Derived> class DenseBase\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n  : public DenseCoeffsBase<Derived>\n#else\n  : public DenseCoeffsBase<Derived,DirectWriteAccessors>\n#endif // not EIGEN_PARSED_BY_DOXYGEN\n{\n  public:\n\n    /** Inner iterator type to iterate over the coefficients of a row or column.\n      * \\sa class InnerIterator\n      */\n    typedef Eigen::InnerIterator<Derived> InnerIterator;\n\n    typedef typename internal::traits<Derived>::StorageKind StorageKind;\n\n    /**\n      * \\brief The type used to store indices\n      * \\details This typedef is relevant for types that store multiple indices such as\n      *          PermutationMatrix or Transpositions, otherwise it defaults to Eigen::Index\n      * \\sa \\blank \\ref TopicPreprocessorDirectives, Eigen::Index, SparseMatrixBase.\n     */\n    typedef typename internal::traits<Derived>::StorageIndex StorageIndex;\n\n    /** The numeric type of the expression' coefficients, e.g. float, double, int or std::complex<float>, etc. */\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    \n    /** The numeric type of the expression' coefficients, e.g. float, double, int or std::complex<float>, etc.\n      *\n      * It is an alias for the Scalar type */\n    typedef Scalar value_type;\n    \n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    typedef DenseCoeffsBase<Derived> Base;\n\n    using Base::derived;\n    using Base::const_cast_derived;\n    using Base::rows;\n    using Base::cols;\n    using Base::size;\n    using Base::rowIndexByOuterInner;\n    using Base::colIndexByOuterInner;\n    using Base::coeff;\n    using Base::coeffByOuterInner;\n    using Base::operator();\n    using Base::operator[];\n    using Base::x;\n    using Base::y;\n    using Base::z;\n    using Base::w;\n    using Base::stride;\n    using Base::innerStride;\n    using Base::outerStride;\n    using Base::rowStride;\n    using Base::colStride;\n    typedef typename Base::CoeffReturnType CoeffReturnType;\n\n    enum {\n\n      RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,\n        /**< The number of rows at compile-time. This is just a copy of the value provided\n          * by the \\a Derived type. If a value is not known at compile-time,\n          * it is set to the \\a Dynamic constant.\n          * \\sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */\n\n      ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,\n        /**< The number of columns at compile-time. This is just a copy of the value provided\n          * by the \\a Derived type. If a value is not known at compile-time,\n          * it is set to the \\a Dynamic constant.\n          * \\sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */\n\n\n      SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,\n                                                   internal::traits<Derived>::ColsAtCompileTime>::ret),\n        /**< This is equal to the number of coefficients, i.e. the number of\n          * rows times the number of columns, or to \\a Dynamic if this is not\n          * known at compile-time. \\sa RowsAtCompileTime, ColsAtCompileTime */\n\n      MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,\n        /**< This value is equal to the maximum possible number of rows that this expression\n          * might have. If this expression might have an arbitrarily high number of rows,\n          * this value is set to \\a Dynamic.\n          *\n          * This value is useful to know when evaluating an expression, in order to determine\n          * whether it is possible to avoid doing a dynamic memory allocation.\n          *\n          * \\sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime\n          */\n\n      MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,\n        /**< This value is equal to the maximum possible number of columns that this expression\n          * might have. If this expression might have an arbitrarily high number of columns,\n          * this value is set to \\a Dynamic.\n          *\n          * This value is useful to know when evaluating an expression, in order to determine\n          * whether it is possible to avoid doing a dynamic memory allocation.\n          *\n          * \\sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime\n          */\n\n      MaxSizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::MaxRowsAtCompileTime,\n                                                      internal::traits<Derived>::MaxColsAtCompileTime>::ret),\n        /**< This value is equal to the maximum possible number of coefficients that this expression\n          * might have. If this expression might have an arbitrarily high number of coefficients,\n          * this value is set to \\a Dynamic.\n          *\n          * This value is useful to know when evaluating an expression, in order to determine\n          * whether it is possible to avoid doing a dynamic memory allocation.\n          *\n          * \\sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime\n          */\n\n      IsVectorAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime == 1\n                           || internal::traits<Derived>::MaxColsAtCompileTime == 1,\n        /**< This is set to true if either the number of rows or the number of\n          * columns is known at compile-time to be equal to 1. Indeed, in that case,\n          * we are dealing with a column-vector (if there is only one column) or with\n          * a row-vector (if there is only one row). */\n\n      Flags = internal::traits<Derived>::Flags,\n        /**< This stores expression \\ref flags flags which may or may not be inherited by new expressions\n          * constructed from this one. See the \\ref flags \"list of flags\".\n          */\n\n      IsRowMajor = int(Flags) & RowMajorBit, /**< True if this expression has row-major storage order. */\n\n      InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? int(SizeAtCompileTime)\n                             : int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime),\n\n      InnerStrideAtCompileTime = internal::inner_stride_at_compile_time<Derived>::ret,\n      OuterStrideAtCompileTime = internal::outer_stride_at_compile_time<Derived>::ret\n    };\n    \n    typedef typename internal::find_best_packet<Scalar,SizeAtCompileTime>::type PacketScalar;\n\n    enum { IsPlainObjectBase = 0 };\n    \n    /** The plain matrix type corresponding to this expression.\n      * \\sa PlainObject */\n    typedef Matrix<typename internal::traits<Derived>::Scalar,\n                internal::traits<Derived>::RowsAtCompileTime,\n                internal::traits<Derived>::ColsAtCompileTime,\n                AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),\n                internal::traits<Derived>::MaxRowsAtCompileTime,\n                internal::traits<Derived>::MaxColsAtCompileTime\n          > PlainMatrix;\n    \n    /** The plain array type corresponding to this expression.\n      * \\sa PlainObject */\n    typedef Array<typename internal::traits<Derived>::Scalar,\n                internal::traits<Derived>::RowsAtCompileTime,\n                internal::traits<Derived>::ColsAtCompileTime,\n                AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),\n                internal::traits<Derived>::MaxRowsAtCompileTime,\n                internal::traits<Derived>::MaxColsAtCompileTime\n          > PlainArray;\n\n    /** \\brief The plain matrix or array type corresponding to this expression.\n      *\n      * This is not necessarily exactly the return type of eval(). In the case of plain matrices,\n      * the return type of eval() is a const reference to a matrix, not a matrix! It is however guaranteed\n      * that the return type of eval() is either PlainObject or const PlainObject&.\n      */\n    typedef typename internal::conditional<internal::is_same<typename internal::traits<Derived>::XprKind,MatrixXpr >::value,\n                                 PlainMatrix, PlainArray>::type PlainObject;\n\n    /** \\returns the number of nonzero coefficients which is in practice the number\n      * of stored coefficients. */\n    EIGEN_DEVICE_FUNC\n    inline Index nonZeros() const { return size(); }\n\n    /** \\returns the outer size.\n      *\n      * \\note For a vector, this returns just 1. For a matrix (non-vector), this is the major dimension\n      * with respect to the \\ref TopicStorageOrders \"storage order\", i.e., the number of columns for a\n      * column-major matrix, and the number of rows for a row-major matrix. */\n    EIGEN_DEVICE_FUNC\n    Index outerSize() const\n    {\n      return IsVectorAtCompileTime ? 1\n           : int(IsRowMajor) ? this->rows() : this->cols();\n    }\n\n    /** \\returns the inner size.\n      *\n      * \\note For a vector, this is just the size. For a matrix (non-vector), this is the minor dimension\n      * with respect to the \\ref TopicStorageOrders \"storage order\", i.e., the number of rows for a \n      * column-major matrix, and the number of columns for a row-major matrix. */\n    EIGEN_DEVICE_FUNC\n    Index innerSize() const\n    {\n      return IsVectorAtCompileTime ? this->size()\n           : int(IsRowMajor) ? this->cols() : this->rows();\n    }\n\n    /** Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods are\n      * Matrix::resize() and Array::resize(). The present method only asserts that the new size equals the old size, and does\n      * nothing else.\n      */\n    EIGEN_DEVICE_FUNC\n    void resize(Index newSize)\n    {\n      EIGEN_ONLY_USED_FOR_DEBUG(newSize);\n      eigen_assert(newSize == this->size()\n                && \"DenseBase::resize() does not actually allow to resize.\");\n    }\n    /** Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods are\n      * Matrix::resize() and Array::resize(). The present method only asserts that the new size equals the old size, and does\n      * nothing else.\n      */\n    EIGEN_DEVICE_FUNC\n    void resize(Index rows, Index cols)\n    {\n      EIGEN_ONLY_USED_FOR_DEBUG(rows);\n      EIGEN_ONLY_USED_FOR_DEBUG(cols);\n      eigen_assert(rows == this->rows() && cols == this->cols()\n                && \"DenseBase::resize() does not actually allow to resize.\");\n    }\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** \\internal Represents a matrix with all coefficients equal to one another*/\n    typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,PlainObject> ConstantReturnType;\n    /** \\internal \\deprecated Represents a vector with linearly spaced coefficients that allows sequential access only. */\n    typedef CwiseNullaryOp<internal::linspaced_op<Scalar,PacketScalar>,PlainObject> SequentialLinSpacedReturnType;\n    /** \\internal Represents a vector with linearly spaced coefficients that allows random access. */\n    typedef CwiseNullaryOp<internal::linspaced_op<Scalar,PacketScalar>,PlainObject> RandomAccessLinSpacedReturnType;\n    /** \\internal the return type of MatrixBase::eigenvalues() */\n    typedef Matrix<typename NumTraits<typename internal::traits<Derived>::Scalar>::Real, internal::traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType;\n\n#endif // not EIGEN_PARSED_BY_DOXYGEN\n\n    /** Copies \\a other into *this. \\returns a reference to *this. */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator=(const DenseBase<OtherDerived>& other);\n\n    /** Special case of the template operator=, in order to prevent the compiler\n      * from generating a default operator= (issue hit with g++ 4.1)\n      */\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator=(const DenseBase& other);\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    Derived& operator=(const EigenBase<OtherDerived> &other);\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    Derived& operator+=(const EigenBase<OtherDerived> &other);\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    Derived& operator-=(const EigenBase<OtherDerived> &other);\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    Derived& operator=(const ReturnByValue<OtherDerived>& func);\n\n    /** \\internal\n      * Copies \\a other into *this without evaluating other. \\returns a reference to *this.\n      * \\deprecated */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    Derived& lazyAssign(const DenseBase<OtherDerived>& other);\n\n    EIGEN_DEVICE_FUNC\n    CommaInitializer<Derived> operator<< (const Scalar& s);\n\n    /** \\deprecated it now returns \\c *this */\n    template<unsigned int Added,unsigned int Removed>\n    EIGEN_DEPRECATED\n    const Derived& flagged() const\n    { return derived(); }\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    CommaInitializer<Derived> operator<< (const DenseBase<OtherDerived>& other);\n\n    typedef Transpose<Derived> TransposeReturnType;\n    EIGEN_DEVICE_FUNC\n    TransposeReturnType transpose();\n    typedef typename internal::add_const<Transpose<const Derived> >::type ConstTransposeReturnType;\n    EIGEN_DEVICE_FUNC\n    ConstTransposeReturnType transpose() const;\n    EIGEN_DEVICE_FUNC\n    void transposeInPlace();\n\n    EIGEN_DEVICE_FUNC static const ConstantReturnType\n    Constant(Index rows, Index cols, const Scalar& value);\n    EIGEN_DEVICE_FUNC static const ConstantReturnType\n    Constant(Index size, const Scalar& value);\n    EIGEN_DEVICE_FUNC static const ConstantReturnType\n    Constant(const Scalar& value);\n\n    EIGEN_DEVICE_FUNC static const SequentialLinSpacedReturnType\n    LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high);\n    EIGEN_DEVICE_FUNC static const RandomAccessLinSpacedReturnType\n    LinSpaced(Index size, const Scalar& low, const Scalar& high);\n    EIGEN_DEVICE_FUNC static const SequentialLinSpacedReturnType\n    LinSpaced(Sequential_t, const Scalar& low, const Scalar& high);\n    EIGEN_DEVICE_FUNC static const RandomAccessLinSpacedReturnType\n    LinSpaced(const Scalar& low, const Scalar& high);\n\n    template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC\n    static const CwiseNullaryOp<CustomNullaryOp, PlainObject>\n    NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func);\n    template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC\n    static const CwiseNullaryOp<CustomNullaryOp, PlainObject>\n    NullaryExpr(Index size, const CustomNullaryOp& func);\n    template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC\n    static const CwiseNullaryOp<CustomNullaryOp, PlainObject>\n    NullaryExpr(const CustomNullaryOp& func);\n\n    EIGEN_DEVICE_FUNC static const ConstantReturnType Zero(Index rows, Index cols);\n    EIGEN_DEVICE_FUNC static const ConstantReturnType Zero(Index size);\n    EIGEN_DEVICE_FUNC static const ConstantReturnType Zero();\n    EIGEN_DEVICE_FUNC static const ConstantReturnType Ones(Index rows, Index cols);\n    EIGEN_DEVICE_FUNC static const ConstantReturnType Ones(Index size);\n    EIGEN_DEVICE_FUNC static const ConstantReturnType Ones();\n\n    EIGEN_DEVICE_FUNC void fill(const Scalar& value);\n    EIGEN_DEVICE_FUNC Derived& setConstant(const Scalar& value);\n    EIGEN_DEVICE_FUNC Derived& setLinSpaced(Index size, const Scalar& low, const Scalar& high);\n    EIGEN_DEVICE_FUNC Derived& setLinSpaced(const Scalar& low, const Scalar& high);\n    EIGEN_DEVICE_FUNC Derived& setZero();\n    EIGEN_DEVICE_FUNC Derived& setOnes();\n    EIGEN_DEVICE_FUNC Derived& setRandom();\n\n    template<typename OtherDerived> EIGEN_DEVICE_FUNC\n    bool isApprox(const DenseBase<OtherDerived>& other,\n                  const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n    EIGEN_DEVICE_FUNC \n    bool isMuchSmallerThan(const RealScalar& other,\n                           const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n    template<typename OtherDerived> EIGEN_DEVICE_FUNC\n    bool isMuchSmallerThan(const DenseBase<OtherDerived>& other,\n                           const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n\n    EIGEN_DEVICE_FUNC bool isApproxToConstant(const Scalar& value, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n    EIGEN_DEVICE_FUNC bool isConstant(const Scalar& value, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n    EIGEN_DEVICE_FUNC bool isZero(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n    EIGEN_DEVICE_FUNC bool isOnes(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n    \n    inline bool hasNaN() const;\n    inline bool allFinite() const;\n\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator*=(const Scalar& other);\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator/=(const Scalar& other);\n\n    typedef typename internal::add_const_on_value_type<typename internal::eval<Derived>::type>::type EvalReturnType;\n    /** \\returns the matrix or vector obtained by evaluating this expression.\n      *\n      * Notice that in the case of a plain matrix or vector (not an expression) this function just returns\n      * a const reference, in order to avoid a useless copy.\n      * \n      * \\warning Be carefull with eval() and the auto C++ keyword, as detailed in this \\link TopicPitfalls_auto_keyword page \\endlink.\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE EvalReturnType eval() const\n    {\n      // Even though MSVC does not honor strong inlining when the return type\n      // is a dynamic matrix, we desperately need strong inlining for fixed\n      // size types on MSVC.\n      return typename internal::eval<Derived>::type(derived());\n    }\n    \n    /** swaps *this with the expression \\a other.\n      *\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    void swap(const DenseBase<OtherDerived>& other)\n    {\n      EIGEN_STATIC_ASSERT(!OtherDerived::IsPlainObjectBase,THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);\n      eigen_assert(rows()==other.rows() && cols()==other.cols());\n      call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());\n    }\n\n    /** swaps *this with the matrix or array \\a other.\n      *\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    void swap(PlainObjectBase<OtherDerived>& other)\n    {\n      eigen_assert(rows()==other.rows() && cols()==other.cols());\n      call_assignment(derived(), other.derived(), internal::swap_assign_op<Scalar>());\n    }\n\n    EIGEN_DEVICE_FUNC inline const NestByValue<Derived> nestByValue() const;\n    EIGEN_DEVICE_FUNC inline const ForceAlignedAccess<Derived> forceAlignedAccess() const;\n    EIGEN_DEVICE_FUNC inline ForceAlignedAccess<Derived> forceAlignedAccess();\n    template<bool Enable> EIGEN_DEVICE_FUNC\n    inline const typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf() const;\n    template<bool Enable> EIGEN_DEVICE_FUNC\n    inline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf();\n\n    EIGEN_DEVICE_FUNC Scalar sum() const;\n    EIGEN_DEVICE_FUNC Scalar mean() const;\n    EIGEN_DEVICE_FUNC Scalar trace() const;\n\n    EIGEN_DEVICE_FUNC Scalar prod() const;\n\n    EIGEN_DEVICE_FUNC typename internal::traits<Derived>::Scalar minCoeff() const;\n    EIGEN_DEVICE_FUNC typename internal::traits<Derived>::Scalar maxCoeff() const;\n\n    template<typename IndexType> EIGEN_DEVICE_FUNC\n    typename internal::traits<Derived>::Scalar minCoeff(IndexType* row, IndexType* col) const;\n    template<typename IndexType> EIGEN_DEVICE_FUNC\n    typename internal::traits<Derived>::Scalar maxCoeff(IndexType* row, IndexType* col) const;\n    template<typename IndexType> EIGEN_DEVICE_FUNC\n    typename internal::traits<Derived>::Scalar minCoeff(IndexType* index) const;\n    template<typename IndexType> EIGEN_DEVICE_FUNC\n    typename internal::traits<Derived>::Scalar maxCoeff(IndexType* index) const;\n\n    template<typename BinaryOp>\n    EIGEN_DEVICE_FUNC\n    Scalar redux(const BinaryOp& func) const;\n\n    template<typename Visitor>\n    EIGEN_DEVICE_FUNC\n    void visit(Visitor& func) const;\n\n    /** \\returns a WithFormat proxy object allowing to print a matrix the with given\n      * format \\a fmt.\n      *\n      * See class IOFormat for some examples.\n      *\n      * \\sa class IOFormat, class WithFormat\n      */\n    inline const WithFormat<Derived> format(const IOFormat& fmt) const\n    {\n      return WithFormat<Derived>(derived(), fmt);\n    }\n\n    /** \\returns the unique coefficient of a 1x1 expression */\n    EIGEN_DEVICE_FUNC\n    CoeffReturnType value() const\n    {\n      EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)\n      eigen_assert(this->rows() == 1 && this->cols() == 1);\n      return derived().coeff(0,0);\n    }\n\n    EIGEN_DEVICE_FUNC bool all() const;\n    EIGEN_DEVICE_FUNC bool any() const;\n    EIGEN_DEVICE_FUNC Index count() const;\n\n    typedef VectorwiseOp<Derived, Horizontal> RowwiseReturnType;\n    typedef const VectorwiseOp<const Derived, Horizontal> ConstRowwiseReturnType;\n    typedef VectorwiseOp<Derived, Vertical> ColwiseReturnType;\n    typedef const VectorwiseOp<const Derived, Vertical> ConstColwiseReturnType;\n\n    /** \\returns a VectorwiseOp wrapper of *this providing additional partial reduction operations\n    *\n    * Example: \\include MatrixBase_rowwise.cpp\n    * Output: \\verbinclude MatrixBase_rowwise.out\n    *\n    * \\sa colwise(), class VectorwiseOp, \\ref TutorialReductionsVisitorsBroadcasting\n    */\n    //Code moved here due to a CUDA compiler bug\n    EIGEN_DEVICE_FUNC inline ConstRowwiseReturnType rowwise() const {\n      return ConstRowwiseReturnType(derived());\n    }\n    EIGEN_DEVICE_FUNC RowwiseReturnType rowwise();\n\n    /** \\returns a VectorwiseOp wrapper of *this providing additional partial reduction operations\n    *\n    * Example: \\include MatrixBase_colwise.cpp\n    * Output: \\verbinclude MatrixBase_colwise.out\n    *\n    * \\sa rowwise(), class VectorwiseOp, \\ref TutorialReductionsVisitorsBroadcasting\n    */\n    EIGEN_DEVICE_FUNC inline ConstColwiseReturnType colwise() const {\n      return ConstColwiseReturnType(derived());\n    }\n    EIGEN_DEVICE_FUNC ColwiseReturnType colwise();\n\n    typedef CwiseNullaryOp<internal::scalar_random_op<Scalar>,PlainObject> RandomReturnType;\n    static const RandomReturnType Random(Index rows, Index cols);\n    static const RandomReturnType Random(Index size);\n    static const RandomReturnType Random();\n\n    template<typename ThenDerived,typename ElseDerived>\n    const Select<Derived,ThenDerived,ElseDerived>\n    select(const DenseBase<ThenDerived>& thenMatrix,\n           const DenseBase<ElseDerived>& elseMatrix) const;\n\n    template<typename ThenDerived>\n    inline const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>\n    select(const DenseBase<ThenDerived>& thenMatrix, const typename ThenDerived::Scalar& elseScalar) const;\n\n    template<typename ElseDerived>\n    inline const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >\n    select(const typename ElseDerived::Scalar& thenScalar, const DenseBase<ElseDerived>& elseMatrix) const;\n\n    template<int p> RealScalar lpNorm() const;\n\n    template<int RowFactor, int ColFactor>\n    EIGEN_DEVICE_FUNC\n    const Replicate<Derived,RowFactor,ColFactor> replicate() const;\n    /**\n    * \\return an expression of the replication of \\c *this\n    *\n    * Example: \\include MatrixBase_replicate_int_int.cpp\n    * Output: \\verbinclude MatrixBase_replicate_int_int.out\n    *\n    * \\sa VectorwiseOp::replicate(), DenseBase::replicate<int,int>(), class Replicate\n    */\n    //Code moved here due to a CUDA compiler bug\n    EIGEN_DEVICE_FUNC\n    const Replicate<Derived, Dynamic, Dynamic> replicate(Index rowFactor, Index colFactor) const\n    {\n      return Replicate<Derived, Dynamic, Dynamic>(derived(), rowFactor, colFactor);\n    }\n\n    typedef Reverse<Derived, BothDirections> ReverseReturnType;\n    typedef const Reverse<const Derived, BothDirections> ConstReverseReturnType;\n    EIGEN_DEVICE_FUNC ReverseReturnType reverse();\n    /** This is the const version of reverse(). */\n    //Code moved here due to a CUDA compiler bug\n    EIGEN_DEVICE_FUNC ConstReverseReturnType reverse() const\n    {\n      return ConstReverseReturnType(derived());\n    }\n    EIGEN_DEVICE_FUNC void reverseInPlace();\n\n#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase\n#define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n#define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND)\n#   include \"../plugins/BlockMethods.h\"\n#   ifdef EIGEN_DENSEBASE_PLUGIN\n#     include EIGEN_DENSEBASE_PLUGIN\n#   endif\n#undef EIGEN_CURRENT_STORAGE_BASE_CLASS\n#undef EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n#undef EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF\n\n    // disable the use of evalTo for dense objects with a nice compilation error\n    template<typename Dest>\n    EIGEN_DEVICE_FUNC\n    inline void evalTo(Dest& ) const\n    {\n      EIGEN_STATIC_ASSERT((internal::is_same<Dest,void>::value),THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS);\n    }\n\n  protected:\n    /** Default constructor. Do nothing. */\n    EIGEN_DEVICE_FUNC DenseBase()\n    {\n      /* Just checks for self-consistency of the flags.\n       * Only do it when debugging Eigen, as this borders on paranoiac and could slow compilation down\n       */\n#ifdef EIGEN_INTERNAL_DEBUGGING\n      EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, int(IsRowMajor))\n                        && EIGEN_IMPLIES(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, int(!IsRowMajor))),\n                          INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION)\n#endif\n    }\n\n  private:\n    EIGEN_DEVICE_FUNC explicit DenseBase(int);\n    EIGEN_DEVICE_FUNC DenseBase(int,int);\n    template<typename OtherDerived> EIGEN_DEVICE_FUNC explicit DenseBase(const DenseBase<OtherDerived>&);\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_DENSEBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/DenseCoeffsBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_DENSECOEFFSBASE_H\n#define EIGEN_DENSECOEFFSBASE_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate<typename T> struct add_const_on_value_type_if_arithmetic\n{\n  typedef typename conditional<is_arithmetic<T>::value, T, typename add_const_on_value_type<T>::type>::type type;\n};\n}\n\n/** \\brief Base class providing read-only coefficient access to matrices and arrays.\n  * \\ingroup Core_Module\n  * \\tparam Derived Type of the derived class\n  * \\tparam #ReadOnlyAccessors Constant indicating read-only access\n  *\n  * This class defines the \\c operator() \\c const function and friends, which can be used to read specific\n  * entries of a matrix or array.\n  * \n  * \\sa DenseCoeffsBase<Derived, WriteAccessors>, DenseCoeffsBase<Derived, DirectAccessors>,\n  *     \\ref TopicClassHierarchy\n  */\ntemplate<typename Derived>\nclass DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived>\n{\n  public:\n    typedef typename internal::traits<Derived>::StorageKind StorageKind;\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    typedef typename internal::packet_traits<Scalar>::type PacketScalar;\n\n    // Explanation for this CoeffReturnType typedef.\n    // - This is the return type of the coeff() method.\n    // - The LvalueBit means exactly that we can offer a coeffRef() method, which means exactly that we can get references\n    // to coeffs, which means exactly that we can have coeff() return a const reference (as opposed to returning a value).\n    // - The is_artihmetic check is required since \"const int\", \"const double\", etc. will cause warnings on some systems\n    // while the declaration of \"const T\", where T is a non arithmetic type does not. Always returning \"const Scalar&\" is\n    // not possible, since the underlying expressions might not offer a valid address the reference could be referring to.\n    typedef typename internal::conditional<bool(internal::traits<Derived>::Flags&LvalueBit),\n                         const Scalar&,\n                         typename internal::conditional<internal::is_arithmetic<Scalar>::value, Scalar, const Scalar>::type\n                     >::type CoeffReturnType;\n\n    typedef typename internal::add_const_on_value_type_if_arithmetic<\n                         typename internal::packet_traits<Scalar>::type\n                     >::type PacketReturnType;\n\n    typedef EigenBase<Derived> Base;\n    using Base::rows;\n    using Base::cols;\n    using Base::size;\n    using Base::derived;\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Index rowIndexByOuterInner(Index outer, Index inner) const\n    {\n      return int(Derived::RowsAtCompileTime) == 1 ? 0\n          : int(Derived::ColsAtCompileTime) == 1 ? inner\n          : int(Derived::Flags)&RowMajorBit ? outer\n          : inner;\n    }\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Index colIndexByOuterInner(Index outer, Index inner) const\n    {\n      return int(Derived::ColsAtCompileTime) == 1 ? 0\n          : int(Derived::RowsAtCompileTime) == 1 ? inner\n          : int(Derived::Flags)&RowMajorBit ? inner\n          : outer;\n    }\n\n    /** Short version: don't use this function, use\n      * \\link operator()(Index,Index) const \\endlink instead.\n      *\n      * Long version: this function is similar to\n      * \\link operator()(Index,Index) const \\endlink, but without the assertion.\n      * Use this for limiting the performance cost of debugging code when doing\n      * repeated coefficient access. Only use this when it is guaranteed that the\n      * parameters \\a row and \\a col are in range.\n      *\n      * If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this\n      * function equivalent to \\link operator()(Index,Index) const \\endlink.\n      *\n      * \\sa operator()(Index,Index) const, coeffRef(Index,Index), coeff(Index) const\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const\n    {\n      eigen_internal_assert(row >= 0 && row < rows()\n                         && col >= 0 && col < cols());\n      return internal::evaluator<Derived>(derived()).coeff(row,col);\n    }\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE CoeffReturnType coeffByOuterInner(Index outer, Index inner) const\n    {\n      return coeff(rowIndexByOuterInner(outer, inner),\n                   colIndexByOuterInner(outer, inner));\n    }\n\n    /** \\returns the coefficient at given the given row and column.\n      *\n      * \\sa operator()(Index,Index), operator[](Index)\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE CoeffReturnType operator()(Index row, Index col) const\n    {\n      eigen_assert(row >= 0 && row < rows()\n          && col >= 0 && col < cols());\n      return coeff(row, col);\n    }\n\n    /** Short version: don't use this function, use\n      * \\link operator[](Index) const \\endlink instead.\n      *\n      * Long version: this function is similar to\n      * \\link operator[](Index) const \\endlink, but without the assertion.\n      * Use this for limiting the performance cost of debugging code when doing\n      * repeated coefficient access. Only use this when it is guaranteed that the\n      * parameter \\a index is in range.\n      *\n      * If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this\n      * function equivalent to \\link operator[](Index) const \\endlink.\n      *\n      * \\sa operator[](Index) const, coeffRef(Index), coeff(Index,Index) const\n      */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE CoeffReturnType\n    coeff(Index index) const\n    {\n      EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags & LinearAccessBit,\n                          THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)\n      eigen_internal_assert(index >= 0 && index < size());\n      return internal::evaluator<Derived>(derived()).coeff(index);\n    }\n\n\n    /** \\returns the coefficient at given index.\n      *\n      * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.\n      *\n      * \\sa operator[](Index), operator()(Index,Index) const, x() const, y() const,\n      * z() const, w() const\n      */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE CoeffReturnType\n    operator[](Index index) const\n    {\n      EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,\n                          THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)\n      eigen_assert(index >= 0 && index < size());\n      return coeff(index);\n    }\n\n    /** \\returns the coefficient at given index.\n      *\n      * This is synonymous to operator[](Index) const.\n      *\n      * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.\n      *\n      * \\sa operator[](Index), operator()(Index,Index) const, x() const, y() const,\n      * z() const, w() const\n      */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE CoeffReturnType\n    operator()(Index index) const\n    {\n      eigen_assert(index >= 0 && index < size());\n      return coeff(index);\n    }\n\n    /** equivalent to operator[](0).  */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE CoeffReturnType\n    x() const { return (*this)[0]; }\n\n    /** equivalent to operator[](1).  */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE CoeffReturnType\n    y() const\n    {\n      EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=2, OUT_OF_RANGE_ACCESS);\n      return (*this)[1];\n    }\n\n    /** equivalent to operator[](2).  */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE CoeffReturnType\n    z() const\n    {\n      EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=3, OUT_OF_RANGE_ACCESS);\n      return (*this)[2];\n    }\n\n    /** equivalent to operator[](3).  */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE CoeffReturnType\n    w() const\n    {\n      EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=4, OUT_OF_RANGE_ACCESS);\n      return (*this)[3];\n    }\n\n    /** \\internal\n      * \\returns the packet of coefficients starting at the given row and column. It is your responsibility\n      * to ensure that a packet really starts there. This method is only available on expressions having the\n      * PacketAccessBit.\n      *\n      * The \\a LoadMode parameter may have the value \\a #Aligned or \\a #Unaligned. Its effect is to select\n      * the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets\n      * starting at an address which is a multiple of the packet size.\n      */\n\n    template<int LoadMode>\n    EIGEN_STRONG_INLINE PacketReturnType packet(Index row, Index col) const\n    {\n      typedef typename internal::packet_traits<Scalar>::type DefaultPacketType;\n      eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols());\n      return internal::evaluator<Derived>(derived()).template packet<LoadMode,DefaultPacketType>(row,col);\n    }\n\n\n    /** \\internal */\n    template<int LoadMode>\n    EIGEN_STRONG_INLINE PacketReturnType packetByOuterInner(Index outer, Index inner) const\n    {\n      return packet<LoadMode>(rowIndexByOuterInner(outer, inner),\n                              colIndexByOuterInner(outer, inner));\n    }\n\n    /** \\internal\n      * \\returns the packet of coefficients starting at the given index. It is your responsibility\n      * to ensure that a packet really starts there. This method is only available on expressions having the\n      * PacketAccessBit and the LinearAccessBit.\n      *\n      * The \\a LoadMode parameter may have the value \\a #Aligned or \\a #Unaligned. Its effect is to select\n      * the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets\n      * starting at an address which is a multiple of the packet size.\n      */\n\n    template<int LoadMode>\n    EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const\n    {\n      EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags & LinearAccessBit,\n                          THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)\n      typedef typename internal::packet_traits<Scalar>::type DefaultPacketType;\n      eigen_internal_assert(index >= 0 && index < size());\n      return internal::evaluator<Derived>(derived()).template packet<LoadMode,DefaultPacketType>(index);\n    }\n\n  protected:\n    // explanation: DenseBase is doing \"using ...\" on the methods from DenseCoeffsBase.\n    // But some methods are only available in the DirectAccess case.\n    // So we add dummy methods here with these names, so that \"using... \" doesn't fail.\n    // It's not private so that the child class DenseBase can access them, and it's not public\n    // either since it's an implementation detail, so has to be protected.\n    void coeffRef();\n    void coeffRefByOuterInner();\n    void writePacket();\n    void writePacketByOuterInner();\n    void copyCoeff();\n    void copyCoeffByOuterInner();\n    void copyPacket();\n    void copyPacketByOuterInner();\n    void stride();\n    void innerStride();\n    void outerStride();\n    void rowStride();\n    void colStride();\n};\n\n/** \\brief Base class providing read/write coefficient access to matrices and arrays.\n  * \\ingroup Core_Module\n  * \\tparam Derived Type of the derived class\n  * \\tparam #WriteAccessors Constant indicating read/write access\n  *\n  * This class defines the non-const \\c operator() function and friends, which can be used to write specific\n  * entries of a matrix or array. This class inherits DenseCoeffsBase<Derived, ReadOnlyAccessors> which\n  * defines the const variant for reading specific entries.\n  * \n  * \\sa DenseCoeffsBase<Derived, DirectAccessors>, \\ref TopicClassHierarchy\n  */\ntemplate<typename Derived>\nclass DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, ReadOnlyAccessors>\n{\n  public:\n\n    typedef DenseCoeffsBase<Derived, ReadOnlyAccessors> Base;\n\n    typedef typename internal::traits<Derived>::StorageKind StorageKind;\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    typedef typename internal::packet_traits<Scalar>::type PacketScalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n\n    using Base::coeff;\n    using Base::rows;\n    using Base::cols;\n    using Base::size;\n    using Base::derived;\n    using Base::rowIndexByOuterInner;\n    using Base::colIndexByOuterInner;\n    using Base::operator[];\n    using Base::operator();\n    using Base::x;\n    using Base::y;\n    using Base::z;\n    using Base::w;\n\n    /** Short version: don't use this function, use\n      * \\link operator()(Index,Index) \\endlink instead.\n      *\n      * Long version: this function is similar to\n      * \\link operator()(Index,Index) \\endlink, but without the assertion.\n      * Use this for limiting the performance cost of debugging code when doing\n      * repeated coefficient access. Only use this when it is guaranteed that the\n      * parameters \\a row and \\a col are in range.\n      *\n      * If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this\n      * function equivalent to \\link operator()(Index,Index) \\endlink.\n      *\n      * \\sa operator()(Index,Index), coeff(Index, Index) const, coeffRef(Index)\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col)\n    {\n      eigen_internal_assert(row >= 0 && row < rows()\n                         && col >= 0 && col < cols());\n      return internal::evaluator<Derived>(derived()).coeffRef(row,col);\n    }\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar&\n    coeffRefByOuterInner(Index outer, Index inner)\n    {\n      return coeffRef(rowIndexByOuterInner(outer, inner),\n                      colIndexByOuterInner(outer, inner));\n    }\n\n    /** \\returns a reference to the coefficient at given the given row and column.\n      *\n      * \\sa operator[](Index)\n      */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar&\n    operator()(Index row, Index col)\n    {\n      eigen_assert(row >= 0 && row < rows()\n          && col >= 0 && col < cols());\n      return coeffRef(row, col);\n    }\n\n\n    /** Short version: don't use this function, use\n      * \\link operator[](Index) \\endlink instead.\n      *\n      * Long version: this function is similar to\n      * \\link operator[](Index) \\endlink, but without the assertion.\n      * Use this for limiting the performance cost of debugging code when doing\n      * repeated coefficient access. Only use this when it is guaranteed that the\n      * parameters \\a row and \\a col are in range.\n      *\n      * If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this\n      * function equivalent to \\link operator[](Index) \\endlink.\n      *\n      * \\sa operator[](Index), coeff(Index) const, coeffRef(Index,Index)\n      */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar&\n    coeffRef(Index index)\n    {\n      EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags & LinearAccessBit,\n                          THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS)\n      eigen_internal_assert(index >= 0 && index < size());\n      return internal::evaluator<Derived>(derived()).coeffRef(index);\n    }\n\n    /** \\returns a reference to the coefficient at given index.\n      *\n      * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.\n      *\n      * \\sa operator[](Index) const, operator()(Index,Index), x(), y(), z(), w()\n      */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar&\n    operator[](Index index)\n    {\n      EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,\n                          THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)\n      eigen_assert(index >= 0 && index < size());\n      return coeffRef(index);\n    }\n\n    /** \\returns a reference to the coefficient at given index.\n      *\n      * This is synonymous to operator[](Index).\n      *\n      * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.\n      *\n      * \\sa operator[](Index) const, operator()(Index,Index), x(), y(), z(), w()\n      */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar&\n    operator()(Index index)\n    {\n      eigen_assert(index >= 0 && index < size());\n      return coeffRef(index);\n    }\n\n    /** equivalent to operator[](0).  */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar&\n    x() { return (*this)[0]; }\n\n    /** equivalent to operator[](1).  */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar&\n    y()\n    {\n      EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=2, OUT_OF_RANGE_ACCESS);\n      return (*this)[1];\n    }\n\n    /** equivalent to operator[](2).  */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar&\n    z()\n    {\n      EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=3, OUT_OF_RANGE_ACCESS);\n      return (*this)[2];\n    }\n\n    /** equivalent to operator[](3).  */\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar&\n    w()\n    {\n      EIGEN_STATIC_ASSERT(Derived::SizeAtCompileTime==-1 || Derived::SizeAtCompileTime>=4, OUT_OF_RANGE_ACCESS);\n      return (*this)[3];\n    }\n};\n\n/** \\brief Base class providing direct read-only coefficient access to matrices and arrays.\n  * \\ingroup Core_Module\n  * \\tparam Derived Type of the derived class\n  * \\tparam #DirectAccessors Constant indicating direct access\n  *\n  * This class defines functions to work with strides which can be used to access entries directly. This class\n  * inherits DenseCoeffsBase<Derived, ReadOnlyAccessors> which defines functions to access entries read-only using\n  * \\c operator() .\n  *\n  * \\sa \\blank \\ref TopicClassHierarchy\n  */\ntemplate<typename Derived>\nclass DenseCoeffsBase<Derived, DirectAccessors> : public DenseCoeffsBase<Derived, ReadOnlyAccessors>\n{\n  public:\n\n    typedef DenseCoeffsBase<Derived, ReadOnlyAccessors> Base;\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n\n    using Base::rows;\n    using Base::cols;\n    using Base::size;\n    using Base::derived;\n\n    /** \\returns the pointer increment between two consecutive elements within a slice in the inner direction.\n      *\n      * \\sa outerStride(), rowStride(), colStride()\n      */\n    EIGEN_DEVICE_FUNC\n    inline Index innerStride() const\n    {\n      return derived().innerStride();\n    }\n\n    /** \\returns the pointer increment between two consecutive inner slices (for example, between two consecutive columns\n      *          in a column-major matrix).\n      *\n      * \\sa innerStride(), rowStride(), colStride()\n      */\n    EIGEN_DEVICE_FUNC\n    inline Index outerStride() const\n    {\n      return derived().outerStride();\n    }\n\n    // FIXME shall we remove it ?\n    inline Index stride() const\n    {\n      return Derived::IsVectorAtCompileTime ? innerStride() : outerStride();\n    }\n\n    /** \\returns the pointer increment between two consecutive rows.\n      *\n      * \\sa innerStride(), outerStride(), colStride()\n      */\n    EIGEN_DEVICE_FUNC\n    inline Index rowStride() const\n    {\n      return Derived::IsRowMajor ? outerStride() : innerStride();\n    }\n\n    /** \\returns the pointer increment between two consecutive columns.\n      *\n      * \\sa innerStride(), outerStride(), rowStride()\n      */\n    EIGEN_DEVICE_FUNC\n    inline Index colStride() const\n    {\n      return Derived::IsRowMajor ? innerStride() : outerStride();\n    }\n};\n\n/** \\brief Base class providing direct read/write coefficient access to matrices and arrays.\n  * \\ingroup Core_Module\n  * \\tparam Derived Type of the derived class\n  * \\tparam #DirectWriteAccessors Constant indicating direct access\n  *\n  * This class defines functions to work with strides which can be used to access entries directly. This class\n  * inherits DenseCoeffsBase<Derived, WriteAccessors> which defines functions to access entries read/write using\n  * \\c operator().\n  *\n  * \\sa \\blank \\ref TopicClassHierarchy\n  */\ntemplate<typename Derived>\nclass DenseCoeffsBase<Derived, DirectWriteAccessors>\n  : public DenseCoeffsBase<Derived, WriteAccessors>\n{\n  public:\n\n    typedef DenseCoeffsBase<Derived, WriteAccessors> Base;\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n\n    using Base::rows;\n    using Base::cols;\n    using Base::size;\n    using Base::derived;\n\n    /** \\returns the pointer increment between two consecutive elements within a slice in the inner direction.\n      *\n      * \\sa outerStride(), rowStride(), colStride()\n      */\n    EIGEN_DEVICE_FUNC\n    inline Index innerStride() const\n    {\n      return derived().innerStride();\n    }\n\n    /** \\returns the pointer increment between two consecutive inner slices (for example, between two consecutive columns\n      *          in a column-major matrix).\n      *\n      * \\sa innerStride(), rowStride(), colStride()\n      */\n    EIGEN_DEVICE_FUNC\n    inline Index outerStride() const\n    {\n      return derived().outerStride();\n    }\n\n    // FIXME shall we remove it ?\n    inline Index stride() const\n    {\n      return Derived::IsVectorAtCompileTime ? innerStride() : outerStride();\n    }\n\n    /** \\returns the pointer increment between two consecutive rows.\n      *\n      * \\sa innerStride(), outerStride(), colStride()\n      */\n    EIGEN_DEVICE_FUNC\n    inline Index rowStride() const\n    {\n      return Derived::IsRowMajor ? outerStride() : innerStride();\n    }\n\n    /** \\returns the pointer increment between two consecutive columns.\n      *\n      * \\sa innerStride(), outerStride(), rowStride()\n      */\n    EIGEN_DEVICE_FUNC\n    inline Index colStride() const\n    {\n      return Derived::IsRowMajor ? innerStride() : outerStride();\n    }\n};\n\nnamespace internal {\n\ntemplate<int Alignment, typename Derived, bool JustReturnZero>\nstruct first_aligned_impl\n{\n  static inline Index run(const Derived&)\n  { return 0; }\n};\n\ntemplate<int Alignment, typename Derived>\nstruct first_aligned_impl<Alignment, Derived, false>\n{\n  static inline Index run(const Derived& m)\n  {\n    return internal::first_aligned<Alignment>(m.data(), m.size());\n  }\n};\n\n/** \\internal \\returns the index of the first element of the array stored by \\a m that is properly aligned with respect to \\a Alignment for vectorization.\n  *\n  * \\tparam Alignment requested alignment in Bytes.\n  *\n  * There is also the variant first_aligned(const Scalar*, Integer) defined in Memory.h. See it for more\n  * documentation.\n  */\ntemplate<int Alignment, typename Derived>\nstatic inline Index first_aligned(const DenseBase<Derived>& m)\n{\n  enum { ReturnZero = (int(evaluator<Derived>::Alignment) >= Alignment) || !(Derived::Flags & DirectAccessBit) };\n  return first_aligned_impl<Alignment, Derived, ReturnZero>::run(m.derived());\n}\n\ntemplate<typename Derived>\nstatic inline Index first_default_aligned(const DenseBase<Derived>& m)\n{\n  typedef typename Derived::Scalar Scalar;\n  typedef typename packet_traits<Scalar>::type DefaultPacketType;\n  return internal::first_aligned<int(unpacket_traits<DefaultPacketType>::alignment),Derived>(m);\n}\n\ntemplate<typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret>\nstruct inner_stride_at_compile_time\n{\n  enum { ret = traits<Derived>::InnerStrideAtCompileTime };\n};\n\ntemplate<typename Derived>\nstruct inner_stride_at_compile_time<Derived, false>\n{\n  enum { ret = 0 };\n};\n\ntemplate<typename Derived, bool HasDirectAccess = has_direct_access<Derived>::ret>\nstruct outer_stride_at_compile_time\n{\n  enum { ret = traits<Derived>::OuterStrideAtCompileTime };\n};\n\ntemplate<typename Derived>\nstruct outer_stride_at_compile_time<Derived, false>\n{\n  enum { ret = 0 };\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_DENSECOEFFSBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/DenseStorage.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2010-2013 Hauke Heibel <hauke.heibel@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MATRIXSTORAGE_H\n#define EIGEN_MATRIXSTORAGE_H\n\n#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n  #define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X) X; EIGEN_DENSE_STORAGE_CTOR_PLUGIN;\n#else\n  #define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X)\n#endif\n\nnamespace Eigen {\n\nnamespace internal {\n\nstruct constructor_without_unaligned_array_assert {};\n\ntemplate<typename T, int Size>\nEIGEN_DEVICE_FUNC\nvoid check_static_allocation_size()\n{\n  // if EIGEN_STACK_ALLOCATION_LIMIT is defined to 0, then no limit\n  #if EIGEN_STACK_ALLOCATION_LIMIT\n  EIGEN_STATIC_ASSERT(Size * sizeof(T) <= EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);\n  #endif\n}\n\n/** \\internal\n  * Static array. If the MatrixOrArrayOptions require auto-alignment, the array will be automatically aligned:\n  * to 16 bytes boundary if the total size is a multiple of 16 bytes.\n  */\ntemplate <typename T, int Size, int MatrixOrArrayOptions,\n          int Alignment = (MatrixOrArrayOptions&DontAlign) ? 0\n                        : compute_default_alignment<T,Size>::value >\nstruct plain_array\n{\n  T array[Size];\n\n  EIGEN_DEVICE_FUNC\n  plain_array()\n  { \n    check_static_allocation_size<T,Size>();\n  }\n\n  EIGEN_DEVICE_FUNC\n  plain_array(constructor_without_unaligned_array_assert)\n  { \n    check_static_allocation_size<T,Size>();\n  }\n};\n\n#if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)\n  #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask)\n#elif EIGEN_GNUC_AT_LEAST(4,7) \n  // GCC 4.7 is too aggressive in its optimizations and remove the alignement test based on the fact the array is declared to be aligned.\n  // See this bug report: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53900\n  // Hiding the origin of the array pointer behind a function argument seems to do the trick even if the function is inlined:\n  template<typename PtrType>\n  EIGEN_ALWAYS_INLINE PtrType eigen_unaligned_array_assert_workaround_gcc47(PtrType array) { return array; }\n  #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \\\n    eigen_assert((internal::UIntPtr(eigen_unaligned_array_assert_workaround_gcc47(array)) & (sizemask)) == 0 \\\n              && \"this assertion is explained here: \" \\\n              \"http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html\" \\\n              \" **** READ THIS WEB PAGE !!! ****\");\n#else\n  #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \\\n    eigen_assert((internal::UIntPtr(array) & (sizemask)) == 0 \\\n              && \"this assertion is explained here: \" \\\n              \"http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html\" \\\n              \" **** READ THIS WEB PAGE !!! ****\");\n#endif\n\ntemplate <typename T, int Size, int MatrixOrArrayOptions>\nstruct plain_array<T, Size, MatrixOrArrayOptions, 8>\n{\n  EIGEN_ALIGN_TO_BOUNDARY(8) T array[Size];\n\n  EIGEN_DEVICE_FUNC\n  plain_array() \n  {\n    EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(7);\n    check_static_allocation_size<T,Size>();\n  }\n\n  EIGEN_DEVICE_FUNC\n  plain_array(constructor_without_unaligned_array_assert) \n  { \n    check_static_allocation_size<T,Size>();\n  }\n};\n\ntemplate <typename T, int Size, int MatrixOrArrayOptions>\nstruct plain_array<T, Size, MatrixOrArrayOptions, 16>\n{\n  EIGEN_ALIGN_TO_BOUNDARY(16) T array[Size];\n\n  EIGEN_DEVICE_FUNC\n  plain_array() \n  { \n    EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(15);\n    check_static_allocation_size<T,Size>();\n  }\n\n  EIGEN_DEVICE_FUNC\n  plain_array(constructor_without_unaligned_array_assert) \n  { \n    check_static_allocation_size<T,Size>();\n  }\n};\n\ntemplate <typename T, int Size, int MatrixOrArrayOptions>\nstruct plain_array<T, Size, MatrixOrArrayOptions, 32>\n{\n  EIGEN_ALIGN_TO_BOUNDARY(32) T array[Size];\n\n  EIGEN_DEVICE_FUNC\n  plain_array() \n  {\n    EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(31);\n    check_static_allocation_size<T,Size>();\n  }\n\n  EIGEN_DEVICE_FUNC\n  plain_array(constructor_without_unaligned_array_assert) \n  { \n    check_static_allocation_size<T,Size>();\n  }\n};\n\ntemplate <typename T, int Size, int MatrixOrArrayOptions>\nstruct plain_array<T, Size, MatrixOrArrayOptions, 64>\n{\n  EIGEN_ALIGN_TO_BOUNDARY(64) T array[Size];\n\n  EIGEN_DEVICE_FUNC\n  plain_array() \n  { \n    EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(63);\n    check_static_allocation_size<T,Size>();\n  }\n\n  EIGEN_DEVICE_FUNC\n  plain_array(constructor_without_unaligned_array_assert) \n  { \n    check_static_allocation_size<T,Size>();\n  }\n};\n\ntemplate <typename T, int MatrixOrArrayOptions, int Alignment>\nstruct plain_array<T, 0, MatrixOrArrayOptions, Alignment>\n{\n  T array[1];\n  EIGEN_DEVICE_FUNC plain_array() {}\n  EIGEN_DEVICE_FUNC plain_array(constructor_without_unaligned_array_assert) {}\n};\n\n} // end namespace internal\n\n/** \\internal\n  *\n  * \\class DenseStorage\n  * \\ingroup Core_Module\n  *\n  * \\brief Stores the data of a matrix\n  *\n  * This class stores the data of fixed-size, dynamic-size or mixed matrices\n  * in a way as compact as possible.\n  *\n  * \\sa Matrix\n  */\ntemplate<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseStorage;\n\n// purely fixed-size matrix\ntemplate<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseStorage\n{\n    internal::plain_array<T,Size,_Options> m_data;\n  public:\n    EIGEN_DEVICE_FUNC DenseStorage() {\n      EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size)\n    }\n    EIGEN_DEVICE_FUNC\n    explicit DenseStorage(internal::constructor_without_unaligned_array_assert)\n      : m_data(internal::constructor_without_unaligned_array_assert()) {}\n    EIGEN_DEVICE_FUNC \n    DenseStorage(const DenseStorage& other) : m_data(other.m_data) {\n      EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size)\n    }\n    EIGEN_DEVICE_FUNC \n    DenseStorage& operator=(const DenseStorage& other)\n    { \n      if (this != &other) m_data = other.m_data;\n      return *this; \n    }\n    EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols) {\n      EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})\n      eigen_internal_assert(size==rows*cols && rows==_Rows && cols==_Cols);\n      EIGEN_UNUSED_VARIABLE(size);\n      EIGEN_UNUSED_VARIABLE(rows);\n      EIGEN_UNUSED_VARIABLE(cols);\n    }\n    EIGEN_DEVICE_FUNC void swap(DenseStorage& other) { std::swap(m_data,other.m_data); }\n    EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;}\n    EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;}\n    EIGEN_DEVICE_FUNC void conservativeResize(Index,Index,Index) {}\n    EIGEN_DEVICE_FUNC void resize(Index,Index,Index) {}\n    EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }\n    EIGEN_DEVICE_FUNC T *data() { return m_data.array; }\n};\n\n// null matrix\ntemplate<typename T, int _Rows, int _Cols, int _Options> class DenseStorage<T, 0, _Rows, _Cols, _Options>\n{\n  public:\n    EIGEN_DEVICE_FUNC DenseStorage() {}\n    EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert) {}\n    EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage&) {}\n    EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage&) { return *this; }\n    EIGEN_DEVICE_FUNC DenseStorage(Index,Index,Index) {}\n    EIGEN_DEVICE_FUNC void swap(DenseStorage& ) {}\n    EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;}\n    EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;}\n    EIGEN_DEVICE_FUNC void conservativeResize(Index,Index,Index) {}\n    EIGEN_DEVICE_FUNC void resize(Index,Index,Index) {}\n    EIGEN_DEVICE_FUNC const T *data() const { return 0; }\n    EIGEN_DEVICE_FUNC T *data() { return 0; }\n};\n\n// more specializations for null matrices; these are necessary to resolve ambiguities\ntemplate<typename T, int _Options> class DenseStorage<T, 0, Dynamic, Dynamic, _Options>\n: public DenseStorage<T, 0, 0, 0, _Options> { };\n\ntemplate<typename T, int _Rows, int _Options> class DenseStorage<T, 0, _Rows, Dynamic, _Options>\n: public DenseStorage<T, 0, 0, 0, _Options> { };\n\ntemplate<typename T, int _Cols, int _Options> class DenseStorage<T, 0, Dynamic, _Cols, _Options>\n: public DenseStorage<T, 0, 0, 0, _Options> { };\n\n// dynamic-size matrix with fixed-size storage\ntemplate<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic, Dynamic, _Options>\n{\n    internal::plain_array<T,Size,_Options> m_data;\n    Index m_rows;\n    Index m_cols;\n  public:\n    EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0), m_cols(0) {}\n    EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert)\n      : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {}\n    EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {}\n    EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other) \n    { \n      if (this != &other)\n      {\n        m_data = other.m_data;\n        m_rows = other.m_rows;\n        m_cols = other.m_cols;\n      }\n      return *this; \n    }\n    EIGEN_DEVICE_FUNC DenseStorage(Index, Index rows, Index cols) : m_rows(rows), m_cols(cols) {}\n    EIGEN_DEVICE_FUNC void swap(DenseStorage& other)\n    { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }\n    EIGEN_DEVICE_FUNC Index rows() const {return m_rows;}\n    EIGEN_DEVICE_FUNC Index cols() const {return m_cols;}\n    EIGEN_DEVICE_FUNC void conservativeResize(Index, Index rows, Index cols) { m_rows = rows; m_cols = cols; }\n    EIGEN_DEVICE_FUNC void resize(Index, Index rows, Index cols) { m_rows = rows; m_cols = cols; }\n    EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }\n    EIGEN_DEVICE_FUNC T *data() { return m_data.array; }\n};\n\n// dynamic-size matrix with fixed-size storage and fixed width\ntemplate<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Size, Dynamic, _Cols, _Options>\n{\n    internal::plain_array<T,Size,_Options> m_data;\n    Index m_rows;\n  public:\n    EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0) {}\n    EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert)\n      : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0) {}\n    EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows) {}\n    EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other) \n    {\n      if (this != &other)\n      {\n        m_data = other.m_data;\n        m_rows = other.m_rows;\n      }\n      return *this; \n    }\n    EIGEN_DEVICE_FUNC DenseStorage(Index, Index rows, Index) : m_rows(rows) {}\n    EIGEN_DEVICE_FUNC void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }\n    EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;}\n    EIGEN_DEVICE_FUNC Index cols(void) const {return _Cols;}\n    EIGEN_DEVICE_FUNC void conservativeResize(Index, Index rows, Index) { m_rows = rows; }\n    EIGEN_DEVICE_FUNC void resize(Index, Index rows, Index) { m_rows = rows; }\n    EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }\n    EIGEN_DEVICE_FUNC T *data() { return m_data.array; }\n};\n\n// dynamic-size matrix with fixed-size storage and fixed height\ntemplate<typename T, int Size, int _Rows, int _Options> class DenseStorage<T, Size, _Rows, Dynamic, _Options>\n{\n    internal::plain_array<T,Size,_Options> m_data;\n    Index m_cols;\n  public:\n    EIGEN_DEVICE_FUNC DenseStorage() : m_cols(0) {}\n    EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert)\n      : m_data(internal::constructor_without_unaligned_array_assert()), m_cols(0) {}\n    EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_cols(other.m_cols) {}\n    EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)\n    {\n      if (this != &other)\n      {\n        m_data = other.m_data;\n        m_cols = other.m_cols;\n      }\n      return *this;\n    }\n    EIGEN_DEVICE_FUNC DenseStorage(Index, Index, Index cols) : m_cols(cols) {}\n    EIGEN_DEVICE_FUNC void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }\n    EIGEN_DEVICE_FUNC Index rows(void) const {return _Rows;}\n    EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;}\n    void conservativeResize(Index, Index, Index cols) { m_cols = cols; }\n    void resize(Index, Index, Index cols) { m_cols = cols; }\n    EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }\n    EIGEN_DEVICE_FUNC T *data() { return m_data.array; }\n};\n\n// purely dynamic matrix.\ntemplate<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynamic, _Options>\n{\n    T *m_data;\n    Index m_rows;\n    Index m_cols;\n  public:\n    EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_rows(0), m_cols(0) {}\n    EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert)\n       : m_data(0), m_rows(0), m_cols(0) {}\n    EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols)\n      : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(rows), m_cols(cols)\n    {\n      EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})\n      eigen_internal_assert(size==rows*cols && rows>=0 && cols >=0);\n    }\n    EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)\n      : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(other.m_rows*other.m_cols))\n      , m_rows(other.m_rows)\n      , m_cols(other.m_cols)\n    {\n      EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_rows*m_cols)\n      internal::smart_copy(other.m_data, other.m_data+other.m_rows*other.m_cols, m_data);\n    }\n    EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)\n    {\n      if (this != &other)\n      {\n        DenseStorage tmp(other);\n        this->swap(tmp);\n      }\n      return *this;\n    }\n#if EIGEN_HAS_RVALUE_REFERENCES\n    EIGEN_DEVICE_FUNC\n    DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT\n      : m_data(std::move(other.m_data))\n      , m_rows(std::move(other.m_rows))\n      , m_cols(std::move(other.m_cols))\n    {\n      other.m_data = nullptr;\n      other.m_rows = 0;\n      other.m_cols = 0;\n    }\n    EIGEN_DEVICE_FUNC\n    DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT\n    {\n      using std::swap;\n      swap(m_data, other.m_data);\n      swap(m_rows, other.m_rows);\n      swap(m_cols, other.m_cols);\n      return *this;\n    }\n#endif\n    EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); }\n    EIGEN_DEVICE_FUNC void swap(DenseStorage& other)\n    { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }\n    EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;}\n    EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;}\n    void conservativeResize(Index size, Index rows, Index cols)\n    {\n      m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*m_cols);\n      m_rows = rows;\n      m_cols = cols;\n    }\n    EIGEN_DEVICE_FUNC void resize(Index size, Index rows, Index cols)\n    {\n      if(size != m_rows*m_cols)\n      {\n        internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols);\n        if (size)\n          m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);\n        else\n          m_data = 0;\n        EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})\n      }\n      m_rows = rows;\n      m_cols = cols;\n    }\n    EIGEN_DEVICE_FUNC const T *data() const { return m_data; }\n    EIGEN_DEVICE_FUNC T *data() { return m_data; }\n};\n\n// matrix with dynamic width and fixed height (so that matrix has dynamic size).\ntemplate<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Rows, Dynamic, _Options>\n{\n    T *m_data;\n    Index m_cols;\n  public:\n    EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_cols(0) {}\n    explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {}\n    EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_cols(cols)\n    {\n      EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})\n      eigen_internal_assert(size==rows*cols && rows==_Rows && cols >=0);\n      EIGEN_UNUSED_VARIABLE(rows);\n    }\n    EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)\n      : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(_Rows*other.m_cols))\n      , m_cols(other.m_cols)\n    {\n      EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_cols*_Rows)\n      internal::smart_copy(other.m_data, other.m_data+_Rows*m_cols, m_data);\n    }\n    EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)\n    {\n      if (this != &other)\n      {\n        DenseStorage tmp(other);\n        this->swap(tmp);\n      }\n      return *this;\n    }    \n#if EIGEN_HAS_RVALUE_REFERENCES\n    EIGEN_DEVICE_FUNC\n    DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT\n      : m_data(std::move(other.m_data))\n      , m_cols(std::move(other.m_cols))\n    {\n      other.m_data = nullptr;\n      other.m_cols = 0;\n    }\n    EIGEN_DEVICE_FUNC\n    DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT\n    {\n      using std::swap;\n      swap(m_data, other.m_data);\n      swap(m_cols, other.m_cols);\n      return *this;\n    }\n#endif\n    EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); }\n    EIGEN_DEVICE_FUNC void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }\n    EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;}\n    EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;}\n    EIGEN_DEVICE_FUNC void conservativeResize(Index size, Index, Index cols)\n    {\n      m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, _Rows*m_cols);\n      m_cols = cols;\n    }\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index size, Index, Index cols)\n    {\n      if(size != _Rows*m_cols)\n      {\n        internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols);\n        if (size)\n          m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);\n        else\n          m_data = 0;\n        EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})\n      }\n      m_cols = cols;\n    }\n    EIGEN_DEVICE_FUNC const T *data() const { return m_data; }\n    EIGEN_DEVICE_FUNC T *data() { return m_data; }\n};\n\n// matrix with dynamic height and fixed width (so that matrix has dynamic size).\ntemplate<typename T, int _Cols, int _Options> class DenseStorage<T, Dynamic, Dynamic, _Cols, _Options>\n{\n    T *m_data;\n    Index m_rows;\n  public:\n    EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_rows(0) {}\n    explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {}\n    EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(rows)\n    {\n      EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})\n      eigen_internal_assert(size==rows*cols && rows>=0 && cols == _Cols);\n      EIGEN_UNUSED_VARIABLE(cols);\n    }\n    EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)\n      : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(other.m_rows*_Cols))\n      , m_rows(other.m_rows)\n    {\n      EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_rows*_Cols)\n      internal::smart_copy(other.m_data, other.m_data+other.m_rows*_Cols, m_data);\n    }\n    EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)\n    {\n      if (this != &other)\n      {\n        DenseStorage tmp(other);\n        this->swap(tmp);\n      }\n      return *this;\n    }    \n#if EIGEN_HAS_RVALUE_REFERENCES\n    EIGEN_DEVICE_FUNC\n    DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT\n      : m_data(std::move(other.m_data))\n      , m_rows(std::move(other.m_rows))\n    {\n      other.m_data = nullptr;\n      other.m_rows = 0;\n    }\n    EIGEN_DEVICE_FUNC\n    DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT\n    {\n      using std::swap;\n      swap(m_data, other.m_data);\n      swap(m_rows, other.m_rows);\n      return *this;\n    }\n#endif\n    EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); }\n    EIGEN_DEVICE_FUNC void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }\n    EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;}\n    EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;}\n    void conservativeResize(Index size, Index rows, Index)\n    {\n      m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*_Cols);\n      m_rows = rows;\n    }\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index size, Index rows, Index)\n    {\n      if(size != m_rows*_Cols)\n      {\n        internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows);\n        if (size)\n          m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);\n        else\n          m_data = 0;\n        EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})\n      }\n      m_rows = rows;\n    }\n    EIGEN_DEVICE_FUNC const T *data() const { return m_data; }\n    EIGEN_DEVICE_FUNC T *data() { return m_data; }\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_MATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Diagonal.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2007-2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_DIAGONAL_H\n#define EIGEN_DIAGONAL_H\n\nnamespace Eigen { \n\n/** \\class Diagonal\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of a diagonal/subdiagonal/superdiagonal in a matrix\n  *\n  * \\param MatrixType the type of the object in which we are taking a sub/main/super diagonal\n  * \\param DiagIndex the index of the sub/super diagonal. The default is 0 and it means the main diagonal.\n  *              A positive value means a superdiagonal, a negative value means a subdiagonal.\n  *              You can also use DynamicIndex so the index can be set at runtime.\n  *\n  * The matrix is not required to be square.\n  *\n  * This class represents an expression of the main diagonal, or any sub/super diagonal\n  * of a square matrix. It is the return type of MatrixBase::diagonal() and MatrixBase::diagonal(Index) and most of the\n  * time this is the only way it is used.\n  *\n  * \\sa MatrixBase::diagonal(), MatrixBase::diagonal(Index)\n  */\n\nnamespace internal {\ntemplate<typename MatrixType, int DiagIndex>\nstruct traits<Diagonal<MatrixType,DiagIndex> >\n : traits<MatrixType>\n{\n  typedef typename ref_selector<MatrixType>::type MatrixTypeNested;\n  typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;\n  typedef typename MatrixType::StorageKind StorageKind;\n  enum {\n    RowsAtCompileTime = (int(DiagIndex) == DynamicIndex || int(MatrixType::SizeAtCompileTime) == Dynamic) ? Dynamic\n                      : (EIGEN_PLAIN_ENUM_MIN(MatrixType::RowsAtCompileTime - EIGEN_PLAIN_ENUM_MAX(-DiagIndex, 0),\n                                              MatrixType::ColsAtCompileTime - EIGEN_PLAIN_ENUM_MAX( DiagIndex, 0))),\n    ColsAtCompileTime = 1,\n    MaxRowsAtCompileTime = int(MatrixType::MaxSizeAtCompileTime) == Dynamic ? Dynamic\n                         : DiagIndex == DynamicIndex ? EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::MaxRowsAtCompileTime,\n                                                                              MatrixType::MaxColsAtCompileTime)\n                         : (EIGEN_PLAIN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime - EIGEN_PLAIN_ENUM_MAX(-DiagIndex, 0),\n                                                 MatrixType::MaxColsAtCompileTime - EIGEN_PLAIN_ENUM_MAX( DiagIndex, 0))),\n    MaxColsAtCompileTime = 1,\n    MaskLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,\n    Flags = (unsigned int)_MatrixTypeNested::Flags & (RowMajorBit | MaskLvalueBit | DirectAccessBit) & ~RowMajorBit, // FIXME DirectAccessBit should not be handled by expressions\n    MatrixTypeOuterStride = outer_stride_at_compile_time<MatrixType>::ret,\n    InnerStrideAtCompileTime = MatrixTypeOuterStride == Dynamic ? Dynamic : MatrixTypeOuterStride+1,\n    OuterStrideAtCompileTime = 0\n  };\n};\n}\n\ntemplate<typename MatrixType, int _DiagIndex> class Diagonal\n   : public internal::dense_xpr_base< Diagonal<MatrixType,_DiagIndex> >::type\n{\n  public:\n\n    enum { DiagIndex = _DiagIndex };\n    typedef typename internal::dense_xpr_base<Diagonal>::type Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(Diagonal)\n\n    EIGEN_DEVICE_FUNC\n    explicit inline Diagonal(MatrixType& matrix, Index a_index = DiagIndex) : m_matrix(matrix), m_index(a_index) {}\n\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Diagonal)\n\n    EIGEN_DEVICE_FUNC\n    inline Index rows() const\n    {\n      return m_index.value()<0 ? numext::mini<Index>(m_matrix.cols(),m_matrix.rows()+m_index.value())\n                               : numext::mini<Index>(m_matrix.rows(),m_matrix.cols()-m_index.value());\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline Index cols() const { return 1; }\n\n    EIGEN_DEVICE_FUNC\n    inline Index innerStride() const\n    {\n      return m_matrix.outerStride() + 1;\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline Index outerStride() const\n    {\n      return 0;\n    }\n\n    typedef typename internal::conditional<\n                       internal::is_lvalue<MatrixType>::value,\n                       Scalar,\n                       const Scalar\n                     >::type ScalarWithConstIfNotLvalue;\n\n    EIGEN_DEVICE_FUNC\n    inline ScalarWithConstIfNotLvalue* data() { return &(m_matrix.coeffRef(rowOffset(), colOffset())); }\n    EIGEN_DEVICE_FUNC\n    inline const Scalar* data() const { return &(m_matrix.coeffRef(rowOffset(), colOffset())); }\n\n    EIGEN_DEVICE_FUNC\n    inline Scalar& coeffRef(Index row, Index)\n    {\n      EIGEN_STATIC_ASSERT_LVALUE(MatrixType)\n      return m_matrix.coeffRef(row+rowOffset(), row+colOffset());\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index row, Index) const\n    {\n      return m_matrix.coeffRef(row+rowOffset(), row+colOffset());\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline CoeffReturnType coeff(Index row, Index) const\n    {\n      return m_matrix.coeff(row+rowOffset(), row+colOffset());\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline Scalar& coeffRef(Index idx)\n    {\n      EIGEN_STATIC_ASSERT_LVALUE(MatrixType)\n      return m_matrix.coeffRef(idx+rowOffset(), idx+colOffset());\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index idx) const\n    {\n      return m_matrix.coeffRef(idx+rowOffset(), idx+colOffset());\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline CoeffReturnType coeff(Index idx) const\n    {\n      return m_matrix.coeff(idx+rowOffset(), idx+colOffset());\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline const typename internal::remove_all<typename MatrixType::Nested>::type& \n    nestedExpression() const \n    {\n      return m_matrix;\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline Index index() const\n    {\n      return m_index.value();\n    }\n\n  protected:\n    typename internal::ref_selector<MatrixType>::non_const_type m_matrix;\n    const internal::variable_if_dynamicindex<Index, DiagIndex> m_index;\n\n  private:\n    // some compilers may fail to optimize std::max etc in case of compile-time constants...\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Index absDiagIndex() const { return m_index.value()>0 ? m_index.value() : -m_index.value(); }\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Index rowOffset() const { return m_index.value()>0 ? 0 : -m_index.value(); }\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Index colOffset() const { return m_index.value()>0 ? m_index.value() : 0; }\n    // trigger a compile-time error if someone try to call packet\n    template<int LoadMode> typename MatrixType::PacketReturnType packet(Index) const;\n    template<int LoadMode> typename MatrixType::PacketReturnType packet(Index,Index) const;\n};\n\n/** \\returns an expression of the main diagonal of the matrix \\c *this\n  *\n  * \\c *this is not required to be square.\n  *\n  * Example: \\include MatrixBase_diagonal.cpp\n  * Output: \\verbinclude MatrixBase_diagonal.out\n  *\n  * \\sa class Diagonal */\ntemplate<typename Derived>\ninline typename MatrixBase<Derived>::DiagonalReturnType\nMatrixBase<Derived>::diagonal()\n{\n  return DiagonalReturnType(derived());\n}\n\n/** This is the const version of diagonal(). */\ntemplate<typename Derived>\ninline typename MatrixBase<Derived>::ConstDiagonalReturnType\nMatrixBase<Derived>::diagonal() const\n{\n  return ConstDiagonalReturnType(derived());\n}\n\n/** \\returns an expression of the \\a DiagIndex-th sub or super diagonal of the matrix \\c *this\n  *\n  * \\c *this is not required to be square.\n  *\n  * The template parameter \\a DiagIndex represent a super diagonal if \\a DiagIndex > 0\n  * and a sub diagonal otherwise. \\a DiagIndex == 0 is equivalent to the main diagonal.\n  *\n  * Example: \\include MatrixBase_diagonal_int.cpp\n  * Output: \\verbinclude MatrixBase_diagonal_int.out\n  *\n  * \\sa MatrixBase::diagonal(), class Diagonal */\ntemplate<typename Derived>\ninline typename MatrixBase<Derived>::DiagonalDynamicIndexReturnType\nMatrixBase<Derived>::diagonal(Index index)\n{\n  return DiagonalDynamicIndexReturnType(derived(), index);\n}\n\n/** This is the const version of diagonal(Index). */\ntemplate<typename Derived>\ninline typename MatrixBase<Derived>::ConstDiagonalDynamicIndexReturnType\nMatrixBase<Derived>::diagonal(Index index) const\n{\n  return ConstDiagonalDynamicIndexReturnType(derived(), index);\n}\n\n/** \\returns an expression of the \\a DiagIndex-th sub or super diagonal of the matrix \\c *this\n  *\n  * \\c *this is not required to be square.\n  *\n  * The template parameter \\a DiagIndex represent a super diagonal if \\a DiagIndex > 0\n  * and a sub diagonal otherwise. \\a DiagIndex == 0 is equivalent to the main diagonal.\n  *\n  * Example: \\include MatrixBase_diagonal_template_int.cpp\n  * Output: \\verbinclude MatrixBase_diagonal_template_int.out\n  *\n  * \\sa MatrixBase::diagonal(), class Diagonal */\ntemplate<typename Derived>\ntemplate<int Index_>\ninline typename MatrixBase<Derived>::template DiagonalIndexReturnType<Index_>::Type\nMatrixBase<Derived>::diagonal()\n{\n  return typename DiagonalIndexReturnType<Index_>::Type(derived());\n}\n\n/** This is the const version of diagonal<int>(). */\ntemplate<typename Derived>\ntemplate<int Index_>\ninline typename MatrixBase<Derived>::template ConstDiagonalIndexReturnType<Index_>::Type\nMatrixBase<Derived>::diagonal() const\n{\n  return typename ConstDiagonalIndexReturnType<Index_>::Type(derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_DIAGONAL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/DiagonalMatrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2007-2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_DIAGONALMATRIX_H\n#define EIGEN_DIAGONALMATRIX_H\n\nnamespace Eigen { \n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename Derived>\nclass DiagonalBase : public EigenBase<Derived>\n{\n  public:\n    typedef typename internal::traits<Derived>::DiagonalVectorType DiagonalVectorType;\n    typedef typename DiagonalVectorType::Scalar Scalar;\n    typedef typename DiagonalVectorType::RealScalar RealScalar;\n    typedef typename internal::traits<Derived>::StorageKind StorageKind;\n    typedef typename internal::traits<Derived>::StorageIndex StorageIndex;\n\n    enum {\n      RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,\n      ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,\n      MaxRowsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,\n      MaxColsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,\n      IsVectorAtCompileTime = 0,\n      Flags = NoPreferredStorageOrderBit\n    };\n\n    typedef Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, 0, MaxRowsAtCompileTime, MaxColsAtCompileTime> DenseMatrixType;\n    typedef DenseMatrixType DenseType;\n    typedef DiagonalMatrix<Scalar,DiagonalVectorType::SizeAtCompileTime,DiagonalVectorType::MaxSizeAtCompileTime> PlainObject;\n\n    EIGEN_DEVICE_FUNC\n    inline const Derived& derived() const { return *static_cast<const Derived*>(this); }\n    EIGEN_DEVICE_FUNC\n    inline Derived& derived() { return *static_cast<Derived*>(this); }\n\n    EIGEN_DEVICE_FUNC\n    DenseMatrixType toDenseMatrix() const { return derived(); }\n    \n    EIGEN_DEVICE_FUNC\n    inline const DiagonalVectorType& diagonal() const { return derived().diagonal(); }\n    EIGEN_DEVICE_FUNC\n    inline DiagonalVectorType& diagonal() { return derived().diagonal(); }\n\n    EIGEN_DEVICE_FUNC\n    inline Index rows() const { return diagonal().size(); }\n    EIGEN_DEVICE_FUNC\n    inline Index cols() const { return diagonal().size(); }\n\n    template<typename MatrixDerived>\n    EIGEN_DEVICE_FUNC\n    const Product<Derived,MatrixDerived,LazyProduct>\n    operator*(const MatrixBase<MatrixDerived> &matrix) const\n    {\n      return Product<Derived, MatrixDerived, LazyProduct>(derived(),matrix.derived());\n    }\n\n    typedef DiagonalWrapper<const CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const DiagonalVectorType> > InverseReturnType;\n    EIGEN_DEVICE_FUNC\n    inline const InverseReturnType\n    inverse() const\n    {\n      return InverseReturnType(diagonal().cwiseInverse());\n    }\n    \n    EIGEN_DEVICE_FUNC\n    inline const DiagonalWrapper<const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DiagonalVectorType,Scalar,product) >\n    operator*(const Scalar& scalar) const\n    {\n      return DiagonalWrapper<const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DiagonalVectorType,Scalar,product) >(diagonal() * scalar);\n    }\n    EIGEN_DEVICE_FUNC\n    friend inline const DiagonalWrapper<const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,DiagonalVectorType,product) >\n    operator*(const Scalar& scalar, const DiagonalBase& other)\n    {\n      return DiagonalWrapper<const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,DiagonalVectorType,product) >(scalar * other.diagonal());\n    }\n};\n\n#endif\n\n/** \\class DiagonalMatrix\n  * \\ingroup Core_Module\n  *\n  * \\brief Represents a diagonal matrix with its storage\n  *\n  * \\param _Scalar the type of coefficients\n  * \\param SizeAtCompileTime the dimension of the matrix, or Dynamic\n  * \\param MaxSizeAtCompileTime the dimension of the matrix, or Dynamic. This parameter is optional and defaults\n  *        to SizeAtCompileTime. Most of the time, you do not need to specify it.\n  *\n  * \\sa class DiagonalWrapper\n  */\n\nnamespace internal {\ntemplate<typename _Scalar, int SizeAtCompileTime, int MaxSizeAtCompileTime>\nstruct traits<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> >\n : traits<Matrix<_Scalar,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >\n{\n  typedef Matrix<_Scalar,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1> DiagonalVectorType;\n  typedef DiagonalShape StorageKind;\n  enum {\n    Flags = LvalueBit | NoPreferredStorageOrderBit\n  };\n};\n}\ntemplate<typename _Scalar, int SizeAtCompileTime, int MaxSizeAtCompileTime>\nclass DiagonalMatrix\n  : public DiagonalBase<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> >\n{\n  public:\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    typedef typename internal::traits<DiagonalMatrix>::DiagonalVectorType DiagonalVectorType;\n    typedef const DiagonalMatrix& Nested;\n    typedef _Scalar Scalar;\n    typedef typename internal::traits<DiagonalMatrix>::StorageKind StorageKind;\n    typedef typename internal::traits<DiagonalMatrix>::StorageIndex StorageIndex;\n    #endif\n\n  protected:\n\n    DiagonalVectorType m_diagonal;\n\n  public:\n\n    /** const version of diagonal(). */\n    EIGEN_DEVICE_FUNC\n    inline const DiagonalVectorType& diagonal() const { return m_diagonal; }\n    /** \\returns a reference to the stored vector of diagonal coefficients. */\n    EIGEN_DEVICE_FUNC\n    inline DiagonalVectorType& diagonal() { return m_diagonal; }\n\n    /** Default constructor without initialization */\n    EIGEN_DEVICE_FUNC\n    inline DiagonalMatrix() {}\n\n    /** Constructs a diagonal matrix with given dimension  */\n    EIGEN_DEVICE_FUNC\n    explicit inline DiagonalMatrix(Index dim) : m_diagonal(dim) {}\n\n    /** 2D constructor. */\n    EIGEN_DEVICE_FUNC\n    inline DiagonalMatrix(const Scalar& x, const Scalar& y) : m_diagonal(x,y) {}\n\n    /** 3D constructor. */\n    EIGEN_DEVICE_FUNC\n    inline DiagonalMatrix(const Scalar& x, const Scalar& y, const Scalar& z) : m_diagonal(x,y,z) {}\n\n    /** Copy constructor. */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    inline DiagonalMatrix(const DiagonalBase<OtherDerived>& other) : m_diagonal(other.diagonal()) {}\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** copy constructor. prevent a default copy constructor from hiding the other templated constructor */\n    inline DiagonalMatrix(const DiagonalMatrix& other) : m_diagonal(other.diagonal()) {}\n    #endif\n\n    /** generic constructor from expression of the diagonal coefficients */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    explicit inline DiagonalMatrix(const MatrixBase<OtherDerived>& other) : m_diagonal(other)\n    {}\n\n    /** Copy operator. */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    DiagonalMatrix& operator=(const DiagonalBase<OtherDerived>& other)\n    {\n      m_diagonal = other.diagonal();\n      return *this;\n    }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** This is a special case of the templated operator=. Its purpose is to\n      * prevent a default operator= from hiding the templated operator=.\n      */\n    EIGEN_DEVICE_FUNC\n    DiagonalMatrix& operator=(const DiagonalMatrix& other)\n    {\n      m_diagonal = other.diagonal();\n      return *this;\n    }\n    #endif\n\n    /** Resizes to given size. */\n    EIGEN_DEVICE_FUNC\n    inline void resize(Index size) { m_diagonal.resize(size); }\n    /** Sets all coefficients to zero. */\n    EIGEN_DEVICE_FUNC\n    inline void setZero() { m_diagonal.setZero(); }\n    /** Resizes and sets all coefficients to zero. */\n    EIGEN_DEVICE_FUNC\n    inline void setZero(Index size) { m_diagonal.setZero(size); }\n    /** Sets this matrix to be the identity matrix of the current size. */\n    EIGEN_DEVICE_FUNC\n    inline void setIdentity() { m_diagonal.setOnes(); }\n    /** Sets this matrix to be the identity matrix of the given size. */\n    EIGEN_DEVICE_FUNC\n    inline void setIdentity(Index size) { m_diagonal.setOnes(size); }\n};\n\n/** \\class DiagonalWrapper\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of a diagonal matrix\n  *\n  * \\param _DiagonalVectorType the type of the vector of diagonal coefficients\n  *\n  * This class is an expression of a diagonal matrix, but not storing its own vector of diagonal coefficients,\n  * instead wrapping an existing vector expression. It is the return type of MatrixBase::asDiagonal()\n  * and most of the time this is the only way that it is used.\n  *\n  * \\sa class DiagonalMatrix, class DiagonalBase, MatrixBase::asDiagonal()\n  */\n\nnamespace internal {\ntemplate<typename _DiagonalVectorType>\nstruct traits<DiagonalWrapper<_DiagonalVectorType> >\n{\n  typedef _DiagonalVectorType DiagonalVectorType;\n  typedef typename DiagonalVectorType::Scalar Scalar;\n  typedef typename DiagonalVectorType::StorageIndex StorageIndex;\n  typedef DiagonalShape StorageKind;\n  typedef typename traits<DiagonalVectorType>::XprKind XprKind;\n  enum {\n    RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,\n    ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,\n    MaxRowsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,\n    MaxColsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,\n    Flags =  (traits<DiagonalVectorType>::Flags & LvalueBit) | NoPreferredStorageOrderBit\n  };\n};\n}\n\ntemplate<typename _DiagonalVectorType>\nclass DiagonalWrapper\n  : public DiagonalBase<DiagonalWrapper<_DiagonalVectorType> >, internal::no_assignment_operator\n{\n  public:\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    typedef _DiagonalVectorType DiagonalVectorType;\n    typedef DiagonalWrapper Nested;\n    #endif\n\n    /** Constructor from expression of diagonal coefficients to wrap. */\n    EIGEN_DEVICE_FUNC\n    explicit inline DiagonalWrapper(DiagonalVectorType& a_diagonal) : m_diagonal(a_diagonal) {}\n\n    /** \\returns a const reference to the wrapped expression of diagonal coefficients. */\n    EIGEN_DEVICE_FUNC\n    const DiagonalVectorType& diagonal() const { return m_diagonal; }\n\n  protected:\n    typename DiagonalVectorType::Nested m_diagonal;\n};\n\n/** \\returns a pseudo-expression of a diagonal matrix with *this as vector of diagonal coefficients\n  *\n  * \\only_for_vectors\n  *\n  * Example: \\include MatrixBase_asDiagonal.cpp\n  * Output: \\verbinclude MatrixBase_asDiagonal.out\n  *\n  * \\sa class DiagonalWrapper, class DiagonalMatrix, diagonal(), isDiagonal()\n  **/\ntemplate<typename Derived>\ninline const DiagonalWrapper<const Derived>\nMatrixBase<Derived>::asDiagonal() const\n{\n  return DiagonalWrapper<const Derived>(derived());\n}\n\n/** \\returns true if *this is approximately equal to a diagonal matrix,\n  *          within the precision given by \\a prec.\n  *\n  * Example: \\include MatrixBase_isDiagonal.cpp\n  * Output: \\verbinclude MatrixBase_isDiagonal.out\n  *\n  * \\sa asDiagonal()\n  */\ntemplate<typename Derived>\nbool MatrixBase<Derived>::isDiagonal(const RealScalar& prec) const\n{\n  if(cols() != rows()) return false;\n  RealScalar maxAbsOnDiagonal = static_cast<RealScalar>(-1);\n  for(Index j = 0; j < cols(); ++j)\n  {\n    RealScalar absOnDiagonal = numext::abs(coeff(j,j));\n    if(absOnDiagonal > maxAbsOnDiagonal) maxAbsOnDiagonal = absOnDiagonal;\n  }\n  for(Index j = 0; j < cols(); ++j)\n    for(Index i = 0; i < j; ++i)\n    {\n      if(!internal::isMuchSmallerThan(coeff(i, j), maxAbsOnDiagonal, prec)) return false;\n      if(!internal::isMuchSmallerThan(coeff(j, i), maxAbsOnDiagonal, prec)) return false;\n    }\n  return true;\n}\n\nnamespace internal {\n\ntemplate<> struct storage_kind_to_shape<DiagonalShape> { typedef DiagonalShape Shape; };\n\nstruct Diagonal2Dense {};\n\ntemplate<> struct AssignmentKind<DenseShape,DiagonalShape> { typedef Diagonal2Dense Kind; };\n\n// Diagonal matrix to Dense assignment\ntemplate< typename DstXprType, typename SrcXprType, typename Functor>\nstruct Assignment<DstXprType, SrcXprType, Functor, Diagonal2Dense>\n{\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n    \n    dst.setZero();\n    dst.diagonal() = src.diagonal();\n  }\n  \n  static void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)\n  { dst.diagonal() += src.diagonal(); }\n  \n  static void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)\n  { dst.diagonal() -= src.diagonal(); }\n};\n\n} // namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_DIAGONALMATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/DiagonalProduct.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2007-2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_DIAGONALPRODUCT_H\n#define EIGEN_DIAGONALPRODUCT_H\n\nnamespace Eigen { \n\n/** \\returns the diagonal matrix product of \\c *this by the diagonal matrix \\a diagonal.\n  */\ntemplate<typename Derived>\ntemplate<typename DiagonalDerived>\ninline const Product<Derived, DiagonalDerived, LazyProduct>\nMatrixBase<Derived>::operator*(const DiagonalBase<DiagonalDerived> &a_diagonal) const\n{\n  return Product<Derived, DiagonalDerived, LazyProduct>(derived(),a_diagonal.derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_DIAGONALPRODUCT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Dot.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2008, 2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_DOT_H\n#define EIGEN_DOT_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n// helper function for dot(). The problem is that if we put that in the body of dot(), then upon calling dot\n// with mismatched types, the compiler emits errors about failing to instantiate cwiseProduct BEFORE\n// looking at the static assertions. Thus this is a trick to get better compile errors.\ntemplate<typename T, typename U,\n// the NeedToTranspose condition here is taken straight from Assign.h\n         bool NeedToTranspose = T::IsVectorAtCompileTime\n                && U::IsVectorAtCompileTime\n                && ((int(T::RowsAtCompileTime) == 1 && int(U::ColsAtCompileTime) == 1)\n                      |  // FIXME | instead of || to please GCC 4.4.0 stupid warning \"suggest parentheses around &&\".\n                         // revert to || as soon as not needed anymore.\n                    (int(T::ColsAtCompileTime) == 1 && int(U::RowsAtCompileTime) == 1))\n>\nstruct dot_nocheck\n{\n  typedef scalar_conj_product_op<typename traits<T>::Scalar,typename traits<U>::Scalar> conj_prod;\n  typedef typename conj_prod::result_type ResScalar;\n  EIGEN_DEVICE_FUNC\n  static inline ResScalar run(const MatrixBase<T>& a, const MatrixBase<U>& b)\n  {\n    return a.template binaryExpr<conj_prod>(b).sum();\n  }\n};\n\ntemplate<typename T, typename U>\nstruct dot_nocheck<T, U, true>\n{\n  typedef scalar_conj_product_op<typename traits<T>::Scalar,typename traits<U>::Scalar> conj_prod;\n  typedef typename conj_prod::result_type ResScalar;\n  EIGEN_DEVICE_FUNC\n  static inline ResScalar run(const MatrixBase<T>& a, const MatrixBase<U>& b)\n  {\n    return a.transpose().template binaryExpr<conj_prod>(b).sum();\n  }\n};\n\n} // end namespace internal\n\n/** \\fn MatrixBase::dot\n  * \\returns the dot product of *this with other.\n  *\n  * \\only_for_vectors\n  *\n  * \\note If the scalar type is complex numbers, then this function returns the hermitian\n  * (sesquilinear) dot product, conjugate-linear in the first variable and linear in the\n  * second variable.\n  *\n  * \\sa squaredNorm(), norm()\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\ntypename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,typename internal::traits<OtherDerived>::Scalar>::ReturnType\nMatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n  EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)\n#if !(defined(EIGEN_NO_STATIC_ASSERT) && defined(EIGEN_NO_DEBUG))\n  typedef internal::scalar_conj_product_op<Scalar,typename OtherDerived::Scalar> func;\n  EIGEN_CHECK_BINARY_COMPATIBILIY(func,Scalar,typename OtherDerived::Scalar);\n#endif\n  \n  eigen_assert(size() == other.size());\n\n  return internal::dot_nocheck<Derived,OtherDerived>::run(*this, other);\n}\n\n//---------- implementation of L2 norm and related functions ----------\n\n/** \\returns, for vectors, the squared \\em l2 norm of \\c *this, and for matrices the Frobenius norm.\n  * In both cases, it consists in the sum of the square of all the matrix entries.\n  * For vectors, this is also equals to the dot product of \\c *this with itself.\n  *\n  * \\sa dot(), norm(), lpNorm()\n  */\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::squaredNorm() const\n{\n  return numext::real((*this).cwiseAbs2().sum());\n}\n\n/** \\returns, for vectors, the \\em l2 norm of \\c *this, and for matrices the Frobenius norm.\n  * In both cases, it consists in the square root of the sum of the square of all the matrix entries.\n  * For vectors, this is also equals to the square root of the dot product of \\c *this with itself.\n  *\n  * \\sa lpNorm(), dot(), squaredNorm()\n  */\ntemplate<typename Derived>\ninline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::norm() const\n{\n  return numext::sqrt(squaredNorm());\n}\n\n/** \\returns an expression of the quotient of \\c *this by its own norm.\n  *\n  * \\warning If the input vector is too small (i.e., this->norm()==0),\n  *          then this function returns a copy of the input.\n  *\n  * \\only_for_vectors\n  *\n  * \\sa norm(), normalize()\n  */\ntemplate<typename Derived>\ninline const typename MatrixBase<Derived>::PlainObject\nMatrixBase<Derived>::normalized() const\n{\n  typedef typename internal::nested_eval<Derived,2>::type _Nested;\n  _Nested n(derived());\n  RealScalar z = n.squaredNorm();\n  // NOTE: after extensive benchmarking, this conditional does not impact performance, at least on recent x86 CPU\n  if(z>RealScalar(0))\n    return n / numext::sqrt(z);\n  else\n    return n;\n}\n\n/** Normalizes the vector, i.e. divides it by its own norm.\n  *\n  * \\only_for_vectors\n  *\n  * \\warning If the input vector is too small (i.e., this->norm()==0), then \\c *this is left unchanged.\n  *\n  * \\sa norm(), normalized()\n  */\ntemplate<typename Derived>\ninline void MatrixBase<Derived>::normalize()\n{\n  RealScalar z = squaredNorm();\n  // NOTE: after extensive benchmarking, this conditional does not impact performance, at least on recent x86 CPU\n  if(z>RealScalar(0))\n    derived() /= numext::sqrt(z);\n}\n\n/** \\returns an expression of the quotient of \\c *this by its own norm while avoiding underflow and overflow.\n  *\n  * \\only_for_vectors\n  *\n  * This method is analogue to the normalized() method, but it reduces the risk of\n  * underflow and overflow when computing the norm.\n  *\n  * \\warning If the input vector is too small (i.e., this->norm()==0),\n  *          then this function returns a copy of the input.\n  *\n  * \\sa stableNorm(), stableNormalize(), normalized()\n  */\ntemplate<typename Derived>\ninline const typename MatrixBase<Derived>::PlainObject\nMatrixBase<Derived>::stableNormalized() const\n{\n  typedef typename internal::nested_eval<Derived,3>::type _Nested;\n  _Nested n(derived());\n  RealScalar w = n.cwiseAbs().maxCoeff();\n  RealScalar z = (n/w).squaredNorm();\n  if(z>RealScalar(0))\n    return n / (numext::sqrt(z)*w);\n  else\n    return n;\n}\n\n/** Normalizes the vector while avoid underflow and overflow\n  *\n  * \\only_for_vectors\n  *\n  * This method is analogue to the normalize() method, but it reduces the risk of\n  * underflow and overflow when computing the norm.\n  *\n  * \\warning If the input vector is too small (i.e., this->norm()==0), then \\c *this is left unchanged.\n  *\n  * \\sa stableNorm(), stableNormalized(), normalize()\n  */\ntemplate<typename Derived>\ninline void MatrixBase<Derived>::stableNormalize()\n{\n  RealScalar w = cwiseAbs().maxCoeff();\n  RealScalar z = (derived()/w).squaredNorm();\n  if(z>RealScalar(0))\n    derived() /= numext::sqrt(z)*w;\n}\n\n//---------- implementation of other norms ----------\n\nnamespace internal {\n\ntemplate<typename Derived, int p>\nstruct lpNorm_selector\n{\n  typedef typename NumTraits<typename traits<Derived>::Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar run(const MatrixBase<Derived>& m)\n  {\n    EIGEN_USING_STD_MATH(pow)\n    return pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1)/p);\n  }\n};\n\ntemplate<typename Derived>\nstruct lpNorm_selector<Derived, 1>\n{\n  EIGEN_DEVICE_FUNC\n  static inline typename NumTraits<typename traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)\n  {\n    return m.cwiseAbs().sum();\n  }\n};\n\ntemplate<typename Derived>\nstruct lpNorm_selector<Derived, 2>\n{\n  EIGEN_DEVICE_FUNC\n  static inline typename NumTraits<typename traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)\n  {\n    return m.norm();\n  }\n};\n\ntemplate<typename Derived>\nstruct lpNorm_selector<Derived, Infinity>\n{\n  typedef typename NumTraits<typename traits<Derived>::Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar run(const MatrixBase<Derived>& m)\n  {\n    if(Derived::SizeAtCompileTime==0 || (Derived::SizeAtCompileTime==Dynamic && m.size()==0))\n      return RealScalar(0);\n    return m.cwiseAbs().maxCoeff();\n  }\n};\n\n} // end namespace internal\n\n/** \\returns the \\b coefficient-wise \\f$ \\ell^p \\f$ norm of \\c *this, that is, returns the p-th root of the sum of the p-th powers of the absolute values\n  *          of the coefficients of \\c *this. If \\a p is the special value \\a Eigen::Infinity, this function returns the \\f$ \\ell^\\infty \\f$\n  *          norm, that is the maximum of the absolute values of the coefficients of \\c *this.\n  *\n  * In all cases, if \\c *this is empty, then the value 0 is returned.\n  *\n  * \\note For matrices, this function does not compute the <a href=\"https://en.wikipedia.org/wiki/Operator_norm\">operator-norm</a>. That is, if \\c *this is a matrix, then its coefficients are interpreted as a 1D vector. Nonetheless, you can easily compute the 1-norm and \\f$\\infty\\f$-norm matrix operator norms using \\link TutorialReductionsVisitorsBroadcastingReductionsNorm partial reductions \\endlink.\n  *\n  * \\sa norm()\n  */\ntemplate<typename Derived>\ntemplate<int p>\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ninline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real\n#else\nMatrixBase<Derived>::RealScalar\n#endif\nMatrixBase<Derived>::lpNorm() const\n{\n  return internal::lpNorm_selector<Derived, p>::run(*this);\n}\n\n//---------- implementation of isOrthogonal / isUnitary ----------\n\n/** \\returns true if *this is approximately orthogonal to \\a other,\n  *          within the precision given by \\a prec.\n  *\n  * Example: \\include MatrixBase_isOrthogonal.cpp\n  * Output: \\verbinclude MatrixBase_isOrthogonal.out\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nbool MatrixBase<Derived>::isOrthogonal\n(const MatrixBase<OtherDerived>& other, const RealScalar& prec) const\n{\n  typename internal::nested_eval<Derived,2>::type nested(derived());\n  typename internal::nested_eval<OtherDerived,2>::type otherNested(other.derived());\n  return numext::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm();\n}\n\n/** \\returns true if *this is approximately an unitary matrix,\n  *          within the precision given by \\a prec. In the case where the \\a Scalar\n  *          type is real numbers, a unitary matrix is an orthogonal matrix, whence the name.\n  *\n  * \\note This can be used to check whether a family of vectors forms an orthonormal basis.\n  *       Indeed, \\c m.isUnitary() returns true if and only if the columns (equivalently, the rows) of m form an\n  *       orthonormal basis.\n  *\n  * Example: \\include MatrixBase_isUnitary.cpp\n  * Output: \\verbinclude MatrixBase_isUnitary.out\n  */\ntemplate<typename Derived>\nbool MatrixBase<Derived>::isUnitary(const RealScalar& prec) const\n{\n  typename internal::nested_eval<Derived,1>::type self(derived());\n  for(Index i = 0; i < cols(); ++i)\n  {\n    if(!internal::isApprox(self.col(i).squaredNorm(), static_cast<RealScalar>(1), prec))\n      return false;\n    for(Index j = 0; j < i; ++j)\n      if(!internal::isMuchSmallerThan(self.col(i).dot(self.col(j)), static_cast<Scalar>(1), prec))\n        return false;\n  }\n  return true;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_DOT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/EigenBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_EIGENBASE_H\n#define EIGEN_EIGENBASE_H\n\nnamespace Eigen {\n\n/** \\class EigenBase\n  * \\ingroup Core_Module\n  * \n  * Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor MatrixBase(T).\n  *\n  * In other words, an EigenBase object is an object that can be copied into a MatrixBase.\n  *\n  * Besides MatrixBase-derived classes, this also includes special matrix classes such as diagonal matrices, etc.\n  *\n  * Notice that this class is trivial, it is only used to disambiguate overloaded functions.\n  *\n  * \\sa \\blank \\ref TopicClassHierarchy\n  */\ntemplate<typename Derived> struct EigenBase\n{\n//   typedef typename internal::plain_matrix_type<Derived>::type PlainObject;\n  \n  /** \\brief The interface type of indices\n    * \\details To change this, \\c \\#define the preprocessor symbol \\c EIGEN_DEFAULT_DENSE_INDEX_TYPE.\n    * \\deprecated Since Eigen 3.3, its usage is deprecated. Use Eigen::Index instead.\n    * \\sa StorageIndex, \\ref TopicPreprocessorDirectives.\n    */\n  typedef Eigen::Index Index;\n\n  // FIXME is it needed?\n  typedef typename internal::traits<Derived>::StorageKind StorageKind;\n\n  /** \\returns a reference to the derived object */\n  EIGEN_DEVICE_FUNC\n  Derived& derived() { return *static_cast<Derived*>(this); }\n  /** \\returns a const reference to the derived object */\n  EIGEN_DEVICE_FUNC\n  const Derived& derived() const { return *static_cast<const Derived*>(this); }\n\n  EIGEN_DEVICE_FUNC\n  inline Derived& const_cast_derived() const\n  { return *static_cast<Derived*>(const_cast<EigenBase*>(this)); }\n  EIGEN_DEVICE_FUNC\n  inline const Derived& const_derived() const\n  { return *static_cast<const Derived*>(this); }\n\n  /** \\returns the number of rows. \\sa cols(), RowsAtCompileTime */\n  EIGEN_DEVICE_FUNC\n  inline Index rows() const { return derived().rows(); }\n  /** \\returns the number of columns. \\sa rows(), ColsAtCompileTime*/\n  EIGEN_DEVICE_FUNC\n  inline Index cols() const { return derived().cols(); }\n  /** \\returns the number of coefficients, which is rows()*cols().\n    * \\sa rows(), cols(), SizeAtCompileTime. */\n  EIGEN_DEVICE_FUNC\n  inline Index size() const { return rows() * cols(); }\n\n  /** \\internal Don't use it, but do the equivalent: \\code dst = *this; \\endcode */\n  template<typename Dest>\n  EIGEN_DEVICE_FUNC\n  inline void evalTo(Dest& dst) const\n  { derived().evalTo(dst); }\n\n  /** \\internal Don't use it, but do the equivalent: \\code dst += *this; \\endcode */\n  template<typename Dest>\n  EIGEN_DEVICE_FUNC\n  inline void addTo(Dest& dst) const\n  {\n    // This is the default implementation,\n    // derived class can reimplement it in a more optimized way.\n    typename Dest::PlainObject res(rows(),cols());\n    evalTo(res);\n    dst += res;\n  }\n\n  /** \\internal Don't use it, but do the equivalent: \\code dst -= *this; \\endcode */\n  template<typename Dest>\n  EIGEN_DEVICE_FUNC\n  inline void subTo(Dest& dst) const\n  {\n    // This is the default implementation,\n    // derived class can reimplement it in a more optimized way.\n    typename Dest::PlainObject res(rows(),cols());\n    evalTo(res);\n    dst -= res;\n  }\n\n  /** \\internal Don't use it, but do the equivalent: \\code dst.applyOnTheRight(*this); \\endcode */\n  template<typename Dest>\n  EIGEN_DEVICE_FUNC inline void applyThisOnTheRight(Dest& dst) const\n  {\n    // This is the default implementation,\n    // derived class can reimplement it in a more optimized way.\n    dst = dst * this->derived();\n  }\n\n  /** \\internal Don't use it, but do the equivalent: \\code dst.applyOnTheLeft(*this); \\endcode */\n  template<typename Dest>\n  EIGEN_DEVICE_FUNC inline void applyThisOnTheLeft(Dest& dst) const\n  {\n    // This is the default implementation,\n    // derived class can reimplement it in a more optimized way.\n    dst = this->derived() * dst;\n  }\n\n};\n\n/***************************************************************************\n* Implementation of matrix base methods\n***************************************************************************/\n\n/** \\brief Copies the generic expression \\a other into *this.\n  *\n  * \\details The expression must provide a (templated) evalTo(Derived& dst) const\n  * function which does the actual job. In practice, this allows any user to write\n  * its own special matrix without having to modify MatrixBase\n  *\n  * \\returns a reference to *this.\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\nDerived& DenseBase<Derived>::operator=(const EigenBase<OtherDerived> &other)\n{\n  call_assignment(derived(), other.derived());\n  return derived();\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\nDerived& DenseBase<Derived>::operator+=(const EigenBase<OtherDerived> &other)\n{\n  call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\nDerived& DenseBase<Derived>::operator-=(const EigenBase<OtherDerived> &other)\n{\n  call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_EIGENBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/ForceAlignedAccess.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_FORCEALIGNEDACCESS_H\n#define EIGEN_FORCEALIGNEDACCESS_H\n\nnamespace Eigen {\n\n/** \\class ForceAlignedAccess\n  * \\ingroup Core_Module\n  *\n  * \\brief Enforce aligned packet loads and stores regardless of what is requested\n  *\n  * \\param ExpressionType the type of the object of which we are forcing aligned packet access\n  *\n  * This class is the return type of MatrixBase::forceAlignedAccess()\n  * and most of the time this is the only way it is used.\n  *\n  * \\sa MatrixBase::forceAlignedAccess()\n  */\n\nnamespace internal {\ntemplate<typename ExpressionType>\nstruct traits<ForceAlignedAccess<ExpressionType> > : public traits<ExpressionType>\n{};\n}\n\ntemplate<typename ExpressionType> class ForceAlignedAccess\n  : public internal::dense_xpr_base< ForceAlignedAccess<ExpressionType> >::type\n{\n  public:\n\n    typedef typename internal::dense_xpr_base<ForceAlignedAccess>::type Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess)\n\n    EIGEN_DEVICE_FUNC explicit inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {}\n\n    EIGEN_DEVICE_FUNC inline Index rows() const { return m_expression.rows(); }\n    EIGEN_DEVICE_FUNC inline Index cols() const { return m_expression.cols(); }\n    EIGEN_DEVICE_FUNC inline Index outerStride() const { return m_expression.outerStride(); }\n    EIGEN_DEVICE_FUNC inline Index innerStride() const { return m_expression.innerStride(); }\n\n    EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index row, Index col) const\n    {\n      return m_expression.coeff(row, col);\n    }\n\n    EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index col)\n    {\n      return m_expression.const_cast_derived().coeffRef(row, col);\n    }\n\n    EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index index) const\n    {\n      return m_expression.coeff(index);\n    }\n\n    EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index)\n    {\n      return m_expression.const_cast_derived().coeffRef(index);\n    }\n\n    template<int LoadMode>\n    inline const PacketScalar packet(Index row, Index col) const\n    {\n      return m_expression.template packet<Aligned>(row, col);\n    }\n\n    template<int LoadMode>\n    inline void writePacket(Index row, Index col, const PacketScalar& x)\n    {\n      m_expression.const_cast_derived().template writePacket<Aligned>(row, col, x);\n    }\n\n    template<int LoadMode>\n    inline const PacketScalar packet(Index index) const\n    {\n      return m_expression.template packet<Aligned>(index);\n    }\n\n    template<int LoadMode>\n    inline void writePacket(Index index, const PacketScalar& x)\n    {\n      m_expression.const_cast_derived().template writePacket<Aligned>(index, x);\n    }\n\n    EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; }\n\n  protected:\n    const ExpressionType& m_expression;\n\n  private:\n    ForceAlignedAccess& operator=(const ForceAlignedAccess&);\n};\n\n/** \\returns an expression of *this with forced aligned access\n  * \\sa forceAlignedAccessIf(),class ForceAlignedAccess\n  */\ntemplate<typename Derived>\ninline const ForceAlignedAccess<Derived>\nMatrixBase<Derived>::forceAlignedAccess() const\n{\n  return ForceAlignedAccess<Derived>(derived());\n}\n\n/** \\returns an expression of *this with forced aligned access\n  * \\sa forceAlignedAccessIf(), class ForceAlignedAccess\n  */\ntemplate<typename Derived>\ninline ForceAlignedAccess<Derived>\nMatrixBase<Derived>::forceAlignedAccess()\n{\n  return ForceAlignedAccess<Derived>(derived());\n}\n\n/** \\returns an expression of *this with forced aligned access if \\a Enable is true.\n  * \\sa forceAlignedAccess(), class ForceAlignedAccess\n  */\ntemplate<typename Derived>\ntemplate<bool Enable>\ninline typename internal::add_const_on_value_type<typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type>::type\nMatrixBase<Derived>::forceAlignedAccessIf() const\n{\n  return derived();  // FIXME This should not work but apparently is never used\n}\n\n/** \\returns an expression of *this with forced aligned access if \\a Enable is true.\n  * \\sa forceAlignedAccess(), class ForceAlignedAccess\n  */\ntemplate<typename Derived>\ntemplate<bool Enable>\ninline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type\nMatrixBase<Derived>::forceAlignedAccessIf()\n{\n  return derived();  // FIXME This should not work but apparently is never used\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_FORCEALIGNEDACCESS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Fuzzy.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_FUZZY_H\n#define EIGEN_FUZZY_H\n\nnamespace Eigen { \n\nnamespace internal\n{\n\ntemplate<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>\nstruct isApprox_selector\n{\n  EIGEN_DEVICE_FUNC\n  static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar& prec)\n  {\n    typename internal::nested_eval<Derived,2>::type nested(x);\n    typename internal::nested_eval<OtherDerived,2>::type otherNested(y);\n    return (nested - otherNested).cwiseAbs2().sum() <= prec * prec * numext::mini(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum());\n  }\n};\n\ntemplate<typename Derived, typename OtherDerived>\nstruct isApprox_selector<Derived, OtherDerived, true>\n{\n  EIGEN_DEVICE_FUNC\n  static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar&)\n  {\n    return x.matrix() == y.matrix();\n  }\n};\n\ntemplate<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>\nstruct isMuchSmallerThan_object_selector\n{\n  EIGEN_DEVICE_FUNC\n  static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar& prec)\n  {\n    return x.cwiseAbs2().sum() <= numext::abs2(prec) * y.cwiseAbs2().sum();\n  }\n};\n\ntemplate<typename Derived, typename OtherDerived>\nstruct isMuchSmallerThan_object_selector<Derived, OtherDerived, true>\n{\n  EIGEN_DEVICE_FUNC\n  static bool run(const Derived& x, const OtherDerived&, const typename Derived::RealScalar&)\n  {\n    return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();\n  }\n};\n\ntemplate<typename Derived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>\nstruct isMuchSmallerThan_scalar_selector\n{\n  EIGEN_DEVICE_FUNC\n  static bool run(const Derived& x, const typename Derived::RealScalar& y, const typename Derived::RealScalar& prec)\n  {\n    return x.cwiseAbs2().sum() <= numext::abs2(prec * y);\n  }\n};\n\ntemplate<typename Derived>\nstruct isMuchSmallerThan_scalar_selector<Derived, true>\n{\n  EIGEN_DEVICE_FUNC\n  static bool run(const Derived& x, const typename Derived::RealScalar&, const typename Derived::RealScalar&)\n  {\n    return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();\n  }\n};\n\n} // end namespace internal\n\n\n/** \\returns \\c true if \\c *this is approximately equal to \\a other, within the precision\n  * determined by \\a prec.\n  *\n  * \\note The fuzzy compares are done multiplicatively. Two vectors \\f$ v \\f$ and \\f$ w \\f$\n  * are considered to be approximately equal within precision \\f$ p \\f$ if\n  * \\f[ \\Vert v - w \\Vert \\leqslant p\\,\\min(\\Vert v\\Vert, \\Vert w\\Vert). \\f]\n  * For matrices, the comparison is done using the Hilbert-Schmidt norm (aka Frobenius norm\n  * L2 norm).\n  *\n  * \\note Because of the multiplicativeness of this comparison, one can't use this function\n  * to check whether \\c *this is approximately equal to the zero matrix or vector.\n  * Indeed, \\c isApprox(zero) returns false unless \\c *this itself is exactly the zero matrix\n  * or vector. If you want to test whether \\c *this is zero, use internal::isMuchSmallerThan(const\n  * RealScalar&, RealScalar) instead.\n  *\n  * \\sa internal::isMuchSmallerThan(const RealScalar&, RealScalar) const\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nbool DenseBase<Derived>::isApprox(\n  const DenseBase<OtherDerived>& other,\n  const RealScalar& prec\n) const\n{\n  return internal::isApprox_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);\n}\n\n/** \\returns \\c true if the norm of \\c *this is much smaller than \\a other,\n  * within the precision determined by \\a prec.\n  *\n  * \\note The fuzzy compares are done multiplicatively. A vector \\f$ v \\f$ is\n  * considered to be much smaller than \\f$ x \\f$ within precision \\f$ p \\f$ if\n  * \\f[ \\Vert v \\Vert \\leqslant p\\,\\vert x\\vert. \\f]\n  *\n  * For matrices, the comparison is done using the Hilbert-Schmidt norm. For this reason,\n  * the value of the reference scalar \\a other should come from the Hilbert-Schmidt norm\n  * of a reference matrix of same dimensions.\n  *\n  * \\sa isApprox(), isMuchSmallerThan(const DenseBase<OtherDerived>&, RealScalar) const\n  */\ntemplate<typename Derived>\nbool DenseBase<Derived>::isMuchSmallerThan(\n  const typename NumTraits<Scalar>::Real& other,\n  const RealScalar& prec\n) const\n{\n  return internal::isMuchSmallerThan_scalar_selector<Derived>::run(derived(), other, prec);\n}\n\n/** \\returns \\c true if the norm of \\c *this is much smaller than the norm of \\a other,\n  * within the precision determined by \\a prec.\n  *\n  * \\note The fuzzy compares are done multiplicatively. A vector \\f$ v \\f$ is\n  * considered to be much smaller than a vector \\f$ w \\f$ within precision \\f$ p \\f$ if\n  * \\f[ \\Vert v \\Vert \\leqslant p\\,\\Vert w\\Vert. \\f]\n  * For matrices, the comparison is done using the Hilbert-Schmidt norm.\n  *\n  * \\sa isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nbool DenseBase<Derived>::isMuchSmallerThan(\n  const DenseBase<OtherDerived>& other,\n  const RealScalar& prec\n) const\n{\n  return internal::isMuchSmallerThan_object_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_FUZZY_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/GeneralProduct.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008-2011 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_GENERAL_PRODUCT_H\n#define EIGEN_GENERAL_PRODUCT_H\n\nnamespace Eigen {\n\nenum {\n  Large = 2,\n  Small = 3\n};\n\nnamespace internal {\n\ntemplate<int Rows, int Cols, int Depth> struct product_type_selector;\n\ntemplate<int Size, int MaxSize> struct product_size_category\n{\n  enum { is_large = MaxSize == Dynamic ||\n                    Size >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ||\n                    (Size==Dynamic && MaxSize>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD),\n         value = is_large  ? Large\n               : Size == 1 ? 1\n                           : Small\n  };\n};\n\ntemplate<typename Lhs, typename Rhs> struct product_type\n{\n  typedef typename remove_all<Lhs>::type _Lhs;\n  typedef typename remove_all<Rhs>::type _Rhs;\n  enum {\n    MaxRows = traits<_Lhs>::MaxRowsAtCompileTime,\n    Rows    = traits<_Lhs>::RowsAtCompileTime,\n    MaxCols = traits<_Rhs>::MaxColsAtCompileTime,\n    Cols    = traits<_Rhs>::ColsAtCompileTime,\n    MaxDepth = EIGEN_SIZE_MIN_PREFER_FIXED(traits<_Lhs>::MaxColsAtCompileTime,\n                                           traits<_Rhs>::MaxRowsAtCompileTime),\n    Depth = EIGEN_SIZE_MIN_PREFER_FIXED(traits<_Lhs>::ColsAtCompileTime,\n                                        traits<_Rhs>::RowsAtCompileTime)\n  };\n\n  // the splitting into different lines of code here, introducing the _select enums and the typedef below,\n  // is to work around an internal compiler error with gcc 4.1 and 4.2.\nprivate:\n  enum {\n    rows_select = product_size_category<Rows,MaxRows>::value,\n    cols_select = product_size_category<Cols,MaxCols>::value,\n    depth_select = product_size_category<Depth,MaxDepth>::value\n  };\n  typedef product_type_selector<rows_select, cols_select, depth_select> selector;\n\npublic:\n  enum {\n    value = selector::ret,\n    ret = selector::ret\n  };\n#ifdef EIGEN_DEBUG_PRODUCT\n  static void debug()\n  {\n      EIGEN_DEBUG_VAR(Rows);\n      EIGEN_DEBUG_VAR(Cols);\n      EIGEN_DEBUG_VAR(Depth);\n      EIGEN_DEBUG_VAR(rows_select);\n      EIGEN_DEBUG_VAR(cols_select);\n      EIGEN_DEBUG_VAR(depth_select);\n      EIGEN_DEBUG_VAR(value);\n  }\n#endif\n};\n\n/* The following allows to select the kind of product at compile time\n * based on the three dimensions of the product.\n * This is a compile time mapping from {1,Small,Large}^3 -> {product types} */\n// FIXME I'm not sure the current mapping is the ideal one.\ntemplate<int M, int N>  struct product_type_selector<M,N,1>              { enum { ret = OuterProduct }; };\ntemplate<int M>         struct product_type_selector<M, 1, 1>            { enum { ret = LazyCoeffBasedProductMode }; };\ntemplate<int N>         struct product_type_selector<1, N, 1>            { enum { ret = LazyCoeffBasedProductMode }; };\ntemplate<int Depth>     struct product_type_selector<1,    1,    Depth>  { enum { ret = InnerProduct }; };\ntemplate<>              struct product_type_selector<1,    1,    1>      { enum { ret = InnerProduct }; };\ntemplate<>              struct product_type_selector<Small,1,    Small>  { enum { ret = CoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<1,    Small,Small>  { enum { ret = CoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<Small,Small,Small>  { enum { ret = CoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<Small, Small, 1>    { enum { ret = LazyCoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<Small, Large, 1>    { enum { ret = LazyCoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<Large, Small, 1>    { enum { ret = LazyCoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<1,    Large,Small>  { enum { ret = CoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<1,    Large,Large>  { enum { ret = GemvProduct }; };\ntemplate<>              struct product_type_selector<1,    Small,Large>  { enum { ret = CoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<Large,1,    Small>  { enum { ret = CoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<Large,1,    Large>  { enum { ret = GemvProduct }; };\ntemplate<>              struct product_type_selector<Small,1,    Large>  { enum { ret = CoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<Small,Small,Large>  { enum { ret = GemmProduct }; };\ntemplate<>              struct product_type_selector<Large,Small,Large>  { enum { ret = GemmProduct }; };\ntemplate<>              struct product_type_selector<Small,Large,Large>  { enum { ret = GemmProduct }; };\ntemplate<>              struct product_type_selector<Large,Large,Large>  { enum { ret = GemmProduct }; };\ntemplate<>              struct product_type_selector<Large,Small,Small>  { enum { ret = CoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<Small,Large,Small>  { enum { ret = CoeffBasedProductMode }; };\ntemplate<>              struct product_type_selector<Large,Large,Small>  { enum { ret = GemmProduct }; };\n\n} // end namespace internal\n\n/***********************************************************************\n*  Implementation of Inner Vector Vector Product\n***********************************************************************/\n\n// FIXME : maybe the \"inner product\" could return a Scalar\n// instead of a 1x1 matrix ??\n// Pro: more natural for the user\n// Cons: this could be a problem if in a meta unrolled algorithm a matrix-matrix\n// product ends up to a row-vector times col-vector product... To tackle this use\n// case, we could have a specialization for Block<MatrixType,1,1> with: operator=(Scalar x);\n\n/***********************************************************************\n*  Implementation of Outer Vector Vector Product\n***********************************************************************/\n\n/***********************************************************************\n*  Implementation of General Matrix Vector Product\n***********************************************************************/\n\n/*  According to the shape/flags of the matrix we have to distinghish 3 different cases:\n *   1 - the matrix is col-major, BLAS compatible and M is large => call fast BLAS-like colmajor routine\n *   2 - the matrix is row-major, BLAS compatible and N is large => call fast BLAS-like rowmajor routine\n *   3 - all other cases are handled using a simple loop along the outer-storage direction.\n *  Therefore we need a lower level meta selector.\n *  Furthermore, if the matrix is the rhs, then the product has to be transposed.\n */\nnamespace internal {\n\ntemplate<int Side, int StorageOrder, bool BlasCompatible>\nstruct gemv_dense_selector;\n\n} // end namespace internal\n\nnamespace internal {\n\ntemplate<typename Scalar,int Size,int MaxSize,bool Cond> struct gemv_static_vector_if;\n\ntemplate<typename Scalar,int Size,int MaxSize>\nstruct gemv_static_vector_if<Scalar,Size,MaxSize,false>\n{\n  EIGEN_STRONG_INLINE  Scalar* data() { eigen_internal_assert(false && \"should never be called\"); return 0; }\n};\n\ntemplate<typename Scalar,int Size>\nstruct gemv_static_vector_if<Scalar,Size,Dynamic,true>\n{\n  EIGEN_STRONG_INLINE Scalar* data() { return 0; }\n};\n\ntemplate<typename Scalar,int Size,int MaxSize>\nstruct gemv_static_vector_if<Scalar,Size,MaxSize,true>\n{\n  enum {\n    ForceAlignment  = internal::packet_traits<Scalar>::Vectorizable,\n    PacketSize      = internal::packet_traits<Scalar>::size\n  };\n  #if EIGEN_MAX_STATIC_ALIGN_BYTES!=0\n  internal::plain_array<Scalar,EIGEN_SIZE_MIN_PREFER_FIXED(Size,MaxSize),0,EIGEN_PLAIN_ENUM_MIN(AlignedMax,PacketSize)> m_data;\n  EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; }\n  #else\n  // Some architectures cannot align on the stack,\n  // => let's manually enforce alignment by allocating more data and return the address of the first aligned element.\n  internal::plain_array<Scalar,EIGEN_SIZE_MIN_PREFER_FIXED(Size,MaxSize)+(ForceAlignment?EIGEN_MAX_ALIGN_BYTES:0),0> m_data;\n  EIGEN_STRONG_INLINE Scalar* data() {\n    return ForceAlignment\n            ? reinterpret_cast<Scalar*>((internal::UIntPtr(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES-1))) + EIGEN_MAX_ALIGN_BYTES)\n            : m_data.array;\n  }\n  #endif\n};\n\n// The vector is on the left => transposition\ntemplate<int StorageOrder, bool BlasCompatible>\nstruct gemv_dense_selector<OnTheLeft,StorageOrder,BlasCompatible>\n{\n  template<typename Lhs, typename Rhs, typename Dest>\n  static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)\n  {\n    Transpose<Dest> destT(dest);\n    enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor };\n    gemv_dense_selector<OnTheRight,OtherStorageOrder,BlasCompatible>\n      ::run(rhs.transpose(), lhs.transpose(), destT, alpha);\n  }\n};\n\ntemplate<> struct gemv_dense_selector<OnTheRight,ColMajor,true>\n{\n  template<typename Lhs, typename Rhs, typename Dest>\n  static inline void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)\n  {\n    typedef typename Lhs::Scalar   LhsScalar;\n    typedef typename Rhs::Scalar   RhsScalar;\n    typedef typename Dest::Scalar  ResScalar;\n    typedef typename Dest::RealScalar  RealScalar;\n    \n    typedef internal::blas_traits<Lhs> LhsBlasTraits;\n    typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;\n    typedef internal::blas_traits<Rhs> RhsBlasTraits;\n    typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;\n  \n    typedef Map<Matrix<ResScalar,Dynamic,1>, EIGEN_PLAIN_ENUM_MIN(AlignedMax,internal::packet_traits<ResScalar>::size)> MappedDest;\n\n    ActualLhsType actualLhs = LhsBlasTraits::extract(lhs);\n    ActualRhsType actualRhs = RhsBlasTraits::extract(rhs);\n\n    ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(lhs)\n                                  * RhsBlasTraits::extractScalarFactor(rhs);\n\n    // make sure Dest is a compile-time vector type (bug 1166)\n    typedef typename conditional<Dest::IsVectorAtCompileTime, Dest, typename Dest::ColXpr>::type ActualDest;\n\n    enum {\n      // FIXME find a way to allow an inner stride on the result if packet_traits<Scalar>::size==1\n      // on, the other hand it is good for the cache to pack the vector anyways...\n      EvalToDestAtCompileTime = (ActualDest::InnerStrideAtCompileTime==1),\n      ComplexByReal = (NumTraits<LhsScalar>::IsComplex) && (!NumTraits<RhsScalar>::IsComplex),\n      MightCannotUseDest = (!EvalToDestAtCompileTime) || ComplexByReal\n    };\n\n    typedef const_blas_data_mapper<LhsScalar,Index,ColMajor> LhsMapper;\n    typedef const_blas_data_mapper<RhsScalar,Index,RowMajor> RhsMapper;\n    RhsScalar compatibleAlpha = get_factor<ResScalar,RhsScalar>::run(actualAlpha);\n\n    if(!MightCannotUseDest)\n    {\n      // shortcut if we are sure to be able to use dest directly,\n      // this ease the compiler to generate cleaner and more optimzized code for most common cases\n      general_matrix_vector_product\n          <Index,LhsScalar,LhsMapper,ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>::run(\n          actualLhs.rows(), actualLhs.cols(),\n          LhsMapper(actualLhs.data(), actualLhs.outerStride()),\n          RhsMapper(actualRhs.data(), actualRhs.innerStride()),\n          dest.data(), 1,\n          compatibleAlpha);\n    }\n    else\n    {\n      gemv_static_vector_if<ResScalar,ActualDest::SizeAtCompileTime,ActualDest::MaxSizeAtCompileTime,MightCannotUseDest> static_dest;\n\n      const bool alphaIsCompatible = (!ComplexByReal) || (numext::imag(actualAlpha)==RealScalar(0));\n      const bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;\n\n      ei_declare_aligned_stack_constructed_variable(ResScalar,actualDestPtr,dest.size(),\n                                                    evalToDest ? dest.data() : static_dest.data());\n\n      if(!evalToDest)\n      {\n        #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n        Index size = dest.size();\n        EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n        #endif\n        if(!alphaIsCompatible)\n        {\n          MappedDest(actualDestPtr, dest.size()).setZero();\n          compatibleAlpha = RhsScalar(1);\n        }\n        else\n          MappedDest(actualDestPtr, dest.size()) = dest;\n      }\n\n      general_matrix_vector_product\n          <Index,LhsScalar,LhsMapper,ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>::run(\n          actualLhs.rows(), actualLhs.cols(),\n          LhsMapper(actualLhs.data(), actualLhs.outerStride()),\n          RhsMapper(actualRhs.data(), actualRhs.innerStride()),\n          actualDestPtr, 1,\n          compatibleAlpha);\n\n      if (!evalToDest)\n      {\n        if(!alphaIsCompatible)\n          dest.matrix() += actualAlpha * MappedDest(actualDestPtr, dest.size());\n        else\n          dest = MappedDest(actualDestPtr, dest.size());\n      }\n    }\n  }\n};\n\ntemplate<> struct gemv_dense_selector<OnTheRight,RowMajor,true>\n{\n  template<typename Lhs, typename Rhs, typename Dest>\n  static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)\n  {\n    typedef typename Lhs::Scalar   LhsScalar;\n    typedef typename Rhs::Scalar   RhsScalar;\n    typedef typename Dest::Scalar  ResScalar;\n    \n    typedef internal::blas_traits<Lhs> LhsBlasTraits;\n    typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;\n    typedef internal::blas_traits<Rhs> RhsBlasTraits;\n    typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;\n    typedef typename internal::remove_all<ActualRhsType>::type ActualRhsTypeCleaned;\n\n    typename add_const<ActualLhsType>::type actualLhs = LhsBlasTraits::extract(lhs);\n    typename add_const<ActualRhsType>::type actualRhs = RhsBlasTraits::extract(rhs);\n\n    ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(lhs)\n                                  * RhsBlasTraits::extractScalarFactor(rhs);\n\n    enum {\n      // FIXME find a way to allow an inner stride on the result if packet_traits<Scalar>::size==1\n      // on, the other hand it is good for the cache to pack the vector anyways...\n      DirectlyUseRhs = ActualRhsTypeCleaned::InnerStrideAtCompileTime==1\n    };\n\n    gemv_static_vector_if<RhsScalar,ActualRhsTypeCleaned::SizeAtCompileTime,ActualRhsTypeCleaned::MaxSizeAtCompileTime,!DirectlyUseRhs> static_rhs;\n\n    ei_declare_aligned_stack_constructed_variable(RhsScalar,actualRhsPtr,actualRhs.size(),\n        DirectlyUseRhs ? const_cast<RhsScalar*>(actualRhs.data()) : static_rhs.data());\n\n    if(!DirectlyUseRhs)\n    {\n      #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n      Index size = actualRhs.size();\n      EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n      #endif\n      Map<typename ActualRhsTypeCleaned::PlainObject>(actualRhsPtr, actualRhs.size()) = actualRhs;\n    }\n\n    typedef const_blas_data_mapper<LhsScalar,Index,RowMajor> LhsMapper;\n    typedef const_blas_data_mapper<RhsScalar,Index,ColMajor> RhsMapper;\n    general_matrix_vector_product\n        <Index,LhsScalar,LhsMapper,RowMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>::run(\n        actualLhs.rows(), actualLhs.cols(),\n        LhsMapper(actualLhs.data(), actualLhs.outerStride()),\n        RhsMapper(actualRhsPtr, 1),\n        dest.data(), dest.col(0).innerStride(), //NOTE  if dest is not a vector at compile-time, then dest.innerStride() might be wrong. (bug 1166)\n        actualAlpha);\n  }\n};\n\ntemplate<> struct gemv_dense_selector<OnTheRight,ColMajor,false>\n{\n  template<typename Lhs, typename Rhs, typename Dest>\n  static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)\n  {\n    EIGEN_STATIC_ASSERT((!nested_eval<Lhs,1>::Evaluate),EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE);\n    // TODO if rhs is large enough it might be beneficial to make sure that dest is sequentially stored in memory, otherwise use a temp\n    typename nested_eval<Rhs,1>::type actual_rhs(rhs);\n    const Index size = rhs.rows();\n    for(Index k=0; k<size; ++k)\n      dest += (alpha*actual_rhs.coeff(k)) * lhs.col(k);\n  }\n};\n\ntemplate<> struct gemv_dense_selector<OnTheRight,RowMajor,false>\n{\n  template<typename Lhs, typename Rhs, typename Dest>\n  static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)\n  {\n    EIGEN_STATIC_ASSERT((!nested_eval<Lhs,1>::Evaluate),EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE);\n    typename nested_eval<Rhs,Lhs::RowsAtCompileTime>::type actual_rhs(rhs);\n    const Index rows = dest.rows();\n    for(Index i=0; i<rows; ++i)\n      dest.coeffRef(i) += alpha * (lhs.row(i).cwiseProduct(actual_rhs.transpose())).sum();\n  }\n};\n\n} // end namespace internal\n\n/***************************************************************************\n* Implementation of matrix base methods\n***************************************************************************/\n\n/** \\returns the matrix product of \\c *this and \\a other.\n  *\n  * \\note If instead of the matrix product you want the coefficient-wise product, see Cwise::operator*().\n  *\n  * \\sa lazyProduct(), operator*=(const MatrixBase&), Cwise::operator*()\n  */\n#ifndef __CUDACC__\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\ninline const Product<Derived, OtherDerived>\nMatrixBase<Derived>::operator*(const MatrixBase<OtherDerived> &other) const\n{\n  // A note regarding the function declaration: In MSVC, this function will sometimes\n  // not be inlined since DenseStorage is an unwindable object for dynamic\n  // matrices and product types are holding a member to store the result.\n  // Thus it does not help tagging this function with EIGEN_STRONG_INLINE.\n  enum {\n    ProductIsValid =  Derived::ColsAtCompileTime==Dynamic\n                   || OtherDerived::RowsAtCompileTime==Dynamic\n                   || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime),\n    AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,\n    SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived,OtherDerived)\n  };\n  // note to the lost user:\n  //    * for a dot product use: v1.dot(v2)\n  //    * for a coeff-wise product use: v1.cwiseProduct(v2)\n  EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes),\n    INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)\n  EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),\n    INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)\n  EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)\n#ifdef EIGEN_DEBUG_PRODUCT\n  internal::product_type<Derived,OtherDerived>::debug();\n#endif\n\n  return Product<Derived, OtherDerived>(derived(), other.derived());\n}\n\n#endif // __CUDACC__\n\n/** \\returns an expression of the matrix product of \\c *this and \\a other without implicit evaluation.\n  *\n  * The returned product will behave like any other expressions: the coefficients of the product will be\n  * computed once at a time as requested. This might be useful in some extremely rare cases when only\n  * a small and no coherent fraction of the result's coefficients have to be computed.\n  *\n  * \\warning This version of the matrix product can be much much slower. So use it only if you know\n  * what you are doing and that you measured a true speed improvement.\n  *\n  * \\sa operator*(const MatrixBase&)\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nconst Product<Derived,OtherDerived,LazyProduct>\nMatrixBase<Derived>::lazyProduct(const MatrixBase<OtherDerived> &other) const\n{\n  enum {\n    ProductIsValid =  Derived::ColsAtCompileTime==Dynamic\n                   || OtherDerived::RowsAtCompileTime==Dynamic\n                   || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime),\n    AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,\n    SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived,OtherDerived)\n  };\n  // note to the lost user:\n  //    * for a dot product use: v1.dot(v2)\n  //    * for a coeff-wise product use: v1.cwiseProduct(v2)\n  EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes),\n    INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)\n  EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),\n    INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)\n  EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)\n\n  return Product<Derived,OtherDerived,LazyProduct>(derived(), other.derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_PRODUCT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/GenericPacketMath.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_GENERIC_PACKET_MATH_H\n#define EIGEN_GENERIC_PACKET_MATH_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n/** \\internal\n  * \\file GenericPacketMath.h\n  *\n  * Default implementation for types not supported by the vectorization.\n  * In practice these functions are provided to make easier the writing\n  * of generic vectorized code.\n  */\n\n#ifndef EIGEN_DEBUG_ALIGNED_LOAD\n#define EIGEN_DEBUG_ALIGNED_LOAD\n#endif\n\n#ifndef EIGEN_DEBUG_UNALIGNED_LOAD\n#define EIGEN_DEBUG_UNALIGNED_LOAD\n#endif\n\n#ifndef EIGEN_DEBUG_ALIGNED_STORE\n#define EIGEN_DEBUG_ALIGNED_STORE\n#endif\n\n#ifndef EIGEN_DEBUG_UNALIGNED_STORE\n#define EIGEN_DEBUG_UNALIGNED_STORE\n#endif\n\nstruct default_packet_traits\n{\n  enum {\n    HasHalfPacket = 0,\n\n    HasAdd    = 1,\n    HasSub    = 1,\n    HasMul    = 1,\n    HasNegate = 1,\n    HasAbs    = 1,\n    HasArg    = 0,\n    HasAbs2   = 1,\n    HasMin    = 1,\n    HasMax    = 1,\n    HasConj   = 1,\n    HasSetLinear = 1,\n    HasBlend  = 0,\n\n    HasDiv    = 0,\n    HasSqrt   = 0,\n    HasRsqrt  = 0,\n    HasExp    = 0,\n    HasLog    = 0,\n    HasLog1p  = 0,\n    HasLog10  = 0,\n    HasPow    = 0,\n\n    HasSin    = 0,\n    HasCos    = 0,\n    HasTan    = 0,\n    HasASin   = 0,\n    HasACos   = 0,\n    HasATan   = 0,\n    HasSinh   = 0,\n    HasCosh   = 0,\n    HasTanh   = 0,\n    HasLGamma = 0,\n    HasDiGamma = 0,\n    HasZeta = 0,\n    HasPolygamma = 0,\n    HasErf = 0,\n    HasErfc = 0,\n    HasIGamma = 0,\n    HasIGammac = 0,\n    HasBetaInc = 0,\n\n    HasRound  = 0,\n    HasFloor  = 0,\n    HasCeil   = 0,\n\n    HasSign   = 0\n  };\n};\n\ntemplate<typename T> struct packet_traits : default_packet_traits\n{\n  typedef T type;\n  typedef T half;\n  enum {\n    Vectorizable = 0,\n    size = 1,\n    AlignedOnScalar = 0,\n    HasHalfPacket = 0\n  };\n  enum {\n    HasAdd    = 0,\n    HasSub    = 0,\n    HasMul    = 0,\n    HasNegate = 0,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasConj   = 0,\n    HasSetLinear = 0\n  };\n};\n\ntemplate<typename T> struct packet_traits<const T> : packet_traits<T> { };\n\ntemplate <typename Src, typename Tgt> struct type_casting_traits {\n  enum {\n    VectorizedCast = 0,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 1\n  };\n};\n\n\n/** \\internal \\returns static_cast<TgtType>(a) (coeff-wise) */\ntemplate <typename SrcPacket, typename TgtPacket>\nEIGEN_DEVICE_FUNC inline TgtPacket\npcast(const SrcPacket& a) {\n  return static_cast<TgtPacket>(a);\n}\ntemplate <typename SrcPacket, typename TgtPacket>\nEIGEN_DEVICE_FUNC inline TgtPacket\npcast(const SrcPacket& a, const SrcPacket& /*b*/) {\n  return static_cast<TgtPacket>(a);\n}\n\ntemplate <typename SrcPacket, typename TgtPacket>\nEIGEN_DEVICE_FUNC inline TgtPacket\npcast(const SrcPacket& a, const SrcPacket& /*b*/, const SrcPacket& /*c*/, const SrcPacket& /*d*/) {\n  return static_cast<TgtPacket>(a);\n}\n\n/** \\internal \\returns a + b (coeff-wise) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npadd(const Packet& a,\n        const Packet& b) { return a+b; }\n\n/** \\internal \\returns a - b (coeff-wise) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npsub(const Packet& a,\n        const Packet& b) { return a-b; }\n\n/** \\internal \\returns -a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npnegate(const Packet& a) { return -a; }\n\n/** \\internal \\returns conj(a) (coeff-wise) */\n\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npconj(const Packet& a) { return numext::conj(a); }\n\n/** \\internal \\returns a * b (coeff-wise) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npmul(const Packet& a,\n        const Packet& b) { return a*b; }\n\n/** \\internal \\returns a / b (coeff-wise) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npdiv(const Packet& a,\n        const Packet& b) { return a/b; }\n\n/** \\internal \\returns the min of \\a a and \\a b  (coeff-wise) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npmin(const Packet& a,\n        const Packet& b) { return numext::mini(a, b); }\n\n/** \\internal \\returns the max of \\a a and \\a b  (coeff-wise) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npmax(const Packet& a,\n        const Packet& b) { return numext::maxi(a, b); }\n\n/** \\internal \\returns the absolute value of \\a a */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npabs(const Packet& a) { using std::abs; return abs(a); }\n\n/** \\internal \\returns the phase angle of \\a a */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\nparg(const Packet& a) { using numext::arg; return arg(a); }\n\n/** \\internal \\returns the bitwise and of \\a a and \\a b */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npand(const Packet& a, const Packet& b) { return a & b; }\n\n/** \\internal \\returns the bitwise or of \\a a and \\a b */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npor(const Packet& a, const Packet& b) { return a | b; }\n\n/** \\internal \\returns the bitwise xor of \\a a and \\a b */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npxor(const Packet& a, const Packet& b) { return a ^ b; }\n\n/** \\internal \\returns the bitwise andnot of \\a a and \\a b */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npandnot(const Packet& a, const Packet& b) { return a & (!b); }\n\n/** \\internal \\returns a packet version of \\a *from, from must be 16 bytes aligned */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npload(const typename unpacket_traits<Packet>::type* from) { return *from; }\n\n/** \\internal \\returns a packet version of \\a *from, (un-aligned load) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\nploadu(const typename unpacket_traits<Packet>::type* from) { return *from; }\n\n/** \\internal \\returns a packet with constant coefficients \\a a, e.g.: (a,a,a,a) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npset1(const typename unpacket_traits<Packet>::type& a) { return a; }\n\n/** \\internal \\returns a packet with constant coefficients \\a a[0], e.g.: (a[0],a[0],a[0],a[0]) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npload1(const typename unpacket_traits<Packet>::type  *a) { return pset1<Packet>(*a); }\n\n/** \\internal \\returns a packet with elements of \\a *from duplicated.\n  * For instance, for a packet of 8 elements, 4 scalars will be read from \\a *from and\n  * duplicated to form: {from[0],from[0],from[1],from[1],from[2],from[2],from[3],from[3]}\n  * Currently, this function is only used for scalar * complex products.\n  */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet\nploaddup(const typename unpacket_traits<Packet>::type* from) { return *from; }\n\n/** \\internal \\returns a packet with elements of \\a *from quadrupled.\n  * For instance, for a packet of 8 elements, 2 scalars will be read from \\a *from and\n  * replicated to form: {from[0],from[0],from[0],from[0],from[1],from[1],from[1],from[1]}\n  * Currently, this function is only used in matrix products.\n  * For packet-size smaller or equal to 4, this function is equivalent to pload1 \n  */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\nploadquad(const typename unpacket_traits<Packet>::type* from)\n{ return pload1<Packet>(from); }\n\n/** \\internal equivalent to\n  * \\code\n  * a0 = pload1(a+0);\n  * a1 = pload1(a+1);\n  * a2 = pload1(a+2);\n  * a3 = pload1(a+3);\n  * \\endcode\n  * \\sa pset1, pload1, ploaddup, pbroadcast2\n  */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC\ninline void pbroadcast4(const typename unpacket_traits<Packet>::type *a,\n                        Packet& a0, Packet& a1, Packet& a2, Packet& a3)\n{\n  a0 = pload1<Packet>(a+0);\n  a1 = pload1<Packet>(a+1);\n  a2 = pload1<Packet>(a+2);\n  a3 = pload1<Packet>(a+3);\n}\n\n/** \\internal equivalent to\n  * \\code\n  * a0 = pload1(a+0);\n  * a1 = pload1(a+1);\n  * \\endcode\n  * \\sa pset1, pload1, ploaddup, pbroadcast4\n  */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC\ninline void pbroadcast2(const typename unpacket_traits<Packet>::type *a,\n                        Packet& a0, Packet& a1)\n{\n  a0 = pload1<Packet>(a+0);\n  a1 = pload1<Packet>(a+1);\n}\n\n/** \\internal \\brief Returns a packet with coefficients (a,a+1,...,a+packet_size-1). */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet\nplset(const typename unpacket_traits<Packet>::type& a) { return a; }\n\n/** \\internal copy the packet \\a from to \\a *to, \\a to must be 16 bytes aligned */\ntemplate<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline void pstore(Scalar* to, const Packet& from)\n{ (*to) = from; }\n\n/** \\internal copy the packet \\a from to \\a *to, (un-aligned store) */\ntemplate<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline void pstoreu(Scalar* to, const Packet& from)\n{  (*to) = from; }\n\n template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline Packet pgather(const Scalar* from, Index /*stride*/)\n { return ploadu<Packet>(from); }\n\n template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline void pscatter(Scalar* to, const Packet& from, Index /*stride*/)\n { pstore(to, from); }\n\n/** \\internal tries to do cache prefetching of \\a addr */\ntemplate<typename Scalar> EIGEN_DEVICE_FUNC inline void prefetch(const Scalar* addr)\n{\n#ifdef __CUDA_ARCH__\n#if defined(__LP64__)\n  // 64-bit pointer operand constraint for inlined asm\n  asm(\" prefetch.L1 [ %1 ];\" : \"=l\"(addr) : \"l\"(addr));\n#else\n  // 32-bit pointer operand constraint for inlined asm\n  asm(\" prefetch.L1 [ %1 ];\" : \"=r\"(addr) : \"r\"(addr));\n#endif\n#elif (!EIGEN_COMP_MSVC) && (EIGEN_COMP_GNUC || EIGEN_COMP_CLANG || EIGEN_COMP_ICC)\n  __builtin_prefetch(addr);\n#endif\n}\n\n/** \\internal \\returns the first element of a packet */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline typename unpacket_traits<Packet>::type pfirst(const Packet& a)\n{ return a; }\n\n/** \\internal \\returns a packet where the element i contains the sum of the packet of \\a vec[i] */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npreduxp(const Packet* vecs) { return vecs[0]; }\n\n/** \\internal \\returns the sum of the elements of \\a a*/\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline typename unpacket_traits<Packet>::type predux(const Packet& a)\n{ return a; }\n\n/** \\internal \\returns the sum of the elements of \\a a by block of 4 elements.\n  * For a packet {a0, a1, a2, a3, a4, a5, a6, a7}, it returns a half packet {a0+a4, a1+a5, a2+a6, a3+a7}\n  * For packet-size smaller or equal to 4, this boils down to a noop.\n  */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline\ntypename conditional<(unpacket_traits<Packet>::size%8)==0,typename unpacket_traits<Packet>::half,Packet>::type\npredux_downto4(const Packet& a)\n{ return a; }\n\n/** \\internal \\returns the product of the elements of \\a a*/\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline typename unpacket_traits<Packet>::type predux_mul(const Packet& a)\n{ return a; }\n\n/** \\internal \\returns the min of the elements of \\a a*/\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline typename unpacket_traits<Packet>::type predux_min(const Packet& a)\n{ return a; }\n\n/** \\internal \\returns the max of the elements of \\a a*/\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline typename unpacket_traits<Packet>::type predux_max(const Packet& a)\n{ return a; }\n\n/** \\internal \\returns the reversed elements of \\a a*/\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet preverse(const Packet& a)\n{ return a; }\n\n/** \\internal \\returns \\a a with real and imaginary part flipped (for complex type only) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet pcplxflip(const Packet& a)\n{\n  // FIXME: uncomment the following in case we drop the internal imag and real functions.\n//   using std::imag;\n//   using std::real;\n  return Packet(imag(a),real(a));\n}\n\n/**************************\n* Special math functions\n***************************/\n\n/** \\internal \\returns the sine of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket psin(const Packet& a) { using std::sin; return sin(a); }\n\n/** \\internal \\returns the cosine of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket pcos(const Packet& a) { using std::cos; return cos(a); }\n\n/** \\internal \\returns the tan of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket ptan(const Packet& a) { using std::tan; return tan(a); }\n\n/** \\internal \\returns the arc sine of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket pasin(const Packet& a) { using std::asin; return asin(a); }\n\n/** \\internal \\returns the arc cosine of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket pacos(const Packet& a) { using std::acos; return acos(a); }\n\n/** \\internal \\returns the arc tangent of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket patan(const Packet& a) { using std::atan; return atan(a); }\n\n/** \\internal \\returns the hyperbolic sine of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket psinh(const Packet& a) { using std::sinh; return sinh(a); }\n\n/** \\internal \\returns the hyperbolic cosine of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket pcosh(const Packet& a) { using std::cosh; return cosh(a); }\n\n/** \\internal \\returns the hyperbolic tan of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket ptanh(const Packet& a) { using std::tanh; return tanh(a); }\n\n/** \\internal \\returns the exp of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket pexp(const Packet& a) { using std::exp; return exp(a); }\n\n/** \\internal \\returns the log of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket plog(const Packet& a) { using std::log; return log(a); }\n\n/** \\internal \\returns the log1p of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket plog1p(const Packet& a) { return numext::log1p(a); }\n\n/** \\internal \\returns the log10 of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket plog10(const Packet& a) { using std::log10; return log10(a); }\n\n/** \\internal \\returns the square-root of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket psqrt(const Packet& a) { using std::sqrt; return sqrt(a); }\n\n/** \\internal \\returns the reciprocal square-root of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket prsqrt(const Packet& a) {\n  return pdiv(pset1<Packet>(1), psqrt(a));\n}\n\n/** \\internal \\returns the rounded value of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket pround(const Packet& a) { using numext::round; return round(a); }\n\n/** \\internal \\returns the floor of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket pfloor(const Packet& a) { using numext::floor; return floor(a); }\n\n/** \\internal \\returns the ceil of \\a a (coeff-wise) */\ntemplate<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\nPacket pceil(const Packet& a) { using numext::ceil; return ceil(a); }\n\n/***************************************************************************\n* The following functions might not have to be overwritten for vectorized types\n***************************************************************************/\n\n/** \\internal copy a packet with constant coeficient \\a a (e.g., [a,a,a,a]) to \\a *to. \\a to must be 16 bytes aligned */\n// NOTE: this function must really be templated on the packet type (think about different packet types for the same scalar type)\ntemplate<typename Packet>\ninline void pstore1(typename unpacket_traits<Packet>::type* to, const typename unpacket_traits<Packet>::type& a)\n{\n  pstore(to, pset1<Packet>(a));\n}\n\n/** \\internal \\returns a * b + c (coeff-wise) */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npmadd(const Packet&  a,\n         const Packet&  b,\n         const Packet&  c)\n{ return padd(pmul(a, b),c); }\n\n/** \\internal \\returns a packet version of \\a *from.\n  * The pointer \\a from must be aligned on a \\a Alignment bytes boundary. */\ntemplate<typename Packet, int Alignment>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet ploadt(const typename unpacket_traits<Packet>::type* from)\n{\n  if(Alignment >= unpacket_traits<Packet>::alignment)\n    return pload<Packet>(from);\n  else\n    return ploadu<Packet>(from);\n}\n\n/** \\internal copy the packet \\a from to \\a *to.\n  * The pointer \\a from must be aligned on a \\a Alignment bytes boundary. */\ntemplate<typename Scalar, typename Packet, int Alignment>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void pstoret(Scalar* to, const Packet& from)\n{\n  if(Alignment >= unpacket_traits<Packet>::alignment)\n    pstore(to, from);\n  else\n    pstoreu(to, from);\n}\n\n/** \\internal \\returns a packet version of \\a *from.\n  * Unlike ploadt, ploadt_ro takes advantage of the read-only memory path on the\n  * hardware if available to speedup the loading of data that won't be modified\n  * by the current computation.\n  */\ntemplate<typename Packet, int LoadMode>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet ploadt_ro(const typename unpacket_traits<Packet>::type* from)\n{\n  return ploadt<Packet, LoadMode>(from);\n}\n\n/** \\internal default implementation of palign() allowing partial specialization */\ntemplate<int Offset,typename PacketType>\nstruct palign_impl\n{\n  // by default data are aligned, so there is nothing to be done :)\n  static inline void run(PacketType&, const PacketType&) {}\n};\n\n/** \\internal update \\a first using the concatenation of the packet_size minus \\a Offset last elements\n  * of \\a first and \\a Offset first elements of \\a second.\n  * \n  * This function is currently only used to optimize matrix-vector products on unligned matrices.\n  * It takes 2 packets that represent a contiguous memory array, and returns a packet starting\n  * at the position \\a Offset. For instance, for packets of 4 elements, we have:\n  *  Input:\n  *  - first = {f0,f1,f2,f3}\n  *  - second = {s0,s1,s2,s3}\n  * Output: \n  *   - if Offset==0 then {f0,f1,f2,f3}\n  *   - if Offset==1 then {f1,f2,f3,s0}\n  *   - if Offset==2 then {f2,f3,s0,s1}\n  *   - if Offset==3 then {f3,s0,s1,s3}\n  */\ntemplate<int Offset,typename PacketType>\ninline void palign(PacketType& first, const PacketType& second)\n{\n  palign_impl<Offset,PacketType>::run(first,second);\n}\n\n/***************************************************************************\n* Fast complex products (GCC generates a function call which is very slow)\n***************************************************************************/\n\n// Eigen+CUDA does not support complexes.\n#ifndef __CUDACC__\n\ntemplate<> inline std::complex<float> pmul(const std::complex<float>& a, const std::complex<float>& b)\n{ return std::complex<float>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }\n\ntemplate<> inline std::complex<double> pmul(const std::complex<double>& a, const std::complex<double>& b)\n{ return std::complex<double>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }\n\n#endif\n\n\n/***************************************************************************\n * PacketBlock, that is a collection of N packets where the number of words\n * in the packet is a multiple of N.\n***************************************************************************/\ntemplate <typename Packet,int N=unpacket_traits<Packet>::size> struct PacketBlock {\n  Packet packet[N];\n};\n\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet,1>& /*kernel*/) {\n  // Nothing to do in the scalar case, i.e. a 1x1 matrix.\n}\n\n/***************************************************************************\n * Selector, i.e. vector of N boolean values used to select (i.e. blend)\n * words from 2 packets.\n***************************************************************************/\ntemplate <size_t N> struct Selector {\n  bool select[N];\n};\n\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npblend(const Selector<unpacket_traits<Packet>::size>& ifPacket, const Packet& thenPacket, const Packet& elsePacket) {\n  return ifPacket.select[0] ? thenPacket : elsePacket;\n}\n\n/** \\internal \\returns \\a a with the first coefficient replaced by the scalar b */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npinsertfirst(const Packet& a, typename unpacket_traits<Packet>::type b)\n{\n  // Default implementation based on pblend.\n  // It must be specialized for higher performance.\n  Selector<unpacket_traits<Packet>::size> mask;\n  mask.select[0] = true;\n  // This for loop should be optimized away by the compiler.\n  for(Index i=1; i<unpacket_traits<Packet>::size; ++i)\n    mask.select[i] = false;\n  return pblend(mask, pset1<Packet>(b), a);\n}\n\n/** \\internal \\returns \\a a with the last coefficient replaced by the scalar b */\ntemplate<typename Packet> EIGEN_DEVICE_FUNC inline Packet\npinsertlast(const Packet& a, typename unpacket_traits<Packet>::type b)\n{\n  // Default implementation based on pblend.\n  // It must be specialized for higher performance.\n  Selector<unpacket_traits<Packet>::size> mask;\n  // This for loop should be optimized away by the compiler.\n  for(Index i=0; i<unpacket_traits<Packet>::size-1; ++i)\n    mask.select[i] = false;\n  mask.select[unpacket_traits<Packet>::size-1] = true;\n  return pblend(mask, pset1<Packet>(b), a);\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_GENERIC_PACKET_MATH_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/GlobalFunctions.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010-2016 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_GLOBAL_FUNCTIONS_H\n#define EIGEN_GLOBAL_FUNCTIONS_H\n\n#ifdef EIGEN_PARSED_BY_DOXYGEN\n\n#define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME,FUNCTOR,DOC_OP,DOC_DETAILS) \\\n  /** \\returns an expression of the coefficient-wise DOC_OP of \\a x\n\n    DOC_DETAILS\n\n    \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_##NAME\">Math functions</a>, class CwiseUnaryOp\n    */ \\\n  template<typename Derived> \\\n  inline const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> \\\n  NAME(const Eigen::ArrayBase<Derived>& x);\n\n#else\n\n#define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME,FUNCTOR,DOC_OP,DOC_DETAILS) \\\n  template<typename Derived> \\\n  inline const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> \\\n  (NAME)(const Eigen::ArrayBase<Derived>& x) { \\\n    return Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived>(x.derived()); \\\n  }\n\n#endif // EIGEN_PARSED_BY_DOXYGEN\n\n#define EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME,FUNCTOR) \\\n  \\\n  template<typename Derived> \\\n  struct NAME##_retval<ArrayBase<Derived> > \\\n  { \\\n    typedef const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> type; \\\n  }; \\\n  template<typename Derived> \\\n  struct NAME##_impl<ArrayBase<Derived> > \\\n  { \\\n    static inline typename NAME##_retval<ArrayBase<Derived> >::type run(const Eigen::ArrayBase<Derived>& x) \\\n    { \\\n      return typename NAME##_retval<ArrayBase<Derived> >::type(x.derived()); \\\n    } \\\n  };\n\nnamespace Eigen\n{\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(real,scalar_real_op,real part,\\sa ArrayBase::real)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(imag,scalar_imag_op,imaginary part,\\sa ArrayBase::imag)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(conj,scalar_conjugate_op,complex conjugate,\\sa ArrayBase::conjugate)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(inverse,scalar_inverse_op,inverse,\\sa ArrayBase::inverse)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sin,scalar_sin_op,sine,\\sa ArrayBase::sin)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cos,scalar_cos_op,cosine,\\sa ArrayBase::cos)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tan,scalar_tan_op,tangent,\\sa ArrayBase::tan)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(atan,scalar_atan_op,arc-tangent,\\sa ArrayBase::atan)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asin,scalar_asin_op,arc-sine,\\sa ArrayBase::asin)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acos,scalar_acos_op,arc-consine,\\sa ArrayBase::acos)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sinh,scalar_sinh_op,hyperbolic sine,\\sa ArrayBase::sinh)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cosh,scalar_cosh_op,hyperbolic cosine,\\sa ArrayBase::cosh)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tanh,scalar_tanh_op,hyperbolic tangent,\\sa ArrayBase::tanh)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(lgamma,scalar_lgamma_op,natural logarithm of the gamma function,\\sa ArrayBase::lgamma)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(digamma,scalar_digamma_op,derivative of lgamma,\\sa ArrayBase::digamma)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(erf,scalar_erf_op,error function,\\sa ArrayBase::erf)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(erfc,scalar_erfc_op,complement error function,\\sa ArrayBase::erfc)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(exp,scalar_exp_op,exponential,\\sa ArrayBase::exp)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log,scalar_log_op,natural logarithm,\\sa Eigen::log10 DOXCOMMA ArrayBase::log)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log1p,scalar_log1p_op,natural logarithm of 1 plus the value,\\sa ArrayBase::log1p)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log10,scalar_log10_op,base 10 logarithm,\\sa Eigen::log DOXCOMMA ArrayBase::log)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs,scalar_abs_op,absolute value,\\sa ArrayBase::abs DOXCOMMA MatrixBase::cwiseAbs)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs2,scalar_abs2_op,squared absolute value,\\sa ArrayBase::abs2 DOXCOMMA MatrixBase::cwiseAbs2)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(arg,scalar_arg_op,complex argument,\\sa ArrayBase::arg)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sqrt,scalar_sqrt_op,square root,\\sa ArrayBase::sqrt DOXCOMMA MatrixBase::cwiseSqrt)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(rsqrt,scalar_rsqrt_op,reciprocal square root,\\sa ArrayBase::rsqrt)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(square,scalar_square_op,square (power 2),\\sa Eigen::abs2 DOXCOMMA Eigen::pow DOXCOMMA ArrayBase::square)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cube,scalar_cube_op,cube (power 3),\\sa Eigen::pow DOXCOMMA ArrayBase::cube)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(round,scalar_round_op,nearest integer,\\sa Eigen::floor DOXCOMMA Eigen::ceil DOXCOMMA ArrayBase::round)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(floor,scalar_floor_op,nearest integer not greater than the giben value,\\sa Eigen::ceil DOXCOMMA ArrayBase::floor)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(ceil,scalar_ceil_op,nearest integer not less than the giben value,\\sa Eigen::floor DOXCOMMA ArrayBase::ceil)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isnan,scalar_isnan_op,not-a-number test,\\sa Eigen::isinf DOXCOMMA Eigen::isfinite DOXCOMMA ArrayBase::isnan)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isinf,scalar_isinf_op,infinite value test,\\sa Eigen::isnan DOXCOMMA Eigen::isfinite DOXCOMMA ArrayBase::isinf)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isfinite,scalar_isfinite_op,finite value test,\\sa Eigen::isinf DOXCOMMA Eigen::isnan DOXCOMMA ArrayBase::isfinite)\n  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sign,scalar_sign_op,sign (or 0),\\sa ArrayBase::sign)\n  \n  /** \\returns an expression of the coefficient-wise power of \\a x to the given constant \\a exponent.\n    *\n    * \\tparam ScalarExponent is the scalar type of \\a exponent. It must be compatible with the scalar type of the given expression (\\c Derived::Scalar).\n    *\n    * \\sa ArrayBase::pow()\n    *\n    * \\relates ArrayBase\n    */\n#ifdef EIGEN_PARSED_BY_DOXYGEN\n  template<typename Derived,typename ScalarExponent>\n  inline const CwiseBinaryOp<internal::scalar_pow_op<Derived::Scalar,ScalarExponent>,Derived,Constant<ScalarExponent> >\n  pow(const Eigen::ArrayBase<Derived>& x, const ScalarExponent& exponent);\n#else\n  template<typename Derived,typename ScalarExponent>\n  inline typename internal::enable_if<   !(internal::is_same<typename Derived::Scalar,ScalarExponent>::value) && EIGEN_SCALAR_BINARY_SUPPORTED(pow,typename Derived::Scalar,ScalarExponent),\n          const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,ScalarExponent,pow) >::type\n  pow(const Eigen::ArrayBase<Derived>& x, const ScalarExponent& exponent) {\n    return x.derived().pow(exponent);\n  }\n\n  template<typename Derived>\n  inline const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,typename Derived::Scalar,pow)\n  pow(const Eigen::ArrayBase<Derived>& x, const typename Derived::Scalar& exponent) {\n    return x.derived().pow(exponent);\n  }\n#endif\n\n  /** \\returns an expression of the coefficient-wise power of \\a x to the given array of \\a exponents.\n    *\n    * This function computes the coefficient-wise power.\n    *\n    * Example: \\include Cwise_array_power_array.cpp\n    * Output: \\verbinclude Cwise_array_power_array.out\n    * \n    * \\sa ArrayBase::pow()\n    *\n    * \\relates ArrayBase\n    */\n  template<typename Derived,typename ExponentDerived>\n  inline const Eigen::CwiseBinaryOp<Eigen::internal::scalar_pow_op<typename Derived::Scalar, typename ExponentDerived::Scalar>, const Derived, const ExponentDerived>\n  pow(const Eigen::ArrayBase<Derived>& x, const Eigen::ArrayBase<ExponentDerived>& exponents) \n  {\n    return Eigen::CwiseBinaryOp<Eigen::internal::scalar_pow_op<typename Derived::Scalar, typename ExponentDerived::Scalar>, const Derived, const ExponentDerived>(\n      x.derived(),\n      exponents.derived()\n    );\n  }\n  \n  /** \\returns an expression of the coefficient-wise power of the scalar \\a x to the given array of \\a exponents.\n    *\n    * This function computes the coefficient-wise power between a scalar and an array of exponents.\n    *\n    * \\tparam Scalar is the scalar type of \\a x. It must be compatible with the scalar type of the given array expression (\\c Derived::Scalar).\n    *\n    * Example: \\include Cwise_scalar_power_array.cpp\n    * Output: \\verbinclude Cwise_scalar_power_array.out\n    * \n    * \\sa ArrayBase::pow()\n    *\n    * \\relates ArrayBase\n    */\n#ifdef EIGEN_PARSED_BY_DOXYGEN\n  template<typename Scalar,typename Derived>\n  inline const CwiseBinaryOp<internal::scalar_pow_op<Scalar,Derived::Scalar>,Constant<Scalar>,Derived>\n  pow(const Scalar& x,const Eigen::ArrayBase<Derived>& x);\n#else\n  template<typename Scalar, typename Derived>\n  inline typename internal::enable_if<   !(internal::is_same<typename Derived::Scalar,Scalar>::value) && EIGEN_SCALAR_BINARY_SUPPORTED(pow,Scalar,typename Derived::Scalar),\n          const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,Derived,pow) >::type\n  pow(const Scalar& x, const Eigen::ArrayBase<Derived>& exponents)\n  {\n    return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,Derived,pow)(\n            typename internal::plain_constant_type<Derived,Scalar>::type(exponents.rows(), exponents.cols(), x), exponents.derived() );\n  }\n\n  template<typename Derived>\n  inline const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename Derived::Scalar,Derived,pow)\n  pow(const typename Derived::Scalar& x, const Eigen::ArrayBase<Derived>& exponents)\n  {\n    return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename Derived::Scalar,Derived,pow)(\n      typename internal::plain_constant_type<Derived,typename Derived::Scalar>::type(exponents.rows(), exponents.cols(), x), exponents.derived() );\n  }\n#endif\n\n\n  namespace internal\n  {\n    EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(real,scalar_real_op)\n    EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(imag,scalar_imag_op)\n    EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs2,scalar_abs2_op)\n  }\n}\n\n// TODO: cleanly disable those functions that are not supported on Array (numext::real_ref, internal::random, internal::isApprox...)\n\n#endif // EIGEN_GLOBAL_FUNCTIONS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/IO.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_IO_H\n#define EIGEN_IO_H\n\nnamespace Eigen { \n\nenum { DontAlignCols = 1 };\nenum { StreamPrecision = -1,\n       FullPrecision = -2 };\n\nnamespace internal {\ntemplate<typename Derived>\nstd::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt);\n}\n\n/** \\class IOFormat\n  * \\ingroup Core_Module\n  *\n  * \\brief Stores a set of parameters controlling the way matrices are printed\n  *\n  * List of available parameters:\n  *  - \\b precision number of digits for floating point values, or one of the special constants \\c StreamPrecision and \\c FullPrecision.\n  *                 The default is the special value \\c StreamPrecision which means to use the\n  *                 stream's own precision setting, as set for instance using \\c cout.precision(3). The other special value\n  *                 \\c FullPrecision means that the number of digits will be computed to match the full precision of each floating-point\n  *                 type.\n  *  - \\b flags an OR-ed combination of flags, the default value is 0, the only currently available flag is \\c DontAlignCols which\n  *             allows to disable the alignment of columns, resulting in faster code.\n  *  - \\b coeffSeparator string printed between two coefficients of the same row\n  *  - \\b rowSeparator string printed between two rows\n  *  - \\b rowPrefix string printed at the beginning of each row\n  *  - \\b rowSuffix string printed at the end of each row\n  *  - \\b matPrefix string printed at the beginning of the matrix\n  *  - \\b matSuffix string printed at the end of the matrix\n  *\n  * Example: \\include IOFormat.cpp\n  * Output: \\verbinclude IOFormat.out\n  *\n  * \\sa DenseBase::format(), class WithFormat\n  */\nstruct IOFormat\n{\n  /** Default constructor, see class IOFormat for the meaning of the parameters */\n  IOFormat(int _precision = StreamPrecision, int _flags = 0,\n    const std::string& _coeffSeparator = \" \",\n    const std::string& _rowSeparator = \"\\n\", const std::string& _rowPrefix=\"\", const std::string& _rowSuffix=\"\",\n    const std::string& _matPrefix=\"\", const std::string& _matSuffix=\"\")\n  : matPrefix(_matPrefix), matSuffix(_matSuffix), rowPrefix(_rowPrefix), rowSuffix(_rowSuffix), rowSeparator(_rowSeparator),\n    rowSpacer(\"\"), coeffSeparator(_coeffSeparator), precision(_precision), flags(_flags)\n  {\n    // TODO check if rowPrefix, rowSuffix or rowSeparator contains a newline\n    // don't add rowSpacer if columns are not to be aligned\n    if((flags & DontAlignCols))\n      return;\n    int i = int(matSuffix.length())-1;\n    while (i>=0 && matSuffix[i]!='\\n')\n    {\n      rowSpacer += ' ';\n      i--;\n    }\n  }\n  std::string matPrefix, matSuffix;\n  std::string rowPrefix, rowSuffix, rowSeparator, rowSpacer;\n  std::string coeffSeparator;\n  int precision;\n  int flags;\n};\n\n/** \\class WithFormat\n  * \\ingroup Core_Module\n  *\n  * \\brief Pseudo expression providing matrix output with given format\n  *\n  * \\tparam ExpressionType the type of the object on which IO stream operations are performed\n  *\n  * This class represents an expression with stream operators controlled by a given IOFormat.\n  * It is the return type of DenseBase::format()\n  * and most of the time this is the only way it is used.\n  *\n  * See class IOFormat for some examples.\n  *\n  * \\sa DenseBase::format(), class IOFormat\n  */\ntemplate<typename ExpressionType>\nclass WithFormat\n{\n  public:\n\n    WithFormat(const ExpressionType& matrix, const IOFormat& format)\n      : m_matrix(matrix), m_format(format)\n    {}\n\n    friend std::ostream & operator << (std::ostream & s, const WithFormat& wf)\n    {\n      return internal::print_matrix(s, wf.m_matrix.eval(), wf.m_format);\n    }\n\n  protected:\n    typename ExpressionType::Nested m_matrix;\n    IOFormat m_format;\n};\n\nnamespace internal {\n\n// NOTE: This helper is kept for backward compatibility with previous code specializing\n//       this internal::significant_decimals_impl structure. In the future we should directly\n//       call digits10() which has been introduced in July 2016 in 3.3.\ntemplate<typename Scalar>\nstruct significant_decimals_impl\n{\n  static inline int run()\n  {\n    return NumTraits<Scalar>::digits10();\n  }\n};\n\n/** \\internal\n  * print the matrix \\a _m to the output stream \\a s using the output format \\a fmt */\ntemplate<typename Derived>\nstd::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt)\n{\n  if(_m.size() == 0)\n  {\n    s << fmt.matPrefix << fmt.matSuffix;\n    return s;\n  }\n  \n  typename Derived::Nested m = _m;\n  typedef typename Derived::Scalar Scalar;\n\n  Index width = 0;\n\n  std::streamsize explicit_precision;\n  if(fmt.precision == StreamPrecision)\n  {\n    explicit_precision = 0;\n  }\n  else if(fmt.precision == FullPrecision)\n  {\n    if (NumTraits<Scalar>::IsInteger)\n    {\n      explicit_precision = 0;\n    }\n    else\n    {\n      explicit_precision = significant_decimals_impl<Scalar>::run();\n    }\n  }\n  else\n  {\n    explicit_precision = fmt.precision;\n  }\n\n  std::streamsize old_precision = 0;\n  if(explicit_precision) old_precision = s.precision(explicit_precision);\n\n  bool align_cols = !(fmt.flags & DontAlignCols);\n  if(align_cols)\n  {\n    // compute the largest width\n    for(Index j = 0; j < m.cols(); ++j)\n      for(Index i = 0; i < m.rows(); ++i)\n      {\n        std::stringstream sstr;\n        sstr.copyfmt(s);\n        sstr << m.coeff(i,j);\n        width = std::max<Index>(width, Index(sstr.str().length()));\n      }\n  }\n  s << fmt.matPrefix;\n  for(Index i = 0; i < m.rows(); ++i)\n  {\n    if (i)\n      s << fmt.rowSpacer;\n    s << fmt.rowPrefix;\n    if(width) s.width(width);\n    s << m.coeff(i, 0);\n    for(Index j = 1; j < m.cols(); ++j)\n    {\n      s << fmt.coeffSeparator;\n      if (width) s.width(width);\n      s << m.coeff(i, j);\n    }\n    s << fmt.rowSuffix;\n    if( i < m.rows() - 1)\n      s << fmt.rowSeparator;\n  }\n  s << fmt.matSuffix;\n  if(explicit_precision) s.precision(old_precision);\n  return s;\n}\n\n} // end namespace internal\n\n/** \\relates DenseBase\n  *\n  * Outputs the matrix, to the given stream.\n  *\n  * If you wish to print the matrix with a format different than the default, use DenseBase::format().\n  *\n  * It is also possible to change the default format by defining EIGEN_DEFAULT_IO_FORMAT before including Eigen headers.\n  * If not defined, this will automatically be defined to Eigen::IOFormat(), that is the Eigen::IOFormat with default parameters.\n  *\n  * \\sa DenseBase::format()\n  */\ntemplate<typename Derived>\nstd::ostream & operator <<\n(std::ostream & s,\n const DenseBase<Derived> & m)\n{\n  return internal::print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT);\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_IO_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Inverse.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_INVERSE_H\n#define EIGEN_INVERSE_H\n\nnamespace Eigen { \n\ntemplate<typename XprType,typename StorageKind> class InverseImpl;\n\nnamespace internal {\n\ntemplate<typename XprType>\nstruct traits<Inverse<XprType> >\n  : traits<typename XprType::PlainObject>\n{\n  typedef typename XprType::PlainObject PlainObject;\n  typedef traits<PlainObject> BaseTraits;\n  enum {\n    Flags = BaseTraits::Flags & RowMajorBit\n  };\n};\n\n} // end namespace internal\n\n/** \\class Inverse\n  *\n  * \\brief Expression of the inverse of another expression\n  *\n  * \\tparam XprType the type of the expression we are taking the inverse\n  *\n  * This class represents an abstract expression of A.inverse()\n  * and most of the time this is the only way it is used.\n  *\n  */\ntemplate<typename XprType>\nclass Inverse : public InverseImpl<XprType,typename internal::traits<XprType>::StorageKind>\n{\npublic:\n  typedef typename XprType::StorageIndex StorageIndex;\n  typedef typename XprType::PlainObject                       PlainObject;\n  typedef typename XprType::Scalar                            Scalar;\n  typedef typename internal::ref_selector<XprType>::type      XprTypeNested;\n  typedef typename internal::remove_all<XprTypeNested>::type  XprTypeNestedCleaned;\n  typedef typename internal::ref_selector<Inverse>::type Nested;\n  typedef typename internal::remove_all<XprType>::type NestedExpression;\n  \n  explicit EIGEN_DEVICE_FUNC Inverse(const XprType &xpr)\n    : m_xpr(xpr)\n  {}\n\n  EIGEN_DEVICE_FUNC Index rows() const { return m_xpr.rows(); }\n  EIGEN_DEVICE_FUNC Index cols() const { return m_xpr.cols(); }\n\n  EIGEN_DEVICE_FUNC const XprTypeNestedCleaned& nestedExpression() const { return m_xpr; }\n\nprotected:\n  XprTypeNested m_xpr;\n};\n\n// Generic API dispatcher\ntemplate<typename XprType, typename StorageKind>\nclass InverseImpl\n  : public internal::generic_xpr_base<Inverse<XprType> >::type\n{\npublic:\n  typedef typename internal::generic_xpr_base<Inverse<XprType> >::type Base;\n  typedef typename XprType::Scalar Scalar;\nprivate:\n\n  Scalar coeff(Index row, Index col) const;\n  Scalar coeff(Index i) const;\n};\n\nnamespace internal {\n\n/** \\internal\n  * \\brief Default evaluator for Inverse expression.\n  * \n  * This default evaluator for Inverse expression simply evaluate the inverse into a temporary\n  * by a call to internal::call_assignment_no_alias.\n  * Therefore, inverse implementers only have to specialize Assignment<Dst,Inverse<...>, ...> for\n  * there own nested expression.\n  *\n  * \\sa class Inverse\n  */\ntemplate<typename ArgType>\nstruct unary_evaluator<Inverse<ArgType> >\n  : public evaluator<typename Inverse<ArgType>::PlainObject>\n{\n  typedef Inverse<ArgType> InverseType;\n  typedef typename InverseType::PlainObject PlainObject;\n  typedef evaluator<PlainObject> Base;\n  \n  enum { Flags = Base::Flags | EvalBeforeNestingBit };\n\n  unary_evaluator(const InverseType& inv_xpr)\n    : m_result(inv_xpr.rows(), inv_xpr.cols())\n  {\n    ::new (static_cast<Base*>(this)) Base(m_result);\n    internal::call_assignment_no_alias(m_result, inv_xpr);\n  }\n  \nprotected:\n  PlainObject m_result;\n};\n  \n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_INVERSE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Map.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MAP_H\n#define EIGEN_MAP_H\n\nnamespace Eigen { \n\nnamespace internal {\ntemplate<typename PlainObjectType, int MapOptions, typename StrideType>\nstruct traits<Map<PlainObjectType, MapOptions, StrideType> >\n  : public traits<PlainObjectType>\n{\n  typedef traits<PlainObjectType> TraitsBase;\n  enum {\n    InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0\n                             ? int(PlainObjectType::InnerStrideAtCompileTime)\n                             : int(StrideType::InnerStrideAtCompileTime),\n    OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0\n                             ? int(PlainObjectType::OuterStrideAtCompileTime)\n                             : int(StrideType::OuterStrideAtCompileTime),\n    Alignment = int(MapOptions)&int(AlignedMask),\n    Flags0 = TraitsBase::Flags & (~NestByRefBit),\n    Flags = is_lvalue<PlainObjectType>::value ? int(Flags0) : (int(Flags0) & ~LvalueBit)\n  };\nprivate:\n  enum { Options }; // Expressions don't have Options\n};\n}\n\n/** \\class Map\n  * \\ingroup Core_Module\n  *\n  * \\brief A matrix or vector expression mapping an existing array of data.\n  *\n  * \\tparam PlainObjectType the equivalent matrix type of the mapped data\n  * \\tparam MapOptions specifies the pointer alignment in bytes. It can be: \\c #Aligned128, , \\c #Aligned64, \\c #Aligned32, \\c #Aligned16, \\c #Aligned8 or \\c #Unaligned.\n  *                The default is \\c #Unaligned.\n  * \\tparam StrideType optionally specifies strides. By default, Map assumes the memory layout\n  *                   of an ordinary, contiguous array. This can be overridden by specifying strides.\n  *                   The type passed here must be a specialization of the Stride template, see examples below.\n  *\n  * This class represents a matrix or vector expression mapping an existing array of data.\n  * It can be used to let Eigen interface without any overhead with non-Eigen data structures,\n  * such as plain C arrays or structures from other libraries. By default, it assumes that the\n  * data is laid out contiguously in memory. You can however override this by explicitly specifying\n  * inner and outer strides.\n  *\n  * Here's an example of simply mapping a contiguous array as a \\ref TopicStorageOrders \"column-major\" matrix:\n  * \\include Map_simple.cpp\n  * Output: \\verbinclude Map_simple.out\n  *\n  * If you need to map non-contiguous arrays, you can do so by specifying strides:\n  *\n  * Here's an example of mapping an array as a vector, specifying an inner stride, that is, the pointer\n  * increment between two consecutive coefficients. Here, we're specifying the inner stride as a compile-time\n  * fixed value.\n  * \\include Map_inner_stride.cpp\n  * Output: \\verbinclude Map_inner_stride.out\n  *\n  * Here's an example of mapping an array while specifying an outer stride. Here, since we're mapping\n  * as a column-major matrix, 'outer stride' means the pointer increment between two consecutive columns.\n  * Here, we're specifying the outer stride as a runtime parameter. Note that here \\c OuterStride<> is\n  * a short version of \\c OuterStride<Dynamic> because the default template parameter of OuterStride\n  * is  \\c Dynamic\n  * \\include Map_outer_stride.cpp\n  * Output: \\verbinclude Map_outer_stride.out\n  *\n  * For more details and for an example of specifying both an inner and an outer stride, see class Stride.\n  *\n  * \\b Tip: to change the array of data mapped by a Map object, you can use the C++\n  * placement new syntax:\n  *\n  * Example: \\include Map_placement_new.cpp\n  * Output: \\verbinclude Map_placement_new.out\n  *\n  * This class is the return type of PlainObjectBase::Map() but can also be used directly.\n  *\n  * \\sa PlainObjectBase::Map(), \\ref TopicStorageOrders\n  */\ntemplate<typename PlainObjectType, int MapOptions, typename StrideType> class Map\n  : public MapBase<Map<PlainObjectType, MapOptions, StrideType> >\n{\n  public:\n\n    typedef MapBase<Map> Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(Map)\n\n    typedef typename Base::PointerType PointerType;\n    typedef PointerType PointerArgType;\n    EIGEN_DEVICE_FUNC\n    inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; }\n\n    EIGEN_DEVICE_FUNC\n    inline Index innerStride() const\n    {\n      return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline Index outerStride() const\n    {\n      return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()\n           : IsVectorAtCompileTime ? this->size()\n           : int(Flags)&RowMajorBit ? this->cols()\n           : this->rows();\n    }\n\n    /** Constructor in the fixed-size case.\n      *\n      * \\param dataPtr pointer to the array to map\n      * \\param stride optional Stride object, passing the strides.\n      */\n    EIGEN_DEVICE_FUNC\n    explicit inline Map(PointerArgType dataPtr, const StrideType& stride = StrideType())\n      : Base(cast_to_pointer_type(dataPtr)), m_stride(stride)\n    {\n      PlainObjectType::Base::_check_template_params();\n    }\n\n    /** Constructor in the dynamic-size vector case.\n      *\n      * \\param dataPtr pointer to the array to map\n      * \\param size the size of the vector expression\n      * \\param stride optional Stride object, passing the strides.\n      */\n    EIGEN_DEVICE_FUNC\n    inline Map(PointerArgType dataPtr, Index size, const StrideType& stride = StrideType())\n      : Base(cast_to_pointer_type(dataPtr), size), m_stride(stride)\n    {\n      PlainObjectType::Base::_check_template_params();\n    }\n\n    /** Constructor in the dynamic-size matrix case.\n      *\n      * \\param dataPtr pointer to the array to map\n      * \\param rows the number of rows of the matrix expression\n      * \\param cols the number of columns of the matrix expression\n      * \\param stride optional Stride object, passing the strides.\n      */\n    EIGEN_DEVICE_FUNC\n    inline Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType& stride = StrideType())\n      : Base(cast_to_pointer_type(dataPtr), rows, cols), m_stride(stride)\n    {\n      PlainObjectType::Base::_check_template_params();\n    }\n\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)\n\n  protected:\n    StrideType m_stride;\n};\n\n\n} // end namespace Eigen\n\n#endif // EIGEN_MAP_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/MapBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MAPBASE_H\n#define EIGEN_MAPBASE_H\n\n#define EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived) \\\n      EIGEN_STATIC_ASSERT((int(internal::evaluator<Derived>::Flags) & LinearAccessBit) || Derived::IsVectorAtCompileTime, \\\n                          YOU_ARE_TRYING_TO_USE_AN_INDEX_BASED_ACCESSOR_ON_AN_EXPRESSION_THAT_DOES_NOT_SUPPORT_THAT)\n\nnamespace Eigen { \n\n/** \\ingroup Core_Module\n  *\n  * \\brief Base class for dense Map and Block expression with direct access\n  *\n  * This base class provides the const low-level accessors (e.g. coeff, coeffRef) of dense\n  * Map and Block objects with direct access.\n  * Typical users do not have to directly deal with this class.\n  *\n  * This class can be extended by through the macro plugin \\c EIGEN_MAPBASE_PLUGIN.\n  * See \\link TopicCustomizing_Plugins customizing Eigen \\endlink for details.\n  *\n  * The \\c Derived class has to provide the following two methods describing the memory layout:\n  *  \\code Index innerStride() const; \\endcode\n  *  \\code Index outerStride() const; \\endcode\n  *\n  * \\sa class Map, class Block\n  */\ntemplate<typename Derived> class MapBase<Derived, ReadOnlyAccessors>\n  : public internal::dense_xpr_base<Derived>::type\n{\n  public:\n\n    typedef typename internal::dense_xpr_base<Derived>::type Base;\n    enum {\n      RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,\n      ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,\n      SizeAtCompileTime = Base::SizeAtCompileTime\n    };\n\n    typedef typename internal::traits<Derived>::StorageKind StorageKind;\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    typedef typename internal::packet_traits<Scalar>::type PacketScalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    typedef typename internal::conditional<\n                         bool(internal::is_lvalue<Derived>::value),\n                         Scalar *,\n                         const Scalar *>::type\n                     PointerType;\n\n    using Base::derived;\n//    using Base::RowsAtCompileTime;\n//    using Base::ColsAtCompileTime;\n//    using Base::SizeAtCompileTime;\n    using Base::MaxRowsAtCompileTime;\n    using Base::MaxColsAtCompileTime;\n    using Base::MaxSizeAtCompileTime;\n    using Base::IsVectorAtCompileTime;\n    using Base::Flags;\n    using Base::IsRowMajor;\n\n    using Base::rows;\n    using Base::cols;\n    using Base::size;\n    using Base::coeff;\n    using Base::coeffRef;\n    using Base::lazyAssign;\n    using Base::eval;\n\n    using Base::innerStride;\n    using Base::outerStride;\n    using Base::rowStride;\n    using Base::colStride;\n\n    // bug 217 - compile error on ICC 11.1\n    using Base::operator=;\n\n    typedef typename Base::CoeffReturnType CoeffReturnType;\n\n    /** \\copydoc DenseBase::rows() */\n    EIGEN_DEVICE_FUNC inline Index rows() const { return m_rows.value(); }\n    /** \\copydoc DenseBase::cols() */\n    EIGEN_DEVICE_FUNC inline Index cols() const { return m_cols.value(); }\n\n    /** Returns a pointer to the first coefficient of the matrix or vector.\n      *\n      * \\note When addressing this data, make sure to honor the strides returned by innerStride() and outerStride().\n      *\n      * \\sa innerStride(), outerStride()\n      */\n    EIGEN_DEVICE_FUNC inline const Scalar* data() const { return m_data; }\n\n    /** \\copydoc PlainObjectBase::coeff(Index,Index) const */\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeff(Index rowId, Index colId) const\n    {\n      return m_data[colId * colStride() + rowId * rowStride()];\n    }\n\n    /** \\copydoc PlainObjectBase::coeff(Index) const */\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeff(Index index) const\n    {\n      EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)\n      return m_data[index * innerStride()];\n    }\n\n    /** \\copydoc PlainObjectBase::coeffRef(Index,Index) const */\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index rowId, Index colId) const\n    {\n      return this->m_data[colId * colStride() + rowId * rowStride()];\n    }\n\n    /** \\copydoc PlainObjectBase::coeffRef(Index) const */\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index index) const\n    {\n      EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)\n      return this->m_data[index * innerStride()];\n    }\n\n    /** \\internal */\n    template<int LoadMode>\n    inline PacketScalar packet(Index rowId, Index colId) const\n    {\n      return internal::ploadt<PacketScalar, LoadMode>\n               (m_data + (colId * colStride() + rowId * rowStride()));\n    }\n\n    /** \\internal */\n    template<int LoadMode>\n    inline PacketScalar packet(Index index) const\n    {\n      EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)\n      return internal::ploadt<PacketScalar, LoadMode>(m_data + index * innerStride());\n    }\n\n    /** \\internal Constructor for fixed size matrices or vectors */\n    EIGEN_DEVICE_FUNC\n    explicit inline MapBase(PointerType dataPtr) : m_data(dataPtr), m_rows(RowsAtCompileTime), m_cols(ColsAtCompileTime)\n    {\n      EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)\n      checkSanity<Derived>();\n    }\n\n    /** \\internal Constructor for dynamically sized vectors */\n    EIGEN_DEVICE_FUNC\n    inline MapBase(PointerType dataPtr, Index vecSize)\n            : m_data(dataPtr),\n              m_rows(RowsAtCompileTime == Dynamic ? vecSize : Index(RowsAtCompileTime)),\n              m_cols(ColsAtCompileTime == Dynamic ? vecSize : Index(ColsAtCompileTime))\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n      eigen_assert(vecSize >= 0);\n      eigen_assert(dataPtr == 0 || SizeAtCompileTime == Dynamic || SizeAtCompileTime == vecSize);\n      checkSanity<Derived>();\n    }\n\n    /** \\internal Constructor for dynamically sized matrices */\n    EIGEN_DEVICE_FUNC\n    inline MapBase(PointerType dataPtr, Index rows, Index cols)\n            : m_data(dataPtr), m_rows(rows), m_cols(cols)\n    {\n      eigen_assert( (dataPtr == 0)\n              || (   rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)\n                  && cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)));\n      checkSanity<Derived>();\n    }\n\n    #ifdef EIGEN_MAPBASE_PLUGIN\n    #include EIGEN_MAPBASE_PLUGIN\n    #endif\n\n  protected:\n\n    template<typename T>\n    EIGEN_DEVICE_FUNC\n    void checkSanity(typename internal::enable_if<(internal::traits<T>::Alignment>0),void*>::type = 0) const\n    {\n#if EIGEN_MAX_ALIGN_BYTES>0\n      eigen_assert((   ((internal::UIntPtr(m_data) % internal::traits<Derived>::Alignment) == 0)\n                    || (cols() * rows() * innerStride() * sizeof(Scalar)) < internal::traits<Derived>::Alignment ) && \"data is not aligned\");\n#endif\n    }\n\n    template<typename T>\n    EIGEN_DEVICE_FUNC\n    void checkSanity(typename internal::enable_if<internal::traits<T>::Alignment==0,void*>::type = 0) const\n    {}\n\n    PointerType m_data;\n    const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_rows;\n    const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_cols;\n};\n\n/** \\ingroup Core_Module\n  *\n  * \\brief Base class for non-const dense Map and Block expression with direct access\n  *\n  * This base class provides the non-const low-level accessors (e.g. coeff and coeffRef) of\n  * dense Map and Block objects with direct access.\n  * It inherits MapBase<Derived, ReadOnlyAccessors> which defines the const variant for reading specific entries.\n  *\n  * \\sa class Map, class Block\n  */\ntemplate<typename Derived> class MapBase<Derived, WriteAccessors>\n  : public MapBase<Derived, ReadOnlyAccessors>\n{\n    typedef MapBase<Derived, ReadOnlyAccessors> ReadOnlyMapBase;\n  public:\n\n    typedef MapBase<Derived, ReadOnlyAccessors> Base;\n\n    typedef typename Base::Scalar Scalar;\n    typedef typename Base::PacketScalar PacketScalar;\n    typedef typename Base::StorageIndex StorageIndex;\n    typedef typename Base::PointerType PointerType;\n\n    using Base::derived;\n    using Base::rows;\n    using Base::cols;\n    using Base::size;\n    using Base::coeff;\n    using Base::coeffRef;\n\n    using Base::innerStride;\n    using Base::outerStride;\n    using Base::rowStride;\n    using Base::colStride;\n\n    typedef typename internal::conditional<\n                    internal::is_lvalue<Derived>::value,\n                    Scalar,\n                    const Scalar\n                  >::type ScalarWithConstIfNotLvalue;\n\n    EIGEN_DEVICE_FUNC\n    inline const Scalar* data() const { return this->m_data; }\n    EIGEN_DEVICE_FUNC\n    inline ScalarWithConstIfNotLvalue* data() { return this->m_data; } // no const-cast here so non-const-correct code will give a compile error\n\n    EIGEN_DEVICE_FUNC\n    inline ScalarWithConstIfNotLvalue& coeffRef(Index row, Index col)\n    {\n      return this->m_data[col * colStride() + row * rowStride()];\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline ScalarWithConstIfNotLvalue& coeffRef(Index index)\n    {\n      EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)\n      return this->m_data[index * innerStride()];\n    }\n\n    template<int StoreMode>\n    inline void writePacket(Index row, Index col, const PacketScalar& val)\n    {\n      internal::pstoret<Scalar, PacketScalar, StoreMode>\n               (this->m_data + (col * colStride() + row * rowStride()), val);\n    }\n\n    template<int StoreMode>\n    inline void writePacket(Index index, const PacketScalar& val)\n    {\n      EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)\n      internal::pstoret<Scalar, PacketScalar, StoreMode>\n                (this->m_data + index * innerStride(), val);\n    }\n\n    EIGEN_DEVICE_FUNC explicit inline MapBase(PointerType dataPtr) : Base(dataPtr) {}\n    EIGEN_DEVICE_FUNC inline MapBase(PointerType dataPtr, Index vecSize) : Base(dataPtr, vecSize) {}\n    EIGEN_DEVICE_FUNC inline MapBase(PointerType dataPtr, Index rows, Index cols) : Base(dataPtr, rows, cols) {}\n\n    EIGEN_DEVICE_FUNC\n    Derived& operator=(const MapBase& other)\n    {\n      ReadOnlyMapBase::Base::operator=(other);\n      return derived();\n    }\n\n    // In theory we could simply refer to Base:Base::operator=, but MSVC does not like Base::Base,\n    // see bugs 821 and 920.\n    using ReadOnlyMapBase::Base::operator=;\n};\n\n#undef EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS\n\n} // end namespace Eigen\n\n#endif // EIGEN_MAPBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/MathFunctions.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MATHFUNCTIONS_H\n#define EIGEN_MATHFUNCTIONS_H\n\n// source: http://www.geom.uiuc.edu/~huberty/math5337/groupe/digits.html\n// TODO this should better be moved to NumTraits\n#define EIGEN_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406L\n\n\nnamespace Eigen {\n\n// On WINCE, std::abs is defined for int only, so let's defined our own overloads:\n// This issue has been confirmed with MSVC 2008 only, but the issue might exist for more recent versions too.\n#if EIGEN_OS_WINCE && EIGEN_COMP_MSVC && EIGEN_COMP_MSVC<=1500\nlong        abs(long        x) { return (labs(x));  }\ndouble      abs(double      x) { return (fabs(x));  }\nfloat       abs(float       x) { return (fabsf(x)); }\nlong double abs(long double x) { return (fabsl(x)); }\n#endif\n\nnamespace internal {\n\n/** \\internal \\class global_math_functions_filtering_base\n  *\n  * What it does:\n  * Defines a typedef 'type' as follows:\n  * - if type T has a member typedef Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl, then\n  *   global_math_functions_filtering_base<T>::type is a typedef for it.\n  * - otherwise, global_math_functions_filtering_base<T>::type is a typedef for T.\n  *\n  * How it's used:\n  * To allow to defined the global math functions (like sin...) in certain cases, like the Array expressions.\n  * When you do sin(array1+array2), the object array1+array2 has a complicated expression type, all what you want to know\n  * is that it inherits ArrayBase. So we implement a partial specialization of sin_impl for ArrayBase<Derived>.\n  * So we must make sure to use sin_impl<ArrayBase<Derived> > and not sin_impl<Derived>, otherwise our partial specialization\n  * won't be used. How does sin know that? That's exactly what global_math_functions_filtering_base tells it.\n  *\n  * How it's implemented:\n  * SFINAE in the style of enable_if. Highly susceptible of breaking compilers. With GCC, it sure does work, but if you replace\n  * the typename dummy by an integer template parameter, it doesn't work anymore!\n  */\n\ntemplate<typename T, typename dummy = void>\nstruct global_math_functions_filtering_base\n{\n  typedef T type;\n};\n\ntemplate<typename T> struct always_void { typedef void type; };\n\ntemplate<typename T>\nstruct global_math_functions_filtering_base\n  <T,\n   typename always_void<typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl>::type\n  >\n{\n  typedef typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl type;\n};\n\n#define EIGEN_MATHFUNC_IMPL(func, scalar) Eigen::internal::func##_impl<typename Eigen::internal::global_math_functions_filtering_base<scalar>::type>\n#define EIGEN_MATHFUNC_RETVAL(func, scalar) typename Eigen::internal::func##_retval<typename Eigen::internal::global_math_functions_filtering_base<scalar>::type>::type\n\n/****************************************************************************\n* Implementation of real                                                 *\n****************************************************************************/\n\ntemplate<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>\nstruct real_default_impl\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar run(const Scalar& x)\n  {\n    return x;\n  }\n};\n\ntemplate<typename Scalar>\nstruct real_default_impl<Scalar,true>\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar run(const Scalar& x)\n  {\n    using std::real;\n    return real(x);\n  }\n};\n\ntemplate<typename Scalar> struct real_impl : real_default_impl<Scalar> {};\n\n#ifdef __CUDA_ARCH__\ntemplate<typename T>\nstruct real_impl<std::complex<T> >\n{\n  typedef T RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline T run(const std::complex<T>& x)\n  {\n    return x.real();\n  }\n};\n#endif\n\ntemplate<typename Scalar>\nstruct real_retval\n{\n  typedef typename NumTraits<Scalar>::Real type;\n};\n\n/****************************************************************************\n* Implementation of imag                                                 *\n****************************************************************************/\n\ntemplate<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>\nstruct imag_default_impl\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar run(const Scalar&)\n  {\n    return RealScalar(0);\n  }\n};\n\ntemplate<typename Scalar>\nstruct imag_default_impl<Scalar,true>\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar run(const Scalar& x)\n  {\n    using std::imag;\n    return imag(x);\n  }\n};\n\ntemplate<typename Scalar> struct imag_impl : imag_default_impl<Scalar> {};\n\n#ifdef __CUDA_ARCH__\ntemplate<typename T>\nstruct imag_impl<std::complex<T> >\n{\n  typedef T RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline T run(const std::complex<T>& x)\n  {\n    return x.imag();\n  }\n};\n#endif\n\ntemplate<typename Scalar>\nstruct imag_retval\n{\n  typedef typename NumTraits<Scalar>::Real type;\n};\n\n/****************************************************************************\n* Implementation of real_ref                                             *\n****************************************************************************/\n\ntemplate<typename Scalar>\nstruct real_ref_impl\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar& run(Scalar& x)\n  {\n    return reinterpret_cast<RealScalar*>(&x)[0];\n  }\n  EIGEN_DEVICE_FUNC\n  static inline const RealScalar& run(const Scalar& x)\n  {\n    return reinterpret_cast<const RealScalar*>(&x)[0];\n  }\n};\n\ntemplate<typename Scalar>\nstruct real_ref_retval\n{\n  typedef typename NumTraits<Scalar>::Real & type;\n};\n\n/****************************************************************************\n* Implementation of imag_ref                                             *\n****************************************************************************/\n\ntemplate<typename Scalar, bool IsComplex>\nstruct imag_ref_default_impl\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar& run(Scalar& x)\n  {\n    return reinterpret_cast<RealScalar*>(&x)[1];\n  }\n  EIGEN_DEVICE_FUNC\n  static inline const RealScalar& run(const Scalar& x)\n  {\n    return reinterpret_cast<RealScalar*>(&x)[1];\n  }\n};\n\ntemplate<typename Scalar>\nstruct imag_ref_default_impl<Scalar, false>\n{\n  EIGEN_DEVICE_FUNC\n  static inline Scalar run(Scalar&)\n  {\n    return Scalar(0);\n  }\n  EIGEN_DEVICE_FUNC\n  static inline const Scalar run(const Scalar&)\n  {\n    return Scalar(0);\n  }\n};\n\ntemplate<typename Scalar>\nstruct imag_ref_impl : imag_ref_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {};\n\ntemplate<typename Scalar>\nstruct imag_ref_retval\n{\n  typedef typename NumTraits<Scalar>::Real & type;\n};\n\n/****************************************************************************\n* Implementation of conj                                                 *\n****************************************************************************/\n\ntemplate<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>\nstruct conj_impl\n{\n  EIGEN_DEVICE_FUNC\n  static inline Scalar run(const Scalar& x)\n  {\n    return x;\n  }\n};\n\ntemplate<typename Scalar>\nstruct conj_impl<Scalar,true>\n{\n  EIGEN_DEVICE_FUNC\n  static inline Scalar run(const Scalar& x)\n  {\n    using std::conj;\n    return conj(x);\n  }\n};\n\ntemplate<typename Scalar>\nstruct conj_retval\n{\n  typedef Scalar type;\n};\n\n/****************************************************************************\n* Implementation of abs2                                                 *\n****************************************************************************/\n\ntemplate<typename Scalar,bool IsComplex>\nstruct abs2_impl_default\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar run(const Scalar& x)\n  {\n    return x*x;\n  }\n};\n\ntemplate<typename Scalar>\nstruct abs2_impl_default<Scalar, true> // IsComplex\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar run(const Scalar& x)\n  {\n    return real(x)*real(x) + imag(x)*imag(x);\n  }\n};\n\ntemplate<typename Scalar>\nstruct abs2_impl\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar run(const Scalar& x)\n  {\n    return abs2_impl_default<Scalar,NumTraits<Scalar>::IsComplex>::run(x);\n  }\n};\n\ntemplate<typename Scalar>\nstruct abs2_retval\n{\n  typedef typename NumTraits<Scalar>::Real type;\n};\n\n/****************************************************************************\n* Implementation of norm1                                                *\n****************************************************************************/\n\ntemplate<typename Scalar, bool IsComplex>\nstruct norm1_default_impl\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar run(const Scalar& x)\n  {\n    EIGEN_USING_STD_MATH(abs);\n    return abs(real(x)) + abs(imag(x));\n  }\n};\n\ntemplate<typename Scalar>\nstruct norm1_default_impl<Scalar, false>\n{\n  EIGEN_DEVICE_FUNC\n  static inline Scalar run(const Scalar& x)\n  {\n    EIGEN_USING_STD_MATH(abs);\n    return abs(x);\n  }\n};\n\ntemplate<typename Scalar>\nstruct norm1_impl : norm1_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {};\n\ntemplate<typename Scalar>\nstruct norm1_retval\n{\n  typedef typename NumTraits<Scalar>::Real type;\n};\n\n/****************************************************************************\n* Implementation of hypot                                                *\n****************************************************************************/\n\ntemplate<typename Scalar>\nstruct hypot_impl\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  static inline RealScalar run(const Scalar& x, const Scalar& y)\n  {\n    EIGEN_USING_STD_MATH(abs);\n    EIGEN_USING_STD_MATH(sqrt);\n    RealScalar _x = abs(x);\n    RealScalar _y = abs(y);\n    Scalar p, qp;\n    if(_x>_y)\n    {\n      p = _x;\n      qp = _y / p;\n    }\n    else\n    {\n      p = _y;\n      qp = _x / p;\n    }\n    if(p==RealScalar(0)) return RealScalar(0);\n    return p * sqrt(RealScalar(1) + qp*qp);\n  }\n};\n\ntemplate<typename Scalar>\nstruct hypot_retval\n{\n  typedef typename NumTraits<Scalar>::Real type;\n};\n\n/****************************************************************************\n* Implementation of cast                                                 *\n****************************************************************************/\n\ntemplate<typename OldType, typename NewType>\nstruct cast_impl\n{\n  EIGEN_DEVICE_FUNC\n  static inline NewType run(const OldType& x)\n  {\n    return static_cast<NewType>(x);\n  }\n};\n\n// here, for once, we're plainly returning NewType: we don't want cast to do weird things.\n\ntemplate<typename OldType, typename NewType>\nEIGEN_DEVICE_FUNC\ninline NewType cast(const OldType& x)\n{\n  return cast_impl<OldType, NewType>::run(x);\n}\n\n/****************************************************************************\n* Implementation of round                                                   *\n****************************************************************************/\n\n#if EIGEN_HAS_CXX11_MATH\n  template<typename Scalar>\n  struct round_impl {\n    static inline Scalar run(const Scalar& x)\n    {\n      EIGEN_STATIC_ASSERT((!NumTraits<Scalar>::IsComplex), NUMERIC_TYPE_MUST_BE_REAL)\n      using std::round;\n      return round(x);\n    }\n  };\n#else\n  template<typename Scalar>\n  struct round_impl\n  {\n    static inline Scalar run(const Scalar& x)\n    {\n      EIGEN_STATIC_ASSERT((!NumTraits<Scalar>::IsComplex), NUMERIC_TYPE_MUST_BE_REAL)\n      EIGEN_USING_STD_MATH(floor);\n      EIGEN_USING_STD_MATH(ceil);\n      return (x > Scalar(0)) ? floor(x + Scalar(0.5)) : ceil(x - Scalar(0.5));\n    }\n  };\n#endif\n\ntemplate<typename Scalar>\nstruct round_retval\n{\n  typedef Scalar type;\n};\n\n/****************************************************************************\n* Implementation of arg                                                     *\n****************************************************************************/\n\n#if EIGEN_HAS_CXX11_MATH\n  template<typename Scalar>\n  struct arg_impl {\n    static inline Scalar run(const Scalar& x)\n    {\n      EIGEN_USING_STD_MATH(arg);\n      return arg(x);\n    }\n  };\n#else\n  template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>\n  struct arg_default_impl\n  {\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    EIGEN_DEVICE_FUNC\n    static inline RealScalar run(const Scalar& x)\n    {\n      return (x < Scalar(0)) ? Scalar(EIGEN_PI) : Scalar(0); }\n  };\n\n  template<typename Scalar>\n  struct arg_default_impl<Scalar,true>\n  {\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    EIGEN_DEVICE_FUNC\n    static inline RealScalar run(const Scalar& x)\n    {\n      EIGEN_USING_STD_MATH(arg);\n      return arg(x);\n    }\n  };\n\n  template<typename Scalar> struct arg_impl : arg_default_impl<Scalar> {};\n#endif\n\ntemplate<typename Scalar>\nstruct arg_retval\n{\n  typedef typename NumTraits<Scalar>::Real type;\n};\n\n/****************************************************************************\n* Implementation of log1p                                                   *\n****************************************************************************/\n\nnamespace std_fallback {\n  // fallback log1p implementation in case there is no log1p(Scalar) function in namespace of Scalar,\n  // or that there is no suitable std::log1p function available\n  template<typename Scalar>\n  EIGEN_DEVICE_FUNC inline Scalar log1p(const Scalar& x) {\n    EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    EIGEN_USING_STD_MATH(log);\n    Scalar x1p = RealScalar(1) + x;\n    return ( x1p == Scalar(1) ) ? x : x * ( log(x1p) / (x1p - RealScalar(1)) );\n  }\n}\n\ntemplate<typename Scalar>\nstruct log1p_impl {\n  static inline Scalar run(const Scalar& x)\n  {\n    EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)\n    #if EIGEN_HAS_CXX11_MATH\n    using std::log1p;\n    #endif\n    using std_fallback::log1p;\n    return log1p(x);\n  }\n};\n\n\ntemplate<typename Scalar>\nstruct log1p_retval\n{\n  typedef Scalar type;\n};\n\n/****************************************************************************\n* Implementation of pow                                                  *\n****************************************************************************/\n\ntemplate<typename ScalarX,typename ScalarY, bool IsInteger = NumTraits<ScalarX>::IsInteger&&NumTraits<ScalarY>::IsInteger>\nstruct pow_impl\n{\n  //typedef Scalar retval;\n  typedef typename ScalarBinaryOpTraits<ScalarX,ScalarY,internal::scalar_pow_op<ScalarX,ScalarY> >::ReturnType result_type;\n  static EIGEN_DEVICE_FUNC inline result_type run(const ScalarX& x, const ScalarY& y)\n  {\n    EIGEN_USING_STD_MATH(pow);\n    return pow(x, y);\n  }\n};\n\ntemplate<typename ScalarX,typename ScalarY>\nstruct pow_impl<ScalarX,ScalarY, true>\n{\n  typedef ScalarX result_type;\n  static EIGEN_DEVICE_FUNC inline ScalarX run(ScalarX x, ScalarY y)\n  {\n    ScalarX res(1);\n    eigen_assert(!NumTraits<ScalarY>::IsSigned || y >= 0);\n    if(y & 1) res *= x;\n    y >>= 1;\n    while(y)\n    {\n      x *= x;\n      if(y&1) res *= x;\n      y >>= 1;\n    }\n    return res;\n  }\n};\n\n/****************************************************************************\n* Implementation of random                                               *\n****************************************************************************/\n\ntemplate<typename Scalar,\n         bool IsComplex,\n         bool IsInteger>\nstruct random_default_impl {};\n\ntemplate<typename Scalar>\nstruct random_impl : random_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {};\n\ntemplate<typename Scalar>\nstruct random_retval\n{\n  typedef Scalar type;\n};\n\ntemplate<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y);\ntemplate<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random();\n\ntemplate<typename Scalar>\nstruct random_default_impl<Scalar, false, false>\n{\n  static inline Scalar run(const Scalar& x, const Scalar& y)\n  {\n    return x + (y-x) * Scalar(std::rand()) / Scalar(RAND_MAX);\n  }\n  static inline Scalar run()\n  {\n    return run(Scalar(NumTraits<Scalar>::IsSigned ? -1 : 0), Scalar(1));\n  }\n};\n\nenum {\n  meta_floor_log2_terminate,\n  meta_floor_log2_move_up,\n  meta_floor_log2_move_down,\n  meta_floor_log2_bogus\n};\n\ntemplate<unsigned int n, int lower, int upper> struct meta_floor_log2_selector\n{\n  enum { middle = (lower + upper) / 2,\n         value = (upper <= lower + 1) ? int(meta_floor_log2_terminate)\n               : (n < (1 << middle)) ? int(meta_floor_log2_move_down)\n               : (n==0) ? int(meta_floor_log2_bogus)\n               : int(meta_floor_log2_move_up)\n  };\n};\n\ntemplate<unsigned int n,\n         int lower = 0,\n         int upper = sizeof(unsigned int) * CHAR_BIT - 1,\n         int selector = meta_floor_log2_selector<n, lower, upper>::value>\nstruct meta_floor_log2 {};\n\ntemplate<unsigned int n, int lower, int upper>\nstruct meta_floor_log2<n, lower, upper, meta_floor_log2_move_down>\n{\n  enum { value = meta_floor_log2<n, lower, meta_floor_log2_selector<n, lower, upper>::middle>::value };\n};\n\ntemplate<unsigned int n, int lower, int upper>\nstruct meta_floor_log2<n, lower, upper, meta_floor_log2_move_up>\n{\n  enum { value = meta_floor_log2<n, meta_floor_log2_selector<n, lower, upper>::middle, upper>::value };\n};\n\ntemplate<unsigned int n, int lower, int upper>\nstruct meta_floor_log2<n, lower, upper, meta_floor_log2_terminate>\n{\n  enum { value = (n >= ((unsigned int)(1) << (lower+1))) ? lower+1 : lower };\n};\n\ntemplate<unsigned int n, int lower, int upper>\nstruct meta_floor_log2<n, lower, upper, meta_floor_log2_bogus>\n{\n  // no value, error at compile time\n};\n\ntemplate<typename Scalar>\nstruct random_default_impl<Scalar, false, true>\n{\n  static inline Scalar run(const Scalar& x, const Scalar& y)\n  { \n    typedef typename conditional<NumTraits<Scalar>::IsSigned,std::ptrdiff_t,std::size_t>::type ScalarX;\n    if(y<x)\n      return x;\n    // the following difference might overflow on a 32 bits system,\n    // but since y>=x the result converted to an unsigned long is still correct.\n    std::size_t range = ScalarX(y)-ScalarX(x);\n    std::size_t offset = 0;\n    // rejection sampling\n    std::size_t divisor = 1;\n    std::size_t multiplier = 1;\n    if(range<RAND_MAX) divisor = (std::size_t(RAND_MAX)+1)/(range+1);\n    else               multiplier = 1 + range/(std::size_t(RAND_MAX)+1);\n    do {\n      offset = (std::size_t(std::rand()) * multiplier) / divisor;\n    } while (offset > range);\n    return Scalar(ScalarX(x) + offset);\n  }\n\n  static inline Scalar run()\n  {\n#ifdef EIGEN_MAKING_DOCS\n    return run(Scalar(NumTraits<Scalar>::IsSigned ? -10 : 0), Scalar(10));\n#else\n    enum { rand_bits = meta_floor_log2<(unsigned int)(RAND_MAX)+1>::value,\n           scalar_bits = sizeof(Scalar) * CHAR_BIT,\n           shift = EIGEN_PLAIN_ENUM_MAX(0, int(rand_bits) - int(scalar_bits)),\n           offset = NumTraits<Scalar>::IsSigned ? (1 << (EIGEN_PLAIN_ENUM_MIN(rand_bits,scalar_bits)-1)) : 0\n    };\n    return Scalar((std::rand() >> shift) - offset);\n#endif\n  }\n};\n\ntemplate<typename Scalar>\nstruct random_default_impl<Scalar, true, false>\n{\n  static inline Scalar run(const Scalar& x, const Scalar& y)\n  {\n    return Scalar(random(real(x), real(y)),\n                  random(imag(x), imag(y)));\n  }\n  static inline Scalar run()\n  {\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    return Scalar(random<RealScalar>(), random<RealScalar>());\n  }\n};\n\ntemplate<typename Scalar>\ninline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y)\n{\n  return EIGEN_MATHFUNC_IMPL(random, Scalar)::run(x, y);\n}\n\ntemplate<typename Scalar>\ninline EIGEN_MATHFUNC_RETVAL(random, Scalar) random()\n{\n  return EIGEN_MATHFUNC_IMPL(random, Scalar)::run();\n}\n\n// Implementatin of is* functions\n\n// std::is* do not work with fast-math and gcc, std::is* are available on MSVC 2013 and newer, as well as in clang.\n#if (EIGEN_HAS_CXX11_MATH && !(EIGEN_COMP_GNUC_STRICT && __FINITE_MATH_ONLY__)) || (EIGEN_COMP_MSVC>=1800) || (EIGEN_COMP_CLANG)\n#define EIGEN_USE_STD_FPCLASSIFY 1\n#else\n#define EIGEN_USE_STD_FPCLASSIFY 0\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\ntypename internal::enable_if<internal::is_integral<T>::value,bool>::type\nisnan_impl(const T&) { return false; }\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\ntypename internal::enable_if<internal::is_integral<T>::value,bool>::type\nisinf_impl(const T&) { return false; }\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\ntypename internal::enable_if<internal::is_integral<T>::value,bool>::type\nisfinite_impl(const T&) { return true; }\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\ntypename internal::enable_if<(!internal::is_integral<T>::value)&&(!NumTraits<T>::IsComplex),bool>::type\nisfinite_impl(const T& x)\n{\n  #ifdef __CUDA_ARCH__\n    return (::isfinite)(x);\n  #elif EIGEN_USE_STD_FPCLASSIFY\n    using std::isfinite;\n    return isfinite EIGEN_NOT_A_MACRO (x);\n  #else\n    return x<=NumTraits<T>::highest() && x>=NumTraits<T>::lowest();\n  #endif\n}\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\ntypename internal::enable_if<(!internal::is_integral<T>::value)&&(!NumTraits<T>::IsComplex),bool>::type\nisinf_impl(const T& x)\n{\n  #ifdef __CUDA_ARCH__\n    return (::isinf)(x);\n  #elif EIGEN_USE_STD_FPCLASSIFY\n    using std::isinf;\n    return isinf EIGEN_NOT_A_MACRO (x);\n  #else\n    return x>NumTraits<T>::highest() || x<NumTraits<T>::lowest();\n  #endif\n}\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\ntypename internal::enable_if<(!internal::is_integral<T>::value)&&(!NumTraits<T>::IsComplex),bool>::type\nisnan_impl(const T& x)\n{\n  #ifdef __CUDA_ARCH__\n    return (::isnan)(x);\n  #elif EIGEN_USE_STD_FPCLASSIFY\n    using std::isnan;\n    return isnan EIGEN_NOT_A_MACRO (x);\n  #else\n    return x != x;\n  #endif\n}\n\n#if (!EIGEN_USE_STD_FPCLASSIFY)\n\n#if EIGEN_COMP_MSVC\n\ntemplate<typename T> EIGEN_DEVICE_FUNC bool isinf_msvc_helper(T x)\n{\n  return _fpclass(x)==_FPCLASS_NINF || _fpclass(x)==_FPCLASS_PINF;\n}\n\n//MSVC defines a _isnan builtin function, but for double only\nEIGEN_DEVICE_FUNC inline bool isnan_impl(const long double& x) { return _isnan(x)!=0; }\nEIGEN_DEVICE_FUNC inline bool isnan_impl(const double& x)      { return _isnan(x)!=0; }\nEIGEN_DEVICE_FUNC inline bool isnan_impl(const float& x)       { return _isnan(x)!=0; }\n\nEIGEN_DEVICE_FUNC inline bool isinf_impl(const long double& x) { return isinf_msvc_helper(x); }\nEIGEN_DEVICE_FUNC inline bool isinf_impl(const double& x)      { return isinf_msvc_helper(x); }\nEIGEN_DEVICE_FUNC inline bool isinf_impl(const float& x)       { return isinf_msvc_helper(x); }\n\n#elif (defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ && EIGEN_COMP_GNUC)\n\n#if EIGEN_GNUC_AT_LEAST(5,0)\n  #define EIGEN_TMP_NOOPT_ATTRIB EIGEN_DEVICE_FUNC inline __attribute__((optimize(\"no-finite-math-only\")))\n#else\n  // NOTE the inline qualifier and noinline attribute are both needed: the former is to avoid linking issue (duplicate symbol),\n  //      while the second prevent too aggressive optimizations in fast-math mode:\n  #define EIGEN_TMP_NOOPT_ATTRIB EIGEN_DEVICE_FUNC inline __attribute__((noinline,optimize(\"no-finite-math-only\")))\n#endif\n\ntemplate<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const long double& x) { return __builtin_isnan(x); }\ntemplate<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const double& x)      { return __builtin_isnan(x); }\ntemplate<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const float& x)       { return __builtin_isnan(x); }\ntemplate<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const double& x)      { return __builtin_isinf(x); }\ntemplate<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const float& x)       { return __builtin_isinf(x); }\ntemplate<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const long double& x) { return __builtin_isinf(x); }\n\n#undef EIGEN_TMP_NOOPT_ATTRIB\n\n#endif\n\n#endif\n\n// The following overload are defined at the end of this file\ntemplate<typename T> EIGEN_DEVICE_FUNC bool isfinite_impl(const std::complex<T>& x);\ntemplate<typename T> EIGEN_DEVICE_FUNC bool isnan_impl(const std::complex<T>& x);\ntemplate<typename T> EIGEN_DEVICE_FUNC bool isinf_impl(const std::complex<T>& x);\n\ntemplate<typename T> T generic_fast_tanh_float(const T& a_x);\n\n} // end namespace internal\n\n/****************************************************************************\n* Generic math functions                                                    *\n****************************************************************************/\n\nnamespace numext {\n\n#ifndef __CUDA_ARCH__\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\nEIGEN_ALWAYS_INLINE T mini(const T& x, const T& y)\n{\n  EIGEN_USING_STD_MATH(min);\n  return min EIGEN_NOT_A_MACRO (x,y);\n}\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\nEIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y)\n{\n  EIGEN_USING_STD_MATH(max);\n  return max EIGEN_NOT_A_MACRO (x,y);\n}\n#else\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\nEIGEN_ALWAYS_INLINE T mini(const T& x, const T& y)\n{\n  return y < x ? y : x;\n}\ntemplate<>\nEIGEN_DEVICE_FUNC\nEIGEN_ALWAYS_INLINE float mini(const float& x, const float& y)\n{\n  return fminf(x, y);\n}\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\nEIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y)\n{\n  return x < y ? y : x;\n}\ntemplate<>\nEIGEN_DEVICE_FUNC\nEIGEN_ALWAYS_INLINE float maxi(const float& x, const float& y)\n{\n  return fmaxf(x, y);\n}\n#endif\n\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline EIGEN_MATHFUNC_RETVAL(real, Scalar) real(const Scalar& x)\n{\n  return EIGEN_MATHFUNC_IMPL(real, Scalar)::run(x);\n}\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline typename internal::add_const_on_value_type< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) >::type real_ref(const Scalar& x)\n{\n  return internal::real_ref_impl<Scalar>::run(x);\n}\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) real_ref(Scalar& x)\n{\n  return EIGEN_MATHFUNC_IMPL(real_ref, Scalar)::run(x);\n}\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline EIGEN_MATHFUNC_RETVAL(imag, Scalar) imag(const Scalar& x)\n{\n  return EIGEN_MATHFUNC_IMPL(imag, Scalar)::run(x);\n}\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline EIGEN_MATHFUNC_RETVAL(arg, Scalar) arg(const Scalar& x)\n{\n  return EIGEN_MATHFUNC_IMPL(arg, Scalar)::run(x);\n}\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline typename internal::add_const_on_value_type< EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) >::type imag_ref(const Scalar& x)\n{\n  return internal::imag_ref_impl<Scalar>::run(x);\n}\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) imag_ref(Scalar& x)\n{\n  return EIGEN_MATHFUNC_IMPL(imag_ref, Scalar)::run(x);\n}\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x)\n{\n  return EIGEN_MATHFUNC_IMPL(conj, Scalar)::run(x);\n}\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x)\n{\n  return EIGEN_MATHFUNC_IMPL(abs2, Scalar)::run(x);\n}\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x)\n{\n  return EIGEN_MATHFUNC_IMPL(norm1, Scalar)::run(x);\n}\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline EIGEN_MATHFUNC_RETVAL(hypot, Scalar) hypot(const Scalar& x, const Scalar& y)\n{\n  return EIGEN_MATHFUNC_IMPL(hypot, Scalar)::run(x, y);\n}\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline EIGEN_MATHFUNC_RETVAL(log1p, Scalar) log1p(const Scalar& x)\n{\n  return EIGEN_MATHFUNC_IMPL(log1p, Scalar)::run(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat log1p(const float &x) { return ::log1pf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble log1p(const double &x) { return ::log1p(x); }\n#endif\n\ntemplate<typename ScalarX,typename ScalarY>\nEIGEN_DEVICE_FUNC\ninline typename internal::pow_impl<ScalarX,ScalarY>::result_type pow(const ScalarX& x, const ScalarY& y)\n{\n  return internal::pow_impl<ScalarX,ScalarY>::run(x, y);\n}\n\ntemplate<typename T> EIGEN_DEVICE_FUNC bool (isnan)   (const T &x) { return internal::isnan_impl(x); }\ntemplate<typename T> EIGEN_DEVICE_FUNC bool (isinf)   (const T &x) { return internal::isinf_impl(x); }\ntemplate<typename T> EIGEN_DEVICE_FUNC bool (isfinite)(const T &x) { return internal::isfinite_impl(x); }\n\ntemplate<typename Scalar>\nEIGEN_DEVICE_FUNC\ninline EIGEN_MATHFUNC_RETVAL(round, Scalar) round(const Scalar& x)\n{\n  return EIGEN_MATHFUNC_IMPL(round, Scalar)::run(x);\n}\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\nT (floor)(const T& x)\n{\n  EIGEN_USING_STD_MATH(floor);\n  return floor(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat floor(const float &x) { return ::floorf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble floor(const double &x) { return ::floor(x); }\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\nT (ceil)(const T& x)\n{\n  EIGEN_USING_STD_MATH(ceil);\n  return ceil(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat ceil(const float &x) { return ::ceilf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble ceil(const double &x) { return ::ceil(x); }\n#endif\n\n\n/** Log base 2 for 32 bits positive integers.\n  * Conveniently returns 0 for x==0. */\ninline int log2(int x)\n{\n  eigen_assert(x>=0);\n  unsigned int v(x);\n  static const int table[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };\n  v |= v >> 1;\n  v |= v >> 2;\n  v |= v >> 4;\n  v |= v >> 8;\n  v |= v >> 16;\n  return table[(v * 0x07C4ACDDU) >> 27];\n}\n\n/** \\returns the square root of \\a x.\n  *\n  * It is essentially equivalent to \\code using std::sqrt; return sqrt(x); \\endcode,\n  * but slightly faster for float/double and some compilers (e.g., gcc), thanks to\n  * specializations when SSE is enabled.\n  *\n  * It's usage is justified in performance critical functions, like norm/normalize.\n  */\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT sqrt(const T &x)\n{\n  EIGEN_USING_STD_MATH(sqrt);\n  return sqrt(x);\n}\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT log(const T &x) {\n  EIGEN_USING_STD_MATH(log);\n  return log(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat log(const float &x) { return ::logf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble log(const double &x) { return ::log(x); }\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ntypename internal::enable_if<NumTraits<T>::IsSigned || NumTraits<T>::IsComplex,typename NumTraits<T>::Real>::type\nabs(const T &x) {\n  EIGEN_USING_STD_MATH(abs);\n  return abs(x);\n}\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ntypename internal::enable_if<!(NumTraits<T>::IsSigned || NumTraits<T>::IsComplex),typename NumTraits<T>::Real>::type\nabs(const T &x) {\n  return x;\n}\n\n#if defined(__SYCL_DEVICE_ONLY__)\nEIGEN_ALWAYS_INLINE float   abs(float x) { return cl::sycl::fabs(x); }\nEIGEN_ALWAYS_INLINE double  abs(double x) { return cl::sycl::fabs(x); }\n#endif // defined(__SYCL_DEVICE_ONLY__)\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat abs(const float &x) { return ::fabsf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble abs(const double &x) { return ::fabs(x); }\n\ntemplate <> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat abs(const std::complex<float>& x) {\n  return ::hypotf(x.real(), x.imag());\n}\n\ntemplate <> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble abs(const std::complex<double>& x) {\n  return ::hypot(x.real(), x.imag());\n}\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT exp(const T &x) {\n  EIGEN_USING_STD_MATH(exp);\n  return exp(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat exp(const float &x) { return ::expf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble exp(const double &x) { return ::exp(x); }\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT cos(const T &x) {\n  EIGEN_USING_STD_MATH(cos);\n  return cos(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat cos(const float &x) { return ::cosf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble cos(const double &x) { return ::cos(x); }\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT sin(const T &x) {\n  EIGEN_USING_STD_MATH(sin);\n  return sin(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat sin(const float &x) { return ::sinf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble sin(const double &x) { return ::sin(x); }\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT tan(const T &x) {\n  EIGEN_USING_STD_MATH(tan);\n  return tan(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat tan(const float &x) { return ::tanf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble tan(const double &x) { return ::tan(x); }\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT acos(const T &x) {\n  EIGEN_USING_STD_MATH(acos);\n  return acos(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat acos(const float &x) { return ::acosf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble acos(const double &x) { return ::acos(x); }\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT asin(const T &x) {\n  EIGEN_USING_STD_MATH(asin);\n  return asin(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat asin(const float &x) { return ::asinf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble asin(const double &x) { return ::asin(x); }\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT atan(const T &x) {\n  EIGEN_USING_STD_MATH(atan);\n  return atan(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat atan(const float &x) { return ::atanf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble atan(const double &x) { return ::atan(x); }\n#endif\n\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT cosh(const T &x) {\n  EIGEN_USING_STD_MATH(cosh);\n  return cosh(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat cosh(const float &x) { return ::coshf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble cosh(const double &x) { return ::cosh(x); }\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT sinh(const T &x) {\n  EIGEN_USING_STD_MATH(sinh);\n  return sinh(x);\n}\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat sinh(const float &x) { return ::sinhf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble sinh(const double &x) { return ::sinh(x); }\n#endif\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT tanh(const T &x) {\n  EIGEN_USING_STD_MATH(tanh);\n  return tanh(x);\n}\n\n#if (!defined(__CUDACC__)) && EIGEN_FAST_MATH\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat tanh(float x) { return internal::generic_fast_tanh_float(x); }\n#endif\n\n#ifdef __CUDACC__\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat tanh(const float &x) { return ::tanhf(x); }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble tanh(const double &x) { return ::tanh(x); }\n#endif\n\ntemplate <typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nT fmod(const T& a, const T& b) {\n  EIGEN_USING_STD_MATH(fmod);\n  return fmod(a, b);\n}\n\n#ifdef __CUDACC__\ntemplate <>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat fmod(const float& a, const float& b) {\n  return ::fmodf(a, b);\n}\n\ntemplate <>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble fmod(const double& a, const double& b) {\n  return ::fmod(a, b);\n}\n#endif\n\n} // end namespace numext\n\nnamespace internal {\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC bool isfinite_impl(const std::complex<T>& x)\n{\n  return (numext::isfinite)(numext::real(x)) && (numext::isfinite)(numext::imag(x));\n}\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC bool isnan_impl(const std::complex<T>& x)\n{\n  return (numext::isnan)(numext::real(x)) || (numext::isnan)(numext::imag(x));\n}\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC bool isinf_impl(const std::complex<T>& x)\n{\n  return ((numext::isinf)(numext::real(x)) || (numext::isinf)(numext::imag(x))) && (!(numext::isnan)(x));\n}\n\n/****************************************************************************\n* Implementation of fuzzy comparisons                                       *\n****************************************************************************/\n\ntemplate<typename Scalar,\n         bool IsComplex,\n         bool IsInteger>\nstruct scalar_fuzzy_default_impl {};\n\ntemplate<typename Scalar>\nstruct scalar_fuzzy_default_impl<Scalar, false, false>\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  template<typename OtherScalar> EIGEN_DEVICE_FUNC\n  static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec)\n  {\n    return numext::abs(x) <= numext::abs(y) * prec;\n  }\n  EIGEN_DEVICE_FUNC\n  static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec)\n  {\n    return numext::abs(x - y) <= numext::mini(numext::abs(x), numext::abs(y)) * prec;\n  }\n  EIGEN_DEVICE_FUNC\n  static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar& prec)\n  {\n    return x <= y || isApprox(x, y, prec);\n  }\n};\n\ntemplate<typename Scalar>\nstruct scalar_fuzzy_default_impl<Scalar, false, true>\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  template<typename OtherScalar> EIGEN_DEVICE_FUNC\n  static inline bool isMuchSmallerThan(const Scalar& x, const Scalar&, const RealScalar&)\n  {\n    return x == Scalar(0);\n  }\n  EIGEN_DEVICE_FUNC\n  static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar&)\n  {\n    return x == y;\n  }\n  EIGEN_DEVICE_FUNC\n  static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar&)\n  {\n    return x <= y;\n  }\n};\n\ntemplate<typename Scalar>\nstruct scalar_fuzzy_default_impl<Scalar, true, false>\n{\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  template<typename OtherScalar> EIGEN_DEVICE_FUNC\n  static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec)\n  {\n    return numext::abs2(x) <= numext::abs2(y) * prec * prec;\n  }\n  EIGEN_DEVICE_FUNC\n  static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec)\n  {\n    return numext::abs2(x - y) <= numext::mini(numext::abs2(x), numext::abs2(y)) * prec * prec;\n  }\n};\n\ntemplate<typename Scalar>\nstruct scalar_fuzzy_impl : scalar_fuzzy_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {};\n\ntemplate<typename Scalar, typename OtherScalar> EIGEN_DEVICE_FUNC\ninline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y,\n                              const typename NumTraits<Scalar>::Real &precision = NumTraits<Scalar>::dummy_precision())\n{\n  return scalar_fuzzy_impl<Scalar>::template isMuchSmallerThan<OtherScalar>(x, y, precision);\n}\n\ntemplate<typename Scalar> EIGEN_DEVICE_FUNC\ninline bool isApprox(const Scalar& x, const Scalar& y,\n                     const typename NumTraits<Scalar>::Real &precision = NumTraits<Scalar>::dummy_precision())\n{\n  return scalar_fuzzy_impl<Scalar>::isApprox(x, y, precision);\n}\n\ntemplate<typename Scalar> EIGEN_DEVICE_FUNC\ninline bool isApproxOrLessThan(const Scalar& x, const Scalar& y,\n                               const typename NumTraits<Scalar>::Real &precision = NumTraits<Scalar>::dummy_precision())\n{\n  return scalar_fuzzy_impl<Scalar>::isApproxOrLessThan(x, y, precision);\n}\n\n/******************************************\n***  The special case of the  bool type ***\n******************************************/\n\ntemplate<> struct random_impl<bool>\n{\n  static inline bool run()\n  {\n    return random<int>(0,1)==0 ? false : true;\n  }\n};\n\ntemplate<> struct scalar_fuzzy_impl<bool>\n{\n  typedef bool RealScalar;\n  \n  template<typename OtherScalar> EIGEN_DEVICE_FUNC\n  static inline bool isMuchSmallerThan(const bool& x, const bool&, const bool&)\n  {\n    return !x;\n  }\n  \n  EIGEN_DEVICE_FUNC\n  static inline bool isApprox(bool x, bool y, bool)\n  {\n    return x == y;\n  }\n\n  EIGEN_DEVICE_FUNC\n  static inline bool isApproxOrLessThan(const bool& x, const bool& y, const bool&)\n  {\n    return (!x) || y;\n  }\n  \n};\n\n  \n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_MATHFUNCTIONS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/MathFunctionsImpl.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2014 Pedro Gonnet (pedro.gonnet@gmail.com)\n// Copyright (C) 2016 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MATHFUNCTIONSIMPL_H\n#define EIGEN_MATHFUNCTIONSIMPL_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n/** \\internal \\returns the hyperbolic tan of \\a a (coeff-wise)\n    Doesn't do anything fancy, just a 13/6-degree rational interpolant which\n    is accurate up to a couple of ulp in the range [-9, 9], outside of which\n    the tanh(x) = +/-1.\n\n    This implementation works on both scalars and packets.\n*/\ntemplate<typename T>\nT generic_fast_tanh_float(const T& a_x)\n{\n  // Clamp the inputs to the range [-9, 9] since anything outside\n  // this range is +/-1.0f in single-precision.\n  const T plus_9 = pset1<T>(9.f);\n  const T minus_9 = pset1<T>(-9.f);\n  // NOTE GCC prior to 6.3 might improperly optimize this max/min\n  //      step such that if a_x is nan, x will be either 9 or -9,\n  //      and tanh will return 1 or -1 instead of nan.\n  //      This is supposed to be fixed in gcc6.3,\n  //      see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72867\n  const T x = pmax(minus_9,pmin(plus_9,a_x));\n  // The monomial coefficients of the numerator polynomial (odd).\n  const T alpha_1 = pset1<T>(4.89352455891786e-03f);\n  const T alpha_3 = pset1<T>(6.37261928875436e-04f);\n  const T alpha_5 = pset1<T>(1.48572235717979e-05f);\n  const T alpha_7 = pset1<T>(5.12229709037114e-08f);\n  const T alpha_9 = pset1<T>(-8.60467152213735e-11f);\n  const T alpha_11 = pset1<T>(2.00018790482477e-13f);\n  const T alpha_13 = pset1<T>(-2.76076847742355e-16f);\n\n  // The monomial coefficients of the denominator polynomial (even).\n  const T beta_0 = pset1<T>(4.89352518554385e-03f);\n  const T beta_2 = pset1<T>(2.26843463243900e-03f);\n  const T beta_4 = pset1<T>(1.18534705686654e-04f);\n  const T beta_6 = pset1<T>(1.19825839466702e-06f);\n\n  // Since the polynomials are odd/even, we need x^2.\n  const T x2 = pmul(x, x);\n\n  // Evaluate the numerator polynomial p.\n  T p = pmadd(x2, alpha_13, alpha_11);\n  p = pmadd(x2, p, alpha_9);\n  p = pmadd(x2, p, alpha_7);\n  p = pmadd(x2, p, alpha_5);\n  p = pmadd(x2, p, alpha_3);\n  p = pmadd(x2, p, alpha_1);\n  p = pmul(x, p);\n\n  // Evaluate the denominator polynomial p.\n  T q = pmadd(x2, beta_6, beta_4);\n  q = pmadd(x2, q, beta_2);\n  q = pmadd(x2, q, beta_0);\n\n  // Divide the numerator by the denominator.\n  return pdiv(p, q);\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_MATHFUNCTIONSIMPL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Matrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MATRIX_H\n#define EIGEN_MATRIX_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>\nstruct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >\n{\nprivate:\n  enum { size = internal::size_at_compile_time<_Rows,_Cols>::ret };\n  typedef typename find_best_packet<_Scalar,size>::type PacketScalar;\n  enum {\n      row_major_bit = _Options&RowMajor ? RowMajorBit : 0,\n      is_dynamic_size_storage = _MaxRows==Dynamic || _MaxCols==Dynamic,\n      max_size = is_dynamic_size_storage ? Dynamic : _MaxRows*_MaxCols,\n      default_alignment = compute_default_alignment<_Scalar,max_size>::value,\n      actual_alignment = ((_Options&DontAlign)==0) ? default_alignment : 0,\n      required_alignment = unpacket_traits<PacketScalar>::alignment,\n      packet_access_bit = (packet_traits<_Scalar>::Vectorizable && (EIGEN_UNALIGNED_VECTORIZE || (actual_alignment>=required_alignment))) ? PacketAccessBit : 0\n    };\n    \npublic:\n  typedef _Scalar Scalar;\n  typedef Dense StorageKind;\n  typedef Eigen::Index StorageIndex;\n  typedef MatrixXpr XprKind;\n  enum {\n    RowsAtCompileTime = _Rows,\n    ColsAtCompileTime = _Cols,\n    MaxRowsAtCompileTime = _MaxRows,\n    MaxColsAtCompileTime = _MaxCols,\n    Flags = compute_matrix_flags<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ret,\n    Options = _Options,\n    InnerStrideAtCompileTime = 1,\n    OuterStrideAtCompileTime = (Options&RowMajor) ? ColsAtCompileTime : RowsAtCompileTime,\n    \n    // FIXME, the following flag in only used to define NeedsToAlign in PlainObjectBase\n    EvaluatorFlags = LinearAccessBit | DirectAccessBit | packet_access_bit | row_major_bit,\n    Alignment = actual_alignment\n  };\n};\n}\n\n/** \\class Matrix\n  * \\ingroup Core_Module\n  *\n  * \\brief The matrix class, also used for vectors and row-vectors\n  *\n  * The %Matrix class is the work-horse for all \\em dense (\\ref dense \"note\") matrices and vectors within Eigen.\n  * Vectors are matrices with one column, and row-vectors are matrices with one row.\n  *\n  * The %Matrix class encompasses \\em both fixed-size and dynamic-size objects (\\ref fixedsize \"note\").\n  *\n  * The first three template parameters are required:\n  * \\tparam _Scalar Numeric type, e.g. float, double, int or std::complex<float>.\n  *                 User defined scalar types are supported as well (see \\ref user_defined_scalars \"here\").\n  * \\tparam _Rows Number of rows, or \\b Dynamic\n  * \\tparam _Cols Number of columns, or \\b Dynamic\n  *\n  * The remaining template parameters are optional -- in most cases you don't have to worry about them.\n  * \\tparam _Options A combination of either \\b #RowMajor or \\b #ColMajor, and of either\n  *                 \\b #AutoAlign or \\b #DontAlign.\n  *                 The former controls \\ref TopicStorageOrders \"storage order\", and defaults to column-major. The latter controls alignment, which is required\n  *                 for vectorization. It defaults to aligning matrices except for fixed sizes that aren't a multiple of the packet size.\n  * \\tparam _MaxRows Maximum number of rows. Defaults to \\a _Rows (\\ref maxrows \"note\").\n  * \\tparam _MaxCols Maximum number of columns. Defaults to \\a _Cols (\\ref maxrows \"note\").\n  *\n  * Eigen provides a number of typedefs covering the usual cases. Here are some examples:\n  *\n  * \\li \\c Matrix2d is a 2x2 square matrix of doubles (\\c Matrix<double, 2, 2>)\n  * \\li \\c Vector4f is a vector of 4 floats (\\c Matrix<float, 4, 1>)\n  * \\li \\c RowVector3i is a row-vector of 3 ints (\\c Matrix<int, 1, 3>)\n  *\n  * \\li \\c MatrixXf is a dynamic-size matrix of floats (\\c Matrix<float, Dynamic, Dynamic>)\n  * \\li \\c VectorXf is a dynamic-size vector of floats (\\c Matrix<float, Dynamic, 1>)\n  *\n  * \\li \\c Matrix2Xf is a partially fixed-size (dynamic-size) matrix of floats (\\c Matrix<float, 2, Dynamic>)\n  * \\li \\c MatrixX3d is a partially dynamic-size (fixed-size) matrix of double (\\c Matrix<double, Dynamic, 3>)\n  *\n  * See \\link matrixtypedefs this page \\endlink for a complete list of predefined \\em %Matrix and \\em Vector typedefs.\n  *\n  * You can access elements of vectors and matrices using normal subscripting:\n  *\n  * \\code\n  * Eigen::VectorXd v(10);\n  * v[0] = 0.1;\n  * v[1] = 0.2;\n  * v(0) = 0.3;\n  * v(1) = 0.4;\n  *\n  * Eigen::MatrixXi m(10, 10);\n  * m(0, 1) = 1;\n  * m(0, 2) = 2;\n  * m(0, 3) = 3;\n  * \\endcode\n  *\n  * This class can be extended with the help of the plugin mechanism described on the page\n  * \\ref TopicCustomizing_Plugins by defining the preprocessor symbol \\c EIGEN_MATRIX_PLUGIN.\n  *\n  * <i><b>Some notes:</b></i>\n  *\n  * <dl>\n  * <dt><b>\\anchor dense Dense versus sparse:</b></dt>\n  * <dd>This %Matrix class handles dense, not sparse matrices and vectors. For sparse matrices and vectors, see the Sparse module.\n  *\n  * Dense matrices and vectors are plain usual arrays of coefficients. All the coefficients are stored, in an ordinary contiguous array.\n  * This is unlike Sparse matrices and vectors where the coefficients are stored as a list of nonzero coefficients.</dd>\n  *\n  * <dt><b>\\anchor fixedsize Fixed-size versus dynamic-size:</b></dt>\n  * <dd>Fixed-size means that the numbers of rows and columns are known are compile-time. In this case, Eigen allocates the array\n  * of coefficients as a fixed-size array, as a class member. This makes sense for very small matrices, typically up to 4x4, sometimes up\n  * to 16x16. Larger matrices should be declared as dynamic-size even if one happens to know their size at compile-time.\n  *\n  * Dynamic-size means that the numbers of rows or columns are not necessarily known at compile-time. In this case they are runtime\n  * variables, and the array of coefficients is allocated dynamically on the heap.\n  *\n  * Note that \\em dense matrices, be they Fixed-size or Dynamic-size, <em>do not</em> expand dynamically in the sense of a std::map.\n  * If you want this behavior, see the Sparse module.</dd>\n  *\n  * <dt><b>\\anchor maxrows _MaxRows and _MaxCols:</b></dt>\n  * <dd>In most cases, one just leaves these parameters to the default values.\n  * These parameters mean the maximum size of rows and columns that the matrix may have. They are useful in cases\n  * when the exact numbers of rows and columns are not known are compile-time, but it is known at compile-time that they cannot\n  * exceed a certain value. This happens when taking dynamic-size blocks inside fixed-size matrices: in this case _MaxRows and _MaxCols\n  * are the dimensions of the original matrix, while _Rows and _Cols are Dynamic.</dd>\n  * </dl>\n  *\n  * <i><b>ABI and storage layout</b></i>\n  *\n  * The table below summarizes the ABI of some possible Matrix instances which is fixed thorough the lifetime of Eigen 3.\n  * <table  class=\"manual\">\n  * <tr><th>Matrix type</th><th>Equivalent C structure</th></tr>\n  * <tr><td>\\code Matrix<T,Dynamic,Dynamic> \\endcode</td><td>\\code\n  * struct {\n  *   T *data;                  // with (size_t(data)%EIGEN_MAX_ALIGN_BYTES)==0\n  *   Eigen::Index rows, cols;\n  *  };\n  * \\endcode</td></tr>\n  * <tr class=\"alt\"><td>\\code\n  * Matrix<T,Dynamic,1>\n  * Matrix<T,1,Dynamic> \\endcode</td><td>\\code\n  * struct {\n  *   T *data;                  // with (size_t(data)%EIGEN_MAX_ALIGN_BYTES)==0\n  *   Eigen::Index size;\n  *  };\n  * \\endcode</td></tr>\n  * <tr><td>\\code Matrix<T,Rows,Cols> \\endcode</td><td>\\code\n  * struct {\n  *   T data[Rows*Cols];        // with (size_t(data)%A(Rows*Cols*sizeof(T)))==0\n  *  };\n  * \\endcode</td></tr>\n  * <tr class=\"alt\"><td>\\code Matrix<T,Dynamic,Dynamic,0,MaxRows,MaxCols> \\endcode</td><td>\\code\n  * struct {\n  *   T data[MaxRows*MaxCols];  // with (size_t(data)%A(MaxRows*MaxCols*sizeof(T)))==0\n  *   Eigen::Index rows, cols;\n  *  };\n  * \\endcode</td></tr>\n  * </table>\n  * Note that in this table Rows, Cols, MaxRows and MaxCols are all positive integers. A(S) is defined to the largest possible power-of-two\n  * smaller to EIGEN_MAX_STATIC_ALIGN_BYTES.\n  *\n  * \\see MatrixBase for the majority of the API methods for matrices, \\ref TopicClassHierarchy,\n  * \\ref TopicStorageOrders\n  */\n\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>\nclass Matrix\n  : public PlainObjectBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >\n{\n  public:\n\n    /** \\brief Base class typedef.\n      * \\sa PlainObjectBase\n      */\n    typedef PlainObjectBase<Matrix> Base;\n\n    enum { Options = _Options };\n\n    EIGEN_DENSE_PUBLIC_INTERFACE(Matrix)\n\n    typedef typename Base::PlainObject PlainObject;\n\n    using Base::base;\n    using Base::coeffRef;\n\n    /**\n      * \\brief Assigns matrices to each other.\n      *\n      * \\note This is a special case of the templated operator=. Its purpose is\n      * to prevent a default operator= from hiding the templated operator=.\n      *\n      * \\callgraph\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Matrix& operator=(const Matrix& other)\n    {\n      return Base::_set(other);\n    }\n\n    /** \\internal\n      * \\brief Copies the value of the expression \\a other into \\c *this with automatic resizing.\n      *\n      * *this might be resized to match the dimensions of \\a other. If *this was a null matrix (not already initialized),\n      * it will be initialized.\n      *\n      * Note that copying a row-vector into a vector (and conversely) is allowed.\n      * The resizing, if any, is then done in the appropriate way so that row-vectors\n      * remain row-vectors and vectors remain vectors.\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Matrix& operator=(const DenseBase<OtherDerived>& other)\n    {\n      return Base::_set(other);\n    }\n\n    /* Here, doxygen failed to copy the brief information when using \\copydoc */\n\n    /**\n      * \\brief Copies the generic expression \\a other into *this.\n      * \\copydetails DenseBase::operator=(const EigenBase<OtherDerived> &other)\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Matrix& operator=(const EigenBase<OtherDerived> &other)\n    {\n      return Base::operator=(other);\n    }\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Matrix& operator=(const ReturnByValue<OtherDerived>& func)\n    {\n      return Base::operator=(func);\n    }\n\n    /** \\brief Default constructor.\n      *\n      * For fixed-size matrices, does nothing.\n      *\n      * For dynamic-size matrices, creates an empty matrix of size 0. Does not allocate any array. Such a matrix\n      * is called a null matrix. This constructor is the unique way to create null matrices: resizing\n      * a matrix to 0 is not supported.\n      *\n      * \\sa resize(Index,Index)\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Matrix() : Base()\n    {\n      Base::_check_template_params();\n      EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED\n    }\n\n    // FIXME is it still needed\n    EIGEN_DEVICE_FUNC\n    explicit Matrix(internal::constructor_without_unaligned_array_assert)\n      : Base(internal::constructor_without_unaligned_array_assert())\n    { Base::_check_template_params(); EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED }\n\n#if EIGEN_HAS_RVALUE_REFERENCES\n    EIGEN_DEVICE_FUNC\n    Matrix(Matrix&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_constructible<Scalar>::value)\n      : Base(std::move(other))\n    {\n      Base::_check_template_params();\n      if (RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic)\n        Base::_set_noalias(other);\n    }\n    EIGEN_DEVICE_FUNC\n    Matrix& operator=(Matrix&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable<Scalar>::value)\n    {\n      other.swap(*this);\n      return *this;\n    }\n#endif\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n\n    // This constructor is for both 1x1 matrices and dynamic vectors\n    template<typename T>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE explicit Matrix(const T& x)\n    {\n      Base::_check_template_params();\n      Base::template _init1<T>(x);\n    }\n\n    template<typename T0, typename T1>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y)\n    {\n      Base::_check_template_params();\n      Base::template _init2<T0,T1>(x, y);\n    }\n    #else\n    /** \\brief Constructs a fixed-sized matrix initialized with coefficients starting at \\a data */\n    EIGEN_DEVICE_FUNC\n    explicit Matrix(const Scalar *data);\n\n    /** \\brief Constructs a vector or row-vector with given dimension. \\only_for_vectors\n      *\n      * This is useful for dynamic-size vectors. For fixed-size vectors,\n      * it is redundant to pass these parameters, so one should use the default constructor\n      * Matrix() instead.\n      * \n      * \\warning This constructor is disabled for fixed-size \\c 1x1 matrices. For instance,\n      * calling Matrix<double,1,1>(1) will call the initialization constructor: Matrix(const Scalar&).\n      * For fixed-size \\c 1x1 matrices it is therefore recommended to use the default\n      * constructor Matrix() instead, especially when using one of the non standard\n      * \\c EIGEN_INITIALIZE_MATRICES_BY_{ZERO,\\c NAN} macros (see \\ref TopicPreprocessorDirectives).\n      */\n    EIGEN_STRONG_INLINE explicit Matrix(Index dim);\n    /** \\brief Constructs an initialized 1x1 matrix with the given coefficient */\n    Matrix(const Scalar& x);\n    /** \\brief Constructs an uninitialized matrix with \\a rows rows and \\a cols columns.\n      *\n      * This is useful for dynamic-size matrices. For fixed-size matrices,\n      * it is redundant to pass these parameters, so one should use the default constructor\n      * Matrix() instead.\n      * \n      * \\warning This constructor is disabled for fixed-size \\c 1x2 and \\c 2x1 vectors. For instance,\n      * calling Matrix2f(2,1) will call the initialization constructor: Matrix(const Scalar& x, const Scalar& y).\n      * For fixed-size \\c 1x2 or \\c 2x1 vectors it is therefore recommended to use the default\n      * constructor Matrix() instead, especially when using one of the non standard\n      * \\c EIGEN_INITIALIZE_MATRICES_BY_{ZERO,\\c NAN} macros (see \\ref TopicPreprocessorDirectives).\n      */\n    EIGEN_DEVICE_FUNC\n    Matrix(Index rows, Index cols);\n    \n    /** \\brief Constructs an initialized 2D vector with given coefficients */\n    Matrix(const Scalar& x, const Scalar& y);\n    #endif\n\n    /** \\brief Constructs an initialized 3D vector with given coefficients */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z)\n    {\n      Base::_check_template_params();\n      EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 3)\n      m_storage.data()[0] = x;\n      m_storage.data()[1] = y;\n      m_storage.data()[2] = z;\n    }\n    /** \\brief Constructs an initialized 4D vector with given coefficients */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)\n    {\n      Base::_check_template_params();\n      EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 4)\n      m_storage.data()[0] = x;\n      m_storage.data()[1] = y;\n      m_storage.data()[2] = z;\n      m_storage.data()[3] = w;\n    }\n\n\n    /** \\brief Copy constructor */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Matrix(const Matrix& other) : Base(other)\n    { }\n\n    /** \\brief Copy constructor for generic expressions.\n      * \\sa MatrixBase::operator=(const EigenBase<OtherDerived>&)\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Matrix(const EigenBase<OtherDerived> &other)\n      : Base(other.derived())\n    { }\n\n    EIGEN_DEVICE_FUNC inline Index innerStride() const { return 1; }\n    EIGEN_DEVICE_FUNC inline Index outerStride() const { return this->innerSize(); }\n\n    /////////// Geometry module ///////////\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    explicit Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r);\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    Matrix& operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r);\n\n    // allow to extend Matrix outside Eigen\n    #ifdef EIGEN_MATRIX_PLUGIN\n    #include EIGEN_MATRIX_PLUGIN\n    #endif\n\n  protected:\n    template <typename Derived, typename OtherDerived, bool IsVector>\n    friend struct internal::conservative_resize_like_impl;\n\n    using Base::m_storage;\n};\n\n/** \\defgroup matrixtypedefs Global matrix typedefs\n  *\n  * \\ingroup Core_Module\n  *\n  * Eigen defines several typedef shortcuts for most common matrix and vector types.\n  *\n  * The general patterns are the following:\n  *\n  * \\c MatrixSizeType where \\c Size can be \\c 2,\\c 3,\\c 4 for fixed size square matrices or \\c X for dynamic size,\n  * and where \\c Type can be \\c i for integer, \\c f for float, \\c d for double, \\c cf for complex float, \\c cd\n  * for complex double.\n  *\n  * For example, \\c Matrix3d is a fixed-size 3x3 matrix type of doubles, and \\c MatrixXf is a dynamic-size matrix of floats.\n  *\n  * There are also \\c VectorSizeType and \\c RowVectorSizeType which are self-explanatory. For example, \\c Vector4cf is\n  * a fixed-size vector of 4 complex floats.\n  *\n  * \\sa class Matrix\n  */\n\n#define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix)   \\\n/** \\ingroup matrixtypedefs */                                    \\\ntypedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix;  \\\n/** \\ingroup matrixtypedefs */                                    \\\ntypedef Matrix<Type, Size, 1>    Vector##SizeSuffix##TypeSuffix;  \\\n/** \\ingroup matrixtypedefs */                                    \\\ntypedef Matrix<Type, 1, Size>    RowVector##SizeSuffix##TypeSuffix;\n\n#define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size)         \\\n/** \\ingroup matrixtypedefs */                                    \\\ntypedef Matrix<Type, Size, Dynamic> Matrix##Size##X##TypeSuffix;  \\\n/** \\ingroup matrixtypedefs */                                    \\\ntypedef Matrix<Type, Dynamic, Size> Matrix##X##Size##TypeSuffix;\n\n#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \\\nEIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \\\nEIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \\\nEIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \\\nEIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \\\nEIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \\\nEIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \\\nEIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4)\n\nEIGEN_MAKE_TYPEDEFS_ALL_SIZES(int,                  i)\nEIGEN_MAKE_TYPEDEFS_ALL_SIZES(float,                f)\nEIGEN_MAKE_TYPEDEFS_ALL_SIZES(double,               d)\nEIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<float>,  cf)\nEIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)\n\n#undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES\n#undef EIGEN_MAKE_TYPEDEFS\n#undef EIGEN_MAKE_FIXED_TYPEDEFS\n\n} // end namespace Eigen\n\n#endif // EIGEN_MATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/MatrixBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MATRIXBASE_H\n#define EIGEN_MATRIXBASE_H\n\nnamespace Eigen {\n\n/** \\class MatrixBase\n  * \\ingroup Core_Module\n  *\n  * \\brief Base class for all dense matrices, vectors, and expressions\n  *\n  * This class is the base that is inherited by all matrix, vector, and related expression\n  * types. Most of the Eigen API is contained in this class, and its base classes. Other important\n  * classes for the Eigen API are Matrix, and VectorwiseOp.\n  *\n  * Note that some methods are defined in other modules such as the \\ref LU_Module LU module\n  * for all functions related to matrix inversions.\n  *\n  * \\tparam Derived is the derived type, e.g. a matrix type, or an expression, etc.\n  *\n  * When writing a function taking Eigen objects as argument, if you want your function\n  * to take as argument any matrix, vector, or expression, just let it take a\n  * MatrixBase argument. As an example, here is a function printFirstRow which, given\n  * a matrix, vector, or expression \\a x, prints the first row of \\a x.\n  *\n  * \\code\n    template<typename Derived>\n    void printFirstRow(const Eigen::MatrixBase<Derived>& x)\n    {\n      cout << x.row(0) << endl;\n    }\n  * \\endcode\n  *\n  * This class can be extended with the help of the plugin mechanism described on the page\n  * \\ref TopicCustomizing_Plugins by defining the preprocessor symbol \\c EIGEN_MATRIXBASE_PLUGIN.\n  *\n  * \\sa \\blank \\ref TopicClassHierarchy\n  */\ntemplate<typename Derived> class MatrixBase\n  : public DenseBase<Derived>\n{\n  public:\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    typedef MatrixBase StorageBaseType;\n    typedef typename internal::traits<Derived>::StorageKind StorageKind;\n    typedef typename internal::traits<Derived>::StorageIndex StorageIndex;\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    typedef typename internal::packet_traits<Scalar>::type PacketScalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n\n    typedef DenseBase<Derived> Base;\n    using Base::RowsAtCompileTime;\n    using Base::ColsAtCompileTime;\n    using Base::SizeAtCompileTime;\n    using Base::MaxRowsAtCompileTime;\n    using Base::MaxColsAtCompileTime;\n    using Base::MaxSizeAtCompileTime;\n    using Base::IsVectorAtCompileTime;\n    using Base::Flags;\n\n    using Base::derived;\n    using Base::const_cast_derived;\n    using Base::rows;\n    using Base::cols;\n    using Base::size;\n    using Base::coeff;\n    using Base::coeffRef;\n    using Base::lazyAssign;\n    using Base::eval;\n    using Base::operator+=;\n    using Base::operator-=;\n    using Base::operator*=;\n    using Base::operator/=;\n\n    typedef typename Base::CoeffReturnType CoeffReturnType;\n    typedef typename Base::ConstTransposeReturnType ConstTransposeReturnType;\n    typedef typename Base::RowXpr RowXpr;\n    typedef typename Base::ColXpr ColXpr;\n#endif // not EIGEN_PARSED_BY_DOXYGEN\n\n\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** type of the equivalent square matrix */\n    typedef Matrix<Scalar,EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime),\n                          EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime)> SquareMatrixType;\n#endif // not EIGEN_PARSED_BY_DOXYGEN\n\n    /** \\returns the size of the main diagonal, which is min(rows(),cols()).\n      * \\sa rows(), cols(), SizeAtCompileTime. */\n    EIGEN_DEVICE_FUNC\n    inline Index diagonalSize() const { return (numext::mini)(rows(),cols()); }\n\n    typedef typename Base::PlainObject PlainObject;\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** \\internal Represents a matrix with all coefficients equal to one another*/\n    typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,PlainObject> ConstantReturnType;\n    /** \\internal the return type of MatrixBase::adjoint() */\n    typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,\n                        CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, ConstTransposeReturnType>,\n                        ConstTransposeReturnType\n                     >::type AdjointReturnType;\n    /** \\internal Return type of eigenvalues() */\n    typedef Matrix<std::complex<RealScalar>, internal::traits<Derived>::ColsAtCompileTime, 1, ColMajor> EigenvaluesReturnType;\n    /** \\internal the return type of identity */\n    typedef CwiseNullaryOp<internal::scalar_identity_op<Scalar>,PlainObject> IdentityReturnType;\n    /** \\internal the return type of unit vectors */\n    typedef Block<const CwiseNullaryOp<internal::scalar_identity_op<Scalar>, SquareMatrixType>,\n                  internal::traits<Derived>::RowsAtCompileTime,\n                  internal::traits<Derived>::ColsAtCompileTime> BasisReturnType;\n#endif // not EIGEN_PARSED_BY_DOXYGEN\n\n#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase\n#define EIGEN_DOC_UNARY_ADDONS(X,Y)\n#   include \"../plugins/CommonCwiseUnaryOps.h\"\n#   include \"../plugins/CommonCwiseBinaryOps.h\"\n#   include \"../plugins/MatrixCwiseUnaryOps.h\"\n#   include \"../plugins/MatrixCwiseBinaryOps.h\"\n#   ifdef EIGEN_MATRIXBASE_PLUGIN\n#     include EIGEN_MATRIXBASE_PLUGIN\n#   endif\n#undef EIGEN_CURRENT_STORAGE_BASE_CLASS\n#undef EIGEN_DOC_UNARY_ADDONS\n\n    /** Special case of the template operator=, in order to prevent the compiler\n      * from generating a default operator= (issue hit with g++ 4.1)\n      */\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator=(const MatrixBase& other);\n\n    // We cannot inherit here via Base::operator= since it is causing\n    // trouble with MSVC.\n\n    template <typename OtherDerived>\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator=(const DenseBase<OtherDerived>& other);\n\n    template <typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    Derived& operator=(const EigenBase<OtherDerived>& other);\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    Derived& operator=(const ReturnByValue<OtherDerived>& other);\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator+=(const MatrixBase<OtherDerived>& other);\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n    Derived& operator-=(const MatrixBase<OtherDerived>& other);\n\n#ifdef __CUDACC__\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    const Product<Derived,OtherDerived,LazyProduct>\n    operator*(const MatrixBase<OtherDerived> &other) const\n    { return this->lazyProduct(other); }\n#else\n\n    template<typename OtherDerived>\n    const Product<Derived,OtherDerived>\n    operator*(const MatrixBase<OtherDerived> &other) const;\n\n#endif\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    const Product<Derived,OtherDerived,LazyProduct>\n    lazyProduct(const MatrixBase<OtherDerived> &other) const;\n\n    template<typename OtherDerived>\n    Derived& operator*=(const EigenBase<OtherDerived>& other);\n\n    template<typename OtherDerived>\n    void applyOnTheLeft(const EigenBase<OtherDerived>& other);\n\n    template<typename OtherDerived>\n    void applyOnTheRight(const EigenBase<OtherDerived>& other);\n\n    template<typename DiagonalDerived>\n    EIGEN_DEVICE_FUNC\n    const Product<Derived, DiagonalDerived, LazyProduct>\n    operator*(const DiagonalBase<DiagonalDerived> &diagonal) const;\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    typename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,typename internal::traits<OtherDerived>::Scalar>::ReturnType\n    dot(const MatrixBase<OtherDerived>& other) const;\n\n    EIGEN_DEVICE_FUNC RealScalar squaredNorm() const;\n    EIGEN_DEVICE_FUNC RealScalar norm() const;\n    RealScalar stableNorm() const;\n    RealScalar blueNorm() const;\n    RealScalar hypotNorm() const;\n    EIGEN_DEVICE_FUNC const PlainObject normalized() const;\n    EIGEN_DEVICE_FUNC const PlainObject stableNormalized() const;\n    EIGEN_DEVICE_FUNC void normalize();\n    EIGEN_DEVICE_FUNC void stableNormalize();\n\n    EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const;\n    EIGEN_DEVICE_FUNC void adjointInPlace();\n\n    typedef Diagonal<Derived> DiagonalReturnType;\n    EIGEN_DEVICE_FUNC\n    DiagonalReturnType diagonal();\n\n    typedef typename internal::add_const<Diagonal<const Derived> >::type ConstDiagonalReturnType;\n    EIGEN_DEVICE_FUNC\n    ConstDiagonalReturnType diagonal() const;\n\n    template<int Index> struct DiagonalIndexReturnType { typedef Diagonal<Derived,Index> Type; };\n    template<int Index> struct ConstDiagonalIndexReturnType { typedef const Diagonal<const Derived,Index> Type; };\n\n    template<int Index>\n    EIGEN_DEVICE_FUNC\n    typename DiagonalIndexReturnType<Index>::Type diagonal();\n\n    template<int Index>\n    EIGEN_DEVICE_FUNC\n    typename ConstDiagonalIndexReturnType<Index>::Type diagonal() const;\n\n    typedef Diagonal<Derived,DynamicIndex> DiagonalDynamicIndexReturnType;\n    typedef typename internal::add_const<Diagonal<const Derived,DynamicIndex> >::type ConstDiagonalDynamicIndexReturnType;\n\n    EIGEN_DEVICE_FUNC\n    DiagonalDynamicIndexReturnType diagonal(Index index);\n    EIGEN_DEVICE_FUNC\n    ConstDiagonalDynamicIndexReturnType diagonal(Index index) const;\n\n    template<unsigned int Mode> struct TriangularViewReturnType { typedef TriangularView<Derived, Mode> Type; };\n    template<unsigned int Mode> struct ConstTriangularViewReturnType { typedef const TriangularView<const Derived, Mode> Type; };\n\n    template<unsigned int Mode>\n    EIGEN_DEVICE_FUNC\n    typename TriangularViewReturnType<Mode>::Type triangularView();\n    template<unsigned int Mode>\n    EIGEN_DEVICE_FUNC\n    typename ConstTriangularViewReturnType<Mode>::Type triangularView() const;\n\n    template<unsigned int UpLo> struct SelfAdjointViewReturnType { typedef SelfAdjointView<Derived, UpLo> Type; };\n    template<unsigned int UpLo> struct ConstSelfAdjointViewReturnType { typedef const SelfAdjointView<const Derived, UpLo> Type; };\n\n    template<unsigned int UpLo>\n    EIGEN_DEVICE_FUNC\n    typename SelfAdjointViewReturnType<UpLo>::Type selfadjointView();\n    template<unsigned int UpLo>\n    EIGEN_DEVICE_FUNC\n    typename ConstSelfAdjointViewReturnType<UpLo>::Type selfadjointView() const;\n\n    const SparseView<Derived> sparseView(const Scalar& m_reference = Scalar(0),\n                                         const typename NumTraits<Scalar>::Real& m_epsilon = NumTraits<Scalar>::dummy_precision()) const;\n    EIGEN_DEVICE_FUNC static const IdentityReturnType Identity();\n    EIGEN_DEVICE_FUNC static const IdentityReturnType Identity(Index rows, Index cols);\n    EIGEN_DEVICE_FUNC static const BasisReturnType Unit(Index size, Index i);\n    EIGEN_DEVICE_FUNC static const BasisReturnType Unit(Index i);\n    EIGEN_DEVICE_FUNC static const BasisReturnType UnitX();\n    EIGEN_DEVICE_FUNC static const BasisReturnType UnitY();\n    EIGEN_DEVICE_FUNC static const BasisReturnType UnitZ();\n    EIGEN_DEVICE_FUNC static const BasisReturnType UnitW();\n\n    EIGEN_DEVICE_FUNC\n    const DiagonalWrapper<const Derived> asDiagonal() const;\n    const PermutationWrapper<const Derived> asPermutation() const;\n\n    EIGEN_DEVICE_FUNC\n    Derived& setIdentity();\n    EIGEN_DEVICE_FUNC\n    Derived& setIdentity(Index rows, Index cols);\n\n    bool isIdentity(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n    bool isDiagonal(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n\n    bool isUpperTriangular(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n    bool isLowerTriangular(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n\n    template<typename OtherDerived>\n    bool isOrthogonal(const MatrixBase<OtherDerived>& other,\n                      const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n    bool isUnitary(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n\n    /** \\returns true if each coefficients of \\c *this and \\a other are all exactly equal.\n      * \\warning When using floating point scalar values you probably should rather use a\n      *          fuzzy comparison such as isApprox()\n      * \\sa isApprox(), operator!= */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC inline bool operator==(const MatrixBase<OtherDerived>& other) const\n    { return cwiseEqual(other).all(); }\n\n    /** \\returns true if at least one pair of coefficients of \\c *this and \\a other are not exactly equal to each other.\n      * \\warning When using floating point scalar values you probably should rather use a\n      *          fuzzy comparison such as isApprox()\n      * \\sa isApprox(), operator== */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC inline bool operator!=(const MatrixBase<OtherDerived>& other) const\n    { return cwiseNotEqual(other).any(); }\n\n    NoAlias<Derived,Eigen::MatrixBase > noalias();\n\n    // TODO forceAlignedAccess is temporarily disabled\n    // Need to find a nicer workaround.\n    inline const Derived& forceAlignedAccess() const { return derived(); }\n    inline Derived& forceAlignedAccess() { return derived(); }\n    template<bool Enable> inline const Derived& forceAlignedAccessIf() const { return derived(); }\n    template<bool Enable> inline Derived& forceAlignedAccessIf() { return derived(); }\n\n    EIGEN_DEVICE_FUNC Scalar trace() const;\n\n    template<int p> EIGEN_DEVICE_FUNC RealScalar lpNorm() const;\n\n    EIGEN_DEVICE_FUNC MatrixBase<Derived>& matrix() { return *this; }\n    EIGEN_DEVICE_FUNC const MatrixBase<Derived>& matrix() const { return *this; }\n\n    /** \\returns an \\link Eigen::ArrayBase Array \\endlink expression of this matrix\n      * \\sa ArrayBase::matrix() */\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ArrayWrapper<Derived> array() { return ArrayWrapper<Derived>(derived()); }\n    /** \\returns a const \\link Eigen::ArrayBase Array \\endlink expression of this matrix\n      * \\sa ArrayBase::matrix() */\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArrayWrapper<const Derived> array() const { return ArrayWrapper<const Derived>(derived()); }\n\n/////////// LU module ///////////\n\n    inline const FullPivLU<PlainObject> fullPivLu() const;\n    inline const PartialPivLU<PlainObject> partialPivLu() const;\n\n    inline const PartialPivLU<PlainObject> lu() const;\n\n    inline const Inverse<Derived> inverse() const;\n\n    template<typename ResultType>\n    inline void computeInverseAndDetWithCheck(\n      ResultType& inverse,\n      typename ResultType::Scalar& determinant,\n      bool& invertible,\n      const RealScalar& absDeterminantThreshold = NumTraits<Scalar>::dummy_precision()\n    ) const;\n    template<typename ResultType>\n    inline void computeInverseWithCheck(\n      ResultType& inverse,\n      bool& invertible,\n      const RealScalar& absDeterminantThreshold = NumTraits<Scalar>::dummy_precision()\n    ) const;\n    Scalar determinant() const;\n\n/////////// Cholesky module ///////////\n\n    inline const LLT<PlainObject>  llt() const;\n    inline const LDLT<PlainObject> ldlt() const;\n\n/////////// QR module ///////////\n\n    inline const HouseholderQR<PlainObject> householderQr() const;\n    inline const ColPivHouseholderQR<PlainObject> colPivHouseholderQr() const;\n    inline const FullPivHouseholderQR<PlainObject> fullPivHouseholderQr() const;\n    inline const CompleteOrthogonalDecomposition<PlainObject> completeOrthogonalDecomposition() const;\n\n/////////// Eigenvalues module ///////////\n\n    inline EigenvaluesReturnType eigenvalues() const;\n    inline RealScalar operatorNorm() const;\n\n/////////// SVD module ///////////\n\n    inline JacobiSVD<PlainObject> jacobiSvd(unsigned int computationOptions = 0) const;\n    inline BDCSVD<PlainObject>    bdcSvd(unsigned int computationOptions = 0) const;\n\n/////////// Geometry module ///////////\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /// \\internal helper struct to form the return type of the cross product\n    template<typename OtherDerived> struct cross_product_return_type {\n      typedef typename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,typename internal::traits<OtherDerived>::Scalar>::ReturnType Scalar;\n      typedef Matrix<Scalar,MatrixBase::RowsAtCompileTime,MatrixBase::ColsAtCompileTime> type;\n    };\n    #endif // EIGEN_PARSED_BY_DOXYGEN\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    inline typename cross_product_return_type<OtherDerived>::type\n#else\n    inline PlainObject\n#endif\n    cross(const MatrixBase<OtherDerived>& other) const;\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    inline PlainObject cross3(const MatrixBase<OtherDerived>& other) const;\n\n    EIGEN_DEVICE_FUNC\n    inline PlainObject unitOrthogonal(void) const;\n\n    EIGEN_DEVICE_FUNC\n    inline Matrix<Scalar,3,1> eulerAngles(Index a0, Index a1, Index a2) const;\n\n    // put this as separate enum value to work around possible GCC 4.3 bug (?)\n    enum { HomogeneousReturnTypeDirection = ColsAtCompileTime==1&&RowsAtCompileTime==1 ? ((internal::traits<Derived>::Flags&RowMajorBit)==RowMajorBit ? Horizontal : Vertical)\n                                          : ColsAtCompileTime==1 ? Vertical : Horizontal };\n    typedef Homogeneous<Derived, HomogeneousReturnTypeDirection> HomogeneousReturnType;\n    EIGEN_DEVICE_FUNC\n    inline HomogeneousReturnType homogeneous() const;\n\n    enum {\n      SizeMinusOne = SizeAtCompileTime==Dynamic ? Dynamic : SizeAtCompileTime-1\n    };\n    typedef Block<const Derived,\n                  internal::traits<Derived>::ColsAtCompileTime==1 ? SizeMinusOne : 1,\n                  internal::traits<Derived>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> ConstStartMinusOne;\n    typedef EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(ConstStartMinusOne,Scalar,quotient) HNormalizedReturnType;\n    EIGEN_DEVICE_FUNC\n    inline const HNormalizedReturnType hnormalized() const;\n\n////////// Householder module ///////////\n\n    void makeHouseholderInPlace(Scalar& tau, RealScalar& beta);\n    template<typename EssentialPart>\n    void makeHouseholder(EssentialPart& essential,\n                         Scalar& tau, RealScalar& beta) const;\n    template<typename EssentialPart>\n    void applyHouseholderOnTheLeft(const EssentialPart& essential,\n                                   const Scalar& tau,\n                                   Scalar* workspace);\n    template<typename EssentialPart>\n    void applyHouseholderOnTheRight(const EssentialPart& essential,\n                                    const Scalar& tau,\n                                    Scalar* workspace);\n\n///////// Jacobi module /////////\n\n    template<typename OtherScalar>\n    void applyOnTheLeft(Index p, Index q, const JacobiRotation<OtherScalar>& j);\n    template<typename OtherScalar>\n    void applyOnTheRight(Index p, Index q, const JacobiRotation<OtherScalar>& j);\n\n///////// SparseCore module /////////\n\n    template<typename OtherDerived>\n    EIGEN_STRONG_INLINE const typename SparseMatrixBase<OtherDerived>::template CwiseProductDenseReturnType<Derived>::Type\n    cwiseProduct(const SparseMatrixBase<OtherDerived> &other) const\n    {\n      return other.cwiseProduct(derived());\n    }\n\n///////// MatrixFunctions module /////////\n\n    typedef typename internal::stem_function<Scalar>::type StemFunction;\n    const MatrixExponentialReturnValue<Derived> exp() const;\n    const MatrixFunctionReturnValue<Derived> matrixFunction(StemFunction f) const;\n    const MatrixFunctionReturnValue<Derived> cosh() const;\n    const MatrixFunctionReturnValue<Derived> sinh() const;\n    const MatrixFunctionReturnValue<Derived> cos() const;\n    const MatrixFunctionReturnValue<Derived> sin() const;\n    const MatrixSquareRootReturnValue<Derived> sqrt() const;\n    const MatrixLogarithmReturnValue<Derived> log() const;\n    const MatrixPowerReturnValue<Derived> pow(const RealScalar& p) const;\n    const MatrixComplexPowerReturnValue<Derived> pow(const std::complex<RealScalar>& p) const;\n\n  protected:\n    EIGEN_DEVICE_FUNC MatrixBase() : Base() {}\n\n  private:\n    EIGEN_DEVICE_FUNC explicit MatrixBase(int);\n    EIGEN_DEVICE_FUNC MatrixBase(int,int);\n    template<typename OtherDerived> EIGEN_DEVICE_FUNC explicit MatrixBase(const MatrixBase<OtherDerived>&);\n  protected:\n    // mixing arrays and matrices is not legal\n    template<typename OtherDerived> Derived& operator+=(const ArrayBase<OtherDerived>& )\n    {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}\n    // mixing arrays and matrices is not legal\n    template<typename OtherDerived> Derived& operator-=(const ArrayBase<OtherDerived>& )\n    {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}\n};\n\n\n/***************************************************************************\n* Implementation of matrix base methods\n***************************************************************************/\n\n/** replaces \\c *this by \\c *this * \\a other.\n  *\n  * \\returns a reference to \\c *this\n  *\n  * Example: \\include MatrixBase_applyOnTheRight.cpp\n  * Output: \\verbinclude MatrixBase_applyOnTheRight.out\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\ninline Derived&\nMatrixBase<Derived>::operator*=(const EigenBase<OtherDerived> &other)\n{\n  other.derived().applyThisOnTheRight(derived());\n  return derived();\n}\n\n/** replaces \\c *this by \\c *this * \\a other. It is equivalent to MatrixBase::operator*=().\n  *\n  * Example: \\include MatrixBase_applyOnTheRight.cpp\n  * Output: \\verbinclude MatrixBase_applyOnTheRight.out\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\ninline void MatrixBase<Derived>::applyOnTheRight(const EigenBase<OtherDerived> &other)\n{\n  other.derived().applyThisOnTheRight(derived());\n}\n\n/** replaces \\c *this by \\a other * \\c *this.\n  *\n  * Example: \\include MatrixBase_applyOnTheLeft.cpp\n  * Output: \\verbinclude MatrixBase_applyOnTheLeft.out\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\ninline void MatrixBase<Derived>::applyOnTheLeft(const EigenBase<OtherDerived> &other)\n{\n  other.derived().applyThisOnTheLeft(derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_MATRIXBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/NestByValue.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_NESTBYVALUE_H\n#define EIGEN_NESTBYVALUE_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate<typename ExpressionType>\nstruct traits<NestByValue<ExpressionType> > : public traits<ExpressionType>\n{};\n}\n\n/** \\class NestByValue\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression which must be nested by value\n  *\n  * \\tparam ExpressionType the type of the object of which we are requiring nesting-by-value\n  *\n  * This class is the return type of MatrixBase::nestByValue()\n  * and most of the time this is the only way it is used.\n  *\n  * \\sa MatrixBase::nestByValue()\n  */\ntemplate<typename ExpressionType> class NestByValue\n  : public internal::dense_xpr_base< NestByValue<ExpressionType> >::type\n{\n  public:\n\n    typedef typename internal::dense_xpr_base<NestByValue>::type Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue)\n\n    EIGEN_DEVICE_FUNC explicit inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {}\n\n    EIGEN_DEVICE_FUNC inline Index rows() const { return m_expression.rows(); }\n    EIGEN_DEVICE_FUNC inline Index cols() const { return m_expression.cols(); }\n    EIGEN_DEVICE_FUNC inline Index outerStride() const { return m_expression.outerStride(); }\n    EIGEN_DEVICE_FUNC inline Index innerStride() const { return m_expression.innerStride(); }\n\n    EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index row, Index col) const\n    {\n      return m_expression.coeff(row, col);\n    }\n\n    EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index col)\n    {\n      return m_expression.const_cast_derived().coeffRef(row, col);\n    }\n\n    EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index index) const\n    {\n      return m_expression.coeff(index);\n    }\n\n    EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index)\n    {\n      return m_expression.const_cast_derived().coeffRef(index);\n    }\n\n    template<int LoadMode>\n    inline const PacketScalar packet(Index row, Index col) const\n    {\n      return m_expression.template packet<LoadMode>(row, col);\n    }\n\n    template<int LoadMode>\n    inline void writePacket(Index row, Index col, const PacketScalar& x)\n    {\n      m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);\n    }\n\n    template<int LoadMode>\n    inline const PacketScalar packet(Index index) const\n    {\n      return m_expression.template packet<LoadMode>(index);\n    }\n\n    template<int LoadMode>\n    inline void writePacket(Index index, const PacketScalar& x)\n    {\n      m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);\n    }\n\n    EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; }\n\n  protected:\n    const ExpressionType m_expression;\n};\n\n/** \\returns an expression of the temporary version of *this.\n  */\ntemplate<typename Derived>\ninline const NestByValue<Derived>\nDenseBase<Derived>::nestByValue() const\n{\n  return NestByValue<Derived>(derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_NESTBYVALUE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/NoAlias.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_NOALIAS_H\n#define EIGEN_NOALIAS_H\n\nnamespace Eigen {\n\n/** \\class NoAlias\n  * \\ingroup Core_Module\n  *\n  * \\brief Pseudo expression providing an operator = assuming no aliasing\n  *\n  * \\tparam ExpressionType the type of the object on which to do the lazy assignment\n  *\n  * This class represents an expression with special assignment operators\n  * assuming no aliasing between the target expression and the source expression.\n  * More precisely it alloas to bypass the EvalBeforeAssignBit flag of the source expression.\n  * It is the return type of MatrixBase::noalias()\n  * and most of the time this is the only way it is used.\n  *\n  * \\sa MatrixBase::noalias()\n  */\ntemplate<typename ExpressionType, template <typename> class StorageBase>\nclass NoAlias\n{\n  public:\n    typedef typename ExpressionType::Scalar Scalar;\n    \n    explicit NoAlias(ExpressionType& expression) : m_expression(expression) {}\n    \n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other)\n    {\n      call_assignment_no_alias(m_expression, other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());\n      return m_expression;\n    }\n    \n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other)\n    {\n      call_assignment_no_alias(m_expression, other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());\n      return m_expression;\n    }\n    \n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other)\n    {\n      call_assignment_no_alias(m_expression, other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());\n      return m_expression;\n    }\n\n    EIGEN_DEVICE_FUNC\n    ExpressionType& expression() const\n    {\n      return m_expression;\n    }\n\n  protected:\n    ExpressionType& m_expression;\n};\n\n/** \\returns a pseudo expression of \\c *this with an operator= assuming\n  * no aliasing between \\c *this and the source expression.\n  *\n  * More precisely, noalias() allows to bypass the EvalBeforeAssignBit flag.\n  * Currently, even though several expressions may alias, only product\n  * expressions have this flag. Therefore, noalias() is only usefull when\n  * the source expression contains a matrix product.\n  *\n  * Here are some examples where noalias is usefull:\n  * \\code\n  * D.noalias()  = A * B;\n  * D.noalias() += A.transpose() * B;\n  * D.noalias() -= 2 * A * B.adjoint();\n  * \\endcode\n  *\n  * On the other hand the following example will lead to a \\b wrong result:\n  * \\code\n  * A.noalias() = A * B;\n  * \\endcode\n  * because the result matrix A is also an operand of the matrix product. Therefore,\n  * there is no alternative than evaluating A * B in a temporary, that is the default\n  * behavior when you write:\n  * \\code\n  * A = A * B;\n  * \\endcode\n  *\n  * \\sa class NoAlias\n  */\ntemplate<typename Derived>\nNoAlias<Derived,MatrixBase> MatrixBase<Derived>::noalias()\n{\n  return NoAlias<Derived, Eigen::MatrixBase >(derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_NOALIAS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/NumTraits.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_NUMTRAITS_H\n#define EIGEN_NUMTRAITS_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n// default implementation of digits10(), based on numeric_limits if specialized,\n// 0 for integer types, and log10(epsilon()) otherwise.\ntemplate< typename T,\n          bool use_numeric_limits = std::numeric_limits<T>::is_specialized,\n          bool is_integer = NumTraits<T>::IsInteger>\nstruct default_digits10_impl\n{\n  static int run() { return std::numeric_limits<T>::digits10; }\n};\n\ntemplate<typename T>\nstruct default_digits10_impl<T,false,false> // Floating point\n{\n  static int run() {\n    using std::log10;\n    using std::ceil;\n    typedef typename NumTraits<T>::Real Real;\n    return int(ceil(-log10(NumTraits<Real>::epsilon())));\n  }\n};\n\ntemplate<typename T>\nstruct default_digits10_impl<T,false,true> // Integer\n{\n  static int run() { return 0; }\n};\n\n} // end namespace internal\n\n/** \\class NumTraits\n  * \\ingroup Core_Module\n  *\n  * \\brief Holds information about the various numeric (i.e. scalar) types allowed by Eigen.\n  *\n  * \\tparam T the numeric type at hand\n  *\n  * This class stores enums, typedefs and static methods giving information about a numeric type.\n  *\n  * The provided data consists of:\n  * \\li A typedef \\c Real, giving the \"real part\" type of \\a T. If \\a T is already real,\n  *     then \\c Real is just a typedef to \\a T. If \\a T is \\c std::complex<U> then \\c Real\n  *     is a typedef to \\a U.\n  * \\li A typedef \\c NonInteger, giving the type that should be used for operations producing non-integral values,\n  *     such as quotients, square roots, etc. If \\a T is a floating-point type, then this typedef just gives\n  *     \\a T again. Note however that many Eigen functions such as internal::sqrt simply refuse to\n  *     take integers. Outside of a few cases, Eigen doesn't do automatic type promotion. Thus, this typedef is\n  *     only intended as a helper for code that needs to explicitly promote types.\n  * \\li A typedef \\c Literal giving the type to use for numeric literals such as \"2\" or \"0.5\". For instance, for \\c std::complex<U>, Literal is defined as \\c U.\n  *     Of course, this type must be fully compatible with \\a T. In doubt, just use \\a T here.\n  * \\li A typedef \\a Nested giving the type to use to nest a value inside of the expression tree. If you don't know what\n  *     this means, just use \\a T here.\n  * \\li An enum value \\a IsComplex. It is equal to 1 if \\a T is a \\c std::complex\n  *     type, and to 0 otherwise.\n  * \\li An enum value \\a IsInteger. It is equal to \\c 1 if \\a T is an integer type such as \\c int,\n  *     and to \\c 0 otherwise.\n  * \\li Enum values ReadCost, AddCost and MulCost representing a rough estimate of the number of CPU cycles needed\n  *     to by move / add / mul instructions respectively, assuming the data is already stored in CPU registers.\n  *     Stay vague here. No need to do architecture-specific stuff.\n  * \\li An enum value \\a IsSigned. It is equal to \\c 1 if \\a T is a signed type and to 0 if \\a T is unsigned.\n  * \\li An enum value \\a RequireInitialization. It is equal to \\c 1 if the constructor of the numeric type \\a T must\n  *     be called, and to 0 if it is safe not to call it. Default is 0 if \\a T is an arithmetic type, and 1 otherwise.\n  * \\li An epsilon() function which, unlike <a href=\"http://en.cppreference.com/w/cpp/types/numeric_limits/epsilon\">std::numeric_limits::epsilon()</a>,\n  *     it returns a \\a Real instead of a \\a T.\n  * \\li A dummy_precision() function returning a weak epsilon value. It is mainly used as a default\n  *     value by the fuzzy comparison operators.\n  * \\li highest() and lowest() functions returning the highest and lowest possible values respectively.\n  * \\li digits10() function returning the number of decimal digits that can be represented without change. This is\n  *     the analogue of <a href=\"http://en.cppreference.com/w/cpp/types/numeric_limits/digits10\">std::numeric_limits<T>::digits10</a>\n  *     which is used as the default implementation if specialized.\n  */\n\ntemplate<typename T> struct GenericNumTraits\n{\n  enum {\n    IsInteger = std::numeric_limits<T>::is_integer,\n    IsSigned = std::numeric_limits<T>::is_signed,\n    IsComplex = 0,\n    RequireInitialization = internal::is_arithmetic<T>::value ? 0 : 1,\n    ReadCost = 1,\n    AddCost = 1,\n    MulCost = 1\n  };\n\n  typedef T Real;\n  typedef typename internal::conditional<\n                     IsInteger,\n                     typename internal::conditional<sizeof(T)<=2, float, double>::type,\n                     T\n                   >::type NonInteger;\n  typedef T Nested;\n  typedef T Literal;\n\n  EIGEN_DEVICE_FUNC\n  static inline Real epsilon()\n  {\n    return numext::numeric_limits<T>::epsilon();\n  }\n\n  EIGEN_DEVICE_FUNC\n  static inline int digits10()\n  {\n    return internal::default_digits10_impl<T>::run();\n  }\n\n  EIGEN_DEVICE_FUNC\n  static inline Real dummy_precision()\n  {\n    // make sure to override this for floating-point types\n    return Real(0);\n  }\n\n\n  EIGEN_DEVICE_FUNC\n  static inline T highest() {\n    return (numext::numeric_limits<T>::max)();\n  }\n\n  EIGEN_DEVICE_FUNC\n  static inline T lowest()  {\n    return IsInteger ? (numext::numeric_limits<T>::min)() : (-(numext::numeric_limits<T>::max)());\n  }\n\n  EIGEN_DEVICE_FUNC\n  static inline T infinity() {\n    return numext::numeric_limits<T>::infinity();\n  }\n\n  EIGEN_DEVICE_FUNC\n  static inline T quiet_NaN() {\n    return numext::numeric_limits<T>::quiet_NaN();\n  }\n};\n\ntemplate<typename T> struct NumTraits : GenericNumTraits<T>\n{};\n\ntemplate<> struct NumTraits<float>\n  : GenericNumTraits<float>\n{\n  EIGEN_DEVICE_FUNC\n  static inline float dummy_precision() { return 1e-5f; }\n};\n\ntemplate<> struct NumTraits<double> : GenericNumTraits<double>\n{\n  EIGEN_DEVICE_FUNC\n  static inline double dummy_precision() { return 1e-12; }\n};\n\ntemplate<> struct NumTraits<long double>\n  : GenericNumTraits<long double>\n{\n  static inline long double dummy_precision() { return 1e-15l; }\n};\n\ntemplate<typename _Real> struct NumTraits<std::complex<_Real> >\n  : GenericNumTraits<std::complex<_Real> >\n{\n  typedef _Real Real;\n  typedef typename NumTraits<_Real>::Literal Literal;\n  enum {\n    IsComplex = 1,\n    RequireInitialization = NumTraits<_Real>::RequireInitialization,\n    ReadCost = 2 * NumTraits<_Real>::ReadCost,\n    AddCost = 2 * NumTraits<Real>::AddCost,\n    MulCost = 4 * NumTraits<Real>::MulCost + 2 * NumTraits<Real>::AddCost\n  };\n\n  EIGEN_DEVICE_FUNC\n  static inline Real epsilon() { return NumTraits<Real>::epsilon(); }\n  EIGEN_DEVICE_FUNC\n  static inline Real dummy_precision() { return NumTraits<Real>::dummy_precision(); }\n  EIGEN_DEVICE_FUNC\n  static inline int digits10() { return NumTraits<Real>::digits10(); }\n};\n\ntemplate<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>\nstruct NumTraits<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> >\n{\n  typedef Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> ArrayType;\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  typedef Array<RealScalar, Rows, Cols, Options, MaxRows, MaxCols> Real;\n  typedef typename NumTraits<Scalar>::NonInteger NonIntegerScalar;\n  typedef Array<NonIntegerScalar, Rows, Cols, Options, MaxRows, MaxCols> NonInteger;\n  typedef ArrayType & Nested;\n  typedef typename NumTraits<Scalar>::Literal Literal;\n\n  enum {\n    IsComplex = NumTraits<Scalar>::IsComplex,\n    IsInteger = NumTraits<Scalar>::IsInteger,\n    IsSigned  = NumTraits<Scalar>::IsSigned,\n    RequireInitialization = 1,\n    ReadCost = ArrayType::SizeAtCompileTime==Dynamic ? HugeCost : ArrayType::SizeAtCompileTime * NumTraits<Scalar>::ReadCost,\n    AddCost  = ArrayType::SizeAtCompileTime==Dynamic ? HugeCost : ArrayType::SizeAtCompileTime * NumTraits<Scalar>::AddCost,\n    MulCost  = ArrayType::SizeAtCompileTime==Dynamic ? HugeCost : ArrayType::SizeAtCompileTime * NumTraits<Scalar>::MulCost\n  };\n\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar epsilon() { return NumTraits<RealScalar>::epsilon(); }\n  EIGEN_DEVICE_FUNC\n  static inline RealScalar dummy_precision() { return NumTraits<RealScalar>::dummy_precision(); }\n\n  static inline int digits10() { return NumTraits<Scalar>::digits10(); }\n};\n\ntemplate<> struct NumTraits<std::string>\n  : GenericNumTraits<std::string>\n{\n  enum {\n    RequireInitialization = 1,\n    ReadCost = HugeCost,\n    AddCost  = HugeCost,\n    MulCost  = HugeCost\n  };\n\n  static inline int digits10() { return 0; }\n\nprivate:\n  static inline std::string epsilon();\n  static inline std::string dummy_precision();\n  static inline std::string lowest();\n  static inline std::string highest();\n  static inline std::string infinity();\n  static inline std::string quiet_NaN();\n};\n\n// Empty specialization for void to allow template specialization based on NumTraits<T>::Real with T==void and SFINAE.\ntemplate<> struct NumTraits<void> {};\n\n} // end namespace Eigen\n\n#endif // EIGEN_NUMTRAITS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/PermutationMatrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2009-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PERMUTATIONMATRIX_H\n#define EIGEN_PERMUTATIONMATRIX_H\n\nnamespace Eigen { \n\nnamespace internal {\n\nenum PermPermProduct_t {PermPermProduct};\n\n} // end namespace internal\n\n/** \\class PermutationBase\n  * \\ingroup Core_Module\n  *\n  * \\brief Base class for permutations\n  *\n  * \\tparam Derived the derived class\n  *\n  * This class is the base class for all expressions representing a permutation matrix,\n  * internally stored as a vector of integers.\n  * The convention followed here is that if \\f$ \\sigma \\f$ is a permutation, the corresponding permutation matrix\n  * \\f$ P_\\sigma \\f$ is such that if \\f$ (e_1,\\ldots,e_p) \\f$ is the canonical basis, we have:\n  *  \\f[ P_\\sigma(e_i) = e_{\\sigma(i)}. \\f]\n  * This convention ensures that for any two permutations \\f$ \\sigma, \\tau \\f$, we have:\n  *  \\f[ P_{\\sigma\\circ\\tau} = P_\\sigma P_\\tau. \\f]\n  *\n  * Permutation matrices are square and invertible.\n  *\n  * Notice that in addition to the member functions and operators listed here, there also are non-member\n  * operator* to multiply any kind of permutation object with any kind of matrix expression (MatrixBase)\n  * on either side.\n  *\n  * \\sa class PermutationMatrix, class PermutationWrapper\n  */\ntemplate<typename Derived>\nclass PermutationBase : public EigenBase<Derived>\n{\n    typedef internal::traits<Derived> Traits;\n    typedef EigenBase<Derived> Base;\n  public:\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    typedef typename Traits::IndicesType IndicesType;\n    enum {\n      Flags = Traits::Flags,\n      RowsAtCompileTime = Traits::RowsAtCompileTime,\n      ColsAtCompileTime = Traits::ColsAtCompileTime,\n      MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = Traits::MaxColsAtCompileTime\n    };\n    typedef typename Traits::StorageIndex StorageIndex;\n    typedef Matrix<StorageIndex,RowsAtCompileTime,ColsAtCompileTime,0,MaxRowsAtCompileTime,MaxColsAtCompileTime>\n            DenseMatrixType;\n    typedef PermutationMatrix<IndicesType::SizeAtCompileTime,IndicesType::MaxSizeAtCompileTime,StorageIndex>\n            PlainPermutationType;\n    typedef PlainPermutationType PlainObject;\n    using Base::derived;\n    typedef Inverse<Derived> InverseReturnType;\n    typedef void Scalar;\n    #endif\n\n    /** Copies the other permutation into *this */\n    template<typename OtherDerived>\n    Derived& operator=(const PermutationBase<OtherDerived>& other)\n    {\n      indices() = other.indices();\n      return derived();\n    }\n\n    /** Assignment from the Transpositions \\a tr */\n    template<typename OtherDerived>\n    Derived& operator=(const TranspositionsBase<OtherDerived>& tr)\n    {\n      setIdentity(tr.size());\n      for(Index k=size()-1; k>=0; --k)\n        applyTranspositionOnTheRight(k,tr.coeff(k));\n      return derived();\n    }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** This is a special case of the templated operator=. Its purpose is to\n      * prevent a default operator= from hiding the templated operator=.\n      */\n    Derived& operator=(const PermutationBase& other)\n    {\n      indices() = other.indices();\n      return derived();\n    }\n    #endif\n\n    /** \\returns the number of rows */\n    inline Index rows() const { return Index(indices().size()); }\n\n    /** \\returns the number of columns */\n    inline Index cols() const { return Index(indices().size()); }\n\n    /** \\returns the size of a side of the respective square matrix, i.e., the number of indices */\n    inline Index size() const { return Index(indices().size()); }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename DenseDerived>\n    void evalTo(MatrixBase<DenseDerived>& other) const\n    {\n      other.setZero();\n      for (Index i=0; i<rows(); ++i)\n        other.coeffRef(indices().coeff(i),i) = typename DenseDerived::Scalar(1);\n    }\n    #endif\n\n    /** \\returns a Matrix object initialized from this permutation matrix. Notice that it\n      * is inefficient to return this Matrix object by value. For efficiency, favor using\n      * the Matrix constructor taking EigenBase objects.\n      */\n    DenseMatrixType toDenseMatrix() const\n    {\n      return derived();\n    }\n\n    /** const version of indices(). */\n    const IndicesType& indices() const { return derived().indices(); }\n    /** \\returns a reference to the stored array representing the permutation. */\n    IndicesType& indices() { return derived().indices(); }\n\n    /** Resizes to given size.\n      */\n    inline void resize(Index newSize)\n    {\n      indices().resize(newSize);\n    }\n\n    /** Sets *this to be the identity permutation matrix */\n    void setIdentity()\n    {\n      StorageIndex n = StorageIndex(size());\n      for(StorageIndex i = 0; i < n; ++i)\n        indices().coeffRef(i) = i;\n    }\n\n    /** Sets *this to be the identity permutation matrix of given size.\n      */\n    void setIdentity(Index newSize)\n    {\n      resize(newSize);\n      setIdentity();\n    }\n\n    /** Multiplies *this by the transposition \\f$(ij)\\f$ on the left.\n      *\n      * \\returns a reference to *this.\n      *\n      * \\warning This is much slower than applyTranspositionOnTheRight(Index,Index):\n      * this has linear complexity and requires a lot of branching.\n      *\n      * \\sa applyTranspositionOnTheRight(Index,Index)\n      */\n    Derived& applyTranspositionOnTheLeft(Index i, Index j)\n    {\n      eigen_assert(i>=0 && j>=0 && i<size() && j<size());\n      for(Index k = 0; k < size(); ++k)\n      {\n        if(indices().coeff(k) == i) indices().coeffRef(k) = StorageIndex(j);\n        else if(indices().coeff(k) == j) indices().coeffRef(k) = StorageIndex(i);\n      }\n      return derived();\n    }\n\n    /** Multiplies *this by the transposition \\f$(ij)\\f$ on the right.\n      *\n      * \\returns a reference to *this.\n      *\n      * This is a fast operation, it only consists in swapping two indices.\n      *\n      * \\sa applyTranspositionOnTheLeft(Index,Index)\n      */\n    Derived& applyTranspositionOnTheRight(Index i, Index j)\n    {\n      eigen_assert(i>=0 && j>=0 && i<size() && j<size());\n      std::swap(indices().coeffRef(i), indices().coeffRef(j));\n      return derived();\n    }\n\n    /** \\returns the inverse permutation matrix.\n      *\n      * \\note \\blank \\note_try_to_help_rvo\n      */\n    inline InverseReturnType inverse() const\n    { return InverseReturnType(derived()); }\n    /** \\returns the tranpose permutation matrix.\n      *\n      * \\note \\blank \\note_try_to_help_rvo\n      */\n    inline InverseReturnType transpose() const\n    { return InverseReturnType(derived()); }\n\n    /**** multiplication helpers to hopefully get RVO ****/\n\n  \n#ifndef EIGEN_PARSED_BY_DOXYGEN\n  protected:\n    template<typename OtherDerived>\n    void assignTranspose(const PermutationBase<OtherDerived>& other)\n    {\n      for (Index i=0; i<rows();++i) indices().coeffRef(other.indices().coeff(i)) = i;\n    }\n    template<typename Lhs,typename Rhs>\n    void assignProduct(const Lhs& lhs, const Rhs& rhs)\n    {\n      eigen_assert(lhs.cols() == rhs.rows());\n      for (Index i=0; i<rows();++i) indices().coeffRef(i) = lhs.indices().coeff(rhs.indices().coeff(i));\n    }\n#endif\n\n  public:\n\n    /** \\returns the product permutation matrix.\n      *\n      * \\note \\blank \\note_try_to_help_rvo\n      */\n    template<typename Other>\n    inline PlainPermutationType operator*(const PermutationBase<Other>& other) const\n    { return PlainPermutationType(internal::PermPermProduct, derived(), other.derived()); }\n\n    /** \\returns the product of a permutation with another inverse permutation.\n      *\n      * \\note \\blank \\note_try_to_help_rvo\n      */\n    template<typename Other>\n    inline PlainPermutationType operator*(const InverseImpl<Other,PermutationStorage>& other) const\n    { return PlainPermutationType(internal::PermPermProduct, *this, other.eval()); }\n\n    /** \\returns the product of an inverse permutation with another permutation.\n      *\n      * \\note \\blank \\note_try_to_help_rvo\n      */\n    template<typename Other> friend\n    inline PlainPermutationType operator*(const InverseImpl<Other, PermutationStorage>& other, const PermutationBase& perm)\n    { return PlainPermutationType(internal::PermPermProduct, other.eval(), perm); }\n    \n    /** \\returns the determinant of the permutation matrix, which is either 1 or -1 depending on the parity of the permutation.\n      *\n      * This function is O(\\c n) procedure allocating a buffer of \\c n booleans.\n      */\n    Index determinant() const\n    {\n      Index res = 1;\n      Index n = size();\n      Matrix<bool,RowsAtCompileTime,1,0,MaxRowsAtCompileTime> mask(n);\n      mask.fill(false);\n      Index r = 0;\n      while(r < n)\n      {\n        // search for the next seed\n        while(r<n && mask[r]) r++;\n        if(r>=n)\n          break;\n        // we got one, let's follow it until we are back to the seed\n        Index k0 = r++;\n        mask.coeffRef(k0) = true;\n        for(Index k=indices().coeff(k0); k!=k0; k=indices().coeff(k))\n        {\n          mask.coeffRef(k) = true;\n          res = -res;\n        }\n      }\n      return res;\n    }\n\n  protected:\n\n};\n\nnamespace internal {\ntemplate<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex>\nstruct traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex> >\n : traits<Matrix<_StorageIndex,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >\n{\n  typedef PermutationStorage StorageKind;\n  typedef Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;\n  typedef _StorageIndex StorageIndex;\n  typedef void Scalar;\n};\n}\n\n/** \\class PermutationMatrix\n  * \\ingroup Core_Module\n  *\n  * \\brief Permutation matrix\n  *\n  * \\tparam SizeAtCompileTime the number of rows/cols, or Dynamic\n  * \\tparam MaxSizeAtCompileTime the maximum number of rows/cols, or Dynamic. This optional parameter defaults to SizeAtCompileTime. Most of the time, you should not have to specify it.\n  * \\tparam _StorageIndex the integer type of the indices\n  *\n  * This class represents a permutation matrix, internally stored as a vector of integers.\n  *\n  * \\sa class PermutationBase, class PermutationWrapper, class DiagonalMatrix\n  */\ntemplate<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex>\nclass PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex> >\n{\n    typedef PermutationBase<PermutationMatrix> Base;\n    typedef internal::traits<PermutationMatrix> Traits;\n  public:\n\n    typedef const PermutationMatrix& Nested;\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    typedef typename Traits::IndicesType IndicesType;\n    typedef typename Traits::StorageIndex StorageIndex;\n    #endif\n\n    inline PermutationMatrix()\n    {}\n\n    /** Constructs an uninitialized permutation matrix of given size.\n      */\n    explicit inline PermutationMatrix(Index size) : m_indices(size)\n    {\n      eigen_internal_assert(size <= NumTraits<StorageIndex>::highest());\n    }\n\n    /** Copy constructor. */\n    template<typename OtherDerived>\n    inline PermutationMatrix(const PermutationBase<OtherDerived>& other)\n      : m_indices(other.indices()) {}\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** Standard copy constructor. Defined only to prevent a default copy constructor\n      * from hiding the other templated constructor */\n    inline PermutationMatrix(const PermutationMatrix& other) : m_indices(other.indices()) {}\n    #endif\n\n    /** Generic constructor from expression of the indices. The indices\n      * array has the meaning that the permutations sends each integer i to indices[i].\n      *\n      * \\warning It is your responsibility to check that the indices array that you passes actually\n      * describes a permutation, i.e., each value between 0 and n-1 occurs exactly once, where n is the\n      * array's size.\n      */\n    template<typename Other>\n    explicit inline PermutationMatrix(const MatrixBase<Other>& indices) : m_indices(indices)\n    {}\n\n    /** Convert the Transpositions \\a tr to a permutation matrix */\n    template<typename Other>\n    explicit PermutationMatrix(const TranspositionsBase<Other>& tr)\n      : m_indices(tr.size())\n    {\n      *this = tr;\n    }\n\n    /** Copies the other permutation into *this */\n    template<typename Other>\n    PermutationMatrix& operator=(const PermutationBase<Other>& other)\n    {\n      m_indices = other.indices();\n      return *this;\n    }\n\n    /** Assignment from the Transpositions \\a tr */\n    template<typename Other>\n    PermutationMatrix& operator=(const TranspositionsBase<Other>& tr)\n    {\n      return Base::operator=(tr.derived());\n    }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** This is a special case of the templated operator=. Its purpose is to\n      * prevent a default operator= from hiding the templated operator=.\n      */\n    PermutationMatrix& operator=(const PermutationMatrix& other)\n    {\n      m_indices = other.m_indices;\n      return *this;\n    }\n    #endif\n\n    /** const version of indices(). */\n    const IndicesType& indices() const { return m_indices; }\n    /** \\returns a reference to the stored array representing the permutation. */\n    IndicesType& indices() { return m_indices; }\n\n\n    /**** multiplication helpers to hopefully get RVO ****/\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename Other>\n    PermutationMatrix(const InverseImpl<Other,PermutationStorage>& other)\n      : m_indices(other.derived().nestedExpression().size())\n    {\n      eigen_internal_assert(m_indices.size() <= NumTraits<StorageIndex>::highest());\n      StorageIndex end = StorageIndex(m_indices.size());\n      for (StorageIndex i=0; i<end;++i)\n        m_indices.coeffRef(other.derived().nestedExpression().indices().coeff(i)) = i;\n    }\n    template<typename Lhs,typename Rhs>\n    PermutationMatrix(internal::PermPermProduct_t, const Lhs& lhs, const Rhs& rhs)\n      : m_indices(lhs.indices().size())\n    {\n      Base::assignProduct(lhs,rhs);\n    }\n#endif\n\n  protected:\n\n    IndicesType m_indices;\n};\n\n\nnamespace internal {\ntemplate<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex, int _PacketAccess>\nstruct traits<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex>,_PacketAccess> >\n : traits<Matrix<_StorageIndex,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >\n{\n  typedef PermutationStorage StorageKind;\n  typedef Map<const Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1>, _PacketAccess> IndicesType;\n  typedef _StorageIndex StorageIndex;\n  typedef void Scalar;\n};\n}\n\ntemplate<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex, int _PacketAccess>\nclass Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex>,_PacketAccess>\n  : public PermutationBase<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex>,_PacketAccess> >\n{\n    typedef PermutationBase<Map> Base;\n    typedef internal::traits<Map> Traits;\n  public:\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    typedef typename Traits::IndicesType IndicesType;\n    typedef typename IndicesType::Scalar StorageIndex;\n    #endif\n\n    inline Map(const StorageIndex* indicesPtr)\n      : m_indices(indicesPtr)\n    {}\n\n    inline Map(const StorageIndex* indicesPtr, Index size)\n      : m_indices(indicesPtr,size)\n    {}\n\n    /** Copies the other permutation into *this */\n    template<typename Other>\n    Map& operator=(const PermutationBase<Other>& other)\n    { return Base::operator=(other.derived()); }\n\n    /** Assignment from the Transpositions \\a tr */\n    template<typename Other>\n    Map& operator=(const TranspositionsBase<Other>& tr)\n    { return Base::operator=(tr.derived()); }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** This is a special case of the templated operator=. Its purpose is to\n      * prevent a default operator= from hiding the templated operator=.\n      */\n    Map& operator=(const Map& other)\n    {\n      m_indices = other.m_indices;\n      return *this;\n    }\n    #endif\n\n    /** const version of indices(). */\n    const IndicesType& indices() const { return m_indices; }\n    /** \\returns a reference to the stored array representing the permutation. */\n    IndicesType& indices() { return m_indices; }\n\n  protected:\n\n    IndicesType m_indices;\n};\n\ntemplate<typename _IndicesType> class TranspositionsWrapper;\nnamespace internal {\ntemplate<typename _IndicesType>\nstruct traits<PermutationWrapper<_IndicesType> >\n{\n  typedef PermutationStorage StorageKind;\n  typedef void Scalar;\n  typedef typename _IndicesType::Scalar StorageIndex;\n  typedef _IndicesType IndicesType;\n  enum {\n    RowsAtCompileTime = _IndicesType::SizeAtCompileTime,\n    ColsAtCompileTime = _IndicesType::SizeAtCompileTime,\n    MaxRowsAtCompileTime = IndicesType::MaxSizeAtCompileTime,\n    MaxColsAtCompileTime = IndicesType::MaxSizeAtCompileTime,\n    Flags = 0\n  };\n};\n}\n\n/** \\class PermutationWrapper\n  * \\ingroup Core_Module\n  *\n  * \\brief Class to view a vector of integers as a permutation matrix\n  *\n  * \\tparam _IndicesType the type of the vector of integer (can be any compatible expression)\n  *\n  * This class allows to view any vector expression of integers as a permutation matrix.\n  *\n  * \\sa class PermutationBase, class PermutationMatrix\n  */\ntemplate<typename _IndicesType>\nclass PermutationWrapper : public PermutationBase<PermutationWrapper<_IndicesType> >\n{\n    typedef PermutationBase<PermutationWrapper> Base;\n    typedef internal::traits<PermutationWrapper> Traits;\n  public:\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    typedef typename Traits::IndicesType IndicesType;\n    #endif\n\n    inline PermutationWrapper(const IndicesType& indices)\n      : m_indices(indices)\n    {}\n\n    /** const version of indices(). */\n    const typename internal::remove_all<typename IndicesType::Nested>::type&\n    indices() const { return m_indices; }\n\n  protected:\n\n    typename IndicesType::Nested m_indices;\n};\n\n\n/** \\returns the matrix with the permutation applied to the columns.\n  */\ntemplate<typename MatrixDerived, typename PermutationDerived>\nEIGEN_DEVICE_FUNC\nconst Product<MatrixDerived, PermutationDerived, AliasFreeProduct>\noperator*(const MatrixBase<MatrixDerived> &matrix,\n          const PermutationBase<PermutationDerived>& permutation)\n{\n  return Product<MatrixDerived, PermutationDerived, AliasFreeProduct>\n            (matrix.derived(), permutation.derived());\n}\n\n/** \\returns the matrix with the permutation applied to the rows.\n  */\ntemplate<typename PermutationDerived, typename MatrixDerived>\nEIGEN_DEVICE_FUNC\nconst Product<PermutationDerived, MatrixDerived, AliasFreeProduct>\noperator*(const PermutationBase<PermutationDerived> &permutation,\n          const MatrixBase<MatrixDerived>& matrix)\n{\n  return Product<PermutationDerived, MatrixDerived, AliasFreeProduct>\n            (permutation.derived(), matrix.derived());\n}\n\n\ntemplate<typename PermutationType>\nclass InverseImpl<PermutationType, PermutationStorage>\n  : public EigenBase<Inverse<PermutationType> >\n{\n    typedef typename PermutationType::PlainPermutationType PlainPermutationType;\n    typedef internal::traits<PermutationType> PermTraits;\n  protected:\n    InverseImpl() {}\n  public:\n    typedef Inverse<PermutationType> InverseType;\n    using EigenBase<Inverse<PermutationType> >::derived;\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    typedef typename PermutationType::DenseMatrixType DenseMatrixType;\n    enum {\n      RowsAtCompileTime = PermTraits::RowsAtCompileTime,\n      ColsAtCompileTime = PermTraits::ColsAtCompileTime,\n      MaxRowsAtCompileTime = PermTraits::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = PermTraits::MaxColsAtCompileTime\n    };\n    #endif\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename DenseDerived>\n    void evalTo(MatrixBase<DenseDerived>& other) const\n    {\n      other.setZero();\n      for (Index i=0; i<derived().rows();++i)\n        other.coeffRef(i, derived().nestedExpression().indices().coeff(i)) = typename DenseDerived::Scalar(1);\n    }\n    #endif\n\n    /** \\return the equivalent permutation matrix */\n    PlainPermutationType eval() const { return derived(); }\n\n    DenseMatrixType toDenseMatrix() const { return derived(); }\n\n    /** \\returns the matrix with the inverse permutation applied to the columns.\n      */\n    template<typename OtherDerived> friend\n    const Product<OtherDerived, InverseType, AliasFreeProduct>\n    operator*(const MatrixBase<OtherDerived>& matrix, const InverseType& trPerm)\n    {\n      return Product<OtherDerived, InverseType, AliasFreeProduct>(matrix.derived(), trPerm.derived());\n    }\n\n    /** \\returns the matrix with the inverse permutation applied to the rows.\n      */\n    template<typename OtherDerived>\n    const Product<InverseType, OtherDerived, AliasFreeProduct>\n    operator*(const MatrixBase<OtherDerived>& matrix) const\n    {\n      return Product<InverseType, OtherDerived, AliasFreeProduct>(derived(), matrix.derived());\n    }\n};\n\ntemplate<typename Derived>\nconst PermutationWrapper<const Derived> MatrixBase<Derived>::asPermutation() const\n{\n  return derived();\n}\n\nnamespace internal {\n\ntemplate<> struct AssignmentKind<DenseShape,PermutationShape> { typedef EigenBase2EigenBase Kind; };\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_PERMUTATIONMATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/PlainObjectBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_DENSESTORAGEBASE_H\n#define EIGEN_DENSESTORAGEBASE_H\n\n#if defined(EIGEN_INITIALIZE_MATRICES_BY_ZERO)\n# define EIGEN_INITIALIZE_COEFFS\n# define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED for(int i=0;i<base().size();++i) coeffRef(i)=Scalar(0);\n#elif defined(EIGEN_INITIALIZE_MATRICES_BY_NAN)\n# define EIGEN_INITIALIZE_COEFFS\n# define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED for(int i=0;i<base().size();++i) coeffRef(i)=std::numeric_limits<Scalar>::quiet_NaN();\n#else\n# undef EIGEN_INITIALIZE_COEFFS\n# define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED\n#endif\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<int MaxSizeAtCompileTime> struct check_rows_cols_for_overflow {\n  template<typename Index>\n  EIGEN_DEVICE_FUNC\n  static EIGEN_ALWAYS_INLINE void run(Index, Index)\n  {\n  }\n};\n\ntemplate<> struct check_rows_cols_for_overflow<Dynamic> {\n  template<typename Index>\n  EIGEN_DEVICE_FUNC\n  static EIGEN_ALWAYS_INLINE void run(Index rows, Index cols)\n  {\n    // http://hg.mozilla.org/mozilla-central/file/6c8a909977d3/xpcom/ds/CheckedInt.h#l242\n    // we assume Index is signed\n    Index max_index = (std::size_t(1) << (8 * sizeof(Index) - 1)) - 1; // assume Index is signed\n    bool error = (rows == 0 || cols == 0) ? false\n               : (rows > max_index / cols);\n    if (error)\n      throw_std_bad_alloc();\n  }\n};\n\ntemplate <typename Derived,\n          typename OtherDerived = Derived,\n          bool IsVector = bool(Derived::IsVectorAtCompileTime) && bool(OtherDerived::IsVectorAtCompileTime)>\nstruct conservative_resize_like_impl;\n\ntemplate<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> struct matrix_swap_impl;\n\n} // end namespace internal\n\n#ifdef EIGEN_PARSED_BY_DOXYGEN\nnamespace doxygen {\n\n// This is a workaround to doxygen not being able to understand the inheritance logic\n// when it is hidden by the dense_xpr_base helper struct.\n// Moreover, doxygen fails to include members that are not documented in the declaration body of\n// MatrixBase if we inherits MatrixBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >,\n// this is why we simply inherits MatrixBase, though this does not make sense.\n\n/** This class is just a workaround for Doxygen and it does not not actually exist. */\ntemplate<typename Derived> struct dense_xpr_base_dispatcher;\n/** This class is just a workaround for Doxygen and it does not not actually exist. */\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>\nstruct dense_xpr_base_dispatcher<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >\n    : public MatrixBase {};\n/** This class is just a workaround for Doxygen and it does not not actually exist. */\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>\nstruct dense_xpr_base_dispatcher<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >\n    : public ArrayBase {};\n\n} // namespace doxygen\n\n/** \\class PlainObjectBase\n  * \\ingroup Core_Module\n  * \\brief %Dense storage base class for matrices and arrays.\n  *\n  * This class can be extended with the help of the plugin mechanism described on the page\n  * \\ref TopicCustomizing_Plugins by defining the preprocessor symbol \\c EIGEN_PLAINOBJECTBASE_PLUGIN.\n  *\n  * \\tparam Derived is the derived type, e.g., a Matrix or Array\n  *\n  * \\sa \\ref TopicClassHierarchy\n  */\ntemplate<typename Derived>\nclass PlainObjectBase : public doxygen::dense_xpr_base_dispatcher<Derived>\n#else\ntemplate<typename Derived>\nclass PlainObjectBase : public internal::dense_xpr_base<Derived>::type\n#endif\n{\n  public:\n    enum { Options = internal::traits<Derived>::Options };\n    typedef typename internal::dense_xpr_base<Derived>::type Base;\n\n    typedef typename internal::traits<Derived>::StorageKind StorageKind;\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    \n    typedef typename internal::packet_traits<Scalar>::type PacketScalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    typedef Derived DenseType;\n\n    using Base::RowsAtCompileTime;\n    using Base::ColsAtCompileTime;\n    using Base::SizeAtCompileTime;\n    using Base::MaxRowsAtCompileTime;\n    using Base::MaxColsAtCompileTime;\n    using Base::MaxSizeAtCompileTime;\n    using Base::IsVectorAtCompileTime;\n    using Base::Flags;\n\n    template<typename PlainObjectType, int MapOptions, typename StrideType> friend class Eigen::Map;\n    friend  class Eigen::Map<Derived, Unaligned>;\n    typedef Eigen::Map<Derived, Unaligned>  MapType;\n    friend  class Eigen::Map<const Derived, Unaligned>;\n    typedef const Eigen::Map<const Derived, Unaligned> ConstMapType;\n#if EIGEN_MAX_ALIGN_BYTES>0\n    // for EIGEN_MAX_ALIGN_BYTES==0, AlignedMax==Unaligned, and many compilers generate warnings for friend-ing a class twice.\n    friend  class Eigen::Map<Derived, AlignedMax>;\n    friend  class Eigen::Map<const Derived, AlignedMax>;\n#endif\n    typedef Eigen::Map<Derived, AlignedMax> AlignedMapType;\n    typedef const Eigen::Map<const Derived, AlignedMax> ConstAlignedMapType;\n    template<typename StrideType> struct StridedMapType { typedef Eigen::Map<Derived, Unaligned, StrideType> type; };\n    template<typename StrideType> struct StridedConstMapType { typedef Eigen::Map<const Derived, Unaligned, StrideType> type; };\n    template<typename StrideType> struct StridedAlignedMapType { typedef Eigen::Map<Derived, AlignedMax, StrideType> type; };\n    template<typename StrideType> struct StridedConstAlignedMapType { typedef Eigen::Map<const Derived, AlignedMax, StrideType> type; };\n\n  protected:\n    DenseStorage<Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options> m_storage;\n\n  public:\n    enum { NeedsToAlign = (SizeAtCompileTime != Dynamic) && (internal::traits<Derived>::Alignment>0) };\n    EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)\n\n    EIGEN_DEVICE_FUNC\n    Base& base() { return *static_cast<Base*>(this); }\n    EIGEN_DEVICE_FUNC\n    const Base& base() const { return *static_cast<const Base*>(this); }\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Index rows() const { return m_storage.rows(); }\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Index cols() const { return m_storage.cols(); }\n\n    /** This is an overloaded version of DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index,Index) const\n      * provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.\n      *\n      * See DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index) const for details. */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE const Scalar& coeff(Index rowId, Index colId) const\n    {\n      if(Flags & RowMajorBit)\n        return m_storage.data()[colId + rowId * m_storage.cols()];\n      else // column-major\n        return m_storage.data()[rowId + colId * m_storage.rows()];\n    }\n\n    /** This is an overloaded version of DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index) const\n      * provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.\n      *\n      * See DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index) const for details. */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE const Scalar& coeff(Index index) const\n    {\n      return m_storage.data()[index];\n    }\n\n    /** This is an overloaded version of DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index,Index) const\n      * provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.\n      *\n      * See DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index,Index) const for details. */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar& coeffRef(Index rowId, Index colId)\n    {\n      if(Flags & RowMajorBit)\n        return m_storage.data()[colId + rowId * m_storage.cols()];\n      else // column-major\n        return m_storage.data()[rowId + colId * m_storage.rows()];\n    }\n\n    /** This is an overloaded version of DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index) const\n      * provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.\n      *\n      * See DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index) const for details. */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Scalar& coeffRef(Index index)\n    {\n      return m_storage.data()[index];\n    }\n\n    /** This is the const version of coeffRef(Index,Index) which is thus synonym of coeff(Index,Index).\n      * It is provided for convenience. */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE const Scalar& coeffRef(Index rowId, Index colId) const\n    {\n      if(Flags & RowMajorBit)\n        return m_storage.data()[colId + rowId * m_storage.cols()];\n      else // column-major\n        return m_storage.data()[rowId + colId * m_storage.rows()];\n    }\n\n    /** This is the const version of coeffRef(Index) which is thus synonym of coeff(Index).\n      * It is provided for convenience. */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE const Scalar& coeffRef(Index index) const\n    {\n      return m_storage.data()[index];\n    }\n\n    /** \\internal */\n    template<int LoadMode>\n    EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId) const\n    {\n      return internal::ploadt<PacketScalar, LoadMode>\n               (m_storage.data() + (Flags & RowMajorBit\n                                   ? colId + rowId * m_storage.cols()\n                                   : rowId + colId * m_storage.rows()));\n    }\n\n    /** \\internal */\n    template<int LoadMode>\n    EIGEN_STRONG_INLINE PacketScalar packet(Index index) const\n    {\n      return internal::ploadt<PacketScalar, LoadMode>(m_storage.data() + index);\n    }\n\n    /** \\internal */\n    template<int StoreMode>\n    EIGEN_STRONG_INLINE void writePacket(Index rowId, Index colId, const PacketScalar& val)\n    {\n      internal::pstoret<Scalar, PacketScalar, StoreMode>\n              (m_storage.data() + (Flags & RowMajorBit\n                                   ? colId + rowId * m_storage.cols()\n                                   : rowId + colId * m_storage.rows()), val);\n    }\n\n    /** \\internal */\n    template<int StoreMode>\n    EIGEN_STRONG_INLINE void writePacket(Index index, const PacketScalar& val)\n    {\n      internal::pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, val);\n    }\n\n    /** \\returns a const pointer to the data array of this matrix */\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar *data() const\n    { return m_storage.data(); }\n\n    /** \\returns a pointer to the data array of this matrix */\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar *data()\n    { return m_storage.data(); }\n\n    /** Resizes \\c *this to a \\a rows x \\a cols matrix.\n      *\n      * This method is intended for dynamic-size matrices, although it is legal to call it on any\n      * matrix as long as fixed dimensions are left unchanged. If you only want to change the number\n      * of rows and/or of columns, you can use resize(NoChange_t, Index), resize(Index, NoChange_t).\n      *\n      * If the current number of coefficients of \\c *this exactly matches the\n      * product \\a rows * \\a cols, then no memory allocation is performed and\n      * the current values are left unchanged. In all other cases, including\n      * shrinking, the data is reallocated and all previous values are lost.\n      *\n      * Example: \\include Matrix_resize_int_int.cpp\n      * Output: \\verbinclude Matrix_resize_int_int.out\n      *\n      * \\sa resize(Index) for vectors, resize(NoChange_t, Index), resize(Index, NoChange_t)\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void resize(Index rows, Index cols)\n    {\n      eigen_assert(   EIGEN_IMPLIES(RowsAtCompileTime!=Dynamic,rows==RowsAtCompileTime)\n                   && EIGEN_IMPLIES(ColsAtCompileTime!=Dynamic,cols==ColsAtCompileTime)\n                   && EIGEN_IMPLIES(RowsAtCompileTime==Dynamic && MaxRowsAtCompileTime!=Dynamic,rows<=MaxRowsAtCompileTime)\n                   && EIGEN_IMPLIES(ColsAtCompileTime==Dynamic && MaxColsAtCompileTime!=Dynamic,cols<=MaxColsAtCompileTime)\n                   && rows>=0 && cols>=0 && \"Invalid sizes when resizing a matrix or array.\");\n      internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime>::run(rows, cols);\n      #ifdef EIGEN_INITIALIZE_COEFFS\n        Index size = rows*cols;\n        bool size_changed = size != this->size();\n        m_storage.resize(size, rows, cols);\n        if(size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED\n      #else\n        m_storage.resize(rows*cols, rows, cols);\n      #endif\n    }\n\n    /** Resizes \\c *this to a vector of length \\a size\n      *\n      * \\only_for_vectors. This method does not work for\n      * partially dynamic matrices when the static dimension is anything other\n      * than 1. For example it will not work with Matrix<double, 2, Dynamic>.\n      *\n      * Example: \\include Matrix_resize_int.cpp\n      * Output: \\verbinclude Matrix_resize_int.out\n      *\n      * \\sa resize(Index,Index), resize(NoChange_t, Index), resize(Index, NoChange_t)\n      */\n    EIGEN_DEVICE_FUNC\n    inline void resize(Index size)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(PlainObjectBase)\n      eigen_assert(((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime==Dynamic || size<=MaxSizeAtCompileTime)) || SizeAtCompileTime == size) && size>=0);\n      #ifdef EIGEN_INITIALIZE_COEFFS\n        bool size_changed = size != this->size();\n      #endif\n      if(RowsAtCompileTime == 1)\n        m_storage.resize(size, 1, size);\n      else\n        m_storage.resize(size, size, 1);\n      #ifdef EIGEN_INITIALIZE_COEFFS\n        if(size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED\n      #endif\n    }\n\n    /** Resizes the matrix, changing only the number of columns. For the parameter of type NoChange_t, just pass the special value \\c NoChange\n      * as in the example below.\n      *\n      * Example: \\include Matrix_resize_NoChange_int.cpp\n      * Output: \\verbinclude Matrix_resize_NoChange_int.out\n      *\n      * \\sa resize(Index,Index)\n      */\n    EIGEN_DEVICE_FUNC\n    inline void resize(NoChange_t, Index cols)\n    {\n      resize(rows(), cols);\n    }\n\n    /** Resizes the matrix, changing only the number of rows. For the parameter of type NoChange_t, just pass the special value \\c NoChange\n      * as in the example below.\n      *\n      * Example: \\include Matrix_resize_int_NoChange.cpp\n      * Output: \\verbinclude Matrix_resize_int_NoChange.out\n      *\n      * \\sa resize(Index,Index)\n      */\n    EIGEN_DEVICE_FUNC\n    inline void resize(Index rows, NoChange_t)\n    {\n      resize(rows, cols());\n    }\n\n    /** Resizes \\c *this to have the same dimensions as \\a other.\n      * Takes care of doing all the checking that's needed.\n      *\n      * Note that copying a row-vector into a vector (and conversely) is allowed.\n      * The resizing, if any, is then done in the appropriate way so that row-vectors\n      * remain row-vectors and vectors remain vectors.\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC \n    EIGEN_STRONG_INLINE void resizeLike(const EigenBase<OtherDerived>& _other)\n    {\n      const OtherDerived& other = _other.derived();\n      internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime>::run(other.rows(), other.cols());\n      const Index othersize = other.rows()*other.cols();\n      if(RowsAtCompileTime == 1)\n      {\n        eigen_assert(other.rows() == 1 || other.cols() == 1);\n        resize(1, othersize);\n      }\n      else if(ColsAtCompileTime == 1)\n      {\n        eigen_assert(other.rows() == 1 || other.cols() == 1);\n        resize(othersize, 1);\n      }\n      else resize(other.rows(), other.cols());\n    }\n\n    /** Resizes the matrix to \\a rows x \\a cols while leaving old values untouched.\n      *\n      * The method is intended for matrices of dynamic size. If you only want to change the number\n      * of rows and/or of columns, you can use conservativeResize(NoChange_t, Index) or\n      * conservativeResize(Index, NoChange_t).\n      *\n      * Matrices are resized relative to the top-left element. In case values need to be \n      * appended to the matrix they will be uninitialized.\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void conservativeResize(Index rows, Index cols)\n    {\n      internal::conservative_resize_like_impl<Derived>::run(*this, rows, cols);\n    }\n\n    /** Resizes the matrix to \\a rows x \\a cols while leaving old values untouched.\n      *\n      * As opposed to conservativeResize(Index rows, Index cols), this version leaves\n      * the number of columns unchanged.\n      *\n      * In case the matrix is growing, new rows will be uninitialized.\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void conservativeResize(Index rows, NoChange_t)\n    {\n      // Note: see the comment in conservativeResize(Index,Index)\n      conservativeResize(rows, cols());\n    }\n\n    /** Resizes the matrix to \\a rows x \\a cols while leaving old values untouched.\n      *\n      * As opposed to conservativeResize(Index rows, Index cols), this version leaves\n      * the number of rows unchanged.\n      *\n      * In case the matrix is growing, new columns will be uninitialized.\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void conservativeResize(NoChange_t, Index cols)\n    {\n      // Note: see the comment in conservativeResize(Index,Index)\n      conservativeResize(rows(), cols);\n    }\n\n    /** Resizes the vector to \\a size while retaining old values.\n      *\n      * \\only_for_vectors. This method does not work for\n      * partially dynamic matrices when the static dimension is anything other\n      * than 1. For example it will not work with Matrix<double, 2, Dynamic>.\n      *\n      * When values are appended, they will be uninitialized.\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void conservativeResize(Index size)\n    {\n      internal::conservative_resize_like_impl<Derived>::run(*this, size);\n    }\n\n    /** Resizes the matrix to \\a rows x \\a cols of \\c other, while leaving old values untouched.\n      *\n      * The method is intended for matrices of dynamic size. If you only want to change the number\n      * of rows and/or of columns, you can use conservativeResize(NoChange_t, Index) or\n      * conservativeResize(Index, NoChange_t).\n      *\n      * Matrices are resized relative to the top-left element. In case values need to be \n      * appended to the matrix they will copied from \\c other.\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void conservativeResizeLike(const DenseBase<OtherDerived>& other)\n    {\n      internal::conservative_resize_like_impl<Derived,OtherDerived>::run(*this, other);\n    }\n\n    /** This is a special case of the templated operator=. Its purpose is to\n      * prevent a default operator= from hiding the templated operator=.\n      */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Derived& operator=(const PlainObjectBase& other)\n    {\n      return _set(other);\n    }\n\n    /** \\sa MatrixBase::lazyAssign() */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Derived& lazyAssign(const DenseBase<OtherDerived>& other)\n    {\n      _resize_to_match(other);\n      return Base::lazyAssign(other.derived());\n    }\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE Derived& operator=(const ReturnByValue<OtherDerived>& func)\n    {\n      resize(func.rows(), func.cols());\n      return Base::operator=(func);\n    }\n\n    // Prevent user from trying to instantiate PlainObjectBase objects\n    // by making all its constructor protected. See bug 1074.\n  protected:\n\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE PlainObjectBase() : m_storage()\n    {\n//       _check_template_params();\n//       EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED\n    }\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    // FIXME is it still needed ?\n    /** \\internal */\n    EIGEN_DEVICE_FUNC\n    explicit PlainObjectBase(internal::constructor_without_unaligned_array_assert)\n      : m_storage(internal::constructor_without_unaligned_array_assert())\n    {\n//       _check_template_params(); EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED\n    }\n#endif\n\n#if EIGEN_HAS_RVALUE_REFERENCES\n    EIGEN_DEVICE_FUNC\n    PlainObjectBase(PlainObjectBase&& other) EIGEN_NOEXCEPT\n      : m_storage( std::move(other.m_storage) )\n    {\n    }\n\n    EIGEN_DEVICE_FUNC\n    PlainObjectBase& operator=(PlainObjectBase&& other) EIGEN_NOEXCEPT\n    {\n      using std::swap;\n      swap(m_storage, other.m_storage);\n      return *this;\n    }\n#endif\n\n    /** Copy constructor */\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE PlainObjectBase(const PlainObjectBase& other)\n      : Base(), m_storage(other.m_storage) { }\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE PlainObjectBase(Index size, Index rows, Index cols)\n      : m_storage(size, rows, cols)\n    {\n//       _check_template_params();\n//       EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED\n    }\n\n    /** \\sa PlainObjectBase::operator=(const EigenBase<OtherDerived>&) */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase<OtherDerived> &other)\n      : m_storage()\n    {\n      _check_template_params();\n      resizeLike(other);\n      _set_noalias(other);\n    }\n\n    /** \\sa PlainObjectBase::operator=(const EigenBase<OtherDerived>&) */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase<OtherDerived> &other)\n      : m_storage()\n    {\n      _check_template_params();\n      resizeLike(other);\n      *this = other.derived();\n    }\n    /** \\brief Copy constructor with in-place evaluation */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE PlainObjectBase(const ReturnByValue<OtherDerived>& other)\n    {\n      _check_template_params();\n      // FIXME this does not automatically transpose vectors if necessary\n      resize(other.rows(), other.cols());\n      other.evalTo(this->derived());\n    }\n\n  public:\n\n    /** \\brief Copies the generic expression \\a other into *this.\n      * \\copydetails DenseBase::operator=(const EigenBase<OtherDerived> &other)\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC \n    EIGEN_STRONG_INLINE Derived& operator=(const EigenBase<OtherDerived> &other)\n    {\n      _resize_to_match(other);\n      Base::operator=(other.derived());\n      return this->derived();\n    }\n\n    /** \\name Map\n      * These are convenience functions returning Map objects. The Map() static functions return unaligned Map objects,\n      * while the AlignedMap() functions return aligned Map objects and thus should be called only with 16-byte-aligned\n      * \\a data pointers.\n      *\n      * \\see class Map\n      */\n    //@{\n    static inline ConstMapType Map(const Scalar* data)\n    { return ConstMapType(data); }\n    static inline MapType Map(Scalar* data)\n    { return MapType(data); }\n    static inline ConstMapType Map(const Scalar* data, Index size)\n    { return ConstMapType(data, size); }\n    static inline MapType Map(Scalar* data, Index size)\n    { return MapType(data, size); }\n    static inline ConstMapType Map(const Scalar* data, Index rows, Index cols)\n    { return ConstMapType(data, rows, cols); }\n    static inline MapType Map(Scalar* data, Index rows, Index cols)\n    { return MapType(data, rows, cols); }\n\n    static inline ConstAlignedMapType MapAligned(const Scalar* data)\n    { return ConstAlignedMapType(data); }\n    static inline AlignedMapType MapAligned(Scalar* data)\n    { return AlignedMapType(data); }\n    static inline ConstAlignedMapType MapAligned(const Scalar* data, Index size)\n    { return ConstAlignedMapType(data, size); }\n    static inline AlignedMapType MapAligned(Scalar* data, Index size)\n    { return AlignedMapType(data, size); }\n    static inline ConstAlignedMapType MapAligned(const Scalar* data, Index rows, Index cols)\n    { return ConstAlignedMapType(data, rows, cols); }\n    static inline AlignedMapType MapAligned(Scalar* data, Index rows, Index cols)\n    { return AlignedMapType(data, rows, cols); }\n\n    template<int Outer, int Inner>\n    static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(const Scalar* data, const Stride<Outer, Inner>& stride)\n    { return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, stride); }\n    template<int Outer, int Inner>\n    static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar* data, const Stride<Outer, Inner>& stride)\n    { return typename StridedMapType<Stride<Outer, Inner> >::type(data, stride); }\n    template<int Outer, int Inner>\n    static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(const Scalar* data, Index size, const Stride<Outer, Inner>& stride)\n    { return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, size, stride); }\n    template<int Outer, int Inner>\n    static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar* data, Index size, const Stride<Outer, Inner>& stride)\n    { return typename StridedMapType<Stride<Outer, Inner> >::type(data, size, stride); }\n    template<int Outer, int Inner>\n    static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(const Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride)\n    { return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }\n    template<int Outer, int Inner>\n    static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride)\n    { return typename StridedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }\n\n    template<int Outer, int Inner>\n    static inline typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type MapAligned(const Scalar* data, const Stride<Outer, Inner>& stride)\n    { return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, stride); }\n    template<int Outer, int Inner>\n    static inline typename StridedAlignedMapType<Stride<Outer, Inner> >::type MapAligned(Scalar* data, const Stride<Outer, Inner>& stride)\n    { return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, stride); }\n    template<int Outer, int Inner>\n    static inline typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type MapAligned(const Scalar* data, Index size, const Stride<Outer, Inner>& stride)\n    { return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, size, stride); }\n    template<int Outer, int Inner>\n    static inline typename StridedAlignedMapType<Stride<Outer, Inner> >::type MapAligned(Scalar* data, Index size, const Stride<Outer, Inner>& stride)\n    { return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, size, stride); }\n    template<int Outer, int Inner>\n    static inline typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type MapAligned(const Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride)\n    { return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }\n    template<int Outer, int Inner>\n    static inline typename StridedAlignedMapType<Stride<Outer, Inner> >::type MapAligned(Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride)\n    { return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }\n    //@}\n\n    using Base::setConstant;\n    EIGEN_DEVICE_FUNC Derived& setConstant(Index size, const Scalar& val);\n    EIGEN_DEVICE_FUNC Derived& setConstant(Index rows, Index cols, const Scalar& val);\n\n    using Base::setZero;\n    EIGEN_DEVICE_FUNC Derived& setZero(Index size);\n    EIGEN_DEVICE_FUNC Derived& setZero(Index rows, Index cols);\n\n    using Base::setOnes;\n    EIGEN_DEVICE_FUNC Derived& setOnes(Index size);\n    EIGEN_DEVICE_FUNC Derived& setOnes(Index rows, Index cols);\n\n    using Base::setRandom;\n    Derived& setRandom(Index size);\n    Derived& setRandom(Index rows, Index cols);\n\n    #ifdef EIGEN_PLAINOBJECTBASE_PLUGIN\n    #include EIGEN_PLAINOBJECTBASE_PLUGIN\n    #endif\n\n  protected:\n    /** \\internal Resizes *this in preparation for assigning \\a other to it.\n      * Takes care of doing all the checking that's needed.\n      *\n      * Note that copying a row-vector into a vector (and conversely) is allowed.\n      * The resizing, if any, is then done in the appropriate way so that row-vectors\n      * remain row-vectors and vectors remain vectors.\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC \n    EIGEN_STRONG_INLINE void _resize_to_match(const EigenBase<OtherDerived>& other)\n    {\n      #ifdef EIGEN_NO_AUTOMATIC_RESIZING\n      eigen_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.size())\n                 : (rows() == other.rows() && cols() == other.cols())))\n        && \"Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined\");\n      EIGEN_ONLY_USED_FOR_DEBUG(other);\n      #else\n      resizeLike(other);\n      #endif\n    }\n\n    /**\n      * \\brief Copies the value of the expression \\a other into \\c *this with automatic resizing.\n      *\n      * *this might be resized to match the dimensions of \\a other. If *this was a null matrix (not already initialized),\n      * it will be initialized.\n      *\n      * Note that copying a row-vector into a vector (and conversely) is allowed.\n      * The resizing, if any, is then done in the appropriate way so that row-vectors\n      * remain row-vectors and vectors remain vectors.\n      *\n      * \\sa operator=(const MatrixBase<OtherDerived>&), _set_noalias()\n      *\n      * \\internal\n      */\n    // aliasing is dealt once in internall::call_assignment\n    // so at this stage we have to assume aliasing... and resising has to be done later.\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC \n    EIGEN_STRONG_INLINE Derived& _set(const DenseBase<OtherDerived>& other)\n    {\n      internal::call_assignment(this->derived(), other.derived());\n      return this->derived();\n    }\n\n    /** \\internal Like _set() but additionally makes the assumption that no aliasing effect can happen (which\n      * is the case when creating a new matrix) so one can enforce lazy evaluation.\n      *\n      * \\sa operator=(const MatrixBase<OtherDerived>&), _set()\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC \n    EIGEN_STRONG_INLINE Derived& _set_noalias(const DenseBase<OtherDerived>& other)\n    {\n      // I don't think we need this resize call since the lazyAssign will anyways resize\n      // and lazyAssign will be called by the assign selector.\n      //_resize_to_match(other);\n      // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because\n      // it wouldn't allow to copy a row-vector into a column-vector.\n      internal::call_assignment_no_alias(this->derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());\n      return this->derived();\n    }\n\n    template<typename T0, typename T1>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, typename internal::enable_if<Base::SizeAtCompileTime!=2,T0>::type* = 0)\n    {\n      EIGEN_STATIC_ASSERT(bool(NumTraits<T0>::IsInteger) &&\n                          bool(NumTraits<T1>::IsInteger),\n                          FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)\n      resize(rows,cols);\n    }\n    \n    template<typename T0, typename T1>\n    EIGEN_DEVICE_FUNC \n    EIGEN_STRONG_INLINE void _init2(const T0& val0, const T1& val1, typename internal::enable_if<Base::SizeAtCompileTime==2,T0>::type* = 0)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)\n      m_storage.data()[0] = Scalar(val0);\n      m_storage.data()[1] = Scalar(val1);\n    }\n    \n    template<typename T0, typename T1>\n    EIGEN_DEVICE_FUNC \n    EIGEN_STRONG_INLINE void _init2(const Index& val0, const Index& val1,\n                                    typename internal::enable_if<    (!internal::is_same<Index,Scalar>::value)\n                                                                  && (internal::is_same<T0,Index>::value)\n                                                                  && (internal::is_same<T1,Index>::value)\n                                                                  && Base::SizeAtCompileTime==2,T1>::type* = 0)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)\n      m_storage.data()[0] = Scalar(val0);\n      m_storage.data()[1] = Scalar(val1);\n    }\n\n    // The argument is convertible to the Index type and we either have a non 1x1 Matrix, or a dynamic-sized Array,\n    // then the argument is meant to be the size of the object.\n    template<typename T>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init1(Index size, typename internal::enable_if<    (Base::SizeAtCompileTime!=1 || !internal::is_convertible<T, Scalar>::value)\n                                                                              && ((!internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value || Base::SizeAtCompileTime==Dynamic)),T>::type* = 0)\n    {\n      // NOTE MSVC 2008 complains if we directly put bool(NumTraits<T>::IsInteger) as the EIGEN_STATIC_ASSERT argument.\n      const bool is_integer = NumTraits<T>::IsInteger;\n      EIGEN_UNUSED_VARIABLE(is_integer);\n      EIGEN_STATIC_ASSERT(is_integer,\n                          FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)\n      resize(size);\n    }\n    \n    // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar type can be implicitely converted)\n    template<typename T>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init1(const Scalar& val0, typename internal::enable_if<Base::SizeAtCompileTime==1 && internal::is_convertible<T, Scalar>::value,T>::type* = 0)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)\n      m_storage.data()[0] = val0;\n    }\n    \n    // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar type match the index type)\n    template<typename T>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init1(const Index& val0,\n                                    typename internal::enable_if<    (!internal::is_same<Index,Scalar>::value)\n                                                                  && (internal::is_same<Index,T>::value)\n                                                                  && Base::SizeAtCompileTime==1\n                                                                  && internal::is_convertible<T, Scalar>::value,T*>::type* = 0)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)\n      m_storage.data()[0] = Scalar(val0);\n    }\n\n    // Initialize a fixed size matrix from a pointer to raw data\n    template<typename T>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init1(const Scalar* data){\n      this->_set_noalias(ConstMapType(data));\n    }\n\n    // Initialize an arbitrary matrix from a dense expression\n    template<typename T, typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init1(const DenseBase<OtherDerived>& other){\n      this->_set_noalias(other);\n    }\n\n    // Initialize an arbitrary matrix from an object convertible to the Derived type.\n    template<typename T>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init1(const Derived& other){\n      this->_set_noalias(other);\n    }\n\n    // Initialize an arbitrary matrix from a generic Eigen expression\n    template<typename T, typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init1(const EigenBase<OtherDerived>& other){\n      this->derived() = other;\n    }\n\n    template<typename T, typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init1(const ReturnByValue<OtherDerived>& other)\n    {\n      resize(other.rows(), other.cols());\n      other.evalTo(this->derived());\n    }\n\n    template<typename T, typename OtherDerived, int ColsAtCompileTime>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init1(const RotationBase<OtherDerived,ColsAtCompileTime>& r)\n    {\n      this->derived() = r;\n    }\n    \n    // For fixed-size Array<Scalar,...>\n    template<typename T>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init1(const Scalar& val0,\n                                    typename internal::enable_if<    Base::SizeAtCompileTime!=Dynamic\n                                                                  && Base::SizeAtCompileTime!=1\n                                                                  && internal::is_convertible<T, Scalar>::value\n                                                                  && internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value,T>::type* = 0)\n    {\n      Base::setConstant(val0);\n    }\n    \n    // For fixed-size Array<Index,...>\n    template<typename T>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _init1(const Index& val0,\n                                    typename internal::enable_if<    (!internal::is_same<Index,Scalar>::value)\n                                                                  && (internal::is_same<Index,T>::value)\n                                                                  && Base::SizeAtCompileTime!=Dynamic\n                                                                  && Base::SizeAtCompileTime!=1\n                                                                  && internal::is_convertible<T, Scalar>::value\n                                                                  && internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value,T*>::type* = 0)\n    {\n      Base::setConstant(val0);\n    }\n    \n    template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>\n    friend struct internal::matrix_swap_impl;\n\n  public:\n    \n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** \\internal\n      * \\brief Override DenseBase::swap() since for dynamic-sized matrices\n      * of same type it is enough to swap the data pointers.\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    void swap(DenseBase<OtherDerived> & other)\n    {\n      enum { SwapPointers = internal::is_same<Derived, OtherDerived>::value && Base::SizeAtCompileTime==Dynamic };\n      internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.derived());\n    }\n    \n    /** \\internal\n      * \\brief const version forwarded to DenseBase::swap\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    void swap(DenseBase<OtherDerived> const & other)\n    { Base::swap(other.derived()); }\n    \n    EIGEN_DEVICE_FUNC \n    static EIGEN_STRONG_INLINE void _check_template_params()\n    {\n      EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, (Options&RowMajor)==RowMajor)\n                        && EIGEN_IMPLIES(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, (Options&RowMajor)==0)\n                        && ((RowsAtCompileTime == Dynamic) || (RowsAtCompileTime >= 0))\n                        && ((ColsAtCompileTime == Dynamic) || (ColsAtCompileTime >= 0))\n                        && ((MaxRowsAtCompileTime == Dynamic) || (MaxRowsAtCompileTime >= 0))\n                        && ((MaxColsAtCompileTime == Dynamic) || (MaxColsAtCompileTime >= 0))\n                        && (MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime==Dynamic)\n                        && (MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime==Dynamic)\n                        && (Options & (DontAlign|RowMajor)) == Options),\n        INVALID_MATRIX_TEMPLATE_PARAMETERS)\n    }\n\n    enum { IsPlainObjectBase = 1 };\n#endif\n};\n\nnamespace internal {\n\ntemplate <typename Derived, typename OtherDerived, bool IsVector>\nstruct conservative_resize_like_impl\n{\n  static void run(DenseBase<Derived>& _this, Index rows, Index cols)\n  {\n    if (_this.rows() == rows && _this.cols() == cols) return;\n    EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)\n\n    if ( ( Derived::IsRowMajor && _this.cols() == cols) || // row-major and we change only the number of rows\n         (!Derived::IsRowMajor && _this.rows() == rows) )  // column-major and we change only the number of columns\n    {\n      internal::check_rows_cols_for_overflow<Derived::MaxSizeAtCompileTime>::run(rows, cols);\n      _this.derived().m_storage.conservativeResize(rows*cols,rows,cols);\n    }\n    else\n    {\n      // The storage order does not allow us to use reallocation.\n      typename Derived::PlainObject tmp(rows,cols);\n      const Index common_rows = numext::mini(rows, _this.rows());\n      const Index common_cols = numext::mini(cols, _this.cols());\n      tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);\n      _this.derived().swap(tmp);\n    }\n  }\n\n  static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other)\n  {\n    if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;\n\n    // Note: Here is space for improvement. Basically, for conservativeResize(Index,Index),\n    // neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the\n    // dimensions is dynamic, one could use either conservativeResize(Index rows, NoChange_t) or\n    // conservativeResize(NoChange_t, Index cols). For these methods new static asserts like\n    // EIGEN_STATIC_ASSERT_DYNAMIC_ROWS and EIGEN_STATIC_ASSERT_DYNAMIC_COLS would be good.\n    EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)\n    EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)\n\n    if ( ( Derived::IsRowMajor && _this.cols() == other.cols()) || // row-major and we change only the number of rows\n         (!Derived::IsRowMajor && _this.rows() == other.rows()) )  // column-major and we change only the number of columns\n    {\n      const Index new_rows = other.rows() - _this.rows();\n      const Index new_cols = other.cols() - _this.cols();\n      _this.derived().m_storage.conservativeResize(other.size(),other.rows(),other.cols());\n      if (new_rows>0)\n        _this.bottomRightCorner(new_rows, other.cols()) = other.bottomRows(new_rows);\n      else if (new_cols>0)\n        _this.bottomRightCorner(other.rows(), new_cols) = other.rightCols(new_cols);\n    }\n    else\n    {\n      // The storage order does not allow us to use reallocation.\n      typename Derived::PlainObject tmp(other);\n      const Index common_rows = numext::mini(tmp.rows(), _this.rows());\n      const Index common_cols = numext::mini(tmp.cols(), _this.cols());\n      tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);\n      _this.derived().swap(tmp);\n    }\n  }\n};\n\n// Here, the specialization for vectors inherits from the general matrix case\n// to allow calling .conservativeResize(rows,cols) on vectors.\ntemplate <typename Derived, typename OtherDerived>\nstruct conservative_resize_like_impl<Derived,OtherDerived,true>\n  : conservative_resize_like_impl<Derived,OtherDerived,false>\n{\n  using conservative_resize_like_impl<Derived,OtherDerived,false>::run;\n  \n  static void run(DenseBase<Derived>& _this, Index size)\n  {\n    const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : size;\n    const Index new_cols = Derived::RowsAtCompileTime==1 ? size : 1;\n    _this.derived().m_storage.conservativeResize(size,new_rows,new_cols);\n  }\n\n  static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other)\n  {\n    if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;\n\n    const Index num_new_elements = other.size() - _this.size();\n\n    const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : other.rows();\n    const Index new_cols = Derived::RowsAtCompileTime==1 ? other.cols() : 1;\n    _this.derived().m_storage.conservativeResize(other.size(),new_rows,new_cols);\n\n    if (num_new_elements > 0)\n      _this.tail(num_new_elements) = other.tail(num_new_elements);\n  }\n};\n\ntemplate<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>\nstruct matrix_swap_impl\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(MatrixTypeA& a, MatrixTypeB& b)\n  {\n    a.base().swap(b);\n  }\n};\n\ntemplate<typename MatrixTypeA, typename MatrixTypeB>\nstruct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true>\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(MatrixTypeA& a, MatrixTypeB& b)\n  {\n    static_cast<typename MatrixTypeA::Base&>(a).m_storage.swap(static_cast<typename MatrixTypeB::Base&>(b).m_storage);\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_DENSESTORAGEBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Product.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2011 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PRODUCT_H\n#define EIGEN_PRODUCT_H\n\nnamespace Eigen {\n\ntemplate<typename Lhs, typename Rhs, int Option, typename StorageKind> class ProductImpl;\n\nnamespace internal {\n\ntemplate<typename Lhs, typename Rhs, int Option>\nstruct traits<Product<Lhs, Rhs, Option> >\n{\n  typedef typename remove_all<Lhs>::type LhsCleaned;\n  typedef typename remove_all<Rhs>::type RhsCleaned;\n  typedef traits<LhsCleaned> LhsTraits;\n  typedef traits<RhsCleaned> RhsTraits;\n  \n  typedef MatrixXpr XprKind;\n  \n  typedef typename ScalarBinaryOpTraits<typename traits<LhsCleaned>::Scalar, typename traits<RhsCleaned>::Scalar>::ReturnType Scalar;\n  typedef typename product_promote_storage_type<typename LhsTraits::StorageKind,\n                                                typename RhsTraits::StorageKind,\n                                                internal::product_type<Lhs,Rhs>::ret>::ret StorageKind;\n  typedef typename promote_index_type<typename LhsTraits::StorageIndex,\n                                      typename RhsTraits::StorageIndex>::type StorageIndex;\n  \n  enum {\n    RowsAtCompileTime    = LhsTraits::RowsAtCompileTime,\n    ColsAtCompileTime    = RhsTraits::ColsAtCompileTime,\n    MaxRowsAtCompileTime = LhsTraits::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = RhsTraits::MaxColsAtCompileTime,\n    \n    // FIXME: only needed by GeneralMatrixMatrixTriangular\n    InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(LhsTraits::ColsAtCompileTime, RhsTraits::RowsAtCompileTime),\n    \n    // The storage order is somewhat arbitrary here. The correct one will be determined through the evaluator.\n    Flags = (MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1) ? RowMajorBit\n          : (MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1) ? 0\n          : (   ((LhsTraits::Flags&NoPreferredStorageOrderBit) && (RhsTraits::Flags&RowMajorBit))\n             || ((RhsTraits::Flags&NoPreferredStorageOrderBit) && (LhsTraits::Flags&RowMajorBit)) ) ? RowMajorBit\n          : NoPreferredStorageOrderBit\n  };\n};\n\n} // end namespace internal\n\n/** \\class Product\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of the product of two arbitrary matrices or vectors\n  *\n  * \\tparam _Lhs the type of the left-hand side expression\n  * \\tparam _Rhs the type of the right-hand side expression\n  *\n  * This class represents an expression of the product of two arbitrary matrices.\n  *\n  * The other template parameters are:\n  * \\tparam Option     can be DefaultProduct, AliasFreeProduct, or LazyProduct\n  *\n  */\ntemplate<typename _Lhs, typename _Rhs, int Option>\nclass Product : public ProductImpl<_Lhs,_Rhs,Option,\n                                   typename internal::product_promote_storage_type<typename internal::traits<_Lhs>::StorageKind,\n                                                                                   typename internal::traits<_Rhs>::StorageKind,\n                                                                                   internal::product_type<_Lhs,_Rhs>::ret>::ret>\n{\n  public:\n    \n    typedef _Lhs Lhs;\n    typedef _Rhs Rhs;\n    \n    typedef typename ProductImpl<\n        Lhs, Rhs, Option,\n        typename internal::product_promote_storage_type<typename internal::traits<Lhs>::StorageKind,\n                                                        typename internal::traits<Rhs>::StorageKind,\n                                                        internal::product_type<Lhs,Rhs>::ret>::ret>::Base Base;\n    EIGEN_GENERIC_PUBLIC_INTERFACE(Product)\n\n    typedef typename internal::ref_selector<Lhs>::type LhsNested;\n    typedef typename internal::ref_selector<Rhs>::type RhsNested;\n    typedef typename internal::remove_all<LhsNested>::type LhsNestedCleaned;\n    typedef typename internal::remove_all<RhsNested>::type RhsNestedCleaned;\n\n    EIGEN_DEVICE_FUNC Product(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs)\n    {\n      eigen_assert(lhs.cols() == rhs.rows()\n        && \"invalid matrix product\"\n        && \"if you wanted a coeff-wise or a dot product use the respective explicit functions\");\n    }\n\n    EIGEN_DEVICE_FUNC inline Index rows() const { return m_lhs.rows(); }\n    EIGEN_DEVICE_FUNC inline Index cols() const { return m_rhs.cols(); }\n\n    EIGEN_DEVICE_FUNC const LhsNestedCleaned& lhs() const { return m_lhs; }\n    EIGEN_DEVICE_FUNC const RhsNestedCleaned& rhs() const { return m_rhs; }\n\n  protected:\n\n    LhsNested m_lhs;\n    RhsNested m_rhs;\n};\n\nnamespace internal {\n  \ntemplate<typename Lhs, typename Rhs, int Option, int ProductTag = internal::product_type<Lhs,Rhs>::ret>\nclass dense_product_base\n : public internal::dense_xpr_base<Product<Lhs,Rhs,Option> >::type\n{};\n\n/** Convertion to scalar for inner-products */\ntemplate<typename Lhs, typename Rhs, int Option>\nclass dense_product_base<Lhs, Rhs, Option, InnerProduct>\n : public internal::dense_xpr_base<Product<Lhs,Rhs,Option> >::type\n{\n  typedef Product<Lhs,Rhs,Option> ProductXpr;\n  typedef typename internal::dense_xpr_base<ProductXpr>::type Base;\npublic:\n  using Base::derived;\n  typedef typename Base::Scalar Scalar;\n  \n  operator const Scalar() const\n  {\n    return internal::evaluator<ProductXpr>(derived()).coeff(0,0);\n  }\n};\n\n} // namespace internal\n\n// Generic API dispatcher\ntemplate<typename Lhs, typename Rhs, int Option, typename StorageKind>\nclass ProductImpl : public internal::generic_xpr_base<Product<Lhs,Rhs,Option>, MatrixXpr, StorageKind>::type\n{\n  public:\n    typedef typename internal::generic_xpr_base<Product<Lhs,Rhs,Option>, MatrixXpr, StorageKind>::type Base;\n};\n\ntemplate<typename Lhs, typename Rhs, int Option>\nclass ProductImpl<Lhs,Rhs,Option,Dense>\n  : public internal::dense_product_base<Lhs,Rhs,Option>\n{\n    typedef Product<Lhs, Rhs, Option> Derived;\n    \n  public:\n    \n    typedef typename internal::dense_product_base<Lhs, Rhs, Option> Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(Derived)\n  protected:\n    enum {\n      IsOneByOne = (RowsAtCompileTime == 1 || RowsAtCompileTime == Dynamic) && \n                   (ColsAtCompileTime == 1 || ColsAtCompileTime == Dynamic),\n      EnableCoeff = IsOneByOne || Option==LazyProduct\n    };\n    \n  public:\n  \n    EIGEN_DEVICE_FUNC Scalar coeff(Index row, Index col) const\n    {\n      EIGEN_STATIC_ASSERT(EnableCoeff, THIS_METHOD_IS_ONLY_FOR_INNER_OR_LAZY_PRODUCTS);\n      eigen_assert( (Option==LazyProduct) || (this->rows() == 1 && this->cols() == 1) );\n      \n      return internal::evaluator<Derived>(derived()).coeff(row,col);\n    }\n\n    EIGEN_DEVICE_FUNC Scalar coeff(Index i) const\n    {\n      EIGEN_STATIC_ASSERT(EnableCoeff, THIS_METHOD_IS_ONLY_FOR_INNER_OR_LAZY_PRODUCTS);\n      eigen_assert( (Option==LazyProduct) || (this->rows() == 1 && this->cols() == 1) );\n      \n      return internal::evaluator<Derived>(derived()).coeff(i);\n    }\n    \n  \n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_PRODUCT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/ProductEvaluators.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2011 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n\n#ifndef EIGEN_PRODUCTEVALUATORS_H\n#define EIGEN_PRODUCTEVALUATORS_H\n\nnamespace Eigen {\n  \nnamespace internal {\n\n/** \\internal\n  * Evaluator of a product expression.\n  * Since products require special treatments to handle all possible cases,\n  * we simply deffer the evaluation logic to a product_evaluator class\n  * which offers more partial specialization possibilities.\n  * \n  * \\sa class product_evaluator\n  */\ntemplate<typename Lhs, typename Rhs, int Options>\nstruct evaluator<Product<Lhs, Rhs, Options> > \n : public product_evaluator<Product<Lhs, Rhs, Options> >\n{\n  typedef Product<Lhs, Rhs, Options> XprType;\n  typedef product_evaluator<XprType> Base;\n  \n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr) {}\n};\n \n// Catch \"scalar * ( A * B )\" and transform it to \"(A*scalar) * B\"\n// TODO we should apply that rule only if that's really helpful\ntemplate<typename Lhs, typename Rhs, typename Scalar1, typename Scalar2, typename Plain1>\nstruct evaluator_assume_aliasing<CwiseBinaryOp<internal::scalar_product_op<Scalar1,Scalar2>,\n                                               const CwiseNullaryOp<internal::scalar_constant_op<Scalar1>, Plain1>,\n                                               const Product<Lhs, Rhs, DefaultProduct> > >\n{\n  static const bool value = true;\n};\ntemplate<typename Lhs, typename Rhs, typename Scalar1, typename Scalar2, typename Plain1>\nstruct evaluator<CwiseBinaryOp<internal::scalar_product_op<Scalar1,Scalar2>,\n                               const CwiseNullaryOp<internal::scalar_constant_op<Scalar1>, Plain1>,\n                               const Product<Lhs, Rhs, DefaultProduct> > >\n : public evaluator<Product<EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar1,Lhs,product), Rhs, DefaultProduct> >\n{\n  typedef CwiseBinaryOp<internal::scalar_product_op<Scalar1,Scalar2>,\n                               const CwiseNullaryOp<internal::scalar_constant_op<Scalar1>, Plain1>,\n                               const Product<Lhs, Rhs, DefaultProduct> > XprType;\n  typedef evaluator<Product<EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar1,Lhs,product), Rhs, DefaultProduct> > Base;\n\n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr)\n    : Base(xpr.lhs().functor().m_other * xpr.rhs().lhs() * xpr.rhs().rhs())\n  {}\n};\n\n\ntemplate<typename Lhs, typename Rhs, int DiagIndex>\nstruct evaluator<Diagonal<const Product<Lhs, Rhs, DefaultProduct>, DiagIndex> > \n : public evaluator<Diagonal<const Product<Lhs, Rhs, LazyProduct>, DiagIndex> >\n{\n  typedef Diagonal<const Product<Lhs, Rhs, DefaultProduct>, DiagIndex> XprType;\n  typedef evaluator<Diagonal<const Product<Lhs, Rhs, LazyProduct>, DiagIndex> > Base;\n  \n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr)\n    : Base(Diagonal<const Product<Lhs, Rhs, LazyProduct>, DiagIndex>(\n        Product<Lhs, Rhs, LazyProduct>(xpr.nestedExpression().lhs(), xpr.nestedExpression().rhs()),\n        xpr.index() ))\n  {}\n};\n\n\n// Helper class to perform a matrix product with the destination at hand.\n// Depending on the sizes of the factors, there are different evaluation strategies\n// as controlled by internal::product_type.\ntemplate< typename Lhs, typename Rhs,\n          typename LhsShape = typename evaluator_traits<Lhs>::Shape,\n          typename RhsShape = typename evaluator_traits<Rhs>::Shape,\n          int ProductType = internal::product_type<Lhs,Rhs>::value>\nstruct generic_product_impl;\n\ntemplate<typename Lhs, typename Rhs>\nstruct evaluator_assume_aliasing<Product<Lhs, Rhs, DefaultProduct> > {\n  static const bool value = true;\n};\n\n// This is the default evaluator implementation for products:\n// It creates a temporary and call generic_product_impl\ntemplate<typename Lhs, typename Rhs, int Options, int ProductTag, typename LhsShape, typename RhsShape>\nstruct product_evaluator<Product<Lhs, Rhs, Options>, ProductTag, LhsShape, RhsShape>\n  : public evaluator<typename Product<Lhs, Rhs, Options>::PlainObject>\n{\n  typedef Product<Lhs, Rhs, Options> XprType;\n  typedef typename XprType::PlainObject PlainObject;\n  typedef evaluator<PlainObject> Base;\n  enum {\n    Flags = Base::Flags | EvalBeforeNestingBit\n  };\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  explicit product_evaluator(const XprType& xpr)\n    : m_result(xpr.rows(), xpr.cols())\n  {\n    ::new (static_cast<Base*>(this)) Base(m_result);\n    \n// FIXME shall we handle nested_eval here?,\n// if so, then we must take care at removing the call to nested_eval in the specializations (e.g., in permutation_matrix_product, transposition_matrix_product, etc.)\n//     typedef typename internal::nested_eval<Lhs,Rhs::ColsAtCompileTime>::type LhsNested;\n//     typedef typename internal::nested_eval<Rhs,Lhs::RowsAtCompileTime>::type RhsNested;\n//     typedef typename internal::remove_all<LhsNested>::type LhsNestedCleaned;\n//     typedef typename internal::remove_all<RhsNested>::type RhsNestedCleaned;\n//     \n//     const LhsNested lhs(xpr.lhs());\n//     const RhsNested rhs(xpr.rhs());\n//   \n//     generic_product_impl<LhsNestedCleaned, RhsNestedCleaned>::evalTo(m_result, lhs, rhs);\n\n    generic_product_impl<Lhs, Rhs, LhsShape, RhsShape, ProductTag>::evalTo(m_result, xpr.lhs(), xpr.rhs());\n  }\n  \nprotected:  \n  PlainObject m_result;\n};\n\n// The following three shortcuts are enabled only if the scalar types match excatly.\n// TODO: we could enable them for different scalar types when the product is not vectorized.\n\n// Dense = Product\ntemplate< typename DstXprType, typename Lhs, typename Rhs, int Options, typename Scalar>\nstruct Assignment<DstXprType, Product<Lhs,Rhs,Options>, internal::assign_op<Scalar,Scalar>, Dense2Dense,\n  typename enable_if<(Options==DefaultProduct || Options==AliasFreeProduct)>::type>\n{\n  typedef Product<Lhs,Rhs,Options> SrcXprType;\n  static EIGEN_STRONG_INLINE\n  void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,Scalar> &)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n    // FIXME shall we handle nested_eval here?\n    generic_product_impl<Lhs, Rhs>::evalTo(dst, src.lhs(), src.rhs());\n  }\n};\n\n// Dense += Product\ntemplate< typename DstXprType, typename Lhs, typename Rhs, int Options, typename Scalar>\nstruct Assignment<DstXprType, Product<Lhs,Rhs,Options>, internal::add_assign_op<Scalar,Scalar>, Dense2Dense,\n  typename enable_if<(Options==DefaultProduct || Options==AliasFreeProduct)>::type>\n{\n  typedef Product<Lhs,Rhs,Options> SrcXprType;\n  static EIGEN_STRONG_INLINE\n  void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op<Scalar,Scalar> &)\n  {\n    eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());\n    // FIXME shall we handle nested_eval here?\n    generic_product_impl<Lhs, Rhs>::addTo(dst, src.lhs(), src.rhs());\n  }\n};\n\n// Dense -= Product\ntemplate< typename DstXprType, typename Lhs, typename Rhs, int Options, typename Scalar>\nstruct Assignment<DstXprType, Product<Lhs,Rhs,Options>, internal::sub_assign_op<Scalar,Scalar>, Dense2Dense,\n  typename enable_if<(Options==DefaultProduct || Options==AliasFreeProduct)>::type>\n{\n  typedef Product<Lhs,Rhs,Options> SrcXprType;\n  static EIGEN_STRONG_INLINE\n  void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op<Scalar,Scalar> &)\n  {\n    eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());\n    // FIXME shall we handle nested_eval here?\n    generic_product_impl<Lhs, Rhs>::subTo(dst, src.lhs(), src.rhs());\n  }\n};\n\n\n// Dense ?= scalar * Product\n// TODO we should apply that rule if that's really helpful\n// for instance, this is not good for inner products\ntemplate< typename DstXprType, typename Lhs, typename Rhs, typename AssignFunc, typename Scalar, typename ScalarBis, typename Plain>\nstruct Assignment<DstXprType, CwiseBinaryOp<internal::scalar_product_op<ScalarBis,Scalar>, const CwiseNullaryOp<internal::scalar_constant_op<ScalarBis>,Plain>,\n                                           const Product<Lhs,Rhs,DefaultProduct> >, AssignFunc, Dense2Dense>\n{\n  typedef CwiseBinaryOp<internal::scalar_product_op<ScalarBis,Scalar>,\n                        const CwiseNullaryOp<internal::scalar_constant_op<ScalarBis>,Plain>,\n                        const Product<Lhs,Rhs,DefaultProduct> > SrcXprType;\n  static EIGEN_STRONG_INLINE\n  void run(DstXprType &dst, const SrcXprType &src, const AssignFunc& func)\n  {\n    call_assignment_no_alias(dst, (src.lhs().functor().m_other * src.rhs().lhs())*src.rhs().rhs(), func);\n  }\n};\n\n//----------------------------------------\n// Catch \"Dense ?= xpr + Product<>\" expression to save one temporary\n// FIXME we could probably enable these rules for any product, i.e., not only Dense and DefaultProduct\n\ntemplate<typename OtherXpr, typename Lhs, typename Rhs>\nstruct evaluator_assume_aliasing<CwiseBinaryOp<internal::scalar_sum_op<typename OtherXpr::Scalar,typename Product<Lhs,Rhs,DefaultProduct>::Scalar>, const OtherXpr,\n                                               const Product<Lhs,Rhs,DefaultProduct> >, DenseShape > {\n  static const bool value = true;\n};\n\ntemplate<typename OtherXpr, typename Lhs, typename Rhs>\nstruct evaluator_assume_aliasing<CwiseBinaryOp<internal::scalar_difference_op<typename OtherXpr::Scalar,typename Product<Lhs,Rhs,DefaultProduct>::Scalar>, const OtherXpr,\n                                               const Product<Lhs,Rhs,DefaultProduct> >, DenseShape > {\n  static const bool value = true;\n};\n\ntemplate<typename DstXprType, typename OtherXpr, typename ProductType, typename Func1, typename Func2>\nstruct assignment_from_xpr_op_product\n{\n  template<typename SrcXprType, typename InitialFunc>\n  static EIGEN_STRONG_INLINE\n  void run(DstXprType &dst, const SrcXprType &src, const InitialFunc& /*func*/)\n  {\n    call_assignment_no_alias(dst, src.lhs(), Func1());\n    call_assignment_no_alias(dst, src.rhs(), Func2());\n  }\n};\n\n#define EIGEN_CATCH_ASSIGN_XPR_OP_PRODUCT(ASSIGN_OP,BINOP,ASSIGN_OP2) \\\n  template< typename DstXprType, typename OtherXpr, typename Lhs, typename Rhs, typename DstScalar, typename SrcScalar, typename OtherScalar,typename ProdScalar> \\\n  struct Assignment<DstXprType, CwiseBinaryOp<internal::BINOP<OtherScalar,ProdScalar>, const OtherXpr, \\\n                                            const Product<Lhs,Rhs,DefaultProduct> >, internal::ASSIGN_OP<DstScalar,SrcScalar>, Dense2Dense> \\\n    : assignment_from_xpr_op_product<DstXprType, OtherXpr, Product<Lhs,Rhs,DefaultProduct>, internal::ASSIGN_OP<DstScalar,OtherScalar>, internal::ASSIGN_OP2<DstScalar,ProdScalar> > \\\n  {}\n\nEIGEN_CATCH_ASSIGN_XPR_OP_PRODUCT(assign_op,    scalar_sum_op,add_assign_op);\nEIGEN_CATCH_ASSIGN_XPR_OP_PRODUCT(add_assign_op,scalar_sum_op,add_assign_op);\nEIGEN_CATCH_ASSIGN_XPR_OP_PRODUCT(sub_assign_op,scalar_sum_op,sub_assign_op);\n\nEIGEN_CATCH_ASSIGN_XPR_OP_PRODUCT(assign_op,    scalar_difference_op,sub_assign_op);\nEIGEN_CATCH_ASSIGN_XPR_OP_PRODUCT(add_assign_op,scalar_difference_op,sub_assign_op);\nEIGEN_CATCH_ASSIGN_XPR_OP_PRODUCT(sub_assign_op,scalar_difference_op,add_assign_op);\n\n//----------------------------------------\n\ntemplate<typename Lhs, typename Rhs>\nstruct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,InnerProduct>\n{\n  template<typename Dst>\n  static inline void evalTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    dst.coeffRef(0,0) = (lhs.transpose().cwiseProduct(rhs)).sum();\n  }\n  \n  template<typename Dst>\n  static inline void addTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    dst.coeffRef(0,0) += (lhs.transpose().cwiseProduct(rhs)).sum();\n  }\n  \n  template<typename Dst>\n  static void subTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  { dst.coeffRef(0,0) -= (lhs.transpose().cwiseProduct(rhs)).sum(); }\n};\n\n\n/***********************************************************************\n*  Implementation of outer dense * dense vector product\n***********************************************************************/\n\n// Column major result\ntemplate<typename Dst, typename Lhs, typename Rhs, typename Func>\nvoid outer_product_selector_run(Dst& dst, const Lhs &lhs, const Rhs &rhs, const Func& func, const false_type&)\n{\n  evaluator<Rhs> rhsEval(rhs);\n  typename nested_eval<Lhs,Rhs::SizeAtCompileTime>::type actual_lhs(lhs);\n  // FIXME if cols is large enough, then it might be useful to make sure that lhs is sequentially stored\n  // FIXME not very good if rhs is real and lhs complex while alpha is real too\n  const Index cols = dst.cols();\n  for (Index j=0; j<cols; ++j)\n    func(dst.col(j), rhsEval.coeff(Index(0),j) * actual_lhs);\n}\n\n// Row major result\ntemplate<typename Dst, typename Lhs, typename Rhs, typename Func>\nvoid outer_product_selector_run(Dst& dst, const Lhs &lhs, const Rhs &rhs, const Func& func, const true_type&)\n{\n  evaluator<Lhs> lhsEval(lhs);\n  typename nested_eval<Rhs,Lhs::SizeAtCompileTime>::type actual_rhs(rhs);\n  // FIXME if rows is large enough, then it might be useful to make sure that rhs is sequentially stored\n  // FIXME not very good if lhs is real and rhs complex while alpha is real too\n  const Index rows = dst.rows();\n  for (Index i=0; i<rows; ++i)\n    func(dst.row(i), lhsEval.coeff(i,Index(0)) * actual_rhs);\n}\n\ntemplate<typename Lhs, typename Rhs>\nstruct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,OuterProduct>\n{\n  template<typename T> struct is_row_major : internal::conditional<(int(T::Flags)&RowMajorBit), internal::true_type, internal::false_type>::type {};\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  \n  // TODO it would be nice to be able to exploit our *_assign_op functors for that purpose\n  struct set  { template<typename Dst, typename Src> void operator()(const Dst& dst, const Src& src) const { dst.const_cast_derived()  = src; } };\n  struct add  { template<typename Dst, typename Src> void operator()(const Dst& dst, const Src& src) const { dst.const_cast_derived() += src; } };\n  struct sub  { template<typename Dst, typename Src> void operator()(const Dst& dst, const Src& src) const { dst.const_cast_derived() -= src; } };\n  struct adds {\n    Scalar m_scale;\n    explicit adds(const Scalar& s) : m_scale(s) {}\n    template<typename Dst, typename Src> void operator()(const Dst& dst, const Src& src) const {\n      dst.const_cast_derived() += m_scale * src;\n    }\n  };\n  \n  template<typename Dst>\n  static inline void evalTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    internal::outer_product_selector_run(dst, lhs, rhs, set(), is_row_major<Dst>());\n  }\n  \n  template<typename Dst>\n  static inline void addTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    internal::outer_product_selector_run(dst, lhs, rhs, add(), is_row_major<Dst>());\n  }\n  \n  template<typename Dst>\n  static inline void subTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    internal::outer_product_selector_run(dst, lhs, rhs, sub(), is_row_major<Dst>());\n  }\n  \n  template<typename Dst>\n  static inline void scaleAndAddTo(Dst& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)\n  {\n    internal::outer_product_selector_run(dst, lhs, rhs, adds(alpha), is_row_major<Dst>());\n  }\n  \n};\n\n\n// This base class provides default implementations for evalTo, addTo, subTo, in terms of scaleAndAddTo\ntemplate<typename Lhs, typename Rhs, typename Derived>\nstruct generic_product_impl_base\n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  \n  template<typename Dst>\n  static EIGEN_STRONG_INLINE void evalTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  { dst.setZero(); scaleAndAddTo(dst, lhs, rhs, Scalar(1)); }\n\n  template<typename Dst>\n  static EIGEN_STRONG_INLINE void addTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  { scaleAndAddTo(dst,lhs, rhs, Scalar(1)); }\n\n  template<typename Dst>\n  static EIGEN_STRONG_INLINE void subTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  { scaleAndAddTo(dst, lhs, rhs, Scalar(-1)); }\n  \n  template<typename Dst>\n  static EIGEN_STRONG_INLINE void scaleAndAddTo(Dst& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)\n  { Derived::scaleAndAddTo(dst,lhs,rhs,alpha); }\n\n};\n\ntemplate<typename Lhs, typename Rhs>\nstruct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemvProduct>\n  : generic_product_impl_base<Lhs,Rhs,generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemvProduct> >\n{\n  typedef typename nested_eval<Lhs,1>::type LhsNested;\n  typedef typename nested_eval<Rhs,1>::type RhsNested;\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  enum { Side = Lhs::IsVectorAtCompileTime ? OnTheLeft : OnTheRight };\n  typedef typename internal::remove_all<typename internal::conditional<int(Side)==OnTheRight,LhsNested,RhsNested>::type>::type MatrixType;\n\n  template<typename Dest>\n  static EIGEN_STRONG_INLINE void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)\n  {\n    LhsNested actual_lhs(lhs);\n    RhsNested actual_rhs(rhs);\n    internal::gemv_dense_selector<Side,\n                            (int(MatrixType::Flags)&RowMajorBit) ? RowMajor : ColMajor,\n                            bool(internal::blas_traits<MatrixType>::HasUsableDirectAccess)\n                           >::run(actual_lhs, actual_rhs, dst, alpha);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs>\nstruct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,CoeffBasedProductMode> \n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  \n  template<typename Dst>\n  static EIGEN_STRONG_INLINE void evalTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    // Same as: dst.noalias() = lhs.lazyProduct(rhs);\n    // but easier on the compiler side\n    call_assignment_no_alias(dst, lhs.lazyProduct(rhs), internal::assign_op<typename Dst::Scalar,Scalar>());\n  }\n  \n  template<typename Dst>\n  static EIGEN_STRONG_INLINE void addTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    // dst.noalias() += lhs.lazyProduct(rhs);\n    call_assignment_no_alias(dst, lhs.lazyProduct(rhs), internal::add_assign_op<typename Dst::Scalar,Scalar>());\n  }\n  \n  template<typename Dst>\n  static EIGEN_STRONG_INLINE void subTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    // dst.noalias() -= lhs.lazyProduct(rhs);\n    call_assignment_no_alias(dst, lhs.lazyProduct(rhs), internal::sub_assign_op<typename Dst::Scalar,Scalar>());\n  }\n  \n//   template<typename Dst>\n//   static inline void scaleAndAddTo(Dst& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)\n//   { dst.noalias() += alpha * lhs.lazyProduct(rhs); }\n};\n\n// This specialization enforces the use of a coefficient-based evaluation strategy\ntemplate<typename Lhs, typename Rhs>\nstruct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,LazyCoeffBasedProductMode>\n  : generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,CoeffBasedProductMode> {};\n\n// Case 2: Evaluate coeff by coeff\n//\n// This is mostly taken from CoeffBasedProduct.h\n// The main difference is that we add an extra argument to the etor_product_*_impl::run() function\n// for the inner dimension of the product, because evaluator object do not know their size.\n\ntemplate<int Traversal, int UnrollingIndex, typename Lhs, typename Rhs, typename RetScalar>\nstruct etor_product_coeff_impl;\n\ntemplate<int StorageOrder, int UnrollingIndex, typename Lhs, typename Rhs, typename Packet, int LoadMode>\nstruct etor_product_packet_impl;\n\ntemplate<typename Lhs, typename Rhs, int ProductTag>\nstruct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape, DenseShape>\n    : evaluator_base<Product<Lhs, Rhs, LazyProduct> >\n{\n  typedef Product<Lhs, Rhs, LazyProduct> XprType;\n  typedef typename XprType::Scalar Scalar;\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  explicit product_evaluator(const XprType& xpr)\n    : m_lhs(xpr.lhs()),\n      m_rhs(xpr.rhs()),\n      m_lhsImpl(m_lhs),     // FIXME the creation of the evaluator objects should result in a no-op, but check that!\n      m_rhsImpl(m_rhs),     //       Moreover, they are only useful for the packet path, so we could completely disable them when not needed,\n                            //       or perhaps declare them on the fly on the packet method... We have experiment to check what's best.\n      m_innerDim(xpr.lhs().cols())\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(NumTraits<Scalar>::MulCost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(NumTraits<Scalar>::AddCost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n#if 0\n    std::cerr << \"LhsOuterStrideBytes=  \" << LhsOuterStrideBytes << \"\\n\";\n    std::cerr << \"RhsOuterStrideBytes=  \" << RhsOuterStrideBytes << \"\\n\";\n    std::cerr << \"LhsAlignment=         \" << LhsAlignment << \"\\n\";\n    std::cerr << \"RhsAlignment=         \" << RhsAlignment << \"\\n\";\n    std::cerr << \"CanVectorizeLhs=      \" << CanVectorizeLhs << \"\\n\";\n    std::cerr << \"CanVectorizeRhs=      \" << CanVectorizeRhs << \"\\n\";\n    std::cerr << \"CanVectorizeInner=    \" << CanVectorizeInner << \"\\n\";\n    std::cerr << \"EvalToRowMajor=       \" << EvalToRowMajor << \"\\n\";\n    std::cerr << \"Alignment=            \" << Alignment << \"\\n\";\n    std::cerr << \"Flags=                \" << Flags << \"\\n\";\n#endif\n  }\n\n  // Everything below here is taken from CoeffBasedProduct.h\n\n  typedef typename internal::nested_eval<Lhs,Rhs::ColsAtCompileTime>::type LhsNested;\n  typedef typename internal::nested_eval<Rhs,Lhs::RowsAtCompileTime>::type RhsNested;\n  \n  typedef typename internal::remove_all<LhsNested>::type LhsNestedCleaned;\n  typedef typename internal::remove_all<RhsNested>::type RhsNestedCleaned;\n\n  typedef evaluator<LhsNestedCleaned> LhsEtorType;\n  typedef evaluator<RhsNestedCleaned> RhsEtorType;\n\n  enum {\n    RowsAtCompileTime = LhsNestedCleaned::RowsAtCompileTime,\n    ColsAtCompileTime = RhsNestedCleaned::ColsAtCompileTime,\n    InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(LhsNestedCleaned::ColsAtCompileTime, RhsNestedCleaned::RowsAtCompileTime),\n    MaxRowsAtCompileTime = LhsNestedCleaned::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = RhsNestedCleaned::MaxColsAtCompileTime\n  };\n\n  typedef typename find_best_packet<Scalar,RowsAtCompileTime>::type LhsVecPacketType;\n  typedef typename find_best_packet<Scalar,ColsAtCompileTime>::type RhsVecPacketType;\n\n  enum {\n      \n    LhsCoeffReadCost = LhsEtorType::CoeffReadCost,\n    RhsCoeffReadCost = RhsEtorType::CoeffReadCost,\n    CoeffReadCost = InnerSize==0 ? NumTraits<Scalar>::ReadCost\n                  : InnerSize == Dynamic ? HugeCost\n                  : InnerSize * (NumTraits<Scalar>::MulCost + LhsCoeffReadCost + RhsCoeffReadCost)\n                    + (InnerSize - 1) * NumTraits<Scalar>::AddCost,\n\n    Unroll = CoeffReadCost <= EIGEN_UNROLLING_LIMIT,\n    \n    LhsFlags = LhsEtorType::Flags,\n    RhsFlags = RhsEtorType::Flags,\n    \n    LhsRowMajor = LhsFlags & RowMajorBit,\n    RhsRowMajor = RhsFlags & RowMajorBit,\n\n    LhsVecPacketSize = unpacket_traits<LhsVecPacketType>::size,\n    RhsVecPacketSize = unpacket_traits<RhsVecPacketType>::size,\n\n    // Here, we don't care about alignment larger than the usable packet size.\n    LhsAlignment = EIGEN_PLAIN_ENUM_MIN(LhsEtorType::Alignment,LhsVecPacketSize*int(sizeof(typename LhsNestedCleaned::Scalar))),\n    RhsAlignment = EIGEN_PLAIN_ENUM_MIN(RhsEtorType::Alignment,RhsVecPacketSize*int(sizeof(typename RhsNestedCleaned::Scalar))),\n      \n    SameType = is_same<typename LhsNestedCleaned::Scalar,typename RhsNestedCleaned::Scalar>::value,\n\n    CanVectorizeRhs = bool(RhsRowMajor) && (RhsFlags & PacketAccessBit) && (ColsAtCompileTime!=1),\n    CanVectorizeLhs = (!LhsRowMajor) && (LhsFlags & PacketAccessBit) && (RowsAtCompileTime!=1),\n\n    EvalToRowMajor = (MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1\n                    : (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0\n                    : (bool(RhsRowMajor) && !CanVectorizeLhs),\n\n    Flags = ((unsigned int)(LhsFlags | RhsFlags) & HereditaryBits & ~RowMajorBit)\n          | (EvalToRowMajor ? RowMajorBit : 0)\n          // TODO enable vectorization for mixed types\n          | (SameType && (CanVectorizeLhs || CanVectorizeRhs) ? PacketAccessBit : 0)\n          | (XprType::IsVectorAtCompileTime ? LinearAccessBit : 0),\n          \n    LhsOuterStrideBytes = int(LhsNestedCleaned::OuterStrideAtCompileTime) * int(sizeof(typename LhsNestedCleaned::Scalar)),\n    RhsOuterStrideBytes = int(RhsNestedCleaned::OuterStrideAtCompileTime) * int(sizeof(typename RhsNestedCleaned::Scalar)),\n\n    Alignment = bool(CanVectorizeLhs) ? (LhsOuterStrideBytes<=0 || (int(LhsOuterStrideBytes) % EIGEN_PLAIN_ENUM_MAX(1,LhsAlignment))!=0 ? 0 : LhsAlignment)\n              : bool(CanVectorizeRhs) ? (RhsOuterStrideBytes<=0 || (int(RhsOuterStrideBytes) % EIGEN_PLAIN_ENUM_MAX(1,RhsAlignment))!=0 ? 0 : RhsAlignment)\n              : 0,\n\n    /* CanVectorizeInner deserves special explanation. It does not affect the product flags. It is not used outside\n     * of Product. If the Product itself is not a packet-access expression, there is still a chance that the inner\n     * loop of the product might be vectorized. This is the meaning of CanVectorizeInner. Since it doesn't affect\n     * the Flags, it is safe to make this value depend on ActualPacketAccessBit, that doesn't affect the ABI.\n     */\n    CanVectorizeInner =    SameType\n                        && LhsRowMajor\n                        && (!RhsRowMajor)\n                        && (LhsFlags & RhsFlags & ActualPacketAccessBit)\n                        && (InnerSize % packet_traits<Scalar>::size == 0)\n  };\n  \n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index row, Index col) const\n  {\n    return (m_lhs.row(row).transpose().cwiseProduct( m_rhs.col(col) )).sum();\n  }\n\n  /* Allow index-based non-packet access. It is impossible though to allow index-based packed access,\n   * which is why we don't set the LinearAccessBit.\n   * TODO: this seems possible when the result is a vector\n   */\n  EIGEN_DEVICE_FUNC const CoeffReturnType coeff(Index index) const\n  {\n    const Index row = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime==1) ? 0 : index;\n    const Index col = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime==1) ? index : 0;\n    return (m_lhs.row(row).transpose().cwiseProduct( m_rhs.col(col) )).sum();\n  }\n\n  template<int LoadMode, typename PacketType>\n  const PacketType packet(Index row, Index col) const\n  {\n    PacketType res;\n    typedef etor_product_packet_impl<bool(int(Flags)&RowMajorBit) ? RowMajor : ColMajor,\n                                     Unroll ? int(InnerSize) : Dynamic,\n                                     LhsEtorType, RhsEtorType, PacketType, LoadMode> PacketImpl;\n    PacketImpl::run(row, col, m_lhsImpl, m_rhsImpl, m_innerDim, res);\n    return res;\n  }\n\n  template<int LoadMode, typename PacketType>\n  const PacketType packet(Index index) const\n  {\n    const Index row = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime==1) ? 0 : index;\n    const Index col = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime==1) ? index : 0;\n    return packet<LoadMode,PacketType>(row,col);\n  }\n\nprotected:\n  typename internal::add_const_on_value_type<LhsNested>::type m_lhs;\n  typename internal::add_const_on_value_type<RhsNested>::type m_rhs;\n  \n  LhsEtorType m_lhsImpl;\n  RhsEtorType m_rhsImpl;\n\n  // TODO: Get rid of m_innerDim if known at compile time\n  Index m_innerDim;\n};\n\ntemplate<typename Lhs, typename Rhs>\nstruct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, LazyCoeffBasedProductMode, DenseShape, DenseShape>\n  : product_evaluator<Product<Lhs, Rhs, LazyProduct>, CoeffBasedProductMode, DenseShape, DenseShape>\n{\n  typedef Product<Lhs, Rhs, DefaultProduct> XprType;\n  typedef Product<Lhs, Rhs, LazyProduct> BaseProduct;\n  typedef product_evaluator<BaseProduct, CoeffBasedProductMode, DenseShape, DenseShape> Base;\n  enum {\n    Flags = Base::Flags | EvalBeforeNestingBit\n  };\n  EIGEN_DEVICE_FUNC explicit product_evaluator(const XprType& xpr)\n    : Base(BaseProduct(xpr.lhs(),xpr.rhs()))\n  {}\n};\n\n/****************************************\n*** Coeff based product, Packet path  ***\n****************************************/\n\ntemplate<int UnrollingIndex, typename Lhs, typename Rhs, typename Packet, int LoadMode>\nstruct etor_product_packet_impl<RowMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode>\n{\n  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet &res)\n  {\n    etor_product_packet_impl<RowMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, innerDim, res);\n    res =  pmadd(pset1<Packet>(lhs.coeff(row, Index(UnrollingIndex-1))), rhs.template packet<LoadMode,Packet>(Index(UnrollingIndex-1), col), res);\n  }\n};\n\ntemplate<int UnrollingIndex, typename Lhs, typename Rhs, typename Packet, int LoadMode>\nstruct etor_product_packet_impl<ColMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode>\n{\n  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet &res)\n  {\n    etor_product_packet_impl<ColMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, innerDim, res);\n    res =  pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename Packet, int LoadMode>\nstruct etor_product_packet_impl<RowMajor, 1, Lhs, Rhs, Packet, LoadMode>\n{\n  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, Packet &res)\n  {\n    res = pmul(pset1<Packet>(lhs.coeff(row, Index(0))),rhs.template packet<LoadMode,Packet>(Index(0), col));\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename Packet, int LoadMode>\nstruct etor_product_packet_impl<ColMajor, 1, Lhs, Rhs, Packet, LoadMode>\n{\n  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, Packet &res)\n  {\n    res = pmul(lhs.template packet<LoadMode,Packet>(row, Index(0)), pset1<Packet>(rhs.coeff(Index(0), col)));\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename Packet, int LoadMode>\nstruct etor_product_packet_impl<RowMajor, 0, Lhs, Rhs, Packet, LoadMode>\n{\n  static EIGEN_STRONG_INLINE void run(Index /*row*/, Index /*col*/, const Lhs& /*lhs*/, const Rhs& /*rhs*/, Index /*innerDim*/, Packet &res)\n  {\n    res = pset1<Packet>(typename unpacket_traits<Packet>::type(0));\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename Packet, int LoadMode>\nstruct etor_product_packet_impl<ColMajor, 0, Lhs, Rhs, Packet, LoadMode>\n{\n  static EIGEN_STRONG_INLINE void run(Index /*row*/, Index /*col*/, const Lhs& /*lhs*/, const Rhs& /*rhs*/, Index /*innerDim*/, Packet &res)\n  {\n    res = pset1<Packet>(typename unpacket_traits<Packet>::type(0));\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename Packet, int LoadMode>\nstruct etor_product_packet_impl<RowMajor, Dynamic, Lhs, Rhs, Packet, LoadMode>\n{\n  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet& res)\n  {\n    res = pset1<Packet>(typename unpacket_traits<Packet>::type(0));\n    for(Index i = 0; i < innerDim; ++i)\n      res =  pmadd(pset1<Packet>(lhs.coeff(row, i)), rhs.template packet<LoadMode,Packet>(i, col), res);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename Packet, int LoadMode>\nstruct etor_product_packet_impl<ColMajor, Dynamic, Lhs, Rhs, Packet, LoadMode>\n{\n  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet& res)\n  {\n    res = pset1<Packet>(typename unpacket_traits<Packet>::type(0));\n    for(Index i = 0; i < innerDim; ++i)\n      res =  pmadd(lhs.template packet<LoadMode,Packet>(row, i), pset1<Packet>(rhs.coeff(i, col)), res);\n  }\n};\n\n\n/***************************************************************************\n* Triangular products\n***************************************************************************/\ntemplate<int Mode, bool LhsIsTriangular,\n         typename Lhs, bool LhsIsVector,\n         typename Rhs, bool RhsIsVector>\nstruct triangular_product_impl;\n\ntemplate<typename Lhs, typename Rhs, int ProductTag>\nstruct generic_product_impl<Lhs,Rhs,TriangularShape,DenseShape,ProductTag>\n  : generic_product_impl_base<Lhs,Rhs,generic_product_impl<Lhs,Rhs,TriangularShape,DenseShape,ProductTag> >\n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  \n  template<typename Dest>\n  static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)\n  {\n    triangular_product_impl<Lhs::Mode,true,typename Lhs::MatrixType,false,Rhs, Rhs::ColsAtCompileTime==1>\n        ::run(dst, lhs.nestedExpression(), rhs, alpha);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag>\nstruct generic_product_impl<Lhs,Rhs,DenseShape,TriangularShape,ProductTag>\n: generic_product_impl_base<Lhs,Rhs,generic_product_impl<Lhs,Rhs,DenseShape,TriangularShape,ProductTag> >\n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  \n  template<typename Dest>\n  static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)\n  {\n    triangular_product_impl<Rhs::Mode,false,Lhs,Lhs::RowsAtCompileTime==1, typename Rhs::MatrixType, false>::run(dst, lhs, rhs.nestedExpression(), alpha);\n  }\n};\n\n\n/***************************************************************************\n* SelfAdjoint products\n***************************************************************************/\ntemplate <typename Lhs, int LhsMode, bool LhsIsVector,\n          typename Rhs, int RhsMode, bool RhsIsVector>\nstruct selfadjoint_product_impl;\n\ntemplate<typename Lhs, typename Rhs, int ProductTag>\nstruct generic_product_impl<Lhs,Rhs,SelfAdjointShape,DenseShape,ProductTag>\n  : generic_product_impl_base<Lhs,Rhs,generic_product_impl<Lhs,Rhs,SelfAdjointShape,DenseShape,ProductTag> >\n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  \n  template<typename Dest>\n  static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)\n  {\n    selfadjoint_product_impl<typename Lhs::MatrixType,Lhs::Mode,false,Rhs,0,Rhs::IsVectorAtCompileTime>::run(dst, lhs.nestedExpression(), rhs, alpha);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag>\nstruct generic_product_impl<Lhs,Rhs,DenseShape,SelfAdjointShape,ProductTag>\n: generic_product_impl_base<Lhs,Rhs,generic_product_impl<Lhs,Rhs,DenseShape,SelfAdjointShape,ProductTag> >\n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  \n  template<typename Dest>\n  static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)\n  {\n    selfadjoint_product_impl<Lhs,0,Lhs::IsVectorAtCompileTime,typename Rhs::MatrixType,Rhs::Mode,false>::run(dst, lhs, rhs.nestedExpression(), alpha);\n  }\n};\n\n\n/***************************************************************************\n* Diagonal products\n***************************************************************************/\n  \ntemplate<typename MatrixType, typename DiagonalType, typename Derived, int ProductOrder>\nstruct diagonal_product_evaluator_base\n  : evaluator_base<Derived>\n{\n   typedef typename ScalarBinaryOpTraits<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ReturnType Scalar;\npublic:\n  enum {\n    CoeffReadCost = NumTraits<Scalar>::MulCost + evaluator<MatrixType>::CoeffReadCost + evaluator<DiagonalType>::CoeffReadCost,\n    \n    MatrixFlags = evaluator<MatrixType>::Flags,\n    DiagFlags = evaluator<DiagonalType>::Flags,\n    _StorageOrder = MatrixFlags & RowMajorBit ? RowMajor : ColMajor,\n    _ScalarAccessOnDiag =  !((int(_StorageOrder) == ColMajor && int(ProductOrder) == OnTheLeft)\n                           ||(int(_StorageOrder) == RowMajor && int(ProductOrder) == OnTheRight)),\n    _SameTypes = is_same<typename MatrixType::Scalar, typename DiagonalType::Scalar>::value,\n    // FIXME currently we need same types, but in the future the next rule should be the one\n    //_Vectorizable = bool(int(MatrixFlags)&PacketAccessBit) && ((!_PacketOnDiag) || (_SameTypes && bool(int(DiagFlags)&PacketAccessBit))),\n    _Vectorizable = bool(int(MatrixFlags)&PacketAccessBit) && _SameTypes && (_ScalarAccessOnDiag || (bool(int(DiagFlags)&PacketAccessBit))),\n    _LinearAccessMask = (MatrixType::RowsAtCompileTime==1 || MatrixType::ColsAtCompileTime==1) ? LinearAccessBit : 0,\n    Flags = ((HereditaryBits|_LinearAccessMask) & (unsigned int)(MatrixFlags)) | (_Vectorizable ? PacketAccessBit : 0),\n    Alignment = evaluator<MatrixType>::Alignment\n  };\n  \n  diagonal_product_evaluator_base(const MatrixType &mat, const DiagonalType &diag)\n    : m_diagImpl(diag), m_matImpl(mat)\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(NumTraits<Scalar>::MulCost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n  \n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff(Index idx) const\n  {\n    return m_diagImpl.coeff(idx) * m_matImpl.coeff(idx);\n  }\n  \nprotected:\n  template<int LoadMode,typename PacketType>\n  EIGEN_STRONG_INLINE PacketType packet_impl(Index row, Index col, Index id, internal::true_type) const\n  {\n    return internal::pmul(m_matImpl.template packet<LoadMode,PacketType>(row, col),\n                          internal::pset1<PacketType>(m_diagImpl.coeff(id)));\n  }\n  \n  template<int LoadMode,typename PacketType>\n  EIGEN_STRONG_INLINE PacketType packet_impl(Index row, Index col, Index id, internal::false_type) const\n  {\n    enum {\n      InnerSize = (MatrixType::Flags & RowMajorBit) ? MatrixType::ColsAtCompileTime : MatrixType::RowsAtCompileTime,\n      DiagonalPacketLoadMode = EIGEN_PLAIN_ENUM_MIN(LoadMode,((InnerSize%16) == 0) ? int(Aligned16) : int(evaluator<DiagonalType>::Alignment)) // FIXME hardcoded 16!!\n    };\n    return internal::pmul(m_matImpl.template packet<LoadMode,PacketType>(row, col),\n                          m_diagImpl.template packet<DiagonalPacketLoadMode,PacketType>(id));\n  }\n  \n  evaluator<DiagonalType> m_diagImpl;\n  evaluator<MatrixType>   m_matImpl;\n};\n\n// diagonal * dense\ntemplate<typename Lhs, typename Rhs, int ProductKind, int ProductTag>\nstruct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DiagonalShape, DenseShape>\n  : diagonal_product_evaluator_base<Rhs, typename Lhs::DiagonalVectorType, Product<Lhs, Rhs, LazyProduct>, OnTheLeft>\n{\n  typedef diagonal_product_evaluator_base<Rhs, typename Lhs::DiagonalVectorType, Product<Lhs, Rhs, LazyProduct>, OnTheLeft> Base;\n  using Base::m_diagImpl;\n  using Base::m_matImpl;\n  using Base::coeff;\n  typedef typename Base::Scalar Scalar;\n  \n  typedef Product<Lhs, Rhs, ProductKind> XprType;\n  typedef typename XprType::PlainObject PlainObject;\n  \n  enum {\n    StorageOrder = int(Rhs::Flags) & RowMajorBit ? RowMajor : ColMajor\n  };\n\n  EIGEN_DEVICE_FUNC explicit product_evaluator(const XprType& xpr)\n    : Base(xpr.rhs(), xpr.lhs().diagonal())\n  {\n  }\n  \n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff(Index row, Index col) const\n  {\n    return m_diagImpl.coeff(row) * m_matImpl.coeff(row, col);\n  }\n  \n#ifndef __CUDACC__\n  template<int LoadMode,typename PacketType>\n  EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const\n  {\n    // FIXME: NVCC used to complain about the template keyword, but we have to check whether this is still the case.\n    // See also similar calls below.\n    return this->template packet_impl<LoadMode,PacketType>(row,col, row,\n                                 typename internal::conditional<int(StorageOrder)==RowMajor, internal::true_type, internal::false_type>::type());\n  }\n  \n  template<int LoadMode,typename PacketType>\n  EIGEN_STRONG_INLINE PacketType packet(Index idx) const\n  {\n    return packet<LoadMode,PacketType>(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx);\n  }\n#endif\n};\n\n// dense * diagonal\ntemplate<typename Lhs, typename Rhs, int ProductKind, int ProductTag>\nstruct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DenseShape, DiagonalShape>\n  : diagonal_product_evaluator_base<Lhs, typename Rhs::DiagonalVectorType, Product<Lhs, Rhs, LazyProduct>, OnTheRight>\n{\n  typedef diagonal_product_evaluator_base<Lhs, typename Rhs::DiagonalVectorType, Product<Lhs, Rhs, LazyProduct>, OnTheRight> Base;\n  using Base::m_diagImpl;\n  using Base::m_matImpl;\n  using Base::coeff;\n  typedef typename Base::Scalar Scalar;\n  \n  typedef Product<Lhs, Rhs, ProductKind> XprType;\n  typedef typename XprType::PlainObject PlainObject;\n  \n  enum { StorageOrder = int(Lhs::Flags) & RowMajorBit ? RowMajor : ColMajor };\n\n  EIGEN_DEVICE_FUNC explicit product_evaluator(const XprType& xpr)\n    : Base(xpr.lhs(), xpr.rhs().diagonal())\n  {\n  }\n  \n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff(Index row, Index col) const\n  {\n    return m_matImpl.coeff(row, col) * m_diagImpl.coeff(col);\n  }\n  \n#ifndef __CUDACC__\n  template<int LoadMode,typename PacketType>\n  EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const\n  {\n    return this->template packet_impl<LoadMode,PacketType>(row,col, col,\n                                 typename internal::conditional<int(StorageOrder)==ColMajor, internal::true_type, internal::false_type>::type());\n  }\n  \n  template<int LoadMode,typename PacketType>\n  EIGEN_STRONG_INLINE PacketType packet(Index idx) const\n  {\n    return packet<LoadMode,PacketType>(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx);\n  }\n#endif\n};\n\n/***************************************************************************\n* Products with permutation matrices\n***************************************************************************/\n\n/** \\internal\n  * \\class permutation_matrix_product\n  * Internal helper class implementing the product between a permutation matrix and a matrix.\n  * This class is specialized for DenseShape below and for SparseShape in SparseCore/SparsePermutation.h\n  */\ntemplate<typename ExpressionType, int Side, bool Transposed, typename ExpressionShape>\nstruct permutation_matrix_product;\n\ntemplate<typename ExpressionType, int Side, bool Transposed>\nstruct permutation_matrix_product<ExpressionType, Side, Transposed, DenseShape>\n{\n    typedef typename nested_eval<ExpressionType, 1>::type MatrixType;\n    typedef typename remove_all<MatrixType>::type MatrixTypeCleaned;\n\n    template<typename Dest, typename PermutationType>\n    static inline void run(Dest& dst, const PermutationType& perm, const ExpressionType& xpr)\n    {\n      MatrixType mat(xpr);\n      const Index n = Side==OnTheLeft ? mat.rows() : mat.cols();\n      // FIXME we need an is_same for expression that is not sensitive to constness. For instance\n      // is_same_xpr<Block<const Matrix>, Block<Matrix> >::value should be true.\n      //if(is_same<MatrixTypeCleaned,Dest>::value && extract_data(dst) == extract_data(mat))\n      if(is_same_dense(dst, mat))\n      {\n        // apply the permutation inplace\n        Matrix<bool,PermutationType::RowsAtCompileTime,1,0,PermutationType::MaxRowsAtCompileTime> mask(perm.size());\n        mask.fill(false);\n        Index r = 0;\n        while(r < perm.size())\n        {\n          // search for the next seed\n          while(r<perm.size() && mask[r]) r++;\n          if(r>=perm.size())\n            break;\n          // we got one, let's follow it until we are back to the seed\n          Index k0 = r++;\n          Index kPrev = k0;\n          mask.coeffRef(k0) = true;\n          for(Index k=perm.indices().coeff(k0); k!=k0; k=perm.indices().coeff(k))\n          {\n                  Block<Dest, Side==OnTheLeft ? 1 : Dest::RowsAtCompileTime, Side==OnTheRight ? 1 : Dest::ColsAtCompileTime>(dst, k)\n            .swap(Block<Dest, Side==OnTheLeft ? 1 : Dest::RowsAtCompileTime, Side==OnTheRight ? 1 : Dest::ColsAtCompileTime>\n                       (dst,((Side==OnTheLeft) ^ Transposed) ? k0 : kPrev));\n\n            mask.coeffRef(k) = true;\n            kPrev = k;\n          }\n        }\n      }\n      else\n      {\n        for(Index i = 0; i < n; ++i)\n        {\n          Block<Dest, Side==OnTheLeft ? 1 : Dest::RowsAtCompileTime, Side==OnTheRight ? 1 : Dest::ColsAtCompileTime>\n               (dst, ((Side==OnTheLeft) ^ Transposed) ? perm.indices().coeff(i) : i)\n\n          =\n\n          Block<const MatrixTypeCleaned,Side==OnTheLeft ? 1 : MatrixTypeCleaned::RowsAtCompileTime,Side==OnTheRight ? 1 : MatrixTypeCleaned::ColsAtCompileTime>\n               (mat, ((Side==OnTheRight) ^ Transposed) ? perm.indices().coeff(i) : i);\n        }\n      }\n    }\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag, typename MatrixShape>\nstruct generic_product_impl<Lhs, Rhs, PermutationShape, MatrixShape, ProductTag>\n{\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    permutation_matrix_product<Rhs, OnTheLeft, false, MatrixShape>::run(dst, lhs, rhs);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag, typename MatrixShape>\nstruct generic_product_impl<Lhs, Rhs, MatrixShape, PermutationShape, ProductTag>\n{\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    permutation_matrix_product<Lhs, OnTheRight, false, MatrixShape>::run(dst, rhs, lhs);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag, typename MatrixShape>\nstruct generic_product_impl<Inverse<Lhs>, Rhs, PermutationShape, MatrixShape, ProductTag>\n{\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Inverse<Lhs>& lhs, const Rhs& rhs)\n  {\n    permutation_matrix_product<Rhs, OnTheLeft, true, MatrixShape>::run(dst, lhs.nestedExpression(), rhs);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag, typename MatrixShape>\nstruct generic_product_impl<Lhs, Inverse<Rhs>, MatrixShape, PermutationShape, ProductTag>\n{\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Lhs& lhs, const Inverse<Rhs>& rhs)\n  {\n    permutation_matrix_product<Lhs, OnTheRight, true, MatrixShape>::run(dst, rhs.nestedExpression(), lhs);\n  }\n};\n\n\n/***************************************************************************\n* Products with transpositions matrices\n***************************************************************************/\n\n// FIXME could we unify Transpositions and Permutation into a single \"shape\"??\n\n/** \\internal\n  * \\class transposition_matrix_product\n  * Internal helper class implementing the product between a permutation matrix and a matrix.\n  */\ntemplate<typename ExpressionType, int Side, bool Transposed, typename ExpressionShape>\nstruct transposition_matrix_product\n{\n  typedef typename nested_eval<ExpressionType, 1>::type MatrixType;\n  typedef typename remove_all<MatrixType>::type MatrixTypeCleaned;\n  \n  template<typename Dest, typename TranspositionType>\n  static inline void run(Dest& dst, const TranspositionType& tr, const ExpressionType& xpr)\n  {\n    MatrixType mat(xpr);\n    typedef typename TranspositionType::StorageIndex StorageIndex;\n    const Index size = tr.size();\n    StorageIndex j = 0;\n\n    if(!is_same_dense(dst,mat))\n      dst = mat;\n\n    for(Index k=(Transposed?size-1:0) ; Transposed?k>=0:k<size ; Transposed?--k:++k)\n      if(Index(j=tr.coeff(k))!=k)\n      {\n        if(Side==OnTheLeft)        dst.row(k).swap(dst.row(j));\n        else if(Side==OnTheRight)  dst.col(k).swap(dst.col(j));\n      }\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag, typename MatrixShape>\nstruct generic_product_impl<Lhs, Rhs, TranspositionsShape, MatrixShape, ProductTag>\n{\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    transposition_matrix_product<Rhs, OnTheLeft, false, MatrixShape>::run(dst, lhs, rhs);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag, typename MatrixShape>\nstruct generic_product_impl<Lhs, Rhs, MatrixShape, TranspositionsShape, ProductTag>\n{\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    transposition_matrix_product<Lhs, OnTheRight, false, MatrixShape>::run(dst, rhs, lhs);\n  }\n};\n\n\ntemplate<typename Lhs, typename Rhs, int ProductTag, typename MatrixShape>\nstruct generic_product_impl<Transpose<Lhs>, Rhs, TranspositionsShape, MatrixShape, ProductTag>\n{\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Transpose<Lhs>& lhs, const Rhs& rhs)\n  {\n    transposition_matrix_product<Rhs, OnTheLeft, true, MatrixShape>::run(dst, lhs.nestedExpression(), rhs);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag, typename MatrixShape>\nstruct generic_product_impl<Lhs, Transpose<Rhs>, MatrixShape, TranspositionsShape, ProductTag>\n{\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Lhs& lhs, const Transpose<Rhs>& rhs)\n  {\n    transposition_matrix_product<Lhs, OnTheRight, true, MatrixShape>::run(dst, rhs.nestedExpression(), lhs);\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_PRODUCT_EVALUATORS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Random.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_RANDOM_H\n#define EIGEN_RANDOM_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Scalar> struct scalar_random_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_random_op)\n  inline const Scalar operator() () const { return random<Scalar>(); }\n};\n\ntemplate<typename Scalar>\nstruct functor_traits<scalar_random_op<Scalar> >\n{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false }; };\n\n} // end namespace internal\n\n/** \\returns a random matrix expression\n  *\n  * Numbers are uniformly spread through their whole definition range for integer types,\n  * and in the [-1:1] range for floating point scalar types.\n  * \n  * The parameters \\a rows and \\a cols are the number of rows and of columns of\n  * the returned matrix. Must be compatible with this MatrixBase type.\n  *\n  * \\not_reentrant\n  * \n  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,\n  * it is redundant to pass \\a rows and \\a cols as arguments, so Random() should be used\n  * instead.\n  * \n  *\n  * Example: \\include MatrixBase_random_int_int.cpp\n  * Output: \\verbinclude MatrixBase_random_int_int.out\n  *\n  * This expression has the \"evaluate before nesting\" flag so that it will be evaluated into\n  * a temporary matrix whenever it is nested in a larger expression. This prevents unexpected\n  * behavior with expressions involving random matrices.\n  * \n  * See DenseBase::NullaryExpr(Index, const CustomNullaryOp&) for an example using C++11 random generators.\n  *\n  * \\sa DenseBase::setRandom(), DenseBase::Random(Index), DenseBase::Random()\n  */\ntemplate<typename Derived>\ninline const typename DenseBase<Derived>::RandomReturnType\nDenseBase<Derived>::Random(Index rows, Index cols)\n{\n  return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());\n}\n\n/** \\returns a random vector expression\n  *\n  * Numbers are uniformly spread through their whole definition range for integer types,\n  * and in the [-1:1] range for floating point scalar types.\n  *\n  * The parameter \\a size is the size of the returned vector.\n  * Must be compatible with this MatrixBase type.\n  *\n  * \\only_for_vectors\n  * \\not_reentrant\n  *\n  * This variant is meant to be used for dynamic-size vector types. For fixed-size types,\n  * it is redundant to pass \\a size as argument, so Random() should be used\n  * instead.\n  *\n  * Example: \\include MatrixBase_random_int.cpp\n  * Output: \\verbinclude MatrixBase_random_int.out\n  *\n  * This expression has the \"evaluate before nesting\" flag so that it will be evaluated into\n  * a temporary vector whenever it is nested in a larger expression. This prevents unexpected\n  * behavior with expressions involving random matrices.\n  *\n  * \\sa DenseBase::setRandom(), DenseBase::Random(Index,Index), DenseBase::Random()\n  */\ntemplate<typename Derived>\ninline const typename DenseBase<Derived>::RandomReturnType\nDenseBase<Derived>::Random(Index size)\n{\n  return NullaryExpr(size, internal::scalar_random_op<Scalar>());\n}\n\n/** \\returns a fixed-size random matrix or vector expression\n  *\n  * Numbers are uniformly spread through their whole definition range for integer types,\n  * and in the [-1:1] range for floating point scalar types.\n  * \n  * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you\n  * need to use the variants taking size arguments.\n  *\n  * Example: \\include MatrixBase_random.cpp\n  * Output: \\verbinclude MatrixBase_random.out\n  *\n  * This expression has the \"evaluate before nesting\" flag so that it will be evaluated into\n  * a temporary matrix whenever it is nested in a larger expression. This prevents unexpected\n  * behavior with expressions involving random matrices.\n  * \n  * \\not_reentrant\n  *\n  * \\sa DenseBase::setRandom(), DenseBase::Random(Index,Index), DenseBase::Random(Index)\n  */\ntemplate<typename Derived>\ninline const typename DenseBase<Derived>::RandomReturnType\nDenseBase<Derived>::Random()\n{\n  return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());\n}\n\n/** Sets all coefficients in this expression to random values.\n  *\n  * Numbers are uniformly spread through their whole definition range for integer types,\n  * and in the [-1:1] range for floating point scalar types.\n  * \n  * \\not_reentrant\n  * \n  * Example: \\include MatrixBase_setRandom.cpp\n  * Output: \\verbinclude MatrixBase_setRandom.out\n  *\n  * \\sa class CwiseNullaryOp, setRandom(Index), setRandom(Index,Index)\n  */\ntemplate<typename Derived>\ninline Derived& DenseBase<Derived>::setRandom()\n{\n  return *this = Random(rows(), cols());\n}\n\n/** Resizes to the given \\a newSize, and sets all coefficients in this expression to random values.\n  *\n  * Numbers are uniformly spread through their whole definition range for integer types,\n  * and in the [-1:1] range for floating point scalar types.\n  * \n  * \\only_for_vectors\n  * \\not_reentrant\n  *\n  * Example: \\include Matrix_setRandom_int.cpp\n  * Output: \\verbinclude Matrix_setRandom_int.out\n  *\n  * \\sa DenseBase::setRandom(), setRandom(Index,Index), class CwiseNullaryOp, DenseBase::Random()\n  */\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE Derived&\nPlainObjectBase<Derived>::setRandom(Index newSize)\n{\n  resize(newSize);\n  return setRandom();\n}\n\n/** Resizes to the given size, and sets all coefficients in this expression to random values.\n  *\n  * Numbers are uniformly spread through their whole definition range for integer types,\n  * and in the [-1:1] range for floating point scalar types.\n  *\n  * \\not_reentrant\n  * \n  * \\param rows the new number of rows\n  * \\param cols the new number of columns\n  *\n  * Example: \\include Matrix_setRandom_int_int.cpp\n  * Output: \\verbinclude Matrix_setRandom_int_int.out\n  *\n  * \\sa DenseBase::setRandom(), setRandom(Index), class CwiseNullaryOp, DenseBase::Random()\n  */\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE Derived&\nPlainObjectBase<Derived>::setRandom(Index rows, Index cols)\n{\n  resize(rows, cols);\n  return setRandom();\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_RANDOM_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Redux.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_REDUX_H\n#define EIGEN_REDUX_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n// TODO\n//  * implement other kind of vectorization\n//  * factorize code\n\n/***************************************************************************\n* Part 1 : the logic deciding a strategy for vectorization and unrolling\n***************************************************************************/\n\ntemplate<typename Func, typename Derived>\nstruct redux_traits\n{\npublic:\n    typedef typename find_best_packet<typename Derived::Scalar,Derived::SizeAtCompileTime>::type PacketType;\n  enum {\n    PacketSize = unpacket_traits<PacketType>::size,\n    InnerMaxSize = int(Derived::IsRowMajor)\n                 ? Derived::MaxColsAtCompileTime\n                 : Derived::MaxRowsAtCompileTime\n  };\n\n  enum {\n    MightVectorize = (int(Derived::Flags)&ActualPacketAccessBit)\n                  && (functor_traits<Func>::PacketAccess),\n    MayLinearVectorize = bool(MightVectorize) && (int(Derived::Flags)&LinearAccessBit),\n    MaySliceVectorize  = bool(MightVectorize) && int(InnerMaxSize)>=3*PacketSize\n  };\n\npublic:\n  enum {\n    Traversal = int(MayLinearVectorize) ? int(LinearVectorizedTraversal)\n              : int(MaySliceVectorize)  ? int(SliceVectorizedTraversal)\n                                        : int(DefaultTraversal)\n  };\n\npublic:\n  enum {\n    Cost = Derived::SizeAtCompileTime == Dynamic ? HugeCost\n         : Derived::SizeAtCompileTime * Derived::CoeffReadCost + (Derived::SizeAtCompileTime-1) * functor_traits<Func>::Cost,\n    UnrollingLimit = EIGEN_UNROLLING_LIMIT * (int(Traversal) == int(DefaultTraversal) ? 1 : int(PacketSize))\n  };\n\npublic:\n  enum {\n    Unrolling = Cost <= UnrollingLimit ? CompleteUnrolling : NoUnrolling\n  };\n  \n#ifdef EIGEN_DEBUG_ASSIGN\n  static void debug()\n  {\n    std::cerr << \"Xpr: \" << typeid(typename Derived::XprType).name() << std::endl;\n    std::cerr.setf(std::ios::hex, std::ios::basefield);\n    EIGEN_DEBUG_VAR(Derived::Flags)\n    std::cerr.unsetf(std::ios::hex);\n    EIGEN_DEBUG_VAR(InnerMaxSize)\n    EIGEN_DEBUG_VAR(PacketSize)\n    EIGEN_DEBUG_VAR(MightVectorize)\n    EIGEN_DEBUG_VAR(MayLinearVectorize)\n    EIGEN_DEBUG_VAR(MaySliceVectorize)\n    EIGEN_DEBUG_VAR(Traversal)\n    EIGEN_DEBUG_VAR(UnrollingLimit)\n    EIGEN_DEBUG_VAR(Unrolling)\n    std::cerr << std::endl;\n  }\n#endif\n};\n\n/***************************************************************************\n* Part 2 : unrollers\n***************************************************************************/\n\n/*** no vectorization ***/\n\ntemplate<typename Func, typename Derived, int Start, int Length>\nstruct redux_novec_unroller\n{\n  enum {\n    HalfLength = Length/2\n  };\n\n  typedef typename Derived::Scalar Scalar;\n\n  EIGEN_DEVICE_FUNC\n  static EIGEN_STRONG_INLINE Scalar run(const Derived &mat, const Func& func)\n  {\n    return func(redux_novec_unroller<Func, Derived, Start, HalfLength>::run(mat,func),\n                redux_novec_unroller<Func, Derived, Start+HalfLength, Length-HalfLength>::run(mat,func));\n  }\n};\n\ntemplate<typename Func, typename Derived, int Start>\nstruct redux_novec_unroller<Func, Derived, Start, 1>\n{\n  enum {\n    outer = Start / Derived::InnerSizeAtCompileTime,\n    inner = Start % Derived::InnerSizeAtCompileTime\n  };\n\n  typedef typename Derived::Scalar Scalar;\n\n  EIGEN_DEVICE_FUNC\n  static EIGEN_STRONG_INLINE Scalar run(const Derived &mat, const Func&)\n  {\n    return mat.coeffByOuterInner(outer, inner);\n  }\n};\n\n// This is actually dead code and will never be called. It is required\n// to prevent false warnings regarding failed inlining though\n// for 0 length run() will never be called at all.\ntemplate<typename Func, typename Derived, int Start>\nstruct redux_novec_unroller<Func, Derived, Start, 0>\n{\n  typedef typename Derived::Scalar Scalar;\n  EIGEN_DEVICE_FUNC \n  static EIGEN_STRONG_INLINE Scalar run(const Derived&, const Func&) { return Scalar(); }\n};\n\n/*** vectorization ***/\n\ntemplate<typename Func, typename Derived, int Start, int Length>\nstruct redux_vec_unroller\n{\n  enum {\n    PacketSize = redux_traits<Func, Derived>::PacketSize,\n    HalfLength = Length/2\n  };\n\n  typedef typename Derived::Scalar Scalar;\n  typedef typename redux_traits<Func, Derived>::PacketType PacketScalar;\n\n  static EIGEN_STRONG_INLINE PacketScalar run(const Derived &mat, const Func& func)\n  {\n    return func.packetOp(\n            redux_vec_unroller<Func, Derived, Start, HalfLength>::run(mat,func),\n            redux_vec_unroller<Func, Derived, Start+HalfLength, Length-HalfLength>::run(mat,func) );\n  }\n};\n\ntemplate<typename Func, typename Derived, int Start>\nstruct redux_vec_unroller<Func, Derived, Start, 1>\n{\n  enum {\n    index = Start * redux_traits<Func, Derived>::PacketSize,\n    outer = index / int(Derived::InnerSizeAtCompileTime),\n    inner = index % int(Derived::InnerSizeAtCompileTime),\n    alignment = Derived::Alignment\n  };\n\n  typedef typename Derived::Scalar Scalar;\n  typedef typename redux_traits<Func, Derived>::PacketType PacketScalar;\n\n  static EIGEN_STRONG_INLINE PacketScalar run(const Derived &mat, const Func&)\n  {\n    return mat.template packetByOuterInner<alignment,PacketScalar>(outer, inner);\n  }\n};\n\n/***************************************************************************\n* Part 3 : implementation of all cases\n***************************************************************************/\n\ntemplate<typename Func, typename Derived,\n         int Traversal = redux_traits<Func, Derived>::Traversal,\n         int Unrolling = redux_traits<Func, Derived>::Unrolling\n>\nstruct redux_impl;\n\ntemplate<typename Func, typename Derived>\nstruct redux_impl<Func, Derived, DefaultTraversal, NoUnrolling>\n{\n  typedef typename Derived::Scalar Scalar;\n  EIGEN_DEVICE_FUNC\n  static EIGEN_STRONG_INLINE Scalar run(const Derived &mat, const Func& func)\n  {\n    eigen_assert(mat.rows()>0 && mat.cols()>0 && \"you are using an empty matrix\");\n    Scalar res;\n    res = mat.coeffByOuterInner(0, 0);\n    for(Index i = 1; i < mat.innerSize(); ++i)\n      res = func(res, mat.coeffByOuterInner(0, i));\n    for(Index i = 1; i < mat.outerSize(); ++i)\n      for(Index j = 0; j < mat.innerSize(); ++j)\n        res = func(res, mat.coeffByOuterInner(i, j));\n    return res;\n  }\n};\n\ntemplate<typename Func, typename Derived>\nstruct redux_impl<Func,Derived, DefaultTraversal, CompleteUnrolling>\n  : public redux_novec_unroller<Func,Derived, 0, Derived::SizeAtCompileTime>\n{};\n\ntemplate<typename Func, typename Derived>\nstruct redux_impl<Func, Derived, LinearVectorizedTraversal, NoUnrolling>\n{\n  typedef typename Derived::Scalar Scalar;\n  typedef typename redux_traits<Func, Derived>::PacketType PacketScalar;\n\n  static Scalar run(const Derived &mat, const Func& func)\n  {\n    const Index size = mat.size();\n    \n    const Index packetSize = redux_traits<Func, Derived>::PacketSize;\n    const int packetAlignment = unpacket_traits<PacketScalar>::alignment;\n    enum {\n      alignment0 = (bool(Derived::Flags & DirectAccessBit) && bool(packet_traits<Scalar>::AlignedOnScalar)) ? int(packetAlignment) : int(Unaligned),\n      alignment = EIGEN_PLAIN_ENUM_MAX(alignment0, Derived::Alignment)\n    };\n    const Index alignedStart = internal::first_default_aligned(mat.nestedExpression());\n    const Index alignedSize2 = ((size-alignedStart)/(2*packetSize))*(2*packetSize);\n    const Index alignedSize = ((size-alignedStart)/(packetSize))*(packetSize);\n    const Index alignedEnd2 = alignedStart + alignedSize2;\n    const Index alignedEnd  = alignedStart + alignedSize;\n    Scalar res;\n    if(alignedSize)\n    {\n      PacketScalar packet_res0 = mat.template packet<alignment,PacketScalar>(alignedStart);\n      if(alignedSize>packetSize) // we have at least two packets to partly unroll the loop\n      {\n        PacketScalar packet_res1 = mat.template packet<alignment,PacketScalar>(alignedStart+packetSize);\n        for(Index index = alignedStart + 2*packetSize; index < alignedEnd2; index += 2*packetSize)\n        {\n          packet_res0 = func.packetOp(packet_res0, mat.template packet<alignment,PacketScalar>(index));\n          packet_res1 = func.packetOp(packet_res1, mat.template packet<alignment,PacketScalar>(index+packetSize));\n        }\n\n        packet_res0 = func.packetOp(packet_res0,packet_res1);\n        if(alignedEnd>alignedEnd2)\n          packet_res0 = func.packetOp(packet_res0, mat.template packet<alignment,PacketScalar>(alignedEnd2));\n      }\n      res = func.predux(packet_res0);\n\n      for(Index index = 0; index < alignedStart; ++index)\n        res = func(res,mat.coeff(index));\n\n      for(Index index = alignedEnd; index < size; ++index)\n        res = func(res,mat.coeff(index));\n    }\n    else // too small to vectorize anything.\n         // since this is dynamic-size hence inefficient anyway for such small sizes, don't try to optimize.\n    {\n      res = mat.coeff(0);\n      for(Index index = 1; index < size; ++index)\n        res = func(res,mat.coeff(index));\n    }\n\n    return res;\n  }\n};\n\n// NOTE: for SliceVectorizedTraversal we simply bypass unrolling\ntemplate<typename Func, typename Derived, int Unrolling>\nstruct redux_impl<Func, Derived, SliceVectorizedTraversal, Unrolling>\n{\n  typedef typename Derived::Scalar Scalar;\n  typedef typename redux_traits<Func, Derived>::PacketType PacketType;\n\n  EIGEN_DEVICE_FUNC static Scalar run(const Derived &mat, const Func& func)\n  {\n    eigen_assert(mat.rows()>0 && mat.cols()>0 && \"you are using an empty matrix\");\n    const Index innerSize = mat.innerSize();\n    const Index outerSize = mat.outerSize();\n    enum {\n      packetSize = redux_traits<Func, Derived>::PacketSize\n    };\n    const Index packetedInnerSize = ((innerSize)/packetSize)*packetSize;\n    Scalar res;\n    if(packetedInnerSize)\n    {\n      PacketType packet_res = mat.template packet<Unaligned,PacketType>(0,0);\n      for(Index j=0; j<outerSize; ++j)\n        for(Index i=(j==0?packetSize:0); i<packetedInnerSize; i+=Index(packetSize))\n          packet_res = func.packetOp(packet_res, mat.template packetByOuterInner<Unaligned,PacketType>(j,i));\n\n      res = func.predux(packet_res);\n      for(Index j=0; j<outerSize; ++j)\n        for(Index i=packetedInnerSize; i<innerSize; ++i)\n          res = func(res, mat.coeffByOuterInner(j,i));\n    }\n    else // too small to vectorize anything.\n         // since this is dynamic-size hence inefficient anyway for such small sizes, don't try to optimize.\n    {\n      res = redux_impl<Func, Derived, DefaultTraversal, NoUnrolling>::run(mat, func);\n    }\n\n    return res;\n  }\n};\n\ntemplate<typename Func, typename Derived>\nstruct redux_impl<Func, Derived, LinearVectorizedTraversal, CompleteUnrolling>\n{\n  typedef typename Derived::Scalar Scalar;\n\n  typedef typename redux_traits<Func, Derived>::PacketType PacketScalar;\n  enum {\n    PacketSize = redux_traits<Func, Derived>::PacketSize,\n    Size = Derived::SizeAtCompileTime,\n    VectorizedSize = (Size / PacketSize) * PacketSize\n  };\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Scalar run(const Derived &mat, const Func& func)\n  {\n    eigen_assert(mat.rows()>0 && mat.cols()>0 && \"you are using an empty matrix\");\n    if (VectorizedSize > 0) {\n      Scalar res = func.predux(redux_vec_unroller<Func, Derived, 0, Size / PacketSize>::run(mat,func));\n      if (VectorizedSize != Size)\n        res = func(res,redux_novec_unroller<Func, Derived, VectorizedSize, Size-VectorizedSize>::run(mat,func));\n      return res;\n    }\n    else {\n      return redux_novec_unroller<Func, Derived, 0, Size>::run(mat,func);\n    }\n  }\n};\n\n// evaluator adaptor\ntemplate<typename _XprType>\nclass redux_evaluator\n{\npublic:\n  typedef _XprType XprType;\n  EIGEN_DEVICE_FUNC explicit redux_evaluator(const XprType &xpr) : m_evaluator(xpr), m_xpr(xpr) {}\n  \n  typedef typename XprType::Scalar Scalar;\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n  typedef typename XprType::PacketScalar PacketScalar;\n  typedef typename XprType::PacketReturnType PacketReturnType;\n  \n  enum {\n    MaxRowsAtCompileTime = XprType::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = XprType::MaxColsAtCompileTime,\n    // TODO we should not remove DirectAccessBit and rather find an elegant way to query the alignment offset at runtime from the evaluator\n    Flags = evaluator<XprType>::Flags & ~DirectAccessBit,\n    IsRowMajor = XprType::IsRowMajor,\n    SizeAtCompileTime = XprType::SizeAtCompileTime,\n    InnerSizeAtCompileTime = XprType::InnerSizeAtCompileTime,\n    CoeffReadCost = evaluator<XprType>::CoeffReadCost,\n    Alignment = evaluator<XprType>::Alignment\n  };\n  \n  EIGEN_DEVICE_FUNC Index rows() const { return m_xpr.rows(); }\n  EIGEN_DEVICE_FUNC Index cols() const { return m_xpr.cols(); }\n  EIGEN_DEVICE_FUNC Index size() const { return m_xpr.size(); }\n  EIGEN_DEVICE_FUNC Index innerSize() const { return m_xpr.innerSize(); }\n  EIGEN_DEVICE_FUNC Index outerSize() const { return m_xpr.outerSize(); }\n\n  EIGEN_DEVICE_FUNC\n  CoeffReturnType coeff(Index row, Index col) const\n  { return m_evaluator.coeff(row, col); }\n\n  EIGEN_DEVICE_FUNC\n  CoeffReturnType coeff(Index index) const\n  { return m_evaluator.coeff(index); }\n\n  template<int LoadMode, typename PacketType>\n  PacketType packet(Index row, Index col) const\n  { return m_evaluator.template packet<LoadMode,PacketType>(row, col); }\n\n  template<int LoadMode, typename PacketType>\n  PacketType packet(Index index) const\n  { return m_evaluator.template packet<LoadMode,PacketType>(index); }\n  \n  EIGEN_DEVICE_FUNC\n  CoeffReturnType coeffByOuterInner(Index outer, Index inner) const\n  { return m_evaluator.coeff(IsRowMajor ? outer : inner, IsRowMajor ? inner : outer); }\n  \n  template<int LoadMode, typename PacketType>\n  PacketType packetByOuterInner(Index outer, Index inner) const\n  { return m_evaluator.template packet<LoadMode,PacketType>(IsRowMajor ? outer : inner, IsRowMajor ? inner : outer); }\n  \n  const XprType & nestedExpression() const { return m_xpr; }\n  \nprotected:\n  internal::evaluator<XprType> m_evaluator;\n  const XprType &m_xpr;\n};\n\n} // end namespace internal\n\n/***************************************************************************\n* Part 4 : public API\n***************************************************************************/\n\n\n/** \\returns the result of a full redux operation on the whole matrix or vector using \\a func\n  *\n  * The template parameter \\a BinaryOp is the type of the functor \\a func which must be\n  * an associative operator. Both current C++98 and C++11 functor styles are handled.\n  *\n  * \\sa DenseBase::sum(), DenseBase::minCoeff(), DenseBase::maxCoeff(), MatrixBase::colwise(), MatrixBase::rowwise()\n  */\ntemplate<typename Derived>\ntemplate<typename Func>\ntypename internal::traits<Derived>::Scalar\nDenseBase<Derived>::redux(const Func& func) const\n{\n  eigen_assert(this->rows()>0 && this->cols()>0 && \"you are using an empty matrix\");\n\n  typedef typename internal::redux_evaluator<Derived> ThisEvaluator;\n  ThisEvaluator thisEval(derived());\n  \n  return internal::redux_impl<Func, ThisEvaluator>::run(thisEval, func);\n}\n\n/** \\returns the minimum of all coefficients of \\c *this.\n  * \\warning the result is undefined if \\c *this contains NaN.\n  */\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar\nDenseBase<Derived>::minCoeff() const\n{\n  return derived().redux(Eigen::internal::scalar_min_op<Scalar,Scalar>());\n}\n\n/** \\returns the maximum of all coefficients of \\c *this.\n  * \\warning the result is undefined if \\c *this contains NaN.\n  */\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar\nDenseBase<Derived>::maxCoeff() const\n{\n  return derived().redux(Eigen::internal::scalar_max_op<Scalar,Scalar>());\n}\n\n/** \\returns the sum of all coefficients of \\c *this\n  *\n  * If \\c *this is empty, then the value 0 is returned.\n  *\n  * \\sa trace(), prod(), mean()\n  */\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar\nDenseBase<Derived>::sum() const\n{\n  if(SizeAtCompileTime==0 || (SizeAtCompileTime==Dynamic && size()==0))\n    return Scalar(0);\n  return derived().redux(Eigen::internal::scalar_sum_op<Scalar,Scalar>());\n}\n\n/** \\returns the mean of all coefficients of *this\n*\n* \\sa trace(), prod(), sum()\n*/\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar\nDenseBase<Derived>::mean() const\n{\n#ifdef __INTEL_COMPILER\n  #pragma warning push\n  #pragma warning ( disable : 2259 )\n#endif\n  return Scalar(derived().redux(Eigen::internal::scalar_sum_op<Scalar,Scalar>())) / Scalar(this->size());\n#ifdef __INTEL_COMPILER\n  #pragma warning pop\n#endif\n}\n\n/** \\returns the product of all coefficients of *this\n  *\n  * Example: \\include MatrixBase_prod.cpp\n  * Output: \\verbinclude MatrixBase_prod.out\n  *\n  * \\sa sum(), mean(), trace()\n  */\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar\nDenseBase<Derived>::prod() const\n{\n  if(SizeAtCompileTime==0 || (SizeAtCompileTime==Dynamic && size()==0))\n    return Scalar(1);\n  return derived().redux(Eigen::internal::scalar_product_op<Scalar>());\n}\n\n/** \\returns the trace of \\c *this, i.e. the sum of the coefficients on the main diagonal.\n  *\n  * \\c *this can be any matrix, not necessarily square.\n  *\n  * \\sa diagonal(), sum()\n  */\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE typename internal::traits<Derived>::Scalar\nMatrixBase<Derived>::trace() const\n{\n  return derived().diagonal().sum();\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_REDUX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Ref.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_REF_H\n#define EIGEN_REF_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename _PlainObjectType, int _Options, typename _StrideType>\nstruct traits<Ref<_PlainObjectType, _Options, _StrideType> >\n  : public traits<Map<_PlainObjectType, _Options, _StrideType> >\n{\n  typedef _PlainObjectType PlainObjectType;\n  typedef _StrideType StrideType;\n  enum {\n    Options = _Options,\n    Flags = traits<Map<_PlainObjectType, _Options, _StrideType> >::Flags | NestByRefBit,\n    Alignment = traits<Map<_PlainObjectType, _Options, _StrideType> >::Alignment\n  };\n\n  template<typename Derived> struct match {\n    enum {\n      HasDirectAccess = internal::has_direct_access<Derived>::ret,\n      StorageOrderMatch = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime || ((PlainObjectType::Flags&RowMajorBit)==(Derived::Flags&RowMajorBit)),\n      InnerStrideMatch = int(StrideType::InnerStrideAtCompileTime)==int(Dynamic)\n                      || int(StrideType::InnerStrideAtCompileTime)==int(Derived::InnerStrideAtCompileTime)\n                      || (int(StrideType::InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1),\n      OuterStrideMatch = Derived::IsVectorAtCompileTime\n                      || int(StrideType::OuterStrideAtCompileTime)==int(Dynamic) || int(StrideType::OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime),\n      // NOTE, this indirection of evaluator<Derived>::Alignment is needed\n      // to workaround a very strange bug in MSVC related to the instantiation\n      // of has_*ary_operator in evaluator<CwiseNullaryOp>.\n      // This line is surprisingly very sensitive. For instance, simply adding parenthesis\n      // as \"DerivedAlignment = (int(evaluator<Derived>::Alignment)),\" will make MSVC fail...\n      DerivedAlignment = int(evaluator<Derived>::Alignment),\n      AlignmentMatch = (int(traits<PlainObjectType>::Alignment)==int(Unaligned)) || (DerivedAlignment >= int(Alignment)), // FIXME the first condition is not very clear, it should be replaced by the required alignment\n      ScalarTypeMatch = internal::is_same<typename PlainObjectType::Scalar, typename Derived::Scalar>::value,\n      MatchAtCompileTime = HasDirectAccess && StorageOrderMatch && InnerStrideMatch && OuterStrideMatch && AlignmentMatch && ScalarTypeMatch\n    };\n    typedef typename internal::conditional<MatchAtCompileTime,internal::true_type,internal::false_type>::type type;\n  };\n  \n};\n\ntemplate<typename Derived>\nstruct traits<RefBase<Derived> > : public traits<Derived> {};\n\n}\n\ntemplate<typename Derived> class RefBase\n : public MapBase<Derived>\n{\n  typedef typename internal::traits<Derived>::PlainObjectType PlainObjectType;\n  typedef typename internal::traits<Derived>::StrideType StrideType;\n\npublic:\n\n  typedef MapBase<Derived> Base;\n  EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)\n\n  EIGEN_DEVICE_FUNC inline Index innerStride() const\n  {\n    return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;\n  }\n\n  EIGEN_DEVICE_FUNC inline Index outerStride() const\n  {\n    return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()\n         : IsVectorAtCompileTime ? this->size()\n         : int(Flags)&RowMajorBit ? this->cols()\n         : this->rows();\n  }\n\n  EIGEN_DEVICE_FUNC RefBase()\n    : Base(0,RowsAtCompileTime==Dynamic?0:RowsAtCompileTime,ColsAtCompileTime==Dynamic?0:ColsAtCompileTime),\n      // Stride<> does not allow default ctor for Dynamic strides, so let' initialize it with dummy values:\n      m_stride(StrideType::OuterStrideAtCompileTime==Dynamic?0:StrideType::OuterStrideAtCompileTime,\n               StrideType::InnerStrideAtCompileTime==Dynamic?0:StrideType::InnerStrideAtCompileTime)\n  {}\n  \n  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(RefBase)\n\nprotected:\n\n  typedef Stride<StrideType::OuterStrideAtCompileTime,StrideType::InnerStrideAtCompileTime> StrideBase;\n\n  template<typename Expression>\n  EIGEN_DEVICE_FUNC void construct(Expression& expr)\n  {\n    if(PlainObjectType::RowsAtCompileTime==1)\n    {\n      eigen_assert(expr.rows()==1 || expr.cols()==1);\n      ::new (static_cast<Base*>(this)) Base(expr.data(), 1, expr.size());\n    }\n    else if(PlainObjectType::ColsAtCompileTime==1)\n    {\n      eigen_assert(expr.rows()==1 || expr.cols()==1);\n      ::new (static_cast<Base*>(this)) Base(expr.data(), expr.size(), 1);\n    }\n    else\n      ::new (static_cast<Base*>(this)) Base(expr.data(), expr.rows(), expr.cols());\n    \n    if(Expression::IsVectorAtCompileTime && (!PlainObjectType::IsVectorAtCompileTime) && ((Expression::Flags&RowMajorBit)!=(PlainObjectType::Flags&RowMajorBit)))\n      ::new (&m_stride) StrideBase(expr.innerStride(), StrideType::InnerStrideAtCompileTime==0?0:1);\n    else\n      ::new (&m_stride) StrideBase(StrideType::OuterStrideAtCompileTime==0?0:expr.outerStride(),\n                                   StrideType::InnerStrideAtCompileTime==0?0:expr.innerStride());    \n  }\n\n  StrideBase m_stride;\n};\n\n/** \\class Ref\n  * \\ingroup Core_Module\n  *\n  * \\brief A matrix or vector expression mapping an existing expression\n  *\n  * \\tparam PlainObjectType the equivalent matrix type of the mapped data\n  * \\tparam Options specifies the pointer alignment in bytes. It can be: \\c #Aligned128, , \\c #Aligned64, \\c #Aligned32, \\c #Aligned16, \\c #Aligned8 or \\c #Unaligned.\n  *                 The default is \\c #Unaligned.\n  * \\tparam StrideType optionally specifies strides. By default, Ref implies a contiguous storage along the inner dimension (inner stride==1),\n  *                   but accepts a variable outer stride (leading dimension).\n  *                   This can be overridden by specifying strides.\n  *                   The type passed here must be a specialization of the Stride template, see examples below.\n  *\n  * This class provides a way to write non-template functions taking Eigen objects as parameters while limiting the number of copies.\n  * A Ref<> object can represent either a const expression or a l-value:\n  * \\code\n  * // in-out argument:\n  * void foo1(Ref<VectorXf> x);\n  *\n  * // read-only const argument:\n  * void foo2(const Ref<const VectorXf>& x);\n  * \\endcode\n  *\n  * In the in-out case, the input argument must satisfy the constraints of the actual Ref<> type, otherwise a compilation issue will be triggered.\n  * By default, a Ref<VectorXf> can reference any dense vector expression of float having a contiguous memory layout.\n  * Likewise, a Ref<MatrixXf> can reference any column-major dense matrix expression of float whose column's elements are contiguously stored with\n  * the possibility to have a constant space in-between each column, i.e. the inner stride must be equal to 1, but the outer stride (or leading dimension)\n  * can be greater than the number of rows.\n  *\n  * In the const case, if the input expression does not match the above requirement, then it is evaluated into a temporary before being passed to the function.\n  * Here are some examples:\n  * \\code\n  * MatrixXf A;\n  * VectorXf a;\n  * foo1(a.head());             // OK\n  * foo1(A.col());              // OK\n  * foo1(A.row());              // Compilation error because here innerstride!=1\n  * foo2(A.row());              // Compilation error because A.row() is a 1xN object while foo2 is expecting a Nx1 object\n  * foo2(A.row().transpose());  // The row is copied into a contiguous temporary\n  * foo2(2*a);                  // The expression is evaluated into a temporary\n  * foo2(A.col().segment(2,4)); // No temporary\n  * \\endcode\n  *\n  * The range of inputs that can be referenced without temporary can be enlarged using the last two template parameters.\n  * Here is an example accepting an innerstride!=1:\n  * \\code\n  * // in-out argument:\n  * void foo3(Ref<VectorXf,0,InnerStride<> > x);\n  * foo3(A.row());              // OK\n  * \\endcode\n  * The downside here is that the function foo3 might be significantly slower than foo1 because it won't be able to exploit vectorization, and will involve more\n  * expensive address computations even if the input is contiguously stored in memory. To overcome this issue, one might propose to overload internally calling a\n  * template function, e.g.:\n  * \\code\n  * // in the .h:\n  * void foo(const Ref<MatrixXf>& A);\n  * void foo(const Ref<MatrixXf,0,Stride<> >& A);\n  *\n  * // in the .cpp:\n  * template<typename TypeOfA> void foo_impl(const TypeOfA& A) {\n  *     ... // crazy code goes here\n  * }\n  * void foo(const Ref<MatrixXf>& A) { foo_impl(A); }\n  * void foo(const Ref<MatrixXf,0,Stride<> >& A) { foo_impl(A); }\n  * \\endcode\n  *\n  *\n  * \\sa PlainObjectBase::Map(), \\ref TopicStorageOrders\n  */\ntemplate<typename PlainObjectType, int Options, typename StrideType> class Ref\n  : public RefBase<Ref<PlainObjectType, Options, StrideType> >\n{\n  private:\n    typedef internal::traits<Ref> Traits;\n    template<typename Derived>\n    EIGEN_DEVICE_FUNC inline Ref(const PlainObjectBase<Derived>& expr,\n                                 typename internal::enable_if<bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0);\n  public:\n\n    typedef RefBase<Ref> Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(Ref)\n\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename Derived>\n    EIGEN_DEVICE_FUNC inline Ref(PlainObjectBase<Derived>& expr,\n                                 typename internal::enable_if<bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0)\n    {\n      EIGEN_STATIC_ASSERT(bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);\n      Base::construct(expr.derived());\n    }\n    template<typename Derived>\n    EIGEN_DEVICE_FUNC inline Ref(const DenseBase<Derived>& expr,\n                                 typename internal::enable_if<bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0)\n    #else\n    /** Implicit constructor from any dense expression */\n    template<typename Derived>\n    inline Ref(DenseBase<Derived>& expr)\n    #endif\n    {\n      EIGEN_STATIC_ASSERT(bool(internal::is_lvalue<Derived>::value), THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);\n      EIGEN_STATIC_ASSERT(bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);\n      EIGEN_STATIC_ASSERT(!Derived::IsPlainObjectBase,THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);\n      Base::construct(expr.const_cast_derived());\n    }\n\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Ref)\n\n};\n\n// this is the const ref version\ntemplate<typename TPlainObjectType, int Options, typename StrideType> class Ref<const TPlainObjectType, Options, StrideType>\n  : public RefBase<Ref<const TPlainObjectType, Options, StrideType> >\n{\n    typedef internal::traits<Ref> Traits;\n  public:\n\n    typedef RefBase<Ref> Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(Ref)\n\n    template<typename Derived>\n    EIGEN_DEVICE_FUNC inline Ref(const DenseBase<Derived>& expr,\n                                 typename internal::enable_if<bool(Traits::template match<Derived>::ScalarTypeMatch),Derived>::type* = 0)\n    {\n//      std::cout << match_helper<Derived>::HasDirectAccess << \",\" << match_helper<Derived>::OuterStrideMatch << \",\" << match_helper<Derived>::InnerStrideMatch << \"\\n\";\n//      std::cout << int(StrideType::OuterStrideAtCompileTime) << \" - \" << int(Derived::OuterStrideAtCompileTime) << \"\\n\";\n//      std::cout << int(StrideType::InnerStrideAtCompileTime) << \" - \" << int(Derived::InnerStrideAtCompileTime) << \"\\n\";\n      construct(expr.derived(), typename Traits::template match<Derived>::type());\n    }\n\n    EIGEN_DEVICE_FUNC inline Ref(const Ref& other) : Base(other) {\n      // copy constructor shall not copy the m_object, to avoid unnecessary malloc and copy\n    }\n\n    template<typename OtherRef>\n    EIGEN_DEVICE_FUNC inline Ref(const RefBase<OtherRef>& other) {\n      construct(other.derived(), typename Traits::template match<OtherRef>::type());\n    }\n\n  protected:\n\n    template<typename Expression>\n    EIGEN_DEVICE_FUNC void construct(const Expression& expr,internal::true_type)\n    {\n      Base::construct(expr);\n    }\n\n    template<typename Expression>\n    EIGEN_DEVICE_FUNC void construct(const Expression& expr, internal::false_type)\n    {\n      internal::call_assignment_no_alias(m_object,expr,internal::assign_op<Scalar,Scalar>());\n      Base::construct(m_object);\n    }\n\n  protected:\n    TPlainObjectType m_object;\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_REF_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Replicate.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_REPLICATE_H\n#define EIGEN_REPLICATE_H\n\nnamespace Eigen { \n\nnamespace internal {\ntemplate<typename MatrixType,int RowFactor,int ColFactor>\nstruct traits<Replicate<MatrixType,RowFactor,ColFactor> >\n : traits<MatrixType>\n{\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename traits<MatrixType>::StorageKind StorageKind;\n  typedef typename traits<MatrixType>::XprKind XprKind;\n  typedef typename ref_selector<MatrixType>::type MatrixTypeNested;\n  typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;\n  enum {\n    RowsAtCompileTime = RowFactor==Dynamic || int(MatrixType::RowsAtCompileTime)==Dynamic\n                      ? Dynamic\n                      : RowFactor * MatrixType::RowsAtCompileTime,\n    ColsAtCompileTime = ColFactor==Dynamic || int(MatrixType::ColsAtCompileTime)==Dynamic\n                      ? Dynamic\n                      : ColFactor * MatrixType::ColsAtCompileTime,\n   //FIXME we don't propagate the max sizes !!!\n    MaxRowsAtCompileTime = RowsAtCompileTime,\n    MaxColsAtCompileTime = ColsAtCompileTime,\n    IsRowMajor = MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1 ? 1\n               : MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1 ? 0\n               : (MatrixType::Flags & RowMajorBit) ? 1 : 0,\n    \n    // FIXME enable DirectAccess with negative strides?\n    Flags = IsRowMajor ? RowMajorBit : 0\n  };\n};\n}\n\n/**\n  * \\class Replicate\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of the multiple replication of a matrix or vector\n  *\n  * \\tparam MatrixType the type of the object we are replicating\n  * \\tparam RowFactor number of repetitions at compile time along the vertical direction, can be Dynamic.\n  * \\tparam ColFactor number of repetitions at compile time along the horizontal direction, can be Dynamic.\n  *\n  * This class represents an expression of the multiple replication of a matrix or vector.\n  * It is the return type of DenseBase::replicate() and most of the time\n  * this is the only way it is used.\n  *\n  * \\sa DenseBase::replicate()\n  */\ntemplate<typename MatrixType,int RowFactor,int ColFactor> class Replicate\n  : public internal::dense_xpr_base< Replicate<MatrixType,RowFactor,ColFactor> >::type\n{\n    typedef typename internal::traits<Replicate>::MatrixTypeNested MatrixTypeNested;\n    typedef typename internal::traits<Replicate>::_MatrixTypeNested _MatrixTypeNested;\n  public:\n\n    typedef typename internal::dense_xpr_base<Replicate>::type Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(Replicate)\n    typedef typename internal::remove_all<MatrixType>::type NestedExpression;\n\n    template<typename OriginalMatrixType>\n    EIGEN_DEVICE_FUNC\n    inline explicit Replicate(const OriginalMatrixType& matrix)\n      : m_matrix(matrix), m_rowFactor(RowFactor), m_colFactor(ColFactor)\n    {\n      EIGEN_STATIC_ASSERT((internal::is_same<typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),\n                          THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)\n      eigen_assert(RowFactor!=Dynamic && ColFactor!=Dynamic);\n    }\n\n    template<typename OriginalMatrixType>\n    EIGEN_DEVICE_FUNC\n    inline Replicate(const OriginalMatrixType& matrix, Index rowFactor, Index colFactor)\n      : m_matrix(matrix), m_rowFactor(rowFactor), m_colFactor(colFactor)\n    {\n      EIGEN_STATIC_ASSERT((internal::is_same<typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),\n                          THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline Index rows() const { return m_matrix.rows() * m_rowFactor.value(); }\n    EIGEN_DEVICE_FUNC\n    inline Index cols() const { return m_matrix.cols() * m_colFactor.value(); }\n\n    EIGEN_DEVICE_FUNC\n    const _MatrixTypeNested& nestedExpression() const\n    { \n      return m_matrix; \n    }\n\n  protected:\n    MatrixTypeNested m_matrix;\n    const internal::variable_if_dynamic<Index, RowFactor> m_rowFactor;\n    const internal::variable_if_dynamic<Index, ColFactor> m_colFactor;\n};\n\n/**\n  * \\return an expression of the replication of \\c *this\n  *\n  * Example: \\include MatrixBase_replicate.cpp\n  * Output: \\verbinclude MatrixBase_replicate.out\n  *\n  * \\sa VectorwiseOp::replicate(), DenseBase::replicate(Index,Index), class Replicate\n  */\ntemplate<typename Derived>\ntemplate<int RowFactor, int ColFactor>\nconst Replicate<Derived,RowFactor,ColFactor>\nDenseBase<Derived>::replicate() const\n{\n  return Replicate<Derived,RowFactor,ColFactor>(derived());\n}\n\n/**\n  * \\return an expression of the replication of each column (or row) of \\c *this\n  *\n  * Example: \\include DirectionWise_replicate_int.cpp\n  * Output: \\verbinclude DirectionWise_replicate_int.out\n  *\n  * \\sa VectorwiseOp::replicate(), DenseBase::replicate(), class Replicate\n  */\ntemplate<typename ExpressionType, int Direction>\nconst typename VectorwiseOp<ExpressionType,Direction>::ReplicateReturnType\nVectorwiseOp<ExpressionType,Direction>::replicate(Index factor) const\n{\n  return typename VectorwiseOp<ExpressionType,Direction>::ReplicateReturnType\n          (_expression(),Direction==Vertical?factor:1,Direction==Horizontal?factor:1);\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_REPLICATE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/ReturnByValue.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_RETURNBYVALUE_H\n#define EIGEN_RETURNBYVALUE_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<typename Derived>\nstruct traits<ReturnByValue<Derived> >\n  : public traits<typename traits<Derived>::ReturnType>\n{\n  enum {\n    // We're disabling the DirectAccess because e.g. the constructor of\n    // the Block-with-DirectAccess expression requires to have a coeffRef method.\n    // Also, we don't want to have to implement the stride stuff.\n    Flags = (traits<typename traits<Derived>::ReturnType>::Flags\n             | EvalBeforeNestingBit) & ~DirectAccessBit\n  };\n};\n\n/* The ReturnByValue object doesn't even have a coeff() method.\n * So the only way that nesting it in an expression can work, is by evaluating it into a plain matrix.\n * So internal::nested always gives the plain return matrix type.\n *\n * FIXME: I don't understand why we need this specialization: isn't this taken care of by the EvalBeforeNestingBit ??\n * Answer: EvalBeforeNestingBit should be deprecated since we have the evaluators\n */\ntemplate<typename Derived,int n,typename PlainObject>\nstruct nested_eval<ReturnByValue<Derived>, n, PlainObject>\n{\n  typedef typename traits<Derived>::ReturnType type;\n};\n\n} // end namespace internal\n\n/** \\class ReturnByValue\n  * \\ingroup Core_Module\n  *\n  */\ntemplate<typename Derived> class ReturnByValue\n  : public internal::dense_xpr_base< ReturnByValue<Derived> >::type, internal::no_assignment_operator\n{\n  public:\n    typedef typename internal::traits<Derived>::ReturnType ReturnType;\n\n    typedef typename internal::dense_xpr_base<ReturnByValue>::type Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue)\n\n    template<typename Dest>\n    EIGEN_DEVICE_FUNC\n    inline void evalTo(Dest& dst) const\n    { static_cast<const Derived*>(this)->evalTo(dst); }\n    EIGEN_DEVICE_FUNC inline Index rows() const { return static_cast<const Derived*>(this)->rows(); }\n    EIGEN_DEVICE_FUNC inline Index cols() const { return static_cast<const Derived*>(this)->cols(); }\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n#define Unusable YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT\n    class Unusable{\n      Unusable(const Unusable&) {}\n      Unusable& operator=(const Unusable&) {return *this;}\n    };\n    const Unusable& coeff(Index) const { return *reinterpret_cast<const Unusable*>(this); }\n    const Unusable& coeff(Index,Index) const { return *reinterpret_cast<const Unusable*>(this); }\n    Unusable& coeffRef(Index) { return *reinterpret_cast<Unusable*>(this); }\n    Unusable& coeffRef(Index,Index) { return *reinterpret_cast<Unusable*>(this); }\n#undef Unusable\n#endif\n};\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nDerived& DenseBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)\n{\n  other.evalTo(derived());\n  return derived();\n}\n\nnamespace internal {\n\n// Expression is evaluated in a temporary; default implementation of Assignment is bypassed so that\n// when a ReturnByValue expression is assigned, the evaluator is not constructed.\n// TODO: Finalize port to new regime; ReturnByValue should not exist in the expression world\n  \ntemplate<typename Derived>\nstruct evaluator<ReturnByValue<Derived> >\n  : public evaluator<typename internal::traits<Derived>::ReturnType>\n{\n  typedef ReturnByValue<Derived> XprType;\n  typedef typename internal::traits<Derived>::ReturnType PlainObject;\n  typedef evaluator<PlainObject> Base;\n  \n  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr)\n    : m_result(xpr.rows(), xpr.cols())\n  {\n    ::new (static_cast<Base*>(this)) Base(m_result);\n    xpr.evalTo(m_result);\n  }\n\nprotected:\n  PlainObject m_result;\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_RETURNBYVALUE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Reverse.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2009 Ricard Marxer <email@ricardmarxer.com>\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_REVERSE_H\n#define EIGEN_REVERSE_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename MatrixType, int Direction>\nstruct traits<Reverse<MatrixType, Direction> >\n : traits<MatrixType>\n{\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename traits<MatrixType>::StorageKind StorageKind;\n  typedef typename traits<MatrixType>::XprKind XprKind;\n  typedef typename ref_selector<MatrixType>::type MatrixTypeNested;\n  typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;\n  enum {\n    RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n    ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n    MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,\n    Flags = _MatrixTypeNested::Flags & (RowMajorBit | LvalueBit)\n  };\n};\n\ntemplate<typename PacketType, bool ReversePacket> struct reverse_packet_cond\n{\n  static inline PacketType run(const PacketType& x) { return preverse(x); }\n};\n\ntemplate<typename PacketType> struct reverse_packet_cond<PacketType,false>\n{\n  static inline PacketType run(const PacketType& x) { return x; }\n};\n\n} // end namespace internal \n\n/** \\class Reverse\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of the reverse of a vector or matrix\n  *\n  * \\tparam MatrixType the type of the object of which we are taking the reverse\n  * \\tparam Direction defines the direction of the reverse operation, can be Vertical, Horizontal, or BothDirections\n  *\n  * This class represents an expression of the reverse of a vector.\n  * It is the return type of MatrixBase::reverse() and VectorwiseOp::reverse()\n  * and most of the time this is the only way it is used.\n  *\n  * \\sa MatrixBase::reverse(), VectorwiseOp::reverse()\n  */\ntemplate<typename MatrixType, int Direction> class Reverse\n  : public internal::dense_xpr_base< Reverse<MatrixType, Direction> >::type\n{\n  public:\n\n    typedef typename internal::dense_xpr_base<Reverse>::type Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(Reverse)\n    typedef typename internal::remove_all<MatrixType>::type NestedExpression;\n    using Base::IsRowMajor;\n\n  protected:\n    enum {\n      PacketSize = internal::packet_traits<Scalar>::size,\n      IsColMajor = !IsRowMajor,\n      ReverseRow = (Direction == Vertical)   || (Direction == BothDirections),\n      ReverseCol = (Direction == Horizontal) || (Direction == BothDirections),\n      OffsetRow  = ReverseRow && IsColMajor ? PacketSize : 1,\n      OffsetCol  = ReverseCol && IsRowMajor ? PacketSize : 1,\n      ReversePacket = (Direction == BothDirections)\n                    || ((Direction == Vertical)   && IsColMajor)\n                    || ((Direction == Horizontal) && IsRowMajor)\n    };\n    typedef internal::reverse_packet_cond<PacketScalar,ReversePacket> reverse_packet;\n  public:\n\n    EIGEN_DEVICE_FUNC explicit inline Reverse(const MatrixType& matrix) : m_matrix(matrix) { }\n\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Reverse)\n\n    EIGEN_DEVICE_FUNC inline Index rows() const { return m_matrix.rows(); }\n    EIGEN_DEVICE_FUNC inline Index cols() const { return m_matrix.cols(); }\n\n    EIGEN_DEVICE_FUNC inline Index innerStride() const\n    {\n      return -m_matrix.innerStride();\n    }\n\n    EIGEN_DEVICE_FUNC const typename internal::remove_all<typename MatrixType::Nested>::type&\n    nestedExpression() const \n    {\n      return m_matrix;\n    }\n\n  protected:\n    typename MatrixType::Nested m_matrix;\n};\n\n/** \\returns an expression of the reverse of *this.\n  *\n  * Example: \\include MatrixBase_reverse.cpp\n  * Output: \\verbinclude MatrixBase_reverse.out\n  *\n  */\ntemplate<typename Derived>\ninline typename DenseBase<Derived>::ReverseReturnType\nDenseBase<Derived>::reverse()\n{\n  return ReverseReturnType(derived());\n}\n\n\n//reverse const overload moved DenseBase.h due to a CUDA compiler bug\n\n/** This is the \"in place\" version of reverse: it reverses \\c *this.\n  *\n  * In most cases it is probably better to simply use the reversed expression\n  * of a matrix. However, when reversing the matrix data itself is really needed,\n  * then this \"in-place\" version is probably the right choice because it provides\n  * the following additional benefits:\n  *  - less error prone: doing the same operation with .reverse() requires special care:\n  *    \\code m = m.reverse().eval(); \\endcode\n  *  - this API enables reverse operations without the need for a temporary\n  *  - it allows future optimizations (cache friendliness, etc.)\n  *\n  * \\sa VectorwiseOp::reverseInPlace(), reverse() */\ntemplate<typename Derived>\ninline void DenseBase<Derived>::reverseInPlace()\n{\n  if(cols()>rows())\n  {\n    Index half = cols()/2;\n    leftCols(half).swap(rightCols(half).reverse());\n    if((cols()%2)==1)\n    {\n      Index half2 = rows()/2;\n      col(half).head(half2).swap(col(half).tail(half2).reverse());\n    }\n  }\n  else\n  {\n    Index half = rows()/2;\n    topRows(half).swap(bottomRows(half).reverse());\n    if((rows()%2)==1)\n    {\n      Index half2 = cols()/2;\n      row(half).head(half2).swap(row(half).tail(half2).reverse());\n    }\n  }\n}\n\nnamespace internal {\n  \ntemplate<int Direction>\nstruct vectorwise_reverse_inplace_impl;\n\ntemplate<>\nstruct vectorwise_reverse_inplace_impl<Vertical>\n{\n  template<typename ExpressionType>\n  static void run(ExpressionType &xpr)\n  {\n    Index half = xpr.rows()/2;\n    xpr.topRows(half).swap(xpr.bottomRows(half).colwise().reverse());\n  }\n};\n\ntemplate<>\nstruct vectorwise_reverse_inplace_impl<Horizontal>\n{\n  template<typename ExpressionType>\n  static void run(ExpressionType &xpr)\n  {\n    Index half = xpr.cols()/2;\n    xpr.leftCols(half).swap(xpr.rightCols(half).rowwise().reverse());\n  }\n};\n\n} // end namespace internal\n\n/** This is the \"in place\" version of VectorwiseOp::reverse: it reverses each column or row of \\c *this.\n  *\n  * In most cases it is probably better to simply use the reversed expression\n  * of a matrix. However, when reversing the matrix data itself is really needed,\n  * then this \"in-place\" version is probably the right choice because it provides\n  * the following additional benefits:\n  *  - less error prone: doing the same operation with .reverse() requires special care:\n  *    \\code m = m.reverse().eval(); \\endcode\n  *  - this API enables reverse operations without the need for a temporary\n  *\n  * \\sa DenseBase::reverseInPlace(), reverse() */\ntemplate<typename ExpressionType, int Direction>\nvoid VectorwiseOp<ExpressionType,Direction>::reverseInPlace()\n{\n  internal::vectorwise_reverse_inplace_impl<Direction>::run(_expression().const_cast_derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_REVERSE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Select.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SELECT_H\n#define EIGEN_SELECT_H\n\nnamespace Eigen { \n\n/** \\class Select\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of a coefficient wise version of the C++ ternary operator ?:\n  *\n  * \\param ConditionMatrixType the type of the \\em condition expression which must be a boolean matrix\n  * \\param ThenMatrixType the type of the \\em then expression\n  * \\param ElseMatrixType the type of the \\em else expression\n  *\n  * This class represents an expression of a coefficient wise version of the C++ ternary operator ?:.\n  * It is the return type of DenseBase::select() and most of the time this is the only way it is used.\n  *\n  * \\sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const\n  */\n\nnamespace internal {\ntemplate<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>\nstruct traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >\n : traits<ThenMatrixType>\n{\n  typedef typename traits<ThenMatrixType>::Scalar Scalar;\n  typedef Dense StorageKind;\n  typedef typename traits<ThenMatrixType>::XprKind XprKind;\n  typedef typename ConditionMatrixType::Nested ConditionMatrixNested;\n  typedef typename ThenMatrixType::Nested ThenMatrixNested;\n  typedef typename ElseMatrixType::Nested ElseMatrixNested;\n  enum {\n    RowsAtCompileTime = ConditionMatrixType::RowsAtCompileTime,\n    ColsAtCompileTime = ConditionMatrixType::ColsAtCompileTime,\n    MaxRowsAtCompileTime = ConditionMatrixType::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = ConditionMatrixType::MaxColsAtCompileTime,\n    Flags = (unsigned int)ThenMatrixType::Flags & ElseMatrixType::Flags & RowMajorBit\n  };\n};\n}\n\ntemplate<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>\nclass Select : public internal::dense_xpr_base< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::type,\n               internal::no_assignment_operator\n{\n  public:\n\n    typedef typename internal::dense_xpr_base<Select>::type Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(Select)\n\n    inline EIGEN_DEVICE_FUNC\n    Select(const ConditionMatrixType& a_conditionMatrix,\n           const ThenMatrixType& a_thenMatrix,\n           const ElseMatrixType& a_elseMatrix)\n      : m_condition(a_conditionMatrix), m_then(a_thenMatrix), m_else(a_elseMatrix)\n    {\n      eigen_assert(m_condition.rows() == m_then.rows() && m_condition.rows() == m_else.rows());\n      eigen_assert(m_condition.cols() == m_then.cols() && m_condition.cols() == m_else.cols());\n    }\n\n    inline EIGEN_DEVICE_FUNC Index rows() const { return m_condition.rows(); }\n    inline EIGEN_DEVICE_FUNC Index cols() const { return m_condition.cols(); }\n\n    inline EIGEN_DEVICE_FUNC\n    const Scalar coeff(Index i, Index j) const\n    {\n      if (m_condition.coeff(i,j))\n        return m_then.coeff(i,j);\n      else\n        return m_else.coeff(i,j);\n    }\n\n    inline EIGEN_DEVICE_FUNC\n    const Scalar coeff(Index i) const\n    {\n      if (m_condition.coeff(i))\n        return m_then.coeff(i);\n      else\n        return m_else.coeff(i);\n    }\n\n    inline EIGEN_DEVICE_FUNC const ConditionMatrixType& conditionMatrix() const\n    {\n      return m_condition;\n    }\n\n    inline EIGEN_DEVICE_FUNC const ThenMatrixType& thenMatrix() const\n    {\n      return m_then;\n    }\n\n    inline EIGEN_DEVICE_FUNC const ElseMatrixType& elseMatrix() const\n    {\n      return m_else;\n    }\n\n  protected:\n    typename ConditionMatrixType::Nested m_condition;\n    typename ThenMatrixType::Nested m_then;\n    typename ElseMatrixType::Nested m_else;\n};\n\n\n/** \\returns a matrix where each coefficient (i,j) is equal to \\a thenMatrix(i,j)\n  * if \\c *this(i,j), and \\a elseMatrix(i,j) otherwise.\n  *\n  * Example: \\include MatrixBase_select.cpp\n  * Output: \\verbinclude MatrixBase_select.out\n  *\n  * \\sa class Select\n  */\ntemplate<typename Derived>\ntemplate<typename ThenDerived,typename ElseDerived>\ninline const Select<Derived,ThenDerived,ElseDerived>\nDenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,\n                            const DenseBase<ElseDerived>& elseMatrix) const\n{\n  return Select<Derived,ThenDerived,ElseDerived>(derived(), thenMatrix.derived(), elseMatrix.derived());\n}\n\n/** Version of DenseBase::select(const DenseBase&, const DenseBase&) with\n  * the \\em else expression being a scalar value.\n  *\n  * \\sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const, class Select\n  */\ntemplate<typename Derived>\ntemplate<typename ThenDerived>\ninline const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>\nDenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,\n                           const typename ThenDerived::Scalar& elseScalar) const\n{\n  return Select<Derived,ThenDerived,typename ThenDerived::ConstantReturnType>(\n    derived(), thenMatrix.derived(), ThenDerived::Constant(rows(),cols(),elseScalar));\n}\n\n/** Version of DenseBase::select(const DenseBase&, const DenseBase&) with\n  * the \\em then expression being a scalar value.\n  *\n  * \\sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const, class Select\n  */\ntemplate<typename Derived>\ntemplate<typename ElseDerived>\ninline const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >\nDenseBase<Derived>::select(const typename ElseDerived::Scalar& thenScalar,\n                           const DenseBase<ElseDerived>& elseMatrix) const\n{\n  return Select<Derived,typename ElseDerived::ConstantReturnType,ElseDerived>(\n    derived(), ElseDerived::Constant(rows(),cols(),thenScalar), elseMatrix.derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SELECT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/SelfAdjointView.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SELFADJOINTMATRIX_H\n#define EIGEN_SELFADJOINTMATRIX_H\n\nnamespace Eigen { \n\n/** \\class SelfAdjointView\n  * \\ingroup Core_Module\n  *\n  *\n  * \\brief Expression of a selfadjoint matrix from a triangular part of a dense matrix\n  *\n  * \\param MatrixType the type of the dense matrix storing the coefficients\n  * \\param TriangularPart can be either \\c #Lower or \\c #Upper\n  *\n  * This class is an expression of a sefladjoint matrix from a triangular part of a matrix\n  * with given dense storage of the coefficients. It is the return type of MatrixBase::selfadjointView()\n  * and most of the time this is the only way that it is used.\n  *\n  * \\sa class TriangularBase, MatrixBase::selfadjointView()\n  */\n\nnamespace internal {\ntemplate<typename MatrixType, unsigned int UpLo>\nstruct traits<SelfAdjointView<MatrixType, UpLo> > : traits<MatrixType>\n{\n  typedef typename ref_selector<MatrixType>::non_const_type MatrixTypeNested;\n  typedef typename remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;\n  typedef MatrixType ExpressionType;\n  typedef typename MatrixType::PlainObject FullMatrixType;\n  enum {\n    Mode = UpLo | SelfAdjoint,\n    FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,\n    Flags =  MatrixTypeNestedCleaned::Flags & (HereditaryBits|FlagsLvalueBit)\n           & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit)) // FIXME these flags should be preserved\n  };\n};\n}\n\n\ntemplate<typename _MatrixType, unsigned int UpLo> class SelfAdjointView\n  : public TriangularBase<SelfAdjointView<_MatrixType, UpLo> >\n{\n  public:\n\n    typedef _MatrixType MatrixType;\n    typedef TriangularBase<SelfAdjointView> Base;\n    typedef typename internal::traits<SelfAdjointView>::MatrixTypeNested MatrixTypeNested;\n    typedef typename internal::traits<SelfAdjointView>::MatrixTypeNestedCleaned MatrixTypeNestedCleaned;\n    typedef MatrixTypeNestedCleaned NestedExpression;\n\n    /** \\brief The type of coefficients in this matrix */\n    typedef typename internal::traits<SelfAdjointView>::Scalar Scalar; \n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef typename internal::remove_all<typename MatrixType::ConjugateReturnType>::type MatrixConjugateReturnType;\n\n    enum {\n      Mode = internal::traits<SelfAdjointView>::Mode,\n      Flags = internal::traits<SelfAdjointView>::Flags,\n      TransposeMode = ((Mode & Upper) ? Lower : 0) | ((Mode & Lower) ? Upper : 0)\n    };\n    typedef typename MatrixType::PlainObject PlainObject;\n\n    EIGEN_DEVICE_FUNC\n    explicit inline SelfAdjointView(MatrixType& matrix) : m_matrix(matrix)\n    {}\n\n    EIGEN_DEVICE_FUNC\n    inline Index rows() const { return m_matrix.rows(); }\n    EIGEN_DEVICE_FUNC\n    inline Index cols() const { return m_matrix.cols(); }\n    EIGEN_DEVICE_FUNC\n    inline Index outerStride() const { return m_matrix.outerStride(); }\n    EIGEN_DEVICE_FUNC\n    inline Index innerStride() const { return m_matrix.innerStride(); }\n\n    /** \\sa MatrixBase::coeff()\n      * \\warning the coordinates must fit into the referenced triangular part\n      */\n    EIGEN_DEVICE_FUNC\n    inline Scalar coeff(Index row, Index col) const\n    {\n      Base::check_coordinates_internal(row, col);\n      return m_matrix.coeff(row, col);\n    }\n\n    /** \\sa MatrixBase::coeffRef()\n      * \\warning the coordinates must fit into the referenced triangular part\n      */\n    EIGEN_DEVICE_FUNC\n    inline Scalar& coeffRef(Index row, Index col)\n    {\n      EIGEN_STATIC_ASSERT_LVALUE(SelfAdjointView);\n      Base::check_coordinates_internal(row, col);\n      return m_matrix.coeffRef(row, col);\n    }\n\n    /** \\internal */\n    EIGEN_DEVICE_FUNC\n    const MatrixTypeNestedCleaned& _expression() const { return m_matrix; }\n\n    EIGEN_DEVICE_FUNC\n    const MatrixTypeNestedCleaned& nestedExpression() const { return m_matrix; }\n    EIGEN_DEVICE_FUNC\n    MatrixTypeNestedCleaned& nestedExpression() { return m_matrix; }\n\n    /** Efficient triangular matrix times vector/matrix product */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    const Product<SelfAdjointView,OtherDerived>\n    operator*(const MatrixBase<OtherDerived>& rhs) const\n    {\n      return Product<SelfAdjointView,OtherDerived>(*this, rhs.derived());\n    }\n\n    /** Efficient vector/matrix times triangular matrix product */\n    template<typename OtherDerived> friend\n    EIGEN_DEVICE_FUNC\n    const Product<OtherDerived,SelfAdjointView>\n    operator*(const MatrixBase<OtherDerived>& lhs, const SelfAdjointView& rhs)\n    {\n      return Product<OtherDerived,SelfAdjointView>(lhs.derived(),rhs);\n    }\n    \n    friend EIGEN_DEVICE_FUNC\n    const SelfAdjointView<const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,MatrixType,product),UpLo>\n    operator*(const Scalar& s, const SelfAdjointView& mat)\n    {\n      return (s*mat.nestedExpression()).template selfadjointView<UpLo>();\n    }\n\n    /** Perform a symmetric rank 2 update of the selfadjoint matrix \\c *this:\n      * \\f$ this = this + \\alpha u v^* + conj(\\alpha) v u^* \\f$\n      * \\returns a reference to \\c *this\n      *\n      * The vectors \\a u and \\c v \\b must be column vectors, however they can be\n      * a adjoint expression without any overhead. Only the meaningful triangular\n      * part of the matrix is updated, the rest is left unchanged.\n      *\n      * \\sa rankUpdate(const MatrixBase<DerivedU>&, Scalar)\n      */\n    template<typename DerivedU, typename DerivedV>\n    EIGEN_DEVICE_FUNC\n    SelfAdjointView& rankUpdate(const MatrixBase<DerivedU>& u, const MatrixBase<DerivedV>& v, const Scalar& alpha = Scalar(1));\n\n    /** Perform a symmetric rank K update of the selfadjoint matrix \\c *this:\n      * \\f$ this = this + \\alpha ( u u^* ) \\f$ where \\a u is a vector or matrix.\n      *\n      * \\returns a reference to \\c *this\n      *\n      * Note that to perform \\f$ this = this + \\alpha ( u^* u ) \\f$ you can simply\n      * call this function with u.adjoint().\n      *\n      * \\sa rankUpdate(const MatrixBase<DerivedU>&, const MatrixBase<DerivedV>&, Scalar)\n      */\n    template<typename DerivedU>\n    EIGEN_DEVICE_FUNC\n    SelfAdjointView& rankUpdate(const MatrixBase<DerivedU>& u, const Scalar& alpha = Scalar(1));\n\n    /** \\returns an expression of a triangular view extracted from the current selfadjoint view of a given triangular part\n      *\n      * The parameter \\a TriMode can have the following values: \\c #Upper, \\c #StrictlyUpper, \\c #UnitUpper,\n      * \\c #Lower, \\c #StrictlyLower, \\c #UnitLower.\n      *\n      * If \\c TriMode references the same triangular part than \\c *this, then this method simply return a \\c TriangularView of the nested expression,\n      * otherwise, the nested expression is first transposed, thus returning a \\c TriangularView<Transpose<MatrixType>> object.\n      *\n      * \\sa MatrixBase::triangularView(), class TriangularView\n      */\n    template<unsigned int TriMode>\n    EIGEN_DEVICE_FUNC\n    typename internal::conditional<(TriMode&(Upper|Lower))==(UpLo&(Upper|Lower)),\n                                   TriangularView<MatrixType,TriMode>,\n                                   TriangularView<typename MatrixType::AdjointReturnType,TriMode> >::type\n    triangularView() const\n    {\n      typename internal::conditional<(TriMode&(Upper|Lower))==(UpLo&(Upper|Lower)), MatrixType&, typename MatrixType::ConstTransposeReturnType>::type tmp1(m_matrix);\n      typename internal::conditional<(TriMode&(Upper|Lower))==(UpLo&(Upper|Lower)), MatrixType&, typename MatrixType::AdjointReturnType>::type tmp2(tmp1);\n      return typename internal::conditional<(TriMode&(Upper|Lower))==(UpLo&(Upper|Lower)),\n                                   TriangularView<MatrixType,TriMode>,\n                                   TriangularView<typename MatrixType::AdjointReturnType,TriMode> >::type(tmp2);\n    }\n\n    typedef SelfAdjointView<const MatrixConjugateReturnType,Mode> ConjugateReturnType;\n    /** \\sa MatrixBase::conjugate() const */\n    EIGEN_DEVICE_FUNC\n    inline const ConjugateReturnType conjugate() const\n    { return ConjugateReturnType(m_matrix.conjugate()); }\n\n    typedef SelfAdjointView<const typename MatrixType::AdjointReturnType,TransposeMode> AdjointReturnType;\n    /** \\sa MatrixBase::adjoint() const */\n    EIGEN_DEVICE_FUNC\n    inline const AdjointReturnType adjoint() const\n    { return AdjointReturnType(m_matrix.adjoint()); }\n\n    typedef SelfAdjointView<typename MatrixType::TransposeReturnType,TransposeMode> TransposeReturnType;\n     /** \\sa MatrixBase::transpose() */\n    EIGEN_DEVICE_FUNC\n    inline TransposeReturnType transpose()\n    {\n      EIGEN_STATIC_ASSERT_LVALUE(MatrixType)\n      typename MatrixType::TransposeReturnType tmp(m_matrix);\n      return TransposeReturnType(tmp);\n    }\n\n    typedef SelfAdjointView<const typename MatrixType::ConstTransposeReturnType,TransposeMode> ConstTransposeReturnType;\n    /** \\sa MatrixBase::transpose() const */\n    EIGEN_DEVICE_FUNC\n    inline const ConstTransposeReturnType transpose() const\n    {\n      return ConstTransposeReturnType(m_matrix.transpose());\n    }\n\n    /** \\returns a const expression of the main diagonal of the matrix \\c *this\n      *\n      * This method simply returns the diagonal of the nested expression, thus by-passing the SelfAdjointView decorator.\n      *\n      * \\sa MatrixBase::diagonal(), class Diagonal */\n    EIGEN_DEVICE_FUNC\n    typename MatrixType::ConstDiagonalReturnType diagonal() const\n    {\n      return typename MatrixType::ConstDiagonalReturnType(m_matrix);\n    }\n\n/////////// Cholesky module ///////////\n\n    const LLT<PlainObject, UpLo> llt() const;\n    const LDLT<PlainObject, UpLo> ldlt() const;\n\n/////////// Eigenvalue module ///////////\n\n    /** Real part of #Scalar */\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    /** Return type of eigenvalues() */\n    typedef Matrix<RealScalar, internal::traits<MatrixType>::ColsAtCompileTime, 1> EigenvaluesReturnType;\n\n    EIGEN_DEVICE_FUNC\n    EigenvaluesReturnType eigenvalues() const;\n    EIGEN_DEVICE_FUNC\n    RealScalar operatorNorm() const;\n\n  protected:\n    MatrixTypeNested m_matrix;\n};\n\n\n// template<typename OtherDerived, typename MatrixType, unsigned int UpLo>\n// internal::selfadjoint_matrix_product_returntype<OtherDerived,SelfAdjointView<MatrixType,UpLo> >\n// operator*(const MatrixBase<OtherDerived>& lhs, const SelfAdjointView<MatrixType,UpLo>& rhs)\n// {\n//   return internal::matrix_selfadjoint_product_returntype<OtherDerived,SelfAdjointView<MatrixType,UpLo> >(lhs.derived(),rhs);\n// }\n\n// selfadjoint to dense matrix\n\nnamespace internal {\n\n// TODO currently a selfadjoint expression has the form SelfAdjointView<.,.>\n//      in the future selfadjoint-ness should be defined by the expression traits\n//      such that Transpose<SelfAdjointView<.,.> > is valid. (currently TriangularBase::transpose() is overloaded to make it work)\ntemplate<typename MatrixType, unsigned int Mode>\nstruct evaluator_traits<SelfAdjointView<MatrixType,Mode> >\n{\n  typedef typename storage_kind_to_evaluator_kind<typename MatrixType::StorageKind>::Kind Kind;\n  typedef SelfAdjointShape Shape;\n};\n\ntemplate<int UpLo, int SetOpposite, typename DstEvaluatorTypeT, typename SrcEvaluatorTypeT, typename Functor, int Version>\nclass triangular_dense_assignment_kernel<UpLo,SelfAdjoint,SetOpposite,DstEvaluatorTypeT,SrcEvaluatorTypeT,Functor,Version>\n  : public generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version>\n{\nprotected:\n  typedef generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version> Base;\n  typedef typename Base::DstXprType DstXprType;\n  typedef typename Base::SrcXprType SrcXprType;\n  using Base::m_dst;\n  using Base::m_src;\n  using Base::m_functor;\npublic:\n  \n  typedef typename Base::DstEvaluatorType DstEvaluatorType;\n  typedef typename Base::SrcEvaluatorType SrcEvaluatorType;\n  typedef typename Base::Scalar Scalar;\n  typedef typename Base::AssignmentTraits AssignmentTraits;\n  \n  \n  EIGEN_DEVICE_FUNC triangular_dense_assignment_kernel(DstEvaluatorType &dst, const SrcEvaluatorType &src, const Functor &func, DstXprType& dstExpr)\n    : Base(dst, src, func, dstExpr)\n  {}\n  \n  EIGEN_DEVICE_FUNC void assignCoeff(Index row, Index col)\n  {\n    eigen_internal_assert(row!=col);\n    Scalar tmp = m_src.coeff(row,col);\n    m_functor.assignCoeff(m_dst.coeffRef(row,col), tmp);\n    m_functor.assignCoeff(m_dst.coeffRef(col,row), numext::conj(tmp));\n  }\n  \n  EIGEN_DEVICE_FUNC void assignDiagonalCoeff(Index id)\n  {\n    Base::assignCoeff(id,id);\n  }\n  \n  EIGEN_DEVICE_FUNC void assignOppositeCoeff(Index, Index)\n  { eigen_internal_assert(false && \"should never be called\"); }\n};\n\n} // end namespace internal\n\n/***************************************************************************\n* Implementation of MatrixBase methods\n***************************************************************************/\n\n/** This is the const version of MatrixBase::selfadjointView() */\ntemplate<typename Derived>\ntemplate<unsigned int UpLo>\ntypename MatrixBase<Derived>::template ConstSelfAdjointViewReturnType<UpLo>::Type\nMatrixBase<Derived>::selfadjointView() const\n{\n  return typename ConstSelfAdjointViewReturnType<UpLo>::Type(derived());\n}\n\n/** \\returns an expression of a symmetric/self-adjoint view extracted from the upper or lower triangular part of the current matrix\n  *\n  * The parameter \\a UpLo can be either \\c #Upper or \\c #Lower\n  *\n  * Example: \\include MatrixBase_selfadjointView.cpp\n  * Output: \\verbinclude MatrixBase_selfadjointView.out\n  *\n  * \\sa class SelfAdjointView\n  */\ntemplate<typename Derived>\ntemplate<unsigned int UpLo>\ntypename MatrixBase<Derived>::template SelfAdjointViewReturnType<UpLo>::Type\nMatrixBase<Derived>::selfadjointView()\n{\n  return typename SelfAdjointViewReturnType<UpLo>::Type(derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SELFADJOINTMATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/SelfCwiseBinaryOp.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SELFCWISEBINARYOP_H\n#define EIGEN_SELFCWISEBINARYOP_H\n\nnamespace Eigen { \n\n// TODO generalize the scalar type of 'other'\n\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator*=(const Scalar& other)\n{\n  typedef typename Derived::PlainObject PlainObject;\n  internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op<Scalar,Scalar>());\n  return derived();\n}\n\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase<Derived>::operator+=(const Scalar& other)\n{\n  typedef typename Derived::PlainObject PlainObject;\n  internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::add_assign_op<Scalar,Scalar>());\n  return derived();\n}\n\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase<Derived>::operator-=(const Scalar& other)\n{\n  typedef typename Derived::PlainObject PlainObject;\n  internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::sub_assign_op<Scalar,Scalar>());\n  return derived();\n}\n\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator/=(const Scalar& other)\n{\n  typedef typename Derived::PlainObject PlainObject;\n  internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op<Scalar,Scalar>());\n  return derived();\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SELFCWISEBINARYOP_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Solve.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SOLVE_H\n#define EIGEN_SOLVE_H\n\nnamespace Eigen {\n\ntemplate<typename Decomposition, typename RhsType, typename StorageKind> class SolveImpl;\n  \n/** \\class Solve\n  * \\ingroup Core_Module\n  *\n  * \\brief Pseudo expression representing a solving operation\n  *\n  * \\tparam Decomposition the type of the matrix or decomposion object\n  * \\tparam Rhstype the type of the right-hand side\n  *\n  * This class represents an expression of A.solve(B)\n  * and most of the time this is the only way it is used.\n  *\n  */\nnamespace internal {\n\n// this solve_traits class permits to determine the evaluation type with respect to storage kind (Dense vs Sparse)\ntemplate<typename Decomposition, typename RhsType,typename StorageKind> struct solve_traits;\n\ntemplate<typename Decomposition, typename RhsType>\nstruct solve_traits<Decomposition,RhsType,Dense>\n{\n  typedef typename make_proper_matrix_type<typename RhsType::Scalar,\n                 Decomposition::ColsAtCompileTime,\n                 RhsType::ColsAtCompileTime,\n                 RhsType::PlainObject::Options,\n                 Decomposition::MaxColsAtCompileTime,\n                 RhsType::MaxColsAtCompileTime>::type PlainObject;\n};\n\ntemplate<typename Decomposition, typename RhsType>\nstruct traits<Solve<Decomposition, RhsType> >\n  : traits<typename solve_traits<Decomposition,RhsType,typename internal::traits<RhsType>::StorageKind>::PlainObject>\n{\n  typedef typename solve_traits<Decomposition,RhsType,typename internal::traits<RhsType>::StorageKind>::PlainObject PlainObject;\n  typedef typename promote_index_type<typename Decomposition::StorageIndex, typename RhsType::StorageIndex>::type StorageIndex;\n  typedef traits<PlainObject> BaseTraits;\n  enum {\n    Flags = BaseTraits::Flags & RowMajorBit,\n    CoeffReadCost = HugeCost\n  };\n};\n\n}\n\n\ntemplate<typename Decomposition, typename RhsType>\nclass Solve : public SolveImpl<Decomposition,RhsType,typename internal::traits<RhsType>::StorageKind>\n{\npublic:\n  typedef typename internal::traits<Solve>::PlainObject PlainObject;\n  typedef typename internal::traits<Solve>::StorageIndex StorageIndex;\n  \n  Solve(const Decomposition &dec, const RhsType &rhs)\n    : m_dec(dec), m_rhs(rhs)\n  {}\n  \n  EIGEN_DEVICE_FUNC Index rows() const { return m_dec.cols(); }\n  EIGEN_DEVICE_FUNC Index cols() const { return m_rhs.cols(); }\n\n  EIGEN_DEVICE_FUNC const Decomposition& dec() const { return m_dec; }\n  EIGEN_DEVICE_FUNC const RhsType&       rhs() const { return m_rhs; }\n\nprotected:\n  const Decomposition &m_dec;\n  const RhsType       &m_rhs;\n};\n\n\n// Specialization of the Solve expression for dense results\ntemplate<typename Decomposition, typename RhsType>\nclass SolveImpl<Decomposition,RhsType,Dense>\n  : public MatrixBase<Solve<Decomposition,RhsType> >\n{\n  typedef Solve<Decomposition,RhsType> Derived;\n  \npublic:\n  \n  typedef MatrixBase<Solve<Decomposition,RhsType> > Base;\n  EIGEN_DENSE_PUBLIC_INTERFACE(Derived)\n\nprivate:\n  \n  Scalar coeff(Index row, Index col) const;\n  Scalar coeff(Index i) const;\n};\n\n// Generic API dispatcher\ntemplate<typename Decomposition, typename RhsType, typename StorageKind>\nclass SolveImpl : public internal::generic_xpr_base<Solve<Decomposition,RhsType>, MatrixXpr, StorageKind>::type\n{\n  public:\n    typedef typename internal::generic_xpr_base<Solve<Decomposition,RhsType>, MatrixXpr, StorageKind>::type Base;\n};\n\nnamespace internal {\n\n// Evaluator of Solve -> eval into a temporary\ntemplate<typename Decomposition, typename RhsType>\nstruct evaluator<Solve<Decomposition,RhsType> >\n  : public evaluator<typename Solve<Decomposition,RhsType>::PlainObject>\n{\n  typedef Solve<Decomposition,RhsType> SolveType;\n  typedef typename SolveType::PlainObject PlainObject;\n  typedef evaluator<PlainObject> Base;\n\n  enum { Flags = Base::Flags | EvalBeforeNestingBit };\n  \n  EIGEN_DEVICE_FUNC explicit evaluator(const SolveType& solve)\n    : m_result(solve.rows(), solve.cols())\n  {\n    ::new (static_cast<Base*>(this)) Base(m_result);\n    solve.dec()._solve_impl(solve.rhs(), m_result);\n  }\n  \nprotected:  \n  PlainObject m_result;\n};\n\n// Specialization for \"dst = dec.solve(rhs)\"\n// NOTE we need to specialize it for Dense2Dense to avoid ambiguous specialization error and a Sparse2Sparse specialization must exist somewhere\ntemplate<typename DstXprType, typename DecType, typename RhsType, typename Scalar>\nstruct Assignment<DstXprType, Solve<DecType,RhsType>, internal::assign_op<Scalar,Scalar>, Dense2Dense>\n{\n  typedef Solve<DecType,RhsType> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,Scalar> &)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n\n    src.dec()._solve_impl(src.rhs(), dst);\n  }\n};\n\n// Specialization for \"dst = dec.transpose().solve(rhs)\"\ntemplate<typename DstXprType, typename DecType, typename RhsType, typename Scalar>\nstruct Assignment<DstXprType, Solve<Transpose<const DecType>,RhsType>, internal::assign_op<Scalar,Scalar>, Dense2Dense>\n{\n  typedef Solve<Transpose<const DecType>,RhsType> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,Scalar> &)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n\n    src.dec().nestedExpression().template _solve_impl_transposed<false>(src.rhs(), dst);\n  }\n};\n\n// Specialization for \"dst = dec.adjoint().solve(rhs)\"\ntemplate<typename DstXprType, typename DecType, typename RhsType, typename Scalar>\nstruct Assignment<DstXprType, Solve<CwiseUnaryOp<internal::scalar_conjugate_op<typename DecType::Scalar>, const Transpose<const DecType> >,RhsType>,\n                  internal::assign_op<Scalar,Scalar>, Dense2Dense>\n{\n  typedef Solve<CwiseUnaryOp<internal::scalar_conjugate_op<typename DecType::Scalar>, const Transpose<const DecType> >,RhsType> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,Scalar> &)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n    \n    src.dec().nestedExpression().nestedExpression().template _solve_impl_transposed<true>(src.rhs(), dst);\n  }\n};\n\n} // end namepsace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SOLVE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/SolveTriangular.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SOLVETRIANGULAR_H\n#define EIGEN_SOLVETRIANGULAR_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n// Forward declarations:\n// The following two routines are implemented in the products/TriangularSolver*.h files\ntemplate<typename LhsScalar, typename RhsScalar, typename Index, int Side, int Mode, bool Conjugate, int StorageOrder>\nstruct triangular_solve_vector;\n\ntemplate <typename Scalar, typename Index, int Side, int Mode, bool Conjugate, int TriStorageOrder, int OtherStorageOrder>\nstruct triangular_solve_matrix;\n\n// small helper struct extracting some traits on the underlying solver operation\ntemplate<typename Lhs, typename Rhs, int Side>\nclass trsolve_traits\n{\n  private:\n    enum {\n      RhsIsVectorAtCompileTime = (Side==OnTheLeft ? Rhs::ColsAtCompileTime : Rhs::RowsAtCompileTime)==1\n    };\n  public:\n    enum {\n      Unrolling   = (RhsIsVectorAtCompileTime && Rhs::SizeAtCompileTime != Dynamic && Rhs::SizeAtCompileTime <= 8)\n                  ? CompleteUnrolling : NoUnrolling,\n      RhsVectors  = RhsIsVectorAtCompileTime ? 1 : Dynamic\n    };\n};\n\ntemplate<typename Lhs, typename Rhs,\n  int Side, // can be OnTheLeft/OnTheRight\n  int Mode, // can be Upper/Lower | UnitDiag\n  int Unrolling = trsolve_traits<Lhs,Rhs,Side>::Unrolling,\n  int RhsVectors = trsolve_traits<Lhs,Rhs,Side>::RhsVectors\n  >\nstruct triangular_solver_selector;\n\ntemplate<typename Lhs, typename Rhs, int Side, int Mode>\nstruct triangular_solver_selector<Lhs,Rhs,Side,Mode,NoUnrolling,1>\n{\n  typedef typename Lhs::Scalar LhsScalar;\n  typedef typename Rhs::Scalar RhsScalar;\n  typedef blas_traits<Lhs> LhsProductTraits;\n  typedef typename LhsProductTraits::ExtractType ActualLhsType;\n  typedef Map<Matrix<RhsScalar,Dynamic,1>, Aligned> MappedRhs;\n  static void run(const Lhs& lhs, Rhs& rhs)\n  {\n    ActualLhsType actualLhs = LhsProductTraits::extract(lhs);\n\n    // FIXME find a way to allow an inner stride if packet_traits<Scalar>::size==1\n\n    bool useRhsDirectly = Rhs::InnerStrideAtCompileTime==1 || rhs.innerStride()==1;\n\n    ei_declare_aligned_stack_constructed_variable(RhsScalar,actualRhs,rhs.size(),\n                                                  (useRhsDirectly ? rhs.data() : 0));\n                                                  \n    if(!useRhsDirectly)\n      MappedRhs(actualRhs,rhs.size()) = rhs;\n\n    triangular_solve_vector<LhsScalar, RhsScalar, Index, Side, Mode, LhsProductTraits::NeedToConjugate,\n                            (int(Lhs::Flags) & RowMajorBit) ? RowMajor : ColMajor>\n      ::run(actualLhs.cols(), actualLhs.data(), actualLhs.outerStride(), actualRhs);\n\n    if(!useRhsDirectly)\n      rhs = MappedRhs(actualRhs, rhs.size());\n  }\n};\n\n// the rhs is a matrix\ntemplate<typename Lhs, typename Rhs, int Side, int Mode>\nstruct triangular_solver_selector<Lhs,Rhs,Side,Mode,NoUnrolling,Dynamic>\n{\n  typedef typename Rhs::Scalar Scalar;\n  typedef blas_traits<Lhs> LhsProductTraits;\n  typedef typename LhsProductTraits::DirectLinearAccessType ActualLhsType;\n\n  static void run(const Lhs& lhs, Rhs& rhs)\n  {\n    typename internal::add_const_on_value_type<ActualLhsType>::type actualLhs = LhsProductTraits::extract(lhs);\n\n    const Index size = lhs.rows();\n    const Index othersize = Side==OnTheLeft? rhs.cols() : rhs.rows();\n\n    typedef internal::gemm_blocking_space<(Rhs::Flags&RowMajorBit) ? RowMajor : ColMajor,Scalar,Scalar,\n              Rhs::MaxRowsAtCompileTime, Rhs::MaxColsAtCompileTime, Lhs::MaxRowsAtCompileTime,4> BlockingType;\n\n    BlockingType blocking(rhs.rows(), rhs.cols(), size, 1, false);\n\n    triangular_solve_matrix<Scalar,Index,Side,Mode,LhsProductTraits::NeedToConjugate,(int(Lhs::Flags) & RowMajorBit) ? RowMajor : ColMajor,\n                               (Rhs::Flags&RowMajorBit) ? RowMajor : ColMajor>\n      ::run(size, othersize, &actualLhs.coeffRef(0,0), actualLhs.outerStride(), &rhs.coeffRef(0,0), rhs.outerStride(), blocking);\n  }\n};\n\n/***************************************************************************\n* meta-unrolling implementation\n***************************************************************************/\n\ntemplate<typename Lhs, typename Rhs, int Mode, int LoopIndex, int Size,\n         bool Stop = LoopIndex==Size>\nstruct triangular_solver_unroller;\n\ntemplate<typename Lhs, typename Rhs, int Mode, int LoopIndex, int Size>\nstruct triangular_solver_unroller<Lhs,Rhs,Mode,LoopIndex,Size,false> {\n  enum {\n    IsLower = ((Mode&Lower)==Lower),\n    DiagIndex  = IsLower ? LoopIndex : Size - LoopIndex - 1,\n    StartIndex = IsLower ? 0         : DiagIndex+1\n  };\n  static void run(const Lhs& lhs, Rhs& rhs)\n  {\n    if (LoopIndex>0)\n      rhs.coeffRef(DiagIndex) -= lhs.row(DiagIndex).template segment<LoopIndex>(StartIndex).transpose()\n                                .cwiseProduct(rhs.template segment<LoopIndex>(StartIndex)).sum();\n\n    if(!(Mode & UnitDiag))\n      rhs.coeffRef(DiagIndex) /= lhs.coeff(DiagIndex,DiagIndex);\n\n    triangular_solver_unroller<Lhs,Rhs,Mode,LoopIndex+1,Size>::run(lhs,rhs);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int Mode, int LoopIndex, int Size>\nstruct triangular_solver_unroller<Lhs,Rhs,Mode,LoopIndex,Size,true> {\n  static void run(const Lhs&, Rhs&) {}\n};\n\ntemplate<typename Lhs, typename Rhs, int Mode>\nstruct triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,CompleteUnrolling,1> {\n  static void run(const Lhs& lhs, Rhs& rhs)\n  { triangular_solver_unroller<Lhs,Rhs,Mode,0,Rhs::SizeAtCompileTime>::run(lhs,rhs); }\n};\n\ntemplate<typename Lhs, typename Rhs, int Mode>\nstruct triangular_solver_selector<Lhs,Rhs,OnTheRight,Mode,CompleteUnrolling,1> {\n  static void run(const Lhs& lhs, Rhs& rhs)\n  {\n    Transpose<const Lhs> trLhs(lhs);\n    Transpose<Rhs> trRhs(rhs);\n    \n    triangular_solver_unroller<Transpose<const Lhs>,Transpose<Rhs>,\n                              ((Mode&Upper)==Upper ? Lower : Upper) | (Mode&UnitDiag),\n                              0,Rhs::SizeAtCompileTime>::run(trLhs,trRhs);\n  }\n};\n\n} // end namespace internal\n\n/***************************************************************************\n* TriangularView methods\n***************************************************************************/\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename MatrixType, unsigned int Mode>\ntemplate<int Side, typename OtherDerived>\nvoid TriangularViewImpl<MatrixType,Mode,Dense>::solveInPlace(const MatrixBase<OtherDerived>& _other) const\n{\n  OtherDerived& other = _other.const_cast_derived();\n  eigen_assert( derived().cols() == derived().rows() && ((Side==OnTheLeft && derived().cols() == other.rows()) || (Side==OnTheRight && derived().cols() == other.cols())) );\n  eigen_assert((!(Mode & ZeroDiag)) && bool(Mode & (Upper|Lower)));\n\n  enum { copy = (internal::traits<OtherDerived>::Flags & RowMajorBit)  && OtherDerived::IsVectorAtCompileTime && OtherDerived::SizeAtCompileTime!=1};\n  typedef typename internal::conditional<copy,\n    typename internal::plain_matrix_type_column_major<OtherDerived>::type, OtherDerived&>::type OtherCopy;\n  OtherCopy otherCopy(other);\n\n  internal::triangular_solver_selector<MatrixType, typename internal::remove_reference<OtherCopy>::type,\n    Side, Mode>::run(derived().nestedExpression(), otherCopy);\n\n  if (copy)\n    other = otherCopy;\n}\n\ntemplate<typename Derived, unsigned int Mode>\ntemplate<int Side, typename Other>\nconst internal::triangular_solve_retval<Side,TriangularView<Derived,Mode>,Other>\nTriangularViewImpl<Derived,Mode,Dense>::solve(const MatrixBase<Other>& other) const\n{\n  return internal::triangular_solve_retval<Side,TriangularViewType,Other>(derived(), other.derived());\n}\n#endif\n\nnamespace internal {\n\n\ntemplate<int Side, typename TriangularType, typename Rhs>\nstruct traits<triangular_solve_retval<Side, TriangularType, Rhs> >\n{\n  typedef typename internal::plain_matrix_type_column_major<Rhs>::type ReturnType;\n};\n\ntemplate<int Side, typename TriangularType, typename Rhs> struct triangular_solve_retval\n : public ReturnByValue<triangular_solve_retval<Side, TriangularType, Rhs> >\n{\n  typedef typename remove_all<typename Rhs::Nested>::type RhsNestedCleaned;\n  typedef ReturnByValue<triangular_solve_retval> Base;\n\n  triangular_solve_retval(const TriangularType& tri, const Rhs& rhs)\n    : m_triangularMatrix(tri), m_rhs(rhs)\n  {}\n\n  inline Index rows() const { return m_rhs.rows(); }\n  inline Index cols() const { return m_rhs.cols(); }\n\n  template<typename Dest> inline void evalTo(Dest& dst) const\n  {\n    if(!is_same_dense(dst,m_rhs))\n      dst = m_rhs;\n    m_triangularMatrix.template solveInPlace<Side>(dst);\n  }\n\n  protected:\n    const TriangularType& m_triangularMatrix;\n    typename Rhs::Nested m_rhs;\n};\n\n} // namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SOLVETRIANGULAR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/SolverBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SOLVERBASE_H\n#define EIGEN_SOLVERBASE_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n\n\n} // end namespace internal\n\n/** \\class SolverBase\n  * \\brief A base class for matrix decomposition and solvers\n  *\n  * \\tparam Derived the actual type of the decomposition/solver.\n  *\n  * Any matrix decomposition inheriting this base class provide the following API:\n  *\n  * \\code\n  * MatrixType A, b, x;\n  * DecompositionType dec(A);\n  * x = dec.solve(b);             // solve A   * x = b\n  * x = dec.transpose().solve(b); // solve A^T * x = b\n  * x = dec.adjoint().solve(b);   // solve A'  * x = b\n  * \\endcode\n  *\n  * \\warning Currently, any other usage of transpose() and adjoint() are not supported and will produce compilation errors.\n  *\n  * \\sa class PartialPivLU, class FullPivLU\n  */\ntemplate<typename Derived>\nclass SolverBase : public EigenBase<Derived>\n{\n  public:\n\n    typedef EigenBase<Derived> Base;\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    typedef Scalar CoeffReturnType;\n\n    enum {\n      RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,\n      ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,\n      SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,\n                                                          internal::traits<Derived>::ColsAtCompileTime>::ret),\n      MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,\n      MaxSizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::MaxRowsAtCompileTime,\n                                                             internal::traits<Derived>::MaxColsAtCompileTime>::ret),\n      IsVectorAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime == 1\n                           || internal::traits<Derived>::MaxColsAtCompileTime == 1\n    };\n\n    /** Default constructor */\n    SolverBase()\n    {}\n\n    ~SolverBase()\n    {}\n\n    using Base::derived;\n\n    /** \\returns an expression of the solution x of \\f$ A x = b \\f$ using the current decomposition of A.\n      */\n    template<typename Rhs>\n    inline const Solve<Derived, Rhs>\n    solve(const MatrixBase<Rhs>& b) const\n    {\n      eigen_assert(derived().rows()==b.rows() && \"solve(): invalid number of rows of the right hand side matrix b\");\n      return Solve<Derived, Rhs>(derived(), b.derived());\n    }\n\n    /** \\internal the return type of transpose() */\n    typedef typename internal::add_const<Transpose<const Derived> >::type ConstTransposeReturnType;\n    /** \\returns an expression of the transposed of the factored matrix.\n      *\n      * A typical usage is to solve for the transposed problem A^T x = b:\n      * \\code x = dec.transpose().solve(b); \\endcode\n      *\n      * \\sa adjoint(), solve()\n      */\n    inline ConstTransposeReturnType transpose() const\n    {\n      return ConstTransposeReturnType(derived());\n    }\n\n    /** \\internal the return type of adjoint() */\n    typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,\n                        CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, ConstTransposeReturnType>,\n                        ConstTransposeReturnType\n                     >::type AdjointReturnType;\n    /** \\returns an expression of the adjoint of the factored matrix\n      *\n      * A typical usage is to solve for the adjoint problem A' x = b:\n      * \\code x = dec.adjoint().solve(b); \\endcode\n      *\n      * For real scalar types, this function is equivalent to transpose().\n      *\n      * \\sa transpose(), solve()\n      */\n    inline AdjointReturnType adjoint() const\n    {\n      return AdjointReturnType(derived().transpose());\n    }\n\n  protected:\n};\n\nnamespace internal {\n\ntemplate<typename Derived>\nstruct generic_xpr_base<Derived, MatrixXpr, SolverStorage>\n{\n  typedef SolverBase<Derived> type;\n\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SOLVERBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/StableNorm.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_STABLENORM_H\n#define EIGEN_STABLENORM_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename ExpressionType, typename Scalar>\ninline void stable_norm_kernel(const ExpressionType& bl, Scalar& ssq, Scalar& scale, Scalar& invScale)\n{\n  Scalar maxCoeff = bl.cwiseAbs().maxCoeff();\n  \n  if(maxCoeff>scale)\n  {\n    ssq = ssq * numext::abs2(scale/maxCoeff);\n    Scalar tmp = Scalar(1)/maxCoeff;\n    if(tmp > NumTraits<Scalar>::highest())\n    {\n      invScale = NumTraits<Scalar>::highest();\n      scale = Scalar(1)/invScale;\n    }\n    else if(maxCoeff>NumTraits<Scalar>::highest()) // we got a INF\n    {\n      invScale = Scalar(1);\n      scale = maxCoeff;\n    }\n    else\n    {\n      scale = maxCoeff;\n      invScale = tmp;\n    }\n  }\n  else if(maxCoeff!=maxCoeff) // we got a NaN\n  {\n    scale = maxCoeff;\n  }\n  \n  // TODO if the maxCoeff is much much smaller than the current scale,\n  // then we can neglect this sub vector\n  if(scale>Scalar(0)) // if scale==0, then bl is 0 \n    ssq += (bl*invScale).squaredNorm();\n}\n\ntemplate<typename Derived>\ninline typename NumTraits<typename traits<Derived>::Scalar>::Real\nblueNorm_impl(const EigenBase<Derived>& _vec)\n{\n  typedef typename Derived::RealScalar RealScalar;  \n  using std::pow;\n  using std::sqrt;\n  using std::abs;\n  const Derived& vec(_vec.derived());\n  static bool initialized = false;\n  static RealScalar b1, b2, s1m, s2m, rbig, relerr;\n  if(!initialized)\n  {\n    int ibeta, it, iemin, iemax, iexp;\n    RealScalar eps;\n    // This program calculates the machine-dependent constants\n    // bl, b2, slm, s2m, relerr overfl\n    // from the \"basic\" machine-dependent numbers\n    // nbig, ibeta, it, iemin, iemax, rbig.\n    // The following define the basic machine-dependent constants.\n    // For portability, the PORT subprograms \"ilmaeh\" and \"rlmach\"\n    // are used. For any specific computer, each of the assignment\n    // statements can be replaced\n    ibeta = std::numeric_limits<RealScalar>::radix;                 // base for floating-point numbers\n    it    = std::numeric_limits<RealScalar>::digits;                // number of base-beta digits in mantissa\n    iemin = std::numeric_limits<RealScalar>::min_exponent;          // minimum exponent\n    iemax = std::numeric_limits<RealScalar>::max_exponent;          // maximum exponent\n    rbig  = (std::numeric_limits<RealScalar>::max)();               // largest floating-point number\n\n    iexp  = -((1-iemin)/2);\n    b1    = RealScalar(pow(RealScalar(ibeta),RealScalar(iexp)));    // lower boundary of midrange\n    iexp  = (iemax + 1 - it)/2;\n    b2    = RealScalar(pow(RealScalar(ibeta),RealScalar(iexp)));    // upper boundary of midrange\n\n    iexp  = (2-iemin)/2;\n    s1m   = RealScalar(pow(RealScalar(ibeta),RealScalar(iexp)));    // scaling factor for lower range\n    iexp  = - ((iemax+it)/2);\n    s2m   = RealScalar(pow(RealScalar(ibeta),RealScalar(iexp)));    // scaling factor for upper range\n\n    eps     = RealScalar(pow(double(ibeta), 1-it));\n    relerr  = sqrt(eps);                                            // tolerance for neglecting asml\n    initialized = true;\n  }\n  Index n = vec.size();\n  RealScalar ab2 = b2 / RealScalar(n);\n  RealScalar asml = RealScalar(0);\n  RealScalar amed = RealScalar(0);\n  RealScalar abig = RealScalar(0);\n  for(typename Derived::InnerIterator it(vec, 0); it; ++it)\n  {\n    RealScalar ax = abs(it.value());\n    if(ax > ab2)     abig += numext::abs2(ax*s2m);\n    else if(ax < b1) asml += numext::abs2(ax*s1m);\n    else             amed += numext::abs2(ax);\n  }\n  if(amed!=amed)\n    return amed;  // we got a NaN\n  if(abig > RealScalar(0))\n  {\n    abig = sqrt(abig);\n    if(abig > rbig) // overflow, or *this contains INF values\n      return abig;  // return INF\n    if(amed > RealScalar(0))\n    {\n      abig = abig/s2m;\n      amed = sqrt(amed);\n    }\n    else\n      return abig/s2m;\n  }\n  else if(asml > RealScalar(0))\n  {\n    if (amed > RealScalar(0))\n    {\n      abig = sqrt(amed);\n      amed = sqrt(asml) / s1m;\n    }\n    else\n      return sqrt(asml)/s1m;\n  }\n  else\n    return sqrt(amed);\n  asml = numext::mini(abig, amed);\n  abig = numext::maxi(abig, amed);\n  if(asml <= abig*relerr)\n    return abig;\n  else\n    return abig * sqrt(RealScalar(1) + numext::abs2(asml/abig));\n}\n\n} // end namespace internal\n\n/** \\returns the \\em l2 norm of \\c *this avoiding underflow and overflow.\n  * This version use a blockwise two passes algorithm:\n  *  1 - find the absolute largest coefficient \\c s\n  *  2 - compute \\f$ s \\Vert \\frac{*this}{s} \\Vert \\f$ in a standard way\n  *\n  * For architecture/scalar types supporting vectorization, this version\n  * is faster than blueNorm(). Otherwise the blueNorm() is much faster.\n  *\n  * \\sa norm(), blueNorm(), hypotNorm()\n  */\ntemplate<typename Derived>\ninline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real\nMatrixBase<Derived>::stableNorm() const\n{\n  using std::sqrt;\n  using std::abs;\n  const Index blockSize = 4096;\n  RealScalar scale(0);\n  RealScalar invScale(1);\n  RealScalar ssq(0); // sum of square\n  \n  typedef typename internal::nested_eval<Derived,2>::type DerivedCopy;\n  typedef typename internal::remove_all<DerivedCopy>::type DerivedCopyClean;\n  DerivedCopy copy(derived());\n  \n  enum {\n    CanAlign = (   (int(DerivedCopyClean::Flags)&DirectAccessBit)\n                || (int(internal::evaluator<DerivedCopyClean>::Alignment)>0) // FIXME Alignment)>0 might not be enough\n               ) && (blockSize*sizeof(Scalar)*2<EIGEN_STACK_ALLOCATION_LIMIT)\n                 && (EIGEN_MAX_STATIC_ALIGN_BYTES>0) // if we cannot allocate on the stack, then let's not bother about this optimization\n  };\n  typedef typename internal::conditional<CanAlign, Ref<const Matrix<Scalar,Dynamic,1,0,blockSize,1>, internal::evaluator<DerivedCopyClean>::Alignment>,\n                                                   typename DerivedCopyClean::ConstSegmentReturnType>::type SegmentWrapper;\n  Index n = size();\n  \n  if(n==1)\n    return abs(this->coeff(0));\n  \n  Index bi = internal::first_default_aligned(copy);\n  if (bi>0)\n    internal::stable_norm_kernel(copy.head(bi), ssq, scale, invScale);\n  for (; bi<n; bi+=blockSize)\n    internal::stable_norm_kernel(SegmentWrapper(copy.segment(bi,numext::mini(blockSize, n - bi))), ssq, scale, invScale);\n  return scale * sqrt(ssq);\n}\n\n/** \\returns the \\em l2 norm of \\c *this using the Blue's algorithm.\n  * A Portable Fortran Program to Find the Euclidean Norm of a Vector,\n  * ACM TOMS, Vol 4, Issue 1, 1978.\n  *\n  * For architecture/scalar types without vectorization, this version\n  * is much faster than stableNorm(). Otherwise the stableNorm() is faster.\n  *\n  * \\sa norm(), stableNorm(), hypotNorm()\n  */\ntemplate<typename Derived>\ninline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real\nMatrixBase<Derived>::blueNorm() const\n{\n  return internal::blueNorm_impl(*this);\n}\n\n/** \\returns the \\em l2 norm of \\c *this avoiding undeflow and overflow.\n  * This version use a concatenation of hypot() calls, and it is very slow.\n  *\n  * \\sa norm(), stableNorm()\n  */\ntemplate<typename Derived>\ninline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real\nMatrixBase<Derived>::hypotNorm() const\n{\n  return this->cwiseAbs().redux(internal::scalar_hypot_op<RealScalar>());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_STABLENORM_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Stride.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_STRIDE_H\n#define EIGEN_STRIDE_H\n\nnamespace Eigen { \n\n/** \\class Stride\n  * \\ingroup Core_Module\n  *\n  * \\brief Holds strides information for Map\n  *\n  * This class holds the strides information for mapping arrays with strides with class Map.\n  *\n  * It holds two values: the inner stride and the outer stride.\n  *\n  * The inner stride is the pointer increment between two consecutive entries within a given row of a\n  * row-major matrix or within a given column of a column-major matrix.\n  *\n  * The outer stride is the pointer increment between two consecutive rows of a row-major matrix or\n  * between two consecutive columns of a column-major matrix.\n  *\n  * These two values can be passed either at compile-time as template parameters, or at runtime as\n  * arguments to the constructor.\n  *\n  * Indeed, this class takes two template parameters:\n  *  \\tparam _OuterStrideAtCompileTime the outer stride, or Dynamic if you want to specify it at runtime.\n  *  \\tparam _InnerStrideAtCompileTime the inner stride, or Dynamic if you want to specify it at runtime.\n  *\n  * Here is an example:\n  * \\include Map_general_stride.cpp\n  * Output: \\verbinclude Map_general_stride.out\n  *\n  * \\sa class InnerStride, class OuterStride, \\ref TopicStorageOrders\n  */\ntemplate<int _OuterStrideAtCompileTime, int _InnerStrideAtCompileTime>\nclass Stride\n{\n  public:\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n    enum {\n      InnerStrideAtCompileTime = _InnerStrideAtCompileTime,\n      OuterStrideAtCompileTime = _OuterStrideAtCompileTime\n    };\n\n    /** Default constructor, for use when strides are fixed at compile time */\n    EIGEN_DEVICE_FUNC\n    Stride()\n      : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime)\n    {\n      eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic);\n    }\n\n    /** Constructor allowing to pass the strides at runtime */\n    EIGEN_DEVICE_FUNC\n    Stride(Index outerStride, Index innerStride)\n      : m_outer(outerStride), m_inner(innerStride)\n    {\n      eigen_assert(innerStride>=0 && outerStride>=0);\n    }\n\n    /** Copy constructor */\n    EIGEN_DEVICE_FUNC\n    Stride(const Stride& other)\n      : m_outer(other.outer()), m_inner(other.inner())\n    {}\n\n    /** \\returns the outer stride */\n    EIGEN_DEVICE_FUNC\n    inline Index outer() const { return m_outer.value(); }\n    /** \\returns the inner stride */\n    EIGEN_DEVICE_FUNC\n    inline Index inner() const { return m_inner.value(); }\n\n  protected:\n    internal::variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer;\n    internal::variable_if_dynamic<Index, InnerStrideAtCompileTime> m_inner;\n};\n\n/** \\brief Convenience specialization of Stride to specify only an inner stride\n  * See class Map for some examples */\ntemplate<int Value>\nclass InnerStride : public Stride<0, Value>\n{\n    typedef Stride<0, Value> Base;\n  public:\n    EIGEN_DEVICE_FUNC InnerStride() : Base() {}\n    EIGEN_DEVICE_FUNC InnerStride(Index v) : Base(0, v) {} // FIXME making this explicit could break valid code\n};\n\n/** \\brief Convenience specialization of Stride to specify only an outer stride\n  * See class Map for some examples */\ntemplate<int Value>\nclass OuterStride : public Stride<Value, 0>\n{\n    typedef Stride<Value, 0> Base;\n  public:\n    EIGEN_DEVICE_FUNC OuterStride() : Base() {}\n    EIGEN_DEVICE_FUNC OuterStride(Index v) : Base(v,0) {} // FIXME making this explicit could break valid code\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_STRIDE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Swap.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SWAP_H\n#define EIGEN_SWAP_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n// Overload default assignPacket behavior for swapping them\ntemplate<typename DstEvaluatorTypeT, typename SrcEvaluatorTypeT>\nclass generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, swap_assign_op<typename DstEvaluatorTypeT::Scalar>, Specialized>\n : public generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, swap_assign_op<typename DstEvaluatorTypeT::Scalar>, BuiltIn>\n{\nprotected:\n  typedef generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, swap_assign_op<typename DstEvaluatorTypeT::Scalar>, BuiltIn> Base;\n  using Base::m_dst;\n  using Base::m_src;\n  using Base::m_functor;\n  \npublic:\n  typedef typename Base::Scalar Scalar;\n  typedef typename Base::DstXprType DstXprType;\n  typedef swap_assign_op<Scalar> Functor;\n  \n  EIGEN_DEVICE_FUNC generic_dense_assignment_kernel(DstEvaluatorTypeT &dst, const SrcEvaluatorTypeT &src, const Functor &func, DstXprType& dstExpr)\n    : Base(dst, src, func, dstExpr)\n  {}\n  \n  template<int StoreMode, int LoadMode, typename PacketType>\n  void assignPacket(Index row, Index col)\n  {\n    PacketType tmp = m_src.template packet<LoadMode,PacketType>(row,col);\n    const_cast<SrcEvaluatorTypeT&>(m_src).template writePacket<LoadMode>(row,col, m_dst.template packet<StoreMode,PacketType>(row,col));\n    m_dst.template writePacket<StoreMode>(row,col,tmp);\n  }\n  \n  template<int StoreMode, int LoadMode, typename PacketType>\n  void assignPacket(Index index)\n  {\n    PacketType tmp = m_src.template packet<LoadMode,PacketType>(index);\n    const_cast<SrcEvaluatorTypeT&>(m_src).template writePacket<LoadMode>(index, m_dst.template packet<StoreMode,PacketType>(index));\n    m_dst.template writePacket<StoreMode>(index,tmp);\n  }\n  \n  // TODO find a simple way not to have to copy/paste this function from generic_dense_assignment_kernel, by simple I mean no CRTP (Gael)\n  template<int StoreMode, int LoadMode, typename PacketType>\n  void assignPacketByOuterInner(Index outer, Index inner)\n  {\n    Index row = Base::rowIndexByOuterInner(outer, inner); \n    Index col = Base::colIndexByOuterInner(outer, inner);\n    assignPacket<StoreMode,LoadMode,PacketType>(row, col);\n  }\n};\n\n} // namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SWAP_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Transpose.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2009-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TRANSPOSE_H\n#define EIGEN_TRANSPOSE_H\n\nnamespace Eigen { \n\nnamespace internal {\ntemplate<typename MatrixType>\nstruct traits<Transpose<MatrixType> > : public traits<MatrixType>\n{\n  typedef typename ref_selector<MatrixType>::type MatrixTypeNested;\n  typedef typename remove_reference<MatrixTypeNested>::type MatrixTypeNestedPlain;\n  enum {\n    RowsAtCompileTime = MatrixType::ColsAtCompileTime,\n    ColsAtCompileTime = MatrixType::RowsAtCompileTime,\n    MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime,\n    MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n    FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,\n    Flags0 = traits<MatrixTypeNestedPlain>::Flags & ~(LvalueBit | NestByRefBit),\n    Flags1 = Flags0 | FlagsLvalueBit,\n    Flags = Flags1 ^ RowMajorBit,\n    InnerStrideAtCompileTime = inner_stride_at_compile_time<MatrixType>::ret,\n    OuterStrideAtCompileTime = outer_stride_at_compile_time<MatrixType>::ret\n  };\n};\n}\n\ntemplate<typename MatrixType, typename StorageKind> class TransposeImpl;\n\n/** \\class Transpose\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of the transpose of a matrix\n  *\n  * \\tparam MatrixType the type of the object of which we are taking the transpose\n  *\n  * This class represents an expression of the transpose of a matrix.\n  * It is the return type of MatrixBase::transpose() and MatrixBase::adjoint()\n  * and most of the time this is the only way it is used.\n  *\n  * \\sa MatrixBase::transpose(), MatrixBase::adjoint()\n  */\ntemplate<typename MatrixType> class Transpose\n  : public TransposeImpl<MatrixType,typename internal::traits<MatrixType>::StorageKind>\n{\n  public:\n\n    typedef typename internal::ref_selector<MatrixType>::non_const_type MatrixTypeNested;\n\n    typedef typename TransposeImpl<MatrixType,typename internal::traits<MatrixType>::StorageKind>::Base Base;\n    EIGEN_GENERIC_PUBLIC_INTERFACE(Transpose)\n    typedef typename internal::remove_all<MatrixType>::type NestedExpression;\n\n    EIGEN_DEVICE_FUNC\n    explicit inline Transpose(MatrixType& matrix) : m_matrix(matrix) {}\n\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose)\n\n    EIGEN_DEVICE_FUNC inline Index rows() const { return m_matrix.cols(); }\n    EIGEN_DEVICE_FUNC inline Index cols() const { return m_matrix.rows(); }\n\n    /** \\returns the nested expression */\n    EIGEN_DEVICE_FUNC\n    const typename internal::remove_all<MatrixTypeNested>::type&\n    nestedExpression() const { return m_matrix; }\n\n    /** \\returns the nested expression */\n    EIGEN_DEVICE_FUNC\n    typename internal::remove_reference<MatrixTypeNested>::type&\n    nestedExpression() { return m_matrix; }\n\n    /** \\internal */\n    void resize(Index nrows, Index ncols) {\n      m_matrix.resize(ncols,nrows);\n    }\n\n  protected:\n    typename internal::ref_selector<MatrixType>::non_const_type m_matrix;\n};\n\nnamespace internal {\n\ntemplate<typename MatrixType, bool HasDirectAccess = has_direct_access<MatrixType>::ret>\nstruct TransposeImpl_base\n{\n  typedef typename dense_xpr_base<Transpose<MatrixType> >::type type;\n};\n\ntemplate<typename MatrixType>\nstruct TransposeImpl_base<MatrixType, false>\n{\n  typedef typename dense_xpr_base<Transpose<MatrixType> >::type type;\n};\n\n} // end namespace internal\n\n// Generic API dispatcher\ntemplate<typename XprType, typename StorageKind>\nclass TransposeImpl\n  : public internal::generic_xpr_base<Transpose<XprType> >::type\n{\npublic:\n  typedef typename internal::generic_xpr_base<Transpose<XprType> >::type Base;\n};\n\ntemplate<typename MatrixType> class TransposeImpl<MatrixType,Dense>\n  : public internal::TransposeImpl_base<MatrixType>::type\n{\n  public:\n\n    typedef typename internal::TransposeImpl_base<MatrixType>::type Base;\n    using Base::coeffRef;\n    EIGEN_DENSE_PUBLIC_INTERFACE(Transpose<MatrixType>)\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(TransposeImpl)\n\n    EIGEN_DEVICE_FUNC inline Index innerStride() const { return derived().nestedExpression().innerStride(); }\n    EIGEN_DEVICE_FUNC inline Index outerStride() const { return derived().nestedExpression().outerStride(); }\n\n    typedef typename internal::conditional<\n                       internal::is_lvalue<MatrixType>::value,\n                       Scalar,\n                       const Scalar\n                     >::type ScalarWithConstIfNotLvalue;\n\n    EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue* data() { return derived().nestedExpression().data(); }\n    EIGEN_DEVICE_FUNC inline const Scalar* data() const { return derived().nestedExpression().data(); }\n\n    // FIXME: shall we keep the const version of coeffRef?\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index rowId, Index colId) const\n    {\n      return derived().nestedExpression().coeffRef(colId, rowId);\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline const Scalar& coeffRef(Index index) const\n    {\n      return derived().nestedExpression().coeffRef(index);\n    }\n};\n\n/** \\returns an expression of the transpose of *this.\n  *\n  * Example: \\include MatrixBase_transpose.cpp\n  * Output: \\verbinclude MatrixBase_transpose.out\n  *\n  * \\warning If you want to replace a matrix by its own transpose, do \\b NOT do this:\n  * \\code\n  * m = m.transpose(); // bug!!! caused by aliasing effect\n  * \\endcode\n  * Instead, use the transposeInPlace() method:\n  * \\code\n  * m.transposeInPlace();\n  * \\endcode\n  * which gives Eigen good opportunities for optimization, or alternatively you can also do:\n  * \\code\n  * m = m.transpose().eval();\n  * \\endcode\n  *\n  * \\sa transposeInPlace(), adjoint() */\ntemplate<typename Derived>\ninline Transpose<Derived>\nDenseBase<Derived>::transpose()\n{\n  return TransposeReturnType(derived());\n}\n\n/** This is the const version of transpose().\n  *\n  * Make sure you read the warning for transpose() !\n  *\n  * \\sa transposeInPlace(), adjoint() */\ntemplate<typename Derived>\ninline typename DenseBase<Derived>::ConstTransposeReturnType\nDenseBase<Derived>::transpose() const\n{\n  return ConstTransposeReturnType(derived());\n}\n\n/** \\returns an expression of the adjoint (i.e. conjugate transpose) of *this.\n  *\n  * Example: \\include MatrixBase_adjoint.cpp\n  * Output: \\verbinclude MatrixBase_adjoint.out\n  *\n  * \\warning If you want to replace a matrix by its own adjoint, do \\b NOT do this:\n  * \\code\n  * m = m.adjoint(); // bug!!! caused by aliasing effect\n  * \\endcode\n  * Instead, use the adjointInPlace() method:\n  * \\code\n  * m.adjointInPlace();\n  * \\endcode\n  * which gives Eigen good opportunities for optimization, or alternatively you can also do:\n  * \\code\n  * m = m.adjoint().eval();\n  * \\endcode\n  *\n  * \\sa adjointInPlace(), transpose(), conjugate(), class Transpose, class internal::scalar_conjugate_op */\ntemplate<typename Derived>\ninline const typename MatrixBase<Derived>::AdjointReturnType\nMatrixBase<Derived>::adjoint() const\n{\n  return AdjointReturnType(this->transpose());\n}\n\n/***************************************************************************\n* \"in place\" transpose implementation\n***************************************************************************/\n\nnamespace internal {\n\ntemplate<typename MatrixType,\n  bool IsSquare = (MatrixType::RowsAtCompileTime == MatrixType::ColsAtCompileTime) && MatrixType::RowsAtCompileTime!=Dynamic,\n  bool MatchPacketSize =\n        (int(MatrixType::RowsAtCompileTime) == int(internal::packet_traits<typename MatrixType::Scalar>::size))\n    &&  (internal::evaluator<MatrixType>::Flags&PacketAccessBit) >\nstruct inplace_transpose_selector;\n\ntemplate<typename MatrixType>\nstruct inplace_transpose_selector<MatrixType,true,false> { // square matrix\n  static void run(MatrixType& m) {\n    m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose());\n  }\n};\n\n// TODO: vectorized path is currently limited to LargestPacketSize x LargestPacketSize cases only.\ntemplate<typename MatrixType>\nstruct inplace_transpose_selector<MatrixType,true,true> { // PacketSize x PacketSize\n  static void run(MatrixType& m) {\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename internal::packet_traits<typename MatrixType::Scalar>::type Packet;\n    const Index PacketSize = internal::packet_traits<Scalar>::size;\n    const Index Alignment = internal::evaluator<MatrixType>::Alignment;\n    PacketBlock<Packet> A;\n    for (Index i=0; i<PacketSize; ++i)\n      A.packet[i] = m.template packetByOuterInner<Alignment>(i,0);\n    internal::ptranspose(A);\n    for (Index i=0; i<PacketSize; ++i)\n      m.template writePacket<Alignment>(m.rowIndexByOuterInner(i,0), m.colIndexByOuterInner(i,0), A.packet[i]);\n  }\n};\n\ntemplate<typename MatrixType,bool MatchPacketSize>\nstruct inplace_transpose_selector<MatrixType,false,MatchPacketSize> { // non square matrix\n  static void run(MatrixType& m) {\n    if (m.rows()==m.cols())\n      m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose());\n    else\n      m = m.transpose().eval();\n  }\n};\n\n} // end namespace internal\n\n/** This is the \"in place\" version of transpose(): it replaces \\c *this by its own transpose.\n  * Thus, doing\n  * \\code\n  * m.transposeInPlace();\n  * \\endcode\n  * has the same effect on m as doing\n  * \\code\n  * m = m.transpose().eval();\n  * \\endcode\n  * and is faster and also safer because in the latter line of code, forgetting the eval() results\n  * in a bug caused by \\ref TopicAliasing \"aliasing\".\n  *\n  * Notice however that this method is only useful if you want to replace a matrix by its own transpose.\n  * If you just need the transpose of a matrix, use transpose().\n  *\n  * \\note if the matrix is not square, then \\c *this must be a resizable matrix. \n  * This excludes (non-square) fixed-size matrices, block-expressions and maps.\n  *\n  * \\sa transpose(), adjoint(), adjointInPlace() */\ntemplate<typename Derived>\ninline void DenseBase<Derived>::transposeInPlace()\n{\n  eigen_assert((rows() == cols() || (RowsAtCompileTime == Dynamic && ColsAtCompileTime == Dynamic))\n               && \"transposeInPlace() called on a non-square non-resizable matrix\");\n  internal::inplace_transpose_selector<Derived>::run(derived());\n}\n\n/***************************************************************************\n* \"in place\" adjoint implementation\n***************************************************************************/\n\n/** This is the \"in place\" version of adjoint(): it replaces \\c *this by its own transpose.\n  * Thus, doing\n  * \\code\n  * m.adjointInPlace();\n  * \\endcode\n  * has the same effect on m as doing\n  * \\code\n  * m = m.adjoint().eval();\n  * \\endcode\n  * and is faster and also safer because in the latter line of code, forgetting the eval() results\n  * in a bug caused by aliasing.\n  *\n  * Notice however that this method is only useful if you want to replace a matrix by its own adjoint.\n  * If you just need the adjoint of a matrix, use adjoint().\n  *\n  * \\note if the matrix is not square, then \\c *this must be a resizable matrix.\n  * This excludes (non-square) fixed-size matrices, block-expressions and maps.\n  *\n  * \\sa transpose(), adjoint(), transposeInPlace() */\ntemplate<typename Derived>\ninline void MatrixBase<Derived>::adjointInPlace()\n{\n  derived() = adjoint().eval();\n}\n\n#ifndef EIGEN_NO_DEBUG\n\n// The following is to detect aliasing problems in most common cases.\n\nnamespace internal {\n\ntemplate<bool DestIsTransposed, typename OtherDerived>\nstruct check_transpose_aliasing_compile_time_selector\n{\n  enum { ret = bool(blas_traits<OtherDerived>::IsTransposed) != DestIsTransposed };\n};\n\ntemplate<bool DestIsTransposed, typename BinOp, typename DerivedA, typename DerivedB>\nstruct check_transpose_aliasing_compile_time_selector<DestIsTransposed,CwiseBinaryOp<BinOp,DerivedA,DerivedB> >\n{\n  enum { ret =    bool(blas_traits<DerivedA>::IsTransposed) != DestIsTransposed\n               || bool(blas_traits<DerivedB>::IsTransposed) != DestIsTransposed\n  };\n};\n\ntemplate<typename Scalar, bool DestIsTransposed, typename OtherDerived>\nstruct check_transpose_aliasing_run_time_selector\n{\n  static bool run(const Scalar* dest, const OtherDerived& src)\n  {\n    return (bool(blas_traits<OtherDerived>::IsTransposed) != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src));\n  }\n};\n\ntemplate<typename Scalar, bool DestIsTransposed, typename BinOp, typename DerivedA, typename DerivedB>\nstruct check_transpose_aliasing_run_time_selector<Scalar,DestIsTransposed,CwiseBinaryOp<BinOp,DerivedA,DerivedB> >\n{\n  static bool run(const Scalar* dest, const CwiseBinaryOp<BinOp,DerivedA,DerivedB>& src)\n  {\n    return ((blas_traits<DerivedA>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src.lhs())))\n        || ((blas_traits<DerivedB>::IsTransposed != DestIsTransposed) && (dest!=0 && dest==(const Scalar*)extract_data(src.rhs())));\n  }\n};\n\n// the following selector, checkTransposeAliasing_impl, based on MightHaveTransposeAliasing,\n// is because when the condition controlling the assert is known at compile time, ICC emits a warning.\n// This is actually a good warning: in expressions that don't have any transposing, the condition is\n// known at compile time to be false, and using that, we can avoid generating the code of the assert again\n// and again for all these expressions that don't need it.\n\ntemplate<typename Derived, typename OtherDerived,\n         bool MightHaveTransposeAliasing\n                 = check_transpose_aliasing_compile_time_selector\n                     <blas_traits<Derived>::IsTransposed,OtherDerived>::ret\n        >\nstruct checkTransposeAliasing_impl\n{\n    static void run(const Derived& dst, const OtherDerived& other)\n    {\n        eigen_assert((!check_transpose_aliasing_run_time_selector\n                      <typename Derived::Scalar,blas_traits<Derived>::IsTransposed,OtherDerived>\n                      ::run(extract_data(dst), other))\n          && \"aliasing detected during transposition, use transposeInPlace() \"\n             \"or evaluate the rhs into a temporary using .eval()\");\n\n    }\n};\n\ntemplate<typename Derived, typename OtherDerived>\nstruct checkTransposeAliasing_impl<Derived, OtherDerived, false>\n{\n    static void run(const Derived&, const OtherDerived&)\n    {\n    }\n};\n\ntemplate<typename Dst, typename Src>\nvoid check_for_aliasing(const Dst &dst, const Src &src)\n{\n  internal::checkTransposeAliasing_impl<Dst, Src>::run(dst, src);\n}\n\n} // end namespace internal\n\n#endif // EIGEN_NO_DEBUG\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRANSPOSE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Transpositions.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010-2011 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TRANSPOSITIONS_H\n#define EIGEN_TRANSPOSITIONS_H\n\nnamespace Eigen { \n\ntemplate<typename Derived>\nclass TranspositionsBase\n{\n    typedef internal::traits<Derived> Traits;\n    \n  public:\n\n    typedef typename Traits::IndicesType IndicesType;\n    typedef typename IndicesType::Scalar StorageIndex;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n\n    Derived& derived() { return *static_cast<Derived*>(this); }\n    const Derived& derived() const { return *static_cast<const Derived*>(this); }\n\n    /** Copies the \\a other transpositions into \\c *this */\n    template<typename OtherDerived>\n    Derived& operator=(const TranspositionsBase<OtherDerived>& other)\n    {\n      indices() = other.indices();\n      return derived();\n    }\n    \n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** This is a special case of the templated operator=. Its purpose is to\n      * prevent a default operator= from hiding the templated operator=.\n      */\n    Derived& operator=(const TranspositionsBase& other)\n    {\n      indices() = other.indices();\n      return derived();\n    }\n    #endif\n\n    /** \\returns the number of transpositions */\n    Index size() const { return indices().size(); }\n    /** \\returns the number of rows of the equivalent permutation matrix */\n    Index rows() const { return indices().size(); }\n    /** \\returns the number of columns of the equivalent permutation matrix */\n    Index cols() const { return indices().size(); }\n\n    /** Direct access to the underlying index vector */\n    inline const StorageIndex& coeff(Index i) const { return indices().coeff(i); }\n    /** Direct access to the underlying index vector */\n    inline StorageIndex& coeffRef(Index i) { return indices().coeffRef(i); }\n    /** Direct access to the underlying index vector */\n    inline const StorageIndex& operator()(Index i) const { return indices()(i); }\n    /** Direct access to the underlying index vector */\n    inline StorageIndex& operator()(Index i) { return indices()(i); }\n    /** Direct access to the underlying index vector */\n    inline const StorageIndex& operator[](Index i) const { return indices()(i); }\n    /** Direct access to the underlying index vector */\n    inline StorageIndex& operator[](Index i) { return indices()(i); }\n\n    /** const version of indices(). */\n    const IndicesType& indices() const { return derived().indices(); }\n    /** \\returns a reference to the stored array representing the transpositions. */\n    IndicesType& indices() { return derived().indices(); }\n\n    /** Resizes to given size. */\n    inline void resize(Index newSize)\n    {\n      indices().resize(newSize);\n    }\n\n    /** Sets \\c *this to represents an identity transformation */\n    void setIdentity()\n    {\n      for(StorageIndex i = 0; i < indices().size(); ++i)\n        coeffRef(i) = i;\n    }\n\n    // FIXME: do we want such methods ?\n    // might be usefull when the target matrix expression is complex, e.g.:\n    // object.matrix().block(..,..,..,..) = trans * object.matrix().block(..,..,..,..);\n    /*\n    template<typename MatrixType>\n    void applyForwardToRows(MatrixType& mat) const\n    {\n      for(Index k=0 ; k<size() ; ++k)\n        if(m_indices(k)!=k)\n          mat.row(k).swap(mat.row(m_indices(k)));\n    }\n\n    template<typename MatrixType>\n    void applyBackwardToRows(MatrixType& mat) const\n    {\n      for(Index k=size()-1 ; k>=0 ; --k)\n        if(m_indices(k)!=k)\n          mat.row(k).swap(mat.row(m_indices(k)));\n    }\n    */\n\n    /** \\returns the inverse transformation */\n    inline Transpose<TranspositionsBase> inverse() const\n    { return Transpose<TranspositionsBase>(derived()); }\n\n    /** \\returns the tranpose transformation */\n    inline Transpose<TranspositionsBase> transpose() const\n    { return Transpose<TranspositionsBase>(derived()); }\n\n  protected:\n};\n\nnamespace internal {\ntemplate<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex>\nstruct traits<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >\n : traits<PermutationMatrix<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >\n{\n  typedef Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;\n  typedef TranspositionsStorage StorageKind;\n};\n}\n\n/** \\class Transpositions\n  * \\ingroup Core_Module\n  *\n  * \\brief Represents a sequence of transpositions (row/column interchange)\n  *\n  * \\tparam SizeAtCompileTime the number of transpositions, or Dynamic\n  * \\tparam MaxSizeAtCompileTime the maximum number of transpositions, or Dynamic. This optional parameter defaults to SizeAtCompileTime. Most of the time, you should not have to specify it.\n  *\n  * This class represents a permutation transformation as a sequence of \\em n transpositions\n  * \\f$[T_{n-1} \\ldots T_{i} \\ldots T_{0}]\\f$. It is internally stored as a vector of integers \\c indices.\n  * Each transposition \\f$ T_{i} \\f$ applied on the left of a matrix (\\f$ T_{i} M\\f$) interchanges\n  * the rows \\c i and \\c indices[i] of the matrix \\c M.\n  * A transposition applied on the right (e.g., \\f$ M T_{i}\\f$) yields a column interchange.\n  *\n  * Compared to the class PermutationMatrix, such a sequence of transpositions is what is\n  * computed during a decomposition with pivoting, and it is faster when applying the permutation in-place.\n  *\n  * To apply a sequence of transpositions to a matrix, simply use the operator * as in the following example:\n  * \\code\n  * Transpositions tr;\n  * MatrixXf mat;\n  * mat = tr * mat;\n  * \\endcode\n  * In this example, we detect that the matrix appears on both side, and so the transpositions\n  * are applied in-place without any temporary or extra copy.\n  *\n  * \\sa class PermutationMatrix\n  */\n\ntemplate<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex>\nclass Transpositions : public TranspositionsBase<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >\n{\n    typedef internal::traits<Transpositions> Traits;\n  public:\n\n    typedef TranspositionsBase<Transpositions> Base;\n    typedef typename Traits::IndicesType IndicesType;\n    typedef typename IndicesType::Scalar StorageIndex;\n\n    inline Transpositions() {}\n\n    /** Copy constructor. */\n    template<typename OtherDerived>\n    inline Transpositions(const TranspositionsBase<OtherDerived>& other)\n      : m_indices(other.indices()) {}\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** Standard copy constructor. Defined only to prevent a default copy constructor\n      * from hiding the other templated constructor */\n    inline Transpositions(const Transpositions& other) : m_indices(other.indices()) {}\n    #endif\n\n    /** Generic constructor from expression of the transposition indices. */\n    template<typename Other>\n    explicit inline Transpositions(const MatrixBase<Other>& indices) : m_indices(indices)\n    {}\n\n    /** Copies the \\a other transpositions into \\c *this */\n    template<typename OtherDerived>\n    Transpositions& operator=(const TranspositionsBase<OtherDerived>& other)\n    {\n      return Base::operator=(other);\n    }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** This is a special case of the templated operator=. Its purpose is to\n      * prevent a default operator= from hiding the templated operator=.\n      */\n    Transpositions& operator=(const Transpositions& other)\n    {\n      m_indices = other.m_indices;\n      return *this;\n    }\n    #endif\n\n    /** Constructs an uninitialized permutation matrix of given size.\n      */\n    inline Transpositions(Index size) : m_indices(size)\n    {}\n\n    /** const version of indices(). */\n    const IndicesType& indices() const { return m_indices; }\n    /** \\returns a reference to the stored array representing the transpositions. */\n    IndicesType& indices() { return m_indices; }\n\n  protected:\n\n    IndicesType m_indices;\n};\n\n\nnamespace internal {\ntemplate<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex, int _PacketAccess>\nstruct traits<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,_PacketAccess> >\n : traits<PermutationMatrix<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >\n{\n  typedef Map<const Matrix<_StorageIndex,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1>, _PacketAccess> IndicesType;\n  typedef _StorageIndex StorageIndex;\n  typedef TranspositionsStorage StorageKind;\n};\n}\n\ntemplate<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex, int PacketAccess>\nclass Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess>\n : public TranspositionsBase<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess> >\n{\n    typedef internal::traits<Map> Traits;\n  public:\n\n    typedef TranspositionsBase<Map> Base;\n    typedef typename Traits::IndicesType IndicesType;\n    typedef typename IndicesType::Scalar StorageIndex;\n\n    explicit inline Map(const StorageIndex* indicesPtr)\n      : m_indices(indicesPtr)\n    {}\n\n    inline Map(const StorageIndex* indicesPtr, Index size)\n      : m_indices(indicesPtr,size)\n    {}\n\n    /** Copies the \\a other transpositions into \\c *this */\n    template<typename OtherDerived>\n    Map& operator=(const TranspositionsBase<OtherDerived>& other)\n    {\n      return Base::operator=(other);\n    }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** This is a special case of the templated operator=. Its purpose is to\n      * prevent a default operator= from hiding the templated operator=.\n      */\n    Map& operator=(const Map& other)\n    {\n      m_indices = other.m_indices;\n      return *this;\n    }\n    #endif\n\n    /** const version of indices(). */\n    const IndicesType& indices() const { return m_indices; }\n    \n    /** \\returns a reference to the stored array representing the transpositions. */\n    IndicesType& indices() { return m_indices; }\n\n  protected:\n\n    IndicesType m_indices;\n};\n\nnamespace internal {\ntemplate<typename _IndicesType>\nstruct traits<TranspositionsWrapper<_IndicesType> >\n : traits<PermutationWrapper<_IndicesType> >\n{\n  typedef TranspositionsStorage StorageKind;\n};\n}\n\ntemplate<typename _IndicesType>\nclass TranspositionsWrapper\n : public TranspositionsBase<TranspositionsWrapper<_IndicesType> >\n{\n    typedef internal::traits<TranspositionsWrapper> Traits;\n  public:\n\n    typedef TranspositionsBase<TranspositionsWrapper> Base;\n    typedef typename Traits::IndicesType IndicesType;\n    typedef typename IndicesType::Scalar StorageIndex;\n\n    explicit inline TranspositionsWrapper(IndicesType& indices)\n      : m_indices(indices)\n    {}\n\n    /** Copies the \\a other transpositions into \\c *this */\n    template<typename OtherDerived>\n    TranspositionsWrapper& operator=(const TranspositionsBase<OtherDerived>& other)\n    {\n      return Base::operator=(other);\n    }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** This is a special case of the templated operator=. Its purpose is to\n      * prevent a default operator= from hiding the templated operator=.\n      */\n    TranspositionsWrapper& operator=(const TranspositionsWrapper& other)\n    {\n      m_indices = other.m_indices;\n      return *this;\n    }\n    #endif\n\n    /** const version of indices(). */\n    const IndicesType& indices() const { return m_indices; }\n\n    /** \\returns a reference to the stored array representing the transpositions. */\n    IndicesType& indices() { return m_indices; }\n\n  protected:\n\n    typename IndicesType::Nested m_indices;\n};\n\n\n\n/** \\returns the \\a matrix with the \\a transpositions applied to the columns.\n  */\ntemplate<typename MatrixDerived, typename TranspositionsDerived>\nEIGEN_DEVICE_FUNC\nconst Product<MatrixDerived, TranspositionsDerived, AliasFreeProduct>\noperator*(const MatrixBase<MatrixDerived> &matrix,\n          const TranspositionsBase<TranspositionsDerived>& transpositions)\n{\n  return Product<MatrixDerived, TranspositionsDerived, AliasFreeProduct>\n            (matrix.derived(), transpositions.derived());\n}\n\n/** \\returns the \\a matrix with the \\a transpositions applied to the rows.\n  */\ntemplate<typename TranspositionsDerived, typename MatrixDerived>\nEIGEN_DEVICE_FUNC\nconst Product<TranspositionsDerived, MatrixDerived, AliasFreeProduct>\noperator*(const TranspositionsBase<TranspositionsDerived> &transpositions,\n          const MatrixBase<MatrixDerived>& matrix)\n{\n  return Product<TranspositionsDerived, MatrixDerived, AliasFreeProduct>\n            (transpositions.derived(), matrix.derived());\n}\n\n// Template partial specialization for transposed/inverse transpositions\n\nnamespace internal {\n\ntemplate<typename Derived>\nstruct traits<Transpose<TranspositionsBase<Derived> > >\n : traits<Derived>\n{};\n\n} // end namespace internal\n\ntemplate<typename TranspositionsDerived>\nclass Transpose<TranspositionsBase<TranspositionsDerived> >\n{\n    typedef TranspositionsDerived TranspositionType;\n    typedef typename TranspositionType::IndicesType IndicesType;\n  public:\n\n    explicit Transpose(const TranspositionType& t) : m_transpositions(t) {}\n\n    Index size() const { return m_transpositions.size(); }\n    Index rows() const { return m_transpositions.size(); }\n    Index cols() const { return m_transpositions.size(); }\n\n    /** \\returns the \\a matrix with the inverse transpositions applied to the columns.\n      */\n    template<typename OtherDerived> friend\n    const Product<OtherDerived, Transpose, AliasFreeProduct>\n    operator*(const MatrixBase<OtherDerived>& matrix, const Transpose& trt)\n    {\n      return Product<OtherDerived, Transpose, AliasFreeProduct>(matrix.derived(), trt.derived());\n    }\n\n    /** \\returns the \\a matrix with the inverse transpositions applied to the rows.\n      */\n    template<typename OtherDerived>\n    const Product<Transpose, OtherDerived, AliasFreeProduct>\n    operator*(const MatrixBase<OtherDerived>& matrix) const\n    {\n      return Product<Transpose, OtherDerived, AliasFreeProduct>(*this, matrix.derived());\n    }\n    \n    const TranspositionType& nestedExpression() const { return m_transpositions; }\n\n  protected:\n    const TranspositionType& m_transpositions;\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRANSPOSITIONS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/TriangularMatrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TRIANGULARMATRIX_H\n#define EIGEN_TRIANGULARMATRIX_H\n\nnamespace Eigen { \n\nnamespace internal {\n  \ntemplate<int Side, typename TriangularType, typename Rhs> struct triangular_solve_retval;\n  \n}\n\n/** \\class TriangularBase\n  * \\ingroup Core_Module\n  *\n  * \\brief Base class for triangular part in a matrix\n  */\ntemplate<typename Derived> class TriangularBase : public EigenBase<Derived>\n{\n  public:\n\n    enum {\n      Mode = internal::traits<Derived>::Mode,\n      RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,\n      ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,\n      MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,\n      \n      SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,\n                                                   internal::traits<Derived>::ColsAtCompileTime>::ret),\n      /**< This is equal to the number of coefficients, i.e. the number of\n          * rows times the number of columns, or to \\a Dynamic if this is not\n          * known at compile-time. \\sa RowsAtCompileTime, ColsAtCompileTime */\n      \n      MaxSizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::MaxRowsAtCompileTime,\n                                                   internal::traits<Derived>::MaxColsAtCompileTime>::ret)\n        \n    };\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    typedef typename internal::traits<Derived>::StorageKind StorageKind;\n    typedef typename internal::traits<Derived>::StorageIndex StorageIndex;\n    typedef typename internal::traits<Derived>::FullMatrixType DenseMatrixType;\n    typedef DenseMatrixType DenseType;\n    typedef Derived const& Nested;\n\n    EIGEN_DEVICE_FUNC\n    inline TriangularBase() { eigen_assert(!((Mode&UnitDiag) && (Mode&ZeroDiag))); }\n\n    EIGEN_DEVICE_FUNC\n    inline Index rows() const { return derived().rows(); }\n    EIGEN_DEVICE_FUNC\n    inline Index cols() const { return derived().cols(); }\n    EIGEN_DEVICE_FUNC\n    inline Index outerStride() const { return derived().outerStride(); }\n    EIGEN_DEVICE_FUNC\n    inline Index innerStride() const { return derived().innerStride(); }\n    \n    // dummy resize function\n    void resize(Index rows, Index cols)\n    {\n      EIGEN_UNUSED_VARIABLE(rows);\n      EIGEN_UNUSED_VARIABLE(cols);\n      eigen_assert(rows==this->rows() && cols==this->cols());\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline Scalar coeff(Index row, Index col) const  { return derived().coeff(row,col); }\n    EIGEN_DEVICE_FUNC\n    inline Scalar& coeffRef(Index row, Index col) { return derived().coeffRef(row,col); }\n\n    /** \\see MatrixBase::copyCoeff(row,col)\n      */\n    template<typename Other>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void copyCoeff(Index row, Index col, Other& other)\n    {\n      derived().coeffRef(row, col) = other.coeff(row, col);\n    }\n\n    EIGEN_DEVICE_FUNC\n    inline Scalar operator()(Index row, Index col) const\n    {\n      check_coordinates(row, col);\n      return coeff(row,col);\n    }\n    EIGEN_DEVICE_FUNC\n    inline Scalar& operator()(Index row, Index col)\n    {\n      check_coordinates(row, col);\n      return coeffRef(row,col);\n    }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    EIGEN_DEVICE_FUNC\n    inline const Derived& derived() const { return *static_cast<const Derived*>(this); }\n    EIGEN_DEVICE_FUNC\n    inline Derived& derived() { return *static_cast<Derived*>(this); }\n    #endif // not EIGEN_PARSED_BY_DOXYGEN\n\n    template<typename DenseDerived>\n    EIGEN_DEVICE_FUNC\n    void evalTo(MatrixBase<DenseDerived> &other) const;\n    template<typename DenseDerived>\n    EIGEN_DEVICE_FUNC\n    void evalToLazy(MatrixBase<DenseDerived> &other) const;\n\n    EIGEN_DEVICE_FUNC\n    DenseMatrixType toDenseMatrix() const\n    {\n      DenseMatrixType res(rows(), cols());\n      evalToLazy(res);\n      return res;\n    }\n\n  protected:\n\n    void check_coordinates(Index row, Index col) const\n    {\n      EIGEN_ONLY_USED_FOR_DEBUG(row);\n      EIGEN_ONLY_USED_FOR_DEBUG(col);\n      eigen_assert(col>=0 && col<cols() && row>=0 && row<rows());\n      const int mode = int(Mode) & ~SelfAdjoint;\n      EIGEN_ONLY_USED_FOR_DEBUG(mode);\n      eigen_assert((mode==Upper && col>=row)\n                || (mode==Lower && col<=row)\n                || ((mode==StrictlyUpper || mode==UnitUpper) && col>row)\n                || ((mode==StrictlyLower || mode==UnitLower) && col<row));\n    }\n\n    #ifdef EIGEN_INTERNAL_DEBUGGING\n    void check_coordinates_internal(Index row, Index col) const\n    {\n      check_coordinates(row, col);\n    }\n    #else\n    void check_coordinates_internal(Index , Index ) const {}\n    #endif\n\n};\n\n/** \\class TriangularView\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of a triangular part in a matrix\n  *\n  * \\param MatrixType the type of the object in which we are taking the triangular part\n  * \\param Mode the kind of triangular matrix expression to construct. Can be #Upper,\n  *             #Lower, #UnitUpper, #UnitLower, #StrictlyUpper, or #StrictlyLower.\n  *             This is in fact a bit field; it must have either #Upper or #Lower, \n  *             and additionally it may have #UnitDiag or #ZeroDiag or neither.\n  *\n  * This class represents a triangular part of a matrix, not necessarily square. Strictly speaking, for rectangular\n  * matrices one should speak of \"trapezoid\" parts. This class is the return type\n  * of MatrixBase::triangularView() and SparseMatrixBase::triangularView(), and most of the time this is the only way it is used.\n  *\n  * \\sa MatrixBase::triangularView()\n  */\nnamespace internal {\ntemplate<typename MatrixType, unsigned int _Mode>\nstruct traits<TriangularView<MatrixType, _Mode> > : traits<MatrixType>\n{\n  typedef typename ref_selector<MatrixType>::non_const_type MatrixTypeNested;\n  typedef typename remove_reference<MatrixTypeNested>::type MatrixTypeNestedNonRef;\n  typedef typename remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;\n  typedef typename MatrixType::PlainObject FullMatrixType;\n  typedef MatrixType ExpressionType;\n  enum {\n    Mode = _Mode,\n    FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,\n    Flags = (MatrixTypeNestedCleaned::Flags & (HereditaryBits | FlagsLvalueBit) & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit)))\n  };\n};\n}\n\ntemplate<typename _MatrixType, unsigned int _Mode, typename StorageKind> class TriangularViewImpl;\n\ntemplate<typename _MatrixType, unsigned int _Mode> class TriangularView\n  : public TriangularViewImpl<_MatrixType, _Mode, typename internal::traits<_MatrixType>::StorageKind >\n{\n  public:\n\n    typedef TriangularViewImpl<_MatrixType, _Mode, typename internal::traits<_MatrixType>::StorageKind > Base;\n    typedef typename internal::traits<TriangularView>::Scalar Scalar;\n    typedef _MatrixType MatrixType;\n\n  protected:\n    typedef typename internal::traits<TriangularView>::MatrixTypeNested MatrixTypeNested;\n    typedef typename internal::traits<TriangularView>::MatrixTypeNestedNonRef MatrixTypeNestedNonRef;\n\n    typedef typename internal::remove_all<typename MatrixType::ConjugateReturnType>::type MatrixConjugateReturnType;\n    \n  public:\n\n    typedef typename internal::traits<TriangularView>::StorageKind StorageKind;\n    typedef typename internal::traits<TriangularView>::MatrixTypeNestedCleaned NestedExpression;\n\n    enum {\n      Mode = _Mode,\n      Flags = internal::traits<TriangularView>::Flags,\n      TransposeMode = (Mode & Upper ? Lower : 0)\n                    | (Mode & Lower ? Upper : 0)\n                    | (Mode & (UnitDiag))\n                    | (Mode & (ZeroDiag)),\n      IsVectorAtCompileTime = false\n    };\n\n    EIGEN_DEVICE_FUNC\n    explicit inline TriangularView(MatrixType& matrix) : m_matrix(matrix)\n    {}\n    \n    using Base::operator=;\n    TriangularView& operator=(const TriangularView &other)\n    { return Base::operator=(other); }\n\n    /** \\copydoc EigenBase::rows() */\n    EIGEN_DEVICE_FUNC\n    inline Index rows() const { return m_matrix.rows(); }\n    /** \\copydoc EigenBase::cols() */\n    EIGEN_DEVICE_FUNC\n    inline Index cols() const { return m_matrix.cols(); }\n\n    /** \\returns a const reference to the nested expression */\n    EIGEN_DEVICE_FUNC\n    const NestedExpression& nestedExpression() const { return m_matrix; }\n\n    /** \\returns a reference to the nested expression */\n    EIGEN_DEVICE_FUNC\n    NestedExpression& nestedExpression() { return m_matrix; }\n    \n    typedef TriangularView<const MatrixConjugateReturnType,Mode> ConjugateReturnType;\n    /** \\sa MatrixBase::conjugate() const */\n    EIGEN_DEVICE_FUNC\n    inline const ConjugateReturnType conjugate() const\n    { return ConjugateReturnType(m_matrix.conjugate()); }\n\n    typedef TriangularView<const typename MatrixType::AdjointReturnType,TransposeMode> AdjointReturnType;\n    /** \\sa MatrixBase::adjoint() const */\n    EIGEN_DEVICE_FUNC\n    inline const AdjointReturnType adjoint() const\n    { return AdjointReturnType(m_matrix.adjoint()); }\n\n    typedef TriangularView<typename MatrixType::TransposeReturnType,TransposeMode> TransposeReturnType;\n     /** \\sa MatrixBase::transpose() */\n    EIGEN_DEVICE_FUNC\n    inline TransposeReturnType transpose()\n    {\n      EIGEN_STATIC_ASSERT_LVALUE(MatrixType)\n      typename MatrixType::TransposeReturnType tmp(m_matrix);\n      return TransposeReturnType(tmp);\n    }\n    \n    typedef TriangularView<const typename MatrixType::ConstTransposeReturnType,TransposeMode> ConstTransposeReturnType;\n    /** \\sa MatrixBase::transpose() const */\n    EIGEN_DEVICE_FUNC\n    inline const ConstTransposeReturnType transpose() const\n    {\n      return ConstTransposeReturnType(m_matrix.transpose());\n    }\n\n    template<typename Other>\n    EIGEN_DEVICE_FUNC\n    inline const Solve<TriangularView, Other> \n    solve(const MatrixBase<Other>& other) const\n    { return Solve<TriangularView, Other>(*this, other.derived()); }\n    \n  // workaround MSVC ICE\n  #if EIGEN_COMP_MSVC\n    template<int Side, typename Other>\n    EIGEN_DEVICE_FUNC\n    inline const internal::triangular_solve_retval<Side,TriangularView, Other>\n    solve(const MatrixBase<Other>& other) const\n    { return Base::template solve<Side>(other); }\n  #else\n    using Base::solve;\n  #endif\n\n    /** \\returns a selfadjoint view of the referenced triangular part which must be either \\c #Upper or \\c #Lower.\n      *\n      * This is a shortcut for \\code this->nestedExpression().selfadjointView<(*this)::Mode>() \\endcode\n      * \\sa MatrixBase::selfadjointView() */\n    EIGEN_DEVICE_FUNC\n    SelfAdjointView<MatrixTypeNestedNonRef,Mode> selfadjointView()\n    {\n      EIGEN_STATIC_ASSERT((Mode&(UnitDiag|ZeroDiag))==0,PROGRAMMING_ERROR);\n      return SelfAdjointView<MatrixTypeNestedNonRef,Mode>(m_matrix);\n    }\n\n    /** This is the const version of selfadjointView() */\n    EIGEN_DEVICE_FUNC\n    const SelfAdjointView<MatrixTypeNestedNonRef,Mode> selfadjointView() const\n    {\n      EIGEN_STATIC_ASSERT((Mode&(UnitDiag|ZeroDiag))==0,PROGRAMMING_ERROR);\n      return SelfAdjointView<MatrixTypeNestedNonRef,Mode>(m_matrix);\n    }\n\n\n    /** \\returns the determinant of the triangular matrix\n      * \\sa MatrixBase::determinant() */\n    EIGEN_DEVICE_FUNC\n    Scalar determinant() const\n    {\n      if (Mode & UnitDiag)\n        return 1;\n      else if (Mode & ZeroDiag)\n        return 0;\n      else\n        return m_matrix.diagonal().prod();\n    }\n      \n  protected:\n\n    MatrixTypeNested m_matrix;\n};\n\n/** \\ingroup Core_Module\n  *\n  * \\brief Base class for a triangular part in a \\b dense matrix\n  *\n  * This class is an abstract base class of class TriangularView, and objects of type TriangularViewImpl cannot be instantiated.\n  * It extends class TriangularView with additional methods which available for dense expressions only.\n  *\n  * \\sa class TriangularView, MatrixBase::triangularView()\n  */\ntemplate<typename _MatrixType, unsigned int _Mode> class TriangularViewImpl<_MatrixType,_Mode,Dense>\n  : public TriangularBase<TriangularView<_MatrixType, _Mode> >\n{\n  public:\n\n    typedef TriangularView<_MatrixType, _Mode> TriangularViewType;\n    typedef TriangularBase<TriangularViewType> Base;\n    typedef typename internal::traits<TriangularViewType>::Scalar Scalar;\n\n    typedef _MatrixType MatrixType;\n    typedef typename MatrixType::PlainObject DenseMatrixType;\n    typedef DenseMatrixType PlainObject;\n\n  public:\n    using Base::evalToLazy;\n    using Base::derived;\n\n    typedef typename internal::traits<TriangularViewType>::StorageKind StorageKind;\n\n    enum {\n      Mode = _Mode,\n      Flags = internal::traits<TriangularViewType>::Flags\n    };\n\n    /** \\returns the outer-stride of the underlying dense matrix\n      * \\sa DenseCoeffsBase::outerStride() */\n    EIGEN_DEVICE_FUNC\n    inline Index outerStride() const { return derived().nestedExpression().outerStride(); }\n    /** \\returns the inner-stride of the underlying dense matrix\n      * \\sa DenseCoeffsBase::innerStride() */\n    EIGEN_DEVICE_FUNC\n    inline Index innerStride() const { return derived().nestedExpression().innerStride(); }\n\n    /** \\sa MatrixBase::operator+=() */\n    template<typename Other>\n    EIGEN_DEVICE_FUNC\n    TriangularViewType&  operator+=(const DenseBase<Other>& other) {\n      internal::call_assignment_no_alias(derived(), other.derived(), internal::add_assign_op<Scalar,typename Other::Scalar>());\n      return derived();\n    }\n    /** \\sa MatrixBase::operator-=() */\n    template<typename Other>\n    EIGEN_DEVICE_FUNC\n    TriangularViewType&  operator-=(const DenseBase<Other>& other) {\n      internal::call_assignment_no_alias(derived(), other.derived(), internal::sub_assign_op<Scalar,typename Other::Scalar>());\n      return derived();\n    }\n    \n    /** \\sa MatrixBase::operator*=() */\n    EIGEN_DEVICE_FUNC\n    TriangularViewType&  operator*=(const typename internal::traits<MatrixType>::Scalar& other) { return *this = derived().nestedExpression() * other; }\n    /** \\sa DenseBase::operator/=() */\n    EIGEN_DEVICE_FUNC\n    TriangularViewType&  operator/=(const typename internal::traits<MatrixType>::Scalar& other) { return *this = derived().nestedExpression() / other; }\n\n    /** \\sa MatrixBase::fill() */\n    EIGEN_DEVICE_FUNC\n    void fill(const Scalar& value) { setConstant(value); }\n    /** \\sa MatrixBase::setConstant() */\n    EIGEN_DEVICE_FUNC\n    TriangularViewType& setConstant(const Scalar& value)\n    { return *this = MatrixType::Constant(derived().rows(), derived().cols(), value); }\n    /** \\sa MatrixBase::setZero() */\n    EIGEN_DEVICE_FUNC\n    TriangularViewType& setZero() { return setConstant(Scalar(0)); }\n    /** \\sa MatrixBase::setOnes() */\n    EIGEN_DEVICE_FUNC\n    TriangularViewType& setOnes() { return setConstant(Scalar(1)); }\n\n    /** \\sa MatrixBase::coeff()\n      * \\warning the coordinates must fit into the referenced triangular part\n      */\n    EIGEN_DEVICE_FUNC\n    inline Scalar coeff(Index row, Index col) const\n    {\n      Base::check_coordinates_internal(row, col);\n      return derived().nestedExpression().coeff(row, col);\n    }\n\n    /** \\sa MatrixBase::coeffRef()\n      * \\warning the coordinates must fit into the referenced triangular part\n      */\n    EIGEN_DEVICE_FUNC\n    inline Scalar& coeffRef(Index row, Index col)\n    {\n      EIGEN_STATIC_ASSERT_LVALUE(TriangularViewType);\n      Base::check_coordinates_internal(row, col);\n      return derived().nestedExpression().coeffRef(row, col);\n    }\n\n    /** Assigns a triangular matrix to a triangular part of a dense matrix */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    TriangularViewType& operator=(const TriangularBase<OtherDerived>& other);\n\n    /** Shortcut for\\code *this = other.other.triangularView<(*this)::Mode>() \\endcode */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    TriangularViewType& operator=(const MatrixBase<OtherDerived>& other);\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    EIGEN_DEVICE_FUNC\n    TriangularViewType& operator=(const TriangularViewImpl& other)\n    { return *this = other.derived().nestedExpression(); }\n\n    /** \\deprecated */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    void lazyAssign(const TriangularBase<OtherDerived>& other);\n\n    /** \\deprecated */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    void lazyAssign(const MatrixBase<OtherDerived>& other);\n#endif\n\n    /** Efficient triangular matrix times vector/matrix product */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    const Product<TriangularViewType,OtherDerived>\n    operator*(const MatrixBase<OtherDerived>& rhs) const\n    {\n      return Product<TriangularViewType,OtherDerived>(derived(), rhs.derived());\n    }\n\n    /** Efficient vector/matrix times triangular matrix product */\n    template<typename OtherDerived> friend\n    EIGEN_DEVICE_FUNC\n    const Product<OtherDerived,TriangularViewType>\n    operator*(const MatrixBase<OtherDerived>& lhs, const TriangularViewImpl& rhs)\n    {\n      return Product<OtherDerived,TriangularViewType>(lhs.derived(),rhs.derived());\n    }\n\n    /** \\returns the product of the inverse of \\c *this with \\a other, \\a *this being triangular.\n      *\n      * This function computes the inverse-matrix matrix product inverse(\\c *this) * \\a other if\n      * \\a Side==OnTheLeft (the default), or the right-inverse-multiply  \\a other * inverse(\\c *this) if\n      * \\a Side==OnTheRight.\n      *\n      * Note that the template parameter \\c Side can be ommitted, in which case \\c Side==OnTheLeft\n      *\n      * The matrix \\c *this must be triangular and invertible (i.e., all the coefficients of the\n      * diagonal must be non zero). It works as a forward (resp. backward) substitution if \\c *this\n      * is an upper (resp. lower) triangular matrix.\n      *\n      * Example: \\include Triangular_solve.cpp\n      * Output: \\verbinclude Triangular_solve.out\n      *\n      * This function returns an expression of the inverse-multiply and can works in-place if it is assigned\n      * to the same matrix or vector \\a other.\n      *\n      * For users coming from BLAS, this function (and more specifically solveInPlace()) offer\n      * all the operations supported by the \\c *TRSV and \\c *TRSM BLAS routines.\n      *\n      * \\sa TriangularView::solveInPlace()\n      */\n    template<int Side, typename Other>\n    EIGEN_DEVICE_FUNC\n    inline const internal::triangular_solve_retval<Side,TriangularViewType, Other>\n    solve(const MatrixBase<Other>& other) const;\n\n    /** \"in-place\" version of TriangularView::solve() where the result is written in \\a other\n      *\n      * \\warning The parameter is only marked 'const' to make the C++ compiler accept a temporary expression here.\n      * This function will const_cast it, so constness isn't honored here.\n      *\n      * Note that the template parameter \\c Side can be ommitted, in which case \\c Side==OnTheLeft\n      *\n      * See TriangularView:solve() for the details.\n      */\n    template<int Side, typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    void solveInPlace(const MatrixBase<OtherDerived>& other) const;\n\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    void solveInPlace(const MatrixBase<OtherDerived>& other) const\n    { return solveInPlace<OnTheLeft>(other); }\n\n    /** Swaps the coefficients of the common triangular parts of two matrices */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n#ifdef EIGEN_PARSED_BY_DOXYGEN\n    void swap(TriangularBase<OtherDerived> &other)\n#else\n    void swap(TriangularBase<OtherDerived> const & other)\n#endif\n    {\n      EIGEN_STATIC_ASSERT_LVALUE(OtherDerived);\n      call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());\n    }\n\n    /** \\deprecated\n      * Shortcut for \\code (*this).swap(other.triangularView<(*this)::Mode>()) \\endcode */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    void swap(MatrixBase<OtherDerived> const & other)\n    {\n      EIGEN_STATIC_ASSERT_LVALUE(OtherDerived);\n      call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());\n    }\n\n    template<typename RhsType, typename DstType>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _solve_impl(const RhsType &rhs, DstType &dst) const {\n      if(!internal::is_same_dense(dst,rhs))\n        dst = rhs;\n      this->solveInPlace(dst);\n    }\n\n    template<typename ProductType>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE TriangularViewType& _assignProduct(const ProductType& prod, const Scalar& alpha, bool beta);\n};\n\n/***************************************************************************\n* Implementation of triangular evaluation/assignment\n***************************************************************************/\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n// FIXME should we keep that possibility\ntemplate<typename MatrixType, unsigned int Mode>\ntemplate<typename OtherDerived>\ninline TriangularView<MatrixType, Mode>&\nTriangularViewImpl<MatrixType, Mode, Dense>::operator=(const MatrixBase<OtherDerived>& other)\n{\n  internal::call_assignment_no_alias(derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\n// FIXME should we keep that possibility\ntemplate<typename MatrixType, unsigned int Mode>\ntemplate<typename OtherDerived>\nvoid TriangularViewImpl<MatrixType, Mode, Dense>::lazyAssign(const MatrixBase<OtherDerived>& other)\n{\n  internal::call_assignment_no_alias(derived(), other.template triangularView<Mode>());\n}\n\n\n\ntemplate<typename MatrixType, unsigned int Mode>\ntemplate<typename OtherDerived>\ninline TriangularView<MatrixType, Mode>&\nTriangularViewImpl<MatrixType, Mode, Dense>::operator=(const TriangularBase<OtherDerived>& other)\n{\n  eigen_assert(Mode == int(OtherDerived::Mode));\n  internal::call_assignment(derived(), other.derived());\n  return derived();\n}\n\ntemplate<typename MatrixType, unsigned int Mode>\ntemplate<typename OtherDerived>\nvoid TriangularViewImpl<MatrixType, Mode, Dense>::lazyAssign(const TriangularBase<OtherDerived>& other)\n{\n  eigen_assert(Mode == int(OtherDerived::Mode));\n  internal::call_assignment_no_alias(derived(), other.derived());\n}\n#endif\n\n/***************************************************************************\n* Implementation of TriangularBase methods\n***************************************************************************/\n\n/** Assigns a triangular or selfadjoint matrix to a dense matrix.\n  * If the matrix is triangular, the opposite part is set to zero. */\ntemplate<typename Derived>\ntemplate<typename DenseDerived>\nvoid TriangularBase<Derived>::evalTo(MatrixBase<DenseDerived> &other) const\n{\n  evalToLazy(other.derived());\n}\n\n/***************************************************************************\n* Implementation of TriangularView methods\n***************************************************************************/\n\n/***************************************************************************\n* Implementation of MatrixBase methods\n***************************************************************************/\n\n/**\n  * \\returns an expression of a triangular view extracted from the current matrix\n  *\n  * The parameter \\a Mode can have the following values: \\c #Upper, \\c #StrictlyUpper, \\c #UnitUpper,\n  * \\c #Lower, \\c #StrictlyLower, \\c #UnitLower.\n  *\n  * Example: \\include MatrixBase_triangularView.cpp\n  * Output: \\verbinclude MatrixBase_triangularView.out\n  *\n  * \\sa class TriangularView\n  */\ntemplate<typename Derived>\ntemplate<unsigned int Mode>\ntypename MatrixBase<Derived>::template TriangularViewReturnType<Mode>::Type\nMatrixBase<Derived>::triangularView()\n{\n  return typename TriangularViewReturnType<Mode>::Type(derived());\n}\n\n/** This is the const version of MatrixBase::triangularView() */\ntemplate<typename Derived>\ntemplate<unsigned int Mode>\ntypename MatrixBase<Derived>::template ConstTriangularViewReturnType<Mode>::Type\nMatrixBase<Derived>::triangularView() const\n{\n  return typename ConstTriangularViewReturnType<Mode>::Type(derived());\n}\n\n/** \\returns true if *this is approximately equal to an upper triangular matrix,\n  *          within the precision given by \\a prec.\n  *\n  * \\sa isLowerTriangular()\n  */\ntemplate<typename Derived>\nbool MatrixBase<Derived>::isUpperTriangular(const RealScalar& prec) const\n{\n  RealScalar maxAbsOnUpperPart = static_cast<RealScalar>(-1);\n  for(Index j = 0; j < cols(); ++j)\n  {\n    Index maxi = numext::mini(j, rows()-1);\n    for(Index i = 0; i <= maxi; ++i)\n    {\n      RealScalar absValue = numext::abs(coeff(i,j));\n      if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue;\n    }\n  }\n  RealScalar threshold = maxAbsOnUpperPart * prec;\n  for(Index j = 0; j < cols(); ++j)\n    for(Index i = j+1; i < rows(); ++i)\n      if(numext::abs(coeff(i, j)) > threshold) return false;\n  return true;\n}\n\n/** \\returns true if *this is approximately equal to a lower triangular matrix,\n  *          within the precision given by \\a prec.\n  *\n  * \\sa isUpperTriangular()\n  */\ntemplate<typename Derived>\nbool MatrixBase<Derived>::isLowerTriangular(const RealScalar& prec) const\n{\n  RealScalar maxAbsOnLowerPart = static_cast<RealScalar>(-1);\n  for(Index j = 0; j < cols(); ++j)\n    for(Index i = j; i < rows(); ++i)\n    {\n      RealScalar absValue = numext::abs(coeff(i,j));\n      if(absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue;\n    }\n  RealScalar threshold = maxAbsOnLowerPart * prec;\n  for(Index j = 1; j < cols(); ++j)\n  {\n    Index maxi = numext::mini(j, rows()-1);\n    for(Index i = 0; i < maxi; ++i)\n      if(numext::abs(coeff(i, j)) > threshold) return false;\n  }\n  return true;\n}\n\n\n/***************************************************************************\n****************************************************************************\n* Evaluators and Assignment of triangular expressions\n***************************************************************************\n***************************************************************************/\n\nnamespace internal {\n\n  \n// TODO currently a triangular expression has the form TriangularView<.,.>\n//      in the future triangular-ness should be defined by the expression traits\n//      such that Transpose<TriangularView<.,.> > is valid. (currently TriangularBase::transpose() is overloaded to make it work)\ntemplate<typename MatrixType, unsigned int Mode>\nstruct evaluator_traits<TriangularView<MatrixType,Mode> >\n{\n  typedef typename storage_kind_to_evaluator_kind<typename MatrixType::StorageKind>::Kind Kind;\n  typedef typename glue_shapes<typename evaluator_traits<MatrixType>::Shape, TriangularShape>::type Shape;\n};\n\ntemplate<typename MatrixType, unsigned int Mode>\nstruct unary_evaluator<TriangularView<MatrixType,Mode>, IndexBased>\n : evaluator<typename internal::remove_all<MatrixType>::type>\n{\n  typedef TriangularView<MatrixType,Mode> XprType;\n  typedef evaluator<typename internal::remove_all<MatrixType>::type> Base;\n  unary_evaluator(const XprType &xpr) : Base(xpr.nestedExpression()) {}\n};\n\n// Additional assignment kinds:\nstruct Triangular2Triangular    {};\nstruct Triangular2Dense         {};\nstruct Dense2Triangular         {};\n\n\ntemplate<typename Kernel, unsigned int Mode, int UnrollCount, bool ClearOpposite> struct triangular_assignment_loop;\n\n \n/** \\internal Specialization of the dense assignment kernel for triangular matrices.\n  * The main difference is that the triangular, diagonal, and opposite parts are processed through three different functions.\n  * \\tparam UpLo must be either Lower or Upper\n  * \\tparam Mode must be either 0, UnitDiag, ZeroDiag, or SelfAdjoint\n  */\ntemplate<int UpLo, int Mode, int SetOpposite, typename DstEvaluatorTypeT, typename SrcEvaluatorTypeT, typename Functor, int Version = Specialized>\nclass triangular_dense_assignment_kernel : public generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version>\n{\nprotected:\n  typedef generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version> Base;\n  typedef typename Base::DstXprType DstXprType;\n  typedef typename Base::SrcXprType SrcXprType;\n  using Base::m_dst;\n  using Base::m_src;\n  using Base::m_functor;\npublic:\n  \n  typedef typename Base::DstEvaluatorType DstEvaluatorType;\n  typedef typename Base::SrcEvaluatorType SrcEvaluatorType;\n  typedef typename Base::Scalar Scalar;\n  typedef typename Base::AssignmentTraits AssignmentTraits;\n  \n  \n  EIGEN_DEVICE_FUNC triangular_dense_assignment_kernel(DstEvaluatorType &dst, const SrcEvaluatorType &src, const Functor &func, DstXprType& dstExpr)\n    : Base(dst, src, func, dstExpr)\n  {}\n  \n#ifdef EIGEN_INTERNAL_DEBUGGING\n  EIGEN_DEVICE_FUNC void assignCoeff(Index row, Index col)\n  {\n    eigen_internal_assert(row!=col);\n    Base::assignCoeff(row,col);\n  }\n#else\n  using Base::assignCoeff;\n#endif\n  \n  EIGEN_DEVICE_FUNC void assignDiagonalCoeff(Index id)\n  {\n         if(Mode==UnitDiag && SetOpposite) m_functor.assignCoeff(m_dst.coeffRef(id,id), Scalar(1));\n    else if(Mode==ZeroDiag && SetOpposite) m_functor.assignCoeff(m_dst.coeffRef(id,id), Scalar(0));\n    else if(Mode==0)                       Base::assignCoeff(id,id);\n  }\n  \n  EIGEN_DEVICE_FUNC void assignOppositeCoeff(Index row, Index col)\n  { \n    eigen_internal_assert(row!=col);\n    if(SetOpposite)\n      m_functor.assignCoeff(m_dst.coeffRef(row,col), Scalar(0));\n  }\n};\n\ntemplate<int Mode, bool SetOpposite, typename DstXprType, typename SrcXprType, typename Functor>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid call_triangular_assignment_loop(DstXprType& dst, const SrcXprType& src, const Functor &func)\n{\n  typedef evaluator<DstXprType> DstEvaluatorType;\n  typedef evaluator<SrcXprType> SrcEvaluatorType;\n\n  SrcEvaluatorType srcEvaluator(src);\n\n  Index dstRows = src.rows();\n  Index dstCols = src.cols();\n  if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n    dst.resize(dstRows, dstCols);\n  DstEvaluatorType dstEvaluator(dst);\n    \n  typedef triangular_dense_assignment_kernel< Mode&(Lower|Upper),Mode&(UnitDiag|ZeroDiag|SelfAdjoint),SetOpposite,\n                                              DstEvaluatorType,SrcEvaluatorType,Functor> Kernel;\n  Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived());\n  \n  enum {\n      unroll = DstXprType::SizeAtCompileTime != Dynamic\n            && SrcEvaluatorType::CoeffReadCost < HugeCost\n            && DstXprType::SizeAtCompileTime * (DstEvaluatorType::CoeffReadCost+SrcEvaluatorType::CoeffReadCost) / 2 <= EIGEN_UNROLLING_LIMIT\n    };\n  \n  triangular_assignment_loop<Kernel, Mode, unroll ? int(DstXprType::SizeAtCompileTime) : Dynamic, SetOpposite>::run(kernel);\n}\n\ntemplate<int Mode, bool SetOpposite, typename DstXprType, typename SrcXprType>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nvoid call_triangular_assignment_loop(DstXprType& dst, const SrcXprType& src)\n{\n  call_triangular_assignment_loop<Mode,SetOpposite>(dst, src, internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar>());\n}\n\ntemplate<> struct AssignmentKind<TriangularShape,TriangularShape> { typedef Triangular2Triangular Kind; };\ntemplate<> struct AssignmentKind<DenseShape,TriangularShape>      { typedef Triangular2Dense      Kind; };\ntemplate<> struct AssignmentKind<TriangularShape,DenseShape>      { typedef Dense2Triangular      Kind; };\n\n\ntemplate< typename DstXprType, typename SrcXprType, typename Functor>\nstruct Assignment<DstXprType, SrcXprType, Functor, Triangular2Triangular>\n{\n  EIGEN_DEVICE_FUNC static void run(DstXprType &dst, const SrcXprType &src, const Functor &func)\n  {\n    eigen_assert(int(DstXprType::Mode) == int(SrcXprType::Mode));\n    \n    call_triangular_assignment_loop<DstXprType::Mode, false>(dst, src, func);  \n  }\n};\n\ntemplate< typename DstXprType, typename SrcXprType, typename Functor>\nstruct Assignment<DstXprType, SrcXprType, Functor, Triangular2Dense>\n{\n  EIGEN_DEVICE_FUNC static void run(DstXprType &dst, const SrcXprType &src, const Functor &func)\n  {\n    call_triangular_assignment_loop<SrcXprType::Mode, (SrcXprType::Mode&SelfAdjoint)==0>(dst, src, func);  \n  }\n};\n\ntemplate< typename DstXprType, typename SrcXprType, typename Functor>\nstruct Assignment<DstXprType, SrcXprType, Functor, Dense2Triangular>\n{\n  EIGEN_DEVICE_FUNC static void run(DstXprType &dst, const SrcXprType &src, const Functor &func)\n  {\n    call_triangular_assignment_loop<DstXprType::Mode, false>(dst, src, func);  \n  }\n};\n\n\ntemplate<typename Kernel, unsigned int Mode, int UnrollCount, bool SetOpposite>\nstruct triangular_assignment_loop\n{\n  // FIXME: this is not very clean, perhaps this information should be provided by the kernel?\n  typedef typename Kernel::DstEvaluatorType DstEvaluatorType;\n  typedef typename DstEvaluatorType::XprType DstXprType;\n  \n  enum {\n    col = (UnrollCount-1) / DstXprType::RowsAtCompileTime,\n    row = (UnrollCount-1) % DstXprType::RowsAtCompileTime\n  };\n  \n  typedef typename Kernel::Scalar Scalar;\n\n  EIGEN_DEVICE_FUNC\n  static inline void run(Kernel &kernel)\n  {\n    triangular_assignment_loop<Kernel, Mode, UnrollCount-1, SetOpposite>::run(kernel);\n    \n    if(row==col)\n      kernel.assignDiagonalCoeff(row);\n    else if( ((Mode&Lower) && row>col) || ((Mode&Upper) && row<col) )\n      kernel.assignCoeff(row,col);\n    else if(SetOpposite)\n      kernel.assignOppositeCoeff(row,col);\n  }\n};\n\n// prevent buggy user code from causing an infinite recursion\ntemplate<typename Kernel, unsigned int Mode, bool SetOpposite>\nstruct triangular_assignment_loop<Kernel, Mode, 0, SetOpposite>\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(Kernel &) {}\n};\n\n\n\n// TODO: experiment with a recursive assignment procedure splitting the current\n//       triangular part into one rectangular and two triangular parts.\n\n\ntemplate<typename Kernel, unsigned int Mode, bool SetOpposite>\nstruct triangular_assignment_loop<Kernel, Mode, Dynamic, SetOpposite>\n{\n  typedef typename Kernel::Scalar Scalar;\n  EIGEN_DEVICE_FUNC\n  static inline void run(Kernel &kernel)\n  {\n    for(Index j = 0; j < kernel.cols(); ++j)\n    {\n      Index maxi = numext::mini(j, kernel.rows());\n      Index i = 0;\n      if (((Mode&Lower) && SetOpposite) || (Mode&Upper))\n      {\n        for(; i < maxi; ++i)\n          if(Mode&Upper) kernel.assignCoeff(i, j);\n          else           kernel.assignOppositeCoeff(i, j);\n      }\n      else\n        i = maxi;\n      \n      if(i<kernel.rows()) // then i==j\n        kernel.assignDiagonalCoeff(i++);\n      \n      if (((Mode&Upper) && SetOpposite) || (Mode&Lower))\n      {\n        for(; i < kernel.rows(); ++i)\n          if(Mode&Lower) kernel.assignCoeff(i, j);\n          else           kernel.assignOppositeCoeff(i, j);\n      }\n    }\n  }\n};\n\n} // end namespace internal\n\n/** Assigns a triangular or selfadjoint matrix to a dense matrix.\n  * If the matrix is triangular, the opposite part is set to zero. */\ntemplate<typename Derived>\ntemplate<typename DenseDerived>\nvoid TriangularBase<Derived>::evalToLazy(MatrixBase<DenseDerived> &other) const\n{\n  other.derived().resize(this->rows(), this->cols());\n  internal::call_triangular_assignment_loop<Derived::Mode,(Derived::Mode&SelfAdjoint)==0 /* SetOpposite */>(other.derived(), derived().nestedExpression());\n}\n\nnamespace internal {\n  \n// Triangular = Product\ntemplate< typename DstXprType, typename Lhs, typename Rhs, typename Scalar>\nstruct Assignment<DstXprType, Product<Lhs,Rhs,DefaultProduct>, internal::assign_op<Scalar,typename Product<Lhs,Rhs,DefaultProduct>::Scalar>, Dense2Triangular>\n{\n  typedef Product<Lhs,Rhs,DefaultProduct> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,typename SrcXprType::Scalar> &)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n\n    dst._assignProduct(src, 1, 0);\n  }\n};\n\n// Triangular += Product\ntemplate< typename DstXprType, typename Lhs, typename Rhs, typename Scalar>\nstruct Assignment<DstXprType, Product<Lhs,Rhs,DefaultProduct>, internal::add_assign_op<Scalar,typename Product<Lhs,Rhs,DefaultProduct>::Scalar>, Dense2Triangular>\n{\n  typedef Product<Lhs,Rhs,DefaultProduct> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op<Scalar,typename SrcXprType::Scalar> &)\n  {\n    dst._assignProduct(src, 1, 1);\n  }\n};\n\n// Triangular -= Product\ntemplate< typename DstXprType, typename Lhs, typename Rhs, typename Scalar>\nstruct Assignment<DstXprType, Product<Lhs,Rhs,DefaultProduct>, internal::sub_assign_op<Scalar,typename Product<Lhs,Rhs,DefaultProduct>::Scalar>, Dense2Triangular>\n{\n  typedef Product<Lhs,Rhs,DefaultProduct> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op<Scalar,typename SrcXprType::Scalar> &)\n  {\n    dst._assignProduct(src, -1, 1);\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRIANGULARMATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/VectorBlock.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_VECTORBLOCK_H\n#define EIGEN_VECTORBLOCK_H\n\nnamespace Eigen { \n\nnamespace internal {\ntemplate<typename VectorType, int Size>\nstruct traits<VectorBlock<VectorType, Size> >\n  : public traits<Block<VectorType,\n                     traits<VectorType>::Flags & RowMajorBit ? 1 : Size,\n                     traits<VectorType>::Flags & RowMajorBit ? Size : 1> >\n{\n};\n}\n\n/** \\class VectorBlock\n  * \\ingroup Core_Module\n  *\n  * \\brief Expression of a fixed-size or dynamic-size sub-vector\n  *\n  * \\tparam VectorType the type of the object in which we are taking a sub-vector\n  * \\tparam Size size of the sub-vector we are taking at compile time (optional)\n  *\n  * This class represents an expression of either a fixed-size or dynamic-size sub-vector.\n  * It is the return type of DenseBase::segment(Index,Index) and DenseBase::segment<int>(Index) and\n  * most of the time this is the only way it is used.\n  *\n  * However, if you want to directly maniputate sub-vector expressions,\n  * for instance if you want to write a function returning such an expression, you\n  * will need to use this class.\n  *\n  * Here is an example illustrating the dynamic case:\n  * \\include class_VectorBlock.cpp\n  * Output: \\verbinclude class_VectorBlock.out\n  *\n  * \\note Even though this expression has dynamic size, in the case where \\a VectorType\n  * has fixed size, this expression inherits a fixed maximal size which means that evaluating\n  * it does not cause a dynamic memory allocation.\n  *\n  * Here is an example illustrating the fixed-size case:\n  * \\include class_FixedVectorBlock.cpp\n  * Output: \\verbinclude class_FixedVectorBlock.out\n  *\n  * \\sa class Block, DenseBase::segment(Index,Index,Index,Index), DenseBase::segment(Index,Index)\n  */\ntemplate<typename VectorType, int Size> class VectorBlock\n  : public Block<VectorType,\n                     internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,\n                     internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1>\n{\n    typedef Block<VectorType,\n                     internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,\n                     internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1> Base;\n    enum {\n      IsColVector = !(internal::traits<VectorType>::Flags & RowMajorBit)\n    };\n  public:\n    EIGEN_DENSE_PUBLIC_INTERFACE(VectorBlock)\n\n    using Base::operator=;\n\n    /** Dynamic-size constructor\n      */\n    EIGEN_DEVICE_FUNC\n    inline VectorBlock(VectorType& vector, Index start, Index size)\n      : Base(vector,\n             IsColVector ? start : 0, IsColVector ? 0 : start,\n             IsColVector ? size  : 1, IsColVector ? 1 : size)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);\n    }\n\n    /** Fixed-size constructor\n      */\n    EIGEN_DEVICE_FUNC\n    inline VectorBlock(VectorType& vector, Index start)\n      : Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);\n    }\n};\n\n\n} // end namespace Eigen\n\n#endif // EIGEN_VECTORBLOCK_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/VectorwiseOp.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PARTIAL_REDUX_H\n#define EIGEN_PARTIAL_REDUX_H\n\nnamespace Eigen {\n\n/** \\class PartialReduxExpr\n  * \\ingroup Core_Module\n  *\n  * \\brief Generic expression of a partially reduxed matrix\n  *\n  * \\tparam MatrixType the type of the matrix we are applying the redux operation\n  * \\tparam MemberOp type of the member functor\n  * \\tparam Direction indicates the direction of the redux (#Vertical or #Horizontal)\n  *\n  * This class represents an expression of a partial redux operator of a matrix.\n  * It is the return type of some VectorwiseOp functions,\n  * and most of the time this is the only way it is used.\n  *\n  * \\sa class VectorwiseOp\n  */\n\ntemplate< typename MatrixType, typename MemberOp, int Direction>\nclass PartialReduxExpr;\n\nnamespace internal {\ntemplate<typename MatrixType, typename MemberOp, int Direction>\nstruct traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >\n : traits<MatrixType>\n{\n  typedef typename MemberOp::result_type Scalar;\n  typedef typename traits<MatrixType>::StorageKind StorageKind;\n  typedef typename traits<MatrixType>::XprKind XprKind;\n  typedef typename MatrixType::Scalar InputScalar;\n  enum {\n    RowsAtCompileTime = Direction==Vertical   ? 1 : MatrixType::RowsAtCompileTime,\n    ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime,\n    MaxRowsAtCompileTime = Direction==Vertical   ? 1 : MatrixType::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime,\n    Flags = RowsAtCompileTime == 1 ? RowMajorBit : 0,\n    TraversalSize = Direction==Vertical ? MatrixType::RowsAtCompileTime :  MatrixType::ColsAtCompileTime\n  };\n};\n}\n\ntemplate< typename MatrixType, typename MemberOp, int Direction>\nclass PartialReduxExpr : public internal::dense_xpr_base< PartialReduxExpr<MatrixType, MemberOp, Direction> >::type,\n                         internal::no_assignment_operator\n{\n  public:\n\n    typedef typename internal::dense_xpr_base<PartialReduxExpr>::type Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(PartialReduxExpr)\n\n    EIGEN_DEVICE_FUNC\n    explicit PartialReduxExpr(const MatrixType& mat, const MemberOp& func = MemberOp())\n      : m_matrix(mat), m_functor(func) {}\n\n    EIGEN_DEVICE_FUNC\n    Index rows() const { return (Direction==Vertical   ? 1 : m_matrix.rows()); }\n    EIGEN_DEVICE_FUNC\n    Index cols() const { return (Direction==Horizontal ? 1 : m_matrix.cols()); }\n\n    EIGEN_DEVICE_FUNC\n    typename MatrixType::Nested nestedExpression() const { return m_matrix; }\n\n    EIGEN_DEVICE_FUNC\n    const MemberOp& functor() const { return m_functor; }\n\n  protected:\n    typename MatrixType::Nested m_matrix;\n    const MemberOp m_functor;\n};\n\n#define EIGEN_MEMBER_FUNCTOR(MEMBER,COST)                               \\\n  template <typename ResultType>                                        \\\n  struct member_##MEMBER {                                              \\\n    EIGEN_EMPTY_STRUCT_CTOR(member_##MEMBER)                            \\\n    typedef ResultType result_type;                                     \\\n    template<typename Scalar, int Size> struct Cost                     \\\n    { enum { value = COST }; };                                         \\\n    template<typename XprType>                                          \\\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE                               \\\n    ResultType operator()(const XprType& mat) const                     \\\n    { return mat.MEMBER(); } \\\n  }\n\nnamespace internal {\n\nEIGEN_MEMBER_FUNCTOR(squaredNorm, Size * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);\nEIGEN_MEMBER_FUNCTOR(norm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);\nEIGEN_MEMBER_FUNCTOR(stableNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);\nEIGEN_MEMBER_FUNCTOR(blueNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);\nEIGEN_MEMBER_FUNCTOR(hypotNorm, (Size-1) * functor_traits<scalar_hypot_op<Scalar> >::Cost );\nEIGEN_MEMBER_FUNCTOR(sum, (Size-1)*NumTraits<Scalar>::AddCost);\nEIGEN_MEMBER_FUNCTOR(mean, (Size-1)*NumTraits<Scalar>::AddCost + NumTraits<Scalar>::MulCost);\nEIGEN_MEMBER_FUNCTOR(minCoeff, (Size-1)*NumTraits<Scalar>::AddCost);\nEIGEN_MEMBER_FUNCTOR(maxCoeff, (Size-1)*NumTraits<Scalar>::AddCost);\nEIGEN_MEMBER_FUNCTOR(all, (Size-1)*NumTraits<Scalar>::AddCost);\nEIGEN_MEMBER_FUNCTOR(any, (Size-1)*NumTraits<Scalar>::AddCost);\nEIGEN_MEMBER_FUNCTOR(count, (Size-1)*NumTraits<Scalar>::AddCost);\nEIGEN_MEMBER_FUNCTOR(prod, (Size-1)*NumTraits<Scalar>::MulCost);\n\ntemplate <int p, typename ResultType>\nstruct member_lpnorm {\n  typedef ResultType result_type;\n  template<typename Scalar, int Size> struct Cost\n  { enum { value = (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost }; };\n  EIGEN_DEVICE_FUNC member_lpnorm() {}\n  template<typename XprType>\n  EIGEN_DEVICE_FUNC inline ResultType operator()(const XprType& mat) const\n  { return mat.template lpNorm<p>(); }\n};\n\ntemplate <typename BinaryOp, typename Scalar>\nstruct member_redux {\n  typedef typename result_of<\n                     BinaryOp(const Scalar&,const Scalar&)\n                   >::type  result_type;\n  template<typename _Scalar, int Size> struct Cost\n  { enum { value = (Size-1) * functor_traits<BinaryOp>::Cost }; };\n  EIGEN_DEVICE_FUNC explicit member_redux(const BinaryOp func) : m_functor(func) {}\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline result_type operator()(const DenseBase<Derived>& mat) const\n  { return mat.redux(m_functor); }\n  const BinaryOp m_functor;\n};\n}\n\n/** \\class VectorwiseOp\n  * \\ingroup Core_Module\n  *\n  * \\brief Pseudo expression providing partial reduction operations\n  *\n  * \\tparam ExpressionType the type of the object on which to do partial reductions\n  * \\tparam Direction indicates the direction of the redux (#Vertical or #Horizontal)\n  *\n  * This class represents a pseudo expression with partial reduction features.\n  * It is the return type of DenseBase::colwise() and DenseBase::rowwise()\n  * and most of the time this is the only way it is used.\n  *\n  * Example: \\include MatrixBase_colwise.cpp\n  * Output: \\verbinclude MatrixBase_colwise.out\n  *\n  * \\sa DenseBase::colwise(), DenseBase::rowwise(), class PartialReduxExpr\n  */\ntemplate<typename ExpressionType, int Direction> class VectorwiseOp\n{\n  public:\n\n    typedef typename ExpressionType::Scalar Scalar;\n    typedef typename ExpressionType::RealScalar RealScalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n    typedef typename internal::ref_selector<ExpressionType>::non_const_type ExpressionTypeNested;\n    typedef typename internal::remove_all<ExpressionTypeNested>::type ExpressionTypeNestedCleaned;\n\n    template<template<typename _Scalar> class Functor,\n                      typename Scalar_=Scalar> struct ReturnType\n    {\n      typedef PartialReduxExpr<ExpressionType,\n                               Functor<Scalar_>,\n                               Direction\n                              > Type;\n    };\n\n    template<typename BinaryOp> struct ReduxReturnType\n    {\n      typedef PartialReduxExpr<ExpressionType,\n                               internal::member_redux<BinaryOp,Scalar>,\n                               Direction\n                              > Type;\n    };\n\n    enum {\n      isVertical   = (Direction==Vertical) ? 1 : 0,\n      isHorizontal = (Direction==Horizontal) ? 1 : 0\n    };\n\n  protected:\n\n    typedef typename internal::conditional<isVertical,\n                               typename ExpressionType::ColXpr,\n                               typename ExpressionType::RowXpr>::type SubVector;\n    /** \\internal\n      * \\returns the i-th subvector according to the \\c Direction */\n    EIGEN_DEVICE_FUNC\n    SubVector subVector(Index i)\n    {\n      return SubVector(m_matrix.derived(),i);\n    }\n\n    /** \\internal\n      * \\returns the number of subvectors in the direction \\c Direction */\n    EIGEN_DEVICE_FUNC\n    Index subVectors() const\n    { return isVertical?m_matrix.cols():m_matrix.rows(); }\n\n    template<typename OtherDerived> struct ExtendedType {\n      typedef Replicate<OtherDerived,\n                        isVertical   ? 1 : ExpressionType::RowsAtCompileTime,\n                        isHorizontal ? 1 : ExpressionType::ColsAtCompileTime> Type;\n    };\n\n    /** \\internal\n      * Replicates a vector to match the size of \\c *this */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    typename ExtendedType<OtherDerived>::Type\n    extendedTo(const DenseBase<OtherDerived>& other) const\n    {\n      EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(isVertical, OtherDerived::MaxColsAtCompileTime==1),\n                          YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)\n      EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(isHorizontal, OtherDerived::MaxRowsAtCompileTime==1),\n                          YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)\n      return typename ExtendedType<OtherDerived>::Type\n                      (other.derived(),\n                       isVertical   ? 1 : m_matrix.rows(),\n                       isHorizontal ? 1 : m_matrix.cols());\n    }\n\n    template<typename OtherDerived> struct OppositeExtendedType {\n      typedef Replicate<OtherDerived,\n                        isHorizontal ? 1 : ExpressionType::RowsAtCompileTime,\n                        isVertical   ? 1 : ExpressionType::ColsAtCompileTime> Type;\n    };\n\n    /** \\internal\n      * Replicates a vector in the opposite direction to match the size of \\c *this */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    typename OppositeExtendedType<OtherDerived>::Type\n    extendedToOpposite(const DenseBase<OtherDerived>& other) const\n    {\n      EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(isHorizontal, OtherDerived::MaxColsAtCompileTime==1),\n                          YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)\n      EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(isVertical, OtherDerived::MaxRowsAtCompileTime==1),\n                          YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)\n      return typename OppositeExtendedType<OtherDerived>::Type\n                      (other.derived(),\n                       isHorizontal  ? 1 : m_matrix.rows(),\n                       isVertical    ? 1 : m_matrix.cols());\n    }\n\n  public:\n    EIGEN_DEVICE_FUNC\n    explicit inline VectorwiseOp(ExpressionType& matrix) : m_matrix(matrix) {}\n\n    /** \\internal */\n    EIGEN_DEVICE_FUNC\n    inline const ExpressionType& _expression() const { return m_matrix; }\n\n    /** \\returns a row or column vector expression of \\c *this reduxed by \\a func\n      *\n      * The template parameter \\a BinaryOp is the type of the functor\n      * of the custom redux operator. Note that func must be an associative operator.\n      *\n      * \\sa class VectorwiseOp, DenseBase::colwise(), DenseBase::rowwise()\n      */\n    template<typename BinaryOp>\n    EIGEN_DEVICE_FUNC\n    const typename ReduxReturnType<BinaryOp>::Type\n    redux(const BinaryOp& func = BinaryOp()) const\n    { return typename ReduxReturnType<BinaryOp>::Type(_expression(), internal::member_redux<BinaryOp,Scalar>(func)); }\n\n    typedef typename ReturnType<internal::member_minCoeff>::Type MinCoeffReturnType;\n    typedef typename ReturnType<internal::member_maxCoeff>::Type MaxCoeffReturnType;\n    typedef typename ReturnType<internal::member_squaredNorm,RealScalar>::Type SquaredNormReturnType;\n    typedef typename ReturnType<internal::member_norm,RealScalar>::Type NormReturnType;\n    typedef typename ReturnType<internal::member_blueNorm,RealScalar>::Type BlueNormReturnType;\n    typedef typename ReturnType<internal::member_stableNorm,RealScalar>::Type StableNormReturnType;\n    typedef typename ReturnType<internal::member_hypotNorm,RealScalar>::Type HypotNormReturnType;\n    typedef typename ReturnType<internal::member_sum>::Type SumReturnType;\n    typedef typename ReturnType<internal::member_mean>::Type MeanReturnType;\n    typedef typename ReturnType<internal::member_all>::Type AllReturnType;\n    typedef typename ReturnType<internal::member_any>::Type AnyReturnType;\n    typedef PartialReduxExpr<ExpressionType, internal::member_count<Index>, Direction> CountReturnType;\n    typedef typename ReturnType<internal::member_prod>::Type ProdReturnType;\n    typedef Reverse<const ExpressionType, Direction> ConstReverseReturnType;\n    typedef Reverse<ExpressionType, Direction> ReverseReturnType;\n\n    template<int p> struct LpNormReturnType {\n      typedef PartialReduxExpr<ExpressionType, internal::member_lpnorm<p,RealScalar>,Direction> Type;\n    };\n\n    /** \\returns a row (or column) vector expression of the smallest coefficient\n      * of each column (or row) of the referenced expression.\n      *\n      * \\warning the result is undefined if \\c *this contains NaN.\n      *\n      * Example: \\include PartialRedux_minCoeff.cpp\n      * Output: \\verbinclude PartialRedux_minCoeff.out\n      *\n      * \\sa DenseBase::minCoeff() */\n    EIGEN_DEVICE_FUNC\n    const MinCoeffReturnType minCoeff() const\n    { return MinCoeffReturnType(_expression()); }\n\n    /** \\returns a row (or column) vector expression of the largest coefficient\n      * of each column (or row) of the referenced expression.\n      *\n      * \\warning the result is undefined if \\c *this contains NaN.\n      *\n      * Example: \\include PartialRedux_maxCoeff.cpp\n      * Output: \\verbinclude PartialRedux_maxCoeff.out\n      *\n      * \\sa DenseBase::maxCoeff() */\n    EIGEN_DEVICE_FUNC\n    const MaxCoeffReturnType maxCoeff() const\n    { return MaxCoeffReturnType(_expression()); }\n\n    /** \\returns a row (or column) vector expression of the squared norm\n      * of each column (or row) of the referenced expression.\n      * This is a vector with real entries, even if the original matrix has complex entries.\n      *\n      * Example: \\include PartialRedux_squaredNorm.cpp\n      * Output: \\verbinclude PartialRedux_squaredNorm.out\n      *\n      * \\sa DenseBase::squaredNorm() */\n    EIGEN_DEVICE_FUNC\n    const SquaredNormReturnType squaredNorm() const\n    { return SquaredNormReturnType(_expression()); }\n\n    /** \\returns a row (or column) vector expression of the norm\n      * of each column (or row) of the referenced expression.\n      * This is a vector with real entries, even if the original matrix has complex entries.\n      *\n      * Example: \\include PartialRedux_norm.cpp\n      * Output: \\verbinclude PartialRedux_norm.out\n      *\n      * \\sa DenseBase::norm() */\n    EIGEN_DEVICE_FUNC\n    const NormReturnType norm() const\n    { return NormReturnType(_expression()); }\n\n    /** \\returns a row (or column) vector expression of the norm\n      * of each column (or row) of the referenced expression.\n      * This is a vector with real entries, even if the original matrix has complex entries.\n      *\n      * Example: \\include PartialRedux_norm.cpp\n      * Output: \\verbinclude PartialRedux_norm.out\n      *\n      * \\sa DenseBase::norm() */\n    template<int p>\n    EIGEN_DEVICE_FUNC\n    const typename LpNormReturnType<p>::Type lpNorm() const\n    { return typename LpNormReturnType<p>::Type(_expression()); }\n\n\n    /** \\returns a row (or column) vector expression of the norm\n      * of each column (or row) of the referenced expression, using\n      * Blue's algorithm.\n      * This is a vector with real entries, even if the original matrix has complex entries.\n      *\n      * \\sa DenseBase::blueNorm() */\n    EIGEN_DEVICE_FUNC\n    const BlueNormReturnType blueNorm() const\n    { return BlueNormReturnType(_expression()); }\n\n\n    /** \\returns a row (or column) vector expression of the norm\n      * of each column (or row) of the referenced expression, avoiding\n      * underflow and overflow.\n      * This is a vector with real entries, even if the original matrix has complex entries.\n      *\n      * \\sa DenseBase::stableNorm() */\n    EIGEN_DEVICE_FUNC\n    const StableNormReturnType stableNorm() const\n    { return StableNormReturnType(_expression()); }\n\n\n    /** \\returns a row (or column) vector expression of the norm\n      * of each column (or row) of the referenced expression, avoiding\n      * underflow and overflow using a concatenation of hypot() calls.\n      * This is a vector with real entries, even if the original matrix has complex entries.\n      *\n      * \\sa DenseBase::hypotNorm() */\n    EIGEN_DEVICE_FUNC\n    const HypotNormReturnType hypotNorm() const\n    { return HypotNormReturnType(_expression()); }\n\n    /** \\returns a row (or column) vector expression of the sum\n      * of each column (or row) of the referenced expression.\n      *\n      * Example: \\include PartialRedux_sum.cpp\n      * Output: \\verbinclude PartialRedux_sum.out\n      *\n      * \\sa DenseBase::sum() */\n    EIGEN_DEVICE_FUNC\n    const SumReturnType sum() const\n    { return SumReturnType(_expression()); }\n\n    /** \\returns a row (or column) vector expression of the mean\n    * of each column (or row) of the referenced expression.\n    *\n    * \\sa DenseBase::mean() */\n    EIGEN_DEVICE_FUNC\n    const MeanReturnType mean() const\n    { return MeanReturnType(_expression()); }\n\n    /** \\returns a row (or column) vector expression representing\n      * whether \\b all coefficients of each respective column (or row) are \\c true.\n      * This expression can be assigned to a vector with entries of type \\c bool.\n      *\n      * \\sa DenseBase::all() */\n    EIGEN_DEVICE_FUNC\n    const AllReturnType all() const\n    { return AllReturnType(_expression()); }\n\n    /** \\returns a row (or column) vector expression representing\n      * whether \\b at \\b least one coefficient of each respective column (or row) is \\c true.\n      * This expression can be assigned to a vector with entries of type \\c bool.\n      *\n      * \\sa DenseBase::any() */\n    EIGEN_DEVICE_FUNC\n    const AnyReturnType any() const\n    { return AnyReturnType(_expression()); }\n\n    /** \\returns a row (or column) vector expression representing\n      * the number of \\c true coefficients of each respective column (or row).\n      * This expression can be assigned to a vector whose entries have the same type as is used to\n      * index entries of the original matrix; for dense matrices, this is \\c std::ptrdiff_t .\n      *\n      * Example: \\include PartialRedux_count.cpp\n      * Output: \\verbinclude PartialRedux_count.out\n      *\n      * \\sa DenseBase::count() */\n    EIGEN_DEVICE_FUNC\n    const CountReturnType count() const\n    { return CountReturnType(_expression()); }\n\n    /** \\returns a row (or column) vector expression of the product\n      * of each column (or row) of the referenced expression.\n      *\n      * Example: \\include PartialRedux_prod.cpp\n      * Output: \\verbinclude PartialRedux_prod.out\n      *\n      * \\sa DenseBase::prod() */\n    EIGEN_DEVICE_FUNC\n    const ProdReturnType prod() const\n    { return ProdReturnType(_expression()); }\n\n\n    /** \\returns a matrix expression\n      * where each column (or row) are reversed.\n      *\n      * Example: \\include Vectorwise_reverse.cpp\n      * Output: \\verbinclude Vectorwise_reverse.out\n      *\n      * \\sa DenseBase::reverse() */\n    EIGEN_DEVICE_FUNC\n    const ConstReverseReturnType reverse() const\n    { return ConstReverseReturnType( _expression() ); }\n\n    /** \\returns a writable matrix expression\n      * where each column (or row) are reversed.\n      *\n      * \\sa reverse() const */\n    EIGEN_DEVICE_FUNC\n    ReverseReturnType reverse()\n    { return ReverseReturnType( _expression() ); }\n\n    typedef Replicate<ExpressionType,(isVertical?Dynamic:1),(isHorizontal?Dynamic:1)> ReplicateReturnType;\n    EIGEN_DEVICE_FUNC\n    const ReplicateReturnType replicate(Index factor) const;\n\n    /**\n      * \\return an expression of the replication of each column (or row) of \\c *this\n      *\n      * Example: \\include DirectionWise_replicate.cpp\n      * Output: \\verbinclude DirectionWise_replicate.out\n      *\n      * \\sa VectorwiseOp::replicate(Index), DenseBase::replicate(), class Replicate\n      */\n    // NOTE implemented here because of sunstudio's compilation errors\n    // isVertical*Factor+isHorizontal instead of (isVertical?Factor:1) to handle CUDA bug with ternary operator\n    template<int Factor> const Replicate<ExpressionType,isVertical*Factor+isHorizontal,isHorizontal*Factor+isVertical>\n    EIGEN_DEVICE_FUNC\n    replicate(Index factor = Factor) const\n    {\n      return Replicate<ExpressionType,(isVertical?Factor:1),(isHorizontal?Factor:1)>\n          (_expression(),isVertical?factor:1,isHorizontal?factor:1);\n    }\n\n/////////// Artithmetic operators ///////////\n\n    /** Copies the vector \\a other to each subvector of \\c *this */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    ExpressionType& operator=(const DenseBase<OtherDerived>& other)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n      EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)\n      //eigen_assert((m_matrix.isNull()) == (other.isNull())); FIXME\n      return const_cast<ExpressionType&>(m_matrix = extendedTo(other.derived()));\n    }\n\n    /** Adds the vector \\a other to each subvector of \\c *this */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    ExpressionType& operator+=(const DenseBase<OtherDerived>& other)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n      EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)\n      return const_cast<ExpressionType&>(m_matrix += extendedTo(other.derived()));\n    }\n\n    /** Substracts the vector \\a other to each subvector of \\c *this */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    ExpressionType& operator-=(const DenseBase<OtherDerived>& other)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n      EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)\n      return const_cast<ExpressionType&>(m_matrix -= extendedTo(other.derived()));\n    }\n\n    /** Multiples each subvector of \\c *this by the vector \\a other */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    ExpressionType& operator*=(const DenseBase<OtherDerived>& other)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n      EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)\n      EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)\n      m_matrix *= extendedTo(other.derived());\n      return const_cast<ExpressionType&>(m_matrix);\n    }\n\n    /** Divides each subvector of \\c *this by the vector \\a other */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    ExpressionType& operator/=(const DenseBase<OtherDerived>& other)\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n      EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)\n      EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)\n      m_matrix /= extendedTo(other.derived());\n      return const_cast<ExpressionType&>(m_matrix);\n    }\n\n    /** Returns the expression of the sum of the vector \\a other to each subvector of \\c *this */\n    template<typename OtherDerived> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC\n    CwiseBinaryOp<internal::scalar_sum_op<Scalar,typename OtherDerived::Scalar>,\n                  const ExpressionTypeNestedCleaned,\n                  const typename ExtendedType<OtherDerived>::Type>\n    operator+(const DenseBase<OtherDerived>& other) const\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n      EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)\n      return m_matrix + extendedTo(other.derived());\n    }\n\n    /** Returns the expression of the difference between each subvector of \\c *this and the vector \\a other */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    CwiseBinaryOp<internal::scalar_difference_op<Scalar,typename OtherDerived::Scalar>,\n                  const ExpressionTypeNestedCleaned,\n                  const typename ExtendedType<OtherDerived>::Type>\n    operator-(const DenseBase<OtherDerived>& other) const\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n      EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)\n      return m_matrix - extendedTo(other.derived());\n    }\n\n    /** Returns the expression where each subvector is the product of the vector \\a other\n      * by the corresponding subvector of \\c *this */\n    template<typename OtherDerived> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC\n    CwiseBinaryOp<internal::scalar_product_op<Scalar>,\n                  const ExpressionTypeNestedCleaned,\n                  const typename ExtendedType<OtherDerived>::Type>\n    EIGEN_DEVICE_FUNC\n    operator*(const DenseBase<OtherDerived>& other) const\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n      EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)\n      EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)\n      return m_matrix * extendedTo(other.derived());\n    }\n\n    /** Returns the expression where each subvector is the quotient of the corresponding\n      * subvector of \\c *this by the vector \\a other */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    CwiseBinaryOp<internal::scalar_quotient_op<Scalar>,\n                  const ExpressionTypeNestedCleaned,\n                  const typename ExtendedType<OtherDerived>::Type>\n    operator/(const DenseBase<OtherDerived>& other) const\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n      EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)\n      EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)\n      return m_matrix / extendedTo(other.derived());\n    }\n\n    /** \\returns an expression where each column (or row) of the referenced matrix are normalized.\n      * The referenced matrix is \\b not modified.\n      * \\sa MatrixBase::normalized(), normalize()\n      */\n    EIGEN_DEVICE_FUNC\n    CwiseBinaryOp<internal::scalar_quotient_op<Scalar>,\n                  const ExpressionTypeNestedCleaned,\n                  const typename OppositeExtendedType<typename ReturnType<internal::member_norm,RealScalar>::Type>::Type>\n    normalized() const { return m_matrix.cwiseQuotient(extendedToOpposite(this->norm())); }\n\n\n    /** Normalize in-place each row or columns of the referenced matrix.\n      * \\sa MatrixBase::normalize(), normalized()\n      */\n    EIGEN_DEVICE_FUNC void normalize() {\n      m_matrix = this->normalized();\n    }\n\n    EIGEN_DEVICE_FUNC inline void reverseInPlace();\n\n/////////// Geometry module ///////////\n\n    typedef Homogeneous<ExpressionType,Direction> HomogeneousReturnType;\n    EIGEN_DEVICE_FUNC\n    HomogeneousReturnType homogeneous() const;\n\n    typedef typename ExpressionType::PlainObject CrossReturnType;\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC\n    const CrossReturnType cross(const MatrixBase<OtherDerived>& other) const;\n\n    enum {\n      HNormalized_Size = Direction==Vertical ? internal::traits<ExpressionType>::RowsAtCompileTime\n                                             : internal::traits<ExpressionType>::ColsAtCompileTime,\n      HNormalized_SizeMinusOne = HNormalized_Size==Dynamic ? Dynamic : HNormalized_Size-1\n    };\n    typedef Block<const ExpressionType,\n                  Direction==Vertical   ? int(HNormalized_SizeMinusOne)\n                                        : int(internal::traits<ExpressionType>::RowsAtCompileTime),\n                  Direction==Horizontal ? int(HNormalized_SizeMinusOne)\n                                        : int(internal::traits<ExpressionType>::ColsAtCompileTime)>\n            HNormalized_Block;\n    typedef Block<const ExpressionType,\n                  Direction==Vertical   ? 1 : int(internal::traits<ExpressionType>::RowsAtCompileTime),\n                  Direction==Horizontal ? 1 : int(internal::traits<ExpressionType>::ColsAtCompileTime)>\n            HNormalized_Factors;\n    typedef CwiseBinaryOp<internal::scalar_quotient_op<typename internal::traits<ExpressionType>::Scalar>,\n                const HNormalized_Block,\n                const Replicate<HNormalized_Factors,\n                  Direction==Vertical   ? HNormalized_SizeMinusOne : 1,\n                  Direction==Horizontal ? HNormalized_SizeMinusOne : 1> >\n            HNormalizedReturnType;\n\n    EIGEN_DEVICE_FUNC\n    const HNormalizedReturnType hnormalized() const;\n\n  protected:\n    ExpressionTypeNested m_matrix;\n};\n\n//const colwise moved to DenseBase.h due to CUDA compiler bug\n\n\n/** \\returns a writable VectorwiseOp wrapper of *this providing additional partial reduction operations\n  *\n  * \\sa rowwise(), class VectorwiseOp, \\ref TutorialReductionsVisitorsBroadcasting\n  */\ntemplate<typename Derived>\ninline typename DenseBase<Derived>::ColwiseReturnType\nDenseBase<Derived>::colwise()\n{\n  return ColwiseReturnType(derived());\n}\n\n//const rowwise moved to DenseBase.h due to CUDA compiler bug\n\n\n/** \\returns a writable VectorwiseOp wrapper of *this providing additional partial reduction operations\n  *\n  * \\sa colwise(), class VectorwiseOp, \\ref TutorialReductionsVisitorsBroadcasting\n  */\ntemplate<typename Derived>\ninline typename DenseBase<Derived>::RowwiseReturnType\nDenseBase<Derived>::rowwise()\n{\n  return RowwiseReturnType(derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_PARTIAL_REDUX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/Visitor.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_VISITOR_H\n#define EIGEN_VISITOR_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Visitor, typename Derived, int UnrollCount>\nstruct visitor_impl\n{\n  enum {\n    col = (UnrollCount-1) / Derived::RowsAtCompileTime,\n    row = (UnrollCount-1) % Derived::RowsAtCompileTime\n  };\n\n  EIGEN_DEVICE_FUNC\n  static inline void run(const Derived &mat, Visitor& visitor)\n  {\n    visitor_impl<Visitor, Derived, UnrollCount-1>::run(mat, visitor);\n    visitor(mat.coeff(row, col), row, col);\n  }\n};\n\ntemplate<typename Visitor, typename Derived>\nstruct visitor_impl<Visitor, Derived, 1>\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(const Derived &mat, Visitor& visitor)\n  {\n    return visitor.init(mat.coeff(0, 0), 0, 0);\n  }\n};\n\ntemplate<typename Visitor, typename Derived>\nstruct visitor_impl<Visitor, Derived, Dynamic>\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(const Derived& mat, Visitor& visitor)\n  {\n    visitor.init(mat.coeff(0,0), 0, 0);\n    for(Index i = 1; i < mat.rows(); ++i)\n      visitor(mat.coeff(i, 0), i, 0);\n    for(Index j = 1; j < mat.cols(); ++j)\n      for(Index i = 0; i < mat.rows(); ++i)\n        visitor(mat.coeff(i, j), i, j);\n  }\n};\n\n// evaluator adaptor\ntemplate<typename XprType>\nclass visitor_evaluator\n{\npublic:\n  EIGEN_DEVICE_FUNC\n  explicit visitor_evaluator(const XprType &xpr) : m_evaluator(xpr), m_xpr(xpr) {}\n  \n  typedef typename XprType::Scalar Scalar;\n  typedef typename XprType::CoeffReturnType CoeffReturnType;\n  \n  enum {\n    RowsAtCompileTime = XprType::RowsAtCompileTime,\n    CoeffReadCost = internal::evaluator<XprType>::CoeffReadCost\n  };\n  \n  EIGEN_DEVICE_FUNC Index rows() const { return m_xpr.rows(); }\n  EIGEN_DEVICE_FUNC Index cols() const { return m_xpr.cols(); }\n  EIGEN_DEVICE_FUNC Index size() const { return m_xpr.size(); }\n\n  EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const\n  { return m_evaluator.coeff(row, col); }\n  \nprotected:\n  internal::evaluator<XprType> m_evaluator;\n  const XprType &m_xpr;\n};\n} // end namespace internal\n\n/** Applies the visitor \\a visitor to the whole coefficients of the matrix or vector.\n  *\n  * The template parameter \\a Visitor is the type of the visitor and provides the following interface:\n  * \\code\n  * struct MyVisitor {\n  *   // called for the first coefficient\n  *   void init(const Scalar& value, Index i, Index j);\n  *   // called for all other coefficients\n  *   void operator() (const Scalar& value, Index i, Index j);\n  * };\n  * \\endcode\n  *\n  * \\note compared to one or two \\em for \\em loops, visitors offer automatic\n  * unrolling for small fixed size matrix.\n  *\n  * \\sa minCoeff(Index*,Index*), maxCoeff(Index*,Index*), DenseBase::redux()\n  */\ntemplate<typename Derived>\ntemplate<typename Visitor>\nEIGEN_DEVICE_FUNC\nvoid DenseBase<Derived>::visit(Visitor& visitor) const\n{\n  typedef typename internal::visitor_evaluator<Derived> ThisEvaluator;\n  ThisEvaluator thisEval(derived());\n  \n  enum {\n    unroll =  SizeAtCompileTime != Dynamic\n           && SizeAtCompileTime * ThisEvaluator::CoeffReadCost + (SizeAtCompileTime-1) * internal::functor_traits<Visitor>::Cost <= EIGEN_UNROLLING_LIMIT\n  };\n  return internal::visitor_impl<Visitor, ThisEvaluator, unroll ? int(SizeAtCompileTime) : Dynamic>::run(thisEval, visitor);\n}\n\nnamespace internal {\n\n/** \\internal\n  * \\brief Base class to implement min and max visitors\n  */\ntemplate <typename Derived>\nstruct coeff_visitor\n{\n  typedef typename Derived::Scalar Scalar;\n  Index row, col;\n  Scalar res;\n  EIGEN_DEVICE_FUNC\n  inline void init(const Scalar& value, Index i, Index j)\n  {\n    res = value;\n    row = i;\n    col = j;\n  }\n};\n\n/** \\internal\n  * \\brief Visitor computing the min coefficient with its value and coordinates\n  *\n  * \\sa DenseBase::minCoeff(Index*, Index*)\n  */\ntemplate <typename Derived>\nstruct min_coeff_visitor : coeff_visitor<Derived>\n{\n  typedef typename Derived::Scalar Scalar;\n  EIGEN_DEVICE_FUNC\n  void operator() (const Scalar& value, Index i, Index j)\n  {\n    if(value < this->res)\n    {\n      this->res = value;\n      this->row = i;\n      this->col = j;\n    }\n  }\n};\n\ntemplate<typename Scalar>\nstruct functor_traits<min_coeff_visitor<Scalar> > {\n  enum {\n    Cost = NumTraits<Scalar>::AddCost\n  };\n};\n\n/** \\internal\n  * \\brief Visitor computing the max coefficient with its value and coordinates\n  *\n  * \\sa DenseBase::maxCoeff(Index*, Index*)\n  */\ntemplate <typename Derived>\nstruct max_coeff_visitor : coeff_visitor<Derived>\n{\n  typedef typename Derived::Scalar Scalar; \n  EIGEN_DEVICE_FUNC\n  void operator() (const Scalar& value, Index i, Index j)\n  {\n    if(value > this->res)\n    {\n      this->res = value;\n      this->row = i;\n      this->col = j;\n    }\n  }\n};\n\ntemplate<typename Scalar>\nstruct functor_traits<max_coeff_visitor<Scalar> > {\n  enum {\n    Cost = NumTraits<Scalar>::AddCost\n  };\n};\n\n} // end namespace internal\n\n/** \\fn DenseBase<Derived>::minCoeff(IndexType* rowId, IndexType* colId) const\n  * \\returns the minimum of all coefficients of *this and puts in *row and *col its location.\n  * \\warning the result is undefined if \\c *this contains NaN.\n  *\n  * \\sa DenseBase::minCoeff(Index*), DenseBase::maxCoeff(Index*,Index*), DenseBase::visit(), DenseBase::minCoeff()\n  */\ntemplate<typename Derived>\ntemplate<typename IndexType>\nEIGEN_DEVICE_FUNC\ntypename internal::traits<Derived>::Scalar\nDenseBase<Derived>::minCoeff(IndexType* rowId, IndexType* colId) const\n{\n  internal::min_coeff_visitor<Derived> minVisitor;\n  this->visit(minVisitor);\n  *rowId = minVisitor.row;\n  if (colId) *colId = minVisitor.col;\n  return minVisitor.res;\n}\n\n/** \\returns the minimum of all coefficients of *this and puts in *index its location.\n  * \\warning the result is undefined if \\c *this contains NaN. \n  *\n  * \\sa DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::maxCoeff(IndexType*,IndexType*), DenseBase::visit(), DenseBase::minCoeff()\n  */\ntemplate<typename Derived>\ntemplate<typename IndexType>\nEIGEN_DEVICE_FUNC\ntypename internal::traits<Derived>::Scalar\nDenseBase<Derived>::minCoeff(IndexType* index) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  internal::min_coeff_visitor<Derived> minVisitor;\n  this->visit(minVisitor);\n  *index = IndexType((RowsAtCompileTime==1) ? minVisitor.col : minVisitor.row);\n  return minVisitor.res;\n}\n\n/** \\fn DenseBase<Derived>::maxCoeff(IndexType* rowId, IndexType* colId) const\n  * \\returns the maximum of all coefficients of *this and puts in *row and *col its location.\n  * \\warning the result is undefined if \\c *this contains NaN. \n  *\n  * \\sa DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::visit(), DenseBase::maxCoeff()\n  */\ntemplate<typename Derived>\ntemplate<typename IndexType>\nEIGEN_DEVICE_FUNC\ntypename internal::traits<Derived>::Scalar\nDenseBase<Derived>::maxCoeff(IndexType* rowPtr, IndexType* colPtr) const\n{\n  internal::max_coeff_visitor<Derived> maxVisitor;\n  this->visit(maxVisitor);\n  *rowPtr = maxVisitor.row;\n  if (colPtr) *colPtr = maxVisitor.col;\n  return maxVisitor.res;\n}\n\n/** \\returns the maximum of all coefficients of *this and puts in *index its location.\n  * \\warning the result is undefined if \\c *this contains NaN.\n  *\n  * \\sa DenseBase::maxCoeff(IndexType*,IndexType*), DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::visitor(), DenseBase::maxCoeff()\n  */\ntemplate<typename Derived>\ntemplate<typename IndexType>\nEIGEN_DEVICE_FUNC\ntypename internal::traits<Derived>::Scalar\nDenseBase<Derived>::maxCoeff(IndexType* index) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  internal::max_coeff_visitor<Derived> maxVisitor;\n  this->visit(maxVisitor);\n  *index = (RowsAtCompileTime==1) ? maxVisitor.col : maxVisitor.row;\n  return maxVisitor.res;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_VISITOR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/AVX/Complex.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2014 Benoit Steiner (benoit.steiner.goog@gmail.com)\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COMPLEX_AVX_H\n#define EIGEN_COMPLEX_AVX_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n//---------- float ----------\nstruct Packet4cf\n{\n  EIGEN_STRONG_INLINE Packet4cf() {}\n  EIGEN_STRONG_INLINE explicit Packet4cf(const __m256& a) : v(a) {}\n  __m256  v;\n};\n\ntemplate<> struct packet_traits<std::complex<float> >  : default_packet_traits\n{\n  typedef Packet4cf type;\n  typedef Packet2cf half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 4,\n    HasHalfPacket = 1,\n\n    HasAdd    = 1,\n    HasSub    = 1,\n    HasMul    = 1,\n    HasDiv    = 1,\n    HasNegate = 1,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasSetLinear = 0\n  };\n};\n\ntemplate<> struct unpacket_traits<Packet4cf> { typedef std::complex<float> type; enum {size=4, alignment=Aligned32}; typedef Packet2cf half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf padd<Packet4cf>(const Packet4cf& a, const Packet4cf& b) { return Packet4cf(_mm256_add_ps(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet4cf psub<Packet4cf>(const Packet4cf& a, const Packet4cf& b) { return Packet4cf(_mm256_sub_ps(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pnegate(const Packet4cf& a)\n{\n  return Packet4cf(pnegate(a.v));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pconj(const Packet4cf& a)\n{\n  const __m256 mask = _mm256_castsi256_ps(_mm256_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000,0x00000000,0x80000000,0x00000000,0x80000000));\n  return Packet4cf(_mm256_xor_ps(a.v,mask));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pmul<Packet4cf>(const Packet4cf& a, const Packet4cf& b)\n{\n  __m256 tmp1 = _mm256_mul_ps(_mm256_moveldup_ps(a.v), b.v);\n  __m256 tmp2 = _mm256_mul_ps(_mm256_movehdup_ps(a.v), _mm256_permute_ps(b.v, _MM_SHUFFLE(2,3,0,1)));\n  __m256 result = _mm256_addsub_ps(tmp1, tmp2);\n  return Packet4cf(result);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pand   <Packet4cf>(const Packet4cf& a, const Packet4cf& b) { return Packet4cf(_mm256_and_ps(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet4cf por    <Packet4cf>(const Packet4cf& a, const Packet4cf& b) { return Packet4cf(_mm256_or_ps(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pxor   <Packet4cf>(const Packet4cf& a, const Packet4cf& b) { return Packet4cf(_mm256_xor_ps(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pandnot<Packet4cf>(const Packet4cf& a, const Packet4cf& b) { return Packet4cf(_mm256_andnot_ps(a.v,b.v)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pload <Packet4cf>(const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet4cf(pload<Packet8f>(&numext::real_ref(*from))); }\ntemplate<> EIGEN_STRONG_INLINE Packet4cf ploadu<Packet4cf>(const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet4cf(ploadu<Packet8f>(&numext::real_ref(*from))); }\n\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pset1<Packet4cf>(const std::complex<float>& from)\n{\n  return Packet4cf(_mm256_castpd_ps(_mm256_broadcast_sd((const double*)(const void*)&from)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf ploaddup<Packet4cf>(const std::complex<float>* from)\n{\n  // FIXME The following might be optimized using _mm256_movedup_pd\n  Packet2cf a = ploaddup<Packet2cf>(from);\n  Packet2cf b = ploaddup<Packet2cf>(from+1);\n  return  Packet4cf(_mm256_insertf128_ps(_mm256_castps128_ps256(a.v), b.v, 1));\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float>* to, const Packet4cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore(&numext::real_ref(*to), from.v); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float>* to, const Packet4cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&numext::real_ref(*to), from.v); }\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet4cf pgather<std::complex<float>, Packet4cf>(const std::complex<float>* from, Index stride)\n{\n  return Packet4cf(_mm256_set_ps(std::imag(from[3*stride]), std::real(from[3*stride]),\n                                 std::imag(from[2*stride]), std::real(from[2*stride]),\n                                 std::imag(from[1*stride]), std::real(from[1*stride]),\n                                 std::imag(from[0*stride]), std::real(from[0*stride])));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet4cf>(std::complex<float>* to, const Packet4cf& from, Index stride)\n{\n  __m128 low = _mm256_extractf128_ps(from.v, 0);\n  to[stride*0] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(low, low, 0)),\n                                     _mm_cvtss_f32(_mm_shuffle_ps(low, low, 1)));\n  to[stride*1] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(low, low, 2)),\n                                     _mm_cvtss_f32(_mm_shuffle_ps(low, low, 3)));\n\n  __m128 high = _mm256_extractf128_ps(from.v, 1);\n  to[stride*2] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(high, high, 0)),\n                                     _mm_cvtss_f32(_mm_shuffle_ps(high, high, 1)));\n  to[stride*3] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(high, high, 2)),\n                                     _mm_cvtss_f32(_mm_shuffle_ps(high, high, 3)));\n\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float>  pfirst<Packet4cf>(const Packet4cf& a)\n{\n  return pfirst(Packet2cf(_mm256_castps256_ps128(a.v)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf preverse(const Packet4cf& a) {\n  __m128 low  = _mm256_extractf128_ps(a.v, 0);\n  __m128 high = _mm256_extractf128_ps(a.v, 1);\n  __m128d lowd  = _mm_castps_pd(low);\n  __m128d highd = _mm_castps_pd(high);\n  low  = _mm_castpd_ps(_mm_shuffle_pd(lowd,lowd,0x1));\n  high = _mm_castpd_ps(_mm_shuffle_pd(highd,highd,0x1));\n  __m256 result = _mm256_setzero_ps();\n  result = _mm256_insertf128_ps(result, low, 1);\n  result = _mm256_insertf128_ps(result, high, 0);\n  return Packet4cf(result);\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet4cf>(const Packet4cf& a)\n{\n  return predux(padd(Packet2cf(_mm256_extractf128_ps(a.v,0)),\n                     Packet2cf(_mm256_extractf128_ps(a.v,1))));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf preduxp<Packet4cf>(const Packet4cf* vecs)\n{\n  Packet8f t0 = _mm256_shuffle_ps(vecs[0].v, vecs[0].v, _MM_SHUFFLE(3, 1, 2 ,0));\n  Packet8f t1 = _mm256_shuffle_ps(vecs[1].v, vecs[1].v, _MM_SHUFFLE(3, 1, 2 ,0));\n  t0 = _mm256_hadd_ps(t0,t1);\n  Packet8f t2 = _mm256_shuffle_ps(vecs[2].v, vecs[2].v, _MM_SHUFFLE(3, 1, 2 ,0));\n  Packet8f t3 = _mm256_shuffle_ps(vecs[3].v, vecs[3].v, _MM_SHUFFLE(3, 1, 2 ,0));\n  t2 = _mm256_hadd_ps(t2,t3);\n  \n  t1 = _mm256_permute2f128_ps(t0,t2, 0 + (2<<4));\n  t3 = _mm256_permute2f128_ps(t0,t2, 1 + (3<<4));\n\n  return Packet4cf(_mm256_add_ps(t1,t3));\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet4cf>(const Packet4cf& a)\n{\n  return predux_mul(pmul(Packet2cf(_mm256_extractf128_ps(a.v, 0)),\n                         Packet2cf(_mm256_extractf128_ps(a.v, 1))));\n}\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet4cf>\n{\n  static EIGEN_STRONG_INLINE void run(Packet4cf& first, const Packet4cf& second)\n  {\n    if (Offset==0) return;\n    palign_impl<Offset*2,Packet8f>::run(first.v, second.v);\n  }\n};\n\ntemplate<> struct conj_helper<Packet4cf, Packet4cf, false,true>\n{\n  EIGEN_STRONG_INLINE Packet4cf pmadd(const Packet4cf& x, const Packet4cf& y, const Packet4cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet4cf pmul(const Packet4cf& a, const Packet4cf& b) const\n  {\n    return internal::pmul(a, pconj(b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet4cf, Packet4cf, true,false>\n{\n  EIGEN_STRONG_INLINE Packet4cf pmadd(const Packet4cf& x, const Packet4cf& y, const Packet4cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet4cf pmul(const Packet4cf& a, const Packet4cf& b) const\n  {\n    return internal::pmul(pconj(a), b);\n  }\n};\n\ntemplate<> struct conj_helper<Packet4cf, Packet4cf, true,true>\n{\n  EIGEN_STRONG_INLINE Packet4cf pmadd(const Packet4cf& x, const Packet4cf& y, const Packet4cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet4cf pmul(const Packet4cf& a, const Packet4cf& b) const\n  {\n    return pconj(internal::pmul(a, b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet8f, Packet4cf, false,false>\n{\n  EIGEN_STRONG_INLINE Packet4cf pmadd(const Packet8f& x, const Packet4cf& y, const Packet4cf& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet4cf pmul(const Packet8f& x, const Packet4cf& y) const\n  { return Packet4cf(Eigen::internal::pmul(x, y.v)); }\n};\n\ntemplate<> struct conj_helper<Packet4cf, Packet8f, false,false>\n{\n  EIGEN_STRONG_INLINE Packet4cf pmadd(const Packet4cf& x, const Packet8f& y, const Packet4cf& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet4cf pmul(const Packet4cf& x, const Packet8f& y) const\n  { return Packet4cf(Eigen::internal::pmul(x.v, y)); }\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pdiv<Packet4cf>(const Packet4cf& a, const Packet4cf& b)\n{\n  Packet4cf num = pmul(a, pconj(b));\n  __m256 tmp = _mm256_mul_ps(b.v, b.v);\n  __m256 tmp2    = _mm256_shuffle_ps(tmp,tmp,0xB1);\n  __m256 denom = _mm256_add_ps(tmp, tmp2);\n  return Packet4cf(_mm256_div_ps(num.v, denom));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pcplxflip<Packet4cf>(const Packet4cf& x)\n{\n  return Packet4cf(_mm256_shuffle_ps(x.v, x.v, _MM_SHUFFLE(2, 3, 0 ,1)));\n}\n\n//---------- double ----------\nstruct Packet2cd\n{\n  EIGEN_STRONG_INLINE Packet2cd() {}\n  EIGEN_STRONG_INLINE explicit Packet2cd(const __m256d& a) : v(a) {}\n  __m256d  v;\n};\n\ntemplate<> struct packet_traits<std::complex<double> >  : default_packet_traits\n{\n  typedef Packet2cd type;\n  typedef Packet1cd half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 0,\n    size = 2,\n    HasHalfPacket = 1,\n\n    HasAdd    = 1,\n    HasSub    = 1,\n    HasMul    = 1,\n    HasDiv    = 1,\n    HasNegate = 1,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasSetLinear = 0\n  };\n};\n\ntemplate<> struct unpacket_traits<Packet2cd> { typedef std::complex<double> type; enum {size=2, alignment=Aligned32}; typedef Packet1cd half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd padd<Packet2cd>(const Packet2cd& a, const Packet2cd& b) { return Packet2cd(_mm256_add_pd(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cd psub<Packet2cd>(const Packet2cd& a, const Packet2cd& b) { return Packet2cd(_mm256_sub_pd(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pnegate(const Packet2cd& a) { return Packet2cd(pnegate(a.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pconj(const Packet2cd& a)\n{\n  const __m256d mask = _mm256_castsi256_pd(_mm256_set_epi32(0x80000000,0x0,0x0,0x0,0x80000000,0x0,0x0,0x0));\n  return Packet2cd(_mm256_xor_pd(a.v,mask));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pmul<Packet2cd>(const Packet2cd& a, const Packet2cd& b)\n{\n  __m256d tmp1 = _mm256_shuffle_pd(a.v,a.v,0x0);\n  __m256d even = _mm256_mul_pd(tmp1, b.v);\n  __m256d tmp2 = _mm256_shuffle_pd(a.v,a.v,0xF);\n  __m256d tmp3 = _mm256_shuffle_pd(b.v,b.v,0x5);\n  __m256d odd  = _mm256_mul_pd(tmp2, tmp3);\n  return Packet2cd(_mm256_addsub_pd(even, odd));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pand   <Packet2cd>(const Packet2cd& a, const Packet2cd& b) { return Packet2cd(_mm256_and_pd(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cd por    <Packet2cd>(const Packet2cd& a, const Packet2cd& b) { return Packet2cd(_mm256_or_pd(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pxor   <Packet2cd>(const Packet2cd& a, const Packet2cd& b) { return Packet2cd(_mm256_xor_pd(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pandnot<Packet2cd>(const Packet2cd& a, const Packet2cd& b) { return Packet2cd(_mm256_andnot_pd(a.v,b.v)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pload <Packet2cd>(const std::complex<double>* from)\n{ EIGEN_DEBUG_ALIGNED_LOAD return Packet2cd(pload<Packet4d>((const double*)from)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cd ploadu<Packet2cd>(const std::complex<double>* from)\n{ EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cd(ploadu<Packet4d>((const double*)from)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pset1<Packet2cd>(const std::complex<double>& from)\n{\n  // in case casting to a __m128d* is really not safe, then we can still fallback to this version: (much slower though)\n//   return Packet2cd(_mm256_loadu2_m128d((const double*)&from,(const double*)&from));\n    return Packet2cd(_mm256_broadcast_pd((const __m128d*)(const void*)&from));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd ploaddup<Packet2cd>(const std::complex<double>* from) { return pset1<Packet2cd>(*from); }\n\ntemplate<> EIGEN_STRONG_INLINE void pstore <std::complex<double> >(std::complex<double> *   to, const Packet2cd& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((double*)to, from.v); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex<double> *   to, const Packet2cd& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, from.v); }\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet2cd pgather<std::complex<double>, Packet2cd>(const std::complex<double>* from, Index stride)\n{\n  return Packet2cd(_mm256_set_pd(std::imag(from[1*stride]), std::real(from[1*stride]),\n\t\t\t\t std::imag(from[0*stride]), std::real(from[0*stride])));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet2cd>(std::complex<double>* to, const Packet2cd& from, Index stride)\n{\n  __m128d low = _mm256_extractf128_pd(from.v, 0);\n  to[stride*0] = std::complex<double>(_mm_cvtsd_f64(low), _mm_cvtsd_f64(_mm_shuffle_pd(low, low, 1)));\n  __m128d high = _mm256_extractf128_pd(from.v, 1);\n  to[stride*1] = std::complex<double>(_mm_cvtsd_f64(high), _mm_cvtsd_f64(_mm_shuffle_pd(high, high, 1)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double> pfirst<Packet2cd>(const Packet2cd& a)\n{\n  __m128d low = _mm256_extractf128_pd(a.v, 0);\n  EIGEN_ALIGN16 double res[2];\n  _mm_store_pd(res, low);\n  return std::complex<double>(res[0],res[1]);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd preverse(const Packet2cd& a) {\n  __m256d result = _mm256_permute2f128_pd(a.v, a.v, 1);\n  return Packet2cd(result);\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet2cd>(const Packet2cd& a)\n{\n  return predux(padd(Packet1cd(_mm256_extractf128_pd(a.v,0)),\n                     Packet1cd(_mm256_extractf128_pd(a.v,1))));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd preduxp<Packet2cd>(const Packet2cd* vecs)\n{\n  Packet4d t0 = _mm256_permute2f128_pd(vecs[0].v,vecs[1].v, 0 + (2<<4));\n  Packet4d t1 = _mm256_permute2f128_pd(vecs[0].v,vecs[1].v, 1 + (3<<4));\n\n  return Packet2cd(_mm256_add_pd(t0,t1));\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet2cd>(const Packet2cd& a)\n{\n  return predux(pmul(Packet1cd(_mm256_extractf128_pd(a.v,0)),\n                     Packet1cd(_mm256_extractf128_pd(a.v,1))));\n}\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet2cd>\n{\n  static EIGEN_STRONG_INLINE void run(Packet2cd& first, const Packet2cd& second)\n  {\n    if (Offset==0) return;\n    palign_impl<Offset*2,Packet4d>::run(first.v, second.v);\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cd, Packet2cd, false,true>\n{\n  EIGEN_STRONG_INLINE Packet2cd pmadd(const Packet2cd& x, const Packet2cd& y, const Packet2cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cd pmul(const Packet2cd& a, const Packet2cd& b) const\n  {\n    return internal::pmul(a, pconj(b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cd, Packet2cd, true,false>\n{\n  EIGEN_STRONG_INLINE Packet2cd pmadd(const Packet2cd& x, const Packet2cd& y, const Packet2cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cd pmul(const Packet2cd& a, const Packet2cd& b) const\n  {\n    return internal::pmul(pconj(a), b);\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cd, Packet2cd, true,true>\n{\n  EIGEN_STRONG_INLINE Packet2cd pmadd(const Packet2cd& x, const Packet2cd& y, const Packet2cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cd pmul(const Packet2cd& a, const Packet2cd& b) const\n  {\n    return pconj(internal::pmul(a, b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet4d, Packet2cd, false,false>\n{\n  EIGEN_STRONG_INLINE Packet2cd pmadd(const Packet4d& x, const Packet2cd& y, const Packet2cd& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet2cd pmul(const Packet4d& x, const Packet2cd& y) const\n  { return Packet2cd(Eigen::internal::pmul(x, y.v)); }\n};\n\ntemplate<> struct conj_helper<Packet2cd, Packet4d, false,false>\n{\n  EIGEN_STRONG_INLINE Packet2cd pmadd(const Packet2cd& x, const Packet4d& y, const Packet2cd& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet2cd pmul(const Packet2cd& x, const Packet4d& y) const\n  { return Packet2cd(Eigen::internal::pmul(x.v, y)); }\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pdiv<Packet2cd>(const Packet2cd& a, const Packet2cd& b)\n{\n  Packet2cd num = pmul(a, pconj(b));\n  __m256d tmp = _mm256_mul_pd(b.v, b.v);\n  __m256d denom = _mm256_hadd_pd(tmp, tmp);\n  return Packet2cd(_mm256_div_pd(num.v, denom));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pcplxflip<Packet2cd>(const Packet2cd& x)\n{\n  return Packet2cd(_mm256_shuffle_pd(x.v, x.v, 0x5));\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet4cf,4>& kernel) {\n  __m256d P0 = _mm256_castps_pd(kernel.packet[0].v);\n  __m256d P1 = _mm256_castps_pd(kernel.packet[1].v);\n  __m256d P2 = _mm256_castps_pd(kernel.packet[2].v);\n  __m256d P3 = _mm256_castps_pd(kernel.packet[3].v);\n\n  __m256d T0 = _mm256_shuffle_pd(P0, P1, 15);\n  __m256d T1 = _mm256_shuffle_pd(P0, P1, 0);\n  __m256d T2 = _mm256_shuffle_pd(P2, P3, 15);\n  __m256d T3 = _mm256_shuffle_pd(P2, P3, 0);\n\n  kernel.packet[1].v = _mm256_castpd_ps(_mm256_permute2f128_pd(T0, T2, 32));\n  kernel.packet[3].v = _mm256_castpd_ps(_mm256_permute2f128_pd(T0, T2, 49));\n  kernel.packet[0].v = _mm256_castpd_ps(_mm256_permute2f128_pd(T1, T3, 32));\n  kernel.packet[2].v = _mm256_castpd_ps(_mm256_permute2f128_pd(T1, T3, 49));\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet2cd,2>& kernel) {\n  __m256d tmp = _mm256_permute2f128_pd(kernel.packet[0].v, kernel.packet[1].v, 0+(2<<4));\n  kernel.packet[1].v = _mm256_permute2f128_pd(kernel.packet[0].v, kernel.packet[1].v, 1+(3<<4));\n kernel.packet[0].v = tmp;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pinsertfirst(const Packet4cf& a, std::complex<float> b)\n{\n  return Packet4cf(_mm256_blend_ps(a.v,pset1<Packet4cf>(b).v,1|2));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pinsertfirst(const Packet2cd& a, std::complex<double> b)\n{\n  return Packet2cd(_mm256_blend_pd(a.v,pset1<Packet2cd>(b).v,1|2));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4cf pinsertlast(const Packet4cf& a, std::complex<float> b)\n{\n  return Packet4cf(_mm256_blend_ps(a.v,pset1<Packet4cf>(b).v,(1<<7)|(1<<6)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cd pinsertlast(const Packet2cd& a, std::complex<double> b)\n{\n  return Packet2cd(_mm256_blend_pd(a.v,pset1<Packet2cd>(b).v,(1<<3)|(1<<2)));\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_COMPLEX_AVX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/AVX/MathFunctions.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2014 Pedro Gonnet (pedro.gonnet@gmail.com)\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MATH_FUNCTIONS_AVX_H\n#define EIGEN_MATH_FUNCTIONS_AVX_H\n\n/* The sin, cos, exp, and log functions of this file are loosely derived from\n * Julien Pommier's sse math library: http://gruntthepeon.free.fr/ssemath/\n */\n\nnamespace Eigen {\n\nnamespace internal {\n\ninline Packet8i pshiftleft(Packet8i v, int n)\n{\n#ifdef EIGEN_VECTORIZE_AVX2\n  return _mm256_slli_epi32(v, n);\n#else\n  __m128i lo = _mm_slli_epi32(_mm256_extractf128_si256(v, 0), n);\n  __m128i hi = _mm_slli_epi32(_mm256_extractf128_si256(v, 1), n);\n  return _mm256_insertf128_si256(_mm256_castsi128_si256(lo), (hi), 1);\n#endif\n}\n\ninline Packet8f pshiftright(Packet8f v, int n)\n{\n#ifdef EIGEN_VECTORIZE_AVX2\n  return _mm256_cvtepi32_ps(_mm256_srli_epi32(_mm256_castps_si256(v), n));\n#else\n  __m128i lo = _mm_srli_epi32(_mm256_extractf128_si256(_mm256_castps_si256(v), 0), n);\n  __m128i hi = _mm_srli_epi32(_mm256_extractf128_si256(_mm256_castps_si256(v), 1), n);\n  return _mm256_cvtepi32_ps(_mm256_insertf128_si256(_mm256_castsi128_si256(lo), (hi), 1));\n#endif\n}\n\n// Sine function\n// Computes sin(x) by wrapping x to the interval [-Pi/4,3*Pi/4] and\n// evaluating interpolants in [-Pi/4,Pi/4] or [Pi/4,3*Pi/4]. The interpolants\n// are (anti-)symmetric and thus have only odd/even coefficients\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet8f\npsin<Packet8f>(const Packet8f& _x) {\n  Packet8f x = _x;\n\n  // Some useful values.\n  _EIGEN_DECLARE_CONST_Packet8i(one, 1);\n  _EIGEN_DECLARE_CONST_Packet8f(one, 1.0f);\n  _EIGEN_DECLARE_CONST_Packet8f(two, 2.0f);\n  _EIGEN_DECLARE_CONST_Packet8f(one_over_four, 0.25f);\n  _EIGEN_DECLARE_CONST_Packet8f(one_over_pi, 3.183098861837907e-01f);\n  _EIGEN_DECLARE_CONST_Packet8f(neg_pi_first, -3.140625000000000e+00f);\n  _EIGEN_DECLARE_CONST_Packet8f(neg_pi_second, -9.670257568359375e-04f);\n  _EIGEN_DECLARE_CONST_Packet8f(neg_pi_third, -6.278329571784980e-07f);\n  _EIGEN_DECLARE_CONST_Packet8f(four_over_pi, 1.273239544735163e+00f);\n\n  // Map x from [-Pi/4,3*Pi/4] to z in [-1,3] and subtract the shifted period.\n  Packet8f z = pmul(x, p8f_one_over_pi);\n  Packet8f shift = _mm256_floor_ps(padd(z, p8f_one_over_four));\n  x = pmadd(shift, p8f_neg_pi_first, x);\n  x = pmadd(shift, p8f_neg_pi_second, x);\n  x = pmadd(shift, p8f_neg_pi_third, x);\n  z = pmul(x, p8f_four_over_pi);\n\n  // Make a mask for the entries that need flipping, i.e. wherever the shift\n  // is odd.\n  Packet8i shift_ints = _mm256_cvtps_epi32(shift);\n  Packet8i shift_isodd = _mm256_castps_si256(_mm256_and_ps(_mm256_castsi256_ps(shift_ints), _mm256_castsi256_ps(p8i_one)));\n  Packet8i sign_flip_mask = pshiftleft(shift_isodd, 31);\n\n  // Create a mask for which interpolant to use, i.e. if z > 1, then the mask\n  // is set to ones for that entry.\n  Packet8f ival_mask = _mm256_cmp_ps(z, p8f_one, _CMP_GT_OQ);\n\n  // Evaluate the polynomial for the interval [1,3] in z.\n  _EIGEN_DECLARE_CONST_Packet8f(coeff_right_0, 9.999999724233232e-01f);\n  _EIGEN_DECLARE_CONST_Packet8f(coeff_right_2, -3.084242535619928e-01f);\n  _EIGEN_DECLARE_CONST_Packet8f(coeff_right_4, 1.584991525700324e-02f);\n  _EIGEN_DECLARE_CONST_Packet8f(coeff_right_6, -3.188805084631342e-04f);\n  Packet8f z_minus_two = psub(z, p8f_two);\n  Packet8f z_minus_two2 = pmul(z_minus_two, z_minus_two);\n  Packet8f right = pmadd(p8f_coeff_right_6, z_minus_two2, p8f_coeff_right_4);\n  right = pmadd(right, z_minus_two2, p8f_coeff_right_2);\n  right = pmadd(right, z_minus_two2, p8f_coeff_right_0);\n\n  // Evaluate the polynomial for the interval [-1,1] in z.\n  _EIGEN_DECLARE_CONST_Packet8f(coeff_left_1, 7.853981525427295e-01f);\n  _EIGEN_DECLARE_CONST_Packet8f(coeff_left_3, -8.074536727092352e-02f);\n  _EIGEN_DECLARE_CONST_Packet8f(coeff_left_5, 2.489871967827018e-03f);\n  _EIGEN_DECLARE_CONST_Packet8f(coeff_left_7, -3.587725841214251e-05f);\n  Packet8f z2 = pmul(z, z);\n  Packet8f left = pmadd(p8f_coeff_left_7, z2, p8f_coeff_left_5);\n  left = pmadd(left, z2, p8f_coeff_left_3);\n  left = pmadd(left, z2, p8f_coeff_left_1);\n  left = pmul(left, z);\n\n  // Assemble the results, i.e. select the left and right polynomials.\n  left = _mm256_andnot_ps(ival_mask, left);\n  right = _mm256_and_ps(ival_mask, right);\n  Packet8f res = _mm256_or_ps(left, right);\n\n  // Flip the sign on the odd intervals and return the result.\n  res = _mm256_xor_ps(res, _mm256_castsi256_ps(sign_flip_mask));\n  return res;\n}\n\n// Natural logarithm\n// Computes log(x) as log(2^e * m) = C*e + log(m), where the constant C =log(2)\n// and m is in the range [sqrt(1/2),sqrt(2)). In this range, the logarithm can\n// be easily approximated by a polynomial centered on m=1 for stability.\n// TODO(gonnet): Further reduce the interval allowing for lower-degree\n//               polynomial interpolants -> ... -> profit!\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet8f\nplog<Packet8f>(const Packet8f& _x) {\n  Packet8f x = _x;\n  _EIGEN_DECLARE_CONST_Packet8f(1, 1.0f);\n  _EIGEN_DECLARE_CONST_Packet8f(half, 0.5f);\n  _EIGEN_DECLARE_CONST_Packet8f(126f, 126.0f);\n\n  _EIGEN_DECLARE_CONST_Packet8f_FROM_INT(inv_mant_mask, ~0x7f800000);\n\n  // The smallest non denormalized float number.\n  _EIGEN_DECLARE_CONST_Packet8f_FROM_INT(min_norm_pos, 0x00800000);\n  _EIGEN_DECLARE_CONST_Packet8f_FROM_INT(minus_inf, 0xff800000);\n\n  // Polynomial coefficients.\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_SQRTHF, 0.707106781186547524f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_log_p0, 7.0376836292E-2f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_log_p1, -1.1514610310E-1f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_log_p2, 1.1676998740E-1f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_log_p3, -1.2420140846E-1f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_log_p4, +1.4249322787E-1f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_log_p5, -1.6668057665E-1f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_log_p6, +2.0000714765E-1f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_log_p7, -2.4999993993E-1f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_log_p8, +3.3333331174E-1f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_log_q1, -2.12194440e-4f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_log_q2, 0.693359375f);\n\n  Packet8f invalid_mask = _mm256_cmp_ps(x, _mm256_setzero_ps(), _CMP_NGE_UQ); // not greater equal is true if x is NaN\n  Packet8f iszero_mask = _mm256_cmp_ps(x, _mm256_setzero_ps(), _CMP_EQ_OQ);\n\n  // Truncate input values to the minimum positive normal.\n  x = pmax(x, p8f_min_norm_pos);\n\n  Packet8f emm0 = pshiftright(x,23);\n  Packet8f e = _mm256_sub_ps(emm0, p8f_126f);\n\n  // Set the exponents to -1, i.e. x are in the range [0.5,1).\n  x = _mm256_and_ps(x, p8f_inv_mant_mask);\n  x = _mm256_or_ps(x, p8f_half);\n\n  // part2: Shift the inputs from the range [0.5,1) to [sqrt(1/2),sqrt(2))\n  // and shift by -1. The values are then centered around 0, which improves\n  // the stability of the polynomial evaluation.\n  //   if( x < SQRTHF ) {\n  //     e -= 1;\n  //     x = x + x - 1.0;\n  //   } else { x = x - 1.0; }\n  Packet8f mask = _mm256_cmp_ps(x, p8f_cephes_SQRTHF, _CMP_LT_OQ);\n  Packet8f tmp = _mm256_and_ps(x, mask);\n  x = psub(x, p8f_1);\n  e = psub(e, _mm256_and_ps(p8f_1, mask));\n  x = padd(x, tmp);\n\n  Packet8f x2 = pmul(x, x);\n  Packet8f x3 = pmul(x2, x);\n\n  // Evaluate the polynomial approximant of degree 8 in three parts, probably\n  // to improve instruction-level parallelism.\n  Packet8f y, y1, y2;\n  y = pmadd(p8f_cephes_log_p0, x, p8f_cephes_log_p1);\n  y1 = pmadd(p8f_cephes_log_p3, x, p8f_cephes_log_p4);\n  y2 = pmadd(p8f_cephes_log_p6, x, p8f_cephes_log_p7);\n  y = pmadd(y, x, p8f_cephes_log_p2);\n  y1 = pmadd(y1, x, p8f_cephes_log_p5);\n  y2 = pmadd(y2, x, p8f_cephes_log_p8);\n  y = pmadd(y, x3, y1);\n  y = pmadd(y, x3, y2);\n  y = pmul(y, x3);\n\n  // Add the logarithm of the exponent back to the result of the interpolation.\n  y1 = pmul(e, p8f_cephes_log_q1);\n  tmp = pmul(x2, p8f_half);\n  y = padd(y, y1);\n  x = psub(x, tmp);\n  y2 = pmul(e, p8f_cephes_log_q2);\n  x = padd(x, y);\n  x = padd(x, y2);\n\n  // Filter out invalid inputs, i.e. negative arg will be NAN, 0 will be -INF.\n  return _mm256_or_ps(\n      _mm256_andnot_ps(iszero_mask, _mm256_or_ps(x, invalid_mask)),\n      _mm256_and_ps(iszero_mask, p8f_minus_inf));\n}\n\n// Exponential function. Works by writing \"x = m*log(2) + r\" where\n// \"m = floor(x/log(2)+1/2)\" and \"r\" is the remainder. The result is then\n// \"exp(x) = 2^m*exp(r)\" where exp(r) is in the range [-1,1).\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet8f\npexp<Packet8f>(const Packet8f& _x) {\n  _EIGEN_DECLARE_CONST_Packet8f(1, 1.0f);\n  _EIGEN_DECLARE_CONST_Packet8f(half, 0.5f);\n  _EIGEN_DECLARE_CONST_Packet8f(127, 127.0f);\n\n  _EIGEN_DECLARE_CONST_Packet8f(exp_hi, 88.3762626647950f);\n  _EIGEN_DECLARE_CONST_Packet8f(exp_lo, -88.3762626647949f);\n\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_LOG2EF, 1.44269504088896341f);\n\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_exp_p0, 1.9875691500E-4f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_exp_p1, 1.3981999507E-3f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_exp_p2, 8.3334519073E-3f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_exp_p3, 4.1665795894E-2f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_exp_p4, 1.6666665459E-1f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_exp_p5, 5.0000001201E-1f);\n\n  // Clamp x.\n  Packet8f x = pmax(pmin(_x, p8f_exp_hi), p8f_exp_lo);\n\n  // Express exp(x) as exp(m*ln(2) + r), start by extracting\n  // m = floor(x/ln(2) + 0.5).\n  Packet8f m = _mm256_floor_ps(pmadd(x, p8f_cephes_LOG2EF, p8f_half));\n\n// Get r = x - m*ln(2). If no FMA instructions are available, m*ln(2) is\n// subtracted out in two parts, m*C1+m*C2 = m*ln(2), to avoid accumulating\n// truncation errors. Note that we don't use the \"pmadd\" function here to\n// ensure that a precision-preserving FMA instruction is used.\n#ifdef EIGEN_VECTORIZE_FMA\n  _EIGEN_DECLARE_CONST_Packet8f(nln2, -0.6931471805599453f);\n  Packet8f r = _mm256_fmadd_ps(m, p8f_nln2, x);\n#else\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_exp_C1, 0.693359375f);\n  _EIGEN_DECLARE_CONST_Packet8f(cephes_exp_C2, -2.12194440e-4f);\n  Packet8f r = psub(x, pmul(m, p8f_cephes_exp_C1));\n  r = psub(r, pmul(m, p8f_cephes_exp_C2));\n#endif\n\n  Packet8f r2 = pmul(r, r);\n\n  // TODO(gonnet): Split into odd/even polynomials and try to exploit\n  //               instruction-level parallelism.\n  Packet8f y = p8f_cephes_exp_p0;\n  y = pmadd(y, r, p8f_cephes_exp_p1);\n  y = pmadd(y, r, p8f_cephes_exp_p2);\n  y = pmadd(y, r, p8f_cephes_exp_p3);\n  y = pmadd(y, r, p8f_cephes_exp_p4);\n  y = pmadd(y, r, p8f_cephes_exp_p5);\n  y = pmadd(y, r2, r);\n  y = padd(y, p8f_1);\n\n  // Build emm0 = 2^m.\n  Packet8i emm0 = _mm256_cvttps_epi32(padd(m, p8f_127));\n  emm0 = pshiftleft(emm0, 23);\n\n  // Return 2^m * exp(r).\n  return pmax(pmul(y, _mm256_castsi256_ps(emm0)), _x);\n}\n\n// Hyperbolic Tangent function.\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet8f\nptanh<Packet8f>(const Packet8f& x) {\n  return internal::generic_fast_tanh_float(x);\n}\n\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet4d\npexp<Packet4d>(const Packet4d& _x) {\n  Packet4d x = _x;\n\n  _EIGEN_DECLARE_CONST_Packet4d(1, 1.0);\n  _EIGEN_DECLARE_CONST_Packet4d(2, 2.0);\n  _EIGEN_DECLARE_CONST_Packet4d(half, 0.5);\n\n  _EIGEN_DECLARE_CONST_Packet4d(exp_hi, 709.437);\n  _EIGEN_DECLARE_CONST_Packet4d(exp_lo, -709.436139303);\n\n  _EIGEN_DECLARE_CONST_Packet4d(cephes_LOG2EF, 1.4426950408889634073599);\n\n  _EIGEN_DECLARE_CONST_Packet4d(cephes_exp_p0, 1.26177193074810590878e-4);\n  _EIGEN_DECLARE_CONST_Packet4d(cephes_exp_p1, 3.02994407707441961300e-2);\n  _EIGEN_DECLARE_CONST_Packet4d(cephes_exp_p2, 9.99999999999999999910e-1);\n\n  _EIGEN_DECLARE_CONST_Packet4d(cephes_exp_q0, 3.00198505138664455042e-6);\n  _EIGEN_DECLARE_CONST_Packet4d(cephes_exp_q1, 2.52448340349684104192e-3);\n  _EIGEN_DECLARE_CONST_Packet4d(cephes_exp_q2, 2.27265548208155028766e-1);\n  _EIGEN_DECLARE_CONST_Packet4d(cephes_exp_q3, 2.00000000000000000009e0);\n\n  _EIGEN_DECLARE_CONST_Packet4d(cephes_exp_C1, 0.693145751953125);\n  _EIGEN_DECLARE_CONST_Packet4d(cephes_exp_C2, 1.42860682030941723212e-6);\n  _EIGEN_DECLARE_CONST_Packet4i(1023, 1023);\n\n  Packet4d tmp, fx;\n\n  // clamp x\n  x = pmax(pmin(x, p4d_exp_hi), p4d_exp_lo);\n  // Express exp(x) as exp(g + n*log(2)).\n  fx = pmadd(p4d_cephes_LOG2EF, x, p4d_half);\n\n  // Get the integer modulus of log(2), i.e. the \"n\" described above.\n  fx = _mm256_floor_pd(fx);\n\n  // Get the remainder modulo log(2), i.e. the \"g\" described above. Subtract\n  // n*log(2) out in two steps, i.e. n*C1 + n*C2, C1+C2=log2 to get the last\n  // digits right.\n  tmp = pmul(fx, p4d_cephes_exp_C1);\n  Packet4d z = pmul(fx, p4d_cephes_exp_C2);\n  x = psub(x, tmp);\n  x = psub(x, z);\n\n  Packet4d x2 = pmul(x, x);\n\n  // Evaluate the numerator polynomial of the rational interpolant.\n  Packet4d px = p4d_cephes_exp_p0;\n  px = pmadd(px, x2, p4d_cephes_exp_p1);\n  px = pmadd(px, x2, p4d_cephes_exp_p2);\n  px = pmul(px, x);\n\n  // Evaluate the denominator polynomial of the rational interpolant.\n  Packet4d qx = p4d_cephes_exp_q0;\n  qx = pmadd(qx, x2, p4d_cephes_exp_q1);\n  qx = pmadd(qx, x2, p4d_cephes_exp_q2);\n  qx = pmadd(qx, x2, p4d_cephes_exp_q3);\n\n  // I don't really get this bit, copied from the SSE2 routines, so...\n  // TODO(gonnet): Figure out what is going on here, perhaps find a better\n  // rational interpolant?\n  x = _mm256_div_pd(px, psub(qx, px));\n  x = pmadd(p4d_2, x, p4d_1);\n\n  // Build e=2^n by constructing the exponents in a 128-bit vector and\n  // shifting them to where they belong in double-precision values.\n  __m128i emm0 = _mm256_cvtpd_epi32(fx);\n  emm0 = _mm_add_epi32(emm0, p4i_1023);\n  emm0 = _mm_shuffle_epi32(emm0, _MM_SHUFFLE(3, 1, 2, 0));\n  __m128i lo = _mm_slli_epi64(emm0, 52);\n  __m128i hi = _mm_slli_epi64(_mm_srli_epi64(emm0, 32), 52);\n  __m256i e = _mm256_insertf128_si256(_mm256_setzero_si256(), lo, 0);\n  e = _mm256_insertf128_si256(e, hi, 1);\n\n  // Construct the result 2^n * exp(g) = e * x. The max is used to catch\n  // non-finite values in the input.\n  return pmax(pmul(x, _mm256_castsi256_pd(e)), _x);\n}\n\n// Functions for sqrt.\n// The EIGEN_FAST_MATH version uses the _mm_rsqrt_ps approximation and one step\n// of Newton's method, at a cost of 1-2 bits of precision as opposed to the\n// exact solution. It does not handle +inf, or denormalized numbers correctly.\n// The main advantage of this approach is not just speed, but also the fact that\n// it can be inlined and pipelined with other computations, further reducing its\n// effective latency. This is similar to Quake3's fast inverse square root.\n// For detail see here: http://www.beyond3d.com/content/articles/8/\n#if EIGEN_FAST_MATH\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet8f\npsqrt<Packet8f>(const Packet8f& _x) {\n  Packet8f half = pmul(_x, pset1<Packet8f>(.5f));\n  Packet8f denormal_mask = _mm256_and_ps(\n      _mm256_cmp_ps(_x, pset1<Packet8f>((std::numeric_limits<float>::min)()),\n                    _CMP_LT_OQ),\n      _mm256_cmp_ps(_x, _mm256_setzero_ps(), _CMP_GE_OQ));\n\n  // Compute approximate reciprocal sqrt.\n  Packet8f x = _mm256_rsqrt_ps(_x);\n  // Do a single step of Newton's iteration.\n  x = pmul(x, psub(pset1<Packet8f>(1.5f), pmul(half, pmul(x,x))));\n  // Flush results for denormals to zero.\n  return _mm256_andnot_ps(denormal_mask, pmul(_x,x));\n}\n#else\ntemplate <> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket8f psqrt<Packet8f>(const Packet8f& x) {\n  return _mm256_sqrt_ps(x);\n}\n#endif\ntemplate <> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4d psqrt<Packet4d>(const Packet4d& x) {\n  return _mm256_sqrt_pd(x);\n}\n#if EIGEN_FAST_MATH\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket8f prsqrt<Packet8f>(const Packet8f& _x) {\n  _EIGEN_DECLARE_CONST_Packet8f_FROM_INT(inf, 0x7f800000);\n  _EIGEN_DECLARE_CONST_Packet8f_FROM_INT(nan, 0x7fc00000);\n  _EIGEN_DECLARE_CONST_Packet8f(one_point_five, 1.5f);\n  _EIGEN_DECLARE_CONST_Packet8f(minus_half, -0.5f);\n  _EIGEN_DECLARE_CONST_Packet8f_FROM_INT(flt_min, 0x00800000);\n\n  Packet8f neg_half = pmul(_x, p8f_minus_half);\n\n  // select only the inverse sqrt of positive normal inputs (denormals are\n  // flushed to zero and cause infs as well).\n  Packet8f le_zero_mask = _mm256_cmp_ps(_x, p8f_flt_min, _CMP_LT_OQ);\n  Packet8f x = _mm256_andnot_ps(le_zero_mask, _mm256_rsqrt_ps(_x));\n\n  // Fill in NaNs and Infs for the negative/zero entries.\n  Packet8f neg_mask = _mm256_cmp_ps(_x, _mm256_setzero_ps(), _CMP_LT_OQ);\n  Packet8f zero_mask = _mm256_andnot_ps(neg_mask, le_zero_mask);\n  Packet8f infs_and_nans = _mm256_or_ps(_mm256_and_ps(neg_mask, p8f_nan),\n                                        _mm256_and_ps(zero_mask, p8f_inf));\n\n  // Do a single step of Newton's iteration.\n  x = pmul(x, pmadd(neg_half, pmul(x, x), p8f_one_point_five));\n\n  // Insert NaNs and Infs in all the right places.\n  return _mm256_or_ps(x, infs_and_nans);\n}\n\n#else\ntemplate <> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket8f prsqrt<Packet8f>(const Packet8f& x) {\n  _EIGEN_DECLARE_CONST_Packet8f(one, 1.0f);\n  return _mm256_div_ps(p8f_one, _mm256_sqrt_ps(x));\n}\n#endif\n\ntemplate <> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4d prsqrt<Packet4d>(const Packet4d& x) {\n  _EIGEN_DECLARE_CONST_Packet4d(one, 1.0);\n  return _mm256_div_pd(p4d_one, _mm256_sqrt_pd(x));\n}\n\n\n}  // end namespace internal\n\n}  // end namespace Eigen\n\n#endif  // EIGEN_MATH_FUNCTIONS_AVX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/AVX/PacketMath.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2014 Benoit Steiner (benoit.steiner.goog@gmail.com)\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PACKET_MATH_AVX_H\n#define EIGEN_PACKET_MATH_AVX_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD\n#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8\n#endif\n\n#ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS\n#define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS (2*sizeof(void*))\n#endif\n\n#ifdef __FMA__\n#ifndef EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n#define EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n#endif\n#endif\n\ntypedef __m256  Packet8f;\ntypedef __m256i Packet8i;\ntypedef __m256d Packet4d;\n\ntemplate<> struct is_arithmetic<__m256>  { enum { value = true }; };\ntemplate<> struct is_arithmetic<__m256i> { enum { value = true }; };\ntemplate<> struct is_arithmetic<__m256d> { enum { value = true }; };\n\n#define _EIGEN_DECLARE_CONST_Packet8f(NAME,X) \\\n  const Packet8f p8f_##NAME = pset1<Packet8f>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet4d(NAME,X) \\\n  const Packet4d p4d_##NAME = pset1<Packet4d>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet8f_FROM_INT(NAME,X) \\\n  const Packet8f p8f_##NAME = _mm256_castsi256_ps(pset1<Packet8i>(X))\n\n#define _EIGEN_DECLARE_CONST_Packet8i(NAME,X) \\\n  const Packet8i p8i_##NAME = pset1<Packet8i>(X)\n\n// Use the packet_traits defined in AVX512/PacketMath.h instead if we're going\n// to leverage AVX512 instructions.\n#ifndef EIGEN_VECTORIZE_AVX512\ntemplate<> struct packet_traits<float>  : default_packet_traits\n{\n  typedef Packet8f type;\n  typedef Packet4f half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=8,\n    HasHalfPacket = 1,\n\n    HasDiv  = 1,\n    HasSin  = EIGEN_FAST_MATH,\n    HasCos  = 0,\n    HasLog  = 1,\n    HasExp  = 1,\n    HasSqrt = 1,\n    HasRsqrt = 1,\n    HasTanh  = EIGEN_FAST_MATH,\n    HasBlend = 1,\n    HasRound = 1,\n    HasFloor = 1,\n    HasCeil = 1\n  };\n};\ntemplate<> struct packet_traits<double> : default_packet_traits\n{\n  typedef Packet4d type;\n  typedef Packet2d half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=4,\n    HasHalfPacket = 1,\n\n    HasDiv  = 1,\n    HasExp  = 1,\n    HasSqrt = 1,\n    HasRsqrt = 1,\n    HasBlend = 1,\n    HasRound = 1,\n    HasFloor = 1,\n    HasCeil = 1\n  };\n};\n#endif\n\ntemplate<> struct scalar_div_cost<float,true> { enum { value = 14 }; };\ntemplate<> struct scalar_div_cost<double,true> { enum { value = 16 }; };\n\n/* Proper support for integers is only provided by AVX2. In the meantime, we'll\n   use SSE instructions and packets to deal with integers.\ntemplate<> struct packet_traits<int>    : default_packet_traits\n{\n  typedef Packet8i type;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=8\n  };\n};\n*/\n\ntemplate<> struct unpacket_traits<Packet8f> { typedef float  type; typedef Packet4f half; enum {size=8, alignment=Aligned32}; };\ntemplate<> struct unpacket_traits<Packet4d> { typedef double type; typedef Packet2d half; enum {size=4, alignment=Aligned32}; };\ntemplate<> struct unpacket_traits<Packet8i> { typedef int    type; typedef Packet4i half; enum {size=8, alignment=Aligned32}; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pset1<Packet8f>(const float&  from) { return _mm256_set1_ps(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pset1<Packet4d>(const double& from) { return _mm256_set1_pd(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet8i pset1<Packet8i>(const int&    from) { return _mm256_set1_epi32(from); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pload1<Packet8f>(const float*  from) { return _mm256_broadcast_ss(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pload1<Packet4d>(const double* from) { return _mm256_broadcast_sd(from); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f plset<Packet8f>(const float& a) { return _mm256_add_ps(_mm256_set1_ps(a), _mm256_set_ps(7.0,6.0,5.0,4.0,3.0,2.0,1.0,0.0)); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d plset<Packet4d>(const double& a) { return _mm256_add_pd(_mm256_set1_pd(a), _mm256_set_pd(3.0,2.0,1.0,0.0)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f padd<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_add_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d padd<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_add_pd(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f psub<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_sub_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d psub<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_sub_pd(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pnegate(const Packet8f& a)\n{\n  return _mm256_sub_ps(_mm256_set1_ps(0.0),a);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4d pnegate(const Packet4d& a)\n{\n  return _mm256_sub_pd(_mm256_set1_pd(0.0),a);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pconj(const Packet8f& a) { return a; }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pconj(const Packet4d& a) { return a; }\ntemplate<> EIGEN_STRONG_INLINE Packet8i pconj(const Packet8i& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pmul<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_mul_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pmul<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_mul_pd(a,b); }\n\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pdiv<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_div_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pdiv<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_div_pd(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet8i pdiv<Packet8i>(const Packet8i& /*a*/, const Packet8i& /*b*/)\n{ eigen_assert(false && \"packet integer division are not supported by AVX\");\n  return pset1<Packet8i>(0);\n}\n\n#ifdef __FMA__\ntemplate<> EIGEN_STRONG_INLINE Packet8f pmadd(const Packet8f& a, const Packet8f& b, const Packet8f& c) {\n#if ( EIGEN_COMP_GNUC_STRICT || (EIGEN_COMP_CLANG && (EIGEN_COMP_CLANG<308)) )\n  // clang stupidly generates a vfmadd213ps instruction plus some vmovaps on registers,\n  // and gcc stupidly generates a vfmadd132ps instruction,\n  // so let's enforce it to generate a vfmadd231ps instruction since the most common use case is to accumulate\n  // the result of the product.\n  Packet8f res = c;\n  __asm__(\"vfmadd231ps %[a], %[b], %[c]\" : [c] \"+x\" (res) : [a] \"x\" (a), [b] \"x\" (b));\n  return res;\n#else\n  return _mm256_fmadd_ps(a,b,c);\n#endif\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4d pmadd(const Packet4d& a, const Packet4d& b, const Packet4d& c) {\n#if ( EIGEN_COMP_GNUC_STRICT || (EIGEN_COMP_CLANG && (EIGEN_COMP_CLANG<308)) )\n  // see above\n  Packet4d res = c;\n  __asm__(\"vfmadd231pd %[a], %[b], %[c]\" : [c] \"+x\" (res) : [a] \"x\" (a), [b] \"x\" (b));\n  return res;\n#else\n  return _mm256_fmadd_pd(a,b,c);\n#endif\n}\n#endif\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pmin<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_min_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pmin<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_min_pd(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pmax<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_max_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pmax<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_max_pd(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pround<Packet8f>(const Packet8f& a) { return _mm256_round_ps(a, _MM_FROUND_CUR_DIRECTION); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pround<Packet4d>(const Packet4d& a) { return _mm256_round_pd(a, _MM_FROUND_CUR_DIRECTION); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pceil<Packet8f>(const Packet8f& a) { return _mm256_ceil_ps(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pceil<Packet4d>(const Packet4d& a) { return _mm256_ceil_pd(a); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pfloor<Packet8f>(const Packet8f& a) { return _mm256_floor_ps(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pfloor<Packet4d>(const Packet4d& a) { return _mm256_floor_pd(a); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pand<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_and_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pand<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_and_pd(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f por<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_or_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d por<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_or_pd(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pxor<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_xor_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pxor<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_xor_pd(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pandnot<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_andnot_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pandnot<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_andnot_pd(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pload<Packet8f>(const float*   from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm256_load_ps(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d pload<Packet4d>(const double*  from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm256_load_pd(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet8i pload<Packet8i>(const int*     from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm256_load_si256(reinterpret_cast<const __m256i*>(from)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f ploadu<Packet8f>(const float* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm256_loadu_ps(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet4d ploadu<Packet4d>(const double* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm256_loadu_pd(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet8i ploadu<Packet8i>(const int* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm256_loadu_si256(reinterpret_cast<const __m256i*>(from)); }\n\n// Loads 4 floats from memory a returns the packet {a0, a0  a1, a1, a2, a2, a3, a3}\ntemplate<> EIGEN_STRONG_INLINE Packet8f ploaddup<Packet8f>(const float* from)\n{\n  // TODO try to find a way to avoid the need of a temporary register\n//   Packet8f tmp  = _mm256_castps128_ps256(_mm_loadu_ps(from));\n//   tmp = _mm256_insertf128_ps(tmp, _mm_movehl_ps(_mm256_castps256_ps128(tmp),_mm256_castps256_ps128(tmp)), 1);\n//   return _mm256_unpacklo_ps(tmp,tmp);\n  \n  // _mm256_insertf128_ps is very slow on Haswell, thus:\n  Packet8f tmp = _mm256_broadcast_ps((const __m128*)(const void*)from);\n  // mimic an \"inplace\" permutation of the lower 128bits using a blend\n  tmp = _mm256_blend_ps(tmp,_mm256_castps128_ps256(_mm_permute_ps( _mm256_castps256_ps128(tmp), _MM_SHUFFLE(1,0,1,0))), 15);\n  // then we can perform a consistent permutation on the global register to get everything in shape:\n  return  _mm256_permute_ps(tmp, _MM_SHUFFLE(3,3,2,2));\n}\n// Loads 2 doubles from memory a returns the packet {a0, a0  a1, a1}\ntemplate<> EIGEN_STRONG_INLINE Packet4d ploaddup<Packet4d>(const double* from)\n{\n  Packet4d tmp = _mm256_broadcast_pd((const __m128d*)(const void*)from);\n  return  _mm256_permute_pd(tmp, 3<<2);\n}\n\n// Loads 2 floats from memory a returns the packet {a0, a0  a0, a0, a1, a1, a1, a1}\ntemplate<> EIGEN_STRONG_INLINE Packet8f ploadquad<Packet8f>(const float* from)\n{\n  Packet8f tmp = _mm256_castps128_ps256(_mm_broadcast_ss(from));\n  return _mm256_insertf128_ps(tmp, _mm_broadcast_ss(from+1), 1);\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<float>(float*   to, const Packet8f& from) { EIGEN_DEBUG_ALIGNED_STORE _mm256_store_ps(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstore<double>(double* to, const Packet4d& from) { EIGEN_DEBUG_ALIGNED_STORE _mm256_store_pd(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstore<int>(int*       to, const Packet8i& from) { EIGEN_DEBUG_ALIGNED_STORE _mm256_storeu_si256(reinterpret_cast<__m256i*>(to), from); }\n\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<float>(float*   to, const Packet8f& from) { EIGEN_DEBUG_UNALIGNED_STORE _mm256_storeu_ps(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<double>(double* to, const Packet4d& from) { EIGEN_DEBUG_UNALIGNED_STORE _mm256_storeu_pd(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<int>(int*       to, const Packet8i& from) { EIGEN_DEBUG_UNALIGNED_STORE _mm256_storeu_si256(reinterpret_cast<__m256i*>(to), from); }\n\n// NOTE: leverage _mm256_i32gather_ps and _mm256_i32gather_pd if AVX2 instructions are available\n// NOTE: for the record the following seems to be slower: return _mm256_i32gather_ps(from, _mm256_set1_epi32(stride), 4);\ntemplate<> EIGEN_DEVICE_FUNC inline Packet8f pgather<float, Packet8f>(const float* from, Index stride)\n{\n  return _mm256_set_ps(from[7*stride], from[6*stride], from[5*stride], from[4*stride],\n                       from[3*stride], from[2*stride], from[1*stride], from[0*stride]);\n}\ntemplate<> EIGEN_DEVICE_FUNC inline Packet4d pgather<double, Packet4d>(const double* from, Index stride)\n{\n  return _mm256_set_pd(from[3*stride], from[2*stride], from[1*stride], from[0*stride]);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet8f>(float* to, const Packet8f& from, Index stride)\n{\n  __m128 low = _mm256_extractf128_ps(from, 0);\n  to[stride*0] = _mm_cvtss_f32(low);\n  to[stride*1] = _mm_cvtss_f32(_mm_shuffle_ps(low, low, 1));\n  to[stride*2] = _mm_cvtss_f32(_mm_shuffle_ps(low, low, 2));\n  to[stride*3] = _mm_cvtss_f32(_mm_shuffle_ps(low, low, 3));\n\n  __m128 high = _mm256_extractf128_ps(from, 1);\n  to[stride*4] = _mm_cvtss_f32(high);\n  to[stride*5] = _mm_cvtss_f32(_mm_shuffle_ps(high, high, 1));\n  to[stride*6] = _mm_cvtss_f32(_mm_shuffle_ps(high, high, 2));\n  to[stride*7] = _mm_cvtss_f32(_mm_shuffle_ps(high, high, 3));\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet4d>(double* to, const Packet4d& from, Index stride)\n{\n  __m128d low = _mm256_extractf128_pd(from, 0);\n  to[stride*0] = _mm_cvtsd_f64(low);\n  to[stride*1] = _mm_cvtsd_f64(_mm_shuffle_pd(low, low, 1));\n  __m128d high = _mm256_extractf128_pd(from, 1);\n  to[stride*2] = _mm_cvtsd_f64(high);\n  to[stride*3] = _mm_cvtsd_f64(_mm_shuffle_pd(high, high, 1));\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore1<Packet8f>(float* to, const float& a)\n{\n  Packet8f pa = pset1<Packet8f>(a);\n  pstore(to, pa);\n}\ntemplate<> EIGEN_STRONG_INLINE void pstore1<Packet4d>(double* to, const double& a)\n{\n  Packet4d pa = pset1<Packet4d>(a);\n  pstore(to, pa);\n}\ntemplate<> EIGEN_STRONG_INLINE void pstore1<Packet8i>(int* to, const int& a)\n{\n  Packet8i pa = pset1<Packet8i>(a);\n  pstore(to, pa);\n}\n\n#ifndef EIGEN_VECTORIZE_AVX512\ntemplate<> EIGEN_STRONG_INLINE void prefetch<float>(const float*   addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }\ntemplate<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }\ntemplate<> EIGEN_STRONG_INLINE void prefetch<int>(const int*       addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }\n#endif\n\ntemplate<> EIGEN_STRONG_INLINE float  pfirst<Packet8f>(const Packet8f& a) {\n  return _mm_cvtss_f32(_mm256_castps256_ps128(a));\n}\ntemplate<> EIGEN_STRONG_INLINE double pfirst<Packet4d>(const Packet4d& a) {\n  return _mm_cvtsd_f64(_mm256_castpd256_pd128(a));\n}\ntemplate<> EIGEN_STRONG_INLINE int    pfirst<Packet8i>(const Packet8i& a) {\n  return _mm_cvtsi128_si32(_mm256_castsi256_si128(a));\n}\n\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f preverse(const Packet8f& a)\n{\n  __m256 tmp = _mm256_shuffle_ps(a,a,0x1b);\n  return _mm256_permute2f128_ps(tmp, tmp, 1);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4d preverse(const Packet4d& a)\n{\n   __m256d tmp = _mm256_shuffle_pd(a,a,5);\n  return _mm256_permute2f128_pd(tmp, tmp, 1);\n\n  __m256d swap_halves = _mm256_permute2f128_pd(a,a,1);\n    return _mm256_permute_pd(swap_halves,5);\n}\n\n// pabs should be ok\ntemplate<> EIGEN_STRONG_INLINE Packet8f pabs(const Packet8f& a)\n{\n  const Packet8f mask = _mm256_castsi256_ps(_mm256_setr_epi32(0x7FFFFFFF,0x7FFFFFFF,0x7FFFFFFF,0x7FFFFFFF,0x7FFFFFFF,0x7FFFFFFF,0x7FFFFFFF,0x7FFFFFFF));\n  return _mm256_and_ps(a,mask);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4d pabs(const Packet4d& a)\n{\n  const Packet4d mask = _mm256_castsi256_pd(_mm256_setr_epi32(0xFFFFFFFF,0x7FFFFFFF,0xFFFFFFFF,0x7FFFFFFF,0xFFFFFFFF,0x7FFFFFFF,0xFFFFFFFF,0x7FFFFFFF));\n  return _mm256_and_pd(a,mask);\n}\n\n// preduxp should be ok\n// FIXME: why is this ok? why isn't the simply implementation working as expected?\ntemplate<> EIGEN_STRONG_INLINE Packet8f preduxp<Packet8f>(const Packet8f* vecs)\n{\n    __m256 hsum1 = _mm256_hadd_ps(vecs[0], vecs[1]);\n    __m256 hsum2 = _mm256_hadd_ps(vecs[2], vecs[3]);\n    __m256 hsum3 = _mm256_hadd_ps(vecs[4], vecs[5]);\n    __m256 hsum4 = _mm256_hadd_ps(vecs[6], vecs[7]);\n\n    __m256 hsum5 = _mm256_hadd_ps(hsum1, hsum1);\n    __m256 hsum6 = _mm256_hadd_ps(hsum2, hsum2);\n    __m256 hsum7 = _mm256_hadd_ps(hsum3, hsum3);\n    __m256 hsum8 = _mm256_hadd_ps(hsum4, hsum4);\n\n    __m256 perm1 =  _mm256_permute2f128_ps(hsum5, hsum5, 0x23);\n    __m256 perm2 =  _mm256_permute2f128_ps(hsum6, hsum6, 0x23);\n    __m256 perm3 =  _mm256_permute2f128_ps(hsum7, hsum7, 0x23);\n    __m256 perm4 =  _mm256_permute2f128_ps(hsum8, hsum8, 0x23);\n\n    __m256 sum1 = _mm256_add_ps(perm1, hsum5);\n    __m256 sum2 = _mm256_add_ps(perm2, hsum6);\n    __m256 sum3 = _mm256_add_ps(perm3, hsum7);\n    __m256 sum4 = _mm256_add_ps(perm4, hsum8);\n\n    __m256 blend1 = _mm256_blend_ps(sum1, sum2, 0xcc);\n    __m256 blend2 = _mm256_blend_ps(sum3, sum4, 0xcc);\n\n    __m256 final = _mm256_blend_ps(blend1, blend2, 0xf0);\n    return final;\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4d preduxp<Packet4d>(const Packet4d* vecs)\n{\n Packet4d tmp0, tmp1;\n\n  tmp0 = _mm256_hadd_pd(vecs[0], vecs[1]);\n  tmp0 = _mm256_add_pd(tmp0, _mm256_permute2f128_pd(tmp0, tmp0, 1));\n\n  tmp1 = _mm256_hadd_pd(vecs[2], vecs[3]);\n  tmp1 = _mm256_add_pd(tmp1, _mm256_permute2f128_pd(tmp1, tmp1, 1));\n\n  return _mm256_blend_pd(tmp0, tmp1, 0xC);\n}\n\ntemplate<> EIGEN_STRONG_INLINE float predux<Packet8f>(const Packet8f& a)\n{\n  return predux(Packet4f(_mm_add_ps(_mm256_castps256_ps128(a),_mm256_extractf128_ps(a,1))));\n}\ntemplate<> EIGEN_STRONG_INLINE double predux<Packet4d>(const Packet4d& a)\n{\n  return predux(Packet2d(_mm_add_pd(_mm256_castpd256_pd128(a),_mm256_extractf128_pd(a,1))));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f predux_downto4<Packet8f>(const Packet8f& a)\n{\n  return _mm_add_ps(_mm256_castps256_ps128(a),_mm256_extractf128_ps(a,1));\n}\n\ntemplate<> EIGEN_STRONG_INLINE float predux_mul<Packet8f>(const Packet8f& a)\n{\n  Packet8f tmp;\n  tmp = _mm256_mul_ps(a, _mm256_permute2f128_ps(a,a,1));\n  tmp = _mm256_mul_ps(tmp, _mm256_shuffle_ps(tmp,tmp,_MM_SHUFFLE(1,0,3,2)));\n  return pfirst(_mm256_mul_ps(tmp, _mm256_shuffle_ps(tmp,tmp,1)));\n}\ntemplate<> EIGEN_STRONG_INLINE double predux_mul<Packet4d>(const Packet4d& a)\n{\n  Packet4d tmp;\n  tmp = _mm256_mul_pd(a, _mm256_permute2f128_pd(a,a,1));\n  return pfirst(_mm256_mul_pd(tmp, _mm256_shuffle_pd(tmp,tmp,1)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE float predux_min<Packet8f>(const Packet8f& a)\n{\n  Packet8f tmp = _mm256_min_ps(a, _mm256_permute2f128_ps(a,a,1));\n  tmp = _mm256_min_ps(tmp, _mm256_shuffle_ps(tmp,tmp,_MM_SHUFFLE(1,0,3,2)));\n  return pfirst(_mm256_min_ps(tmp, _mm256_shuffle_ps(tmp,tmp,1)));\n}\ntemplate<> EIGEN_STRONG_INLINE double predux_min<Packet4d>(const Packet4d& a)\n{\n  Packet4d tmp = _mm256_min_pd(a, _mm256_permute2f128_pd(a,a,1));\n  return pfirst(_mm256_min_pd(tmp, _mm256_shuffle_pd(tmp, tmp, 1)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE float predux_max<Packet8f>(const Packet8f& a)\n{\n  Packet8f tmp = _mm256_max_ps(a, _mm256_permute2f128_ps(a,a,1));\n  tmp = _mm256_max_ps(tmp, _mm256_shuffle_ps(tmp,tmp,_MM_SHUFFLE(1,0,3,2)));\n  return pfirst(_mm256_max_ps(tmp, _mm256_shuffle_ps(tmp,tmp,1)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE double predux_max<Packet4d>(const Packet4d& a)\n{\n  Packet4d tmp = _mm256_max_pd(a, _mm256_permute2f128_pd(a,a,1));\n  return pfirst(_mm256_max_pd(tmp, _mm256_shuffle_pd(tmp, tmp, 1)));\n}\n\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet8f>\n{\n  static EIGEN_STRONG_INLINE void run(Packet8f& first, const Packet8f& second)\n  {\n    if (Offset==1)\n    {\n      first = _mm256_blend_ps(first, second, 1);\n      Packet8f tmp1 = _mm256_permute_ps (first, _MM_SHUFFLE(0,3,2,1));\n      Packet8f tmp2 = _mm256_permute2f128_ps (tmp1, tmp1, 1);\n      first = _mm256_blend_ps(tmp1, tmp2, 0x88);\n    }\n    else if (Offset==2)\n    {\n      first = _mm256_blend_ps(first, second, 3);\n      Packet8f tmp1 = _mm256_permute_ps (first, _MM_SHUFFLE(1,0,3,2));\n      Packet8f tmp2 = _mm256_permute2f128_ps (tmp1, tmp1, 1);\n      first = _mm256_blend_ps(tmp1, tmp2, 0xcc);\n    }\n    else if (Offset==3)\n    {\n      first = _mm256_blend_ps(first, second, 7);\n      Packet8f tmp1 = _mm256_permute_ps (first, _MM_SHUFFLE(2,1,0,3));\n      Packet8f tmp2 = _mm256_permute2f128_ps (tmp1, tmp1, 1);\n      first = _mm256_blend_ps(tmp1, tmp2, 0xee);\n    }\n    else if (Offset==4)\n    {\n      first = _mm256_blend_ps(first, second, 15);\n      Packet8f tmp1 = _mm256_permute_ps (first, _MM_SHUFFLE(3,2,1,0));\n      Packet8f tmp2 = _mm256_permute2f128_ps (tmp1, tmp1, 1);\n      first = _mm256_permute_ps(tmp2, _MM_SHUFFLE(3,2,1,0));\n    }\n    else if (Offset==5)\n    {\n      first = _mm256_blend_ps(first, second, 31);\n      first = _mm256_permute2f128_ps(first, first, 1);\n      Packet8f tmp = _mm256_permute_ps (first, _MM_SHUFFLE(0,3,2,1));\n      first = _mm256_permute2f128_ps(tmp, tmp, 1);\n      first = _mm256_blend_ps(tmp, first, 0x88);\n    }\n    else if (Offset==6)\n    {\n      first = _mm256_blend_ps(first, second, 63);\n      first = _mm256_permute2f128_ps(first, first, 1);\n      Packet8f tmp = _mm256_permute_ps (first, _MM_SHUFFLE(1,0,3,2));\n      first = _mm256_permute2f128_ps(tmp, tmp, 1);\n      first = _mm256_blend_ps(tmp, first, 0xcc);\n    }\n    else if (Offset==7)\n    {\n      first = _mm256_blend_ps(first, second, 127);\n      first = _mm256_permute2f128_ps(first, first, 1);\n      Packet8f tmp = _mm256_permute_ps (first, _MM_SHUFFLE(2,1,0,3));\n      first = _mm256_permute2f128_ps(tmp, tmp, 1);\n      first = _mm256_blend_ps(tmp, first, 0xee);\n    }\n  }\n};\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet4d>\n{\n  static EIGEN_STRONG_INLINE void run(Packet4d& first, const Packet4d& second)\n  {\n    if (Offset==1)\n    {\n      first = _mm256_blend_pd(first, second, 1);\n      __m256d tmp = _mm256_permute_pd(first, 5);\n      first = _mm256_permute2f128_pd(tmp, tmp, 1);\n      first = _mm256_blend_pd(tmp, first, 0xA);\n    }\n    else if (Offset==2)\n    {\n      first = _mm256_blend_pd(first, second, 3);\n      first = _mm256_permute2f128_pd(first, first, 1);\n    }\n    else if (Offset==3)\n    {\n      first = _mm256_blend_pd(first, second, 7);\n      __m256d tmp = _mm256_permute_pd(first, 5);\n      first = _mm256_permute2f128_pd(tmp, tmp, 1);\n      first = _mm256_blend_pd(tmp, first, 5);\n    }\n  }\n};\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet8f,8>& kernel) {\n  __m256 T0 = _mm256_unpacklo_ps(kernel.packet[0], kernel.packet[1]);\n  __m256 T1 = _mm256_unpackhi_ps(kernel.packet[0], kernel.packet[1]);\n  __m256 T2 = _mm256_unpacklo_ps(kernel.packet[2], kernel.packet[3]);\n  __m256 T3 = _mm256_unpackhi_ps(kernel.packet[2], kernel.packet[3]);\n  __m256 T4 = _mm256_unpacklo_ps(kernel.packet[4], kernel.packet[5]);\n  __m256 T5 = _mm256_unpackhi_ps(kernel.packet[4], kernel.packet[5]);\n  __m256 T6 = _mm256_unpacklo_ps(kernel.packet[6], kernel.packet[7]);\n  __m256 T7 = _mm256_unpackhi_ps(kernel.packet[6], kernel.packet[7]);\n  __m256 S0 = _mm256_shuffle_ps(T0,T2,_MM_SHUFFLE(1,0,1,0));\n  __m256 S1 = _mm256_shuffle_ps(T0,T2,_MM_SHUFFLE(3,2,3,2));\n  __m256 S2 = _mm256_shuffle_ps(T1,T3,_MM_SHUFFLE(1,0,1,0));\n  __m256 S3 = _mm256_shuffle_ps(T1,T3,_MM_SHUFFLE(3,2,3,2));\n  __m256 S4 = _mm256_shuffle_ps(T4,T6,_MM_SHUFFLE(1,0,1,0));\n  __m256 S5 = _mm256_shuffle_ps(T4,T6,_MM_SHUFFLE(3,2,3,2));\n  __m256 S6 = _mm256_shuffle_ps(T5,T7,_MM_SHUFFLE(1,0,1,0));\n  __m256 S7 = _mm256_shuffle_ps(T5,T7,_MM_SHUFFLE(3,2,3,2));\n  kernel.packet[0] = _mm256_permute2f128_ps(S0, S4, 0x20);\n  kernel.packet[1] = _mm256_permute2f128_ps(S1, S5, 0x20);\n  kernel.packet[2] = _mm256_permute2f128_ps(S2, S6, 0x20);\n  kernel.packet[3] = _mm256_permute2f128_ps(S3, S7, 0x20);\n  kernel.packet[4] = _mm256_permute2f128_ps(S0, S4, 0x31);\n  kernel.packet[5] = _mm256_permute2f128_ps(S1, S5, 0x31);\n  kernel.packet[6] = _mm256_permute2f128_ps(S2, S6, 0x31);\n  kernel.packet[7] = _mm256_permute2f128_ps(S3, S7, 0x31);\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet8f,4>& kernel) {\n  __m256 T0 = _mm256_unpacklo_ps(kernel.packet[0], kernel.packet[1]);\n  __m256 T1 = _mm256_unpackhi_ps(kernel.packet[0], kernel.packet[1]);\n  __m256 T2 = _mm256_unpacklo_ps(kernel.packet[2], kernel.packet[3]);\n  __m256 T3 = _mm256_unpackhi_ps(kernel.packet[2], kernel.packet[3]);\n\n  __m256 S0 = _mm256_shuffle_ps(T0,T2,_MM_SHUFFLE(1,0,1,0));\n  __m256 S1 = _mm256_shuffle_ps(T0,T2,_MM_SHUFFLE(3,2,3,2));\n  __m256 S2 = _mm256_shuffle_ps(T1,T3,_MM_SHUFFLE(1,0,1,0));\n  __m256 S3 = _mm256_shuffle_ps(T1,T3,_MM_SHUFFLE(3,2,3,2));\n\n  kernel.packet[0] = _mm256_permute2f128_ps(S0, S1, 0x20);\n  kernel.packet[1] = _mm256_permute2f128_ps(S2, S3, 0x20);\n  kernel.packet[2] = _mm256_permute2f128_ps(S0, S1, 0x31);\n  kernel.packet[3] = _mm256_permute2f128_ps(S2, S3, 0x31);\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet4d,4>& kernel) {\n  __m256d T0 = _mm256_shuffle_pd(kernel.packet[0], kernel.packet[1], 15);\n  __m256d T1 = _mm256_shuffle_pd(kernel.packet[0], kernel.packet[1], 0);\n  __m256d T2 = _mm256_shuffle_pd(kernel.packet[2], kernel.packet[3], 15);\n  __m256d T3 = _mm256_shuffle_pd(kernel.packet[2], kernel.packet[3], 0);\n\n  kernel.packet[1] = _mm256_permute2f128_pd(T0, T2, 32);\n  kernel.packet[3] = _mm256_permute2f128_pd(T0, T2, 49);\n  kernel.packet[0] = _mm256_permute2f128_pd(T1, T3, 32);\n  kernel.packet[2] = _mm256_permute2f128_pd(T1, T3, 49);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pblend(const Selector<8>& ifPacket, const Packet8f& thenPacket, const Packet8f& elsePacket) {\n  const __m256 zero = _mm256_setzero_ps();\n  const __m256 select = _mm256_set_ps(ifPacket.select[7], ifPacket.select[6], ifPacket.select[5], ifPacket.select[4], ifPacket.select[3], ifPacket.select[2], ifPacket.select[1], ifPacket.select[0]);\n  __m256 false_mask = _mm256_cmp_ps(select, zero, _CMP_EQ_UQ);\n  return _mm256_blendv_ps(thenPacket, elsePacket, false_mask);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4d pblend(const Selector<4>& ifPacket, const Packet4d& thenPacket, const Packet4d& elsePacket) {\n  const __m256d zero = _mm256_setzero_pd();\n  const __m256d select = _mm256_set_pd(ifPacket.select[3], ifPacket.select[2], ifPacket.select[1], ifPacket.select[0]);\n  __m256d false_mask = _mm256_cmp_pd(select, zero, _CMP_EQ_UQ);\n  return _mm256_blendv_pd(thenPacket, elsePacket, false_mask);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pinsertfirst(const Packet8f& a, float b)\n{\n  return _mm256_blend_ps(a,pset1<Packet8f>(b),1);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4d pinsertfirst(const Packet4d& a, double b)\n{\n  return _mm256_blend_pd(a,pset1<Packet4d>(b),1);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pinsertlast(const Packet8f& a, float b)\n{\n  return _mm256_blend_ps(a,pset1<Packet8f>(b),(1<<7));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4d pinsertlast(const Packet4d& a, double b)\n{\n  return _mm256_blend_pd(a,pset1<Packet4d>(b),(1<<3));\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_PACKET_MATH_AVX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/AVX/TypeCasting.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2015 Benoit Steiner <benoit.steiner.goog@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TYPE_CASTING_AVX_H\n#define EIGEN_TYPE_CASTING_AVX_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n// For now we use SSE to handle integers, so we can't use AVX instructions to cast\n// from int to float\ntemplate <>\nstruct type_casting_traits<float, int> {\n  enum {\n    VectorizedCast = 0,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 1\n  };\n};\n\ntemplate <>\nstruct type_casting_traits<int, float> {\n  enum {\n    VectorizedCast = 0,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 1\n  };\n};\n\n\n\ntemplate<> EIGEN_STRONG_INLINE Packet8i pcast<Packet8f, Packet8i>(const Packet8f& a) {\n  return _mm256_cvtps_epi32(a);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pcast<Packet8i, Packet8f>(const Packet8i& a) {\n  return _mm256_cvtepi32_ps(a);\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TYPE_CASTING_AVX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/AVX512/MathFunctions.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2016 Pedro Gonnet (pedro.gonnet@gmail.com)\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef THIRD_PARTY_EIGEN3_EIGEN_SRC_CORE_ARCH_AVX512_MATHFUNCTIONS_H_\n#define THIRD_PARTY_EIGEN3_EIGEN_SRC_CORE_ARCH_AVX512_MATHFUNCTIONS_H_\n\nnamespace Eigen {\n\nnamespace internal {\n\n// Disable the code for older versions of gcc that don't support many of the required avx512 instrinsics.\n#if EIGEN_GNUC_AT_LEAST(5, 3)\n\n#define _EIGEN_DECLARE_CONST_Packet16f(NAME, X) \\\n  const Packet16f p16f_##NAME = pset1<Packet16f>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet16f_FROM_INT(NAME, X) \\\n  const Packet16f p16f_##NAME = (__m512)pset1<Packet16i>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet8d(NAME, X) \\\n  const Packet8d p8d_##NAME = pset1<Packet8d>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet8d_FROM_INT64(NAME, X) \\\n  const Packet8d p8d_##NAME = _mm512_castsi512_pd(_mm512_set1_epi64(X))\n\n// Natural logarithm\n// Computes log(x) as log(2^e * m) = C*e + log(m), where the constant C =log(2)\n// and m is in the range [sqrt(1/2),sqrt(2)). In this range, the logarithm can\n// be easily approximated by a polynomial centered on m=1 for stability.\n#if defined(EIGEN_VECTORIZE_AVX512DQ)\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet16f\nplog<Packet16f>(const Packet16f& _x) {\n  Packet16f x = _x;\n  _EIGEN_DECLARE_CONST_Packet16f(1, 1.0f);\n  _EIGEN_DECLARE_CONST_Packet16f(half, 0.5f);\n  _EIGEN_DECLARE_CONST_Packet16f(126f, 126.0f);\n\n  _EIGEN_DECLARE_CONST_Packet16f_FROM_INT(inv_mant_mask, ~0x7f800000);\n\n  // The smallest non denormalized float number.\n  _EIGEN_DECLARE_CONST_Packet16f_FROM_INT(min_norm_pos, 0x00800000);\n  _EIGEN_DECLARE_CONST_Packet16f_FROM_INT(minus_inf, 0xff800000);\n  _EIGEN_DECLARE_CONST_Packet16f_FROM_INT(nan, 0x7fc00000);\n\n  // Polynomial coefficients.\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_SQRTHF, 0.707106781186547524f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_log_p0, 7.0376836292E-2f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_log_p1, -1.1514610310E-1f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_log_p2, 1.1676998740E-1f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_log_p3, -1.2420140846E-1f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_log_p4, +1.4249322787E-1f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_log_p5, -1.6668057665E-1f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_log_p6, +2.0000714765E-1f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_log_p7, -2.4999993993E-1f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_log_p8, +3.3333331174E-1f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_log_q1, -2.12194440e-4f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_log_q2, 0.693359375f);\n\n  // invalid_mask is set to true when x is NaN\n  __mmask16 invalid_mask =\n      _mm512_cmp_ps_mask(x, _mm512_setzero_ps(), _CMP_NGE_UQ);\n  __mmask16 iszero_mask =\n      _mm512_cmp_ps_mask(x, _mm512_setzero_ps(), _CMP_EQ_UQ);\n\n  // Truncate input values to the minimum positive normal.\n  x = pmax(x, p16f_min_norm_pos);\n\n  // Extract the shifted exponents.\n  Packet16f emm0 = _mm512_cvtepi32_ps(_mm512_srli_epi32((__m512i)x, 23));\n  Packet16f e = _mm512_sub_ps(emm0, p16f_126f);\n\n  // Set the exponents to -1, i.e. x are in the range [0.5,1).\n  x = _mm512_and_ps(x, p16f_inv_mant_mask);\n  x = _mm512_or_ps(x, p16f_half);\n\n  // part2: Shift the inputs from the range [0.5,1) to [sqrt(1/2),sqrt(2))\n  // and shift by -1. The values are then centered around 0, which improves\n  // the stability of the polynomial evaluation.\n  //   if( x < SQRTHF ) {\n  //     e -= 1;\n  //     x = x + x - 1.0;\n  //   } else { x = x - 1.0; }\n  __mmask16 mask = _mm512_cmp_ps_mask(x, p16f_cephes_SQRTHF, _CMP_LT_OQ);\n  Packet16f tmp = _mm512_mask_blend_ps(mask, x, _mm512_setzero_ps());\n  x = psub(x, p16f_1);\n  e = psub(e, _mm512_mask_blend_ps(mask, p16f_1, _mm512_setzero_ps()));\n  x = padd(x, tmp);\n\n  Packet16f x2 = pmul(x, x);\n  Packet16f x3 = pmul(x2, x);\n\n  // Evaluate the polynomial approximant of degree 8 in three parts, probably\n  // to improve instruction-level parallelism.\n  Packet16f y, y1, y2;\n  y = pmadd(p16f_cephes_log_p0, x, p16f_cephes_log_p1);\n  y1 = pmadd(p16f_cephes_log_p3, x, p16f_cephes_log_p4);\n  y2 = pmadd(p16f_cephes_log_p6, x, p16f_cephes_log_p7);\n  y = pmadd(y, x, p16f_cephes_log_p2);\n  y1 = pmadd(y1, x, p16f_cephes_log_p5);\n  y2 = pmadd(y2, x, p16f_cephes_log_p8);\n  y = pmadd(y, x3, y1);\n  y = pmadd(y, x3, y2);\n  y = pmul(y, x3);\n\n  // Add the logarithm of the exponent back to the result of the interpolation.\n  y1 = pmul(e, p16f_cephes_log_q1);\n  tmp = pmul(x2, p16f_half);\n  y = padd(y, y1);\n  x = psub(x, tmp);\n  y2 = pmul(e, p16f_cephes_log_q2);\n  x = padd(x, y);\n  x = padd(x, y2);\n\n  // Filter out invalid inputs, i.e. negative arg will be NAN, 0 will be -INF.\n  return _mm512_mask_blend_ps(iszero_mask, p16f_minus_inf,\n                              _mm512_mask_blend_ps(invalid_mask, p16f_nan, x));\n}\n#endif\n\n// Exponential function. Works by writing \"x = m*log(2) + r\" where\n// \"m = floor(x/log(2)+1/2)\" and \"r\" is the remainder. The result is then\n// \"exp(x) = 2^m*exp(r)\" where exp(r) is in the range [-1,1).\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet16f\npexp<Packet16f>(const Packet16f& _x) {\n  _EIGEN_DECLARE_CONST_Packet16f(1, 1.0f);\n  _EIGEN_DECLARE_CONST_Packet16f(half, 0.5f);\n  _EIGEN_DECLARE_CONST_Packet16f(127, 127.0f);\n\n  _EIGEN_DECLARE_CONST_Packet16f(exp_hi, 88.3762626647950f);\n  _EIGEN_DECLARE_CONST_Packet16f(exp_lo, -88.3762626647949f);\n\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_LOG2EF, 1.44269504088896341f);\n\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_exp_p0, 1.9875691500E-4f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_exp_p1, 1.3981999507E-3f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_exp_p2, 8.3334519073E-3f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_exp_p3, 4.1665795894E-2f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_exp_p4, 1.6666665459E-1f);\n  _EIGEN_DECLARE_CONST_Packet16f(cephes_exp_p5, 5.0000001201E-1f);\n\n  // Clamp x.\n  Packet16f x = pmax(pmin(_x, p16f_exp_hi), p16f_exp_lo);\n\n  // Express exp(x) as exp(m*ln(2) + r), start by extracting\n  // m = floor(x/ln(2) + 0.5).\n  Packet16f m = _mm512_floor_ps(pmadd(x, p16f_cephes_LOG2EF, p16f_half));\n\n  // Get r = x - m*ln(2). Note that we can do this without losing more than one\n  // ulp precision due to the FMA instruction.\n  _EIGEN_DECLARE_CONST_Packet16f(nln2, -0.6931471805599453f);\n  Packet16f r = _mm512_fmadd_ps(m, p16f_nln2, x);\n  Packet16f r2 = pmul(r, r);\n\n  // TODO(gonnet): Split into odd/even polynomials and try to exploit\n  //               instruction-level parallelism.\n  Packet16f y = p16f_cephes_exp_p0;\n  y = pmadd(y, r, p16f_cephes_exp_p1);\n  y = pmadd(y, r, p16f_cephes_exp_p2);\n  y = pmadd(y, r, p16f_cephes_exp_p3);\n  y = pmadd(y, r, p16f_cephes_exp_p4);\n  y = pmadd(y, r, p16f_cephes_exp_p5);\n  y = pmadd(y, r2, r);\n  y = padd(y, p16f_1);\n\n  // Build emm0 = 2^m.\n  Packet16i emm0 = _mm512_cvttps_epi32(padd(m, p16f_127));\n  emm0 = _mm512_slli_epi32(emm0, 23);\n\n  // Return 2^m * exp(r).\n  return pmax(pmul(y, _mm512_castsi512_ps(emm0)), _x);\n}\n\n/*template <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet8d\npexp<Packet8d>(const Packet8d& _x) {\n  Packet8d x = _x;\n\n  _EIGEN_DECLARE_CONST_Packet8d(1, 1.0);\n  _EIGEN_DECLARE_CONST_Packet8d(2, 2.0);\n\n  _EIGEN_DECLARE_CONST_Packet8d(exp_hi, 709.437);\n  _EIGEN_DECLARE_CONST_Packet8d(exp_lo, -709.436139303);\n\n  _EIGEN_DECLARE_CONST_Packet8d(cephes_LOG2EF, 1.4426950408889634073599);\n\n  _EIGEN_DECLARE_CONST_Packet8d(cephes_exp_p0, 1.26177193074810590878e-4);\n  _EIGEN_DECLARE_CONST_Packet8d(cephes_exp_p1, 3.02994407707441961300e-2);\n  _EIGEN_DECLARE_CONST_Packet8d(cephes_exp_p2, 9.99999999999999999910e-1);\n\n  _EIGEN_DECLARE_CONST_Packet8d(cephes_exp_q0, 3.00198505138664455042e-6);\n  _EIGEN_DECLARE_CONST_Packet8d(cephes_exp_q1, 2.52448340349684104192e-3);\n  _EIGEN_DECLARE_CONST_Packet8d(cephes_exp_q2, 2.27265548208155028766e-1);\n  _EIGEN_DECLARE_CONST_Packet8d(cephes_exp_q3, 2.00000000000000000009e0);\n\n  _EIGEN_DECLARE_CONST_Packet8d(cephes_exp_C1, 0.693145751953125);\n  _EIGEN_DECLARE_CONST_Packet8d(cephes_exp_C2, 1.42860682030941723212e-6);\n\n  // clamp x\n  x = pmax(pmin(x, p8d_exp_hi), p8d_exp_lo);\n\n  // Express exp(x) as exp(g + n*log(2)).\n  const Packet8d n =\n      _mm512_mul_round_pd(p8d_cephes_LOG2EF, x, _MM_FROUND_TO_NEAREST_INT);\n\n  // Get the remainder modulo log(2), i.e. the \"g\" described above. Subtract\n  // n*log(2) out in two steps, i.e. n*C1 + n*C2, C1+C2=log2 to get the last\n  // digits right.\n  const Packet8d nC1 = pmul(n, p8d_cephes_exp_C1);\n  const Packet8d nC2 = pmul(n, p8d_cephes_exp_C2);\n  x = psub(x, nC1);\n  x = psub(x, nC2);\n\n  const Packet8d x2 = pmul(x, x);\n\n  // Evaluate the numerator polynomial of the rational interpolant.\n  Packet8d px = p8d_cephes_exp_p0;\n  px = pmadd(px, x2, p8d_cephes_exp_p1);\n  px = pmadd(px, x2, p8d_cephes_exp_p2);\n  px = pmul(px, x);\n\n  // Evaluate the denominator polynomial of the rational interpolant.\n  Packet8d qx = p8d_cephes_exp_q0;\n  qx = pmadd(qx, x2, p8d_cephes_exp_q1);\n  qx = pmadd(qx, x2, p8d_cephes_exp_q2);\n  qx = pmadd(qx, x2, p8d_cephes_exp_q3);\n\n  // I don't really get this bit, copied from the SSE2 routines, so...\n  // TODO(gonnet): Figure out what is going on here, perhaps find a better\n  // rational interpolant?\n  x = _mm512_div_pd(px, psub(qx, px));\n  x = pmadd(p8d_2, x, p8d_1);\n\n  // Build e=2^n.\n  const Packet8d e = _mm512_castsi512_pd(_mm512_slli_epi64(\n      _mm512_add_epi64(_mm512_cvtpd_epi64(n), _mm512_set1_epi64(1023)), 52));\n\n  // Construct the result 2^n * exp(g) = e * x. The max is used to catch\n  // non-finite values in the input.\n  return pmax(pmul(x, e), _x);\n  }*/\n\n// Functions for sqrt.\n// The EIGEN_FAST_MATH version uses the _mm_rsqrt_ps approximation and one step\n// of Newton's method, at a cost of 1-2 bits of precision as opposed to the\n// exact solution. The main advantage of this approach is not just speed, but\n// also the fact that it can be inlined and pipelined with other computations,\n// further reducing its effective latency.\n#if EIGEN_FAST_MATH\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet16f\npsqrt<Packet16f>(const Packet16f& _x) {\n  _EIGEN_DECLARE_CONST_Packet16f(one_point_five, 1.5f);\n  _EIGEN_DECLARE_CONST_Packet16f(minus_half, -0.5f);\n  _EIGEN_DECLARE_CONST_Packet16f_FROM_INT(flt_min, 0x00800000);\n\n  Packet16f neg_half = pmul(_x, p16f_minus_half);\n\n  // select only the inverse sqrt of positive normal inputs (denormals are\n  // flushed to zero and cause infs as well).\n  __mmask16 non_zero_mask = _mm512_cmp_ps_mask(_x, p16f_flt_min, _CMP_GE_OQ);\n  Packet16f x = _mm512_mask_blend_ps(non_zero_mask, _mm512_rsqrt14_ps(_x),\n                                     _mm512_setzero_ps());\n\n  // Do a single step of Newton's iteration.\n  x = pmul(x, pmadd(neg_half, pmul(x, x), p16f_one_point_five));\n\n  // Multiply the original _x by it's reciprocal square root to extract the\n  // square root.\n  return pmul(_x, x);\n}\n\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet8d\npsqrt<Packet8d>(const Packet8d& _x) {\n  _EIGEN_DECLARE_CONST_Packet8d(one_point_five, 1.5);\n  _EIGEN_DECLARE_CONST_Packet8d(minus_half, -0.5);\n  _EIGEN_DECLARE_CONST_Packet8d_FROM_INT64(dbl_min, 0x0010000000000000LL);\n\n  Packet8d neg_half = pmul(_x, p8d_minus_half);\n\n  // select only the inverse sqrt of positive normal inputs (denormals are\n  // flushed to zero and cause infs as well).\n  __mmask8 non_zero_mask = _mm512_cmp_pd_mask(_x, p8d_dbl_min, _CMP_GE_OQ);\n  Packet8d x = _mm512_mask_blend_pd(non_zero_mask, _mm512_rsqrt14_pd(_x),\n                                    _mm512_setzero_pd());\n\n  // Do a first step of Newton's iteration.\n  x = pmul(x, pmadd(neg_half, pmul(x, x), p8d_one_point_five));\n\n  // Do a second step of Newton's iteration.\n  x = pmul(x, pmadd(neg_half, pmul(x, x), p8d_one_point_five));\n\n  // Multiply the original _x by it's reciprocal square root to extract the\n  // square root.\n  return pmul(_x, x);\n}\n#else\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f psqrt<Packet16f>(const Packet16f& x) {\n  return _mm512_sqrt_ps(x);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d psqrt<Packet8d>(const Packet8d& x) {\n  return _mm512_sqrt_pd(x);\n}\n#endif\n\n// Functions for rsqrt.\n// Almost identical to the sqrt routine, just leave out the last multiplication\n// and fill in NaN/Inf where needed. Note that this function only exists as an\n// iterative version for doubles since there is no instruction for diretly\n// computing the reciprocal square root in AVX-512.\n#ifdef EIGEN_FAST_MATH\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet16f\nprsqrt<Packet16f>(const Packet16f& _x) {\n  _EIGEN_DECLARE_CONST_Packet16f_FROM_INT(inf, 0x7f800000);\n  _EIGEN_DECLARE_CONST_Packet16f_FROM_INT(nan, 0x7fc00000);\n  _EIGEN_DECLARE_CONST_Packet16f(one_point_five, 1.5f);\n  _EIGEN_DECLARE_CONST_Packet16f(minus_half, -0.5f);\n  _EIGEN_DECLARE_CONST_Packet16f_FROM_INT(flt_min, 0x00800000);\n\n  Packet16f neg_half = pmul(_x, p16f_minus_half);\n\n  // select only the inverse sqrt of positive normal inputs (denormals are\n  // flushed to zero and cause infs as well).\n  __mmask16 le_zero_mask = _mm512_cmp_ps_mask(_x, p16f_flt_min, _CMP_LT_OQ);\n  Packet16f x = _mm512_mask_blend_ps(le_zero_mask, _mm512_setzero_ps(),\n                                     _mm512_rsqrt14_ps(_x));\n\n  // Fill in NaNs and Infs for the negative/zero entries.\n  __mmask16 neg_mask = _mm512_cmp_ps_mask(_x, _mm512_setzero_ps(), _CMP_LT_OQ);\n  Packet16f infs_and_nans = _mm512_mask_blend_ps(\n      neg_mask, p16f_nan,\n      _mm512_mask_blend_ps(le_zero_mask, p16f_inf, _mm512_setzero_ps()));\n\n  // Do a single step of Newton's iteration.\n  x = pmul(x, pmadd(neg_half, pmul(x, x), p16f_one_point_five));\n\n  // Insert NaNs and Infs in all the right places.\n  return _mm512_mask_blend_ps(le_zero_mask, infs_and_nans, x);\n}\n\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet8d\nprsqrt<Packet8d>(const Packet8d& _x) {\n  _EIGEN_DECLARE_CONST_Packet8d_FROM_INT64(inf, 0x7ff0000000000000LL);\n  _EIGEN_DECLARE_CONST_Packet8d_FROM_INT64(nan, 0x7ff1000000000000LL);\n  _EIGEN_DECLARE_CONST_Packet8d(one_point_five, 1.5);\n  _EIGEN_DECLARE_CONST_Packet8d(minus_half, -0.5);\n  _EIGEN_DECLARE_CONST_Packet8d_FROM_INT64(dbl_min, 0x0010000000000000LL);\n\n  Packet8d neg_half = pmul(_x, p8d_minus_half);\n\n  // select only the inverse sqrt of positive normal inputs (denormals are\n  // flushed to zero and cause infs as well).\n  __mmask8 le_zero_mask = _mm512_cmp_pd_mask(_x, p8d_dbl_min, _CMP_LT_OQ);\n  Packet8d x = _mm512_mask_blend_pd(le_zero_mask, _mm512_setzero_pd(),\n                                    _mm512_rsqrt14_pd(_x));\n\n  // Fill in NaNs and Infs for the negative/zero entries.\n  __mmask8 neg_mask = _mm512_cmp_pd_mask(_x, _mm512_setzero_pd(), _CMP_LT_OQ);\n  Packet8d infs_and_nans = _mm512_mask_blend_pd(\n      neg_mask, p8d_nan,\n      _mm512_mask_blend_pd(le_zero_mask, p8d_inf, _mm512_setzero_pd()));\n\n  // Do a first step of Newton's iteration.\n  x = pmul(x, pmadd(neg_half, pmul(x, x), p8d_one_point_five));\n\n  // Do a second step of Newton's iteration.\n  x = pmul(x, pmadd(neg_half, pmul(x, x), p8d_one_point_five));\n\n  // Insert NaNs and Infs in all the right places.\n  return _mm512_mask_blend_pd(le_zero_mask, infs_and_nans, x);\n}\n#else\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f prsqrt<Packet16f>(const Packet16f& x) {\n  return _mm512_rsqrt28_ps(x);\n}\n#endif\n#endif\n\n}  // end namespace internal\n\n}  // end namespace Eigen\n\n#endif  // THIRD_PARTY_EIGEN3_EIGEN_SRC_CORE_ARCH_AVX512_MATHFUNCTIONS_H_\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/AVX512/PacketMath.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2016 Benoit Steiner (benoit.steiner.goog@gmail.com)\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PACKET_MATH_AVX512_H\n#define EIGEN_PACKET_MATH_AVX512_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD\n#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8\n#endif\n\n#ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS\n#define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS (2*sizeof(void*))\n#endif\n\n#ifdef __FMA__\n#ifndef EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n#define EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n#endif\n#endif\n\ntypedef __m512 Packet16f;\ntypedef __m512i Packet16i;\ntypedef __m512d Packet8d;\n\ntemplate <>\nstruct is_arithmetic<__m512> {\n  enum { value = true };\n};\ntemplate <>\nstruct is_arithmetic<__m512i> {\n  enum { value = true };\n};\ntemplate <>\nstruct is_arithmetic<__m512d> {\n  enum { value = true };\n};\n\ntemplate<> struct packet_traits<float>  : default_packet_traits\n{\n  typedef Packet16f type;\n  typedef Packet8f half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 16,\n    HasHalfPacket = 1,\n#if EIGEN_GNUC_AT_LEAST(5, 3)\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n    HasLog = 1,\n#endif\n    HasExp = 1,\n    HasSqrt = 1,\n    HasRsqrt = 1,\n#endif\n    HasDiv = 1\n  };\n };\ntemplate<> struct packet_traits<double> : default_packet_traits\n{\n  typedef Packet8d type;\n  typedef Packet4d half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 8,\n    HasHalfPacket = 1,\n#if EIGEN_GNUC_AT_LEAST(5, 3)\n    HasSqrt = 1,\n    HasRsqrt = EIGEN_FAST_MATH,\n#endif\n    HasDiv = 1\n  };\n};\n\n/* TODO Implement AVX512 for integers\ntemplate<> struct packet_traits<int>    : default_packet_traits\n{\n  typedef Packet16i type;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=8\n  };\n};\n*/\n\ntemplate <>\nstruct unpacket_traits<Packet16f> {\n  typedef float type;\n  typedef Packet8f half;\n  enum { size = 16, alignment=Aligned64 };\n};\ntemplate <>\nstruct unpacket_traits<Packet8d> {\n  typedef double type;\n  typedef Packet4d half;\n  enum { size = 8, alignment=Aligned64 };\n};\ntemplate <>\nstruct unpacket_traits<Packet16i> {\n  typedef int type;\n  typedef Packet8i half;\n  enum { size = 16, alignment=Aligned64 };\n};\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pset1<Packet16f>(const float& from) {\n  return _mm512_set1_ps(from);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pset1<Packet8d>(const double& from) {\n  return _mm512_set1_pd(from);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet16i pset1<Packet16i>(const int& from) {\n  return _mm512_set1_epi32(from);\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pload1<Packet16f>(const float* from) {\n  return _mm512_broadcastss_ps(_mm_load_ps1(from));\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pload1<Packet8d>(const double* from) {\n  return _mm512_broadcastsd_pd(_mm_load_pd1(from));\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f plset<Packet16f>(const float& a) {\n  return _mm512_add_ps(\n      _mm512_set1_ps(a),\n      _mm512_set_ps(15.0f, 14.0f, 13.0f, 12.0f, 11.0f, 10.0f, 9.0f, 8.0f, 7.0f, 6.0f, 5.0f,\n                    4.0f, 3.0f, 2.0f, 1.0f, 0.0f));\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d plset<Packet8d>(const double& a) {\n  return _mm512_add_pd(_mm512_set1_pd(a),\n                       _mm512_set_pd(7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0));\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f padd<Packet16f>(const Packet16f& a,\n                                              const Packet16f& b) {\n  return _mm512_add_ps(a, b);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d padd<Packet8d>(const Packet8d& a,\n                                            const Packet8d& b) {\n  return _mm512_add_pd(a, b);\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f psub<Packet16f>(const Packet16f& a,\n                                              const Packet16f& b) {\n  return _mm512_sub_ps(a, b);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d psub<Packet8d>(const Packet8d& a,\n                                            const Packet8d& b) {\n  return _mm512_sub_pd(a, b);\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pnegate(const Packet16f& a) {\n  return _mm512_sub_ps(_mm512_set1_ps(0.0), a);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pnegate(const Packet8d& a) {\n  return _mm512_sub_pd(_mm512_set1_pd(0.0), a);\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pconj(const Packet16f& a) {\n  return a;\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pconj(const Packet8d& a) {\n  return a;\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet16i pconj(const Packet16i& a) {\n  return a;\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pmul<Packet16f>(const Packet16f& a,\n                                              const Packet16f& b) {\n  return _mm512_mul_ps(a, b);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pmul<Packet8d>(const Packet8d& a,\n                                            const Packet8d& b) {\n  return _mm512_mul_pd(a, b);\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pdiv<Packet16f>(const Packet16f& a,\n                                              const Packet16f& b) {\n  return _mm512_div_ps(a, b);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pdiv<Packet8d>(const Packet8d& a,\n                                            const Packet8d& b) {\n  return _mm512_div_pd(a, b);\n}\n\n#ifdef __FMA__\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pmadd(const Packet16f& a, const Packet16f& b,\n                                    const Packet16f& c) {\n  return _mm512_fmadd_ps(a, b, c);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pmadd(const Packet8d& a, const Packet8d& b,\n                                   const Packet8d& c) {\n  return _mm512_fmadd_pd(a, b, c);\n}\n#endif\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pmin<Packet16f>(const Packet16f& a,\n                                              const Packet16f& b) {\n  return _mm512_min_ps(a, b);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pmin<Packet8d>(const Packet8d& a,\n                                            const Packet8d& b) {\n  return _mm512_min_pd(a, b);\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pmax<Packet16f>(const Packet16f& a,\n                                              const Packet16f& b) {\n  return _mm512_max_ps(a, b);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pmax<Packet8d>(const Packet8d& a,\n                                            const Packet8d& b) {\n  return _mm512_max_pd(a, b);\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pand<Packet16f>(const Packet16f& a,\n                                              const Packet16f& b) {\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n  return _mm512_and_ps(a, b);\n#else\n  Packet16f res = _mm512_undefined_ps();\n  Packet4f lane0_a = _mm512_extractf32x4_ps(a, 0);\n  Packet4f lane0_b = _mm512_extractf32x4_ps(b, 0);\n  res = _mm512_insertf32x4(res, _mm_and_ps(lane0_a, lane0_b), 0);\n\n  Packet4f lane1_a = _mm512_extractf32x4_ps(a, 1);\n  Packet4f lane1_b = _mm512_extractf32x4_ps(b, 1);\n  res = _mm512_insertf32x4(res, _mm_and_ps(lane1_a, lane1_b), 1);\n\n  Packet4f lane2_a = _mm512_extractf32x4_ps(a, 2);\n  Packet4f lane2_b = _mm512_extractf32x4_ps(b, 2);\n  res = _mm512_insertf32x4(res, _mm_and_ps(lane2_a, lane2_b), 2);\n\n  Packet4f lane3_a = _mm512_extractf32x4_ps(a, 3);\n  Packet4f lane3_b = _mm512_extractf32x4_ps(b, 3);\n  res = _mm512_insertf32x4(res, _mm_and_ps(lane3_a, lane3_b), 3);\n\n  return res;\n#endif\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pand<Packet8d>(const Packet8d& a,\n                                            const Packet8d& b) {\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n  return _mm512_and_pd(a, b);\n#else\n  Packet8d res = _mm512_undefined_pd();\n  Packet4d lane0_a = _mm512_extractf64x4_pd(a, 0);\n  Packet4d lane0_b = _mm512_extractf64x4_pd(b, 0);\n  res = _mm512_insertf64x4(res, _mm256_and_pd(lane0_a, lane0_b), 0);\n\n  Packet4d lane1_a = _mm512_extractf64x4_pd(a, 1);\n  Packet4d lane1_b = _mm512_extractf64x4_pd(b, 1);\n  res = _mm512_insertf64x4(res, _mm256_and_pd(lane1_a, lane1_b), 1);\n\n  return res;\n#endif\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f por<Packet16f>(const Packet16f& a,\n                                             const Packet16f& b) {\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n  return _mm512_or_ps(a, b);\n#else\n  Packet16f res = _mm512_undefined_ps();\n  Packet4f lane0_a = _mm512_extractf32x4_ps(a, 0);\n  Packet4f lane0_b = _mm512_extractf32x4_ps(b, 0);\n  res = _mm512_insertf32x4(res, _mm_or_ps(lane0_a, lane0_b), 0);\n\n  Packet4f lane1_a = _mm512_extractf32x4_ps(a, 1);\n  Packet4f lane1_b = _mm512_extractf32x4_ps(b, 1);\n  res = _mm512_insertf32x4(res, _mm_or_ps(lane1_a, lane1_b), 1);\n\n  Packet4f lane2_a = _mm512_extractf32x4_ps(a, 2);\n  Packet4f lane2_b = _mm512_extractf32x4_ps(b, 2);\n  res = _mm512_insertf32x4(res, _mm_or_ps(lane2_a, lane2_b), 2);\n\n  Packet4f lane3_a = _mm512_extractf32x4_ps(a, 3);\n  Packet4f lane3_b = _mm512_extractf32x4_ps(b, 3);\n  res = _mm512_insertf32x4(res, _mm_or_ps(lane3_a, lane3_b), 3);\n\n  return res;\n#endif\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d por<Packet8d>(const Packet8d& a,\n                                           const Packet8d& b) {\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n  return _mm512_or_pd(a, b);\n#else\n  Packet8d res = _mm512_undefined_pd();\n  Packet4d lane0_a = _mm512_extractf64x4_pd(a, 0);\n  Packet4d lane0_b = _mm512_extractf64x4_pd(b, 0);\n  res = _mm512_insertf64x4(res, _mm256_or_pd(lane0_a, lane0_b), 0);\n\n  Packet4d lane1_a = _mm512_extractf64x4_pd(a, 1);\n  Packet4d lane1_b = _mm512_extractf64x4_pd(b, 1);\n  res = _mm512_insertf64x4(res, _mm256_or_pd(lane1_a, lane1_b), 1);\n\n  return res;\n#endif\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pxor<Packet16f>(const Packet16f& a,\n                                              const Packet16f& b) {\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n  return _mm512_xor_ps(a, b);\n#else\n  Packet16f res = _mm512_undefined_ps();\n  Packet4f lane0_a = _mm512_extractf32x4_ps(a, 0);\n  Packet4f lane0_b = _mm512_extractf32x4_ps(b, 0);\n  res = _mm512_insertf32x4(res, _mm_xor_ps(lane0_a, lane0_b), 0);\n\n  Packet4f lane1_a = _mm512_extractf32x4_ps(a, 1);\n  Packet4f lane1_b = _mm512_extractf32x4_ps(b, 1);\n  res = _mm512_insertf32x4(res, _mm_xor_ps(lane1_a, lane1_b), 1);\n\n  Packet4f lane2_a = _mm512_extractf32x4_ps(a, 2);\n  Packet4f lane2_b = _mm512_extractf32x4_ps(b, 2);\n  res = _mm512_insertf32x4(res, _mm_xor_ps(lane2_a, lane2_b), 2);\n\n  Packet4f lane3_a = _mm512_extractf32x4_ps(a, 3);\n  Packet4f lane3_b = _mm512_extractf32x4_ps(b, 3);\n  res = _mm512_insertf32x4(res, _mm_xor_ps(lane3_a, lane3_b), 3);\n\n  return res;\n#endif\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pxor<Packet8d>(const Packet8d& a,\n                                            const Packet8d& b) {\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n  return _mm512_xor_pd(a, b);\n#else\n  Packet8d res = _mm512_undefined_pd();\n  Packet4d lane0_a = _mm512_extractf64x4_pd(a, 0);\n  Packet4d lane0_b = _mm512_extractf64x4_pd(b, 0);\n  res = _mm512_insertf64x4(res, _mm256_xor_pd(lane0_a, lane0_b), 0);\n\n  Packet4d lane1_a = _mm512_extractf64x4_pd(a, 1);\n  Packet4d lane1_b = _mm512_extractf64x4_pd(b, 1);\n  res = _mm512_insertf64x4(res, _mm256_xor_pd(lane1_a, lane1_b), 1);\n\n  return res;\n#endif\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pandnot<Packet16f>(const Packet16f& a,\n                                                 const Packet16f& b) {\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n  return _mm512_andnot_ps(a, b);\n#else\n  Packet16f res = _mm512_undefined_ps();\n  Packet4f lane0_a = _mm512_extractf32x4_ps(a, 0);\n  Packet4f lane0_b = _mm512_extractf32x4_ps(b, 0);\n  res = _mm512_insertf32x4(res, _mm_andnot_ps(lane0_a, lane0_b), 0);\n\n  Packet4f lane1_a = _mm512_extractf32x4_ps(a, 1);\n  Packet4f lane1_b = _mm512_extractf32x4_ps(b, 1);\n  res = _mm512_insertf32x4(res, _mm_andnot_ps(lane1_a, lane1_b), 1);\n\n  Packet4f lane2_a = _mm512_extractf32x4_ps(a, 2);\n  Packet4f lane2_b = _mm512_extractf32x4_ps(b, 2);\n  res = _mm512_insertf32x4(res, _mm_andnot_ps(lane2_a, lane2_b), 2);\n\n  Packet4f lane3_a = _mm512_extractf32x4_ps(a, 3);\n  Packet4f lane3_b = _mm512_extractf32x4_ps(b, 3);\n  res = _mm512_insertf32x4(res, _mm_andnot_ps(lane3_a, lane3_b), 3);\n\n  return res;\n#endif\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pandnot<Packet8d>(const Packet8d& a,\n                                               const Packet8d& b) {\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n  return _mm512_andnot_pd(a, b);\n#else\n  Packet8d res = _mm512_undefined_pd();\n  Packet4d lane0_a = _mm512_extractf64x4_pd(a, 0);\n  Packet4d lane0_b = _mm512_extractf64x4_pd(b, 0);\n  res = _mm512_insertf64x4(res, _mm256_andnot_pd(lane0_a, lane0_b), 0);\n\n  Packet4d lane1_a = _mm512_extractf64x4_pd(a, 1);\n  Packet4d lane1_b = _mm512_extractf64x4_pd(b, 1);\n  res = _mm512_insertf64x4(res, _mm256_andnot_pd(lane1_a, lane1_b), 1);\n\n  return res;\n#endif\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pload<Packet16f>(const float* from) {\n  EIGEN_DEBUG_ALIGNED_LOAD return _mm512_load_ps(from);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pload<Packet8d>(const double* from) {\n  EIGEN_DEBUG_ALIGNED_LOAD return _mm512_load_pd(from);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet16i pload<Packet16i>(const int* from) {\n  EIGEN_DEBUG_ALIGNED_LOAD return _mm512_load_si512(\n      reinterpret_cast<const __m512i*>(from));\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f ploadu<Packet16f>(const float* from) {\n  EIGEN_DEBUG_UNALIGNED_LOAD return _mm512_loadu_ps(from);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d ploadu<Packet8d>(const double* from) {\n  EIGEN_DEBUG_UNALIGNED_LOAD return _mm512_loadu_pd(from);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet16i ploadu<Packet16i>(const int* from) {\n  EIGEN_DEBUG_UNALIGNED_LOAD return _mm512_loadu_si512(\n      reinterpret_cast<const __m512i*>(from));\n}\n\n// Loads 8 floats from memory a returns the packet\n// {a0, a0  a1, a1, a2, a2, a3, a3, a4, a4, a5, a5, a6, a6, a7, a7}\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f ploaddup<Packet16f>(const float* from) {\n  Packet8f lane0 = _mm256_broadcast_ps((const __m128*)(const void*)from);\n  // mimic an \"inplace\" permutation of the lower 128bits using a blend\n  lane0 = _mm256_blend_ps(\n      lane0, _mm256_castps128_ps256(_mm_permute_ps(\n                 _mm256_castps256_ps128(lane0), _MM_SHUFFLE(1, 0, 1, 0))),\n      15);\n  // then we can perform a consistent permutation on the global register to get\n  // everything in shape:\n  lane0 = _mm256_permute_ps(lane0, _MM_SHUFFLE(3, 3, 2, 2));\n\n  Packet8f lane1 = _mm256_broadcast_ps((const __m128*)(const void*)(from + 4));\n  // mimic an \"inplace\" permutation of the lower 128bits using a blend\n  lane1 = _mm256_blend_ps(\n      lane1, _mm256_castps128_ps256(_mm_permute_ps(\n                 _mm256_castps256_ps128(lane1), _MM_SHUFFLE(1, 0, 1, 0))),\n      15);\n  // then we can perform a consistent permutation on the global register to get\n  // everything in shape:\n  lane1 = _mm256_permute_ps(lane1, _MM_SHUFFLE(3, 3, 2, 2));\n\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n  Packet16f res = _mm512_undefined_ps();\n  return _mm512_insertf32x8(res, lane0, 0);\n  return _mm512_insertf32x8(res, lane1, 1);\n  return res;\n#else\n  Packet16f res = _mm512_undefined_ps();\n  res = _mm512_insertf32x4(res, _mm256_extractf128_ps(lane0, 0), 0);\n  res = _mm512_insertf32x4(res, _mm256_extractf128_ps(lane0, 1), 1);\n  res = _mm512_insertf32x4(res, _mm256_extractf128_ps(lane1, 0), 2);\n  res = _mm512_insertf32x4(res, _mm256_extractf128_ps(lane1, 1), 3);\n  return res;\n#endif\n}\n// Loads 4 doubles from memory a returns the packet {a0, a0  a1, a1, a2, a2, a3,\n// a3}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d ploaddup<Packet8d>(const double* from) {\n  Packet4d lane0 = _mm256_broadcast_pd((const __m128d*)(const void*)from);\n  lane0 = _mm256_permute_pd(lane0, 3 << 2);\n\n  Packet4d lane1 = _mm256_broadcast_pd((const __m128d*)(const void*)(from + 2));\n  lane1 = _mm256_permute_pd(lane1, 3 << 2);\n\n  Packet8d res = _mm512_undefined_pd();\n  res = _mm512_insertf64x4(res, lane0, 0);\n  return _mm512_insertf64x4(res, lane1, 1);\n}\n\n// Loads 4 floats from memory a returns the packet\n// {a0, a0  a0, a0, a1, a1, a1, a1, a2, a2, a2, a2, a3, a3, a3, a3}\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f ploadquad<Packet16f>(const float* from) {\n  Packet16f tmp = _mm512_undefined_ps();\n  tmp = _mm512_insertf32x4(tmp, _mm_load_ps1(from), 0);\n  tmp = _mm512_insertf32x4(tmp, _mm_load_ps1(from + 1), 1);\n  tmp = _mm512_insertf32x4(tmp, _mm_load_ps1(from + 2), 2);\n  tmp = _mm512_insertf32x4(tmp, _mm_load_ps1(from + 3), 3);\n  return tmp;\n}\n// Loads 2 doubles from memory a returns the packet\n// {a0, a0  a0, a0, a1, a1, a1, a1}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d ploadquad<Packet8d>(const double* from) {\n  Packet8d tmp = _mm512_undefined_pd();\n  Packet2d tmp0 = _mm_load_pd1(from);\n  Packet2d tmp1 = _mm_load_pd1(from + 1);\n  Packet4d lane0 = _mm256_broadcastsd_pd(tmp0);\n  Packet4d lane1 = _mm256_broadcastsd_pd(tmp1);\n  tmp = _mm512_insertf64x4(tmp, lane0, 0);\n  return _mm512_insertf64x4(tmp, lane1, 1);\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE void pstore<float>(float* to, const Packet16f& from) {\n  EIGEN_DEBUG_ALIGNED_STORE _mm512_store_ps(to, from);\n}\ntemplate <>\nEIGEN_STRONG_INLINE void pstore<double>(double* to, const Packet8d& from) {\n  EIGEN_DEBUG_ALIGNED_STORE _mm512_store_pd(to, from);\n}\ntemplate <>\nEIGEN_STRONG_INLINE void pstore<int>(int* to, const Packet16i& from) {\n  EIGEN_DEBUG_ALIGNED_STORE _mm512_storeu_si512(reinterpret_cast<__m512i*>(to),\n                                                from);\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE void pstoreu<float>(float* to, const Packet16f& from) {\n  EIGEN_DEBUG_UNALIGNED_STORE _mm512_storeu_ps(to, from);\n}\ntemplate <>\nEIGEN_STRONG_INLINE void pstoreu<double>(double* to, const Packet8d& from) {\n  EIGEN_DEBUG_UNALIGNED_STORE _mm512_storeu_pd(to, from);\n}\ntemplate <>\nEIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet16i& from) {\n  EIGEN_DEBUG_UNALIGNED_STORE _mm512_storeu_si512(\n      reinterpret_cast<__m512i*>(to), from);\n}\n\ntemplate <>\nEIGEN_DEVICE_FUNC inline Packet16f pgather<float, Packet16f>(const float* from,\n                                                             Index stride) {\n  Packet16i stride_vector = _mm512_set1_epi32(stride);\n  Packet16i stride_multiplier =\n      _mm512_set_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);\n  Packet16i indices = _mm512_mullo_epi32(stride_vector, stride_multiplier);\n\n  return _mm512_i32gather_ps(indices, from, 4);\n}\ntemplate <>\nEIGEN_DEVICE_FUNC inline Packet8d pgather<double, Packet8d>(const double* from,\n                                                            Index stride) {\n  Packet8i stride_vector = _mm256_set1_epi32(stride);\n  Packet8i stride_multiplier = _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0);\n  Packet8i indices = _mm256_mullo_epi32(stride_vector, stride_multiplier);\n\n  return _mm512_i32gather_pd(indices, from, 8);\n}\n\ntemplate <>\nEIGEN_DEVICE_FUNC inline void pscatter<float, Packet16f>(float* to,\n                                                         const Packet16f& from,\n                                                         Index stride) {\n  Packet16i stride_vector = _mm512_set1_epi32(stride);\n  Packet16i stride_multiplier =\n      _mm512_set_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);\n  Packet16i indices = _mm512_mullo_epi32(stride_vector, stride_multiplier);\n  _mm512_i32scatter_ps(to, indices, from, 4);\n}\ntemplate <>\nEIGEN_DEVICE_FUNC inline void pscatter<double, Packet8d>(double* to,\n                                                         const Packet8d& from,\n                                                         Index stride) {\n  Packet8i stride_vector = _mm256_set1_epi32(stride);\n  Packet8i stride_multiplier = _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0);\n  Packet8i indices = _mm256_mullo_epi32(stride_vector, stride_multiplier);\n  _mm512_i32scatter_pd(to, indices, from, 8);\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE void pstore1<Packet16f>(float* to, const float& a) {\n  Packet16f pa = pset1<Packet16f>(a);\n  pstore(to, pa);\n}\ntemplate <>\nEIGEN_STRONG_INLINE void pstore1<Packet8d>(double* to, const double& a) {\n  Packet8d pa = pset1<Packet8d>(a);\n  pstore(to, pa);\n}\ntemplate <>\nEIGEN_STRONG_INLINE void pstore1<Packet16i>(int* to, const int& a) {\n  Packet16i pa = pset1<Packet16i>(a);\n  pstore(to, pa);\n}\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<float>(const float*   addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }\ntemplate<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }\ntemplate<> EIGEN_STRONG_INLINE void prefetch<int>(const int*       addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }\n\ntemplate <>\nEIGEN_STRONG_INLINE float pfirst<Packet16f>(const Packet16f& a) {\n  return _mm_cvtss_f32(_mm512_extractf32x4_ps(a, 0));\n}\ntemplate <>\nEIGEN_STRONG_INLINE double pfirst<Packet8d>(const Packet8d& a) {\n  return _mm_cvtsd_f64(_mm256_extractf128_pd(_mm512_extractf64x4_pd(a, 0), 0));\n}\ntemplate <>\nEIGEN_STRONG_INLINE int pfirst<Packet16i>(const Packet16i& a) {\n  return _mm_extract_epi32(_mm512_extracti32x4_epi32(a, 0), 0);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet16f preverse(const Packet16f& a)\n{\n  return _mm512_permutexvar_ps(_mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), a);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8d preverse(const Packet8d& a)\n{\n  return _mm512_permutexvar_pd(_mm512_set_epi32(0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7), a);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet16f pabs(const Packet16f& a)\n{\n  // _mm512_abs_ps intrinsic not found, so hack around it\n  return (__m512)_mm512_and_si512((__m512i)a, _mm512_set1_epi32(0x7fffffff));\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pabs(const Packet8d& a) {\n  // _mm512_abs_ps intrinsic not found, so hack around it\n  return (__m512d)_mm512_and_si512((__m512i)a,\n                                   _mm512_set1_epi64(0x7fffffffffffffff));\n}\n\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n// AVX512F does not define _mm512_extractf32x8_ps to extract _m256 from _m512\n#define EIGEN_EXTRACT_8f_FROM_16f(INPUT, OUTPUT)                           \\\n  __m256 OUTPUT##_0 = _mm512_extractf32x8_ps(INPUT, 0) __m256 OUTPUT##_1 = \\\n      _mm512_extractf32x8_ps(INPUT, 1)\n#else\n#define EIGEN_EXTRACT_8f_FROM_16f(INPUT, OUTPUT)                \\\n  __m256 OUTPUT##_0 = _mm256_insertf128_ps(                     \\\n      _mm256_castps128_ps256(_mm512_extractf32x4_ps(INPUT, 0)), \\\n      _mm512_extractf32x4_ps(INPUT, 1), 1);                     \\\n  __m256 OUTPUT##_1 = _mm256_insertf128_ps(                     \\\n      _mm256_castps128_ps256(_mm512_extractf32x4_ps(INPUT, 2)), \\\n      _mm512_extractf32x4_ps(INPUT, 3), 1);\n#endif\n\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n#define EIGEN_INSERT_8f_INTO_16f(OUTPUT, INPUTA, INPUTB) \\\n  OUTPUT = _mm512_insertf32x8(OUTPUT, INPUTA, 0);        \\\n  OUTPUT = _mm512_insertf32x8(OUTPUT, INPUTB, 1);\n#else\n#define EIGEN_INSERT_8f_INTO_16f(OUTPUT, INPUTA, INPUTB)                    \\\n  OUTPUT = _mm512_insertf32x4(OUTPUT, _mm256_extractf128_ps(INPUTA, 0), 0); \\\n  OUTPUT = _mm512_insertf32x4(OUTPUT, _mm256_extractf128_ps(INPUTA, 1), 1); \\\n  OUTPUT = _mm512_insertf32x4(OUTPUT, _mm256_extractf128_ps(INPUTB, 0), 2); \\\n  OUTPUT = _mm512_insertf32x4(OUTPUT, _mm256_extractf128_ps(INPUTB, 1), 3);\n#endif\ntemplate<> EIGEN_STRONG_INLINE Packet16f preduxp<Packet16f>(const Packet16f*\nvecs)\n{\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[0], vecs0);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[1], vecs1);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[2], vecs2);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[3], vecs3);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[4], vecs4);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[5], vecs5);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[6], vecs6);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[7], vecs7);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[8], vecs8);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[9], vecs9);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[10], vecs10);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[11], vecs11);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[12], vecs12);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[13], vecs13);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[14], vecs14);\n  EIGEN_EXTRACT_8f_FROM_16f(vecs[15], vecs15);\n\n  __m256 hsum1 = _mm256_hadd_ps(vecs0_0, vecs1_0);\n  __m256 hsum2 = _mm256_hadd_ps(vecs2_0, vecs3_0);\n  __m256 hsum3 = _mm256_hadd_ps(vecs4_0, vecs5_0);\n  __m256 hsum4 = _mm256_hadd_ps(vecs6_0, vecs7_0);\n\n  __m256 hsum5 = _mm256_hadd_ps(hsum1, hsum1);\n  __m256 hsum6 = _mm256_hadd_ps(hsum2, hsum2);\n  __m256 hsum7 = _mm256_hadd_ps(hsum3, hsum3);\n  __m256 hsum8 = _mm256_hadd_ps(hsum4, hsum4);\n\n  __m256 perm1 = _mm256_permute2f128_ps(hsum5, hsum5, 0x23);\n  __m256 perm2 = _mm256_permute2f128_ps(hsum6, hsum6, 0x23);\n  __m256 perm3 = _mm256_permute2f128_ps(hsum7, hsum7, 0x23);\n  __m256 perm4 = _mm256_permute2f128_ps(hsum8, hsum8, 0x23);\n\n  __m256 sum1 = _mm256_add_ps(perm1, hsum5);\n  __m256 sum2 = _mm256_add_ps(perm2, hsum6);\n  __m256 sum3 = _mm256_add_ps(perm3, hsum7);\n  __m256 sum4 = _mm256_add_ps(perm4, hsum8);\n\n  __m256 blend1 = _mm256_blend_ps(sum1, sum2, 0xcc);\n  __m256 blend2 = _mm256_blend_ps(sum3, sum4, 0xcc);\n\n  __m256 final = _mm256_blend_ps(blend1, blend2, 0xf0);\n\n  hsum1 = _mm256_hadd_ps(vecs0_1, vecs1_1);\n  hsum2 = _mm256_hadd_ps(vecs2_1, vecs3_1);\n  hsum3 = _mm256_hadd_ps(vecs4_1, vecs5_1);\n  hsum4 = _mm256_hadd_ps(vecs6_1, vecs7_1);\n\n  hsum5 = _mm256_hadd_ps(hsum1, hsum1);\n  hsum6 = _mm256_hadd_ps(hsum2, hsum2);\n  hsum7 = _mm256_hadd_ps(hsum3, hsum3);\n  hsum8 = _mm256_hadd_ps(hsum4, hsum4);\n\n  perm1 = _mm256_permute2f128_ps(hsum5, hsum5, 0x23);\n  perm2 = _mm256_permute2f128_ps(hsum6, hsum6, 0x23);\n  perm3 = _mm256_permute2f128_ps(hsum7, hsum7, 0x23);\n  perm4 = _mm256_permute2f128_ps(hsum8, hsum8, 0x23);\n\n  sum1 = _mm256_add_ps(perm1, hsum5);\n  sum2 = _mm256_add_ps(perm2, hsum6);\n  sum3 = _mm256_add_ps(perm3, hsum7);\n  sum4 = _mm256_add_ps(perm4, hsum8);\n\n  blend1 = _mm256_blend_ps(sum1, sum2, 0xcc);\n  blend2 = _mm256_blend_ps(sum3, sum4, 0xcc);\n\n  final = padd(final, _mm256_blend_ps(blend1, blend2, 0xf0));\n\n  hsum1 = _mm256_hadd_ps(vecs8_0, vecs9_0);\n  hsum2 = _mm256_hadd_ps(vecs10_0, vecs11_0);\n  hsum3 = _mm256_hadd_ps(vecs12_0, vecs13_0);\n  hsum4 = _mm256_hadd_ps(vecs14_0, vecs15_0);\n\n  hsum5 = _mm256_hadd_ps(hsum1, hsum1);\n  hsum6 = _mm256_hadd_ps(hsum2, hsum2);\n  hsum7 = _mm256_hadd_ps(hsum3, hsum3);\n  hsum8 = _mm256_hadd_ps(hsum4, hsum4);\n\n  perm1 = _mm256_permute2f128_ps(hsum5, hsum5, 0x23);\n  perm2 = _mm256_permute2f128_ps(hsum6, hsum6, 0x23);\n  perm3 = _mm256_permute2f128_ps(hsum7, hsum7, 0x23);\n  perm4 = _mm256_permute2f128_ps(hsum8, hsum8, 0x23);\n\n  sum1 = _mm256_add_ps(perm1, hsum5);\n  sum2 = _mm256_add_ps(perm2, hsum6);\n  sum3 = _mm256_add_ps(perm3, hsum7);\n  sum4 = _mm256_add_ps(perm4, hsum8);\n\n  blend1 = _mm256_blend_ps(sum1, sum2, 0xcc);\n  blend2 = _mm256_blend_ps(sum3, sum4, 0xcc);\n\n  __m256 final_1 = _mm256_blend_ps(blend1, blend2, 0xf0);\n\n  hsum1 = _mm256_hadd_ps(vecs8_1, vecs9_1);\n  hsum2 = _mm256_hadd_ps(vecs10_1, vecs11_1);\n  hsum3 = _mm256_hadd_ps(vecs12_1, vecs13_1);\n  hsum4 = _mm256_hadd_ps(vecs14_1, vecs15_1);\n\n  hsum5 = _mm256_hadd_ps(hsum1, hsum1);\n  hsum6 = _mm256_hadd_ps(hsum2, hsum2);\n  hsum7 = _mm256_hadd_ps(hsum3, hsum3);\n  hsum8 = _mm256_hadd_ps(hsum4, hsum4);\n\n  perm1 = _mm256_permute2f128_ps(hsum5, hsum5, 0x23);\n  perm2 = _mm256_permute2f128_ps(hsum6, hsum6, 0x23);\n  perm3 = _mm256_permute2f128_ps(hsum7, hsum7, 0x23);\n  perm4 = _mm256_permute2f128_ps(hsum8, hsum8, 0x23);\n\n  sum1 = _mm256_add_ps(perm1, hsum5);\n  sum2 = _mm256_add_ps(perm2, hsum6);\n  sum3 = _mm256_add_ps(perm3, hsum7);\n  sum4 = _mm256_add_ps(perm4, hsum8);\n\n  blend1 = _mm256_blend_ps(sum1, sum2, 0xcc);\n  blend2 = _mm256_blend_ps(sum3, sum4, 0xcc);\n\n  final_1 = padd(final_1, _mm256_blend_ps(blend1, blend2, 0xf0));\n\n  __m512 final_output;\n\n  EIGEN_INSERT_8f_INTO_16f(final_output, final, final_1);\n  return final_output;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8d preduxp<Packet8d>(const Packet8d* vecs)\n{\n  Packet4d vecs0_0 = _mm512_extractf64x4_pd(vecs[0], 0);\n  Packet4d vecs0_1 = _mm512_extractf64x4_pd(vecs[0], 1);\n\n  Packet4d vecs1_0 = _mm512_extractf64x4_pd(vecs[1], 0);\n  Packet4d vecs1_1 = _mm512_extractf64x4_pd(vecs[1], 1);\n\n  Packet4d vecs2_0 = _mm512_extractf64x4_pd(vecs[2], 0);\n  Packet4d vecs2_1 = _mm512_extractf64x4_pd(vecs[2], 1);\n\n  Packet4d vecs3_0 = _mm512_extractf64x4_pd(vecs[3], 0);\n  Packet4d vecs3_1 = _mm512_extractf64x4_pd(vecs[3], 1);\n\n  Packet4d vecs4_0 = _mm512_extractf64x4_pd(vecs[4], 0);\n  Packet4d vecs4_1 = _mm512_extractf64x4_pd(vecs[4], 1);\n\n  Packet4d vecs5_0 = _mm512_extractf64x4_pd(vecs[5], 0);\n  Packet4d vecs5_1 = _mm512_extractf64x4_pd(vecs[5], 1);\n\n  Packet4d vecs6_0 = _mm512_extractf64x4_pd(vecs[6], 0);\n  Packet4d vecs6_1 = _mm512_extractf64x4_pd(vecs[6], 1);\n\n  Packet4d vecs7_0 = _mm512_extractf64x4_pd(vecs[7], 0);\n  Packet4d vecs7_1 = _mm512_extractf64x4_pd(vecs[7], 1);\n\n  Packet4d tmp0, tmp1;\n\n  tmp0 = _mm256_hadd_pd(vecs0_0, vecs1_0);\n  tmp0 = _mm256_add_pd(tmp0, _mm256_permute2f128_pd(tmp0, tmp0, 1));\n\n  tmp1 = _mm256_hadd_pd(vecs2_0, vecs3_0);\n  tmp1 = _mm256_add_pd(tmp1, _mm256_permute2f128_pd(tmp1, tmp1, 1));\n\n  __m256d final_0 = _mm256_blend_pd(tmp0, tmp1, 0xC);\n\n  tmp0 = _mm256_hadd_pd(vecs0_1, vecs1_1);\n  tmp0 = _mm256_add_pd(tmp0, _mm256_permute2f128_pd(tmp0, tmp0, 1));\n\n  tmp1 = _mm256_hadd_pd(vecs2_1, vecs3_1);\n  tmp1 = _mm256_add_pd(tmp1, _mm256_permute2f128_pd(tmp1, tmp1, 1));\n\n  final_0 = padd(final_0, _mm256_blend_pd(tmp0, tmp1, 0xC));\n\n  tmp0 = _mm256_hadd_pd(vecs4_0, vecs5_0);\n  tmp0 = _mm256_add_pd(tmp0, _mm256_permute2f128_pd(tmp0, tmp0, 1));\n\n  tmp1 = _mm256_hadd_pd(vecs6_0, vecs7_0);\n  tmp1 = _mm256_add_pd(tmp1, _mm256_permute2f128_pd(tmp1, tmp1, 1));\n\n  __m256d final_1 = _mm256_blend_pd(tmp0, tmp1, 0xC);\n\n  tmp0 = _mm256_hadd_pd(vecs4_1, vecs5_1);\n  tmp0 = _mm256_add_pd(tmp0, _mm256_permute2f128_pd(tmp0, tmp0, 1));\n\n  tmp1 = _mm256_hadd_pd(vecs6_1, vecs7_1);\n  tmp1 = _mm256_add_pd(tmp1, _mm256_permute2f128_pd(tmp1, tmp1, 1));\n\n  final_1 = padd(final_1, _mm256_blend_pd(tmp0, tmp1, 0xC));\n\n  __m512d final_output = _mm512_insertf64x4(final_output, final_0, 0);\n\n  return _mm512_insertf64x4(final_output, final_1, 1);\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE float predux<Packet16f>(const Packet16f& a) {\n  //#ifdef EIGEN_VECTORIZE_AVX512DQ\n#if 0\n  Packet8f lane0 = _mm512_extractf32x8_ps(a, 0);\n  Packet8f lane1 = _mm512_extractf32x8_ps(a, 1);\n  Packet8f sum = padd(lane0, lane1);\n  Packet8f tmp0 = _mm256_hadd_ps(sum, _mm256_permute2f128_ps(a, a, 1));\n  tmp0 = _mm256_hadd_ps(tmp0, tmp0);\n  return pfirst(_mm256_hadd_ps(tmp0, tmp0));\n#else\n  Packet4f lane0 = _mm512_extractf32x4_ps(a, 0);\n  Packet4f lane1 = _mm512_extractf32x4_ps(a, 1);\n  Packet4f lane2 = _mm512_extractf32x4_ps(a, 2);\n  Packet4f lane3 = _mm512_extractf32x4_ps(a, 3);\n  Packet4f sum = padd(padd(lane0, lane1), padd(lane2, lane3));\n  sum = _mm_hadd_ps(sum, sum);\n  sum = _mm_hadd_ps(sum, _mm_permute_ps(sum, 1));\n  return pfirst(sum);\n#endif\n}\ntemplate <>\nEIGEN_STRONG_INLINE double predux<Packet8d>(const Packet8d& a) {\n  Packet4d lane0 = _mm512_extractf64x4_pd(a, 0);\n  Packet4d lane1 = _mm512_extractf64x4_pd(a, 1);\n  Packet4d sum = padd(lane0, lane1);\n  Packet4d tmp0 = _mm256_hadd_pd(sum, _mm256_permute2f128_pd(sum, sum, 1));\n  return pfirst(_mm256_hadd_pd(tmp0, tmp0));\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE Packet8f predux_downto4<Packet16f>(const Packet16f& a) {\n#ifdef EIGEN_VECTORIZE_AVX512DQ\n  Packet8f lane0 = _mm512_extractf32x8_ps(a, 0);\n  Packet8f lane1 = _mm512_extractf32x8_ps(a, 1);\n  return padd(lane0, lane1);\n#else\n  Packet4f lane0 = _mm512_extractf32x4_ps(a, 0);\n  Packet4f lane1 = _mm512_extractf32x4_ps(a, 1);\n  Packet4f lane2 = _mm512_extractf32x4_ps(a, 2);\n  Packet4f lane3 = _mm512_extractf32x4_ps(a, 3);\n  Packet4f sum0 = padd(lane0, lane2);\n  Packet4f sum1 = padd(lane1, lane3);\n  return _mm256_insertf128_ps(_mm256_castps128_ps256(sum0), sum1, 1);\n#endif\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet4d predux_downto4<Packet8d>(const Packet8d& a) {\n  Packet4d lane0 = _mm512_extractf64x4_pd(a, 0);\n  Packet4d lane1 = _mm512_extractf64x4_pd(a, 1);\n  Packet4d res = padd(lane0, lane1);\n  return res;\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE float predux_mul<Packet16f>(const Packet16f& a) {\n//#ifdef EIGEN_VECTORIZE_AVX512DQ\n#if 0\n  Packet8f lane0 = _mm512_extractf32x8_ps(a, 0);\n  Packet8f lane1 = _mm512_extractf32x8_ps(a, 1);\n  Packet8f res = pmul(lane0, lane1);\n  res = pmul(res, _mm256_permute2f128_ps(res, res, 1));\n  res = pmul(res, _mm_permute_ps(res, _MM_SHUFFLE(0, 0, 3, 2)));\n  return pfirst(pmul(res, _mm_permute_ps(res, _MM_SHUFFLE(0, 0, 0, 1))));\n#else\n  Packet4f lane0 = _mm512_extractf32x4_ps(a, 0);\n  Packet4f lane1 = _mm512_extractf32x4_ps(a, 1);\n  Packet4f lane2 = _mm512_extractf32x4_ps(a, 2);\n  Packet4f lane3 = _mm512_extractf32x4_ps(a, 3);\n  Packet4f res = pmul(pmul(lane0, lane1), pmul(lane2, lane3));\n  res = pmul(res, _mm_permute_ps(res, _MM_SHUFFLE(0, 0, 3, 2)));\n  return pfirst(pmul(res, _mm_permute_ps(res, _MM_SHUFFLE(0, 0, 0, 1))));\n#endif\n}\ntemplate <>\nEIGEN_STRONG_INLINE double predux_mul<Packet8d>(const Packet8d& a) {\n  Packet4d lane0 = _mm512_extractf64x4_pd(a, 0);\n  Packet4d lane1 = _mm512_extractf64x4_pd(a, 1);\n  Packet4d res = pmul(lane0, lane1);\n  res = pmul(res, _mm256_permute2f128_pd(res, res, 1));\n  return pfirst(pmul(res, _mm256_shuffle_pd(res, res, 1)));\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE float predux_min<Packet16f>(const Packet16f& a) {\n  Packet4f lane0 = _mm512_extractf32x4_ps(a, 0);\n  Packet4f lane1 = _mm512_extractf32x4_ps(a, 1);\n  Packet4f lane2 = _mm512_extractf32x4_ps(a, 2);\n  Packet4f lane3 = _mm512_extractf32x4_ps(a, 3);\n  Packet4f res = _mm_min_ps(_mm_min_ps(lane0, lane1), _mm_min_ps(lane2, lane3));\n  res = _mm_min_ps(res, _mm_permute_ps(res, _MM_SHUFFLE(0, 0, 3, 2)));\n  return pfirst(_mm_min_ps(res, _mm_permute_ps(res, _MM_SHUFFLE(0, 0, 0, 1))));\n}\ntemplate <>\nEIGEN_STRONG_INLINE double predux_min<Packet8d>(const Packet8d& a) {\n  Packet4d lane0 = _mm512_extractf64x4_pd(a, 0);\n  Packet4d lane1 = _mm512_extractf64x4_pd(a, 1);\n  Packet4d res = _mm256_min_pd(lane0, lane1);\n  res = _mm256_min_pd(res, _mm256_permute2f128_pd(res, res, 1));\n  return pfirst(_mm256_min_pd(res, _mm256_shuffle_pd(res, res, 1)));\n}\n\ntemplate <>\nEIGEN_STRONG_INLINE float predux_max<Packet16f>(const Packet16f& a) {\n  Packet4f lane0 = _mm512_extractf32x4_ps(a, 0);\n  Packet4f lane1 = _mm512_extractf32x4_ps(a, 1);\n  Packet4f lane2 = _mm512_extractf32x4_ps(a, 2);\n  Packet4f lane3 = _mm512_extractf32x4_ps(a, 3);\n  Packet4f res = _mm_max_ps(_mm_max_ps(lane0, lane1), _mm_max_ps(lane2, lane3));\n  res = _mm_max_ps(res, _mm_permute_ps(res, _MM_SHUFFLE(0, 0, 3, 2)));\n  return pfirst(_mm_max_ps(res, _mm_permute_ps(res, _MM_SHUFFLE(0, 0, 0, 1))));\n}\ntemplate <>\nEIGEN_STRONG_INLINE double predux_max<Packet8d>(const Packet8d& a) {\n  Packet4d lane0 = _mm512_extractf64x4_pd(a, 0);\n  Packet4d lane1 = _mm512_extractf64x4_pd(a, 1);\n  Packet4d res = _mm256_max_pd(lane0, lane1);\n  res = _mm256_max_pd(res, _mm256_permute2f128_pd(res, res, 1));\n  return pfirst(_mm256_max_pd(res, _mm256_shuffle_pd(res, res, 1)));\n}\n\ntemplate <int Offset>\nstruct palign_impl<Offset, Packet16f> {\n  static EIGEN_STRONG_INLINE void run(Packet16f& first,\n                                      const Packet16f& second) {\n    if (Offset != 0) {\n      __m512i first_idx = _mm512_set_epi32(\n          Offset + 15, Offset + 14, Offset + 13, Offset + 12, Offset + 11,\n          Offset + 10, Offset + 9, Offset + 8, Offset + 7, Offset + 6,\n          Offset + 5, Offset + 4, Offset + 3, Offset + 2, Offset + 1, Offset);\n\n      __m512i second_idx =\n          _mm512_set_epi32(Offset - 1, Offset - 2, Offset - 3, Offset - 4,\n                           Offset - 5, Offset - 6, Offset - 7, Offset - 8,\n                           Offset - 9, Offset - 10, Offset - 11, Offset - 12,\n                           Offset - 13, Offset - 14, Offset - 15, Offset - 16);\n\n      unsigned short mask = 0xFFFF;\n      mask <<= (16 - Offset);\n\n      first = _mm512_permutexvar_ps(first_idx, first);\n      Packet16f tmp = _mm512_permutexvar_ps(second_idx, second);\n      first = _mm512_mask_blend_ps(mask, first, tmp);\n    }\n  }\n};\ntemplate <int Offset>\nstruct palign_impl<Offset, Packet8d> {\n  static EIGEN_STRONG_INLINE void run(Packet8d& first, const Packet8d& second) {\n    if (Offset != 0) {\n      __m512i first_idx = _mm512_set_epi32(\n          0, Offset + 7, 0, Offset + 6, 0, Offset + 5, 0, Offset + 4, 0,\n          Offset + 3, 0, Offset + 2, 0, Offset + 1, 0, Offset);\n\n      __m512i second_idx = _mm512_set_epi32(\n          0, Offset - 1, 0, Offset - 2, 0, Offset - 3, 0, Offset - 4, 0,\n          Offset - 5, 0, Offset - 6, 0, Offset - 7, 0, Offset - 8);\n\n      unsigned char mask = 0xFF;\n      mask <<= (8 - Offset);\n\n      first = _mm512_permutexvar_pd(first_idx, first);\n      Packet8d tmp = _mm512_permutexvar_pd(second_idx, second);\n      first = _mm512_mask_blend_pd(mask, first, tmp);\n    }\n  }\n};\n\n\n#define PACK_OUTPUT(OUTPUT, INPUT, INDEX, STRIDE) \\\n  EIGEN_INSERT_8f_INTO_16f(OUTPUT[INDEX], INPUT[INDEX], INPUT[INDEX + STRIDE]);\n\nEIGEN_DEVICE_FUNC inline void ptranspose(PacketBlock<Packet16f, 16>& kernel) {\n  __m512 T0 = _mm512_unpacklo_ps(kernel.packet[0], kernel.packet[1]);\n  __m512 T1 = _mm512_unpackhi_ps(kernel.packet[0], kernel.packet[1]);\n  __m512 T2 = _mm512_unpacklo_ps(kernel.packet[2], kernel.packet[3]);\n  __m512 T3 = _mm512_unpackhi_ps(kernel.packet[2], kernel.packet[3]);\n  __m512 T4 = _mm512_unpacklo_ps(kernel.packet[4], kernel.packet[5]);\n  __m512 T5 = _mm512_unpackhi_ps(kernel.packet[4], kernel.packet[5]);\n  __m512 T6 = _mm512_unpacklo_ps(kernel.packet[6], kernel.packet[7]);\n  __m512 T7 = _mm512_unpackhi_ps(kernel.packet[6], kernel.packet[7]);\n  __m512 T8 = _mm512_unpacklo_ps(kernel.packet[8], kernel.packet[9]);\n  __m512 T9 = _mm512_unpackhi_ps(kernel.packet[8], kernel.packet[9]);\n  __m512 T10 = _mm512_unpacklo_ps(kernel.packet[10], kernel.packet[11]);\n  __m512 T11 = _mm512_unpackhi_ps(kernel.packet[10], kernel.packet[11]);\n  __m512 T12 = _mm512_unpacklo_ps(kernel.packet[12], kernel.packet[13]);\n  __m512 T13 = _mm512_unpackhi_ps(kernel.packet[12], kernel.packet[13]);\n  __m512 T14 = _mm512_unpacklo_ps(kernel.packet[14], kernel.packet[15]);\n  __m512 T15 = _mm512_unpackhi_ps(kernel.packet[14], kernel.packet[15]);\n  __m512 S0 = _mm512_shuffle_ps(T0, T2, _MM_SHUFFLE(1, 0, 1, 0));\n  __m512 S1 = _mm512_shuffle_ps(T0, T2, _MM_SHUFFLE(3, 2, 3, 2));\n  __m512 S2 = _mm512_shuffle_ps(T1, T3, _MM_SHUFFLE(1, 0, 1, 0));\n  __m512 S3 = _mm512_shuffle_ps(T1, T3, _MM_SHUFFLE(3, 2, 3, 2));\n  __m512 S4 = _mm512_shuffle_ps(T4, T6, _MM_SHUFFLE(1, 0, 1, 0));\n  __m512 S5 = _mm512_shuffle_ps(T4, T6, _MM_SHUFFLE(3, 2, 3, 2));\n  __m512 S6 = _mm512_shuffle_ps(T5, T7, _MM_SHUFFLE(1, 0, 1, 0));\n  __m512 S7 = _mm512_shuffle_ps(T5, T7, _MM_SHUFFLE(3, 2, 3, 2));\n  __m512 S8 = _mm512_shuffle_ps(T8, T10, _MM_SHUFFLE(1, 0, 1, 0));\n  __m512 S9 = _mm512_shuffle_ps(T8, T10, _MM_SHUFFLE(3, 2, 3, 2));\n  __m512 S10 = _mm512_shuffle_ps(T9, T11, _MM_SHUFFLE(1, 0, 1, 0));\n  __m512 S11 = _mm512_shuffle_ps(T9, T11, _MM_SHUFFLE(3, 2, 3, 2));\n  __m512 S12 = _mm512_shuffle_ps(T12, T14, _MM_SHUFFLE(1, 0, 1, 0));\n  __m512 S13 = _mm512_shuffle_ps(T12, T14, _MM_SHUFFLE(3, 2, 3, 2));\n  __m512 S14 = _mm512_shuffle_ps(T13, T15, _MM_SHUFFLE(1, 0, 1, 0));\n  __m512 S15 = _mm512_shuffle_ps(T13, T15, _MM_SHUFFLE(3, 2, 3, 2));\n\n  EIGEN_EXTRACT_8f_FROM_16f(S0, S0);\n  EIGEN_EXTRACT_8f_FROM_16f(S1, S1);\n  EIGEN_EXTRACT_8f_FROM_16f(S2, S2);\n  EIGEN_EXTRACT_8f_FROM_16f(S3, S3);\n  EIGEN_EXTRACT_8f_FROM_16f(S4, S4);\n  EIGEN_EXTRACT_8f_FROM_16f(S5, S5);\n  EIGEN_EXTRACT_8f_FROM_16f(S6, S6);\n  EIGEN_EXTRACT_8f_FROM_16f(S7, S7);\n  EIGEN_EXTRACT_8f_FROM_16f(S8, S8);\n  EIGEN_EXTRACT_8f_FROM_16f(S9, S9);\n  EIGEN_EXTRACT_8f_FROM_16f(S10, S10);\n  EIGEN_EXTRACT_8f_FROM_16f(S11, S11);\n  EIGEN_EXTRACT_8f_FROM_16f(S12, S12);\n  EIGEN_EXTRACT_8f_FROM_16f(S13, S13);\n  EIGEN_EXTRACT_8f_FROM_16f(S14, S14);\n  EIGEN_EXTRACT_8f_FROM_16f(S15, S15);\n\n  PacketBlock<Packet8f, 32> tmp;\n\n  tmp.packet[0] = _mm256_permute2f128_ps(S0_0, S4_0, 0x20);\n  tmp.packet[1] = _mm256_permute2f128_ps(S1_0, S5_0, 0x20);\n  tmp.packet[2] = _mm256_permute2f128_ps(S2_0, S6_0, 0x20);\n  tmp.packet[3] = _mm256_permute2f128_ps(S3_0, S7_0, 0x20);\n  tmp.packet[4] = _mm256_permute2f128_ps(S0_0, S4_0, 0x31);\n  tmp.packet[5] = _mm256_permute2f128_ps(S1_0, S5_0, 0x31);\n  tmp.packet[6] = _mm256_permute2f128_ps(S2_0, S6_0, 0x31);\n  tmp.packet[7] = _mm256_permute2f128_ps(S3_0, S7_0, 0x31);\n\n  tmp.packet[8] = _mm256_permute2f128_ps(S0_1, S4_1, 0x20);\n  tmp.packet[9] = _mm256_permute2f128_ps(S1_1, S5_1, 0x20);\n  tmp.packet[10] = _mm256_permute2f128_ps(S2_1, S6_1, 0x20);\n  tmp.packet[11] = _mm256_permute2f128_ps(S3_1, S7_1, 0x20);\n  tmp.packet[12] = _mm256_permute2f128_ps(S0_1, S4_1, 0x31);\n  tmp.packet[13] = _mm256_permute2f128_ps(S1_1, S5_1, 0x31);\n  tmp.packet[14] = _mm256_permute2f128_ps(S2_1, S6_1, 0x31);\n  tmp.packet[15] = _mm256_permute2f128_ps(S3_1, S7_1, 0x31);\n\n  // Second set of _m256 outputs\n  tmp.packet[16] = _mm256_permute2f128_ps(S8_0, S12_0, 0x20);\n  tmp.packet[17] = _mm256_permute2f128_ps(S9_0, S13_0, 0x20);\n  tmp.packet[18] = _mm256_permute2f128_ps(S10_0, S14_0, 0x20);\n  tmp.packet[19] = _mm256_permute2f128_ps(S11_0, S15_0, 0x20);\n  tmp.packet[20] = _mm256_permute2f128_ps(S8_0, S12_0, 0x31);\n  tmp.packet[21] = _mm256_permute2f128_ps(S9_0, S13_0, 0x31);\n  tmp.packet[22] = _mm256_permute2f128_ps(S10_0, S14_0, 0x31);\n  tmp.packet[23] = _mm256_permute2f128_ps(S11_0, S15_0, 0x31);\n\n  tmp.packet[24] = _mm256_permute2f128_ps(S8_1, S12_1, 0x20);\n  tmp.packet[25] = _mm256_permute2f128_ps(S9_1, S13_1, 0x20);\n  tmp.packet[26] = _mm256_permute2f128_ps(S10_1, S14_1, 0x20);\n  tmp.packet[27] = _mm256_permute2f128_ps(S11_1, S15_1, 0x20);\n  tmp.packet[28] = _mm256_permute2f128_ps(S8_1, S12_1, 0x31);\n  tmp.packet[29] = _mm256_permute2f128_ps(S9_1, S13_1, 0x31);\n  tmp.packet[30] = _mm256_permute2f128_ps(S10_1, S14_1, 0x31);\n  tmp.packet[31] = _mm256_permute2f128_ps(S11_1, S15_1, 0x31);\n\n  // Pack them into the output\n  PACK_OUTPUT(kernel.packet, tmp.packet, 0, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 1, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 2, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 3, 16);\n\n  PACK_OUTPUT(kernel.packet, tmp.packet, 4, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 5, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 6, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 7, 16);\n\n  PACK_OUTPUT(kernel.packet, tmp.packet, 8, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 9, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 10, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 11, 16);\n\n  PACK_OUTPUT(kernel.packet, tmp.packet, 12, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 13, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 14, 16);\n  PACK_OUTPUT(kernel.packet, tmp.packet, 15, 16);\n}\n#define PACK_OUTPUT_2(OUTPUT, INPUT, INDEX, STRIDE)         \\\n  EIGEN_INSERT_8f_INTO_16f(OUTPUT[INDEX], INPUT[2 * INDEX], \\\n                           INPUT[2 * INDEX + STRIDE]);\n\nEIGEN_DEVICE_FUNC inline void ptranspose(PacketBlock<Packet16f, 4>& kernel) {\n  __m512 T0 = _mm512_unpacklo_ps(kernel.packet[0], kernel.packet[1]);\n  __m512 T1 = _mm512_unpackhi_ps(kernel.packet[0], kernel.packet[1]);\n  __m512 T2 = _mm512_unpacklo_ps(kernel.packet[2], kernel.packet[3]);\n  __m512 T3 = _mm512_unpackhi_ps(kernel.packet[2], kernel.packet[3]);\n\n  __m512 S0 = _mm512_shuffle_ps(T0, T2, _MM_SHUFFLE(1, 0, 1, 0));\n  __m512 S1 = _mm512_shuffle_ps(T0, T2, _MM_SHUFFLE(3, 2, 3, 2));\n  __m512 S2 = _mm512_shuffle_ps(T1, T3, _MM_SHUFFLE(1, 0, 1, 0));\n  __m512 S3 = _mm512_shuffle_ps(T1, T3, _MM_SHUFFLE(3, 2, 3, 2));\n\n  EIGEN_EXTRACT_8f_FROM_16f(S0, S0);\n  EIGEN_EXTRACT_8f_FROM_16f(S1, S1);\n  EIGEN_EXTRACT_8f_FROM_16f(S2, S2);\n  EIGEN_EXTRACT_8f_FROM_16f(S3, S3);\n\n  PacketBlock<Packet8f, 8> tmp;\n\n  tmp.packet[0] = _mm256_permute2f128_ps(S0_0, S1_0, 0x20);\n  tmp.packet[1] = _mm256_permute2f128_ps(S2_0, S3_0, 0x20);\n  tmp.packet[2] = _mm256_permute2f128_ps(S0_0, S1_0, 0x31);\n  tmp.packet[3] = _mm256_permute2f128_ps(S2_0, S3_0, 0x31);\n\n  tmp.packet[4] = _mm256_permute2f128_ps(S0_1, S1_1, 0x20);\n  tmp.packet[5] = _mm256_permute2f128_ps(S2_1, S3_1, 0x20);\n  tmp.packet[6] = _mm256_permute2f128_ps(S0_1, S1_1, 0x31);\n  tmp.packet[7] = _mm256_permute2f128_ps(S2_1, S3_1, 0x31);\n\n  PACK_OUTPUT_2(kernel.packet, tmp.packet, 0, 1);\n  PACK_OUTPUT_2(kernel.packet, tmp.packet, 1, 1);\n  PACK_OUTPUT_2(kernel.packet, tmp.packet, 2, 1);\n  PACK_OUTPUT_2(kernel.packet, tmp.packet, 3, 1);\n}\n\n#define PACK_OUTPUT_SQ_D(OUTPUT, INPUT, INDEX, STRIDE)                \\\n  OUTPUT[INDEX] = _mm512_insertf64x4(OUTPUT[INDEX], INPUT[INDEX], 0); \\\n  OUTPUT[INDEX] = _mm512_insertf64x4(OUTPUT[INDEX], INPUT[INDEX + STRIDE], 1);\n\n#define PACK_OUTPUT_D(OUTPUT, INPUT, INDEX, STRIDE)                         \\\n  OUTPUT[INDEX] = _mm512_insertf64x4(OUTPUT[INDEX], INPUT[(2 * INDEX)], 0); \\\n  OUTPUT[INDEX] =                                                           \\\n      _mm512_insertf64x4(OUTPUT[INDEX], INPUT[(2 * INDEX) + STRIDE], 1);\n\nEIGEN_DEVICE_FUNC inline void ptranspose(PacketBlock<Packet8d, 4>& kernel) {\n  __m512d T0 = _mm512_shuffle_pd(kernel.packet[0], kernel.packet[1], 0);\n  __m512d T1 = _mm512_shuffle_pd(kernel.packet[0], kernel.packet[1], 0xff);\n  __m512d T2 = _mm512_shuffle_pd(kernel.packet[2], kernel.packet[3], 0);\n  __m512d T3 = _mm512_shuffle_pd(kernel.packet[2], kernel.packet[3], 0xff);\n\n  PacketBlock<Packet4d, 8> tmp;\n\n  tmp.packet[0] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T0, 0),\n                                         _mm512_extractf64x4_pd(T2, 0), 0x20);\n  tmp.packet[1] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T1, 0),\n                                         _mm512_extractf64x4_pd(T3, 0), 0x20);\n  tmp.packet[2] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T0, 0),\n                                         _mm512_extractf64x4_pd(T2, 0), 0x31);\n  tmp.packet[3] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T1, 0),\n                                         _mm512_extractf64x4_pd(T3, 0), 0x31);\n\n  tmp.packet[4] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T0, 1),\n                                         _mm512_extractf64x4_pd(T2, 1), 0x20);\n  tmp.packet[5] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T1, 1),\n                                         _mm512_extractf64x4_pd(T3, 1), 0x20);\n  tmp.packet[6] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T0, 1),\n                                         _mm512_extractf64x4_pd(T2, 1), 0x31);\n  tmp.packet[7] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T1, 1),\n                                         _mm512_extractf64x4_pd(T3, 1), 0x31);\n\n  PACK_OUTPUT_D(kernel.packet, tmp.packet, 0, 1);\n  PACK_OUTPUT_D(kernel.packet, tmp.packet, 1, 1);\n  PACK_OUTPUT_D(kernel.packet, tmp.packet, 2, 1);\n  PACK_OUTPUT_D(kernel.packet, tmp.packet, 3, 1);\n}\n\nEIGEN_DEVICE_FUNC inline void ptranspose(PacketBlock<Packet8d, 8>& kernel) {\n  __m512d T0 = _mm512_unpacklo_pd(kernel.packet[0], kernel.packet[1]);\n  __m512d T1 = _mm512_unpackhi_pd(kernel.packet[0], kernel.packet[1]);\n  __m512d T2 = _mm512_unpacklo_pd(kernel.packet[2], kernel.packet[3]);\n  __m512d T3 = _mm512_unpackhi_pd(kernel.packet[2], kernel.packet[3]);\n  __m512d T4 = _mm512_unpacklo_pd(kernel.packet[4], kernel.packet[5]);\n  __m512d T5 = _mm512_unpackhi_pd(kernel.packet[4], kernel.packet[5]);\n  __m512d T6 = _mm512_unpacklo_pd(kernel.packet[6], kernel.packet[7]);\n  __m512d T7 = _mm512_unpackhi_pd(kernel.packet[6], kernel.packet[7]);\n\n  PacketBlock<Packet4d, 16> tmp;\n\n  tmp.packet[0] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T0, 0),\n                                         _mm512_extractf64x4_pd(T2, 0), 0x20);\n  tmp.packet[1] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T1, 0),\n                                         _mm512_extractf64x4_pd(T3, 0), 0x20);\n  tmp.packet[2] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T0, 0),\n                                         _mm512_extractf64x4_pd(T2, 0), 0x31);\n  tmp.packet[3] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T1, 0),\n                                         _mm512_extractf64x4_pd(T3, 0), 0x31);\n\n  tmp.packet[4] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T0, 1),\n                                         _mm512_extractf64x4_pd(T2, 1), 0x20);\n  tmp.packet[5] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T1, 1),\n                                         _mm512_extractf64x4_pd(T3, 1), 0x20);\n  tmp.packet[6] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T0, 1),\n                                         _mm512_extractf64x4_pd(T2, 1), 0x31);\n  tmp.packet[7] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T1, 1),\n                                         _mm512_extractf64x4_pd(T3, 1), 0x31);\n\n  tmp.packet[8] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T4, 0),\n                                         _mm512_extractf64x4_pd(T6, 0), 0x20);\n  tmp.packet[9] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T5, 0),\n                                         _mm512_extractf64x4_pd(T7, 0), 0x20);\n  tmp.packet[10] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T4, 0),\n                                          _mm512_extractf64x4_pd(T6, 0), 0x31);\n  tmp.packet[11] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T5, 0),\n                                          _mm512_extractf64x4_pd(T7, 0), 0x31);\n\n  tmp.packet[12] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T4, 1),\n                                          _mm512_extractf64x4_pd(T6, 1), 0x20);\n  tmp.packet[13] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T5, 1),\n                                          _mm512_extractf64x4_pd(T7, 1), 0x20);\n  tmp.packet[14] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T4, 1),\n                                          _mm512_extractf64x4_pd(T6, 1), 0x31);\n  tmp.packet[15] = _mm256_permute2f128_pd(_mm512_extractf64x4_pd(T5, 1),\n                                          _mm512_extractf64x4_pd(T7, 1), 0x31);\n\n  PACK_OUTPUT_SQ_D(kernel.packet, tmp.packet, 0, 8);\n  PACK_OUTPUT_SQ_D(kernel.packet, tmp.packet, 1, 8);\n  PACK_OUTPUT_SQ_D(kernel.packet, tmp.packet, 2, 8);\n  PACK_OUTPUT_SQ_D(kernel.packet, tmp.packet, 3, 8);\n\n  PACK_OUTPUT_SQ_D(kernel.packet, tmp.packet, 4, 8);\n  PACK_OUTPUT_SQ_D(kernel.packet, tmp.packet, 5, 8);\n  PACK_OUTPUT_SQ_D(kernel.packet, tmp.packet, 6, 8);\n  PACK_OUTPUT_SQ_D(kernel.packet, tmp.packet, 7, 8);\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet16f pblend(const Selector<16>& /*ifPacket*/,\n                                     const Packet16f& /*thenPacket*/,\n                                     const Packet16f& /*elsePacket*/) {\n  assert(false && \"To be implemented\");\n  return Packet16f();\n}\ntemplate <>\nEIGEN_STRONG_INLINE Packet8d pblend(const Selector<8>& /*ifPacket*/,\n                                    const Packet8d& /*thenPacket*/,\n                                    const Packet8d& /*elsePacket*/) {\n  assert(false && \"To be implemented\");\n  return Packet8d();\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_PACKET_MATH_AVX512_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/AltiVec/Complex.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010-2016 Konstantinos Margaritis <markos@freevec.org>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COMPLEX32_ALTIVEC_H\n#define EIGEN_COMPLEX32_ALTIVEC_H\n\nnamespace Eigen {\n\nnamespace internal {\n\nstatic Packet4ui  p4ui_CONJ_XOR = vec_mergeh((Packet4ui)p4i_ZERO, (Packet4ui)p4f_MZERO);//{ 0x00000000, 0x80000000, 0x00000000, 0x80000000 };\n#ifdef __VSX__\n#if defined(_BIG_ENDIAN)\nstatic Packet2ul  p2ul_CONJ_XOR1 = (Packet2ul) vec_sld((Packet4ui) p2d_MZERO, (Packet4ui) p2l_ZERO, 8);//{ 0x8000000000000000, 0x0000000000000000 };\nstatic Packet2ul  p2ul_CONJ_XOR2 = (Packet2ul) vec_sld((Packet4ui) p2l_ZERO,  (Packet4ui) p2d_MZERO, 8);//{ 0x8000000000000000, 0x0000000000000000 };\n#else\nstatic Packet2ul  p2ul_CONJ_XOR1 = (Packet2ul) vec_sld((Packet4ui) p2l_ZERO,  (Packet4ui) p2d_MZERO, 8);//{ 0x8000000000000000, 0x0000000000000000 };\nstatic Packet2ul  p2ul_CONJ_XOR2 = (Packet2ul) vec_sld((Packet4ui) p2d_MZERO, (Packet4ui) p2l_ZERO, 8);//{ 0x8000000000000000, 0x0000000000000000 };\n#endif\n#endif\n\n//---------- float ----------\nstruct Packet2cf\n{\n  EIGEN_STRONG_INLINE explicit Packet2cf() : v(p4f_ZERO) {}\n  EIGEN_STRONG_INLINE explicit Packet2cf(const Packet4f& a) : v(a) {}\n  Packet4f  v;\n};\n\ntemplate<> struct packet_traits<std::complex<float> >  : default_packet_traits\n{\n  typedef Packet2cf type;\n  typedef Packet2cf half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 2,\n    HasHalfPacket = 0,\n\n    HasAdd    = 1,\n    HasSub    = 1,\n    HasMul    = 1,\n    HasDiv    = 1,\n    HasNegate = 1,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n#ifdef __VSX__\n    HasBlend  = 1,\n#endif\n    HasSetLinear = 0\n  };\n};\n\ntemplate<> struct unpacket_traits<Packet2cf> { typedef std::complex<float> type; enum {size=2, alignment=Aligned16}; typedef Packet2cf half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>&  from)\n{\n  Packet2cf res;\n  if((std::ptrdiff_t(&from) % 16) == 0)\n    res.v = pload<Packet4f>((const float *)&from);\n  else\n    res.v = ploadu<Packet4f>((const float *)&from);\n  res.v = vec_perm(res.v, res.v, p16uc_PSET64_HI);\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pload<Packet2cf>(const std::complex<float>*        from) { return Packet2cf(pload<Packet4f>((const float *) from)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(const std::complex<float>*       from) { return Packet2cf(ploadu<Packet4f>((const float*) from)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(const std::complex<float>*     from) { return pset1<Packet2cf>(*from); }\n\ntemplate<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> *   to, const Packet2cf& from) { pstore((float*)to, from.v); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> *   to, const Packet2cf& from) { pstoreu((float*)to, from.v); }\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, Index stride)\n{\n  std::complex<float> EIGEN_ALIGN16 af[2];\n  af[0] = from[0*stride];\n  af[1] = from[1*stride];\n  return pload<Packet2cf>(af);\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, Index stride)\n{\n  std::complex<float> EIGEN_ALIGN16 af[2];\n  pstore<std::complex<float> >((std::complex<float> *) af, from);\n  to[0*stride] = af[0];\n  to[1*stride] = af[1];\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(a.v + b.v); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(a.v - b.v); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf& a) { return Packet2cf(pnegate(a.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf& a) { return Packet2cf(pxor<Packet4f>(a.v, reinterpret_cast<Packet4f>(p4ui_CONJ_XOR))); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  Packet4f v1, v2;\n\n  // Permute and multiply the real parts of a and b\n  v1 = vec_perm(a.v, a.v, p16uc_PSET32_WODD);\n  // Get the imaginary parts of a\n  v2 = vec_perm(a.v, a.v, p16uc_PSET32_WEVEN);\n  // multiply a_re * b \n  v1 = vec_madd(v1, b.v, p4f_ZERO);\n  // multiply a_im * b and get the conjugate result\n  v2 = vec_madd(v2, b.v, p4f_ZERO);\n  v2 = reinterpret_cast<Packet4f>(pxor(v2, reinterpret_cast<Packet4f>(p4ui_CONJ_XOR)));\n  // permute back to a proper order\n  v2 = vec_perm(v2, v2, p16uc_COMPLEX32_REV);\n  \n  return Packet2cf(padd<Packet4f>(v1, v2));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pand   <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(pand<Packet4f>(a.v, b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf por    <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(por<Packet4f>(a.v, b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pxor   <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(pxor<Packet4f>(a.v, b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(pandnot<Packet4f>(a.v, b.v)); }\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> * addr)    { EIGEN_PPC_PREFETCH(addr); }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float>  pfirst<Packet2cf>(const Packet2cf& a)\n{\n  std::complex<float> EIGEN_ALIGN16 res[2];\n  pstore((float *)&res, a.v);\n\n  return res[0];\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf& a)\n{\n  Packet4f rev_a;\n  rev_a = vec_perm(a.v, a.v, p16uc_COMPLEX32_REV2);\n  return Packet2cf(rev_a);\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(const Packet2cf& a)\n{\n  Packet4f b;\n  b = vec_sld(a.v, a.v, 8);\n  b = padd<Packet4f>(a.v, b);\n  return pfirst<Packet2cf>(Packet2cf(b));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(const Packet2cf* vecs)\n{\n  Packet4f b1, b2;\n#ifdef _BIG_ENDIAN  \n  b1 = vec_sld(vecs[0].v, vecs[1].v, 8);\n  b2 = vec_sld(vecs[1].v, vecs[0].v, 8);\n#else\n  b1 = vec_sld(vecs[1].v, vecs[0].v, 8);\n  b2 = vec_sld(vecs[0].v, vecs[1].v, 8);\n#endif\n  b2 = vec_sld(b2, b2, 8);\n  b2 = padd<Packet4f>(b1, b2);\n\n  return Packet2cf(b2);\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(const Packet2cf& a)\n{\n  Packet4f b;\n  Packet2cf prod;\n  b = vec_sld(a.v, a.v, 8);\n  prod = pmul<Packet2cf>(a, Packet2cf(b));\n\n  return pfirst<Packet2cf>(prod);\n}\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet2cf>\n{\n  static EIGEN_STRONG_INLINE void run(Packet2cf& first, const Packet2cf& second)\n  {\n    if (Offset==1)\n    {\n#ifdef _BIG_ENDIAN\n      first.v = vec_sld(first.v, second.v, 8);\n#else\n      first.v = vec_sld(second.v, first.v, 8);\n#endif\n    }\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, false,true>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    return internal::pmul(a, pconj(b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, true,false>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    return internal::pmul(pconj(a), b);\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, true,true>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    return pconj(internal::pmul(a, b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet4f, Packet2cf, false,false>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet4f& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet4f& x, const Packet2cf& y) const\n  { return Packet2cf(internal::pmul<Packet4f>(x, y.v)); }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet4f, false,false>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet4f& y, const Packet2cf& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& x, const Packet4f& y) const\n  { return Packet2cf(internal::pmul<Packet4f>(x.v, y)); }\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  // TODO optimize it for AltiVec\n  Packet2cf res = conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a, b);\n  Packet4f s = pmul<Packet4f>(b.v, b.v);\n  return Packet2cf(pdiv(res.v, padd<Packet4f>(s, vec_perm(s, s, p16uc_COMPLEX32_REV))));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pcplxflip<Packet2cf>(const Packet2cf& x)\n{\n  return Packet2cf(vec_perm(x.v, x.v, p16uc_COMPLEX32_REV));\n}\n\nEIGEN_STRONG_INLINE void ptranspose(PacketBlock<Packet2cf,2>& kernel)\n{\n  Packet4f tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);\n  kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);\n  kernel.packet[0].v = tmp;\n}\n\n#ifdef __VSX__\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pblend(const Selector<2>& ifPacket, const Packet2cf& thenPacket, const Packet2cf& elsePacket) {\n  Packet2cf result;\n  result.v = reinterpret_cast<Packet4f>(pblend<Packet2d>(ifPacket, reinterpret_cast<Packet2d>(thenPacket.v), reinterpret_cast<Packet2d>(elsePacket.v)));\n  return result;\n}\n#endif\n\n//---------- double ----------\n#ifdef __VSX__\nstruct Packet1cd\n{\n  EIGEN_STRONG_INLINE Packet1cd() {}\n  EIGEN_STRONG_INLINE explicit Packet1cd(const Packet2d& a) : v(a) {}\n  Packet2d v;\n};\n\ntemplate<> struct packet_traits<std::complex<double> >  : default_packet_traits\n{\n  typedef Packet1cd type;\n  typedef Packet1cd half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 0,\n    size = 1,\n    HasHalfPacket = 0,\n\n    HasAdd    = 1,\n    HasSub    = 1,\n    HasMul    = 1,\n    HasDiv    = 1,\n    HasNegate = 1,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasSetLinear = 0\n  };\n};\n\ntemplate<> struct unpacket_traits<Packet1cd> { typedef std::complex<double> type; enum {size=1, alignment=Aligned16}; typedef Packet1cd half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pload <Packet1cd>(const std::complex<double>* from) { return Packet1cd(pload<Packet2d>((const double*)from)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(const std::complex<double>* from) { return Packet1cd(ploadu<Packet2d>((const double*)from)); }\ntemplate<> EIGEN_STRONG_INLINE void pstore <std::complex<double> >(std::complex<double> *   to, const Packet1cd& from) { pstore((double*)to, from.v); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex<double> *   to, const Packet1cd& from) { pstoreu((double*)to, from.v); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(const std::complex<double>&  from)\n{ /* here we really have to use unaligned loads :( */ return ploadu<Packet1cd>(&from); }\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet1cd pgather<std::complex<double>, Packet1cd>(const std::complex<double>* from, Index stride)\n{\n  std::complex<double> EIGEN_ALIGN16 af[2];\n  af[0] = from[0*stride];\n  af[1] = from[1*stride];\n  return pload<Packet1cd>(af);\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to, const Packet1cd& from, Index stride)\n{\n  std::complex<double> EIGEN_ALIGN16 af[2];\n  pstore<std::complex<double> >(af, from);\n  to[0*stride] = af[0];\n  to[1*stride] = af[1];\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(a.v + b.v); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(a.v - b.v); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pnegate(const Packet1cd& a) { return Packet1cd(pnegate(Packet2d(a.v))); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pconj(const Packet1cd& a) { return Packet1cd(pxor(a.v, reinterpret_cast<Packet2d>(p2ul_CONJ_XOR2))); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pmul<Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  Packet2d a_re, a_im, v1, v2;\n\n  // Permute and multiply the real parts of a and b\n  a_re = vec_perm(a.v, a.v, p16uc_PSET64_HI);\n  // Get the imaginary parts of a\n  a_im = vec_perm(a.v, a.v, p16uc_PSET64_LO);\n  // multiply a_re * b\n  v1 = vec_madd(a_re, b.v, p2d_ZERO);\n  // multiply a_im * b and get the conjugate result\n  v2 = vec_madd(a_im, b.v, p2d_ZERO);\n  v2 = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4ui>(v2), reinterpret_cast<Packet4ui>(v2), 8));\n  v2 = pxor(v2, reinterpret_cast<Packet2d>(p2ul_CONJ_XOR1));\n\n  return Packet1cd(padd<Packet2d>(v1, v2));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pand   <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(pand(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd por    <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(por(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pxor   <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(pxor(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(pandnot(a.v, b.v)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(const std::complex<double>*     from)  { return pset1<Packet1cd>(*from); }\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<std::complex<double> >(const std::complex<double> * addr)    { EIGEN_PPC_PREFETCH(addr); }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double>  pfirst<Packet1cd>(const Packet1cd& a)\n{\n  std::complex<double> EIGEN_ALIGN16 res[2];\n  pstore<std::complex<double> >(res, a);\n\n  return res[0];\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd preverse(const Packet1cd& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(const Packet1cd& a) { return pfirst(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd preduxp<Packet1cd>(const Packet1cd* vecs)        { return vecs[0]; }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(const Packet1cd& a) { return pfirst(a); }\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet1cd>\n{\n  static EIGEN_STRONG_INLINE void run(Packet1cd& /*first*/, const Packet1cd& /*second*/)\n  {\n    // FIXME is it sure we never have to align a Packet1cd?\n    // Even though a std::complex<double> has 16 bytes, it is not necessarily aligned on a 16 bytes boundary...\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, false,true>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    return internal::pmul(a, pconj(b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, true,false>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    return internal::pmul(pconj(a), b);\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, true,true>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    return pconj(internal::pmul(a, b));\n  }\n};\ntemplate<> struct conj_helper<Packet2d, Packet1cd, false,false>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet2d& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet2d& x, const Packet1cd& y) const\n  { return Packet1cd(internal::pmul<Packet2d>(x, y.v)); }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet2d, false,false>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet2d& y, const Packet1cd& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& x, const Packet2d& y) const\n  { return Packet1cd(internal::pmul<Packet2d>(x.v, y)); }\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  // TODO optimize it for AltiVec\n  Packet1cd res = conj_helper<Packet1cd,Packet1cd,false,true>().pmul(a,b);\n  Packet2d s = pmul<Packet2d>(b.v, b.v);\n  return Packet1cd(pdiv(res.v, padd<Packet2d>(s, vec_perm(s, s, p16uc_REVERSE64))));\n}\n\nEIGEN_STRONG_INLINE Packet1cd pcplxflip/*<Packet1cd>*/(const Packet1cd& x)\n{\n  return Packet1cd(preverse(Packet2d(x.v)));\n}\n\nEIGEN_STRONG_INLINE void ptranspose(PacketBlock<Packet1cd,2>& kernel)\n{\n  Packet2d tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);\n  kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);\n  kernel.packet[0].v = tmp;\n}\n#endif // __VSX__\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_COMPLEX32_ALTIVEC_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/AltiVec/MathFunctions.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2007 Julien Pommier\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2016 Konstantinos Margaritis <markos@freevec.org>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* The sin, cos, exp, and log functions of this file come from\n * Julien Pommier's sse math library: http://gruntthepeon.free.fr/ssemath/\n */\n\n#ifndef EIGEN_MATH_FUNCTIONS_ALTIVEC_H\n#define EIGEN_MATH_FUNCTIONS_ALTIVEC_H\n\nnamespace Eigen {\n\nnamespace internal {\n\nstatic _EIGEN_DECLARE_CONST_Packet4f(1 , 1.0f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(half, 0.5f);\nstatic _EIGEN_DECLARE_CONST_Packet4i(0x7f, 0x7f);\nstatic _EIGEN_DECLARE_CONST_Packet4i(23, 23);\n\nstatic _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(inv_mant_mask, ~0x7f800000);\n\n/* the smallest non denormalized float number */\nstatic _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(min_norm_pos,  0x00800000);\nstatic _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(minus_inf,     0xff800000); // -1.f/0.f\nstatic _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(minus_nan,     0xffffffff);\n  \n/* natural logarithm computed for 4 simultaneous float\n  return NaN for x <= 0\n*/\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_SQRTHF, 0.707106781186547524f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p0, 7.0376836292E-2f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p1, - 1.1514610310E-1f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p2, 1.1676998740E-1f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p3, - 1.2420140846E-1f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p4, + 1.4249322787E-1f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p5, - 1.6668057665E-1f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p6, + 2.0000714765E-1f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p7, - 2.4999993993E-1f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p8, + 3.3333331174E-1f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_log_q1, -2.12194440e-4f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_log_q2, 0.693359375f);\n\nstatic _EIGEN_DECLARE_CONST_Packet4f(exp_hi,  88.3762626647950f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(exp_lo, -88.3762626647949f);\n\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_LOG2EF, 1.44269504088896341f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_C1, 0.693359375f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_C2, -2.12194440e-4f);\n\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p0, 1.9875691500E-4f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p1, 1.3981999507E-3f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p2, 8.3334519073E-3f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p3, 4.1665795894E-2f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p4, 1.6666665459E-1f);\nstatic _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p5, 5.0000001201E-1f);\n\n#ifdef __VSX__\nstatic _EIGEN_DECLARE_CONST_Packet2d(1 , 1.0);\nstatic _EIGEN_DECLARE_CONST_Packet2d(2 , 2.0);\nstatic _EIGEN_DECLARE_CONST_Packet2d(half, 0.5);\n\nstatic _EIGEN_DECLARE_CONST_Packet2d(exp_hi,  709.437);\nstatic _EIGEN_DECLARE_CONST_Packet2d(exp_lo, -709.436139303);\n\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_LOG2EF, 1.4426950408889634073599);\n\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_p0, 1.26177193074810590878e-4);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_p1, 3.02994407707441961300e-2);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_p2, 9.99999999999999999910e-1);\n\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q0, 3.00198505138664455042e-6);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q1, 2.52448340349684104192e-3);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q2, 2.27265548208155028766e-1);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q3, 2.00000000000000000009e0);\n\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_C1, 0.693145751953125);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_C2, 1.42860682030941723212e-6);\n\n#ifdef __POWER8_VECTOR__\nstatic Packet2l p2l_1023 = { 1023, 1023 };\nstatic Packet2ul p2ul_52 = { 52, 52 };\n#endif\n\n#endif\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f plog<Packet4f>(const Packet4f& _x)\n{\n  Packet4f x = _x;\n\n  Packet4i emm0;\n\n  /* isvalid_mask is 0 if x < 0 or x is NaN. */\n  Packet4ui isvalid_mask = reinterpret_cast<Packet4ui>(vec_cmpge(x, p4f_ZERO));\n  Packet4ui iszero_mask = reinterpret_cast<Packet4ui>(vec_cmpeq(x, p4f_ZERO));\n\n  x = pmax(x, p4f_min_norm_pos);  /* cut off denormalized stuff */\n  emm0 = vec_sr(reinterpret_cast<Packet4i>(x),\n                reinterpret_cast<Packet4ui>(p4i_23));\n\n  /* keep only the fractional part */\n  x = pand(x, p4f_inv_mant_mask);\n  x = por(x, p4f_half);\n\n  emm0 = psub(emm0, p4i_0x7f);\n  Packet4f e = padd(vec_ctf(emm0, 0), p4f_1);\n\n  /* part2:\n     if( x < SQRTHF ) {\n       e -= 1;\n       x = x + x - 1.0;\n     } else { x = x - 1.0; }\n  */\n  Packet4f mask = reinterpret_cast<Packet4f>(vec_cmplt(x, p4f_cephes_SQRTHF));\n  Packet4f tmp = pand(x, mask);\n  x = psub(x, p4f_1);\n  e = psub(e, pand(p4f_1, mask));\n  x = padd(x, tmp);\n\n  Packet4f x2 = pmul(x,x);\n  Packet4f x3 = pmul(x2,x);\n\n  Packet4f y, y1, y2;\n  y  = pmadd(p4f_cephes_log_p0, x, p4f_cephes_log_p1);\n  y1 = pmadd(p4f_cephes_log_p3, x, p4f_cephes_log_p4);\n  y2 = pmadd(p4f_cephes_log_p6, x, p4f_cephes_log_p7);\n  y  = pmadd(y , x, p4f_cephes_log_p2);\n  y1 = pmadd(y1, x, p4f_cephes_log_p5);\n  y2 = pmadd(y2, x, p4f_cephes_log_p8);\n  y = pmadd(y, x3, y1);\n  y = pmadd(y, x3, y2);\n  y = pmul(y, x3);\n\n  y1 = pmul(e, p4f_cephes_log_q1);\n  tmp = pmul(x2, p4f_half);\n  y = padd(y, y1);\n  x = psub(x, tmp);\n  y2 = pmul(e, p4f_cephes_log_q2);\n  x = padd(x, y);\n  x = padd(x, y2);\n  // negative arg will be NAN, 0 will be -INF\n  x = vec_sel(x, p4f_minus_inf, iszero_mask);\n  x = vec_sel(p4f_minus_nan, x, isvalid_mask);\n  return x;\n}\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f pexp<Packet4f>(const Packet4f& _x)\n{\n  Packet4f x = _x;\n\n  Packet4f tmp, fx;\n  Packet4i emm0;\n\n  // clamp x\n  x = pmax(pmin(x, p4f_exp_hi), p4f_exp_lo);\n\n  // express exp(x) as exp(g + n*log(2))\n  fx = pmadd(x, p4f_cephes_LOG2EF, p4f_half);\n\n  fx = pfloor(fx);\n\n  tmp = pmul(fx, p4f_cephes_exp_C1);\n  Packet4f z = pmul(fx, p4f_cephes_exp_C2);\n  x = psub(x, tmp);\n  x = psub(x, z);\n\n  z = pmul(x,x);\n\n  Packet4f y = p4f_cephes_exp_p0;\n  y = pmadd(y, x, p4f_cephes_exp_p1);\n  y = pmadd(y, x, p4f_cephes_exp_p2);\n  y = pmadd(y, x, p4f_cephes_exp_p3);\n  y = pmadd(y, x, p4f_cephes_exp_p4);\n  y = pmadd(y, x, p4f_cephes_exp_p5);\n  y = pmadd(y, z, x);\n  y = padd(y, p4f_1);\n\n  // build 2^n\n  emm0 = vec_cts(fx, 0);\n  emm0 = vec_add(emm0, p4i_0x7f);\n  emm0 = vec_sl(emm0, reinterpret_cast<Packet4ui>(p4i_23));\n\n  // Altivec's max & min operators just drop silent NaNs. Check NaNs in \n  // inputs and return them unmodified.\n  Packet4ui isnumber_mask = reinterpret_cast<Packet4ui>(vec_cmpeq(_x, _x));\n  return vec_sel(_x, pmax(pmul(y, reinterpret_cast<Packet4f>(emm0)), _x),\n                 isnumber_mask);\n}\n\n#ifndef EIGEN_COMP_CLANG\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f prsqrt<Packet4f>(const Packet4f& x)\n{\n  return  vec_rsqrt(x);\n}\n#endif\n\n#ifdef __VSX__\n#ifndef EIGEN_COMP_CLANG\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket2d prsqrt<Packet2d>(const Packet2d& x)\n{\n  return  vec_rsqrt(x);\n}\n#endif\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f psqrt<Packet4f>(const Packet4f& x)\n{\n  return  vec_sqrt(x);\n}\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket2d psqrt<Packet2d>(const Packet2d& x)\n{\n  return  vec_sqrt(x);\n}\n\n// VSX support varies between different compilers and even different\n// versions of the same compiler.  For gcc version >= 4.9.3, we can use\n// vec_cts to efficiently convert Packet2d to Packet2l.  Otherwise, use\n// a slow version that works with older compilers. \n// Update: apparently vec_cts/vec_ctf intrinsics for 64-bit doubles\n// are buggy, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70963\nstatic inline Packet2l ConvertToPacket2l(const Packet2d& x) {\n#if EIGEN_GNUC_AT_LEAST(5, 4) || \\\n    (EIGEN_GNUC_AT(6, 1) && __GNUC_PATCHLEVEL__ >= 1)\n  return vec_cts(x, 0);    // TODO: check clang version.\n#else\n  double tmp[2];\n  memcpy(tmp, &x, sizeof(tmp));\n  Packet2l l = { static_cast<long long>(tmp[0]),\n                 static_cast<long long>(tmp[1]) };\n  return l;\n#endif\n}\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket2d pexp<Packet2d>(const Packet2d& _x)\n{\n  Packet2d x = _x;\n\n  Packet2d tmp, fx;\n  Packet2l emm0;\n\n  // clamp x\n  x = pmax(pmin(x, p2d_exp_hi), p2d_exp_lo);\n\n  /* express exp(x) as exp(g + n*log(2)) */\n  fx = pmadd(x, p2d_cephes_LOG2EF, p2d_half);\n\n  fx = pfloor(fx);\n\n  tmp = pmul(fx, p2d_cephes_exp_C1);\n  Packet2d z = pmul(fx, p2d_cephes_exp_C2);\n  x = psub(x, tmp);\n  x = psub(x, z);\n\n  Packet2d x2 = pmul(x,x);\n\n  Packet2d px = p2d_cephes_exp_p0;\n  px = pmadd(px, x2, p2d_cephes_exp_p1);\n  px = pmadd(px, x2, p2d_cephes_exp_p2);\n  px = pmul (px, x);\n\n  Packet2d qx = p2d_cephes_exp_q0;\n  qx = pmadd(qx, x2, p2d_cephes_exp_q1);\n  qx = pmadd(qx, x2, p2d_cephes_exp_q2);\n  qx = pmadd(qx, x2, p2d_cephes_exp_q3);\n\n  x = pdiv(px,psub(qx,px));\n  x = pmadd(p2d_2,x,p2d_1);\n\n  // build 2^n\n  emm0 = ConvertToPacket2l(fx);\n\n#ifdef __POWER8_VECTOR__ \n  emm0 = vec_add(emm0, p2l_1023);\n  emm0 = vec_sl(emm0, p2ul_52);\n#else\n  // Code is a bit complex for POWER7.  There is actually a\n  // vec_xxsldi intrinsic but it is not supported by some gcc versions.\n  // So we shift (52-32) bits and do a word swap with zeros.\n  _EIGEN_DECLARE_CONST_Packet4i(1023, 1023);\n  _EIGEN_DECLARE_CONST_Packet4i(20, 20);    // 52 - 32\n\n  Packet4i emm04i = reinterpret_cast<Packet4i>(emm0);\n  emm04i = vec_add(emm04i, p4i_1023);\n  emm04i = vec_sl(emm04i, reinterpret_cast<Packet4ui>(p4i_20));\n  static const Packet16uc perm = {\n    0x14, 0x15, 0x16, 0x17, 0x00, 0x01, 0x02, 0x03, \n    0x1c, 0x1d, 0x1e, 0x1f, 0x08, 0x09, 0x0a, 0x0b };\n#ifdef  _BIG_ENDIAN\n  emm0 = reinterpret_cast<Packet2l>(vec_perm(p4i_ZERO, emm04i, perm));\n#else\n  emm0 = reinterpret_cast<Packet2l>(vec_perm(emm04i, p4i_ZERO, perm));\n#endif\n\n#endif\n\n  // Altivec's max & min operators just drop silent NaNs. Check NaNs in \n  // inputs and return them unmodified.\n  Packet2ul isnumber_mask = reinterpret_cast<Packet2ul>(vec_cmpeq(_x, _x));\n  return vec_sel(_x, pmax(pmul(x, reinterpret_cast<Packet2d>(emm0)), _x),\n                 isnumber_mask);\n}\n#endif\n\n}  // end namespace internal\n\n}  // end namespace Eigen\n\n#endif  // EIGEN_MATH_FUNCTIONS_ALTIVEC_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/AltiVec/PacketMath.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2016 Konstantinos Margaritis <markos@freevec.org>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PACKET_MATH_ALTIVEC_H\n#define EIGEN_PACKET_MATH_ALTIVEC_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD\n#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 4\n#endif\n\n#ifndef EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n#define EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n#endif\n\n#ifndef EIGEN_HAS_SINGLE_INSTRUCTION_CJMADD\n#define EIGEN_HAS_SINGLE_INSTRUCTION_CJMADD\n#endif\n\n// NOTE Altivec has 32 registers, but Eigen only accepts a value of 8 or 16\n#ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS\n#define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS  32\n#endif\n\ntypedef __vector float          Packet4f;\ntypedef __vector int            Packet4i;\ntypedef __vector unsigned int   Packet4ui;\ntypedef __vector __bool int     Packet4bi;\ntypedef __vector short int      Packet8i;\ntypedef __vector unsigned char  Packet16uc;\n\n// We don't want to write the same code all the time, but we need to reuse the constants\n// and it doesn't really work to declare them global, so we define macros instead\n\n#define _EIGEN_DECLARE_CONST_FAST_Packet4f(NAME,X) \\\n  Packet4f p4f_##NAME = reinterpret_cast<Packet4f>(vec_splat_s32(X))\n\n#define _EIGEN_DECLARE_CONST_FAST_Packet4i(NAME,X) \\\n  Packet4i p4i_##NAME = vec_splat_s32(X)\n\n#define _EIGEN_DECLARE_CONST_Packet4f(NAME,X) \\\n  Packet4f p4f_##NAME = pset1<Packet4f>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet4i(NAME,X) \\\n  Packet4i p4i_##NAME = pset1<Packet4i>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet2d(NAME,X) \\\n  Packet2d p2d_##NAME = pset1<Packet2d>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet2l(NAME,X) \\\n  Packet2l p2l_##NAME = pset1<Packet2l>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(NAME,X) \\\n  const Packet4f p4f_##NAME = reinterpret_cast<Packet4f>(pset1<Packet4i>(X))\n\n#define DST_CHAN 1\n#define DST_CTRL(size, count, stride) (((size) << 24) | ((count) << 16) | (stride))\n\n\n// These constants are endian-agnostic\nstatic _EIGEN_DECLARE_CONST_FAST_Packet4f(ZERO, 0); //{ 0.0, 0.0, 0.0, 0.0}\nstatic _EIGEN_DECLARE_CONST_FAST_Packet4i(ZERO, 0); //{ 0, 0, 0, 0,}\nstatic _EIGEN_DECLARE_CONST_FAST_Packet4i(ONE,1); //{ 1, 1, 1, 1}\nstatic _EIGEN_DECLARE_CONST_FAST_Packet4i(MINUS16,-16); //{ -16, -16, -16, -16}\nstatic _EIGEN_DECLARE_CONST_FAST_Packet4i(MINUS1,-1); //{ -1, -1, -1, -1}\nstatic Packet4f p4f_MZERO = (Packet4f) vec_sl((Packet4ui)p4i_MINUS1, (Packet4ui)p4i_MINUS1); //{ 0x80000000, 0x80000000, 0x80000000, 0x80000000}\n#ifndef __VSX__\nstatic Packet4f p4f_ONE = vec_ctf(p4i_ONE, 0); //{ 1.0, 1.0, 1.0, 1.0}\n#endif\n\nstatic Packet4f p4f_COUNTDOWN = { 0.0, 1.0, 2.0, 3.0 };\nstatic Packet4i p4i_COUNTDOWN = { 0, 1, 2, 3 };\n\nstatic Packet16uc p16uc_REVERSE32 = { 12,13,14,15, 8,9,10,11, 4,5,6,7, 0,1,2,3 };\nstatic Packet16uc p16uc_DUPLICATE32_HI = { 0,1,2,3, 0,1,2,3, 4,5,6,7, 4,5,6,7 };\n\n// Mask alignment\n#ifdef __PPC64__\n#define _EIGEN_MASK_ALIGNMENT\t0xfffffffffffffff0\n#else\n#define _EIGEN_MASK_ALIGNMENT\t0xfffffff0\n#endif\n\n#define _EIGEN_ALIGNED_PTR(x)\t((std::ptrdiff_t)(x) & _EIGEN_MASK_ALIGNMENT)\n\n// Handle endianness properly while loading constants\n// Define global static constants:\n#ifdef _BIG_ENDIAN\nstatic Packet16uc p16uc_FORWARD = vec_lvsl(0, (float*)0);\n#ifdef __VSX__\nstatic Packet16uc p16uc_REVERSE64 = { 8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7 };\n#endif\nstatic Packet16uc p16uc_PSET32_WODD   = vec_sld((Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 0), (Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 2), 8);//{ 0,1,2,3, 0,1,2,3, 8,9,10,11, 8,9,10,11 };\nstatic Packet16uc p16uc_PSET32_WEVEN  = vec_sld(p16uc_DUPLICATE32_HI, (Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 3), 8);//{ 4,5,6,7, 4,5,6,7, 12,13,14,15, 12,13,14,15 };\nstatic Packet16uc p16uc_HALF64_0_16 = vec_sld((Packet16uc)p4i_ZERO, vec_splat((Packet16uc) vec_abs(p4i_MINUS16), 3), 8);      //{ 0,0,0,0, 0,0,0,0, 16,16,16,16, 16,16,16,16};\n#else\nstatic Packet16uc p16uc_FORWARD = p16uc_REVERSE32; \nstatic Packet16uc p16uc_REVERSE64 = { 8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7 };\nstatic Packet16uc p16uc_PSET32_WODD = vec_sld((Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 1), (Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 3), 8);//{ 0,1,2,3, 0,1,2,3, 8,9,10,11, 8,9,10,11 };\nstatic Packet16uc p16uc_PSET32_WEVEN = vec_sld((Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 0), (Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 2), 8);//{ 4,5,6,7, 4,5,6,7, 12,13,14,15, 12,13,14,15 };\nstatic Packet16uc p16uc_HALF64_0_16 = vec_sld(vec_splat((Packet16uc) vec_abs(p4i_MINUS16), 0), (Packet16uc)p4i_ZERO, 8);      //{ 0,0,0,0, 0,0,0,0, 16,16,16,16, 16,16,16,16};\n#endif // _BIG_ENDIAN\n\nstatic Packet16uc p16uc_PSET64_HI = (Packet16uc) vec_mergeh((Packet4ui)p16uc_PSET32_WODD, (Packet4ui)p16uc_PSET32_WEVEN);     //{ 0,1,2,3, 4,5,6,7, 0,1,2,3, 4,5,6,7 };\nstatic Packet16uc p16uc_PSET64_LO = (Packet16uc) vec_mergel((Packet4ui)p16uc_PSET32_WODD, (Packet4ui)p16uc_PSET32_WEVEN);     //{ 8,9,10,11, 12,13,14,15, 8,9,10,11, 12,13,14,15 };\nstatic Packet16uc p16uc_TRANSPOSE64_HI = p16uc_PSET64_HI + p16uc_HALF64_0_16;                                         //{ 0,1,2,3, 4,5,6,7, 16,17,18,19, 20,21,22,23};\nstatic Packet16uc p16uc_TRANSPOSE64_LO = p16uc_PSET64_LO + p16uc_HALF64_0_16;                                         //{ 8,9,10,11, 12,13,14,15, 24,25,26,27, 28,29,30,31};\n\nstatic Packet16uc p16uc_COMPLEX32_REV = vec_sld(p16uc_REVERSE32, p16uc_REVERSE32, 8);                                         //{ 4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11 };\n\n#ifdef _BIG_ENDIAN\nstatic Packet16uc p16uc_COMPLEX32_REV2 = vec_sld(p16uc_FORWARD, p16uc_FORWARD, 8);                                            //{ 8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7 };\n#else\nstatic Packet16uc p16uc_COMPLEX32_REV2 = vec_sld(p16uc_PSET64_HI, p16uc_PSET64_LO, 8);                                            //{ 8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7 };\n#endif // _BIG_ENDIAN\n\n#if EIGEN_HAS_BUILTIN(__builtin_prefetch) || EIGEN_COMP_GNUC\n  #define EIGEN_PPC_PREFETCH(ADDR) __builtin_prefetch(ADDR);\n#else\n  #define EIGEN_PPC_PREFETCH(ADDR) asm( \"   dcbt [%[addr]]\\n\" :: [addr] \"r\" (ADDR) : \"cc\" );\n#endif\n\ntemplate<> struct packet_traits<float>  : default_packet_traits\n{\n  typedef Packet4f type;\n  typedef Packet4f half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=4,\n    HasHalfPacket = 1,\n\n    HasAdd  = 1,\n    HasSub  = 1,\n    HasMul  = 1,\n    HasDiv  = 1,\n    HasMin  = 1,\n    HasMax  = 1,\n    HasAbs  = 1,\n    HasSin  = 0,\n    HasCos  = 0,\n    HasLog  = 0,\n    HasExp  = 1,\n#ifdef __VSX__\n    HasSqrt = 1,\n#if !EIGEN_COMP_CLANG\n    HasRsqrt = 1,\n#else\n    HasRsqrt = 0,\n#endif\n#else\n    HasSqrt = 0,\n    HasRsqrt = 0,\n#endif\n    HasRound = 1,\n    HasFloor = 1,\n    HasCeil = 1,\n    HasNegate = 1,\n    HasBlend = 1\n  };\n};\ntemplate<> struct packet_traits<int>    : default_packet_traits\n{\n  typedef Packet4i type;\n  typedef Packet4i half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 4,\n    HasHalfPacket = 0,\n\n    HasAdd  = 1,\n    HasSub  = 1,\n    HasMul  = 1,\n    HasDiv  = 0,\n    HasBlend = 1\n  };\n};\n\n\ntemplate<> struct unpacket_traits<Packet4f> { typedef float  type; enum {size=4, alignment=Aligned16}; typedef Packet4f half; };\ntemplate<> struct unpacket_traits<Packet4i> { typedef int    type; enum {size=4, alignment=Aligned16}; typedef Packet4i half; };\n\ninline std::ostream & operator <<(std::ostream & s, const Packet16uc & v)\n{\n  union {\n    Packet16uc   v;\n    unsigned char n[16];\n  } vt;\n  vt.v = v;\n  for (int i=0; i< 16; i++)\n    s << (int)vt.n[i] << \", \";\n  return s;\n}\n\ninline std::ostream & operator <<(std::ostream & s, const Packet4f & v)\n{\n  union {\n    Packet4f   v;\n    float n[4];\n  } vt;\n  vt.v = v;\n  s << vt.n[0] << \", \" << vt.n[1] << \", \" << vt.n[2] << \", \" << vt.n[3];\n  return s;\n}\n\ninline std::ostream & operator <<(std::ostream & s, const Packet4i & v)\n{\n  union {\n    Packet4i   v;\n    int n[4];\n  } vt;\n  vt.v = v;\n  s << vt.n[0] << \", \" << vt.n[1] << \", \" << vt.n[2] << \", \" << vt.n[3];\n  return s;\n}\n\ninline std::ostream & operator <<(std::ostream & s, const Packet4ui & v)\n{\n  union {\n    Packet4ui   v;\n    unsigned int n[4];\n  } vt;\n  vt.v = v;\n  s << vt.n[0] << \", \" << vt.n[1] << \", \" << vt.n[2] << \", \" << vt.n[3];\n  return s;\n}\n\n// Need to define them first or we get specialization after instantiation errors\ntemplate<> EIGEN_STRONG_INLINE Packet4f pload<Packet4f>(const float* from)\n{\n  EIGEN_DEBUG_ALIGNED_LOAD\n#ifdef __VSX__\n  return vec_vsx_ld(0, from);\n#else\n  return vec_ld(0, from);\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pload<Packet4i>(const int*     from)\n{\n  EIGEN_DEBUG_ALIGNED_LOAD\n#ifdef __VSX__\n  return vec_vsx_ld(0, from);\n#else\n  return vec_ld(0, from);\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<float>(float*   to, const Packet4f& from)\n{\n  EIGEN_DEBUG_ALIGNED_STORE\n#ifdef __VSX__\n  vec_vsx_st(from, 0, to);\n#else\n  vec_st(from, 0, to);\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<int>(int*       to, const Packet4i& from)\n{\n  EIGEN_DEBUG_ALIGNED_STORE\n#ifdef __VSX__\n  vec_vsx_st(from, 0, to);\n#else\n  vec_st(from, 0, to);\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float&  from) {\n  Packet4f v = {from, from, from, from};\n  return v;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(const int&    from)   {\n  Packet4i v = {from, from, from, from};\n  return v;\n}\ntemplate<> EIGEN_STRONG_INLINE void\npbroadcast4<Packet4f>(const float *a,\n                      Packet4f& a0, Packet4f& a1, Packet4f& a2, Packet4f& a3)\n{\n  a3 = pload<Packet4f>(a);\n  a0 = vec_splat(a3, 0);\n  a1 = vec_splat(a3, 1);\n  a2 = vec_splat(a3, 2);\n  a3 = vec_splat(a3, 3);\n}\ntemplate<> EIGEN_STRONG_INLINE void\npbroadcast4<Packet4i>(const int *a,\n                      Packet4i& a0, Packet4i& a1, Packet4i& a2, Packet4i& a3)\n{\n  a3 = pload<Packet4i>(a);\n  a0 = vec_splat(a3, 0);\n  a1 = vec_splat(a3, 1);\n  a2 = vec_splat(a3, 2);\n  a3 = vec_splat(a3, 3);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, Index stride)\n{\n  float EIGEN_ALIGN16 af[4];\n  af[0] = from[0*stride];\n  af[1] = from[1*stride];\n  af[2] = from[2*stride];\n  af[3] = from[3*stride];\n return pload<Packet4f>(af);\n}\ntemplate<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, Index stride)\n{\n  int EIGEN_ALIGN16 ai[4];\n  ai[0] = from[0*stride];\n  ai[1] = from[1*stride];\n  ai[2] = from[2*stride];\n  ai[3] = from[3*stride];\n return pload<Packet4i>(ai);\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, Index stride)\n{\n  float EIGEN_ALIGN16 af[4];\n  pstore<float>(af, from);\n  to[0*stride] = af[0];\n  to[1*stride] = af[1];\n  to[2*stride] = af[2];\n  to[3*stride] = af[3];\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, Index stride)\n{\n  int EIGEN_ALIGN16 ai[4];\n  pstore<int>((int *)ai, from);\n  to[0*stride] = ai[0];\n  to[1*stride] = ai[1];\n  to[2*stride] = ai[2];\n  to[3*stride] = ai[3];\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f plset<Packet4f>(const float& a) { return pset1<Packet4f>(a) + p4f_COUNTDOWN; }\ntemplate<> EIGEN_STRONG_INLINE Packet4i plset<Packet4i>(const int& a)   { return pset1<Packet4i>(a) + p4i_COUNTDOWN; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f padd<Packet4f>(const Packet4f& a, const Packet4f& b) { return a + b; }\ntemplate<> EIGEN_STRONG_INLINE Packet4i padd<Packet4i>(const Packet4i& a, const Packet4i& b) { return a + b; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f psub<Packet4f>(const Packet4f& a, const Packet4f& b) { return a - b; }\ntemplate<> EIGEN_STRONG_INLINE Packet4i psub<Packet4i>(const Packet4i& a, const Packet4i& b) { return a - b; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pnegate(const Packet4f& a) { return p4f_ZERO - a; }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pnegate(const Packet4i& a) { return p4i_ZERO - a; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pconj(const Packet4f& a) { return a; }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pconj(const Packet4i& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmul<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_madd(a,b, p4f_MZERO); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmul<Packet4i>(const Packet4i& a, const Packet4i& b) { return a * b; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pdiv<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n#ifndef __VSX__  // VSX actually provides a div instruction\n  Packet4f t, y_0, y_1;\n\n  // Altivec does not offer a divide instruction, we have to do a reciprocal approximation\n  y_0 = vec_re(b);\n\n  // Do one Newton-Raphson iteration to get the needed accuracy\n  t   = vec_nmsub(y_0, b, p4f_ONE);\n  y_1 = vec_madd(y_0, t, y_0);\n\n  return vec_madd(a, y_1, p4f_MZERO);\n#else\n  return vec_div(a, b);\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pdiv<Packet4i>(const Packet4i& /*a*/, const Packet4i& /*b*/)\n{ eigen_assert(false && \"packet integer division are not supported by AltiVec\");\n  return pset1<Packet4i>(0);\n}\n\n// for some weird raisons, it has to be overloaded for packet of integers\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmadd(const Packet4f& a, const Packet4f& b, const Packet4f& c) { return vec_madd(a,b,c); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmadd(const Packet4i& a, const Packet4i& b, const Packet4i& c) { return a*b + c; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmin<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_min(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmin<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_min(a, b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmax<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_max(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmax<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_max(a, b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pand<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_and(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pand<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_and(a, b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f por<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_or(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i por<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_or(a, b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pxor<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_xor(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pxor<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_xor(a, b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pandnot<Packet4f>(const Packet4f& a, const Packet4f& b) { return vec_and(a, vec_nor(b, b)); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_and(a, vec_nor(b, b)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pround<Packet4f>(const Packet4f& a) { return vec_round(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pceil<Packet4f>(const  Packet4f& a) { return vec_ceil(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pfloor<Packet4f>(const Packet4f& a) { return vec_floor(a); }\n\n#ifdef _BIG_ENDIAN\ntemplate<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float* from)\n{\n  EIGEN_DEBUG_ALIGNED_LOAD\n  Packet16uc MSQ, LSQ;\n  Packet16uc mask;\n  MSQ = vec_ld(0, (unsigned char *)from);          // most significant quadword\n  LSQ = vec_ld(15, (unsigned char *)from);         // least significant quadword\n  mask = vec_lvsl(0, from);                        // create the permute mask\n  return (Packet4f) vec_perm(MSQ, LSQ, mask);           // align the data\n\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i ploadu<Packet4i>(const int* from)\n{\n  EIGEN_DEBUG_ALIGNED_LOAD\n  // Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html\n  Packet16uc MSQ, LSQ;\n  Packet16uc mask;\n  MSQ = vec_ld(0, (unsigned char *)from);          // most significant quadword\n  LSQ = vec_ld(15, (unsigned char *)from);         // least significant quadword\n  mask = vec_lvsl(0, from);                        // create the permute mask\n  return (Packet4i) vec_perm(MSQ, LSQ, mask);    // align the data\n}\n#else\n// We also need ot redefine little endian loading of Packet4i/Packet4f using VSX\ntemplate<> EIGEN_STRONG_INLINE Packet4i ploadu<Packet4i>(const int* from)\n{\n  EIGEN_DEBUG_UNALIGNED_LOAD\n  return (Packet4i) vec_vsx_ld((long)from & 15, (const int*) _EIGEN_ALIGNED_PTR(from));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float* from)\n{\n  EIGEN_DEBUG_UNALIGNED_LOAD\n  return (Packet4f) vec_vsx_ld((long)from & 15, (const float*) _EIGEN_ALIGNED_PTR(from));\n}\n#endif\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f ploaddup<Packet4f>(const float*   from)\n{\n  Packet4f p;\n  if((std::ptrdiff_t(from) % 16) == 0)  p = pload<Packet4f>(from);\n  else                                  p = ploadu<Packet4f>(from);\n  return vec_perm(p, p, p16uc_DUPLICATE32_HI);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i ploaddup<Packet4i>(const int*     from)\n{\n  Packet4i p;\n  if((std::ptrdiff_t(from) % 16) == 0)  p = pload<Packet4i>(from);\n  else                                  p = ploadu<Packet4i>(from);\n  return vec_perm(p, p, p16uc_DUPLICATE32_HI);\n}\n\n#ifdef _BIG_ENDIAN\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<float>(float*  to, const Packet4f& from)\n{\n  EIGEN_DEBUG_UNALIGNED_STORE\n  // Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html\n  // Warning: not thread safe!\n  Packet16uc MSQ, LSQ, edges;\n  Packet16uc edgeAlign, align;\n\n  MSQ = vec_ld(0, (unsigned char *)to);                     // most significant quadword\n  LSQ = vec_ld(15, (unsigned char *)to);                    // least significant quadword\n  edgeAlign = vec_lvsl(0, to);                              // permute map to extract edges\n  edges=vec_perm(LSQ,MSQ,edgeAlign);                        // extract the edges\n  align = vec_lvsr( 0, to );                                // permute map to misalign data\n  MSQ = vec_perm(edges,(Packet16uc)from,align);             // misalign the data (MSQ)\n  LSQ = vec_perm((Packet16uc)from,edges,align);             // misalign the data (LSQ)\n  vec_st( LSQ, 15, (unsigned char *)to );                   // Store the LSQ part first\n  vec_st( MSQ, 0, (unsigned char *)to );                    // Store the MSQ part\n}\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<int>(int*      to, const Packet4i& from)\n{\n  EIGEN_DEBUG_UNALIGNED_STORE\n  // Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html\n  // Warning: not thread safe!\n  Packet16uc MSQ, LSQ, edges;\n  Packet16uc edgeAlign, align;\n\n  MSQ = vec_ld(0, (unsigned char *)to);                     // most significant quadword\n  LSQ = vec_ld(15, (unsigned char *)to);                    // least significant quadword\n  edgeAlign = vec_lvsl(0, to);                              // permute map to extract edges\n  edges=vec_perm(LSQ, MSQ, edgeAlign);                      // extract the edges\n  align = vec_lvsr( 0, to );                                // permute map to misalign data\n  MSQ = vec_perm(edges, (Packet16uc) from, align);          // misalign the data (MSQ)\n  LSQ = vec_perm((Packet16uc) from, edges, align);          // misalign the data (LSQ)\n  vec_st( LSQ, 15, (unsigned char *)to );                   // Store the LSQ part first\n  vec_st( MSQ, 0, (unsigned char *)to );                    // Store the MSQ part\n}\n#else\n// We also need ot redefine little endian loading of Packet4i/Packet4f using VSX\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<int>(int*       to, const Packet4i& from)\n{\n  EIGEN_DEBUG_ALIGNED_STORE\n  vec_vsx_st(from, (long)to & 15, (int*) _EIGEN_ALIGNED_PTR(to));\n}\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<float>(float*   to, const Packet4f& from)\n{\n  EIGEN_DEBUG_ALIGNED_STORE\n  vec_vsx_st(from, (long)to & 15, (float*) _EIGEN_ALIGNED_PTR(to));\n}\n#endif\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<float>(const float* addr)    { EIGEN_PPC_PREFETCH(addr); }\ntemplate<> EIGEN_STRONG_INLINE void prefetch<int>(const int*     addr)    { EIGEN_PPC_PREFETCH(addr); }\n\ntemplate<> EIGEN_STRONG_INLINE float  pfirst<Packet4f>(const Packet4f& a) { float EIGEN_ALIGN16 x; vec_ste(a, 0, &x); return x; }\ntemplate<> EIGEN_STRONG_INLINE int    pfirst<Packet4i>(const Packet4i& a) { int   EIGEN_ALIGN16 x; vec_ste(a, 0, &x); return x; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f preverse(const Packet4f& a)\n{\n  return reinterpret_cast<Packet4f>(vec_perm(reinterpret_cast<Packet16uc>(a), reinterpret_cast<Packet16uc>(a), p16uc_REVERSE32));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i preverse(const Packet4i& a)\n{\n  return reinterpret_cast<Packet4i>(vec_perm(reinterpret_cast<Packet16uc>(a), reinterpret_cast<Packet16uc>(a), p16uc_REVERSE32)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pabs(const Packet4f& a) { return vec_abs(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pabs(const Packet4i& a) { return vec_abs(a); }\n\ntemplate<> EIGEN_STRONG_INLINE float predux<Packet4f>(const Packet4f& a)\n{\n  Packet4f b, sum;\n  b   = vec_sld(a, a, 8);\n  sum = a + b;\n  b   = vec_sld(sum, sum, 4);\n  sum += b;\n  return pfirst(sum);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f preduxp<Packet4f>(const Packet4f* vecs)\n{\n  Packet4f v[4], sum[4];\n\n  // It's easier and faster to transpose then add as columns\n  // Check: http://www.freevec.org/function/matrix_4x4_transpose_floats for explanation\n  // Do the transpose, first set of moves\n  v[0] = vec_mergeh(vecs[0], vecs[2]);\n  v[1] = vec_mergel(vecs[0], vecs[2]);\n  v[2] = vec_mergeh(vecs[1], vecs[3]);\n  v[3] = vec_mergel(vecs[1], vecs[3]);\n  // Get the resulting vectors\n  sum[0] = vec_mergeh(v[0], v[2]);\n  sum[1] = vec_mergel(v[0], v[2]);\n  sum[2] = vec_mergeh(v[1], v[3]);\n  sum[3] = vec_mergel(v[1], v[3]);\n\n  // Now do the summation:\n  // Lines 0+1\n  sum[0] = sum[0] + sum[1];\n  // Lines 2+3\n  sum[1] = sum[2] + sum[3];\n  // Add the results\n  sum[0] = sum[0] + sum[1];\n\n  return sum[0];\n}\n\ntemplate<> EIGEN_STRONG_INLINE int predux<Packet4i>(const Packet4i& a)\n{\n  Packet4i sum;\n  sum = vec_sums(a, p4i_ZERO);\n#ifdef _BIG_ENDIAN\n  sum = vec_sld(sum, p4i_ZERO, 12);\n#else\n  sum = vec_sld(p4i_ZERO, sum, 4);\n#endif\n  return pfirst(sum);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i preduxp<Packet4i>(const Packet4i* vecs)\n{\n  Packet4i v[4], sum[4];\n\n  // It's easier and faster to transpose then add as columns\n  // Check: http://www.freevec.org/function/matrix_4x4_transpose_floats for explanation\n  // Do the transpose, first set of moves\n  v[0] = vec_mergeh(vecs[0], vecs[2]);\n  v[1] = vec_mergel(vecs[0], vecs[2]);\n  v[2] = vec_mergeh(vecs[1], vecs[3]);\n  v[3] = vec_mergel(vecs[1], vecs[3]);\n  // Get the resulting vectors\n  sum[0] = vec_mergeh(v[0], v[2]);\n  sum[1] = vec_mergel(v[0], v[2]);\n  sum[2] = vec_mergeh(v[1], v[3]);\n  sum[3] = vec_mergel(v[1], v[3]);\n\n  // Now do the summation:\n  // Lines 0+1\n  sum[0] = sum[0] + sum[1];\n  // Lines 2+3\n  sum[1] = sum[2] + sum[3];\n  // Add the results\n  sum[0] = sum[0] + sum[1];\n\n  return sum[0];\n}\n\n// Other reduction functions:\n// mul\ntemplate<> EIGEN_STRONG_INLINE float predux_mul<Packet4f>(const Packet4f& a)\n{\n  Packet4f prod;\n  prod = pmul(a, vec_sld(a, a, 8));\n  return pfirst(pmul(prod, vec_sld(prod, prod, 4)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE int predux_mul<Packet4i>(const Packet4i& a)\n{\n  EIGEN_ALIGN16 int aux[4];\n  pstore(aux, a);\n  return aux[0] * aux[1] * aux[2] * aux[3];\n}\n\n// min\ntemplate<> EIGEN_STRONG_INLINE float predux_min<Packet4f>(const Packet4f& a)\n{\n  Packet4f b, res;\n  b = vec_min(a, vec_sld(a, a, 8));\n  res = vec_min(b, vec_sld(b, b, 4));\n  return pfirst(res);\n}\n\ntemplate<> EIGEN_STRONG_INLINE int predux_min<Packet4i>(const Packet4i& a)\n{\n  Packet4i b, res;\n  b = vec_min(a, vec_sld(a, a, 8));\n  res = vec_min(b, vec_sld(b, b, 4));\n  return pfirst(res);\n}\n\n// max\ntemplate<> EIGEN_STRONG_INLINE float predux_max<Packet4f>(const Packet4f& a)\n{\n  Packet4f b, res;\n  b = vec_max(a, vec_sld(a, a, 8));\n  res = vec_max(b, vec_sld(b, b, 4));\n  return pfirst(res);\n}\n\ntemplate<> EIGEN_STRONG_INLINE int predux_max<Packet4i>(const Packet4i& a)\n{\n  Packet4i b, res;\n  b = vec_max(a, vec_sld(a, a, 8));\n  res = vec_max(b, vec_sld(b, b, 4));\n  return pfirst(res);\n}\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet4f>\n{\n  static EIGEN_STRONG_INLINE void run(Packet4f& first, const Packet4f& second)\n  {\n#ifdef _BIG_ENDIAN\n    switch (Offset % 4) {\n    case 1:\n      first = vec_sld(first, second, 4); break;\n    case 2:\n      first = vec_sld(first, second, 8); break;\n    case 3:\n      first = vec_sld(first, second, 12); break;\n    }\n#else\n    switch (Offset % 4) {\n    case 1:\n      first = vec_sld(second, first, 12); break;\n    case 2:\n      first = vec_sld(second, first, 8); break;\n    case 3:\n      first = vec_sld(second, first, 4); break;\n    }\n#endif\n  }\n};\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet4i>\n{\n  static EIGEN_STRONG_INLINE void run(Packet4i& first, const Packet4i& second)\n  {\n#ifdef _BIG_ENDIAN\n    switch (Offset % 4) {\n    case 1:\n      first = vec_sld(first, second, 4); break;\n    case 2:\n      first = vec_sld(first, second, 8); break;\n    case 3:\n      first = vec_sld(first, second, 12); break;\n    }\n#else\n    switch (Offset % 4) {\n    case 1:\n      first = vec_sld(second, first, 12); break;\n    case 2:\n      first = vec_sld(second, first, 8); break;\n    case 3:\n      first = vec_sld(second, first, 4); break;\n    }\n#endif\n  }\n};\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet4f,4>& kernel) {\n  Packet4f t0, t1, t2, t3;\n  t0 = vec_mergeh(kernel.packet[0], kernel.packet[2]);\n  t1 = vec_mergel(kernel.packet[0], kernel.packet[2]);\n  t2 = vec_mergeh(kernel.packet[1], kernel.packet[3]);\n  t3 = vec_mergel(kernel.packet[1], kernel.packet[3]);\n  kernel.packet[0] = vec_mergeh(t0, t2);\n  kernel.packet[1] = vec_mergel(t0, t2);\n  kernel.packet[2] = vec_mergeh(t1, t3);\n  kernel.packet[3] = vec_mergel(t1, t3);\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet4i,4>& kernel) {\n  Packet4i t0, t1, t2, t3;\n  t0 = vec_mergeh(kernel.packet[0], kernel.packet[2]);\n  t1 = vec_mergel(kernel.packet[0], kernel.packet[2]);\n  t2 = vec_mergeh(kernel.packet[1], kernel.packet[3]);\n  t3 = vec_mergel(kernel.packet[1], kernel.packet[3]);\n  kernel.packet[0] = vec_mergeh(t0, t2);\n  kernel.packet[1] = vec_mergel(t0, t2);\n  kernel.packet[2] = vec_mergeh(t1, t3);\n  kernel.packet[3] = vec_mergel(t1, t3);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pblend(const Selector<4>& ifPacket, const Packet4i& thenPacket, const Packet4i& elsePacket) {\n  Packet4ui select = { ifPacket.select[0], ifPacket.select[1], ifPacket.select[2], ifPacket.select[3] };\n  Packet4ui mask = reinterpret_cast<Packet4ui>(vec_cmpeq(reinterpret_cast<Packet4ui>(select), reinterpret_cast<Packet4ui>(p4i_ONE)));\n  return vec_sel(elsePacket, thenPacket, mask);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pblend(const Selector<4>& ifPacket, const Packet4f& thenPacket, const Packet4f& elsePacket) {\n  Packet4ui select = { ifPacket.select[0], ifPacket.select[1], ifPacket.select[2], ifPacket.select[3] };\n  Packet4ui mask = reinterpret_cast<Packet4ui>(vec_cmpeq(reinterpret_cast<Packet4ui>(select), reinterpret_cast<Packet4ui>(p4i_ONE)));\n  return vec_sel(elsePacket, thenPacket, mask);\n}\n\n\n//---------- double ----------\n#ifdef __VSX__\ntypedef __vector double              Packet2d;\ntypedef __vector unsigned long long  Packet2ul;\ntypedef __vector long long           Packet2l;\n#if EIGEN_COMP_CLANG\ntypedef Packet2ul                    Packet2bl;\n#else\ntypedef __vector __bool long         Packet2bl;\n#endif\n\nstatic Packet2l  p2l_ONE  = { 1, 1 };\nstatic Packet2l  p2l_ZERO = reinterpret_cast<Packet2l>(p4i_ZERO);\nstatic Packet2d  p2d_ONE  = { 1.0, 1.0 }; \nstatic Packet2d  p2d_ZERO = reinterpret_cast<Packet2d>(p4f_ZERO);\nstatic Packet2d  p2d_MZERO = { -0.0, -0.0 };\n\n#ifdef _BIG_ENDIAN\nstatic Packet2d p2d_COUNTDOWN = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4f>(p2d_ZERO), reinterpret_cast<Packet4f>(p2d_ONE), 8));\n#else\nstatic Packet2d p2d_COUNTDOWN = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4f>(p2d_ONE), reinterpret_cast<Packet4f>(p2d_ZERO), 8));\n#endif\n\ntemplate<int index> Packet2d vec_splat_dbl(Packet2d& a);\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d vec_splat_dbl<0>(Packet2d& a)\n{\n  return reinterpret_cast<Packet2d>(vec_perm(a, a, p16uc_PSET64_HI));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d vec_splat_dbl<1>(Packet2d& a)\n{\n  return reinterpret_cast<Packet2d>(vec_perm(a, a, p16uc_PSET64_LO));\n}\n\ntemplate<> struct packet_traits<double> : default_packet_traits\n{\n  typedef Packet2d type;\n  typedef Packet2d half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=2,\n    HasHalfPacket = 1,\n\n    HasAdd  = 1,\n    HasSub  = 1,\n    HasMul  = 1,\n    HasDiv  = 1,\n    HasMin  = 1,\n    HasMax  = 1,\n    HasAbs  = 1,\n    HasSin  = 0,\n    HasCos  = 0,\n    HasLog  = 0,\n    HasExp  = 1,\n    HasSqrt = 1,\n    HasRsqrt = 1,\n    HasRound = 1,\n    HasFloor = 1,\n    HasCeil = 1,\n    HasNegate = 1,\n    HasBlend = 1\n  };\n};\n\ntemplate<> struct unpacket_traits<Packet2d> { typedef double type; enum {size=2, alignment=Aligned16}; typedef Packet2d half; };\n\ninline std::ostream & operator <<(std::ostream & s, const Packet2l & v)\n{\n  union {\n    Packet2l   v;\n    int64_t n[2];\n  } vt;\n  vt.v = v;\n  s << vt.n[0] << \", \" << vt.n[1];\n  return s;\n}\n\ninline std::ostream & operator <<(std::ostream & s, const Packet2d & v)\n{\n  union {\n    Packet2d   v;\n    double n[2];\n  } vt;\n  vt.v = v;\n  s << vt.n[0] << \", \" << vt.n[1];\n  return s;\n}\n\n// Need to define them first or we get specialization after instantiation errors\ntemplate<> EIGEN_STRONG_INLINE Packet2d pload<Packet2d>(const double* from)\n{\n  EIGEN_DEBUG_ALIGNED_LOAD\n#ifdef __VSX__\n  return vec_vsx_ld(0, from);\n#else\n  return vec_ld(0, from);\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<double>(double*   to, const Packet2d& from)\n{\n  EIGEN_DEBUG_ALIGNED_STORE\n#ifdef __VSX__\n  vec_vsx_st(from, 0, to);\n#else\n  vec_st(from, 0, to);\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pset1<Packet2d>(const double&  from) {\n  Packet2d v = {from, from};\n  return v;\n}\n\ntemplate<> EIGEN_STRONG_INLINE void\npbroadcast4<Packet2d>(const double *a,\n                      Packet2d& a0, Packet2d& a1, Packet2d& a2, Packet2d& a3)\n{\n  a1 = pload<Packet2d>(a);\n  a0 = vec_splat_dbl<0>(a1);\n  a1 = vec_splat_dbl<1>(a1);\n  a3 = pload<Packet2d>(a+2);\n  a2 = vec_splat_dbl<0>(a3);\n  a3 = vec_splat_dbl<1>(a3);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, Index stride)\n{\n  double EIGEN_ALIGN16 af[2];\n  af[0] = from[0*stride];\n  af[1] = from[1*stride];\n return pload<Packet2d>(af);\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, Index stride)\n{\n  double EIGEN_ALIGN16 af[2];\n  pstore<double>(af, from);\n  to[0*stride] = af[0];\n  to[1*stride] = af[1];\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d plset<Packet2d>(const double& a) { return pset1<Packet2d>(a) + p2d_COUNTDOWN; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d padd<Packet2d>(const Packet2d& a, const Packet2d& b) { return a + b; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d psub<Packet2d>(const Packet2d& a, const Packet2d& b) { return a - b; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pnegate(const Packet2d& a) { return p2d_ZERO - a; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pconj(const Packet2d& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmul<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_madd(a,b,p2d_MZERO); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pdiv<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_div(a,b); }\n\n// for some weird raisons, it has to be overloaded for packet of integers\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmadd(const Packet2d& a, const Packet2d& b, const Packet2d& c) { return vec_madd(a, b, c); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmin<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_min(a, b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmax<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_max(a, b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pand<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_and(a, b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d por<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_or(a, b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pxor<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_xor(a, b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pandnot<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_and(a, vec_nor(b, b)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pround<Packet2d>(const Packet2d& a) { return vec_round(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pceil<Packet2d>(const  Packet2d& a) { return vec_ceil(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pfloor<Packet2d>(const Packet2d& a) { return vec_floor(a); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d ploadu<Packet2d>(const double* from)\n{\n  EIGEN_DEBUG_ALIGNED_LOAD\n  return (Packet2d) vec_vsx_ld((long)from & 15, (const double*) _EIGEN_ALIGNED_PTR(from));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d ploaddup<Packet2d>(const double*   from)\n{\n  Packet2d p;\n  if((std::ptrdiff_t(from) % 16) == 0)  p = pload<Packet2d>(from);\n  else                                  p = ploadu<Packet2d>(from);\n  return vec_splat_dbl<0>(p);\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<double>(double*  to, const Packet2d& from)\n{\n  EIGEN_DEBUG_ALIGNED_STORE\n  vec_vsx_st((Packet4f)from, (long)to & 15, (float*) _EIGEN_ALIGNED_PTR(to));\n}\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { EIGEN_PPC_PREFETCH(addr); }\n\ntemplate<> EIGEN_STRONG_INLINE double  pfirst<Packet2d>(const Packet2d& a) { double EIGEN_ALIGN16 x[2]; pstore<double>(x, a); return x[0]; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d preverse(const Packet2d& a)\n{\n  return reinterpret_cast<Packet2d>(vec_perm(reinterpret_cast<Packet16uc>(a), reinterpret_cast<Packet16uc>(a), p16uc_REVERSE64));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pabs(const Packet2d& a) { return vec_abs(a); }\n\ntemplate<> EIGEN_STRONG_INLINE double predux<Packet2d>(const Packet2d& a)\n{\n  Packet2d b, sum;\n  b   = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4f>(a), reinterpret_cast<Packet4f>(a), 8));\n  sum = a + b;\n  return pfirst<Packet2d>(sum);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d preduxp<Packet2d>(const Packet2d* vecs)\n{\n  Packet2d v[2], sum;\n  v[0] = vecs[0] + reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4f>(vecs[0]), reinterpret_cast<Packet4f>(vecs[0]), 8));\n  v[1] = vecs[1] + reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4f>(vecs[1]), reinterpret_cast<Packet4f>(vecs[1]), 8));\n \n#ifdef _BIG_ENDIAN\n  sum = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4f>(v[0]), reinterpret_cast<Packet4f>(v[1]), 8));\n#else\n  sum = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4f>(v[1]), reinterpret_cast<Packet4f>(v[0]), 8));\n#endif\n\n  return sum;\n}\n// Other reduction functions:\n// mul\ntemplate<> EIGEN_STRONG_INLINE double predux_mul<Packet2d>(const Packet2d& a)\n{\n  return pfirst(pmul(a, reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4ui>(a), reinterpret_cast<Packet4ui>(a), 8))));\n}\n\n// min\ntemplate<> EIGEN_STRONG_INLINE double predux_min<Packet2d>(const Packet2d& a)\n{\n  return pfirst(pmin(a, reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4ui>(a), reinterpret_cast<Packet4ui>(a), 8))));\n}\n\n// max\ntemplate<> EIGEN_STRONG_INLINE double predux_max<Packet2d>(const Packet2d& a)\n{\n  return pfirst(pmax(a, reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4ui>(a), reinterpret_cast<Packet4ui>(a), 8))));\n}\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet2d>\n{\n  static EIGEN_STRONG_INLINE void run(Packet2d& first, const Packet2d& second)\n  {\n    if (Offset == 1)\n#ifdef _BIG_ENDIAN\n      first = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4ui>(first), reinterpret_cast<Packet4ui>(second), 8));\n#else\n      first = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4ui>(second), reinterpret_cast<Packet4ui>(first), 8));\n#endif\n  }\n};\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet2d,2>& kernel) {\n  Packet2d t0, t1;\n  t0 = vec_perm(kernel.packet[0], kernel.packet[1], p16uc_TRANSPOSE64_HI);\n  t1 = vec_perm(kernel.packet[0], kernel.packet[1], p16uc_TRANSPOSE64_LO);\n  kernel.packet[0] = t0;\n  kernel.packet[1] = t1;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pblend(const Selector<2>& ifPacket, const Packet2d& thenPacket, const Packet2d& elsePacket) {\n  Packet2l select = { ifPacket.select[0], ifPacket.select[1] };\n  Packet2bl mask = vec_cmpeq(reinterpret_cast<Packet2d>(select), reinterpret_cast<Packet2d>(p2l_ONE));\n  return vec_sel(elsePacket, thenPacket, mask);\n}\n#endif // __VSX__\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_PACKET_MATH_ALTIVEC_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/CUDA/Complex.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COMPLEX_CUDA_H\n#define EIGEN_COMPLEX_CUDA_H\n\n// clang-format off\n\nnamespace Eigen {\n\nnamespace internal {\n\n#if defined(__CUDACC__) && defined(EIGEN_USE_GPU)\n\n// Many std::complex methods such as operator+, operator-, operator* and\n// operator/ are not constexpr. Due to this, clang does not treat them as device\n// functions and thus Eigen functors making use of these operators fail to\n// compile. Here, we manually specialize these functors for complex types when\n// building for CUDA to avoid non-constexpr methods.\n\n// Sum\ntemplate<typename T> struct scalar_sum_op<const std::complex<T>, const std::complex<T> > : binary_op_base<const std::complex<T>, const std::complex<T> > {\n  typedef typename std::complex<T> result_type;\n\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_sum_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::complex<T> operator() (const std::complex<T>& a, const std::complex<T>& b) const {\n    return std::complex<T>(numext::real(a) + numext::real(b),\n                           numext::imag(a) + numext::imag(b));\n  }\n};\n\ntemplate<typename T> struct scalar_sum_op<std::complex<T>, std::complex<T> > : scalar_sum_op<const std::complex<T>, const std::complex<T> > {};\n\n\n// Difference\ntemplate<typename T> struct scalar_difference_op<const std::complex<T>, const std::complex<T> >  : binary_op_base<const std::complex<T>, const std::complex<T> > {\n  typedef typename std::complex<T> result_type;\n\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_difference_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::complex<T> operator() (const std::complex<T>& a, const std::complex<T>& b) const {\n    return std::complex<T>(numext::real(a) - numext::real(b),\n                           numext::imag(a) - numext::imag(b));\n  }\n};\n\ntemplate<typename T> struct scalar_difference_op<std::complex<T>, std::complex<T> > : scalar_difference_op<const std::complex<T>, const std::complex<T> > {};\n\n\n// Product\ntemplate<typename T> struct scalar_product_op<const std::complex<T>, const std::complex<T> >  : binary_op_base<const std::complex<T>, const std::complex<T> > {\n  enum {\n    Vectorizable = packet_traits<std::complex<T>>::HasMul\n  };\n  typedef typename std::complex<T> result_type;\n\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_product_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::complex<T> operator() (const std::complex<T>& a, const std::complex<T>& b) const {\n    const T a_real = numext::real(a);\n    const T a_imag = numext::imag(a);\n    const T b_real = numext::real(b);\n    const T b_imag = numext::imag(b);\n    return std::complex<T>(a_real * b_real - a_imag * b_imag,\n                           a_real * b_imag + a_imag * b_real);\n  }\n};\n\ntemplate<typename T> struct scalar_product_op<std::complex<T>, std::complex<T> > : scalar_product_op<const std::complex<T>, const std::complex<T> > {};\n\n\n// Quotient\ntemplate<typename T> struct scalar_quotient_op<const std::complex<T>, const std::complex<T> > : binary_op_base<const std::complex<T>, const std::complex<T> > {\n  enum {\n    Vectorizable = packet_traits<std::complex<T>>::HasDiv\n  };\n  typedef typename std::complex<T> result_type;\n\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_quotient_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::complex<T> operator() (const std::complex<T>& a, const std::complex<T>& b) const {\n    const T a_real = numext::real(a);\n    const T a_imag = numext::imag(a);\n    const T b_real = numext::real(b);\n    const T b_imag = numext::imag(b);\n    const T norm = T(1) / (b_real * b_real + b_imag * b_imag);\n    return std::complex<T>((a_real * b_real + a_imag * b_imag) * norm,\n                           (a_imag * b_real - a_real * b_imag) * norm);\n  }\n};\n\ntemplate<typename T> struct scalar_quotient_op<std::complex<T>, std::complex<T> > : scalar_quotient_op<const std::complex<T>, const std::complex<T> > {};\n\n#endif\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_COMPLEX_CUDA_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/CUDA/Half.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n//\n// The conversion routines are Copyright (c) Fabian Giesen, 2016.\n// The original license follows:\n//\n// Copyright (c) Fabian Giesen, 2016\n// All rights reserved.\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted.\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Standard 16-bit float type, mostly useful for GPUs. Defines a new\n// type Eigen::half (inheriting from CUDA's __half struct) with\n// operator overloads such that it behaves basically as an arithmetic\n// type. It will be quite slow on CPUs (so it is recommended to stay\n// in fp32 for CPUs, except for simple parameter conversions, I/O\n// to disk and the likes), but fast on GPUs.\n\n\n#ifndef EIGEN_HALF_CUDA_H\n#define EIGEN_HALF_CUDA_H\n\n#if __cplusplus > 199711L\n#define EIGEN_EXPLICIT_CAST(tgt_type) explicit operator tgt_type()\n#else\n#define EIGEN_EXPLICIT_CAST(tgt_type) operator tgt_type()\n#endif\n\n\nnamespace Eigen {\n\nstruct half;\n\nnamespace half_impl {\n\n#if !defined(EIGEN_HAS_CUDA_FP16)\n\n// Make our own __half definition that is similar to CUDA's.\nstruct __half {\n  EIGEN_DEVICE_FUNC __half() {}\n  explicit EIGEN_DEVICE_FUNC __half(unsigned short raw) : x(raw) {}\n  unsigned short x;\n};\n\n#endif\n\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half raw_uint16_to_half(unsigned short x);\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half float_to_half_rtne(float ff);\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC float half_to_float(__half h);\n\nstruct half_base : public __half {\n  EIGEN_DEVICE_FUNC half_base() {}\n  EIGEN_DEVICE_FUNC half_base(const half_base& h) : __half(h) {}\n  EIGEN_DEVICE_FUNC half_base(const __half& h) : __half(h) {}\n};\n\n} // namespace half_impl\n\n// Class definition.\nstruct half : public half_impl::half_base {\n  #if !defined(EIGEN_HAS_CUDA_FP16)\n    typedef half_impl::__half __half;\n  #endif\n\n  EIGEN_DEVICE_FUNC half() {}\n\n  EIGEN_DEVICE_FUNC half(const __half& h) : half_impl::half_base(h) {}\n  EIGEN_DEVICE_FUNC half(const half& h) : half_impl::half_base(h) {}\n\n  explicit EIGEN_DEVICE_FUNC half(bool b)\n      : half_impl::half_base(half_impl::raw_uint16_to_half(b ? 0x3c00 : 0)) {}\n  template<class T>\n  explicit EIGEN_DEVICE_FUNC half(const T& val)\n      : half_impl::half_base(half_impl::float_to_half_rtne(static_cast<float>(val))) {}\n  explicit EIGEN_DEVICE_FUNC half(float f)\n      : half_impl::half_base(half_impl::float_to_half_rtne(f)) {}\n\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(bool) const {\n    // +0.0 and -0.0 become false, everything else becomes true.\n    return (x & 0x7fff) != 0;\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(signed char) const {\n    return static_cast<signed char>(half_impl::half_to_float(*this));\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned char) const {\n    return static_cast<unsigned char>(half_impl::half_to_float(*this));\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(short) const {\n    return static_cast<short>(half_impl::half_to_float(*this));\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned short) const {\n    return static_cast<unsigned short>(half_impl::half_to_float(*this));\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(int) const {\n    return static_cast<int>(half_impl::half_to_float(*this));\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned int) const {\n    return static_cast<unsigned int>(half_impl::half_to_float(*this));\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(long) const {\n    return static_cast<long>(half_impl::half_to_float(*this));\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned long) const {\n    return static_cast<unsigned long>(half_impl::half_to_float(*this));\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(long long) const {\n    return static_cast<long long>(half_impl::half_to_float(*this));\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned long long) const {\n    return static_cast<unsigned long long>(half_to_float(*this));\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(float) const {\n    return half_impl::half_to_float(*this);\n  }\n  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(double) const {\n    return static_cast<double>(half_impl::half_to_float(*this));\n  }\n\n  EIGEN_DEVICE_FUNC half& operator=(const half& other) {\n    x = other.x;\n    return *this;\n  }\n};\n\nnamespace half_impl {\n\n#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530\n\n// Intrinsics for native fp16 support. Note that on current hardware,\n// these are no faster than fp32 arithmetic (you need to use the half2\n// versions to get the ALU speed increased), but you do save the\n// conversion steps back and forth.\n\n__device__ half operator + (const half& a, const half& b) {\n  return __hadd(a, b);\n}\n__device__ half operator * (const half& a, const half& b) {\n  return __hmul(a, b);\n}\n__device__ half operator - (const half& a, const half& b) {\n  return __hsub(a, b);\n}\n__device__ half operator / (const half& a, const half& b) {\n  float num = __half2float(a);\n  float denom = __half2float(b);\n  return __float2half(num / denom);\n}\n__device__ half operator - (const half& a) {\n  return __hneg(a);\n}\n__device__ half& operator += (half& a, const half& b) {\n  a = a + b;\n  return a;\n}\n__device__ half& operator *= (half& a, const half& b) {\n  a = a * b;\n  return a;\n}\n__device__ half& operator -= (half& a, const half& b) {\n  a = a - b;\n  return a;\n}\n__device__ half& operator /= (half& a, const half& b) {\n  a = a / b;\n  return a;\n}\n__device__ bool operator == (const half& a, const half& b) {\n  return __heq(a, b);\n}\n__device__ bool operator != (const half& a, const half& b) {\n  return __hne(a, b);\n}\n__device__ bool operator < (const half& a, const half& b) {\n  return __hlt(a, b);\n}\n__device__ bool operator <= (const half& a, const half& b) {\n  return __hle(a, b);\n}\n__device__ bool operator > (const half& a, const half& b) {\n  return __hgt(a, b);\n}\n__device__ bool operator >= (const half& a, const half& b) {\n  return __hge(a, b);\n}\n\n#else  // Emulate support for half floats\n\n// Definitions for CPUs and older CUDA, mostly working through conversion\n// to/from fp32.\n\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator + (const half& a, const half& b) {\n  return half(float(a) + float(b));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator * (const half& a, const half& b) {\n  return half(float(a) * float(b));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator - (const half& a, const half& b) {\n  return half(float(a) - float(b));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator / (const half& a, const half& b) {\n  return half(float(a) / float(b));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator - (const half& a) {\n  half result;\n  result.x = a.x ^ 0x8000;\n  return result;\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator += (half& a, const half& b) {\n  a = half(float(a) + float(b));\n  return a;\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator *= (half& a, const half& b) {\n  a = half(float(a) * float(b));\n  return a;\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator -= (half& a, const half& b) {\n  a = half(float(a) - float(b));\n  return a;\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator /= (half& a, const half& b) {\n  a = half(float(a) / float(b));\n  return a;\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator == (const half& a, const half& b) {\n  return float(a) == float(b);\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator != (const half& a, const half& b) {\n  return float(a) != float(b);\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator < (const half& a, const half& b) {\n  return float(a) < float(b);\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator <= (const half& a, const half& b) {\n  return float(a) <= float(b);\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator > (const half& a, const half& b) {\n  return float(a) > float(b);\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator >= (const half& a, const half& b) {\n  return float(a) >= float(b);\n}\n\n#endif  // Emulate support for half floats\n\n// Division by an index. Do it in full float precision to avoid accuracy\n// issues in converting the denominator to half.\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator / (const half& a, Index b) {\n  return half(static_cast<float>(a) / static_cast<float>(b));\n}\n\n// Conversion routines, including fallbacks for the host or older CUDA.\n// Note that newer Intel CPUs (Haswell or newer) have vectorized versions of\n// these in hardware. If we need more performance on older/other CPUs, they are\n// also possible to vectorize directly.\n\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half raw_uint16_to_half(unsigned short x) {\n  __half h;\n  h.x = x;\n  return h;\n}\n\nunion FP32 {\n  unsigned int u;\n  float f;\n};\n\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half float_to_half_rtne(float ff) {\n#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300\n  return __float2half(ff);\n\n#elif defined(EIGEN_HAS_FP16_C)\n  __half h;\n  h.x = _cvtss_sh(ff, 0);\n  return h;\n\n#else\n  FP32 f; f.f = ff;\n\n  const FP32 f32infty = { 255 << 23 };\n  const FP32 f16max = { (127 + 16) << 23 };\n  const FP32 denorm_magic = { ((127 - 15) + (23 - 10) + 1) << 23 };\n  unsigned int sign_mask = 0x80000000u;\n  __half o;\n  o.x = static_cast<unsigned short>(0x0u);\n\n  unsigned int sign = f.u & sign_mask;\n  f.u ^= sign;\n\n  // NOTE all the integer compares in this function can be safely\n  // compiled into signed compares since all operands are below\n  // 0x80000000. Important if you want fast straight SSE2 code\n  // (since there's no unsigned PCMPGTD).\n\n  if (f.u >= f16max.u) {  // result is Inf or NaN (all exponent bits set)\n    o.x = (f.u > f32infty.u) ? 0x7e00 : 0x7c00; // NaN->qNaN and Inf->Inf\n  } else {  // (De)normalized number or zero\n    if (f.u < (113 << 23)) {  // resulting FP16 is subnormal or zero\n      // use a magic value to align our 10 mantissa bits at the bottom of\n      // the float. as long as FP addition is round-to-nearest-even this\n      // just works.\n      f.f += denorm_magic.f;\n\n      // and one integer subtract of the bias later, we have our final float!\n      o.x = static_cast<unsigned short>(f.u - denorm_magic.u);\n    } else {\n      unsigned int mant_odd = (f.u >> 13) & 1; // resulting mantissa is odd\n\n      // update exponent, rounding bias part 1\n      f.u += ((unsigned int)(15 - 127) << 23) + 0xfff;\n      // rounding bias part 2\n      f.u += mant_odd;\n      // take the bits!\n      o.x = static_cast<unsigned short>(f.u >> 13);\n    }\n  }\n\n  o.x |= static_cast<unsigned short>(sign >> 16);\n  return o;\n#endif\n}\n\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC float half_to_float(__half h) {\n#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300\n  return __half2float(h);\n\n#elif defined(EIGEN_HAS_FP16_C)\n  return _cvtsh_ss(h.x);\n\n#else\n  const FP32 magic = { 113 << 23 };\n  const unsigned int shifted_exp = 0x7c00 << 13; // exponent mask after shift\n  FP32 o;\n\n  o.u = (h.x & 0x7fff) << 13;             // exponent/mantissa bits\n  unsigned int exp = shifted_exp & o.u;   // just the exponent\n  o.u += (127 - 15) << 23;                // exponent adjust\n\n  // handle exponent special cases\n  if (exp == shifted_exp) {     // Inf/NaN?\n    o.u += (128 - 16) << 23;    // extra exp adjust\n  } else if (exp == 0) {        // Zero/Denormal?\n    o.u += 1 << 23;             // extra exp adjust\n    o.f -= magic.f;             // renormalize\n  }\n\n  o.u |= (h.x & 0x8000) << 16;    // sign bit\n  return o.f;\n#endif\n}\n\n// --- standard functions ---\n\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool (isinf)(const half& a) {\n  return (a.x & 0x7fff) == 0x7c00;\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool (isnan)(const half& a) {\n#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530\n  return __hisnan(a);\n#else\n  return (a.x & 0x7fff) > 0x7c00;\n#endif\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool (isfinite)(const half& a) {\n  return !(isinf EIGEN_NOT_A_MACRO (a)) && !(isnan EIGEN_NOT_A_MACRO (a));\n}\n\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half abs(const half& a) {\n  half result;\n  result.x = a.x & 0x7FFF;\n  return result;\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half exp(const half& a) {\n  return half(::expf(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log(const half& a) {\n#if defined(EIGEN_HAS_CUDA_FP16) && defined __CUDACC_VER__ && __CUDACC_VER__ >= 80000 && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530\n  return Eigen::half(::hlog(a));\n#else\n  return half(::logf(float(a)));\n#endif\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log1p(const half& a) {\n  return half(numext::log1p(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log10(const half& a) {\n  return half(::log10f(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half sqrt(const half& a) {\n  return half(::sqrtf(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half pow(const half& a, const half& b) {\n  return half(::powf(float(a), float(b)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half sin(const half& a) {\n  return half(::sinf(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half cos(const half& a) {\n  return half(::cosf(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half tan(const half& a) {\n  return half(::tanf(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half tanh(const half& a) {\n  return half(::tanhf(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half floor(const half& a) {\n  return half(::floorf(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half ceil(const half& a) {\n  return half(::ceilf(float(a)));\n}\n\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half (min)(const half& a, const half& b) {\n#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530\n  return __hlt(b, a) ? b : a;\n#else\n  const float f1 = static_cast<float>(a);\n  const float f2 = static_cast<float>(b);\n  return f2 < f1 ? b : a;\n#endif\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half (max)(const half& a, const half& b) {\n#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530\n  return __hlt(a, b) ? b : a;\n#else\n  const float f1 = static_cast<float>(a);\n  const float f2 = static_cast<float>(b);\n  return f1 < f2 ? b : a;\n#endif\n}\n\nEIGEN_ALWAYS_INLINE std::ostream& operator << (std::ostream& os, const half& v) {\n  os << static_cast<float>(v);\n  return os;\n}\n\n} // end namespace half_impl\n\n// import Eigen::half_impl::half into Eigen namespace\n// using half_impl::half;\n\nnamespace internal {\n\ntemplate<>\nstruct random_default_impl<half, false, false>\n{\n  static inline half run(const half& x, const half& y)\n  {\n    return x + (y-x) * half(float(std::rand()) / float(RAND_MAX));\n  }\n  static inline half run()\n  {\n    return run(half(-1.f), half(1.f));\n  }\n};\n\ntemplate<> struct is_arithmetic<half> { enum { value = true }; };\n\n} // end namespace internal\n\n}  // end namespace Eigen\n\nnamespace std {\ntemplate<>\nstruct numeric_limits<Eigen::half> {\n  static const bool is_specialized = true;\n  static const bool is_signed = true;\n  static const bool is_integer = false;\n  static const bool is_exact = false;\n  static const bool has_infinity = true;\n  static const bool has_quiet_NaN = true;\n  static const bool has_signaling_NaN = true;\n  static const float_denorm_style has_denorm = denorm_present;\n  static const bool has_denorm_loss = false;\n  static const std::float_round_style round_style = std::round_to_nearest;\n  static const bool is_iec559 = false;\n  static const bool is_bounded = false;\n  static const bool is_modulo = false;\n  static const int digits = 11;\n  static const int digits10 = 2;\n  //static const int max_digits10 = ;\n  static const int radix = 2;\n  static const int min_exponent = -13;\n  static const int min_exponent10 = -4;\n  static const int max_exponent = 16;\n  static const int max_exponent10 = 4;\n  static const bool traps = true;\n  static const bool tinyness_before = false;\n\n  static Eigen::half (min)() { return Eigen::half_impl::raw_uint16_to_half(0x400); }\n  static Eigen::half lowest() { return Eigen::half_impl::raw_uint16_to_half(0xfbff); }\n  static Eigen::half (max)() { return Eigen::half_impl::raw_uint16_to_half(0x7bff); }\n  static Eigen::half epsilon() { return Eigen::half_impl::raw_uint16_to_half(0x0800); }\n  static Eigen::half round_error() { return Eigen::half(0.5); }\n  static Eigen::half infinity() { return Eigen::half_impl::raw_uint16_to_half(0x7c00); }\n  static Eigen::half quiet_NaN() { return Eigen::half_impl::raw_uint16_to_half(0x7e00); }\n  static Eigen::half signaling_NaN() { return Eigen::half_impl::raw_uint16_to_half(0x7e00); }\n  static Eigen::half denorm_min() { return Eigen::half_impl::raw_uint16_to_half(0x1); }\n};\n}\n\nnamespace Eigen {\n\ntemplate<> struct NumTraits<Eigen::half>\n    : GenericNumTraits<Eigen::half>\n{\n  enum {\n    IsSigned = true,\n    IsInteger = false,\n    IsComplex = false,\n    RequireInitialization = false\n  };\n\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half epsilon() {\n    return half_impl::raw_uint16_to_half(0x0800);\n  }\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half dummy_precision() { return Eigen::half(1e-2f); }\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half highest() {\n    return half_impl::raw_uint16_to_half(0x7bff);\n  }\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half lowest() {\n    return half_impl::raw_uint16_to_half(0xfbff);\n  }\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half infinity() {\n    return half_impl::raw_uint16_to_half(0x7c00);\n  }\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half quiet_NaN() {\n    return half_impl::raw_uint16_to_half(0x7c01);\n  }\n};\n\n} // end namespace Eigen\n\n// C-like standard mathematical functions and trancendentals.\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half fabsh(const Eigen::half& a) {\n  Eigen::half result;\n  result.x = a.x & 0x7FFF;\n  return result;\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half exph(const Eigen::half& a) {\n  return Eigen::half(::expf(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half logh(const Eigen::half& a) {\n#if defined __CUDACC_VER__ && __CUDACC_VER__ >= 80000 && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530\n  return Eigen::half(::hlog(a));\n#else\n  return Eigen::half(::logf(float(a)));\n#endif\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half sqrth(const Eigen::half& a) {\n  return Eigen::half(::sqrtf(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half powh(const Eigen::half& a, const Eigen::half& b) {\n  return Eigen::half(::powf(float(a), float(b)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half floorh(const Eigen::half& a) {\n  return Eigen::half(::floorf(float(a)));\n}\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half ceilh(const Eigen::half& a) {\n  return Eigen::half(::ceilf(float(a)));\n}\n\nnamespace std {\n\n#if __cplusplus > 199711L\ntemplate <>\nstruct hash<Eigen::half> {\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::size_t operator()(const Eigen::half& a) const {\n    return static_cast<std::size_t>(a.x);\n  }\n};\n#endif\n\n} // end namespace std\n\n\n// Add the missing shfl_xor intrinsic\n#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300\n__device__ EIGEN_STRONG_INLINE Eigen::half __shfl_xor(Eigen::half var, int laneMask, int width=warpSize) {\n  return static_cast<Eigen::half>(__shfl_xor(static_cast<float>(var), laneMask, width));\n}\n#endif\n\n// ldg() has an overload for __half, but we also need one for Eigen::half.\n#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 350\nEIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half __ldg(const Eigen::half* ptr) {\n  return Eigen::half_impl::raw_uint16_to_half(\n      __ldg(reinterpret_cast<const unsigned short*>(ptr)));\n}\n#endif\n\n\n#if defined(__CUDA_ARCH__)\nnamespace Eigen {\nnamespace numext {\n\ntemplate<>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nbool (isnan)(const Eigen::half& h) {\n  return (half_impl::isnan)(h);\n}\n\ntemplate<>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nbool (isinf)(const Eigen::half& h) {\n  return (half_impl::isinf)(h);\n}\n\ntemplate<>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nbool (isfinite)(const Eigen::half& h) {\n  return (half_impl::isfinite)(h);\n}\n\n} // namespace Eigen\n}  // namespace numext\n#endif\n\n#endif // EIGEN_HALF_CUDA_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/CUDA/MathFunctions.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MATH_FUNCTIONS_CUDA_H\n#define EIGEN_MATH_FUNCTIONS_CUDA_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n// Make sure this is only available when targeting a GPU: we don't want to\n// introduce conflicts between these packet_traits definitions and the ones\n// we'll use on the host side (SSE, AVX, ...)\n#if defined(__CUDACC__) && defined(EIGEN_USE_GPU)\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nfloat4 plog<float4>(const float4& a)\n{\n  return make_float4(logf(a.x), logf(a.y), logf(a.z), logf(a.w));\n}\n\ntemplate<>  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\ndouble2 plog<double2>(const double2& a)\n{\n  using ::log;\n  return make_double2(log(a.x), log(a.y));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nfloat4 plog1p<float4>(const float4& a)\n{\n  return make_float4(log1pf(a.x), log1pf(a.y), log1pf(a.z), log1pf(a.w));\n}\n\ntemplate<>  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\ndouble2 plog1p<double2>(const double2& a)\n{\n  return make_double2(log1p(a.x), log1p(a.y));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nfloat4 pexp<float4>(const float4& a)\n{\n  return make_float4(expf(a.x), expf(a.y), expf(a.z), expf(a.w));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\ndouble2 pexp<double2>(const double2& a)\n{\n  using ::exp;\n  return make_double2(exp(a.x), exp(a.y));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nfloat4 psqrt<float4>(const float4& a)\n{\n  return make_float4(sqrtf(a.x), sqrtf(a.y), sqrtf(a.z), sqrtf(a.w));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\ndouble2 psqrt<double2>(const double2& a)\n{\n  using ::sqrt;\n  return make_double2(sqrt(a.x), sqrt(a.y));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\nfloat4 prsqrt<float4>(const float4& a)\n{\n  return make_float4(rsqrtf(a.x), rsqrtf(a.y), rsqrtf(a.z), rsqrtf(a.w));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\ndouble2 prsqrt<double2>(const double2& a)\n{\n  return make_double2(rsqrt(a.x), rsqrt(a.y));\n}\n\n\n#endif\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_MATH_FUNCTIONS_CUDA_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/CUDA/PacketMath.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PACKET_MATH_CUDA_H\n#define EIGEN_PACKET_MATH_CUDA_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n// Make sure this is only available when targeting a GPU: we don't want to\n// introduce conflicts between these packet_traits definitions and the ones\n// we'll use on the host side (SSE, AVX, ...)\n#if defined(__CUDACC__) && defined(EIGEN_USE_GPU)\ntemplate<> struct is_arithmetic<float4>  { enum { value = true }; };\ntemplate<> struct is_arithmetic<double2> { enum { value = true }; };\n\ntemplate<> struct packet_traits<float> : default_packet_traits\n{\n  typedef float4 type;\n  typedef float4 half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=4,\n    HasHalfPacket = 0,\n\n    HasDiv  = 1,\n    HasSin  = 0,\n    HasCos  = 0,\n    HasLog  = 1,\n    HasExp  = 1,\n    HasSqrt = 1,\n    HasRsqrt = 1,\n    HasLGamma = 1,\n    HasDiGamma = 1,\n    HasZeta = 1,\n    HasPolygamma = 1,\n    HasErf = 1,\n    HasErfc = 1,\n    HasIGamma = 1,\n    HasIGammac = 1,\n    HasBetaInc = 1,\n\n    HasBlend = 0,\n  };\n};\n\ntemplate<> struct packet_traits<double> : default_packet_traits\n{\n  typedef double2 type;\n  typedef double2 half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=2,\n    HasHalfPacket = 0,\n\n    HasDiv  = 1,\n    HasLog  = 1,\n    HasExp  = 1,\n    HasSqrt = 1,\n    HasRsqrt = 1,\n    HasLGamma = 1,\n    HasDiGamma = 1,\n    HasZeta = 1,\n    HasPolygamma = 1,\n    HasErf = 1,\n    HasErfc = 1,\n    HasIGamma = 1,\n    HasIGammac = 1,\n    HasBetaInc = 1,\n\n    HasBlend = 0,\n  };\n};\n\n\ntemplate<> struct unpacket_traits<float4>  { typedef float  type; enum {size=4, alignment=Aligned16}; typedef float4 half; };\ntemplate<> struct unpacket_traits<double2> { typedef double type; enum {size=2, alignment=Aligned16}; typedef double2 half; };\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pset1<float4>(const float&  from) {\n  return make_float4(from, from, from, from);\n}\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pset1<double2>(const double& from) {\n  return make_double2(from, from);\n}\n\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 plset<float4>(const float& a) {\n  return make_float4(a, a+1, a+2, a+3);\n}\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 plset<double2>(const double& a) {\n  return make_double2(a, a+1);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 padd<float4>(const float4& a, const float4& b) {\n  return make_float4(a.x+b.x, a.y+b.y, a.z+b.z, a.w+b.w);\n}\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 padd<double2>(const double2& a, const double2& b) {\n  return make_double2(a.x+b.x, a.y+b.y);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 psub<float4>(const float4& a, const float4& b) {\n  return make_float4(a.x-b.x, a.y-b.y, a.z-b.z, a.w-b.w);\n}\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 psub<double2>(const double2& a, const double2& b) {\n  return make_double2(a.x-b.x, a.y-b.y);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pnegate(const float4& a) {\n  return make_float4(-a.x, -a.y, -a.z, -a.w);\n}\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pnegate(const double2& a) {\n  return make_double2(-a.x, -a.y);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pconj(const float4& a) { return a; }\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pconj(const double2& a) { return a; }\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pmul<float4>(const float4& a, const float4& b) {\n  return make_float4(a.x*b.x, a.y*b.y, a.z*b.z, a.w*b.w);\n}\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pmul<double2>(const double2& a, const double2& b) {\n  return make_double2(a.x*b.x, a.y*b.y);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pdiv<float4>(const float4& a, const float4& b) {\n  return make_float4(a.x/b.x, a.y/b.y, a.z/b.z, a.w/b.w);\n}\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pdiv<double2>(const double2& a, const double2& b) {\n  return make_double2(a.x/b.x, a.y/b.y);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pmin<float4>(const float4& a, const float4& b) {\n  return make_float4(fminf(a.x, b.x), fminf(a.y, b.y), fminf(a.z, b.z), fminf(a.w, b.w));\n}\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pmin<double2>(const double2& a, const double2& b) {\n  return make_double2(fmin(a.x, b.x), fmin(a.y, b.y));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pmax<float4>(const float4& a, const float4& b) {\n  return make_float4(fmaxf(a.x, b.x), fmaxf(a.y, b.y), fmaxf(a.z, b.z), fmaxf(a.w, b.w));\n}\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pmax<double2>(const double2& a, const double2& b) {\n  return make_double2(fmax(a.x, b.x), fmax(a.y, b.y));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pload<float4>(const float* from) {\n  return *reinterpret_cast<const float4*>(from);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pload<double2>(const double* from) {\n  return *reinterpret_cast<const double2*>(from);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 ploadu<float4>(const float* from) {\n  return make_float4(from[0], from[1], from[2], from[3]);\n}\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 ploadu<double2>(const double* from) {\n  return make_double2(from[0], from[1]);\n}\n\ntemplate<> EIGEN_STRONG_INLINE float4 ploaddup<float4>(const float*   from) {\n  return make_float4(from[0], from[0], from[1], from[1]);\n}\ntemplate<> EIGEN_STRONG_INLINE double2 ploaddup<double2>(const double*  from) {\n  return make_double2(from[0], from[0]);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void pstore<float>(float*   to, const float4& from) {\n  *reinterpret_cast<float4*>(to) = from;\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void pstore<double>(double* to, const double2& from) {\n  *reinterpret_cast<double2*>(to) = from;\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void pstoreu<float>(float*  to, const float4& from) {\n  to[0] = from.x;\n  to[1] = from.y;\n  to[2] = from.z;\n  to[3] = from.w;\n}\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void pstoreu<double>(double* to, const double2& from) {\n  to[0] = from.x;\n  to[1] = from.y;\n}\n\ntemplate<>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float4 ploadt_ro<float4, Aligned>(const float* from) {\n#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 350\n  return __ldg((const float4*)from);\n#else\n  return make_float4(from[0], from[1], from[2], from[3]);\n#endif\n}\ntemplate<>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double2 ploadt_ro<double2, Aligned>(const double* from) {\n#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 350\n  return __ldg((const double2*)from);\n#else\n  return make_double2(from[0], from[1]);\n#endif\n}\n\ntemplate<>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float4 ploadt_ro<float4, Unaligned>(const float* from) {\n#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 350\n  return make_float4(__ldg(from+0), __ldg(from+1), __ldg(from+2), __ldg(from+3));\n#else\n  return make_float4(from[0], from[1], from[2], from[3]);\n#endif\n}\ntemplate<>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double2 ploadt_ro<double2, Unaligned>(const double* from) {\n#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 350\n  return make_double2(__ldg(from+0), __ldg(from+1));\n#else\n  return make_double2(from[0], from[1]);\n#endif\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline float4 pgather<float, float4>(const float* from, Index stride) {\n  return make_float4(from[0*stride], from[1*stride], from[2*stride], from[3*stride]);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline double2 pgather<double, double2>(const double* from, Index stride) {\n  return make_double2(from[0*stride], from[1*stride]);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<float, float4>(float* to, const float4& from, Index stride) {\n  to[stride*0] = from.x;\n  to[stride*1] = from.y;\n  to[stride*2] = from.z;\n  to[stride*3] = from.w;\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<double, double2>(double* to, const double2& from, Index stride) {\n  to[stride*0] = from.x;\n  to[stride*1] = from.y;\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline float  pfirst<float4>(const float4& a) {\n  return a.x;\n}\ntemplate<> EIGEN_DEVICE_FUNC inline double pfirst<double2>(const double2& a) {\n  return a.x;\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline float  predux<float4>(const float4& a) {\n  return a.x + a.y + a.z + a.w;\n}\ntemplate<> EIGEN_DEVICE_FUNC inline double predux<double2>(const double2& a) {\n  return a.x + a.y;\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline float  predux_max<float4>(const float4& a) {\n  return fmaxf(fmaxf(a.x, a.y), fmaxf(a.z, a.w));\n}\ntemplate<> EIGEN_DEVICE_FUNC inline double predux_max<double2>(const double2& a) {\n  return fmax(a.x, a.y);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline float  predux_min<float4>(const float4& a) {\n  return fminf(fminf(a.x, a.y), fminf(a.z, a.w));\n}\ntemplate<> EIGEN_DEVICE_FUNC inline double predux_min<double2>(const double2& a) {\n  return fmin(a.x, a.y);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline float  predux_mul<float4>(const float4& a) {\n  return a.x * a.y * a.z * a.w;\n}\ntemplate<> EIGEN_DEVICE_FUNC inline double predux_mul<double2>(const double2& a) {\n  return a.x * a.y;\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline float4  pabs<float4>(const float4& a) {\n  return make_float4(fabsf(a.x), fabsf(a.y), fabsf(a.z), fabsf(a.w));\n}\ntemplate<> EIGEN_DEVICE_FUNC inline double2 pabs<double2>(const double2& a) {\n  return make_double2(fabs(a.x), fabs(a.y));\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<float4,4>& kernel) {\n  float tmp = kernel.packet[0].y;\n  kernel.packet[0].y = kernel.packet[1].x;\n  kernel.packet[1].x = tmp;\n\n  tmp = kernel.packet[0].z;\n  kernel.packet[0].z = kernel.packet[2].x;\n  kernel.packet[2].x = tmp;\n\n  tmp = kernel.packet[0].w;\n  kernel.packet[0].w = kernel.packet[3].x;\n  kernel.packet[3].x = tmp;\n\n  tmp = kernel.packet[1].z;\n  kernel.packet[1].z = kernel.packet[2].y;\n  kernel.packet[2].y = tmp;\n\n  tmp = kernel.packet[1].w;\n  kernel.packet[1].w = kernel.packet[3].y;\n  kernel.packet[3].y = tmp;\n\n  tmp = kernel.packet[2].w;\n  kernel.packet[2].w = kernel.packet[3].z;\n  kernel.packet[3].z = tmp;\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<double2,2>& kernel) {\n  double tmp = kernel.packet[0].y;\n  kernel.packet[0].y = kernel.packet[1].x;\n  kernel.packet[1].x = tmp;\n}\n\n#endif\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n\n#endif // EIGEN_PACKET_MATH_CUDA_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/CUDA/PacketMathHalf.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2016 Benoit Steiner <benoit.steiner.goog@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PACKET_MATH_HALF_CUDA_H\n#define EIGEN_PACKET_MATH_HALF_CUDA_H\n\n\nnamespace Eigen {\nnamespace internal {\n\n// Most of the following operations require arch >= 3.0\n#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDACC__) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300\n\ntemplate<> struct is_arithmetic<half2> { enum { value = true }; };\n\ntemplate<> struct packet_traits<Eigen::half> : default_packet_traits\n{\n  typedef half2 type;\n  typedef half2 half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=2,\n    HasHalfPacket = 0,\n    HasAdd    = 1,\n    HasMul    = 1,\n    HasDiv    = 1,\n    HasSqrt   = 1,\n    HasRsqrt  = 1,\n    HasExp    = 1,\n    HasLog    = 1,\n    HasLog1p  = 1\n  };\n};\n\ntemplate<> struct unpacket_traits<half2> { typedef Eigen::half type; enum {size=2, alignment=Aligned16}; typedef half2 half; };\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pset1<half2>(const Eigen::half& from) {\n  return __half2half2(from);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pload<half2>(const Eigen::half* from) {\n  return *reinterpret_cast<const half2*>(from);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 ploadu<half2>(const Eigen::half* from) {\n  return __halves2half2(from[0], from[1]);\n}\n\ntemplate<> EIGEN_STRONG_INLINE half2 ploaddup<half2>(const Eigen::half*  from) {\n  return __halves2half2(from[0], from[0]);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE void pstore<Eigen::half>(Eigen::half* to, const half2& from) {\n  *reinterpret_cast<half2*>(to) = from;\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE void pstoreu<Eigen::half>(Eigen::half* to, const half2& from) {\n  to[0] = __low2half(from);\n  to[1] = __high2half(from);\n}\n\ntemplate<>\n __device__ EIGEN_ALWAYS_INLINE half2 ploadt_ro<half2, Aligned>(const Eigen::half* from) {\n#if __CUDA_ARCH__ >= 350\n   return __ldg((const half2*)from);\n#else\n  return __halves2half2(*(from+0), *(from+1));\n#endif\n}\n\ntemplate<>\n__device__ EIGEN_ALWAYS_INLINE half2 ploadt_ro<half2, Unaligned>(const Eigen::half* from) {\n#if __CUDA_ARCH__ >= 350\n   return __halves2half2(__ldg(from+0), __ldg(from+1));\n#else\n  return __halves2half2(*(from+0), *(from+1));\n#endif\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pgather<Eigen::half, half2>(const Eigen::half* from, Index stride) {\n  return __halves2half2(from[0*stride], from[1*stride]);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE void pscatter<Eigen::half, half2>(Eigen::half* to, const half2& from, Index stride) {\n  to[stride*0] = __low2half(from);\n  to[stride*1] = __high2half(from);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE Eigen::half pfirst<half2>(const half2& a) {\n  return __low2half(a);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pabs<half2>(const half2& a) {\n  half2 result;\n  result.x = a.x & 0x7FFF7FFF;\n  return result;\n}\n\n\n__device__ EIGEN_STRONG_INLINE void\nptranspose(PacketBlock<half2,2>& kernel) {\n  __half a1 = __low2half(kernel.packet[0]);\n  __half a2 = __high2half(kernel.packet[0]);\n  __half b1 = __low2half(kernel.packet[1]);\n  __half b2 = __high2half(kernel.packet[1]);\n  kernel.packet[0] = __halves2half2(a1, b1);\n  kernel.packet[1] = __halves2half2(a2, b2);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 plset<half2>(const Eigen::half& a) {\n#if __CUDA_ARCH__ >= 530\n  return __halves2half2(a, __hadd(a, __float2half(1.0f)));\n#else\n  float f = __half2float(a) + 1.0f;\n  return __halves2half2(a, __float2half(f));\n#endif\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 padd<half2>(const half2& a, const half2& b) {\n#if __CUDA_ARCH__ >= 530\n  return __hadd2(a, b);\n#else\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float b1 = __low2float(b);\n  float b2 = __high2float(b);\n  float r1 = a1 + b1;\n  float r2 = a2 + b2;\n  return __floats2half2_rn(r1, r2);\n#endif\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 psub<half2>(const half2& a, const half2& b) {\n#if __CUDA_ARCH__ >= 530\n  return __hsub2(a, b);\n#else\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float b1 = __low2float(b);\n  float b2 = __high2float(b);\n  float r1 = a1 - b1;\n  float r2 = a2 - b2;\n  return __floats2half2_rn(r1, r2);\n#endif\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pnegate(const half2& a) {\n#if __CUDA_ARCH__ >= 530\n  return __hneg2(a);\n#else\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  return __floats2half2_rn(-a1, -a2);\n#endif\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pconj(const half2& a) { return a; }\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pmul<half2>(const half2& a, const half2& b) {\n#if __CUDA_ARCH__ >= 530\n  return __hmul2(a, b);\n#else\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float b1 = __low2float(b);\n  float b2 = __high2float(b);\n  float r1 = a1 * b1;\n  float r2 = a2 * b2;\n  return __floats2half2_rn(r1, r2);\n#endif\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pmadd<half2>(const half2& a, const half2& b, const half2& c) {\n#if __CUDA_ARCH__ >= 530\n   return __hfma2(a, b, c);\n#else\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float b1 = __low2float(b);\n  float b2 = __high2float(b);\n  float c1 = __low2float(c);\n  float c2 = __high2float(c);\n  float r1 = a1 * b1 + c1;\n  float r2 = a2 * b2 + c2;\n  return __floats2half2_rn(r1, r2);\n#endif\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pdiv<half2>(const half2& a, const half2& b) {\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float b1 = __low2float(b);\n  float b2 = __high2float(b);\n  float r1 = a1 / b1;\n  float r2 = a2 / b2;\n  return __floats2half2_rn(r1, r2);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pmin<half2>(const half2& a, const half2& b) {\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float b1 = __low2float(b);\n  float b2 = __high2float(b);\n  __half r1 = a1 < b1 ? __low2half(a) : __low2half(b);\n  __half r2 = a2 < b2 ? __high2half(a) : __high2half(b);\n  return __halves2half2(r1, r2);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pmax<half2>(const half2& a, const half2& b) {\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float b1 = __low2float(b);\n  float b2 = __high2float(b);\n  __half r1 = a1 > b1 ? __low2half(a) : __low2half(b);\n  __half r2 = a2 > b2 ? __high2half(a) : __high2half(b);\n  return __halves2half2(r1, r2);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE Eigen::half predux<half2>(const half2& a) {\n#if __CUDA_ARCH__ >= 530\n  return __hadd(__low2half(a), __high2half(a));\n#else\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  return Eigen::half(half_impl::raw_uint16_to_half(__float2half_rn(a1 + a2)));\n#endif\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE Eigen::half predux_max<half2>(const half2& a) {\n#if __CUDA_ARCH__ >= 530\n  __half first = __low2half(a);\n  __half second = __high2half(a);\n  return __hgt(first, second) ? first : second;\n#else\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  return a1 > a2 ? __low2half(a) : __high2half(a);\n#endif\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE Eigen::half predux_min<half2>(const half2& a) {\n#if __CUDA_ARCH__ >= 530\n  __half first = __low2half(a);\n  __half second = __high2half(a);\n  return __hlt(first, second) ? first : second;\n#else\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  return a1 < a2 ? __low2half(a) : __high2half(a);\n#endif\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE Eigen::half predux_mul<half2>(const half2& a) {\n#if __CUDA_ARCH__ >= 530\n  return __hmul(__low2half(a), __high2half(a));\n#else\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  return Eigen::half(half_impl::raw_uint16_to_half(__float2half_rn(a1 * a2)));\n#endif\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 plog1p<half2>(const half2& a) {\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float r1 = log1pf(a1);\n  float r2 = log1pf(a2);\n  return __floats2half2_rn(r1, r2);\n}\n\n#if defined __CUDACC_VER__ && __CUDACC_VER__ >= 80000 && defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 530\n\ntemplate<>  __device__ EIGEN_STRONG_INLINE\nhalf2 plog<half2>(const half2& a) {\n  return h2log(a);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE\nhalf2 pexp<half2>(const half2& a) {\n  return h2exp(a);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE\nhalf2 psqrt<half2>(const half2& a) {\n  return h2sqrt(a);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE\nhalf2 prsqrt<half2>(const half2& a) {\n  return h2rsqrt(a);\n}\n\n#else\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 plog<half2>(const half2& a) {\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float r1 = logf(a1);\n  float r2 = logf(a2);\n  return __floats2half2_rn(r1, r2);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 pexp<half2>(const half2& a) {\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float r1 = expf(a1);\n  float r2 = expf(a2);\n  return __floats2half2_rn(r1, r2);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 psqrt<half2>(const half2& a) {\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float r1 = sqrtf(a1);\n  float r2 = sqrtf(a2);\n  return __floats2half2_rn(r1, r2);\n}\n\ntemplate<> __device__ EIGEN_STRONG_INLINE half2 prsqrt<half2>(const half2& a) {\n  float a1 = __low2float(a);\n  float a2 = __high2float(a);\n  float r1 = rsqrtf(a1);\n  float r2 = rsqrtf(a2);\n  return __floats2half2_rn(r1, r2);\n}\n\n#endif\n\n#elif defined EIGEN_VECTORIZE_AVX512\n\ntypedef struct {\n  __m256i x;\n} Packet16h;\n\n\ntemplate<> struct is_arithmetic<Packet16h> { enum { value = true }; };\n\ntemplate <>\nstruct packet_traits<half> : default_packet_traits {\n  typedef Packet16h type;\n  // There is no half-size packet for Packet16h.\n  typedef Packet16h half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 16,\n    HasHalfPacket = 0,\n    HasAdd    = 0,\n    HasSub    = 0,\n    HasMul    = 0,\n    HasNegate = 0,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasConj   = 0,\n    HasSetLinear = 0,\n    HasDiv = 0,\n    HasSqrt = 0,\n    HasRsqrt = 0,\n    HasExp = 0,\n    HasLog = 0,\n    HasBlend = 0\n  };\n};\n\n\ntemplate<> struct unpacket_traits<Packet16h> { typedef Eigen::half type; enum {size=16, alignment=Aligned32}; typedef Packet16h half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet16h pset1<Packet16h>(const Eigen::half& from) {\n  Packet16h result;\n  result.x = _mm256_set1_epi16(from.x);\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Eigen::half pfirst<Packet16h>(const Packet16h& from) {\n  return half_impl::raw_uint16_to_half(static_cast<unsigned short>(_mm256_extract_epi16(from.x, 0)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet16h pload<Packet16h>(const Eigen::half* from) {\n  Packet16h result;\n  result.x = _mm256_load_si256(reinterpret_cast<const __m256i*>(from));\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet16h ploadu<Packet16h>(const Eigen::half* from) {\n  Packet16h result;\n  result.x = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(from));\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<half>(Eigen::half* to, const Packet16h& from) {\n  _mm256_store_si256((__m256i*)to, from.x);\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<half>(Eigen::half* to, const Packet16h& from) {\n  _mm256_storeu_si256((__m256i*)to, from.x);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet16h\nploadquad(const Eigen::half* from) {\n  Packet16h result;\n  unsigned short a = from[0].x;\n  unsigned short b = from[1].x;\n  unsigned short c = from[2].x;\n  unsigned short d = from[3].x;\n  result.x = _mm256_set_epi16(d, d, d, d, c, c, c, c, b, b, b, b, a, a, a, a);\n  return result;\n}\n\nEIGEN_STRONG_INLINE Packet16f half2float(const Packet16h& a) {\n#ifdef EIGEN_HAS_FP16_C\n  return _mm512_cvtph_ps(a.x);\n#else\n  EIGEN_ALIGN64 half aux[16];\n  pstore(aux, a);\n  float f0(aux[0]);\n  float f1(aux[1]);\n  float f2(aux[2]);\n  float f3(aux[3]);\n  float f4(aux[4]);\n  float f5(aux[5]);\n  float f6(aux[6]);\n  float f7(aux[7]);\n  float f8(aux[8]);\n  float f9(aux[9]);\n  float fa(aux[10]);\n  float fb(aux[11]);\n  float fc(aux[12]);\n  float fd(aux[13]);\n  float fe(aux[14]);\n  float ff(aux[15]);\n\n  return _mm512_set_ps(\n      ff, fe, fd, fc, fb, fa, f9, f8, f7, f6, f5, f4, f3, f2, f1, f0);\n#endif\n}\n\nEIGEN_STRONG_INLINE Packet16h float2half(const Packet16f& a) {\n#ifdef EIGEN_HAS_FP16_C\n  Packet16h result;\n  result.x = _mm512_cvtps_ph(a, _MM_FROUND_TO_NEAREST_INT|_MM_FROUND_NO_EXC);\n  return result;\n#else\n  EIGEN_ALIGN64 float aux[16];\n  pstore(aux, a);\n  half h0(aux[0]);\n  half h1(aux[1]);\n  half h2(aux[2]);\n  half h3(aux[3]);\n  half h4(aux[4]);\n  half h5(aux[5]);\n  half h6(aux[6]);\n  half h7(aux[7]);\n  half h8(aux[8]);\n  half h9(aux[9]);\n  half ha(aux[10]);\n  half hb(aux[11]);\n  half hc(aux[12]);\n  half hd(aux[13]);\n  half he(aux[14]);\n  half hf(aux[15]);\n\n  Packet16h result;\n  result.x = _mm256_set_epi16(\n      hf.x, he.x, hd.x, hc.x, hb.x, ha.x, h9.x, h8.x,\n      h7.x, h6.x, h5.x, h4.x, h3.x, h2.x, h1.x, h0.x);\n  return result;\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet16h padd<Packet16h>(const Packet16h& a, const Packet16h& b) {\n  Packet16f af = half2float(a);\n  Packet16f bf = half2float(b);\n  Packet16f rf = padd(af, bf);\n  return float2half(rf);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet16h pmul<Packet16h>(const Packet16h& a, const Packet16h& b) {\n  Packet16f af = half2float(a);\n  Packet16f bf = half2float(b);\n  Packet16f rf = pmul(af, bf);\n  return float2half(rf);\n}\n\ntemplate<> EIGEN_STRONG_INLINE half predux<Packet16h>(const Packet16h& from) {\n  Packet16f from_float = half2float(from);\n  return half(predux(from_float));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet16h pgather<Eigen::half, Packet16h>(const Eigen::half* from, Index stride)\n{\n  Packet16h result;\n  result.x = _mm256_set_epi16(\n      from[15*stride].x, from[14*stride].x, from[13*stride].x, from[12*stride].x,\n      from[11*stride].x, from[10*stride].x, from[9*stride].x, from[8*stride].x,\n      from[7*stride].x, from[6*stride].x, from[5*stride].x, from[4*stride].x,\n      from[3*stride].x, from[2*stride].x, from[1*stride].x, from[0*stride].x);\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pscatter<half, Packet16h>(half* to, const Packet16h& from, Index stride)\n{\n  EIGEN_ALIGN64 half aux[16];\n  pstore(aux, from);\n  to[stride*0].x = aux[0].x;\n  to[stride*1].x = aux[1].x;\n  to[stride*2].x = aux[2].x;\n  to[stride*3].x = aux[3].x;\n  to[stride*4].x = aux[4].x;\n  to[stride*5].x = aux[5].x;\n  to[stride*6].x = aux[6].x;\n  to[stride*7].x = aux[7].x;\n  to[stride*8].x = aux[8].x;\n  to[stride*9].x = aux[9].x;\n  to[stride*10].x = aux[10].x;\n  to[stride*11].x = aux[11].x;\n  to[stride*12].x = aux[12].x;\n  to[stride*13].x = aux[13].x;\n  to[stride*14].x = aux[14].x;\n  to[stride*15].x = aux[15].x;\n}\n\nEIGEN_STRONG_INLINE void\nptranspose(PacketBlock<Packet16h,16>& kernel) {\n  __m256i a = kernel.packet[0].x;\n  __m256i b = kernel.packet[1].x;\n  __m256i c = kernel.packet[2].x;\n  __m256i d = kernel.packet[3].x;\n  __m256i e = kernel.packet[4].x;\n  __m256i f = kernel.packet[5].x;\n  __m256i g = kernel.packet[6].x;\n  __m256i h = kernel.packet[7].x;\n  __m256i i = kernel.packet[8].x;\n  __m256i j = kernel.packet[9].x;\n  __m256i k = kernel.packet[10].x;\n  __m256i l = kernel.packet[11].x;\n  __m256i m = kernel.packet[12].x;\n  __m256i n = kernel.packet[13].x;\n  __m256i o = kernel.packet[14].x;\n  __m256i p = kernel.packet[15].x;\n\n  __m256i ab_07 = _mm256_unpacklo_epi16(a, b);\n  __m256i cd_07 = _mm256_unpacklo_epi16(c, d);\n  __m256i ef_07 = _mm256_unpacklo_epi16(e, f);\n  __m256i gh_07 = _mm256_unpacklo_epi16(g, h);\n  __m256i ij_07 = _mm256_unpacklo_epi16(i, j);\n  __m256i kl_07 = _mm256_unpacklo_epi16(k, l);\n  __m256i mn_07 = _mm256_unpacklo_epi16(m, n);\n  __m256i op_07 = _mm256_unpacklo_epi16(o, p);\n\n  __m256i ab_8f = _mm256_unpackhi_epi16(a, b);\n  __m256i cd_8f = _mm256_unpackhi_epi16(c, d);\n  __m256i ef_8f = _mm256_unpackhi_epi16(e, f);\n  __m256i gh_8f = _mm256_unpackhi_epi16(g, h);\n  __m256i ij_8f = _mm256_unpackhi_epi16(i, j);\n  __m256i kl_8f = _mm256_unpackhi_epi16(k, l);\n  __m256i mn_8f = _mm256_unpackhi_epi16(m, n);\n  __m256i op_8f = _mm256_unpackhi_epi16(o, p);\n\n  __m256i abcd_03 = _mm256_unpacklo_epi32(ab_07, cd_07);\n  __m256i abcd_47 = _mm256_unpackhi_epi32(ab_07, cd_07);\n  __m256i efgh_03 = _mm256_unpacklo_epi32(ef_07, gh_07);\n  __m256i efgh_47 = _mm256_unpackhi_epi32(ef_07, gh_07);\n  __m256i ijkl_03 = _mm256_unpacklo_epi32(ij_07, kl_07);\n  __m256i ijkl_47 = _mm256_unpackhi_epi32(ij_07, kl_07);\n  __m256i mnop_03 = _mm256_unpacklo_epi32(mn_07, op_07);\n  __m256i mnop_47 = _mm256_unpackhi_epi32(mn_07, op_07);\n\n  __m256i abcd_8b = _mm256_unpacklo_epi32(ab_8f, cd_8f);\n  __m256i abcd_cf = _mm256_unpackhi_epi32(ab_8f, cd_8f);\n  __m256i efgh_8b = _mm256_unpacklo_epi32(ef_8f, gh_8f);\n  __m256i efgh_cf = _mm256_unpackhi_epi32(ef_8f, gh_8f);\n  __m256i ijkl_8b = _mm256_unpacklo_epi32(ij_8f, kl_8f);\n  __m256i ijkl_cf = _mm256_unpackhi_epi32(ij_8f, kl_8f);\n  __m256i mnop_8b = _mm256_unpacklo_epi32(mn_8f, op_8f);\n  __m256i mnop_cf = _mm256_unpackhi_epi32(mn_8f, op_8f);\n\n  __m256i abcdefgh_01 = _mm256_unpacklo_epi64(abcd_03, efgh_03);\n  __m256i abcdefgh_23 = _mm256_unpackhi_epi64(abcd_03, efgh_03);\n  __m256i ijklmnop_01 = _mm256_unpacklo_epi64(ijkl_03, mnop_03);\n  __m256i ijklmnop_23 = _mm256_unpackhi_epi64(ijkl_03, mnop_03);\n  __m256i abcdefgh_45 = _mm256_unpacklo_epi64(abcd_47, efgh_47);\n  __m256i abcdefgh_67 = _mm256_unpackhi_epi64(abcd_47, efgh_47);\n  __m256i ijklmnop_45 = _mm256_unpacklo_epi64(ijkl_47, mnop_47);\n  __m256i ijklmnop_67 = _mm256_unpackhi_epi64(ijkl_47, mnop_47);\n  __m256i abcdefgh_89 = _mm256_unpacklo_epi64(abcd_8b, efgh_8b);\n  __m256i abcdefgh_ab = _mm256_unpackhi_epi64(abcd_8b, efgh_8b);\n  __m256i ijklmnop_89 = _mm256_unpacklo_epi64(ijkl_8b, mnop_8b);\n  __m256i ijklmnop_ab = _mm256_unpackhi_epi64(ijkl_8b, mnop_8b);\n  __m256i abcdefgh_cd = _mm256_unpacklo_epi64(abcd_cf, efgh_cf);\n  __m256i abcdefgh_ef = _mm256_unpackhi_epi64(abcd_cf, efgh_cf);\n  __m256i ijklmnop_cd = _mm256_unpacklo_epi64(ijkl_cf, mnop_cf);\n  __m256i ijklmnop_ef = _mm256_unpackhi_epi64(ijkl_cf, mnop_cf);\n\n  // NOTE: no unpacklo/hi instr in this case, so using permute instr.\n  __m256i a_p_0 = _mm256_permute2x128_si256(abcdefgh_01, ijklmnop_01, 0x20);\n  __m256i a_p_1 = _mm256_permute2x128_si256(abcdefgh_01, ijklmnop_01, 0x31);\n  __m256i a_p_2 = _mm256_permute2x128_si256(abcdefgh_23, ijklmnop_23, 0x20);\n  __m256i a_p_3 = _mm256_permute2x128_si256(abcdefgh_23, ijklmnop_23, 0x31);\n  __m256i a_p_4 = _mm256_permute2x128_si256(abcdefgh_45, ijklmnop_45, 0x20);\n  __m256i a_p_5 = _mm256_permute2x128_si256(abcdefgh_45, ijklmnop_45, 0x31);\n  __m256i a_p_6 = _mm256_permute2x128_si256(abcdefgh_67, ijklmnop_67, 0x20);\n  __m256i a_p_7 = _mm256_permute2x128_si256(abcdefgh_67, ijklmnop_67, 0x31);\n  __m256i a_p_8 = _mm256_permute2x128_si256(abcdefgh_89, ijklmnop_89, 0x20);\n  __m256i a_p_9 = _mm256_permute2x128_si256(abcdefgh_89, ijklmnop_89, 0x31);\n  __m256i a_p_a = _mm256_permute2x128_si256(abcdefgh_ab, ijklmnop_ab, 0x20);\n  __m256i a_p_b = _mm256_permute2x128_si256(abcdefgh_ab, ijklmnop_ab, 0x31);\n  __m256i a_p_c = _mm256_permute2x128_si256(abcdefgh_cd, ijklmnop_cd, 0x20);\n  __m256i a_p_d = _mm256_permute2x128_si256(abcdefgh_cd, ijklmnop_cd, 0x31);\n  __m256i a_p_e = _mm256_permute2x128_si256(abcdefgh_ef, ijklmnop_ef, 0x20);\n  __m256i a_p_f = _mm256_permute2x128_si256(abcdefgh_ef, ijklmnop_ef, 0x31);\n\n  kernel.packet[0].x = a_p_0;\n  kernel.packet[1].x = a_p_1;\n  kernel.packet[2].x = a_p_2;\n  kernel.packet[3].x = a_p_3;\n  kernel.packet[4].x = a_p_4;\n  kernel.packet[5].x = a_p_5;\n  kernel.packet[6].x = a_p_6;\n  kernel.packet[7].x = a_p_7;\n  kernel.packet[8].x = a_p_8;\n  kernel.packet[9].x = a_p_9;\n  kernel.packet[10].x = a_p_a;\n  kernel.packet[11].x = a_p_b;\n  kernel.packet[12].x = a_p_c;\n  kernel.packet[13].x = a_p_d;\n  kernel.packet[14].x = a_p_e;\n  kernel.packet[15].x = a_p_f;\n}\n\nEIGEN_STRONG_INLINE void\nptranspose(PacketBlock<Packet16h,8>& kernel) {\n  EIGEN_ALIGN64 half in[8][16];\n  pstore<half>(in[0], kernel.packet[0]);\n  pstore<half>(in[1], kernel.packet[1]);\n  pstore<half>(in[2], kernel.packet[2]);\n  pstore<half>(in[3], kernel.packet[3]);\n  pstore<half>(in[4], kernel.packet[4]);\n  pstore<half>(in[5], kernel.packet[5]);\n  pstore<half>(in[6], kernel.packet[6]);\n  pstore<half>(in[7], kernel.packet[7]);\n\n  EIGEN_ALIGN64 half out[8][16];\n\n  for (int i = 0; i < 8; ++i) {\n    for (int j = 0; j < 8; ++j) {\n      out[i][j] = in[j][2*i];\n    }\n    for (int j = 0; j < 8; ++j) {\n      out[i][j+8] = in[j][2*i+1];\n    }\n  }\n\n  kernel.packet[0] = pload<Packet16h>(out[0]);\n  kernel.packet[1] = pload<Packet16h>(out[1]);\n  kernel.packet[2] = pload<Packet16h>(out[2]);\n  kernel.packet[3] = pload<Packet16h>(out[3]);\n  kernel.packet[4] = pload<Packet16h>(out[4]);\n  kernel.packet[5] = pload<Packet16h>(out[5]);\n  kernel.packet[6] = pload<Packet16h>(out[6]);\n  kernel.packet[7] = pload<Packet16h>(out[7]);\n}\n\nEIGEN_STRONG_INLINE void\nptranspose(PacketBlock<Packet16h,4>& kernel) {\n  EIGEN_ALIGN64 half in[4][16];\n  pstore<half>(in[0], kernel.packet[0]);\n  pstore<half>(in[1], kernel.packet[1]);\n  pstore<half>(in[2], kernel.packet[2]);\n  pstore<half>(in[3], kernel.packet[3]);\n\n  EIGEN_ALIGN64 half out[4][16];\n\n  for (int i = 0; i < 4; ++i) {\n    for (int j = 0; j < 4; ++j) {\n      out[i][j] = in[j][4*i];\n    }\n    for (int j = 0; j < 4; ++j) {\n      out[i][j+4] = in[j][4*i+1];\n    }\n    for (int j = 0; j < 4; ++j) {\n      out[i][j+8] = in[j][4*i+2];\n    }\n    for (int j = 0; j < 4; ++j) {\n      out[i][j+12] = in[j][4*i+3];\n    }\n  }\n\n  kernel.packet[0] = pload<Packet16h>(out[0]);\n  kernel.packet[1] = pload<Packet16h>(out[1]);\n  kernel.packet[2] = pload<Packet16h>(out[2]);\n  kernel.packet[3] = pload<Packet16h>(out[3]);\n}\n\n\n#elif defined EIGEN_VECTORIZE_AVX\n\ntypedef struct {\n  __m128i x;\n} Packet8h;\n\n\ntemplate<> struct is_arithmetic<Packet8h> { enum { value = true }; };\n\ntemplate <>\nstruct packet_traits<Eigen::half> : default_packet_traits {\n  typedef Packet8h type;\n  // There is no half-size packet for Packet8h.\n  typedef Packet8h half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 8,\n    HasHalfPacket = 0,\n    HasAdd    = 0,\n    HasSub    = 0,\n    HasMul    = 0,\n    HasNegate = 0,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasConj   = 0,\n    HasSetLinear = 0,\n    HasDiv = 0,\n    HasSqrt = 0,\n    HasRsqrt = 0,\n    HasExp = 0,\n    HasLog = 0,\n    HasBlend = 0\n  };\n};\n\n\ntemplate<> struct unpacket_traits<Packet8h> { typedef Eigen::half type; enum {size=8, alignment=Aligned16}; typedef Packet8h half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet8h pset1<Packet8h>(const Eigen::half& from) {\n  Packet8h result;\n  result.x = _mm_set1_epi16(from.x);\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Eigen::half pfirst<Packet8h>(const Packet8h& from) {\n  return half_impl::raw_uint16_to_half(static_cast<unsigned short>(_mm_extract_epi16(from.x, 0)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8h pload<Packet8h>(const Eigen::half* from) {\n  Packet8h result;\n  result.x = _mm_load_si128(reinterpret_cast<const __m128i*>(from));\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8h ploadu<Packet8h>(const Eigen::half* from) {\n  Packet8h result;\n  result.x = _mm_loadu_si128(reinterpret_cast<const __m128i*>(from));\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<Eigen::half>(Eigen::half* to, const Packet8h& from) {\n  _mm_store_si128(reinterpret_cast<__m128i*>(to), from.x);\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<Eigen::half>(Eigen::half* to, const Packet8h& from) {\n  _mm_storeu_si128(reinterpret_cast<__m128i*>(to), from.x);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8h\nploadquad<Packet8h>(const Eigen::half* from) {\n  Packet8h result;\n  unsigned short a = from[0].x;\n  unsigned short b = from[1].x;\n  result.x = _mm_set_epi16(b, b, b, b, a, a, a, a);\n  return result;\n}\n\nEIGEN_STRONG_INLINE Packet8f half2float(const Packet8h& a) {\n#ifdef EIGEN_HAS_FP16_C\n  return _mm256_cvtph_ps(a.x);\n#else\n  EIGEN_ALIGN32 Eigen::half aux[8];\n  pstore(aux, a);\n  float f0(aux[0]);\n  float f1(aux[1]);\n  float f2(aux[2]);\n  float f3(aux[3]);\n  float f4(aux[4]);\n  float f5(aux[5]);\n  float f6(aux[6]);\n  float f7(aux[7]);\n\n  return _mm256_set_ps(f7, f6, f5, f4, f3, f2, f1, f0);\n#endif\n}\n\nEIGEN_STRONG_INLINE Packet8h float2half(const Packet8f& a) {\n#ifdef EIGEN_HAS_FP16_C\n  Packet8h result;\n  result.x = _mm256_cvtps_ph(a, _MM_FROUND_TO_NEAREST_INT|_MM_FROUND_NO_EXC);\n  return result;\n#else\n  EIGEN_ALIGN32 float aux[8];\n  pstore(aux, a);\n  Eigen::half h0(aux[0]);\n  Eigen::half h1(aux[1]);\n  Eigen::half h2(aux[2]);\n  Eigen::half h3(aux[3]);\n  Eigen::half h4(aux[4]);\n  Eigen::half h5(aux[5]);\n  Eigen::half h6(aux[6]);\n  Eigen::half h7(aux[7]);\n\n  Packet8h result;\n  result.x = _mm_set_epi16(h7.x, h6.x, h5.x, h4.x, h3.x, h2.x, h1.x, h0.x);\n  return result;\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8h pconj(const Packet8h& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet8h padd<Packet8h>(const Packet8h& a, const Packet8h& b) {\n  Packet8f af = half2float(a);\n  Packet8f bf = half2float(b);\n  Packet8f rf = padd(af, bf);\n  return float2half(rf);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8h pmul<Packet8h>(const Packet8h& a, const Packet8h& b) {\n  Packet8f af = half2float(a);\n  Packet8f bf = half2float(b);\n  Packet8f rf = pmul(af, bf);\n  return float2half(rf);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet8h pgather<Eigen::half, Packet8h>(const Eigen::half* from, Index stride)\n{\n  Packet8h result;\n  result.x = _mm_set_epi16(from[7*stride].x, from[6*stride].x, from[5*stride].x, from[4*stride].x, from[3*stride].x, from[2*stride].x, from[1*stride].x, from[0*stride].x);\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pscatter<Eigen::half, Packet8h>(Eigen::half* to, const Packet8h& from, Index stride)\n{\n  EIGEN_ALIGN32 Eigen::half aux[8];\n  pstore(aux, from);\n  to[stride*0].x = aux[0].x;\n  to[stride*1].x = aux[1].x;\n  to[stride*2].x = aux[2].x;\n  to[stride*3].x = aux[3].x;\n  to[stride*4].x = aux[4].x;\n  to[stride*5].x = aux[5].x;\n  to[stride*6].x = aux[6].x;\n  to[stride*7].x = aux[7].x;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Eigen::half predux<Packet8h>(const Packet8h& a) {\n  Packet8f af = half2float(a);\n  float reduced = predux<Packet8f>(af);\n  return Eigen::half(reduced);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Eigen::half predux_max<Packet8h>(const Packet8h& a) {\n  Packet8f af = half2float(a);\n  float reduced = predux_max<Packet8f>(af);\n  return Eigen::half(reduced);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Eigen::half predux_min<Packet8h>(const Packet8h& a) {\n  Packet8f af = half2float(a);\n  float reduced = predux_min<Packet8f>(af);\n  return Eigen::half(reduced);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Eigen::half predux_mul<Packet8h>(const Packet8h& a) {\n  Packet8f af = half2float(a);\n  float reduced = predux_mul<Packet8f>(af);\n  return Eigen::half(reduced);\n}\n\nEIGEN_STRONG_INLINE void\nptranspose(PacketBlock<Packet8h,8>& kernel) {\n  __m128i a = kernel.packet[0].x;\n  __m128i b = kernel.packet[1].x;\n  __m128i c = kernel.packet[2].x;\n  __m128i d = kernel.packet[3].x;\n  __m128i e = kernel.packet[4].x;\n  __m128i f = kernel.packet[5].x;\n  __m128i g = kernel.packet[6].x;\n  __m128i h = kernel.packet[7].x;\n\n  __m128i a03b03 = _mm_unpacklo_epi16(a, b);\n  __m128i c03d03 = _mm_unpacklo_epi16(c, d);\n  __m128i e03f03 = _mm_unpacklo_epi16(e, f);\n  __m128i g03h03 = _mm_unpacklo_epi16(g, h);\n  __m128i a47b47 = _mm_unpackhi_epi16(a, b);\n  __m128i c47d47 = _mm_unpackhi_epi16(c, d);\n  __m128i e47f47 = _mm_unpackhi_epi16(e, f);\n  __m128i g47h47 = _mm_unpackhi_epi16(g, h);\n\n  __m128i a01b01c01d01 = _mm_unpacklo_epi32(a03b03, c03d03);\n  __m128i a23b23c23d23 = _mm_unpackhi_epi32(a03b03, c03d03);\n  __m128i e01f01g01h01 = _mm_unpacklo_epi32(e03f03, g03h03);\n  __m128i e23f23g23h23 = _mm_unpackhi_epi32(e03f03, g03h03);\n  __m128i a45b45c45d45 = _mm_unpacklo_epi32(a47b47, c47d47);\n  __m128i a67b67c67d67 = _mm_unpackhi_epi32(a47b47, c47d47);\n  __m128i e45f45g45h45 = _mm_unpacklo_epi32(e47f47, g47h47);\n  __m128i e67f67g67h67 = _mm_unpackhi_epi32(e47f47, g47h47);\n\n  __m128i a0b0c0d0e0f0g0h0 = _mm_unpacklo_epi64(a01b01c01d01, e01f01g01h01);\n  __m128i a1b1c1d1e1f1g1h1 = _mm_unpackhi_epi64(a01b01c01d01, e01f01g01h01);\n  __m128i a2b2c2d2e2f2g2h2 = _mm_unpacklo_epi64(a23b23c23d23, e23f23g23h23);\n  __m128i a3b3c3d3e3f3g3h3 = _mm_unpackhi_epi64(a23b23c23d23, e23f23g23h23);\n  __m128i a4b4c4d4e4f4g4h4 = _mm_unpacklo_epi64(a45b45c45d45, e45f45g45h45);\n  __m128i a5b5c5d5e5f5g5h5 = _mm_unpackhi_epi64(a45b45c45d45, e45f45g45h45);\n  __m128i a6b6c6d6e6f6g6h6 = _mm_unpacklo_epi64(a67b67c67d67, e67f67g67h67);\n  __m128i a7b7c7d7e7f7g7h7 = _mm_unpackhi_epi64(a67b67c67d67, e67f67g67h67);\n\n  kernel.packet[0].x = a0b0c0d0e0f0g0h0;\n  kernel.packet[1].x = a1b1c1d1e1f1g1h1;\n  kernel.packet[2].x = a2b2c2d2e2f2g2h2;\n  kernel.packet[3].x = a3b3c3d3e3f3g3h3;\n  kernel.packet[4].x = a4b4c4d4e4f4g4h4;\n  kernel.packet[5].x = a5b5c5d5e5f5g5h5;\n  kernel.packet[6].x = a6b6c6d6e6f6g6h6;\n  kernel.packet[7].x = a7b7c7d7e7f7g7h7;\n}\n\nEIGEN_STRONG_INLINE void\nptranspose(PacketBlock<Packet8h,4>& kernel) {\n  EIGEN_ALIGN32 Eigen::half in[4][8];\n  pstore<Eigen::half>(in[0], kernel.packet[0]);\n  pstore<Eigen::half>(in[1], kernel.packet[1]);\n  pstore<Eigen::half>(in[2], kernel.packet[2]);\n  pstore<Eigen::half>(in[3], kernel.packet[3]);\n\n  EIGEN_ALIGN32 Eigen::half out[4][8];\n\n  for (int i = 0; i < 4; ++i) {\n    for (int j = 0; j < 4; ++j) {\n      out[i][j] = in[j][2*i];\n    }\n    for (int j = 0; j < 4; ++j) {\n      out[i][j+4] = in[j][2*i+1];\n    }\n  }\n\n  kernel.packet[0] = pload<Packet8h>(out[0]);\n  kernel.packet[1] = pload<Packet8h>(out[1]);\n  kernel.packet[2] = pload<Packet8h>(out[2]);\n  kernel.packet[3] = pload<Packet8h>(out[3]);\n}\n\n\n// Disable the following code since it's broken on too many platforms / compilers.\n//#elif defined(EIGEN_VECTORIZE_SSE) && (!EIGEN_ARCH_x86_64) && (!EIGEN_COMP_MSVC)\n#elif 0\n\ntypedef struct {\n  __m64 x;\n} Packet4h;\n\n\ntemplate<> struct is_arithmetic<Packet4h> { enum { value = true }; };\n\ntemplate <>\nstruct packet_traits<Eigen::half> : default_packet_traits {\n  typedef Packet4h type;\n  // There is no half-size packet for Packet4h.\n  typedef Packet4h half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 4,\n    HasHalfPacket = 0,\n    HasAdd    = 0,\n    HasSub    = 0,\n    HasMul    = 0,\n    HasNegate = 0,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasConj   = 0,\n    HasSetLinear = 0,\n    HasDiv = 0,\n    HasSqrt = 0,\n    HasRsqrt = 0,\n    HasExp = 0,\n    HasLog = 0,\n    HasBlend = 0\n  };\n};\n\n\ntemplate<> struct unpacket_traits<Packet4h> { typedef Eigen::half type; enum {size=4, alignment=Aligned16}; typedef Packet4h half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet4h pset1<Packet4h>(const Eigen::half& from) {\n  Packet4h result;\n  result.x = _mm_set1_pi16(from.x);\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Eigen::half pfirst<Packet4h>(const Packet4h& from) {\n  return half_impl::raw_uint16_to_half(static_cast<unsigned short>(_mm_cvtsi64_si32(from.x)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4h pconj(const Packet4h& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4h padd<Packet4h>(const Packet4h& a, const Packet4h& b) {\n  __int64_t a64 = _mm_cvtm64_si64(a.x);\n  __int64_t b64 = _mm_cvtm64_si64(b.x);\n\n  Eigen::half h[4];\n\n  Eigen::half ha = half_impl::raw_uint16_to_half(static_cast<unsigned short>(a64));\n  Eigen::half hb = half_impl::raw_uint16_to_half(static_cast<unsigned short>(b64));\n  h[0] = ha + hb;\n  ha = half_impl::raw_uint16_to_half(static_cast<unsigned short>(a64 >> 16));\n  hb = half_impl::raw_uint16_to_half(static_cast<unsigned short>(b64 >> 16));\n  h[1] = ha + hb;\n  ha = half_impl::raw_uint16_to_half(static_cast<unsigned short>(a64 >> 32));\n  hb = half_impl::raw_uint16_to_half(static_cast<unsigned short>(b64 >> 32));\n  h[2] = ha + hb;\n  ha = half_impl::raw_uint16_to_half(static_cast<unsigned short>(a64 >> 48));\n  hb = half_impl::raw_uint16_to_half(static_cast<unsigned short>(b64 >> 48));\n  h[3] = ha + hb;\n  Packet4h result;\n  result.x = _mm_set_pi16(h[3].x, h[2].x, h[1].x, h[0].x);\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4h pmul<Packet4h>(const Packet4h& a, const Packet4h& b) {\n  __int64_t a64 = _mm_cvtm64_si64(a.x);\n  __int64_t b64 = _mm_cvtm64_si64(b.x);\n\n  Eigen::half h[4];\n\n  Eigen::half ha = half_impl::raw_uint16_to_half(static_cast<unsigned short>(a64));\n  Eigen::half hb = half_impl::raw_uint16_to_half(static_cast<unsigned short>(b64));\n  h[0] = ha * hb;\n  ha = half_impl::raw_uint16_to_half(static_cast<unsigned short>(a64 >> 16));\n  hb = half_impl::raw_uint16_to_half(static_cast<unsigned short>(b64 >> 16));\n  h[1] = ha * hb;\n  ha = half_impl::raw_uint16_to_half(static_cast<unsigned short>(a64 >> 32));\n  hb = half_impl::raw_uint16_to_half(static_cast<unsigned short>(b64 >> 32));\n  h[2] = ha * hb;\n  ha = half_impl::raw_uint16_to_half(static_cast<unsigned short>(a64 >> 48));\n  hb = half_impl::raw_uint16_to_half(static_cast<unsigned short>(b64 >> 48));\n  h[3] = ha * hb;\n  Packet4h result;\n  result.x = _mm_set_pi16(h[3].x, h[2].x, h[1].x, h[0].x);\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4h pload<Packet4h>(const Eigen::half* from) {\n  Packet4h result;\n  result.x = _mm_cvtsi64_m64(*reinterpret_cast<const __int64_t*>(from));\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4h ploadu<Packet4h>(const Eigen::half* from) {\n  Packet4h result;\n  result.x = _mm_cvtsi64_m64(*reinterpret_cast<const __int64_t*>(from));\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<Eigen::half>(Eigen::half* to, const Packet4h& from) {\n  __int64_t r = _mm_cvtm64_si64(from.x);\n  *(reinterpret_cast<__int64_t*>(to)) = r;\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<Eigen::half>(Eigen::half* to, const Packet4h& from) {\n  __int64_t r = _mm_cvtm64_si64(from.x);\n  *(reinterpret_cast<__int64_t*>(to)) = r;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4h\nploadquad<Packet4h>(const Eigen::half* from) {\n  return pset1<Packet4h>(*from);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4h pgather<Eigen::half, Packet4h>(const Eigen::half* from, Index stride)\n{\n  Packet4h result;\n  result.x = _mm_set_pi16(from[3*stride].x, from[2*stride].x, from[1*stride].x, from[0*stride].x);\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pscatter<Eigen::half, Packet4h>(Eigen::half* to, const Packet4h& from, Index stride)\n{\n  __int64_t a = _mm_cvtm64_si64(from.x);\n  to[stride*0].x = static_cast<unsigned short>(a);\n  to[stride*1].x = static_cast<unsigned short>(a >> 16);\n  to[stride*2].x = static_cast<unsigned short>(a >> 32);\n  to[stride*3].x = static_cast<unsigned short>(a >> 48);\n}\n\nEIGEN_STRONG_INLINE void\nptranspose(PacketBlock<Packet4h,4>& kernel) {\n  __m64 T0 = _mm_unpacklo_pi16(kernel.packet[0].x, kernel.packet[1].x);\n  __m64 T1 = _mm_unpacklo_pi16(kernel.packet[2].x, kernel.packet[3].x);\n  __m64 T2 = _mm_unpackhi_pi16(kernel.packet[0].x, kernel.packet[1].x);\n  __m64 T3 = _mm_unpackhi_pi16(kernel.packet[2].x, kernel.packet[3].x);\n\n  kernel.packet[0].x = _mm_unpacklo_pi32(T0, T1);\n  kernel.packet[1].x = _mm_unpackhi_pi32(T0, T1);\n  kernel.packet[2].x = _mm_unpacklo_pi32(T2, T3);\n  kernel.packet[3].x = _mm_unpackhi_pi32(T2, T3);\n}\n\n#endif\n\n}\n}\n\n#endif // EIGEN_PACKET_MATH_HALF_CUDA_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/CUDA/TypeCasting.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2016 Benoit Steiner <benoit.steiner.goog@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TYPE_CASTING_CUDA_H\n#define EIGEN_TYPE_CASTING_CUDA_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<>\nstruct scalar_cast_op<float, Eigen::half> {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op)\n  typedef Eigen::half result_type;\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::half operator() (const float& a) const {\n    #if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300\n      return __float2half(a);\n    #else\n      return Eigen::half(a);\n    #endif\n  }\n};\n\ntemplate<>\nstruct functor_traits<scalar_cast_op<float, Eigen::half> >\n{ enum { Cost = NumTraits<float>::AddCost, PacketAccess = false }; };\n\n\ntemplate<>\nstruct scalar_cast_op<int, Eigen::half> {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op)\n  typedef Eigen::half result_type;\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::half operator() (const int& a) const {\n    #if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300\n      return __float2half(static_cast<float>(a));\n    #else\n      return Eigen::half(static_cast<float>(a));\n    #endif\n  }\n};\n\ntemplate<>\nstruct functor_traits<scalar_cast_op<int, Eigen::half> >\n{ enum { Cost = NumTraits<float>::AddCost, PacketAccess = false }; };\n\n\ntemplate<>\nstruct scalar_cast_op<Eigen::half, float> {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op)\n  typedef float result_type;\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float operator() (const Eigen::half& a) const {\n    #if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300\n      return __half2float(a);\n    #else\n      return static_cast<float>(a);\n    #endif\n  }\n};\n\ntemplate<>\nstruct functor_traits<scalar_cast_op<Eigen::half, float> >\n{ enum { Cost = NumTraits<float>::AddCost, PacketAccess = false }; };\n\n\n\n#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300\n\ntemplate <>\nstruct type_casting_traits<Eigen::half, float> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 2,\n    TgtCoeffRatio = 1\n  };\n};\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pcast<half2, float4>(const half2& a, const half2& b) {\n  float2 r1 = __half22float2(a);\n  float2 r2 = __half22float2(b);\n  return make_float4(r1.x, r1.y, r2.x, r2.y);\n}\n\ntemplate <>\nstruct type_casting_traits<float, Eigen::half> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 2\n  };\n};\n\ntemplate<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE half2 pcast<float4, half2>(const float4& a) {\n  // Simply discard the second half of the input\n  return __floats2half2_rn(a.x, a.y);\n}\n\n#elif defined EIGEN_VECTORIZE_AVX512\ntemplate <>\nstruct type_casting_traits<half, float> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 1\n  };\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet16f pcast<Packet16h, Packet16f>(const Packet16h& a) {\n  return half2float(a);\n}\n\ntemplate <>\nstruct type_casting_traits<float, half> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 1\n  };\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet16h pcast<Packet16f, Packet16h>(const Packet16f& a) {\n  return float2half(a);\n}\n\n#elif defined EIGEN_VECTORIZE_AVX\n\ntemplate <>\nstruct type_casting_traits<Eigen::half, float> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 1\n  };\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet8f pcast<Packet8h, Packet8f>(const Packet8h& a) {\n  return half2float(a);\n}\n\ntemplate <>\nstruct type_casting_traits<float, Eigen::half> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 1\n  };\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet8h pcast<Packet8f, Packet8h>(const Packet8f& a) {\n  return float2half(a);\n}\n\n// Disable the following code since it's broken on too many platforms / compilers.\n//#elif defined(EIGEN_VECTORIZE_SSE) && (!EIGEN_ARCH_x86_64) && (!EIGEN_COMP_MSVC)\n#elif 0\n\ntemplate <>\nstruct type_casting_traits<Eigen::half, float> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 1\n  };\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pcast<Packet4h, Packet4f>(const Packet4h& a) {\n  __int64_t a64 = _mm_cvtm64_si64(a.x);\n  Eigen::half h = raw_uint16_to_half(static_cast<unsigned short>(a64));\n  float f1 = static_cast<float>(h);\n  h = raw_uint16_to_half(static_cast<unsigned short>(a64 >> 16));\n  float f2 = static_cast<float>(h);\n  h = raw_uint16_to_half(static_cast<unsigned short>(a64 >> 32));\n  float f3 = static_cast<float>(h);\n  h = raw_uint16_to_half(static_cast<unsigned short>(a64 >> 48));\n  float f4 = static_cast<float>(h);\n  return _mm_set_ps(f4, f3, f2, f1);\n}\n\ntemplate <>\nstruct type_casting_traits<float, Eigen::half> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 1\n  };\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet4h pcast<Packet4f, Packet4h>(const Packet4f& a) {\n  EIGEN_ALIGN16 float aux[4];\n  pstore(aux, a);\n  Eigen::half h0(aux[0]);\n  Eigen::half h1(aux[1]);\n  Eigen::half h2(aux[2]);\n  Eigen::half h3(aux[3]);\n\n  Packet4h result;\n  result.x = _mm_set_pi16(h3.x, h2.x, h1.x, h0.x);\n  return result;\n}\n\n#endif\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TYPE_CASTING_CUDA_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/Default/Settings.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n\n/* All the parameters defined in this file can be specialized in the\n * architecture specific files, and/or by the user.\n * More to come... */\n\n#ifndef EIGEN_DEFAULT_SETTINGS_H\n#define EIGEN_DEFAULT_SETTINGS_H\n\n/** Defines the maximal loop size to enable meta unrolling of loops.\n  * Note that the value here is expressed in Eigen's own notion of \"number of FLOPS\",\n  * it does not correspond to the number of iterations or the number of instructions\n  */\n#ifndef EIGEN_UNROLLING_LIMIT\n#define EIGEN_UNROLLING_LIMIT 100\n#endif\n\n/** Defines the threshold between a \"small\" and a \"large\" matrix.\n  * This threshold is mainly used to select the proper product implementation.\n  */\n#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD\n#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8\n#endif\n\n/** Defines the maximal width of the blocks used in the triangular product and solver\n  * for vectors (level 2 blas xTRMV and xTRSV). The default is 8.\n  */\n#ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH\n#define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8\n#endif\n\n\n/** Defines the default number of registers available for that architecture.\n  * Currently it must be 8 or 16. Other values will fail.\n  */\n#ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS\n#define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8\n#endif\n\n#endif // EIGEN_DEFAULT_SETTINGS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/NEON/Complex.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010 Konstantinos Margaritis <markos@freevec.org>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COMPLEX_NEON_H\n#define EIGEN_COMPLEX_NEON_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ninline uint32x4_t p4ui_CONJ_XOR() {\n// See bug 1325, clang fails to call vld1q_u64.\n#if EIGEN_COMP_CLANG\n  uint32x4_t ret = { 0x00000000, 0x80000000, 0x00000000, 0x80000000 };\n  return ret;\n#else\n  static const uint32_t conj_XOR_DATA[] = { 0x00000000, 0x80000000, 0x00000000, 0x80000000 };\n  return vld1q_u32( conj_XOR_DATA );\n#endif\n}\n\ninline uint32x2_t p2ui_CONJ_XOR() {\n  static const uint32_t conj_XOR_DATA[] = { 0x00000000, 0x80000000 };\n  return vld1_u32( conj_XOR_DATA );\n}\n\n//---------- float ----------\nstruct Packet2cf\n{\n  EIGEN_STRONG_INLINE Packet2cf() {}\n  EIGEN_STRONG_INLINE explicit Packet2cf(const Packet4f& a) : v(a) {}\n  Packet4f  v;\n};\n\ntemplate<> struct packet_traits<std::complex<float> >  : default_packet_traits\n{\n  typedef Packet2cf type;\n  typedef Packet2cf half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 2,\n    HasHalfPacket = 0,\n\n    HasAdd    = 1,\n    HasSub    = 1,\n    HasMul    = 1,\n    HasDiv    = 1,\n    HasNegate = 1,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasSetLinear = 0\n  };\n};\n\ntemplate<> struct unpacket_traits<Packet2cf> { typedef std::complex<float> type; enum {size=2, alignment=Aligned16}; typedef Packet2cf half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>&  from)\n{\n  float32x2_t r64;\n  r64 = vld1_f32((float *)&from);\n\n  return Packet2cf(vcombine_f32(r64, r64));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(padd<Packet4f>(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(psub<Packet4f>(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf& a) { return Packet2cf(pnegate<Packet4f>(a.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf& a)\n{\n  Packet4ui b = vreinterpretq_u32_f32(a.v);\n  return Packet2cf(vreinterpretq_f32_u32(veorq_u32(b, p4ui_CONJ_XOR())));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  Packet4f v1, v2;\n\n  // Get the real values of a | a1_re | a1_re | a2_re | a2_re |\n  v1 = vcombine_f32(vdup_lane_f32(vget_low_f32(a.v), 0), vdup_lane_f32(vget_high_f32(a.v), 0));\n  // Get the imag values of a | a1_im | a1_im | a2_im | a2_im |\n  v2 = vcombine_f32(vdup_lane_f32(vget_low_f32(a.v), 1), vdup_lane_f32(vget_high_f32(a.v), 1));\n  // Multiply the real a with b\n  v1 = vmulq_f32(v1, b.v);\n  // Multiply the imag a with b\n  v2 = vmulq_f32(v2, b.v);\n  // Conjugate v2 \n  v2 = vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(v2), p4ui_CONJ_XOR()));\n  // Swap real/imag elements in v2.\n  v2 = vrev64q_f32(v2);\n  // Add and return the result\n  return Packet2cf(vaddq_f32(v1, v2));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pand   <Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  return Packet2cf(vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v))));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2cf por    <Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  return Packet2cf(vreinterpretq_f32_u32(vorrq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v))));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pxor   <Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  return Packet2cf(vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v))));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  return Packet2cf(vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v))));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pload<Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(pload<Packet4f>((const float*)from)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ploadu<Packet4f>((const float*)from)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(const std::complex<float>* from) { return pset1<Packet2cf>(*from); }\n\ntemplate<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> *   to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((float*)to, from.v); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> *   to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((float*)to, from.v); }\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, Index stride)\n{\n  Packet4f res = pset1<Packet4f>(0.f);\n  res = vsetq_lane_f32(std::real(from[0*stride]), res, 0);\n  res = vsetq_lane_f32(std::imag(from[0*stride]), res, 1);\n  res = vsetq_lane_f32(std::real(from[1*stride]), res, 2);\n  res = vsetq_lane_f32(std::imag(from[1*stride]), res, 3);\n  return Packet2cf(res);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, Index stride)\n{\n  to[stride*0] = std::complex<float>(vgetq_lane_f32(from.v, 0), vgetq_lane_f32(from.v, 1));\n  to[stride*1] = std::complex<float>(vgetq_lane_f32(from.v, 2), vgetq_lane_f32(from.v, 3));\n}\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> *   addr) { EIGEN_ARM_PREFETCH((float *)addr); }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float>  pfirst<Packet2cf>(const Packet2cf& a)\n{\n  std::complex<float> EIGEN_ALIGN16 x[2];\n  vst1q_f32((float *)x, a.v);\n  return x[0];\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf& a)\n{\n  float32x2_t a_lo, a_hi;\n  Packet4f a_r128;\n\n  a_lo = vget_low_f32(a.v);\n  a_hi = vget_high_f32(a.v);\n  a_r128 = vcombine_f32(a_hi, a_lo);\n\n  return Packet2cf(a_r128);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pcplxflip<Packet2cf>(const Packet2cf& a)\n{\n  return Packet2cf(vrev64q_f32(a.v));\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(const Packet2cf& a)\n{\n  float32x2_t a1, a2;\n  std::complex<float> s;\n\n  a1 = vget_low_f32(a.v);\n  a2 = vget_high_f32(a.v);\n  a2 = vadd_f32(a1, a2);\n  vst1_f32((float *)&s, a2);\n\n  return s;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(const Packet2cf* vecs)\n{\n  Packet4f sum1, sum2, sum;\n\n  // Add the first two 64-bit float32x2_t of vecs[0]\n  sum1 = vcombine_f32(vget_low_f32(vecs[0].v), vget_low_f32(vecs[1].v));\n  sum2 = vcombine_f32(vget_high_f32(vecs[0].v), vget_high_f32(vecs[1].v));\n  sum = vaddq_f32(sum1, sum2);\n\n  return Packet2cf(sum);\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(const Packet2cf& a)\n{\n  float32x2_t a1, a2, v1, v2, prod;\n  std::complex<float> s;\n\n  a1 = vget_low_f32(a.v);\n  a2 = vget_high_f32(a.v);\n   // Get the real values of a | a1_re | a1_re | a2_re | a2_re |\n  v1 = vdup_lane_f32(a1, 0);\n  // Get the real values of a | a1_im | a1_im | a2_im | a2_im |\n  v2 = vdup_lane_f32(a1, 1);\n  // Multiply the real a with b\n  v1 = vmul_f32(v1, a2);\n  // Multiply the imag a with b\n  v2 = vmul_f32(v2, a2);\n  // Conjugate v2 \n  v2 = vreinterpret_f32_u32(veor_u32(vreinterpret_u32_f32(v2), p2ui_CONJ_XOR()));\n  // Swap real/imag elements in v2.\n  v2 = vrev64_f32(v2);\n  // Add v1, v2\n  prod = vadd_f32(v1, v2);\n\n  vst1_f32((float *)&s, prod);\n\n  return s;\n}\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet2cf>\n{\n  EIGEN_STRONG_INLINE static void run(Packet2cf& first, const Packet2cf& second)\n  {\n    if (Offset==1)\n    {\n      first.v = vextq_f32(first.v, second.v, 2);\n    }\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, false,true>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    return internal::pmul(a, pconj(b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, true,false>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    return internal::pmul(pconj(a), b);\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, true,true>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    return pconj(internal::pmul(a, b));\n  }\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  // TODO optimize it for NEON\n  Packet2cf res = conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a,b);\n  Packet4f s, rev_s;\n\n  // this computes the norm\n  s = vmulq_f32(b.v, b.v);\n  rev_s = vrev64q_f32(s);\n\n  return Packet2cf(pdiv(res.v, vaddq_f32(s,rev_s)));\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet2cf,2>& kernel) {\n  Packet4f tmp = vcombine_f32(vget_high_f32(kernel.packet[0].v), vget_high_f32(kernel.packet[1].v));\n  kernel.packet[0].v = vcombine_f32(vget_low_f32(kernel.packet[0].v), vget_low_f32(kernel.packet[1].v));\n  kernel.packet[1].v = tmp;\n}\n\n//---------- double ----------\n#if EIGEN_ARCH_ARM64 && !EIGEN_APPLE_DOUBLE_NEON_BUG\n\n// See bug 1325, clang fails to call vld1q_u64.\n#if EIGEN_COMP_CLANG\n  static uint64x2_t p2ul_CONJ_XOR = {0x0, 0x8000000000000000};\n#else\n  const uint64_t  p2ul_conj_XOR_DATA[] = { 0x0, 0x8000000000000000 };\n  static uint64x2_t p2ul_CONJ_XOR = vld1q_u64( p2ul_conj_XOR_DATA );\n#endif\n\nstruct Packet1cd\n{\n  EIGEN_STRONG_INLINE Packet1cd() {}\n  EIGEN_STRONG_INLINE explicit Packet1cd(const Packet2d& a) : v(a) {}\n  Packet2d v;\n};\n\ntemplate<> struct packet_traits<std::complex<double> >  : default_packet_traits\n{\n  typedef Packet1cd type;\n  typedef Packet1cd half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 0,\n    size = 1,\n    HasHalfPacket = 0,\n\n    HasAdd    = 1,\n    HasSub    = 1,\n    HasMul    = 1,\n    HasDiv    = 1,\n    HasNegate = 1,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasSetLinear = 0\n  };\n};\n\ntemplate<> struct unpacket_traits<Packet1cd> { typedef std::complex<double> type; enum {size=1, alignment=Aligned16}; typedef Packet1cd half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pload<Packet1cd>(const std::complex<double>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet1cd(pload<Packet2d>((const double*)from)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(const std::complex<double>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet1cd(ploadu<Packet2d>((const double*)from)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(const std::complex<double>&  from)\n{ /* here we really have to use unaligned loads :( */ return ploadu<Packet1cd>(&from); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(padd<Packet2d>(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(psub<Packet2d>(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pnegate(const Packet1cd& a) { return Packet1cd(pnegate<Packet2d>(a.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pconj(const Packet1cd& a) { return Packet1cd(vreinterpretq_f64_u64(veorq_u64(vreinterpretq_u64_f64(a.v), p2ul_CONJ_XOR))); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pmul<Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  Packet2d v1, v2;\n\n  // Get the real values of a \n  v1 = vdupq_lane_f64(vget_low_f64(a.v), 0);\n  // Get the imag values of a\n  v2 = vdupq_lane_f64(vget_high_f64(a.v), 0);\n  // Multiply the real a with b\n  v1 = vmulq_f64(v1, b.v);\n  // Multiply the imag a with b\n  v2 = vmulq_f64(v2, b.v);\n  // Conjugate v2 \n  v2 = vreinterpretq_f64_u64(veorq_u64(vreinterpretq_u64_f64(v2), p2ul_CONJ_XOR));\n  // Swap real/imag elements in v2.\n  v2 = preverse<Packet2d>(v2);\n  // Add and return the result\n  return Packet1cd(vaddq_f64(v1, v2));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pand   <Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  return Packet1cd(vreinterpretq_f64_u64(vandq_u64(vreinterpretq_u64_f64(a.v),vreinterpretq_u64_f64(b.v))));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet1cd por    <Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  return Packet1cd(vreinterpretq_f64_u64(vorrq_u64(vreinterpretq_u64_f64(a.v),vreinterpretq_u64_f64(b.v))));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pxor   <Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  return Packet1cd(vreinterpretq_f64_u64(veorq_u64(vreinterpretq_u64_f64(a.v),vreinterpretq_u64_f64(b.v))));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  return Packet1cd(vreinterpretq_f64_u64(vbicq_u64(vreinterpretq_u64_f64(a.v),vreinterpretq_u64_f64(b.v))));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(const std::complex<double>* from) { return pset1<Packet1cd>(*from); }\n\ntemplate<> EIGEN_STRONG_INLINE void pstore <std::complex<double> >(std::complex<double> *   to, const Packet1cd& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((double*)to, from.v); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex<double> *   to, const Packet1cd& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, from.v); }\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<std::complex<double> >(const std::complex<double> *   addr) { EIGEN_ARM_PREFETCH((double *)addr); }\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet1cd pgather<std::complex<double>, Packet1cd>(const std::complex<double>* from, Index stride)\n{\n  Packet2d res = pset1<Packet2d>(0.0);\n  res = vsetq_lane_f64(std::real(from[0*stride]), res, 0);\n  res = vsetq_lane_f64(std::imag(from[0*stride]), res, 1);\n  return Packet1cd(res);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to, const Packet1cd& from, Index stride)\n{\n  to[stride*0] = std::complex<double>(vgetq_lane_f64(from.v, 0), vgetq_lane_f64(from.v, 1));\n}\n\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double>  pfirst<Packet1cd>(const Packet1cd& a)\n{\n  std::complex<double> EIGEN_ALIGN16 res;\n  pstore<std::complex<double> >(&res, a);\n\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd preverse(const Packet1cd& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(const Packet1cd& a) { return pfirst(a); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd preduxp<Packet1cd>(const Packet1cd* vecs) { return vecs[0]; }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(const Packet1cd& a) { return pfirst(a); }\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet1cd>\n{\n  static EIGEN_STRONG_INLINE void run(Packet1cd& /*first*/, const Packet1cd& /*second*/)\n  {\n    // FIXME is it sure we never have to align a Packet1cd?\n    // Even though a std::complex<double> has 16 bytes, it is not necessarily aligned on a 16 bytes boundary...\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, false,true>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    return internal::pmul(a, pconj(b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, true,false>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    return internal::pmul(pconj(a), b);\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, true,true>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    return pconj(internal::pmul(a, b));\n  }\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  // TODO optimize it for NEON\n  Packet1cd res = conj_helper<Packet1cd,Packet1cd,false,true>().pmul(a,b);\n  Packet2d s = pmul<Packet2d>(b.v, b.v);\n  Packet2d rev_s = preverse<Packet2d>(s);\n\n  return Packet1cd(pdiv(res.v, padd<Packet2d>(s,rev_s)));\n}\n\nEIGEN_STRONG_INLINE Packet1cd pcplxflip/*<Packet1cd>*/(const Packet1cd& x)\n{\n  return Packet1cd(preverse(Packet2d(x.v)));\n}\n\nEIGEN_STRONG_INLINE void ptranspose(PacketBlock<Packet1cd,2>& kernel)\n{\n  Packet2d tmp = vcombine_f64(vget_high_f64(kernel.packet[0].v), vget_high_f64(kernel.packet[1].v));\n  kernel.packet[0].v = vcombine_f64(vget_low_f64(kernel.packet[0].v), vget_low_f64(kernel.packet[1].v));\n  kernel.packet[1].v = tmp;\n}\n#endif // EIGEN_ARCH_ARM64\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_COMPLEX_NEON_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/NEON/MathFunctions.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* The sin, cos, exp, and log functions of this file come from\n * Julien Pommier's sse math library: http://gruntthepeon.free.fr/ssemath/\n */\n\n#ifndef EIGEN_MATH_FUNCTIONS_NEON_H\n#define EIGEN_MATH_FUNCTIONS_NEON_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f pexp<Packet4f>(const Packet4f& _x)\n{\n  Packet4f x = _x;\n  Packet4f tmp, fx;\n\n  _EIGEN_DECLARE_CONST_Packet4f(1 , 1.0f);\n  _EIGEN_DECLARE_CONST_Packet4f(half, 0.5f);\n  _EIGEN_DECLARE_CONST_Packet4i(0x7f, 0x7f);\n  _EIGEN_DECLARE_CONST_Packet4f(exp_hi,  88.3762626647950f);\n  _EIGEN_DECLARE_CONST_Packet4f(exp_lo, -88.3762626647949f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_LOG2EF, 1.44269504088896341f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_C1, 0.693359375f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_C2, -2.12194440e-4f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p0, 1.9875691500E-4f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p1, 1.3981999507E-3f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p2, 8.3334519073E-3f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p3, 4.1665795894E-2f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p4, 1.6666665459E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p5, 5.0000001201E-1f);\n\n  x = vminq_f32(x, p4f_exp_hi);\n  x = vmaxq_f32(x, p4f_exp_lo);\n\n  /* express exp(x) as exp(g + n*log(2)) */\n  fx = vmlaq_f32(p4f_half, x, p4f_cephes_LOG2EF);\n\n  /* perform a floorf */\n  tmp = vcvtq_f32_s32(vcvtq_s32_f32(fx));\n\n  /* if greater, substract 1 */\n  Packet4ui mask = vcgtq_f32(tmp, fx);\n  mask = vandq_u32(mask, vreinterpretq_u32_f32(p4f_1));\n\n  fx = vsubq_f32(tmp, vreinterpretq_f32_u32(mask));\n\n  tmp = vmulq_f32(fx, p4f_cephes_exp_C1);\n  Packet4f z = vmulq_f32(fx, p4f_cephes_exp_C2);\n  x = vsubq_f32(x, tmp);\n  x = vsubq_f32(x, z);\n\n  Packet4f y = vmulq_f32(p4f_cephes_exp_p0, x);\n  z = vmulq_f32(x, x);\n  y = vaddq_f32(y, p4f_cephes_exp_p1);\n  y = vmulq_f32(y, x);\n  y = vaddq_f32(y, p4f_cephes_exp_p2);\n  y = vmulq_f32(y, x);\n  y = vaddq_f32(y, p4f_cephes_exp_p3);\n  y = vmulq_f32(y, x);\n  y = vaddq_f32(y, p4f_cephes_exp_p4);\n  y = vmulq_f32(y, x);\n  y = vaddq_f32(y, p4f_cephes_exp_p5);\n\n  y = vmulq_f32(y, z);\n  y = vaddq_f32(y, x);\n  y = vaddq_f32(y, p4f_1);\n\n  /* build 2^n */\n  int32x4_t mm;\n  mm = vcvtq_s32_f32(fx);\n  mm = vaddq_s32(mm, p4i_0x7f);\n  mm = vshlq_n_s32(mm, 23);\n  Packet4f pow2n = vreinterpretq_f32_s32(mm);\n\n  y = vmulq_f32(y, pow2n);\n  return y;\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_MATH_FUNCTIONS_NEON_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/NEON/PacketMath.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010 Konstantinos Margaritis <markos@freevec.org>\n// Heavily based on Gael's SSE version.\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PACKET_MATH_NEON_H\n#define EIGEN_PACKET_MATH_NEON_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD\n#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8\n#endif\n\n#ifndef EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n#define EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n#endif\n\n#ifndef EIGEN_HAS_SINGLE_INSTRUCTION_CJMADD\n#define EIGEN_HAS_SINGLE_INSTRUCTION_CJMADD\n#endif\n\n#ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS\n#if EIGEN_ARCH_ARM64\n#define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 32\n#else\n#define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 16 \n#endif\n#endif\n\ntypedef float32x2_t Packet2f;\ntypedef float32x4_t Packet4f;\ntypedef int32x4_t   Packet4i;\ntypedef int32x2_t   Packet2i;\ntypedef uint32x4_t  Packet4ui;\n\n#define _EIGEN_DECLARE_CONST_Packet4f(NAME,X) \\\n  const Packet4f p4f_##NAME = pset1<Packet4f>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(NAME,X) \\\n  const Packet4f p4f_##NAME = vreinterpretq_f32_u32(pset1<int32_t>(X))\n\n#define _EIGEN_DECLARE_CONST_Packet4i(NAME,X) \\\n  const Packet4i p4i_##NAME = pset1<Packet4i>(X)\n\n#if EIGEN_ARCH_ARM64\n  // __builtin_prefetch tends to do nothing on ARM64 compilers because the\n  // prefetch instructions there are too detailed for __builtin_prefetch to map\n  // meaningfully to them.\n  #define EIGEN_ARM_PREFETCH(ADDR)  __asm__ __volatile__(\"prfm pldl1keep, [%[addr]]\\n\" ::[addr] \"r\"(ADDR) : );\n#elif EIGEN_HAS_BUILTIN(__builtin_prefetch) || EIGEN_COMP_GNUC\n  #define EIGEN_ARM_PREFETCH(ADDR) __builtin_prefetch(ADDR);\n#elif defined __pld\n  #define EIGEN_ARM_PREFETCH(ADDR) __pld(ADDR)\n#elif EIGEN_ARCH_ARM32\n  #define EIGEN_ARM_PREFETCH(ADDR) __asm__ __volatile__ (\"pld [%[addr]]\\n\" :: [addr] \"r\" (ADDR) : );\n#else\n  // by default no explicit prefetching\n  #define EIGEN_ARM_PREFETCH(ADDR)\n#endif\n\ntemplate<> struct packet_traits<float>  : default_packet_traits\n{\n  typedef Packet4f type;\n  typedef Packet4f half; // Packet2f intrinsics not implemented yet\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 4,\n    HasHalfPacket=0, // Packet2f intrinsics not implemented yet\n   \n    HasDiv  = 1,\n    // FIXME check the Has*\n    HasSin  = 0,\n    HasCos  = 0,\n    HasLog  = 0,\n    HasExp  = 1,\n    HasSqrt = 0\n  };\n};\ntemplate<> struct packet_traits<int32_t>    : default_packet_traits\n{\n  typedef Packet4i type;\n  typedef Packet4i half; // Packet2i intrinsics not implemented yet\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=4,\n    HasHalfPacket=0 // Packet2i intrinsics not implemented yet\n    // FIXME check the Has*\n  };\n};\n\n#if EIGEN_GNUC_AT_MOST(4,4) && !EIGEN_COMP_LLVM\n// workaround gcc 4.2, 4.3 and 4.4 compilatin issue\nEIGEN_STRONG_INLINE float32x4_t vld1q_f32(const float* x) { return ::vld1q_f32((const float32_t*)x); }\nEIGEN_STRONG_INLINE float32x2_t vld1_f32 (const float* x) { return ::vld1_f32 ((const float32_t*)x); }\nEIGEN_STRONG_INLINE float32x2_t vld1_dup_f32 (const float* x) { return ::vld1_dup_f32 ((const float32_t*)x); }\nEIGEN_STRONG_INLINE void        vst1q_f32(float* to, float32x4_t from) { ::vst1q_f32((float32_t*)to,from); }\nEIGEN_STRONG_INLINE void        vst1_f32 (float* to, float32x2_t from) { ::vst1_f32 ((float32_t*)to,from); }\n#endif\n\ntemplate<> struct unpacket_traits<Packet4f> { typedef float   type; enum {size=4, alignment=Aligned16}; typedef Packet4f half; };\ntemplate<> struct unpacket_traits<Packet4i> { typedef int32_t type; enum {size=4, alignment=Aligned16}; typedef Packet4i half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float&  from) { return vdupq_n_f32(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(const int32_t&    from)   { return vdupq_n_s32(from); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f plset<Packet4f>(const float& a)\n{\n  const float f[] = {0, 1, 2, 3};\n  Packet4f countdown = vld1q_f32(f);\n  return vaddq_f32(pset1<Packet4f>(a), countdown);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i plset<Packet4i>(const int32_t& a)\n{\n  const int32_t i[] = {0, 1, 2, 3};\n  Packet4i countdown = vld1q_s32(i);\n  return vaddq_s32(pset1<Packet4i>(a), countdown);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f padd<Packet4f>(const Packet4f& a, const Packet4f& b) { return vaddq_f32(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i padd<Packet4i>(const Packet4i& a, const Packet4i& b) { return vaddq_s32(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f psub<Packet4f>(const Packet4f& a, const Packet4f& b) { return vsubq_f32(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i psub<Packet4i>(const Packet4i& a, const Packet4i& b) { return vsubq_s32(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pnegate(const Packet4f& a) { return vnegq_f32(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pnegate(const Packet4i& a) { return vnegq_s32(a); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pconj(const Packet4f& a) { return a; }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pconj(const Packet4i& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmul<Packet4f>(const Packet4f& a, const Packet4f& b) { return vmulq_f32(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmul<Packet4i>(const Packet4i& a, const Packet4i& b) { return vmulq_s32(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pdiv<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n#if EIGEN_ARCH_ARM64\n  return vdivq_f32(a,b);\n#else\n  Packet4f inv, restep, div;\n\n  // NEON does not offer a divide instruction, we have to do a reciprocal approximation\n  // However NEON in contrast to other SIMD engines (AltiVec/SSE), offers\n  // a reciprocal estimate AND a reciprocal step -which saves a few instructions\n  // vrecpeq_f32() returns an estimate to 1/b, which we will finetune with\n  // Newton-Raphson and vrecpsq_f32()\n  inv = vrecpeq_f32(b);\n\n  // This returns a differential, by which we will have to multiply inv to get a better\n  // approximation of 1/b.\n  restep = vrecpsq_f32(b, inv);\n  inv = vmulq_f32(restep, inv);\n\n  // Finally, multiply a by 1/b and get the wanted result of the division.\n  div = vmulq_f32(a, inv);\n\n  return div;\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pdiv<Packet4i>(const Packet4i& /*a*/, const Packet4i& /*b*/)\n{ eigen_assert(false && \"packet integer division are not supported by NEON\");\n  return pset1<Packet4i>(0);\n}\n\n// Clang/ARM wrongly advertises __ARM_FEATURE_FMA even when it's not available,\n// then implements a slow software scalar fallback calling fmaf()!\n// Filed LLVM bug:\n//     https://llvm.org/bugs/show_bug.cgi?id=27216\n#if (defined __ARM_FEATURE_FMA) && !(EIGEN_COMP_CLANG && EIGEN_ARCH_ARM)\n// See bug 936.\n// FMA is available on VFPv4 i.e. when compiling with -mfpu=neon-vfpv4.\n// FMA is a true fused multiply-add i.e. only 1 rounding at the end, no intermediate rounding.\n// MLA is not fused i.e. does 2 roundings.\n// In addition to giving better accuracy, FMA also gives better performance here on a Krait (Nexus 4):\n// MLA: 10 GFlop/s ; FMA: 12 GFlops/s.\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmadd(const Packet4f& a, const Packet4f& b, const Packet4f& c) { return vfmaq_f32(c,a,b); }\n#else\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmadd(const Packet4f& a, const Packet4f& b, const Packet4f& c) {\n#if EIGEN_COMP_CLANG && EIGEN_ARCH_ARM\n  // Clang/ARM will replace VMLA by VMUL+VADD at least for some values of -mcpu,\n  // at least -mcpu=cortex-a8 and -mcpu=cortex-a7. Since the former is the default on\n  // -march=armv7-a, that is a very common case.\n  // See e.g. this thread:\n  //     http://lists.llvm.org/pipermail/llvm-dev/2013-December/068806.html\n  // Filed LLVM bug:\n  //     https://llvm.org/bugs/show_bug.cgi?id=27219\n  Packet4f r = c;\n  asm volatile(\n    \"vmla.f32 %q[r], %q[a], %q[b]\"\n    : [r] \"+w\" (r)\n    : [a] \"w\" (a),\n      [b] \"w\" (b)\n    : );\n  return r;\n#else\n  return vmlaq_f32(c,a,b);\n#endif\n}\n#endif\n\n// No FMA instruction for int, so use MLA unconditionally.\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmadd(const Packet4i& a, const Packet4i& b, const Packet4i& c) { return vmlaq_s32(c,a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmin<Packet4f>(const Packet4f& a, const Packet4f& b) { return vminq_f32(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmin<Packet4i>(const Packet4i& a, const Packet4i& b) { return vminq_s32(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmax<Packet4f>(const Packet4f& a, const Packet4f& b) { return vmaxq_f32(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmax<Packet4i>(const Packet4i& a, const Packet4i& b) { return vmaxq_s32(a,b); }\n\n// Logical Operations are not supported for float, so we have to reinterpret casts using NEON intrinsics\ntemplate<> EIGEN_STRONG_INLINE Packet4f pand<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  return vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(a),vreinterpretq_u32_f32(b)));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i pand<Packet4i>(const Packet4i& a, const Packet4i& b) { return vandq_s32(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f por<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  return vreinterpretq_f32_u32(vorrq_u32(vreinterpretq_u32_f32(a),vreinterpretq_u32_f32(b)));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i por<Packet4i>(const Packet4i& a, const Packet4i& b) { return vorrq_s32(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pxor<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  return vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(a),vreinterpretq_u32_f32(b)));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i pxor<Packet4i>(const Packet4i& a, const Packet4i& b) { return veorq_s32(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pandnot<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  return vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(a),vreinterpretq_u32_f32(b)));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return vbicq_s32(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pload<Packet4f>(const float*    from) { EIGEN_DEBUG_ALIGNED_LOAD return vld1q_f32(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pload<Packet4i>(const int32_t*  from) { EIGEN_DEBUG_ALIGNED_LOAD return vld1q_s32(from); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float*   from) { EIGEN_DEBUG_UNALIGNED_LOAD return vld1q_f32(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i ploadu<Packet4i>(const int32_t* from) { EIGEN_DEBUG_UNALIGNED_LOAD return vld1q_s32(from); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f ploaddup<Packet4f>(const float* from)\n{\n  float32x2_t lo, hi;\n  lo = vld1_dup_f32(from);\n  hi = vld1_dup_f32(from+1);\n  return vcombine_f32(lo, hi);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i ploaddup<Packet4i>(const int32_t* from)\n{\n  int32x2_t lo, hi;\n  lo = vld1_dup_s32(from);\n  hi = vld1_dup_s32(from+1);\n  return vcombine_s32(lo, hi);\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<float>  (float*    to, const Packet4f& from) { EIGEN_DEBUG_ALIGNED_STORE vst1q_f32(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstore<int32_t>(int32_t*  to, const Packet4i& from) { EIGEN_DEBUG_ALIGNED_STORE vst1q_s32(to, from); }\n\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<float>  (float*   to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_f32(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<int32_t>(int32_t* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_s32(to, from); }\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, Index stride)\n{\n  Packet4f res = pset1<Packet4f>(0.f);\n  res = vsetq_lane_f32(from[0*stride], res, 0);\n  res = vsetq_lane_f32(from[1*stride], res, 1);\n  res = vsetq_lane_f32(from[2*stride], res, 2);\n  res = vsetq_lane_f32(from[3*stride], res, 3);\n  return res;\n}\ntemplate<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int32_t, Packet4i>(const int32_t* from, Index stride)\n{\n  Packet4i res = pset1<Packet4i>(0);\n  res = vsetq_lane_s32(from[0*stride], res, 0);\n  res = vsetq_lane_s32(from[1*stride], res, 1);\n  res = vsetq_lane_s32(from[2*stride], res, 2);\n  res = vsetq_lane_s32(from[3*stride], res, 3);\n  return res;\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, Index stride)\n{\n  to[stride*0] = vgetq_lane_f32(from, 0);\n  to[stride*1] = vgetq_lane_f32(from, 1);\n  to[stride*2] = vgetq_lane_f32(from, 2);\n  to[stride*3] = vgetq_lane_f32(from, 3);\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<int32_t, Packet4i>(int32_t* to, const Packet4i& from, Index stride)\n{\n  to[stride*0] = vgetq_lane_s32(from, 0);\n  to[stride*1] = vgetq_lane_s32(from, 1);\n  to[stride*2] = vgetq_lane_s32(from, 2);\n  to[stride*3] = vgetq_lane_s32(from, 3);\n}\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<float>  (const float*    addr) { EIGEN_ARM_PREFETCH(addr); }\ntemplate<> EIGEN_STRONG_INLINE void prefetch<int32_t>(const int32_t*  addr) { EIGEN_ARM_PREFETCH(addr); }\n\n// FIXME only store the 2 first elements ?\ntemplate<> EIGEN_STRONG_INLINE float   pfirst<Packet4f>(const Packet4f& a) { float   EIGEN_ALIGN16 x[4]; vst1q_f32(x, a); return x[0]; }\ntemplate<> EIGEN_STRONG_INLINE int32_t pfirst<Packet4i>(const Packet4i& a) { int32_t EIGEN_ALIGN16 x[4]; vst1q_s32(x, a); return x[0]; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f preverse(const Packet4f& a) {\n  float32x2_t a_lo, a_hi;\n  Packet4f a_r64;\n\n  a_r64 = vrev64q_f32(a);\n  a_lo = vget_low_f32(a_r64);\n  a_hi = vget_high_f32(a_r64);\n  return vcombine_f32(a_hi, a_lo);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i preverse(const Packet4i& a) {\n  int32x2_t a_lo, a_hi;\n  Packet4i a_r64;\n\n  a_r64 = vrev64q_s32(a);\n  a_lo = vget_low_s32(a_r64);\n  a_hi = vget_high_s32(a_r64);\n  return vcombine_s32(a_hi, a_lo);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pabs(const Packet4f& a) { return vabsq_f32(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pabs(const Packet4i& a) { return vabsq_s32(a); }\n\ntemplate<> EIGEN_STRONG_INLINE float predux<Packet4f>(const Packet4f& a)\n{\n  float32x2_t a_lo, a_hi, sum;\n\n  a_lo = vget_low_f32(a);\n  a_hi = vget_high_f32(a);\n  sum = vpadd_f32(a_lo, a_hi);\n  sum = vpadd_f32(sum, sum);\n  return vget_lane_f32(sum, 0);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f preduxp<Packet4f>(const Packet4f* vecs)\n{\n  float32x4x2_t vtrn1, vtrn2, res1, res2;\n  Packet4f sum1, sum2, sum;\n\n  // NEON zip performs interleaving of the supplied vectors.\n  // We perform two interleaves in a row to acquire the transposed vector\n  vtrn1 = vzipq_f32(vecs[0], vecs[2]);\n  vtrn2 = vzipq_f32(vecs[1], vecs[3]);\n  res1 = vzipq_f32(vtrn1.val[0], vtrn2.val[0]);\n  res2 = vzipq_f32(vtrn1.val[1], vtrn2.val[1]);\n\n  // Do the addition of the resulting vectors\n  sum1 = vaddq_f32(res1.val[0], res1.val[1]);\n  sum2 = vaddq_f32(res2.val[0], res2.val[1]);\n  sum = vaddq_f32(sum1, sum2);\n\n  return sum;\n}\n\ntemplate<> EIGEN_STRONG_INLINE int32_t predux<Packet4i>(const Packet4i& a)\n{\n  int32x2_t a_lo, a_hi, sum;\n\n  a_lo = vget_low_s32(a);\n  a_hi = vget_high_s32(a);\n  sum = vpadd_s32(a_lo, a_hi);\n  sum = vpadd_s32(sum, sum);\n  return vget_lane_s32(sum, 0);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i preduxp<Packet4i>(const Packet4i* vecs)\n{\n  int32x4x2_t vtrn1, vtrn2, res1, res2;\n  Packet4i sum1, sum2, sum;\n\n  // NEON zip performs interleaving of the supplied vectors.\n  // We perform two interleaves in a row to acquire the transposed vector\n  vtrn1 = vzipq_s32(vecs[0], vecs[2]);\n  vtrn2 = vzipq_s32(vecs[1], vecs[3]);\n  res1 = vzipq_s32(vtrn1.val[0], vtrn2.val[0]);\n  res2 = vzipq_s32(vtrn1.val[1], vtrn2.val[1]);\n\n  // Do the addition of the resulting vectors\n  sum1 = vaddq_s32(res1.val[0], res1.val[1]);\n  sum2 = vaddq_s32(res2.val[0], res2.val[1]);\n  sum = vaddq_s32(sum1, sum2);\n\n  return sum;\n}\n\n// Other reduction functions:\n// mul\ntemplate<> EIGEN_STRONG_INLINE float predux_mul<Packet4f>(const Packet4f& a)\n{\n  float32x2_t a_lo, a_hi, prod;\n\n  // Get a_lo = |a1|a2| and a_hi = |a3|a4|\n  a_lo = vget_low_f32(a);\n  a_hi = vget_high_f32(a);\n  // Get the product of a_lo * a_hi -> |a1*a3|a2*a4|\n  prod = vmul_f32(a_lo, a_hi);\n  // Multiply prod with its swapped value |a2*a4|a1*a3|\n  prod = vmul_f32(prod, vrev64_f32(prod));\n\n  return vget_lane_f32(prod, 0);\n}\ntemplate<> EIGEN_STRONG_INLINE int32_t predux_mul<Packet4i>(const Packet4i& a)\n{\n  int32x2_t a_lo, a_hi, prod;\n\n  // Get a_lo = |a1|a2| and a_hi = |a3|a4|\n  a_lo = vget_low_s32(a);\n  a_hi = vget_high_s32(a);\n  // Get the product of a_lo * a_hi -> |a1*a3|a2*a4|\n  prod = vmul_s32(a_lo, a_hi);\n  // Multiply prod with its swapped value |a2*a4|a1*a3|\n  prod = vmul_s32(prod, vrev64_s32(prod));\n\n  return vget_lane_s32(prod, 0);\n}\n\n// min\ntemplate<> EIGEN_STRONG_INLINE float predux_min<Packet4f>(const Packet4f& a)\n{\n  float32x2_t a_lo, a_hi, min;\n\n  a_lo = vget_low_f32(a);\n  a_hi = vget_high_f32(a);\n  min = vpmin_f32(a_lo, a_hi);\n  min = vpmin_f32(min, min);\n\n  return vget_lane_f32(min, 0);\n}\n\ntemplate<> EIGEN_STRONG_INLINE int32_t predux_min<Packet4i>(const Packet4i& a)\n{\n  int32x2_t a_lo, a_hi, min;\n\n  a_lo = vget_low_s32(a);\n  a_hi = vget_high_s32(a);\n  min = vpmin_s32(a_lo, a_hi);\n  min = vpmin_s32(min, min);\n  \n  return vget_lane_s32(min, 0);\n}\n\n// max\ntemplate<> EIGEN_STRONG_INLINE float predux_max<Packet4f>(const Packet4f& a)\n{\n  float32x2_t a_lo, a_hi, max;\n\n  a_lo = vget_low_f32(a);\n  a_hi = vget_high_f32(a);\n  max = vpmax_f32(a_lo, a_hi);\n  max = vpmax_f32(max, max);\n\n  return vget_lane_f32(max, 0);\n}\n\ntemplate<> EIGEN_STRONG_INLINE int32_t predux_max<Packet4i>(const Packet4i& a)\n{\n  int32x2_t a_lo, a_hi, max;\n\n  a_lo = vget_low_s32(a);\n  a_hi = vget_high_s32(a);\n  max = vpmax_s32(a_lo, a_hi);\n  max = vpmax_s32(max, max);\n\n  return vget_lane_s32(max, 0);\n}\n\n// this PALIGN_NEON business is to work around a bug in LLVM Clang 3.0 causing incorrect compilation errors,\n// see bug 347 and this LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=11074\n#define PALIGN_NEON(Offset,Type,Command) \\\ntemplate<>\\\nstruct palign_impl<Offset,Type>\\\n{\\\n    EIGEN_STRONG_INLINE static void run(Type& first, const Type& second)\\\n    {\\\n        if (Offset!=0)\\\n            first = Command(first, second, Offset);\\\n    }\\\n};\\\n\nPALIGN_NEON(0,Packet4f,vextq_f32)\nPALIGN_NEON(1,Packet4f,vextq_f32)\nPALIGN_NEON(2,Packet4f,vextq_f32)\nPALIGN_NEON(3,Packet4f,vextq_f32)\nPALIGN_NEON(0,Packet4i,vextq_s32)\nPALIGN_NEON(1,Packet4i,vextq_s32)\nPALIGN_NEON(2,Packet4i,vextq_s32)\nPALIGN_NEON(3,Packet4i,vextq_s32)\n\n#undef PALIGN_NEON\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet4f,4>& kernel) {\n  float32x4x2_t tmp1 = vzipq_f32(kernel.packet[0], kernel.packet[1]);\n  float32x4x2_t tmp2 = vzipq_f32(kernel.packet[2], kernel.packet[3]);\n\n  kernel.packet[0] = vcombine_f32(vget_low_f32(tmp1.val[0]), vget_low_f32(tmp2.val[0]));\n  kernel.packet[1] = vcombine_f32(vget_high_f32(tmp1.val[0]), vget_high_f32(tmp2.val[0]));\n  kernel.packet[2] = vcombine_f32(vget_low_f32(tmp1.val[1]), vget_low_f32(tmp2.val[1]));\n  kernel.packet[3] = vcombine_f32(vget_high_f32(tmp1.val[1]), vget_high_f32(tmp2.val[1]));\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet4i,4>& kernel) {\n  int32x4x2_t tmp1 = vzipq_s32(kernel.packet[0], kernel.packet[1]);\n  int32x4x2_t tmp2 = vzipq_s32(kernel.packet[2], kernel.packet[3]);\n  kernel.packet[0] = vcombine_s32(vget_low_s32(tmp1.val[0]), vget_low_s32(tmp2.val[0]));\n  kernel.packet[1] = vcombine_s32(vget_high_s32(tmp1.val[0]), vget_high_s32(tmp2.val[0]));\n  kernel.packet[2] = vcombine_s32(vget_low_s32(tmp1.val[1]), vget_low_s32(tmp2.val[1]));\n  kernel.packet[3] = vcombine_s32(vget_high_s32(tmp1.val[1]), vget_high_s32(tmp2.val[1]));\n}\n\n//---------- double ----------\n\n// Clang 3.5 in the iOS toolchain has an ICE triggered by NEON intrisics for double.\n// Confirmed at least with __apple_build_version__ = 6000054.\n#ifdef __apple_build_version__\n// Let's hope that by the time __apple_build_version__ hits the 601* range, the bug will be fixed.\n// https://gist.github.com/yamaya/2924292 suggests that the 3 first digits are only updated with\n// major toolchain updates.\n#define EIGEN_APPLE_DOUBLE_NEON_BUG (__apple_build_version__ < 6010000)\n#else\n#define EIGEN_APPLE_DOUBLE_NEON_BUG 0\n#endif\n\n#if EIGEN_ARCH_ARM64 && !EIGEN_APPLE_DOUBLE_NEON_BUG\n\n// Bug 907: workaround missing declarations of the following two functions in the ADK\n// Defining these functions as templates ensures that if these intrinsics are\n// already defined in arm_neon.h, then our workaround doesn't cause a conflict\n// and has lower priority in overload resolution.\ntemplate <typename T>\nuint64x2_t vreinterpretq_u64_f64(T a)\n{\n  return (uint64x2_t) a;\n}\n\ntemplate <typename T>\nfloat64x2_t vreinterpretq_f64_u64(T a)\n{\n  return (float64x2_t) a;\n}\n\ntypedef float64x2_t Packet2d;\ntypedef float64x1_t Packet1d;\n\ntemplate<> struct packet_traits<double>  : default_packet_traits\n{\n  typedef Packet2d type;\n  typedef Packet2d half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 2,\n    HasHalfPacket=0,\n   \n    HasDiv  = 1,\n    // FIXME check the Has*\n    HasSin  = 0,\n    HasCos  = 0,\n    HasLog  = 0,\n    HasExp  = 0,\n    HasSqrt = 0\n  };\n};\n\ntemplate<> struct unpacket_traits<Packet2d> { typedef double  type; enum {size=2, alignment=Aligned16}; typedef Packet2d half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pset1<Packet2d>(const double&  from) { return vdupq_n_f64(from); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d plset<Packet2d>(const double& a)\n{\n  const double countdown_raw[] = {0.0,1.0};\n  const Packet2d countdown = vld1q_f64(countdown_raw);\n  return vaddq_f64(pset1<Packet2d>(a), countdown);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d padd<Packet2d>(const Packet2d& a, const Packet2d& b) { return vaddq_f64(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d psub<Packet2d>(const Packet2d& a, const Packet2d& b) { return vsubq_f64(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pnegate(const Packet2d& a) { return vnegq_f64(a); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pconj(const Packet2d& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmul<Packet2d>(const Packet2d& a, const Packet2d& b) { return vmulq_f64(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pdiv<Packet2d>(const Packet2d& a, const Packet2d& b) { return vdivq_f64(a,b); }\n\n#ifdef __ARM_FEATURE_FMA\n// See bug 936. See above comment about FMA for float.\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmadd(const Packet2d& a, const Packet2d& b, const Packet2d& c) { return vfmaq_f64(c,a,b); }\n#else\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmadd(const Packet2d& a, const Packet2d& b, const Packet2d& c) { return vmlaq_f64(c,a,b); }\n#endif\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmin<Packet2d>(const Packet2d& a, const Packet2d& b) { return vminq_f64(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmax<Packet2d>(const Packet2d& a, const Packet2d& b) { return vmaxq_f64(a,b); }\n\n// Logical Operations are not supported for float, so we have to reinterpret casts using NEON intrinsics\ntemplate<> EIGEN_STRONG_INLINE Packet2d pand<Packet2d>(const Packet2d& a, const Packet2d& b)\n{\n  return vreinterpretq_f64_u64(vandq_u64(vreinterpretq_u64_f64(a),vreinterpretq_u64_f64(b)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d por<Packet2d>(const Packet2d& a, const Packet2d& b)\n{\n  return vreinterpretq_f64_u64(vorrq_u64(vreinterpretq_u64_f64(a),vreinterpretq_u64_f64(b)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pxor<Packet2d>(const Packet2d& a, const Packet2d& b)\n{\n  return vreinterpretq_f64_u64(veorq_u64(vreinterpretq_u64_f64(a),vreinterpretq_u64_f64(b)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pandnot<Packet2d>(const Packet2d& a, const Packet2d& b)\n{\n  return vreinterpretq_f64_u64(vbicq_u64(vreinterpretq_u64_f64(a),vreinterpretq_u64_f64(b)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pload<Packet2d>(const double* from) { EIGEN_DEBUG_ALIGNED_LOAD return vld1q_f64(from); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d ploadu<Packet2d>(const double* from) { EIGEN_DEBUG_UNALIGNED_LOAD return vld1q_f64(from); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d ploaddup<Packet2d>(const double*   from)\n{\n  return vld1q_dup_f64(from);\n}\ntemplate<> EIGEN_STRONG_INLINE void pstore<double>(double*   to, const Packet2d& from) { EIGEN_DEBUG_ALIGNED_STORE vst1q_f64(to, from); }\n\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<double>(double*  to, const Packet2d& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_f64(to, from); }\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, Index stride)\n{\n  Packet2d res = pset1<Packet2d>(0.0);\n  res = vsetq_lane_f64(from[0*stride], res, 0);\n  res = vsetq_lane_f64(from[1*stride], res, 1);\n  return res;\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, Index stride)\n{\n  to[stride*0] = vgetq_lane_f64(from, 0);\n  to[stride*1] = vgetq_lane_f64(from, 1);\n}\ntemplate<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { EIGEN_ARM_PREFETCH(addr); }\n\n// FIXME only store the 2 first elements ?\ntemplate<> EIGEN_STRONG_INLINE double pfirst<Packet2d>(const Packet2d& a) { return vgetq_lane_f64(a, 0); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d preverse(const Packet2d& a) { return vcombine_f64(vget_high_f64(a), vget_low_f64(a)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pabs(const Packet2d& a) { return vabsq_f64(a); }\n\n#if EIGEN_COMP_CLANG && defined(__apple_build_version__)\n// workaround ICE, see bug 907\ntemplate<> EIGEN_STRONG_INLINE double predux<Packet2d>(const Packet2d& a) { return (vget_low_f64(a) + vget_high_f64(a))[0]; }\n#else\ntemplate<> EIGEN_STRONG_INLINE double predux<Packet2d>(const Packet2d& a) { return vget_lane_f64(vget_low_f64(a) + vget_high_f64(a), 0); }\n#endif\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d preduxp<Packet2d>(const Packet2d* vecs)\n{\n  float64x2_t trn1, trn2;\n\n  // NEON zip performs interleaving of the supplied vectors.\n  // We perform two interleaves in a row to acquire the transposed vector\n  trn1 = vzip1q_f64(vecs[0], vecs[1]);\n  trn2 = vzip2q_f64(vecs[0], vecs[1]);\n\n  // Do the addition of the resulting vectors\n  return vaddq_f64(trn1, trn2);\n}\n// Other reduction functions:\n// mul\n#if EIGEN_COMP_CLANG && defined(__apple_build_version__)\ntemplate<> EIGEN_STRONG_INLINE double predux_mul<Packet2d>(const Packet2d& a) { return (vget_low_f64(a) * vget_high_f64(a))[0]; }\n#else\ntemplate<> EIGEN_STRONG_INLINE double predux_mul<Packet2d>(const Packet2d& a) { return vget_lane_f64(vget_low_f64(a) * vget_high_f64(a), 0); }\n#endif\n\n// min\ntemplate<> EIGEN_STRONG_INLINE double predux_min<Packet2d>(const Packet2d& a) { return vgetq_lane_f64(vpminq_f64(a, a), 0); }\n\n// max\ntemplate<> EIGEN_STRONG_INLINE double predux_max<Packet2d>(const Packet2d& a) { return vgetq_lane_f64(vpmaxq_f64(a, a), 0); }\n\n// this PALIGN_NEON business is to work around a bug in LLVM Clang 3.0 causing incorrect compilation errors,\n// see bug 347 and this LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=11074\n#define PALIGN_NEON(Offset,Type,Command) \\\ntemplate<>\\\nstruct palign_impl<Offset,Type>\\\n{\\\n    EIGEN_STRONG_INLINE static void run(Type& first, const Type& second)\\\n    {\\\n        if (Offset!=0)\\\n            first = Command(first, second, Offset);\\\n    }\\\n};\\\n\nPALIGN_NEON(0,Packet2d,vextq_f64)\nPALIGN_NEON(1,Packet2d,vextq_f64)\n#undef PALIGN_NEON\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet2d,2>& kernel) {\n  float64x2_t trn1 = vzip1q_f64(kernel.packet[0], kernel.packet[1]);\n  float64x2_t trn2 = vzip2q_f64(kernel.packet[0], kernel.packet[1]);\n\n  kernel.packet[0] = trn1;\n  kernel.packet[1] = trn2;\n}\n#endif // EIGEN_ARCH_ARM64 \n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_PACKET_MATH_NEON_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/SSE/Complex.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COMPLEX_SSE_H\n#define EIGEN_COMPLEX_SSE_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n//---------- float ----------\nstruct Packet2cf\n{\n  EIGEN_STRONG_INLINE Packet2cf() {}\n  EIGEN_STRONG_INLINE explicit Packet2cf(const __m128& a) : v(a) {}\n  __m128  v;\n};\n\n// Use the packet_traits defined in AVX/PacketMath.h instead if we're going\n// to leverage AVX instructions.\n#ifndef EIGEN_VECTORIZE_AVX\ntemplate<> struct packet_traits<std::complex<float> >  : default_packet_traits\n{\n  typedef Packet2cf type;\n  typedef Packet2cf half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 2,\n    HasHalfPacket = 0,\n\n    HasAdd    = 1,\n    HasSub    = 1,\n    HasMul    = 1,\n    HasDiv    = 1,\n    HasNegate = 1,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasSetLinear = 0,\n    HasBlend = 1\n  };\n};\n#endif\n\ntemplate<> struct unpacket_traits<Packet2cf> { typedef std::complex<float> type; enum {size=2, alignment=Aligned16}; typedef Packet2cf half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_add_ps(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_sub_ps(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf& a)\n{\n  const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x80000000,0x80000000,0x80000000));\n  return Packet2cf(_mm_xor_ps(a.v,mask));\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf& a)\n{\n  const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));\n  return Packet2cf(_mm_xor_ps(a.v,mask));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  #ifdef EIGEN_VECTORIZE_SSE3\n  return Packet2cf(_mm_addsub_ps(_mm_mul_ps(_mm_moveldup_ps(a.v), b.v),\n                                 _mm_mul_ps(_mm_movehdup_ps(a.v),\n                                            vec4f_swizzle1(b.v, 1, 0, 3, 2))));\n//   return Packet2cf(_mm_addsub_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v),\n//                                  _mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),\n//                                             vec4f_swizzle1(b.v, 1, 0, 3, 2))));\n  #else\n  const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x00000000,0x80000000,0x00000000));\n  return Packet2cf(_mm_add_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v),\n                              _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),\n                                                    vec4f_swizzle1(b.v, 1, 0, 3, 2)), mask)));\n  #endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pand   <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_and_ps(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf por    <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_or_ps(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pxor   <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_xor_ps(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_andnot_ps(a.v,b.v)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pload <Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(pload<Packet4f>(&numext::real_ref(*from))); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ploadu<Packet4f>(&numext::real_ref(*from))); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>&  from)\n{\n  Packet2cf res;\n#if EIGEN_GNUC_AT_MOST(4,2)\n  // Workaround annoying \"may be used uninitialized in this function\" warning with gcc 4.2\n  res.v = _mm_loadl_pi(_mm_set1_ps(0.0f), reinterpret_cast<const __m64*>(&from));\n#elif EIGEN_GNUC_AT_LEAST(4,6)\n  // Suppress annoying \"may be used uninitialized in this function\" warning with gcc >= 4.6\n  #pragma GCC diagnostic push\n  #pragma GCC diagnostic ignored \"-Wuninitialized\"\n  res.v = _mm_loadl_pi(res.v, (const __m64*)&from);\n  #pragma GCC diagnostic pop\n#else\n  res.v = _mm_loadl_pi(res.v, (const __m64*)&from);\n#endif\n  return Packet2cf(_mm_movelh_ps(res.v,res.v));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(const std::complex<float>* from) { return pset1<Packet2cf>(*from); }\n\ntemplate<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> *   to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore(&numext::real_ref(*to), Packet4f(from.v)); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> *   to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&numext::real_ref(*to), Packet4f(from.v)); }\n\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, Index stride)\n{\n  return Packet2cf(_mm_set_ps(std::imag(from[1*stride]), std::real(from[1*stride]),\n                              std::imag(from[0*stride]), std::real(from[0*stride])));\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, Index stride)\n{\n  to[stride*0] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 0)),\n                                     _mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 1)));\n  to[stride*1] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 2)),\n                                     _mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 3)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> *   addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float>  pfirst<Packet2cf>(const Packet2cf& a)\n{\n  #if EIGEN_GNUC_AT_MOST(4,3)\n  // Workaround gcc 4.2 ICE - this is not performance wise ideal, but who cares...\n  // This workaround also fix invalid code generation with gcc 4.3\n  EIGEN_ALIGN16 std::complex<float> res[2];\n  _mm_store_ps((float*)res, a.v);\n  return res[0];\n  #else\n  std::complex<float> res;\n  _mm_storel_pi((__m64*)&res, a.v);\n  return res;\n  #endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf& a) { return Packet2cf(_mm_castpd_ps(preverse(Packet2d(_mm_castps_pd(a.v))))); }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(const Packet2cf& a)\n{\n  return pfirst(Packet2cf(_mm_add_ps(a.v, _mm_movehl_ps(a.v,a.v))));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(const Packet2cf* vecs)\n{\n  return Packet2cf(_mm_add_ps(_mm_movelh_ps(vecs[0].v,vecs[1].v), _mm_movehl_ps(vecs[1].v,vecs[0].v)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(const Packet2cf& a)\n{\n  return pfirst(pmul(a, Packet2cf(_mm_movehl_ps(a.v,a.v))));\n}\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet2cf>\n{\n  static EIGEN_STRONG_INLINE void run(Packet2cf& first, const Packet2cf& second)\n  {\n    if (Offset==1)\n    {\n      first.v = _mm_movehl_ps(first.v, first.v);\n      first.v = _mm_movelh_ps(first.v, second.v);\n    }\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, false,true>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    #ifdef EIGEN_VECTORIZE_SSE3\n    return internal::pmul(a, pconj(b));\n    #else\n    const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));\n    return Packet2cf(_mm_add_ps(_mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), mask),\n                                _mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),\n                                           vec4f_swizzle1(b.v, 1, 0, 3, 2))));\n    #endif\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, true,false>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    #ifdef EIGEN_VECTORIZE_SSE3\n    return internal::pmul(pconj(a), b);\n    #else\n    const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));\n    return Packet2cf(_mm_add_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v),\n                                _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),\n                                                      vec4f_swizzle1(b.v, 1, 0, 3, 2)), mask)));\n    #endif\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, true,true>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    #ifdef EIGEN_VECTORIZE_SSE3\n    return pconj(internal::pmul(a, b));\n    #else\n    const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));\n    return Packet2cf(_mm_sub_ps(_mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), mask),\n                                _mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),\n                                           vec4f_swizzle1(b.v, 1, 0, 3, 2))));\n    #endif\n  }\n};\n\ntemplate<> struct conj_helper<Packet4f, Packet2cf, false,false>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet4f& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet4f& x, const Packet2cf& y) const\n  { return Packet2cf(Eigen::internal::pmul<Packet4f>(x, y.v)); }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet4f, false,false>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet4f& y, const Packet2cf& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& x, const Packet4f& y) const\n  { return Packet2cf(Eigen::internal::pmul<Packet4f>(x.v, y)); }\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  // TODO optimize it for SSE3 and 4\n  Packet2cf res = conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a,b);\n  __m128 s = _mm_mul_ps(b.v,b.v);\n  return Packet2cf(_mm_div_ps(res.v,_mm_add_ps(s,_mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(s), 0xb1)))));\n}\n\nEIGEN_STRONG_INLINE Packet2cf pcplxflip/* <Packet2cf> */(const Packet2cf& x)\n{\n  return Packet2cf(vec4f_swizzle1(x.v, 1, 0, 3, 2));\n}\n\n\n//---------- double ----------\nstruct Packet1cd\n{\n  EIGEN_STRONG_INLINE Packet1cd() {}\n  EIGEN_STRONG_INLINE explicit Packet1cd(const __m128d& a) : v(a) {}\n  __m128d  v;\n};\n\n// Use the packet_traits defined in AVX/PacketMath.h instead if we're going\n// to leverage AVX instructions.\n#ifndef EIGEN_VECTORIZE_AVX\ntemplate<> struct packet_traits<std::complex<double> >  : default_packet_traits\n{\n  typedef Packet1cd type;\n  typedef Packet1cd half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 0,\n    size = 1,\n    HasHalfPacket = 0,\n\n    HasAdd    = 1,\n    HasSub    = 1,\n    HasMul    = 1,\n    HasDiv    = 1,\n    HasNegate = 1,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasSetLinear = 0\n  };\n};\n#endif\n\ntemplate<> struct unpacket_traits<Packet1cd> { typedef std::complex<double> type; enum {size=1, alignment=Aligned16}; typedef Packet1cd half; };\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_add_pd(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_sub_pd(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pnegate(const Packet1cd& a) { return Packet1cd(pnegate(Packet2d(a.v))); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pconj(const Packet1cd& a)\n{\n  const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));\n  return Packet1cd(_mm_xor_pd(a.v,mask));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pmul<Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  #ifdef EIGEN_VECTORIZE_SSE3\n  return Packet1cd(_mm_addsub_pd(_mm_mul_pd(_mm_movedup_pd(a.v), b.v),\n                                 _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),\n                                            vec2d_swizzle1(b.v, 1, 0))));\n  #else\n  const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x0,0x0,0x80000000,0x0));\n  return Packet1cd(_mm_add_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v),\n                              _mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),\n                                                    vec2d_swizzle1(b.v, 1, 0)), mask)));\n  #endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pand   <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_and_pd(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd por    <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_or_pd(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pxor   <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_xor_pd(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_andnot_pd(a.v,b.v)); }\n\n// FIXME force unaligned load, this is a temporary fix\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pload <Packet1cd>(const std::complex<double>* from)\n{ EIGEN_DEBUG_ALIGNED_LOAD return Packet1cd(pload<Packet2d>((const double*)from)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(const std::complex<double>* from)\n{ EIGEN_DEBUG_UNALIGNED_LOAD return Packet1cd(ploadu<Packet2d>((const double*)from)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(const std::complex<double>&  from)\n{ /* here we really have to use unaligned loads :( */ return ploadu<Packet1cd>(&from); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(const std::complex<double>* from) { return pset1<Packet1cd>(*from); }\n\n// FIXME force unaligned store, this is a temporary fix\ntemplate<> EIGEN_STRONG_INLINE void pstore <std::complex<double> >(std::complex<double> *   to, const Packet1cd& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((double*)to, Packet2d(from.v)); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex<double> *   to, const Packet1cd& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, Packet2d(from.v)); }\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<std::complex<double> >(const std::complex<double> *   addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double>  pfirst<Packet1cd>(const Packet1cd& a)\n{\n  EIGEN_ALIGN16 double res[2];\n  _mm_store_pd(res, a.v);\n  return std::complex<double>(res[0],res[1]);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd preverse(const Packet1cd& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(const Packet1cd& a)\n{\n  return pfirst(a);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd preduxp<Packet1cd>(const Packet1cd* vecs)\n{\n  return vecs[0];\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(const Packet1cd& a)\n{\n  return pfirst(a);\n}\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet1cd>\n{\n  static EIGEN_STRONG_INLINE void run(Packet1cd& /*first*/, const Packet1cd& /*second*/)\n  {\n    // FIXME is it sure we never have to align a Packet1cd?\n    // Even though a std::complex<double> has 16 bytes, it is not necessarily aligned on a 16 bytes boundary...\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, false,true>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    #ifdef EIGEN_VECTORIZE_SSE3\n    return internal::pmul(a, pconj(b));\n    #else\n    const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));\n    return Packet1cd(_mm_add_pd(_mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v), mask),\n                                _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),\n                                           vec2d_swizzle1(b.v, 1, 0))));\n    #endif\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, true,false>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    #ifdef EIGEN_VECTORIZE_SSE3\n    return internal::pmul(pconj(a), b);\n    #else\n    const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));\n    return Packet1cd(_mm_add_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v),\n                                _mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),\n                                                      vec2d_swizzle1(b.v, 1, 0)), mask)));\n    #endif\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, true,true>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    #ifdef EIGEN_VECTORIZE_SSE3\n    return pconj(internal::pmul(a, b));\n    #else\n    const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));\n    return Packet1cd(_mm_sub_pd(_mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v), mask),\n                                _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),\n                                           vec2d_swizzle1(b.v, 1, 0))));\n    #endif\n  }\n};\n\ntemplate<> struct conj_helper<Packet2d, Packet1cd, false,false>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet2d& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet2d& x, const Packet1cd& y) const\n  { return Packet1cd(Eigen::internal::pmul<Packet2d>(x, y.v)); }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet2d, false,false>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet2d& y, const Packet1cd& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& x, const Packet2d& y) const\n  { return Packet1cd(Eigen::internal::pmul<Packet2d>(x.v, y)); }\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  // TODO optimize it for SSE3 and 4\n  Packet1cd res = conj_helper<Packet1cd,Packet1cd,false,true>().pmul(a,b);\n  __m128d s = _mm_mul_pd(b.v,b.v);\n  return Packet1cd(_mm_div_pd(res.v, _mm_add_pd(s,_mm_shuffle_pd(s, s, 0x1))));\n}\n\nEIGEN_STRONG_INLINE Packet1cd pcplxflip/* <Packet1cd> */(const Packet1cd& x)\n{\n  return Packet1cd(preverse(Packet2d(x.v)));\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet2cf,2>& kernel) {\n  __m128d w1 = _mm_castps_pd(kernel.packet[0].v);\n  __m128d w2 = _mm_castps_pd(kernel.packet[1].v);\n\n  __m128 tmp = _mm_castpd_ps(_mm_unpackhi_pd(w1, w2));\n  kernel.packet[0].v = _mm_castpd_ps(_mm_unpacklo_pd(w1, w2));\n  kernel.packet[1].v = tmp;\n}\n\ntemplate<>  EIGEN_STRONG_INLINE Packet2cf pblend(const Selector<2>& ifPacket, const Packet2cf& thenPacket, const Packet2cf& elsePacket) {\n  __m128d result = pblend<Packet2d>(ifPacket, _mm_castps_pd(thenPacket.v), _mm_castps_pd(elsePacket.v));\n  return Packet2cf(_mm_castpd_ps(result));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pinsertfirst(const Packet2cf& a, std::complex<float> b)\n{\n  return Packet2cf(_mm_loadl_pi(a.v, reinterpret_cast<const __m64*>(&b)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pinsertfirst(const Packet1cd&, std::complex<double> b)\n{\n  return pset1<Packet1cd>(b);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pinsertlast(const Packet2cf& a, std::complex<float> b)\n{\n  return Packet2cf(_mm_loadh_pi(a.v, reinterpret_cast<const __m64*>(&b)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pinsertlast(const Packet1cd&, std::complex<double> b)\n{\n  return pset1<Packet1cd>(b);\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_COMPLEX_SSE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/SSE/MathFunctions.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2007 Julien Pommier\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* The sin, cos, exp, and log functions of this file come from\n * Julien Pommier's sse math library: http://gruntthepeon.free.fr/ssemath/\n */\n\n#ifndef EIGEN_MATH_FUNCTIONS_SSE_H\n#define EIGEN_MATH_FUNCTIONS_SSE_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f plog<Packet4f>(const Packet4f& _x)\n{\n  Packet4f x = _x;\n  _EIGEN_DECLARE_CONST_Packet4f(1 , 1.0f);\n  _EIGEN_DECLARE_CONST_Packet4f(half, 0.5f);\n  _EIGEN_DECLARE_CONST_Packet4i(0x7f, 0x7f);\n\n  _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(inv_mant_mask, ~0x7f800000);\n\n  /* the smallest non denormalized float number */\n  _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(min_norm_pos,  0x00800000);\n  _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(minus_inf,     0xff800000);//-1.f/0.f);\n\n  /* natural logarithm computed for 4 simultaneous float\n    return NaN for x <= 0\n  */\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_SQRTHF, 0.707106781186547524f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p0, 7.0376836292E-2f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p1, - 1.1514610310E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p2, 1.1676998740E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p3, - 1.2420140846E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p4, + 1.4249322787E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p5, - 1.6668057665E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p6, + 2.0000714765E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p7, - 2.4999993993E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_log_p8, + 3.3333331174E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_log_q1, -2.12194440e-4f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_log_q2, 0.693359375f);\n\n\n  Packet4i emm0;\n\n  Packet4f invalid_mask = _mm_cmpnge_ps(x, _mm_setzero_ps()); // not greater equal is true if x is NaN\n  Packet4f iszero_mask = _mm_cmpeq_ps(x, _mm_setzero_ps());\n\n  x = pmax(x, p4f_min_norm_pos);  /* cut off denormalized stuff */\n  emm0 = _mm_srli_epi32(_mm_castps_si128(x), 23);\n\n  /* keep only the fractional part */\n  x = _mm_and_ps(x, p4f_inv_mant_mask);\n  x = _mm_or_ps(x, p4f_half);\n\n  emm0 = _mm_sub_epi32(emm0, p4i_0x7f);\n  Packet4f e = padd(Packet4f(_mm_cvtepi32_ps(emm0)), p4f_1);\n\n  /* part2:\n     if( x < SQRTHF ) {\n       e -= 1;\n       x = x + x - 1.0;\n     } else { x = x - 1.0; }\n  */\n  Packet4f mask = _mm_cmplt_ps(x, p4f_cephes_SQRTHF);\n  Packet4f tmp = pand(x, mask);\n  x = psub(x, p4f_1);\n  e = psub(e, pand(p4f_1, mask));\n  x = padd(x, tmp);\n\n  Packet4f x2 = pmul(x,x);\n  Packet4f x3 = pmul(x2,x);\n\n  Packet4f y, y1, y2;\n  y  = pmadd(p4f_cephes_log_p0, x, p4f_cephes_log_p1);\n  y1 = pmadd(p4f_cephes_log_p3, x, p4f_cephes_log_p4);\n  y2 = pmadd(p4f_cephes_log_p6, x, p4f_cephes_log_p7);\n  y  = pmadd(y , x, p4f_cephes_log_p2);\n  y1 = pmadd(y1, x, p4f_cephes_log_p5);\n  y2 = pmadd(y2, x, p4f_cephes_log_p8);\n  y = pmadd(y, x3, y1);\n  y = pmadd(y, x3, y2);\n  y = pmul(y, x3);\n\n  y1 = pmul(e, p4f_cephes_log_q1);\n  tmp = pmul(x2, p4f_half);\n  y = padd(y, y1);\n  x = psub(x, tmp);\n  y2 = pmul(e, p4f_cephes_log_q2);\n  x = padd(x, y);\n  x = padd(x, y2);\n  // negative arg will be NAN, 0 will be -INF\n  return _mm_or_ps(_mm_andnot_ps(iszero_mask, _mm_or_ps(x, invalid_mask)),\n                   _mm_and_ps(iszero_mask, p4f_minus_inf));\n}\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f pexp<Packet4f>(const Packet4f& _x)\n{\n  Packet4f x = _x;\n  _EIGEN_DECLARE_CONST_Packet4f(1 , 1.0f);\n  _EIGEN_DECLARE_CONST_Packet4f(half, 0.5f);\n  _EIGEN_DECLARE_CONST_Packet4i(0x7f, 0x7f);\n\n\n  _EIGEN_DECLARE_CONST_Packet4f(exp_hi,  88.3762626647950f);\n  _EIGEN_DECLARE_CONST_Packet4f(exp_lo, -88.3762626647949f);\n\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_LOG2EF, 1.44269504088896341f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_C1, 0.693359375f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_C2, -2.12194440e-4f);\n\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p0, 1.9875691500E-4f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p1, 1.3981999507E-3f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p2, 8.3334519073E-3f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p3, 4.1665795894E-2f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p4, 1.6666665459E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p5, 5.0000001201E-1f);\n\n  Packet4f tmp, fx;\n  Packet4i emm0;\n\n  // clamp x\n  x = pmax(pmin(x, p4f_exp_hi), p4f_exp_lo);\n\n  /* express exp(x) as exp(g + n*log(2)) */\n  fx = pmadd(x, p4f_cephes_LOG2EF, p4f_half);\n\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  fx = _mm_floor_ps(fx);\n#else\n  emm0 = _mm_cvttps_epi32(fx);\n  tmp  = _mm_cvtepi32_ps(emm0);\n  /* if greater, substract 1 */\n  Packet4f mask = _mm_cmpgt_ps(tmp, fx);\n  mask = _mm_and_ps(mask, p4f_1);\n  fx = psub(tmp, mask);\n#endif\n\n  tmp = pmul(fx, p4f_cephes_exp_C1);\n  Packet4f z = pmul(fx, p4f_cephes_exp_C2);\n  x = psub(x, tmp);\n  x = psub(x, z);\n\n  z = pmul(x,x);\n\n  Packet4f y = p4f_cephes_exp_p0;\n  y = pmadd(y, x, p4f_cephes_exp_p1);\n  y = pmadd(y, x, p4f_cephes_exp_p2);\n  y = pmadd(y, x, p4f_cephes_exp_p3);\n  y = pmadd(y, x, p4f_cephes_exp_p4);\n  y = pmadd(y, x, p4f_cephes_exp_p5);\n  y = pmadd(y, z, x);\n  y = padd(y, p4f_1);\n\n  // build 2^n\n  emm0 = _mm_cvttps_epi32(fx);\n  emm0 = _mm_add_epi32(emm0, p4i_0x7f);\n  emm0 = _mm_slli_epi32(emm0, 23);\n  return pmax(pmul(y, Packet4f(_mm_castsi128_ps(emm0))), _x);\n}\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket2d pexp<Packet2d>(const Packet2d& _x)\n{\n  Packet2d x = _x;\n\n  _EIGEN_DECLARE_CONST_Packet2d(1 , 1.0);\n  _EIGEN_DECLARE_CONST_Packet2d(2 , 2.0);\n  _EIGEN_DECLARE_CONST_Packet2d(half, 0.5);\n\n  _EIGEN_DECLARE_CONST_Packet2d(exp_hi,  709.437);\n  _EIGEN_DECLARE_CONST_Packet2d(exp_lo, -709.436139303);\n\n  _EIGEN_DECLARE_CONST_Packet2d(cephes_LOG2EF, 1.4426950408889634073599);\n\n  _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_p0, 1.26177193074810590878e-4);\n  _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_p1, 3.02994407707441961300e-2);\n  _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_p2, 9.99999999999999999910e-1);\n\n  _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q0, 3.00198505138664455042e-6);\n  _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q1, 2.52448340349684104192e-3);\n  _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q2, 2.27265548208155028766e-1);\n  _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q3, 2.00000000000000000009e0);\n\n  _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_C1, 0.693145751953125);\n  _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_C2, 1.42860682030941723212e-6);\n  static const __m128i p4i_1023_0 = _mm_setr_epi32(1023, 1023, 0, 0);\n\n  Packet2d tmp, fx;\n  Packet4i emm0;\n\n  // clamp x\n  x = pmax(pmin(x, p2d_exp_hi), p2d_exp_lo);\n  /* express exp(x) as exp(g + n*log(2)) */\n  fx = pmadd(p2d_cephes_LOG2EF, x, p2d_half);\n\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  fx = _mm_floor_pd(fx);\n#else\n  emm0 = _mm_cvttpd_epi32(fx);\n  tmp  = _mm_cvtepi32_pd(emm0);\n  /* if greater, substract 1 */\n  Packet2d mask = _mm_cmpgt_pd(tmp, fx);\n  mask = _mm_and_pd(mask, p2d_1);\n  fx = psub(tmp, mask);\n#endif\n\n  tmp = pmul(fx, p2d_cephes_exp_C1);\n  Packet2d z = pmul(fx, p2d_cephes_exp_C2);\n  x = psub(x, tmp);\n  x = psub(x, z);\n\n  Packet2d x2 = pmul(x,x);\n\n  Packet2d px = p2d_cephes_exp_p0;\n  px = pmadd(px, x2, p2d_cephes_exp_p1);\n  px = pmadd(px, x2, p2d_cephes_exp_p2);\n  px = pmul (px, x);\n\n  Packet2d qx = p2d_cephes_exp_q0;\n  qx = pmadd(qx, x2, p2d_cephes_exp_q1);\n  qx = pmadd(qx, x2, p2d_cephes_exp_q2);\n  qx = pmadd(qx, x2, p2d_cephes_exp_q3);\n\n  x = pdiv(px,psub(qx,px));\n  x = pmadd(p2d_2,x,p2d_1);\n\n  // build 2^n\n  emm0 = _mm_cvttpd_epi32(fx);\n  emm0 = _mm_add_epi32(emm0, p4i_1023_0);\n  emm0 = _mm_slli_epi32(emm0, 20);\n  emm0 = _mm_shuffle_epi32(emm0, _MM_SHUFFLE(1,2,0,3));\n  return pmax(pmul(x, Packet2d(_mm_castsi128_pd(emm0))), _x);\n}\n\n/* evaluation of 4 sines at onces, using SSE2 intrinsics.\n\n   The code is the exact rewriting of the cephes sinf function.\n   Precision is excellent as long as x < 8192 (I did not bother to\n   take into account the special handling they have for greater values\n   -- it does not return garbage for arguments over 8192, though, but\n   the extra precision is missing).\n\n   Note that it is such that sinf((float)M_PI) = 8.74e-8, which is the\n   surprising but correct result.\n*/\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f psin<Packet4f>(const Packet4f& _x)\n{\n  Packet4f x = _x;\n  _EIGEN_DECLARE_CONST_Packet4f(1 , 1.0f);\n  _EIGEN_DECLARE_CONST_Packet4f(half, 0.5f);\n\n  _EIGEN_DECLARE_CONST_Packet4i(1, 1);\n  _EIGEN_DECLARE_CONST_Packet4i(not1, ~1);\n  _EIGEN_DECLARE_CONST_Packet4i(2, 2);\n  _EIGEN_DECLARE_CONST_Packet4i(4, 4);\n\n  _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(sign_mask, 0x80000000);\n\n  _EIGEN_DECLARE_CONST_Packet4f(minus_cephes_DP1,-0.78515625f);\n  _EIGEN_DECLARE_CONST_Packet4f(minus_cephes_DP2, -2.4187564849853515625e-4f);\n  _EIGEN_DECLARE_CONST_Packet4f(minus_cephes_DP3, -3.77489497744594108e-8f);\n  _EIGEN_DECLARE_CONST_Packet4f(sincof_p0, -1.9515295891E-4f);\n  _EIGEN_DECLARE_CONST_Packet4f(sincof_p1,  8.3321608736E-3f);\n  _EIGEN_DECLARE_CONST_Packet4f(sincof_p2, -1.6666654611E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(coscof_p0,  2.443315711809948E-005f);\n  _EIGEN_DECLARE_CONST_Packet4f(coscof_p1, -1.388731625493765E-003f);\n  _EIGEN_DECLARE_CONST_Packet4f(coscof_p2,  4.166664568298827E-002f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_FOPI, 1.27323954473516f); // 4 / M_PI\n\n  Packet4f xmm1, xmm2, xmm3, sign_bit, y;\n\n  Packet4i emm0, emm2;\n  sign_bit = x;\n  /* take the absolute value */\n  x = pabs(x);\n\n  /* take the modulo */\n\n  /* extract the sign bit (upper one) */\n  sign_bit = _mm_and_ps(sign_bit, p4f_sign_mask);\n\n  /* scale by 4/Pi */\n  y = pmul(x, p4f_cephes_FOPI);\n\n  /* store the integer part of y in mm0 */\n  emm2 = _mm_cvttps_epi32(y);\n  /* j=(j+1) & (~1) (see the cephes sources) */\n  emm2 = _mm_add_epi32(emm2, p4i_1);\n  emm2 = _mm_and_si128(emm2, p4i_not1);\n  y = _mm_cvtepi32_ps(emm2);\n  /* get the swap sign flag */\n  emm0 = _mm_and_si128(emm2, p4i_4);\n  emm0 = _mm_slli_epi32(emm0, 29);\n  /* get the polynom selection mask\n     there is one polynom for 0 <= x <= Pi/4\n     and another one for Pi/4<x<=Pi/2\n\n     Both branches will be computed.\n  */\n  emm2 = _mm_and_si128(emm2, p4i_2);\n  emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());\n\n  Packet4f swap_sign_bit = _mm_castsi128_ps(emm0);\n  Packet4f poly_mask = _mm_castsi128_ps(emm2);\n  sign_bit = _mm_xor_ps(sign_bit, swap_sign_bit);\n\n  /* The magic pass: \"Extended precision modular arithmetic\"\n     x = ((x - y * DP1) - y * DP2) - y * DP3; */\n  xmm1 = pmul(y, p4f_minus_cephes_DP1);\n  xmm2 = pmul(y, p4f_minus_cephes_DP2);\n  xmm3 = pmul(y, p4f_minus_cephes_DP3);\n  x = padd(x, xmm1);\n  x = padd(x, xmm2);\n  x = padd(x, xmm3);\n\n  /* Evaluate the first polynom  (0 <= x <= Pi/4) */\n  y = p4f_coscof_p0;\n  Packet4f z = _mm_mul_ps(x,x);\n\n  y = pmadd(y, z, p4f_coscof_p1);\n  y = pmadd(y, z, p4f_coscof_p2);\n  y = pmul(y, z);\n  y = pmul(y, z);\n  Packet4f tmp = pmul(z, p4f_half);\n  y = psub(y, tmp);\n  y = padd(y, p4f_1);\n\n  /* Evaluate the second polynom  (Pi/4 <= x <= 0) */\n\n  Packet4f y2 = p4f_sincof_p0;\n  y2 = pmadd(y2, z, p4f_sincof_p1);\n  y2 = pmadd(y2, z, p4f_sincof_p2);\n  y2 = pmul(y2, z);\n  y2 = pmul(y2, x);\n  y2 = padd(y2, x);\n\n  /* select the correct result from the two polynoms */\n  y2 = _mm_and_ps(poly_mask, y2);\n  y = _mm_andnot_ps(poly_mask, y);\n  y = _mm_or_ps(y,y2);\n  /* update the sign */\n  return _mm_xor_ps(y, sign_bit);\n}\n\n/* almost the same as psin */\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f pcos<Packet4f>(const Packet4f& _x)\n{\n  Packet4f x = _x;\n  _EIGEN_DECLARE_CONST_Packet4f(1 , 1.0f);\n  _EIGEN_DECLARE_CONST_Packet4f(half, 0.5f);\n\n  _EIGEN_DECLARE_CONST_Packet4i(1, 1);\n  _EIGEN_DECLARE_CONST_Packet4i(not1, ~1);\n  _EIGEN_DECLARE_CONST_Packet4i(2, 2);\n  _EIGEN_DECLARE_CONST_Packet4i(4, 4);\n\n  _EIGEN_DECLARE_CONST_Packet4f(minus_cephes_DP1,-0.78515625f);\n  _EIGEN_DECLARE_CONST_Packet4f(minus_cephes_DP2, -2.4187564849853515625e-4f);\n  _EIGEN_DECLARE_CONST_Packet4f(minus_cephes_DP3, -3.77489497744594108e-8f);\n  _EIGEN_DECLARE_CONST_Packet4f(sincof_p0, -1.9515295891E-4f);\n  _EIGEN_DECLARE_CONST_Packet4f(sincof_p1,  8.3321608736E-3f);\n  _EIGEN_DECLARE_CONST_Packet4f(sincof_p2, -1.6666654611E-1f);\n  _EIGEN_DECLARE_CONST_Packet4f(coscof_p0,  2.443315711809948E-005f);\n  _EIGEN_DECLARE_CONST_Packet4f(coscof_p1, -1.388731625493765E-003f);\n  _EIGEN_DECLARE_CONST_Packet4f(coscof_p2,  4.166664568298827E-002f);\n  _EIGEN_DECLARE_CONST_Packet4f(cephes_FOPI, 1.27323954473516f); // 4 / M_PI\n\n  Packet4f xmm1, xmm2, xmm3, y;\n  Packet4i emm0, emm2;\n\n  x = pabs(x);\n\n  /* scale by 4/Pi */\n  y = pmul(x, p4f_cephes_FOPI);\n\n  /* get the integer part of y */\n  emm2 = _mm_cvttps_epi32(y);\n  /* j=(j+1) & (~1) (see the cephes sources) */\n  emm2 = _mm_add_epi32(emm2, p4i_1);\n  emm2 = _mm_and_si128(emm2, p4i_not1);\n  y = _mm_cvtepi32_ps(emm2);\n\n  emm2 = _mm_sub_epi32(emm2, p4i_2);\n\n  /* get the swap sign flag */\n  emm0 = _mm_andnot_si128(emm2, p4i_4);\n  emm0 = _mm_slli_epi32(emm0, 29);\n  /* get the polynom selection mask */\n  emm2 = _mm_and_si128(emm2, p4i_2);\n  emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());\n\n  Packet4f sign_bit = _mm_castsi128_ps(emm0);\n  Packet4f poly_mask = _mm_castsi128_ps(emm2);\n\n  /* The magic pass: \"Extended precision modular arithmetic\"\n     x = ((x - y * DP1) - y * DP2) - y * DP3; */\n  xmm1 = pmul(y, p4f_minus_cephes_DP1);\n  xmm2 = pmul(y, p4f_minus_cephes_DP2);\n  xmm3 = pmul(y, p4f_minus_cephes_DP3);\n  x = padd(x, xmm1);\n  x = padd(x, xmm2);\n  x = padd(x, xmm3);\n\n  /* Evaluate the first polynom  (0 <= x <= Pi/4) */\n  y = p4f_coscof_p0;\n  Packet4f z = pmul(x,x);\n\n  y = pmadd(y,z,p4f_coscof_p1);\n  y = pmadd(y,z,p4f_coscof_p2);\n  y = pmul(y, z);\n  y = pmul(y, z);\n  Packet4f tmp = _mm_mul_ps(z, p4f_half);\n  y = psub(y, tmp);\n  y = padd(y, p4f_1);\n\n  /* Evaluate the second polynom  (Pi/4 <= x <= 0) */\n  Packet4f y2 = p4f_sincof_p0;\n  y2 = pmadd(y2, z, p4f_sincof_p1);\n  y2 = pmadd(y2, z, p4f_sincof_p2);\n  y2 = pmul(y2, z);\n  y2 = pmadd(y2, x, x);\n\n  /* select the correct result from the two polynoms */\n  y2 = _mm_and_ps(poly_mask, y2);\n  y  = _mm_andnot_ps(poly_mask, y);\n  y  = _mm_or_ps(y,y2);\n\n  /* update the sign */\n  return _mm_xor_ps(y, sign_bit);\n}\n\n#if EIGEN_FAST_MATH\n\n// Functions for sqrt.\n// The EIGEN_FAST_MATH version uses the _mm_rsqrt_ps approximation and one step\n// of Newton's method, at a cost of 1-2 bits of precision as opposed to the\n// exact solution. It does not handle +inf, or denormalized numbers correctly.\n// The main advantage of this approach is not just speed, but also the fact that\n// it can be inlined and pipelined with other computations, further reducing its\n// effective latency. This is similar to Quake3's fast inverse square root.\n// For detail see here: http://www.beyond3d.com/content/articles/8/\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f psqrt<Packet4f>(const Packet4f& _x)\n{\n  Packet4f half = pmul(_x, pset1<Packet4f>(.5f));\n  Packet4f denormal_mask = _mm_and_ps(\n      _mm_cmpge_ps(_x, _mm_setzero_ps()),\n      _mm_cmplt_ps(_x, pset1<Packet4f>((std::numeric_limits<float>::min)())));\n\n  // Compute approximate reciprocal sqrt.\n  Packet4f x = _mm_rsqrt_ps(_x);\n  // Do a single step of Newton's iteration.\n  x = pmul(x, psub(pset1<Packet4f>(1.5f), pmul(half, pmul(x,x))));\n  // Flush results for denormals to zero.\n  return _mm_andnot_ps(denormal_mask, pmul(_x,x));\n}\n\n#else\n\ntemplate<>EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f psqrt<Packet4f>(const Packet4f& x) { return _mm_sqrt_ps(x); }\n\n#endif\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket2d psqrt<Packet2d>(const Packet2d& x) { return _mm_sqrt_pd(x); }\n\n#if EIGEN_FAST_MATH\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f prsqrt<Packet4f>(const Packet4f& _x) {\n  _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(inf, 0x7f800000);\n  _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(nan, 0x7fc00000);\n  _EIGEN_DECLARE_CONST_Packet4f(one_point_five, 1.5f);\n  _EIGEN_DECLARE_CONST_Packet4f(minus_half, -0.5f);\n  _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(flt_min, 0x00800000);\n\n  Packet4f neg_half = pmul(_x, p4f_minus_half);\n\n  // select only the inverse sqrt of positive normal inputs (denormals are\n  // flushed to zero and cause infs as well).\n  Packet4f le_zero_mask = _mm_cmple_ps(_x, p4f_flt_min);\n  Packet4f x = _mm_andnot_ps(le_zero_mask, _mm_rsqrt_ps(_x));\n\n  // Fill in NaNs and Infs for the negative/zero entries.\n  Packet4f neg_mask = _mm_cmplt_ps(_x, _mm_setzero_ps());\n  Packet4f zero_mask = _mm_andnot_ps(neg_mask, le_zero_mask);\n  Packet4f infs_and_nans = _mm_or_ps(_mm_and_ps(neg_mask, p4f_nan),\n                                     _mm_and_ps(zero_mask, p4f_inf));\n\n  // Do a single step of Newton's iteration.\n  x = pmul(x, pmadd(neg_half, pmul(x, x), p4f_one_point_five));\n\n  // Insert NaNs and Infs in all the right places.\n  return _mm_or_ps(x, infs_and_nans);\n}\n\n#else\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f prsqrt<Packet4f>(const Packet4f& x) {\n  // Unfortunately we can't use the much faster mm_rqsrt_ps since it only provides an approximation.\n  return _mm_div_ps(pset1<Packet4f>(1.0f), _mm_sqrt_ps(x));\n}\n\n#endif\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket2d prsqrt<Packet2d>(const Packet2d& x) {\n  // Unfortunately we can't use the much faster mm_rqsrt_pd since it only provides an approximation.\n  return _mm_div_pd(pset1<Packet2d>(1.0), _mm_sqrt_pd(x));\n}\n\n// Hyperbolic Tangent function.\ntemplate <>\nEIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet4f\nptanh<Packet4f>(const Packet4f& x) {\n  return internal::generic_fast_tanh_float(x);\n}\n\n} // end namespace internal\n\nnamespace numext {\n\ntemplate<>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\nfloat sqrt(const float &x)\n{\n  return internal::pfirst(internal::Packet4f(_mm_sqrt_ss(_mm_set_ss(x))));\n}\n\ntemplate<>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE\ndouble sqrt(const double &x)\n{\n#if EIGEN_COMP_GNUC_STRICT\n  // This works around a GCC bug generating poor code for _mm_sqrt_pd\n  // See https://bitbucket.org/eigen/eigen/commits/14f468dba4d350d7c19c9b93072e19f7b3df563b\n  return internal::pfirst(internal::Packet2d(__builtin_ia32_sqrtsd(_mm_set_sd(x))));\n#else\n  return internal::pfirst(internal::Packet2d(_mm_sqrt_pd(_mm_set_sd(x))));\n#endif\n}\n\n} // end namespace numex\n\n} // end namespace Eigen\n\n#endif // EIGEN_MATH_FUNCTIONS_SSE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/SSE/PacketMath.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PACKET_MATH_SSE_H\n#define EIGEN_PACKET_MATH_SSE_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD\n#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8\n#endif\n\n#ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS\n#define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS (2*sizeof(void*))\n#endif\n\n#ifdef __FMA__\n#ifndef EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n#define EIGEN_HAS_SINGLE_INSTRUCTION_MADD 1\n#endif\n#endif\n\n#if (defined EIGEN_VECTORIZE_AVX) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_MINGW) && (__GXX_ABI_VERSION < 1004)\n// With GCC's default ABI version, a __m128 or __m256 are the same types and therefore we cannot\n// have overloads for both types without linking error.\n// One solution is to increase ABI version using -fabi-version=4 (or greater).\n// Otherwise, we workaround this inconvenience by wrapping 128bit types into the following helper\n// structure:\ntemplate<typename T>\nstruct eigen_packet_wrapper\n{\n  EIGEN_ALWAYS_INLINE operator T&() { return m_val; }\n  EIGEN_ALWAYS_INLINE operator const T&() const { return m_val; }\n  EIGEN_ALWAYS_INLINE eigen_packet_wrapper() {}\n  EIGEN_ALWAYS_INLINE eigen_packet_wrapper(const T &v) : m_val(v) {}\n  EIGEN_ALWAYS_INLINE eigen_packet_wrapper& operator=(const T &v) {\n    m_val = v;\n    return *this;\n  }\n  \n  T m_val;\n};\ntypedef eigen_packet_wrapper<__m128>  Packet4f;\ntypedef eigen_packet_wrapper<__m128i> Packet4i;\ntypedef eigen_packet_wrapper<__m128d> Packet2d;\n#else\ntypedef __m128  Packet4f;\ntypedef __m128i Packet4i;\ntypedef __m128d Packet2d;\n#endif\n\ntemplate<> struct is_arithmetic<__m128>  { enum { value = true }; };\ntemplate<> struct is_arithmetic<__m128i> { enum { value = true }; };\ntemplate<> struct is_arithmetic<__m128d> { enum { value = true }; };\n\n#define vec4f_swizzle1(v,p,q,r,s) \\\n  (_mm_castsi128_ps(_mm_shuffle_epi32( _mm_castps_si128(v), ((s)<<6|(r)<<4|(q)<<2|(p)))))\n\n#define vec4i_swizzle1(v,p,q,r,s) \\\n  (_mm_shuffle_epi32( v, ((s)<<6|(r)<<4|(q)<<2|(p))))\n\n#define vec2d_swizzle1(v,p,q) \\\n  (_mm_castsi128_pd(_mm_shuffle_epi32( _mm_castpd_si128(v), ((q*2+1)<<6|(q*2)<<4|(p*2+1)<<2|(p*2)))))\n  \n#define vec4f_swizzle2(a,b,p,q,r,s) \\\n  (_mm_shuffle_ps( (a), (b), ((s)<<6|(r)<<4|(q)<<2|(p))))\n\n#define vec4i_swizzle2(a,b,p,q,r,s) \\\n  (_mm_castps_si128( (_mm_shuffle_ps( _mm_castsi128_ps(a), _mm_castsi128_ps(b), ((s)<<6|(r)<<4|(q)<<2|(p))))))\n\n#define _EIGEN_DECLARE_CONST_Packet4f(NAME,X) \\\n  const Packet4f p4f_##NAME = pset1<Packet4f>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet2d(NAME,X) \\\n  const Packet2d p2d_##NAME = pset1<Packet2d>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet4f_FROM_INT(NAME,X) \\\n  const Packet4f p4f_##NAME = _mm_castsi128_ps(pset1<Packet4i>(X))\n\n#define _EIGEN_DECLARE_CONST_Packet4i(NAME,X) \\\n  const Packet4i p4i_##NAME = pset1<Packet4i>(X)\n\n\n// Use the packet_traits defined in AVX/PacketMath.h instead if we're going\n// to leverage AVX instructions.\n#ifndef EIGEN_VECTORIZE_AVX\ntemplate<> struct packet_traits<float>  : default_packet_traits\n{\n  typedef Packet4f type;\n  typedef Packet4f half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=4,\n    HasHalfPacket = 0,\n\n    HasDiv  = 1,\n    HasSin  = EIGEN_FAST_MATH,\n    HasCos  = EIGEN_FAST_MATH,\n    HasLog  = 1,\n    HasExp  = 1,\n    HasSqrt = 1,\n    HasRsqrt = 1,\n    HasTanh  = EIGEN_FAST_MATH,\n    HasBlend = 1\n\n#ifdef EIGEN_VECTORIZE_SSE4_1\n    ,\n    HasRound = 1,\n    HasFloor = 1,\n    HasCeil = 1\n#endif\n  };\n};\ntemplate<> struct packet_traits<double> : default_packet_traits\n{\n  typedef Packet2d type;\n  typedef Packet2d half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=2,\n    HasHalfPacket = 0,\n\n    HasDiv  = 1,\n    HasExp  = 1,\n    HasSqrt = 1,\n    HasRsqrt = 1,\n    HasBlend = 1\n\n#ifdef EIGEN_VECTORIZE_SSE4_1\n    ,\n    HasRound = 1,\n    HasFloor = 1,\n    HasCeil = 1\n#endif\n  };\n};\n#endif\ntemplate<> struct packet_traits<int>    : default_packet_traits\n{\n  typedef Packet4i type;\n  typedef Packet4i half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=4,\n\n    HasBlend = 1\n  };\n};\n\ntemplate<> struct unpacket_traits<Packet4f> { typedef float  type; enum {size=4, alignment=Aligned16}; typedef Packet4f half; };\ntemplate<> struct unpacket_traits<Packet2d> { typedef double type; enum {size=2, alignment=Aligned16}; typedef Packet2d half; };\ntemplate<> struct unpacket_traits<Packet4i> { typedef int    type; enum {size=4, alignment=Aligned16}; typedef Packet4i half; };\n\n#ifndef EIGEN_VECTORIZE_AVX\ntemplate<> struct scalar_div_cost<float,true> { enum { value = 7 }; };\ntemplate<> struct scalar_div_cost<double,true> { enum { value = 8 }; };\n#endif\n\n#if EIGEN_COMP_MSVC==1500\n// Workaround MSVC 9 internal compiler error.\n// TODO: It has been detected with win64 builds (amd64), so let's check whether it also happens in 32bits+SSE mode\n// TODO: let's check whether there does not exist a better fix, like adding a pset0() function. (it crashed on pset1(0)).\ntemplate<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float&  from) { return _mm_set_ps(from,from,from,from); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pset1<Packet2d>(const double& from) { return _mm_set_pd(from,from); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(const int&    from) { return _mm_set_epi32(from,from,from,from); }\n#else\ntemplate<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float&  from) { return _mm_set_ps1(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pset1<Packet2d>(const double& from) { return _mm_set1_pd(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(const int&    from) { return _mm_set1_epi32(from); }\n#endif\n\n// GCC generates a shufps instruction for _mm_set1_ps/_mm_load1_ps instead of the more efficient pshufd instruction.\n// However, using inrinsics for pset1 makes gcc to generate crappy code in some cases (see bug 203)\n// Using inline assembly is also not an option because then gcc fails to reorder properly the instructions.\n// Therefore, we introduced the pload1 functions to be used in product kernels for which bug 203 does not apply.\n// Also note that with AVX, we want it to generate a vbroadcastss.\n#if EIGEN_COMP_GNUC_STRICT && (!defined __AVX__)\ntemplate<> EIGEN_STRONG_INLINE Packet4f pload1<Packet4f>(const float *from) {\n  return vec4f_swizzle1(_mm_load_ss(from),0,0,0,0);\n}\n#endif\n  \ntemplate<> EIGEN_STRONG_INLINE Packet4f plset<Packet4f>(const float& a) { return _mm_add_ps(pset1<Packet4f>(a), _mm_set_ps(3,2,1,0)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d plset<Packet2d>(const double& a) { return _mm_add_pd(pset1<Packet2d>(a),_mm_set_pd(1,0)); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i plset<Packet4i>(const int& a) { return _mm_add_epi32(pset1<Packet4i>(a),_mm_set_epi32(3,2,1,0)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f padd<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_add_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d padd<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_add_pd(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i padd<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_add_epi32(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f psub<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_sub_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d psub<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_sub_pd(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i psub<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_sub_epi32(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pnegate(const Packet4f& a)\n{\n  const Packet4f mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x80000000,0x80000000,0x80000000));\n  return _mm_xor_ps(a,mask);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pnegate(const Packet2d& a)\n{\n  const Packet2d mask = _mm_castsi128_pd(_mm_setr_epi32(0x0,0x80000000,0x0,0x80000000));\n  return _mm_xor_pd(a,mask);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i pnegate(const Packet4i& a)\n{\n  return psub(Packet4i(_mm_setr_epi32(0,0,0,0)), a);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pconj(const Packet4f& a) { return a; }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pconj(const Packet2d& a) { return a; }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pconj(const Packet4i& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmul<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_mul_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmul<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_mul_pd(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmul<Packet4i>(const Packet4i& a, const Packet4i& b)\n{\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  return _mm_mullo_epi32(a,b);\n#else\n  // this version is slightly faster than 4 scalar products\n  return vec4i_swizzle1(\n            vec4i_swizzle2(\n              _mm_mul_epu32(a,b),\n              _mm_mul_epu32(vec4i_swizzle1(a,1,0,3,2),\n                            vec4i_swizzle1(b,1,0,3,2)),\n              0,2,0,2),\n            0,2,1,3);\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pdiv<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_div_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pdiv<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_div_pd(a,b); }\n\n// for some weird raisons, it has to be overloaded for packet of integers\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmadd(const Packet4i& a, const Packet4i& b, const Packet4i& c) { return padd(pmul(a,b), c); }\n#ifdef __FMA__\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmadd(const Packet4f& a, const Packet4f& b, const Packet4f& c) { return _mm_fmadd_ps(a,b,c); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmadd(const Packet2d& a, const Packet2d& b, const Packet2d& c) { return _mm_fmadd_pd(a,b,c); }\n#endif\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmin<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_min_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmin<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_min_pd(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmin<Packet4i>(const Packet4i& a, const Packet4i& b)\n{\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  return _mm_min_epi32(a,b);\n#else\n  // after some bench, this version *is* faster than a scalar implementation\n  Packet4i mask = _mm_cmplt_epi32(a,b);\n  return _mm_or_si128(_mm_and_si128(mask,a),_mm_andnot_si128(mask,b));\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmax<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_max_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmax<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_max_pd(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmax<Packet4i>(const Packet4i& a, const Packet4i& b)\n{\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  return _mm_max_epi32(a,b);\n#else\n  // after some bench, this version *is* faster than a scalar implementation\n  Packet4i mask = _mm_cmpgt_epi32(a,b);\n  return _mm_or_si128(_mm_and_si128(mask,a),_mm_andnot_si128(mask,b));\n#endif\n}\n\n#ifdef EIGEN_VECTORIZE_SSE4_1\ntemplate<> EIGEN_STRONG_INLINE Packet4f pround<Packet4f>(const Packet4f& a) { return _mm_round_ps(a, 0); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pround<Packet2d>(const Packet2d& a) { return _mm_round_pd(a, 0); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pceil<Packet4f>(const Packet4f& a) { return _mm_ceil_ps(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pceil<Packet2d>(const Packet2d& a) { return _mm_ceil_pd(a); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pfloor<Packet4f>(const Packet4f& a) { return _mm_floor_ps(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pfloor<Packet2d>(const Packet2d& a) { return _mm_floor_pd(a); }\n#endif\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pand<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_and_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pand<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_and_pd(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pand<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_and_si128(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f por<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_or_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d por<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_or_pd(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i por<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_or_si128(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pxor<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_xor_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pxor<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_xor_pd(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pxor<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_xor_si128(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pandnot<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_andnot_ps(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pandnot<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_andnot_pd(a,b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_andnot_si128(a,b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pload<Packet4f>(const float*   from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_ps(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pload<Packet2d>(const double*  from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_pd(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i pload<Packet4i>(const int*     from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_si128(reinterpret_cast<const __m128i*>(from)); }\n\n#if EIGEN_COMP_MSVC\n  template<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float*  from) {\n    EIGEN_DEBUG_UNALIGNED_LOAD\n    #if (EIGEN_COMP_MSVC==1600)\n    // NOTE Some version of MSVC10 generates bad code when using _mm_loadu_ps\n    // (i.e., it does not generate an unaligned load!!\n    __m128 res = _mm_loadl_pi(_mm_set1_ps(0.0f), (const __m64*)(from));\n    res = _mm_loadh_pi(res, (const __m64*)(from+2));\n    return res;\n    #else\n    return _mm_loadu_ps(from);\n    #endif\n  }\n#else\n// NOTE: with the code below, MSVC's compiler crashes!\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float* from)\n{\n  EIGEN_DEBUG_UNALIGNED_LOAD\n  return _mm_loadu_ps(from);\n}\n#endif\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d ploadu<Packet2d>(const double* from)\n{\n  EIGEN_DEBUG_UNALIGNED_LOAD\n  return _mm_loadu_pd(from);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i ploadu<Packet4i>(const int* from)\n{\n  EIGEN_DEBUG_UNALIGNED_LOAD\n  return _mm_loadu_si128(reinterpret_cast<const __m128i*>(from));\n}\n\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f ploaddup<Packet4f>(const float*   from)\n{\n  return vec4f_swizzle1(_mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(from))), 0, 0, 1, 1);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d ploaddup<Packet2d>(const double*  from)\n{ return pset1<Packet2d>(from[0]); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i ploaddup<Packet4i>(const int*     from)\n{\n  Packet4i tmp;\n  tmp = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(from));\n  return vec4i_swizzle1(tmp, 0, 0, 1, 1);\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<float>(float*   to, const Packet4f& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_ps(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstore<double>(double* to, const Packet2d& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_pd(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstore<int>(int*       to, const Packet4i& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_si128(reinterpret_cast<__m128i*>(to), from); }\n\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<double>(double* to, const Packet2d& from) { EIGEN_DEBUG_UNALIGNED_STORE _mm_storeu_pd(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<float>(float*   to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE _mm_storeu_ps(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<int>(int*       to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE _mm_storeu_si128(reinterpret_cast<__m128i*>(to), from); }\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, Index stride)\n{\n return _mm_set_ps(from[3*stride], from[2*stride], from[1*stride], from[0*stride]);\n}\ntemplate<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, Index stride)\n{\n return _mm_set_pd(from[1*stride], from[0*stride]);\n}\ntemplate<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, Index stride)\n{\n return _mm_set_epi32(from[3*stride], from[2*stride], from[1*stride], from[0*stride]);\n }\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, Index stride)\n{\n  to[stride*0] = _mm_cvtss_f32(from);\n  to[stride*1] = _mm_cvtss_f32(_mm_shuffle_ps(from, from, 1));\n  to[stride*2] = _mm_cvtss_f32(_mm_shuffle_ps(from, from, 2));\n  to[stride*3] = _mm_cvtss_f32(_mm_shuffle_ps(from, from, 3));\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, Index stride)\n{\n  to[stride*0] = _mm_cvtsd_f64(from);\n  to[stride*1] = _mm_cvtsd_f64(_mm_shuffle_pd(from, from, 1));\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, Index stride)\n{\n  to[stride*0] = _mm_cvtsi128_si32(from);\n  to[stride*1] = _mm_cvtsi128_si32(_mm_shuffle_epi32(from, 1));\n  to[stride*2] = _mm_cvtsi128_si32(_mm_shuffle_epi32(from, 2));\n  to[stride*3] = _mm_cvtsi128_si32(_mm_shuffle_epi32(from, 3));\n}\n\n// some compilers might be tempted to perform multiple moves instead of using a vector path.\ntemplate<> EIGEN_STRONG_INLINE void pstore1<Packet4f>(float* to, const float& a)\n{\n  Packet4f pa = _mm_set_ss(a);\n  pstore(to, Packet4f(vec4f_swizzle1(pa,0,0,0,0)));\n}\n// some compilers might be tempted to perform multiple moves instead of using a vector path.\ntemplate<> EIGEN_STRONG_INLINE void pstore1<Packet2d>(double* to, const double& a)\n{\n  Packet2d pa = _mm_set_sd(a);\n  pstore(to, Packet2d(vec2d_swizzle1(pa,0,0)));\n}\n\n#ifndef EIGEN_VECTORIZE_AVX\ntemplate<> EIGEN_STRONG_INLINE void prefetch<float>(const float*   addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }\ntemplate<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }\ntemplate<> EIGEN_STRONG_INLINE void prefetch<int>(const int*       addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }\n#endif\n\n#if EIGEN_COMP_MSVC_STRICT && EIGEN_OS_WIN64\n// The temporary variable fixes an internal compilation error in vs <= 2008 and a wrong-result bug in vs 2010\n// Direct of the struct members fixed bug #62.\ntemplate<> EIGEN_STRONG_INLINE float  pfirst<Packet4f>(const Packet4f& a) { return a.m128_f32[0]; }\ntemplate<> EIGEN_STRONG_INLINE double pfirst<Packet2d>(const Packet2d& a) { return a.m128d_f64[0]; }\ntemplate<> EIGEN_STRONG_INLINE int    pfirst<Packet4i>(const Packet4i& a) { int x = _mm_cvtsi128_si32(a); return x; }\n#elif EIGEN_COMP_MSVC_STRICT\n// The temporary variable fixes an internal compilation error in vs <= 2008 and a wrong-result bug in vs 2010\ntemplate<> EIGEN_STRONG_INLINE float  pfirst<Packet4f>(const Packet4f& a) { float x = _mm_cvtss_f32(a); return x; }\ntemplate<> EIGEN_STRONG_INLINE double pfirst<Packet2d>(const Packet2d& a) { double x = _mm_cvtsd_f64(a); return x; }\ntemplate<> EIGEN_STRONG_INLINE int    pfirst<Packet4i>(const Packet4i& a) { int x = _mm_cvtsi128_si32(a); return x; }\n#else\ntemplate<> EIGEN_STRONG_INLINE float  pfirst<Packet4f>(const Packet4f& a) { return _mm_cvtss_f32(a); }\ntemplate<> EIGEN_STRONG_INLINE double pfirst<Packet2d>(const Packet2d& a) { return _mm_cvtsd_f64(a); }\ntemplate<> EIGEN_STRONG_INLINE int    pfirst<Packet4i>(const Packet4i& a) { return _mm_cvtsi128_si32(a); }\n#endif\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f preverse(const Packet4f& a)\n{ return _mm_shuffle_ps(a,a,0x1B); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d preverse(const Packet2d& a)\n{ return _mm_shuffle_pd(a,a,0x1); }\ntemplate<> EIGEN_STRONG_INLINE Packet4i preverse(const Packet4i& a)\n{ return _mm_shuffle_epi32(a,0x1B); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pabs(const Packet4f& a)\n{\n  const Packet4f mask = _mm_castsi128_ps(_mm_setr_epi32(0x7FFFFFFF,0x7FFFFFFF,0x7FFFFFFF,0x7FFFFFFF));\n  return _mm_and_ps(a,mask);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pabs(const Packet2d& a)\n{\n  const Packet2d mask = _mm_castsi128_pd(_mm_setr_epi32(0xFFFFFFFF,0x7FFFFFFF,0xFFFFFFFF,0x7FFFFFFF));\n  return _mm_and_pd(a,mask);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4i pabs(const Packet4i& a)\n{\n  #ifdef EIGEN_VECTORIZE_SSSE3\n  return _mm_abs_epi32(a);\n  #else\n  Packet4i aux = _mm_srai_epi32(a,31);\n  return _mm_sub_epi32(_mm_xor_si128(a,aux),aux);\n  #endif\n}\n\n// with AVX, the default implementations based on pload1 are faster\n#ifndef __AVX__\ntemplate<> EIGEN_STRONG_INLINE void\npbroadcast4<Packet4f>(const float *a,\n                      Packet4f& a0, Packet4f& a1, Packet4f& a2, Packet4f& a3)\n{\n  a3 = pload<Packet4f>(a);\n  a0 = vec4f_swizzle1(a3, 0,0,0,0);\n  a1 = vec4f_swizzle1(a3, 1,1,1,1);\n  a2 = vec4f_swizzle1(a3, 2,2,2,2);\n  a3 = vec4f_swizzle1(a3, 3,3,3,3);\n}\ntemplate<> EIGEN_STRONG_INLINE void\npbroadcast4<Packet2d>(const double *a,\n                      Packet2d& a0, Packet2d& a1, Packet2d& a2, Packet2d& a3)\n{\n#ifdef EIGEN_VECTORIZE_SSE3\n  a0 = _mm_loaddup_pd(a+0);\n  a1 = _mm_loaddup_pd(a+1);\n  a2 = _mm_loaddup_pd(a+2);\n  a3 = _mm_loaddup_pd(a+3);\n#else\n  a1 = pload<Packet2d>(a);\n  a0 = vec2d_swizzle1(a1, 0,0);\n  a1 = vec2d_swizzle1(a1, 1,1);\n  a3 = pload<Packet2d>(a+2);\n  a2 = vec2d_swizzle1(a3, 0,0);\n  a3 = vec2d_swizzle1(a3, 1,1);\n#endif\n}\n#endif\n\nEIGEN_STRONG_INLINE void punpackp(Packet4f* vecs)\n{\n  vecs[1] = _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(vecs[0]), 0x55));\n  vecs[2] = _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(vecs[0]), 0xAA));\n  vecs[3] = _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(vecs[0]), 0xFF));\n  vecs[0] = _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(vecs[0]), 0x00));\n}\n\n#ifdef EIGEN_VECTORIZE_SSE3\ntemplate<> EIGEN_STRONG_INLINE Packet4f preduxp<Packet4f>(const Packet4f* vecs)\n{\n  return _mm_hadd_ps(_mm_hadd_ps(vecs[0], vecs[1]),_mm_hadd_ps(vecs[2], vecs[3]));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d preduxp<Packet2d>(const Packet2d* vecs)\n{\n  return _mm_hadd_pd(vecs[0], vecs[1]);\n}\n\n#else\ntemplate<> EIGEN_STRONG_INLINE Packet4f preduxp<Packet4f>(const Packet4f* vecs)\n{\n  Packet4f tmp0, tmp1, tmp2;\n  tmp0 = _mm_unpacklo_ps(vecs[0], vecs[1]);\n  tmp1 = _mm_unpackhi_ps(vecs[0], vecs[1]);\n  tmp2 = _mm_unpackhi_ps(vecs[2], vecs[3]);\n  tmp0 = _mm_add_ps(tmp0, tmp1);\n  tmp1 = _mm_unpacklo_ps(vecs[2], vecs[3]);\n  tmp1 = _mm_add_ps(tmp1, tmp2);\n  tmp2 = _mm_movehl_ps(tmp1, tmp0);\n  tmp0 = _mm_movelh_ps(tmp0, tmp1);\n  return _mm_add_ps(tmp0, tmp2);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d preduxp<Packet2d>(const Packet2d* vecs)\n{\n  return _mm_add_pd(_mm_unpacklo_pd(vecs[0], vecs[1]), _mm_unpackhi_pd(vecs[0], vecs[1]));\n}\n#endif  // SSE3\n\ntemplate<> EIGEN_STRONG_INLINE float predux<Packet4f>(const Packet4f& a)\n{\n  // Disable SSE3 _mm_hadd_pd that is extremely slow on all existing Intel's architectures\n  // (from Nehalem to Haswell)\n// #ifdef EIGEN_VECTORIZE_SSE3\n//   Packet4f tmp = _mm_add_ps(a, vec4f_swizzle1(a,2,3,2,3));\n//   return pfirst<Packet4f>(_mm_hadd_ps(tmp, tmp));\n// #else\n  Packet4f tmp = _mm_add_ps(a, _mm_movehl_ps(a,a));\n  return pfirst<Packet4f>(_mm_add_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1)));\n// #endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE double predux<Packet2d>(const Packet2d& a)\n{\n  // Disable SSE3 _mm_hadd_pd that is extremely slow on all existing Intel's architectures\n  // (from Nehalem to Haswell)\n// #ifdef EIGEN_VECTORIZE_SSE3\n//   return pfirst<Packet2d>(_mm_hadd_pd(a, a));\n// #else\n  return pfirst<Packet2d>(_mm_add_sd(a, _mm_unpackhi_pd(a,a)));\n// #endif\n}\n\n#ifdef EIGEN_VECTORIZE_SSSE3\ntemplate<> EIGEN_STRONG_INLINE Packet4i preduxp<Packet4i>(const Packet4i* vecs)\n{\n  return _mm_hadd_epi32(_mm_hadd_epi32(vecs[0], vecs[1]),_mm_hadd_epi32(vecs[2], vecs[3]));\n}\ntemplate<> EIGEN_STRONG_INLINE int predux<Packet4i>(const Packet4i& a)\n{\n  Packet4i tmp0 = _mm_hadd_epi32(a,a);\n  return pfirst<Packet4i>(_mm_hadd_epi32(tmp0,tmp0));\n}\n#else\ntemplate<> EIGEN_STRONG_INLINE int predux<Packet4i>(const Packet4i& a)\n{\n  Packet4i tmp = _mm_add_epi32(a, _mm_unpackhi_epi64(a,a));\n  return pfirst(tmp) + pfirst<Packet4i>(_mm_shuffle_epi32(tmp, 1));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i preduxp<Packet4i>(const Packet4i* vecs)\n{\n  Packet4i tmp0, tmp1, tmp2;\n  tmp0 = _mm_unpacklo_epi32(vecs[0], vecs[1]);\n  tmp1 = _mm_unpackhi_epi32(vecs[0], vecs[1]);\n  tmp2 = _mm_unpackhi_epi32(vecs[2], vecs[3]);\n  tmp0 = _mm_add_epi32(tmp0, tmp1);\n  tmp1 = _mm_unpacklo_epi32(vecs[2], vecs[3]);\n  tmp1 = _mm_add_epi32(tmp1, tmp2);\n  tmp2 = _mm_unpacklo_epi64(tmp0, tmp1);\n  tmp0 = _mm_unpackhi_epi64(tmp0, tmp1);\n  return _mm_add_epi32(tmp0, tmp2);\n}\n#endif\n// Other reduction functions:\n\n// mul\ntemplate<> EIGEN_STRONG_INLINE float predux_mul<Packet4f>(const Packet4f& a)\n{\n  Packet4f tmp = _mm_mul_ps(a, _mm_movehl_ps(a,a));\n  return pfirst<Packet4f>(_mm_mul_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1)));\n}\ntemplate<> EIGEN_STRONG_INLINE double predux_mul<Packet2d>(const Packet2d& a)\n{\n  return pfirst<Packet2d>(_mm_mul_sd(a, _mm_unpackhi_pd(a,a)));\n}\ntemplate<> EIGEN_STRONG_INLINE int predux_mul<Packet4i>(const Packet4i& a)\n{\n  // after some experiments, it is seems this is the fastest way to implement it\n  // for GCC (eg., reusing pmul is very slow !)\n  // TODO try to call _mm_mul_epu32 directly\n  EIGEN_ALIGN16 int aux[4];\n  pstore(aux, a);\n  return  (aux[0] * aux[1]) * (aux[2] * aux[3]);;\n}\n\n// min\ntemplate<> EIGEN_STRONG_INLINE float predux_min<Packet4f>(const Packet4f& a)\n{\n  Packet4f tmp = _mm_min_ps(a, _mm_movehl_ps(a,a));\n  return pfirst<Packet4f>(_mm_min_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1)));\n}\ntemplate<> EIGEN_STRONG_INLINE double predux_min<Packet2d>(const Packet2d& a)\n{\n  return pfirst<Packet2d>(_mm_min_sd(a, _mm_unpackhi_pd(a,a)));\n}\ntemplate<> EIGEN_STRONG_INLINE int predux_min<Packet4i>(const Packet4i& a)\n{\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  Packet4i tmp = _mm_min_epi32(a, _mm_shuffle_epi32(a, _MM_SHUFFLE(0,0,3,2)));\n  return pfirst<Packet4i>(_mm_min_epi32(tmp,_mm_shuffle_epi32(tmp, 1)));\n#else\n  // after some experiments, it is seems this is the fastest way to implement it\n  // for GCC (eg., it does not like using std::min after the pstore !!)\n  EIGEN_ALIGN16 int aux[4];\n  pstore(aux, a);\n  int aux0 = aux[0]<aux[1] ? aux[0] : aux[1];\n  int aux2 = aux[2]<aux[3] ? aux[2] : aux[3];\n  return aux0<aux2 ? aux0 : aux2;\n#endif // EIGEN_VECTORIZE_SSE4_1\n}\n\n// max\ntemplate<> EIGEN_STRONG_INLINE float predux_max<Packet4f>(const Packet4f& a)\n{\n  Packet4f tmp = _mm_max_ps(a, _mm_movehl_ps(a,a));\n  return pfirst<Packet4f>(_mm_max_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1)));\n}\ntemplate<> EIGEN_STRONG_INLINE double predux_max<Packet2d>(const Packet2d& a)\n{\n  return pfirst<Packet2d>(_mm_max_sd(a, _mm_unpackhi_pd(a,a)));\n}\ntemplate<> EIGEN_STRONG_INLINE int predux_max<Packet4i>(const Packet4i& a)\n{\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  Packet4i tmp = _mm_max_epi32(a, _mm_shuffle_epi32(a, _MM_SHUFFLE(0,0,3,2)));\n  return pfirst<Packet4i>(_mm_max_epi32(tmp,_mm_shuffle_epi32(tmp, 1)));\n#else\n  // after some experiments, it is seems this is the fastest way to implement it\n  // for GCC (eg., it does not like using std::min after the pstore !!)\n  EIGEN_ALIGN16 int aux[4];\n  pstore(aux, a);\n  int aux0 = aux[0]>aux[1] ? aux[0] : aux[1];\n  int aux2 = aux[2]>aux[3] ? aux[2] : aux[3];\n  return aux0>aux2 ? aux0 : aux2;\n#endif // EIGEN_VECTORIZE_SSE4_1\n}\n\n#if EIGEN_COMP_GNUC\n// template <> EIGEN_STRONG_INLINE Packet4f pmadd(const Packet4f&  a, const Packet4f&  b, const Packet4f&  c)\n// {\n//   Packet4f res = b;\n//   asm(\"mulps %[a], %[b] \\n\\taddps %[c], %[b]\" : [b] \"+x\" (res) : [a] \"x\" (a), [c] \"x\" (c));\n//   return res;\n// }\n// EIGEN_STRONG_INLINE Packet4i _mm_alignr_epi8(const Packet4i&  a, const Packet4i&  b, const int i)\n// {\n//   Packet4i res = a;\n//   asm(\"palignr %[i], %[a], %[b] \" : [b] \"+x\" (res) : [a] \"x\" (a), [i] \"i\" (i));\n//   return res;\n// }\n#endif\n\n#ifdef EIGEN_VECTORIZE_SSSE3\n// SSSE3 versions\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet4f>\n{\n  static EIGEN_STRONG_INLINE void run(Packet4f& first, const Packet4f& second)\n  {\n    if (Offset!=0)\n      first = _mm_castsi128_ps(_mm_alignr_epi8(_mm_castps_si128(second), _mm_castps_si128(first), Offset*4));\n  }\n};\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet4i>\n{\n  static EIGEN_STRONG_INLINE void run(Packet4i& first, const Packet4i& second)\n  {\n    if (Offset!=0)\n      first = _mm_alignr_epi8(second,first, Offset*4);\n  }\n};\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet2d>\n{\n  static EIGEN_STRONG_INLINE void run(Packet2d& first, const Packet2d& second)\n  {\n    if (Offset==1)\n      first = _mm_castsi128_pd(_mm_alignr_epi8(_mm_castpd_si128(second), _mm_castpd_si128(first), 8));\n  }\n};\n#else\n// SSE2 versions\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet4f>\n{\n  static EIGEN_STRONG_INLINE void run(Packet4f& first, const Packet4f& second)\n  {\n    if (Offset==1)\n    {\n      first = _mm_move_ss(first,second);\n      first = _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(first),0x39));\n    }\n    else if (Offset==2)\n    {\n      first = _mm_movehl_ps(first,first);\n      first = _mm_movelh_ps(first,second);\n    }\n    else if (Offset==3)\n    {\n      first = _mm_move_ss(first,second);\n      first = _mm_shuffle_ps(first,second,0x93);\n    }\n  }\n};\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet4i>\n{\n  static EIGEN_STRONG_INLINE void run(Packet4i& first, const Packet4i& second)\n  {\n    if (Offset==1)\n    {\n      first = _mm_castps_si128(_mm_move_ss(_mm_castsi128_ps(first),_mm_castsi128_ps(second)));\n      first = _mm_shuffle_epi32(first,0x39);\n    }\n    else if (Offset==2)\n    {\n      first = _mm_castps_si128(_mm_movehl_ps(_mm_castsi128_ps(first),_mm_castsi128_ps(first)));\n      first = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(first),_mm_castsi128_ps(second)));\n    }\n    else if (Offset==3)\n    {\n      first = _mm_castps_si128(_mm_move_ss(_mm_castsi128_ps(first),_mm_castsi128_ps(second)));\n      first = _mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(first),_mm_castsi128_ps(second),0x93));\n    }\n  }\n};\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet2d>\n{\n  static EIGEN_STRONG_INLINE void run(Packet2d& first, const Packet2d& second)\n  {\n    if (Offset==1)\n    {\n      first = _mm_castps_pd(_mm_movehl_ps(_mm_castpd_ps(first),_mm_castpd_ps(first)));\n      first = _mm_castps_pd(_mm_movelh_ps(_mm_castpd_ps(first),_mm_castpd_ps(second)));\n    }\n  }\n};\n#endif\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet4f,4>& kernel) {\n  _MM_TRANSPOSE4_PS(kernel.packet[0], kernel.packet[1], kernel.packet[2], kernel.packet[3]);\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet2d,2>& kernel) {\n  __m128d tmp = _mm_unpackhi_pd(kernel.packet[0], kernel.packet[1]);\n  kernel.packet[0] = _mm_unpacklo_pd(kernel.packet[0], kernel.packet[1]);\n  kernel.packet[1] = tmp;\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet4i,4>& kernel) {\n  __m128i T0 = _mm_unpacklo_epi32(kernel.packet[0], kernel.packet[1]);\n  __m128i T1 = _mm_unpacklo_epi32(kernel.packet[2], kernel.packet[3]);\n  __m128i T2 = _mm_unpackhi_epi32(kernel.packet[0], kernel.packet[1]);\n  __m128i T3 = _mm_unpackhi_epi32(kernel.packet[2], kernel.packet[3]);\n\n  kernel.packet[0] = _mm_unpacklo_epi64(T0, T1);\n  kernel.packet[1] = _mm_unpackhi_epi64(T0, T1);\n  kernel.packet[2] = _mm_unpacklo_epi64(T2, T3);\n  kernel.packet[3] = _mm_unpackhi_epi64(T2, T3);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pblend(const Selector<4>& ifPacket, const Packet4i& thenPacket, const Packet4i& elsePacket) {\n  const __m128i zero = _mm_setzero_si128();\n  const __m128i select = _mm_set_epi32(ifPacket.select[3], ifPacket.select[2], ifPacket.select[1], ifPacket.select[0]);\n  __m128i false_mask = _mm_cmpeq_epi32(select, zero);\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  return _mm_blendv_epi8(thenPacket, elsePacket, false_mask);\n#else\n  return _mm_or_si128(_mm_andnot_si128(false_mask, thenPacket), _mm_and_si128(false_mask, elsePacket));\n#endif\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4f pblend(const Selector<4>& ifPacket, const Packet4f& thenPacket, const Packet4f& elsePacket) {\n  const __m128 zero = _mm_setzero_ps();\n  const __m128 select = _mm_set_ps(ifPacket.select[3], ifPacket.select[2], ifPacket.select[1], ifPacket.select[0]);\n  __m128 false_mask = _mm_cmpeq_ps(select, zero);\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  return _mm_blendv_ps(thenPacket, elsePacket, false_mask);\n#else\n  return _mm_or_ps(_mm_andnot_ps(false_mask, thenPacket), _mm_and_ps(false_mask, elsePacket));\n#endif\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pblend(const Selector<2>& ifPacket, const Packet2d& thenPacket, const Packet2d& elsePacket) {\n  const __m128d zero = _mm_setzero_pd();\n  const __m128d select = _mm_set_pd(ifPacket.select[1], ifPacket.select[0]);\n  __m128d false_mask = _mm_cmpeq_pd(select, zero);\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  return _mm_blendv_pd(thenPacket, elsePacket, false_mask);\n#else\n  return _mm_or_pd(_mm_andnot_pd(false_mask, thenPacket), _mm_and_pd(false_mask, elsePacket));\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pinsertfirst(const Packet4f& a, float b)\n{\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  return _mm_blend_ps(a,pset1<Packet4f>(b),1);\n#else\n  return _mm_move_ss(a, _mm_load_ss(&b));\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pinsertfirst(const Packet2d& a, double b)\n{\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  return _mm_blend_pd(a,pset1<Packet2d>(b),1);\n#else\n  return _mm_move_sd(a, _mm_load_sd(&b));\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pinsertlast(const Packet4f& a, float b)\n{\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  return _mm_blend_ps(a,pset1<Packet4f>(b),(1<<3));\n#else\n  const Packet4f mask = _mm_castsi128_ps(_mm_setr_epi32(0x0,0x0,0x0,0xFFFFFFFF));\n  return _mm_or_ps(_mm_andnot_ps(mask, a), _mm_and_ps(mask, pset1<Packet4f>(b)));\n#endif\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pinsertlast(const Packet2d& a, double b)\n{\n#ifdef EIGEN_VECTORIZE_SSE4_1\n  return _mm_blend_pd(a,pset1<Packet2d>(b),(1<<1));\n#else\n  const Packet2d mask = _mm_castsi128_pd(_mm_setr_epi32(0x0,0x0,0xFFFFFFFF,0xFFFFFFFF));\n  return _mm_or_pd(_mm_andnot_pd(mask, a), _mm_and_pd(mask, pset1<Packet2d>(b)));\n#endif\n}\n\n// Scalar path for pmadd with FMA to ensure consistency with vectorized path.\n#ifdef __FMA__\ntemplate<> EIGEN_STRONG_INLINE float pmadd(const float& a, const float& b, const float& c) {\n  return ::fmaf(a,b,c);\n}\ntemplate<> EIGEN_STRONG_INLINE double pmadd(const double& a, const double& b, const double& c) {\n  return ::fma(a,b,c);\n}\n#endif\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_PACKET_MATH_SSE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/SSE/TypeCasting.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2015 Benoit Steiner <benoit.steiner.goog@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TYPE_CASTING_SSE_H\n#define EIGEN_TYPE_CASTING_SSE_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate <>\nstruct type_casting_traits<float, int> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 1\n  };\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pcast<Packet4f, Packet4i>(const Packet4f& a) {\n  return _mm_cvttps_epi32(a);\n}\n\n\ntemplate <>\nstruct type_casting_traits<int, float> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 1\n  };\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pcast<Packet4i, Packet4f>(const Packet4i& a) {\n  return _mm_cvtepi32_ps(a);\n}\n\n\ntemplate <>\nstruct type_casting_traits<double, float> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 2,\n    TgtCoeffRatio = 1\n  };\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pcast<Packet2d, Packet4f>(const Packet2d& a, const Packet2d& b) {\n  return _mm_shuffle_ps(_mm_cvtpd_ps(a), _mm_cvtpd_ps(b), (1 << 2) | (1 << 6));\n}\n\ntemplate <>\nstruct type_casting_traits<float, double> {\n  enum {\n    VectorizedCast = 1,\n    SrcCoeffRatio = 1,\n    TgtCoeffRatio = 2\n  };\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pcast<Packet4f, Packet2d>(const Packet4f& a) {\n  // Simply discard the second half of the input\n  return _mm_cvtps_pd(a);\n}\n\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TYPE_CASTING_SSE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/ZVector/Complex.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2016 Konstantinos Margaritis <markos@freevec.org>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COMPLEX32_ALTIVEC_H\n#define EIGEN_COMPLEX32_ALTIVEC_H\n\nnamespace Eigen {\n\nnamespace internal {\n\nstatic Packet2ul  p2ul_CONJ_XOR1 = (Packet2ul) vec_sld((Packet4ui) p2d_ZERO_, (Packet4ui) p2l_ZERO, 8);//{ 0x8000000000000000, 0x0000000000000000 };\nstatic Packet2ul  p2ul_CONJ_XOR2 = (Packet2ul) vec_sld((Packet4ui) p2l_ZERO,  (Packet4ui) p2d_ZERO_, 8);//{ 0x8000000000000000, 0x0000000000000000 };\n\nstruct Packet1cd\n{\n  EIGEN_STRONG_INLINE Packet1cd() {}\n  EIGEN_STRONG_INLINE explicit Packet1cd(const Packet2d& a) : v(a) {}\n  Packet2d v;\n};\n\nstruct Packet2cf\n{\n  EIGEN_STRONG_INLINE Packet2cf() {}\n  EIGEN_STRONG_INLINE explicit Packet2cf(const Packet4f& a) : v(a) {}\n  union {\n    Packet4f v;\n    Packet1cd cd[2];\n  };\n};\n\ntemplate<> struct packet_traits<std::complex<float> >  : default_packet_traits\n{\n  typedef Packet2cf type;\n  typedef Packet2cf half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 2,\n    HasHalfPacket = 0,\n\n    HasAdd    = 1,\n    HasSub    = 1,\n    HasMul    = 1,\n    HasDiv    = 1,\n    HasNegate = 1,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasBlend  = 1,\n    HasSetLinear = 0\n  };\n};\n\n\ntemplate<> struct packet_traits<std::complex<double> >  : default_packet_traits\n{\n  typedef Packet1cd type;\n  typedef Packet1cd half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 1,\n    HasHalfPacket = 0,\n\n    HasAdd    = 1,\n    HasSub    = 1,\n    HasMul    = 1,\n    HasDiv    = 1,\n    HasNegate = 1,\n    HasAbs    = 0,\n    HasAbs2   = 0,\n    HasMin    = 0,\n    HasMax    = 0,\n    HasSetLinear = 0\n  };\n};\n\ntemplate<> struct unpacket_traits<Packet2cf> { typedef std::complex<float>  type; enum {size=2, alignment=Aligned16}; typedef Packet2cf half; };\ntemplate<> struct unpacket_traits<Packet1cd> { typedef std::complex<double> type; enum {size=1, alignment=Aligned16}; typedef Packet1cd half; };\n\n/* Forward declaration */\nEIGEN_STRONG_INLINE void ptranspose(PacketBlock<Packet2cf,2>& kernel);\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pload <Packet2cf>(const std::complex<float>* from)  { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(pload<Packet4f>((const float*)from)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pload <Packet1cd>(const std::complex<double>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet1cd(pload<Packet2d>((const double*)from)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(const std::complex<float>* from)  { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ploadu<Packet4f>((const float*)from)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(const std::complex<double>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet1cd(ploadu<Packet2d>((const double*)from)); }\ntemplate<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> *     to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((float*)to, from.v); }\ntemplate<> EIGEN_STRONG_INLINE void pstore <std::complex<double> >(std::complex<double> *   to, const Packet1cd& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((double*)to, from.v); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> *     to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((float*)to, from.v); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex<double> *   to, const Packet1cd& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, from.v); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(const std::complex<double>&  from)\n{ /* here we really have to use unaligned loads :( */ return ploadu<Packet1cd>(&from); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>&  from)\n{\n  Packet2cf res;\n  res.cd[0] = Packet1cd(vec_ld2f((const float *)&from));\n  res.cd[1] = res.cd[0];\n  return res;\n}\ntemplate<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, Index stride)\n{\n  std::complex<float> EIGEN_ALIGN16 af[2];\n  af[0] = from[0*stride];\n  af[1] = from[1*stride];\n  return pload<Packet2cf>(af);\n}\ntemplate<> EIGEN_DEVICE_FUNC inline Packet1cd pgather<std::complex<double>, Packet1cd>(const std::complex<double>* from, Index stride EIGEN_UNUSED)\n{\n  return pload<Packet1cd>(from);\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, Index stride)\n{\n  std::complex<float> EIGEN_ALIGN16 af[2];\n  pstore<std::complex<float> >((std::complex<float> *) af, from);\n  to[0*stride] = af[0];\n  to[1*stride] = af[1];\n}\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to, const Packet1cd& from, Index stride EIGEN_UNUSED)\n{\n  pstore<std::complex<double> >(to, from);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(padd<Packet4f>(a.v, b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(a.v + b.v); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(psub<Packet4f>(a.v, b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(a.v - b.v); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pnegate(const Packet1cd& a) { return Packet1cd(pnegate(Packet2d(a.v))); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf& a) { return Packet2cf(pnegate(Packet4f(a.v))); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pconj(const Packet1cd& a) { return Packet1cd((Packet2d)vec_xor((Packet2d)a.v, (Packet2d)p2ul_CONJ_XOR2)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf& a)\n{\n  Packet2cf res;\n  res.v.v4f[0] = pconj(Packet1cd(reinterpret_cast<Packet2d>(a.v.v4f[0]))).v;\n  res.v.v4f[1] = pconj(Packet1cd(reinterpret_cast<Packet2d>(a.v.v4f[1]))).v;\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pmul<Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  Packet2d a_re, a_im, v1, v2;\n\n  // Permute and multiply the real parts of a and b\n  a_re = vec_perm(a.v, a.v, p16uc_PSET64_HI);\n  // Get the imaginary parts of a\n  a_im = vec_perm(a.v, a.v, p16uc_PSET64_LO);\n  // multiply a_re * b\n  v1 = vec_madd(a_re, b.v, p2d_ZERO);\n  // multiply a_im * b and get the conjugate result\n  v2 = vec_madd(a_im, b.v, p2d_ZERO);\n  v2 = (Packet2d) vec_sld((Packet4ui)v2, (Packet4ui)v2, 8);\n  v2 = (Packet2d) vec_xor((Packet2d)v2, (Packet2d) p2ul_CONJ_XOR1);\n\n  return Packet1cd(v1 + v2);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  Packet2cf res;\n  res.v.v4f[0] = pmul(Packet1cd(reinterpret_cast<Packet2d>(a.v.v4f[0])), Packet1cd(reinterpret_cast<Packet2d>(b.v.v4f[0]))).v;\n  res.v.v4f[1] = pmul(Packet1cd(reinterpret_cast<Packet2d>(a.v.v4f[1])), Packet1cd(reinterpret_cast<Packet2d>(b.v.v4f[1]))).v;\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pand   <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(vec_and(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pand   <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(pand<Packet4f>(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd por    <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(vec_or(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf por    <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(por<Packet4f>(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pxor   <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(vec_xor(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pxor   <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(pxor<Packet4f>(a.v,b.v)); }\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(vec_and(a.v, vec_nor(b.v,b.v))); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(pandnot<Packet4f>(a.v,b.v)); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(const std::complex<double>*     from) {  return pset1<Packet1cd>(*from); }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(const std::complex<float>*      from) {  return pset1<Packet2cf>(*from); }\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> *     addr) { EIGEN_ZVECTOR_PREFETCH(addr); }\ntemplate<> EIGEN_STRONG_INLINE void prefetch<std::complex<double> >(const std::complex<double> *   addr) { EIGEN_ZVECTOR_PREFETCH(addr); }\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double>  pfirst<Packet1cd>(const Packet1cd& a)\n{\n  std::complex<double> EIGEN_ALIGN16 res;\n  pstore<std::complex<double> >(&res, a);\n\n  return res;\n}\ntemplate<> EIGEN_STRONG_INLINE std::complex<float>  pfirst<Packet2cf>(const Packet2cf& a)\n{\n  std::complex<float> EIGEN_ALIGN16 res[2];\n  pstore<std::complex<float> >(res, a);\n\n  return res[0];\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd preverse(const Packet1cd& a) { return a; }\ntemplate<> EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf& a)\n{\n  Packet2cf res;\n  res.cd[0] = a.cd[1];\n  res.cd[1] = a.cd[0];\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(const Packet1cd& a)\n{\n  return pfirst(a);\n}\ntemplate<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(const Packet2cf& a)\n{\n  std::complex<float> res;\n  Packet1cd b = padd<Packet1cd>(a.cd[0], a.cd[1]);\n  vec_st2f(b.v, (float*)&res);\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd preduxp<Packet1cd>(const Packet1cd* vecs)\n{\n  return vecs[0];\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(const Packet2cf* vecs)\n{\n  PacketBlock<Packet2cf,2> transpose;\n  transpose.packet[0] = vecs[0];\n  transpose.packet[1] = vecs[1];\n  ptranspose(transpose);\n\n  return padd<Packet2cf>(transpose.packet[0], transpose.packet[1]);\n} \n\ntemplate<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(const Packet1cd& a)\n{\n  return pfirst(a);\n}\ntemplate<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(const Packet2cf& a)\n{\n  std::complex<float> res;\n  Packet1cd b = pmul<Packet1cd>(a.cd[0], a.cd[1]);\n  vec_st2f(b.v, (float*)&res);\n  return res;\n}\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet1cd>\n{\n  static EIGEN_STRONG_INLINE void run(Packet1cd& /*first*/, const Packet1cd& /*second*/)\n  {\n    // FIXME is it sure we never have to align a Packet1cd?\n    // Even though a std::complex<double> has 16 bytes, it is not necessarily aligned on a 16 bytes boundary...\n  }\n};\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet2cf>\n{\n  static EIGEN_STRONG_INLINE void run(Packet2cf& first, const Packet2cf& second)\n  {\n    if (Offset == 1) {\n      first.cd[0] = first.cd[1];\n      first.cd[1] = second.cd[0];\n    }\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, false,true>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    return internal::pmul(a, pconj(b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, true,false>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    return internal::pmul(pconj(a), b);\n  }\n};\n\ntemplate<> struct conj_helper<Packet1cd, Packet1cd, true,true>\n{\n  EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const\n  {\n    return pconj(internal::pmul(a, b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, false,true>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    return internal::pmul(a, pconj(b));\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, true,false>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    return internal::pmul(pconj(a), b);\n  }\n};\n\ntemplate<> struct conj_helper<Packet2cf, Packet2cf, true,true>\n{\n  EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const\n  { return padd(pmul(x,y),c); }\n\n  EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n  {\n    return pconj(internal::pmul(a, b));\n  }\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(const Packet1cd& a, const Packet1cd& b)\n{\n  // TODO optimize it for AltiVec\n  Packet1cd res = conj_helper<Packet1cd,Packet1cd,false,true>().pmul(a,b);\n  Packet2d s = vec_madd(b.v, b.v, p2d_ZERO_);\n  return Packet1cd(pdiv(res.v, s + vec_perm(s, s, p16uc_REVERSE64)));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b)\n{\n  // TODO optimize it for AltiVec\n  Packet2cf res;\n  res.cd[0] = pdiv<Packet1cd>(a.cd[0], b.cd[0]);\n  res.cd[1] = pdiv<Packet1cd>(a.cd[1], b.cd[1]);\n  return res;\n}\n\nEIGEN_STRONG_INLINE Packet1cd pcplxflip/*<Packet1cd>*/(const Packet1cd& x)\n{\n  return Packet1cd(preverse(Packet2d(x.v)));\n}\n\nEIGEN_STRONG_INLINE Packet2cf pcplxflip/*<Packet2cf>*/(const Packet2cf& x)\n{\n  Packet2cf res;\n  res.cd[0] = pcplxflip(x.cd[0]);\n  res.cd[1] = pcplxflip(x.cd[1]);\n  return res;\n}\n\nEIGEN_STRONG_INLINE void ptranspose(PacketBlock<Packet1cd,2>& kernel)\n{\n  Packet2d tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);\n  kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);\n  kernel.packet[0].v = tmp;\n}\n\nEIGEN_STRONG_INLINE void ptranspose(PacketBlock<Packet2cf,2>& kernel)\n{\n  Packet1cd tmp = kernel.packet[0].cd[1];\n  kernel.packet[0].cd[1] = kernel.packet[1].cd[0];\n  kernel.packet[1].cd[0] = tmp;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2cf pblend(const Selector<2>& ifPacket, const Packet2cf& thenPacket, const Packet2cf& elsePacket) {\n  Packet2cf result;\n  const Selector<4> ifPacket4 = { ifPacket.select[0], ifPacket.select[0], ifPacket.select[1], ifPacket.select[1] };\n  result.v = pblend<Packet4f>(ifPacket4, thenPacket.v, elsePacket.v);\n  return result;\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_COMPLEX32_ALTIVEC_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/ZVector/MathFunctions.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2007 Julien Pommier\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2016 Konstantinos Margaritis <markos@freevec.org>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* The sin, cos, exp, and log functions of this file come from\n * Julien Pommier's sse math library: http://gruntthepeon.free.fr/ssemath/\n */\n\n#ifndef EIGEN_MATH_FUNCTIONS_ALTIVEC_H\n#define EIGEN_MATH_FUNCTIONS_ALTIVEC_H\n\nnamespace Eigen {\n\nnamespace internal {\n\nstatic _EIGEN_DECLARE_CONST_Packet2d(1 , 1.0);\nstatic _EIGEN_DECLARE_CONST_Packet2d(2 , 2.0);\nstatic _EIGEN_DECLARE_CONST_Packet2d(half, 0.5);\n\nstatic _EIGEN_DECLARE_CONST_Packet2d(exp_hi,  709.437);\nstatic _EIGEN_DECLARE_CONST_Packet2d(exp_lo, -709.436139303);\n\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_LOG2EF, 1.4426950408889634073599);\n\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_p0, 1.26177193074810590878e-4);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_p1, 3.02994407707441961300e-2);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_p2, 9.99999999999999999910e-1);\n\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q0, 3.00198505138664455042e-6);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q1, 2.52448340349684104192e-3);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q2, 2.27265548208155028766e-1);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_q3, 2.00000000000000000009e0);\n\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_C1, 0.693145751953125);\nstatic _EIGEN_DECLARE_CONST_Packet2d(cephes_exp_C2, 1.42860682030941723212e-6);\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket2d pexp<Packet2d>(const Packet2d& _x)\n{\n  Packet2d x = _x;\n\n  Packet2d tmp, fx;\n  Packet2l emm0;\n\n  // clamp x\n  x = pmax(pmin(x, p2d_exp_hi), p2d_exp_lo);\n  /* express exp(x) as exp(g + n*log(2)) */\n  fx = pmadd(p2d_cephes_LOG2EF, x, p2d_half);\n\n  fx = vec_floor(fx);\n\n  tmp = pmul(fx, p2d_cephes_exp_C1);\n  Packet2d z = pmul(fx, p2d_cephes_exp_C2);\n  x = psub(x, tmp);\n  x = psub(x, z);\n\n  Packet2d x2 = pmul(x,x);\n\n  Packet2d px = p2d_cephes_exp_p0;\n  px = pmadd(px, x2, p2d_cephes_exp_p1);\n  px = pmadd(px, x2, p2d_cephes_exp_p2);\n  px = pmul (px, x);\n\n  Packet2d qx = p2d_cephes_exp_q0;\n  qx = pmadd(qx, x2, p2d_cephes_exp_q1);\n  qx = pmadd(qx, x2, p2d_cephes_exp_q2);\n  qx = pmadd(qx, x2, p2d_cephes_exp_q3);\n\n  x = pdiv(px,psub(qx,px));\n  x = pmadd(p2d_2,x,p2d_1);\n\n  // build 2^n\n  emm0 = vec_ctsl(fx, 0);\n\n  static const Packet2l p2l_1023 = { 1023, 1023 };\n  static const Packet2ul p2ul_52 = { 52, 52 };\n\n  emm0 = emm0 + p2l_1023;\n  emm0 = emm0 << reinterpret_cast<Packet2l>(p2ul_52);\n\n  // Altivec's max & min operators just drop silent NaNs. Check NaNs in \n  // inputs and return them unmodified.\n  Packet2ul isnumber_mask = reinterpret_cast<Packet2ul>(vec_cmpeq(_x, _x));\n  return vec_sel(_x, pmax(pmul(x, reinterpret_cast<Packet2d>(emm0)), _x),\n                 isnumber_mask);\n}\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f pexp<Packet4f>(const Packet4f& x)\n{\n  Packet4f res;\n  res.v4f[0] = pexp<Packet2d>(x.v4f[0]);\n  res.v4f[1] = pexp<Packet2d>(x.v4f[1]);\n  return res;\n}\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket2d psqrt<Packet2d>(const Packet2d& x)\n{\n  return  __builtin_s390_vfsqdb(x);\n}\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f psqrt<Packet4f>(const Packet4f& x)\n{\n  Packet4f res;\n  res.v4f[0] = psqrt<Packet2d>(x.v4f[0]);\n  res.v4f[1] = psqrt<Packet2d>(x.v4f[1]);\n  return res;\n}\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket2d prsqrt<Packet2d>(const Packet2d& x) {\n  // Unfortunately we can't use the much faster mm_rqsrt_pd since it only provides an approximation.\n  return pset1<Packet2d>(1.0) / psqrt<Packet2d>(x);\n}\n\ntemplate<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED\nPacket4f prsqrt<Packet4f>(const Packet4f& x) {\n  Packet4f res;\n  res.v4f[0] = prsqrt<Packet2d>(x.v4f[0]);\n  res.v4f[1] = prsqrt<Packet2d>(x.v4f[1]);\n  return res;\n}\n\n}  // end namespace internal\n\n}  // end namespace Eigen\n\n#endif  // EIGEN_MATH_FUNCTIONS_ALTIVEC_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/arch/ZVector/PacketMath.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2016 Konstantinos Margaritis <markos@freevec.org>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PACKET_MATH_ZVECTOR_H\n#define EIGEN_PACKET_MATH_ZVECTOR_H\n\n#include <stdint.h>\n\nnamespace Eigen {\n\nnamespace internal {\n\n#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD\n#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 4\n#endif\n\n#ifndef EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n#define EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n#endif\n\n#ifndef EIGEN_HAS_SINGLE_INSTRUCTION_CJMADD\n#define EIGEN_HAS_SINGLE_INSTRUCTION_CJMADD\n#endif\n\n#ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS\n#define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS  16\n#endif\n\ntypedef __vector int                 Packet4i;\ntypedef __vector unsigned int        Packet4ui;\ntypedef __vector __bool int          Packet4bi;\ntypedef __vector short int           Packet8i;\ntypedef __vector unsigned char       Packet16uc;\ntypedef __vector double              Packet2d;\ntypedef __vector unsigned long long  Packet2ul;\ntypedef __vector long long           Packet2l;\n\ntypedef struct {\n\tPacket2d  v4f[2];\n} Packet4f;\n\ntypedef union {\n  int32_t   i[4];\n  uint32_t ui[4];\n  int64_t   l[2];\n  uint64_t ul[2];\n  double    d[2];\n  Packet4i  v4i;\n  Packet4ui v4ui;\n  Packet2l  v2l;\n  Packet2ul v2ul;\n  Packet2d  v2d;\n} Packet;\n\n// We don't want to write the same code all the time, but we need to reuse the constants\n// and it doesn't really work to declare them global, so we define macros instead\n\n#define _EIGEN_DECLARE_CONST_FAST_Packet4i(NAME,X) \\\n  Packet4i p4i_##NAME = reinterpret_cast<Packet4i>(vec_splat_s32(X))\n\n#define _EIGEN_DECLARE_CONST_FAST_Packet2d(NAME,X) \\\n  Packet2d p2d_##NAME = reinterpret_cast<Packet2d>(vec_splat_s64(X))\n\n#define _EIGEN_DECLARE_CONST_FAST_Packet2l(NAME,X) \\\n  Packet2l p2l_##NAME = reinterpret_cast<Packet2l>(vec_splat_s64(X))\n\n#define _EIGEN_DECLARE_CONST_Packet4i(NAME,X) \\\n  Packet4i p4i_##NAME = pset1<Packet4i>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet2d(NAME,X) \\\n  Packet2d p2d_##NAME = pset1<Packet2d>(X)\n\n#define _EIGEN_DECLARE_CONST_Packet2l(NAME,X) \\\n  Packet2l p2l_##NAME = pset1<Packet2l>(X)\n\n// These constants are endian-agnostic\n//static _EIGEN_DECLARE_CONST_FAST_Packet4i(ZERO, 0); //{ 0, 0, 0, 0,}\nstatic _EIGEN_DECLARE_CONST_FAST_Packet4i(ONE, 1); //{ 1, 1, 1, 1}\n\nstatic _EIGEN_DECLARE_CONST_FAST_Packet2d(ZERO, 0);\nstatic _EIGEN_DECLARE_CONST_FAST_Packet2l(ZERO, 0);\nstatic _EIGEN_DECLARE_CONST_FAST_Packet2l(ONE, 1);\n\nstatic Packet2d p2d_ONE = { 1.0, 1.0 }; \nstatic Packet2d p2d_ZERO_ = { -0.0, -0.0 };\n\nstatic Packet4i p4i_COUNTDOWN = { 0, 1, 2, 3 };\nstatic Packet4f p4f_COUNTDOWN = { 0.0, 1.0, 2.0, 3.0 };\nstatic Packet2d p2d_COUNTDOWN = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet16uc>(p2d_ZERO), reinterpret_cast<Packet16uc>(p2d_ONE), 8));\n\nstatic Packet16uc p16uc_PSET64_HI = { 0,1,2,3, 4,5,6,7, 0,1,2,3, 4,5,6,7 };\nstatic Packet16uc p16uc_DUPLICATE32_HI = { 0,1,2,3, 0,1,2,3, 4,5,6,7, 4,5,6,7 };\n\n// Mask alignment\n#define _EIGEN_MASK_ALIGNMENT\t0xfffffffffffffff0\n\n#define _EIGEN_ALIGNED_PTR(x)\t((std::ptrdiff_t)(x) & _EIGEN_MASK_ALIGNMENT)\n\n// Handle endianness properly while loading constants\n// Define global static constants:\n\nstatic Packet16uc p16uc_FORWARD =   { 0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15 };\nstatic Packet16uc p16uc_REVERSE32 = { 12,13,14,15, 8,9,10,11, 4,5,6,7, 0,1,2,3 };\nstatic Packet16uc p16uc_REVERSE64 = { 8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7 };\n\nstatic Packet16uc p16uc_PSET32_WODD   = vec_sld((Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 0), (Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 2), 8);//{ 0,1,2,3, 0,1,2,3, 8,9,10,11, 8,9,10,11 };\nstatic Packet16uc p16uc_PSET32_WEVEN  = vec_sld(p16uc_DUPLICATE32_HI, (Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 3), 8);//{ 4,5,6,7, 4,5,6,7, 12,13,14,15, 12,13,14,15 };\n/*static Packet16uc p16uc_HALF64_0_16 = vec_sld((Packet16uc)p4i_ZERO, vec_splat((Packet16uc) vec_abs(p4i_MINUS16), 3), 8);      //{ 0,0,0,0, 0,0,0,0, 16,16,16,16, 16,16,16,16};\n\nstatic Packet16uc p16uc_PSET64_HI = (Packet16uc) vec_mergeh((Packet4ui)p16uc_PSET32_WODD, (Packet4ui)p16uc_PSET32_WEVEN);     //{ 0,1,2,3, 4,5,6,7, 0,1,2,3, 4,5,6,7 };*/\nstatic Packet16uc p16uc_PSET64_LO = (Packet16uc) vec_mergel((Packet4ui)p16uc_PSET32_WODD, (Packet4ui)p16uc_PSET32_WEVEN);     //{ 8,9,10,11, 12,13,14,15, 8,9,10,11, 12,13,14,15 };\n/*static Packet16uc p16uc_TRANSPOSE64_HI = vec_add(p16uc_PSET64_HI, p16uc_HALF64_0_16);                                         //{ 0,1,2,3, 4,5,6,7, 16,17,18,19, 20,21,22,23};\nstatic Packet16uc p16uc_TRANSPOSE64_LO = vec_add(p16uc_PSET64_LO, p16uc_HALF64_0_16);                                         //{ 8,9,10,11, 12,13,14,15, 24,25,26,27, 28,29,30,31};*/\nstatic Packet16uc p16uc_TRANSPOSE64_HI = { 0,1,2,3, 4,5,6,7, 16,17,18,19, 20,21,22,23};\nstatic Packet16uc p16uc_TRANSPOSE64_LO = { 8,9,10,11, 12,13,14,15, 24,25,26,27, 28,29,30,31};\n\n//static Packet16uc p16uc_COMPLEX32_REV = vec_sld(p16uc_REVERSE32, p16uc_REVERSE32, 8);                                         //{ 4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11 };\n\n//static Packet16uc p16uc_COMPLEX32_REV2 = vec_sld(p16uc_FORWARD, p16uc_FORWARD, 8);                                            //{ 8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7 };\n\n\n#if EIGEN_HAS_BUILTIN(__builtin_prefetch) || EIGEN_COMP_GNUC\n  #define EIGEN_ZVECTOR_PREFETCH(ADDR) __builtin_prefetch(ADDR);\n#else\n  #define EIGEN_ZVECTOR_PREFETCH(ADDR) asm( \"   pfd [%[addr]]\\n\" :: [addr] \"r\" (ADDR) : \"cc\" );\n#endif\n\ntemplate<> struct packet_traits<int>    : default_packet_traits\n{\n  typedef Packet4i type;\n  typedef Packet4i half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size = 4,\n    HasHalfPacket = 0,\n\n    HasAdd  = 1,\n    HasSub  = 1,\n    HasMul  = 1,\n    HasDiv  = 1,\n    HasBlend = 1\n  };\n};\n\ntemplate<> struct packet_traits<float> : default_packet_traits\n{\n  typedef Packet4f type;\n  typedef Packet4f half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=4,\n    HasHalfPacket = 0,\n\n    HasAdd  = 1,\n    HasSub  = 1,\n    HasMul  = 1,\n    HasDiv  = 1,\n    HasMin  = 1,\n    HasMax  = 1,\n    HasAbs  = 1,\n    HasSin  = 0,\n    HasCos  = 0,\n    HasLog  = 0,\n    HasExp  = 1,\n    HasSqrt = 1,\n    HasRsqrt = 1,\n    HasRound = 1,\n    HasFloor = 1,\n    HasCeil = 1,\n    HasNegate = 1,\n    HasBlend = 1\n  };\n};\n\ntemplate<> struct packet_traits<double> : default_packet_traits\n{\n  typedef Packet2d type;\n  typedef Packet2d half;\n  enum {\n    Vectorizable = 1,\n    AlignedOnScalar = 1,\n    size=2,\n    HasHalfPacket = 1,\n\n    HasAdd  = 1,\n    HasSub  = 1,\n    HasMul  = 1,\n    HasDiv  = 1,\n    HasMin  = 1,\n    HasMax  = 1,\n    HasAbs  = 1,\n    HasSin  = 0,\n    HasCos  = 0,\n    HasLog  = 0,\n    HasExp  = 1,\n    HasSqrt = 1,\n    HasRsqrt = 1,\n    HasRound = 1,\n    HasFloor = 1,\n    HasCeil = 1,\n    HasNegate = 1,\n    HasBlend = 1\n  };\n};\n\ntemplate<> struct unpacket_traits<Packet4i> { typedef int    type; enum {size=4, alignment=Aligned16}; typedef Packet4i half; };\ntemplate<> struct unpacket_traits<Packet4f> { typedef float  type; enum {size=4, alignment=Aligned16}; typedef Packet4f half; };\ntemplate<> struct unpacket_traits<Packet2d> { typedef double type; enum {size=2, alignment=Aligned16}; typedef Packet2d half; };\n\n/* Forward declaration */\nEIGEN_DEVICE_FUNC inline void ptranspose(PacketBlock<Packet4f,4>& kernel);\n \ninline std::ostream & operator <<(std::ostream & s, const Packet4i & v)\n{\n  Packet vt;\n  vt.v4i = v;\n  s << vt.i[0] << \", \" << vt.i[1] << \", \" << vt.i[2] << \", \" << vt.i[3];\n  return s;\n}\n\ninline std::ostream & operator <<(std::ostream & s, const Packet4ui & v)\n{\n  Packet vt;\n  vt.v4ui = v;\n  s << vt.ui[0] << \", \" << vt.ui[1] << \", \" << vt.ui[2] << \", \" << vt.ui[3];\n  return s;\n}\n\ninline std::ostream & operator <<(std::ostream & s, const Packet2l & v)\n{\n  Packet vt;\n  vt.v2l = v;\n  s << vt.l[0] << \", \" << vt.l[1];\n  return s;\n}\n\ninline std::ostream & operator <<(std::ostream & s, const Packet2ul & v)\n{\n  Packet vt;\n  vt.v2ul = v;\n  s << vt.ul[0] << \", \" << vt.ul[1] ;\n  return s;\n}\n\ninline std::ostream & operator <<(std::ostream & s, const Packet2d & v)\n{\n  Packet vt;\n  vt.v2d = v;\n  s << vt.d[0] << \", \" << vt.d[1];\n  return s;\n}\n\n/* Helper function to simulate a vec_splat_packet4f\n */\ntemplate<int element> EIGEN_STRONG_INLINE Packet4f vec_splat_packet4f(const Packet4f&   from)\n{\n  Packet4f splat;\n  switch (element) {\n  case 0:\n    splat.v4f[0] = vec_splat(from.v4f[0], 0);\n    splat.v4f[1] = splat.v4f[0];\n    break;\n  case 1:\n    splat.v4f[0] = vec_splat(from.v4f[0], 1);\n    splat.v4f[1] = splat.v4f[0];\n    break;\n  case 2:\n    splat.v4f[0] = vec_splat(from.v4f[1], 0);\n    splat.v4f[1] = splat.v4f[0];\n    break;\n  case 3:\n    splat.v4f[0] = vec_splat(from.v4f[1], 1);\n    splat.v4f[1] = splat.v4f[0];\n    break;\n  }\n  return splat;\n}\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet4i>\n{\n  static EIGEN_STRONG_INLINE void run(Packet4i& first, const Packet4i& second)\n  {\n    switch (Offset % 4) {\n    case 1:\n      first = vec_sld(first, second, 4); break;\n    case 2:\n      first = vec_sld(first, second, 8); break;\n    case 3:\n      first = vec_sld(first, second, 12); break;\n    }\n  }\n};\n\n/* This is a tricky one, we have to translate float alignment to vector elements of sizeof double\n */\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet4f>\n{\n  static EIGEN_STRONG_INLINE void run(Packet4f& first, const Packet4f& second)\n  {\n    switch (Offset % 4) {\n    case 1:\n      first.v4f[0] = vec_sld(first.v4f[0], first.v4f[1], 8);\n      first.v4f[1] = vec_sld(first.v4f[1], second.v4f[0], 8);\n      break;\n    case 2:\n      first.v4f[0] = first.v4f[1];\n      first.v4f[1] = second.v4f[0];\n      break;\n    case 3:\n      first.v4f[0] = vec_sld(first.v4f[1],  second.v4f[0], 8);\n      first.v4f[1] = vec_sld(second.v4f[0], second.v4f[1], 8);\n      break;\n    }\n  }\n};\n\n\ntemplate<int Offset>\nstruct palign_impl<Offset,Packet2d>\n{\n  static EIGEN_STRONG_INLINE void run(Packet2d& first, const Packet2d& second)\n  {\n    if (Offset == 1)\n      first = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4i>(first), reinterpret_cast<Packet4i>(second), 8));\n  }\n};\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pload<Packet4i>(const int*     from)\n{\n  // FIXME: No intrinsic yet\n  EIGEN_DEBUG_ALIGNED_LOAD\n  Packet *vfrom;\n  vfrom = (Packet *) from;\n  return vfrom->v4i;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pload<Packet4f>(const float*   from)\n{\n  // FIXME: No intrinsic yet\n  EIGEN_DEBUG_ALIGNED_LOAD\n  Packet4f vfrom;\n  vfrom.v4f[0] = vec_ld2f(&from[0]);\n  vfrom.v4f[1] = vec_ld2f(&from[2]);\n  return vfrom;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pload<Packet2d>(const double* from)\n{\n  // FIXME: No intrinsic yet\n  EIGEN_DEBUG_ALIGNED_LOAD\n  Packet *vfrom;\n  vfrom = (Packet *) from;\n  return vfrom->v2d;\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<int>(int*       to, const Packet4i& from)\n{\n  // FIXME: No intrinsic yet\n  EIGEN_DEBUG_ALIGNED_STORE\n  Packet *vto;\n  vto = (Packet *) to;\n  vto->v4i = from;\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<float>(float*   to, const Packet4f& from)\n{\n  // FIXME: No intrinsic yet\n  EIGEN_DEBUG_ALIGNED_STORE\n  vec_st2f(from.v4f[0], &to[0]);\n  vec_st2f(from.v4f[1], &to[2]);\n}\n\n\ntemplate<> EIGEN_STRONG_INLINE void pstore<double>(double*   to, const Packet2d& from)\n{\n  // FIXME: No intrinsic yet\n  EIGEN_DEBUG_ALIGNED_STORE\n  Packet *vto;\n  vto = (Packet *) to;\n  vto->v2d = from;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(const int&    from)\n{\n  return vec_splats(from);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pset1<Packet2d>(const double& from) {\n  return vec_splats(from);\n}\ntemplate<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float&    from)\n{\n  Packet4f to;\n  to.v4f[0] = pset1<Packet2d>(static_cast<const double&>(from));\n  to.v4f[1] = to.v4f[0];\n  return to;\n}\n\ntemplate<> EIGEN_STRONG_INLINE void\npbroadcast4<Packet4i>(const int *a,\n                      Packet4i& a0, Packet4i& a1, Packet4i& a2, Packet4i& a3)\n{\n  a3 = pload<Packet4i>(a);\n  a0 = vec_splat(a3, 0);\n  a1 = vec_splat(a3, 1);\n  a2 = vec_splat(a3, 2);\n  a3 = vec_splat(a3, 3);\n}\n\ntemplate<> EIGEN_STRONG_INLINE void\npbroadcast4<Packet4f>(const float *a,\n                      Packet4f& a0, Packet4f& a1, Packet4f& a2, Packet4f& a3)\n{\n  a3 = pload<Packet4f>(a);\n  a0 = vec_splat_packet4f<0>(a3);\n  a1 = vec_splat_packet4f<1>(a3);\n  a2 = vec_splat_packet4f<2>(a3);\n  a3 = vec_splat_packet4f<3>(a3);\n}\n\ntemplate<> EIGEN_STRONG_INLINE void\npbroadcast4<Packet2d>(const double *a,\n                      Packet2d& a0, Packet2d& a1, Packet2d& a2, Packet2d& a3)\n{\n  a1 = pload<Packet2d>(a);\n  a0 = vec_splat(a1, 0);\n  a1 = vec_splat(a1, 1);\n  a3 = pload<Packet2d>(a+2);\n  a2 = vec_splat(a3, 0);\n  a3 = vec_splat(a3, 1);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, Index stride)\n{\n  int EIGEN_ALIGN16 ai[4];\n  ai[0] = from[0*stride];\n  ai[1] = from[1*stride];\n  ai[2] = from[2*stride];\n  ai[3] = from[3*stride];\n return pload<Packet4i>(ai);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, Index stride)\n{\n  float EIGEN_ALIGN16 ai[4];\n  ai[0] = from[0*stride];\n  ai[1] = from[1*stride];\n  ai[2] = from[2*stride];\n  ai[3] = from[3*stride];\n return pload<Packet4f>(ai);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, Index stride)\n{\n  double EIGEN_ALIGN16 af[2];\n  af[0] = from[0*stride];\n  af[1] = from[1*stride];\n return pload<Packet2d>(af);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, Index stride)\n{\n  int EIGEN_ALIGN16 ai[4];\n  pstore<int>((int *)ai, from);\n  to[0*stride] = ai[0];\n  to[1*stride] = ai[1];\n  to[2*stride] = ai[2];\n  to[3*stride] = ai[3];\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, Index stride)\n{\n  float EIGEN_ALIGN16 ai[4];\n  pstore<float>((float *)ai, from);\n  to[0*stride] = ai[0];\n  to[1*stride] = ai[1];\n  to[2*stride] = ai[2];\n  to[3*stride] = ai[3];\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, Index stride)\n{\n  double EIGEN_ALIGN16 af[2];\n  pstore<double>(af, from);\n  to[0*stride] = af[0];\n  to[1*stride] = af[1];\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i padd<Packet4i>(const Packet4i& a, const Packet4i& b) { return (a + b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f padd<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  Packet4f c;\n  c.v4f[0] = a.v4f[0] + b.v4f[0];\n  c.v4f[1] = a.v4f[1] + b.v4f[1];\n  return c;\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d padd<Packet2d>(const Packet2d& a, const Packet2d& b) { return (a + b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i psub<Packet4i>(const Packet4i& a, const Packet4i& b) { return (a - b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f psub<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  Packet4f c;\n  c.v4f[0] = a.v4f[0] - b.v4f[0];\n  c.v4f[1] = a.v4f[1] - b.v4f[1];\n  return c;\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d psub<Packet2d>(const Packet2d& a, const Packet2d& b) { return (a - b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmul<Packet4i>(const Packet4i& a, const Packet4i& b) { return (a * b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmul<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  Packet4f c;\n  c.v4f[0] = a.v4f[0] * b.v4f[0];\n  c.v4f[1] = a.v4f[1] * b.v4f[1];\n  return c;\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmul<Packet2d>(const Packet2d& a, const Packet2d& b) { return (a * b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pdiv<Packet4i>(const Packet4i& a, const Packet4i& b) { return (a / b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pdiv<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  Packet4f c;\n  c.v4f[0] = a.v4f[0] / b.v4f[0];\n  c.v4f[1] = a.v4f[1] / b.v4f[1];\n  return c;\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pdiv<Packet2d>(const Packet2d& a, const Packet2d& b) { return (a / b); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pnegate(const Packet4i& a) { return (-a); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pnegate(const Packet4f& a)\n{\n  Packet4f c;\n  c.v4f[0] = -a.v4f[0];\n  c.v4f[1] = -a.v4f[1];\n  return c;\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pnegate(const Packet2d& a) { return (-a); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pconj(const Packet4i& a) { return a; }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pconj(const Packet4f& a) { return a; }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pconj(const Packet2d& a) { return a; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmadd(const Packet4i& a, const Packet4i& b, const Packet4i& c) { return padd<Packet4i>(pmul<Packet4i>(a, b), c); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmadd(const Packet4f& a, const Packet4f& b, const Packet4f& c)\n{\n  Packet4f res;\n  res.v4f[0] = vec_madd(a.v4f[0], b.v4f[0], c.v4f[0]);\n  res.v4f[1] = vec_madd(a.v4f[1], b.v4f[1], c.v4f[1]);\n  return res;\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmadd(const Packet2d& a, const Packet2d& b, const Packet2d& c) { return vec_madd(a, b, c); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i plset<Packet4i>(const int& a)    { return padd<Packet4i>(pset1<Packet4i>(a), p4i_COUNTDOWN); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f plset<Packet4f>(const float& a)  { return padd<Packet4f>(pset1<Packet4f>(a), p4f_COUNTDOWN); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d plset<Packet2d>(const double& a) { return padd<Packet2d>(pset1<Packet2d>(a), p2d_COUNTDOWN); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmin<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_min(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmin<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_min(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmin<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  Packet4f res;\n  res.v4f[0] = pmin(a.v4f[0], b.v4f[0]);\n  res.v4f[1] = pmin(a.v4f[1], b.v4f[1]);\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pmax<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_max(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pmax<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_max(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pmax<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  Packet4f res;\n  res.v4f[0] = pmax(a.v4f[0], b.v4f[0]);\n  res.v4f[1] = pmax(a.v4f[1], b.v4f[1]);\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pand<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_and(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pand<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_and(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pand<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  Packet4f res;\n  res.v4f[0] = pand(a.v4f[0], b.v4f[0]);\n  res.v4f[1] = pand(a.v4f[1], b.v4f[1]);\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i por<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_or(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d por<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_or(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f por<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  Packet4f res;\n  res.v4f[0] = pand(a.v4f[0], b.v4f[0]);\n  res.v4f[1] = pand(a.v4f[1], b.v4f[1]);\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pxor<Packet4i>(const Packet4i& a, const Packet4i& b) { return vec_xor(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pxor<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_xor(a, b); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pxor<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  Packet4f res;\n  res.v4f[0] = pand(a.v4f[0], b.v4f[0]);\n  res.v4f[1] = pand(a.v4f[1], b.v4f[1]);\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return pand<Packet4i>(a, vec_nor(b, b)); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pandnot<Packet2d>(const Packet2d& a, const Packet2d& b) { return vec_and(a, vec_nor(b, b)); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pandnot<Packet4f>(const Packet4f& a, const Packet4f& b)\n{\n  Packet4f res;\n  res.v4f[0] = pandnot(a.v4f[0], b.v4f[0]);\n  res.v4f[1] = pandnot(a.v4f[1], b.v4f[1]);\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pround<Packet4f>(const Packet4f& a)\n{\n  Packet4f res;\n  res.v4f[0] = vec_round(a.v4f[0]);\n  res.v4f[1] = vec_round(a.v4f[1]);\n  return res;\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pround<Packet2d>(const Packet2d& a) { return vec_round(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pceil<Packet4f>(const  Packet4f& a)\n{\n  Packet4f res;\n  res.v4f[0] = vec_ceil(a.v4f[0]);\n  res.v4f[1] = vec_ceil(a.v4f[1]);\n  return res;\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pceil<Packet2d>(const  Packet2d& a) { return vec_ceil(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pfloor<Packet4f>(const Packet4f& a)\n{\n  Packet4f res;\n  res.v4f[0] = vec_floor(a.v4f[0]);\n  res.v4f[1] = vec_floor(a.v4f[1]);\n  return res;\n}\ntemplate<> EIGEN_STRONG_INLINE Packet2d pfloor<Packet2d>(const Packet2d& a) { return vec_floor(a); }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i ploadu<Packet4i>(const int*       from) { return pload<Packet4i>(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(const float*     from) { return pload<Packet4f>(from); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d ploadu<Packet2d>(const double*    from) { return pload<Packet2d>(from); }\n\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i ploaddup<Packet4i>(const int*     from)\n{\n  Packet4i p = pload<Packet4i>(from);\n  return vec_perm(p, p, p16uc_DUPLICATE32_HI);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f ploaddup<Packet4f>(const float*    from)\n{\n  Packet4f p = pload<Packet4f>(from);\n  p.v4f[1] = vec_splat(p.v4f[0], 1);\n  p.v4f[0] = vec_splat(p.v4f[0], 0);\n  return p;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d ploaddup<Packet2d>(const double*   from)\n{\n  Packet2d p = pload<Packet2d>(from);\n  return vec_perm(p, p, p16uc_PSET64_HI);\n}\n\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<int>(int*        to, const Packet4i& from) { pstore<int>(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<float>(float*    to, const Packet4f& from) { pstore<float>(to, from); }\ntemplate<> EIGEN_STRONG_INLINE void pstoreu<double>(double*  to, const Packet2d& from) { pstore<double>(to, from); }\n\ntemplate<> EIGEN_STRONG_INLINE void prefetch<int>(const int*       addr) { EIGEN_ZVECTOR_PREFETCH(addr); }\ntemplate<> EIGEN_STRONG_INLINE void prefetch<float>(const float*   addr) { EIGEN_ZVECTOR_PREFETCH(addr); }\ntemplate<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { EIGEN_ZVECTOR_PREFETCH(addr); }\n\ntemplate<> EIGEN_STRONG_INLINE int    pfirst<Packet4i>(const Packet4i& a) { int    EIGEN_ALIGN16 x[4]; pstore(x, a); return x[0]; }\ntemplate<> EIGEN_STRONG_INLINE float  pfirst<Packet4f>(const Packet4f& a) { float  EIGEN_ALIGN16 x[2]; vec_st2f(a.v4f[0], &x[0]); return x[0]; }\ntemplate<> EIGEN_STRONG_INLINE double pfirst<Packet2d>(const Packet2d& a) { double EIGEN_ALIGN16 x[2]; pstore(x, a); return x[0]; }\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i preverse(const Packet4i& a)\n{\n  return reinterpret_cast<Packet4i>(vec_perm(reinterpret_cast<Packet16uc>(a), reinterpret_cast<Packet16uc>(a), p16uc_REVERSE32));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d preverse(const Packet2d& a)\n{\n  return reinterpret_cast<Packet2d>(vec_perm(reinterpret_cast<Packet16uc>(a), reinterpret_cast<Packet16uc>(a), p16uc_REVERSE64));\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f preverse(const Packet4f& a)\n{\n  Packet4f rev;\n  rev.v4f[0] = preverse<Packet2d>(a.v4f[1]);\n  rev.v4f[1] = preverse<Packet2d>(a.v4f[0]);\n  return rev;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pabs<Packet4i>(const Packet4i& a) { return vec_abs(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet2d pabs<Packet2d>(const Packet2d& a) { return vec_abs(a); }\ntemplate<> EIGEN_STRONG_INLINE Packet4f pabs<Packet4f>(const Packet4f& a)\n{\n  Packet4f res;\n  res.v4f[0] = pabs(a.v4f[0]);\n  res.v4f[1] = pabs(a.v4f[1]);\n  return res;\n}\n\ntemplate<> EIGEN_STRONG_INLINE int predux<Packet4i>(const Packet4i& a)\n{\n  Packet4i b, sum;\n  b   = vec_sld(a, a, 8);\n  sum = padd<Packet4i>(a, b);\n  b   = vec_sld(sum, sum, 4);\n  sum = padd<Packet4i>(sum, b);\n  return pfirst(sum);\n}\n\ntemplate<> EIGEN_STRONG_INLINE double predux<Packet2d>(const Packet2d& a)\n{\n  Packet2d b, sum;\n  b   = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4i>(a), reinterpret_cast<Packet4i>(a), 8));\n  sum = padd<Packet2d>(a, b);\n  return pfirst(sum);\n}\ntemplate<> EIGEN_STRONG_INLINE float predux<Packet4f>(const Packet4f& a)\n{\n  Packet2d sum;\n  sum = padd<Packet2d>(a.v4f[0], a.v4f[1]);\n  double first = predux<Packet2d>(sum);\n  return static_cast<float>(first);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i preduxp<Packet4i>(const Packet4i* vecs)\n{\n  Packet4i v[4], sum[4];\n\n  // It's easier and faster to transpose then add as columns\n  // Check: http://www.freevec.org/function/matrix_4x4_transpose_floats for explanation\n  // Do the transpose, first set of moves\n  v[0] = vec_mergeh(vecs[0], vecs[2]);\n  v[1] = vec_mergel(vecs[0], vecs[2]);\n  v[2] = vec_mergeh(vecs[1], vecs[3]);\n  v[3] = vec_mergel(vecs[1], vecs[3]);\n  // Get the resulting vectors\n  sum[0] = vec_mergeh(v[0], v[2]);\n  sum[1] = vec_mergel(v[0], v[2]);\n  sum[2] = vec_mergeh(v[1], v[3]);\n  sum[3] = vec_mergel(v[1], v[3]);\n\n  // Now do the summation:\n  // Lines 0+1\n  sum[0] = padd<Packet4i>(sum[0], sum[1]);\n  // Lines 2+3\n  sum[1] = padd<Packet4i>(sum[2], sum[3]);\n  // Add the results\n  sum[0] = padd<Packet4i>(sum[0], sum[1]);\n\n  return sum[0];\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d preduxp<Packet2d>(const Packet2d* vecs)\n{\n  Packet2d v[2], sum;\n  v[0] = padd<Packet2d>(vecs[0], reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4ui>(vecs[0]), reinterpret_cast<Packet4ui>(vecs[0]), 8)));\n  v[1] = padd<Packet2d>(vecs[1], reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4ui>(vecs[1]), reinterpret_cast<Packet4ui>(vecs[1]), 8)));\n \n  sum = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4ui>(v[0]), reinterpret_cast<Packet4ui>(v[1]), 8));\n\n  return sum;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f preduxp<Packet4f>(const Packet4f* vecs)\n{\n  PacketBlock<Packet4f,4> transpose;\n  transpose.packet[0] = vecs[0];\n  transpose.packet[1] = vecs[1];\n  transpose.packet[2] = vecs[2];\n  transpose.packet[3] = vecs[3];\n  ptranspose(transpose);\n\n  Packet4f sum = padd(transpose.packet[0], transpose.packet[1]);\n  sum = padd(sum, transpose.packet[2]);\n  sum = padd(sum, transpose.packet[3]);\n  return sum;\n}\n\n// Other reduction functions:\n// mul\ntemplate<> EIGEN_STRONG_INLINE int predux_mul<Packet4i>(const Packet4i& a)\n{\n  EIGEN_ALIGN16 int aux[4];\n  pstore(aux, a);\n  return aux[0] * aux[1] * aux[2] * aux[3];\n}\n\ntemplate<> EIGEN_STRONG_INLINE double predux_mul<Packet2d>(const Packet2d& a)\n{\n  return pfirst(pmul(a, reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4i>(a), reinterpret_cast<Packet4i>(a), 8))));\n}\n\ntemplate<> EIGEN_STRONG_INLINE float predux_mul<Packet4f>(const Packet4f& a)\n{\n  // Return predux_mul<Packet2d> of the subvectors product\n  return static_cast<float>(pfirst(predux_mul(pmul(a.v4f[0], a.v4f[1]))));\n}\n\n// min\ntemplate<> EIGEN_STRONG_INLINE int predux_min<Packet4i>(const Packet4i& a)\n{\n  Packet4i b, res;\n  b   = pmin<Packet4i>(a, vec_sld(a, a, 8));\n  res = pmin<Packet4i>(b, vec_sld(b, b, 4));\n  return pfirst(res);\n}\n\ntemplate<> EIGEN_STRONG_INLINE double predux_min<Packet2d>(const Packet2d& a)\n{\n  return pfirst(pmin<Packet2d>(a, reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4i>(a), reinterpret_cast<Packet4i>(a), 8))));\n}\n\ntemplate<> EIGEN_STRONG_INLINE float predux_min<Packet4f>(const Packet4f& a)\n{\n  Packet2d b, res;\n  b   = pmin<Packet2d>(a.v4f[0], a.v4f[1]);\n  res = pmin<Packet2d>(b, reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4i>(b), reinterpret_cast<Packet4i>(b), 8)));\n  return static_cast<float>(pfirst(res));\n}\n\n// max\ntemplate<> EIGEN_STRONG_INLINE int predux_max<Packet4i>(const Packet4i& a)\n{\n  Packet4i b, res;\n  b = pmax<Packet4i>(a, vec_sld(a, a, 8));\n  res = pmax<Packet4i>(b, vec_sld(b, b, 4));\n  return pfirst(res);\n}\n\n// max\ntemplate<> EIGEN_STRONG_INLINE double predux_max<Packet2d>(const Packet2d& a)\n{\n  return pfirst(pmax<Packet2d>(a, reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4i>(a), reinterpret_cast<Packet4i>(a), 8))));\n}\n\ntemplate<> EIGEN_STRONG_INLINE float predux_max<Packet4f>(const Packet4f& a)\n{\n  Packet2d b, res;\n  b   = pmax<Packet2d>(a.v4f[0], a.v4f[1]);\n  res = pmax<Packet2d>(b, reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4i>(b), reinterpret_cast<Packet4i>(b), 8)));\n  return static_cast<float>(pfirst(res));\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet4i,4>& kernel) {\n  Packet4i t0 = vec_mergeh(kernel.packet[0], kernel.packet[2]);\n  Packet4i t1 = vec_mergel(kernel.packet[0], kernel.packet[2]);\n  Packet4i t2 = vec_mergeh(kernel.packet[1], kernel.packet[3]);\n  Packet4i t3 = vec_mergel(kernel.packet[1], kernel.packet[3]);\n  kernel.packet[0] = vec_mergeh(t0, t2);\n  kernel.packet[1] = vec_mergel(t0, t2);\n  kernel.packet[2] = vec_mergeh(t1, t3);\n  kernel.packet[3] = vec_mergel(t1, t3);\n}\n\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet2d,2>& kernel) {\n  Packet2d t0 = vec_perm(kernel.packet[0], kernel.packet[1], p16uc_TRANSPOSE64_HI);\n  Packet2d t1 = vec_perm(kernel.packet[0], kernel.packet[1], p16uc_TRANSPOSE64_LO);\n  kernel.packet[0] = t0;\n  kernel.packet[1] = t1;\n}\n\n/* Split the Packet4f PacketBlock into 4 Packet2d PacketBlocks and transpose each one\n */\nEIGEN_DEVICE_FUNC inline void\nptranspose(PacketBlock<Packet4f,4>& kernel) {\n  PacketBlock<Packet2d,2> t0,t1,t2,t3;\n  // copy top-left 2x2 Packet2d block\n  t0.packet[0] = kernel.packet[0].v4f[0];\n  t0.packet[1] = kernel.packet[1].v4f[0];\n\n  // copy top-right 2x2 Packet2d block\n  t1.packet[0] = kernel.packet[0].v4f[1];\n  t1.packet[1] = kernel.packet[1].v4f[1];\n\n  // copy bottom-left 2x2 Packet2d block\n  t2.packet[0] = kernel.packet[2].v4f[0];\n  t2.packet[1] = kernel.packet[3].v4f[0];\n\n  // copy bottom-right 2x2 Packet2d block\n  t3.packet[0] = kernel.packet[2].v4f[1];\n  t3.packet[1] = kernel.packet[3].v4f[1];\n\n  // Transpose all 2x2 blocks\n  ptranspose(t0);\n  ptranspose(t1);\n  ptranspose(t2);\n  ptranspose(t3);\n\n  // Copy back transposed blocks, but exchange t1 and t2 due to transposition\n  kernel.packet[0].v4f[0] = t0.packet[0];\n  kernel.packet[0].v4f[1] = t2.packet[0];\n  kernel.packet[1].v4f[0] = t0.packet[1];\n  kernel.packet[1].v4f[1] = t2.packet[1];\n  kernel.packet[2].v4f[0] = t1.packet[0];\n  kernel.packet[2].v4f[1] = t3.packet[0];\n  kernel.packet[3].v4f[0] = t1.packet[1];\n  kernel.packet[3].v4f[1] = t3.packet[1];\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4i pblend(const Selector<4>& ifPacket, const Packet4i& thenPacket, const Packet4i& elsePacket) {\n  Packet4ui select = { ifPacket.select[0], ifPacket.select[1], ifPacket.select[2], ifPacket.select[3] };\n  Packet4ui mask = vec_cmpeq(select, reinterpret_cast<Packet4ui>(p4i_ONE));\n  return vec_sel(elsePacket, thenPacket, mask);\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet4f pblend(const Selector<4>& ifPacket, const Packet4f& thenPacket, const Packet4f& elsePacket) {\n  Packet2ul select_hi = { ifPacket.select[0], ifPacket.select[1] };\n  Packet2ul select_lo = { ifPacket.select[2], ifPacket.select[3] };\n  Packet2ul mask_hi = vec_cmpeq(select_hi, reinterpret_cast<Packet2ul>(p2l_ONE));\n  Packet2ul mask_lo = vec_cmpeq(select_lo, reinterpret_cast<Packet2ul>(p2l_ONE));\n  Packet4f result;\n  result.v4f[0] = vec_sel(elsePacket.v4f[0], thenPacket.v4f[0], mask_hi);\n  result.v4f[1] = vec_sel(elsePacket.v4f[1], thenPacket.v4f[1], mask_lo);\n  return result;\n}\n\ntemplate<> EIGEN_STRONG_INLINE Packet2d pblend(const Selector<2>& ifPacket, const Packet2d& thenPacket, const Packet2d& elsePacket) {\n  Packet2ul select = { ifPacket.select[0], ifPacket.select[1] };\n  Packet2ul mask = vec_cmpeq(select, reinterpret_cast<Packet2ul>(p2l_ONE));\n  return vec_sel(elsePacket, thenPacket, mask);\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_PACKET_MATH_ZVECTOR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/functors/AssignmentFunctors.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ASSIGNMENT_FUNCTORS_H\n#define EIGEN_ASSIGNMENT_FUNCTORS_H\n\nnamespace Eigen {\n\nnamespace internal {\n  \n/** \\internal\n  * \\brief Template functor for scalar/packet assignment\n  *\n  */\ntemplate<typename DstScalar,typename SrcScalar> struct assign_op {\n\n  EIGEN_EMPTY_STRUCT_CTOR(assign_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(DstScalar& a, const SrcScalar& b) const { a = b; }\n  \n  template<int Alignment, typename Packet>\n  EIGEN_STRONG_INLINE void assignPacket(DstScalar* a, const Packet& b) const\n  { internal::pstoret<DstScalar,Packet,Alignment>(a,b); }\n};\n\n// Empty overload for void type (used by PermutationMatrix)\ntemplate<typename DstScalar> struct assign_op<DstScalar,void> {};\n\ntemplate<typename DstScalar,typename SrcScalar>\nstruct functor_traits<assign_op<DstScalar,SrcScalar> > {\n  enum {\n    Cost = NumTraits<DstScalar>::ReadCost,\n    PacketAccess = is_same<DstScalar,SrcScalar>::value && packet_traits<DstScalar>::Vectorizable && packet_traits<SrcScalar>::Vectorizable\n  };\n};\n\n/** \\internal\n  * \\brief Template functor for scalar/packet assignment with addition\n  *\n  */\ntemplate<typename DstScalar,typename SrcScalar> struct add_assign_op {\n\n  EIGEN_EMPTY_STRUCT_CTOR(add_assign_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(DstScalar& a, const SrcScalar& b) const { a += b; }\n  \n  template<int Alignment, typename Packet>\n  EIGEN_STRONG_INLINE void assignPacket(DstScalar* a, const Packet& b) const\n  { internal::pstoret<DstScalar,Packet,Alignment>(a,internal::padd(internal::ploadt<Packet,Alignment>(a),b)); }\n};\ntemplate<typename DstScalar,typename SrcScalar>\nstruct functor_traits<add_assign_op<DstScalar,SrcScalar> > {\n  enum {\n    Cost = NumTraits<DstScalar>::ReadCost + NumTraits<DstScalar>::AddCost,\n    PacketAccess = is_same<DstScalar,SrcScalar>::value && packet_traits<DstScalar>::HasAdd\n  };\n};\n\n/** \\internal\n  * \\brief Template functor for scalar/packet assignment with subtraction\n  *\n  */\ntemplate<typename DstScalar,typename SrcScalar> struct sub_assign_op {\n\n  EIGEN_EMPTY_STRUCT_CTOR(sub_assign_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(DstScalar& a, const SrcScalar& b) const { a -= b; }\n  \n  template<int Alignment, typename Packet>\n  EIGEN_STRONG_INLINE void assignPacket(DstScalar* a, const Packet& b) const\n  { internal::pstoret<DstScalar,Packet,Alignment>(a,internal::psub(internal::ploadt<Packet,Alignment>(a),b)); }\n};\ntemplate<typename DstScalar,typename SrcScalar>\nstruct functor_traits<sub_assign_op<DstScalar,SrcScalar> > {\n  enum {\n    Cost = NumTraits<DstScalar>::ReadCost + NumTraits<DstScalar>::AddCost,\n    PacketAccess = is_same<DstScalar,SrcScalar>::value && packet_traits<DstScalar>::HasSub\n  };\n};\n\n/** \\internal\n  * \\brief Template functor for scalar/packet assignment with multiplication\n  *\n  */\ntemplate<typename DstScalar, typename SrcScalar=DstScalar>\nstruct mul_assign_op {\n\n  EIGEN_EMPTY_STRUCT_CTOR(mul_assign_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(DstScalar& a, const SrcScalar& b) const { a *= b; }\n  \n  template<int Alignment, typename Packet>\n  EIGEN_STRONG_INLINE void assignPacket(DstScalar* a, const Packet& b) const\n  { internal::pstoret<DstScalar,Packet,Alignment>(a,internal::pmul(internal::ploadt<Packet,Alignment>(a),b)); }\n};\ntemplate<typename DstScalar, typename SrcScalar>\nstruct functor_traits<mul_assign_op<DstScalar,SrcScalar> > {\n  enum {\n    Cost = NumTraits<DstScalar>::ReadCost + NumTraits<DstScalar>::MulCost,\n    PacketAccess = is_same<DstScalar,SrcScalar>::value && packet_traits<DstScalar>::HasMul\n  };\n};\n\n/** \\internal\n  * \\brief Template functor for scalar/packet assignment with diviving\n  *\n  */\ntemplate<typename DstScalar, typename SrcScalar=DstScalar> struct div_assign_op {\n\n  EIGEN_EMPTY_STRUCT_CTOR(div_assign_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(DstScalar& a, const SrcScalar& b) const { a /= b; }\n  \n  template<int Alignment, typename Packet>\n  EIGEN_STRONG_INLINE void assignPacket(DstScalar* a, const Packet& b) const\n  { internal::pstoret<DstScalar,Packet,Alignment>(a,internal::pdiv(internal::ploadt<Packet,Alignment>(a),b)); }\n};\ntemplate<typename DstScalar, typename SrcScalar>\nstruct functor_traits<div_assign_op<DstScalar,SrcScalar> > {\n  enum {\n    Cost = NumTraits<DstScalar>::ReadCost + NumTraits<DstScalar>::MulCost,\n    PacketAccess = is_same<DstScalar,SrcScalar>::value && packet_traits<DstScalar>::HasDiv\n  };\n};\n\n/** \\internal\n  * \\brief Template functor for scalar/packet assignment with swapping\n  *\n  * It works as follow. For a non-vectorized evaluation loop, we have:\n  *   for(i) func(A.coeffRef(i), B.coeff(i));\n  * where B is a SwapWrapper expression. The trick is to make SwapWrapper::coeff behaves like a non-const coeffRef.\n  * Actually, SwapWrapper might not even be needed since even if B is a plain expression, since it has to be writable\n  * B.coeff already returns a const reference to the underlying scalar value.\n  * \n  * The case of a vectorized loop is more tricky:\n  *   for(i,j) func.assignPacket<A_Align>(&A.coeffRef(i,j), B.packet<B_Align>(i,j));\n  * Here, B must be a SwapWrapper whose packet function actually returns a proxy object holding a Scalar*,\n  * the actual alignment and Packet type.\n  *\n  */\ntemplate<typename Scalar> struct swap_assign_op {\n\n  EIGEN_EMPTY_STRUCT_CTOR(swap_assign_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(Scalar& a, const Scalar& b) const\n  {\n#ifdef __CUDACC__\n    // FIXME is there some kind of cuda::swap?\n    Scalar t=b; const_cast<Scalar&>(b)=a; a=t;\n#else\n    using std::swap;\n    swap(a,const_cast<Scalar&>(b));\n#endif\n  }\n};\ntemplate<typename Scalar>\nstruct functor_traits<swap_assign_op<Scalar> > {\n  enum {\n    Cost = 3 * NumTraits<Scalar>::ReadCost,\n    PacketAccess = packet_traits<Scalar>::Vectorizable\n  };\n};\n\n} // namespace internal\n\n} // namespace Eigen\n\n#endif // EIGEN_ASSIGNMENT_FUNCTORS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/functors/BinaryFunctors.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_BINARY_FUNCTORS_H\n#define EIGEN_BINARY_FUNCTORS_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n//---------- associative binary functors ----------\n\ntemplate<typename Arg1, typename Arg2>\nstruct binary_op_base\n{\n  typedef Arg1 first_argument_type;\n  typedef Arg2 second_argument_type;\n};\n\n/** \\internal\n  * \\brief Template functor to compute the sum of two scalars\n  *\n  * \\sa class CwiseBinaryOp, MatrixBase::operator+, class VectorwiseOp, DenseBase::sum()\n  */\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct scalar_sum_op : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar,scalar_sum_op>::ReturnType result_type;\n#ifndef EIGEN_SCALAR_BINARY_OP_PLUGIN\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_sum_op)\n#else\n  scalar_sum_op() {\n    EIGEN_SCALAR_BINARY_OP_PLUGIN\n  }\n#endif\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return a + b; }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const\n  { return internal::padd(a,b); }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type predux(const Packet& a) const\n  { return internal::predux(a); }\n};\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct functor_traits<scalar_sum_op<LhsScalar,RhsScalar> > {\n  enum {\n    Cost = (NumTraits<LhsScalar>::AddCost+NumTraits<RhsScalar>::AddCost)/2, // rough estimate!\n    PacketAccess = is_same<LhsScalar,RhsScalar>::value && packet_traits<LhsScalar>::HasAdd && packet_traits<RhsScalar>::HasAdd\n    // TODO vectorize mixed sum\n  };\n};\n\n/** \\internal\n  * \\brief Template specialization to deprecate the summation of boolean expressions.\n  * This is required to solve Bug 426.\n  * \\sa DenseBase::count(), DenseBase::any(), ArrayBase::cast(), MatrixBase::cast()\n  */\ntemplate<> struct scalar_sum_op<bool,bool> : scalar_sum_op<int,int> {\n  EIGEN_DEPRECATED\n  scalar_sum_op() {}\n};\n\n\n/** \\internal\n  * \\brief Template functor to compute the product of two scalars\n  *\n  * \\sa class CwiseBinaryOp, Cwise::operator*(), class VectorwiseOp, MatrixBase::redux()\n  */\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct scalar_product_op  : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar,scalar_product_op>::ReturnType result_type;\n#ifndef EIGEN_SCALAR_BINARY_OP_PLUGIN\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_product_op)\n#else\n  scalar_product_op() {\n    EIGEN_SCALAR_BINARY_OP_PLUGIN\n  }\n#endif\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return a * b; }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const\n  { return internal::pmul(a,b); }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type predux(const Packet& a) const\n  { return internal::predux_mul(a); }\n};\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct functor_traits<scalar_product_op<LhsScalar,RhsScalar> > {\n  enum {\n    Cost = (NumTraits<LhsScalar>::MulCost + NumTraits<RhsScalar>::MulCost)/2, // rough estimate!\n    PacketAccess = is_same<LhsScalar,RhsScalar>::value && packet_traits<LhsScalar>::HasMul && packet_traits<RhsScalar>::HasMul\n    // TODO vectorize mixed product\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the conjugate product of two scalars\n  *\n  * This is a short cut for conj(x) * y which is needed for optimization purpose; in Eigen2 support mode, this becomes x * conj(y)\n  */\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct scalar_conj_product_op  : binary_op_base<LhsScalar,RhsScalar>\n{\n\n  enum {\n    Conj = NumTraits<LhsScalar>::IsComplex\n  };\n  \n  typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar,scalar_conj_product_op>::ReturnType result_type;\n  \n  EIGEN_EMPTY_STRUCT_CTOR(scalar_conj_product_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const\n  { return conj_helper<LhsScalar,RhsScalar,Conj,false>().pmul(a,b); }\n  \n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const\n  { return conj_helper<Packet,Packet,Conj,false>().pmul(a,b); }\n};\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct functor_traits<scalar_conj_product_op<LhsScalar,RhsScalar> > {\n  enum {\n    Cost = NumTraits<LhsScalar>::MulCost,\n    PacketAccess = internal::is_same<LhsScalar, RhsScalar>::value && packet_traits<LhsScalar>::HasMul\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the min of two scalars\n  *\n  * \\sa class CwiseBinaryOp, MatrixBase::cwiseMin, class VectorwiseOp, MatrixBase::minCoeff()\n  */\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct scalar_min_op : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar,scalar_min_op>::ReturnType result_type;\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_min_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return numext::mini(a, b); }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const\n  { return internal::pmin(a,b); }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type predux(const Packet& a) const\n  { return internal::predux_min(a); }\n};\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct functor_traits<scalar_min_op<LhsScalar,RhsScalar> > {\n  enum {\n    Cost = (NumTraits<LhsScalar>::AddCost+NumTraits<RhsScalar>::AddCost)/2,\n    PacketAccess = internal::is_same<LhsScalar, RhsScalar>::value && packet_traits<LhsScalar>::HasMin\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the max of two scalars\n  *\n  * \\sa class CwiseBinaryOp, MatrixBase::cwiseMax, class VectorwiseOp, MatrixBase::maxCoeff()\n  */\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct scalar_max_op  : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar,scalar_max_op>::ReturnType result_type;\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_max_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return numext::maxi(a, b); }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const\n  { return internal::pmax(a,b); }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type predux(const Packet& a) const\n  { return internal::predux_max(a); }\n};\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct functor_traits<scalar_max_op<LhsScalar,RhsScalar> > {\n  enum {\n    Cost = (NumTraits<LhsScalar>::AddCost+NumTraits<RhsScalar>::AddCost)/2,\n    PacketAccess = internal::is_same<LhsScalar, RhsScalar>::value && packet_traits<LhsScalar>::HasMax\n  };\n};\n\n/** \\internal\n  * \\brief Template functors for comparison of two scalars\n  * \\todo Implement packet-comparisons\n  */\ntemplate<typename LhsScalar, typename RhsScalar, ComparisonName cmp> struct scalar_cmp_op;\n\ntemplate<typename LhsScalar, typename RhsScalar, ComparisonName cmp>\nstruct functor_traits<scalar_cmp_op<LhsScalar,RhsScalar, cmp> > {\n  enum {\n    Cost = (NumTraits<LhsScalar>::AddCost+NumTraits<RhsScalar>::AddCost)/2,\n    PacketAccess = false\n  };\n};\n\ntemplate<ComparisonName Cmp, typename LhsScalar, typename RhsScalar>\nstruct result_of<scalar_cmp_op<LhsScalar, RhsScalar, Cmp>(LhsScalar,RhsScalar)> {\n  typedef bool type;\n};\n\n\ntemplate<typename LhsScalar, typename RhsScalar>\nstruct scalar_cmp_op<LhsScalar,RhsScalar, cmp_EQ> : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef bool result_type;\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(const LhsScalar& a, const RhsScalar& b) const {return a==b;}\n};\ntemplate<typename LhsScalar, typename RhsScalar>\nstruct scalar_cmp_op<LhsScalar,RhsScalar, cmp_LT> : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef bool result_type;\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(const LhsScalar& a, const RhsScalar& b) const {return a<b;}\n};\ntemplate<typename LhsScalar, typename RhsScalar>\nstruct scalar_cmp_op<LhsScalar,RhsScalar, cmp_LE> : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef bool result_type;\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(const LhsScalar& a, const RhsScalar& b) const {return a<=b;}\n};\ntemplate<typename LhsScalar, typename RhsScalar>\nstruct scalar_cmp_op<LhsScalar,RhsScalar, cmp_GT> : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef bool result_type;\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(const LhsScalar& a, const RhsScalar& b) const {return a>b;}\n};\ntemplate<typename LhsScalar, typename RhsScalar>\nstruct scalar_cmp_op<LhsScalar,RhsScalar, cmp_GE> : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef bool result_type;\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(const LhsScalar& a, const RhsScalar& b) const {return a>=b;}\n};\ntemplate<typename LhsScalar, typename RhsScalar>\nstruct scalar_cmp_op<LhsScalar,RhsScalar, cmp_UNORD> : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef bool result_type;\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(const LhsScalar& a, const RhsScalar& b) const {return !(a<=b || b<=a);}\n};\ntemplate<typename LhsScalar, typename RhsScalar>\nstruct scalar_cmp_op<LhsScalar,RhsScalar, cmp_NEQ> : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef bool result_type;\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(const LhsScalar& a, const RhsScalar& b) const {return a!=b;}\n};\n\n\n/** \\internal\n  * \\brief Template functor to compute the hypot of two scalars\n  *\n  * \\sa MatrixBase::stableNorm(), class Redux\n  */\ntemplate<typename Scalar>\nstruct scalar_hypot_op<Scalar,Scalar> : binary_op_base<Scalar,Scalar>\n{\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_hypot_op)\n//   typedef typename NumTraits<Scalar>::Real result_type;\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& _x, const Scalar& _y) const\n  {\n    EIGEN_USING_STD_MATH(sqrt)\n    Scalar p, qp;\n    if(_x>_y)\n    {\n      p = _x;\n      qp = _y / p;\n    }\n    else\n    {\n      p = _y;\n      qp = _x / p;\n    }\n    return p * sqrt(Scalar(1) + qp*qp);\n  }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_hypot_op<Scalar,Scalar> > {\n  enum\n  {\n    Cost = 3 * NumTraits<Scalar>::AddCost +\n           2 * NumTraits<Scalar>::MulCost +\n           2 * scalar_div_cost<Scalar,false>::value,\n    PacketAccess = false\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the pow of two scalars\n  */\ntemplate<typename Scalar, typename Exponent>\nstruct scalar_pow_op  : binary_op_base<Scalar,Exponent>\n{\n  typedef typename ScalarBinaryOpTraits<Scalar,Exponent,scalar_pow_op>::ReturnType result_type;\n#ifndef EIGEN_SCALAR_BINARY_OP_PLUGIN\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_pow_op)\n#else\n  scalar_pow_op() {\n    typedef Scalar LhsScalar;\n    typedef Exponent RhsScalar;\n    EIGEN_SCALAR_BINARY_OP_PLUGIN\n  }\n#endif\n  EIGEN_DEVICE_FUNC\n  inline result_type operator() (const Scalar& a, const Exponent& b) const { return numext::pow(a, b); }\n};\ntemplate<typename Scalar, typename Exponent>\nstruct functor_traits<scalar_pow_op<Scalar,Exponent> > {\n  enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false };\n};\n\n\n\n//---------- non associative binary functors ----------\n\n/** \\internal\n  * \\brief Template functor to compute the difference of two scalars\n  *\n  * \\sa class CwiseBinaryOp, MatrixBase::operator-\n  */\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct scalar_difference_op : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar,scalar_difference_op>::ReturnType result_type;\n#ifndef EIGEN_SCALAR_BINARY_OP_PLUGIN\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_difference_op)\n#else\n  scalar_difference_op() {\n    EIGEN_SCALAR_BINARY_OP_PLUGIN\n  }\n#endif\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return a - b; }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const\n  { return internal::psub(a,b); }\n};\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct functor_traits<scalar_difference_op<LhsScalar,RhsScalar> > {\n  enum {\n    Cost = (NumTraits<LhsScalar>::AddCost+NumTraits<RhsScalar>::AddCost)/2,\n    PacketAccess = is_same<LhsScalar,RhsScalar>::value && packet_traits<LhsScalar>::HasSub && packet_traits<RhsScalar>::HasSub\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the quotient of two scalars\n  *\n  * \\sa class CwiseBinaryOp, Cwise::operator/()\n  */\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct scalar_quotient_op  : binary_op_base<LhsScalar,RhsScalar>\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar,scalar_quotient_op>::ReturnType result_type;\n#ifndef EIGEN_SCALAR_BINARY_OP_PLUGIN\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_quotient_op)\n#else\n  scalar_quotient_op() {\n    EIGEN_SCALAR_BINARY_OP_PLUGIN\n  }\n#endif\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return a / b; }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const\n  { return internal::pdiv(a,b); }\n};\ntemplate<typename LhsScalar,typename RhsScalar>\nstruct functor_traits<scalar_quotient_op<LhsScalar,RhsScalar> > {\n  typedef typename scalar_quotient_op<LhsScalar,RhsScalar>::result_type result_type;\n  enum {\n    PacketAccess = is_same<LhsScalar,RhsScalar>::value && packet_traits<LhsScalar>::HasDiv && packet_traits<RhsScalar>::HasDiv,\n    Cost = scalar_div_cost<result_type,PacketAccess>::value\n  };\n};\n\n\n\n/** \\internal\n  * \\brief Template functor to compute the and of two booleans\n  *\n  * \\sa class CwiseBinaryOp, ArrayBase::operator&&\n  */\nstruct scalar_boolean_and_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_boolean_and_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator() (const bool& a, const bool& b) const { return a && b; }\n};\ntemplate<> struct functor_traits<scalar_boolean_and_op> {\n  enum {\n    Cost = NumTraits<bool>::AddCost,\n    PacketAccess = false\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the or of two booleans\n  *\n  * \\sa class CwiseBinaryOp, ArrayBase::operator||\n  */\nstruct scalar_boolean_or_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_boolean_or_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator() (const bool& a, const bool& b) const { return a || b; }\n};\ntemplate<> struct functor_traits<scalar_boolean_or_op> {\n  enum {\n    Cost = NumTraits<bool>::AddCost,\n    PacketAccess = false\n  };\n};\n\n/** \\internal\n * \\brief Template functor to compute the xor of two booleans\n *\n * \\sa class CwiseBinaryOp, ArrayBase::operator^\n */\nstruct scalar_boolean_xor_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_boolean_xor_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator() (const bool& a, const bool& b) const { return a ^ b; }\n};\ntemplate<> struct functor_traits<scalar_boolean_xor_op> {\n  enum {\n    Cost = NumTraits<bool>::AddCost,\n    PacketAccess = false\n  };\n};\n\n\n\n//---------- binary functors bound to a constant, thus appearing as a unary functor ----------\n\n// The following two classes permits to turn any binary functor into a unary one with one argument bound to a constant value.\n// They are analogues to std::binder1st/binder2nd but with the following differences:\n//  - they are compatible with packetOp\n//  - they are portable across C++ versions (the std::binder* are deprecated in C++11)\ntemplate<typename BinaryOp> struct bind1st_op : BinaryOp {\n\n  typedef typename BinaryOp::first_argument_type  first_argument_type;\n  typedef typename BinaryOp::second_argument_type second_argument_type;\n  typedef typename BinaryOp::result_type          result_type;\n\n  bind1st_op(const first_argument_type &val) : m_value(val) {}\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const second_argument_type& b) const { return BinaryOp::operator()(m_value,b); }\n\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& b) const\n  { return BinaryOp::packetOp(internal::pset1<Packet>(m_value), b); }\n\n  first_argument_type m_value;\n};\ntemplate<typename BinaryOp> struct functor_traits<bind1st_op<BinaryOp> > : functor_traits<BinaryOp> {};\n\n\ntemplate<typename BinaryOp> struct bind2nd_op : BinaryOp {\n\n  typedef typename BinaryOp::first_argument_type  first_argument_type;\n  typedef typename BinaryOp::second_argument_type second_argument_type;\n  typedef typename BinaryOp::result_type          result_type;\n\n  bind2nd_op(const second_argument_type &val) : m_value(val) {}\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const first_argument_type& a) const { return BinaryOp::operator()(a,m_value); }\n\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const\n  { return BinaryOp::packetOp(a,internal::pset1<Packet>(m_value)); }\n\n  second_argument_type m_value;\n};\ntemplate<typename BinaryOp> struct functor_traits<bind2nd_op<BinaryOp> > : functor_traits<BinaryOp> {};\n\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_BINARY_FUNCTORS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/functors/NullaryFunctors.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2016 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_NULLARY_FUNCTORS_H\n#define EIGEN_NULLARY_FUNCTORS_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<typename Scalar>\nstruct scalar_constant_op {\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_constant_op(const scalar_constant_op& other) : m_other(other.m_other) { }\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_constant_op(const Scalar& other) : m_other(other) { }\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const { return m_other; }\n  template<typename PacketType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const PacketType packetOp() const { return internal::pset1<PacketType>(m_other); }\n  const Scalar m_other;\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_constant_op<Scalar> >\n{ enum { Cost = 0 /* as the constant value should be loaded in register only once for the whole expression */,\n         PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = true }; };\n\ntemplate<typename Scalar> struct scalar_identity_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_identity_op)\n  template<typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (IndexType row, IndexType col) const { return row==col ? Scalar(1) : Scalar(0); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_identity_op<Scalar> >\n{ enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = false, IsRepeatable = true }; };\n\ntemplate <typename Scalar, typename Packet, bool IsInteger> struct linspaced_op_impl;\n\ntemplate <typename Scalar, typename Packet>\nstruct linspaced_op_impl<Scalar,Packet,/*IsInteger*/false>\n{\n  linspaced_op_impl(const Scalar& low, const Scalar& high, Index num_steps) :\n    m_low(low), m_high(high), m_size1(num_steps==1 ? 1 : num_steps-1), m_step(num_steps==1 ? Scalar() : (high-low)/Scalar(num_steps-1)),\n    m_flip(numext::abs(high)<numext::abs(low))\n  {}\n\n  template<typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (IndexType i) const {\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    if(m_flip)\n      return (i==0)? m_low : (m_high - RealScalar(m_size1-i)*m_step);\n    else\n      return (i==m_size1)? m_high : (m_low + RealScalar(i)*m_step);\n  }\n\n  template<typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(IndexType i) const\n  {\n    // Principle:\n    // [low, ..., low] + ( [step, ..., step] * ( [i, ..., i] + [0, ..., size] ) )\n    if(m_flip)\n    {\n      Packet pi = plset<Packet>(Scalar(i-m_size1));\n      Packet res = padd(pset1<Packet>(m_high), pmul(pset1<Packet>(m_step), pi));\n      if(i==0)\n        res = pinsertfirst(res, m_low);\n      return res;\n    }\n    else\n    {\n      Packet pi = plset<Packet>(Scalar(i));\n      Packet res = padd(pset1<Packet>(m_low), pmul(pset1<Packet>(m_step), pi));\n      if(i==m_size1-unpacket_traits<Packet>::size+1)\n        res = pinsertlast(res, m_high);\n      return res;\n    }\n  }\n\n  const Scalar m_low;\n  const Scalar m_high;\n  const Index m_size1;\n  const Scalar m_step;\n  const bool m_flip;\n};\n\ntemplate <typename Scalar, typename Packet>\nstruct linspaced_op_impl<Scalar,Packet,/*IsInteger*/true>\n{\n  linspaced_op_impl(const Scalar& low, const Scalar& high, Index num_steps) :\n    m_low(low),\n    m_multiplier((high-low)/convert_index<Scalar>(num_steps<=1 ? 1 : num_steps-1)),\n    m_divisor(convert_index<Scalar>((high>=low?num_steps:-num_steps)+(high-low))/((numext::abs(high-low)+1)==0?1:(numext::abs(high-low)+1))),\n    m_use_divisor(num_steps>1 && (numext::abs(high-low)+1)<num_steps)\n  {}\n\n  template<typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n  const Scalar operator() (IndexType i) const\n  {\n    if(m_use_divisor) return m_low + convert_index<Scalar>(i)/m_divisor;\n    else              return m_low + convert_index<Scalar>(i)*m_multiplier;\n  }\n\n  const Scalar m_low;\n  const Scalar m_multiplier;\n  const Scalar m_divisor;\n  const bool m_use_divisor;\n};\n\n// ----- Linspace functor ----------------------------------------------------------------\n\n// Forward declaration (we default to random access which does not really give\n// us a speed gain when using packet access but it allows to use the functor in\n// nested expressions).\ntemplate <typename Scalar, typename PacketType> struct linspaced_op;\ntemplate <typename Scalar, typename PacketType> struct functor_traits< linspaced_op<Scalar,PacketType> >\n{\n  enum\n  {\n    Cost = 1,\n    PacketAccess =   (!NumTraits<Scalar>::IsInteger) && packet_traits<Scalar>::HasSetLinear && packet_traits<Scalar>::HasBlend,\n                  /*&& ((!NumTraits<Scalar>::IsInteger) || packet_traits<Scalar>::HasDiv),*/ // <- vectorization for integer is currently disabled\n    IsRepeatable = true\n  };\n};\ntemplate <typename Scalar, typename PacketType> struct linspaced_op\n{\n  linspaced_op(const Scalar& low, const Scalar& high, Index num_steps)\n    : impl((num_steps==1 ? high : low),high,num_steps)\n  {}\n\n  template<typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (IndexType i) const { return impl(i); }\n\n  template<typename Packet,typename IndexType>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(IndexType i) const { return impl.packetOp(i); }\n\n  // This proxy object handles the actual required temporaries and the different\n  // implementations (integer vs. floating point).\n  const linspaced_op_impl<Scalar,PacketType,NumTraits<Scalar>::IsInteger> impl;\n};\n\n// Linear access is automatically determined from the operator() prototypes available for the given functor.\n// If it exposes an operator()(i,j), then we assume the i and j coefficients are required independently\n// and linear access is not possible. In all other cases, linear access is enabled.\n// Users should not have to deal with this structure.\ntemplate<typename Functor> struct functor_has_linear_access { enum { ret = !has_binary_operator<Functor>::value }; };\n\n// For unreliable compilers, let's specialize the has_*ary_operator\n// helpers so that at least built-in nullary functors work fine.\n#if !( (EIGEN_COMP_MSVC>1600) || (EIGEN_GNUC_AT_LEAST(4,8)) || (EIGEN_COMP_ICC>=1600))\ntemplate<typename Scalar,typename IndexType>\nstruct has_nullary_operator<scalar_constant_op<Scalar>,IndexType> { enum { value = 1}; };\ntemplate<typename Scalar,typename IndexType>\nstruct has_unary_operator<scalar_constant_op<Scalar>,IndexType> { enum { value = 0}; };\ntemplate<typename Scalar,typename IndexType>\nstruct has_binary_operator<scalar_constant_op<Scalar>,IndexType> { enum { value = 0}; };\n\ntemplate<typename Scalar,typename IndexType>\nstruct has_nullary_operator<scalar_identity_op<Scalar>,IndexType> { enum { value = 0}; };\ntemplate<typename Scalar,typename IndexType>\nstruct has_unary_operator<scalar_identity_op<Scalar>,IndexType> { enum { value = 0}; };\ntemplate<typename Scalar,typename IndexType>\nstruct has_binary_operator<scalar_identity_op<Scalar>,IndexType> { enum { value = 1}; };\n\ntemplate<typename Scalar, typename PacketType,typename IndexType>\nstruct has_nullary_operator<linspaced_op<Scalar,PacketType>,IndexType> { enum { value = 0}; };\ntemplate<typename Scalar, typename PacketType,typename IndexType>\nstruct has_unary_operator<linspaced_op<Scalar,PacketType>,IndexType> { enum { value = 1}; };\ntemplate<typename Scalar, typename PacketType,typename IndexType>\nstruct has_binary_operator<linspaced_op<Scalar,PacketType>,IndexType> { enum { value = 0}; };\n\ntemplate<typename Scalar,typename IndexType>\nstruct has_nullary_operator<scalar_random_op<Scalar>,IndexType> { enum { value = 1}; };\ntemplate<typename Scalar,typename IndexType>\nstruct has_unary_operator<scalar_random_op<Scalar>,IndexType> { enum { value = 0}; };\ntemplate<typename Scalar,typename IndexType>\nstruct has_binary_operator<scalar_random_op<Scalar>,IndexType> { enum { value = 0}; };\n#endif\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_NULLARY_FUNCTORS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/functors/StlFunctors.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_STL_FUNCTORS_H\n#define EIGEN_STL_FUNCTORS_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n// default functor traits for STL functors:\n\ntemplate<typename T>\nstruct functor_traits<std::multiplies<T> >\n{ enum { Cost = NumTraits<T>::MulCost, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::divides<T> >\n{ enum { Cost = NumTraits<T>::MulCost, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::plus<T> >\n{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::minus<T> >\n{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::negate<T> >\n{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::logical_or<T> >\n{ enum { Cost = 1, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::logical_and<T> >\n{ enum { Cost = 1, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::logical_not<T> >\n{ enum { Cost = 1, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::greater<T> >\n{ enum { Cost = 1, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::less<T> >\n{ enum { Cost = 1, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::greater_equal<T> >\n{ enum { Cost = 1, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::less_equal<T> >\n{ enum { Cost = 1, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::equal_to<T> >\n{ enum { Cost = 1, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::not_equal_to<T> >\n{ enum { Cost = 1, PacketAccess = false }; };\n\n#if (__cplusplus < 201103L) && (EIGEN_COMP_MSVC <= 1900)\n// std::binder* are deprecated since c++11 and will be removed in c++17\ntemplate<typename T>\nstruct functor_traits<std::binder2nd<T> >\n{ enum { Cost = functor_traits<T>::Cost, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::binder1st<T> >\n{ enum { Cost = functor_traits<T>::Cost, PacketAccess = false }; };\n#endif\n\ntemplate<typename T>\nstruct functor_traits<std::unary_negate<T> >\n{ enum { Cost = 1 + functor_traits<T>::Cost, PacketAccess = false }; };\n\ntemplate<typename T>\nstruct functor_traits<std::binary_negate<T> >\n{ enum { Cost = 1 + functor_traits<T>::Cost, PacketAccess = false }; };\n\n#ifdef EIGEN_STDEXT_SUPPORT\n\ntemplate<typename T0,typename T1>\nstruct functor_traits<std::project1st<T0,T1> >\n{ enum { Cost = 0, PacketAccess = false }; };\n\ntemplate<typename T0,typename T1>\nstruct functor_traits<std::project2nd<T0,T1> >\n{ enum { Cost = 0, PacketAccess = false }; };\n\ntemplate<typename T0,typename T1>\nstruct functor_traits<std::select2nd<std::pair<T0,T1> > >\n{ enum { Cost = 0, PacketAccess = false }; };\n\ntemplate<typename T0,typename T1>\nstruct functor_traits<std::select1st<std::pair<T0,T1> > >\n{ enum { Cost = 0, PacketAccess = false }; };\n\ntemplate<typename T0,typename T1>\nstruct functor_traits<std::unary_compose<T0,T1> >\n{ enum { Cost = functor_traits<T0>::Cost + functor_traits<T1>::Cost, PacketAccess = false }; };\n\ntemplate<typename T0,typename T1,typename T2>\nstruct functor_traits<std::binary_compose<T0,T1,T2> >\n{ enum { Cost = functor_traits<T0>::Cost + functor_traits<T1>::Cost + functor_traits<T2>::Cost, PacketAccess = false }; };\n\n#endif // EIGEN_STDEXT_SUPPORT\n\n// allow to add new functors and specializations of functor_traits from outside Eigen.\n// this macro is really needed because functor_traits must be specialized after it is declared but before it is used...\n#ifdef EIGEN_FUNCTORS_PLUGIN\n#include EIGEN_FUNCTORS_PLUGIN\n#endif\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_STL_FUNCTORS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/functors/TernaryFunctors.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2016 Eugene Brevdo <ebrevdo@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TERNARY_FUNCTORS_H\n#define EIGEN_TERNARY_FUNCTORS_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n//---------- associative ternary functors ----------\n\n\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TERNARY_FUNCTORS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/functors/UnaryFunctors.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2016 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_UNARY_FUNCTORS_H\n#define EIGEN_UNARY_FUNCTORS_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n/** \\internal\n  * \\brief Template functor to compute the opposite of a scalar\n  *\n  * \\sa class CwiseUnaryOp, MatrixBase::operator-\n  */\ntemplate<typename Scalar> struct scalar_opposite_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_opposite_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return -a; }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const\n  { return internal::pnegate(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_opposite_op<Scalar> >\n{ enum {\n    Cost = NumTraits<Scalar>::AddCost,\n    PacketAccess = packet_traits<Scalar>::HasNegate };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the absolute value of a scalar\n  *\n  * \\sa class CwiseUnaryOp, Cwise::abs\n  */\ntemplate<typename Scalar> struct scalar_abs_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_abs_op)\n  typedef typename NumTraits<Scalar>::Real result_type;\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return numext::abs(a); }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const\n  { return internal::pabs(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_abs_op<Scalar> >\n{\n  enum {\n    Cost = NumTraits<Scalar>::AddCost,\n    PacketAccess = packet_traits<Scalar>::HasAbs\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the score of a scalar, to chose a pivot\n  *\n  * \\sa class CwiseUnaryOp\n  */\ntemplate<typename Scalar> struct scalar_score_coeff_op : scalar_abs_op<Scalar>\n{\n  typedef void Score_is_abs;\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_score_coeff_op<Scalar> > : functor_traits<scalar_abs_op<Scalar> > {};\n\n/* Avoid recomputing abs when we know the score and they are the same. Not a true Eigen functor.  */\ntemplate<typename Scalar, typename=void> struct abs_knowing_score\n{\n  EIGEN_EMPTY_STRUCT_CTOR(abs_knowing_score)\n  typedef typename NumTraits<Scalar>::Real result_type;\n  template<typename Score>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a, const Score&) const { return numext::abs(a); }\n};\ntemplate<typename Scalar> struct abs_knowing_score<Scalar, typename scalar_score_coeff_op<Scalar>::Score_is_abs>\n{\n  EIGEN_EMPTY_STRUCT_CTOR(abs_knowing_score)\n  typedef typename NumTraits<Scalar>::Real result_type;\n  template<typename Scal>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const Scal&, const result_type& a) const { return a; }\n};\n\n/** \\internal\n  * \\brief Template functor to compute the squared absolute value of a scalar\n  *\n  * \\sa class CwiseUnaryOp, Cwise::abs2\n  */\ntemplate<typename Scalar> struct scalar_abs2_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_abs2_op)\n  typedef typename NumTraits<Scalar>::Real result_type;\n  EIGEN_DEVICE_FUNC\n  EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return numext::abs2(a); }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const\n  { return internal::pmul(a,a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_abs2_op<Scalar> >\n{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasAbs2 }; };\n\n/** \\internal\n  * \\brief Template functor to compute the conjugate of a complex value\n  *\n  * \\sa class CwiseUnaryOp, MatrixBase::conjugate()\n  */\ntemplate<typename Scalar> struct scalar_conjugate_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_conjugate_op)\n  EIGEN_DEVICE_FUNC\n  EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { using numext::conj; return conj(a); }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const { return internal::pconj(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_conjugate_op<Scalar> >\n{\n  enum {\n    Cost = NumTraits<Scalar>::IsComplex ? NumTraits<Scalar>::AddCost : 0,\n    PacketAccess = packet_traits<Scalar>::HasConj\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the phase angle of a complex\n  *\n  * \\sa class CwiseUnaryOp, Cwise::arg\n  */\ntemplate<typename Scalar> struct scalar_arg_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_arg_op)\n  typedef typename NumTraits<Scalar>::Real result_type;\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { using numext::arg; return arg(a); }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const\n  { return internal::parg(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_arg_op<Scalar> >\n{\n  enum {\n    Cost = NumTraits<Scalar>::IsComplex ? 5 * NumTraits<Scalar>::MulCost : NumTraits<Scalar>::AddCost,\n    PacketAccess = packet_traits<Scalar>::HasArg\n  };\n};\n/** \\internal\n  * \\brief Template functor to cast a scalar to another type\n  *\n  * \\sa class CwiseUnaryOp, MatrixBase::cast()\n  */\ntemplate<typename Scalar, typename NewType>\nstruct scalar_cast_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op)\n  typedef NewType result_type;\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const NewType operator() (const Scalar& a) const { return cast<Scalar, NewType>(a); }\n};\ntemplate<typename Scalar, typename NewType>\nstruct functor_traits<scalar_cast_op<Scalar,NewType> >\n{ enum { Cost = is_same<Scalar, NewType>::value ? 0 : NumTraits<NewType>::AddCost, PacketAccess = false }; };\n\n/** \\internal\n  * \\brief Template functor to extract the real part of a complex\n  *\n  * \\sa class CwiseUnaryOp, MatrixBase::real()\n  */\ntemplate<typename Scalar>\nstruct scalar_real_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_real_op)\n  typedef typename NumTraits<Scalar>::Real result_type;\n  EIGEN_DEVICE_FUNC\n  EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::real(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_real_op<Scalar> >\n{ enum { Cost = 0, PacketAccess = false }; };\n\n/** \\internal\n  * \\brief Template functor to extract the imaginary part of a complex\n  *\n  * \\sa class CwiseUnaryOp, MatrixBase::imag()\n  */\ntemplate<typename Scalar>\nstruct scalar_imag_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_imag_op)\n  typedef typename NumTraits<Scalar>::Real result_type;\n  EIGEN_DEVICE_FUNC\n  EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::imag(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_imag_op<Scalar> >\n{ enum { Cost = 0, PacketAccess = false }; };\n\n/** \\internal\n  * \\brief Template functor to extract the real part of a complex as a reference\n  *\n  * \\sa class CwiseUnaryOp, MatrixBase::real()\n  */\ntemplate<typename Scalar>\nstruct scalar_real_ref_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_real_ref_op)\n  typedef typename NumTraits<Scalar>::Real result_type;\n  EIGEN_DEVICE_FUNC\n  EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return numext::real_ref(*const_cast<Scalar*>(&a)); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_real_ref_op<Scalar> >\n{ enum { Cost = 0, PacketAccess = false }; };\n\n/** \\internal\n  * \\brief Template functor to extract the imaginary part of a complex as a reference\n  *\n  * \\sa class CwiseUnaryOp, MatrixBase::imag()\n  */\ntemplate<typename Scalar>\nstruct scalar_imag_ref_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_imag_ref_op)\n  typedef typename NumTraits<Scalar>::Real result_type;\n  EIGEN_DEVICE_FUNC\n  EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return numext::imag_ref(*const_cast<Scalar*>(&a)); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_imag_ref_op<Scalar> >\n{ enum { Cost = 0, PacketAccess = false }; };\n\n/** \\internal\n  *\n  * \\brief Template functor to compute the exponential of a scalar\n  *\n  * \\sa class CwiseUnaryOp, Cwise::exp()\n  */\ntemplate<typename Scalar> struct scalar_exp_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_exp_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::exp(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pexp(a); }\n};\ntemplate <typename Scalar>\nstruct functor_traits<scalar_exp_op<Scalar> > {\n  enum {\n    PacketAccess = packet_traits<Scalar>::HasExp,\n    // The following numbers are based on the AVX implementation.\n#ifdef EIGEN_VECTORIZE_FMA\n    // Haswell can issue 2 add/mul/madd per cycle.\n    Cost =\n    (sizeof(Scalar) == 4\n     // float: 8 pmadd, 4 pmul, 2 padd/psub, 6 other\n     ? (8 * NumTraits<Scalar>::AddCost + 6 * NumTraits<Scalar>::MulCost)\n     // double: 7 pmadd, 5 pmul, 3 padd/psub, 1 div,  13 other\n     : (14 * NumTraits<Scalar>::AddCost +\n        6 * NumTraits<Scalar>::MulCost +\n        scalar_div_cost<Scalar,packet_traits<Scalar>::HasDiv>::value))\n#else\n    Cost =\n    (sizeof(Scalar) == 4\n     // float: 7 pmadd, 6 pmul, 4 padd/psub, 10 other\n     ? (21 * NumTraits<Scalar>::AddCost + 13 * NumTraits<Scalar>::MulCost)\n     // double: 7 pmadd, 5 pmul, 3 padd/psub, 1 div,  13 other\n     : (23 * NumTraits<Scalar>::AddCost +\n        12 * NumTraits<Scalar>::MulCost +\n        scalar_div_cost<Scalar,packet_traits<Scalar>::HasDiv>::value))\n#endif\n  };\n};\n\n/** \\internal\n  *\n  * \\brief Template functor to compute the logarithm of a scalar\n  *\n  * \\sa class CwiseUnaryOp, ArrayBase::log()\n  */\ntemplate<typename Scalar> struct scalar_log_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_log_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::log(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::plog(a); }\n};\ntemplate <typename Scalar>\nstruct functor_traits<scalar_log_op<Scalar> > {\n  enum {\n    PacketAccess = packet_traits<Scalar>::HasLog,\n    Cost =\n    (PacketAccess\n     // The following numbers are based on the AVX implementation.\n#ifdef EIGEN_VECTORIZE_FMA\n     // 8 pmadd, 6 pmul, 8 padd/psub, 16 other, can issue 2 add/mul/madd per cycle.\n     ? (20 * NumTraits<Scalar>::AddCost + 7 * NumTraits<Scalar>::MulCost)\n#else\n     // 8 pmadd, 6 pmul, 8 padd/psub, 20 other\n     ? (36 * NumTraits<Scalar>::AddCost + 14 * NumTraits<Scalar>::MulCost)\n#endif\n     // Measured cost of std::log.\n     : sizeof(Scalar)==4 ? 40 : 85)\n  };\n};\n\n/** \\internal\n  *\n  * \\brief Template functor to compute the logarithm of 1 plus a scalar value\n  *\n  * \\sa class CwiseUnaryOp, ArrayBase::log1p()\n  */\ntemplate<typename Scalar> struct scalar_log1p_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_log1p_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::log1p(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::plog1p(a); }\n};\ntemplate <typename Scalar>\nstruct functor_traits<scalar_log1p_op<Scalar> > {\n  enum {\n    PacketAccess = packet_traits<Scalar>::HasLog1p,\n    Cost = functor_traits<scalar_log_op<Scalar> >::Cost // TODO measure cost of log1p\n  };\n};\n\n/** \\internal\n  *\n  * \\brief Template functor to compute the base-10 logarithm of a scalar\n  *\n  * \\sa class CwiseUnaryOp, Cwise::log10()\n  */\ntemplate<typename Scalar> struct scalar_log10_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_log10_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { EIGEN_USING_STD_MATH(log10) return log10(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::plog10(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_log10_op<Scalar> >\n{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasLog10 }; };\n\n/** \\internal\n  * \\brief Template functor to compute the square root of a scalar\n  * \\sa class CwiseUnaryOp, Cwise::sqrt()\n  */\ntemplate<typename Scalar> struct scalar_sqrt_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_sqrt_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::sqrt(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::psqrt(a); }\n};\ntemplate <typename Scalar>\nstruct functor_traits<scalar_sqrt_op<Scalar> > {\n  enum {\n#if EIGEN_FAST_MATH\n    // The following numbers are based on the AVX implementation.\n    Cost = (sizeof(Scalar) == 8 ? 28\n                                // 4 pmul, 1 pmadd, 3 other\n                                : (3 * NumTraits<Scalar>::AddCost +\n                                   5 * NumTraits<Scalar>::MulCost)),\n#else\n    // The following numbers are based on min VSQRT throughput on Haswell.\n    Cost = (sizeof(Scalar) == 8 ? 28 : 14),\n#endif\n    PacketAccess = packet_traits<Scalar>::HasSqrt\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the reciprocal square root of a scalar\n  * \\sa class CwiseUnaryOp, Cwise::rsqrt()\n  */\ntemplate<typename Scalar> struct scalar_rsqrt_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_rsqrt_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return Scalar(1)/numext::sqrt(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::prsqrt(a); }\n};\n\ntemplate<typename Scalar>\nstruct functor_traits<scalar_rsqrt_op<Scalar> >\n{ enum {\n    Cost = 5 * NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasRsqrt\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the cosine of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::cos()\n  */\ntemplate<typename Scalar> struct scalar_cos_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cos_op)\n  EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { return numext::cos(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pcos(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_cos_op<Scalar> >\n{\n  enum {\n    Cost = 5 * NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasCos\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the sine of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::sin()\n  */\ntemplate<typename Scalar> struct scalar_sin_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_sin_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::sin(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::psin(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_sin_op<Scalar> >\n{\n  enum {\n    Cost = 5 * NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasSin\n  };\n};\n\n\n/** \\internal\n  * \\brief Template functor to compute the tan of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::tan()\n  */\ntemplate<typename Scalar> struct scalar_tan_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_tan_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::tan(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::ptan(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_tan_op<Scalar> >\n{\n  enum {\n    Cost = 5 * NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasTan\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the arc cosine of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::acos()\n  */\ntemplate<typename Scalar> struct scalar_acos_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_acos_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::acos(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pacos(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_acos_op<Scalar> >\n{\n  enum {\n    Cost = 5 * NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasACos\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the arc sine of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::asin()\n  */\ntemplate<typename Scalar> struct scalar_asin_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_asin_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::asin(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pasin(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_asin_op<Scalar> >\n{\n  enum {\n    Cost = 5 * NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasASin\n  };\n};\n\n\n/** \\internal\n  * \\brief Template functor to compute the atan of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::atan()\n  */\ntemplate<typename Scalar> struct scalar_atan_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_atan_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::atan(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::patan(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_atan_op<Scalar> >\n{\n  enum {\n    Cost = 5 * NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasATan\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the tanh of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::tanh()\n  */\ntemplate <typename Scalar>\nstruct scalar_tanh_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_tanh_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator()(const Scalar& a) const { return numext::tanh(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& x) const { return ptanh(x); }\n};\n\ntemplate <typename Scalar>\nstruct functor_traits<scalar_tanh_op<Scalar> > {\n  enum {\n    PacketAccess = packet_traits<Scalar>::HasTanh,\n    Cost = ( (EIGEN_FAST_MATH && is_same<Scalar,float>::value)\n// The following numbers are based on the AVX implementation,\n#ifdef EIGEN_VECTORIZE_FMA\n                // Haswell can issue 2 add/mul/madd per cycle.\n                // 9 pmadd, 2 pmul, 1 div, 2 other\n                ? (2 * NumTraits<Scalar>::AddCost +\n                   6 * NumTraits<Scalar>::MulCost +\n                   scalar_div_cost<Scalar,packet_traits<Scalar>::HasDiv>::value)\n#else\n                ? (11 * NumTraits<Scalar>::AddCost +\n                   11 * NumTraits<Scalar>::MulCost +\n                   scalar_div_cost<Scalar,packet_traits<Scalar>::HasDiv>::value)\n#endif\n                // This number assumes a naive implementation of tanh\n                : (6 * NumTraits<Scalar>::AddCost +\n                   3 * NumTraits<Scalar>::MulCost +\n                   2 * scalar_div_cost<Scalar,packet_traits<Scalar>::HasDiv>::value +\n                   functor_traits<scalar_exp_op<Scalar> >::Cost))\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the sinh of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::sinh()\n  */\ntemplate<typename Scalar> struct scalar_sinh_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_sinh_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::sinh(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::psinh(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_sinh_op<Scalar> >\n{\n  enum {\n    Cost = 5 * NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasSinh\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the cosh of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::cosh()\n  */\ntemplate<typename Scalar> struct scalar_cosh_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cosh_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::cosh(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pcosh(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_cosh_op<Scalar> >\n{\n  enum {\n    Cost = 5 * NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasCosh\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the inverse of a scalar\n  * \\sa class CwiseUnaryOp, Cwise::inverse()\n  */\ntemplate<typename Scalar>\nstruct scalar_inverse_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_inverse_op)\n  EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { return Scalar(1)/a; }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC inline const Packet packetOp(const Packet& a) const\n  { return internal::pdiv(pset1<Packet>(Scalar(1)),a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_inverse_op<Scalar> >\n{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasDiv }; };\n\n/** \\internal\n  * \\brief Template functor to compute the square of a scalar\n  * \\sa class CwiseUnaryOp, Cwise::square()\n  */\ntemplate<typename Scalar>\nstruct scalar_square_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_square_op)\n  EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { return a*a; }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC inline const Packet packetOp(const Packet& a) const\n  { return internal::pmul(a,a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_square_op<Scalar> >\n{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasMul }; };\n\n/** \\internal\n  * \\brief Template functor to compute the cube of a scalar\n  * \\sa class CwiseUnaryOp, Cwise::cube()\n  */\ntemplate<typename Scalar>\nstruct scalar_cube_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_cube_op)\n  EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { return a*a*a; }\n  template<typename Packet>\n  EIGEN_DEVICE_FUNC inline const Packet packetOp(const Packet& a) const\n  { return internal::pmul(a,pmul(a,a)); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_cube_op<Scalar> >\n{ enum { Cost = 2*NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasMul }; };\n\n/** \\internal\n  * \\brief Template functor to compute the rounded value of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::round()\n  */\ntemplate<typename Scalar> struct scalar_round_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_round_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return numext::round(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pround(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_round_op<Scalar> >\n{\n  enum {\n    Cost = NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasRound\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the floor of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::floor()\n  */\ntemplate<typename Scalar> struct scalar_floor_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_floor_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return numext::floor(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pfloor(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_floor_op<Scalar> >\n{\n  enum {\n    Cost = NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasFloor\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the ceil of a scalar\n  * \\sa class CwiseUnaryOp, ArrayBase::ceil()\n  */\ntemplate<typename Scalar> struct scalar_ceil_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_ceil_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return numext::ceil(a); }\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pceil(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_ceil_op<Scalar> >\n{\n  enum {\n    Cost = NumTraits<Scalar>::MulCost,\n    PacketAccess = packet_traits<Scalar>::HasCeil\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute whether a scalar is NaN\n  * \\sa class CwiseUnaryOp, ArrayBase::isnan()\n  */\ntemplate<typename Scalar> struct scalar_isnan_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_isnan_op)\n  typedef bool result_type;\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return (numext::isnan)(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_isnan_op<Scalar> >\n{\n  enum {\n    Cost = NumTraits<Scalar>::MulCost,\n    PacketAccess = false\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to check whether a scalar is +/-inf\n  * \\sa class CwiseUnaryOp, ArrayBase::isinf()\n  */\ntemplate<typename Scalar> struct scalar_isinf_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_isinf_op)\n  typedef bool result_type;\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return (numext::isinf)(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_isinf_op<Scalar> >\n{\n  enum {\n    Cost = NumTraits<Scalar>::MulCost,\n    PacketAccess = false\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to check whether a scalar has a finite value\n  * \\sa class CwiseUnaryOp, ArrayBase::isfinite()\n  */\ntemplate<typename Scalar> struct scalar_isfinite_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_isfinite_op)\n  typedef bool result_type;\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return (numext::isfinite)(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_isfinite_op<Scalar> >\n{\n  enum {\n    Cost = NumTraits<Scalar>::MulCost,\n    PacketAccess = false\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the logical not of a boolean\n  *\n  * \\sa class CwiseUnaryOp, ArrayBase::operator!\n  */\ntemplate<typename Scalar> struct scalar_boolean_not_op {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_boolean_not_op)\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator() (const bool& a) const { return !a; }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_boolean_not_op<Scalar> > {\n  enum {\n    Cost = NumTraits<bool>::AddCost,\n    PacketAccess = false\n  };\n};\n\n/** \\internal\n  * \\brief Template functor to compute the signum of a scalar\n  * \\sa class CwiseUnaryOp, Cwise::sign()\n  */\ntemplate<typename Scalar,bool iscpx=(NumTraits<Scalar>::IsComplex!=0) > struct scalar_sign_op;\ntemplate<typename Scalar>\nstruct scalar_sign_op<Scalar,false> {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_sign_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const\n  {\n      return Scalar( (a>Scalar(0)) - (a<Scalar(0)) );\n  }\n  //TODO\n  //template <typename Packet>\n  //EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::psign(a); }\n};\ntemplate<typename Scalar>\nstruct scalar_sign_op<Scalar,true> {\n  EIGEN_EMPTY_STRUCT_CTOR(scalar_sign_op)\n  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const\n  {\n    typedef typename NumTraits<Scalar>::Real real_type;\n    real_type aa = numext::abs(a);\n    if (aa==real_type(0))\n      return Scalar(0);\n    aa = real_type(1)/aa;\n    return Scalar(real(a)*aa, imag(a)*aa );\n  }\n  //TODO\n  //template <typename Packet>\n  //EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::psign(a); }\n};\ntemplate<typename Scalar>\nstruct functor_traits<scalar_sign_op<Scalar> >\n{ enum {\n    Cost = \n        NumTraits<Scalar>::IsComplex\n        ? ( 8*NumTraits<Scalar>::MulCost  ) // roughly\n        : ( 3*NumTraits<Scalar>::AddCost),\n    PacketAccess = packet_traits<Scalar>::HasSign\n  };\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_FUNCTORS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/GeneralBlockPanelKernel.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_GENERAL_BLOCK_PANEL_H\n#define EIGEN_GENERAL_BLOCK_PANEL_H\n\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<typename _LhsScalar, typename _RhsScalar, bool _ConjLhs=false, bool _ConjRhs=false>\nclass gebp_traits;\n\n\n/** \\internal \\returns b if a<=0, and returns a otherwise. */\ninline std::ptrdiff_t manage_caching_sizes_helper(std::ptrdiff_t a, std::ptrdiff_t b)\n{\n  return a<=0 ? b : a;\n}\n\n#if EIGEN_ARCH_i386_OR_x86_64\nconst std::ptrdiff_t defaultL1CacheSize = 32*1024;\nconst std::ptrdiff_t defaultL2CacheSize = 256*1024;\nconst std::ptrdiff_t defaultL3CacheSize = 2*1024*1024;\n#else\nconst std::ptrdiff_t defaultL1CacheSize = 16*1024;\nconst std::ptrdiff_t defaultL2CacheSize = 512*1024;\nconst std::ptrdiff_t defaultL3CacheSize = 512*1024;\n#endif\n\n/** \\internal */\nstruct CacheSizes {\n  CacheSizes(): m_l1(-1),m_l2(-1),m_l3(-1) {\n    int l1CacheSize, l2CacheSize, l3CacheSize;\n    queryCacheSizes(l1CacheSize, l2CacheSize, l3CacheSize);\n    m_l1 = manage_caching_sizes_helper(l1CacheSize, defaultL1CacheSize);\n    m_l2 = manage_caching_sizes_helper(l2CacheSize, defaultL2CacheSize);\n    m_l3 = manage_caching_sizes_helper(l3CacheSize, defaultL3CacheSize);\n  }\n\n  std::ptrdiff_t m_l1;\n  std::ptrdiff_t m_l2;\n  std::ptrdiff_t m_l3;\n};\n\n\n/** \\internal */\ninline void manage_caching_sizes(Action action, std::ptrdiff_t* l1, std::ptrdiff_t* l2, std::ptrdiff_t* l3)\n{\n  static CacheSizes m_cacheSizes;\n\n  if(action==SetAction)\n  {\n    // set the cpu cache size and cache all block sizes from a global cache size in byte\n    eigen_internal_assert(l1!=0 && l2!=0);\n    m_cacheSizes.m_l1 = *l1;\n    m_cacheSizes.m_l2 = *l2;\n    m_cacheSizes.m_l3 = *l3;\n  }\n  else if(action==GetAction)\n  {\n    eigen_internal_assert(l1!=0 && l2!=0);\n    *l1 = m_cacheSizes.m_l1;\n    *l2 = m_cacheSizes.m_l2;\n    *l3 = m_cacheSizes.m_l3;\n  }\n  else\n  {\n    eigen_internal_assert(false);\n  }\n}\n\n/* Helper for computeProductBlockingSizes.\n *\n * Given a m x k times k x n matrix product of scalar types \\c LhsScalar and \\c RhsScalar,\n * this function computes the blocking size parameters along the respective dimensions\n * for matrix products and related algorithms. The blocking sizes depends on various\n * parameters:\n * - the L1 and L2 cache sizes,\n * - the register level blocking sizes defined by gebp_traits,\n * - the number of scalars that fit into a packet (when vectorization is enabled).\n *\n * \\sa setCpuCacheSizes */\n\ntemplate<typename LhsScalar, typename RhsScalar, int KcFactor, typename Index>\nvoid evaluateProductBlockingSizesHeuristic(Index& k, Index& m, Index& n, Index num_threads = 1)\n{\n  typedef gebp_traits<LhsScalar,RhsScalar> Traits;\n\n  // Explanations:\n  // Let's recall that the product algorithms form mc x kc vertical panels A' on the lhs and\n  // kc x nc blocks B' on the rhs. B' has to fit into L2/L3 cache. Moreover, A' is processed\n  // per mr x kc horizontal small panels where mr is the blocking size along the m dimension\n  // at the register level. This small horizontal panel has to stay within L1 cache.\n  std::ptrdiff_t l1, l2, l3;\n  manage_caching_sizes(GetAction, &l1, &l2, &l3);\n\n  if (num_threads > 1) {\n    typedef typename Traits::ResScalar ResScalar;\n    enum {\n      kdiv = KcFactor * (Traits::mr * sizeof(LhsScalar) + Traits::nr * sizeof(RhsScalar)),\n      ksub = Traits::mr * Traits::nr * sizeof(ResScalar),\n      kr = 8,\n      mr = Traits::mr,\n      nr = Traits::nr\n    };\n    // Increasing k gives us more time to prefetch the content of the \"C\"\n    // registers. However once the latency is hidden there is no point in\n    // increasing the value of k, so we'll cap it at 320 (value determined\n    // experimentally).\n    const Index k_cache = (numext::mini<Index>)((l1-ksub)/kdiv, 320);\n    if (k_cache < k) {\n      k = k_cache - (k_cache % kr);\n      eigen_internal_assert(k > 0);\n    }\n\n    const Index n_cache = (l2-l1) / (nr * sizeof(RhsScalar) * k);\n    const Index n_per_thread = numext::div_ceil(n, num_threads);\n    if (n_cache <= n_per_thread) {\n      // Don't exceed the capacity of the l2 cache.\n      eigen_internal_assert(n_cache >= static_cast<Index>(nr));\n      n = n_cache - (n_cache % nr);\n      eigen_internal_assert(n > 0);\n    } else {\n      n = (numext::mini<Index>)(n, (n_per_thread + nr - 1) - ((n_per_thread + nr - 1) % nr));\n    }\n\n    if (l3 > l2) {\n      // l3 is shared between all cores, so we'll give each thread its own chunk of l3.\n      const Index m_cache = (l3-l2) / (sizeof(LhsScalar) * k * num_threads);\n      const Index m_per_thread = numext::div_ceil(m, num_threads);\n      if(m_cache < m_per_thread && m_cache >= static_cast<Index>(mr)) {\n        m = m_cache - (m_cache % mr);\n        eigen_internal_assert(m > 0);\n      } else {\n        m = (numext::mini<Index>)(m, (m_per_thread + mr - 1) - ((m_per_thread + mr - 1) % mr));\n      }\n    }\n  }\n  else {\n    // In unit tests we do not want to use extra large matrices,\n    // so we reduce the cache size to check the blocking strategy is not flawed\n#ifdef EIGEN_DEBUG_SMALL_PRODUCT_BLOCKS\n    l1 = 9*1024;\n    l2 = 32*1024;\n    l3 = 512*1024;\n#endif\n\n    // Early return for small problems because the computation below are time consuming for small problems.\n    // Perhaps it would make more sense to consider k*n*m??\n    // Note that for very tiny problem, this function should be bypassed anyway\n    // because we use the coefficient-based implementation for them.\n    if((numext::maxi)(k,(numext::maxi)(m,n))<48)\n      return;\n\n    typedef typename Traits::ResScalar ResScalar;\n    enum {\n      k_peeling = 8,\n      k_div = KcFactor * (Traits::mr * sizeof(LhsScalar) + Traits::nr * sizeof(RhsScalar)),\n      k_sub = Traits::mr * Traits::nr * sizeof(ResScalar)\n    };\n\n    // ---- 1st level of blocking on L1, yields kc ----\n\n    // Blocking on the third dimension (i.e., k) is chosen so that an horizontal panel\n    // of size mr x kc of the lhs plus a vertical panel of kc x nr of the rhs both fits within L1 cache.\n    // We also include a register-level block of the result (mx x nr).\n    // (In an ideal world only the lhs panel would stay in L1)\n    // Moreover, kc has to be a multiple of 8 to be compatible with loop peeling, leading to a maximum blocking size of:\n    const Index max_kc = numext::maxi<Index>(((l1-k_sub)/k_div) & (~(k_peeling-1)),1);\n    const Index old_k = k;\n    if(k>max_kc)\n    {\n      // We are really blocking on the third dimension:\n      // -> reduce blocking size to make sure the last block is as large as possible\n      //    while keeping the same number of sweeps over the result.\n      k = (k%max_kc)==0 ? max_kc\n                        : max_kc - k_peeling * ((max_kc-1-(k%max_kc))/(k_peeling*(k/max_kc+1)));\n\n      eigen_internal_assert(((old_k/k) == (old_k/max_kc)) && \"the number of sweeps has to remain the same\");\n    }\n\n    // ---- 2nd level of blocking on max(L2,L3), yields nc ----\n\n    // TODO find a reliable way to get the actual amount of cache per core to use for 2nd level blocking, that is:\n    //      actual_l2 = max(l2, l3/nb_core_sharing_l3)\n    // The number below is quite conservative: it is better to underestimate the cache size rather than overestimating it)\n    // For instance, it corresponds to 6MB of L3 shared among 4 cores.\n    #ifdef EIGEN_DEBUG_SMALL_PRODUCT_BLOCKS\n    const Index actual_l2 = l3;\n    #else\n    const Index actual_l2 = 1572864; // == 1.5 MB\n    #endif\n\n    // Here, nc is chosen such that a block of kc x nc of the rhs fit within half of L2.\n    // The second half is implicitly reserved to access the result and lhs coefficients.\n    // When k<max_kc, then nc can arbitrarily growth. In practice, it seems to be fruitful\n    // to limit this growth: we bound nc to growth by a factor x1.5.\n    // However, if the entire lhs block fit within L1, then we are not going to block on the rows at all,\n    // and it becomes fruitful to keep the packed rhs blocks in L1 if there is enough remaining space.\n    Index max_nc;\n    const Index lhs_bytes = m * k * sizeof(LhsScalar);\n    const Index remaining_l1 = l1- k_sub - lhs_bytes;\n    if(remaining_l1 >= Index(Traits::nr*sizeof(RhsScalar))*k)\n    {\n      // L1 blocking\n      max_nc = remaining_l1 / (k*sizeof(RhsScalar));\n    }\n    else\n    {\n      // L2 blocking\n      max_nc = (3*actual_l2)/(2*2*max_kc*sizeof(RhsScalar));\n    }\n    // WARNING Below, we assume that Traits::nr is a power of two.\n    Index nc = numext::mini<Index>(actual_l2/(2*k*sizeof(RhsScalar)), max_nc) & (~(Traits::nr-1));\n    if(n>nc)\n    {\n      // We are really blocking over the columns:\n      // -> reduce blocking size to make sure the last block is as large as possible\n      //    while keeping the same number of sweeps over the packed lhs.\n      //    Here we allow one more sweep if this gives us a perfect match, thus the commented \"-1\"\n      n = (n%nc)==0 ? nc\n                    : (nc - Traits::nr * ((nc/*-1*/-(n%nc))/(Traits::nr*(n/nc+1))));\n    }\n    else if(old_k==k)\n    {\n      // So far, no blocking at all, i.e., kc==k, and nc==n.\n      // In this case, let's perform a blocking over the rows such that the packed lhs data is kept in cache L1/L2\n      // TODO: part of this blocking strategy is now implemented within the kernel itself, so the L1-based heuristic here should be obsolete.\n      Index problem_size = k*n*sizeof(LhsScalar);\n      Index actual_lm = actual_l2;\n      Index max_mc = m;\n      if(problem_size<=1024)\n      {\n        // problem is small enough to keep in L1\n        // Let's choose m such that lhs's block fit in 1/3 of L1\n        actual_lm = l1;\n      }\n      else if(l3!=0 && problem_size<=32768)\n      {\n        // we have both L2 and L3, and problem is small enough to be kept in L2\n        // Let's choose m such that lhs's block fit in 1/3 of L2\n        actual_lm = l2;\n        max_mc = (numext::mini<Index>)(576,max_mc);\n      }\n      Index mc = (numext::mini<Index>)(actual_lm/(3*k*sizeof(LhsScalar)), max_mc);\n      if (mc > Traits::mr) mc -= mc % Traits::mr;\n      else if (mc==0) return;\n      m = (m%mc)==0 ? mc\n                    : (mc - Traits::mr * ((mc/*-1*/-(m%mc))/(Traits::mr*(m/mc+1))));\n    }\n  }\n}\n\ntemplate <typename Index>\ninline bool useSpecificBlockingSizes(Index& k, Index& m, Index& n)\n{\n#ifdef EIGEN_TEST_SPECIFIC_BLOCKING_SIZES\n  if (EIGEN_TEST_SPECIFIC_BLOCKING_SIZES) {\n    k = numext::mini<Index>(k, EIGEN_TEST_SPECIFIC_BLOCKING_SIZE_K);\n    m = numext::mini<Index>(m, EIGEN_TEST_SPECIFIC_BLOCKING_SIZE_M);\n    n = numext::mini<Index>(n, EIGEN_TEST_SPECIFIC_BLOCKING_SIZE_N);\n    return true;\n  }\n#else\n  EIGEN_UNUSED_VARIABLE(k)\n  EIGEN_UNUSED_VARIABLE(m)\n  EIGEN_UNUSED_VARIABLE(n)\n#endif\n  return false;\n}\n\n/** \\brief Computes the blocking parameters for a m x k times k x n matrix product\n  *\n  * \\param[in,out] k Input: the third dimension of the product. Output: the blocking size along the same dimension.\n  * \\param[in,out] m Input: the number of rows of the left hand side. Output: the blocking size along the same dimension.\n  * \\param[in,out] n Input: the number of columns of the right hand side. Output: the blocking size along the same dimension.\n  *\n  * Given a m x k times k x n matrix product of scalar types \\c LhsScalar and \\c RhsScalar,\n  * this function computes the blocking size parameters along the respective dimensions\n  * for matrix products and related algorithms.\n  *\n  * The blocking size parameters may be evaluated:\n  *   - either by a heuristic based on cache sizes;\n  *   - or using fixed prescribed values (for testing purposes).\n  *\n  * \\sa setCpuCacheSizes */\n\ntemplate<typename LhsScalar, typename RhsScalar, int KcFactor, typename Index>\nvoid computeProductBlockingSizes(Index& k, Index& m, Index& n, Index num_threads = 1)\n{\n  if (!useSpecificBlockingSizes(k, m, n)) {\n    evaluateProductBlockingSizesHeuristic<LhsScalar, RhsScalar, KcFactor, Index>(k, m, n, num_threads);\n  }\n}\n\ntemplate<typename LhsScalar, typename RhsScalar, typename Index>\ninline void computeProductBlockingSizes(Index& k, Index& m, Index& n, Index num_threads = 1)\n{\n  computeProductBlockingSizes<LhsScalar,RhsScalar,1,Index>(k, m, n, num_threads);\n}\n\n#ifdef EIGEN_HAS_SINGLE_INSTRUCTION_CJMADD\n  #define CJMADD(CJ,A,B,C,T)  C = CJ.pmadd(A,B,C);\n#else\n\n  // FIXME (a bit overkill maybe ?)\n\n  template<typename CJ, typename A, typename B, typename C, typename T> struct gebp_madd_selector {\n    EIGEN_ALWAYS_INLINE static void run(const CJ& cj, A& a, B& b, C& c, T& /*t*/)\n    {\n      c = cj.pmadd(a,b,c);\n    }\n  };\n\n  template<typename CJ, typename T> struct gebp_madd_selector<CJ,T,T,T,T> {\n    EIGEN_ALWAYS_INLINE static void run(const CJ& cj, T& a, T& b, T& c, T& t)\n    {\n      t = b; t = cj.pmul(a,t); c = padd(c,t);\n    }\n  };\n\n  template<typename CJ, typename A, typename B, typename C, typename T>\n  EIGEN_STRONG_INLINE void gebp_madd(const CJ& cj, A& a, B& b, C& c, T& t)\n  {\n    gebp_madd_selector<CJ,A,B,C,T>::run(cj,a,b,c,t);\n  }\n\n  #define CJMADD(CJ,A,B,C,T)  gebp_madd(CJ,A,B,C,T);\n//   #define CJMADD(CJ,A,B,C,T)  T = B; T = CJ.pmul(A,T); C = padd(C,T);\n#endif\n\n/* Vectorization logic\n *  real*real: unpack rhs to constant packets, ...\n * \n *  cd*cd : unpack rhs to (b_r,b_r), (b_i,b_i), mul to get (a_r b_r,a_i b_r) (a_r b_i,a_i b_i),\n *          storing each res packet into two packets (2x2),\n *          at the end combine them: swap the second and addsub them \n *  cf*cf : same but with 2x4 blocks\n *  cplx*real : unpack rhs to constant packets, ...\n *  real*cplx : load lhs as (a0,a0,a1,a1), and mul as usual\n */\ntemplate<typename _LhsScalar, typename _RhsScalar, bool _ConjLhs, bool _ConjRhs>\nclass gebp_traits\n{\npublic:\n  typedef _LhsScalar LhsScalar;\n  typedef _RhsScalar RhsScalar;\n  typedef typename ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType ResScalar;\n\n  enum {\n    ConjLhs = _ConjLhs,\n    ConjRhs = _ConjRhs,\n    Vectorizable = packet_traits<LhsScalar>::Vectorizable && packet_traits<RhsScalar>::Vectorizable,\n    LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1,\n    RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1,\n    ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1,\n    \n    NumberOfRegisters = EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS,\n\n    // register block size along the N direction must be 1 or 4\n    nr = 4,\n\n    // register block size along the M direction (currently, this one cannot be modified)\n    default_mr = (EIGEN_PLAIN_ENUM_MIN(16,NumberOfRegisters)/2/nr)*LhsPacketSize,\n#if defined(EIGEN_HAS_SINGLE_INSTRUCTION_MADD) && !defined(EIGEN_VECTORIZE_ALTIVEC) && !defined(EIGEN_VECTORIZE_VSX)\n    // we assume 16 registers\n    // See bug 992, if the scalar type is not vectorizable but that EIGEN_HAS_SINGLE_INSTRUCTION_MADD is defined,\n    // then using 3*LhsPacketSize triggers non-implemented paths in syrk.\n    mr = Vectorizable ? 3*LhsPacketSize : default_mr,\n#else\n    mr = default_mr,\n#endif\n    \n    LhsProgress = LhsPacketSize,\n    RhsProgress = 1\n  };\n\n  typedef typename packet_traits<LhsScalar>::type  _LhsPacket;\n  typedef typename packet_traits<RhsScalar>::type  _RhsPacket;\n  typedef typename packet_traits<ResScalar>::type  _ResPacket;\n\n  typedef typename conditional<Vectorizable,_LhsPacket,LhsScalar>::type LhsPacket;\n  typedef typename conditional<Vectorizable,_RhsPacket,RhsScalar>::type RhsPacket;\n  typedef typename conditional<Vectorizable,_ResPacket,ResScalar>::type ResPacket;\n\n  typedef ResPacket AccPacket;\n  \n  EIGEN_STRONG_INLINE void initAcc(AccPacket& p)\n  {\n    p = pset1<ResPacket>(ResScalar(0));\n  }\n  \n  EIGEN_STRONG_INLINE void broadcastRhs(const RhsScalar* b, RhsPacket& b0, RhsPacket& b1, RhsPacket& b2, RhsPacket& b3)\n  {\n    pbroadcast4(b, b0, b1, b2, b3);\n  }\n  \n//   EIGEN_STRONG_INLINE void broadcastRhs(const RhsScalar* b, RhsPacket& b0, RhsPacket& b1)\n//   {\n//     pbroadcast2(b, b0, b1);\n//   }\n  \n  template<typename RhsPacketType>\n  EIGEN_STRONG_INLINE void loadRhs(const RhsScalar* b, RhsPacketType& dest) const\n  {\n    dest = pset1<RhsPacketType>(*b);\n  }\n  \n  EIGEN_STRONG_INLINE void loadRhsQuad(const RhsScalar* b, RhsPacket& dest) const\n  {\n    dest = ploadquad<RhsPacket>(b);\n  }\n\n  template<typename LhsPacketType>\n  EIGEN_STRONG_INLINE void loadLhs(const LhsScalar* a, LhsPacketType& dest) const\n  {\n    dest = pload<LhsPacketType>(a);\n  }\n\n  template<typename LhsPacketType>\n  EIGEN_STRONG_INLINE void loadLhsUnaligned(const LhsScalar* a, LhsPacketType& dest) const\n  {\n    dest = ploadu<LhsPacketType>(a);\n  }\n\n  template<typename LhsPacketType, typename RhsPacketType, typename AccPacketType>\n  EIGEN_STRONG_INLINE void madd(const LhsPacketType& a, const RhsPacketType& b, AccPacketType& c, AccPacketType& tmp) const\n  {\n    conj_helper<LhsPacketType,RhsPacketType,ConjLhs,ConjRhs> cj;\n    // It would be a lot cleaner to call pmadd all the time. Unfortunately if we\n    // let gcc allocate the register in which to store the result of the pmul\n    // (in the case where there is no FMA) gcc fails to figure out how to avoid\n    // spilling register.\n#ifdef EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n    EIGEN_UNUSED_VARIABLE(tmp);\n    c = cj.pmadd(a,b,c);\n#else\n    tmp = b; tmp = cj.pmul(a,tmp); c = padd(c,tmp);\n#endif\n  }\n\n  EIGEN_STRONG_INLINE void acc(const AccPacket& c, const ResPacket& alpha, ResPacket& r) const\n  {\n    r = pmadd(c,alpha,r);\n  }\n  \n  template<typename ResPacketHalf>\n  EIGEN_STRONG_INLINE void acc(const ResPacketHalf& c, const ResPacketHalf& alpha, ResPacketHalf& r) const\n  {\n    r = pmadd(c,alpha,r);\n  }\n\n};\n\ntemplate<typename RealScalar, bool _ConjLhs>\nclass gebp_traits<std::complex<RealScalar>, RealScalar, _ConjLhs, false>\n{\npublic:\n  typedef std::complex<RealScalar> LhsScalar;\n  typedef RealScalar RhsScalar;\n  typedef typename ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType ResScalar;\n\n  enum {\n    ConjLhs = _ConjLhs,\n    ConjRhs = false,\n    Vectorizable = packet_traits<LhsScalar>::Vectorizable && packet_traits<RhsScalar>::Vectorizable,\n    LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1,\n    RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1,\n    ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1,\n    \n    NumberOfRegisters = EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS,\n    nr = 4,\n#if defined(EIGEN_HAS_SINGLE_INSTRUCTION_MADD) && !defined(EIGEN_VECTORIZE_ALTIVEC) && !defined(EIGEN_VECTORIZE_VSX)\n    // we assume 16 registers\n    mr = 3*LhsPacketSize,\n#else\n    mr = (EIGEN_PLAIN_ENUM_MIN(16,NumberOfRegisters)/2/nr)*LhsPacketSize,\n#endif\n\n    LhsProgress = LhsPacketSize,\n    RhsProgress = 1\n  };\n\n  typedef typename packet_traits<LhsScalar>::type  _LhsPacket;\n  typedef typename packet_traits<RhsScalar>::type  _RhsPacket;\n  typedef typename packet_traits<ResScalar>::type  _ResPacket;\n\n  typedef typename conditional<Vectorizable,_LhsPacket,LhsScalar>::type LhsPacket;\n  typedef typename conditional<Vectorizable,_RhsPacket,RhsScalar>::type RhsPacket;\n  typedef typename conditional<Vectorizable,_ResPacket,ResScalar>::type ResPacket;\n\n  typedef ResPacket AccPacket;\n\n  EIGEN_STRONG_INLINE void initAcc(AccPacket& p)\n  {\n    p = pset1<ResPacket>(ResScalar(0));\n  }\n\n  EIGEN_STRONG_INLINE void loadRhs(const RhsScalar* b, RhsPacket& dest) const\n  {\n    dest = pset1<RhsPacket>(*b);\n  }\n  \n  EIGEN_STRONG_INLINE void loadRhsQuad(const RhsScalar* b, RhsPacket& dest) const\n  {\n    dest = pset1<RhsPacket>(*b);\n  }\n\n  EIGEN_STRONG_INLINE void loadLhs(const LhsScalar* a, LhsPacket& dest) const\n  {\n    dest = pload<LhsPacket>(a);\n  }\n\n  EIGEN_STRONG_INLINE void loadLhsUnaligned(const LhsScalar* a, LhsPacket& dest) const\n  {\n    dest = ploadu<LhsPacket>(a);\n  }\n\n  EIGEN_STRONG_INLINE void broadcastRhs(const RhsScalar* b, RhsPacket& b0, RhsPacket& b1, RhsPacket& b2, RhsPacket& b3)\n  {\n    pbroadcast4(b, b0, b1, b2, b3);\n  }\n  \n//   EIGEN_STRONG_INLINE void broadcastRhs(const RhsScalar* b, RhsPacket& b0, RhsPacket& b1)\n//   {\n//     pbroadcast2(b, b0, b1);\n//   }\n\n  EIGEN_STRONG_INLINE void madd(const LhsPacket& a, const RhsPacket& b, AccPacket& c, RhsPacket& tmp) const\n  {\n    madd_impl(a, b, c, tmp, typename conditional<Vectorizable,true_type,false_type>::type());\n  }\n\n  EIGEN_STRONG_INLINE void madd_impl(const LhsPacket& a, const RhsPacket& b, AccPacket& c, RhsPacket& tmp, const true_type&) const\n  {\n#ifdef EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n    EIGEN_UNUSED_VARIABLE(tmp);\n    c.v = pmadd(a.v,b,c.v);\n#else\n    tmp = b; tmp = pmul(a.v,tmp); c.v = padd(c.v,tmp);\n#endif\n  }\n\n  EIGEN_STRONG_INLINE void madd_impl(const LhsScalar& a, const RhsScalar& b, ResScalar& c, RhsScalar& /*tmp*/, const false_type&) const\n  {\n    c += a * b;\n  }\n\n  EIGEN_STRONG_INLINE void acc(const AccPacket& c, const ResPacket& alpha, ResPacket& r) const\n  {\n    r = cj.pmadd(c,alpha,r);\n  }\n\nprotected:\n  conj_helper<ResPacket,ResPacket,ConjLhs,false> cj;\n};\n\ntemplate<typename Packet>\nstruct DoublePacket\n{\n  Packet first;\n  Packet second;\n};\n\ntemplate<typename Packet>\nDoublePacket<Packet> padd(const DoublePacket<Packet> &a, const DoublePacket<Packet> &b)\n{\n  DoublePacket<Packet> res;\n  res.first  = padd(a.first, b.first);\n  res.second = padd(a.second,b.second);\n  return res;\n}\n\ntemplate<typename Packet>\nconst DoublePacket<Packet>& predux_downto4(const DoublePacket<Packet> &a)\n{\n  return a;\n}\n\ntemplate<typename Packet> struct unpacket_traits<DoublePacket<Packet> > { typedef DoublePacket<Packet> half; };\n// template<typename Packet>\n// DoublePacket<Packet> pmadd(const DoublePacket<Packet> &a, const DoublePacket<Packet> &b)\n// {\n//   DoublePacket<Packet> res;\n//   res.first  = padd(a.first, b.first);\n//   res.second = padd(a.second,b.second);\n//   return res;\n// }\n\ntemplate<typename RealScalar, bool _ConjLhs, bool _ConjRhs>\nclass gebp_traits<std::complex<RealScalar>, std::complex<RealScalar>, _ConjLhs, _ConjRhs >\n{\npublic:\n  typedef std::complex<RealScalar>  Scalar;\n  typedef std::complex<RealScalar>  LhsScalar;\n  typedef std::complex<RealScalar>  RhsScalar;\n  typedef std::complex<RealScalar>  ResScalar;\n  \n  enum {\n    ConjLhs = _ConjLhs,\n    ConjRhs = _ConjRhs,\n    Vectorizable = packet_traits<RealScalar>::Vectorizable\n                && packet_traits<Scalar>::Vectorizable,\n    RealPacketSize  = Vectorizable ? packet_traits<RealScalar>::size : 1,\n    ResPacketSize   = Vectorizable ? packet_traits<ResScalar>::size : 1,\n    LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1,\n    RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1,\n\n    // FIXME: should depend on NumberOfRegisters\n    nr = 4,\n    mr = ResPacketSize,\n\n    LhsProgress = ResPacketSize,\n    RhsProgress = 1\n  };\n  \n  typedef typename packet_traits<RealScalar>::type RealPacket;\n  typedef typename packet_traits<Scalar>::type     ScalarPacket;\n  typedef DoublePacket<RealPacket> DoublePacketType;\n\n  typedef typename conditional<Vectorizable,RealPacket,  Scalar>::type LhsPacket;\n  typedef typename conditional<Vectorizable,DoublePacketType,Scalar>::type RhsPacket;\n  typedef typename conditional<Vectorizable,ScalarPacket,Scalar>::type ResPacket;\n  typedef typename conditional<Vectorizable,DoublePacketType,Scalar>::type AccPacket;\n  \n  EIGEN_STRONG_INLINE void initAcc(Scalar& p) { p = Scalar(0); }\n\n  EIGEN_STRONG_INLINE void initAcc(DoublePacketType& p)\n  {\n    p.first   = pset1<RealPacket>(RealScalar(0));\n    p.second  = pset1<RealPacket>(RealScalar(0));\n  }\n\n  // Scalar path\n  EIGEN_STRONG_INLINE void loadRhs(const RhsScalar* b, ResPacket& dest) const\n  {\n    dest = pset1<ResPacket>(*b);\n  }\n\n  // Vectorized path\n  EIGEN_STRONG_INLINE void loadRhs(const RhsScalar* b, DoublePacketType& dest) const\n  {\n    dest.first  = pset1<RealPacket>(real(*b));\n    dest.second = pset1<RealPacket>(imag(*b));\n  }\n  \n  EIGEN_STRONG_INLINE void loadRhsQuad(const RhsScalar* b, ResPacket& dest) const\n  {\n    loadRhs(b,dest);\n  }\n  EIGEN_STRONG_INLINE void loadRhsQuad(const RhsScalar* b, DoublePacketType& dest) const\n  {\n    eigen_internal_assert(unpacket_traits<ScalarPacket>::size<=4);\n    loadRhs(b,dest);\n  }\n  \n  EIGEN_STRONG_INLINE void broadcastRhs(const RhsScalar* b, RhsPacket& b0, RhsPacket& b1, RhsPacket& b2, RhsPacket& b3)\n  {\n    // FIXME not sure that's the best way to implement it!\n    loadRhs(b+0, b0);\n    loadRhs(b+1, b1);\n    loadRhs(b+2, b2);\n    loadRhs(b+3, b3);\n  }\n  \n  // Vectorized path\n  EIGEN_STRONG_INLINE void broadcastRhs(const RhsScalar* b, DoublePacketType& b0, DoublePacketType& b1)\n  {\n    // FIXME not sure that's the best way to implement it!\n    loadRhs(b+0, b0);\n    loadRhs(b+1, b1);\n  }\n  \n  // Scalar path\n  EIGEN_STRONG_INLINE void broadcastRhs(const RhsScalar* b, RhsScalar& b0, RhsScalar& b1)\n  {\n    // FIXME not sure that's the best way to implement it!\n    loadRhs(b+0, b0);\n    loadRhs(b+1, b1);\n  }\n\n  // nothing special here\n  EIGEN_STRONG_INLINE void loadLhs(const LhsScalar* a, LhsPacket& dest) const\n  {\n    dest = pload<LhsPacket>((const typename unpacket_traits<LhsPacket>::type*)(a));\n  }\n\n  EIGEN_STRONG_INLINE void loadLhsUnaligned(const LhsScalar* a, LhsPacket& dest) const\n  {\n    dest = ploadu<LhsPacket>((const typename unpacket_traits<LhsPacket>::type*)(a));\n  }\n\n  EIGEN_STRONG_INLINE void madd(const LhsPacket& a, const RhsPacket& b, DoublePacketType& c, RhsPacket& /*tmp*/) const\n  {\n    c.first   = padd(pmul(a,b.first), c.first);\n    c.second  = padd(pmul(a,b.second),c.second);\n  }\n\n  EIGEN_STRONG_INLINE void madd(const LhsPacket& a, const RhsPacket& b, ResPacket& c, RhsPacket& /*tmp*/) const\n  {\n    c = cj.pmadd(a,b,c);\n  }\n  \n  EIGEN_STRONG_INLINE void acc(const Scalar& c, const Scalar& alpha, Scalar& r) const { r += alpha * c; }\n  \n  EIGEN_STRONG_INLINE void acc(const DoublePacketType& c, const ResPacket& alpha, ResPacket& r) const\n  {\n    // assemble c\n    ResPacket tmp;\n    if((!ConjLhs)&&(!ConjRhs))\n    {\n      tmp = pcplxflip(pconj(ResPacket(c.second)));\n      tmp = padd(ResPacket(c.first),tmp);\n    }\n    else if((!ConjLhs)&&(ConjRhs))\n    {\n      tmp = pconj(pcplxflip(ResPacket(c.second)));\n      tmp = padd(ResPacket(c.first),tmp);\n    }\n    else if((ConjLhs)&&(!ConjRhs))\n    {\n      tmp = pcplxflip(ResPacket(c.second));\n      tmp = padd(pconj(ResPacket(c.first)),tmp);\n    }\n    else if((ConjLhs)&&(ConjRhs))\n    {\n      tmp = pcplxflip(ResPacket(c.second));\n      tmp = psub(pconj(ResPacket(c.first)),tmp);\n    }\n    \n    r = pmadd(tmp,alpha,r);\n  }\n\nprotected:\n  conj_helper<LhsScalar,RhsScalar,ConjLhs,ConjRhs> cj;\n};\n\ntemplate<typename RealScalar, bool _ConjRhs>\nclass gebp_traits<RealScalar, std::complex<RealScalar>, false, _ConjRhs >\n{\npublic:\n  typedef std::complex<RealScalar>  Scalar;\n  typedef RealScalar  LhsScalar;\n  typedef Scalar      RhsScalar;\n  typedef Scalar      ResScalar;\n\n  enum {\n    ConjLhs = false,\n    ConjRhs = _ConjRhs,\n    Vectorizable = packet_traits<RealScalar>::Vectorizable\n                && packet_traits<Scalar>::Vectorizable,\n    LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1,\n    RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1,\n    ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1,\n    \n    NumberOfRegisters = EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS,\n    // FIXME: should depend on NumberOfRegisters\n    nr = 4,\n    mr = (EIGEN_PLAIN_ENUM_MIN(16,NumberOfRegisters)/2/nr)*ResPacketSize,\n\n    LhsProgress = ResPacketSize,\n    RhsProgress = 1\n  };\n\n  typedef typename packet_traits<LhsScalar>::type  _LhsPacket;\n  typedef typename packet_traits<RhsScalar>::type  _RhsPacket;\n  typedef typename packet_traits<ResScalar>::type  _ResPacket;\n\n  typedef typename conditional<Vectorizable,_LhsPacket,LhsScalar>::type LhsPacket;\n  typedef typename conditional<Vectorizable,_RhsPacket,RhsScalar>::type RhsPacket;\n  typedef typename conditional<Vectorizable,_ResPacket,ResScalar>::type ResPacket;\n\n  typedef ResPacket AccPacket;\n\n  EIGEN_STRONG_INLINE void initAcc(AccPacket& p)\n  {\n    p = pset1<ResPacket>(ResScalar(0));\n  }\n\n  EIGEN_STRONG_INLINE void loadRhs(const RhsScalar* b, RhsPacket& dest) const\n  {\n    dest = pset1<RhsPacket>(*b);\n  }\n  \n  void broadcastRhs(const RhsScalar* b, RhsPacket& b0, RhsPacket& b1, RhsPacket& b2, RhsPacket& b3)\n  {\n    pbroadcast4(b, b0, b1, b2, b3);\n  }\n  \n//   EIGEN_STRONG_INLINE void broadcastRhs(const RhsScalar* b, RhsPacket& b0, RhsPacket& b1)\n//   {\n//     // FIXME not sure that's the best way to implement it!\n//     b0 = pload1<RhsPacket>(b+0);\n//     b1 = pload1<RhsPacket>(b+1);\n//   }\n\n  EIGEN_STRONG_INLINE void loadLhs(const LhsScalar* a, LhsPacket& dest) const\n  {\n    dest = ploaddup<LhsPacket>(a);\n  }\n  \n  EIGEN_STRONG_INLINE void loadRhsQuad(const RhsScalar* b, RhsPacket& dest) const\n  {\n    eigen_internal_assert(unpacket_traits<RhsPacket>::size<=4);\n    loadRhs(b,dest);\n  }\n\n  EIGEN_STRONG_INLINE void loadLhsUnaligned(const LhsScalar* a, LhsPacket& dest) const\n  {\n    dest = ploaddup<LhsPacket>(a);\n  }\n\n  EIGEN_STRONG_INLINE void madd(const LhsPacket& a, const RhsPacket& b, AccPacket& c, RhsPacket& tmp) const\n  {\n    madd_impl(a, b, c, tmp, typename conditional<Vectorizable,true_type,false_type>::type());\n  }\n\n  EIGEN_STRONG_INLINE void madd_impl(const LhsPacket& a, const RhsPacket& b, AccPacket& c, RhsPacket& tmp, const true_type&) const\n  {\n#ifdef EIGEN_HAS_SINGLE_INSTRUCTION_MADD\n    EIGEN_UNUSED_VARIABLE(tmp);\n    c.v = pmadd(a,b.v,c.v);\n#else\n    tmp = b; tmp.v = pmul(a,tmp.v); c = padd(c,tmp);\n#endif\n    \n  }\n\n  EIGEN_STRONG_INLINE void madd_impl(const LhsScalar& a, const RhsScalar& b, ResScalar& c, RhsScalar& /*tmp*/, const false_type&) const\n  {\n    c += a * b;\n  }\n\n  EIGEN_STRONG_INLINE void acc(const AccPacket& c, const ResPacket& alpha, ResPacket& r) const\n  {\n    r = cj.pmadd(alpha,c,r);\n  }\n\nprotected:\n  conj_helper<ResPacket,ResPacket,false,ConjRhs> cj;\n};\n\n/* optimized GEneral packed Block * packed Panel product kernel\n *\n * Mixing type logic: C += A * B\n *  |  A  |  B  | comments\n *  |real |cplx | no vectorization yet, would require to pack A with duplication\n *  |cplx |real | easy vectorization\n */\ntemplate<typename LhsScalar, typename RhsScalar, typename Index, typename DataMapper, int mr, int nr, bool ConjugateLhs, bool ConjugateRhs>\nstruct gebp_kernel\n{\n  typedef gebp_traits<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> Traits;\n  typedef typename Traits::ResScalar ResScalar;\n  typedef typename Traits::LhsPacket LhsPacket;\n  typedef typename Traits::RhsPacket RhsPacket;\n  typedef typename Traits::ResPacket ResPacket;\n  typedef typename Traits::AccPacket AccPacket;\n\n  typedef gebp_traits<RhsScalar,LhsScalar,ConjugateRhs,ConjugateLhs> SwappedTraits;\n  typedef typename SwappedTraits::ResScalar SResScalar;\n  typedef typename SwappedTraits::LhsPacket SLhsPacket;\n  typedef typename SwappedTraits::RhsPacket SRhsPacket;\n  typedef typename SwappedTraits::ResPacket SResPacket;\n  typedef typename SwappedTraits::AccPacket SAccPacket;\n\n  typedef typename DataMapper::LinearMapper LinearMapper;\n\n  enum {\n    Vectorizable  = Traits::Vectorizable,\n    LhsProgress   = Traits::LhsProgress,\n    RhsProgress   = Traits::RhsProgress,\n    ResPacketSize = Traits::ResPacketSize\n  };\n\n  EIGEN_DONT_INLINE\n  void operator()(const DataMapper& res, const LhsScalar* blockA, const RhsScalar* blockB,\n                  Index rows, Index depth, Index cols, ResScalar alpha,\n                  Index strideA=-1, Index strideB=-1, Index offsetA=0, Index offsetB=0);\n};\n\ntemplate<typename LhsScalar, typename RhsScalar, typename Index, typename DataMapper, int mr, int nr, bool ConjugateLhs, bool ConjugateRhs>\nEIGEN_DONT_INLINE\nvoid gebp_kernel<LhsScalar,RhsScalar,Index,DataMapper,mr,nr,ConjugateLhs,ConjugateRhs>\n  ::operator()(const DataMapper& res, const LhsScalar* blockA, const RhsScalar* blockB,\n               Index rows, Index depth, Index cols, ResScalar alpha,\n               Index strideA, Index strideB, Index offsetA, Index offsetB)\n  {\n    Traits traits;\n    SwappedTraits straits;\n    \n    if(strideA==-1) strideA = depth;\n    if(strideB==-1) strideB = depth;\n    conj_helper<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> cj;\n    Index packet_cols4 = nr>=4 ? (cols/4) * 4 : 0;\n    const Index peeled_mc3 = mr>=3*Traits::LhsProgress ? (rows/(3*LhsProgress))*(3*LhsProgress) : 0;\n    const Index peeled_mc2 = mr>=2*Traits::LhsProgress ? peeled_mc3+((rows-peeled_mc3)/(2*LhsProgress))*(2*LhsProgress) : 0;\n    const Index peeled_mc1 = mr>=1*Traits::LhsProgress ? (rows/(1*LhsProgress))*(1*LhsProgress) : 0;\n    enum { pk = 8 }; // NOTE Such a large peeling factor is important for large matrices (~ +5% when >1000 on Haswell)\n    const Index peeled_kc  = depth & ~(pk-1);\n    const Index prefetch_res_offset = 32/sizeof(ResScalar);    \n//     const Index depth2     = depth & ~1;\n\n    //---------- Process 3 * LhsProgress rows at once ----------\n    // This corresponds to 3*LhsProgress x nr register blocks.\n    // Usually, make sense only with FMA\n    if(mr>=3*Traits::LhsProgress)\n    {\n      // Here, the general idea is to loop on each largest micro horizontal panel of the lhs (3*Traits::LhsProgress x depth)\n      // and on each largest micro vertical panel of the rhs (depth * nr).\n      // Blocking sizes, i.e., 'depth' has been computed so that the micro horizontal panel of the lhs fit in L1.\n      // However, if depth is too small, we can extend the number of rows of these horizontal panels.\n      // This actual number of rows is computed as follow:\n      const Index l1 = defaultL1CacheSize; // in Bytes, TODO, l1 should be passed to this function.\n      // The max(1, ...) here is needed because we may be using blocking params larger than what our known l1 cache size\n      // suggests we should be using: either because our known l1 cache size is inaccurate (e.g. on Android, we can only guess),\n      // or because we are testing specific blocking sizes.\n      const Index actual_panel_rows = (3*LhsProgress) * std::max<Index>(1,( (l1 - sizeof(ResScalar)*mr*nr - depth*nr*sizeof(RhsScalar)) / (depth * sizeof(LhsScalar) * 3*LhsProgress) ));\n      for(Index i1=0; i1<peeled_mc3; i1+=actual_panel_rows)\n      {\n        const Index actual_panel_end = (std::min)(i1+actual_panel_rows, peeled_mc3);\n        for(Index j2=0; j2<packet_cols4; j2+=nr)\n        {\n          for(Index i=i1; i<actual_panel_end; i+=3*LhsProgress)\n          {\n          \n          // We selected a 3*Traits::LhsProgress x nr micro block of res which is entirely\n          // stored into 3 x nr registers.\n          \n          const LhsScalar* blA = &blockA[i*strideA+offsetA*(3*LhsProgress)];\n          prefetch(&blA[0]);\n\n          // gets res block as register\n          AccPacket C0, C1, C2,  C3,\n                    C4, C5, C6,  C7,\n                    C8, C9, C10, C11;\n          traits.initAcc(C0);  traits.initAcc(C1);  traits.initAcc(C2);  traits.initAcc(C3);\n          traits.initAcc(C4);  traits.initAcc(C5);  traits.initAcc(C6);  traits.initAcc(C7);\n          traits.initAcc(C8);  traits.initAcc(C9);  traits.initAcc(C10); traits.initAcc(C11);\n\n          LinearMapper r0 = res.getLinearMapper(i, j2 + 0);\n          LinearMapper r1 = res.getLinearMapper(i, j2 + 1);\n          LinearMapper r2 = res.getLinearMapper(i, j2 + 2);\n          LinearMapper r3 = res.getLinearMapper(i, j2 + 3);\n\n          r0.prefetch(0);\n          r1.prefetch(0);\n          r2.prefetch(0);\n          r3.prefetch(0);\n\n          // performs \"inner\" products\n          const RhsScalar* blB = &blockB[j2*strideB+offsetB*nr];\n          prefetch(&blB[0]);\n          LhsPacket A0, A1;\n\n          for(Index k=0; k<peeled_kc; k+=pk)\n          {\n            EIGEN_ASM_COMMENT(\"begin gebp micro kernel 3pX4\");\n            RhsPacket B_0, T0;\n            LhsPacket A2;\n\n#define EIGEN_GEBP_ONESTEP(K) \\\n            do { \\\n              EIGEN_ASM_COMMENT(\"begin step of gebp micro kernel 3pX4\"); \\\n              EIGEN_ASM_COMMENT(\"Note: these asm comments work around bug 935!\"); \\\n              internal::prefetch(blA+(3*K+16)*LhsProgress); \\\n              if (EIGEN_ARCH_ARM) { internal::prefetch(blB+(4*K+16)*RhsProgress); } /* Bug 953 */ \\\n              traits.loadLhs(&blA[(0+3*K)*LhsProgress], A0);  \\\n              traits.loadLhs(&blA[(1+3*K)*LhsProgress], A1);  \\\n              traits.loadLhs(&blA[(2+3*K)*LhsProgress], A2);  \\\n              traits.loadRhs(blB + (0+4*K)*Traits::RhsProgress, B_0); \\\n              traits.madd(A0, B_0, C0, T0); \\\n              traits.madd(A1, B_0, C4, T0); \\\n              traits.madd(A2, B_0, C8, B_0); \\\n              traits.loadRhs(blB + (1+4*K)*Traits::RhsProgress, B_0); \\\n              traits.madd(A0, B_0, C1, T0); \\\n              traits.madd(A1, B_0, C5, T0); \\\n              traits.madd(A2, B_0, C9, B_0); \\\n              traits.loadRhs(blB + (2+4*K)*Traits::RhsProgress, B_0); \\\n              traits.madd(A0, B_0, C2,  T0); \\\n              traits.madd(A1, B_0, C6,  T0); \\\n              traits.madd(A2, B_0, C10, B_0); \\\n              traits.loadRhs(blB + (3+4*K)*Traits::RhsProgress, B_0); \\\n              traits.madd(A0, B_0, C3 , T0); \\\n              traits.madd(A1, B_0, C7,  T0); \\\n              traits.madd(A2, B_0, C11, B_0); \\\n              EIGEN_ASM_COMMENT(\"end step of gebp micro kernel 3pX4\"); \\\n            } while(false)\n\n            internal::prefetch(blB);\n            EIGEN_GEBP_ONESTEP(0);\n            EIGEN_GEBP_ONESTEP(1);\n            EIGEN_GEBP_ONESTEP(2);\n            EIGEN_GEBP_ONESTEP(3);\n            EIGEN_GEBP_ONESTEP(4);\n            EIGEN_GEBP_ONESTEP(5);\n            EIGEN_GEBP_ONESTEP(6);\n            EIGEN_GEBP_ONESTEP(7);\n\n            blB += pk*4*RhsProgress;\n            blA += pk*3*Traits::LhsProgress;\n\n            EIGEN_ASM_COMMENT(\"end gebp micro kernel 3pX4\");\n          }\n          // process remaining peeled loop\n          for(Index k=peeled_kc; k<depth; k++)\n          {\n            RhsPacket B_0, T0;\n            LhsPacket A2;\n            EIGEN_GEBP_ONESTEP(0);\n            blB += 4*RhsProgress;\n            blA += 3*Traits::LhsProgress;\n          }\n\n#undef EIGEN_GEBP_ONESTEP\n\n          ResPacket R0, R1, R2;\n          ResPacket alphav = pset1<ResPacket>(alpha);\n\n          R0 = r0.loadPacket(0 * Traits::ResPacketSize);\n          R1 = r0.loadPacket(1 * Traits::ResPacketSize);\n          R2 = r0.loadPacket(2 * Traits::ResPacketSize);\n          traits.acc(C0, alphav, R0);\n          traits.acc(C4, alphav, R1);\n          traits.acc(C8, alphav, R2);\n          r0.storePacket(0 * Traits::ResPacketSize, R0);\n          r0.storePacket(1 * Traits::ResPacketSize, R1);\n          r0.storePacket(2 * Traits::ResPacketSize, R2);\n\n          R0 = r1.loadPacket(0 * Traits::ResPacketSize);\n          R1 = r1.loadPacket(1 * Traits::ResPacketSize);\n          R2 = r1.loadPacket(2 * Traits::ResPacketSize);\n          traits.acc(C1, alphav, R0);\n          traits.acc(C5, alphav, R1);\n          traits.acc(C9, alphav, R2);\n          r1.storePacket(0 * Traits::ResPacketSize, R0);\n          r1.storePacket(1 * Traits::ResPacketSize, R1);\n          r1.storePacket(2 * Traits::ResPacketSize, R2);\n\n          R0 = r2.loadPacket(0 * Traits::ResPacketSize);\n          R1 = r2.loadPacket(1 * Traits::ResPacketSize);\n          R2 = r2.loadPacket(2 * Traits::ResPacketSize);\n          traits.acc(C2, alphav, R0);\n          traits.acc(C6, alphav, R1);\n          traits.acc(C10, alphav, R2);\n          r2.storePacket(0 * Traits::ResPacketSize, R0);\n          r2.storePacket(1 * Traits::ResPacketSize, R1);\n          r2.storePacket(2 * Traits::ResPacketSize, R2);\n\n          R0 = r3.loadPacket(0 * Traits::ResPacketSize);\n          R1 = r3.loadPacket(1 * Traits::ResPacketSize);\n          R2 = r3.loadPacket(2 * Traits::ResPacketSize);\n          traits.acc(C3, alphav, R0);\n          traits.acc(C7, alphav, R1);\n          traits.acc(C11, alphav, R2);\n          r3.storePacket(0 * Traits::ResPacketSize, R0);\n          r3.storePacket(1 * Traits::ResPacketSize, R1);\n          r3.storePacket(2 * Traits::ResPacketSize, R2);          \n          }\n        }\n\n        // Deal with remaining columns of the rhs\n        for(Index j2=packet_cols4; j2<cols; j2++)\n        {\n          for(Index i=i1; i<actual_panel_end; i+=3*LhsProgress)\n          {\n          // One column at a time\n          const LhsScalar* blA = &blockA[i*strideA+offsetA*(3*Traits::LhsProgress)];\n          prefetch(&blA[0]);\n\n          // gets res block as register\n          AccPacket C0, C4, C8;\n          traits.initAcc(C0);\n          traits.initAcc(C4);\n          traits.initAcc(C8);\n\n          LinearMapper r0 = res.getLinearMapper(i, j2);\n          r0.prefetch(0);\n\n          // performs \"inner\" products\n          const RhsScalar* blB = &blockB[j2*strideB+offsetB];\n          LhsPacket A0, A1, A2;\n          \n          for(Index k=0; k<peeled_kc; k+=pk)\n          {\n            EIGEN_ASM_COMMENT(\"begin gebp micro kernel 3pX1\");\n            RhsPacket B_0;\n#define EIGEN_GEBGP_ONESTEP(K) \\\n            do { \\\n              EIGEN_ASM_COMMENT(\"begin step of gebp micro kernel 3pX1\"); \\\n              EIGEN_ASM_COMMENT(\"Note: these asm comments work around bug 935!\"); \\\n              traits.loadLhs(&blA[(0+3*K)*LhsProgress], A0);  \\\n              traits.loadLhs(&blA[(1+3*K)*LhsProgress], A1);  \\\n              traits.loadLhs(&blA[(2+3*K)*LhsProgress], A2);  \\\n              traits.loadRhs(&blB[(0+K)*RhsProgress], B_0);   \\\n              traits.madd(A0, B_0, C0, B_0); \\\n              traits.madd(A1, B_0, C4, B_0); \\\n              traits.madd(A2, B_0, C8, B_0); \\\n              EIGEN_ASM_COMMENT(\"end step of gebp micro kernel 3pX1\"); \\\n            } while(false)\n        \n            EIGEN_GEBGP_ONESTEP(0);\n            EIGEN_GEBGP_ONESTEP(1);\n            EIGEN_GEBGP_ONESTEP(2);\n            EIGEN_GEBGP_ONESTEP(3);\n            EIGEN_GEBGP_ONESTEP(4);\n            EIGEN_GEBGP_ONESTEP(5);\n            EIGEN_GEBGP_ONESTEP(6);\n            EIGEN_GEBGP_ONESTEP(7);\n\n            blB += pk*RhsProgress;\n            blA += pk*3*Traits::LhsProgress;\n\n            EIGEN_ASM_COMMENT(\"end gebp micro kernel 3pX1\");\n          }\n\n          // process remaining peeled loop\n          for(Index k=peeled_kc; k<depth; k++)\n          {\n            RhsPacket B_0;\n            EIGEN_GEBGP_ONESTEP(0);\n            blB += RhsProgress;\n            blA += 3*Traits::LhsProgress;\n          }\n#undef EIGEN_GEBGP_ONESTEP\n          ResPacket R0, R1, R2;\n          ResPacket alphav = pset1<ResPacket>(alpha);\n\n          R0 = r0.loadPacket(0 * Traits::ResPacketSize);\n          R1 = r0.loadPacket(1 * Traits::ResPacketSize);\n          R2 = r0.loadPacket(2 * Traits::ResPacketSize);\n          traits.acc(C0, alphav, R0);\n          traits.acc(C4, alphav, R1);\n          traits.acc(C8, alphav, R2);\n          r0.storePacket(0 * Traits::ResPacketSize, R0);\n          r0.storePacket(1 * Traits::ResPacketSize, R1);\n          r0.storePacket(2 * Traits::ResPacketSize, R2);          \n          }\n        }\n      }\n    }\n\n    //---------- Process 2 * LhsProgress rows at once ----------\n    if(mr>=2*Traits::LhsProgress)\n    {\n      const Index l1 = defaultL1CacheSize; // in Bytes, TODO, l1 should be passed to this function.\n      // The max(1, ...) here is needed because we may be using blocking params larger than what our known l1 cache size\n      // suggests we should be using: either because our known l1 cache size is inaccurate (e.g. on Android, we can only guess),\n      // or because we are testing specific blocking sizes.\n      Index actual_panel_rows = (2*LhsProgress) * std::max<Index>(1,( (l1 - sizeof(ResScalar)*mr*nr - depth*nr*sizeof(RhsScalar)) / (depth * sizeof(LhsScalar) * 2*LhsProgress) ));\n\n      for(Index i1=peeled_mc3; i1<peeled_mc2; i1+=actual_panel_rows)\n      {\n        Index actual_panel_end = (std::min)(i1+actual_panel_rows, peeled_mc2);\n        for(Index j2=0; j2<packet_cols4; j2+=nr)\n        {\n          for(Index i=i1; i<actual_panel_end; i+=2*LhsProgress)\n          {\n          \n          // We selected a 2*Traits::LhsProgress x nr micro block of res which is entirely\n          // stored into 2 x nr registers.\n          \n          const LhsScalar* blA = &blockA[i*strideA+offsetA*(2*Traits::LhsProgress)];\n          prefetch(&blA[0]);\n\n          // gets res block as register\n          AccPacket C0, C1, C2, C3,\n                    C4, C5, C6, C7;\n          traits.initAcc(C0); traits.initAcc(C1); traits.initAcc(C2); traits.initAcc(C3);\n          traits.initAcc(C4); traits.initAcc(C5); traits.initAcc(C6); traits.initAcc(C7);\n\n          LinearMapper r0 = res.getLinearMapper(i, j2 + 0);\n          LinearMapper r1 = res.getLinearMapper(i, j2 + 1);\n          LinearMapper r2 = res.getLinearMapper(i, j2 + 2);\n          LinearMapper r3 = res.getLinearMapper(i, j2 + 3);\n\n          r0.prefetch(prefetch_res_offset);\n          r1.prefetch(prefetch_res_offset);\n          r2.prefetch(prefetch_res_offset);\n          r3.prefetch(prefetch_res_offset);\n\n          // performs \"inner\" products\n          const RhsScalar* blB = &blockB[j2*strideB+offsetB*nr];\n          prefetch(&blB[0]);\n          LhsPacket A0, A1;\n\n          for(Index k=0; k<peeled_kc; k+=pk)\n          {\n            EIGEN_ASM_COMMENT(\"begin gebp micro kernel 2pX4\");\n            RhsPacket B_0, B1, B2, B3, T0;\n\n   #define EIGEN_GEBGP_ONESTEP(K) \\\n            do {                                                                \\\n              EIGEN_ASM_COMMENT(\"begin step of gebp micro kernel 2pX4\");        \\\n              EIGEN_ASM_COMMENT(\"Note: these asm comments work around bug 935!\"); \\\n              traits.loadLhs(&blA[(0+2*K)*LhsProgress], A0);                    \\\n              traits.loadLhs(&blA[(1+2*K)*LhsProgress], A1);                    \\\n              traits.broadcastRhs(&blB[(0+4*K)*RhsProgress], B_0, B1, B2, B3);  \\\n              traits.madd(A0, B_0, C0, T0);                                     \\\n              traits.madd(A1, B_0, C4, B_0);                                    \\\n              traits.madd(A0, B1,  C1, T0);                                     \\\n              traits.madd(A1, B1,  C5, B1);                                     \\\n              traits.madd(A0, B2,  C2, T0);                                     \\\n              traits.madd(A1, B2,  C6, B2);                                     \\\n              traits.madd(A0, B3,  C3, T0);                                     \\\n              traits.madd(A1, B3,  C7, B3);                                     \\\n              EIGEN_ASM_COMMENT(\"end step of gebp micro kernel 2pX4\");          \\\n            } while(false)\n            \n            internal::prefetch(blB+(48+0));\n            EIGEN_GEBGP_ONESTEP(0);\n            EIGEN_GEBGP_ONESTEP(1);\n            EIGEN_GEBGP_ONESTEP(2);\n            EIGEN_GEBGP_ONESTEP(3);\n            internal::prefetch(blB+(48+16));\n            EIGEN_GEBGP_ONESTEP(4);\n            EIGEN_GEBGP_ONESTEP(5);\n            EIGEN_GEBGP_ONESTEP(6);\n            EIGEN_GEBGP_ONESTEP(7);\n\n            blB += pk*4*RhsProgress;\n            blA += pk*(2*Traits::LhsProgress);\n\n            EIGEN_ASM_COMMENT(\"end gebp micro kernel 2pX4\");\n          }\n          // process remaining peeled loop\n          for(Index k=peeled_kc; k<depth; k++)\n          {\n            RhsPacket B_0, B1, B2, B3, T0;\n            EIGEN_GEBGP_ONESTEP(0);\n            blB += 4*RhsProgress;\n            blA += 2*Traits::LhsProgress;\n          }\n#undef EIGEN_GEBGP_ONESTEP\n\n          ResPacket R0, R1, R2, R3;\n          ResPacket alphav = pset1<ResPacket>(alpha);\n\n          R0 = r0.loadPacket(0 * Traits::ResPacketSize);\n          R1 = r0.loadPacket(1 * Traits::ResPacketSize);\n          R2 = r1.loadPacket(0 * Traits::ResPacketSize);\n          R3 = r1.loadPacket(1 * Traits::ResPacketSize);\n          traits.acc(C0, alphav, R0);\n          traits.acc(C4, alphav, R1);\n          traits.acc(C1, alphav, R2);\n          traits.acc(C5, alphav, R3);\n          r0.storePacket(0 * Traits::ResPacketSize, R0);\n          r0.storePacket(1 * Traits::ResPacketSize, R1);\n          r1.storePacket(0 * Traits::ResPacketSize, R2);\n          r1.storePacket(1 * Traits::ResPacketSize, R3);\n\n          R0 = r2.loadPacket(0 * Traits::ResPacketSize);\n          R1 = r2.loadPacket(1 * Traits::ResPacketSize);\n          R2 = r3.loadPacket(0 * Traits::ResPacketSize);\n          R3 = r3.loadPacket(1 * Traits::ResPacketSize);\n          traits.acc(C2,  alphav, R0);\n          traits.acc(C6,  alphav, R1);\n          traits.acc(C3,  alphav, R2);\n          traits.acc(C7,  alphav, R3);\n          r2.storePacket(0 * Traits::ResPacketSize, R0);\n          r2.storePacket(1 * Traits::ResPacketSize, R1);\n          r3.storePacket(0 * Traits::ResPacketSize, R2);\n          r3.storePacket(1 * Traits::ResPacketSize, R3);\n          }\n        }\n      \n        // Deal with remaining columns of the rhs\n        for(Index j2=packet_cols4; j2<cols; j2++)\n        {\n          for(Index i=i1; i<actual_panel_end; i+=2*LhsProgress)\n          {\n          // One column at a time\n          const LhsScalar* blA = &blockA[i*strideA+offsetA*(2*Traits::LhsProgress)];\n          prefetch(&blA[0]);\n\n          // gets res block as register\n          AccPacket C0, C4;\n          traits.initAcc(C0);\n          traits.initAcc(C4);\n\n          LinearMapper r0 = res.getLinearMapper(i, j2);\n          r0.prefetch(prefetch_res_offset);\n\n          // performs \"inner\" products\n          const RhsScalar* blB = &blockB[j2*strideB+offsetB];\n          LhsPacket A0, A1;\n\n          for(Index k=0; k<peeled_kc; k+=pk)\n          {\n            EIGEN_ASM_COMMENT(\"begin gebp micro kernel 2pX1\");\n            RhsPacket B_0, B1;\n        \n#define EIGEN_GEBGP_ONESTEP(K) \\\n            do {                                                                  \\\n              EIGEN_ASM_COMMENT(\"begin step of gebp micro kernel 2pX1\");          \\\n              EIGEN_ASM_COMMENT(\"Note: these asm comments work around bug 935!\"); \\\n              traits.loadLhs(&blA[(0+2*K)*LhsProgress], A0);                      \\\n              traits.loadLhs(&blA[(1+2*K)*LhsProgress], A1);                      \\\n              traits.loadRhs(&blB[(0+K)*RhsProgress], B_0);                       \\\n              traits.madd(A0, B_0, C0, B1);                                       \\\n              traits.madd(A1, B_0, C4, B_0);                                      \\\n              EIGEN_ASM_COMMENT(\"end step of gebp micro kernel 2pX1\");            \\\n            } while(false)\n        \n            EIGEN_GEBGP_ONESTEP(0);\n            EIGEN_GEBGP_ONESTEP(1);\n            EIGEN_GEBGP_ONESTEP(2);\n            EIGEN_GEBGP_ONESTEP(3);\n            EIGEN_GEBGP_ONESTEP(4);\n            EIGEN_GEBGP_ONESTEP(5);\n            EIGEN_GEBGP_ONESTEP(6);\n            EIGEN_GEBGP_ONESTEP(7);\n\n            blB += pk*RhsProgress;\n            blA += pk*2*Traits::LhsProgress;\n\n            EIGEN_ASM_COMMENT(\"end gebp micro kernel 2pX1\");\n          }\n\n          // process remaining peeled loop\n          for(Index k=peeled_kc; k<depth; k++)\n          {\n            RhsPacket B_0, B1;\n            EIGEN_GEBGP_ONESTEP(0);\n            blB += RhsProgress;\n            blA += 2*Traits::LhsProgress;\n          }\n#undef EIGEN_GEBGP_ONESTEP\n          ResPacket R0, R1;\n          ResPacket alphav = pset1<ResPacket>(alpha);\n\n          R0 = r0.loadPacket(0 * Traits::ResPacketSize);\n          R1 = r0.loadPacket(1 * Traits::ResPacketSize);\n          traits.acc(C0, alphav, R0);\n          traits.acc(C4, alphav, R1);\n          r0.storePacket(0 * Traits::ResPacketSize, R0);\n          r0.storePacket(1 * Traits::ResPacketSize, R1);\n          }\n        }\n      }\n    }\n    //---------- Process 1 * LhsProgress rows at once ----------\n    if(mr>=1*Traits::LhsProgress)\n    {\n      // loops on each largest micro horizontal panel of lhs (1*LhsProgress x depth)\n      for(Index i=peeled_mc2; i<peeled_mc1; i+=1*LhsProgress)\n      {\n        // loops on each largest micro vertical panel of rhs (depth * nr)\n        for(Index j2=0; j2<packet_cols4; j2+=nr)\n        {\n          // We select a 1*Traits::LhsProgress x nr micro block of res which is entirely\n          // stored into 1 x nr registers.\n          \n          const LhsScalar* blA = &blockA[i*strideA+offsetA*(1*Traits::LhsProgress)];\n          prefetch(&blA[0]);\n\n          // gets res block as register\n          AccPacket C0, C1, C2, C3;\n          traits.initAcc(C0);\n          traits.initAcc(C1);\n          traits.initAcc(C2);\n          traits.initAcc(C3);\n\n          LinearMapper r0 = res.getLinearMapper(i, j2 + 0);\n          LinearMapper r1 = res.getLinearMapper(i, j2 + 1);\n          LinearMapper r2 = res.getLinearMapper(i, j2 + 2);\n          LinearMapper r3 = res.getLinearMapper(i, j2 + 3);\n\n          r0.prefetch(prefetch_res_offset);\n          r1.prefetch(prefetch_res_offset);\n          r2.prefetch(prefetch_res_offset);\n          r3.prefetch(prefetch_res_offset);\n\n          // performs \"inner\" products\n          const RhsScalar* blB = &blockB[j2*strideB+offsetB*nr];\n          prefetch(&blB[0]);\n          LhsPacket A0;\n\n          for(Index k=0; k<peeled_kc; k+=pk)\n          {\n            EIGEN_ASM_COMMENT(\"begin gebp micro kernel 1pX4\");\n            RhsPacket B_0, B1, B2, B3;\n               \n#define EIGEN_GEBGP_ONESTEP(K) \\\n            do {                                                                \\\n              EIGEN_ASM_COMMENT(\"begin step of gebp micro kernel 1pX4\");        \\\n              EIGEN_ASM_COMMENT(\"Note: these asm comments work around bug 935!\"); \\\n              traits.loadLhs(&blA[(0+1*K)*LhsProgress], A0);                    \\\n              traits.broadcastRhs(&blB[(0+4*K)*RhsProgress], B_0, B1, B2, B3);  \\\n              traits.madd(A0, B_0, C0, B_0);                                    \\\n              traits.madd(A0, B1,  C1, B1);                                     \\\n              traits.madd(A0, B2,  C2, B2);                                     \\\n              traits.madd(A0, B3,  C3, B3);                                     \\\n              EIGEN_ASM_COMMENT(\"end step of gebp micro kernel 1pX4\");          \\\n            } while(false)\n            \n            internal::prefetch(blB+(48+0));\n            EIGEN_GEBGP_ONESTEP(0);\n            EIGEN_GEBGP_ONESTEP(1);\n            EIGEN_GEBGP_ONESTEP(2);\n            EIGEN_GEBGP_ONESTEP(3);\n            internal::prefetch(blB+(48+16));\n            EIGEN_GEBGP_ONESTEP(4);\n            EIGEN_GEBGP_ONESTEP(5);\n            EIGEN_GEBGP_ONESTEP(6);\n            EIGEN_GEBGP_ONESTEP(7);\n\n            blB += pk*4*RhsProgress;\n            blA += pk*1*LhsProgress;\n\n            EIGEN_ASM_COMMENT(\"end gebp micro kernel 1pX4\");\n          }\n          // process remaining peeled loop\n          for(Index k=peeled_kc; k<depth; k++)\n          {\n            RhsPacket B_0, B1, B2, B3;\n            EIGEN_GEBGP_ONESTEP(0);\n            blB += 4*RhsProgress;\n            blA += 1*LhsProgress;\n          }\n#undef EIGEN_GEBGP_ONESTEP\n\n          ResPacket R0, R1;\n          ResPacket alphav = pset1<ResPacket>(alpha);\n\n          R0 = r0.loadPacket(0 * Traits::ResPacketSize);\n          R1 = r1.loadPacket(0 * Traits::ResPacketSize);\n          traits.acc(C0, alphav, R0);\n          traits.acc(C1,  alphav, R1);\n          r0.storePacket(0 * Traits::ResPacketSize, R0);\n          r1.storePacket(0 * Traits::ResPacketSize, R1);\n\n          R0 = r2.loadPacket(0 * Traits::ResPacketSize);\n          R1 = r3.loadPacket(0 * Traits::ResPacketSize);\n          traits.acc(C2,  alphav, R0);\n          traits.acc(C3,  alphav, R1);\n          r2.storePacket(0 * Traits::ResPacketSize, R0);\n          r3.storePacket(0 * Traits::ResPacketSize, R1);\n        }\n\n        // Deal with remaining columns of the rhs\n        for(Index j2=packet_cols4; j2<cols; j2++)\n        {\n          // One column at a time\n          const LhsScalar* blA = &blockA[i*strideA+offsetA*(1*Traits::LhsProgress)];\n          prefetch(&blA[0]);\n\n          // gets res block as register\n          AccPacket C0;\n          traits.initAcc(C0);\n\n          LinearMapper r0 = res.getLinearMapper(i, j2);\n\n          // performs \"inner\" products\n          const RhsScalar* blB = &blockB[j2*strideB+offsetB];\n          LhsPacket A0;\n\n          for(Index k=0; k<peeled_kc; k+=pk)\n          {\n            EIGEN_ASM_COMMENT(\"begin gebp micro kernel 1pX1\");\n            RhsPacket B_0;\n        \n#define EIGEN_GEBGP_ONESTEP(K) \\\n            do {                                                                \\\n              EIGEN_ASM_COMMENT(\"begin step of gebp micro kernel 1pX1\");        \\\n              EIGEN_ASM_COMMENT(\"Note: these asm comments work around bug 935!\"); \\\n              traits.loadLhs(&blA[(0+1*K)*LhsProgress], A0);                    \\\n              traits.loadRhs(&blB[(0+K)*RhsProgress], B_0);                     \\\n              traits.madd(A0, B_0, C0, B_0);                                    \\\n              EIGEN_ASM_COMMENT(\"end step of gebp micro kernel 1pX1\");          \\\n            } while(false);\n\n            EIGEN_GEBGP_ONESTEP(0);\n            EIGEN_GEBGP_ONESTEP(1);\n            EIGEN_GEBGP_ONESTEP(2);\n            EIGEN_GEBGP_ONESTEP(3);\n            EIGEN_GEBGP_ONESTEP(4);\n            EIGEN_GEBGP_ONESTEP(5);\n            EIGEN_GEBGP_ONESTEP(6);\n            EIGEN_GEBGP_ONESTEP(7);\n\n            blB += pk*RhsProgress;\n            blA += pk*1*Traits::LhsProgress;\n\n            EIGEN_ASM_COMMENT(\"end gebp micro kernel 1pX1\");\n          }\n\n          // process remaining peeled loop\n          for(Index k=peeled_kc; k<depth; k++)\n          {\n            RhsPacket B_0;\n            EIGEN_GEBGP_ONESTEP(0);\n            blB += RhsProgress;\n            blA += 1*Traits::LhsProgress;\n          }\n#undef EIGEN_GEBGP_ONESTEP\n          ResPacket R0;\n          ResPacket alphav = pset1<ResPacket>(alpha);\n          R0 = r0.loadPacket(0 * Traits::ResPacketSize);\n          traits.acc(C0, alphav, R0);\n          r0.storePacket(0 * Traits::ResPacketSize, R0);\n        }\n      }\n    }\n    //---------- Process remaining rows, 1 at once ----------\n    if(peeled_mc1<rows)\n    {\n      // loop on each panel of the rhs\n      for(Index j2=0; j2<packet_cols4; j2+=nr)\n      {\n        // loop on each row of the lhs (1*LhsProgress x depth)\n        for(Index i=peeled_mc1; i<rows; i+=1)\n        {\n          const LhsScalar* blA = &blockA[i*strideA+offsetA];\n          prefetch(&blA[0]);\n          const RhsScalar* blB = &blockB[j2*strideB+offsetB*nr];\n\n          // The following piece of code wont work for 512 bit registers\n          // Moreover, if LhsProgress==8 it assumes that there is a half packet of the same size\n          // as nr (which is currently 4) for the return type.\n          typedef typename unpacket_traits<SResPacket>::half SResPacketHalf;\n          if ((SwappedTraits::LhsProgress % 4) == 0 &&\n              (SwappedTraits::LhsProgress <= 8) &&\n              (SwappedTraits::LhsProgress!=8 || unpacket_traits<SResPacketHalf>::size==nr))\n          {\n            SAccPacket C0, C1, C2, C3;\n            straits.initAcc(C0);\n            straits.initAcc(C1);\n            straits.initAcc(C2);\n            straits.initAcc(C3);\n\n            const Index spk   = (std::max)(1,SwappedTraits::LhsProgress/4);\n            const Index endk  = (depth/spk)*spk;\n            const Index endk4 = (depth/(spk*4))*(spk*4);\n\n            Index k=0;\n            for(; k<endk4; k+=4*spk)\n            {\n              SLhsPacket A0,A1;\n              SRhsPacket B_0,B_1;\n\n              straits.loadLhsUnaligned(blB+0*SwappedTraits::LhsProgress, A0);\n              straits.loadLhsUnaligned(blB+1*SwappedTraits::LhsProgress, A1);\n\n              straits.loadRhsQuad(blA+0*spk, B_0);\n              straits.loadRhsQuad(blA+1*spk, B_1);\n              straits.madd(A0,B_0,C0,B_0);\n              straits.madd(A1,B_1,C1,B_1);\n\n              straits.loadLhsUnaligned(blB+2*SwappedTraits::LhsProgress, A0);\n              straits.loadLhsUnaligned(blB+3*SwappedTraits::LhsProgress, A1);\n              straits.loadRhsQuad(blA+2*spk, B_0);\n              straits.loadRhsQuad(blA+3*spk, B_1);\n              straits.madd(A0,B_0,C2,B_0);\n              straits.madd(A1,B_1,C3,B_1);\n\n              blB += 4*SwappedTraits::LhsProgress;\n              blA += 4*spk;\n            }\n            C0 = padd(padd(C0,C1),padd(C2,C3));\n            for(; k<endk; k+=spk)\n            {\n              SLhsPacket A0;\n              SRhsPacket B_0;\n\n              straits.loadLhsUnaligned(blB, A0);\n              straits.loadRhsQuad(blA, B_0);\n              straits.madd(A0,B_0,C0,B_0);\n\n              blB += SwappedTraits::LhsProgress;\n              blA += spk;\n            }\n            if(SwappedTraits::LhsProgress==8)\n            {\n              // Special case where we have to first reduce the accumulation register C0\n              typedef typename conditional<SwappedTraits::LhsProgress>=8,typename unpacket_traits<SResPacket>::half,SResPacket>::type SResPacketHalf;\n              typedef typename conditional<SwappedTraits::LhsProgress>=8,typename unpacket_traits<SLhsPacket>::half,SLhsPacket>::type SLhsPacketHalf;\n              typedef typename conditional<SwappedTraits::LhsProgress>=8,typename unpacket_traits<SLhsPacket>::half,SRhsPacket>::type SRhsPacketHalf;\n              typedef typename conditional<SwappedTraits::LhsProgress>=8,typename unpacket_traits<SAccPacket>::half,SAccPacket>::type SAccPacketHalf;\n\n              SResPacketHalf R = res.template gatherPacket<SResPacketHalf>(i, j2);\n              SResPacketHalf alphav = pset1<SResPacketHalf>(alpha);\n\n              if(depth-endk>0)\n              {\n                // We have to handle the last row of the rhs which corresponds to a half-packet\n                SLhsPacketHalf a0;\n                SRhsPacketHalf b0;\n                straits.loadLhsUnaligned(blB, a0);\n                straits.loadRhs(blA, b0);\n                SAccPacketHalf c0 = predux_downto4(C0);\n                straits.madd(a0,b0,c0,b0);\n                straits.acc(c0, alphav, R);\n              }\n              else\n              {\n                straits.acc(predux_downto4(C0), alphav, R);\n              }\n              res.scatterPacket(i, j2, R);\n            }\n            else\n            {\n              SResPacket R = res.template gatherPacket<SResPacket>(i, j2);\n              SResPacket alphav = pset1<SResPacket>(alpha);\n              straits.acc(C0, alphav, R);\n              res.scatterPacket(i, j2, R);\n            }\n          }\n          else // scalar path\n          {\n            // get a 1 x 4 res block as registers\n            ResScalar C0(0), C1(0), C2(0), C3(0);\n\n            for(Index k=0; k<depth; k++)\n            {\n              LhsScalar A0;\n              RhsScalar B_0, B_1;\n\n              A0 = blA[k];\n\n              B_0 = blB[0];\n              B_1 = blB[1];\n              CJMADD(cj,A0,B_0,C0,  B_0);\n              CJMADD(cj,A0,B_1,C1,  B_1);\n              \n              B_0 = blB[2];\n              B_1 = blB[3];\n              CJMADD(cj,A0,B_0,C2,  B_0);\n              CJMADD(cj,A0,B_1,C3,  B_1);\n              \n              blB += 4;\n            }\n            res(i, j2 + 0) += alpha * C0;\n            res(i, j2 + 1) += alpha * C1;\n            res(i, j2 + 2) += alpha * C2;\n            res(i, j2 + 3) += alpha * C3;\n          }\n        }\n      }\n      // remaining columns\n      for(Index j2=packet_cols4; j2<cols; j2++)\n      {\n        // loop on each row of the lhs (1*LhsProgress x depth)\n        for(Index i=peeled_mc1; i<rows; i+=1)\n        {\n          const LhsScalar* blA = &blockA[i*strideA+offsetA];\n          prefetch(&blA[0]);\n          // gets a 1 x 1 res block as registers\n          ResScalar C0(0);\n          const RhsScalar* blB = &blockB[j2*strideB+offsetB];\n          for(Index k=0; k<depth; k++)\n          {\n            LhsScalar A0 = blA[k];\n            RhsScalar B_0 = blB[k];\n            CJMADD(cj, A0, B_0, C0, B_0);\n          }\n          res(i, j2) += alpha * C0;\n        }\n      }\n    }\n  }\n\n\n#undef CJMADD\n\n// pack a block of the lhs\n// The traversal is as follow (mr==4):\n//   0  4  8 12 ...\n//   1  5  9 13 ...\n//   2  6 10 14 ...\n//   3  7 11 15 ...\n//\n//  16 20 24 28 ...\n//  17 21 25 29 ...\n//  18 22 26 30 ...\n//  19 23 27 31 ...\n//\n//  32 33 34 35 ...\n//  36 36 38 39 ...\ntemplate<typename Scalar, typename Index, typename DataMapper, int Pack1, int Pack2, bool Conjugate, bool PanelMode>\nstruct gemm_pack_lhs<Scalar, Index, DataMapper, Pack1, Pack2, ColMajor, Conjugate, PanelMode>\n{\n  typedef typename DataMapper::LinearMapper LinearMapper;\n  EIGEN_DONT_INLINE void operator()(Scalar* blockA, const DataMapper& lhs, Index depth, Index rows, Index stride=0, Index offset=0);\n};\n\ntemplate<typename Scalar, typename Index, typename DataMapper, int Pack1, int Pack2, bool Conjugate, bool PanelMode>\nEIGEN_DONT_INLINE void gemm_pack_lhs<Scalar, Index, DataMapper, Pack1, Pack2, ColMajor, Conjugate, PanelMode>\n  ::operator()(Scalar* blockA, const DataMapper& lhs, Index depth, Index rows, Index stride, Index offset)\n{\n  typedef typename packet_traits<Scalar>::type Packet;\n  enum { PacketSize = packet_traits<Scalar>::size };\n\n  EIGEN_ASM_COMMENT(\"EIGEN PRODUCT PACK LHS\");\n  EIGEN_UNUSED_VARIABLE(stride);\n  EIGEN_UNUSED_VARIABLE(offset);\n  eigen_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride));\n  eigen_assert( ((Pack1%PacketSize)==0 && Pack1<=4*PacketSize) || (Pack1<=4) );\n  conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj;\n  Index count = 0;\n\n  const Index peeled_mc3 = Pack1>=3*PacketSize ? (rows/(3*PacketSize))*(3*PacketSize) : 0;\n  const Index peeled_mc2 = Pack1>=2*PacketSize ? peeled_mc3+((rows-peeled_mc3)/(2*PacketSize))*(2*PacketSize) : 0;\n  const Index peeled_mc1 = Pack1>=1*PacketSize ? (rows/(1*PacketSize))*(1*PacketSize) : 0;\n  const Index peeled_mc0 = Pack2>=1*PacketSize ? peeled_mc1\n                         : Pack2>1             ? (rows/Pack2)*Pack2 : 0;\n\n  Index i=0;\n\n  // Pack 3 packets\n  if(Pack1>=3*PacketSize)\n  {\n    for(; i<peeled_mc3; i+=3*PacketSize)\n    {\n      if(PanelMode) count += (3*PacketSize) * offset;\n\n      for(Index k=0; k<depth; k++)\n      {\n        Packet A, B, C;\n        A = lhs.loadPacket(i+0*PacketSize, k);\n        B = lhs.loadPacket(i+1*PacketSize, k);\n        C = lhs.loadPacket(i+2*PacketSize, k);\n        pstore(blockA+count, cj.pconj(A)); count+=PacketSize;\n        pstore(blockA+count, cj.pconj(B)); count+=PacketSize;\n        pstore(blockA+count, cj.pconj(C)); count+=PacketSize;\n      }\n      if(PanelMode) count += (3*PacketSize) * (stride-offset-depth);\n    }\n  }\n  // Pack 2 packets\n  if(Pack1>=2*PacketSize)\n  {\n    for(; i<peeled_mc2; i+=2*PacketSize)\n    {\n      if(PanelMode) count += (2*PacketSize) * offset;\n\n      for(Index k=0; k<depth; k++)\n      {\n        Packet A, B;\n        A = lhs.loadPacket(i+0*PacketSize, k);\n        B = lhs.loadPacket(i+1*PacketSize, k);\n        pstore(blockA+count, cj.pconj(A)); count+=PacketSize;\n        pstore(blockA+count, cj.pconj(B)); count+=PacketSize;\n      }\n      if(PanelMode) count += (2*PacketSize) * (stride-offset-depth);\n    }\n  }\n  // Pack 1 packets\n  if(Pack1>=1*PacketSize)\n  {\n    for(; i<peeled_mc1; i+=1*PacketSize)\n    {\n      if(PanelMode) count += (1*PacketSize) * offset;\n\n      for(Index k=0; k<depth; k++)\n      {\n        Packet A;\n        A = lhs.loadPacket(i+0*PacketSize, k);\n        pstore(blockA+count, cj.pconj(A));\n        count+=PacketSize;\n      }\n      if(PanelMode) count += (1*PacketSize) * (stride-offset-depth);\n    }\n  }\n  // Pack scalars\n  if(Pack2<PacketSize && Pack2>1)\n  {\n    for(; i<peeled_mc0; i+=Pack2)\n    {\n      if(PanelMode) count += Pack2 * offset;\n\n      for(Index k=0; k<depth; k++)\n        for(Index w=0; w<Pack2; w++)\n          blockA[count++] = cj(lhs(i+w, k));\n\n      if(PanelMode) count += Pack2 * (stride-offset-depth);\n    }\n  }\n  for(; i<rows; i++)\n  {\n    if(PanelMode) count += offset;\n    for(Index k=0; k<depth; k++)\n      blockA[count++] = cj(lhs(i, k));\n    if(PanelMode) count += (stride-offset-depth);\n  }\n}\n\ntemplate<typename Scalar, typename Index, typename DataMapper, int Pack1, int Pack2, bool Conjugate, bool PanelMode>\nstruct gemm_pack_lhs<Scalar, Index, DataMapper, Pack1, Pack2, RowMajor, Conjugate, PanelMode>\n{\n  typedef typename DataMapper::LinearMapper LinearMapper;\n  EIGEN_DONT_INLINE void operator()(Scalar* blockA, const DataMapper& lhs, Index depth, Index rows, Index stride=0, Index offset=0);\n};\n\ntemplate<typename Scalar, typename Index, typename DataMapper, int Pack1, int Pack2, bool Conjugate, bool PanelMode>\nEIGEN_DONT_INLINE void gemm_pack_lhs<Scalar, Index, DataMapper, Pack1, Pack2, RowMajor, Conjugate, PanelMode>\n  ::operator()(Scalar* blockA, const DataMapper& lhs, Index depth, Index rows, Index stride, Index offset)\n{\n  typedef typename packet_traits<Scalar>::type Packet;\n  enum { PacketSize = packet_traits<Scalar>::size };\n\n  EIGEN_ASM_COMMENT(\"EIGEN PRODUCT PACK LHS\");\n  EIGEN_UNUSED_VARIABLE(stride);\n  EIGEN_UNUSED_VARIABLE(offset);\n  eigen_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride));\n  conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj;\n  Index count = 0;\n\n//   const Index peeled_mc3 = Pack1>=3*PacketSize ? (rows/(3*PacketSize))*(3*PacketSize) : 0;\n//   const Index peeled_mc2 = Pack1>=2*PacketSize ? peeled_mc3+((rows-peeled_mc3)/(2*PacketSize))*(2*PacketSize) : 0;\n//   const Index peeled_mc1 = Pack1>=1*PacketSize ? (rows/(1*PacketSize))*(1*PacketSize) : 0;\n\n  int pack = Pack1;\n  Index i = 0;\n  while(pack>0)\n  {\n    Index remaining_rows = rows-i;\n    Index peeled_mc = i+(remaining_rows/pack)*pack;\n    for(; i<peeled_mc; i+=pack)\n    {\n      if(PanelMode) count += pack * offset;\n\n      const Index peeled_k = (depth/PacketSize)*PacketSize;\n      Index k=0;\n      if(pack>=PacketSize)\n      {\n        for(; k<peeled_k; k+=PacketSize)\n        {\n          for (Index m = 0; m < pack; m += PacketSize)\n          {\n            PacketBlock<Packet> kernel;\n            for (int p = 0; p < PacketSize; ++p) kernel.packet[p] = lhs.loadPacket(i+p+m, k);\n            ptranspose(kernel);\n            for (int p = 0; p < PacketSize; ++p) pstore(blockA+count+m+(pack)*p, cj.pconj(kernel.packet[p]));\n          }\n          count += PacketSize*pack;\n        }\n      }\n      for(; k<depth; k++)\n      {\n        Index w=0;\n        for(; w<pack-3; w+=4)\n        {\n          Scalar a(cj(lhs(i+w+0, k))),\n                 b(cj(lhs(i+w+1, k))),\n                 c(cj(lhs(i+w+2, k))),\n                 d(cj(lhs(i+w+3, k)));\n          blockA[count++] = a;\n          blockA[count++] = b;\n          blockA[count++] = c;\n          blockA[count++] = d;\n        }\n        if(pack%4)\n          for(;w<pack;++w)\n            blockA[count++] = cj(lhs(i+w, k));\n      }\n\n      if(PanelMode) count += pack * (stride-offset-depth);\n    }\n\n    pack -= PacketSize;\n    if(pack<Pack2 && (pack+PacketSize)!=Pack2)\n      pack = Pack2;\n  }\n\n  for(; i<rows; i++)\n  {\n    if(PanelMode) count += offset;\n    for(Index k=0; k<depth; k++)\n      blockA[count++] = cj(lhs(i, k));\n    if(PanelMode) count += (stride-offset-depth);\n  }\n}\n\n// copy a complete panel of the rhs\n// this version is optimized for column major matrices\n// The traversal order is as follow: (nr==4):\n//  0  1  2  3   12 13 14 15   24 27\n//  4  5  6  7   16 17 18 19   25 28\n//  8  9 10 11   20 21 22 23   26 29\n//  .  .  .  .    .  .  .  .    .  .\ntemplate<typename Scalar, typename Index, typename DataMapper, int nr, bool Conjugate, bool PanelMode>\nstruct gemm_pack_rhs<Scalar, Index, DataMapper, nr, ColMajor, Conjugate, PanelMode>\n{\n  typedef typename packet_traits<Scalar>::type Packet;\n  typedef typename DataMapper::LinearMapper LinearMapper;\n  enum { PacketSize = packet_traits<Scalar>::size };\n  EIGEN_DONT_INLINE void operator()(Scalar* blockB, const DataMapper& rhs, Index depth, Index cols, Index stride=0, Index offset=0);\n};\n\ntemplate<typename Scalar, typename Index, typename DataMapper, int nr, bool Conjugate, bool PanelMode>\nEIGEN_DONT_INLINE void gemm_pack_rhs<Scalar, Index, DataMapper, nr, ColMajor, Conjugate, PanelMode>\n  ::operator()(Scalar* blockB, const DataMapper& rhs, Index depth, Index cols, Index stride, Index offset)\n{\n  EIGEN_ASM_COMMENT(\"EIGEN PRODUCT PACK RHS COLMAJOR\");\n  EIGEN_UNUSED_VARIABLE(stride);\n  EIGEN_UNUSED_VARIABLE(offset);\n  eigen_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride));\n  conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj;\n  Index packet_cols8 = nr>=8 ? (cols/8) * 8 : 0;\n  Index packet_cols4 = nr>=4 ? (cols/4) * 4 : 0;\n  Index count = 0;\n  const Index peeled_k = (depth/PacketSize)*PacketSize;\n//   if(nr>=8)\n//   {\n//     for(Index j2=0; j2<packet_cols8; j2+=8)\n//     {\n//       // skip what we have before\n//       if(PanelMode) count += 8 * offset;\n//       const Scalar* b0 = &rhs[(j2+0)*rhsStride];\n//       const Scalar* b1 = &rhs[(j2+1)*rhsStride];\n//       const Scalar* b2 = &rhs[(j2+2)*rhsStride];\n//       const Scalar* b3 = &rhs[(j2+3)*rhsStride];\n//       const Scalar* b4 = &rhs[(j2+4)*rhsStride];\n//       const Scalar* b5 = &rhs[(j2+5)*rhsStride];\n//       const Scalar* b6 = &rhs[(j2+6)*rhsStride];\n//       const Scalar* b7 = &rhs[(j2+7)*rhsStride];\n//       Index k=0;\n//       if(PacketSize==8) // TODO enbale vectorized transposition for PacketSize==4\n//       {\n//         for(; k<peeled_k; k+=PacketSize) {\n//           PacketBlock<Packet> kernel;\n//           for (int p = 0; p < PacketSize; ++p) {\n//             kernel.packet[p] = ploadu<Packet>(&rhs[(j2+p)*rhsStride+k]);\n//           }\n//           ptranspose(kernel);\n//           for (int p = 0; p < PacketSize; ++p) {\n//             pstoreu(blockB+count, cj.pconj(kernel.packet[p]));\n//             count+=PacketSize;\n//           }\n//         }\n//       }\n//       for(; k<depth; k++)\n//       {\n//         blockB[count+0] = cj(b0[k]);\n//         blockB[count+1] = cj(b1[k]);\n//         blockB[count+2] = cj(b2[k]);\n//         blockB[count+3] = cj(b3[k]);\n//         blockB[count+4] = cj(b4[k]);\n//         blockB[count+5] = cj(b5[k]);\n//         blockB[count+6] = cj(b6[k]);\n//         blockB[count+7] = cj(b7[k]);\n//         count += 8;\n//       }\n//       // skip what we have after\n//       if(PanelMode) count += 8 * (stride-offset-depth);\n//     }\n//   }\n\n  if(nr>=4)\n  {\n    for(Index j2=packet_cols8; j2<packet_cols4; j2+=4)\n    {\n      // skip what we have before\n      if(PanelMode) count += 4 * offset;\n      const LinearMapper dm0 = rhs.getLinearMapper(0, j2 + 0);\n      const LinearMapper dm1 = rhs.getLinearMapper(0, j2 + 1);\n      const LinearMapper dm2 = rhs.getLinearMapper(0, j2 + 2);\n      const LinearMapper dm3 = rhs.getLinearMapper(0, j2 + 3);\n\n      Index k=0;\n      if((PacketSize%4)==0) // TODO enable vectorized transposition for PacketSize==2 ??\n      {\n        for(; k<peeled_k; k+=PacketSize) {\n          PacketBlock<Packet,(PacketSize%4)==0?4:PacketSize> kernel;\n          kernel.packet[0] = dm0.loadPacket(k);\n          kernel.packet[1%PacketSize] = dm1.loadPacket(k);\n          kernel.packet[2%PacketSize] = dm2.loadPacket(k);\n          kernel.packet[3%PacketSize] = dm3.loadPacket(k);\n          ptranspose(kernel);\n          pstoreu(blockB+count+0*PacketSize, cj.pconj(kernel.packet[0]));\n          pstoreu(blockB+count+1*PacketSize, cj.pconj(kernel.packet[1%PacketSize]));\n          pstoreu(blockB+count+2*PacketSize, cj.pconj(kernel.packet[2%PacketSize]));\n          pstoreu(blockB+count+3*PacketSize, cj.pconj(kernel.packet[3%PacketSize]));\n          count+=4*PacketSize;\n        }\n      }\n      for(; k<depth; k++)\n      {\n        blockB[count+0] = cj(dm0(k));\n        blockB[count+1] = cj(dm1(k));\n        blockB[count+2] = cj(dm2(k));\n        blockB[count+3] = cj(dm3(k));\n        count += 4;\n      }\n      // skip what we have after\n      if(PanelMode) count += 4 * (stride-offset-depth);\n    }\n  }\n\n  // copy the remaining columns one at a time (nr==1)\n  for(Index j2=packet_cols4; j2<cols; ++j2)\n  {\n    if(PanelMode) count += offset;\n    const LinearMapper dm0 = rhs.getLinearMapper(0, j2);\n    for(Index k=0; k<depth; k++)\n    {\n      blockB[count] = cj(dm0(k));\n      count += 1;\n    }\n    if(PanelMode) count += (stride-offset-depth);\n  }\n}\n\n// this version is optimized for row major matrices\ntemplate<typename Scalar, typename Index, typename DataMapper, int nr, bool Conjugate, bool PanelMode>\nstruct gemm_pack_rhs<Scalar, Index, DataMapper, nr, RowMajor, Conjugate, PanelMode>\n{\n  typedef typename packet_traits<Scalar>::type Packet;\n  typedef typename DataMapper::LinearMapper LinearMapper;\n  enum { PacketSize = packet_traits<Scalar>::size };\n  EIGEN_DONT_INLINE void operator()(Scalar* blockB, const DataMapper& rhs, Index depth, Index cols, Index stride=0, Index offset=0);\n};\n\ntemplate<typename Scalar, typename Index, typename DataMapper, int nr, bool Conjugate, bool PanelMode>\nEIGEN_DONT_INLINE void gemm_pack_rhs<Scalar, Index, DataMapper, nr, RowMajor, Conjugate, PanelMode>\n  ::operator()(Scalar* blockB, const DataMapper& rhs, Index depth, Index cols, Index stride, Index offset)\n{\n  EIGEN_ASM_COMMENT(\"EIGEN PRODUCT PACK RHS ROWMAJOR\");\n  EIGEN_UNUSED_VARIABLE(stride);\n  EIGEN_UNUSED_VARIABLE(offset);\n  eigen_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride));\n  conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj;\n  Index packet_cols8 = nr>=8 ? (cols/8) * 8 : 0;\n  Index packet_cols4 = nr>=4 ? (cols/4) * 4 : 0;\n  Index count = 0;\n\n//   if(nr>=8)\n//   {\n//     for(Index j2=0; j2<packet_cols8; j2+=8)\n//     {\n//       // skip what we have before\n//       if(PanelMode) count += 8 * offset;\n//       for(Index k=0; k<depth; k++)\n//       {\n//         if (PacketSize==8) {\n//           Packet A = ploadu<Packet>(&rhs[k*rhsStride + j2]);\n//           pstoreu(blockB+count, cj.pconj(A));\n//         } else if (PacketSize==4) {\n//           Packet A = ploadu<Packet>(&rhs[k*rhsStride + j2]);\n//           Packet B = ploadu<Packet>(&rhs[k*rhsStride + j2 + PacketSize]);\n//           pstoreu(blockB+count, cj.pconj(A));\n//           pstoreu(blockB+count+PacketSize, cj.pconj(B));\n//         } else {\n//           const Scalar* b0 = &rhs[k*rhsStride + j2];\n//           blockB[count+0] = cj(b0[0]);\n//           blockB[count+1] = cj(b0[1]);\n//           blockB[count+2] = cj(b0[2]);\n//           blockB[count+3] = cj(b0[3]);\n//           blockB[count+4] = cj(b0[4]);\n//           blockB[count+5] = cj(b0[5]);\n//           blockB[count+6] = cj(b0[6]);\n//           blockB[count+7] = cj(b0[7]);\n//         }\n//         count += 8;\n//       }\n//       // skip what we have after\n//       if(PanelMode) count += 8 * (stride-offset-depth);\n//     }\n//   }\n  if(nr>=4)\n  {\n    for(Index j2=packet_cols8; j2<packet_cols4; j2+=4)\n    {\n      // skip what we have before\n      if(PanelMode) count += 4 * offset;\n      for(Index k=0; k<depth; k++)\n      {\n        if (PacketSize==4) {\n          Packet A = rhs.loadPacket(k, j2);\n          pstoreu(blockB+count, cj.pconj(A));\n          count += PacketSize;\n        } else {\n          const LinearMapper dm0 = rhs.getLinearMapper(k, j2);\n          blockB[count+0] = cj(dm0(0));\n          blockB[count+1] = cj(dm0(1));\n          blockB[count+2] = cj(dm0(2));\n          blockB[count+3] = cj(dm0(3));\n          count += 4;\n        }\n      }\n      // skip what we have after\n      if(PanelMode) count += 4 * (stride-offset-depth);\n    }\n  }\n  // copy the remaining columns one at a time (nr==1)\n  for(Index j2=packet_cols4; j2<cols; ++j2)\n  {\n    if(PanelMode) count += offset;\n    for(Index k=0; k<depth; k++)\n    {\n      blockB[count] = cj(rhs(k, j2));\n      count += 1;\n    }\n    if(PanelMode) count += stride-offset-depth;\n  }\n}\n\n} // end namespace internal\n\n/** \\returns the currently set level 1 cpu cache size (in bytes) used to estimate the ideal blocking size parameters.\n  * \\sa setCpuCacheSize */\ninline std::ptrdiff_t l1CacheSize()\n{\n  std::ptrdiff_t l1, l2, l3;\n  internal::manage_caching_sizes(GetAction, &l1, &l2, &l3);\n  return l1;\n}\n\n/** \\returns the currently set level 2 cpu cache size (in bytes) used to estimate the ideal blocking size parameters.\n  * \\sa setCpuCacheSize */\ninline std::ptrdiff_t l2CacheSize()\n{\n  std::ptrdiff_t l1, l2, l3;\n  internal::manage_caching_sizes(GetAction, &l1, &l2, &l3);\n  return l2;\n}\n\n/** \\returns the currently set level 3 cpu cache size (in bytes) used to estimate the ideal blocking size paramete\\\nrs.                                                                                                                \n* \\sa setCpuCacheSize */\ninline std::ptrdiff_t l3CacheSize()\n{\n  std::ptrdiff_t l1, l2, l3;\n  internal::manage_caching_sizes(GetAction, &l1, &l2, &l3);\n  return l3;\n}\n\n/** Set the cpu L1 and L2 cache sizes (in bytes).\n  * These values are use to adjust the size of the blocks\n  * for the algorithms working per blocks.\n  *\n  * \\sa computeProductBlockingSizes */\ninline void setCpuCacheSizes(std::ptrdiff_t l1, std::ptrdiff_t l2, std::ptrdiff_t l3)\n{\n  internal::manage_caching_sizes(SetAction, &l1, &l2, &l3);\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_GENERAL_BLOCK_PANEL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/GeneralMatrixMatrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_GENERAL_MATRIX_MATRIX_H\n#define EIGEN_GENERAL_MATRIX_MATRIX_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<typename _LhsScalar, typename _RhsScalar> class level3_blocking;\n\n/* Specialization for a row-major destination matrix => simple transposition of the product */\ntemplate<\n  typename Index,\n  typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs,\n  typename RhsScalar, int RhsStorageOrder, bool ConjugateRhs>\nstruct general_matrix_matrix_product<Index,LhsScalar,LhsStorageOrder,ConjugateLhs,RhsScalar,RhsStorageOrder,ConjugateRhs,RowMajor>\n{\n  typedef gebp_traits<RhsScalar,LhsScalar> Traits;\n\n  typedef typename ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType ResScalar;\n  static EIGEN_STRONG_INLINE void run(\n    Index rows, Index cols, Index depth,\n    const LhsScalar* lhs, Index lhsStride,\n    const RhsScalar* rhs, Index rhsStride,\n    ResScalar* res, Index resStride,\n    ResScalar alpha,\n    level3_blocking<RhsScalar,LhsScalar>& blocking,\n    GemmParallelInfo<Index>* info = 0)\n  {\n    // transpose the product such that the result is column major\n    general_matrix_matrix_product<Index,\n      RhsScalar, RhsStorageOrder==RowMajor ? ColMajor : RowMajor, ConjugateRhs,\n      LhsScalar, LhsStorageOrder==RowMajor ? ColMajor : RowMajor, ConjugateLhs,\n      ColMajor>\n    ::run(cols,rows,depth,rhs,rhsStride,lhs,lhsStride,res,resStride,alpha,blocking,info);\n  }\n};\n\n/*  Specialization for a col-major destination matrix\n *    => Blocking algorithm following Goto's paper */\ntemplate<\n  typename Index,\n  typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs,\n  typename RhsScalar, int RhsStorageOrder, bool ConjugateRhs>\nstruct general_matrix_matrix_product<Index,LhsScalar,LhsStorageOrder,ConjugateLhs,RhsScalar,RhsStorageOrder,ConjugateRhs,ColMajor>\n{\n\ntypedef gebp_traits<LhsScalar,RhsScalar> Traits;\n\ntypedef typename ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType ResScalar;\nstatic void run(Index rows, Index cols, Index depth,\n  const LhsScalar* _lhs, Index lhsStride,\n  const RhsScalar* _rhs, Index rhsStride,\n  ResScalar* _res, Index resStride,\n  ResScalar alpha,\n  level3_blocking<LhsScalar,RhsScalar>& blocking,\n  GemmParallelInfo<Index>* info = 0)\n{\n  typedef const_blas_data_mapper<LhsScalar, Index, LhsStorageOrder> LhsMapper;\n  typedef const_blas_data_mapper<RhsScalar, Index, RhsStorageOrder> RhsMapper;\n  typedef blas_data_mapper<typename Traits::ResScalar, Index, ColMajor> ResMapper;\n  LhsMapper lhs(_lhs,lhsStride);\n  RhsMapper rhs(_rhs,rhsStride);\n  ResMapper res(_res, resStride);\n\n  Index kc = blocking.kc();                   // cache block size along the K direction\n  Index mc = (std::min)(rows,blocking.mc());  // cache block size along the M direction\n  Index nc = (std::min)(cols,blocking.nc());  // cache block size along the N direction\n\n  gemm_pack_lhs<LhsScalar, Index, LhsMapper, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs;\n  gemm_pack_rhs<RhsScalar, Index, RhsMapper, Traits::nr, RhsStorageOrder> pack_rhs;\n  gebp_kernel<LhsScalar, RhsScalar, Index, ResMapper, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp;\n\n#ifdef EIGEN_HAS_OPENMP\n  if(info)\n  {\n    // this is the parallel version!\n    int tid = omp_get_thread_num();\n    int threads = omp_get_num_threads();\n\n    LhsScalar* blockA = blocking.blockA();\n    eigen_internal_assert(blockA!=0);\n\n    std::size_t sizeB = kc*nc;\n    ei_declare_aligned_stack_constructed_variable(RhsScalar, blockB, sizeB, 0);\n\n    // For each horizontal panel of the rhs, and corresponding vertical panel of the lhs...\n    for(Index k=0; k<depth; k+=kc)\n    {\n      const Index actual_kc = (std::min)(k+kc,depth)-k; // => rows of B', and cols of the A'\n\n      // In order to reduce the chance that a thread has to wait for the other,\n      // let's start by packing B'.\n      pack_rhs(blockB, rhs.getSubMapper(k,0), actual_kc, nc);\n\n      // Pack A_k to A' in a parallel fashion:\n      // each thread packs the sub block A_k,i to A'_i where i is the thread id.\n\n      // However, before copying to A'_i, we have to make sure that no other thread is still using it,\n      // i.e., we test that info[tid].users equals 0.\n      // Then, we set info[tid].users to the number of threads to mark that all other threads are going to use it.\n      while(info[tid].users!=0) {}\n      info[tid].users += threads;\n\n      pack_lhs(blockA+info[tid].lhs_start*actual_kc, lhs.getSubMapper(info[tid].lhs_start,k), actual_kc, info[tid].lhs_length);\n\n      // Notify the other threads that the part A'_i is ready to go.\n      info[tid].sync = k;\n\n      // Computes C_i += A' * B' per A'_i\n      for(int shift=0; shift<threads; ++shift)\n      {\n        int i = (tid+shift)%threads;\n\n        // At this point we have to make sure that A'_i has been updated by the thread i,\n        // we use testAndSetOrdered to mimic a volatile access.\n        // However, no need to wait for the B' part which has been updated by the current thread!\n        if (shift>0) {\n          while(info[i].sync!=k) {\n          }\n        }\n\n        gebp(res.getSubMapper(info[i].lhs_start, 0), blockA+info[i].lhs_start*actual_kc, blockB, info[i].lhs_length, actual_kc, nc, alpha);\n      }\n\n      // Then keep going as usual with the remaining B'\n      for(Index j=nc; j<cols; j+=nc)\n      {\n        const Index actual_nc = (std::min)(j+nc,cols)-j;\n\n        // pack B_k,j to B'\n        pack_rhs(blockB, rhs.getSubMapper(k,j), actual_kc, actual_nc);\n\n        // C_j += A' * B'\n        gebp(res.getSubMapper(0, j), blockA, blockB, rows, actual_kc, actual_nc, alpha);\n      }\n\n      // Release all the sub blocks A'_i of A' for the current thread,\n      // i.e., we simply decrement the number of users by 1\n      for(Index i=0; i<threads; ++i)\n        #pragma omp atomic\n        info[i].users -= 1;\n    }\n  }\n  else\n#endif // EIGEN_HAS_OPENMP\n  {\n    EIGEN_UNUSED_VARIABLE(info);\n\n    // this is the sequential version!\n    std::size_t sizeA = kc*mc;\n    std::size_t sizeB = kc*nc;\n\n    ei_declare_aligned_stack_constructed_variable(LhsScalar, blockA, sizeA, blocking.blockA());\n    ei_declare_aligned_stack_constructed_variable(RhsScalar, blockB, sizeB, blocking.blockB());\n\n    const bool pack_rhs_once = mc!=rows && kc==depth && nc==cols;\n\n    // For each horizontal panel of the rhs, and corresponding panel of the lhs...\n    for(Index i2=0; i2<rows; i2+=mc)\n    {\n      const Index actual_mc = (std::min)(i2+mc,rows)-i2;\n\n      for(Index k2=0; k2<depth; k2+=kc)\n      {\n        const Index actual_kc = (std::min)(k2+kc,depth)-k2;\n\n        // OK, here we have selected one horizontal panel of rhs and one vertical panel of lhs.\n        // => Pack lhs's panel into a sequential chunk of memory (L2/L3 caching)\n        // Note that this panel will be read as many times as the number of blocks in the rhs's\n        // horizontal panel which is, in practice, a very low number.\n        pack_lhs(blockA, lhs.getSubMapper(i2,k2), actual_kc, actual_mc);\n\n        // For each kc x nc block of the rhs's horizontal panel...\n        for(Index j2=0; j2<cols; j2+=nc)\n        {\n          const Index actual_nc = (std::min)(j2+nc,cols)-j2;\n\n          // We pack the rhs's block into a sequential chunk of memory (L2 caching)\n          // Note that this block will be read a very high number of times, which is equal to the number of\n          // micro horizontal panel of the large rhs's panel (e.g., rows/12 times).\n          if((!pack_rhs_once) || i2==0)\n            pack_rhs(blockB, rhs.getSubMapper(k2,j2), actual_kc, actual_nc);\n\n          // Everything is packed, we can now call the panel * block kernel:\n          gebp(res.getSubMapper(i2, j2), blockA, blockB, actual_mc, actual_kc, actual_nc, alpha);\n        }\n      }\n    }\n  }\n}\n\n};\n\n/*********************************************************************************\n*  Specialization of generic_product_impl for \"large\" GEMM, i.e.,\n*  implementation of the high level wrapper to general_matrix_matrix_product\n**********************************************************************************/\n\ntemplate<typename Scalar, typename Index, typename Gemm, typename Lhs, typename Rhs, typename Dest, typename BlockingType>\nstruct gemm_functor\n{\n  gemm_functor(const Lhs& lhs, const Rhs& rhs, Dest& dest, const Scalar& actualAlpha, BlockingType& blocking)\n    : m_lhs(lhs), m_rhs(rhs), m_dest(dest), m_actualAlpha(actualAlpha), m_blocking(blocking)\n  {}\n\n  void initParallelSession(Index num_threads) const\n  {\n    m_blocking.initParallel(m_lhs.rows(), m_rhs.cols(), m_lhs.cols(), num_threads);\n    m_blocking.allocateA();\n  }\n\n  void operator() (Index row, Index rows, Index col=0, Index cols=-1, GemmParallelInfo<Index>* info=0) const\n  {\n    if(cols==-1)\n      cols = m_rhs.cols();\n\n    Gemm::run(rows, cols, m_lhs.cols(),\n              &m_lhs.coeffRef(row,0), m_lhs.outerStride(),\n              &m_rhs.coeffRef(0,col), m_rhs.outerStride(),\n              (Scalar*)&(m_dest.coeffRef(row,col)), m_dest.outerStride(),\n              m_actualAlpha, m_blocking, info);\n  }\n\n  typedef typename Gemm::Traits Traits;\n\n  protected:\n    const Lhs& m_lhs;\n    const Rhs& m_rhs;\n    Dest& m_dest;\n    Scalar m_actualAlpha;\n    BlockingType& m_blocking;\n};\n\ntemplate<int StorageOrder, typename LhsScalar, typename RhsScalar, int MaxRows, int MaxCols, int MaxDepth, int KcFactor=1,\nbool FiniteAtCompileTime = MaxRows!=Dynamic && MaxCols!=Dynamic && MaxDepth != Dynamic> class gemm_blocking_space;\n\ntemplate<typename _LhsScalar, typename _RhsScalar>\nclass level3_blocking\n{\n    typedef _LhsScalar LhsScalar;\n    typedef _RhsScalar RhsScalar;\n\n  protected:\n    LhsScalar* m_blockA;\n    RhsScalar* m_blockB;\n\n    Index m_mc;\n    Index m_nc;\n    Index m_kc;\n\n  public:\n\n    level3_blocking()\n      : m_blockA(0), m_blockB(0), m_mc(0), m_nc(0), m_kc(0)\n    {}\n\n    inline Index mc() const { return m_mc; }\n    inline Index nc() const { return m_nc; }\n    inline Index kc() const { return m_kc; }\n\n    inline LhsScalar* blockA() { return m_blockA; }\n    inline RhsScalar* blockB() { return m_blockB; }\n};\n\ntemplate<int StorageOrder, typename _LhsScalar, typename _RhsScalar, int MaxRows, int MaxCols, int MaxDepth, int KcFactor>\nclass gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols, MaxDepth, KcFactor, true /* == FiniteAtCompileTime */>\n  : public level3_blocking<\n      typename conditional<StorageOrder==RowMajor,_RhsScalar,_LhsScalar>::type,\n      typename conditional<StorageOrder==RowMajor,_LhsScalar,_RhsScalar>::type>\n{\n    enum {\n      Transpose = StorageOrder==RowMajor,\n      ActualRows = Transpose ? MaxCols : MaxRows,\n      ActualCols = Transpose ? MaxRows : MaxCols\n    };\n    typedef typename conditional<Transpose,_RhsScalar,_LhsScalar>::type LhsScalar;\n    typedef typename conditional<Transpose,_LhsScalar,_RhsScalar>::type RhsScalar;\n    typedef gebp_traits<LhsScalar,RhsScalar> Traits;\n    enum {\n      SizeA = ActualRows * MaxDepth,\n      SizeB = ActualCols * MaxDepth\n    };\n\n#if EIGEN_MAX_STATIC_ALIGN_BYTES >= EIGEN_DEFAULT_ALIGN_BYTES\n    EIGEN_ALIGN_MAX LhsScalar m_staticA[SizeA];\n    EIGEN_ALIGN_MAX RhsScalar m_staticB[SizeB];\n#else\n    EIGEN_ALIGN_MAX char m_staticA[SizeA * sizeof(LhsScalar) + EIGEN_DEFAULT_ALIGN_BYTES-1];\n    EIGEN_ALIGN_MAX char m_staticB[SizeB * sizeof(RhsScalar) + EIGEN_DEFAULT_ALIGN_BYTES-1];\n#endif\n\n  public:\n\n    gemm_blocking_space(Index /*rows*/, Index /*cols*/, Index /*depth*/, Index /*num_threads*/, bool /*full_rows = false*/)\n    {\n      this->m_mc = ActualRows;\n      this->m_nc = ActualCols;\n      this->m_kc = MaxDepth;\n#if EIGEN_MAX_STATIC_ALIGN_BYTES >= EIGEN_DEFAULT_ALIGN_BYTES\n      this->m_blockA = m_staticA;\n      this->m_blockB = m_staticB;\n#else\n      this->m_blockA = reinterpret_cast<LhsScalar*>((internal::UIntPtr(m_staticA) + (EIGEN_DEFAULT_ALIGN_BYTES-1)) & ~std::size_t(EIGEN_DEFAULT_ALIGN_BYTES-1));\n      this->m_blockB = reinterpret_cast<RhsScalar*>((internal::UIntPtr(m_staticB) + (EIGEN_DEFAULT_ALIGN_BYTES-1)) & ~std::size_t(EIGEN_DEFAULT_ALIGN_BYTES-1));\n#endif\n    }\n\n    void initParallel(Index, Index, Index, Index)\n    {}\n\n    inline void allocateA() {}\n    inline void allocateB() {}\n    inline void allocateAll() {}\n};\n\ntemplate<int StorageOrder, typename _LhsScalar, typename _RhsScalar, int MaxRows, int MaxCols, int MaxDepth, int KcFactor>\nclass gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols, MaxDepth, KcFactor, false>\n  : public level3_blocking<\n      typename conditional<StorageOrder==RowMajor,_RhsScalar,_LhsScalar>::type,\n      typename conditional<StorageOrder==RowMajor,_LhsScalar,_RhsScalar>::type>\n{\n    enum {\n      Transpose = StorageOrder==RowMajor\n    };\n    typedef typename conditional<Transpose,_RhsScalar,_LhsScalar>::type LhsScalar;\n    typedef typename conditional<Transpose,_LhsScalar,_RhsScalar>::type RhsScalar;\n    typedef gebp_traits<LhsScalar,RhsScalar> Traits;\n\n    Index m_sizeA;\n    Index m_sizeB;\n\n  public:\n\n    gemm_blocking_space(Index rows, Index cols, Index depth, Index num_threads, bool l3_blocking)\n    {\n      this->m_mc = Transpose ? cols : rows;\n      this->m_nc = Transpose ? rows : cols;\n      this->m_kc = depth;\n\n      if(l3_blocking)\n      {\n        computeProductBlockingSizes<LhsScalar,RhsScalar,KcFactor>(this->m_kc, this->m_mc, this->m_nc, num_threads);\n      }\n      else  // no l3 blocking\n      {\n        Index n = this->m_nc;\n        computeProductBlockingSizes<LhsScalar,RhsScalar,KcFactor>(this->m_kc, this->m_mc, n, num_threads);\n      }\n\n      m_sizeA = this->m_mc * this->m_kc;\n      m_sizeB = this->m_kc * this->m_nc;\n    }\n\n    void initParallel(Index rows, Index cols, Index depth, Index num_threads)\n    {\n      this->m_mc = Transpose ? cols : rows;\n      this->m_nc = Transpose ? rows : cols;\n      this->m_kc = depth;\n\n      eigen_internal_assert(this->m_blockA==0 && this->m_blockB==0);\n      Index m = this->m_mc;\n      computeProductBlockingSizes<LhsScalar,RhsScalar,KcFactor>(this->m_kc, m, this->m_nc, num_threads);\n      m_sizeA = this->m_mc * this->m_kc;\n      m_sizeB = this->m_kc * this->m_nc;\n    }\n\n    void allocateA()\n    {\n      if(this->m_blockA==0)\n        this->m_blockA = aligned_new<LhsScalar>(m_sizeA);\n    }\n\n    void allocateB()\n    {\n      if(this->m_blockB==0)\n        this->m_blockB = aligned_new<RhsScalar>(m_sizeB);\n    }\n\n    void allocateAll()\n    {\n      allocateA();\n      allocateB();\n    }\n\n    ~gemm_blocking_space()\n    {\n      aligned_delete(this->m_blockA, m_sizeA);\n      aligned_delete(this->m_blockB, m_sizeB);\n    }\n};\n\n} // end namespace internal\n\nnamespace internal {\n\ntemplate<typename Lhs, typename Rhs>\nstruct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemmProduct>\n  : generic_product_impl_base<Lhs,Rhs,generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemmProduct> >\n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  typedef typename Lhs::Scalar LhsScalar;\n  typedef typename Rhs::Scalar RhsScalar;\n\n  typedef internal::blas_traits<Lhs> LhsBlasTraits;\n  typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;\n  typedef typename internal::remove_all<ActualLhsType>::type ActualLhsTypeCleaned;\n\n  typedef internal::blas_traits<Rhs> RhsBlasTraits;\n  typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;\n  typedef typename internal::remove_all<ActualRhsType>::type ActualRhsTypeCleaned;\n\n  enum {\n    MaxDepthAtCompileTime = EIGEN_SIZE_MIN_PREFER_FIXED(Lhs::MaxColsAtCompileTime,Rhs::MaxRowsAtCompileTime)\n  };\n\n  typedef generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,CoeffBasedProductMode> lazyproduct;\n\n  template<typename Dst>\n  static void evalTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    if((rhs.rows()+dst.rows()+dst.cols())<20 && rhs.rows()>0)\n      lazyproduct::evalTo(dst, lhs, rhs);\n    else\n    {\n      dst.setZero();\n      scaleAndAddTo(dst, lhs, rhs, Scalar(1));\n    }\n  }\n\n  template<typename Dst>\n  static void addTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    if((rhs.rows()+dst.rows()+dst.cols())<20 && rhs.rows()>0)\n      lazyproduct::addTo(dst, lhs, rhs);\n    else\n      scaleAndAddTo(dst,lhs, rhs, Scalar(1));\n  }\n\n  template<typename Dst>\n  static void subTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    if((rhs.rows()+dst.rows()+dst.cols())<20 && rhs.rows()>0)\n      lazyproduct::subTo(dst, lhs, rhs);\n    else\n      scaleAndAddTo(dst, lhs, rhs, Scalar(-1));\n  }\n\n  template<typename Dest>\n  static void scaleAndAddTo(Dest& dst, const Lhs& a_lhs, const Rhs& a_rhs, const Scalar& alpha)\n  {\n    eigen_assert(dst.rows()==a_lhs.rows() && dst.cols()==a_rhs.cols());\n    if(a_lhs.cols()==0 || a_lhs.rows()==0 || a_rhs.cols()==0)\n      return;\n\n    typename internal::add_const_on_value_type<ActualLhsType>::type lhs = LhsBlasTraits::extract(a_lhs);\n    typename internal::add_const_on_value_type<ActualRhsType>::type rhs = RhsBlasTraits::extract(a_rhs);\n\n    Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(a_lhs)\n                               * RhsBlasTraits::extractScalarFactor(a_rhs);\n\n    typedef internal::gemm_blocking_space<(Dest::Flags&RowMajorBit) ? RowMajor : ColMajor,LhsScalar,RhsScalar,\n            Dest::MaxRowsAtCompileTime,Dest::MaxColsAtCompileTime,MaxDepthAtCompileTime> BlockingType;\n\n    typedef internal::gemm_functor<\n      Scalar, Index,\n      internal::general_matrix_matrix_product<\n        Index,\n        LhsScalar, (ActualLhsTypeCleaned::Flags&RowMajorBit) ? RowMajor : ColMajor, bool(LhsBlasTraits::NeedToConjugate),\n        RhsScalar, (ActualRhsTypeCleaned::Flags&RowMajorBit) ? RowMajor : ColMajor, bool(RhsBlasTraits::NeedToConjugate),\n        (Dest::Flags&RowMajorBit) ? RowMajor : ColMajor>,\n      ActualLhsTypeCleaned, ActualRhsTypeCleaned, Dest, BlockingType> GemmFunctor;\n\n    BlockingType blocking(dst.rows(), dst.cols(), lhs.cols(), 1, true);\n    internal::parallelize_gemm<(Dest::MaxRowsAtCompileTime>32 || Dest::MaxRowsAtCompileTime==Dynamic)>\n        (GemmFunctor(lhs, rhs, dst, actualAlpha, blocking), a_lhs.rows(), a_rhs.cols(), a_lhs.cols(), Dest::Flags&RowMajorBit);\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_GENERAL_MATRIX_MATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_H\n#define EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_H\n\nnamespace Eigen { \n\ntemplate<typename Scalar, typename Index, int StorageOrder, int UpLo, bool ConjLhs, bool ConjRhs>\nstruct selfadjoint_rank1_update;\n\nnamespace internal {\n\n/**********************************************************************\n* This file implements a general A * B product while\n* evaluating only one triangular part of the product.\n* This is a more general version of self adjoint product (C += A A^T)\n* as the level 3 SYRK Blas routine.\n**********************************************************************/\n\n// forward declarations (defined at the end of this file)\ntemplate<typename LhsScalar, typename RhsScalar, typename Index, int mr, int nr, bool ConjLhs, bool ConjRhs, int UpLo>\nstruct tribb_kernel;\n  \n/* Optimized matrix-matrix product evaluating only one triangular half */\ntemplate <typename Index,\n          typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs,\n          typename RhsScalar, int RhsStorageOrder, bool ConjugateRhs,\n                              int ResStorageOrder, int  UpLo, int Version = Specialized>\nstruct general_matrix_matrix_triangular_product;\n\n// as usual if the result is row major => we transpose the product\ntemplate <typename Index, typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs,\n                          typename RhsScalar, int RhsStorageOrder, bool ConjugateRhs, int  UpLo, int Version>\nstruct general_matrix_matrix_triangular_product<Index,LhsScalar,LhsStorageOrder,ConjugateLhs,RhsScalar,RhsStorageOrder,ConjugateRhs,RowMajor,UpLo,Version>\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType ResScalar;\n  static EIGEN_STRONG_INLINE void run(Index size, Index depth,const LhsScalar* lhs, Index lhsStride,\n                                      const RhsScalar* rhs, Index rhsStride, ResScalar* res, Index resStride,\n                                      const ResScalar& alpha, level3_blocking<RhsScalar,LhsScalar>& blocking)\n  {\n    general_matrix_matrix_triangular_product<Index,\n        RhsScalar, RhsStorageOrder==RowMajor ? ColMajor : RowMajor, ConjugateRhs,\n        LhsScalar, LhsStorageOrder==RowMajor ? ColMajor : RowMajor, ConjugateLhs,\n        ColMajor, UpLo==Lower?Upper:Lower>\n      ::run(size,depth,rhs,rhsStride,lhs,lhsStride,res,resStride,alpha,blocking);\n  }\n};\n\ntemplate <typename Index, typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs,\n                          typename RhsScalar, int RhsStorageOrder, bool ConjugateRhs, int  UpLo, int Version>\nstruct general_matrix_matrix_triangular_product<Index,LhsScalar,LhsStorageOrder,ConjugateLhs,RhsScalar,RhsStorageOrder,ConjugateRhs,ColMajor,UpLo,Version>\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType ResScalar;\n  static EIGEN_STRONG_INLINE void run(Index size, Index depth,const LhsScalar* _lhs, Index lhsStride,\n                                      const RhsScalar* _rhs, Index rhsStride, ResScalar* _res, Index resStride,\n                                      const ResScalar& alpha, level3_blocking<LhsScalar,RhsScalar>& blocking)\n  {\n    typedef gebp_traits<LhsScalar,RhsScalar> Traits;\n\n    typedef const_blas_data_mapper<LhsScalar, Index, LhsStorageOrder> LhsMapper;\n    typedef const_blas_data_mapper<RhsScalar, Index, RhsStorageOrder> RhsMapper;\n    typedef blas_data_mapper<typename Traits::ResScalar, Index, ColMajor> ResMapper;\n    LhsMapper lhs(_lhs,lhsStride);\n    RhsMapper rhs(_rhs,rhsStride);\n    ResMapper res(_res, resStride);\n\n    Index kc = blocking.kc();\n    Index mc = (std::min)(size,blocking.mc());\n\n    // !!! mc must be a multiple of nr:\n    if(mc > Traits::nr)\n      mc = (mc/Traits::nr)*Traits::nr;\n\n    std::size_t sizeA = kc*mc;\n    std::size_t sizeB = kc*size;\n\n    ei_declare_aligned_stack_constructed_variable(LhsScalar, blockA, sizeA, blocking.blockA());\n    ei_declare_aligned_stack_constructed_variable(RhsScalar, blockB, sizeB, blocking.blockB());\n\n    gemm_pack_lhs<LhsScalar, Index, LhsMapper, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs;\n    gemm_pack_rhs<RhsScalar, Index, RhsMapper, Traits::nr, RhsStorageOrder> pack_rhs;\n    gebp_kernel<LhsScalar, RhsScalar, Index, ResMapper, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp;\n    tribb_kernel<LhsScalar, RhsScalar, Index, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs, UpLo> sybb;\n\n    for(Index k2=0; k2<depth; k2+=kc)\n    {\n      const Index actual_kc = (std::min)(k2+kc,depth)-k2;\n\n      // note that the actual rhs is the transpose/adjoint of mat\n      pack_rhs(blockB, rhs.getSubMapper(k2,0), actual_kc, size);\n\n      for(Index i2=0; i2<size; i2+=mc)\n      {\n        const Index actual_mc = (std::min)(i2+mc,size)-i2;\n\n        pack_lhs(blockA, lhs.getSubMapper(i2, k2), actual_kc, actual_mc);\n\n        // the selected actual_mc * size panel of res is split into three different part:\n        //  1 - before the diagonal => processed with gebp or skipped\n        //  2 - the actual_mc x actual_mc symmetric block => processed with a special kernel\n        //  3 - after the diagonal => processed with gebp or skipped\n        if (UpLo==Lower)\n          gebp(res.getSubMapper(i2, 0), blockA, blockB, actual_mc, actual_kc,\n               (std::min)(size,i2), alpha, -1, -1, 0, 0);\n\n\n        sybb(_res+resStride*i2 + i2, resStride, blockA, blockB + actual_kc*i2, actual_mc, actual_kc, alpha);\n\n        if (UpLo==Upper)\n        {\n          Index j2 = i2+actual_mc;\n          gebp(res.getSubMapper(i2, j2), blockA, blockB+actual_kc*j2, actual_mc,\n               actual_kc, (std::max)(Index(0), size-j2), alpha, -1, -1, 0, 0);\n        }\n      }\n    }\n  }\n};\n\n// Optimized packed Block * packed Block product kernel evaluating only one given triangular part\n// This kernel is built on top of the gebp kernel:\n// - the current destination block is processed per panel of actual_mc x BlockSize\n//   where BlockSize is set to the minimal value allowing gebp to be as fast as possible\n// - then, as usual, each panel is split into three parts along the diagonal,\n//   the sub blocks above and below the diagonal are processed as usual,\n//   while the triangular block overlapping the diagonal is evaluated into a\n//   small temporary buffer which is then accumulated into the result using a\n//   triangular traversal.\ntemplate<typename LhsScalar, typename RhsScalar, typename Index, int mr, int nr, bool ConjLhs, bool ConjRhs, int UpLo>\nstruct tribb_kernel\n{\n  typedef gebp_traits<LhsScalar,RhsScalar,ConjLhs,ConjRhs> Traits;\n  typedef typename Traits::ResScalar ResScalar;\n\n  enum {\n    BlockSize  = meta_least_common_multiple<EIGEN_PLAIN_ENUM_MAX(mr,nr),EIGEN_PLAIN_ENUM_MIN(mr,nr)>::ret\n  };\n  void operator()(ResScalar* _res, Index resStride, const LhsScalar* blockA, const RhsScalar* blockB, Index size, Index depth, const ResScalar& alpha)\n  {\n    typedef blas_data_mapper<ResScalar, Index, ColMajor> ResMapper;\n    ResMapper res(_res, resStride);\n    gebp_kernel<LhsScalar, RhsScalar, Index, ResMapper, mr, nr, ConjLhs, ConjRhs> gebp_kernel;\n\n    Matrix<ResScalar,BlockSize,BlockSize,ColMajor> buffer((internal::constructor_without_unaligned_array_assert()));\n\n    // let's process the block per panel of actual_mc x BlockSize,\n    // again, each is split into three parts, etc.\n    for (Index j=0; j<size; j+=BlockSize)\n    {\n      Index actualBlockSize = std::min<Index>(BlockSize,size - j);\n      const RhsScalar* actual_b = blockB+j*depth;\n\n      if(UpLo==Upper)\n        gebp_kernel(res.getSubMapper(0, j), blockA, actual_b, j, depth, actualBlockSize, alpha,\n                    -1, -1, 0, 0);\n\n      // selfadjoint micro block\n      {\n        Index i = j;\n        buffer.setZero();\n        // 1 - apply the kernel on the temporary buffer\n        gebp_kernel(ResMapper(buffer.data(), BlockSize), blockA+depth*i, actual_b, actualBlockSize, depth, actualBlockSize, alpha,\n                    -1, -1, 0, 0);\n        // 2 - triangular accumulation\n        for(Index j1=0; j1<actualBlockSize; ++j1)\n        {\n          ResScalar* r = &res(i, j + j1);\n          for(Index i1=UpLo==Lower ? j1 : 0;\n              UpLo==Lower ? i1<actualBlockSize : i1<=j1; ++i1)\n            r[i1] += buffer(i1,j1);\n        }\n      }\n\n      if(UpLo==Lower)\n      {\n        Index i = j+actualBlockSize;\n        gebp_kernel(res.getSubMapper(i, j), blockA+depth*i, actual_b, size-i, \n                    depth, actualBlockSize, alpha, -1, -1, 0, 0);\n      }\n    }\n  }\n};\n\n} // end namespace internal\n\n// high level API\n\ntemplate<typename MatrixType, typename ProductType, int UpLo, bool IsOuterProduct>\nstruct general_product_to_triangular_selector;\n\n\ntemplate<typename MatrixType, typename ProductType, int UpLo>\nstruct general_product_to_triangular_selector<MatrixType,ProductType,UpLo,true>\n{\n  static void run(MatrixType& mat, const ProductType& prod, const typename MatrixType::Scalar& alpha, bool beta)\n  {\n    typedef typename MatrixType::Scalar Scalar;\n    \n    typedef typename internal::remove_all<typename ProductType::LhsNested>::type Lhs;\n    typedef internal::blas_traits<Lhs> LhsBlasTraits;\n    typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhs;\n    typedef typename internal::remove_all<ActualLhs>::type _ActualLhs;\n    typename internal::add_const_on_value_type<ActualLhs>::type actualLhs = LhsBlasTraits::extract(prod.lhs());\n    \n    typedef typename internal::remove_all<typename ProductType::RhsNested>::type Rhs;\n    typedef internal::blas_traits<Rhs> RhsBlasTraits;\n    typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhs;\n    typedef typename internal::remove_all<ActualRhs>::type _ActualRhs;\n    typename internal::add_const_on_value_type<ActualRhs>::type actualRhs = RhsBlasTraits::extract(prod.rhs());\n\n    Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(prod.lhs().derived()) * RhsBlasTraits::extractScalarFactor(prod.rhs().derived());\n\n    if(!beta)\n      mat.template triangularView<UpLo>().setZero();\n\n    enum {\n      StorageOrder = (internal::traits<MatrixType>::Flags&RowMajorBit) ? RowMajor : ColMajor,\n      UseLhsDirectly = _ActualLhs::InnerStrideAtCompileTime==1,\n      UseRhsDirectly = _ActualRhs::InnerStrideAtCompileTime==1\n    };\n    \n    internal::gemv_static_vector_if<Scalar,Lhs::SizeAtCompileTime,Lhs::MaxSizeAtCompileTime,!UseLhsDirectly> static_lhs;\n    ei_declare_aligned_stack_constructed_variable(Scalar, actualLhsPtr, actualLhs.size(),\n      (UseLhsDirectly ? const_cast<Scalar*>(actualLhs.data()) : static_lhs.data()));\n    if(!UseLhsDirectly) Map<typename _ActualLhs::PlainObject>(actualLhsPtr, actualLhs.size()) = actualLhs;\n    \n    internal::gemv_static_vector_if<Scalar,Rhs::SizeAtCompileTime,Rhs::MaxSizeAtCompileTime,!UseRhsDirectly> static_rhs;\n    ei_declare_aligned_stack_constructed_variable(Scalar, actualRhsPtr, actualRhs.size(),\n      (UseRhsDirectly ? const_cast<Scalar*>(actualRhs.data()) : static_rhs.data()));\n    if(!UseRhsDirectly) Map<typename _ActualRhs::PlainObject>(actualRhsPtr, actualRhs.size()) = actualRhs;\n    \n    \n    selfadjoint_rank1_update<Scalar,Index,StorageOrder,UpLo,\n                              LhsBlasTraits::NeedToConjugate && NumTraits<Scalar>::IsComplex,\n                              RhsBlasTraits::NeedToConjugate && NumTraits<Scalar>::IsComplex>\n          ::run(actualLhs.size(), mat.data(), mat.outerStride(), actualLhsPtr, actualRhsPtr, actualAlpha);\n  }\n};\n\ntemplate<typename MatrixType, typename ProductType, int UpLo>\nstruct general_product_to_triangular_selector<MatrixType,ProductType,UpLo,false>\n{\n  static void run(MatrixType& mat, const ProductType& prod, const typename MatrixType::Scalar& alpha, bool beta)\n  {\n    typedef typename internal::remove_all<typename ProductType::LhsNested>::type Lhs;\n    typedef internal::blas_traits<Lhs> LhsBlasTraits;\n    typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhs;\n    typedef typename internal::remove_all<ActualLhs>::type _ActualLhs;\n    typename internal::add_const_on_value_type<ActualLhs>::type actualLhs = LhsBlasTraits::extract(prod.lhs());\n    \n    typedef typename internal::remove_all<typename ProductType::RhsNested>::type Rhs;\n    typedef internal::blas_traits<Rhs> RhsBlasTraits;\n    typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhs;\n    typedef typename internal::remove_all<ActualRhs>::type _ActualRhs;\n    typename internal::add_const_on_value_type<ActualRhs>::type actualRhs = RhsBlasTraits::extract(prod.rhs());\n\n    typename ProductType::Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(prod.lhs().derived()) * RhsBlasTraits::extractScalarFactor(prod.rhs().derived());\n\n    if(!beta)\n      mat.template triangularView<UpLo>().setZero();\n\n    enum {\n      IsRowMajor = (internal::traits<MatrixType>::Flags&RowMajorBit) ? 1 : 0,\n      LhsIsRowMajor = _ActualLhs::Flags&RowMajorBit ? 1 : 0,\n      RhsIsRowMajor = _ActualRhs::Flags&RowMajorBit ? 1 : 0,\n      SkipDiag = (UpLo&(UnitDiag|ZeroDiag))!=0\n    };\n\n    Index size = mat.cols();\n    if(SkipDiag)\n      size--;\n    Index depth = actualLhs.cols();\n\n    typedef internal::gemm_blocking_space<IsRowMajor ? RowMajor : ColMajor,typename Lhs::Scalar,typename Rhs::Scalar,\n          MatrixType::MaxColsAtCompileTime, MatrixType::MaxColsAtCompileTime, _ActualRhs::MaxColsAtCompileTime> BlockingType;\n\n    BlockingType blocking(size, size, depth, 1, false);\n\n    internal::general_matrix_matrix_triangular_product<Index,\n      typename Lhs::Scalar, LhsIsRowMajor ? RowMajor : ColMajor, LhsBlasTraits::NeedToConjugate,\n      typename Rhs::Scalar, RhsIsRowMajor ? RowMajor : ColMajor, RhsBlasTraits::NeedToConjugate,\n      IsRowMajor ? RowMajor : ColMajor, UpLo&(Lower|Upper)>\n      ::run(size, depth,\n            &actualLhs.coeffRef(SkipDiag&&(UpLo&Lower)==Lower ? 1 : 0,0), actualLhs.outerStride(),\n            &actualRhs.coeffRef(0,SkipDiag&&(UpLo&Upper)==Upper ? 1 : 0), actualRhs.outerStride(),\n            mat.data() + (SkipDiag ? (bool(IsRowMajor) != ((UpLo&Lower)==Lower) ? 1 : mat.outerStride() ) : 0), mat.outerStride(), actualAlpha, blocking);\n  }\n};\n\ntemplate<typename MatrixType, unsigned int UpLo>\ntemplate<typename ProductType>\nTriangularView<MatrixType,UpLo>& TriangularViewImpl<MatrixType,UpLo,Dense>::_assignProduct(const ProductType& prod, const Scalar& alpha, bool beta)\n{\n  EIGEN_STATIC_ASSERT((UpLo&UnitDiag)==0, WRITING_TO_TRIANGULAR_PART_WITH_UNIT_DIAGONAL_IS_NOT_SUPPORTED);\n  eigen_assert(derived().nestedExpression().rows() == prod.rows() && derived().cols() == prod.cols());\n  \n  general_product_to_triangular_selector<MatrixType, ProductType, UpLo, internal::traits<ProductType>::InnerSize==1>::run(derived().nestedExpression().const_cast_derived(), prod, alpha, beta);\n  \n  return derived();\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to BLAS F77\n *   Level 3 BLAS SYRK/HERK implementation.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_BLAS_H\n#define EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_BLAS_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate <typename Index, typename Scalar, int AStorageOrder, bool ConjugateA, int ResStorageOrder, int  UpLo>\nstruct general_matrix_matrix_rankupdate :\n       general_matrix_matrix_triangular_product<\n         Index,Scalar,AStorageOrder,ConjugateA,Scalar,AStorageOrder,ConjugateA,ResStorageOrder,UpLo,BuiltIn> {};\n\n\n// try to go to BLAS specialization\n#define EIGEN_BLAS_RANKUPDATE_SPECIALIZE(Scalar) \\\ntemplate <typename Index, int LhsStorageOrder, bool ConjugateLhs, \\\n                          int RhsStorageOrder, bool ConjugateRhs, int  UpLo> \\\nstruct general_matrix_matrix_triangular_product<Index,Scalar,LhsStorageOrder,ConjugateLhs, \\\n               Scalar,RhsStorageOrder,ConjugateRhs,ColMajor,UpLo,Specialized> { \\\n  static EIGEN_STRONG_INLINE void run(Index size, Index depth,const Scalar* lhs, Index lhsStride, \\\n                          const Scalar* rhs, Index rhsStride, Scalar* res, Index resStride, Scalar alpha, level3_blocking<Scalar, Scalar>& blocking) \\\n  { \\\n    if ( lhs==rhs && ((UpLo&(Lower|Upper)==UpLo)) ) { \\\n      general_matrix_matrix_rankupdate<Index,Scalar,LhsStorageOrder,ConjugateLhs,ColMajor,UpLo> \\\n      ::run(size,depth,lhs,lhsStride,rhs,rhsStride,res,resStride,alpha,blocking); \\\n    } else { \\\n      general_matrix_matrix_triangular_product<Index, \\\n        Scalar, LhsStorageOrder, ConjugateLhs, \\\n        Scalar, RhsStorageOrder, ConjugateRhs, \\\n        ColMajor, UpLo, BuiltIn> \\\n      ::run(size,depth,lhs,lhsStride,rhs,rhsStride,res,resStride,alpha,blocking); \\\n    } \\\n  } \\\n};\n\nEIGEN_BLAS_RANKUPDATE_SPECIALIZE(double)\nEIGEN_BLAS_RANKUPDATE_SPECIALIZE(float)\n// TODO handle complex cases\n// EIGEN_BLAS_RANKUPDATE_SPECIALIZE(dcomplex)\n// EIGEN_BLAS_RANKUPDATE_SPECIALIZE(scomplex)\n\n// SYRK for float/double\n#define EIGEN_BLAS_RANKUPDATE_R(EIGTYPE, BLASTYPE, BLASFUNC) \\\ntemplate <typename Index, int AStorageOrder, bool ConjugateA, int  UpLo> \\\nstruct general_matrix_matrix_rankupdate<Index,EIGTYPE,AStorageOrder,ConjugateA,ColMajor,UpLo> { \\\n  enum { \\\n    IsLower = (UpLo&Lower) == Lower, \\\n    LowUp = IsLower ? Lower : Upper, \\\n    conjA = ((AStorageOrder==ColMajor) && ConjugateA) ? 1 : 0 \\\n  }; \\\n  static EIGEN_STRONG_INLINE void run(Index size, Index depth,const EIGTYPE* lhs, Index lhsStride, \\\n                          const EIGTYPE* /*rhs*/, Index /*rhsStride*/, EIGTYPE* res, Index resStride, EIGTYPE alpha, level3_blocking<EIGTYPE, EIGTYPE>& /*blocking*/) \\\n  { \\\n  /* typedef Matrix<EIGTYPE, Dynamic, Dynamic, RhsStorageOrder> MatrixRhs;*/ \\\n\\\n   BlasIndex lda=convert_index<BlasIndex>(lhsStride), ldc=convert_index<BlasIndex>(resStride), n=convert_index<BlasIndex>(size), k=convert_index<BlasIndex>(depth); \\\n   char uplo=((IsLower) ? 'L' : 'U'), trans=((AStorageOrder==RowMajor) ? 'T':'N'); \\\n   EIGTYPE beta(1); \\\n   BLASFUNC(&uplo, &trans, &n, &k, &numext::real_ref(alpha), lhs, &lda, &numext::real_ref(beta), res, &ldc); \\\n  } \\\n};\n\n// HERK for complex data\n#define EIGEN_BLAS_RANKUPDATE_C(EIGTYPE, BLASTYPE, RTYPE, BLASFUNC) \\\ntemplate <typename Index, int AStorageOrder, bool ConjugateA, int  UpLo> \\\nstruct general_matrix_matrix_rankupdate<Index,EIGTYPE,AStorageOrder,ConjugateA,ColMajor,UpLo> { \\\n  enum { \\\n    IsLower = (UpLo&Lower) == Lower, \\\n    LowUp = IsLower ? Lower : Upper, \\\n    conjA = (((AStorageOrder==ColMajor) && ConjugateA) || ((AStorageOrder==RowMajor) && !ConjugateA)) ? 1 : 0 \\\n  }; \\\n  static EIGEN_STRONG_INLINE void run(Index size, Index depth,const EIGTYPE* lhs, Index lhsStride, \\\n                          const EIGTYPE* /*rhs*/, Index /*rhsStride*/, EIGTYPE* res, Index resStride, EIGTYPE alpha, level3_blocking<EIGTYPE, EIGTYPE>& /*blocking*/) \\\n  { \\\n   typedef Matrix<EIGTYPE, Dynamic, Dynamic, AStorageOrder> MatrixType; \\\n\\\n   BlasIndex lda=convert_index<BlasIndex>(lhsStride), ldc=convert_index<BlasIndex>(resStride), n=convert_index<BlasIndex>(size), k=convert_index<BlasIndex>(depth); \\\n   char uplo=((IsLower) ? 'L' : 'U'), trans=((AStorageOrder==RowMajor) ? 'C':'N'); \\\n   RTYPE alpha_, beta_; \\\n   const EIGTYPE* a_ptr; \\\n\\\n   alpha_ = alpha.real(); \\\n   beta_ = 1.0; \\\n/* Copy with conjugation in some cases*/ \\\n   MatrixType a; \\\n   if (conjA) { \\\n     Map<const MatrixType, 0, OuterStride<> > mapA(lhs,n,k,OuterStride<>(lhsStride)); \\\n     a = mapA.conjugate(); \\\n     lda = a.outerStride(); \\\n     a_ptr = a.data(); \\\n   } else a_ptr=lhs; \\\n   BLASFUNC(&uplo, &trans, &n, &k, &alpha_, (BLASTYPE*)a_ptr, &lda, &beta_, (BLASTYPE*)res, &ldc); \\\n  } \\\n};\n\n\nEIGEN_BLAS_RANKUPDATE_R(double, double, dsyrk_)\nEIGEN_BLAS_RANKUPDATE_R(float,  float,  ssyrk_)\n\n// TODO hanlde complex cases\n// EIGEN_BLAS_RANKUPDATE_C(dcomplex, double, double, zherk_)\n// EIGEN_BLAS_RANKUPDATE_C(scomplex, float,  float, cherk_)\n\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_BLAS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to BLAS F77\n *   General matrix-matrix product functionality based on ?GEMM.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_GENERAL_MATRIX_MATRIX_BLAS_H\n#define EIGEN_GENERAL_MATRIX_MATRIX_BLAS_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/**********************************************************************\n* This file implements general matrix-matrix multiplication using BLAS\n* gemm function via partial specialization of\n* general_matrix_matrix_product::run(..) method for float, double,\n* std::complex<float> and std::complex<double> types\n**********************************************************************/\n\n// gemm specialization\n\n#define GEMM_SPECIALIZATION(EIGTYPE, EIGPREFIX, BLASTYPE, BLASPREFIX) \\\ntemplate< \\\n  typename Index, \\\n  int LhsStorageOrder, bool ConjugateLhs, \\\n  int RhsStorageOrder, bool ConjugateRhs> \\\nstruct general_matrix_matrix_product<Index,EIGTYPE,LhsStorageOrder,ConjugateLhs,EIGTYPE,RhsStorageOrder,ConjugateRhs,ColMajor> \\\n{ \\\ntypedef gebp_traits<EIGTYPE,EIGTYPE> Traits; \\\n\\\nstatic void run(Index rows, Index cols, Index depth, \\\n  const EIGTYPE* _lhs, Index lhsStride, \\\n  const EIGTYPE* _rhs, Index rhsStride, \\\n  EIGTYPE* res, Index resStride, \\\n  EIGTYPE alpha, \\\n  level3_blocking<EIGTYPE, EIGTYPE>& /*blocking*/, \\\n  GemmParallelInfo<Index>* /*info = 0*/) \\\n{ \\\n  using std::conj; \\\n\\\n  char transa, transb; \\\n  BlasIndex m, n, k, lda, ldb, ldc; \\\n  const EIGTYPE *a, *b; \\\n  EIGTYPE beta(1); \\\n  MatrixX##EIGPREFIX a_tmp, b_tmp; \\\n\\\n/* Set transpose options */ \\\n  transa = (LhsStorageOrder==RowMajor) ? ((ConjugateLhs) ? 'C' : 'T') : 'N'; \\\n  transb = (RhsStorageOrder==RowMajor) ? ((ConjugateRhs) ? 'C' : 'T') : 'N'; \\\n\\\n/* Set m, n, k */ \\\n  m = convert_index<BlasIndex>(rows);  \\\n  n = convert_index<BlasIndex>(cols);  \\\n  k = convert_index<BlasIndex>(depth); \\\n\\\n/* Set lda, ldb, ldc */ \\\n  lda = convert_index<BlasIndex>(lhsStride); \\\n  ldb = convert_index<BlasIndex>(rhsStride); \\\n  ldc = convert_index<BlasIndex>(resStride); \\\n\\\n/* Set a, b, c */ \\\n  if ((LhsStorageOrder==ColMajor) && (ConjugateLhs)) { \\\n    Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs,m,k,OuterStride<>(lhsStride)); \\\n    a_tmp = lhs.conjugate(); \\\n    a = a_tmp.data(); \\\n    lda = convert_index<BlasIndex>(a_tmp.outerStride()); \\\n  } else a = _lhs; \\\n\\\n  if ((RhsStorageOrder==ColMajor) && (ConjugateRhs)) { \\\n    Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs,k,n,OuterStride<>(rhsStride)); \\\n    b_tmp = rhs.conjugate(); \\\n    b = b_tmp.data(); \\\n    ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \\\n  } else b = _rhs; \\\n\\\n  BLASPREFIX##gemm_(&transa, &transb, &m, &n, &k, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)b, &ldb, &numext::real_ref(beta), (BLASTYPE*)res, &ldc); \\\n}};\n\nGEMM_SPECIALIZATION(double,   d,  double, d)\nGEMM_SPECIALIZATION(float,    f,  float,  s)\nGEMM_SPECIALIZATION(dcomplex, cd, double, z)\nGEMM_SPECIALIZATION(scomplex, cf, float,  c)\n\n} // end namespase internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_GENERAL_MATRIX_MATRIX_BLAS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/GeneralMatrixVector.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_GENERAL_MATRIX_VECTOR_H\n#define EIGEN_GENERAL_MATRIX_VECTOR_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n/* Optimized col-major matrix * vector product:\n * This algorithm processes 4 columns at onces that allows to both reduce\n * the number of load/stores of the result by a factor 4 and to reduce\n * the instruction dependency. Moreover, we know that all bands have the\n * same alignment pattern.\n *\n * Mixing type logic: C += alpha * A * B\n *  |  A  |  B  |alpha| comments\n *  |real |cplx |cplx | no vectorization\n *  |real |cplx |real | alpha is converted to a cplx when calling the run function, no vectorization\n *  |cplx |real |cplx | invalid, the caller has to do tmp: = A * B; C += alpha*tmp\n *  |cplx |real |real | optimal case, vectorization possible via real-cplx mul\n *\n * Accesses to the matrix coefficients follow the following logic:\n *\n * - if all columns have the same alignment then\n *   - if the columns have the same alignment as the result vector, then easy! (-> AllAligned case)\n *   - otherwise perform unaligned loads only (-> NoneAligned case)\n * - otherwise\n *   - if even columns have the same alignment then\n *     // odd columns are guaranteed to have the same alignment too\n *     - if even or odd columns have the same alignment as the result, then\n *       // for a register size of 2 scalars, this is guarantee to be the case (e.g., SSE with double)\n *       - perform half aligned and half unaligned loads (-> EvenAligned case)\n *     - otherwise perform unaligned loads only (-> NoneAligned case)\n *   - otherwise, if the register size is 4 scalars (e.g., SSE with float) then\n *     - one over 4 consecutive columns is guaranteed to be aligned with the result vector,\n *       perform simple aligned loads for this column and aligned loads plus re-alignment for the other. (-> FirstAligned case)\n *       // this re-alignment is done by the palign function implemented for SSE in Eigen/src/Core/arch/SSE/PacketMath.h\n *   - otherwise,\n *     // if we get here, this means the register size is greater than 4 (e.g., AVX with floats),\n *     // we currently fall back to the NoneAligned case\n *\n * The same reasoning apply for the transposed case.\n *\n * The last case (PacketSize>4) could probably be improved by generalizing the FirstAligned case, but since we do not support AVX yet...\n * One might also wonder why in the EvenAligned case we perform unaligned loads instead of using the aligned-loads plus re-alignment\n * strategy as in the FirstAligned case. The reason is that we observed that unaligned loads on a 8 byte boundary are not too slow\n * compared to unaligned loads on a 4 byte boundary.\n *\n */\ntemplate<typename Index, typename LhsScalar, typename LhsMapper, bool ConjugateLhs, typename RhsScalar, typename RhsMapper, bool ConjugateRhs, int Version>\nstruct general_matrix_vector_product<Index,LhsScalar,LhsMapper,ColMajor,ConjugateLhs,RhsScalar,RhsMapper,ConjugateRhs,Version>\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType ResScalar;\n\nenum {\n  Vectorizable = packet_traits<LhsScalar>::Vectorizable && packet_traits<RhsScalar>::Vectorizable\n              && int(packet_traits<LhsScalar>::size)==int(packet_traits<RhsScalar>::size),\n  LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1,\n  RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1,\n  ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1\n};\n\ntypedef typename packet_traits<LhsScalar>::type  _LhsPacket;\ntypedef typename packet_traits<RhsScalar>::type  _RhsPacket;\ntypedef typename packet_traits<ResScalar>::type  _ResPacket;\n\ntypedef typename conditional<Vectorizable,_LhsPacket,LhsScalar>::type LhsPacket;\ntypedef typename conditional<Vectorizable,_RhsPacket,RhsScalar>::type RhsPacket;\ntypedef typename conditional<Vectorizable,_ResPacket,ResScalar>::type ResPacket;\n\nEIGEN_DONT_INLINE static void run(\n  Index rows, Index cols,\n  const LhsMapper& lhs,\n  const RhsMapper& rhs,\n        ResScalar* res, Index resIncr,\n  RhsScalar alpha);\n};\n\ntemplate<typename Index, typename LhsScalar, typename LhsMapper, bool ConjugateLhs, typename RhsScalar, typename RhsMapper, bool ConjugateRhs, int Version>\nEIGEN_DONT_INLINE void general_matrix_vector_product<Index,LhsScalar,LhsMapper,ColMajor,ConjugateLhs,RhsScalar,RhsMapper,ConjugateRhs,Version>::run(\n  Index rows, Index cols,\n  const LhsMapper& lhs,\n  const RhsMapper& rhs,\n        ResScalar* res, Index resIncr,\n  RhsScalar alpha)\n{\n  EIGEN_UNUSED_VARIABLE(resIncr);\n  eigen_internal_assert(resIncr==1);\n  #ifdef _EIGEN_ACCUMULATE_PACKETS\n  #error _EIGEN_ACCUMULATE_PACKETS has already been defined\n  #endif\n  #define _EIGEN_ACCUMULATE_PACKETS(Alignment0,Alignment13,Alignment2) \\\n    pstore(&res[j], \\\n      padd(pload<ResPacket>(&res[j]), \\\n        padd( \\\n      padd(pcj.pmul(lhs0.template load<LhsPacket, Alignment0>(j),    ptmp0), \\\n      pcj.pmul(lhs1.template load<LhsPacket, Alignment13>(j),   ptmp1)),   \\\n      padd(pcj.pmul(lhs2.template load<LhsPacket, Alignment2>(j),    ptmp2), \\\n      pcj.pmul(lhs3.template load<LhsPacket, Alignment13>(j),   ptmp3)) )))\n\n  typedef typename LhsMapper::VectorMapper LhsScalars;\n\n  conj_helper<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> cj;\n  conj_helper<LhsPacket,RhsPacket,ConjugateLhs,ConjugateRhs> pcj;\n  if(ConjugateRhs)\n    alpha = numext::conj(alpha);\n\n  enum { AllAligned = 0, EvenAligned, FirstAligned, NoneAligned };\n  const Index columnsAtOnce = 4;\n  const Index peels = 2;\n  const Index LhsPacketAlignedMask = LhsPacketSize-1;\n  const Index ResPacketAlignedMask = ResPacketSize-1;\n//  const Index PeelAlignedMask = ResPacketSize*peels-1;\n  const Index size = rows;\n\n  const Index lhsStride = lhs.stride();\n\n  // How many coeffs of the result do we have to skip to be aligned.\n  // Here we assume data are at least aligned on the base scalar type.\n  Index alignedStart = internal::first_default_aligned(res,size);\n  Index alignedSize = ResPacketSize>1 ? alignedStart + ((size-alignedStart) & ~ResPacketAlignedMask) : 0;\n  const Index peeledSize = alignedSize - RhsPacketSize*peels - RhsPacketSize + 1;\n\n  const Index alignmentStep = LhsPacketSize>1 ? (LhsPacketSize - lhsStride % LhsPacketSize) & LhsPacketAlignedMask : 0;\n  Index alignmentPattern = alignmentStep==0 ? AllAligned\n                       : alignmentStep==(LhsPacketSize/2) ? EvenAligned\n                       : FirstAligned;\n\n  // we cannot assume the first element is aligned because of sub-matrices\n  const Index lhsAlignmentOffset = lhs.firstAligned(size);\n\n  // find how many columns do we have to skip to be aligned with the result (if possible)\n  Index skipColumns = 0;\n  // if the data cannot be aligned (TODO add some compile time tests when possible, e.g. for floats)\n  if( (lhsAlignmentOffset < 0) || (lhsAlignmentOffset == size) || (UIntPtr(res)%sizeof(ResScalar)) )\n  {\n    alignedSize = 0;\n    alignedStart = 0;\n    alignmentPattern = NoneAligned;\n  }\n  else if(LhsPacketSize > 4)\n  {\n    // TODO: extend the code to support aligned loads whenever possible when LhsPacketSize > 4.\n    // Currently, it seems to be better to perform unaligned loads anyway\n    alignmentPattern = NoneAligned;\n  }\n  else if (LhsPacketSize>1)\n  {\n  //    eigen_internal_assert(size_t(firstLhs+lhsAlignmentOffset)%sizeof(LhsPacket)==0 || size<LhsPacketSize);\n\n    while (skipColumns<LhsPacketSize &&\n          alignedStart != ((lhsAlignmentOffset + alignmentStep*skipColumns)%LhsPacketSize))\n      ++skipColumns;\n    if (skipColumns==LhsPacketSize)\n    {\n      // nothing can be aligned, no need to skip any column\n      alignmentPattern = NoneAligned;\n      skipColumns = 0;\n    }\n    else\n    {\n      skipColumns = (std::min)(skipColumns,cols);\n      // note that the skiped columns are processed later.\n    }\n\n    /*    eigen_internal_assert(  (alignmentPattern==NoneAligned)\n                      || (skipColumns + columnsAtOnce >= cols)\n                      || LhsPacketSize > size\n                      || (size_t(firstLhs+alignedStart+lhsStride*skipColumns)%sizeof(LhsPacket))==0);*/\n  }\n  else if(Vectorizable)\n  {\n    alignedStart = 0;\n    alignedSize = size;\n    alignmentPattern = AllAligned;\n  }\n\n  const Index offset1 = (FirstAligned && alignmentStep==1)?3:1;\n  const Index offset3 = (FirstAligned && alignmentStep==1)?1:3;\n\n  Index columnBound = ((cols-skipColumns)/columnsAtOnce)*columnsAtOnce + skipColumns;\n  for (Index i=skipColumns; i<columnBound; i+=columnsAtOnce)\n  {\n    RhsPacket ptmp0 = pset1<RhsPacket>(alpha*rhs(i, 0)),\n              ptmp1 = pset1<RhsPacket>(alpha*rhs(i+offset1, 0)),\n              ptmp2 = pset1<RhsPacket>(alpha*rhs(i+2, 0)),\n              ptmp3 = pset1<RhsPacket>(alpha*rhs(i+offset3, 0));\n\n    // this helps a lot generating better binary code\n    const LhsScalars lhs0 = lhs.getVectorMapper(0, i+0),   lhs1 = lhs.getVectorMapper(0, i+offset1),\n                     lhs2 = lhs.getVectorMapper(0, i+2),   lhs3 = lhs.getVectorMapper(0, i+offset3);\n\n    if (Vectorizable)\n    {\n      /* explicit vectorization */\n      // process initial unaligned coeffs\n      for (Index j=0; j<alignedStart; ++j)\n      {\n        res[j] = cj.pmadd(lhs0(j), pfirst(ptmp0), res[j]);\n        res[j] = cj.pmadd(lhs1(j), pfirst(ptmp1), res[j]);\n        res[j] = cj.pmadd(lhs2(j), pfirst(ptmp2), res[j]);\n        res[j] = cj.pmadd(lhs3(j), pfirst(ptmp3), res[j]);\n      }\n\n      if (alignedSize>alignedStart)\n      {\n        switch(alignmentPattern)\n        {\n          case AllAligned:\n            for (Index j = alignedStart; j<alignedSize; j+=ResPacketSize)\n              _EIGEN_ACCUMULATE_PACKETS(Aligned,Aligned,Aligned);\n            break;\n          case EvenAligned:\n            for (Index j = alignedStart; j<alignedSize; j+=ResPacketSize)\n              _EIGEN_ACCUMULATE_PACKETS(Aligned,Unaligned,Aligned);\n            break;\n          case FirstAligned:\n          {\n            Index j = alignedStart;\n            if(peels>1)\n            {\n              LhsPacket A00, A01, A02, A03, A10, A11, A12, A13;\n              ResPacket T0, T1;\n\n              A01 = lhs1.template load<LhsPacket, Aligned>(alignedStart-1);\n              A02 = lhs2.template load<LhsPacket, Aligned>(alignedStart-2);\n              A03 = lhs3.template load<LhsPacket, Aligned>(alignedStart-3);\n\n              for (; j<peeledSize; j+=peels*ResPacketSize)\n              {\n                A11 = lhs1.template load<LhsPacket, Aligned>(j-1+LhsPacketSize);  palign<1>(A01,A11);\n                A12 = lhs2.template load<LhsPacket, Aligned>(j-2+LhsPacketSize);  palign<2>(A02,A12);\n                A13 = lhs3.template load<LhsPacket, Aligned>(j-3+LhsPacketSize);  palign<3>(A03,A13);\n\n                A00 = lhs0.template load<LhsPacket, Aligned>(j);\n                A10 = lhs0.template load<LhsPacket, Aligned>(j+LhsPacketSize);\n                T0  = pcj.pmadd(A00, ptmp0, pload<ResPacket>(&res[j]));\n                T1  = pcj.pmadd(A10, ptmp0, pload<ResPacket>(&res[j+ResPacketSize]));\n\n                T0  = pcj.pmadd(A01, ptmp1, T0);\n                A01 = lhs1.template load<LhsPacket, Aligned>(j-1+2*LhsPacketSize);  palign<1>(A11,A01);\n                T0  = pcj.pmadd(A02, ptmp2, T0);\n                A02 = lhs2.template load<LhsPacket, Aligned>(j-2+2*LhsPacketSize);  palign<2>(A12,A02);\n                T0  = pcj.pmadd(A03, ptmp3, T0);\n                pstore(&res[j],T0);\n                A03 = lhs3.template load<LhsPacket, Aligned>(j-3+2*LhsPacketSize);  palign<3>(A13,A03);\n                T1  = pcj.pmadd(A11, ptmp1, T1);\n                T1  = pcj.pmadd(A12, ptmp2, T1);\n                T1  = pcj.pmadd(A13, ptmp3, T1);\n                pstore(&res[j+ResPacketSize],T1);\n              }\n            }\n            for (; j<alignedSize; j+=ResPacketSize)\n              _EIGEN_ACCUMULATE_PACKETS(Aligned,Unaligned,Unaligned);\n            break;\n          }\n          default:\n            for (Index j = alignedStart; j<alignedSize; j+=ResPacketSize)\n              _EIGEN_ACCUMULATE_PACKETS(Unaligned,Unaligned,Unaligned);\n            break;\n        }\n      }\n    } // end explicit vectorization\n\n    /* process remaining coeffs (or all if there is no explicit vectorization) */\n    for (Index j=alignedSize; j<size; ++j)\n    {\n      res[j] = cj.pmadd(lhs0(j), pfirst(ptmp0), res[j]);\n      res[j] = cj.pmadd(lhs1(j), pfirst(ptmp1), res[j]);\n      res[j] = cj.pmadd(lhs2(j), pfirst(ptmp2), res[j]);\n      res[j] = cj.pmadd(lhs3(j), pfirst(ptmp3), res[j]);\n    }\n  }\n\n  // process remaining first and last columns (at most columnsAtOnce-1)\n  Index end = cols;\n  Index start = columnBound;\n  do\n  {\n    for (Index k=start; k<end; ++k)\n    {\n      RhsPacket ptmp0 = pset1<RhsPacket>(alpha*rhs(k, 0));\n      const LhsScalars lhs0 = lhs.getVectorMapper(0, k);\n\n      if (Vectorizable)\n      {\n        /* explicit vectorization */\n        // process first unaligned result's coeffs\n        for (Index j=0; j<alignedStart; ++j)\n          res[j] += cj.pmul(lhs0(j), pfirst(ptmp0));\n        // process aligned result's coeffs\n        if (lhs0.template aligned<LhsPacket>(alignedStart))\n          for (Index i = alignedStart;i<alignedSize;i+=ResPacketSize)\n            pstore(&res[i], pcj.pmadd(lhs0.template load<LhsPacket, Aligned>(i), ptmp0, pload<ResPacket>(&res[i])));\n        else\n          for (Index i = alignedStart;i<alignedSize;i+=ResPacketSize)\n            pstore(&res[i], pcj.pmadd(lhs0.template load<LhsPacket, Unaligned>(i), ptmp0, pload<ResPacket>(&res[i])));\n      }\n\n      // process remaining scalars (or all if no explicit vectorization)\n      for (Index i=alignedSize; i<size; ++i)\n        res[i] += cj.pmul(lhs0(i), pfirst(ptmp0));\n    }\n    if (skipColumns)\n    {\n      start = 0;\n      end = skipColumns;\n      skipColumns = 0;\n    }\n    else\n      break;\n  } while(Vectorizable);\n  #undef _EIGEN_ACCUMULATE_PACKETS\n}\n\n/* Optimized row-major matrix * vector product:\n * This algorithm processes 4 rows at onces that allows to both reduce\n * the number of load/stores of the result by a factor 4 and to reduce\n * the instruction dependency. Moreover, we know that all bands have the\n * same alignment pattern.\n *\n * Mixing type logic:\n *  - alpha is always a complex (or converted to a complex)\n *  - no vectorization\n */\ntemplate<typename Index, typename LhsScalar, typename LhsMapper, bool ConjugateLhs, typename RhsScalar, typename RhsMapper, bool ConjugateRhs, int Version>\nstruct general_matrix_vector_product<Index,LhsScalar,LhsMapper,RowMajor,ConjugateLhs,RhsScalar,RhsMapper,ConjugateRhs,Version>\n{\ntypedef typename ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType ResScalar;\n\nenum {\n  Vectorizable = packet_traits<LhsScalar>::Vectorizable && packet_traits<RhsScalar>::Vectorizable\n              && int(packet_traits<LhsScalar>::size)==int(packet_traits<RhsScalar>::size),\n  LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1,\n  RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1,\n  ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1\n};\n\ntypedef typename packet_traits<LhsScalar>::type  _LhsPacket;\ntypedef typename packet_traits<RhsScalar>::type  _RhsPacket;\ntypedef typename packet_traits<ResScalar>::type  _ResPacket;\n\ntypedef typename conditional<Vectorizable,_LhsPacket,LhsScalar>::type LhsPacket;\ntypedef typename conditional<Vectorizable,_RhsPacket,RhsScalar>::type RhsPacket;\ntypedef typename conditional<Vectorizable,_ResPacket,ResScalar>::type ResPacket;\n\nEIGEN_DONT_INLINE static void run(\n  Index rows, Index cols,\n  const LhsMapper& lhs,\n  const RhsMapper& rhs,\n        ResScalar* res, Index resIncr,\n  ResScalar alpha);\n};\n\ntemplate<typename Index, typename LhsScalar, typename LhsMapper, bool ConjugateLhs, typename RhsScalar, typename RhsMapper, bool ConjugateRhs, int Version>\nEIGEN_DONT_INLINE void general_matrix_vector_product<Index,LhsScalar,LhsMapper,RowMajor,ConjugateLhs,RhsScalar,RhsMapper,ConjugateRhs,Version>::run(\n  Index rows, Index cols,\n  const LhsMapper& lhs,\n  const RhsMapper& rhs,\n  ResScalar* res, Index resIncr,\n  ResScalar alpha)\n{\n  eigen_internal_assert(rhs.stride()==1);\n\n  #ifdef _EIGEN_ACCUMULATE_PACKETS\n  #error _EIGEN_ACCUMULATE_PACKETS has already been defined\n  #endif\n\n  #define _EIGEN_ACCUMULATE_PACKETS(Alignment0,Alignment13,Alignment2) {\\\n    RhsPacket b = rhs.getVectorMapper(j, 0).template load<RhsPacket, Aligned>(0);  \\\n    ptmp0 = pcj.pmadd(lhs0.template load<LhsPacket, Alignment0>(j), b, ptmp0); \\\n    ptmp1 = pcj.pmadd(lhs1.template load<LhsPacket, Alignment13>(j), b, ptmp1); \\\n    ptmp2 = pcj.pmadd(lhs2.template load<LhsPacket, Alignment2>(j), b, ptmp2); \\\n    ptmp3 = pcj.pmadd(lhs3.template load<LhsPacket, Alignment13>(j), b, ptmp3); }\n\n  conj_helper<LhsScalar,RhsScalar,ConjugateLhs,ConjugateRhs> cj;\n  conj_helper<LhsPacket,RhsPacket,ConjugateLhs,ConjugateRhs> pcj;\n\n  typedef typename LhsMapper::VectorMapper LhsScalars;\n\n  enum { AllAligned=0, EvenAligned=1, FirstAligned=2, NoneAligned=3 };\n  const Index rowsAtOnce = 4;\n  const Index peels = 2;\n  const Index RhsPacketAlignedMask = RhsPacketSize-1;\n  const Index LhsPacketAlignedMask = LhsPacketSize-1;\n  const Index depth = cols;\n  const Index lhsStride = lhs.stride();\n\n  // How many coeffs of the result do we have to skip to be aligned.\n  // Here we assume data are at least aligned on the base scalar type\n  // if that's not the case then vectorization is discarded, see below.\n  Index alignedStart = rhs.firstAligned(depth);\n  Index alignedSize = RhsPacketSize>1 ? alignedStart + ((depth-alignedStart) & ~RhsPacketAlignedMask) : 0;\n  const Index peeledSize = alignedSize - RhsPacketSize*peels - RhsPacketSize + 1;\n\n  const Index alignmentStep = LhsPacketSize>1 ? (LhsPacketSize - lhsStride % LhsPacketSize) & LhsPacketAlignedMask : 0;\n  Index alignmentPattern = alignmentStep==0 ? AllAligned\n                           : alignmentStep==(LhsPacketSize/2) ? EvenAligned\n                           : FirstAligned;\n\n  // we cannot assume the first element is aligned because of sub-matrices\n  const Index lhsAlignmentOffset = lhs.firstAligned(depth);\n  const Index rhsAlignmentOffset = rhs.firstAligned(rows);\n\n  // find how many rows do we have to skip to be aligned with rhs (if possible)\n  Index skipRows = 0;\n  // if the data cannot be aligned (TODO add some compile time tests when possible, e.g. for floats)\n  if( (sizeof(LhsScalar)!=sizeof(RhsScalar)) ||\n      (lhsAlignmentOffset < 0) || (lhsAlignmentOffset == depth) ||\n      (rhsAlignmentOffset < 0) || (rhsAlignmentOffset == rows) )\n  {\n    alignedSize = 0;\n    alignedStart = 0;\n    alignmentPattern = NoneAligned;\n  }\n  else if(LhsPacketSize > 4)\n  {\n    // TODO: extend the code to support aligned loads whenever possible when LhsPacketSize > 4.\n    alignmentPattern = NoneAligned;\n  }\n  else if (LhsPacketSize>1)\n  {\n  //    eigen_internal_assert(size_t(firstLhs+lhsAlignmentOffset)%sizeof(LhsPacket)==0  || depth<LhsPacketSize);\n\n    while (skipRows<LhsPacketSize &&\n           alignedStart != ((lhsAlignmentOffset + alignmentStep*skipRows)%LhsPacketSize))\n      ++skipRows;\n    if (skipRows==LhsPacketSize)\n    {\n      // nothing can be aligned, no need to skip any column\n      alignmentPattern = NoneAligned;\n      skipRows = 0;\n    }\n    else\n    {\n      skipRows = (std::min)(skipRows,Index(rows));\n      // note that the skiped columns are processed later.\n    }\n    /*    eigen_internal_assert(  alignmentPattern==NoneAligned\n                      || LhsPacketSize==1\n                      || (skipRows + rowsAtOnce >= rows)\n                      || LhsPacketSize > depth\n                      || (size_t(firstLhs+alignedStart+lhsStride*skipRows)%sizeof(LhsPacket))==0);*/\n  }\n  else if(Vectorizable)\n  {\n    alignedStart = 0;\n    alignedSize = depth;\n    alignmentPattern = AllAligned;\n  }\n\n  const Index offset1 = (FirstAligned && alignmentStep==1)?3:1;\n  const Index offset3 = (FirstAligned && alignmentStep==1)?1:3;\n\n  Index rowBound = ((rows-skipRows)/rowsAtOnce)*rowsAtOnce + skipRows;\n  for (Index i=skipRows; i<rowBound; i+=rowsAtOnce)\n  {\n    // FIXME: what is the purpose of this EIGEN_ALIGN_DEFAULT ??\n    EIGEN_ALIGN_MAX ResScalar tmp0 = ResScalar(0);\n    ResScalar tmp1 = ResScalar(0), tmp2 = ResScalar(0), tmp3 = ResScalar(0);\n\n    // this helps the compiler generating good binary code\n    const LhsScalars lhs0 = lhs.getVectorMapper(i+0, 0),    lhs1 = lhs.getVectorMapper(i+offset1, 0),\n                     lhs2 = lhs.getVectorMapper(i+2, 0),    lhs3 = lhs.getVectorMapper(i+offset3, 0);\n\n    if (Vectorizable)\n    {\n      /* explicit vectorization */\n      ResPacket ptmp0 = pset1<ResPacket>(ResScalar(0)), ptmp1 = pset1<ResPacket>(ResScalar(0)),\n                ptmp2 = pset1<ResPacket>(ResScalar(0)), ptmp3 = pset1<ResPacket>(ResScalar(0));\n\n      // process initial unaligned coeffs\n      // FIXME this loop get vectorized by the compiler !\n      for (Index j=0; j<alignedStart; ++j)\n      {\n        RhsScalar b = rhs(j, 0);\n        tmp0 += cj.pmul(lhs0(j),b); tmp1 += cj.pmul(lhs1(j),b);\n        tmp2 += cj.pmul(lhs2(j),b); tmp3 += cj.pmul(lhs3(j),b);\n      }\n\n      if (alignedSize>alignedStart)\n      {\n        switch(alignmentPattern)\n        {\n          case AllAligned:\n            for (Index j = alignedStart; j<alignedSize; j+=RhsPacketSize)\n              _EIGEN_ACCUMULATE_PACKETS(Aligned,Aligned,Aligned);\n            break;\n          case EvenAligned:\n            for (Index j = alignedStart; j<alignedSize; j+=RhsPacketSize)\n              _EIGEN_ACCUMULATE_PACKETS(Aligned,Unaligned,Aligned);\n            break;\n          case FirstAligned:\n          {\n            Index j = alignedStart;\n            if (peels>1)\n            {\n              /* Here we proccess 4 rows with with two peeled iterations to hide\n               * the overhead of unaligned loads. Moreover unaligned loads are handled\n               * using special shift/move operations between the two aligned packets\n               * overlaping the desired unaligned packet. This is *much* more efficient\n               * than basic unaligned loads.\n               */\n              LhsPacket A01, A02, A03, A11, A12, A13;\n              A01 = lhs1.template load<LhsPacket, Aligned>(alignedStart-1);\n              A02 = lhs2.template load<LhsPacket, Aligned>(alignedStart-2);\n              A03 = lhs3.template load<LhsPacket, Aligned>(alignedStart-3);\n\n              for (; j<peeledSize; j+=peels*RhsPacketSize)\n              {\n                RhsPacket b = rhs.getVectorMapper(j, 0).template load<RhsPacket, Aligned>(0);\n                A11 = lhs1.template load<LhsPacket, Aligned>(j-1+LhsPacketSize);  palign<1>(A01,A11);\n                A12 = lhs2.template load<LhsPacket, Aligned>(j-2+LhsPacketSize);  palign<2>(A02,A12);\n                A13 = lhs3.template load<LhsPacket, Aligned>(j-3+LhsPacketSize);  palign<3>(A03,A13);\n\n                ptmp0 = pcj.pmadd(lhs0.template load<LhsPacket, Aligned>(j), b, ptmp0);\n                ptmp1 = pcj.pmadd(A01, b, ptmp1);\n                A01 = lhs1.template load<LhsPacket, Aligned>(j-1+2*LhsPacketSize);  palign<1>(A11,A01);\n                ptmp2 = pcj.pmadd(A02, b, ptmp2);\n                A02 = lhs2.template load<LhsPacket, Aligned>(j-2+2*LhsPacketSize);  palign<2>(A12,A02);\n                ptmp3 = pcj.pmadd(A03, b, ptmp3);\n                A03 = lhs3.template load<LhsPacket, Aligned>(j-3+2*LhsPacketSize);  palign<3>(A13,A03);\n\n                b = rhs.getVectorMapper(j+RhsPacketSize, 0).template load<RhsPacket, Aligned>(0);\n                ptmp0 = pcj.pmadd(lhs0.template load<LhsPacket, Aligned>(j+LhsPacketSize), b, ptmp0);\n                ptmp1 = pcj.pmadd(A11, b, ptmp1);\n                ptmp2 = pcj.pmadd(A12, b, ptmp2);\n                ptmp3 = pcj.pmadd(A13, b, ptmp3);\n              }\n            }\n            for (; j<alignedSize; j+=RhsPacketSize)\n              _EIGEN_ACCUMULATE_PACKETS(Aligned,Unaligned,Unaligned);\n            break;\n          }\n          default:\n            for (Index j = alignedStart; j<alignedSize; j+=RhsPacketSize)\n              _EIGEN_ACCUMULATE_PACKETS(Unaligned,Unaligned,Unaligned);\n            break;\n        }\n        tmp0 += predux(ptmp0);\n        tmp1 += predux(ptmp1);\n        tmp2 += predux(ptmp2);\n        tmp3 += predux(ptmp3);\n      }\n    } // end explicit vectorization\n\n    // process remaining coeffs (or all if no explicit vectorization)\n    // FIXME this loop get vectorized by the compiler !\n    for (Index j=alignedSize; j<depth; ++j)\n    {\n      RhsScalar b = rhs(j, 0);\n      tmp0 += cj.pmul(lhs0(j),b); tmp1 += cj.pmul(lhs1(j),b);\n      tmp2 += cj.pmul(lhs2(j),b); tmp3 += cj.pmul(lhs3(j),b);\n    }\n    res[i*resIncr]            += alpha*tmp0;\n    res[(i+offset1)*resIncr]  += alpha*tmp1;\n    res[(i+2)*resIncr]        += alpha*tmp2;\n    res[(i+offset3)*resIncr]  += alpha*tmp3;\n  }\n\n  // process remaining first and last rows (at most columnsAtOnce-1)\n  Index end = rows;\n  Index start = rowBound;\n  do\n  {\n    for (Index i=start; i<end; ++i)\n    {\n      EIGEN_ALIGN_MAX ResScalar tmp0 = ResScalar(0);\n      ResPacket ptmp0 = pset1<ResPacket>(tmp0);\n      const LhsScalars lhs0 = lhs.getVectorMapper(i, 0);\n      // process first unaligned result's coeffs\n      // FIXME this loop get vectorized by the compiler !\n      for (Index j=0; j<alignedStart; ++j)\n        tmp0 += cj.pmul(lhs0(j), rhs(j, 0));\n\n      if (alignedSize>alignedStart)\n      {\n        // process aligned rhs coeffs\n        if (lhs0.template aligned<LhsPacket>(alignedStart))\n          for (Index j = alignedStart;j<alignedSize;j+=RhsPacketSize)\n            ptmp0 = pcj.pmadd(lhs0.template load<LhsPacket, Aligned>(j), rhs.getVectorMapper(j, 0).template load<RhsPacket, Aligned>(0), ptmp0);\n        else\n          for (Index j = alignedStart;j<alignedSize;j+=RhsPacketSize)\n            ptmp0 = pcj.pmadd(lhs0.template load<LhsPacket, Unaligned>(j), rhs.getVectorMapper(j, 0).template load<RhsPacket, Aligned>(0), ptmp0);\n        tmp0 += predux(ptmp0);\n      }\n\n      // process remaining scalars\n      // FIXME this loop get vectorized by the compiler !\n      for (Index j=alignedSize; j<depth; ++j)\n        tmp0 += cj.pmul(lhs0(j), rhs(j, 0));\n      res[i*resIncr] += alpha*tmp0;\n    }\n    if (skipRows)\n    {\n      start = 0;\n      end = skipRows;\n      skipRows = 0;\n    }\n    else\n      break;\n  } while(Vectorizable);\n\n  #undef _EIGEN_ACCUMULATE_PACKETS\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_GENERAL_MATRIX_VECTOR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to BLAS F77\n *   General matrix-vector product functionality based on ?GEMV.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_GENERAL_MATRIX_VECTOR_BLAS_H\n#define EIGEN_GENERAL_MATRIX_VECTOR_BLAS_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/**********************************************************************\n* This file implements general matrix-vector multiplication using BLAS\n* gemv function via partial specialization of\n* general_matrix_vector_product::run(..) method for float, double,\n* std::complex<float> and std::complex<double> types\n**********************************************************************/\n\n// gemv specialization\n\ntemplate<typename Index, typename LhsScalar, int StorageOrder, bool ConjugateLhs, typename RhsScalar, bool ConjugateRhs>\nstruct general_matrix_vector_product_gemv;\n\n#define EIGEN_BLAS_GEMV_SPECIALIZE(Scalar) \\\ntemplate<typename Index, bool ConjugateLhs, bool ConjugateRhs> \\\nstruct general_matrix_vector_product<Index,Scalar,const_blas_data_mapper<Scalar,Index,ColMajor>,ColMajor,ConjugateLhs,Scalar,const_blas_data_mapper<Scalar,Index,RowMajor>,ConjugateRhs,Specialized> { \\\nstatic void run( \\\n  Index rows, Index cols, \\\n  const const_blas_data_mapper<Scalar,Index,ColMajor> &lhs, \\\n  const const_blas_data_mapper<Scalar,Index,RowMajor> &rhs, \\\n  Scalar* res, Index resIncr, Scalar alpha) \\\n{ \\\n  if (ConjugateLhs) { \\\n    general_matrix_vector_product<Index,Scalar,const_blas_data_mapper<Scalar,Index,ColMajor>,ColMajor,ConjugateLhs,Scalar,const_blas_data_mapper<Scalar,Index,RowMajor>,ConjugateRhs,BuiltIn>::run( \\\n      rows, cols, lhs, rhs, res, resIncr, alpha); \\\n  } else { \\\n    general_matrix_vector_product_gemv<Index,Scalar,ColMajor,ConjugateLhs,Scalar,ConjugateRhs>::run( \\\n      rows, cols, lhs.data(), lhs.stride(), rhs.data(), rhs.stride(), res, resIncr, alpha); \\\n  } \\\n} \\\n}; \\\ntemplate<typename Index, bool ConjugateLhs, bool ConjugateRhs> \\\nstruct general_matrix_vector_product<Index,Scalar,const_blas_data_mapper<Scalar,Index,RowMajor>,RowMajor,ConjugateLhs,Scalar,const_blas_data_mapper<Scalar,Index,ColMajor>,ConjugateRhs,Specialized> { \\\nstatic void run( \\\n  Index rows, Index cols, \\\n  const const_blas_data_mapper<Scalar,Index,RowMajor> &lhs, \\\n  const const_blas_data_mapper<Scalar,Index,ColMajor> &rhs, \\\n  Scalar* res, Index resIncr, Scalar alpha) \\\n{ \\\n    general_matrix_vector_product_gemv<Index,Scalar,RowMajor,ConjugateLhs,Scalar,ConjugateRhs>::run( \\\n      rows, cols, lhs.data(), lhs.stride(), rhs.data(), rhs.stride(), res, resIncr, alpha); \\\n} \\\n}; \\\n\nEIGEN_BLAS_GEMV_SPECIALIZE(double)\nEIGEN_BLAS_GEMV_SPECIALIZE(float)\nEIGEN_BLAS_GEMV_SPECIALIZE(dcomplex)\nEIGEN_BLAS_GEMV_SPECIALIZE(scomplex)\n\n#define EIGEN_BLAS_GEMV_SPECIALIZATION(EIGTYPE,BLASTYPE,BLASPREFIX) \\\ntemplate<typename Index, int LhsStorageOrder, bool ConjugateLhs, bool ConjugateRhs> \\\nstruct general_matrix_vector_product_gemv<Index,EIGTYPE,LhsStorageOrder,ConjugateLhs,EIGTYPE,ConjugateRhs> \\\n{ \\\ntypedef Matrix<EIGTYPE,Dynamic,1,ColMajor> GEMVVector;\\\n\\\nstatic void run( \\\n  Index rows, Index cols, \\\n  const EIGTYPE* lhs, Index lhsStride, \\\n  const EIGTYPE* rhs, Index rhsIncr, \\\n  EIGTYPE* res, Index resIncr, EIGTYPE alpha) \\\n{ \\\n  BlasIndex m=convert_index<BlasIndex>(rows), n=convert_index<BlasIndex>(cols), \\\n            lda=convert_index<BlasIndex>(lhsStride), incx=convert_index<BlasIndex>(rhsIncr), incy=convert_index<BlasIndex>(resIncr); \\\n  const EIGTYPE beta(1); \\\n  const EIGTYPE *x_ptr; \\\n  char trans=(LhsStorageOrder==ColMajor) ? 'N' : (ConjugateLhs) ? 'C' : 'T'; \\\n  if (LhsStorageOrder==RowMajor) { \\\n    m = convert_index<BlasIndex>(cols); \\\n    n = convert_index<BlasIndex>(rows); \\\n  }\\\n  GEMVVector x_tmp; \\\n  if (ConjugateRhs) { \\\n    Map<const GEMVVector, 0, InnerStride<> > map_x(rhs,cols,1,InnerStride<>(incx)); \\\n    x_tmp=map_x.conjugate(); \\\n    x_ptr=x_tmp.data(); \\\n    incx=1; \\\n  } else x_ptr=rhs; \\\n  BLASPREFIX##gemv_(&trans, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)lhs, &lda, (const BLASTYPE*)x_ptr, &incx, &numext::real_ref(beta), (BLASTYPE*)res, &incy); \\\n}\\\n};\n\nEIGEN_BLAS_GEMV_SPECIALIZATION(double,   double, d)\nEIGEN_BLAS_GEMV_SPECIALIZATION(float,    float,  s)\nEIGEN_BLAS_GEMV_SPECIALIZATION(dcomplex, double, z)\nEIGEN_BLAS_GEMV_SPECIALIZATION(scomplex, float,  c)\n\n} // end namespase internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_GENERAL_MATRIX_VECTOR_BLAS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/Parallelizer.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PARALLELIZER_H\n#define EIGEN_PARALLELIZER_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n/** \\internal */\ninline void manage_multi_threading(Action action, int* v)\n{\n  static EIGEN_UNUSED int m_maxThreads = -1;\n\n  if(action==SetAction)\n  {\n    eigen_internal_assert(v!=0);\n    m_maxThreads = *v;\n  }\n  else if(action==GetAction)\n  {\n    eigen_internal_assert(v!=0);\n    #ifdef EIGEN_HAS_OPENMP\n    if(m_maxThreads>0)\n      *v = m_maxThreads;\n    else\n      *v = omp_get_max_threads();\n    #else\n    *v = 1;\n    #endif\n  }\n  else\n  {\n    eigen_internal_assert(false);\n  }\n}\n\n}\n\n/** Must be call first when calling Eigen from multiple threads */\ninline void initParallel()\n{\n  int nbt;\n  internal::manage_multi_threading(GetAction, &nbt);\n  std::ptrdiff_t l1, l2, l3;\n  internal::manage_caching_sizes(GetAction, &l1, &l2, &l3);\n}\n\n/** \\returns the max number of threads reserved for Eigen\n  * \\sa setNbThreads */\ninline int nbThreads()\n{\n  int ret;\n  internal::manage_multi_threading(GetAction, &ret);\n  return ret;\n}\n\n/** Sets the max number of threads reserved for Eigen\n  * \\sa nbThreads */\ninline void setNbThreads(int v)\n{\n  internal::manage_multi_threading(SetAction, &v);\n}\n\nnamespace internal {\n\ntemplate<typename Index> struct GemmParallelInfo\n{\n  GemmParallelInfo() : sync(-1), users(0), lhs_start(0), lhs_length(0) {}\n\n  Index volatile sync;\n  int volatile users;\n\n  Index lhs_start;\n  Index lhs_length;\n};\n\ntemplate<bool Condition, typename Functor, typename Index>\nvoid parallelize_gemm(const Functor& func, Index rows, Index cols, Index depth, bool transpose)\n{\n  // TODO when EIGEN_USE_BLAS is defined,\n  // we should still enable OMP for other scalar types\n#if !(defined (EIGEN_HAS_OPENMP)) || defined (EIGEN_USE_BLAS)\n  // FIXME the transpose variable is only needed to properly split\n  // the matrix product when multithreading is enabled. This is a temporary\n  // fix to support row-major destination matrices. This whole\n  // parallelizer mechanism has to be redisigned anyway.\n  EIGEN_UNUSED_VARIABLE(depth);\n  EIGEN_UNUSED_VARIABLE(transpose);\n  func(0,rows, 0,cols);\n#else\n\n  // Dynamically check whether we should enable or disable OpenMP.\n  // The conditions are:\n  // - the max number of threads we can create is greater than 1\n  // - we are not already in a parallel code\n  // - the sizes are large enough\n\n  // compute the maximal number of threads from the size of the product:\n  // This first heuristic takes into account that the product kernel is fully optimized when working with nr columns at once.\n  Index size = transpose ? rows : cols;\n  Index pb_max_threads = std::max<Index>(1,size / Functor::Traits::nr);\n\n  // compute the maximal number of threads from the total amount of work:\n  double work = static_cast<double>(rows) * static_cast<double>(cols) *\n      static_cast<double>(depth);\n  double kMinTaskSize = 50000;  // FIXME improve this heuristic.\n  pb_max_threads = std::max<Index>(1, std::min<Index>(pb_max_threads, work / kMinTaskSize));\n\n  // compute the number of threads we are going to use\n  Index threads = std::min<Index>(nbThreads(), pb_max_threads);\n\n  // if multi-threading is explicitely disabled, not useful, or if we already are in a parallel session,\n  // then abort multi-threading\n  // FIXME omp_get_num_threads()>1 only works for openmp, what if the user does not use openmp?\n  if((!Condition) || (threads==1) || (omp_get_num_threads()>1))\n    return func(0,rows, 0,cols);\n\n  Eigen::initParallel();\n  func.initParallelSession(threads);\n\n  if(transpose)\n    std::swap(rows,cols);\n\n  ei_declare_aligned_stack_constructed_variable(GemmParallelInfo<Index>,info,threads,0);\n\n  #pragma omp parallel num_threads(threads)\n  {\n    Index i = omp_get_thread_num();\n    // Note that the actual number of threads might be lower than the number of request ones.\n    Index actual_threads = omp_get_num_threads();\n\n    Index blockCols = (cols / actual_threads) & ~Index(0x3);\n    Index blockRows = (rows / actual_threads);\n    blockRows = (blockRows/Functor::Traits::mr)*Functor::Traits::mr;\n\n    Index r0 = i*blockRows;\n    Index actualBlockRows = (i+1==actual_threads) ? rows-r0 : blockRows;\n\n    Index c0 = i*blockCols;\n    Index actualBlockCols = (i+1==actual_threads) ? cols-c0 : blockCols;\n\n    info[i].lhs_start = r0;\n    info[i].lhs_length = actualBlockRows;\n\n    if(transpose) func(c0, actualBlockCols, 0, rows, info);\n    else          func(0, rows, c0, actualBlockCols, info);\n  }\n#endif\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_PARALLELIZER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/SelfadjointMatrixMatrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SELFADJOINT_MATRIX_MATRIX_H\n#define EIGEN_SELFADJOINT_MATRIX_MATRIX_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n// pack a selfadjoint block diagonal for use with the gebp_kernel\ntemplate<typename Scalar, typename Index, int Pack1, int Pack2_dummy, int StorageOrder>\nstruct symm_pack_lhs\n{\n  template<int BlockRows> inline\n  void pack(Scalar* blockA, const const_blas_data_mapper<Scalar,Index,StorageOrder>& lhs, Index cols, Index i, Index& count)\n  {\n    // normal copy\n    for(Index k=0; k<i; k++)\n      for(Index w=0; w<BlockRows; w++)\n        blockA[count++] = lhs(i+w,k);           // normal\n    // symmetric copy\n    Index h = 0;\n    for(Index k=i; k<i+BlockRows; k++)\n    {\n      for(Index w=0; w<h; w++)\n        blockA[count++] = numext::conj(lhs(k, i+w)); // transposed\n\n      blockA[count++] = numext::real(lhs(k,k));   // real (diagonal)\n\n      for(Index w=h+1; w<BlockRows; w++)\n        blockA[count++] = lhs(i+w, k);          // normal\n      ++h;\n    }\n    // transposed copy\n    for(Index k=i+BlockRows; k<cols; k++)\n      for(Index w=0; w<BlockRows; w++)\n        blockA[count++] = numext::conj(lhs(k, i+w)); // transposed\n  }\n  void operator()(Scalar* blockA, const Scalar* _lhs, Index lhsStride, Index cols, Index rows)\n  {\n    enum { PacketSize = packet_traits<Scalar>::size };\n    const_blas_data_mapper<Scalar,Index,StorageOrder> lhs(_lhs,lhsStride);\n    Index count = 0;\n    //Index peeled_mc3 = (rows/Pack1)*Pack1;\n    \n    const Index peeled_mc3 = Pack1>=3*PacketSize ? (rows/(3*PacketSize))*(3*PacketSize) : 0;\n    const Index peeled_mc2 = Pack1>=2*PacketSize ? peeled_mc3+((rows-peeled_mc3)/(2*PacketSize))*(2*PacketSize) : 0;\n    const Index peeled_mc1 = Pack1>=1*PacketSize ? (rows/(1*PacketSize))*(1*PacketSize) : 0;\n    \n    if(Pack1>=3*PacketSize)\n      for(Index i=0; i<peeled_mc3; i+=3*PacketSize)\n        pack<3*PacketSize>(blockA, lhs, cols, i, count);\n    \n    if(Pack1>=2*PacketSize)\n      for(Index i=peeled_mc3; i<peeled_mc2; i+=2*PacketSize)\n        pack<2*PacketSize>(blockA, lhs, cols, i, count);\n    \n    if(Pack1>=1*PacketSize)\n      for(Index i=peeled_mc2; i<peeled_mc1; i+=1*PacketSize)\n        pack<1*PacketSize>(blockA, lhs, cols, i, count);\n\n    // do the same with mr==1\n    for(Index i=peeled_mc1; i<rows; i++)\n    {\n      for(Index k=0; k<i; k++)\n        blockA[count++] = lhs(i, k);                   // normal\n\n      blockA[count++] = numext::real(lhs(i, i));       // real (diagonal)\n\n      for(Index k=i+1; k<cols; k++)\n        blockA[count++] = numext::conj(lhs(k, i));     // transposed\n    }\n  }\n};\n\ntemplate<typename Scalar, typename Index, int nr, int StorageOrder>\nstruct symm_pack_rhs\n{\n  enum { PacketSize = packet_traits<Scalar>::size };\n  void operator()(Scalar* blockB, const Scalar* _rhs, Index rhsStride, Index rows, Index cols, Index k2)\n  {\n    Index end_k = k2 + rows;\n    Index count = 0;\n    const_blas_data_mapper<Scalar,Index,StorageOrder> rhs(_rhs,rhsStride);\n    Index packet_cols8 = nr>=8 ? (cols/8) * 8 : 0;\n    Index packet_cols4 = nr>=4 ? (cols/4) * 4 : 0;\n\n    // first part: normal case\n    for(Index j2=0; j2<k2; j2+=nr)\n    {\n      for(Index k=k2; k<end_k; k++)\n      {\n        blockB[count+0] = rhs(k,j2+0);\n        blockB[count+1] = rhs(k,j2+1);\n        if (nr>=4)\n        {\n          blockB[count+2] = rhs(k,j2+2);\n          blockB[count+3] = rhs(k,j2+3);\n        }\n        if (nr>=8)\n        {\n          blockB[count+4] = rhs(k,j2+4);\n          blockB[count+5] = rhs(k,j2+5);\n          blockB[count+6] = rhs(k,j2+6);\n          blockB[count+7] = rhs(k,j2+7);\n        }\n        count += nr;\n      }\n    }\n\n    // second part: diagonal block\n    Index end8 = nr>=8 ? (std::min)(k2+rows,packet_cols8) : k2;\n    if(nr>=8)\n    {\n      for(Index j2=k2; j2<end8; j2+=8)\n      {\n        // again we can split vertically in three different parts (transpose, symmetric, normal)\n        // transpose\n        for(Index k=k2; k<j2; k++)\n        {\n          blockB[count+0] = numext::conj(rhs(j2+0,k));\n          blockB[count+1] = numext::conj(rhs(j2+1,k));\n          blockB[count+2] = numext::conj(rhs(j2+2,k));\n          blockB[count+3] = numext::conj(rhs(j2+3,k));\n          blockB[count+4] = numext::conj(rhs(j2+4,k));\n          blockB[count+5] = numext::conj(rhs(j2+5,k));\n          blockB[count+6] = numext::conj(rhs(j2+6,k));\n          blockB[count+7] = numext::conj(rhs(j2+7,k));\n          count += 8;\n        }\n        // symmetric\n        Index h = 0;\n        for(Index k=j2; k<j2+8; k++)\n        {\n          // normal\n          for (Index w=0 ; w<h; ++w)\n            blockB[count+w] = rhs(k,j2+w);\n\n          blockB[count+h] = numext::real(rhs(k,k));\n\n          // transpose\n          for (Index w=h+1 ; w<8; ++w)\n            blockB[count+w] = numext::conj(rhs(j2+w,k));\n          count += 8;\n          ++h;\n        }\n        // normal\n        for(Index k=j2+8; k<end_k; k++)\n        {\n          blockB[count+0] = rhs(k,j2+0);\n          blockB[count+1] = rhs(k,j2+1);\n          blockB[count+2] = rhs(k,j2+2);\n          blockB[count+3] = rhs(k,j2+3);\n          blockB[count+4] = rhs(k,j2+4);\n          blockB[count+5] = rhs(k,j2+5);\n          blockB[count+6] = rhs(k,j2+6);\n          blockB[count+7] = rhs(k,j2+7);\n          count += 8;\n        }\n      }\n    }\n    if(nr>=4)\n    {\n      for(Index j2=end8; j2<(std::min)(k2+rows,packet_cols4); j2+=4)\n      {\n        // again we can split vertically in three different parts (transpose, symmetric, normal)\n        // transpose\n        for(Index k=k2; k<j2; k++)\n        {\n          blockB[count+0] = numext::conj(rhs(j2+0,k));\n          blockB[count+1] = numext::conj(rhs(j2+1,k));\n          blockB[count+2] = numext::conj(rhs(j2+2,k));\n          blockB[count+3] = numext::conj(rhs(j2+3,k));\n          count += 4;\n        }\n        // symmetric\n        Index h = 0;\n        for(Index k=j2; k<j2+4; k++)\n        {\n          // normal\n          for (Index w=0 ; w<h; ++w)\n            blockB[count+w] = rhs(k,j2+w);\n\n          blockB[count+h] = numext::real(rhs(k,k));\n\n          // transpose\n          for (Index w=h+1 ; w<4; ++w)\n            blockB[count+w] = numext::conj(rhs(j2+w,k));\n          count += 4;\n          ++h;\n        }\n        // normal\n        for(Index k=j2+4; k<end_k; k++)\n        {\n          blockB[count+0] = rhs(k,j2+0);\n          blockB[count+1] = rhs(k,j2+1);\n          blockB[count+2] = rhs(k,j2+2);\n          blockB[count+3] = rhs(k,j2+3);\n          count += 4;\n        }\n      }\n    }\n\n    // third part: transposed\n    if(nr>=8)\n    {\n      for(Index j2=k2+rows; j2<packet_cols8; j2+=8)\n      {\n        for(Index k=k2; k<end_k; k++)\n        {\n          blockB[count+0] = numext::conj(rhs(j2+0,k));\n          blockB[count+1] = numext::conj(rhs(j2+1,k));\n          blockB[count+2] = numext::conj(rhs(j2+2,k));\n          blockB[count+3] = numext::conj(rhs(j2+3,k));\n          blockB[count+4] = numext::conj(rhs(j2+4,k));\n          blockB[count+5] = numext::conj(rhs(j2+5,k));\n          blockB[count+6] = numext::conj(rhs(j2+6,k));\n          blockB[count+7] = numext::conj(rhs(j2+7,k));\n          count += 8;\n        }\n      }\n    }\n    if(nr>=4)\n    {\n      for(Index j2=(std::max)(packet_cols8,k2+rows); j2<packet_cols4; j2+=4)\n      {\n        for(Index k=k2; k<end_k; k++)\n        {\n          blockB[count+0] = numext::conj(rhs(j2+0,k));\n          blockB[count+1] = numext::conj(rhs(j2+1,k));\n          blockB[count+2] = numext::conj(rhs(j2+2,k));\n          blockB[count+3] = numext::conj(rhs(j2+3,k));\n          count += 4;\n        }\n      }\n    }\n\n    // copy the remaining columns one at a time (=> the same with nr==1)\n    for(Index j2=packet_cols4; j2<cols; ++j2)\n    {\n      // transpose\n      Index half = (std::min)(end_k,j2);\n      for(Index k=k2; k<half; k++)\n      {\n        blockB[count] = numext::conj(rhs(j2,k));\n        count += 1;\n      }\n\n      if(half==j2 && half<k2+rows)\n      {\n        blockB[count] = numext::real(rhs(j2,j2));\n        count += 1;\n      }\n      else\n        half--;\n\n      // normal\n      for(Index k=half+1; k<k2+rows; k++)\n      {\n        blockB[count] = rhs(k,j2);\n        count += 1;\n      }\n    }\n  }\n};\n\n/* Optimized selfadjoint matrix * matrix (_SYMM) product built on top of\n * the general matrix matrix product.\n */\ntemplate <typename Scalar, typename Index,\n          int LhsStorageOrder, bool LhsSelfAdjoint, bool ConjugateLhs,\n          int RhsStorageOrder, bool RhsSelfAdjoint, bool ConjugateRhs,\n          int ResStorageOrder>\nstruct product_selfadjoint_matrix;\n\ntemplate <typename Scalar, typename Index,\n          int LhsStorageOrder, bool LhsSelfAdjoint, bool ConjugateLhs,\n          int RhsStorageOrder, bool RhsSelfAdjoint, bool ConjugateRhs>\nstruct product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,LhsSelfAdjoint,ConjugateLhs, RhsStorageOrder,RhsSelfAdjoint,ConjugateRhs,RowMajor>\n{\n\n  static EIGEN_STRONG_INLINE void run(\n    Index rows, Index cols,\n    const Scalar* lhs, Index lhsStride,\n    const Scalar* rhs, Index rhsStride,\n    Scalar* res,       Index resStride,\n    const Scalar& alpha, level3_blocking<Scalar,Scalar>& blocking)\n  {\n    product_selfadjoint_matrix<Scalar, Index,\n      EIGEN_LOGICAL_XOR(RhsSelfAdjoint,RhsStorageOrder==RowMajor) ? ColMajor : RowMajor,\n      RhsSelfAdjoint, NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(RhsSelfAdjoint,ConjugateRhs),\n      EIGEN_LOGICAL_XOR(LhsSelfAdjoint,LhsStorageOrder==RowMajor) ? ColMajor : RowMajor,\n      LhsSelfAdjoint, NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(LhsSelfAdjoint,ConjugateLhs),\n      ColMajor>\n      ::run(cols, rows,  rhs, rhsStride,  lhs, lhsStride,  res, resStride,  alpha, blocking);\n  }\n};\n\ntemplate <typename Scalar, typename Index,\n          int LhsStorageOrder, bool ConjugateLhs,\n          int RhsStorageOrder, bool ConjugateRhs>\nstruct product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,true,ConjugateLhs, RhsStorageOrder,false,ConjugateRhs,ColMajor>\n{\n\n  static EIGEN_DONT_INLINE void run(\n    Index rows, Index cols,\n    const Scalar* _lhs, Index lhsStride,\n    const Scalar* _rhs, Index rhsStride,\n    Scalar* res,        Index resStride,\n    const Scalar& alpha, level3_blocking<Scalar,Scalar>& blocking);\n};\n\ntemplate <typename Scalar, typename Index,\n          int LhsStorageOrder, bool ConjugateLhs,\n          int RhsStorageOrder, bool ConjugateRhs>\nEIGEN_DONT_INLINE void product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,true,ConjugateLhs, RhsStorageOrder,false,ConjugateRhs,ColMajor>::run(\n    Index rows, Index cols,\n    const Scalar* _lhs, Index lhsStride,\n    const Scalar* _rhs, Index rhsStride,\n    Scalar* _res,        Index resStride,\n    const Scalar& alpha, level3_blocking<Scalar,Scalar>& blocking)\n  {\n    Index size = rows;\n\n    typedef gebp_traits<Scalar,Scalar> Traits;\n\n    typedef const_blas_data_mapper<Scalar, Index, LhsStorageOrder> LhsMapper;\n    typedef const_blas_data_mapper<Scalar, Index, (LhsStorageOrder == RowMajor) ? ColMajor : RowMajor> LhsTransposeMapper;\n    typedef const_blas_data_mapper<Scalar, Index, RhsStorageOrder> RhsMapper;\n    typedef blas_data_mapper<typename Traits::ResScalar, Index, ColMajor> ResMapper;\n    LhsMapper lhs(_lhs,lhsStride);\n    LhsTransposeMapper lhs_transpose(_lhs,lhsStride);\n    RhsMapper rhs(_rhs,rhsStride);\n    ResMapper res(_res, resStride);\n\n    Index kc = blocking.kc();                   // cache block size along the K direction\n    Index mc = (std::min)(rows,blocking.mc());  // cache block size along the M direction\n    // kc must be smaller than mc\n    kc = (std::min)(kc,mc);\n    std::size_t sizeA = kc*mc;\n    std::size_t sizeB = kc*cols;\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockA, sizeA, blocking.blockA());\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockB, sizeB, blocking.blockB());\n\n    gebp_kernel<Scalar, Scalar, Index, ResMapper, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel;\n    symm_pack_lhs<Scalar, Index, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs;\n    gemm_pack_rhs<Scalar, Index, RhsMapper, Traits::nr,RhsStorageOrder> pack_rhs;\n    gemm_pack_lhs<Scalar, Index, LhsTransposeMapper, Traits::mr, Traits::LhsProgress, LhsStorageOrder==RowMajor?ColMajor:RowMajor, true> pack_lhs_transposed;\n\n    for(Index k2=0; k2<size; k2+=kc)\n    {\n      const Index actual_kc = (std::min)(k2+kc,size)-k2;\n\n      // we have selected one row panel of rhs and one column panel of lhs\n      // pack rhs's panel into a sequential chunk of memory\n      // and expand each coeff to a constant packet for further reuse\n      pack_rhs(blockB, rhs.getSubMapper(k2,0), actual_kc, cols);\n\n      // the select lhs's panel has to be split in three different parts:\n      //  1 - the transposed panel above the diagonal block => transposed packed copy\n      //  2 - the diagonal block => special packed copy\n      //  3 - the panel below the diagonal block => generic packed copy\n      for(Index i2=0; i2<k2; i2+=mc)\n      {\n        const Index actual_mc = (std::min)(i2+mc,k2)-i2;\n        // transposed packed copy\n        pack_lhs_transposed(blockA, lhs_transpose.getSubMapper(i2, k2), actual_kc, actual_mc);\n\n        gebp_kernel(res.getSubMapper(i2, 0), blockA, blockB, actual_mc, actual_kc, cols, alpha);\n      }\n      // the block diagonal\n      {\n        const Index actual_mc = (std::min)(k2+kc,size)-k2;\n        // symmetric packed copy\n        pack_lhs(blockA, &lhs(k2,k2), lhsStride, actual_kc, actual_mc);\n\n        gebp_kernel(res.getSubMapper(k2, 0), blockA, blockB, actual_mc, actual_kc, cols, alpha);\n      }\n\n      for(Index i2=k2+kc; i2<size; i2+=mc)\n      {\n        const Index actual_mc = (std::min)(i2+mc,size)-i2;\n        gemm_pack_lhs<Scalar, Index, LhsMapper, Traits::mr, Traits::LhsProgress, LhsStorageOrder,false>()\n          (blockA, lhs.getSubMapper(i2, k2), actual_kc, actual_mc);\n\n        gebp_kernel(res.getSubMapper(i2, 0), blockA, blockB, actual_mc, actual_kc, cols, alpha);\n      }\n    }\n  }\n\n// matrix * selfadjoint product\ntemplate <typename Scalar, typename Index,\n          int LhsStorageOrder, bool ConjugateLhs,\n          int RhsStorageOrder, bool ConjugateRhs>\nstruct product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,false,ConjugateLhs, RhsStorageOrder,true,ConjugateRhs,ColMajor>\n{\n\n  static EIGEN_DONT_INLINE void run(\n    Index rows, Index cols,\n    const Scalar* _lhs, Index lhsStride,\n    const Scalar* _rhs, Index rhsStride,\n    Scalar* res,        Index resStride,\n    const Scalar& alpha, level3_blocking<Scalar,Scalar>& blocking);\n};\n\ntemplate <typename Scalar, typename Index,\n          int LhsStorageOrder, bool ConjugateLhs,\n          int RhsStorageOrder, bool ConjugateRhs>\nEIGEN_DONT_INLINE void product_selfadjoint_matrix<Scalar,Index,LhsStorageOrder,false,ConjugateLhs, RhsStorageOrder,true,ConjugateRhs,ColMajor>::run(\n    Index rows, Index cols,\n    const Scalar* _lhs, Index lhsStride,\n    const Scalar* _rhs, Index rhsStride,\n    Scalar* _res,        Index resStride,\n    const Scalar& alpha, level3_blocking<Scalar,Scalar>& blocking)\n  {\n    Index size = cols;\n\n    typedef gebp_traits<Scalar,Scalar> Traits;\n\n    typedef const_blas_data_mapper<Scalar, Index, LhsStorageOrder> LhsMapper;\n    typedef blas_data_mapper<typename Traits::ResScalar, Index, ColMajor> ResMapper;\n    LhsMapper lhs(_lhs,lhsStride);\n    ResMapper res(_res,resStride);\n\n    Index kc = blocking.kc();                   // cache block size along the K direction\n    Index mc = (std::min)(rows,blocking.mc());  // cache block size along the M direction\n    std::size_t sizeA = kc*mc;\n    std::size_t sizeB = kc*cols;\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockA, sizeA, blocking.blockA());\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockB, sizeB, blocking.blockB());\n\n    gebp_kernel<Scalar, Scalar, Index, ResMapper, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel;\n    gemm_pack_lhs<Scalar, Index, LhsMapper, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs;\n    symm_pack_rhs<Scalar, Index, Traits::nr,RhsStorageOrder> pack_rhs;\n\n    for(Index k2=0; k2<size; k2+=kc)\n    {\n      const Index actual_kc = (std::min)(k2+kc,size)-k2;\n\n      pack_rhs(blockB, _rhs, rhsStride, actual_kc, cols, k2);\n\n      // => GEPP\n      for(Index i2=0; i2<rows; i2+=mc)\n      {\n        const Index actual_mc = (std::min)(i2+mc,rows)-i2;\n        pack_lhs(blockA, lhs.getSubMapper(i2, k2), actual_kc, actual_mc);\n\n        gebp_kernel(res.getSubMapper(i2, 0), blockA, blockB, actual_mc, actual_kc, cols, alpha);\n      }\n    }\n  }\n\n} // end namespace internal\n\n/***************************************************************************\n* Wrapper to product_selfadjoint_matrix\n***************************************************************************/\n\nnamespace internal {\n  \ntemplate<typename Lhs, int LhsMode, typename Rhs, int RhsMode>\nstruct selfadjoint_product_impl<Lhs,LhsMode,false,Rhs,RhsMode,false>\n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  \n  typedef internal::blas_traits<Lhs> LhsBlasTraits;\n  typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;\n  typedef internal::blas_traits<Rhs> RhsBlasTraits;\n  typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;\n  \n  enum {\n    LhsIsUpper = (LhsMode&(Upper|Lower))==Upper,\n    LhsIsSelfAdjoint = (LhsMode&SelfAdjoint)==SelfAdjoint,\n    RhsIsUpper = (RhsMode&(Upper|Lower))==Upper,\n    RhsIsSelfAdjoint = (RhsMode&SelfAdjoint)==SelfAdjoint\n  };\n  \n  template<typename Dest>\n  static void run(Dest &dst, const Lhs &a_lhs, const Rhs &a_rhs, const Scalar& alpha)\n  {\n    eigen_assert(dst.rows()==a_lhs.rows() && dst.cols()==a_rhs.cols());\n\n    typename internal::add_const_on_value_type<ActualLhsType>::type lhs = LhsBlasTraits::extract(a_lhs);\n    typename internal::add_const_on_value_type<ActualRhsType>::type rhs = RhsBlasTraits::extract(a_rhs);\n\n    Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(a_lhs)\n                               * RhsBlasTraits::extractScalarFactor(a_rhs);\n\n    typedef internal::gemm_blocking_space<(Dest::Flags&RowMajorBit) ? RowMajor : ColMajor,Scalar,Scalar,\n              Lhs::MaxRowsAtCompileTime, Rhs::MaxColsAtCompileTime, Lhs::MaxColsAtCompileTime,1> BlockingType;\n\n    BlockingType blocking(lhs.rows(), rhs.cols(), lhs.cols(), 1, false);\n\n    internal::product_selfadjoint_matrix<Scalar, Index,\n      EIGEN_LOGICAL_XOR(LhsIsUpper,internal::traits<Lhs>::Flags &RowMajorBit) ? RowMajor : ColMajor, LhsIsSelfAdjoint,\n      NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(LhsIsUpper,bool(LhsBlasTraits::NeedToConjugate)),\n      EIGEN_LOGICAL_XOR(RhsIsUpper,internal::traits<Rhs>::Flags &RowMajorBit) ? RowMajor : ColMajor, RhsIsSelfAdjoint,\n      NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(RhsIsUpper,bool(RhsBlasTraits::NeedToConjugate)),\n      internal::traits<Dest>::Flags&RowMajorBit  ? RowMajor : ColMajor>\n      ::run(\n        lhs.rows(), rhs.cols(),                 // sizes\n        &lhs.coeffRef(0,0), lhs.outerStride(),  // lhs info\n        &rhs.coeffRef(0,0), rhs.outerStride(),  // rhs info\n        &dst.coeffRef(0,0), dst.outerStride(),  // result info\n        actualAlpha, blocking                   // alpha\n      );\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SELFADJOINT_MATRIX_MATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n ********************************************************************************\n *   Content : Eigen bindings to BLAS F77\n *   Self adjoint matrix * matrix product functionality based on ?SYMM/?HEMM.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_SELFADJOINT_MATRIX_MATRIX_BLAS_H\n#define EIGEN_SELFADJOINT_MATRIX_MATRIX_BLAS_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n\n/* Optimized selfadjoint matrix * matrix (?SYMM/?HEMM) product */\n\n#define EIGEN_BLAS_SYMM_L(EIGTYPE, BLASTYPE, EIGPREFIX, BLASPREFIX) \\\ntemplate <typename Index, \\\n          int LhsStorageOrder, bool ConjugateLhs, \\\n          int RhsStorageOrder, bool ConjugateRhs> \\\nstruct product_selfadjoint_matrix<EIGTYPE,Index,LhsStorageOrder,true,ConjugateLhs,RhsStorageOrder,false,ConjugateRhs,ColMajor> \\\n{\\\n\\\n  static void run( \\\n    Index rows, Index cols, \\\n    const EIGTYPE* _lhs, Index lhsStride, \\\n    const EIGTYPE* _rhs, Index rhsStride, \\\n    EIGTYPE* res,        Index resStride, \\\n    EIGTYPE alpha, level3_blocking<EIGTYPE, EIGTYPE>& /*blocking*/) \\\n  { \\\n    char side='L', uplo='L'; \\\n    BlasIndex m, n, lda, ldb, ldc; \\\n    const EIGTYPE *a, *b; \\\n    EIGTYPE beta(1); \\\n    MatrixX##EIGPREFIX b_tmp; \\\n\\\n/* Set transpose options */ \\\n/* Set m, n, k */ \\\n    m = convert_index<BlasIndex>(rows);  \\\n    n = convert_index<BlasIndex>(cols);  \\\n\\\n/* Set lda, ldb, ldc */ \\\n    lda = convert_index<BlasIndex>(lhsStride); \\\n    ldb = convert_index<BlasIndex>(rhsStride); \\\n    ldc = convert_index<BlasIndex>(resStride); \\\n\\\n/* Set a, b, c */ \\\n    if (LhsStorageOrder==RowMajor) uplo='U'; \\\n    a = _lhs; \\\n\\\n    if (RhsStorageOrder==RowMajor) { \\\n      Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs,n,m,OuterStride<>(rhsStride)); \\\n      b_tmp = rhs.adjoint(); \\\n      b = b_tmp.data(); \\\n      ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \\\n    } else b = _rhs; \\\n\\\n    BLASPREFIX##symm_(&side, &uplo, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)b, &ldb, &numext::real_ref(beta), (BLASTYPE*)res, &ldc); \\\n\\\n  } \\\n};\n\n\n#define EIGEN_BLAS_HEMM_L(EIGTYPE, BLASTYPE, EIGPREFIX, BLASPREFIX) \\\ntemplate <typename Index, \\\n          int LhsStorageOrder, bool ConjugateLhs, \\\n          int RhsStorageOrder, bool ConjugateRhs> \\\nstruct product_selfadjoint_matrix<EIGTYPE,Index,LhsStorageOrder,true,ConjugateLhs,RhsStorageOrder,false,ConjugateRhs,ColMajor> \\\n{\\\n  static void run( \\\n    Index rows, Index cols, \\\n    const EIGTYPE* _lhs, Index lhsStride, \\\n    const EIGTYPE* _rhs, Index rhsStride, \\\n    EIGTYPE* res,        Index resStride, \\\n    EIGTYPE alpha, level3_blocking<EIGTYPE, EIGTYPE>& /*blocking*/) \\\n  { \\\n    char side='L', uplo='L'; \\\n    BlasIndex m, n, lda, ldb, ldc; \\\n    const EIGTYPE *a, *b; \\\n    EIGTYPE beta(1); \\\n    MatrixX##EIGPREFIX b_tmp; \\\n    Matrix<EIGTYPE, Dynamic, Dynamic, LhsStorageOrder> a_tmp; \\\n\\\n/* Set transpose options */ \\\n/* Set m, n, k */ \\\n    m = convert_index<BlasIndex>(rows); \\\n    n = convert_index<BlasIndex>(cols); \\\n\\\n/* Set lda, ldb, ldc */ \\\n    lda = convert_index<BlasIndex>(lhsStride); \\\n    ldb = convert_index<BlasIndex>(rhsStride); \\\n    ldc = convert_index<BlasIndex>(resStride); \\\n\\\n/* Set a, b, c */ \\\n    if (((LhsStorageOrder==ColMajor) && ConjugateLhs) || ((LhsStorageOrder==RowMajor) && (!ConjugateLhs))) { \\\n      Map<const Matrix<EIGTYPE, Dynamic, Dynamic, LhsStorageOrder>, 0, OuterStride<> > lhs(_lhs,m,m,OuterStride<>(lhsStride)); \\\n      a_tmp = lhs.conjugate(); \\\n      a = a_tmp.data(); \\\n      lda = convert_index<BlasIndex>(a_tmp.outerStride()); \\\n    } else a = _lhs; \\\n    if (LhsStorageOrder==RowMajor) uplo='U'; \\\n\\\n    if (RhsStorageOrder==ColMajor && (!ConjugateRhs)) { \\\n       b = _rhs; } \\\n    else { \\\n      if (RhsStorageOrder==ColMajor && ConjugateRhs) { \\\n        Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs,m,n,OuterStride<>(rhsStride)); \\\n        b_tmp = rhs.conjugate(); \\\n      } else \\\n      if (ConjugateRhs) { \\\n        Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs,n,m,OuterStride<>(rhsStride)); \\\n        b_tmp = rhs.adjoint(); \\\n      } else { \\\n        Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs,n,m,OuterStride<>(rhsStride)); \\\n        b_tmp = rhs.transpose(); \\\n      } \\\n      b = b_tmp.data(); \\\n      ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \\\n    } \\\n\\\n    BLASPREFIX##hemm_(&side, &uplo, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)b, &ldb, &numext::real_ref(beta), (BLASTYPE*)res, &ldc); \\\n\\\n  } \\\n};\n\nEIGEN_BLAS_SYMM_L(double, double, d, d)\nEIGEN_BLAS_SYMM_L(float, float, f, s)\nEIGEN_BLAS_HEMM_L(dcomplex, double, cd, z)\nEIGEN_BLAS_HEMM_L(scomplex, float, cf, c)\n\n\n/* Optimized matrix * selfadjoint matrix (?SYMM/?HEMM) product */\n\n#define EIGEN_BLAS_SYMM_R(EIGTYPE, BLASTYPE, EIGPREFIX, BLASPREFIX) \\\ntemplate <typename Index, \\\n          int LhsStorageOrder, bool ConjugateLhs, \\\n          int RhsStorageOrder, bool ConjugateRhs> \\\nstruct product_selfadjoint_matrix<EIGTYPE,Index,LhsStorageOrder,false,ConjugateLhs,RhsStorageOrder,true,ConjugateRhs,ColMajor> \\\n{\\\n\\\n  static void run( \\\n    Index rows, Index cols, \\\n    const EIGTYPE* _lhs, Index lhsStride, \\\n    const EIGTYPE* _rhs, Index rhsStride, \\\n    EIGTYPE* res,        Index resStride, \\\n    EIGTYPE alpha, level3_blocking<EIGTYPE, EIGTYPE>& /*blocking*/) \\\n  { \\\n    char side='R', uplo='L'; \\\n    BlasIndex m, n, lda, ldb, ldc; \\\n    const EIGTYPE *a, *b; \\\n    EIGTYPE beta(1); \\\n    MatrixX##EIGPREFIX b_tmp; \\\n\\\n/* Set m, n, k */ \\\n    m = convert_index<BlasIndex>(rows);  \\\n    n = convert_index<BlasIndex>(cols);  \\\n\\\n/* Set lda, ldb, ldc */ \\\n    lda = convert_index<BlasIndex>(rhsStride); \\\n    ldb = convert_index<BlasIndex>(lhsStride); \\\n    ldc = convert_index<BlasIndex>(resStride); \\\n\\\n/* Set a, b, c */ \\\n    if (RhsStorageOrder==RowMajor) uplo='U'; \\\n    a = _rhs; \\\n\\\n    if (LhsStorageOrder==RowMajor) { \\\n      Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs,n,m,OuterStride<>(rhsStride)); \\\n      b_tmp = lhs.adjoint(); \\\n      b = b_tmp.data(); \\\n      ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \\\n    } else b = _lhs; \\\n\\\n    BLASPREFIX##symm_(&side, &uplo, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)b, &ldb, &numext::real_ref(beta), (BLASTYPE*)res, &ldc); \\\n\\\n  } \\\n};\n\n\n#define EIGEN_BLAS_HEMM_R(EIGTYPE, BLASTYPE, EIGPREFIX, BLASPREFIX) \\\ntemplate <typename Index, \\\n          int LhsStorageOrder, bool ConjugateLhs, \\\n          int RhsStorageOrder, bool ConjugateRhs> \\\nstruct product_selfadjoint_matrix<EIGTYPE,Index,LhsStorageOrder,false,ConjugateLhs,RhsStorageOrder,true,ConjugateRhs,ColMajor> \\\n{\\\n  static void run( \\\n    Index rows, Index cols, \\\n    const EIGTYPE* _lhs, Index lhsStride, \\\n    const EIGTYPE* _rhs, Index rhsStride, \\\n    EIGTYPE* res,        Index resStride, \\\n    EIGTYPE alpha, level3_blocking<EIGTYPE, EIGTYPE>& /*blocking*/) \\\n  { \\\n    char side='R', uplo='L'; \\\n    BlasIndex m, n, lda, ldb, ldc; \\\n    const EIGTYPE *a, *b; \\\n    EIGTYPE beta(1); \\\n    MatrixX##EIGPREFIX b_tmp; \\\n    Matrix<EIGTYPE, Dynamic, Dynamic, RhsStorageOrder> a_tmp; \\\n\\\n/* Set m, n, k */ \\\n    m = convert_index<BlasIndex>(rows); \\\n    n = convert_index<BlasIndex>(cols); \\\n\\\n/* Set lda, ldb, ldc */ \\\n    lda = convert_index<BlasIndex>(rhsStride); \\\n    ldb = convert_index<BlasIndex>(lhsStride); \\\n    ldc = convert_index<BlasIndex>(resStride); \\\n\\\n/* Set a, b, c */ \\\n    if (((RhsStorageOrder==ColMajor) && ConjugateRhs) || ((RhsStorageOrder==RowMajor) && (!ConjugateRhs))) { \\\n      Map<const Matrix<EIGTYPE, Dynamic, Dynamic, RhsStorageOrder>, 0, OuterStride<> > rhs(_rhs,n,n,OuterStride<>(rhsStride)); \\\n      a_tmp = rhs.conjugate(); \\\n      a = a_tmp.data(); \\\n      lda = convert_index<BlasIndex>(a_tmp.outerStride()); \\\n    } else a = _rhs; \\\n    if (RhsStorageOrder==RowMajor) uplo='U'; \\\n\\\n    if (LhsStorageOrder==ColMajor && (!ConjugateLhs)) { \\\n       b = _lhs; } \\\n    else { \\\n      if (LhsStorageOrder==ColMajor && ConjugateLhs) { \\\n        Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs,m,n,OuterStride<>(lhsStride)); \\\n        b_tmp = lhs.conjugate(); \\\n      } else \\\n      if (ConjugateLhs) { \\\n        Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs,n,m,OuterStride<>(lhsStride)); \\\n        b_tmp = lhs.adjoint(); \\\n      } else { \\\n        Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs,n,m,OuterStride<>(lhsStride)); \\\n        b_tmp = lhs.transpose(); \\\n      } \\\n      b = b_tmp.data(); \\\n      ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \\\n    } \\\n\\\n    BLASPREFIX##hemm_(&side, &uplo, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)b, &ldb, &numext::real_ref(beta), (BLASTYPE*)res, &ldc); \\\n  } \\\n};\n\nEIGEN_BLAS_SYMM_R(double, double, d, d)\nEIGEN_BLAS_SYMM_R(float, float, f, s)\nEIGEN_BLAS_HEMM_R(dcomplex, double, cd, z)\nEIGEN_BLAS_HEMM_R(scomplex, float, cf, c)\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SELFADJOINT_MATRIX_MATRIX_BLAS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/SelfadjointMatrixVector.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SELFADJOINT_MATRIX_VECTOR_H\n#define EIGEN_SELFADJOINT_MATRIX_VECTOR_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/* Optimized selfadjoint matrix * vector product:\n * This algorithm processes 2 columns at onces that allows to both reduce\n * the number of load/stores of the result by a factor 2 and to reduce\n * the instruction dependency.\n */\n\ntemplate<typename Scalar, typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs, int Version=Specialized>\nstruct selfadjoint_matrix_vector_product;\n\ntemplate<typename Scalar, typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs, int Version>\nstruct selfadjoint_matrix_vector_product\n\n{\nstatic EIGEN_DONT_INLINE void run(\n  Index size,\n  const Scalar*  lhs, Index lhsStride,\n  const Scalar*  rhs,\n  Scalar* res,\n  Scalar alpha);\n};\n\ntemplate<typename Scalar, typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs, int Version>\nEIGEN_DONT_INLINE void selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,Version>::run(\n  Index size,\n  const Scalar*  lhs, Index lhsStride,\n  const Scalar*  rhs,\n  Scalar* res,\n  Scalar alpha)\n{\n  typedef typename packet_traits<Scalar>::type Packet;\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  const Index PacketSize = sizeof(Packet)/sizeof(Scalar);\n\n  enum {\n    IsRowMajor = StorageOrder==RowMajor ? 1 : 0,\n    IsLower = UpLo == Lower ? 1 : 0,\n    FirstTriangular = IsRowMajor == IsLower\n  };\n\n  conj_helper<Scalar,Scalar,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs,  IsRowMajor), ConjugateRhs> cj0;\n  conj_helper<Scalar,Scalar,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, !IsRowMajor), ConjugateRhs> cj1;\n  conj_helper<RealScalar,Scalar,false, ConjugateRhs> cjd;\n\n  conj_helper<Packet,Packet,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs,  IsRowMajor), ConjugateRhs> pcj0;\n  conj_helper<Packet,Packet,NumTraits<Scalar>::IsComplex && EIGEN_LOGICAL_XOR(ConjugateLhs, !IsRowMajor), ConjugateRhs> pcj1;\n\n  Scalar cjAlpha = ConjugateRhs ? numext::conj(alpha) : alpha;\n\n\n  Index bound = (std::max)(Index(0),size-8) & 0xfffffffe;\n  if (FirstTriangular)\n    bound = size - bound;\n\n  for (Index j=FirstTriangular ? bound : 0;\n       j<(FirstTriangular ? size : bound);j+=2)\n  {\n    const Scalar* EIGEN_RESTRICT A0 = lhs + j*lhsStride;\n    const Scalar* EIGEN_RESTRICT A1 = lhs + (j+1)*lhsStride;\n\n    Scalar t0 = cjAlpha * rhs[j];\n    Packet ptmp0 = pset1<Packet>(t0);\n    Scalar t1 = cjAlpha * rhs[j+1];\n    Packet ptmp1 = pset1<Packet>(t1);\n\n    Scalar t2(0);\n    Packet ptmp2 = pset1<Packet>(t2);\n    Scalar t3(0);\n    Packet ptmp3 = pset1<Packet>(t3);\n\n    Index starti = FirstTriangular ? 0 : j+2;\n    Index endi   = FirstTriangular ? j : size;\n    Index alignedStart = (starti) + internal::first_default_aligned(&res[starti], endi-starti);\n    Index alignedEnd = alignedStart + ((endi-alignedStart)/(PacketSize))*(PacketSize);\n\n    res[j]   += cjd.pmul(numext::real(A0[j]), t0);\n    res[j+1] += cjd.pmul(numext::real(A1[j+1]), t1);\n    if(FirstTriangular)\n    {\n      res[j]   += cj0.pmul(A1[j],   t1);\n      t3       += cj1.pmul(A1[j],   rhs[j]);\n    }\n    else\n    {\n      res[j+1] += cj0.pmul(A0[j+1],t0);\n      t2 += cj1.pmul(A0[j+1], rhs[j+1]);\n    }\n\n    for (Index i=starti; i<alignedStart; ++i)\n    {\n      res[i] += cj0.pmul(A0[i], t0) + cj0.pmul(A1[i],t1);\n      t2 += cj1.pmul(A0[i], rhs[i]);\n      t3 += cj1.pmul(A1[i], rhs[i]);\n    }\n    // Yes this an optimization for gcc 4.3 and 4.4 (=> huge speed up)\n    // gcc 4.2 does this optimization automatically.\n    const Scalar* EIGEN_RESTRICT a0It  = A0  + alignedStart;\n    const Scalar* EIGEN_RESTRICT a1It  = A1  + alignedStart;\n    const Scalar* EIGEN_RESTRICT rhsIt = rhs + alignedStart;\n          Scalar* EIGEN_RESTRICT resIt = res + alignedStart;\n    for (Index i=alignedStart; i<alignedEnd; i+=PacketSize)\n    {\n      Packet A0i = ploadu<Packet>(a0It);  a0It  += PacketSize;\n      Packet A1i = ploadu<Packet>(a1It);  a1It  += PacketSize;\n      Packet Bi  = ploadu<Packet>(rhsIt); rhsIt += PacketSize; // FIXME should be aligned in most cases\n      Packet Xi  = pload <Packet>(resIt);\n\n      Xi    = pcj0.pmadd(A0i,ptmp0, pcj0.pmadd(A1i,ptmp1,Xi));\n      ptmp2 = pcj1.pmadd(A0i,  Bi, ptmp2);\n      ptmp3 = pcj1.pmadd(A1i,  Bi, ptmp3);\n      pstore(resIt,Xi); resIt += PacketSize;\n    }\n    for (Index i=alignedEnd; i<endi; i++)\n    {\n      res[i] += cj0.pmul(A0[i], t0) + cj0.pmul(A1[i],t1);\n      t2 += cj1.pmul(A0[i], rhs[i]);\n      t3 += cj1.pmul(A1[i], rhs[i]);\n    }\n\n    res[j]   += alpha * (t2 + predux(ptmp2));\n    res[j+1] += alpha * (t3 + predux(ptmp3));\n  }\n  for (Index j=FirstTriangular ? 0 : bound;j<(FirstTriangular ? bound : size);j++)\n  {\n    const Scalar* EIGEN_RESTRICT A0 = lhs + j*lhsStride;\n\n    Scalar t1 = cjAlpha * rhs[j];\n    Scalar t2(0);\n    res[j] += cjd.pmul(numext::real(A0[j]), t1);\n    for (Index i=FirstTriangular ? 0 : j+1; i<(FirstTriangular ? j : size); i++)\n    {\n      res[i] += cj0.pmul(A0[i], t1);\n      t2 += cj1.pmul(A0[i], rhs[i]);\n    }\n    res[j] += alpha * t2;\n  }\n}\n\n} // end namespace internal \n\n/***************************************************************************\n* Wrapper to product_selfadjoint_vector\n***************************************************************************/\n\nnamespace internal {\n\ntemplate<typename Lhs, int LhsMode, typename Rhs>\nstruct selfadjoint_product_impl<Lhs,LhsMode,false,Rhs,0,true>\n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  \n  typedef internal::blas_traits<Lhs> LhsBlasTraits;\n  typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;\n  typedef typename internal::remove_all<ActualLhsType>::type ActualLhsTypeCleaned;\n  \n  typedef internal::blas_traits<Rhs> RhsBlasTraits;\n  typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;\n  typedef typename internal::remove_all<ActualRhsType>::type ActualRhsTypeCleaned;\n\n  enum { LhsUpLo = LhsMode&(Upper|Lower) };\n\n  template<typename Dest>\n  static void run(Dest& dest, const Lhs &a_lhs, const Rhs &a_rhs, const Scalar& alpha)\n  {\n    typedef typename Dest::Scalar ResScalar;\n    typedef typename Rhs::Scalar RhsScalar;\n    typedef Map<Matrix<ResScalar,Dynamic,1>, EIGEN_PLAIN_ENUM_MIN(AlignedMax,internal::packet_traits<ResScalar>::size)> MappedDest;\n    \n    eigen_assert(dest.rows()==a_lhs.rows() && dest.cols()==a_rhs.cols());\n\n    typename internal::add_const_on_value_type<ActualLhsType>::type lhs = LhsBlasTraits::extract(a_lhs);\n    typename internal::add_const_on_value_type<ActualRhsType>::type rhs = RhsBlasTraits::extract(a_rhs);\n\n    Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(a_lhs)\n                               * RhsBlasTraits::extractScalarFactor(a_rhs);\n\n    enum {\n      EvalToDest = (Dest::InnerStrideAtCompileTime==1),\n      UseRhs = (ActualRhsTypeCleaned::InnerStrideAtCompileTime==1)\n    };\n    \n    internal::gemv_static_vector_if<ResScalar,Dest::SizeAtCompileTime,Dest::MaxSizeAtCompileTime,!EvalToDest> static_dest;\n    internal::gemv_static_vector_if<RhsScalar,ActualRhsTypeCleaned::SizeAtCompileTime,ActualRhsTypeCleaned::MaxSizeAtCompileTime,!UseRhs> static_rhs;\n\n    ei_declare_aligned_stack_constructed_variable(ResScalar,actualDestPtr,dest.size(),\n                                                  EvalToDest ? dest.data() : static_dest.data());\n                                                  \n    ei_declare_aligned_stack_constructed_variable(RhsScalar,actualRhsPtr,rhs.size(),\n        UseRhs ? const_cast<RhsScalar*>(rhs.data()) : static_rhs.data());\n    \n    if(!EvalToDest)\n    {\n      #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n      Index size = dest.size();\n      EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n      #endif\n      MappedDest(actualDestPtr, dest.size()) = dest;\n    }\n      \n    if(!UseRhs)\n    {\n      #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n      Index size = rhs.size();\n      EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n      #endif\n      Map<typename ActualRhsTypeCleaned::PlainObject>(actualRhsPtr, rhs.size()) = rhs;\n    }\n      \n      \n    internal::selfadjoint_matrix_vector_product<Scalar, Index, (internal::traits<ActualLhsTypeCleaned>::Flags&RowMajorBit) ? RowMajor : ColMajor,\n                                                int(LhsUpLo), bool(LhsBlasTraits::NeedToConjugate), bool(RhsBlasTraits::NeedToConjugate)>::run\n      (\n        lhs.rows(),                             // size\n        &lhs.coeffRef(0,0),  lhs.outerStride(), // lhs info\n        actualRhsPtr,                           // rhs info\n        actualDestPtr,                          // result info\n        actualAlpha                             // scale factor\n      );\n    \n    if(!EvalToDest)\n      dest = MappedDest(actualDestPtr, dest.size());\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int RhsMode>\nstruct selfadjoint_product_impl<Lhs,0,true,Rhs,RhsMode,false>\n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  enum { RhsUpLo = RhsMode&(Upper|Lower)  };\n\n  template<typename Dest>\n  static void run(Dest& dest, const Lhs &a_lhs, const Rhs &a_rhs, const Scalar& alpha)\n  {\n    // let's simply transpose the product\n    Transpose<Dest> destT(dest);\n    selfadjoint_product_impl<Transpose<const Rhs>, int(RhsUpLo)==Upper ? Lower : Upper, false,\n                             Transpose<const Lhs>, 0, true>::run(destT, a_rhs.transpose(), a_lhs.transpose(), alpha);\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SELFADJOINT_MATRIX_VECTOR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to BLAS F77\n *   Selfadjoint matrix-vector product functionality based on ?SYMV/HEMV.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_SELFADJOINT_MATRIX_VECTOR_BLAS_H\n#define EIGEN_SELFADJOINT_MATRIX_VECTOR_BLAS_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/**********************************************************************\n* This file implements selfadjoint matrix-vector multiplication using BLAS\n**********************************************************************/\n\n// symv/hemv specialization\n\ntemplate<typename Scalar, typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs>\nstruct selfadjoint_matrix_vector_product_symv :\n  selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,BuiltIn> {};\n\n#define EIGEN_BLAS_SYMV_SPECIALIZE(Scalar) \\\ntemplate<typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs> \\\nstruct selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,Specialized> { \\\nstatic void run( \\\n  Index size, const Scalar*  lhs, Index lhsStride, \\\n  const Scalar* _rhs, Scalar* res, Scalar alpha) { \\\n    enum {\\\n      IsColMajor = StorageOrder==ColMajor \\\n    }; \\\n    if (IsColMajor == ConjugateLhs) {\\\n      selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,BuiltIn>::run( \\\n        size, lhs, lhsStride, _rhs, res, alpha);  \\\n    } else {\\\n      selfadjoint_matrix_vector_product_symv<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs>::run( \\\n        size, lhs, lhsStride, _rhs, res, alpha);  \\\n    }\\\n  } \\\n}; \\\n\nEIGEN_BLAS_SYMV_SPECIALIZE(double)\nEIGEN_BLAS_SYMV_SPECIALIZE(float)\nEIGEN_BLAS_SYMV_SPECIALIZE(dcomplex)\nEIGEN_BLAS_SYMV_SPECIALIZE(scomplex)\n\n#define EIGEN_BLAS_SYMV_SPECIALIZATION(EIGTYPE,BLASTYPE,BLASFUNC) \\\ntemplate<typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs> \\\nstruct selfadjoint_matrix_vector_product_symv<EIGTYPE,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs> \\\n{ \\\ntypedef Matrix<EIGTYPE,Dynamic,1,ColMajor> SYMVVector;\\\n\\\nstatic void run( \\\nIndex size, const EIGTYPE*  lhs, Index lhsStride, \\\nconst EIGTYPE* _rhs, EIGTYPE* res, EIGTYPE alpha) \\\n{ \\\n  enum {\\\n    IsRowMajor = StorageOrder==RowMajor ? 1 : 0, \\\n    IsLower = UpLo == Lower ? 1 : 0 \\\n  }; \\\n  BlasIndex n=convert_index<BlasIndex>(size), lda=convert_index<BlasIndex>(lhsStride), incx=1, incy=1; \\\n  EIGTYPE beta(1); \\\n  const EIGTYPE *x_ptr; \\\n  char uplo=(IsRowMajor) ? (IsLower ? 'U' : 'L') : (IsLower ? 'L' : 'U'); \\\n  SYMVVector x_tmp; \\\n  if (ConjugateRhs) { \\\n    Map<const SYMVVector, 0 > map_x(_rhs,size,1); \\\n    x_tmp=map_x.conjugate(); \\\n    x_ptr=x_tmp.data(); \\\n  } else x_ptr=_rhs; \\\n  BLASFUNC(&uplo, &n, &numext::real_ref(alpha), (const BLASTYPE*)lhs, &lda, (const BLASTYPE*)x_ptr, &incx, &numext::real_ref(beta), (BLASTYPE*)res, &incy); \\\n}\\\n};\n\nEIGEN_BLAS_SYMV_SPECIALIZATION(double,   double, dsymv_)\nEIGEN_BLAS_SYMV_SPECIALIZATION(float,    float,  ssymv_)\nEIGEN_BLAS_SYMV_SPECIALIZATION(dcomplex, double, zhemv_)\nEIGEN_BLAS_SYMV_SPECIALIZATION(scomplex, float,  chemv_)\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SELFADJOINT_MATRIX_VECTOR_BLAS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/SelfadjointProduct.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SELFADJOINT_PRODUCT_H\n#define EIGEN_SELFADJOINT_PRODUCT_H\n\n/**********************************************************************\n* This file implements a self adjoint product: C += A A^T updating only\n* half of the selfadjoint matrix C.\n* It corresponds to the level 3 SYRK and level 2 SYR Blas routines.\n**********************************************************************/\n\nnamespace Eigen { \n\n\ntemplate<typename Scalar, typename Index, int UpLo, bool ConjLhs, bool ConjRhs>\nstruct selfadjoint_rank1_update<Scalar,Index,ColMajor,UpLo,ConjLhs,ConjRhs>\n{\n  static void run(Index size, Scalar* mat, Index stride, const Scalar* vecX, const Scalar* vecY, const Scalar& alpha)\n  {\n    internal::conj_if<ConjRhs> cj;\n    typedef Map<const Matrix<Scalar,Dynamic,1> > OtherMap;\n    typedef typename internal::conditional<ConjLhs,typename OtherMap::ConjugateReturnType,const OtherMap&>::type ConjLhsType;\n    for (Index i=0; i<size; ++i)\n    {\n      Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i+(UpLo==Lower ? i : 0), (UpLo==Lower ? size-i : (i+1)))\n          += (alpha * cj(vecY[i])) * ConjLhsType(OtherMap(vecX+(UpLo==Lower ? i : 0),UpLo==Lower ? size-i : (i+1)));\n    }\n  }\n};\n\ntemplate<typename Scalar, typename Index, int UpLo, bool ConjLhs, bool ConjRhs>\nstruct selfadjoint_rank1_update<Scalar,Index,RowMajor,UpLo,ConjLhs,ConjRhs>\n{\n  static void run(Index size, Scalar* mat, Index stride, const Scalar* vecX, const Scalar* vecY, const Scalar& alpha)\n  {\n    selfadjoint_rank1_update<Scalar,Index,ColMajor,UpLo==Lower?Upper:Lower,ConjRhs,ConjLhs>::run(size,mat,stride,vecY,vecX,alpha);\n  }\n};\n\ntemplate<typename MatrixType, typename OtherType, int UpLo, bool OtherIsVector = OtherType::IsVectorAtCompileTime>\nstruct selfadjoint_product_selector;\n\ntemplate<typename MatrixType, typename OtherType, int UpLo>\nstruct selfadjoint_product_selector<MatrixType,OtherType,UpLo,true>\n{\n  static void run(MatrixType& mat, const OtherType& other, const typename MatrixType::Scalar& alpha)\n  {\n    typedef typename MatrixType::Scalar Scalar;\n    typedef internal::blas_traits<OtherType> OtherBlasTraits;\n    typedef typename OtherBlasTraits::DirectLinearAccessType ActualOtherType;\n    typedef typename internal::remove_all<ActualOtherType>::type _ActualOtherType;\n    typename internal::add_const_on_value_type<ActualOtherType>::type actualOther = OtherBlasTraits::extract(other.derived());\n\n    Scalar actualAlpha = alpha * OtherBlasTraits::extractScalarFactor(other.derived());\n\n    enum {\n      StorageOrder = (internal::traits<MatrixType>::Flags&RowMajorBit) ? RowMajor : ColMajor,\n      UseOtherDirectly = _ActualOtherType::InnerStrideAtCompileTime==1\n    };\n    internal::gemv_static_vector_if<Scalar,OtherType::SizeAtCompileTime,OtherType::MaxSizeAtCompileTime,!UseOtherDirectly> static_other;\n\n    ei_declare_aligned_stack_constructed_variable(Scalar, actualOtherPtr, other.size(),\n      (UseOtherDirectly ? const_cast<Scalar*>(actualOther.data()) : static_other.data()));\n      \n    if(!UseOtherDirectly)\n      Map<typename _ActualOtherType::PlainObject>(actualOtherPtr, actualOther.size()) = actualOther;\n    \n    selfadjoint_rank1_update<Scalar,Index,StorageOrder,UpLo,\n                              OtherBlasTraits::NeedToConjugate  && NumTraits<Scalar>::IsComplex,\n                            (!OtherBlasTraits::NeedToConjugate) && NumTraits<Scalar>::IsComplex>\n          ::run(other.size(), mat.data(), mat.outerStride(), actualOtherPtr, actualOtherPtr, actualAlpha);\n  }\n};\n\ntemplate<typename MatrixType, typename OtherType, int UpLo>\nstruct selfadjoint_product_selector<MatrixType,OtherType,UpLo,false>\n{\n  static void run(MatrixType& mat, const OtherType& other, const typename MatrixType::Scalar& alpha)\n  {\n    typedef typename MatrixType::Scalar Scalar;\n    typedef internal::blas_traits<OtherType> OtherBlasTraits;\n    typedef typename OtherBlasTraits::DirectLinearAccessType ActualOtherType;\n    typedef typename internal::remove_all<ActualOtherType>::type _ActualOtherType;\n    typename internal::add_const_on_value_type<ActualOtherType>::type actualOther = OtherBlasTraits::extract(other.derived());\n\n    Scalar actualAlpha = alpha * OtherBlasTraits::extractScalarFactor(other.derived());\n\n    enum {\n      IsRowMajor = (internal::traits<MatrixType>::Flags&RowMajorBit) ? 1 : 0,\n      OtherIsRowMajor = _ActualOtherType::Flags&RowMajorBit ? 1 : 0\n    };\n\n    Index size = mat.cols();\n    Index depth = actualOther.cols();\n\n    typedef internal::gemm_blocking_space<IsRowMajor ? RowMajor : ColMajor,Scalar,Scalar,\n              MatrixType::MaxColsAtCompileTime, MatrixType::MaxColsAtCompileTime, _ActualOtherType::MaxColsAtCompileTime> BlockingType;\n\n    BlockingType blocking(size, size, depth, 1, false);\n\n\n    internal::general_matrix_matrix_triangular_product<Index,\n      Scalar, OtherIsRowMajor ? RowMajor : ColMajor,   OtherBlasTraits::NeedToConjugate  && NumTraits<Scalar>::IsComplex,\n      Scalar, OtherIsRowMajor ? ColMajor : RowMajor, (!OtherBlasTraits::NeedToConjugate) && NumTraits<Scalar>::IsComplex,\n      IsRowMajor ? RowMajor : ColMajor, UpLo>\n      ::run(size, depth,\n            &actualOther.coeffRef(0,0), actualOther.outerStride(), &actualOther.coeffRef(0,0), actualOther.outerStride(),\n            mat.data(), mat.outerStride(), actualAlpha, blocking);\n  }\n};\n\n// high level API\n\ntemplate<typename MatrixType, unsigned int UpLo>\ntemplate<typename DerivedU>\nSelfAdjointView<MatrixType,UpLo>& SelfAdjointView<MatrixType,UpLo>\n::rankUpdate(const MatrixBase<DerivedU>& u, const Scalar& alpha)\n{\n  selfadjoint_product_selector<MatrixType,DerivedU,UpLo>::run(_expression().const_cast_derived(), u.derived(), alpha);\n\n  return *this;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SELFADJOINT_PRODUCT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/SelfadjointRank2Update.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SELFADJOINTRANK2UPTADE_H\n#define EIGEN_SELFADJOINTRANK2UPTADE_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/* Optimized selfadjoint matrix += alpha * uv' + conj(alpha)*vu'\n * It corresponds to the Level2 syr2 BLAS routine\n */\n\ntemplate<typename Scalar, typename Index, typename UType, typename VType, int UpLo>\nstruct selfadjoint_rank2_update_selector;\n\ntemplate<typename Scalar, typename Index, typename UType, typename VType>\nstruct selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Lower>\n{\n  static void run(Scalar* mat, Index stride, const UType& u, const VType& v, const Scalar& alpha)\n  {\n    const Index size = u.size();\n    for (Index i=0; i<size; ++i)\n    {\n      Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i+i, size-i) +=\n                        (numext::conj(alpha) * numext::conj(u.coeff(i))) * v.tail(size-i)\n                      + (alpha * numext::conj(v.coeff(i))) * u.tail(size-i);\n    }\n  }\n};\n\ntemplate<typename Scalar, typename Index, typename UType, typename VType>\nstruct selfadjoint_rank2_update_selector<Scalar,Index,UType,VType,Upper>\n{\n  static void run(Scalar* mat, Index stride, const UType& u, const VType& v, const Scalar& alpha)\n  {\n    const Index size = u.size();\n    for (Index i=0; i<size; ++i)\n      Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i, i+1) +=\n                        (numext::conj(alpha)  * numext::conj(u.coeff(i))) * v.head(i+1)\n                      + (alpha * numext::conj(v.coeff(i))) * u.head(i+1);\n  }\n};\n\ntemplate<bool Cond, typename T> struct conj_expr_if\n  : conditional<!Cond, const T&,\n      CwiseUnaryOp<scalar_conjugate_op<typename traits<T>::Scalar>,T> > {};\n\n} // end namespace internal\n\ntemplate<typename MatrixType, unsigned int UpLo>\ntemplate<typename DerivedU, typename DerivedV>\nSelfAdjointView<MatrixType,UpLo>& SelfAdjointView<MatrixType,UpLo>\n::rankUpdate(const MatrixBase<DerivedU>& u, const MatrixBase<DerivedV>& v, const Scalar& alpha)\n{\n  typedef internal::blas_traits<DerivedU> UBlasTraits;\n  typedef typename UBlasTraits::DirectLinearAccessType ActualUType;\n  typedef typename internal::remove_all<ActualUType>::type _ActualUType;\n  typename internal::add_const_on_value_type<ActualUType>::type actualU = UBlasTraits::extract(u.derived());\n\n  typedef internal::blas_traits<DerivedV> VBlasTraits;\n  typedef typename VBlasTraits::DirectLinearAccessType ActualVType;\n  typedef typename internal::remove_all<ActualVType>::type _ActualVType;\n  typename internal::add_const_on_value_type<ActualVType>::type actualV = VBlasTraits::extract(v.derived());\n\n  // If MatrixType is row major, then we use the routine for lower triangular in the upper triangular case and\n  // vice versa, and take the complex conjugate of all coefficients and vector entries.\n\n  enum { IsRowMajor = (internal::traits<MatrixType>::Flags&RowMajorBit) ? 1 : 0 };\n  Scalar actualAlpha = alpha * UBlasTraits::extractScalarFactor(u.derived())\n                             * numext::conj(VBlasTraits::extractScalarFactor(v.derived()));\n  if (IsRowMajor)\n    actualAlpha = numext::conj(actualAlpha);\n\n  typedef typename internal::remove_all<typename internal::conj_expr_if<IsRowMajor ^ UBlasTraits::NeedToConjugate,_ActualUType>::type>::type UType;\n  typedef typename internal::remove_all<typename internal::conj_expr_if<IsRowMajor ^ VBlasTraits::NeedToConjugate,_ActualVType>::type>::type VType;\n  internal::selfadjoint_rank2_update_selector<Scalar, Index, UType, VType,\n    (IsRowMajor ? int(UpLo==Upper ? Lower : Upper) : UpLo)>\n    ::run(_expression().const_cast_derived().data(),_expression().outerStride(),UType(actualU),VType(actualV),actualAlpha);\n\n  return *this;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SELFADJOINTRANK2UPTADE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/TriangularMatrixMatrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TRIANGULAR_MATRIX_MATRIX_H\n#define EIGEN_TRIANGULAR_MATRIX_MATRIX_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n// template<typename Scalar, int mr, int StorageOrder, bool Conjugate, int Mode>\n// struct gemm_pack_lhs_triangular\n// {\n//   Matrix<Scalar,mr,mr,\n//   void operator()(Scalar* blockA, const EIGEN_RESTRICT Scalar* _lhs, int lhsStride, int depth, int rows)\n//   {\n//     conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj;\n//     const_blas_data_mapper<Scalar, StorageOrder> lhs(_lhs,lhsStride);\n//     int count = 0;\n//     const int peeled_mc = (rows/mr)*mr;\n//     for(int i=0; i<peeled_mc; i+=mr)\n//     {\n//       for(int k=0; k<depth; k++)\n//         for(int w=0; w<mr; w++)\n//           blockA[count++] = cj(lhs(i+w, k));\n//     }\n//     for(int i=peeled_mc; i<rows; i++)\n//     {\n//       for(int k=0; k<depth; k++)\n//         blockA[count++] = cj(lhs(i, k));\n//     }\n//   }\n// };\n\n/* Optimized triangular matrix * matrix (_TRMM++) product built on top of\n * the general matrix matrix product.\n */\ntemplate <typename Scalar, typename Index,\n          int Mode, bool LhsIsTriangular,\n          int LhsStorageOrder, bool ConjugateLhs,\n          int RhsStorageOrder, bool ConjugateRhs,\n          int ResStorageOrder, int Version = Specialized>\nstruct product_triangular_matrix_matrix;\n\ntemplate <typename Scalar, typename Index,\n          int Mode, bool LhsIsTriangular,\n          int LhsStorageOrder, bool ConjugateLhs,\n          int RhsStorageOrder, bool ConjugateRhs, int Version>\nstruct product_triangular_matrix_matrix<Scalar,Index,Mode,LhsIsTriangular,\n                                           LhsStorageOrder,ConjugateLhs,\n                                           RhsStorageOrder,ConjugateRhs,RowMajor,Version>\n{\n  static EIGEN_STRONG_INLINE void run(\n    Index rows, Index cols, Index depth,\n    const Scalar* lhs, Index lhsStride,\n    const Scalar* rhs, Index rhsStride,\n    Scalar* res,       Index resStride,\n    const Scalar& alpha, level3_blocking<Scalar,Scalar>& blocking)\n  {\n    product_triangular_matrix_matrix<Scalar, Index,\n      (Mode&(UnitDiag|ZeroDiag)) | ((Mode&Upper) ? Lower : Upper),\n      (!LhsIsTriangular),\n      RhsStorageOrder==RowMajor ? ColMajor : RowMajor,\n      ConjugateRhs,\n      LhsStorageOrder==RowMajor ? ColMajor : RowMajor,\n      ConjugateLhs,\n      ColMajor>\n      ::run(cols, rows, depth, rhs, rhsStride, lhs, lhsStride, res, resStride, alpha, blocking);\n  }\n};\n\n// implements col-major += alpha * op(triangular) * op(general)\ntemplate <typename Scalar, typename Index, int Mode,\n          int LhsStorageOrder, bool ConjugateLhs,\n          int RhsStorageOrder, bool ConjugateRhs, int Version>\nstruct product_triangular_matrix_matrix<Scalar,Index,Mode,true,\n                                           LhsStorageOrder,ConjugateLhs,\n                                           RhsStorageOrder,ConjugateRhs,ColMajor,Version>\n{\n  \n  typedef gebp_traits<Scalar,Scalar> Traits;\n  enum {\n    SmallPanelWidth   = 2 * EIGEN_PLAIN_ENUM_MAX(Traits::mr,Traits::nr),\n    IsLower = (Mode&Lower) == Lower,\n    SetDiag = (Mode&(ZeroDiag|UnitDiag)) ? 0 : 1\n  };\n\n  static EIGEN_DONT_INLINE void run(\n    Index _rows, Index _cols, Index _depth,\n    const Scalar* _lhs, Index lhsStride,\n    const Scalar* _rhs, Index rhsStride,\n    Scalar* res,        Index resStride,\n    const Scalar& alpha, level3_blocking<Scalar,Scalar>& blocking);\n};\n\ntemplate <typename Scalar, typename Index, int Mode,\n          int LhsStorageOrder, bool ConjugateLhs,\n          int RhsStorageOrder, bool ConjugateRhs, int Version>\nEIGEN_DONT_INLINE void product_triangular_matrix_matrix<Scalar,Index,Mode,true,\n                                                        LhsStorageOrder,ConjugateLhs,\n                                                        RhsStorageOrder,ConjugateRhs,ColMajor,Version>::run(\n    Index _rows, Index _cols, Index _depth,\n    const Scalar* _lhs, Index lhsStride,\n    const Scalar* _rhs, Index rhsStride,\n    Scalar* _res,        Index resStride,\n    const Scalar& alpha, level3_blocking<Scalar,Scalar>& blocking)\n  {\n    // strip zeros\n    Index diagSize  = (std::min)(_rows,_depth);\n    Index rows      = IsLower ? _rows : diagSize;\n    Index depth     = IsLower ? diagSize : _depth;\n    Index cols      = _cols;\n    \n    typedef const_blas_data_mapper<Scalar, Index, LhsStorageOrder> LhsMapper;\n    typedef const_blas_data_mapper<Scalar, Index, RhsStorageOrder> RhsMapper;\n    typedef blas_data_mapper<typename Traits::ResScalar, Index, ColMajor> ResMapper;\n    LhsMapper lhs(_lhs,lhsStride);\n    RhsMapper rhs(_rhs,rhsStride);\n    ResMapper res(_res, resStride);\n\n    Index kc = blocking.kc();                   // cache block size along the K direction\n    Index mc = (std::min)(rows,blocking.mc());  // cache block size along the M direction\n    // The small panel size must not be larger than blocking size.\n    // Usually this should never be the case because SmallPanelWidth^2 is very small\n    // compared to L2 cache size, but let's be safe:\n    Index panelWidth = (std::min)(Index(SmallPanelWidth),(std::min)(kc,mc));\n\n    std::size_t sizeA = kc*mc;\n    std::size_t sizeB = kc*cols;\n\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockA, sizeA, blocking.blockA());\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockB, sizeB, blocking.blockB());\n\n    Matrix<Scalar,SmallPanelWidth,SmallPanelWidth,LhsStorageOrder> triangularBuffer((internal::constructor_without_unaligned_array_assert()));\n    triangularBuffer.setZero();\n    if((Mode&ZeroDiag)==ZeroDiag)\n      triangularBuffer.diagonal().setZero();\n    else\n      triangularBuffer.diagonal().setOnes();\n\n    gebp_kernel<Scalar, Scalar, Index, ResMapper, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel;\n    gemm_pack_lhs<Scalar, Index, LhsMapper, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs;\n    gemm_pack_rhs<Scalar, Index, RhsMapper, Traits::nr,RhsStorageOrder> pack_rhs;\n\n    for(Index k2=IsLower ? depth : 0;\n        IsLower ? k2>0 : k2<depth;\n        IsLower ? k2-=kc : k2+=kc)\n    {\n      Index actual_kc = (std::min)(IsLower ? k2 : depth-k2, kc);\n      Index actual_k2 = IsLower ? k2-actual_kc : k2;\n\n      // align blocks with the end of the triangular part for trapezoidal lhs\n      if((!IsLower)&&(k2<rows)&&(k2+actual_kc>rows))\n      {\n        actual_kc = rows-k2;\n        k2 = k2+actual_kc-kc;\n      }\n\n      pack_rhs(blockB, rhs.getSubMapper(actual_k2,0), actual_kc, cols);\n\n      // the selected lhs's panel has to be split in three different parts:\n      //  1 - the part which is zero => skip it\n      //  2 - the diagonal block => special kernel\n      //  3 - the dense panel below (lower case) or above (upper case) the diagonal block => GEPP\n\n      // the block diagonal, if any:\n      if(IsLower || actual_k2<rows)\n      {\n        // for each small vertical panels of lhs\n        for (Index k1=0; k1<actual_kc; k1+=panelWidth)\n        {\n          Index actualPanelWidth = std::min<Index>(actual_kc-k1, panelWidth);\n          Index lengthTarget = IsLower ? actual_kc-k1-actualPanelWidth : k1;\n          Index startBlock   = actual_k2+k1;\n          Index blockBOffset = k1;\n\n          // => GEBP with the micro triangular block\n          // The trick is to pack this micro block while filling the opposite triangular part with zeros.\n          // To this end we do an extra triangular copy to a small temporary buffer\n          for (Index k=0;k<actualPanelWidth;++k)\n          {\n            if (SetDiag)\n              triangularBuffer.coeffRef(k,k) = lhs(startBlock+k,startBlock+k);\n            for (Index i=IsLower ? k+1 : 0; IsLower ? i<actualPanelWidth : i<k; ++i)\n              triangularBuffer.coeffRef(i,k) = lhs(startBlock+i,startBlock+k);\n          }\n          pack_lhs(blockA, LhsMapper(triangularBuffer.data(), triangularBuffer.outerStride()), actualPanelWidth, actualPanelWidth);\n\n          gebp_kernel(res.getSubMapper(startBlock, 0), blockA, blockB,\n                      actualPanelWidth, actualPanelWidth, cols, alpha,\n                      actualPanelWidth, actual_kc, 0, blockBOffset);\n\n          // GEBP with remaining micro panel\n          if (lengthTarget>0)\n          {\n            Index startTarget  = IsLower ? actual_k2+k1+actualPanelWidth : actual_k2;\n\n            pack_lhs(blockA, lhs.getSubMapper(startTarget,startBlock), actualPanelWidth, lengthTarget);\n\n            gebp_kernel(res.getSubMapper(startTarget, 0), blockA, blockB,\n                        lengthTarget, actualPanelWidth, cols, alpha,\n                        actualPanelWidth, actual_kc, 0, blockBOffset);\n          }\n        }\n      }\n      // the part below (lower case) or above (upper case) the diagonal => GEPP\n      {\n        Index start = IsLower ? k2 : 0;\n        Index end   = IsLower ? rows : (std::min)(actual_k2,rows);\n        for(Index i2=start; i2<end; i2+=mc)\n        {\n          const Index actual_mc = (std::min)(i2+mc,end)-i2;\n          gemm_pack_lhs<Scalar, Index, LhsMapper, Traits::mr,Traits::LhsProgress, LhsStorageOrder,false>()\n            (blockA, lhs.getSubMapper(i2, actual_k2), actual_kc, actual_mc);\n\n          gebp_kernel(res.getSubMapper(i2, 0), blockA, blockB, actual_mc,\n                      actual_kc, cols, alpha, -1, -1, 0, 0);\n        }\n      }\n    }\n  }\n\n// implements col-major += alpha * op(general) * op(triangular)\ntemplate <typename Scalar, typename Index, int Mode,\n          int LhsStorageOrder, bool ConjugateLhs,\n          int RhsStorageOrder, bool ConjugateRhs, int Version>\nstruct product_triangular_matrix_matrix<Scalar,Index,Mode,false,\n                                        LhsStorageOrder,ConjugateLhs,\n                                        RhsStorageOrder,ConjugateRhs,ColMajor,Version>\n{\n  typedef gebp_traits<Scalar,Scalar> Traits;\n  enum {\n    SmallPanelWidth   = EIGEN_PLAIN_ENUM_MAX(Traits::mr,Traits::nr),\n    IsLower = (Mode&Lower) == Lower,\n    SetDiag = (Mode&(ZeroDiag|UnitDiag)) ? 0 : 1\n  };\n\n  static EIGEN_DONT_INLINE void run(\n    Index _rows, Index _cols, Index _depth,\n    const Scalar* _lhs, Index lhsStride,\n    const Scalar* _rhs, Index rhsStride,\n    Scalar* res,        Index resStride,\n    const Scalar& alpha, level3_blocking<Scalar,Scalar>& blocking);\n};\n\ntemplate <typename Scalar, typename Index, int Mode,\n          int LhsStorageOrder, bool ConjugateLhs,\n          int RhsStorageOrder, bool ConjugateRhs, int Version>\nEIGEN_DONT_INLINE void product_triangular_matrix_matrix<Scalar,Index,Mode,false,\n                                                        LhsStorageOrder,ConjugateLhs,\n                                                        RhsStorageOrder,ConjugateRhs,ColMajor,Version>::run(\n    Index _rows, Index _cols, Index _depth,\n    const Scalar* _lhs, Index lhsStride,\n    const Scalar* _rhs, Index rhsStride,\n    Scalar* _res,        Index resStride,\n    const Scalar& alpha, level3_blocking<Scalar,Scalar>& blocking)\n  {\n    const Index PacketBytes = packet_traits<Scalar>::size*sizeof(Scalar);\n    // strip zeros\n    Index diagSize  = (std::min)(_cols,_depth);\n    Index rows      = _rows;\n    Index depth     = IsLower ? _depth : diagSize;\n    Index cols      = IsLower ? diagSize : _cols;\n    \n    typedef const_blas_data_mapper<Scalar, Index, LhsStorageOrder> LhsMapper;\n    typedef const_blas_data_mapper<Scalar, Index, RhsStorageOrder> RhsMapper;\n    typedef blas_data_mapper<typename Traits::ResScalar, Index, ColMajor> ResMapper;\n    LhsMapper lhs(_lhs,lhsStride);\n    RhsMapper rhs(_rhs,rhsStride);\n    ResMapper res(_res, resStride);\n\n    Index kc = blocking.kc();                   // cache block size along the K direction\n    Index mc = (std::min)(rows,blocking.mc());  // cache block size along the M direction\n\n    std::size_t sizeA = kc*mc;\n    std::size_t sizeB = kc*cols+EIGEN_MAX_ALIGN_BYTES/sizeof(Scalar);\n\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockA, sizeA, blocking.blockA());\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockB, sizeB, blocking.blockB());\n\n    Matrix<Scalar,SmallPanelWidth,SmallPanelWidth,RhsStorageOrder> triangularBuffer((internal::constructor_without_unaligned_array_assert()));\n    triangularBuffer.setZero();\n    if((Mode&ZeroDiag)==ZeroDiag)\n      triangularBuffer.diagonal().setZero();\n    else\n      triangularBuffer.diagonal().setOnes();\n\n    gebp_kernel<Scalar, Scalar, Index, ResMapper, Traits::mr, Traits::nr, ConjugateLhs, ConjugateRhs> gebp_kernel;\n    gemm_pack_lhs<Scalar, Index, LhsMapper, Traits::mr, Traits::LhsProgress, LhsStorageOrder> pack_lhs;\n    gemm_pack_rhs<Scalar, Index, RhsMapper, Traits::nr,RhsStorageOrder> pack_rhs;\n    gemm_pack_rhs<Scalar, Index, RhsMapper, Traits::nr,RhsStorageOrder,false,true> pack_rhs_panel;\n\n    for(Index k2=IsLower ? 0 : depth;\n        IsLower ? k2<depth  : k2>0;\n        IsLower ? k2+=kc   : k2-=kc)\n    {\n      Index actual_kc = (std::min)(IsLower ? depth-k2 : k2, kc);\n      Index actual_k2 = IsLower ? k2 : k2-actual_kc;\n\n      // align blocks with the end of the triangular part for trapezoidal rhs\n      if(IsLower && (k2<cols) && (actual_k2+actual_kc>cols))\n      {\n        actual_kc = cols-k2;\n        k2 = actual_k2 + actual_kc - kc;\n      }\n\n      // remaining size\n      Index rs = IsLower ? (std::min)(cols,actual_k2) : cols - k2;\n      // size of the triangular part\n      Index ts = (IsLower && actual_k2>=cols) ? 0 : actual_kc;\n\n      Scalar* geb = blockB+ts*ts;\n      geb = geb + internal::first_aligned<PacketBytes>(geb,PacketBytes/sizeof(Scalar));\n\n      pack_rhs(geb, rhs.getSubMapper(actual_k2,IsLower ? 0 : k2), actual_kc, rs);\n\n      // pack the triangular part of the rhs padding the unrolled blocks with zeros\n      if(ts>0)\n      {\n        for (Index j2=0; j2<actual_kc; j2+=SmallPanelWidth)\n        {\n          Index actualPanelWidth = std::min<Index>(actual_kc-j2, SmallPanelWidth);\n          Index actual_j2 = actual_k2 + j2;\n          Index panelOffset = IsLower ? j2+actualPanelWidth : 0;\n          Index panelLength = IsLower ? actual_kc-j2-actualPanelWidth : j2;\n          // general part\n          pack_rhs_panel(blockB+j2*actual_kc,\n                         rhs.getSubMapper(actual_k2+panelOffset, actual_j2),\n                         panelLength, actualPanelWidth,\n                         actual_kc, panelOffset);\n\n          // append the triangular part via a temporary buffer\n          for (Index j=0;j<actualPanelWidth;++j)\n          {\n            if (SetDiag)\n              triangularBuffer.coeffRef(j,j) = rhs(actual_j2+j,actual_j2+j);\n            for (Index k=IsLower ? j+1 : 0; IsLower ? k<actualPanelWidth : k<j; ++k)\n              triangularBuffer.coeffRef(k,j) = rhs(actual_j2+k,actual_j2+j);\n          }\n\n          pack_rhs_panel(blockB+j2*actual_kc,\n                         RhsMapper(triangularBuffer.data(), triangularBuffer.outerStride()),\n                         actualPanelWidth, actualPanelWidth,\n                         actual_kc, j2);\n        }\n      }\n\n      for (Index i2=0; i2<rows; i2+=mc)\n      {\n        const Index actual_mc = (std::min)(mc,rows-i2);\n        pack_lhs(blockA, lhs.getSubMapper(i2, actual_k2), actual_kc, actual_mc);\n\n        // triangular kernel\n        if(ts>0)\n        {\n          for (Index j2=0; j2<actual_kc; j2+=SmallPanelWidth)\n          {\n            Index actualPanelWidth = std::min<Index>(actual_kc-j2, SmallPanelWidth);\n            Index panelLength = IsLower ? actual_kc-j2 : j2+actualPanelWidth;\n            Index blockOffset = IsLower ? j2 : 0;\n\n            gebp_kernel(res.getSubMapper(i2, actual_k2 + j2),\n                        blockA, blockB+j2*actual_kc,\n                        actual_mc, panelLength, actualPanelWidth,\n                        alpha,\n                        actual_kc, actual_kc,  // strides\n                        blockOffset, blockOffset);// offsets\n          }\n        }\n        gebp_kernel(res.getSubMapper(i2, IsLower ? 0 : k2),\n                    blockA, geb, actual_mc, actual_kc, rs,\n                    alpha,\n                    -1, -1, 0, 0);\n      }\n    }\n  }\n\n/***************************************************************************\n* Wrapper to product_triangular_matrix_matrix\n***************************************************************************/\n\n} // end namespace internal\n\nnamespace internal {\ntemplate<int Mode, bool LhsIsTriangular, typename Lhs, typename Rhs>\nstruct triangular_product_impl<Mode,LhsIsTriangular,Lhs,false,Rhs,false>\n{\n  template<typename Dest> static void run(Dest& dst, const Lhs &a_lhs, const Rhs &a_rhs, const typename Dest::Scalar& alpha)\n  {\n    typedef typename Dest::Scalar     Scalar;\n    \n    typedef internal::blas_traits<Lhs> LhsBlasTraits;\n    typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;\n    typedef typename internal::remove_all<ActualLhsType>::type ActualLhsTypeCleaned;\n    typedef internal::blas_traits<Rhs> RhsBlasTraits;\n    typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;\n    typedef typename internal::remove_all<ActualRhsType>::type ActualRhsTypeCleaned;\n    \n    typename internal::add_const_on_value_type<ActualLhsType>::type lhs = LhsBlasTraits::extract(a_lhs);\n    typename internal::add_const_on_value_type<ActualRhsType>::type rhs = RhsBlasTraits::extract(a_rhs);\n\n    Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(a_lhs)\n                               * RhsBlasTraits::extractScalarFactor(a_rhs);\n\n    typedef internal::gemm_blocking_space<(Dest::Flags&RowMajorBit) ? RowMajor : ColMajor,Scalar,Scalar,\n              Lhs::MaxRowsAtCompileTime, Rhs::MaxColsAtCompileTime, Lhs::MaxColsAtCompileTime,4> BlockingType;\n\n    enum { IsLower = (Mode&Lower) == Lower };\n    Index stripedRows  = ((!LhsIsTriangular) || (IsLower))  ? lhs.rows() : (std::min)(lhs.rows(),lhs.cols());\n    Index stripedCols  = ((LhsIsTriangular)  || (!IsLower)) ? rhs.cols() : (std::min)(rhs.cols(),rhs.rows());\n    Index stripedDepth = LhsIsTriangular ? ((!IsLower) ? lhs.cols() : (std::min)(lhs.cols(),lhs.rows()))\n                                         : ((IsLower)  ? rhs.rows() : (std::min)(rhs.rows(),rhs.cols()));\n\n    BlockingType blocking(stripedRows, stripedCols, stripedDepth, 1, false);\n\n    internal::product_triangular_matrix_matrix<Scalar, Index,\n      Mode, LhsIsTriangular,\n      (internal::traits<ActualLhsTypeCleaned>::Flags&RowMajorBit) ? RowMajor : ColMajor, LhsBlasTraits::NeedToConjugate,\n      (internal::traits<ActualRhsTypeCleaned>::Flags&RowMajorBit) ? RowMajor : ColMajor, RhsBlasTraits::NeedToConjugate,\n      (internal::traits<Dest          >::Flags&RowMajorBit) ? RowMajor : ColMajor>\n      ::run(\n        stripedRows, stripedCols, stripedDepth,   // sizes\n        &lhs.coeffRef(0,0), lhs.outerStride(),    // lhs info\n        &rhs.coeffRef(0,0), rhs.outerStride(),    // rhs info\n        &dst.coeffRef(0,0), dst.outerStride(),    // result info\n        actualAlpha, blocking\n      );\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRIANGULAR_MATRIX_MATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to BLAS F77\n *   Triangular matrix * matrix product functionality based on ?TRMM.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_TRIANGULAR_MATRIX_MATRIX_BLAS_H\n#define EIGEN_TRIANGULAR_MATRIX_MATRIX_BLAS_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n\ntemplate <typename Scalar, typename Index,\n          int Mode, bool LhsIsTriangular,\n          int LhsStorageOrder, bool ConjugateLhs,\n          int RhsStorageOrder, bool ConjugateRhs,\n          int ResStorageOrder>\nstruct product_triangular_matrix_matrix_trmm :\n       product_triangular_matrix_matrix<Scalar,Index,Mode,\n          LhsIsTriangular,LhsStorageOrder,ConjugateLhs,\n          RhsStorageOrder, ConjugateRhs, ResStorageOrder, BuiltIn> {};\n\n\n// try to go to BLAS specialization\n#define EIGEN_BLAS_TRMM_SPECIALIZE(Scalar, LhsIsTriangular) \\\ntemplate <typename Index, int Mode, \\\n          int LhsStorageOrder, bool ConjugateLhs, \\\n          int RhsStorageOrder, bool ConjugateRhs> \\\nstruct product_triangular_matrix_matrix<Scalar,Index, Mode, LhsIsTriangular, \\\n           LhsStorageOrder,ConjugateLhs, RhsStorageOrder,ConjugateRhs,ColMajor,Specialized> { \\\n  static inline void run(Index _rows, Index _cols, Index _depth, const Scalar* _lhs, Index lhsStride,\\\n    const Scalar* _rhs, Index rhsStride, Scalar* res, Index resStride, Scalar alpha, level3_blocking<Scalar,Scalar>& blocking) { \\\n      product_triangular_matrix_matrix_trmm<Scalar,Index,Mode, \\\n        LhsIsTriangular,LhsStorageOrder,ConjugateLhs, \\\n        RhsStorageOrder, ConjugateRhs, ColMajor>::run( \\\n        _rows, _cols, _depth, _lhs, lhsStride, _rhs, rhsStride, res, resStride, alpha, blocking); \\\n  } \\\n};\n\nEIGEN_BLAS_TRMM_SPECIALIZE(double, true)\nEIGEN_BLAS_TRMM_SPECIALIZE(double, false)\nEIGEN_BLAS_TRMM_SPECIALIZE(dcomplex, true)\nEIGEN_BLAS_TRMM_SPECIALIZE(dcomplex, false)\nEIGEN_BLAS_TRMM_SPECIALIZE(float, true)\nEIGEN_BLAS_TRMM_SPECIALIZE(float, false)\nEIGEN_BLAS_TRMM_SPECIALIZE(scomplex, true)\nEIGEN_BLAS_TRMM_SPECIALIZE(scomplex, false)\n\n// implements col-major += alpha * op(triangular) * op(general)\n#define EIGEN_BLAS_TRMM_L(EIGTYPE, BLASTYPE, EIGPREFIX, BLASPREFIX) \\\ntemplate <typename Index, int Mode, \\\n          int LhsStorageOrder, bool ConjugateLhs, \\\n          int RhsStorageOrder, bool ConjugateRhs> \\\nstruct product_triangular_matrix_matrix_trmm<EIGTYPE,Index,Mode,true, \\\n         LhsStorageOrder,ConjugateLhs,RhsStorageOrder,ConjugateRhs,ColMajor> \\\n{ \\\n  enum { \\\n    IsLower = (Mode&Lower) == Lower, \\\n    SetDiag = (Mode&(ZeroDiag|UnitDiag)) ? 0 : 1, \\\n    IsUnitDiag  = (Mode&UnitDiag) ? 1 : 0, \\\n    IsZeroDiag  = (Mode&ZeroDiag) ? 1 : 0, \\\n    LowUp = IsLower ? Lower : Upper, \\\n    conjA = ((LhsStorageOrder==ColMajor) && ConjugateLhs) ? 1 : 0 \\\n  }; \\\n\\\n  static void run( \\\n    Index _rows, Index _cols, Index _depth, \\\n    const EIGTYPE* _lhs, Index lhsStride, \\\n    const EIGTYPE* _rhs, Index rhsStride, \\\n    EIGTYPE* res,        Index resStride, \\\n    EIGTYPE alpha, level3_blocking<EIGTYPE,EIGTYPE>& blocking) \\\n  { \\\n   Index diagSize  = (std::min)(_rows,_depth); \\\n   Index rows      = IsLower ? _rows : diagSize; \\\n   Index depth     = IsLower ? diagSize : _depth; \\\n   Index cols      = _cols; \\\n\\\n   typedef Matrix<EIGTYPE, Dynamic, Dynamic, LhsStorageOrder> MatrixLhs; \\\n   typedef Matrix<EIGTYPE, Dynamic, Dynamic, RhsStorageOrder> MatrixRhs; \\\n\\\n/* Non-square case - doesn't fit to BLAS ?TRMM. Fall to default triangular product or call BLAS ?GEMM*/ \\\n   if (rows != depth) { \\\n\\\n     /* FIXME handle mkl_domain_get_max_threads */ \\\n     /*int nthr = mkl_domain_get_max_threads(EIGEN_BLAS_DOMAIN_BLAS);*/ int nthr = 1;\\\n\\\n     if (((nthr==1) && (((std::max)(rows,depth)-diagSize)/(double)diagSize < 0.5))) { \\\n     /* Most likely no benefit to call TRMM or GEMM from BLAS */ \\\n       product_triangular_matrix_matrix<EIGTYPE,Index,Mode,true, \\\n       LhsStorageOrder,ConjugateLhs, RhsStorageOrder, ConjugateRhs, ColMajor, BuiltIn>::run( \\\n           _rows, _cols, _depth, _lhs, lhsStride, _rhs, rhsStride, res, resStride, alpha, blocking); \\\n     /*std::cout << \"TRMM_L: A is not square! Go to Eigen TRMM implementation!\\n\";*/ \\\n     } else { \\\n     /* Make sense to call GEMM */ \\\n       Map<const MatrixLhs, 0, OuterStride<> > lhsMap(_lhs,rows,depth,OuterStride<>(lhsStride)); \\\n       MatrixLhs aa_tmp=lhsMap.template triangularView<Mode>(); \\\n       BlasIndex aStride = convert_index<BlasIndex>(aa_tmp.outerStride()); \\\n       gemm_blocking_space<ColMajor,EIGTYPE,EIGTYPE,Dynamic,Dynamic,Dynamic> gemm_blocking(_rows,_cols,_depth, 1, true); \\\n       general_matrix_matrix_product<Index,EIGTYPE,LhsStorageOrder,ConjugateLhs,EIGTYPE,RhsStorageOrder,ConjugateRhs,ColMajor>::run( \\\n       rows, cols, depth, aa_tmp.data(), aStride, _rhs, rhsStride, res, resStride, alpha, gemm_blocking, 0); \\\n\\\n     /*std::cout << \"TRMM_L: A is not square! Go to BLAS GEMM implementation! \" << nthr<<\" \\n\";*/ \\\n     } \\\n     return; \\\n   } \\\n   char side = 'L', transa, uplo, diag = 'N'; \\\n   EIGTYPE *b; \\\n   const EIGTYPE *a; \\\n   BlasIndex m, n, lda, ldb; \\\n\\\n/* Set m, n */ \\\n   m = convert_index<BlasIndex>(diagSize); \\\n   n = convert_index<BlasIndex>(cols); \\\n\\\n/* Set trans */ \\\n   transa = (LhsStorageOrder==RowMajor) ? ((ConjugateLhs) ? 'C' : 'T') : 'N'; \\\n\\\n/* Set b, ldb */ \\\n   Map<const MatrixRhs, 0, OuterStride<> > rhs(_rhs,depth,cols,OuterStride<>(rhsStride)); \\\n   MatrixX##EIGPREFIX b_tmp; \\\n\\\n   if (ConjugateRhs) b_tmp = rhs.conjugate(); else b_tmp = rhs; \\\n   b = b_tmp.data(); \\\n   ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \\\n\\\n/* Set uplo */ \\\n   uplo = IsLower ? 'L' : 'U'; \\\n   if (LhsStorageOrder==RowMajor) uplo = (uplo == 'L') ? 'U' : 'L'; \\\n/* Set a, lda */ \\\n   Map<const MatrixLhs, 0, OuterStride<> > lhs(_lhs,rows,depth,OuterStride<>(lhsStride)); \\\n   MatrixLhs a_tmp; \\\n\\\n   if ((conjA!=0) || (SetDiag==0)) { \\\n     if (conjA) a_tmp = lhs.conjugate(); else a_tmp = lhs; \\\n     if (IsZeroDiag) \\\n       a_tmp.diagonal().setZero(); \\\n     else if (IsUnitDiag) \\\n       a_tmp.diagonal().setOnes();\\\n     a = a_tmp.data(); \\\n     lda = convert_index<BlasIndex>(a_tmp.outerStride()); \\\n   } else { \\\n     a = _lhs; \\\n     lda = convert_index<BlasIndex>(lhsStride); \\\n   } \\\n   /*std::cout << \"TRMM_L: A is square! Go to BLAS TRMM implementation! \\n\";*/ \\\n/* call ?trmm*/ \\\n   BLASPREFIX##trmm_(&side, &uplo, &transa, &diag, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (BLASTYPE*)b, &ldb); \\\n\\\n/* Add op(a_triangular)*b into res*/ \\\n   Map<MatrixX##EIGPREFIX, 0, OuterStride<> > res_tmp(res,rows,cols,OuterStride<>(resStride)); \\\n   res_tmp=res_tmp+b_tmp; \\\n  } \\\n};\n\nEIGEN_BLAS_TRMM_L(double, double, d, d)\nEIGEN_BLAS_TRMM_L(dcomplex, double, cd, z)\nEIGEN_BLAS_TRMM_L(float, float, f, s)\nEIGEN_BLAS_TRMM_L(scomplex, float, cf, c)\n\n// implements col-major += alpha * op(general) * op(triangular)\n#define EIGEN_BLAS_TRMM_R(EIGTYPE, BLASTYPE, EIGPREFIX, BLASPREFIX) \\\ntemplate <typename Index, int Mode, \\\n          int LhsStorageOrder, bool ConjugateLhs, \\\n          int RhsStorageOrder, bool ConjugateRhs> \\\nstruct product_triangular_matrix_matrix_trmm<EIGTYPE,Index,Mode,false, \\\n         LhsStorageOrder,ConjugateLhs,RhsStorageOrder,ConjugateRhs,ColMajor> \\\n{ \\\n  enum { \\\n    IsLower = (Mode&Lower) == Lower, \\\n    SetDiag = (Mode&(ZeroDiag|UnitDiag)) ? 0 : 1, \\\n    IsUnitDiag  = (Mode&UnitDiag) ? 1 : 0, \\\n    IsZeroDiag  = (Mode&ZeroDiag) ? 1 : 0, \\\n    LowUp = IsLower ? Lower : Upper, \\\n    conjA = ((RhsStorageOrder==ColMajor) && ConjugateRhs) ? 1 : 0 \\\n  }; \\\n\\\n  static void run( \\\n    Index _rows, Index _cols, Index _depth, \\\n    const EIGTYPE* _lhs, Index lhsStride, \\\n    const EIGTYPE* _rhs, Index rhsStride, \\\n    EIGTYPE* res,        Index resStride, \\\n    EIGTYPE alpha, level3_blocking<EIGTYPE,EIGTYPE>& blocking) \\\n  { \\\n   Index diagSize  = (std::min)(_cols,_depth); \\\n   Index rows      = _rows; \\\n   Index depth     = IsLower ? _depth : diagSize; \\\n   Index cols      = IsLower ? diagSize : _cols; \\\n\\\n   typedef Matrix<EIGTYPE, Dynamic, Dynamic, LhsStorageOrder> MatrixLhs; \\\n   typedef Matrix<EIGTYPE, Dynamic, Dynamic, RhsStorageOrder> MatrixRhs; \\\n\\\n/* Non-square case - doesn't fit to BLAS ?TRMM. Fall to default triangular product or call BLAS ?GEMM*/ \\\n   if (cols != depth) { \\\n\\\n     int nthr = 1 /*mkl_domain_get_max_threads(EIGEN_BLAS_DOMAIN_BLAS)*/; \\\n\\\n     if ((nthr==1) && (((std::max)(cols,depth)-diagSize)/(double)diagSize < 0.5)) { \\\n     /* Most likely no benefit to call TRMM or GEMM from BLAS*/ \\\n       product_triangular_matrix_matrix<EIGTYPE,Index,Mode,false, \\\n       LhsStorageOrder,ConjugateLhs, RhsStorageOrder, ConjugateRhs, ColMajor, BuiltIn>::run( \\\n           _rows, _cols, _depth, _lhs, lhsStride, _rhs, rhsStride, res, resStride, alpha, blocking); \\\n       /*std::cout << \"TRMM_R: A is not square! Go to Eigen TRMM implementation!\\n\";*/ \\\n     } else { \\\n     /* Make sense to call GEMM */ \\\n       Map<const MatrixRhs, 0, OuterStride<> > rhsMap(_rhs,depth,cols, OuterStride<>(rhsStride)); \\\n       MatrixRhs aa_tmp=rhsMap.template triangularView<Mode>(); \\\n       BlasIndex aStride = convert_index<BlasIndex>(aa_tmp.outerStride()); \\\n       gemm_blocking_space<ColMajor,EIGTYPE,EIGTYPE,Dynamic,Dynamic,Dynamic> gemm_blocking(_rows,_cols,_depth, 1, true); \\\n       general_matrix_matrix_product<Index,EIGTYPE,LhsStorageOrder,ConjugateLhs,EIGTYPE,RhsStorageOrder,ConjugateRhs,ColMajor>::run( \\\n       rows, cols, depth, _lhs, lhsStride, aa_tmp.data(), aStride, res, resStride, alpha, gemm_blocking, 0); \\\n\\\n     /*std::cout << \"TRMM_R: A is not square! Go to BLAS GEMM implementation! \" << nthr<<\" \\n\";*/ \\\n     } \\\n     return; \\\n   } \\\n   char side = 'R', transa, uplo, diag = 'N'; \\\n   EIGTYPE *b; \\\n   const EIGTYPE *a; \\\n   BlasIndex m, n, lda, ldb; \\\n\\\n/* Set m, n */ \\\n   m = convert_index<BlasIndex>(rows); \\\n   n = convert_index<BlasIndex>(diagSize); \\\n\\\n/* Set trans */ \\\n   transa = (RhsStorageOrder==RowMajor) ? ((ConjugateRhs) ? 'C' : 'T') : 'N'; \\\n\\\n/* Set b, ldb */ \\\n   Map<const MatrixLhs, 0, OuterStride<> > lhs(_lhs,rows,depth,OuterStride<>(lhsStride)); \\\n   MatrixX##EIGPREFIX b_tmp; \\\n\\\n   if (ConjugateLhs) b_tmp = lhs.conjugate(); else b_tmp = lhs; \\\n   b = b_tmp.data(); \\\n   ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \\\n\\\n/* Set uplo */ \\\n   uplo = IsLower ? 'L' : 'U'; \\\n   if (RhsStorageOrder==RowMajor) uplo = (uplo == 'L') ? 'U' : 'L'; \\\n/* Set a, lda */ \\\n   Map<const MatrixRhs, 0, OuterStride<> > rhs(_rhs,depth,cols, OuterStride<>(rhsStride)); \\\n   MatrixRhs a_tmp; \\\n\\\n   if ((conjA!=0) || (SetDiag==0)) { \\\n     if (conjA) a_tmp = rhs.conjugate(); else a_tmp = rhs; \\\n     if (IsZeroDiag) \\\n       a_tmp.diagonal().setZero(); \\\n     else if (IsUnitDiag) \\\n       a_tmp.diagonal().setOnes();\\\n     a = a_tmp.data(); \\\n     lda = convert_index<BlasIndex>(a_tmp.outerStride()); \\\n   } else { \\\n     a = _rhs; \\\n     lda = convert_index<BlasIndex>(rhsStride); \\\n   } \\\n   /*std::cout << \"TRMM_R: A is square! Go to BLAS TRMM implementation! \\n\";*/ \\\n/* call ?trmm*/ \\\n   BLASPREFIX##trmm_(&side, &uplo, &transa, &diag, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (BLASTYPE*)b, &ldb); \\\n\\\n/* Add op(a_triangular)*b into res*/ \\\n   Map<MatrixX##EIGPREFIX, 0, OuterStride<> > res_tmp(res,rows,cols,OuterStride<>(resStride)); \\\n   res_tmp=res_tmp+b_tmp; \\\n  } \\\n};\n\nEIGEN_BLAS_TRMM_R(double, double, d, d)\nEIGEN_BLAS_TRMM_R(dcomplex, double, cd, z)\nEIGEN_BLAS_TRMM_R(float, float, f, s)\nEIGEN_BLAS_TRMM_R(scomplex, float, cf, c)\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRIANGULAR_MATRIX_MATRIX_BLAS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/TriangularMatrixVector.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TRIANGULARMATRIXVECTOR_H\n#define EIGEN_TRIANGULARMATRIXVECTOR_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<typename Index, int Mode, typename LhsScalar, bool ConjLhs, typename RhsScalar, bool ConjRhs, int StorageOrder, int Version=Specialized>\nstruct triangular_matrix_vector_product;\n\ntemplate<typename Index, int Mode, typename LhsScalar, bool ConjLhs, typename RhsScalar, bool ConjRhs, int Version>\nstruct triangular_matrix_vector_product<Index,Mode,LhsScalar,ConjLhs,RhsScalar,ConjRhs,ColMajor,Version>\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType ResScalar;\n  enum {\n    IsLower = ((Mode&Lower)==Lower),\n    HasUnitDiag = (Mode & UnitDiag)==UnitDiag,\n    HasZeroDiag = (Mode & ZeroDiag)==ZeroDiag\n  };\n  static EIGEN_DONT_INLINE  void run(Index _rows, Index _cols, const LhsScalar* _lhs, Index lhsStride,\n                                     const RhsScalar* _rhs, Index rhsIncr, ResScalar* _res, Index resIncr, const RhsScalar& alpha);\n};\n\ntemplate<typename Index, int Mode, typename LhsScalar, bool ConjLhs, typename RhsScalar, bool ConjRhs, int Version>\nEIGEN_DONT_INLINE void triangular_matrix_vector_product<Index,Mode,LhsScalar,ConjLhs,RhsScalar,ConjRhs,ColMajor,Version>\n  ::run(Index _rows, Index _cols, const LhsScalar* _lhs, Index lhsStride,\n        const RhsScalar* _rhs, Index rhsIncr, ResScalar* _res, Index resIncr, const RhsScalar& alpha)\n  {\n    static const Index PanelWidth = EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH;\n    Index size = (std::min)(_rows,_cols);\n    Index rows = IsLower ? _rows : (std::min)(_rows,_cols);\n    Index cols = IsLower ? (std::min)(_rows,_cols) : _cols;\n\n    typedef Map<const Matrix<LhsScalar,Dynamic,Dynamic,ColMajor>, 0, OuterStride<> > LhsMap;\n    const LhsMap lhs(_lhs,rows,cols,OuterStride<>(lhsStride));\n    typename conj_expr_if<ConjLhs,LhsMap>::type cjLhs(lhs);\n\n    typedef Map<const Matrix<RhsScalar,Dynamic,1>, 0, InnerStride<> > RhsMap;\n    const RhsMap rhs(_rhs,cols,InnerStride<>(rhsIncr));\n    typename conj_expr_if<ConjRhs,RhsMap>::type cjRhs(rhs);\n\n    typedef Map<Matrix<ResScalar,Dynamic,1> > ResMap;\n    ResMap res(_res,rows);\n\n    typedef const_blas_data_mapper<LhsScalar,Index,ColMajor> LhsMapper;\n    typedef const_blas_data_mapper<RhsScalar,Index,RowMajor> RhsMapper;\n\n    for (Index pi=0; pi<size; pi+=PanelWidth)\n    {\n      Index actualPanelWidth = (std::min)(PanelWidth, size-pi);\n      for (Index k=0; k<actualPanelWidth; ++k)\n      {\n        Index i = pi + k;\n        Index s = IsLower ? ((HasUnitDiag||HasZeroDiag) ? i+1 : i ) : pi;\n        Index r = IsLower ? actualPanelWidth-k : k+1;\n        if ((!(HasUnitDiag||HasZeroDiag)) || (--r)>0)\n          res.segment(s,r) += (alpha * cjRhs.coeff(i)) * cjLhs.col(i).segment(s,r);\n        if (HasUnitDiag)\n          res.coeffRef(i) += alpha * cjRhs.coeff(i);\n      }\n      Index r = IsLower ? rows - pi - actualPanelWidth : pi;\n      if (r>0)\n      {\n        Index s = IsLower ? pi+actualPanelWidth : 0;\n        general_matrix_vector_product<Index,LhsScalar,LhsMapper,ColMajor,ConjLhs,RhsScalar,RhsMapper,ConjRhs,BuiltIn>::run(\n            r, actualPanelWidth,\n            LhsMapper(&lhs.coeffRef(s,pi), lhsStride),\n            RhsMapper(&rhs.coeffRef(pi), rhsIncr),\n            &res.coeffRef(s), resIncr, alpha);\n      }\n    }\n    if((!IsLower) && cols>size)\n    {\n      general_matrix_vector_product<Index,LhsScalar,LhsMapper,ColMajor,ConjLhs,RhsScalar,RhsMapper,ConjRhs>::run(\n          rows, cols-size,\n          LhsMapper(&lhs.coeffRef(0,size), lhsStride),\n          RhsMapper(&rhs.coeffRef(size), rhsIncr),\n          _res, resIncr, alpha);\n    }\n  }\n\ntemplate<typename Index, int Mode, typename LhsScalar, bool ConjLhs, typename RhsScalar, bool ConjRhs,int Version>\nstruct triangular_matrix_vector_product<Index,Mode,LhsScalar,ConjLhs,RhsScalar,ConjRhs,RowMajor,Version>\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType ResScalar;\n  enum {\n    IsLower = ((Mode&Lower)==Lower),\n    HasUnitDiag = (Mode & UnitDiag)==UnitDiag,\n    HasZeroDiag = (Mode & ZeroDiag)==ZeroDiag\n  };\n  static EIGEN_DONT_INLINE void run(Index _rows, Index _cols, const LhsScalar* _lhs, Index lhsStride,\n                                    const RhsScalar* _rhs, Index rhsIncr, ResScalar* _res, Index resIncr, const ResScalar& alpha);\n};\n\ntemplate<typename Index, int Mode, typename LhsScalar, bool ConjLhs, typename RhsScalar, bool ConjRhs,int Version>\nEIGEN_DONT_INLINE void triangular_matrix_vector_product<Index,Mode,LhsScalar,ConjLhs,RhsScalar,ConjRhs,RowMajor,Version>\n  ::run(Index _rows, Index _cols, const LhsScalar* _lhs, Index lhsStride,\n        const RhsScalar* _rhs, Index rhsIncr, ResScalar* _res, Index resIncr, const ResScalar& alpha)\n  {\n    static const Index PanelWidth = EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH;\n    Index diagSize = (std::min)(_rows,_cols);\n    Index rows = IsLower ? _rows : diagSize;\n    Index cols = IsLower ? diagSize : _cols;\n\n    typedef Map<const Matrix<LhsScalar,Dynamic,Dynamic,RowMajor>, 0, OuterStride<> > LhsMap;\n    const LhsMap lhs(_lhs,rows,cols,OuterStride<>(lhsStride));\n    typename conj_expr_if<ConjLhs,LhsMap>::type cjLhs(lhs);\n\n    typedef Map<const Matrix<RhsScalar,Dynamic,1> > RhsMap;\n    const RhsMap rhs(_rhs,cols);\n    typename conj_expr_if<ConjRhs,RhsMap>::type cjRhs(rhs);\n\n    typedef Map<Matrix<ResScalar,Dynamic,1>, 0, InnerStride<> > ResMap;\n    ResMap res(_res,rows,InnerStride<>(resIncr));\n\n    typedef const_blas_data_mapper<LhsScalar,Index,RowMajor> LhsMapper;\n    typedef const_blas_data_mapper<RhsScalar,Index,RowMajor> RhsMapper;\n\n    for (Index pi=0; pi<diagSize; pi+=PanelWidth)\n    {\n      Index actualPanelWidth = (std::min)(PanelWidth, diagSize-pi);\n      for (Index k=0; k<actualPanelWidth; ++k)\n      {\n        Index i = pi + k;\n        Index s = IsLower ? pi  : ((HasUnitDiag||HasZeroDiag) ? i+1 : i);\n        Index r = IsLower ? k+1 : actualPanelWidth-k;\n        if ((!(HasUnitDiag||HasZeroDiag)) || (--r)>0)\n          res.coeffRef(i) += alpha * (cjLhs.row(i).segment(s,r).cwiseProduct(cjRhs.segment(s,r).transpose())).sum();\n        if (HasUnitDiag)\n          res.coeffRef(i) += alpha * cjRhs.coeff(i);\n      }\n      Index r = IsLower ? pi : cols - pi - actualPanelWidth;\n      if (r>0)\n      {\n        Index s = IsLower ? 0 : pi + actualPanelWidth;\n        general_matrix_vector_product<Index,LhsScalar,LhsMapper,RowMajor,ConjLhs,RhsScalar,RhsMapper,ConjRhs,BuiltIn>::run(\n            actualPanelWidth, r,\n            LhsMapper(&lhs.coeffRef(pi,s), lhsStride),\n            RhsMapper(&rhs.coeffRef(s), rhsIncr),\n            &res.coeffRef(pi), resIncr, alpha);\n      }\n    }\n    if(IsLower && rows>diagSize)\n    {\n      general_matrix_vector_product<Index,LhsScalar,LhsMapper,RowMajor,ConjLhs,RhsScalar,RhsMapper,ConjRhs>::run(\n            rows-diagSize, cols,\n            LhsMapper(&lhs.coeffRef(diagSize,0), lhsStride),\n            RhsMapper(&rhs.coeffRef(0), rhsIncr),\n            &res.coeffRef(diagSize), resIncr, alpha);\n    }\n  }\n\n/***************************************************************************\n* Wrapper to product_triangular_vector\n***************************************************************************/\n\ntemplate<int Mode,int StorageOrder>\nstruct trmv_selector;\n\n} // end namespace internal\n\nnamespace internal {\n\ntemplate<int Mode, typename Lhs, typename Rhs>\nstruct triangular_product_impl<Mode,true,Lhs,false,Rhs,true>\n{\n  template<typename Dest> static void run(Dest& dst, const Lhs &lhs, const Rhs &rhs, const typename Dest::Scalar& alpha)\n  {\n    eigen_assert(dst.rows()==lhs.rows() && dst.cols()==rhs.cols());\n  \n    internal::trmv_selector<Mode,(int(internal::traits<Lhs>::Flags)&RowMajorBit) ? RowMajor : ColMajor>::run(lhs, rhs, dst, alpha);\n  }\n};\n\ntemplate<int Mode, typename Lhs, typename Rhs>\nstruct triangular_product_impl<Mode,false,Lhs,true,Rhs,false>\n{\n  template<typename Dest> static void run(Dest& dst, const Lhs &lhs, const Rhs &rhs, const typename Dest::Scalar& alpha)\n  {\n    eigen_assert(dst.rows()==lhs.rows() && dst.cols()==rhs.cols());\n\n    Transpose<Dest> dstT(dst);\n    internal::trmv_selector<(Mode & (UnitDiag|ZeroDiag)) | ((Mode & Lower) ? Upper : Lower),\n                            (int(internal::traits<Rhs>::Flags)&RowMajorBit) ? ColMajor : RowMajor>\n            ::run(rhs.transpose(),lhs.transpose(), dstT, alpha);\n  }\n};\n\n} // end namespace internal\n\nnamespace internal {\n\n// TODO: find a way to factorize this piece of code with gemv_selector since the logic is exactly the same.\n  \ntemplate<int Mode> struct trmv_selector<Mode,ColMajor>\n{\n  template<typename Lhs, typename Rhs, typename Dest>\n  static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)\n  {\n    typedef typename Lhs::Scalar      LhsScalar;\n    typedef typename Rhs::Scalar      RhsScalar;\n    typedef typename Dest::Scalar     ResScalar;\n    typedef typename Dest::RealScalar RealScalar;\n    \n    typedef internal::blas_traits<Lhs> LhsBlasTraits;\n    typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;\n    typedef internal::blas_traits<Rhs> RhsBlasTraits;\n    typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;\n    \n    typedef Map<Matrix<ResScalar,Dynamic,1>, EIGEN_PLAIN_ENUM_MIN(AlignedMax,internal::packet_traits<ResScalar>::size)> MappedDest;\n\n    typename internal::add_const_on_value_type<ActualLhsType>::type actualLhs = LhsBlasTraits::extract(lhs);\n    typename internal::add_const_on_value_type<ActualRhsType>::type actualRhs = RhsBlasTraits::extract(rhs);\n\n    ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(lhs)\n                                  * RhsBlasTraits::extractScalarFactor(rhs);\n\n    enum {\n      // FIXME find a way to allow an inner stride on the result if packet_traits<Scalar>::size==1\n      // on, the other hand it is good for the cache to pack the vector anyways...\n      EvalToDestAtCompileTime = Dest::InnerStrideAtCompileTime==1,\n      ComplexByReal = (NumTraits<LhsScalar>::IsComplex) && (!NumTraits<RhsScalar>::IsComplex),\n      MightCannotUseDest = (Dest::InnerStrideAtCompileTime!=1) || ComplexByReal\n    };\n\n    gemv_static_vector_if<ResScalar,Dest::SizeAtCompileTime,Dest::MaxSizeAtCompileTime,MightCannotUseDest> static_dest;\n\n    bool alphaIsCompatible = (!ComplexByReal) || (numext::imag(actualAlpha)==RealScalar(0));\n    bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;\n\n    RhsScalar compatibleAlpha = get_factor<ResScalar,RhsScalar>::run(actualAlpha);\n\n    ei_declare_aligned_stack_constructed_variable(ResScalar,actualDestPtr,dest.size(),\n                                                  evalToDest ? dest.data() : static_dest.data());\n\n    if(!evalToDest)\n    {\n      #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n      Index size = dest.size();\n      EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n      #endif\n      if(!alphaIsCompatible)\n      {\n        MappedDest(actualDestPtr, dest.size()).setZero();\n        compatibleAlpha = RhsScalar(1);\n      }\n      else\n        MappedDest(actualDestPtr, dest.size()) = dest;\n    }\n\n    internal::triangular_matrix_vector_product\n      <Index,Mode,\n       LhsScalar, LhsBlasTraits::NeedToConjugate,\n       RhsScalar, RhsBlasTraits::NeedToConjugate,\n       ColMajor>\n      ::run(actualLhs.rows(),actualLhs.cols(),\n            actualLhs.data(),actualLhs.outerStride(),\n            actualRhs.data(),actualRhs.innerStride(),\n            actualDestPtr,1,compatibleAlpha);\n\n    if (!evalToDest)\n    {\n      if(!alphaIsCompatible)\n        dest += actualAlpha * MappedDest(actualDestPtr, dest.size());\n      else\n        dest = MappedDest(actualDestPtr, dest.size());\n    }\n  }\n};\n\ntemplate<int Mode> struct trmv_selector<Mode,RowMajor>\n{\n  template<typename Lhs, typename Rhs, typename Dest>\n  static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)\n  {\n    typedef typename Lhs::Scalar      LhsScalar;\n    typedef typename Rhs::Scalar      RhsScalar;\n    typedef typename Dest::Scalar     ResScalar;\n    \n    typedef internal::blas_traits<Lhs> LhsBlasTraits;\n    typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;\n    typedef internal::blas_traits<Rhs> RhsBlasTraits;\n    typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;\n    typedef typename internal::remove_all<ActualRhsType>::type ActualRhsTypeCleaned;\n\n    typename add_const<ActualLhsType>::type actualLhs = LhsBlasTraits::extract(lhs);\n    typename add_const<ActualRhsType>::type actualRhs = RhsBlasTraits::extract(rhs);\n\n    ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(lhs)\n                                  * RhsBlasTraits::extractScalarFactor(rhs);\n\n    enum {\n      DirectlyUseRhs = ActualRhsTypeCleaned::InnerStrideAtCompileTime==1\n    };\n\n    gemv_static_vector_if<RhsScalar,ActualRhsTypeCleaned::SizeAtCompileTime,ActualRhsTypeCleaned::MaxSizeAtCompileTime,!DirectlyUseRhs> static_rhs;\n\n    ei_declare_aligned_stack_constructed_variable(RhsScalar,actualRhsPtr,actualRhs.size(),\n        DirectlyUseRhs ? const_cast<RhsScalar*>(actualRhs.data()) : static_rhs.data());\n\n    if(!DirectlyUseRhs)\n    {\n      #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n      Index size = actualRhs.size();\n      EIGEN_DENSE_STORAGE_CTOR_PLUGIN\n      #endif\n      Map<typename ActualRhsTypeCleaned::PlainObject>(actualRhsPtr, actualRhs.size()) = actualRhs;\n    }\n\n    internal::triangular_matrix_vector_product\n      <Index,Mode,\n       LhsScalar, LhsBlasTraits::NeedToConjugate,\n       RhsScalar, RhsBlasTraits::NeedToConjugate,\n       RowMajor>\n      ::run(actualLhs.rows(),actualLhs.cols(),\n            actualLhs.data(),actualLhs.outerStride(),\n            actualRhsPtr,1,\n            dest.data(),dest.innerStride(),\n            actualAlpha);\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRIANGULARMATRIXVECTOR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to BLAS F77\n *   Triangular matrix-vector product functionality based on ?TRMV.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_TRIANGULAR_MATRIX_VECTOR_BLAS_H\n#define EIGEN_TRIANGULAR_MATRIX_VECTOR_BLAS_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/**********************************************************************\n* This file implements triangular matrix-vector multiplication using BLAS\n**********************************************************************/\n\n// trmv/hemv specialization\n\ntemplate<typename Index, int Mode, typename LhsScalar, bool ConjLhs, typename RhsScalar, bool ConjRhs, int StorageOrder>\nstruct triangular_matrix_vector_product_trmv :\n  triangular_matrix_vector_product<Index,Mode,LhsScalar,ConjLhs,RhsScalar,ConjRhs,StorageOrder,BuiltIn> {};\n\n#define EIGEN_BLAS_TRMV_SPECIALIZE(Scalar) \\\ntemplate<typename Index, int Mode, bool ConjLhs, bool ConjRhs> \\\nstruct triangular_matrix_vector_product<Index,Mode,Scalar,ConjLhs,Scalar,ConjRhs,ColMajor,Specialized> { \\\n static void run(Index _rows, Index _cols, const Scalar* _lhs, Index lhsStride, \\\n                                     const Scalar* _rhs, Index rhsIncr, Scalar* _res, Index resIncr, Scalar alpha) { \\\n      triangular_matrix_vector_product_trmv<Index,Mode,Scalar,ConjLhs,Scalar,ConjRhs,ColMajor>::run( \\\n        _rows, _cols, _lhs, lhsStride, _rhs, rhsIncr, _res, resIncr, alpha); \\\n  } \\\n}; \\\ntemplate<typename Index, int Mode, bool ConjLhs, bool ConjRhs> \\\nstruct triangular_matrix_vector_product<Index,Mode,Scalar,ConjLhs,Scalar,ConjRhs,RowMajor,Specialized> { \\\n static void run(Index _rows, Index _cols, const Scalar* _lhs, Index lhsStride, \\\n                                     const Scalar* _rhs, Index rhsIncr, Scalar* _res, Index resIncr, Scalar alpha) { \\\n      triangular_matrix_vector_product_trmv<Index,Mode,Scalar,ConjLhs,Scalar,ConjRhs,RowMajor>::run( \\\n        _rows, _cols, _lhs, lhsStride, _rhs, rhsIncr, _res, resIncr, alpha); \\\n  } \\\n};\n\nEIGEN_BLAS_TRMV_SPECIALIZE(double)\nEIGEN_BLAS_TRMV_SPECIALIZE(float)\nEIGEN_BLAS_TRMV_SPECIALIZE(dcomplex)\nEIGEN_BLAS_TRMV_SPECIALIZE(scomplex)\n\n// implements col-major: res += alpha * op(triangular) * vector\n#define EIGEN_BLAS_TRMV_CM(EIGTYPE, BLASTYPE, EIGPREFIX, BLASPREFIX) \\\ntemplate<typename Index, int Mode, bool ConjLhs, bool ConjRhs> \\\nstruct triangular_matrix_vector_product_trmv<Index,Mode,EIGTYPE,ConjLhs,EIGTYPE,ConjRhs,ColMajor> { \\\n  enum { \\\n    IsLower = (Mode&Lower) == Lower, \\\n    SetDiag = (Mode&(ZeroDiag|UnitDiag)) ? 0 : 1, \\\n    IsUnitDiag  = (Mode&UnitDiag) ? 1 : 0, \\\n    IsZeroDiag  = (Mode&ZeroDiag) ? 1 : 0, \\\n    LowUp = IsLower ? Lower : Upper \\\n  }; \\\n static void run(Index _rows, Index _cols, const EIGTYPE* _lhs, Index lhsStride, \\\n                 const EIGTYPE* _rhs, Index rhsIncr, EIGTYPE* _res, Index resIncr, EIGTYPE alpha) \\\n { \\\n   if (ConjLhs || IsZeroDiag) { \\\n     triangular_matrix_vector_product<Index,Mode,EIGTYPE,ConjLhs,EIGTYPE,ConjRhs,ColMajor,BuiltIn>::run( \\\n       _rows, _cols, _lhs, lhsStride, _rhs, rhsIncr, _res, resIncr, alpha); \\\n     return; \\\n   }\\\n   Index size = (std::min)(_rows,_cols); \\\n   Index rows = IsLower ? _rows : size; \\\n   Index cols = IsLower ? size : _cols; \\\n\\\n   typedef VectorX##EIGPREFIX VectorRhs; \\\n   EIGTYPE *x, *y;\\\n\\\n/* Set x*/ \\\n   Map<const VectorRhs, 0, InnerStride<> > rhs(_rhs,cols,InnerStride<>(rhsIncr)); \\\n   VectorRhs x_tmp; \\\n   if (ConjRhs) x_tmp = rhs.conjugate(); else x_tmp = rhs; \\\n   x = x_tmp.data(); \\\n\\\n/* Square part handling */\\\n\\\n   char trans, uplo, diag; \\\n   BlasIndex m, n, lda, incx, incy; \\\n   EIGTYPE const *a; \\\n   EIGTYPE beta(1); \\\n\\\n/* Set m, n */ \\\n   n = convert_index<BlasIndex>(size); \\\n   lda = convert_index<BlasIndex>(lhsStride); \\\n   incx = 1; \\\n   incy = convert_index<BlasIndex>(resIncr); \\\n\\\n/* Set uplo, trans and diag*/ \\\n   trans = 'N'; \\\n   uplo = IsLower ? 'L' : 'U'; \\\n   diag = IsUnitDiag ? 'U' : 'N'; \\\n\\\n/* call ?TRMV*/ \\\n   BLASPREFIX##trmv_(&uplo, &trans, &diag, &n, (const BLASTYPE*)_lhs, &lda, (BLASTYPE*)x, &incx); \\\n\\\n/* Add op(a_tr)rhs into res*/ \\\n   BLASPREFIX##axpy_(&n, &numext::real_ref(alpha),(const BLASTYPE*)x, &incx, (BLASTYPE*)_res, &incy); \\\n/* Non-square case - doesn't fit to BLAS ?TRMV. Fall to default triangular product*/ \\\n   if (size<(std::max)(rows,cols)) { \\\n     if (ConjRhs) x_tmp = rhs.conjugate(); else x_tmp = rhs; \\\n     x = x_tmp.data(); \\\n     if (size<rows) { \\\n       y = _res + size*resIncr; \\\n       a = _lhs + size; \\\n       m = convert_index<BlasIndex>(rows-size); \\\n       n = convert_index<BlasIndex>(size); \\\n     } \\\n     else { \\\n       x += size; \\\n       y = _res; \\\n       a = _lhs + size*lda; \\\n       m = convert_index<BlasIndex>(size); \\\n       n = convert_index<BlasIndex>(cols-size); \\\n     } \\\n     BLASPREFIX##gemv_(&trans, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)x, &incx, &numext::real_ref(beta), (BLASTYPE*)y, &incy); \\\n   } \\\n  } \\\n};\n\nEIGEN_BLAS_TRMV_CM(double,   double, d,  d)\nEIGEN_BLAS_TRMV_CM(dcomplex, double, cd, z)\nEIGEN_BLAS_TRMV_CM(float,    float,  f,  s)\nEIGEN_BLAS_TRMV_CM(scomplex, float,  cf, c)\n\n// implements row-major: res += alpha * op(triangular) * vector\n#define EIGEN_BLAS_TRMV_RM(EIGTYPE, BLASTYPE, EIGPREFIX, BLASPREFIX) \\\ntemplate<typename Index, int Mode, bool ConjLhs, bool ConjRhs> \\\nstruct triangular_matrix_vector_product_trmv<Index,Mode,EIGTYPE,ConjLhs,EIGTYPE,ConjRhs,RowMajor> { \\\n  enum { \\\n    IsLower = (Mode&Lower) == Lower, \\\n    SetDiag = (Mode&(ZeroDiag|UnitDiag)) ? 0 : 1, \\\n    IsUnitDiag  = (Mode&UnitDiag) ? 1 : 0, \\\n    IsZeroDiag  = (Mode&ZeroDiag) ? 1 : 0, \\\n    LowUp = IsLower ? Lower : Upper \\\n  }; \\\n static void run(Index _rows, Index _cols, const EIGTYPE* _lhs, Index lhsStride, \\\n                 const EIGTYPE* _rhs, Index rhsIncr, EIGTYPE* _res, Index resIncr, EIGTYPE alpha) \\\n { \\\n   if (IsZeroDiag) { \\\n     triangular_matrix_vector_product<Index,Mode,EIGTYPE,ConjLhs,EIGTYPE,ConjRhs,RowMajor,BuiltIn>::run( \\\n       _rows, _cols, _lhs, lhsStride, _rhs, rhsIncr, _res, resIncr, alpha); \\\n     return; \\\n   }\\\n   Index size = (std::min)(_rows,_cols); \\\n   Index rows = IsLower ? _rows : size; \\\n   Index cols = IsLower ? size : _cols; \\\n\\\n   typedef VectorX##EIGPREFIX VectorRhs; \\\n   EIGTYPE *x, *y;\\\n\\\n/* Set x*/ \\\n   Map<const VectorRhs, 0, InnerStride<> > rhs(_rhs,cols,InnerStride<>(rhsIncr)); \\\n   VectorRhs x_tmp; \\\n   if (ConjRhs) x_tmp = rhs.conjugate(); else x_tmp = rhs; \\\n   x = x_tmp.data(); \\\n\\\n/* Square part handling */\\\n\\\n   char trans, uplo, diag; \\\n   BlasIndex m, n, lda, incx, incy; \\\n   EIGTYPE const *a; \\\n   EIGTYPE beta(1); \\\n\\\n/* Set m, n */ \\\n   n = convert_index<BlasIndex>(size); \\\n   lda = convert_index<BlasIndex>(lhsStride); \\\n   incx = 1; \\\n   incy = convert_index<BlasIndex>(resIncr); \\\n\\\n/* Set uplo, trans and diag*/ \\\n   trans = ConjLhs ? 'C' : 'T'; \\\n   uplo = IsLower ? 'U' : 'L'; \\\n   diag = IsUnitDiag ? 'U' : 'N'; \\\n\\\n/* call ?TRMV*/ \\\n   BLASPREFIX##trmv_(&uplo, &trans, &diag, &n, (const BLASTYPE*)_lhs, &lda, (BLASTYPE*)x, &incx); \\\n\\\n/* Add op(a_tr)rhs into res*/ \\\n   BLASPREFIX##axpy_(&n, &numext::real_ref(alpha),(const BLASTYPE*)x, &incx, (BLASTYPE*)_res, &incy); \\\n/* Non-square case - doesn't fit to BLAS ?TRMV. Fall to default triangular product*/ \\\n   if (size<(std::max)(rows,cols)) { \\\n     if (ConjRhs) x_tmp = rhs.conjugate(); else x_tmp = rhs; \\\n     x = x_tmp.data(); \\\n     if (size<rows) { \\\n       y = _res + size*resIncr; \\\n       a = _lhs + size*lda; \\\n       m = convert_index<BlasIndex>(rows-size); \\\n       n = convert_index<BlasIndex>(size); \\\n     } \\\n     else { \\\n       x += size; \\\n       y = _res; \\\n       a = _lhs + size; \\\n       m = convert_index<BlasIndex>(size); \\\n       n = convert_index<BlasIndex>(cols-size); \\\n     } \\\n     BLASPREFIX##gemv_(&trans, &n, &m, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)x, &incx, &numext::real_ref(beta), (BLASTYPE*)y, &incy); \\\n   } \\\n  } \\\n};\n\nEIGEN_BLAS_TRMV_RM(double,   double, d,  d)\nEIGEN_BLAS_TRMV_RM(dcomplex, double, cd, z)\nEIGEN_BLAS_TRMV_RM(float,    float,  f,  s)\nEIGEN_BLAS_TRMV_RM(scomplex, float,  cf, c)\n\n} // end namespase internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRIANGULAR_MATRIX_VECTOR_BLAS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/TriangularSolverMatrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TRIANGULAR_SOLVER_MATRIX_H\n#define EIGEN_TRIANGULAR_SOLVER_MATRIX_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n// if the rhs is row major, let's transpose the product\ntemplate <typename Scalar, typename Index, int Side, int Mode, bool Conjugate, int TriStorageOrder>\nstruct triangular_solve_matrix<Scalar,Index,Side,Mode,Conjugate,TriStorageOrder,RowMajor>\n{\n  static void run(\n    Index size, Index cols,\n    const Scalar*  tri, Index triStride,\n    Scalar* _other, Index otherStride,\n    level3_blocking<Scalar,Scalar>& blocking)\n  {\n    triangular_solve_matrix<\n      Scalar, Index, Side==OnTheLeft?OnTheRight:OnTheLeft,\n      (Mode&UnitDiag) | ((Mode&Upper) ? Lower : Upper),\n      NumTraits<Scalar>::IsComplex && Conjugate,\n      TriStorageOrder==RowMajor ? ColMajor : RowMajor, ColMajor>\n      ::run(size, cols, tri, triStride, _other, otherStride, blocking);\n  }\n};\n\n/* Optimized triangular solver with multiple right hand side and the triangular matrix on the left\n */\ntemplate <typename Scalar, typename Index, int Mode, bool Conjugate, int TriStorageOrder>\nstruct triangular_solve_matrix<Scalar,Index,OnTheLeft,Mode,Conjugate,TriStorageOrder,ColMajor>\n{\n  static EIGEN_DONT_INLINE void run(\n    Index size, Index otherSize,\n    const Scalar* _tri, Index triStride,\n    Scalar* _other, Index otherStride,\n    level3_blocking<Scalar,Scalar>& blocking);\n};\ntemplate <typename Scalar, typename Index, int Mode, bool Conjugate, int TriStorageOrder>\nEIGEN_DONT_INLINE void triangular_solve_matrix<Scalar,Index,OnTheLeft,Mode,Conjugate,TriStorageOrder,ColMajor>::run(\n    Index size, Index otherSize,\n    const Scalar* _tri, Index triStride,\n    Scalar* _other, Index otherStride,\n    level3_blocking<Scalar,Scalar>& blocking)\n  {\n    Index cols = otherSize;\n\n    typedef const_blas_data_mapper<Scalar, Index, TriStorageOrder> TriMapper;\n    typedef blas_data_mapper<Scalar, Index, ColMajor> OtherMapper;\n    TriMapper tri(_tri, triStride);\n    OtherMapper other(_other, otherStride);\n\n    typedef gebp_traits<Scalar,Scalar> Traits;\n\n    enum {\n      SmallPanelWidth   = EIGEN_PLAIN_ENUM_MAX(Traits::mr,Traits::nr),\n      IsLower = (Mode&Lower) == Lower\n    };\n\n    Index kc = blocking.kc();                   // cache block size along the K direction\n    Index mc = (std::min)(size,blocking.mc());  // cache block size along the M direction\n\n    std::size_t sizeA = kc*mc;\n    std::size_t sizeB = kc*cols;\n\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockA, sizeA, blocking.blockA());\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockB, sizeB, blocking.blockB());\n\n    conj_if<Conjugate> conj;\n    gebp_kernel<Scalar, Scalar, Index, OtherMapper, Traits::mr, Traits::nr, Conjugate, false> gebp_kernel;\n    gemm_pack_lhs<Scalar, Index, TriMapper, Traits::mr, Traits::LhsProgress, TriStorageOrder> pack_lhs;\n    gemm_pack_rhs<Scalar, Index, OtherMapper, Traits::nr, ColMajor, false, true> pack_rhs;\n\n    // the goal here is to subdivise the Rhs panels such that we keep some cache\n    // coherence when accessing the rhs elements\n    std::ptrdiff_t l1, l2, l3;\n    manage_caching_sizes(GetAction, &l1, &l2, &l3);\n    Index subcols = cols>0 ? l2/(4 * sizeof(Scalar) * std::max<Index>(otherStride,size)) : 0;\n    subcols = std::max<Index>((subcols/Traits::nr)*Traits::nr, Traits::nr);\n\n    for(Index k2=IsLower ? 0 : size;\n        IsLower ? k2<size : k2>0;\n        IsLower ? k2+=kc : k2-=kc)\n    {\n      const Index actual_kc = (std::min)(IsLower ? size-k2 : k2, kc);\n\n      // We have selected and packed a big horizontal panel R1 of rhs. Let B be the packed copy of this panel,\n      // and R2 the remaining part of rhs. The corresponding vertical panel of lhs is split into\n      // A11 (the triangular part) and A21 the remaining rectangular part.\n      // Then the high level algorithm is:\n      //  - B = R1                    => general block copy (done during the next step)\n      //  - R1 = A11^-1 B             => tricky part\n      //  - update B from the new R1  => actually this has to be performed continuously during the above step\n      //  - R2 -= A21 * B             => GEPP\n\n      // The tricky part: compute R1 = A11^-1 B while updating B from R1\n      // The idea is to split A11 into multiple small vertical panels.\n      // Each panel can be split into a small triangular part T1k which is processed without optimization,\n      // and the remaining small part T2k which is processed using gebp with appropriate block strides\n      for(Index j2=0; j2<cols; j2+=subcols)\n      {\n        Index actual_cols = (std::min)(cols-j2,subcols);\n        // for each small vertical panels [T1k^T, T2k^T]^T of lhs\n        for (Index k1=0; k1<actual_kc; k1+=SmallPanelWidth)\n        {\n          Index actualPanelWidth = std::min<Index>(actual_kc-k1, SmallPanelWidth);\n          // tr solve\n          for (Index k=0; k<actualPanelWidth; ++k)\n          {\n            // TODO write a small kernel handling this (can be shared with trsv)\n            Index i  = IsLower ? k2+k1+k : k2-k1-k-1;\n            Index rs = actualPanelWidth - k - 1; // remaining size\n            Index s  = TriStorageOrder==RowMajor ? (IsLower ? k2+k1 : i+1)\n                                                 :  IsLower ? i+1 : i-rs;\n\n            Scalar a = (Mode & UnitDiag) ? Scalar(1) : Scalar(1)/conj(tri(i,i));\n            for (Index j=j2; j<j2+actual_cols; ++j)\n            {\n              if (TriStorageOrder==RowMajor)\n              {\n                Scalar b(0);\n                const Scalar* l = &tri(i,s);\n                Scalar* r = &other(s,j);\n                for (Index i3=0; i3<k; ++i3)\n                  b += conj(l[i3]) * r[i3];\n\n                other(i,j) = (other(i,j) - b)*a;\n              }\n              else\n              {\n                Scalar b = (other(i,j) *= a);\n                Scalar* r = &other(s,j);\n                const Scalar* l = &tri(s,i);\n                for (Index i3=0;i3<rs;++i3)\n                  r[i3] -= b * conj(l[i3]);\n              }\n            }\n          }\n\n          Index lengthTarget = actual_kc-k1-actualPanelWidth;\n          Index startBlock   = IsLower ? k2+k1 : k2-k1-actualPanelWidth;\n          Index blockBOffset = IsLower ? k1 : lengthTarget;\n\n          // update the respective rows of B from other\n          pack_rhs(blockB+actual_kc*j2, other.getSubMapper(startBlock,j2), actualPanelWidth, actual_cols, actual_kc, blockBOffset);\n\n          // GEBP\n          if (lengthTarget>0)\n          {\n            Index startTarget  = IsLower ? k2+k1+actualPanelWidth : k2-actual_kc;\n\n            pack_lhs(blockA, tri.getSubMapper(startTarget,startBlock), actualPanelWidth, lengthTarget);\n\n            gebp_kernel(other.getSubMapper(startTarget,j2), blockA, blockB+actual_kc*j2, lengthTarget, actualPanelWidth, actual_cols, Scalar(-1),\n                        actualPanelWidth, actual_kc, 0, blockBOffset);\n          }\n        }\n      }\n      \n      // R2 -= A21 * B => GEPP\n      {\n        Index start = IsLower ? k2+kc : 0;\n        Index end   = IsLower ? size : k2-kc;\n        for(Index i2=start; i2<end; i2+=mc)\n        {\n          const Index actual_mc = (std::min)(mc,end-i2);\n          if (actual_mc>0)\n          {\n            pack_lhs(blockA, tri.getSubMapper(i2, IsLower ? k2 : k2-kc), actual_kc, actual_mc);\n\n            gebp_kernel(other.getSubMapper(i2, 0), blockA, blockB, actual_mc, actual_kc, cols, Scalar(-1), -1, -1, 0, 0);\n          }\n        }\n      }\n    }\n  }\n\n/* Optimized triangular solver with multiple left hand sides and the triangular matrix on the right\n */\ntemplate <typename Scalar, typename Index, int Mode, bool Conjugate, int TriStorageOrder>\nstruct triangular_solve_matrix<Scalar,Index,OnTheRight,Mode,Conjugate,TriStorageOrder,ColMajor>\n{\n  static EIGEN_DONT_INLINE void run(\n    Index size, Index otherSize,\n    const Scalar* _tri, Index triStride,\n    Scalar* _other, Index otherStride,\n    level3_blocking<Scalar,Scalar>& blocking);\n};\ntemplate <typename Scalar, typename Index, int Mode, bool Conjugate, int TriStorageOrder>\nEIGEN_DONT_INLINE void triangular_solve_matrix<Scalar,Index,OnTheRight,Mode,Conjugate,TriStorageOrder,ColMajor>::run(\n    Index size, Index otherSize,\n    const Scalar* _tri, Index triStride,\n    Scalar* _other, Index otherStride,\n    level3_blocking<Scalar,Scalar>& blocking)\n  {\n    Index rows = otherSize;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n\n    typedef blas_data_mapper<Scalar, Index, ColMajor> LhsMapper;\n    typedef const_blas_data_mapper<Scalar, Index, TriStorageOrder> RhsMapper;\n    LhsMapper lhs(_other, otherStride);\n    RhsMapper rhs(_tri, triStride);\n\n    typedef gebp_traits<Scalar,Scalar> Traits;\n    enum {\n      RhsStorageOrder   = TriStorageOrder,\n      SmallPanelWidth   = EIGEN_PLAIN_ENUM_MAX(Traits::mr,Traits::nr),\n      IsLower = (Mode&Lower) == Lower\n    };\n\n    Index kc = blocking.kc();                   // cache block size along the K direction\n    Index mc = (std::min)(rows,blocking.mc());  // cache block size along the M direction\n\n    std::size_t sizeA = kc*mc;\n    std::size_t sizeB = kc*size;\n\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockA, sizeA, blocking.blockA());\n    ei_declare_aligned_stack_constructed_variable(Scalar, blockB, sizeB, blocking.blockB());\n\n    conj_if<Conjugate> conj;\n    gebp_kernel<Scalar, Scalar, Index, LhsMapper, Traits::mr, Traits::nr, false, Conjugate> gebp_kernel;\n    gemm_pack_rhs<Scalar, Index, RhsMapper, Traits::nr, RhsStorageOrder> pack_rhs;\n    gemm_pack_rhs<Scalar, Index, RhsMapper, Traits::nr, RhsStorageOrder,false,true> pack_rhs_panel;\n    gemm_pack_lhs<Scalar, Index, LhsMapper, Traits::mr, Traits::LhsProgress, ColMajor, false, true> pack_lhs_panel;\n\n    for(Index k2=IsLower ? size : 0;\n        IsLower ? k2>0 : k2<size;\n        IsLower ? k2-=kc : k2+=kc)\n    {\n      const Index actual_kc = (std::min)(IsLower ? k2 : size-k2, kc);\n      Index actual_k2 = IsLower ? k2-actual_kc : k2 ;\n\n      Index startPanel = IsLower ? 0 : k2+actual_kc;\n      Index rs = IsLower ? actual_k2 : size - actual_k2 - actual_kc;\n      Scalar* geb = blockB+actual_kc*actual_kc;\n\n      if (rs>0) pack_rhs(geb, rhs.getSubMapper(actual_k2,startPanel), actual_kc, rs);\n\n      // triangular packing (we only pack the panels off the diagonal,\n      // neglecting the blocks overlapping the diagonal\n      {\n        for (Index j2=0; j2<actual_kc; j2+=SmallPanelWidth)\n        {\n          Index actualPanelWidth = std::min<Index>(actual_kc-j2, SmallPanelWidth);\n          Index actual_j2 = actual_k2 + j2;\n          Index panelOffset = IsLower ? j2+actualPanelWidth : 0;\n          Index panelLength = IsLower ? actual_kc-j2-actualPanelWidth : j2;\n\n          if (panelLength>0)\n          pack_rhs_panel(blockB+j2*actual_kc,\n                         rhs.getSubMapper(actual_k2+panelOffset, actual_j2),\n                         panelLength, actualPanelWidth,\n                         actual_kc, panelOffset);\n        }\n      }\n\n      for(Index i2=0; i2<rows; i2+=mc)\n      {\n        const Index actual_mc = (std::min)(mc,rows-i2);\n\n        // triangular solver kernel\n        {\n          // for each small block of the diagonal (=> vertical panels of rhs)\n          for (Index j2 = IsLower\n                      ? (actual_kc - ((actual_kc%SmallPanelWidth) ? Index(actual_kc%SmallPanelWidth)\n                                                                  : Index(SmallPanelWidth)))\n                      : 0;\n               IsLower ? j2>=0 : j2<actual_kc;\n               IsLower ? j2-=SmallPanelWidth : j2+=SmallPanelWidth)\n          {\n            Index actualPanelWidth = std::min<Index>(actual_kc-j2, SmallPanelWidth);\n            Index absolute_j2 = actual_k2 + j2;\n            Index panelOffset = IsLower ? j2+actualPanelWidth : 0;\n            Index panelLength = IsLower ? actual_kc - j2 - actualPanelWidth : j2;\n\n            // GEBP\n            if(panelLength>0)\n            {\n              gebp_kernel(lhs.getSubMapper(i2,absolute_j2),\n                          blockA, blockB+j2*actual_kc,\n                          actual_mc, panelLength, actualPanelWidth,\n                          Scalar(-1),\n                          actual_kc, actual_kc, // strides\n                          panelOffset, panelOffset); // offsets\n            }\n\n            // unblocked triangular solve\n            for (Index k=0; k<actualPanelWidth; ++k)\n            {\n              Index j = IsLower ? absolute_j2+actualPanelWidth-k-1 : absolute_j2+k;\n\n              Scalar* r = &lhs(i2,j);\n              for (Index k3=0; k3<k; ++k3)\n              {\n                Scalar b = conj(rhs(IsLower ? j+1+k3 : absolute_j2+k3,j));\n                Scalar* a = &lhs(i2,IsLower ? j+1+k3 : absolute_j2+k3);\n                for (Index i=0; i<actual_mc; ++i)\n                  r[i] -= a[i] * b;\n              }\n              if((Mode & UnitDiag)==0)\n              {\n                Scalar inv_rjj = RealScalar(1)/conj(rhs(j,j));\n                for (Index i=0; i<actual_mc; ++i)\n                  r[i] *= inv_rjj;\n              }\n            }\n\n            // pack the just computed part of lhs to A\n            pack_lhs_panel(blockA, LhsMapper(_other+absolute_j2*otherStride+i2, otherStride),\n                           actualPanelWidth, actual_mc,\n                           actual_kc, j2);\n          }\n        }\n\n        if (rs>0)\n          gebp_kernel(lhs.getSubMapper(i2, startPanel), blockA, geb,\n                      actual_mc, actual_kc, rs, Scalar(-1),\n                      -1, -1, 0, 0);\n      }\n    }\n  }\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRIANGULAR_SOLVER_MATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to BLAS F77\n *   Triangular matrix * matrix product functionality based on ?TRMM.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_TRIANGULAR_SOLVER_MATRIX_BLAS_H\n#define EIGEN_TRIANGULAR_SOLVER_MATRIX_BLAS_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n// implements LeftSide op(triangular)^-1 * general\n#define EIGEN_BLAS_TRSM_L(EIGTYPE, BLASTYPE, BLASPREFIX) \\\ntemplate <typename Index, int Mode, bool Conjugate, int TriStorageOrder> \\\nstruct triangular_solve_matrix<EIGTYPE,Index,OnTheLeft,Mode,Conjugate,TriStorageOrder,ColMajor> \\\n{ \\\n  enum { \\\n    IsLower = (Mode&Lower) == Lower, \\\n    IsUnitDiag  = (Mode&UnitDiag) ? 1 : 0, \\\n    IsZeroDiag  = (Mode&ZeroDiag) ? 1 : 0, \\\n    conjA = ((TriStorageOrder==ColMajor) && Conjugate) ? 1 : 0 \\\n  }; \\\n  static void run( \\\n      Index size, Index otherSize, \\\n      const EIGTYPE* _tri, Index triStride, \\\n      EIGTYPE* _other, Index otherStride, level3_blocking<EIGTYPE,EIGTYPE>& /*blocking*/) \\\n  { \\\n   BlasIndex m = convert_index<BlasIndex>(size), n = convert_index<BlasIndex>(otherSize), lda, ldb; \\\n   char side = 'L', uplo, diag='N', transa; \\\n   /* Set alpha_ */ \\\n   EIGTYPE alpha(1); \\\n   ldb = convert_index<BlasIndex>(otherStride);\\\n\\\n   const EIGTYPE *a; \\\n/* Set trans */ \\\n   transa = (TriStorageOrder==RowMajor) ? ((Conjugate) ? 'C' : 'T') : 'N'; \\\n/* Set uplo */ \\\n   uplo = IsLower ? 'L' : 'U'; \\\n   if (TriStorageOrder==RowMajor) uplo = (uplo == 'L') ? 'U' : 'L'; \\\n/* Set a, lda */ \\\n   typedef Matrix<EIGTYPE, Dynamic, Dynamic, TriStorageOrder> MatrixTri; \\\n   Map<const MatrixTri, 0, OuterStride<> > tri(_tri,size,size,OuterStride<>(triStride)); \\\n   MatrixTri a_tmp; \\\n\\\n   if (conjA) { \\\n     a_tmp = tri.conjugate(); \\\n     a = a_tmp.data(); \\\n     lda = convert_index<BlasIndex>(a_tmp.outerStride()); \\\n   } else { \\\n     a = _tri; \\\n     lda = convert_index<BlasIndex>(triStride); \\\n   } \\\n   if (IsUnitDiag) diag='U'; \\\n/* call ?trsm*/ \\\n   BLASPREFIX##trsm_(&side, &uplo, &transa, &diag, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (BLASTYPE*)_other, &ldb); \\\n } \\\n};\n\nEIGEN_BLAS_TRSM_L(double,   double, d)\nEIGEN_BLAS_TRSM_L(dcomplex, double, z)\nEIGEN_BLAS_TRSM_L(float,    float,  s)\nEIGEN_BLAS_TRSM_L(scomplex, float,  c)\n\n\n// implements RightSide general * op(triangular)^-1\n#define EIGEN_BLAS_TRSM_R(EIGTYPE, BLASTYPE, BLASPREFIX) \\\ntemplate <typename Index, int Mode, bool Conjugate, int TriStorageOrder> \\\nstruct triangular_solve_matrix<EIGTYPE,Index,OnTheRight,Mode,Conjugate,TriStorageOrder,ColMajor> \\\n{ \\\n  enum { \\\n    IsLower = (Mode&Lower) == Lower, \\\n    IsUnitDiag  = (Mode&UnitDiag) ? 1 : 0, \\\n    IsZeroDiag  = (Mode&ZeroDiag) ? 1 : 0, \\\n    conjA = ((TriStorageOrder==ColMajor) && Conjugate) ? 1 : 0 \\\n  }; \\\n  static void run( \\\n      Index size, Index otherSize, \\\n      const EIGTYPE* _tri, Index triStride, \\\n      EIGTYPE* _other, Index otherStride, level3_blocking<EIGTYPE,EIGTYPE>& /*blocking*/) \\\n  { \\\n   BlasIndex m = convert_index<BlasIndex>(otherSize), n = convert_index<BlasIndex>(size), lda, ldb; \\\n   char side = 'R', uplo, diag='N', transa; \\\n   /* Set alpha_ */ \\\n   EIGTYPE alpha(1); \\\n   ldb = convert_index<BlasIndex>(otherStride);\\\n\\\n   const EIGTYPE *a; \\\n/* Set trans */ \\\n   transa = (TriStorageOrder==RowMajor) ? ((Conjugate) ? 'C' : 'T') : 'N'; \\\n/* Set uplo */ \\\n   uplo = IsLower ? 'L' : 'U'; \\\n   if (TriStorageOrder==RowMajor) uplo = (uplo == 'L') ? 'U' : 'L'; \\\n/* Set a, lda */ \\\n   typedef Matrix<EIGTYPE, Dynamic, Dynamic, TriStorageOrder> MatrixTri; \\\n   Map<const MatrixTri, 0, OuterStride<> > tri(_tri,size,size,OuterStride<>(triStride)); \\\n   MatrixTri a_tmp; \\\n\\\n   if (conjA) { \\\n     a_tmp = tri.conjugate(); \\\n     a = a_tmp.data(); \\\n     lda = convert_index<BlasIndex>(a_tmp.outerStride()); \\\n   } else { \\\n     a = _tri; \\\n     lda = convert_index<BlasIndex>(triStride); \\\n   } \\\n   if (IsUnitDiag) diag='U'; \\\n/* call ?trsm*/ \\\n   BLASPREFIX##trsm_(&side, &uplo, &transa, &diag, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (BLASTYPE*)_other, &ldb); \\\n   /*std::cout << \"TRMS_L specialization!\\n\";*/ \\\n } \\\n};\n\nEIGEN_BLAS_TRSM_R(double,   double, d)\nEIGEN_BLAS_TRSM_R(dcomplex, double, z)\nEIGEN_BLAS_TRSM_R(float,    float,  s)\nEIGEN_BLAS_TRSM_R(scomplex, float,  c)\n\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRIANGULAR_SOLVER_MATRIX_BLAS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/products/TriangularSolverVector.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TRIANGULAR_SOLVER_VECTOR_H\n#define EIGEN_TRIANGULAR_SOLVER_VECTOR_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<typename LhsScalar, typename RhsScalar, typename Index, int Mode, bool Conjugate, int StorageOrder>\nstruct triangular_solve_vector<LhsScalar, RhsScalar, Index, OnTheRight, Mode, Conjugate, StorageOrder>\n{\n  static void run(Index size, const LhsScalar* _lhs, Index lhsStride, RhsScalar* rhs)\n  {\n    triangular_solve_vector<LhsScalar,RhsScalar,Index,OnTheLeft,\n        ((Mode&Upper)==Upper ? Lower : Upper) | (Mode&UnitDiag),\n        Conjugate,StorageOrder==RowMajor?ColMajor:RowMajor\n      >::run(size, _lhs, lhsStride, rhs);\n  }\n};\n\n// forward and backward substitution, row-major, rhs is a vector\ntemplate<typename LhsScalar, typename RhsScalar, typename Index, int Mode, bool Conjugate>\nstruct triangular_solve_vector<LhsScalar, RhsScalar, Index, OnTheLeft, Mode, Conjugate, RowMajor>\n{\n  enum {\n    IsLower = ((Mode&Lower)==Lower)\n  };\n  static void run(Index size, const LhsScalar* _lhs, Index lhsStride, RhsScalar* rhs)\n  {\n    typedef Map<const Matrix<LhsScalar,Dynamic,Dynamic,RowMajor>, 0, OuterStride<> > LhsMap;\n    const LhsMap lhs(_lhs,size,size,OuterStride<>(lhsStride));\n\n    typedef const_blas_data_mapper<LhsScalar,Index,RowMajor> LhsMapper;\n    typedef const_blas_data_mapper<RhsScalar,Index,ColMajor> RhsMapper;\n\n    typename internal::conditional<\n                          Conjugate,\n                          const CwiseUnaryOp<typename internal::scalar_conjugate_op<LhsScalar>,LhsMap>,\n                          const LhsMap&>\n                        ::type cjLhs(lhs);\n    static const Index PanelWidth = EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH;\n    for(Index pi=IsLower ? 0 : size;\n        IsLower ? pi<size : pi>0;\n        IsLower ? pi+=PanelWidth : pi-=PanelWidth)\n    {\n      Index actualPanelWidth = (std::min)(IsLower ? size - pi : pi, PanelWidth);\n\n      Index r = IsLower ? pi : size - pi; // remaining size\n      if (r > 0)\n      {\n        // let's directly call the low level product function because:\n        // 1 - it is faster to compile\n        // 2 - it is slighlty faster at runtime\n        Index startRow = IsLower ? pi : pi-actualPanelWidth;\n        Index startCol = IsLower ? 0 : pi;\n\n        general_matrix_vector_product<Index,LhsScalar,LhsMapper,RowMajor,Conjugate,RhsScalar,RhsMapper,false>::run(\n          actualPanelWidth, r,\n          LhsMapper(&lhs.coeffRef(startRow,startCol), lhsStride),\n          RhsMapper(rhs + startCol, 1),\n          rhs + startRow, 1,\n          RhsScalar(-1));\n      }\n\n      for(Index k=0; k<actualPanelWidth; ++k)\n      {\n        Index i = IsLower ? pi+k : pi-k-1;\n        Index s = IsLower ? pi   : i+1;\n        if (k>0)\n          rhs[i] -= (cjLhs.row(i).segment(s,k).transpose().cwiseProduct(Map<const Matrix<RhsScalar,Dynamic,1> >(rhs+s,k))).sum();\n\n        if(!(Mode & UnitDiag))\n          rhs[i] /= cjLhs(i,i);\n      }\n    }\n  }\n};\n\n// forward and backward substitution, column-major, rhs is a vector\ntemplate<typename LhsScalar, typename RhsScalar, typename Index, int Mode, bool Conjugate>\nstruct triangular_solve_vector<LhsScalar, RhsScalar, Index, OnTheLeft, Mode, Conjugate, ColMajor>\n{\n  enum {\n    IsLower = ((Mode&Lower)==Lower)\n  };\n  static void run(Index size, const LhsScalar* _lhs, Index lhsStride, RhsScalar* rhs)\n  {\n    typedef Map<const Matrix<LhsScalar,Dynamic,Dynamic,ColMajor>, 0, OuterStride<> > LhsMap;\n    const LhsMap lhs(_lhs,size,size,OuterStride<>(lhsStride));\n    typedef const_blas_data_mapper<LhsScalar,Index,ColMajor> LhsMapper;\n    typedef const_blas_data_mapper<RhsScalar,Index,ColMajor> RhsMapper;\n    typename internal::conditional<Conjugate,\n                                   const CwiseUnaryOp<typename internal::scalar_conjugate_op<LhsScalar>,LhsMap>,\n                                   const LhsMap&\n                                  >::type cjLhs(lhs);\n    static const Index PanelWidth = EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH;\n\n    for(Index pi=IsLower ? 0 : size;\n        IsLower ? pi<size : pi>0;\n        IsLower ? pi+=PanelWidth : pi-=PanelWidth)\n    {\n      Index actualPanelWidth = (std::min)(IsLower ? size - pi : pi, PanelWidth);\n      Index startBlock = IsLower ? pi : pi-actualPanelWidth;\n      Index endBlock = IsLower ? pi + actualPanelWidth : 0;\n\n      for(Index k=0; k<actualPanelWidth; ++k)\n      {\n        Index i = IsLower ? pi+k : pi-k-1;\n        if(!(Mode & UnitDiag))\n          rhs[i] /= cjLhs.coeff(i,i);\n\n        Index r = actualPanelWidth - k - 1; // remaining size\n        Index s = IsLower ? i+1 : i-r;\n        if (r>0)\n          Map<Matrix<RhsScalar,Dynamic,1> >(rhs+s,r) -= rhs[i] * cjLhs.col(i).segment(s,r);\n      }\n      Index r = IsLower ? size - endBlock : startBlock; // remaining size\n      if (r > 0)\n      {\n        // let's directly call the low level product function because:\n        // 1 - it is faster to compile\n        // 2 - it is slighlty faster at runtime\n        general_matrix_vector_product<Index,LhsScalar,LhsMapper,ColMajor,Conjugate,RhsScalar,RhsMapper,false>::run(\n            r, actualPanelWidth,\n            LhsMapper(&lhs.coeffRef(endBlock,startBlock), lhsStride),\n            RhsMapper(rhs+startBlock, 1),\n            rhs+endBlock, 1, RhsScalar(-1));\n      }\n    }\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRIANGULAR_SOLVER_VECTOR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/BlasUtil.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_BLASUTIL_H\n#define EIGEN_BLASUTIL_H\n\n// This file contains many lightweight helper classes used to\n// implement and control fast level 2 and level 3 BLAS-like routines.\n\nnamespace Eigen {\n\nnamespace internal {\n\n// forward declarations\ntemplate<typename LhsScalar, typename RhsScalar, typename Index, typename DataMapper, int mr, int nr, bool ConjugateLhs=false, bool ConjugateRhs=false>\nstruct gebp_kernel;\n\ntemplate<typename Scalar, typename Index, typename DataMapper, int nr, int StorageOrder, bool Conjugate = false, bool PanelMode=false>\nstruct gemm_pack_rhs;\n\ntemplate<typename Scalar, typename Index, typename DataMapper, int Pack1, int Pack2, int StorageOrder, bool Conjugate = false, bool PanelMode = false>\nstruct gemm_pack_lhs;\n\ntemplate<\n  typename Index,\n  typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs,\n  typename RhsScalar, int RhsStorageOrder, bool ConjugateRhs,\n  int ResStorageOrder>\nstruct general_matrix_matrix_product;\n\ntemplate<typename Index,\n         typename LhsScalar, typename LhsMapper, int LhsStorageOrder, bool ConjugateLhs,\n         typename RhsScalar, typename RhsMapper, bool ConjugateRhs, int Version=Specialized>\nstruct general_matrix_vector_product;\n\n\ntemplate<bool Conjugate> struct conj_if;\n\ntemplate<> struct conj_if<true> {\n  template<typename T>\n  inline T operator()(const T& x) const { return numext::conj(x); }\n  template<typename T>\n  inline T pconj(const T& x) const { return internal::pconj(x); }\n};\n\ntemplate<> struct conj_if<false> {\n  template<typename T>\n  inline const T& operator()(const T& x) const { return x; }\n  template<typename T>\n  inline const T& pconj(const T& x) const { return x; }\n};\n\n// Generic implementation for custom complex types.\ntemplate<typename LhsScalar, typename RhsScalar, bool ConjLhs, bool ConjRhs>\nstruct conj_helper\n{\n  typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar>::ReturnType Scalar;\n\n  EIGEN_STRONG_INLINE Scalar pmadd(const LhsScalar& x, const RhsScalar& y, const Scalar& c) const\n  { return padd(c, pmul(x,y)); }\n\n  EIGEN_STRONG_INLINE Scalar pmul(const LhsScalar& x, const RhsScalar& y) const\n  { return conj_if<ConjLhs>()(x) *  conj_if<ConjRhs>()(y); }\n};\n\ntemplate<typename Scalar> struct conj_helper<Scalar,Scalar,false,false>\n{\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const { return internal::pmadd(x,y,c); }\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const { return internal::pmul(x,y); }\n};\n\ntemplate<typename RealScalar> struct conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, false,true>\n{\n  typedef std::complex<RealScalar> Scalar;\n  EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const\n  { return c + pmul(x,y); }\n\n  EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const\n  { return Scalar(numext::real(x)*numext::real(y) + numext::imag(x)*numext::imag(y), numext::imag(x)*numext::real(y) - numext::real(x)*numext::imag(y)); }\n};\n\ntemplate<typename RealScalar> struct conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, true,false>\n{\n  typedef std::complex<RealScalar> Scalar;\n  EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const\n  { return c + pmul(x,y); }\n\n  EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const\n  { return Scalar(numext::real(x)*numext::real(y) + numext::imag(x)*numext::imag(y), numext::real(x)*numext::imag(y) - numext::imag(x)*numext::real(y)); }\n};\n\ntemplate<typename RealScalar> struct conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, true,true>\n{\n  typedef std::complex<RealScalar> Scalar;\n  EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const\n  { return c + pmul(x,y); }\n\n  EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const\n  { return Scalar(numext::real(x)*numext::real(y) - numext::imag(x)*numext::imag(y), - numext::real(x)*numext::imag(y) - numext::imag(x)*numext::real(y)); }\n};\n\ntemplate<typename RealScalar,bool Conj> struct conj_helper<std::complex<RealScalar>, RealScalar, Conj,false>\n{\n  typedef std::complex<RealScalar> Scalar;\n  EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const RealScalar& y, const Scalar& c) const\n  { return padd(c, pmul(x,y)); }\n  EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const RealScalar& y) const\n  { return conj_if<Conj>()(x)*y; }\n};\n\ntemplate<typename RealScalar,bool Conj> struct conj_helper<RealScalar, std::complex<RealScalar>, false,Conj>\n{\n  typedef std::complex<RealScalar> Scalar;\n  EIGEN_STRONG_INLINE Scalar pmadd(const RealScalar& x, const Scalar& y, const Scalar& c) const\n  { return padd(c, pmul(x,y)); }\n  EIGEN_STRONG_INLINE Scalar pmul(const RealScalar& x, const Scalar& y) const\n  { return x*conj_if<Conj>()(y); }\n};\n\ntemplate<typename From,typename To> struct get_factor {\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE To run(const From& x) { return To(x); }\n};\n\ntemplate<typename Scalar> struct get_factor<Scalar,typename NumTraits<Scalar>::Real> {\n  EIGEN_DEVICE_FUNC\n  static EIGEN_STRONG_INLINE typename NumTraits<Scalar>::Real run(const Scalar& x) { return numext::real(x); }\n};\n\n\ntemplate<typename Scalar, typename Index>\nclass BlasVectorMapper {\n  public:\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE BlasVectorMapper(Scalar *data) : m_data(data) {}\n\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar operator()(Index i) const {\n    return m_data[i];\n  }\n  template <typename Packet, int AlignmentType>\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet load(Index i) const {\n    return ploadt<Packet, AlignmentType>(m_data + i);\n  }\n\n  template <typename Packet>\n  EIGEN_DEVICE_FUNC bool aligned(Index i) const {\n    return (UIntPtr(m_data+i)%sizeof(Packet))==0;\n  }\n\n  protected:\n  Scalar* m_data;\n};\n\ntemplate<typename Scalar, typename Index, int AlignmentType>\nclass BlasLinearMapper {\n  public:\n  typedef typename packet_traits<Scalar>::type Packet;\n  typedef typename packet_traits<Scalar>::half HalfPacket;\n\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE BlasLinearMapper(Scalar *data) : m_data(data) {}\n\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void prefetch(int i) const {\n    internal::prefetch(&operator()(i));\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar& operator()(Index i) const {\n    return m_data[i];\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet loadPacket(Index i) const {\n    return ploadt<Packet, AlignmentType>(m_data + i);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE HalfPacket loadHalfPacket(Index i) const {\n    return ploadt<HalfPacket, AlignmentType>(m_data + i);\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void storePacket(Index i, const Packet &p) const {\n    pstoret<Scalar, Packet, AlignmentType>(m_data + i, p);\n  }\n\n  protected:\n  Scalar *m_data;\n};\n\n// Lightweight helper class to access matrix coefficients.\ntemplate<typename Scalar, typename Index, int StorageOrder, int AlignmentType = Unaligned>\nclass blas_data_mapper {\n  public:\n  typedef typename packet_traits<Scalar>::type Packet;\n  typedef typename packet_traits<Scalar>::half HalfPacket;\n\n  typedef BlasLinearMapper<Scalar, Index, AlignmentType> LinearMapper;\n  typedef BlasVectorMapper<Scalar, Index> VectorMapper;\n\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE blas_data_mapper(Scalar* data, Index stride) : m_data(data), m_stride(stride) {}\n\n  EIGEN_DEVICE_FUNC  EIGEN_ALWAYS_INLINE blas_data_mapper<Scalar, Index, StorageOrder, AlignmentType>\n  getSubMapper(Index i, Index j) const {\n    return blas_data_mapper<Scalar, Index, StorageOrder, AlignmentType>(&operator()(i, j), m_stride);\n  }\n\n  EIGEN_DEVICE_FUNC  EIGEN_ALWAYS_INLINE LinearMapper getLinearMapper(Index i, Index j) const {\n    return LinearMapper(&operator()(i, j));\n  }\n\n  EIGEN_DEVICE_FUNC  EIGEN_ALWAYS_INLINE VectorMapper getVectorMapper(Index i, Index j) const {\n    return VectorMapper(&operator()(i, j));\n  }\n\n\n  EIGEN_DEVICE_FUNC\n  EIGEN_ALWAYS_INLINE Scalar& operator()(Index i, Index j) const {\n    return m_data[StorageOrder==RowMajor ? j + i*m_stride : i + j*m_stride];\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet loadPacket(Index i, Index j) const {\n    return ploadt<Packet, AlignmentType>(&operator()(i, j));\n  }\n\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE HalfPacket loadHalfPacket(Index i, Index j) const {\n    return ploadt<HalfPacket, AlignmentType>(&operator()(i, j));\n  }\n\n  template<typename SubPacket>\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void scatterPacket(Index i, Index j, const SubPacket &p) const {\n    pscatter<Scalar, SubPacket>(&operator()(i, j), p, m_stride);\n  }\n\n  template<typename SubPacket>\n  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE SubPacket gatherPacket(Index i, Index j) const {\n    return pgather<Scalar, SubPacket>(&operator()(i, j), m_stride);\n  }\n\n  EIGEN_DEVICE_FUNC const Index stride() const { return m_stride; }\n  EIGEN_DEVICE_FUNC const Scalar* data() const { return m_data; }\n\n  EIGEN_DEVICE_FUNC Index firstAligned(Index size) const {\n    if (UIntPtr(m_data)%sizeof(Scalar)) {\n      return -1;\n    }\n    return internal::first_default_aligned(m_data, size);\n  }\n\n  protected:\n  Scalar* EIGEN_RESTRICT m_data;\n  const Index m_stride;\n};\n\n// lightweight helper class to access matrix coefficients (const version)\ntemplate<typename Scalar, typename Index, int StorageOrder>\nclass const_blas_data_mapper : public blas_data_mapper<const Scalar, Index, StorageOrder> {\n  public:\n  EIGEN_ALWAYS_INLINE const_blas_data_mapper(const Scalar *data, Index stride) : blas_data_mapper<const Scalar, Index, StorageOrder>(data, stride) {}\n\n  EIGEN_ALWAYS_INLINE const_blas_data_mapper<Scalar, Index, StorageOrder> getSubMapper(Index i, Index j) const {\n    return const_blas_data_mapper<Scalar, Index, StorageOrder>(&(this->operator()(i, j)), this->m_stride);\n  }\n};\n\n\n/* Helper class to analyze the factors of a Product expression.\n * In particular it allows to pop out operator-, scalar multiples,\n * and conjugate */\ntemplate<typename XprType> struct blas_traits\n{\n  typedef typename traits<XprType>::Scalar Scalar;\n  typedef const XprType& ExtractType;\n  typedef XprType _ExtractType;\n  enum {\n    IsComplex = NumTraits<Scalar>::IsComplex,\n    IsTransposed = false,\n    NeedToConjugate = false,\n    HasUsableDirectAccess = (    (int(XprType::Flags)&DirectAccessBit)\n                              && (   bool(XprType::IsVectorAtCompileTime)\n                                  || int(inner_stride_at_compile_time<XprType>::ret) == 1)\n                             ) ?  1 : 0\n  };\n  typedef typename conditional<bool(HasUsableDirectAccess),\n    ExtractType,\n    typename _ExtractType::PlainObject\n    >::type DirectLinearAccessType;\n  static inline ExtractType extract(const XprType& x) { return x; }\n  static inline const Scalar extractScalarFactor(const XprType&) { return Scalar(1); }\n};\n\n// pop conjugate\ntemplate<typename Scalar, typename NestedXpr>\nstruct blas_traits<CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> >\n : blas_traits<NestedXpr>\n{\n  typedef blas_traits<NestedXpr> Base;\n  typedef CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> XprType;\n  typedef typename Base::ExtractType ExtractType;\n\n  enum {\n    IsComplex = NumTraits<Scalar>::IsComplex,\n    NeedToConjugate = Base::NeedToConjugate ? 0 : IsComplex\n  };\n  static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }\n  static inline Scalar extractScalarFactor(const XprType& x) { return conj(Base::extractScalarFactor(x.nestedExpression())); }\n};\n\n// pop scalar multiple\ntemplate<typename Scalar, typename NestedXpr, typename Plain>\nstruct blas_traits<CwiseBinaryOp<scalar_product_op<Scalar>, const CwiseNullaryOp<scalar_constant_op<Scalar>,Plain>, NestedXpr> >\n : blas_traits<NestedXpr>\n{\n  typedef blas_traits<NestedXpr> Base;\n  typedef CwiseBinaryOp<scalar_product_op<Scalar>, const CwiseNullaryOp<scalar_constant_op<Scalar>,Plain>, NestedXpr> XprType;\n  typedef typename Base::ExtractType ExtractType;\n  static inline ExtractType extract(const XprType& x) { return Base::extract(x.rhs()); }\n  static inline Scalar extractScalarFactor(const XprType& x)\n  { return x.lhs().functor().m_other * Base::extractScalarFactor(x.rhs()); }\n};\ntemplate<typename Scalar, typename NestedXpr, typename Plain>\nstruct blas_traits<CwiseBinaryOp<scalar_product_op<Scalar>, NestedXpr, const CwiseNullaryOp<scalar_constant_op<Scalar>,Plain> > >\n : blas_traits<NestedXpr>\n{\n  typedef blas_traits<NestedXpr> Base;\n  typedef CwiseBinaryOp<scalar_product_op<Scalar>, NestedXpr, const CwiseNullaryOp<scalar_constant_op<Scalar>,Plain> > XprType;\n  typedef typename Base::ExtractType ExtractType;\n  static inline ExtractType extract(const XprType& x) { return Base::extract(x.lhs()); }\n  static inline Scalar extractScalarFactor(const XprType& x)\n  { return Base::extractScalarFactor(x.lhs()) * x.rhs().functor().m_other; }\n};\ntemplate<typename Scalar, typename Plain1, typename Plain2>\nstruct blas_traits<CwiseBinaryOp<scalar_product_op<Scalar>, const CwiseNullaryOp<scalar_constant_op<Scalar>,Plain1>,\n                                                            const CwiseNullaryOp<scalar_constant_op<Scalar>,Plain2> > >\n : blas_traits<CwiseNullaryOp<scalar_constant_op<Scalar>,Plain1> >\n{};\n\n// pop opposite\ntemplate<typename Scalar, typename NestedXpr>\nstruct blas_traits<CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> >\n : blas_traits<NestedXpr>\n{\n  typedef blas_traits<NestedXpr> Base;\n  typedef CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> XprType;\n  typedef typename Base::ExtractType ExtractType;\n  static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }\n  static inline Scalar extractScalarFactor(const XprType& x)\n  { return - Base::extractScalarFactor(x.nestedExpression()); }\n};\n\n// pop/push transpose\ntemplate<typename NestedXpr>\nstruct blas_traits<Transpose<NestedXpr> >\n : blas_traits<NestedXpr>\n{\n  typedef typename NestedXpr::Scalar Scalar;\n  typedef blas_traits<NestedXpr> Base;\n  typedef Transpose<NestedXpr> XprType;\n  typedef Transpose<const typename Base::_ExtractType>  ExtractType; // const to get rid of a compile error; anyway blas traits are only used on the RHS\n  typedef Transpose<const typename Base::_ExtractType> _ExtractType;\n  typedef typename conditional<bool(Base::HasUsableDirectAccess),\n    ExtractType,\n    typename ExtractType::PlainObject\n    >::type DirectLinearAccessType;\n  enum {\n    IsTransposed = Base::IsTransposed ? 0 : 1\n  };\n  static inline ExtractType extract(const XprType& x) { return ExtractType(Base::extract(x.nestedExpression())); }\n  static inline Scalar extractScalarFactor(const XprType& x) { return Base::extractScalarFactor(x.nestedExpression()); }\n};\n\ntemplate<typename T>\nstruct blas_traits<const T>\n     : blas_traits<T>\n{};\n\ntemplate<typename T, bool HasUsableDirectAccess=blas_traits<T>::HasUsableDirectAccess>\nstruct extract_data_selector {\n  static const typename T::Scalar* run(const T& m)\n  {\n    return blas_traits<T>::extract(m).data();\n  }\n};\n\ntemplate<typename T>\nstruct extract_data_selector<T,false> {\n  static typename T::Scalar* run(const T&) { return 0; }\n};\n\ntemplate<typename T> const typename T::Scalar* extract_data(const T& m)\n{\n  return extract_data_selector<T>::run(m);\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_BLASUTIL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/Constants.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2007-2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CONSTANTS_H\n#define EIGEN_CONSTANTS_H\n\nnamespace Eigen {\n\n/** This value means that a positive quantity (e.g., a size) is not known at compile-time, and that instead the value is\n  * stored in some runtime variable.\n  *\n  * Changing the value of Dynamic breaks the ABI, as Dynamic is often used as a template parameter for Matrix.\n  */\nconst int Dynamic = -1;\n\n/** This value means that a signed quantity (e.g., a signed index) is not known at compile-time, and that instead its value\n  * has to be specified at runtime.\n  */\nconst int DynamicIndex = 0xffffff;\n\n/** This value means +Infinity; it is currently used only as the p parameter to MatrixBase::lpNorm<int>().\n  * The value Infinity there means the L-infinity norm.\n  */\nconst int Infinity = -1;\n\n/** This value means that the cost to evaluate an expression coefficient is either very expensive or\n  * cannot be known at compile time.\n  *\n  * This value has to be positive to (1) simplify cost computation, and (2) allow to distinguish between a very expensive and very very expensive expressions.\n  * It thus must also be large enough to make sure unrolling won't happen and that sub expressions will be evaluated, but not too large to avoid overflow.\n  */\nconst int HugeCost = 10000;\n\n/** \\defgroup flags Flags\n  * \\ingroup Core_Module\n  *\n  * These are the possible bits which can be OR'ed to constitute the flags of a matrix or\n  * expression.\n  *\n  * It is important to note that these flags are a purely compile-time notion. They are a compile-time property of\n  * an expression type, implemented as enum's. They are not stored in memory at runtime, and they do not incur any\n  * runtime overhead.\n  *\n  * \\sa MatrixBase::Flags\n  */\n\n/** \\ingroup flags\n  *\n  * for a matrix, this means that the storage order is row-major.\n  * If this bit is not set, the storage order is column-major.\n  * For an expression, this determines the storage order of\n  * the matrix created by evaluation of that expression.\n  * \\sa \\blank  \\ref TopicStorageOrders */\nconst unsigned int RowMajorBit = 0x1;\n\n/** \\ingroup flags\n  * means the expression should be evaluated by the calling expression */\nconst unsigned int EvalBeforeNestingBit = 0x2;\n\n/** \\ingroup flags\n  * \\deprecated\n  * means the expression should be evaluated before any assignment */\nEIGEN_DEPRECATED\nconst unsigned int EvalBeforeAssigningBit = 0x4; // FIXME deprecated\n\n/** \\ingroup flags\n  *\n  * Short version: means the expression might be vectorized\n  *\n  * Long version: means that the coefficients can be handled by packets\n  * and start at a memory location whose alignment meets the requirements\n  * of the present CPU architecture for optimized packet access. In the fixed-size\n  * case, there is the additional condition that it be possible to access all the\n  * coefficients by packets (this implies the requirement that the size be a multiple of 16 bytes,\n  * and that any nontrivial strides don't break the alignment). In the dynamic-size case,\n  * there is no such condition on the total size and strides, so it might not be possible to access\n  * all coeffs by packets.\n  *\n  * \\note This bit can be set regardless of whether vectorization is actually enabled.\n  *       To check for actual vectorizability, see \\a ActualPacketAccessBit.\n  */\nconst unsigned int PacketAccessBit = 0x8;\n\n#ifdef EIGEN_VECTORIZE\n/** \\ingroup flags\n  *\n  * If vectorization is enabled (EIGEN_VECTORIZE is defined) this constant\n  * is set to the value \\a PacketAccessBit.\n  *\n  * If vectorization is not enabled (EIGEN_VECTORIZE is not defined) this constant\n  * is set to the value 0.\n  */\nconst unsigned int ActualPacketAccessBit = PacketAccessBit;\n#else\nconst unsigned int ActualPacketAccessBit = 0x0;\n#endif\n\n/** \\ingroup flags\n  *\n  * Short version: means the expression can be seen as 1D vector.\n  *\n  * Long version: means that one can access the coefficients\n  * of this expression by coeff(int), and coeffRef(int) in the case of a lvalue expression. These\n  * index-based access methods are guaranteed\n  * to not have to do any runtime computation of a (row, col)-pair from the index, so that it\n  * is guaranteed that whenever it is available, index-based access is at least as fast as\n  * (row,col)-based access. Expressions for which that isn't possible don't have the LinearAccessBit.\n  *\n  * If both PacketAccessBit and LinearAccessBit are set, then the\n  * packets of this expression can be accessed by packet(int), and writePacket(int) in the case of a\n  * lvalue expression.\n  *\n  * Typically, all vector expressions have the LinearAccessBit, but there is one exception:\n  * Product expressions don't have it, because it would be troublesome for vectorization, even when the\n  * Product is a vector expression. Thus, vector Product expressions allow index-based coefficient access but\n  * not index-based packet access, so they don't have the LinearAccessBit.\n  */\nconst unsigned int LinearAccessBit = 0x10;\n\n/** \\ingroup flags\n  *\n  * Means the expression has a coeffRef() method, i.e. is writable as its individual coefficients are directly addressable.\n  * This rules out read-only expressions.\n  *\n  * Note that DirectAccessBit and LvalueBit are mutually orthogonal, as there are examples of expression having one but note\n  * the other:\n  *   \\li writable expressions that don't have a very simple memory layout as a strided array, have LvalueBit but not DirectAccessBit\n  *   \\li Map-to-const expressions, for example Map<const Matrix>, have DirectAccessBit but not LvalueBit\n  *\n  * Expressions having LvalueBit also have their coeff() method returning a const reference instead of returning a new value.\n  */\nconst unsigned int LvalueBit = 0x20;\n\n/** \\ingroup flags\n  *\n  * Means that the underlying array of coefficients can be directly accessed as a plain strided array. The memory layout\n  * of the array of coefficients must be exactly the natural one suggested by rows(), cols(),\n  * outerStride(), innerStride(), and the RowMajorBit. This rules out expressions such as Diagonal, whose coefficients,\n  * though referencable, do not have such a regular memory layout.\n  *\n  * See the comment on LvalueBit for an explanation of how LvalueBit and DirectAccessBit are mutually orthogonal.\n  */\nconst unsigned int DirectAccessBit = 0x40;\n\n/** \\deprecated \\ingroup flags\n  *\n  * means the first coefficient packet is guaranteed to be aligned.\n  * An expression cannot has the AlignedBit without the PacketAccessBit flag.\n  * In other words, this means we are allow to perform an aligned packet access to the first element regardless\n  * of the expression kind:\n  * \\code\n  * expression.packet<Aligned>(0);\n  * \\endcode\n  */\nEIGEN_DEPRECATED const unsigned int AlignedBit = 0x80;\n\nconst unsigned int NestByRefBit = 0x100;\n\n/** \\ingroup flags\n  *\n  * for an expression, this means that the storage order\n  * can be either row-major or column-major.\n  * The precise choice will be decided at evaluation time or when\n  * combined with other expressions.\n  * \\sa \\blank  \\ref RowMajorBit, \\ref TopicStorageOrders */\nconst unsigned int NoPreferredStorageOrderBit = 0x200;\n\n/** \\ingroup flags\n  *\n  * Means that the underlying coefficients can be accessed through pointers to the sparse (un)compressed storage format,\n  * that is, the expression provides:\n  * \\code\n    inline const Scalar* valuePtr() const;\n    inline const Index* innerIndexPtr() const;\n    inline const Index* outerIndexPtr() const;\n    inline const Index* innerNonZeroPtr() const;\n    \\endcode\n  */\nconst unsigned int CompressedAccessBit = 0x400;\n\n\n// list of flags that are inherited by default\nconst unsigned int HereditaryBits = RowMajorBit\n                                  | EvalBeforeNestingBit;\n\n/** \\defgroup enums Enumerations\n  * \\ingroup Core_Module\n  *\n  * Various enumerations used in %Eigen. Many of these are used as template parameters.\n  */\n\n/** \\ingroup enums\n  * Enum containing possible values for the \\c Mode or \\c UpLo parameter of\n  * MatrixBase::selfadjointView() and MatrixBase::triangularView(), and selfadjoint solvers. */\nenum UpLoType {\n  /** View matrix as a lower triangular matrix. */\n  Lower=0x1,                      \n  /** View matrix as an upper triangular matrix. */\n  Upper=0x2,                      \n  /** %Matrix has ones on the diagonal; to be used in combination with #Lower or #Upper. */\n  UnitDiag=0x4, \n  /** %Matrix has zeros on the diagonal; to be used in combination with #Lower or #Upper. */\n  ZeroDiag=0x8,\n  /** View matrix as a lower triangular matrix with ones on the diagonal. */\n  UnitLower=UnitDiag|Lower, \n  /** View matrix as an upper triangular matrix with ones on the diagonal. */\n  UnitUpper=UnitDiag|Upper,\n  /** View matrix as a lower triangular matrix with zeros on the diagonal. */\n  StrictlyLower=ZeroDiag|Lower, \n  /** View matrix as an upper triangular matrix with zeros on the diagonal. */\n  StrictlyUpper=ZeroDiag|Upper,\n  /** Used in BandMatrix and SelfAdjointView to indicate that the matrix is self-adjoint. */\n  SelfAdjoint=0x10,\n  /** Used to support symmetric, non-selfadjoint, complex matrices. */\n  Symmetric=0x20\n};\n\n/** \\ingroup enums\n  * Enum for indicating whether a buffer is aligned or not. */\nenum AlignmentType {\n  Unaligned=0,        /**< Data pointer has no specific alignment. */\n  Aligned8=8,         /**< Data pointer is aligned on a 8 bytes boundary. */\n  Aligned16=16,       /**< Data pointer is aligned on a 16 bytes boundary. */\n  Aligned32=32,       /**< Data pointer is aligned on a 32 bytes boundary. */\n  Aligned64=64,       /**< Data pointer is aligned on a 64 bytes boundary. */\n  Aligned128=128,     /**< Data pointer is aligned on a 128 bytes boundary. */\n  AlignedMask=255,\n  Aligned=16,         /**< \\deprecated Synonym for Aligned16. */\n#if EIGEN_MAX_ALIGN_BYTES==128\n  AlignedMax = Aligned128\n#elif EIGEN_MAX_ALIGN_BYTES==64\n  AlignedMax = Aligned64\n#elif EIGEN_MAX_ALIGN_BYTES==32\n  AlignedMax = Aligned32\n#elif EIGEN_MAX_ALIGN_BYTES==16\n  AlignedMax = Aligned16\n#elif EIGEN_MAX_ALIGN_BYTES==8\n  AlignedMax = Aligned8\n#elif EIGEN_MAX_ALIGN_BYTES==0\n  AlignedMax = Unaligned\n#else\n#error Invalid value for EIGEN_MAX_ALIGN_BYTES\n#endif\n};\n\n/** \\ingroup enums\n * Enum used by DenseBase::corner() in Eigen2 compatibility mode. */\n// FIXME after the corner() API change, this was not needed anymore, except by AlignedBox\n// TODO: find out what to do with that. Adapt the AlignedBox API ?\nenum CornerType { TopLeft, TopRight, BottomLeft, BottomRight };\n\n/** \\ingroup enums\n  * Enum containing possible values for the \\p Direction parameter of\n  * Reverse, PartialReduxExpr and VectorwiseOp. */\nenum DirectionType { \n  /** For Reverse, all columns are reversed; \n    * for PartialReduxExpr and VectorwiseOp, act on columns. */\n  Vertical, \n  /** For Reverse, all rows are reversed; \n    * for PartialReduxExpr and VectorwiseOp, act on rows. */\n  Horizontal, \n  /** For Reverse, both rows and columns are reversed; \n    * not used for PartialReduxExpr and VectorwiseOp. */\n  BothDirections \n};\n\n/** \\internal \\ingroup enums\n  * Enum to specify how to traverse the entries of a matrix. */\nenum TraversalType {\n  /** \\internal Default traversal, no vectorization, no index-based access */\n  DefaultTraversal,\n  /** \\internal No vectorization, use index-based access to have only one for loop instead of 2 nested loops */\n  LinearTraversal,\n  /** \\internal Equivalent to a slice vectorization for fixed-size matrices having good alignment\n    * and good size */\n  InnerVectorizedTraversal,\n  /** \\internal Vectorization path using a single loop plus scalar loops for the\n    * unaligned boundaries */\n  LinearVectorizedTraversal,\n  /** \\internal Generic vectorization path using one vectorized loop per row/column with some\n    * scalar loops to handle the unaligned boundaries */\n  SliceVectorizedTraversal,\n  /** \\internal Special case to properly handle incompatible scalar types or other defecting cases*/\n  InvalidTraversal,\n  /** \\internal Evaluate all entries at once */\n  AllAtOnceTraversal\n};\n\n/** \\internal \\ingroup enums\n  * Enum to specify whether to unroll loops when traversing over the entries of a matrix. */\nenum UnrollingType {\n  /** \\internal Do not unroll loops. */\n  NoUnrolling,\n  /** \\internal Unroll only the inner loop, but not the outer loop. */\n  InnerUnrolling,\n  /** \\internal Unroll both the inner and the outer loop. If there is only one loop, \n    * because linear traversal is used, then unroll that loop. */\n  CompleteUnrolling\n};\n\n/** \\internal \\ingroup enums\n  * Enum to specify whether to use the default (built-in) implementation or the specialization. */\nenum SpecializedType {\n  Specialized,\n  BuiltIn\n};\n\n/** \\ingroup enums\n  * Enum containing possible values for the \\p _Options template parameter of\n  * Matrix, Array and BandMatrix. */\nenum StorageOptions {\n  /** Storage order is column major (see \\ref TopicStorageOrders). */\n  ColMajor = 0,\n  /** Storage order is row major (see \\ref TopicStorageOrders). */\n  RowMajor = 0x1,  // it is only a coincidence that this is equal to RowMajorBit -- don't rely on that\n  /** Align the matrix itself if it is vectorizable fixed-size */\n  AutoAlign = 0,\n  /** Don't require alignment for the matrix itself (the array of coefficients, if dynamically allocated, may still be requested to be aligned) */ // FIXME --- clarify the situation\n  DontAlign = 0x2\n};\n\n/** \\ingroup enums\n  * Enum for specifying whether to apply or solve on the left or right. */\nenum SideType {\n  /** Apply transformation on the left. */\n  OnTheLeft = 1,  \n  /** Apply transformation on the right. */\n  OnTheRight = 2  \n};\n\n/* the following used to be written as:\n *\n *   struct NoChange_t {};\n *   namespace {\n *     EIGEN_UNUSED NoChange_t NoChange;\n *   }\n *\n * on the ground that it feels dangerous to disambiguate overloaded functions on enum/integer types.  \n * However, this leads to \"variable declared but never referenced\" warnings on Intel Composer XE,\n * and we do not know how to get rid of them (bug 450).\n */\n\nenum NoChange_t   { NoChange };\nenum Sequential_t { Sequential };\nenum Default_t    { Default };\n\n/** \\internal \\ingroup enums\n  * Used in AmbiVector. */\nenum AmbiVectorMode {\n  IsDense         = 0,\n  IsSparse\n};\n\n/** \\ingroup enums\n  * Used as template parameter in DenseCoeffBase and MapBase to indicate \n  * which accessors should be provided. */\nenum AccessorLevels {\n  /** Read-only access via a member function. */\n  ReadOnlyAccessors, \n  /** Read/write access via member functions. */\n  WriteAccessors, \n  /** Direct read-only access to the coefficients. */\n  DirectAccessors, \n  /** Direct read/write access to the coefficients. */\n  DirectWriteAccessors\n};\n\n/** \\ingroup enums\n  * Enum with options to give to various decompositions. */\nenum DecompositionOptions {\n  /** \\internal Not used (meant for LDLT?). */\n  Pivoting            = 0x01, \n  /** \\internal Not used (meant for LDLT?). */\n  NoPivoting          = 0x02, \n  /** Used in JacobiSVD to indicate that the square matrix U is to be computed. */\n  ComputeFullU        = 0x04,\n  /** Used in JacobiSVD to indicate that the thin matrix U is to be computed. */\n  ComputeThinU        = 0x08,\n  /** Used in JacobiSVD to indicate that the square matrix V is to be computed. */\n  ComputeFullV        = 0x10,\n  /** Used in JacobiSVD to indicate that the thin matrix V is to be computed. */\n  ComputeThinV        = 0x20,\n  /** Used in SelfAdjointEigenSolver and GeneralizedSelfAdjointEigenSolver to specify\n    * that only the eigenvalues are to be computed and not the eigenvectors. */\n  EigenvaluesOnly     = 0x40,\n  /** Used in SelfAdjointEigenSolver and GeneralizedSelfAdjointEigenSolver to specify\n    * that both the eigenvalues and the eigenvectors are to be computed. */\n  ComputeEigenvectors = 0x80,\n  /** \\internal */\n  EigVecMask = EigenvaluesOnly | ComputeEigenvectors,\n  /** Used in GeneralizedSelfAdjointEigenSolver to indicate that it should\n    * solve the generalized eigenproblem \\f$ Ax = \\lambda B x \\f$. */\n  Ax_lBx              = 0x100,\n  /** Used in GeneralizedSelfAdjointEigenSolver to indicate that it should\n    * solve the generalized eigenproblem \\f$ ABx = \\lambda x \\f$. */\n  ABx_lx              = 0x200,\n  /** Used in GeneralizedSelfAdjointEigenSolver to indicate that it should\n    * solve the generalized eigenproblem \\f$ BAx = \\lambda x \\f$. */\n  BAx_lx              = 0x400,\n  /** \\internal */\n  GenEigMask = Ax_lBx | ABx_lx | BAx_lx\n};\n\n/** \\ingroup enums\n  * Possible values for the \\p QRPreconditioner template parameter of JacobiSVD. */\nenum QRPreconditioners {\n  /** Do not specify what is to be done if the SVD of a non-square matrix is asked for. */\n  NoQRPreconditioner,\n  /** Use a QR decomposition without pivoting as the first step. */\n  HouseholderQRPreconditioner,\n  /** Use a QR decomposition with column pivoting as the first step. */\n  ColPivHouseholderQRPreconditioner,\n  /** Use a QR decomposition with full pivoting as the first step. */\n  FullPivHouseholderQRPreconditioner\n};\n\n#ifdef Success\n#error The preprocessor symbol 'Success' is defined, possibly by the X11 header file X.h\n#endif\n\n/** \\ingroup enums\n  * Enum for reporting the status of a computation. */\nenum ComputationInfo {\n  /** Computation was successful. */\n  Success = 0,        \n  /** The provided data did not satisfy the prerequisites. */\n  NumericalIssue = 1, \n  /** Iterative procedure did not converge. */\n  NoConvergence = 2,\n  /** The inputs are invalid, or the algorithm has been improperly called.\n    * When assertions are enabled, such errors trigger an assert. */\n  InvalidInput = 3\n};\n\n/** \\ingroup enums\n  * Enum used to specify how a particular transformation is stored in a matrix.\n  * \\sa Transform, Hyperplane::transform(). */\nenum TransformTraits {\n  /** Transformation is an isometry. */\n  Isometry      = 0x1,\n  /** Transformation is an affine transformation stored as a (Dim+1)^2 matrix whose last row is \n    * assumed to be [0 ... 0 1]. */\n  Affine        = 0x2,\n  /** Transformation is an affine transformation stored as a (Dim) x (Dim+1) matrix. */\n  AffineCompact = 0x10 | Affine,\n  /** Transformation is a general projective transformation stored as a (Dim+1)^2 matrix. */\n  Projective    = 0x20\n};\n\n/** \\internal \\ingroup enums\n  * Enum used to choose between implementation depending on the computer architecture. */\nnamespace Architecture\n{\n  enum Type {\n    Generic = 0x0,\n    SSE = 0x1,\n    AltiVec = 0x2,\n    VSX = 0x3,\n    NEON = 0x4,\n#if defined EIGEN_VECTORIZE_SSE\n    Target = SSE\n#elif defined EIGEN_VECTORIZE_ALTIVEC\n    Target = AltiVec\n#elif defined EIGEN_VECTORIZE_VSX\n    Target = VSX\n#elif defined EIGEN_VECTORIZE_NEON\n    Target = NEON\n#else\n    Target = Generic\n#endif\n  };\n}\n\n/** \\internal \\ingroup enums\n  * Enum used as template parameter in Product and product evaluators. */\nenum ProductImplType\n{ DefaultProduct=0, LazyProduct, AliasFreeProduct, CoeffBasedProductMode, LazyCoeffBasedProductMode, OuterProduct, InnerProduct, GemvProduct, GemmProduct };\n\n/** \\internal \\ingroup enums\n  * Enum used in experimental parallel implementation. */\nenum Action {GetAction, SetAction};\n\n/** The type used to identify a dense storage. */\nstruct Dense {};\n\n/** The type used to identify a general sparse storage. */\nstruct Sparse {};\n\n/** The type used to identify a general solver (factored) storage. */\nstruct SolverStorage {};\n\n/** The type used to identify a permutation storage. */\nstruct PermutationStorage {};\n\n/** The type used to identify a permutation storage. */\nstruct TranspositionsStorage {};\n\n/** The type used to identify a matrix expression */\nstruct MatrixXpr {};\n\n/** The type used to identify an array expression */\nstruct ArrayXpr {};\n\n// An evaluator must define its shape. By default, it can be one of the following:\nstruct DenseShape             { static std::string debugName() { return \"DenseShape\"; } };\nstruct SolverShape            { static std::string debugName() { return \"SolverShape\"; } };\nstruct HomogeneousShape       { static std::string debugName() { return \"HomogeneousShape\"; } };\nstruct DiagonalShape          { static std::string debugName() { return \"DiagonalShape\"; } };\nstruct BandShape              { static std::string debugName() { return \"BandShape\"; } };\nstruct TriangularShape        { static std::string debugName() { return \"TriangularShape\"; } };\nstruct SelfAdjointShape       { static std::string debugName() { return \"SelfAdjointShape\"; } };\nstruct PermutationShape       { static std::string debugName() { return \"PermutationShape\"; } };\nstruct TranspositionsShape    { static std::string debugName() { return \"TranspositionsShape\"; } };\nstruct SparseShape            { static std::string debugName() { return \"SparseShape\"; } };\n\nnamespace internal {\n\n  // random access iterators based on coeff*() accessors.\nstruct IndexBased {};\n\n// evaluator based on iterators to access coefficients. \nstruct IteratorBased {};\n\n/** \\internal\n * Constants for comparison functors\n */\nenum ComparisonName {\n  cmp_EQ = 0,\n  cmp_LT = 1,\n  cmp_LE = 2,\n  cmp_UNORD = 3,\n  cmp_NEQ = 4,\n  cmp_GT = 5,\n  cmp_GE = 6\n};\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_CONSTANTS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/DisableStupidWarnings.h",
    "content": "#ifndef EIGEN_WARNINGS_DISABLED\n#define EIGEN_WARNINGS_DISABLED\n\n#ifdef _MSC_VER\n  // 4100 - unreferenced formal parameter (occurred e.g. in aligned_allocator::destroy(pointer p))\n  // 4101 - unreferenced local variable\n  // 4127 - conditional expression is constant\n  // 4181 - qualifier applied to reference type ignored\n  // 4211 - nonstandard extension used : redefined extern to static\n  // 4244 - 'argument' : conversion from 'type1' to 'type2', possible loss of data\n  // 4273 - QtAlignedMalloc, inconsistent DLL linkage\n  // 4324 - structure was padded due to declspec(align())\n  // 4503 - decorated name length exceeded, name was truncated\n  // 4512 - assignment operator could not be generated\n  // 4522 - 'class' : multiple assignment operators specified\n  // 4700 - uninitialized local variable 'xyz' used\n  // 4714 - function marked as __forceinline not inlined\n  // 4717 - 'function' : recursive on all control paths, function will cause runtime stack overflow\n  // 4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning)\n  #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS\n    #pragma warning( push )\n  #endif\n  #pragma warning( disable : 4100 4101 4127 4181 4211 4244 4273 4324 4503 4512 4522 4700 4714 4717 4800)\n\n#elif defined __INTEL_COMPILER\n  // 2196 - routine is both \"inline\" and \"noinline\" (\"noinline\" assumed)\n  //        ICC 12 generates this warning even without any inline keyword, when defining class methods 'inline' i.e. inside of class body\n  //        typedef that may be a reference type.\n  // 279  - controlling expression is constant\n  //        ICC 12 generates this warning on assert(constant_expression_depending_on_template_params) and frankly this is a legitimate use case.\n  // 1684 - conversion from pointer to same-sized integral type (potential portability problem)\n  // 2259 - non-pointer conversion from \"Eigen::Index={ptrdiff_t={long}}\" to \"int\" may lose significant bits\n  #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS\n    #pragma warning push\n  #endif\n  #pragma warning disable 2196 279 1684 2259\n\n#elif defined __clang__\n  // -Wconstant-logical-operand - warning: use of logical && with constant operand; switch to bitwise & or remove constant\n  //     this is really a stupid warning as it warns on compile-time expressions involving enums\n  #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS\n    #pragma clang diagnostic push\n  #endif\n  #pragma clang diagnostic ignored \"-Wconstant-logical-operand\"\n\n#elif defined __GNUC__ && __GNUC__>=6\n\n  #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS\n    #pragma GCC diagnostic push\n  #endif\n  #pragma GCC diagnostic ignored \"-Wignored-attributes\"\n\n#endif\n\n#if defined __NVCC__\n  // Disable the \"statement is unreachable\" message\n  #pragma diag_suppress code_is_unreachable\n  // Disable the \"dynamic initialization in unreachable code\" message\n  #pragma diag_suppress initialization_not_reachable\n  // Disable the \"invalid error number\" message that we get with older versions of nvcc\n  #pragma diag_suppress 1222\n  // Disable the \"calling a __host__ function from a __host__ __device__ function is not allowed\" messages (yes, there are many of them and they seem to change with every version of the compiler)\n  #pragma diag_suppress 2527\n  #pragma diag_suppress 2529\n  #pragma diag_suppress 2651\n  #pragma diag_suppress 2653\n  #pragma diag_suppress 2668\n  #pragma diag_suppress 2669\n  #pragma diag_suppress 2670\n  #pragma diag_suppress 2671\n  #pragma diag_suppress 2735\n  #pragma diag_suppress 2737\n#endif\n\n#endif // not EIGEN_WARNINGS_DISABLED\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/ForwardDeclarations.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_FORWARDDECLARATIONS_H\n#define EIGEN_FORWARDDECLARATIONS_H\n\nnamespace Eigen {\nnamespace internal {\n\ntemplate<typename T> struct traits;\n\n// here we say once and for all that traits<const T> == traits<T>\n// When constness must affect traits, it has to be constness on template parameters on which T itself depends.\n// For example, traits<Map<const T> > != traits<Map<T> >, but\n//              traits<const Map<T> > == traits<Map<T> >\ntemplate<typename T> struct traits<const T> : traits<T> {};\n\ntemplate<typename Derived> struct has_direct_access\n{\n  enum { ret = (traits<Derived>::Flags & DirectAccessBit) ? 1 : 0 };\n};\n\ntemplate<typename Derived> struct accessors_level\n{\n  enum { has_direct_access = (traits<Derived>::Flags & DirectAccessBit) ? 1 : 0,\n         has_write_access = (traits<Derived>::Flags & LvalueBit) ? 1 : 0,\n         value = has_direct_access ? (has_write_access ? DirectWriteAccessors : DirectAccessors)\n                                   : (has_write_access ? WriteAccessors       : ReadOnlyAccessors)\n  };\n};\n\ntemplate<typename T> struct evaluator_traits;\n\ntemplate< typename T> struct evaluator;\n\n} // end namespace internal\n\ntemplate<typename T> struct NumTraits;\n\ntemplate<typename Derived> struct EigenBase;\ntemplate<typename Derived> class DenseBase;\ntemplate<typename Derived> class PlainObjectBase;\n\n\ntemplate<typename Derived,\n         int Level = internal::accessors_level<Derived>::value >\nclass DenseCoeffsBase;\n\ntemplate<typename _Scalar, int _Rows, int _Cols,\n         int _Options = AutoAlign |\n#if EIGEN_GNUC_AT(3,4)\n    // workaround a bug in at least gcc 3.4.6\n    // the innermost ?: ternary operator is misparsed. We write it slightly\n    // differently and this makes gcc 3.4.6 happy, but it's ugly.\n    // The error would only show up with EIGEN_DEFAULT_TO_ROW_MAJOR is defined\n    // (when EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION is RowMajor)\n                          ( (_Rows==1 && _Cols!=1) ? Eigen::RowMajor\n                          : !(_Cols==1 && _Rows!=1) ?  EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION\n                          : Eigen::ColMajor ),\n#else\n                          ( (_Rows==1 && _Cols!=1) ? Eigen::RowMajor\n                          : (_Cols==1 && _Rows!=1) ? Eigen::ColMajor\n                          : EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ),\n#endif\n         int _MaxRows = _Rows,\n         int _MaxCols = _Cols\n> class Matrix;\n\ntemplate<typename Derived> class MatrixBase;\ntemplate<typename Derived> class ArrayBase;\n\ntemplate<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged;\ntemplate<typename ExpressionType, template <typename> class StorageBase > class NoAlias;\ntemplate<typename ExpressionType> class NestByValue;\ntemplate<typename ExpressionType> class ForceAlignedAccess;\ntemplate<typename ExpressionType> class SwapWrapper;\n\ntemplate<typename XprType, int BlockRows=Dynamic, int BlockCols=Dynamic, bool InnerPanel = false> class Block;\n\ntemplate<typename MatrixType, int Size=Dynamic> class VectorBlock;\ntemplate<typename MatrixType> class Transpose;\ntemplate<typename MatrixType> class Conjugate;\ntemplate<typename NullaryOp, typename MatrixType>         class CwiseNullaryOp;\ntemplate<typename UnaryOp,   typename MatrixType>         class CwiseUnaryOp;\ntemplate<typename ViewOp,    typename MatrixType>         class CwiseUnaryView;\ntemplate<typename BinaryOp,  typename Lhs, typename Rhs>  class CwiseBinaryOp;\ntemplate<typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>  class CwiseTernaryOp;\ntemplate<typename Decomposition, typename Rhstype>        class Solve;\ntemplate<typename XprType>                                class Inverse;\n\ntemplate<typename Lhs, typename Rhs, int Option = DefaultProduct> class Product;\n\ntemplate<typename Derived> class DiagonalBase;\ntemplate<typename _DiagonalVectorType> class DiagonalWrapper;\ntemplate<typename _Scalar, int SizeAtCompileTime, int MaxSizeAtCompileTime=SizeAtCompileTime> class DiagonalMatrix;\ntemplate<typename MatrixType, typename DiagonalType, int ProductOrder> class DiagonalProduct;\ntemplate<typename MatrixType, int Index = 0> class Diagonal;\ntemplate<int SizeAtCompileTime, int MaxSizeAtCompileTime = SizeAtCompileTime, typename IndexType=int> class PermutationMatrix;\ntemplate<int SizeAtCompileTime, int MaxSizeAtCompileTime = SizeAtCompileTime, typename IndexType=int> class Transpositions;\ntemplate<typename Derived> class PermutationBase;\ntemplate<typename Derived> class TranspositionsBase;\ntemplate<typename _IndicesType> class PermutationWrapper;\ntemplate<typename _IndicesType> class TranspositionsWrapper;\n\ntemplate<typename Derived,\n         int Level = internal::accessors_level<Derived>::has_write_access ? WriteAccessors : ReadOnlyAccessors\n> class MapBase;\ntemplate<int InnerStrideAtCompileTime, int OuterStrideAtCompileTime> class Stride;\ntemplate<int Value = Dynamic> class InnerStride;\ntemplate<int Value = Dynamic> class OuterStride;\ntemplate<typename MatrixType, int MapOptions=Unaligned, typename StrideType = Stride<0,0> > class Map;\ntemplate<typename Derived> class RefBase;\ntemplate<typename PlainObjectType, int Options = 0,\n         typename StrideType = typename internal::conditional<PlainObjectType::IsVectorAtCompileTime,InnerStride<1>,OuterStride<> >::type > class Ref;\n\ntemplate<typename Derived> class TriangularBase;\ntemplate<typename MatrixType, unsigned int Mode> class TriangularView;\ntemplate<typename MatrixType, unsigned int Mode> class SelfAdjointView;\ntemplate<typename MatrixType> class SparseView;\ntemplate<typename ExpressionType> class WithFormat;\ntemplate<typename MatrixType> struct CommaInitializer;\ntemplate<typename Derived> class ReturnByValue;\ntemplate<typename ExpressionType> class ArrayWrapper;\ntemplate<typename ExpressionType> class MatrixWrapper;\ntemplate<typename Derived> class SolverBase;\ntemplate<typename XprType> class InnerIterator;\n\nnamespace internal {\ntemplate<typename DecompositionType> struct kernel_retval_base;\ntemplate<typename DecompositionType> struct kernel_retval;\ntemplate<typename DecompositionType> struct image_retval_base;\ntemplate<typename DecompositionType> struct image_retval;\n} // end namespace internal\n\nnamespace internal {\ntemplate<typename _Scalar, int Rows=Dynamic, int Cols=Dynamic, int Supers=Dynamic, int Subs=Dynamic, int Options=0> class BandMatrix;\n}\n\nnamespace internal {\ntemplate<typename Lhs, typename Rhs> struct product_type;\n\ntemplate<bool> struct EnableIf;\n\n/** \\internal\n  * \\class product_evaluator\n  * Products need their own evaluator with more template arguments allowing for\n  * easier partial template specializations.\n  */\ntemplate< typename T,\n          int ProductTag = internal::product_type<typename T::Lhs,typename T::Rhs>::ret,\n          typename LhsShape = typename evaluator_traits<typename T::Lhs>::Shape,\n          typename RhsShape = typename evaluator_traits<typename T::Rhs>::Shape,\n          typename LhsScalar = typename traits<typename T::Lhs>::Scalar,\n          typename RhsScalar = typename traits<typename T::Rhs>::Scalar\n        > struct product_evaluator;\n}\n\ntemplate<typename Lhs, typename Rhs,\n         int ProductType = internal::product_type<Lhs,Rhs>::value>\nstruct ProductReturnType;\n\n// this is a workaround for sun CC\ntemplate<typename Lhs, typename Rhs> struct LazyProductReturnType;\n\nnamespace internal {\n\n// Provides scalar/packet-wise product and product with accumulation\n// with optional conjugation of the arguments.\ntemplate<typename LhsScalar, typename RhsScalar, bool ConjLhs=false, bool ConjRhs=false> struct conj_helper;\n\ntemplate<typename LhsScalar,typename RhsScalar=LhsScalar> struct scalar_sum_op;\ntemplate<typename LhsScalar,typename RhsScalar=LhsScalar> struct scalar_difference_op;\ntemplate<typename LhsScalar,typename RhsScalar=LhsScalar> struct scalar_conj_product_op;\ntemplate<typename LhsScalar,typename RhsScalar=LhsScalar> struct scalar_min_op;\ntemplate<typename LhsScalar,typename RhsScalar=LhsScalar> struct scalar_max_op;\ntemplate<typename Scalar> struct scalar_opposite_op;\ntemplate<typename Scalar> struct scalar_conjugate_op;\ntemplate<typename Scalar> struct scalar_real_op;\ntemplate<typename Scalar> struct scalar_imag_op;\ntemplate<typename Scalar> struct scalar_abs_op;\ntemplate<typename Scalar> struct scalar_abs2_op;\ntemplate<typename Scalar> struct scalar_sqrt_op;\ntemplate<typename Scalar> struct scalar_rsqrt_op;\ntemplate<typename Scalar> struct scalar_exp_op;\ntemplate<typename Scalar> struct scalar_log_op;\ntemplate<typename Scalar> struct scalar_cos_op;\ntemplate<typename Scalar> struct scalar_sin_op;\ntemplate<typename Scalar> struct scalar_acos_op;\ntemplate<typename Scalar> struct scalar_asin_op;\ntemplate<typename Scalar> struct scalar_tan_op;\ntemplate<typename Scalar> struct scalar_inverse_op;\ntemplate<typename Scalar> struct scalar_square_op;\ntemplate<typename Scalar> struct scalar_cube_op;\ntemplate<typename Scalar, typename NewType> struct scalar_cast_op;\ntemplate<typename Scalar> struct scalar_random_op;\ntemplate<typename Scalar> struct scalar_constant_op;\ntemplate<typename Scalar> struct scalar_identity_op;\ntemplate<typename Scalar,bool iscpx> struct scalar_sign_op;\ntemplate<typename Scalar,typename ScalarExponent> struct scalar_pow_op;\ntemplate<typename LhsScalar,typename RhsScalar=LhsScalar> struct scalar_hypot_op;\ntemplate<typename LhsScalar,typename RhsScalar=LhsScalar> struct scalar_product_op;\ntemplate<typename LhsScalar,typename RhsScalar=LhsScalar> struct scalar_quotient_op;\n\n// SpecialFunctions module\ntemplate<typename Scalar> struct scalar_lgamma_op;\ntemplate<typename Scalar> struct scalar_digamma_op;\ntemplate<typename Scalar> struct scalar_erf_op;\ntemplate<typename Scalar> struct scalar_erfc_op;\ntemplate<typename Scalar> struct scalar_igamma_op;\ntemplate<typename Scalar> struct scalar_igammac_op;\ntemplate<typename Scalar> struct scalar_zeta_op;\ntemplate<typename Scalar> struct scalar_betainc_op;\n\n} // end namespace internal\n\nstruct IOFormat;\n\n// Array module\ntemplate<typename _Scalar, int _Rows, int _Cols,\n         int _Options = AutoAlign |\n#if EIGEN_GNUC_AT(3,4)\n    // workaround a bug in at least gcc 3.4.6\n    // the innermost ?: ternary operator is misparsed. We write it slightly\n    // differently and this makes gcc 3.4.6 happy, but it's ugly.\n    // The error would only show up with EIGEN_DEFAULT_TO_ROW_MAJOR is defined\n    // (when EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION is RowMajor)\n                          ( (_Rows==1 && _Cols!=1) ? Eigen::RowMajor\n                          : !(_Cols==1 && _Rows!=1) ?  EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION\n                          : Eigen::ColMajor ),\n#else\n                          ( (_Rows==1 && _Cols!=1) ? Eigen::RowMajor\n                          : (_Cols==1 && _Rows!=1) ? Eigen::ColMajor\n                          : EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ),\n#endif\n         int _MaxRows = _Rows, int _MaxCols = _Cols> class Array;\ntemplate<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType> class Select;\ntemplate<typename MatrixType, typename BinaryOp, int Direction> class PartialReduxExpr;\ntemplate<typename ExpressionType, int Direction> class VectorwiseOp;\ntemplate<typename MatrixType,int RowFactor,int ColFactor> class Replicate;\ntemplate<typename MatrixType, int Direction = BothDirections> class Reverse;\n\ntemplate<typename MatrixType> class FullPivLU;\ntemplate<typename MatrixType> class PartialPivLU;\nnamespace internal {\ntemplate<typename MatrixType> struct inverse_impl;\n}\ntemplate<typename MatrixType> class HouseholderQR;\ntemplate<typename MatrixType> class ColPivHouseholderQR;\ntemplate<typename MatrixType> class FullPivHouseholderQR;\ntemplate<typename MatrixType> class CompleteOrthogonalDecomposition;\ntemplate<typename MatrixType, int QRPreconditioner = ColPivHouseholderQRPreconditioner> class JacobiSVD;\ntemplate<typename MatrixType> class BDCSVD;\ntemplate<typename MatrixType, int UpLo = Lower> class LLT;\ntemplate<typename MatrixType, int UpLo = Lower> class LDLT;\ntemplate<typename VectorsType, typename CoeffsType, int Side=OnTheLeft> class HouseholderSequence;\ntemplate<typename Scalar>     class JacobiRotation;\n\n// Geometry module:\ntemplate<typename Derived, int _Dim> class RotationBase;\ntemplate<typename Lhs, typename Rhs> class Cross;\ntemplate<typename Derived> class QuaternionBase;\ntemplate<typename Scalar> class Rotation2D;\ntemplate<typename Scalar> class AngleAxis;\ntemplate<typename Scalar,int Dim> class Translation;\ntemplate<typename Scalar,int Dim> class AlignedBox;\ntemplate<typename Scalar, int Options = AutoAlign> class Quaternion;\ntemplate<typename Scalar,int Dim,int Mode,int _Options=AutoAlign> class Transform;\ntemplate <typename _Scalar, int _AmbientDim, int Options=AutoAlign> class ParametrizedLine;\ntemplate <typename _Scalar, int _AmbientDim, int Options=AutoAlign> class Hyperplane;\ntemplate<typename Scalar> class UniformScaling;\ntemplate<typename MatrixType,int Direction> class Homogeneous;\n\n// Sparse module:\ntemplate<typename Derived> class SparseMatrixBase;\n\n// MatrixFunctions module\ntemplate<typename Derived> struct MatrixExponentialReturnValue;\ntemplate<typename Derived> class MatrixFunctionReturnValue;\ntemplate<typename Derived> class MatrixSquareRootReturnValue;\ntemplate<typename Derived> class MatrixLogarithmReturnValue;\ntemplate<typename Derived> class MatrixPowerReturnValue;\ntemplate<typename Derived> class MatrixComplexPowerReturnValue;\n\nnamespace internal {\ntemplate <typename Scalar>\nstruct stem_function\n{\n  typedef std::complex<typename NumTraits<Scalar>::Real> ComplexScalar;\n  typedef ComplexScalar type(ComplexScalar, int);\n};\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_FORWARDDECLARATIONS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/MKL_support.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to Intel(R) MKL\n *   Include file with common MKL declarations\n ********************************************************************************\n*/\n\n#ifndef EIGEN_MKL_SUPPORT_H\n#define EIGEN_MKL_SUPPORT_H\n\n#ifdef EIGEN_USE_MKL_ALL\n  #ifndef EIGEN_USE_BLAS\n    #define EIGEN_USE_BLAS\n  #endif\n  #ifndef EIGEN_USE_LAPACKE\n    #define EIGEN_USE_LAPACKE\n  #endif\n  #ifndef EIGEN_USE_MKL_VML\n    #define EIGEN_USE_MKL_VML\n  #endif\n#endif\n\n#ifdef EIGEN_USE_LAPACKE_STRICT\n  #define EIGEN_USE_LAPACKE\n#endif\n\n#if defined(EIGEN_USE_MKL_VML)\n  #define EIGEN_USE_MKL\n#endif\n\n#if defined EIGEN_USE_MKL\n#   include <mkl.h> \n/*Check IMKL version for compatibility: < 10.3 is not usable with Eigen*/\n#   ifndef INTEL_MKL_VERSION\n#       undef EIGEN_USE_MKL /* INTEL_MKL_VERSION is not even defined on older versions */\n#   elif INTEL_MKL_VERSION < 100305    /* the intel-mkl-103-release-notes say this was when the lapacke.h interface was added*/\n#       undef EIGEN_USE_MKL\n#   endif\n#   ifndef EIGEN_USE_MKL\n    /*If the MKL version is too old, undef everything*/\n#       undef   EIGEN_USE_MKL_ALL\n#       undef   EIGEN_USE_LAPACKE\n#       undef   EIGEN_USE_MKL_VML\n#       undef   EIGEN_USE_LAPACKE_STRICT\n#       undef   EIGEN_USE_LAPACKE\n#   endif\n#endif\n\n#if defined EIGEN_USE_MKL\n\n#define EIGEN_MKL_VML_THRESHOLD 128\n\n/* MKL_DOMAIN_BLAS, etc are defined only in 10.3 update 7 */\n/* MKL_BLAS, etc are not defined in 11.2 */\n#ifdef MKL_DOMAIN_ALL\n#define EIGEN_MKL_DOMAIN_ALL MKL_DOMAIN_ALL\n#else\n#define EIGEN_MKL_DOMAIN_ALL MKL_ALL\n#endif\n\n#ifdef MKL_DOMAIN_BLAS\n#define EIGEN_MKL_DOMAIN_BLAS MKL_DOMAIN_BLAS\n#else\n#define EIGEN_MKL_DOMAIN_BLAS MKL_BLAS\n#endif\n\n#ifdef MKL_DOMAIN_FFT\n#define EIGEN_MKL_DOMAIN_FFT MKL_DOMAIN_FFT\n#else\n#define EIGEN_MKL_DOMAIN_FFT MKL_FFT\n#endif\n\n#ifdef MKL_DOMAIN_VML\n#define EIGEN_MKL_DOMAIN_VML MKL_DOMAIN_VML\n#else\n#define EIGEN_MKL_DOMAIN_VML MKL_VML\n#endif\n\n#ifdef MKL_DOMAIN_PARDISO\n#define EIGEN_MKL_DOMAIN_PARDISO MKL_DOMAIN_PARDISO\n#else\n#define EIGEN_MKL_DOMAIN_PARDISO MKL_PARDISO\n#endif\n#endif\n\nnamespace Eigen {\n\ntypedef std::complex<double> dcomplex;\ntypedef std::complex<float>  scomplex;\n\n#if defined(EIGEN_USE_MKL)\ntypedef MKL_INT BlasIndex;\n#else\ntypedef int BlasIndex;\n#endif\n\n} // end namespace Eigen\n\n#if defined(EIGEN_USE_BLAS)\n#include \"../../misc/blas.h\"\n#endif\n\n#endif // EIGEN_MKL_SUPPORT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/Macros.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MACROS_H\n#define EIGEN_MACROS_H\n\n#define EIGEN_WORLD_VERSION 3\n#define EIGEN_MAJOR_VERSION 3\n#define EIGEN_MINOR_VERSION 4\n\n#define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \\\n                                      (EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \\\n                                                                 EIGEN_MINOR_VERSION>=z))))\n\n// Compiler identification, EIGEN_COMP_*\n\n/// \\internal EIGEN_COMP_GNUC set to 1 for all compilers compatible with GCC\n#ifdef __GNUC__\n  #define EIGEN_COMP_GNUC 1\n#else\n  #define EIGEN_COMP_GNUC 0\n#endif\n\n/// \\internal EIGEN_COMP_CLANG set to major+minor version (e.g., 307 for clang 3.7) if the compiler is clang\n#if defined(__clang__)\n  #define EIGEN_COMP_CLANG (__clang_major__*100+__clang_minor__)\n#else\n  #define EIGEN_COMP_CLANG 0\n#endif\n\n\n/// \\internal EIGEN_COMP_LLVM set to 1 if the compiler backend is llvm\n#if defined(__llvm__)\n  #define EIGEN_COMP_LLVM 1\n#else\n  #define EIGEN_COMP_LLVM 0\n#endif\n\n/// \\internal EIGEN_COMP_ICC set to __INTEL_COMPILER if the compiler is Intel compiler, 0 otherwise\n#if defined(__INTEL_COMPILER)\n  #define EIGEN_COMP_ICC __INTEL_COMPILER\n#else\n  #define EIGEN_COMP_ICC 0\n#endif\n\n/// \\internal EIGEN_COMP_MINGW set to 1 if the compiler is mingw\n#if defined(__MINGW32__)\n  #define EIGEN_COMP_MINGW 1\n#else\n  #define EIGEN_COMP_MINGW 0\n#endif\n\n/// \\internal EIGEN_COMP_SUNCC set to 1 if the compiler is Solaris Studio\n#if defined(__SUNPRO_CC)\n  #define EIGEN_COMP_SUNCC 1\n#else\n  #define EIGEN_COMP_SUNCC 0\n#endif\n\n/// \\internal EIGEN_COMP_MSVC set to _MSC_VER if the compiler is Microsoft Visual C++, 0 otherwise.\n#if defined(_MSC_VER)\n  #define EIGEN_COMP_MSVC _MSC_VER\n#else\n  #define EIGEN_COMP_MSVC 0\n#endif\n\n// For the record, here is a table summarizing the possible values for EIGEN_COMP_MSVC:\n//  name  ver   MSC_VER\n//  2008    9      1500\n//  2010   10      1600\n//  2012   11      1700\n//  2013   12      1800\n//  2015   14      1900\n//  \"15\"   15      1900\n\n/// \\internal EIGEN_COMP_MSVC_STRICT set to 1 if the compiler is really Microsoft Visual C++ and not ,e.g., ICC or clang-cl\n#if EIGEN_COMP_MSVC && !(EIGEN_COMP_ICC || EIGEN_COMP_LLVM || EIGEN_COMP_CLANG)\n  #define EIGEN_COMP_MSVC_STRICT _MSC_VER\n#else\n  #define EIGEN_COMP_MSVC_STRICT 0\n#endif\n\n/// \\internal EIGEN_COMP_IBM set to 1 if the compiler is IBM XL C++\n#if defined(__IBMCPP__) || defined(__xlc__)\n  #define EIGEN_COMP_IBM 1\n#else\n  #define EIGEN_COMP_IBM 0\n#endif\n\n/// \\internal EIGEN_COMP_PGI set to 1 if the compiler is Portland Group Compiler\n#if defined(__PGI)\n  #define EIGEN_COMP_PGI 1\n#else\n  #define EIGEN_COMP_PGI 0\n#endif\n\n/// \\internal EIGEN_COMP_ARM set to 1 if the compiler is ARM Compiler\n#if defined(__CC_ARM) || defined(__ARMCC_VERSION)\n  #define EIGEN_COMP_ARM 1\n#else\n  #define EIGEN_COMP_ARM 0\n#endif\n\n/// \\internal EIGEN_COMP_ARM set to 1 if the compiler is ARM Compiler\n#if defined(__EMSCRIPTEN__)\n  #define EIGEN_COMP_EMSCRIPTEN 1\n#else\n  #define EIGEN_COMP_EMSCRIPTEN 0\n#endif\n\n\n/// \\internal EIGEN_GNUC_STRICT set to 1 if the compiler is really GCC and not a compatible compiler (e.g., ICC, clang, mingw, etc.)\n#if EIGEN_COMP_GNUC && !(EIGEN_COMP_CLANG || EIGEN_COMP_ICC || EIGEN_COMP_MINGW || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM || EIGEN_COMP_EMSCRIPTEN)\n  #define EIGEN_COMP_GNUC_STRICT 1\n#else\n  #define EIGEN_COMP_GNUC_STRICT 0\n#endif\n\n\n#if EIGEN_COMP_GNUC\n  #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__==x && __GNUC_MINOR__>=y) || __GNUC__>x)\n  #define EIGEN_GNUC_AT_MOST(x,y)  ((__GNUC__==x && __GNUC_MINOR__<=y) || __GNUC__<x)\n  #define EIGEN_GNUC_AT(x,y)       ( __GNUC__==x && __GNUC_MINOR__==y )\n#else\n  #define EIGEN_GNUC_AT_LEAST(x,y) 0\n  #define EIGEN_GNUC_AT_MOST(x,y)  0\n  #define EIGEN_GNUC_AT(x,y)       0\n#endif\n\n// FIXME: could probably be removed as we do not support gcc 3.x anymore\n#if EIGEN_COMP_GNUC && (__GNUC__ <= 3)\n#define EIGEN_GCC3_OR_OLDER 1\n#else\n#define EIGEN_GCC3_OR_OLDER 0\n#endif\n\n\n// Architecture identification, EIGEN_ARCH_*\n\n#if defined(__x86_64__) || defined(_M_X64) || defined(__amd64)\n  #define EIGEN_ARCH_x86_64 1\n#else\n  #define EIGEN_ARCH_x86_64 0\n#endif\n\n#if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__i386)\n  #define EIGEN_ARCH_i386 1\n#else\n  #define EIGEN_ARCH_i386 0\n#endif\n\n#if EIGEN_ARCH_x86_64 || EIGEN_ARCH_i386\n  #define EIGEN_ARCH_i386_OR_x86_64 1\n#else\n  #define EIGEN_ARCH_i386_OR_x86_64 0\n#endif\n\n/// \\internal EIGEN_ARCH_ARM set to 1 if the architecture is ARM\n#if defined(__arm__)\n  #define EIGEN_ARCH_ARM 1\n#else\n  #define EIGEN_ARCH_ARM 0\n#endif\n\n/// \\internal EIGEN_ARCH_ARM64 set to 1 if the architecture is ARM64\n#if defined(__aarch64__)\n  #define EIGEN_ARCH_ARM64 1\n#else\n  #define EIGEN_ARCH_ARM64 0\n#endif\n\n#if EIGEN_ARCH_ARM || EIGEN_ARCH_ARM64\n  #define EIGEN_ARCH_ARM_OR_ARM64 1\n#else\n  #define EIGEN_ARCH_ARM_OR_ARM64 0\n#endif\n\n/// \\internal EIGEN_ARCH_MIPS set to 1 if the architecture is MIPS\n#if defined(__mips__) || defined(__mips)\n  #define EIGEN_ARCH_MIPS 1\n#else\n  #define EIGEN_ARCH_MIPS 0\n#endif\n\n/// \\internal EIGEN_ARCH_SPARC set to 1 if the architecture is SPARC\n#if defined(__sparc__) || defined(__sparc)\n  #define EIGEN_ARCH_SPARC 1\n#else\n  #define EIGEN_ARCH_SPARC 0\n#endif\n\n/// \\internal EIGEN_ARCH_IA64 set to 1 if the architecture is Intel Itanium\n#if defined(__ia64__)\n  #define EIGEN_ARCH_IA64 1\n#else\n  #define EIGEN_ARCH_IA64 0\n#endif\n\n/// \\internal EIGEN_ARCH_PPC set to 1 if the architecture is PowerPC\n#if defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC)\n  #define EIGEN_ARCH_PPC 1\n#else\n  #define EIGEN_ARCH_PPC 0\n#endif\n\n\n\n// Operating system identification, EIGEN_OS_*\n\n/// \\internal EIGEN_OS_UNIX set to 1 if the OS is a unix variant\n#if defined(__unix__) || defined(__unix)\n  #define EIGEN_OS_UNIX 1\n#else\n  #define EIGEN_OS_UNIX 0\n#endif\n\n/// \\internal EIGEN_OS_LINUX set to 1 if the OS is based on Linux kernel\n#if defined(__linux__)\n  #define EIGEN_OS_LINUX 1\n#else\n  #define EIGEN_OS_LINUX 0\n#endif\n\n/// \\internal EIGEN_OS_ANDROID set to 1 if the OS is Android\n// note: ANDROID is defined when using ndk_build, __ANDROID__ is defined when using a standalone toolchain.\n#if defined(__ANDROID__) || defined(ANDROID)\n  #define EIGEN_OS_ANDROID 1\n#else\n  #define EIGEN_OS_ANDROID 0\n#endif\n\n/// \\internal EIGEN_OS_GNULINUX set to 1 if the OS is GNU Linux and not Linux-based OS (e.g., not android)\n#if defined(__gnu_linux__) && !(EIGEN_OS_ANDROID)\n  #define EIGEN_OS_GNULINUX 1\n#else\n  #define EIGEN_OS_GNULINUX 0\n#endif\n\n/// \\internal EIGEN_OS_BSD set to 1 if the OS is a BSD variant\n#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)\n  #define EIGEN_OS_BSD 1\n#else\n  #define EIGEN_OS_BSD 0\n#endif\n\n/// \\internal EIGEN_OS_MAC set to 1 if the OS is MacOS\n#if defined(__APPLE__)\n  #define EIGEN_OS_MAC 1\n#else\n  #define EIGEN_OS_MAC 0\n#endif\n\n/// \\internal EIGEN_OS_QNX set to 1 if the OS is QNX\n#if defined(__QNX__)\n  #define EIGEN_OS_QNX 1\n#else\n  #define EIGEN_OS_QNX 0\n#endif\n\n/// \\internal EIGEN_OS_WIN set to 1 if the OS is Windows based\n#if defined(_WIN32)\n  #define EIGEN_OS_WIN 1\n#else\n  #define EIGEN_OS_WIN 0\n#endif\n\n/// \\internal EIGEN_OS_WIN64 set to 1 if the OS is Windows 64bits\n#if defined(_WIN64)\n  #define EIGEN_OS_WIN64 1\n#else\n  #define EIGEN_OS_WIN64 0\n#endif\n\n/// \\internal EIGEN_OS_WINCE set to 1 if the OS is Windows CE\n#if defined(_WIN32_WCE)\n  #define EIGEN_OS_WINCE 1\n#else\n  #define EIGEN_OS_WINCE 0\n#endif\n\n/// \\internal EIGEN_OS_CYGWIN set to 1 if the OS is Windows/Cygwin\n#if defined(__CYGWIN__)\n  #define EIGEN_OS_CYGWIN 1\n#else\n  #define EIGEN_OS_CYGWIN 0\n#endif\n\n/// \\internal EIGEN_OS_WIN_STRICT set to 1 if the OS is really Windows and not some variants\n#if EIGEN_OS_WIN && !( EIGEN_OS_WINCE || EIGEN_OS_CYGWIN )\n  #define EIGEN_OS_WIN_STRICT 1\n#else\n  #define EIGEN_OS_WIN_STRICT 0\n#endif\n\n/// \\internal EIGEN_OS_SUN set to 1 if the OS is SUN\n#if (defined(sun) || defined(__sun)) && !(defined(__SVR4) || defined(__svr4__))\n  #define EIGEN_OS_SUN 1\n#else\n  #define EIGEN_OS_SUN 0\n#endif\n\n/// \\internal EIGEN_OS_SOLARIS set to 1 if the OS is Solaris\n#if (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__))\n  #define EIGEN_OS_SOLARIS 1\n#else\n  #define EIGEN_OS_SOLARIS 0\n#endif\n\n\n\n#if EIGEN_GNUC_AT_MOST(4,3) && !EIGEN_COMP_CLANG\n  // see bug 89\n  #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 0\n#else\n  #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 1\n#endif\n\n// This macro can be used to prevent from macro expansion, e.g.:\n//   std::max EIGEN_NOT_A_MACRO(a,b)\n#define EIGEN_NOT_A_MACRO\n\n#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR\n#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::RowMajor\n#else\n#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::ColMajor\n#endif\n\n#ifndef EIGEN_DEFAULT_DENSE_INDEX_TYPE\n#define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t\n#endif\n\n// Cross compiler wrapper around LLVM's __has_builtin\n#ifdef __has_builtin\n#  define EIGEN_HAS_BUILTIN(x) __has_builtin(x)\n#else\n#  define EIGEN_HAS_BUILTIN(x) 0\n#endif\n\n// A Clang feature extension to determine compiler features.\n// We use it to determine 'cxx_rvalue_references'\n#ifndef __has_feature\n# define __has_feature(x) 0\n#endif\n\n// Upperbound on the C++ version to use.\n// Expected values are 03, 11, 14, 17, etc.\n// By default, let's use an arbitrarily large C++ version.\n#ifndef EIGEN_MAX_CPP_VER\n#define EIGEN_MAX_CPP_VER 99\n#endif\n\n#if EIGEN_MAX_CPP_VER>=11 && (defined(__cplusplus) && (__cplusplus >= 201103L) || EIGEN_COMP_MSVC >= 1900)\n#define EIGEN_HAS_CXX11 1\n#else\n#define EIGEN_HAS_CXX11 0\n#endif\n\n\n// Do we support r-value references?\n#ifndef EIGEN_HAS_RVALUE_REFERENCES\n#if EIGEN_MAX_CPP_VER>=11 && \\\n    (__has_feature(cxx_rvalue_references) || \\\n    (defined(__cplusplus) && __cplusplus >= 201103L) || \\\n    (EIGEN_COMP_MSVC >= 1600))\n  #define EIGEN_HAS_RVALUE_REFERENCES 1\n#else\n  #define EIGEN_HAS_RVALUE_REFERENCES 0\n#endif\n#endif\n\n// Does the compiler support C99?\n#ifndef EIGEN_HAS_C99_MATH\n#if EIGEN_MAX_CPP_VER>=11 && \\\n    ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901))       \\\n  || (defined(__GNUC__) && defined(_GLIBCXX_USE_C99)) \\\n  || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)))\n  #define EIGEN_HAS_C99_MATH 1\n#else\n  #define EIGEN_HAS_C99_MATH 0\n#endif\n#endif\n\n// Does the compiler support result_of?\n#ifndef EIGEN_HAS_STD_RESULT_OF\n#if EIGEN_MAX_CPP_VER>=11 && ((__has_feature(cxx_lambdas) || (defined(__cplusplus) && __cplusplus >= 201103L)))\n#define EIGEN_HAS_STD_RESULT_OF 1\n#else\n#define EIGEN_HAS_STD_RESULT_OF 0\n#endif\n#endif\n\n// Does the compiler support variadic templates?\n#ifndef EIGEN_HAS_VARIADIC_TEMPLATES\n#if EIGEN_MAX_CPP_VER>=11 && (__cplusplus > 199711L || EIGEN_COMP_MSVC >= 1900) \\\n  && ( !defined(__NVCC__) || !EIGEN_ARCH_ARM_OR_ARM64 || (defined __CUDACC_VER__ && __CUDACC_VER__ >= 80000) )\n    // ^^ Disable the use of variadic templates when compiling with versions of nvcc older than 8.0 on ARM devices:\n    //    this prevents nvcc from crashing when compiling Eigen on Tegra X1\n#define EIGEN_HAS_VARIADIC_TEMPLATES 1\n#else\n#define EIGEN_HAS_VARIADIC_TEMPLATES 0\n#endif\n#endif\n\n// Does the compiler fully support const expressions? (as in c++14)\n#ifndef EIGEN_HAS_CONSTEXPR\n\n#ifdef __CUDACC__\n// Const expressions are supported provided that c++11 is enabled and we're using either clang or nvcc 7.5 or above\n#if EIGEN_MAX_CPP_VER>=14 && (__cplusplus > 199711L && defined(__CUDACC_VER__) && (EIGEN_COMP_CLANG || __CUDACC_VER__ >= 70500))\n  #define EIGEN_HAS_CONSTEXPR 1\n#endif\n#elif EIGEN_MAX_CPP_VER>=14 && (__has_feature(cxx_relaxed_constexpr) || (defined(__cplusplus) && __cplusplus >= 201402L) || \\\n  (EIGEN_GNUC_AT_LEAST(4,8) && (__cplusplus > 199711L)))\n#define EIGEN_HAS_CONSTEXPR 1\n#endif\n\n#ifndef EIGEN_HAS_CONSTEXPR\n#define EIGEN_HAS_CONSTEXPR 0\n#endif\n\n#endif\n\n// Does the compiler support C++11 math?\n// Let's be conservative and enable the default C++11 implementation only if we are sure it exists\n#ifndef EIGEN_HAS_CXX11_MATH\n  #if EIGEN_MAX_CPP_VER>=11 && ((__cplusplus > 201103L) || (__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC)  \\\n      && (EIGEN_ARCH_i386_OR_x86_64) && (EIGEN_OS_GNULINUX || EIGEN_OS_WIN_STRICT || EIGEN_OS_MAC))\n    #define EIGEN_HAS_CXX11_MATH 1\n  #else\n    #define EIGEN_HAS_CXX11_MATH 0\n  #endif\n#endif\n\n// Does the compiler support proper C++11 containers?\n#ifndef EIGEN_HAS_CXX11_CONTAINERS\n  #if    EIGEN_MAX_CPP_VER>=11 && \\\n         ((__cplusplus > 201103L) \\\n      || ((__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_ICC>=1400)) \\\n      || EIGEN_COMP_MSVC >= 1900)\n    #define EIGEN_HAS_CXX11_CONTAINERS 1\n  #else\n    #define EIGEN_HAS_CXX11_CONTAINERS 0\n  #endif\n#endif\n\n// Does the compiler support C++11 noexcept?\n#ifndef EIGEN_HAS_CXX11_NOEXCEPT\n  #if    EIGEN_MAX_CPP_VER>=11 && \\\n         (__has_feature(cxx_noexcept) \\\n      || (__cplusplus > 201103L) \\\n      || ((__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_ICC>=1400)) \\\n      || EIGEN_COMP_MSVC >= 1900)\n    #define EIGEN_HAS_CXX11_NOEXCEPT 1\n  #else\n    #define EIGEN_HAS_CXX11_NOEXCEPT 0\n  #endif\n#endif\n\n/** Allows to disable some optimizations which might affect the accuracy of the result.\n  * Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them.\n  * They currently include:\n  *   - single precision ArrayBase::sin() and ArrayBase::cos() for SSE and AVX vectorization.\n  */\n#ifndef EIGEN_FAST_MATH\n#define EIGEN_FAST_MATH 1\n#endif\n\n#define EIGEN_DEBUG_VAR(x) std::cerr << #x << \" = \" << x << std::endl;\n\n// concatenate two tokens\n#define EIGEN_CAT2(a,b) a ## b\n#define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)\n\n#define EIGEN_COMMA ,\n\n// convert a token to a string\n#define EIGEN_MAKESTRING2(a) #a\n#define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)\n\n// EIGEN_STRONG_INLINE is a stronger version of the inline, using __forceinline on MSVC,\n// but it still doesn't use GCC's always_inline. This is useful in (common) situations where MSVC needs forceinline\n// but GCC is still doing fine with just inline.\n#if EIGEN_COMP_MSVC || EIGEN_COMP_ICC\n#define EIGEN_STRONG_INLINE __forceinline\n#else\n#define EIGEN_STRONG_INLINE inline\n#endif\n\n// EIGEN_ALWAYS_INLINE is the stronget, it has the effect of making the function inline and adding every possible\n// attribute to maximize inlining. This should only be used when really necessary: in particular,\n// it uses __attribute__((always_inline)) on GCC, which most of the time is useless and can severely harm compile times.\n// FIXME with the always_inline attribute,\n// gcc 3.4.x and 4.1 reports the following compilation error:\n//   Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const'\n//    : function body not available\n//   See also bug 1367\n#if EIGEN_GNUC_AT_LEAST(4,2)\n#define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline\n#else\n#define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE\n#endif\n\n#if EIGEN_COMP_GNUC\n#define EIGEN_DONT_INLINE __attribute__((noinline))\n#elif EIGEN_COMP_MSVC\n#define EIGEN_DONT_INLINE __declspec(noinline)\n#else\n#define EIGEN_DONT_INLINE\n#endif\n\n#if EIGEN_COMP_GNUC\n#define EIGEN_PERMISSIVE_EXPR __extension__\n#else\n#define EIGEN_PERMISSIVE_EXPR\n#endif\n\n// this macro allows to get rid of linking errors about multiply defined functions.\n//  - static is not very good because it prevents definitions from different object files to be merged.\n//           So static causes the resulting linked executable to be bloated with multiple copies of the same function.\n//  - inline is not perfect either as it unwantedly hints the compiler toward inlining the function.\n#define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS\n#define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS inline\n\n#ifdef NDEBUG\n# ifndef EIGEN_NO_DEBUG\n#  define EIGEN_NO_DEBUG\n# endif\n#endif\n\n// eigen_plain_assert is where we implement the workaround for the assert() bug in GCC <= 4.3, see bug 89\n#ifdef EIGEN_NO_DEBUG\n  #define eigen_plain_assert(x)\n#else\n  #if EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO\n    namespace Eigen {\n    namespace internal {\n    inline bool copy_bool(bool b) { return b; }\n    }\n    }\n    #define eigen_plain_assert(x) assert(x)\n  #else\n    // work around bug 89\n    #include <cstdlib>   // for abort\n    #include <iostream>  // for std::cerr\n\n    namespace Eigen {\n    namespace internal {\n    // trivial function copying a bool. Must be EIGEN_DONT_INLINE, so we implement it after including Eigen headers.\n    // see bug 89.\n    namespace {\n    EIGEN_DONT_INLINE bool copy_bool(bool b) { return b; }\n    }\n    inline void assert_fail(const char *condition, const char *function, const char *file, int line)\n    {\n      std::cerr << \"assertion failed: \" << condition << \" in function \" << function << \" at \" << file << \":\" << line << std::endl;\n      abort();\n    }\n    }\n    }\n    #define eigen_plain_assert(x) \\\n      do { \\\n        if(!Eigen::internal::copy_bool(x)) \\\n          Eigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \\\n      } while(false)\n  #endif\n#endif\n\n// eigen_assert can be overridden\n#ifndef eigen_assert\n#define eigen_assert(x) eigen_plain_assert(x)\n#endif\n\n#ifdef EIGEN_INTERNAL_DEBUGGING\n#define eigen_internal_assert(x) eigen_assert(x)\n#else\n#define eigen_internal_assert(x)\n#endif\n\n#ifdef EIGEN_NO_DEBUG\n#define EIGEN_ONLY_USED_FOR_DEBUG(x) EIGEN_UNUSED_VARIABLE(x)\n#else\n#define EIGEN_ONLY_USED_FOR_DEBUG(x)\n#endif\n\n#ifndef EIGEN_NO_DEPRECATED_WARNING\n  #if EIGEN_COMP_GNUC\n    #define EIGEN_DEPRECATED __attribute__((deprecated))\n  #elif EIGEN_COMP_MSVC\n    #define EIGEN_DEPRECATED __declspec(deprecated)\n  #else\n    #define EIGEN_DEPRECATED\n  #endif\n#else\n  #define EIGEN_DEPRECATED\n#endif\n\n#if EIGEN_COMP_GNUC\n#define EIGEN_UNUSED __attribute__((unused))\n#else\n#define EIGEN_UNUSED\n#endif\n\n// Suppresses 'unused variable' warnings.\nnamespace Eigen {\n  namespace internal {\n    template<typename T> EIGEN_DEVICE_FUNC void ignore_unused_variable(const T&) {}\n  }\n}\n#define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var);\n\n#if !defined(EIGEN_ASM_COMMENT)\n  #if EIGEN_COMP_GNUC && (EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64)\n    #define EIGEN_ASM_COMMENT(X)  __asm__(\"#\" X)\n  #else\n    #define EIGEN_ASM_COMMENT(X)\n  #endif\n#endif\n\n\n//------------------------------------------------------------------------------------------\n// Static and dynamic alignment control\n//\n// The main purpose of this section is to define EIGEN_MAX_ALIGN_BYTES and EIGEN_MAX_STATIC_ALIGN_BYTES\n// as the maximal boundary in bytes on which dynamically and statically allocated data may be alignment respectively.\n// The values of EIGEN_MAX_ALIGN_BYTES and EIGEN_MAX_STATIC_ALIGN_BYTES can be specified by the user. If not,\n// a default value is automatically computed based on architecture, compiler, and OS.\n//\n// This section also defines macros EIGEN_ALIGN_TO_BOUNDARY(N) and the shortcuts EIGEN_ALIGN{8,16,32,_MAX}\n// to be used to declare statically aligned buffers.\n//------------------------------------------------------------------------------------------\n\n\n/* EIGEN_ALIGN_TO_BOUNDARY(n) forces data to be n-byte aligned. This is used to satisfy SIMD requirements.\n * However, we do that EVEN if vectorization (EIGEN_VECTORIZE) is disabled,\n * so that vectorization doesn't affect binary compatibility.\n *\n * If we made alignment depend on whether or not EIGEN_VECTORIZE is defined, it would be impossible to link\n * vectorized and non-vectorized code.\n */\n#if (defined __CUDACC__)\n  #define EIGEN_ALIGN_TO_BOUNDARY(n) __align__(n)\n#elif EIGEN_COMP_GNUC || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM\n  #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))\n#elif EIGEN_COMP_MSVC\n  #define EIGEN_ALIGN_TO_BOUNDARY(n) __declspec(align(n))\n#elif EIGEN_COMP_SUNCC\n  // FIXME not sure about this one:\n  #define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))\n#else\n  #error Please tell me what is the equivalent of __attribute__((aligned(n))) for your compiler\n#endif\n\n// If the user explicitly disable vectorization, then we also disable alignment\n#if defined(EIGEN_DONT_VECTORIZE)\n  #define EIGEN_IDEAL_MAX_ALIGN_BYTES 0\n#elif defined(EIGEN_VECTORIZE_AVX512)\n  // 64 bytes static alignmeent is preferred only if really required\n  #define EIGEN_IDEAL_MAX_ALIGN_BYTES 64\n#elif defined(__AVX__)\n  // 32 bytes static alignmeent is preferred only if really required\n  #define EIGEN_IDEAL_MAX_ALIGN_BYTES 32\n#else\n  #define EIGEN_IDEAL_MAX_ALIGN_BYTES 16\n#endif\n\n\n// EIGEN_MIN_ALIGN_BYTES defines the minimal value for which the notion of explicit alignment makes sense\n#define EIGEN_MIN_ALIGN_BYTES 16\n\n// Defined the boundary (in bytes) on which the data needs to be aligned. Note\n// that unless EIGEN_ALIGN is defined and not equal to 0, the data may not be\n// aligned at all regardless of the value of this #define.\n\n#if (defined(EIGEN_DONT_ALIGN_STATICALLY) || defined(EIGEN_DONT_ALIGN))  && defined(EIGEN_MAX_STATIC_ALIGN_BYTES) && EIGEN_MAX_STATIC_ALIGN_BYTES>0\n#error EIGEN_MAX_STATIC_ALIGN_BYTES and EIGEN_DONT_ALIGN[_STATICALLY] are both defined with EIGEN_MAX_STATIC_ALIGN_BYTES!=0. Use EIGEN_MAX_STATIC_ALIGN_BYTES=0 as a synonym of EIGEN_DONT_ALIGN_STATICALLY.\n#endif\n\n// EIGEN_DONT_ALIGN_STATICALLY and EIGEN_DONT_ALIGN are deprectated\n// They imply EIGEN_MAX_STATIC_ALIGN_BYTES=0\n#if defined(EIGEN_DONT_ALIGN_STATICALLY) || defined(EIGEN_DONT_ALIGN)\n  #ifdef EIGEN_MAX_STATIC_ALIGN_BYTES\n    #undef EIGEN_MAX_STATIC_ALIGN_BYTES\n  #endif\n  #define EIGEN_MAX_STATIC_ALIGN_BYTES 0\n#endif\n\n#ifndef EIGEN_MAX_STATIC_ALIGN_BYTES\n\n  // Try to automatically guess what is the best default value for EIGEN_MAX_STATIC_ALIGN_BYTES\n\n  // 16 byte alignment is only useful for vectorization. Since it affects the ABI, we need to enable\n  // 16 byte alignment on all platforms where vectorization might be enabled. In theory we could always\n  // enable alignment, but it can be a cause of problems on some platforms, so we just disable it in\n  // certain common platform (compiler+architecture combinations) to avoid these problems.\n  // Only static alignment is really problematic (relies on nonstandard compiler extensions),\n  // try to keep heap alignment even when we have to disable static alignment.\n  #if EIGEN_COMP_GNUC && !(EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64 || EIGEN_ARCH_PPC || EIGEN_ARCH_IA64)\n  #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1\n  #elif EIGEN_ARCH_ARM_OR_ARM64 && EIGEN_COMP_GNUC_STRICT && EIGEN_GNUC_AT_MOST(4, 6)\n  // Old versions of GCC on ARM, at least 4.4, were once seen to have buggy static alignment support.\n  // Not sure which version fixed it, hopefully it doesn't affect 4.7, which is still somewhat in use.\n  // 4.8 and newer seem definitely unaffected.\n  #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1\n  #else\n  #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 0\n  #endif\n\n  // static alignment is completely disabled with GCC 3, Sun Studio, and QCC/QNX\n  #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT \\\n  && !EIGEN_GCC3_OR_OLDER \\\n  && !EIGEN_COMP_SUNCC \\\n  && !EIGEN_OS_QNX\n    #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 1\n  #else\n    #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 0\n  #endif\n\n  #if EIGEN_ARCH_WANTS_STACK_ALIGNMENT\n    #define EIGEN_MAX_STATIC_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES\n  #else\n    #define EIGEN_MAX_STATIC_ALIGN_BYTES 0\n  #endif\n\n#endif\n\n// If EIGEN_MAX_ALIGN_BYTES is defined, then it is considered as an upper bound for EIGEN_MAX_ALIGN_BYTES\n#if defined(EIGEN_MAX_ALIGN_BYTES) && EIGEN_MAX_ALIGN_BYTES<EIGEN_MAX_STATIC_ALIGN_BYTES\n#undef EIGEN_MAX_STATIC_ALIGN_BYTES\n#define EIGEN_MAX_STATIC_ALIGN_BYTES EIGEN_MAX_ALIGN_BYTES\n#endif\n\n#if EIGEN_MAX_STATIC_ALIGN_BYTES==0 && !defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)\n  #define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT\n#endif\n\n// At this stage, EIGEN_MAX_STATIC_ALIGN_BYTES>0 is the true test whether we want to align arrays on the stack or not.\n// It takes into account both the user choice to explicitly enable/disable alignment (by settting EIGEN_MAX_STATIC_ALIGN_BYTES)\n// and the architecture config (EIGEN_ARCH_WANTS_STACK_ALIGNMENT).\n// Henceforth, only EIGEN_MAX_STATIC_ALIGN_BYTES should be used.\n\n\n// Shortcuts to EIGEN_ALIGN_TO_BOUNDARY\n#define EIGEN_ALIGN8  EIGEN_ALIGN_TO_BOUNDARY(8)\n#define EIGEN_ALIGN16 EIGEN_ALIGN_TO_BOUNDARY(16)\n#define EIGEN_ALIGN32 EIGEN_ALIGN_TO_BOUNDARY(32)\n#define EIGEN_ALIGN64 EIGEN_ALIGN_TO_BOUNDARY(64)\n#if EIGEN_MAX_STATIC_ALIGN_BYTES>0\n#define EIGEN_ALIGN_MAX EIGEN_ALIGN_TO_BOUNDARY(EIGEN_MAX_STATIC_ALIGN_BYTES)\n#else\n#define EIGEN_ALIGN_MAX\n#endif\n\n\n// Dynamic alignment control\n\n#if defined(EIGEN_DONT_ALIGN) && defined(EIGEN_MAX_ALIGN_BYTES) && EIGEN_MAX_ALIGN_BYTES>0\n#error EIGEN_MAX_ALIGN_BYTES and EIGEN_DONT_ALIGN are both defined with EIGEN_MAX_ALIGN_BYTES!=0. Use EIGEN_MAX_ALIGN_BYTES=0 as a synonym of EIGEN_DONT_ALIGN.\n#endif\n\n#ifdef EIGEN_DONT_ALIGN\n  #ifdef EIGEN_MAX_ALIGN_BYTES\n    #undef EIGEN_MAX_ALIGN_BYTES\n  #endif\n  #define EIGEN_MAX_ALIGN_BYTES 0\n#elif !defined(EIGEN_MAX_ALIGN_BYTES)\n  #define EIGEN_MAX_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES\n#endif\n\n#if EIGEN_IDEAL_MAX_ALIGN_BYTES > EIGEN_MAX_ALIGN_BYTES\n#define EIGEN_DEFAULT_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES\n#else\n#define EIGEN_DEFAULT_ALIGN_BYTES EIGEN_MAX_ALIGN_BYTES\n#endif\n\n\n#ifndef EIGEN_UNALIGNED_VECTORIZE\n#define EIGEN_UNALIGNED_VECTORIZE 1\n#endif\n\n//----------------------------------------------------------------------\n\n\n#ifdef EIGEN_DONT_USE_RESTRICT_KEYWORD\n  #define EIGEN_RESTRICT\n#endif\n#ifndef EIGEN_RESTRICT\n  #define EIGEN_RESTRICT __restrict\n#endif\n\n#ifndef EIGEN_STACK_ALLOCATION_LIMIT\n// 131072 == 128 KB\n#define EIGEN_STACK_ALLOCATION_LIMIT 131072\n#endif\n\n#ifndef EIGEN_DEFAULT_IO_FORMAT\n#ifdef EIGEN_MAKING_DOCS\n// format used in Eigen's documentation\n// needed to define it here as escaping characters in CMake add_definition's argument seems very problematic.\n#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat(3, 0, \" \", \"\\n\", \"\", \"\")\n#else\n#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()\n#endif\n#endif\n\n// just an empty macro !\n#define EIGEN_EMPTY\n\n#if EIGEN_COMP_MSVC_STRICT && (EIGEN_COMP_MSVC < 1900 ||  defined(__CUDACC_VER__)) // for older MSVC versions, as well as 1900 && CUDA 8, using the base operator is sufficient (cf Bugs 1000, 1324)\n  #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \\\n    using Base::operator =;\n#elif EIGEN_COMP_CLANG // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653)\n  #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \\\n    using Base::operator =; \\\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) { Base::operator=(other); return *this; } \\\n    template <typename OtherDerived> \\\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const DenseBase<OtherDerived>& other) { Base::operator=(other.derived()); return *this; }\n#else\n  #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \\\n    using Base::operator =; \\\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \\\n    { \\\n      Base::operator=(other); \\\n      return *this; \\\n    }\n#endif\n\n\n/** \\internal\n * \\brief Macro to manually inherit assignment operators.\n * This is necessary, because the implicitly defined assignment operator gets deleted when a custom operator= is defined.\n */\n#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)\n\n/**\n* Just a side note. Commenting within defines works only by documenting\n* behind the object (via '!<'). Comments cannot be multi-line and thus\n* we have these extra long lines. What is confusing doxygen over here is\n* that we use '\\' and basically have a bunch of typedefs with their\n* documentation in a single line.\n**/\n\n#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \\\n  typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; /*!< \\brief Numeric type, e.g. float, double, int or std::complex<float>. */ \\\n  typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; /*!< \\brief The underlying numeric type for composed scalar types. \\details In cases where Scalar is e.g. std::complex<T>, T were corresponding to RealScalar. */ \\\n  typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \\brief The return type for coefficient access. \\details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \\\n  typedef typename Eigen::internal::ref_selector<Derived>::type Nested; \\\n  typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \\\n  typedef typename Eigen::internal::traits<Derived>::StorageIndex StorageIndex; \\\n  enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \\\n        ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \\\n        Flags = Eigen::internal::traits<Derived>::Flags, \\\n        SizeAtCompileTime = Base::SizeAtCompileTime, \\\n        MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \\\n        IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \\\n  using Base::derived; \\\n  using Base::const_cast_derived;\n\n\n// FIXME Maybe the EIGEN_DENSE_PUBLIC_INTERFACE could be removed as importing PacketScalar is rarely needed\n#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \\\n  EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \\\n  typedef typename Base::PacketScalar PacketScalar;\n\n\n#define EIGEN_PLAIN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)\n#define EIGEN_PLAIN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b)\n\n// EIGEN_SIZE_MIN_PREFER_DYNAMIC gives the min between compile-time sizes. 0 has absolute priority, followed by 1,\n// followed by Dynamic, followed by other finite values. The reason for giving Dynamic the priority over\n// finite values is that min(3, Dynamic) should be Dynamic, since that could be anything between 0 and 3.\n#define EIGEN_SIZE_MIN_PREFER_DYNAMIC(a,b) (((int)a == 0 || (int)b == 0) ? 0 \\\n                           : ((int)a == 1 || (int)b == 1) ? 1 \\\n                           : ((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \\\n                           : ((int)a <= (int)b) ? (int)a : (int)b)\n\n// EIGEN_SIZE_MIN_PREFER_FIXED is a variant of EIGEN_SIZE_MIN_PREFER_DYNAMIC comparing MaxSizes. The difference is that finite values\n// now have priority over Dynamic, so that min(3, Dynamic) gives 3. Indeed, whatever the actual value is\n// (between 0 and 3), it is not more than 3.\n#define EIGEN_SIZE_MIN_PREFER_FIXED(a,b)  (((int)a == 0 || (int)b == 0) ? 0 \\\n                           : ((int)a == 1 || (int)b == 1) ? 1 \\\n                           : ((int)a == Dynamic && (int)b == Dynamic) ? Dynamic \\\n                           : ((int)a == Dynamic) ? (int)b \\\n                           : ((int)b == Dynamic) ? (int)a \\\n                           : ((int)a <= (int)b) ? (int)a : (int)b)\n\n// see EIGEN_SIZE_MIN_PREFER_DYNAMIC. No need for a separate variant for MaxSizes here.\n#define EIGEN_SIZE_MAX(a,b) (((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \\\n                           : ((int)a >= (int)b) ? (int)a : (int)b)\n\n#define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b)))\n\n#define EIGEN_IMPLIES(a,b) (!(a) || (b))\n\n// the expression type of a standard coefficient wise binary operation\n#define EIGEN_CWISE_BINARY_RETURN_TYPE(LHS,RHS,OPNAME) \\\n    CwiseBinaryOp< \\\n      EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)< \\\n          typename internal::traits<LHS>::Scalar, \\\n          typename internal::traits<RHS>::Scalar \\\n      >, \\\n      const LHS, \\\n      const RHS \\\n    >\n\n#define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,OPNAME) \\\n  template<typename OtherDerived> \\\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,OPNAME) \\\n  (METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \\\n  { \\\n    return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,OPNAME)(derived(), other.derived()); \\\n  }\n\n#define EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,TYPEA,TYPEB) \\\n  (Eigen::internal::has_ReturnType<Eigen::ScalarBinaryOpTraits<TYPEA,TYPEB,EIGEN_CAT(EIGEN_CAT(Eigen::internal::scalar_,OPNAME),_op)<TYPEA,TYPEB>  > >::value)\n\n#define EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(EXPR,SCALAR,OPNAME) \\\n  CwiseBinaryOp<EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<typename internal::traits<EXPR>::Scalar,SCALAR>, const EXPR, \\\n                const typename internal::plain_constant_type<EXPR,SCALAR>::type>\n\n#define EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(SCALAR,EXPR,OPNAME) \\\n  CwiseBinaryOp<EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<SCALAR,typename internal::traits<EXPR>::Scalar>, \\\n                const typename internal::plain_constant_type<EXPR,SCALAR>::type, const EXPR>\n\n// Workaround for MSVC 2010 (see ML thread \"patch with compile for for MSVC 2010\")\n#if EIGEN_COMP_MSVC_STRICT<=1600\n#define EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(X) typename internal::enable_if<true,X>::type\n#else\n#define EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(X) X\n#endif\n\n#define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME) \\\n  template <typename T> EIGEN_DEVICE_FUNC inline \\\n  EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,typename internal::promote_scalar_arg<Scalar EIGEN_COMMA T EIGEN_COMMA EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,Scalar,T)>::type,OPNAME))\\\n  (METHOD)(const T& scalar) const { \\\n    typedef typename internal::promote_scalar_arg<Scalar,T,EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,Scalar,T)>::type PromotedT; \\\n    return EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,PromotedT,OPNAME)(derived(), \\\n           typename internal::plain_constant_type<Derived,PromotedT>::type(derived().rows(), derived().cols(), internal::scalar_constant_op<PromotedT>(scalar))); \\\n  }\n\n#define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \\\n  template <typename T> EIGEN_DEVICE_FUNC inline friend \\\n  EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename internal::promote_scalar_arg<Scalar EIGEN_COMMA T EIGEN_COMMA EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,T,Scalar)>::type,Derived,OPNAME)) \\\n  (METHOD)(const T& scalar, const StorageBaseType& matrix) { \\\n    typedef typename internal::promote_scalar_arg<Scalar,T,EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,T,Scalar)>::type PromotedT; \\\n    return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(PromotedT,Derived,OPNAME)( \\\n           typename internal::plain_constant_type<Derived,PromotedT>::type(matrix.derived().rows(), matrix.derived().cols(), internal::scalar_constant_op<PromotedT>(scalar)), matrix.derived()); \\\n  }\n\n#define EIGEN_MAKE_SCALAR_BINARY_OP(METHOD,OPNAME) \\\n  EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \\\n  EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME)\n\n\n#ifdef EIGEN_EXCEPTIONS\n#  define EIGEN_THROW_X(X) throw X\n#  define EIGEN_THROW throw\n#  define EIGEN_TRY try\n#  define EIGEN_CATCH(X) catch (X)\n#else\n#  ifdef __CUDA_ARCH__\n#    define EIGEN_THROW_X(X) asm(\"trap;\")\n#    define EIGEN_THROW asm(\"trap;\")\n#  else\n#    define EIGEN_THROW_X(X) std::abort()\n#    define EIGEN_THROW std::abort()\n#  endif\n#  define EIGEN_TRY if (true)\n#  define EIGEN_CATCH(X) else\n#endif\n\n\n#if EIGEN_HAS_CXX11_NOEXCEPT\n#   define EIGEN_INCLUDE_TYPE_TRAITS\n#   define EIGEN_NOEXCEPT noexcept\n#   define EIGEN_NOEXCEPT_IF(x) noexcept(x)\n#   define EIGEN_NO_THROW noexcept(true)\n#   define EIGEN_EXCEPTION_SPEC(X) noexcept(false)\n#else\n#   define EIGEN_NOEXCEPT\n#   define EIGEN_NOEXCEPT_IF(x)\n#   define EIGEN_NO_THROW throw()\n#   define EIGEN_EXCEPTION_SPEC(X) throw(X)\n#endif\n\n#endif // EIGEN_MACROS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/Memory.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2008-2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2009 Kenneth Riddile <kfriddile@yahoo.com>\n// Copyright (C) 2010 Hauke Heibel <hauke.heibel@gmail.com>\n// Copyright (C) 2010 Thomas Capricelli <orzel@freehackers.org>\n// Copyright (C) 2013 Pavel Holoborodko <pavel@holoborodko.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n\n/*****************************************************************************\n*** Platform checks for aligned malloc functions                           ***\n*****************************************************************************/\n\n#ifndef EIGEN_MEMORY_H\n#define EIGEN_MEMORY_H\n\n#ifndef EIGEN_MALLOC_ALREADY_ALIGNED\n\n// Try to determine automatically if malloc is already aligned.\n\n// On 64-bit systems, glibc's malloc returns 16-byte-aligned pointers, see:\n//   http://www.gnu.org/s/libc/manual/html_node/Aligned-Memory-Blocks.html\n// This is true at least since glibc 2.8.\n// This leaves the question how to detect 64-bit. According to this document,\n//   http://gcc.fyxm.net/summit/2003/Porting%20to%2064%20bit.pdf\n// page 114, \"[The] LP64 model [...] is used by all 64-bit UNIX ports\" so it's indeed\n// quite safe, at least within the context of glibc, to equate 64-bit with LP64.\n#if defined(__GLIBC__) && ((__GLIBC__>=2 && __GLIBC_MINOR__ >= 8) || __GLIBC__>2) \\\n && defined(__LP64__) && ! defined( __SANITIZE_ADDRESS__ ) && (EIGEN_DEFAULT_ALIGN_BYTES == 16)\n  #define EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED 1\n#else\n  #define EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED 0\n#endif\n\n// FreeBSD 6 seems to have 16-byte aligned malloc\n//   See http://svn.freebsd.org/viewvc/base/stable/6/lib/libc/stdlib/malloc.c?view=markup\n// FreeBSD 7 seems to have 16-byte aligned malloc except on ARM and MIPS architectures\n//   See http://svn.freebsd.org/viewvc/base/stable/7/lib/libc/stdlib/malloc.c?view=markup\n#if defined(__FreeBSD__) && !(EIGEN_ARCH_ARM || EIGEN_ARCH_MIPS) && (EIGEN_DEFAULT_ALIGN_BYTES == 16)\n  #define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 1\n#else\n  #define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 0\n#endif\n\n#if (EIGEN_OS_MAC && (EIGEN_DEFAULT_ALIGN_BYTES == 16))     \\\n || (EIGEN_OS_WIN64 && (EIGEN_DEFAULT_ALIGN_BYTES == 16))   \\\n || EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED              \\\n || EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED\n  #define EIGEN_MALLOC_ALREADY_ALIGNED 1\n#else\n  #define EIGEN_MALLOC_ALREADY_ALIGNED 0\n#endif\n\n#endif\n\nnamespace Eigen {\n\nnamespace internal {\n\nEIGEN_DEVICE_FUNC \ninline void throw_std_bad_alloc()\n{\n  #ifdef EIGEN_EXCEPTIONS\n    throw std::bad_alloc();\n  #else\n    std::size_t huge = static_cast<std::size_t>(-1);\n    new int[huge];\n  #endif\n}\n\n/*****************************************************************************\n*** Implementation of handmade aligned functions                           ***\n*****************************************************************************/\n\n/* ----- Hand made implementations of aligned malloc/free and realloc ----- */\n\n/** \\internal Like malloc, but the returned pointer is guaranteed to be 16-byte aligned.\n  * Fast, but wastes 16 additional bytes of memory. Does not throw any exception.\n  */\ninline void* handmade_aligned_malloc(std::size_t size)\n{\n  void *original = std::malloc(size+EIGEN_DEFAULT_ALIGN_BYTES);\n  if (original == 0) return 0;\n  void *aligned = reinterpret_cast<void*>((reinterpret_cast<std::size_t>(original) & ~(std::size_t(EIGEN_DEFAULT_ALIGN_BYTES-1))) + EIGEN_DEFAULT_ALIGN_BYTES);\n  *(reinterpret_cast<void**>(aligned) - 1) = original;\n  return aligned;\n}\n\n/** \\internal Frees memory allocated with handmade_aligned_malloc */\ninline void handmade_aligned_free(void *ptr)\n{\n  if (ptr) std::free(*(reinterpret_cast<void**>(ptr) - 1));\n}\n\n/** \\internal\n  * \\brief Reallocates aligned memory.\n  * Since we know that our handmade version is based on std::malloc\n  * we can use std::realloc to implement efficient reallocation.\n  */\ninline void* handmade_aligned_realloc(void* ptr, std::size_t size, std::size_t = 0)\n{\n  if (ptr == 0) return handmade_aligned_malloc(size);\n  void *original = *(reinterpret_cast<void**>(ptr) - 1);\n  std::ptrdiff_t previous_offset = static_cast<char *>(ptr)-static_cast<char *>(original);\n  original = std::realloc(original,size+EIGEN_DEFAULT_ALIGN_BYTES);\n  if (original == 0) return 0;\n  void *aligned = reinterpret_cast<void*>((reinterpret_cast<std::size_t>(original) & ~(std::size_t(EIGEN_DEFAULT_ALIGN_BYTES-1))) + EIGEN_DEFAULT_ALIGN_BYTES);\n  void *previous_aligned = static_cast<char *>(original)+previous_offset;\n  if(aligned!=previous_aligned)\n    std::memmove(aligned, previous_aligned, size);\n  \n  *(reinterpret_cast<void**>(aligned) - 1) = original;\n  return aligned;\n}\n\n/*****************************************************************************\n*** Implementation of portable aligned versions of malloc/free/realloc     ***\n*****************************************************************************/\n\n#ifdef EIGEN_NO_MALLOC\nEIGEN_DEVICE_FUNC inline void check_that_malloc_is_allowed()\n{\n  eigen_assert(false && \"heap allocation is forbidden (EIGEN_NO_MALLOC is defined)\");\n}\n#elif defined EIGEN_RUNTIME_NO_MALLOC\nEIGEN_DEVICE_FUNC inline bool is_malloc_allowed_impl(bool update, bool new_value = false)\n{\n  static bool value = true;\n  if (update == 1)\n    value = new_value;\n  return value;\n}\nEIGEN_DEVICE_FUNC inline bool is_malloc_allowed() { return is_malloc_allowed_impl(false); }\nEIGEN_DEVICE_FUNC inline bool set_is_malloc_allowed(bool new_value) { return is_malloc_allowed_impl(true, new_value); }\nEIGEN_DEVICE_FUNC inline void check_that_malloc_is_allowed()\n{\n  eigen_assert(is_malloc_allowed() && \"heap allocation is forbidden (EIGEN_RUNTIME_NO_MALLOC is defined and g_is_malloc_allowed is false)\");\n}\n#else \nEIGEN_DEVICE_FUNC inline void check_that_malloc_is_allowed()\n{}\n#endif\n\n/** \\internal Allocates \\a size bytes. The returned pointer is guaranteed to have 16 or 32 bytes alignment depending on the requirements.\n  * On allocation error, the returned pointer is null, and std::bad_alloc is thrown.\n  */\nEIGEN_DEVICE_FUNC inline void* aligned_malloc(std::size_t size)\n{\n  check_that_malloc_is_allowed();\n\n  void *result;\n  #if (EIGEN_DEFAULT_ALIGN_BYTES==0) || EIGEN_MALLOC_ALREADY_ALIGNED\n    result = std::malloc(size);\n    #if EIGEN_DEFAULT_ALIGN_BYTES==16\n    eigen_assert((size<16 || (std::size_t(result)%16)==0) && \"System's malloc returned an unaligned pointer. Compile with EIGEN_MALLOC_ALREADY_ALIGNED=0 to fallback to handmade alignd memory allocator.\");\n    #endif\n  #else\n    result = handmade_aligned_malloc(size);\n  #endif\n\n  if(!result && size)\n    throw_std_bad_alloc();\n\n  return result;\n}\n\n/** \\internal Frees memory allocated with aligned_malloc. */\nEIGEN_DEVICE_FUNC inline void aligned_free(void *ptr)\n{\n  #if (EIGEN_DEFAULT_ALIGN_BYTES==0) || EIGEN_MALLOC_ALREADY_ALIGNED\n    std::free(ptr);\n  #else\n    handmade_aligned_free(ptr);\n  #endif\n}\n\n/**\n  * \\internal\n  * \\brief Reallocates an aligned block of memory.\n  * \\throws std::bad_alloc on allocation failure\n  */\ninline void* aligned_realloc(void *ptr, std::size_t new_size, std::size_t old_size)\n{\n  EIGEN_UNUSED_VARIABLE(old_size);\n\n  void *result;\n#if (EIGEN_DEFAULT_ALIGN_BYTES==0) || EIGEN_MALLOC_ALREADY_ALIGNED\n  result = std::realloc(ptr,new_size);\n#else\n  result = handmade_aligned_realloc(ptr,new_size,old_size);\n#endif\n\n  if (!result && new_size)\n    throw_std_bad_alloc();\n\n  return result;\n}\n\n/*****************************************************************************\n*** Implementation of conditionally aligned functions                      ***\n*****************************************************************************/\n\n/** \\internal Allocates \\a size bytes. If Align is true, then the returned ptr is 16-byte-aligned.\n  * On allocation error, the returned pointer is null, and a std::bad_alloc is thrown.\n  */\ntemplate<bool Align> EIGEN_DEVICE_FUNC inline void* conditional_aligned_malloc(std::size_t size)\n{\n  return aligned_malloc(size);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void* conditional_aligned_malloc<false>(std::size_t size)\n{\n  check_that_malloc_is_allowed();\n\n  void *result = std::malloc(size);\n  if(!result && size)\n    throw_std_bad_alloc();\n  return result;\n}\n\n/** \\internal Frees memory allocated with conditional_aligned_malloc */\ntemplate<bool Align> EIGEN_DEVICE_FUNC inline void conditional_aligned_free(void *ptr)\n{\n  aligned_free(ptr);\n}\n\ntemplate<> EIGEN_DEVICE_FUNC inline void conditional_aligned_free<false>(void *ptr)\n{\n  std::free(ptr);\n}\n\ntemplate<bool Align> inline void* conditional_aligned_realloc(void* ptr, std::size_t new_size, std::size_t old_size)\n{\n  return aligned_realloc(ptr, new_size, old_size);\n}\n\ntemplate<> inline void* conditional_aligned_realloc<false>(void* ptr, std::size_t new_size, std::size_t)\n{\n  return std::realloc(ptr, new_size);\n}\n\n/*****************************************************************************\n*** Construction/destruction of array elements                             ***\n*****************************************************************************/\n\n/** \\internal Destructs the elements of an array.\n  * The \\a size parameters tells on how many objects to call the destructor of T.\n  */\ntemplate<typename T> EIGEN_DEVICE_FUNC inline void destruct_elements_of_array(T *ptr, std::size_t size)\n{\n  // always destruct an array starting from the end.\n  if(ptr)\n    while(size) ptr[--size].~T();\n}\n\n/** \\internal Constructs the elements of an array.\n  * The \\a size parameter tells on how many objects to call the constructor of T.\n  */\ntemplate<typename T> EIGEN_DEVICE_FUNC inline T* construct_elements_of_array(T *ptr, std::size_t size)\n{\n  std::size_t i;\n  EIGEN_TRY\n  {\n      for (i = 0; i < size; ++i) ::new (ptr + i) T;\n      return ptr;\n  }\n  EIGEN_CATCH(...)\n  {\n    destruct_elements_of_array(ptr, i);\n    EIGEN_THROW;\n  }\n  return NULL;\n}\n\n/*****************************************************************************\n*** Implementation of aligned new/delete-like functions                    ***\n*****************************************************************************/\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void check_size_for_overflow(std::size_t size)\n{\n  if(size > std::size_t(-1) / sizeof(T))\n    throw_std_bad_alloc();\n}\n\n/** \\internal Allocates \\a size objects of type T. The returned pointer is guaranteed to have 16 bytes alignment.\n  * On allocation error, the returned pointer is undefined, but a std::bad_alloc is thrown.\n  * The default constructor of T is called.\n  */\ntemplate<typename T> EIGEN_DEVICE_FUNC inline T* aligned_new(std::size_t size)\n{\n  check_size_for_overflow<T>(size);\n  T *result = reinterpret_cast<T*>(aligned_malloc(sizeof(T)*size));\n  EIGEN_TRY\n  {\n    return construct_elements_of_array(result, size);\n  }\n  EIGEN_CATCH(...)\n  {\n    aligned_free(result);\n    EIGEN_THROW;\n  }\n  return result;\n}\n\ntemplate<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned_new(std::size_t size)\n{\n  check_size_for_overflow<T>(size);\n  T *result = reinterpret_cast<T*>(conditional_aligned_malloc<Align>(sizeof(T)*size));\n  EIGEN_TRY\n  {\n    return construct_elements_of_array(result, size);\n  }\n  EIGEN_CATCH(...)\n  {\n    conditional_aligned_free<Align>(result);\n    EIGEN_THROW;\n  }\n  return result;\n}\n\n/** \\internal Deletes objects constructed with aligned_new\n  * The \\a size parameters tells on how many objects to call the destructor of T.\n  */\ntemplate<typename T> EIGEN_DEVICE_FUNC inline void aligned_delete(T *ptr, std::size_t size)\n{\n  destruct_elements_of_array<T>(ptr, size);\n  aligned_free(ptr);\n}\n\n/** \\internal Deletes objects constructed with conditional_aligned_new\n  * The \\a size parameters tells on how many objects to call the destructor of T.\n  */\ntemplate<typename T, bool Align> EIGEN_DEVICE_FUNC inline void conditional_aligned_delete(T *ptr, std::size_t size)\n{\n  destruct_elements_of_array<T>(ptr, size);\n  conditional_aligned_free<Align>(ptr);\n}\n\ntemplate<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned_realloc_new(T* pts, std::size_t new_size, std::size_t old_size)\n{\n  check_size_for_overflow<T>(new_size);\n  check_size_for_overflow<T>(old_size);\n  if(new_size < old_size)\n    destruct_elements_of_array(pts+new_size, old_size-new_size);\n  T *result = reinterpret_cast<T*>(conditional_aligned_realloc<Align>(reinterpret_cast<void*>(pts), sizeof(T)*new_size, sizeof(T)*old_size));\n  if(new_size > old_size)\n  {\n    EIGEN_TRY\n    {\n      construct_elements_of_array(result+old_size, new_size-old_size);\n    }\n    EIGEN_CATCH(...)\n    {\n      conditional_aligned_free<Align>(result);\n      EIGEN_THROW;\n    }\n  }\n  return result;\n}\n\n\ntemplate<typename T, bool Align> EIGEN_DEVICE_FUNC inline T* conditional_aligned_new_auto(std::size_t size)\n{\n  if(size==0)\n    return 0; // short-cut. Also fixes Bug 884\n  check_size_for_overflow<T>(size);\n  T *result = reinterpret_cast<T*>(conditional_aligned_malloc<Align>(sizeof(T)*size));\n  if(NumTraits<T>::RequireInitialization)\n  {\n    EIGEN_TRY\n    {\n      construct_elements_of_array(result, size);\n    }\n    EIGEN_CATCH(...)\n    {\n      conditional_aligned_free<Align>(result);\n      EIGEN_THROW;\n    }\n  }\n  return result;\n}\n\ntemplate<typename T, bool Align> inline T* conditional_aligned_realloc_new_auto(T* pts, std::size_t new_size, std::size_t old_size)\n{\n  check_size_for_overflow<T>(new_size);\n  check_size_for_overflow<T>(old_size);\n  if(NumTraits<T>::RequireInitialization && (new_size < old_size))\n    destruct_elements_of_array(pts+new_size, old_size-new_size);\n  T *result = reinterpret_cast<T*>(conditional_aligned_realloc<Align>(reinterpret_cast<void*>(pts), sizeof(T)*new_size, sizeof(T)*old_size));\n  if(NumTraits<T>::RequireInitialization && (new_size > old_size))\n  {\n    EIGEN_TRY\n    {\n      construct_elements_of_array(result+old_size, new_size-old_size);\n    }\n    EIGEN_CATCH(...)\n    {\n      conditional_aligned_free<Align>(result);\n      EIGEN_THROW;\n    }\n  }\n  return result;\n}\n\ntemplate<typename T, bool Align> EIGEN_DEVICE_FUNC inline void conditional_aligned_delete_auto(T *ptr, std::size_t size)\n{\n  if(NumTraits<T>::RequireInitialization)\n    destruct_elements_of_array<T>(ptr, size);\n  conditional_aligned_free<Align>(ptr);\n}\n\n/****************************************************************************/\n\n/** \\internal Returns the index of the first element of the array that is well aligned with respect to the requested \\a Alignment.\n  *\n  * \\tparam Alignment requested alignment in Bytes.\n  * \\param array the address of the start of the array\n  * \\param size the size of the array\n  *\n  * \\note If no element of the array is well aligned or the requested alignment is not a multiple of a scalar,\n  * the size of the array is returned. For example with SSE, the requested alignment is typically 16-bytes. If\n  * packet size for the given scalar type is 1, then everything is considered well-aligned.\n  *\n  * \\note Otherwise, if the Alignment is larger that the scalar size, we rely on the assumptions that sizeof(Scalar) is a\n  * power of 2. On the other hand, we do not assume that the array address is a multiple of sizeof(Scalar), as that fails for\n  * example with Scalar=double on certain 32-bit platforms, see bug #79.\n  *\n  * There is also the variant first_aligned(const MatrixBase&) defined in DenseCoeffsBase.h.\n  * \\sa first_default_aligned()\n  */\ntemplate<int Alignment, typename Scalar, typename Index>\nEIGEN_DEVICE_FUNC inline Index first_aligned(const Scalar* array, Index size)\n{\n  const Index ScalarSize = sizeof(Scalar);\n  const Index AlignmentSize = Alignment / ScalarSize;\n  const Index AlignmentMask = AlignmentSize-1;\n\n  if(AlignmentSize<=1)\n  {\n    // Either the requested alignment if smaller than a scalar, or it exactly match a 1 scalar\n    // so that all elements of the array have the same alignment.\n    return 0;\n  }\n  else if( (UIntPtr(array) & (sizeof(Scalar)-1)) || (Alignment%ScalarSize)!=0)\n  {\n    // The array is not aligned to the size of a single scalar, or the requested alignment is not a multiple of the scalar size.\n    // Consequently, no element of the array is well aligned.\n    return size;\n  }\n  else\n  {\n    Index first = (AlignmentSize - (Index((UIntPtr(array)/sizeof(Scalar))) & AlignmentMask)) & AlignmentMask;\n    return (first < size) ? first : size;\n  }\n}\n\n/** \\internal Returns the index of the first element of the array that is well aligned with respect the largest packet requirement.\n   * \\sa first_aligned(Scalar*,Index) and first_default_aligned(DenseBase<Derived>) */\ntemplate<typename Scalar, typename Index>\nEIGEN_DEVICE_FUNC inline Index first_default_aligned(const Scalar* array, Index size)\n{\n  typedef typename packet_traits<Scalar>::type DefaultPacketType;\n  return first_aligned<unpacket_traits<DefaultPacketType>::alignment>(array, size);\n}\n\n/** \\internal Returns the smallest integer multiple of \\a base and greater or equal to \\a size\n  */ \ntemplate<typename Index> \ninline Index first_multiple(Index size, Index base)\n{\n  return ((size+base-1)/base)*base;\n}\n\n// std::copy is much slower than memcpy, so let's introduce a smart_copy which\n// use memcpy on trivial types, i.e., on types that does not require an initialization ctor.\ntemplate<typename T, bool UseMemcpy> struct smart_copy_helper;\n\ntemplate<typename T> EIGEN_DEVICE_FUNC void smart_copy(const T* start, const T* end, T* target)\n{\n  smart_copy_helper<T,!NumTraits<T>::RequireInitialization>::run(start, end, target);\n}\n\ntemplate<typename T> struct smart_copy_helper<T,true> {\n  EIGEN_DEVICE_FUNC static inline void run(const T* start, const T* end, T* target)\n  {\n    IntPtr size = IntPtr(end)-IntPtr(start);\n    if(size==0) return;\n    eigen_internal_assert(start!=0 && end!=0 && target!=0);\n    memcpy(target, start, size);\n  }\n};\n\ntemplate<typename T> struct smart_copy_helper<T,false> {\n  EIGEN_DEVICE_FUNC static inline void run(const T* start, const T* end, T* target)\n  { std::copy(start, end, target); }\n};\n\n// intelligent memmove. falls back to std::memmove for POD types, uses std::copy otherwise. \ntemplate<typename T, bool UseMemmove> struct smart_memmove_helper;\n\ntemplate<typename T> void smart_memmove(const T* start, const T* end, T* target)\n{\n  smart_memmove_helper<T,!NumTraits<T>::RequireInitialization>::run(start, end, target);\n}\n\ntemplate<typename T> struct smart_memmove_helper<T,true> {\n  static inline void run(const T* start, const T* end, T* target)\n  {\n    IntPtr size = IntPtr(end)-IntPtr(start);\n    if(size==0) return;\n    eigen_internal_assert(start!=0 && end!=0 && target!=0);\n    std::memmove(target, start, size);\n  }\n};\n\ntemplate<typename T> struct smart_memmove_helper<T,false> {\n  static inline void run(const T* start, const T* end, T* target)\n  { \n    if (UIntPtr(target) < UIntPtr(start))\n    {\n      std::copy(start, end, target);\n    }\n    else                                 \n    {\n      std::ptrdiff_t count = (std::ptrdiff_t(end)-std::ptrdiff_t(start)) / sizeof(T);\n      std::copy_backward(start, end, target + count); \n    }\n  }\n};\n\n\n/*****************************************************************************\n*** Implementation of runtime stack allocation (falling back to malloc)    ***\n*****************************************************************************/\n\n// you can overwrite Eigen's default behavior regarding alloca by defining EIGEN_ALLOCA\n// to the appropriate stack allocation function\n#ifndef EIGEN_ALLOCA\n  #if EIGEN_OS_LINUX || EIGEN_OS_MAC || (defined alloca)\n    #define EIGEN_ALLOCA alloca\n  #elif EIGEN_COMP_MSVC\n    #define EIGEN_ALLOCA _alloca\n  #endif\n#endif\n\n// This helper class construct the allocated memory, and takes care of destructing and freeing the handled data\n// at destruction time. In practice this helper class is mainly useful to avoid memory leak in case of exceptions.\ntemplate<typename T> class aligned_stack_memory_handler : noncopyable\n{\n  public:\n    /* Creates a stack_memory_handler responsible for the buffer \\a ptr of size \\a size.\n     * Note that \\a ptr can be 0 regardless of the other parameters.\n     * This constructor takes care of constructing/initializing the elements of the buffer if required by the scalar type T (see NumTraits<T>::RequireInitialization).\n     * In this case, the buffer elements will also be destructed when this handler will be destructed.\n     * Finally, if \\a dealloc is true, then the pointer \\a ptr is freed.\n     **/\n    aligned_stack_memory_handler(T* ptr, std::size_t size, bool dealloc)\n      : m_ptr(ptr), m_size(size), m_deallocate(dealloc)\n    {\n      if(NumTraits<T>::RequireInitialization && m_ptr)\n        Eigen::internal::construct_elements_of_array(m_ptr, size);\n    }\n    ~aligned_stack_memory_handler()\n    {\n      if(NumTraits<T>::RequireInitialization && m_ptr)\n        Eigen::internal::destruct_elements_of_array<T>(m_ptr, m_size);\n      if(m_deallocate)\n        Eigen::internal::aligned_free(m_ptr);\n    }\n  protected:\n    T* m_ptr;\n    std::size_t m_size;\n    bool m_deallocate;\n};\n\ntemplate<typename T> class scoped_array : noncopyable\n{\n  T* m_ptr;\npublic:\n  explicit scoped_array(std::ptrdiff_t size)\n  {\n    m_ptr = new T[size];\n  }\n  ~scoped_array()\n  {\n    delete[] m_ptr;\n  }\n  T& operator[](std::ptrdiff_t i) { return m_ptr[i]; }\n  const T& operator[](std::ptrdiff_t i) const { return m_ptr[i]; }\n  T* &ptr() { return m_ptr; }\n  const T* ptr() const { return m_ptr; }\n  operator const T*() const { return m_ptr; }\n};\n\ntemplate<typename T> void swap(scoped_array<T> &a,scoped_array<T> &b)\n{\n  std::swap(a.ptr(),b.ptr());\n}\n    \n} // end namespace internal\n\n/** \\internal\n  * Declares, allocates and construct an aligned buffer named NAME of SIZE elements of type TYPE on the stack\n  * if SIZE is smaller than EIGEN_STACK_ALLOCATION_LIMIT, and if stack allocation is supported by the platform\n  * (currently, this is Linux and Visual Studio only). Otherwise the memory is allocated on the heap.\n  * The allocated buffer is automatically deleted when exiting the scope of this declaration.\n  * If BUFFER is non null, then the declared variable is simply an alias for BUFFER, and no allocation/deletion occurs.\n  * Here is an example:\n  * \\code\n  * {\n  *   ei_declare_aligned_stack_constructed_variable(float,data,size,0);\n  *   // use data[0] to data[size-1]\n  * }\n  * \\endcode\n  * The underlying stack allocation function can controlled with the EIGEN_ALLOCA preprocessor token.\n  */\n#ifdef EIGEN_ALLOCA\n  \n  #if EIGEN_DEFAULT_ALIGN_BYTES>0\n    // We always manually re-align the result of EIGEN_ALLOCA.\n    // If alloca is already aligned, the compiler should be smart enough to optimize away the re-alignment.\n    #define EIGEN_ALIGNED_ALLOCA(SIZE) reinterpret_cast<void*>((internal::UIntPtr(EIGEN_ALLOCA(SIZE+EIGEN_DEFAULT_ALIGN_BYTES-1)) + EIGEN_DEFAULT_ALIGN_BYTES-1) & ~(std::size_t(EIGEN_DEFAULT_ALIGN_BYTES-1)))\n  #else\n    #define EIGEN_ALIGNED_ALLOCA(SIZE) EIGEN_ALLOCA(SIZE)\n  #endif\n\n  #define ei_declare_aligned_stack_constructed_variable(TYPE,NAME,SIZE,BUFFER) \\\n    Eigen::internal::check_size_for_overflow<TYPE>(SIZE); \\\n    TYPE* NAME = (BUFFER)!=0 ? (BUFFER) \\\n               : reinterpret_cast<TYPE*>( \\\n                      (sizeof(TYPE)*SIZE<=EIGEN_STACK_ALLOCATION_LIMIT) ? EIGEN_ALIGNED_ALLOCA(sizeof(TYPE)*SIZE) \\\n                    : Eigen::internal::aligned_malloc(sizeof(TYPE)*SIZE) );  \\\n    Eigen::internal::aligned_stack_memory_handler<TYPE> EIGEN_CAT(NAME,_stack_memory_destructor)((BUFFER)==0 ? NAME : 0,SIZE,sizeof(TYPE)*SIZE>EIGEN_STACK_ALLOCATION_LIMIT)\n\n#else\n\n  #define ei_declare_aligned_stack_constructed_variable(TYPE,NAME,SIZE,BUFFER) \\\n    Eigen::internal::check_size_for_overflow<TYPE>(SIZE); \\\n    TYPE* NAME = (BUFFER)!=0 ? BUFFER : reinterpret_cast<TYPE*>(Eigen::internal::aligned_malloc(sizeof(TYPE)*SIZE));    \\\n    Eigen::internal::aligned_stack_memory_handler<TYPE> EIGEN_CAT(NAME,_stack_memory_destructor)((BUFFER)==0 ? NAME : 0,SIZE,true)\n    \n#endif\n\n\n/*****************************************************************************\n*** Implementation of EIGEN_MAKE_ALIGNED_OPERATOR_NEW [_IF]                ***\n*****************************************************************************/\n\n#if EIGEN_MAX_ALIGN_BYTES!=0\n  #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \\\n      void* operator new(std::size_t size, const std::nothrow_t&) EIGEN_NO_THROW { \\\n        EIGEN_TRY { return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); } \\\n        EIGEN_CATCH (...) { return 0; } \\\n      }\n  #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \\\n      void *operator new(std::size_t size) { \\\n        return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \\\n      } \\\n      void *operator new[](std::size_t size) { \\\n        return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \\\n      } \\\n      void operator delete(void * ptr) EIGEN_NO_THROW { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \\\n      void operator delete[](void * ptr) EIGEN_NO_THROW { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \\\n      void operator delete(void * ptr, std::size_t /* sz */) EIGEN_NO_THROW { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \\\n      void operator delete[](void * ptr, std::size_t /* sz */) EIGEN_NO_THROW { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \\\n      /* in-place new and delete. since (at least afaik) there is no actual   */ \\\n      /* memory allocated we can safely let the default implementation handle */ \\\n      /* this particular case. */ \\\n      static void *operator new(std::size_t size, void *ptr) { return ::operator new(size,ptr); } \\\n      static void *operator new[](std::size_t size, void* ptr) { return ::operator new[](size,ptr); } \\\n      void operator delete(void * memory, void *ptr) EIGEN_NO_THROW { return ::operator delete(memory,ptr); } \\\n      void operator delete[](void * memory, void *ptr) EIGEN_NO_THROW { return ::operator delete[](memory,ptr); } \\\n      /* nothrow-new (returns zero instead of std::bad_alloc) */ \\\n      EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \\\n      void operator delete(void *ptr, const std::nothrow_t&) EIGEN_NO_THROW { \\\n        Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); \\\n      } \\\n      typedef void eigen_aligned_operator_new_marker_type;\n#else\n  #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)\n#endif\n\n#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(true)\n#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar,Size) \\\n  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(bool(((Size)!=Eigen::Dynamic) && ((sizeof(Scalar)*(Size))%EIGEN_MAX_ALIGN_BYTES==0)))\n\n/****************************************************************************/\n\n/** \\class aligned_allocator\n* \\ingroup Core_Module\n*\n* \\brief STL compatible allocator to use with with 16 byte aligned types\n*\n* Example:\n* \\code\n* // Matrix4f requires 16 bytes alignment:\n* std::map< int, Matrix4f, std::less<int>, \n*           aligned_allocator<std::pair<const int, Matrix4f> > > my_map_mat4;\n* // Vector3f does not require 16 bytes alignment, no need to use Eigen's allocator:\n* std::map< int, Vector3f > my_map_vec3;\n* \\endcode\n*\n* \\sa \\blank \\ref TopicStlContainers.\n*/\ntemplate<class T>\nclass aligned_allocator : public std::allocator<T>\n{\npublic:\n  typedef std::size_t     size_type;\n  typedef std::ptrdiff_t  difference_type;\n  typedef T*              pointer;\n  typedef const T*        const_pointer;\n  typedef T&              reference;\n  typedef const T&        const_reference;\n  typedef T               value_type;\n\n  template<class U>\n  struct rebind\n  {\n    typedef aligned_allocator<U> other;\n  };\n\n  aligned_allocator() : std::allocator<T>() {}\n\n  aligned_allocator(const aligned_allocator& other) : std::allocator<T>(other) {}\n\n  template<class U>\n  aligned_allocator(const aligned_allocator<U>& other) : std::allocator<T>(other) {}\n\n  ~aligned_allocator() {}\n\n  pointer allocate(size_type num, const void* /*hint*/ = 0)\n  {\n    internal::check_size_for_overflow<T>(num);\n    return static_cast<pointer>( internal::aligned_malloc(num * sizeof(T)) );\n  }\n\n  void deallocate(pointer p, size_type /*num*/)\n  {\n    internal::aligned_free(p);\n  }\n};\n\n//---------- Cache sizes ----------\n\n#if !defined(EIGEN_NO_CPUID)\n#  if EIGEN_COMP_GNUC && EIGEN_ARCH_i386_OR_x86_64\n#    if defined(__PIC__) && EIGEN_ARCH_i386\n       // Case for x86 with PIC\n#      define EIGEN_CPUID(abcd,func,id) \\\n         __asm__ __volatile__ (\"xchgl %%ebx, %k1;cpuid; xchgl %%ebx,%k1\": \"=a\" (abcd[0]), \"=&r\" (abcd[1]), \"=c\" (abcd[2]), \"=d\" (abcd[3]) : \"a\" (func), \"c\" (id));\n#    elif defined(__PIC__) && EIGEN_ARCH_x86_64\n       // Case for x64 with PIC. In theory this is only a problem with recent gcc and with medium or large code model, not with the default small code model.\n       // However, we cannot detect which code model is used, and the xchg overhead is negligible anyway.\n#      define EIGEN_CPUID(abcd,func,id) \\\n        __asm__ __volatile__ (\"xchg{q}\\t{%%}rbx, %q1; cpuid; xchg{q}\\t{%%}rbx, %q1\": \"=a\" (abcd[0]), \"=&r\" (abcd[1]), \"=c\" (abcd[2]), \"=d\" (abcd[3]) : \"0\" (func), \"2\" (id));\n#    else\n       // Case for x86_64 or x86 w/o PIC\n#      define EIGEN_CPUID(abcd,func,id) \\\n         __asm__ __volatile__ (\"cpuid\": \"=a\" (abcd[0]), \"=b\" (abcd[1]), \"=c\" (abcd[2]), \"=d\" (abcd[3]) : \"0\" (func), \"2\" (id) );\n#    endif\n#  elif EIGEN_COMP_MSVC\n#    if (EIGEN_COMP_MSVC > 1500) && EIGEN_ARCH_i386_OR_x86_64\n#      define EIGEN_CPUID(abcd,func,id) __cpuidex((int*)abcd,func,id)\n#    endif\n#  endif\n#endif\n\nnamespace internal {\n\n#ifdef EIGEN_CPUID\n\ninline bool cpuid_is_vendor(int abcd[4], const int vendor[3])\n{\n  return abcd[1]==vendor[0] && abcd[3]==vendor[1] && abcd[2]==vendor[2];\n}\n\ninline void queryCacheSizes_intel_direct(int& l1, int& l2, int& l3)\n{\n  int abcd[4];\n  l1 = l2 = l3 = 0;\n  int cache_id = 0;\n  int cache_type = 0;\n  do {\n    abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;\n    EIGEN_CPUID(abcd,0x4,cache_id);\n    cache_type  = (abcd[0] & 0x0F) >> 0;\n    if(cache_type==1||cache_type==3) // data or unified cache\n    {\n      int cache_level = (abcd[0] & 0xE0) >> 5;  // A[7:5]\n      int ways        = (abcd[1] & 0xFFC00000) >> 22; // B[31:22]\n      int partitions  = (abcd[1] & 0x003FF000) >> 12; // B[21:12]\n      int line_size   = (abcd[1] & 0x00000FFF) >>  0; // B[11:0]\n      int sets        = (abcd[2]);                    // C[31:0]\n\n      int cache_size = (ways+1) * (partitions+1) * (line_size+1) * (sets+1);\n\n      switch(cache_level)\n      {\n        case 1: l1 = cache_size; break;\n        case 2: l2 = cache_size; break;\n        case 3: l3 = cache_size; break;\n        default: break;\n      }\n    }\n    cache_id++;\n  } while(cache_type>0 && cache_id<16);\n}\n\ninline void queryCacheSizes_intel_codes(int& l1, int& l2, int& l3)\n{\n  int abcd[4];\n  abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;\n  l1 = l2 = l3 = 0;\n  EIGEN_CPUID(abcd,0x00000002,0);\n  unsigned char * bytes = reinterpret_cast<unsigned char *>(abcd)+2;\n  bool check_for_p2_core2 = false;\n  for(int i=0; i<14; ++i)\n  {\n    switch(bytes[i])\n    {\n      case 0x0A: l1 = 8; break;   // 0Ah   data L1 cache, 8 KB, 2 ways, 32 byte lines\n      case 0x0C: l1 = 16; break;  // 0Ch   data L1 cache, 16 KB, 4 ways, 32 byte lines\n      case 0x0E: l1 = 24; break;  // 0Eh   data L1 cache, 24 KB, 6 ways, 64 byte lines\n      case 0x10: l1 = 16; break;  // 10h   data L1 cache, 16 KB, 4 ways, 32 byte lines (IA-64)\n      case 0x15: l1 = 16; break;  // 15h   code L1 cache, 16 KB, 4 ways, 32 byte lines (IA-64)\n      case 0x2C: l1 = 32; break;  // 2Ch   data L1 cache, 32 KB, 8 ways, 64 byte lines\n      case 0x30: l1 = 32; break;  // 30h   code L1 cache, 32 KB, 8 ways, 64 byte lines\n      case 0x60: l1 = 16; break;  // 60h   data L1 cache, 16 KB, 8 ways, 64 byte lines, sectored\n      case 0x66: l1 = 8; break;   // 66h   data L1 cache, 8 KB, 4 ways, 64 byte lines, sectored\n      case 0x67: l1 = 16; break;  // 67h   data L1 cache, 16 KB, 4 ways, 64 byte lines, sectored\n      case 0x68: l1 = 32; break;  // 68h   data L1 cache, 32 KB, 4 ways, 64 byte lines, sectored\n      case 0x1A: l2 = 96; break;   // code and data L2 cache, 96 KB, 6 ways, 64 byte lines (IA-64)\n      case 0x22: l3 = 512; break;   // code and data L3 cache, 512 KB, 4 ways (!), 64 byte lines, dual-sectored\n      case 0x23: l3 = 1024; break;   // code and data L3 cache, 1024 KB, 8 ways, 64 byte lines, dual-sectored\n      case 0x25: l3 = 2048; break;   // code and data L3 cache, 2048 KB, 8 ways, 64 byte lines, dual-sectored\n      case 0x29: l3 = 4096; break;   // code and data L3 cache, 4096 KB, 8 ways, 64 byte lines, dual-sectored\n      case 0x39: l2 = 128; break;   // code and data L2 cache, 128 KB, 4 ways, 64 byte lines, sectored\n      case 0x3A: l2 = 192; break;   // code and data L2 cache, 192 KB, 6 ways, 64 byte lines, sectored\n      case 0x3B: l2 = 128; break;   // code and data L2 cache, 128 KB, 2 ways, 64 byte lines, sectored\n      case 0x3C: l2 = 256; break;   // code and data L2 cache, 256 KB, 4 ways, 64 byte lines, sectored\n      case 0x3D: l2 = 384; break;   // code and data L2 cache, 384 KB, 6 ways, 64 byte lines, sectored\n      case 0x3E: l2 = 512; break;   // code and data L2 cache, 512 KB, 4 ways, 64 byte lines, sectored\n      case 0x40: l2 = 0; break;   // no integrated L2 cache (P6 core) or L3 cache (P4 core)\n      case 0x41: l2 = 128; break;   // code and data L2 cache, 128 KB, 4 ways, 32 byte lines\n      case 0x42: l2 = 256; break;   // code and data L2 cache, 256 KB, 4 ways, 32 byte lines\n      case 0x43: l2 = 512; break;   // code and data L2 cache, 512 KB, 4 ways, 32 byte lines\n      case 0x44: l2 = 1024; break;   // code and data L2 cache, 1024 KB, 4 ways, 32 byte lines\n      case 0x45: l2 = 2048; break;   // code and data L2 cache, 2048 KB, 4 ways, 32 byte lines\n      case 0x46: l3 = 4096; break;   // code and data L3 cache, 4096 KB, 4 ways, 64 byte lines\n      case 0x47: l3 = 8192; break;   // code and data L3 cache, 8192 KB, 8 ways, 64 byte lines\n      case 0x48: l2 = 3072; break;   // code and data L2 cache, 3072 KB, 12 ways, 64 byte lines\n      case 0x49: if(l2!=0) l3 = 4096; else {check_for_p2_core2=true; l3 = l2 = 4096;} break;// code and data L3 cache, 4096 KB, 16 ways, 64 byte lines (P4) or L2 for core2\n      case 0x4A: l3 = 6144; break;   // code and data L3 cache, 6144 KB, 12 ways, 64 byte lines\n      case 0x4B: l3 = 8192; break;   // code and data L3 cache, 8192 KB, 16 ways, 64 byte lines\n      case 0x4C: l3 = 12288; break;   // code and data L3 cache, 12288 KB, 12 ways, 64 byte lines\n      case 0x4D: l3 = 16384; break;   // code and data L3 cache, 16384 KB, 16 ways, 64 byte lines\n      case 0x4E: l2 = 6144; break;   // code and data L2 cache, 6144 KB, 24 ways, 64 byte lines\n      case 0x78: l2 = 1024; break;   // code and data L2 cache, 1024 KB, 4 ways, 64 byte lines\n      case 0x79: l2 = 128; break;   // code and data L2 cache, 128 KB, 8 ways, 64 byte lines, dual-sectored\n      case 0x7A: l2 = 256; break;   // code and data L2 cache, 256 KB, 8 ways, 64 byte lines, dual-sectored\n      case 0x7B: l2 = 512; break;   // code and data L2 cache, 512 KB, 8 ways, 64 byte lines, dual-sectored\n      case 0x7C: l2 = 1024; break;   // code and data L2 cache, 1024 KB, 8 ways, 64 byte lines, dual-sectored\n      case 0x7D: l2 = 2048; break;   // code and data L2 cache, 2048 KB, 8 ways, 64 byte lines\n      case 0x7E: l2 = 256; break;   // code and data L2 cache, 256 KB, 8 ways, 128 byte lines, sect. (IA-64)\n      case 0x7F: l2 = 512; break;   // code and data L2 cache, 512 KB, 2 ways, 64 byte lines\n      case 0x80: l2 = 512; break;   // code and data L2 cache, 512 KB, 8 ways, 64 byte lines\n      case 0x81: l2 = 128; break;   // code and data L2 cache, 128 KB, 8 ways, 32 byte lines\n      case 0x82: l2 = 256; break;   // code and data L2 cache, 256 KB, 8 ways, 32 byte lines\n      case 0x83: l2 = 512; break;   // code and data L2 cache, 512 KB, 8 ways, 32 byte lines\n      case 0x84: l2 = 1024; break;   // code and data L2 cache, 1024 KB, 8 ways, 32 byte lines\n      case 0x85: l2 = 2048; break;   // code and data L2 cache, 2048 KB, 8 ways, 32 byte lines\n      case 0x86: l2 = 512; break;   // code and data L2 cache, 512 KB, 4 ways, 64 byte lines\n      case 0x87: l2 = 1024; break;   // code and data L2 cache, 1024 KB, 8 ways, 64 byte lines\n      case 0x88: l3 = 2048; break;   // code and data L3 cache, 2048 KB, 4 ways, 64 byte lines (IA-64)\n      case 0x89: l3 = 4096; break;   // code and data L3 cache, 4096 KB, 4 ways, 64 byte lines (IA-64)\n      case 0x8A: l3 = 8192; break;   // code and data L3 cache, 8192 KB, 4 ways, 64 byte lines (IA-64)\n      case 0x8D: l3 = 3072; break;   // code and data L3 cache, 3072 KB, 12 ways, 128 byte lines (IA-64)\n\n      default: break;\n    }\n  }\n  if(check_for_p2_core2 && l2 == l3)\n    l3 = 0;\n  l1 *= 1024;\n  l2 *= 1024;\n  l3 *= 1024;\n}\n\ninline void queryCacheSizes_intel(int& l1, int& l2, int& l3, int max_std_funcs)\n{\n  if(max_std_funcs>=4)\n    queryCacheSizes_intel_direct(l1,l2,l3);\n  else\n    queryCacheSizes_intel_codes(l1,l2,l3);\n}\n\ninline void queryCacheSizes_amd(int& l1, int& l2, int& l3)\n{\n  int abcd[4];\n  abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;\n  EIGEN_CPUID(abcd,0x80000005,0);\n  l1 = (abcd[2] >> 24) * 1024; // C[31:24] = L1 size in KB\n  abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;\n  EIGEN_CPUID(abcd,0x80000006,0);\n  l2 = (abcd[2] >> 16) * 1024; // C[31;16] = l2 cache size in KB\n  l3 = ((abcd[3] & 0xFFFC000) >> 18) * 512 * 1024; // D[31;18] = l3 cache size in 512KB\n}\n#endif\n\n/** \\internal\n * Queries and returns the cache sizes in Bytes of the L1, L2, and L3 data caches respectively */\ninline void queryCacheSizes(int& l1, int& l2, int& l3)\n{\n  #ifdef EIGEN_CPUID\n  int abcd[4];\n  const int GenuineIntel[] = {0x756e6547, 0x49656e69, 0x6c65746e};\n  const int AuthenticAMD[] = {0x68747541, 0x69746e65, 0x444d4163};\n  const int AMDisbetter_[] = {0x69444d41, 0x74656273, 0x21726574}; // \"AMDisbetter!\"\n\n  // identify the CPU vendor\n  EIGEN_CPUID(abcd,0x0,0);\n  int max_std_funcs = abcd[1];\n  if(cpuid_is_vendor(abcd,GenuineIntel))\n    queryCacheSizes_intel(l1,l2,l3,max_std_funcs);\n  else if(cpuid_is_vendor(abcd,AuthenticAMD) || cpuid_is_vendor(abcd,AMDisbetter_))\n    queryCacheSizes_amd(l1,l2,l3);\n  else\n    // by default let's use Intel's API\n    queryCacheSizes_intel(l1,l2,l3,max_std_funcs);\n\n  // here is the list of other vendors:\n//   ||cpuid_is_vendor(abcd,\"VIA VIA VIA \")\n//   ||cpuid_is_vendor(abcd,\"CyrixInstead\")\n//   ||cpuid_is_vendor(abcd,\"CentaurHauls\")\n//   ||cpuid_is_vendor(abcd,\"GenuineTMx86\")\n//   ||cpuid_is_vendor(abcd,\"TransmetaCPU\")\n//   ||cpuid_is_vendor(abcd,\"RiseRiseRise\")\n//   ||cpuid_is_vendor(abcd,\"Geode by NSC\")\n//   ||cpuid_is_vendor(abcd,\"SiS SiS SiS \")\n//   ||cpuid_is_vendor(abcd,\"UMC UMC UMC \")\n//   ||cpuid_is_vendor(abcd,\"NexGenDriven\")\n  #else\n  l1 = l2 = l3 = -1;\n  #endif\n}\n\n/** \\internal\n * \\returns the size in Bytes of the L1 data cache */\ninline int queryL1CacheSize()\n{\n  int l1(-1), l2, l3;\n  queryCacheSizes(l1,l2,l3);\n  return l1;\n}\n\n/** \\internal\n * \\returns the size in Bytes of the L2 or L3 cache if this later is present */\ninline int queryTopLevelCacheSize()\n{\n  int l1, l2(-1), l3(-1);\n  queryCacheSizes(l1,l2,l3);\n  return (std::max)(l2,l3);\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_MEMORY_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/Meta.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_META_H\n#define EIGEN_META_H\n\n#if defined(__CUDA_ARCH__)\n#include <cfloat>\n#include <math_constants.h>\n#endif\n\n#if EIGEN_COMP_ICC>=1600 &&  __cplusplus >= 201103L\n#include <cstdint>\n#endif\n\nnamespace Eigen {\n\ntypedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex;\n\n/**\n * \\brief The Index type as used for the API.\n * \\details To change this, \\c \\#define the preprocessor symbol \\c EIGEN_DEFAULT_DENSE_INDEX_TYPE.\n * \\sa \\blank \\ref TopicPreprocessorDirectives, StorageIndex.\n */\n\ntypedef EIGEN_DEFAULT_DENSE_INDEX_TYPE Index;\n\nnamespace internal {\n\n/** \\internal\n  * \\file Meta.h\n  * This file contains generic metaprogramming classes which are not specifically related to Eigen.\n  * \\note In case you wonder, yes we're aware that Boost already provides all these features,\n  * we however don't want to add a dependency to Boost.\n  */\n\n// Only recent versions of ICC complain about using ptrdiff_t to hold pointers,\n// and older versions do not provide *intptr_t types.\n#if EIGEN_COMP_ICC>=1600 &&  __cplusplus >= 201103L\ntypedef std::intptr_t  IntPtr;\ntypedef std::uintptr_t UIntPtr;\n#else\ntypedef std::ptrdiff_t IntPtr;\ntypedef std::size_t UIntPtr;\n#endif\n\nstruct true_type {  enum { value = 1 }; };\nstruct false_type { enum { value = 0 }; };\n\ntemplate<bool Condition, typename Then, typename Else>\nstruct conditional { typedef Then type; };\n\ntemplate<typename Then, typename Else>\nstruct conditional <false, Then, Else> { typedef Else type; };\n\ntemplate<typename T, typename U> struct is_same { enum { value = 0 }; };\ntemplate<typename T> struct is_same<T,T> { enum { value = 1 }; };\n\ntemplate<typename T> struct remove_reference { typedef T type; };\ntemplate<typename T> struct remove_reference<T&> { typedef T type; };\n\ntemplate<typename T> struct remove_pointer { typedef T type; };\ntemplate<typename T> struct remove_pointer<T*> { typedef T type; };\ntemplate<typename T> struct remove_pointer<T*const> { typedef T type; };\n\ntemplate <class T> struct remove_const { typedef T type; };\ntemplate <class T> struct remove_const<const T> { typedef T type; };\ntemplate <class T> struct remove_const<const T[]> { typedef T type[]; };\ntemplate <class T, unsigned int Size> struct remove_const<const T[Size]> { typedef T type[Size]; };\n\ntemplate<typename T> struct remove_all { typedef T type; };\ntemplate<typename T> struct remove_all<const T>   { typedef typename remove_all<T>::type type; };\ntemplate<typename T> struct remove_all<T const&>  { typedef typename remove_all<T>::type type; };\ntemplate<typename T> struct remove_all<T&>        { typedef typename remove_all<T>::type type; };\ntemplate<typename T> struct remove_all<T const*>  { typedef typename remove_all<T>::type type; };\ntemplate<typename T> struct remove_all<T*>        { typedef typename remove_all<T>::type type; };\n\ntemplate<typename T> struct is_arithmetic      { enum { value = false }; };\ntemplate<> struct is_arithmetic<float>         { enum { value = true }; };\ntemplate<> struct is_arithmetic<double>        { enum { value = true }; };\ntemplate<> struct is_arithmetic<long double>   { enum { value = true }; };\ntemplate<> struct is_arithmetic<bool>          { enum { value = true }; };\ntemplate<> struct is_arithmetic<char>          { enum { value = true }; };\ntemplate<> struct is_arithmetic<signed char>   { enum { value = true }; };\ntemplate<> struct is_arithmetic<unsigned char> { enum { value = true }; };\ntemplate<> struct is_arithmetic<signed short>  { enum { value = true }; };\ntemplate<> struct is_arithmetic<unsigned short>{ enum { value = true }; };\ntemplate<> struct is_arithmetic<signed int>    { enum { value = true }; };\ntemplate<> struct is_arithmetic<unsigned int>  { enum { value = true }; };\ntemplate<> struct is_arithmetic<signed long>   { enum { value = true }; };\ntemplate<> struct is_arithmetic<unsigned long> { enum { value = true }; };\n\ntemplate<typename T> struct is_integral        { enum { value = false }; };\ntemplate<> struct is_integral<bool>            { enum { value = true }; };\ntemplate<> struct is_integral<char>            { enum { value = true }; };\ntemplate<> struct is_integral<signed char>     { enum { value = true }; };\ntemplate<> struct is_integral<unsigned char>   { enum { value = true }; };\ntemplate<> struct is_integral<signed short>    { enum { value = true }; };\ntemplate<> struct is_integral<unsigned short>  { enum { value = true }; };\ntemplate<> struct is_integral<signed int>      { enum { value = true }; };\ntemplate<> struct is_integral<unsigned int>    { enum { value = true }; };\ntemplate<> struct is_integral<signed long>     { enum { value = true }; };\ntemplate<> struct is_integral<unsigned long>   { enum { value = true }; };\n\ntemplate <typename T> struct add_const { typedef const T type; };\ntemplate <typename T> struct add_const<T&> { typedef T& type; };\n\ntemplate <typename T> struct is_const { enum { value = 0 }; };\ntemplate <typename T> struct is_const<T const> { enum { value = 1 }; };\n\ntemplate<typename T> struct add_const_on_value_type            { typedef const T type;  };\ntemplate<typename T> struct add_const_on_value_type<T&>        { typedef T const& type; };\ntemplate<typename T> struct add_const_on_value_type<T*>        { typedef T const* type; };\ntemplate<typename T> struct add_const_on_value_type<T* const>  { typedef T const* const type; };\ntemplate<typename T> struct add_const_on_value_type<T const* const>  { typedef T const* const type; };\n\n\ntemplate<typename From, typename To>\nstruct is_convertible_impl\n{\nprivate:\n  struct any_conversion\n  {\n    template <typename T> any_conversion(const volatile T&);\n    template <typename T> any_conversion(T&);\n  };\n  struct yes {int a[1];};\n  struct no  {int a[2];};\n\n  static yes test(const To&, int);\n  static no  test(any_conversion, ...);\n\npublic:\n  static From ms_from;\n#ifdef __INTEL_COMPILER\n  #pragma warning push\n  #pragma warning ( disable : 2259 )\n#endif\n  enum { value = sizeof(test(ms_from, 0))==sizeof(yes) };\n#ifdef __INTEL_COMPILER\n  #pragma warning pop\n#endif\n};\n\ntemplate<typename From, typename To>\nstruct is_convertible\n{\n  enum { value = is_convertible_impl<typename remove_all<From>::type,\n                                     typename remove_all<To  >::type>::value };\n};\n\n/** \\internal Allows to enable/disable an overload\n  * according to a compile time condition.\n  */\ntemplate<bool Condition, typename T=void> struct enable_if;\n\ntemplate<typename T> struct enable_if<true,T>\n{ typedef T type; };\n\n#if defined(__CUDA_ARCH__)\n#if !defined(__FLT_EPSILON__)\n#define __FLT_EPSILON__ FLT_EPSILON\n#define __DBL_EPSILON__ DBL_EPSILON\n#endif\n\nnamespace device {\n\ntemplate<typename T> struct numeric_limits\n{\n  EIGEN_DEVICE_FUNC\n  static T epsilon() { return 0; }\n  static T (max)() { assert(false && \"Highest not supported for this type\"); }\n  static T (min)() { assert(false && \"Lowest not supported for this type\"); }\n  static T infinity() { assert(false && \"Infinity not supported for this type\"); }\n  static T quiet_NaN() { assert(false && \"quiet_NaN not supported for this type\"); }\n};\ntemplate<> struct numeric_limits<float>\n{\n  EIGEN_DEVICE_FUNC\n  static float epsilon() { return __FLT_EPSILON__; }\n  EIGEN_DEVICE_FUNC\n  static float (max)() { return CUDART_MAX_NORMAL_F; }\n  EIGEN_DEVICE_FUNC\n  static float (min)() { return FLT_MIN; }\n  EIGEN_DEVICE_FUNC\n  static float infinity() { return CUDART_INF_F; }\n  EIGEN_DEVICE_FUNC\n  static float quiet_NaN() { return CUDART_NAN_F; }\n};\ntemplate<> struct numeric_limits<double>\n{\n  EIGEN_DEVICE_FUNC\n  static double epsilon() { return __DBL_EPSILON__; }\n  EIGEN_DEVICE_FUNC\n  static double (max)() { return DBL_MAX; }\n  EIGEN_DEVICE_FUNC\n  static double (min)() { return DBL_MIN; }\n  EIGEN_DEVICE_FUNC\n  static double infinity() { return CUDART_INF; }\n  EIGEN_DEVICE_FUNC\n  static double quiet_NaN() { return CUDART_NAN; }\n};\ntemplate<> struct numeric_limits<int>\n{\n  EIGEN_DEVICE_FUNC\n  static int epsilon() { return 0; }\n  EIGEN_DEVICE_FUNC\n  static int (max)() { return INT_MAX; }\n  EIGEN_DEVICE_FUNC\n  static int (min)() { return INT_MIN; }\n};\ntemplate<> struct numeric_limits<unsigned int>\n{\n  EIGEN_DEVICE_FUNC\n  static unsigned int epsilon() { return 0; }\n  EIGEN_DEVICE_FUNC\n  static unsigned int (max)() { return UINT_MAX; }\n  EIGEN_DEVICE_FUNC\n  static unsigned int (min)() { return 0; }\n};\ntemplate<> struct numeric_limits<long>\n{\n  EIGEN_DEVICE_FUNC\n  static long epsilon() { return 0; }\n  EIGEN_DEVICE_FUNC\n  static long (max)() { return LONG_MAX; }\n  EIGEN_DEVICE_FUNC\n  static long (min)() { return LONG_MIN; }\n};\ntemplate<> struct numeric_limits<unsigned long>\n{\n  EIGEN_DEVICE_FUNC\n  static unsigned long epsilon() { return 0; }\n  EIGEN_DEVICE_FUNC\n  static unsigned long (max)() { return ULONG_MAX; }\n  EIGEN_DEVICE_FUNC\n  static unsigned long (min)() { return 0; }\n};\ntemplate<> struct numeric_limits<long long>\n{\n  EIGEN_DEVICE_FUNC\n  static long long epsilon() { return 0; }\n  EIGEN_DEVICE_FUNC\n  static long long (max)() { return LLONG_MAX; }\n  EIGEN_DEVICE_FUNC\n  static long long (min)() { return LLONG_MIN; }\n};\ntemplate<> struct numeric_limits<unsigned long long>\n{\n  EIGEN_DEVICE_FUNC\n  static unsigned long long epsilon() { return 0; }\n  EIGEN_DEVICE_FUNC\n  static unsigned long long (max)() { return ULLONG_MAX; }\n  EIGEN_DEVICE_FUNC\n  static unsigned long long (min)() { return 0; }\n};\n\n}\n\n#endif\n\n/** \\internal\n  * A base class do disable default copy ctor and copy assignement operator.\n  */\nclass noncopyable\n{\n  EIGEN_DEVICE_FUNC noncopyable(const noncopyable&);\n  EIGEN_DEVICE_FUNC const noncopyable& operator=(const noncopyable&);\nprotected:\n  EIGEN_DEVICE_FUNC noncopyable() {}\n  EIGEN_DEVICE_FUNC ~noncopyable() {}\n};\n\n/** \\internal\n  * Convenient struct to get the result type of a unary or binary functor.\n  *\n  * It supports both the current STL mechanism (using the result_type member) as well as\n  * upcoming next STL generation (using a templated result member).\n  * If none of these members is provided, then the type of the first argument is returned. FIXME, that behavior is a pretty bad hack.\n  */\n#if EIGEN_HAS_STD_RESULT_OF\ntemplate<typename T> struct result_of {\n  typedef typename std::result_of<T>::type type1;\n  typedef typename remove_all<type1>::type type;\n};\n#else\ntemplate<typename T> struct result_of { };\n\nstruct has_none {int a[1];};\nstruct has_std_result_type {int a[2];};\nstruct has_tr1_result {int a[3];};\n\ntemplate<typename Func, typename ArgType, int SizeOf=sizeof(has_none)>\nstruct unary_result_of_select {typedef typename internal::remove_all<ArgType>::type type;};\n\ntemplate<typename Func, typename ArgType>\nstruct unary_result_of_select<Func, ArgType, sizeof(has_std_result_type)> {typedef typename Func::result_type type;};\n\ntemplate<typename Func, typename ArgType>\nstruct unary_result_of_select<Func, ArgType, sizeof(has_tr1_result)> {typedef typename Func::template result<Func(ArgType)>::type type;};\n\ntemplate<typename Func, typename ArgType>\nstruct result_of<Func(ArgType)> {\n    template<typename T>\n    static has_std_result_type    testFunctor(T const *, typename T::result_type const * = 0);\n    template<typename T>\n    static has_tr1_result         testFunctor(T const *, typename T::template result<T(ArgType)>::type const * = 0);\n    static has_none               testFunctor(...);\n\n    // note that the following indirection is needed for gcc-3.3\n    enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};\n    typedef typename unary_result_of_select<Func, ArgType, FunctorType>::type type;\n};\n\ntemplate<typename Func, typename ArgType0, typename ArgType1, int SizeOf=sizeof(has_none)>\nstruct binary_result_of_select {typedef typename internal::remove_all<ArgType0>::type type;};\n\ntemplate<typename Func, typename ArgType0, typename ArgType1>\nstruct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_std_result_type)>\n{typedef typename Func::result_type type;};\n\ntemplate<typename Func, typename ArgType0, typename ArgType1>\nstruct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_tr1_result)>\n{typedef typename Func::template result<Func(ArgType0,ArgType1)>::type type;};\n\ntemplate<typename Func, typename ArgType0, typename ArgType1>\nstruct result_of<Func(ArgType0,ArgType1)> {\n    template<typename T>\n    static has_std_result_type    testFunctor(T const *, typename T::result_type const * = 0);\n    template<typename T>\n    static has_tr1_result         testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1)>::type const * = 0);\n    static has_none               testFunctor(...);\n\n    // note that the following indirection is needed for gcc-3.3\n    enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};\n    typedef typename binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type;\n};\n\ntemplate<typename Func, typename ArgType0, typename ArgType1, typename ArgType2, int SizeOf=sizeof(has_none)>\nstruct ternary_result_of_select {typedef typename internal::remove_all<ArgType0>::type type;};\n\ntemplate<typename Func, typename ArgType0, typename ArgType1, typename ArgType2>\nstruct ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, sizeof(has_std_result_type)>\n{typedef typename Func::result_type type;};\n\ntemplate<typename Func, typename ArgType0, typename ArgType1, typename ArgType2>\nstruct ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, sizeof(has_tr1_result)>\n{typedef typename Func::template result<Func(ArgType0,ArgType1,ArgType2)>::type type;};\n\ntemplate<typename Func, typename ArgType0, typename ArgType1, typename ArgType2>\nstruct result_of<Func(ArgType0,ArgType1,ArgType2)> {\n    template<typename T>\n    static has_std_result_type    testFunctor(T const *, typename T::result_type const * = 0);\n    template<typename T>\n    static has_tr1_result         testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1,ArgType2)>::type const * = 0);\n    static has_none               testFunctor(...);\n\n    // note that the following indirection is needed for gcc-3.3\n    enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};\n    typedef typename ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, FunctorType>::type type;\n};\n#endif\n\nstruct meta_yes { char a[1]; };\nstruct meta_no  { char a[2]; };\n\n// Check whether T::ReturnType does exist\ntemplate <typename T>\nstruct has_ReturnType\n{\n  template <typename C> static meta_yes testFunctor(typename C::ReturnType const *);\n  template <typename C> static meta_no testFunctor(...);\n\n  enum { value = sizeof(testFunctor<T>(0)) == sizeof(meta_yes) };\n};\n\ntemplate<typename T> const T* return_ptr();\n\ntemplate <typename T, typename IndexType=Index>\nstruct has_nullary_operator\n{\n  template <typename C> static meta_yes testFunctor(C const *,typename enable_if<(sizeof(return_ptr<C>()->operator()())>0)>::type * = 0);\n  static meta_no testFunctor(...);\n\n  enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };\n};\n\ntemplate <typename T, typename IndexType=Index>\nstruct has_unary_operator\n{\n  template <typename C> static meta_yes testFunctor(C const *,typename enable_if<(sizeof(return_ptr<C>()->operator()(IndexType(0)))>0)>::type * = 0);\n  static meta_no testFunctor(...);\n\n  enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };\n};\n\ntemplate <typename T, typename IndexType=Index>\nstruct has_binary_operator\n{\n  template <typename C> static meta_yes testFunctor(C const *,typename enable_if<(sizeof(return_ptr<C>()->operator()(IndexType(0),IndexType(0)))>0)>::type * = 0);\n  static meta_no testFunctor(...);\n\n  enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };\n};\n\n/** \\internal In short, it computes int(sqrt(\\a Y)) with \\a Y an integer.\n  * Usage example: \\code meta_sqrt<1023>::ret \\endcode\n  */\ntemplate<int Y,\n         int InfX = 0,\n         int SupX = ((Y==1) ? 1 : Y/2),\n         bool Done = ((SupX-InfX)<=1 ? true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) >\n                                // use ?: instead of || just to shut up a stupid gcc 4.3 warning\nclass meta_sqrt\n{\n    enum {\n      MidX = (InfX+SupX)/2,\n      TakeInf = MidX*MidX > Y ? 1 : 0,\n      NewInf = int(TakeInf) ? InfX : int(MidX),\n      NewSup = int(TakeInf) ? int(MidX) : SupX\n    };\n  public:\n    enum { ret = meta_sqrt<Y,NewInf,NewSup>::ret };\n};\n\ntemplate<int Y, int InfX, int SupX>\nclass meta_sqrt<Y, InfX, SupX, true> { public:  enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };\n\n\n/** \\internal Computes the least common multiple of two positive integer A and B\n  * at compile-time. It implements a naive algorithm testing all multiples of A.\n  * It thus works better if A>=B.\n  */\ntemplate<int A, int B, int K=1, bool Done = ((A*K)%B)==0>\nstruct meta_least_common_multiple\n{\n  enum { ret = meta_least_common_multiple<A,B,K+1>::ret };\n};\ntemplate<int A, int B, int K>\nstruct meta_least_common_multiple<A,B,K,true>\n{\n  enum { ret = A*K };\n};\n\n/** \\internal determines whether the product of two numeric types is allowed and what the return type is */\ntemplate<typename T, typename U> struct scalar_product_traits\n{\n  enum { Defined = 0 };\n};\n\n// FIXME quick workaround around current limitation of result_of\n// template<typename Scalar, typename ArgType0, typename ArgType1>\n// struct result_of<scalar_product_op<Scalar>(ArgType0,ArgType1)> {\n// typedef typename scalar_product_traits<typename remove_all<ArgType0>::type, typename remove_all<ArgType1>::type>::ReturnType type;\n// };\n\n} // end namespace internal\n\nnamespace numext {\n  \n#if defined(__CUDA_ARCH__)\ntemplate<typename T> EIGEN_DEVICE_FUNC   void swap(T &a, T &b) { T tmp = b; b = a; a = tmp; }\n#else\ntemplate<typename T> EIGEN_STRONG_INLINE void swap(T &a, T &b) { std::swap(a,b); }\n#endif\n\n#if defined(__CUDA_ARCH__)\nusing internal::device::numeric_limits;\n#else\nusing std::numeric_limits;\n#endif\n\n// Integer division with rounding up.\n// T is assumed to be an integer type with a>=0, and b>0\ntemplate<typename T>\nT div_ceil(const T &a, const T &b)\n{\n  return (a+b-1) / b;\n}\n\n} // end namespace numext\n\n} // end namespace Eigen\n\n#endif // EIGEN_META_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/NonMPL2.h",
    "content": "#ifdef EIGEN_MPL2_ONLY\n#error Including non-MPL2 code in EIGEN_MPL2_ONLY mode\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/ReenableStupidWarnings.h",
    "content": "#ifdef EIGEN_WARNINGS_DISABLED\n#undef EIGEN_WARNINGS_DISABLED\n\n#ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS\n  #ifdef _MSC_VER\n    #pragma warning( pop )\n  #elif defined __INTEL_COMPILER\n    #pragma warning pop\n  #elif defined __clang__\n    #pragma clang diagnostic pop\n  #elif defined __GNUC__ && __GNUC__>=6\n    #pragma GCC diagnostic pop\n  #endif\n\n  #if defined __NVCC__\n//    Don't reenable the diagnostic messages, as it turns out these messages need\n//    to be disabled at the point of the template instantiation (i.e the user code)\n//    otherwise they'll be triggered by nvcc.\n//    #pragma diag_default code_is_unreachable\n//    #pragma diag_default initialization_not_reachable\n//    #pragma diag_default 2651\n//    #pragma diag_default 2653\n  #endif\n\n#endif\n\n#endif // EIGEN_WARNINGS_DISABLED\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/StaticAssert.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_STATIC_ASSERT_H\n#define EIGEN_STATIC_ASSERT_H\n\n/* Some notes on Eigen's static assertion mechanism:\n *\n *  - in EIGEN_STATIC_ASSERT(CONDITION,MSG) the parameter CONDITION must be a compile time boolean\n *    expression, and MSG an enum listed in struct internal::static_assertion<true>\n *\n *  - define EIGEN_NO_STATIC_ASSERT to disable them (and save compilation time)\n *    in that case, the static assertion is converted to the following runtime assert:\n *      eigen_assert(CONDITION && \"MSG\")\n *\n *  - currently EIGEN_STATIC_ASSERT can only be used in function scope\n *\n */\n\n#ifndef EIGEN_NO_STATIC_ASSERT\n\n  #if EIGEN_MAX_CPP_VER>=11 && (__has_feature(cxx_static_assert) || (defined(__cplusplus) && __cplusplus >= 201103L) || (EIGEN_COMP_MSVC >= 1600))\n\n    // if native static_assert is enabled, let's use it\n    #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);\n\n  #else // not CXX0X\n\n    namespace Eigen {\n\n    namespace internal {\n\n    template<bool condition>\n    struct static_assertion {};\n\n    template<>\n    struct static_assertion<true>\n    {\n      enum {\n        YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX,\n        YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES,\n        YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES,\n        THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE,\n        THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE,\n        THIS_METHOD_IS_ONLY_FOR_OBJECTS_OF_A_SPECIFIC_SIZE,\n        OUT_OF_RANGE_ACCESS,\n        YOU_MADE_A_PROGRAMMING_MISTAKE,\n        EIGEN_INTERNAL_ERROR_PLEASE_FILE_A_BUG_REPORT,\n        EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE,\n        YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR,\n        YOU_CALLED_A_DYNAMIC_SIZE_METHOD_ON_A_FIXED_SIZE_MATRIX_OR_VECTOR,\n        UNALIGNED_LOAD_AND_STORE_OPERATIONS_UNIMPLEMENTED_ON_ALTIVEC,\n        THIS_FUNCTION_IS_NOT_FOR_INTEGER_NUMERIC_TYPES,\n        FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED,\n        NUMERIC_TYPE_MUST_BE_REAL,\n        COEFFICIENT_WRITE_ACCESS_TO_SELFADJOINT_NOT_SUPPORTED,\n        WRITING_TO_TRIANGULAR_PART_WITH_UNIT_DIAGONAL_IS_NOT_SUPPORTED,\n        THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE,\n        INVALID_MATRIX_PRODUCT,\n        INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS,\n        INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION,\n        YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY,\n        THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES,\n        THIS_METHOD_IS_ONLY_FOR_ROW_MAJOR_MATRICES,\n        INVALID_MATRIX_TEMPLATE_PARAMETERS,\n        INVALID_MATRIXBASE_TEMPLATE_PARAMETERS,\n        BOTH_MATRICES_MUST_HAVE_THE_SAME_STORAGE_ORDER,\n        THIS_METHOD_IS_ONLY_FOR_DIAGONAL_MATRIX,\n        THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE,\n        THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES,\n        YOU_ALREADY_SPECIFIED_THIS_STRIDE,\n        INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION,\n        THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD,\n        PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1,\n        THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS,\n        YOU_CANNOT_MIX_ARRAYS_AND_MATRICES,\n        YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION,\n        THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY,\n        YOU_ARE_TRYING_TO_USE_AN_INDEX_BASED_ACCESSOR_ON_AN_EXPRESSION_THAT_DOES_NOT_SUPPORT_THAT,\n        THIS_METHOD_IS_ONLY_FOR_1x1_EXPRESSIONS,\n        THIS_METHOD_IS_ONLY_FOR_INNER_OR_LAZY_PRODUCTS,\n        THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL,\n        THIS_METHOD_IS_ONLY_FOR_ARRAYS_NOT_MATRICES,\n        YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED,\n        YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED,\n        THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE,\n        THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH,\n        OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG,\n        IMPLICIT_CONVERSION_TO_SCALAR_IS_FOR_INNER_PRODUCT_ONLY,\n        STORAGE_LAYOUT_DOES_NOT_MATCH,\n        EIGEN_INTERNAL_ERROR_PLEASE_FILE_A_BUG_REPORT__INVALID_COST_VALUE,\n        THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS,\n        MATRIX_FREE_CONJUGATE_GRADIENT_IS_COMPATIBLE_WITH_UPPER_UNION_LOWER_MODE_ONLY,\n        THIS_TYPE_IS_NOT_SUPPORTED,\n        STORAGE_KIND_MUST_MATCH,\n        STORAGE_INDEX_MUST_MATCH,\n        CHOLMOD_SUPPORTS_DOUBLE_PRECISION_ONLY\n      };\n    };\n\n    } // end namespace internal\n\n    } // end namespace Eigen\n\n    // Specialized implementation for MSVC to avoid \"conditional\n    // expression is constant\" warnings.  This implementation doesn't\n    // appear to work under GCC, hence the multiple implementations.\n    #if EIGEN_COMP_MSVC\n\n      #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \\\n        {Eigen::internal::static_assertion<bool(CONDITION)>::MSG;}\n\n    #else\n      // In some cases clang interprets bool(CONDITION) as function declaration\n      #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \\\n        if (Eigen::internal::static_assertion<static_cast<bool>(CONDITION)>::MSG) {}\n\n    #endif\n\n  #endif // not CXX0X\n\n#else // EIGEN_NO_STATIC_ASSERT\n\n  #define EIGEN_STATIC_ASSERT(CONDITION,MSG) eigen_assert((CONDITION) && #MSG);\n\n#endif // EIGEN_NO_STATIC_ASSERT\n\n\n// static assertion failing if the type \\a TYPE is not a vector type\n#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE) \\\n  EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime, \\\n                      YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX)\n\n// static assertion failing if the type \\a TYPE is not fixed-size\n#define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE) \\\n  EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime!=Eigen::Dynamic, \\\n                      YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR)\n\n// static assertion failing if the type \\a TYPE is not dynamic-size\n#define EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(TYPE) \\\n  EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime==Eigen::Dynamic, \\\n                      YOU_CALLED_A_DYNAMIC_SIZE_METHOD_ON_A_FIXED_SIZE_MATRIX_OR_VECTOR)\n\n// static assertion failing if the type \\a TYPE is not a vector type of the given size\n#define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE) \\\n  EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime && TYPE::SizeAtCompileTime==SIZE, \\\n                      THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE)\n\n// static assertion failing if the type \\a TYPE is not a vector type of the given size\n#define EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(TYPE, ROWS, COLS) \\\n  EIGEN_STATIC_ASSERT(TYPE::RowsAtCompileTime==ROWS && TYPE::ColsAtCompileTime==COLS, \\\n                      THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE)\n\n// static assertion failing if the two vector expression types are not compatible (same fixed-size or dynamic size)\n#define EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0,TYPE1) \\\n  EIGEN_STATIC_ASSERT( \\\n      (int(TYPE0::SizeAtCompileTime)==Eigen::Dynamic \\\n    || int(TYPE1::SizeAtCompileTime)==Eigen::Dynamic \\\n    || int(TYPE0::SizeAtCompileTime)==int(TYPE1::SizeAtCompileTime)),\\\n    YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES)\n\n#define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1) \\\n     ( \\\n        (int(Eigen::internal::size_of_xpr_at_compile_time<TYPE0>::ret)==0 && int(Eigen::internal::size_of_xpr_at_compile_time<TYPE1>::ret)==0) \\\n    || (\\\n          (int(TYPE0::RowsAtCompileTime)==Eigen::Dynamic \\\n        || int(TYPE1::RowsAtCompileTime)==Eigen::Dynamic \\\n        || int(TYPE0::RowsAtCompileTime)==int(TYPE1::RowsAtCompileTime)) \\\n      &&  (int(TYPE0::ColsAtCompileTime)==Eigen::Dynamic \\\n        || int(TYPE1::ColsAtCompileTime)==Eigen::Dynamic \\\n        || int(TYPE0::ColsAtCompileTime)==int(TYPE1::ColsAtCompileTime))\\\n       ) \\\n     )\n\n#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE) \\\n    EIGEN_STATIC_ASSERT(!NumTraits<TYPE>::IsInteger, THIS_FUNCTION_IS_NOT_FOR_INTEGER_NUMERIC_TYPES)\n\n\n// static assertion failing if it is guaranteed at compile-time that the two matrix expression types have different sizes\n#define EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0,TYPE1) \\\n  EIGEN_STATIC_ASSERT( \\\n     EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1),\\\n    YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES)\n\n#define EIGEN_STATIC_ASSERT_SIZE_1x1(TYPE) \\\n      EIGEN_STATIC_ASSERT((TYPE::RowsAtCompileTime == 1 || TYPE::RowsAtCompileTime == Dynamic) && \\\n                          (TYPE::ColsAtCompileTime == 1 || TYPE::ColsAtCompileTime == Dynamic), \\\n                          THIS_METHOD_IS_ONLY_FOR_1x1_EXPRESSIONS)\n\n#define EIGEN_STATIC_ASSERT_LVALUE(Derived) \\\n      EIGEN_STATIC_ASSERT(Eigen::internal::is_lvalue<Derived>::value, \\\n                          THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY)\n\n#define EIGEN_STATIC_ASSERT_ARRAYXPR(Derived) \\\n      EIGEN_STATIC_ASSERT((Eigen::internal::is_same<typename Eigen::internal::traits<Derived>::XprKind, ArrayXpr>::value), \\\n                          THIS_METHOD_IS_ONLY_FOR_ARRAYS_NOT_MATRICES)\n\n#define EIGEN_STATIC_ASSERT_SAME_XPR_KIND(Derived1, Derived2) \\\n      EIGEN_STATIC_ASSERT((Eigen::internal::is_same<typename Eigen::internal::traits<Derived1>::XprKind, \\\n                                             typename Eigen::internal::traits<Derived2>::XprKind \\\n                                            >::value), \\\n                          YOU_CANNOT_MIX_ARRAYS_AND_MATRICES)\n\n// Check that a cost value is positive, and that is stay within a reasonable range\n// TODO this check could be enabled for internal debugging only\n#define EIGEN_INTERNAL_CHECK_COST_VALUE(C) \\\n      EIGEN_STATIC_ASSERT((C)>=0 && (C)<=HugeCost*HugeCost, EIGEN_INTERNAL_ERROR_PLEASE_FILE_A_BUG_REPORT__INVALID_COST_VALUE);\n\n#endif // EIGEN_STATIC_ASSERT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Core/util/XprHelper.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_XPRHELPER_H\n#define EIGEN_XPRHELPER_H\n\n// just a workaround because GCC seems to not really like empty structs\n// FIXME: gcc 4.3 generates bad code when strict-aliasing is enabled\n// so currently we simply disable this optimization for gcc 4.3\n#if EIGEN_COMP_GNUC && !EIGEN_GNUC_AT(4,3)\n  #define EIGEN_EMPTY_STRUCT_CTOR(X) \\\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE X() {} \\\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE X(const X& ) {}\n#else\n  #define EIGEN_EMPTY_STRUCT_CTOR(X)\n#endif\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<typename IndexDest, typename IndexSrc>\nEIGEN_DEVICE_FUNC\ninline IndexDest convert_index(const IndexSrc& idx) {\n  // for sizeof(IndexDest)>=sizeof(IndexSrc) compilers should be able to optimize this away:\n  eigen_internal_assert(idx <= NumTraits<IndexDest>::highest() && \"Index value to big for target type\");\n  return IndexDest(idx);\n}\n\n\n// promote_scalar_arg is an helper used in operation between an expression and a scalar, like:\n//    expression * scalar\n// Its role is to determine how the type T of the scalar operand should be promoted given the scalar type ExprScalar of the given expression.\n// The IsSupported template parameter must be provided by the caller as: internal::has_ReturnType<ScalarBinaryOpTraits<ExprScalar,T,op> >::value using the proper order for ExprScalar and T.\n// Then the logic is as follows:\n//  - if the operation is natively supported as defined by IsSupported, then the scalar type is not promoted, and T is returned.\n//  - otherwise, NumTraits<ExprScalar>::Literal is returned if T is implicitly convertible to NumTraits<ExprScalar>::Literal AND that this does not imply a float to integer conversion.\n//  - otherwise, ExprScalar is returned if T is implicitly convertible to ExprScalar AND that this does not imply a float to integer conversion.\n//  - In all other cases, the promoted type is not defined, and the respective operation is thus invalid and not available (SFINAE).\ntemplate<typename ExprScalar,typename T, bool IsSupported>\nstruct promote_scalar_arg;\n\ntemplate<typename S,typename T>\nstruct promote_scalar_arg<S,T,true>\n{\n  typedef T type;\n};\n\n// Recursively check safe conversion to PromotedType, and then ExprScalar if they are different.\ntemplate<typename ExprScalar,typename T,typename PromotedType,\n  bool ConvertibleToLiteral = internal::is_convertible<T,PromotedType>::value,\n  bool IsSafe = NumTraits<T>::IsInteger || !NumTraits<PromotedType>::IsInteger>\nstruct promote_scalar_arg_unsupported;\n\n// Start recursion with NumTraits<ExprScalar>::Literal\ntemplate<typename S,typename T>\nstruct promote_scalar_arg<S,T,false> : promote_scalar_arg_unsupported<S,T,typename NumTraits<S>::Literal> {};\n\n// We found a match!\ntemplate<typename S,typename T, typename PromotedType>\nstruct promote_scalar_arg_unsupported<S,T,PromotedType,true,true>\n{\n  typedef PromotedType type;\n};\n\n// No match, but no real-to-integer issues, and ExprScalar and current PromotedType are different,\n// so let's try to promote to ExprScalar\ntemplate<typename ExprScalar,typename T, typename PromotedType>\nstruct promote_scalar_arg_unsupported<ExprScalar,T,PromotedType,false,true>\n   : promote_scalar_arg_unsupported<ExprScalar,T,ExprScalar>\n{};\n\n// Unsafe real-to-integer, let's stop.\ntemplate<typename S,typename T, typename PromotedType, bool ConvertibleToLiteral>\nstruct promote_scalar_arg_unsupported<S,T,PromotedType,ConvertibleToLiteral,false> {};\n\n// T is not even convertible to ExprScalar, let's stop.\ntemplate<typename S,typename T>\nstruct promote_scalar_arg_unsupported<S,T,S,false,true> {};\n\n//classes inheriting no_assignment_operator don't generate a default operator=.\nclass no_assignment_operator\n{\n  private:\n    no_assignment_operator& operator=(const no_assignment_operator&);\n};\n\n/** \\internal return the index type with the largest number of bits */\ntemplate<typename I1, typename I2>\nstruct promote_index_type\n{\n  typedef typename conditional<(sizeof(I1)<sizeof(I2)), I2, I1>::type type;\n};\n\n/** \\internal If the template parameter Value is Dynamic, this class is just a wrapper around a T variable that\n  * can be accessed using value() and setValue().\n  * Otherwise, this class is an empty structure and value() just returns the template parameter Value.\n  */\ntemplate<typename T, int Value> class variable_if_dynamic\n{\n  public:\n    EIGEN_EMPTY_STRUCT_CTOR(variable_if_dynamic)\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit variable_if_dynamic(T v) { EIGEN_ONLY_USED_FOR_DEBUG(v); eigen_assert(v == T(Value)); }\n    EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE T value() { return T(Value); }\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void setValue(T) {}\n};\n\ntemplate<typename T> class variable_if_dynamic<T, Dynamic>\n{\n    T m_value;\n    EIGEN_DEVICE_FUNC variable_if_dynamic() { eigen_assert(false); }\n  public:\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit variable_if_dynamic(T value) : m_value(value) {}\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T value() const { return m_value; }\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void setValue(T value) { m_value = value; }\n};\n\n/** \\internal like variable_if_dynamic but for DynamicIndex\n  */\ntemplate<typename T, int Value> class variable_if_dynamicindex\n{\n  public:\n    EIGEN_EMPTY_STRUCT_CTOR(variable_if_dynamicindex)\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit variable_if_dynamicindex(T v) { EIGEN_ONLY_USED_FOR_DEBUG(v); eigen_assert(v == T(Value)); }\n    EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE T value() { return T(Value); }\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void setValue(T) {}\n};\n\ntemplate<typename T> class variable_if_dynamicindex<T, DynamicIndex>\n{\n    T m_value;\n    EIGEN_DEVICE_FUNC variable_if_dynamicindex() { eigen_assert(false); }\n  public:\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit variable_if_dynamicindex(T value) : m_value(value) {}\n    EIGEN_DEVICE_FUNC T EIGEN_STRONG_INLINE value() const { return m_value; }\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void setValue(T value) { m_value = value; }\n};\n\ntemplate<typename T> struct functor_traits\n{\n  enum\n  {\n    Cost = 10,\n    PacketAccess = false,\n    IsRepeatable = false\n  };\n};\n\ntemplate<typename T> struct packet_traits;\n\ntemplate<typename T> struct unpacket_traits\n{\n  typedef T type;\n  typedef T half;\n  enum\n  {\n    size = 1,\n    alignment = 1\n  };\n};\n\ntemplate<int Size, typename PacketType,\n         bool Stop = Size==Dynamic || (Size%unpacket_traits<PacketType>::size)==0 || is_same<PacketType,typename unpacket_traits<PacketType>::half>::value>\nstruct find_best_packet_helper;\n\ntemplate< int Size, typename PacketType>\nstruct find_best_packet_helper<Size,PacketType,true>\n{\n  typedef PacketType type;\n};\n\ntemplate<int Size, typename PacketType>\nstruct find_best_packet_helper<Size,PacketType,false>\n{\n  typedef typename find_best_packet_helper<Size,typename unpacket_traits<PacketType>::half>::type type;\n};\n\ntemplate<typename T, int Size>\nstruct find_best_packet\n{\n  typedef typename find_best_packet_helper<Size,typename packet_traits<T>::type>::type type;\n};\n\n#if EIGEN_MAX_STATIC_ALIGN_BYTES>0\ntemplate<int ArrayBytes, int AlignmentBytes,\n         bool Match     =  bool((ArrayBytes%AlignmentBytes)==0),\n         bool TryHalf   =  bool(EIGEN_MIN_ALIGN_BYTES<AlignmentBytes) >\nstruct compute_default_alignment_helper\n{\n  enum { value = 0 };\n};\n\ntemplate<int ArrayBytes, int AlignmentBytes, bool TryHalf>\nstruct compute_default_alignment_helper<ArrayBytes, AlignmentBytes, true, TryHalf> // Match\n{\n  enum { value = AlignmentBytes };\n};\n\ntemplate<int ArrayBytes, int AlignmentBytes>\nstruct compute_default_alignment_helper<ArrayBytes, AlignmentBytes, false, true> // Try-half\n{\n  // current packet too large, try with an half-packet\n  enum { value = compute_default_alignment_helper<ArrayBytes, AlignmentBytes/2>::value };\n};\n#else\n// If static alignment is disabled, no need to bother.\n// This also avoids a division by zero in \"bool Match =  bool((ArrayBytes%AlignmentBytes)==0)\"\ntemplate<int ArrayBytes, int AlignmentBytes>\nstruct compute_default_alignment_helper\n{\n  enum { value = 0 };\n};\n#endif\n\ntemplate<typename T, int Size> struct compute_default_alignment {\n  enum { value = compute_default_alignment_helper<Size*sizeof(T),EIGEN_MAX_STATIC_ALIGN_BYTES>::value };\n};\n\ntemplate<typename T> struct compute_default_alignment<T,Dynamic> {\n  enum { value = EIGEN_MAX_ALIGN_BYTES };\n};\n\ntemplate<typename _Scalar, int _Rows, int _Cols,\n         int _Options = AutoAlign |\n                          ( (_Rows==1 && _Cols!=1) ? RowMajor\n                          : (_Cols==1 && _Rows!=1) ? ColMajor\n                          : EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ),\n         int _MaxRows = _Rows,\n         int _MaxCols = _Cols\n> class make_proper_matrix_type\n{\n    enum {\n      IsColVector = _Cols==1 && _Rows!=1,\n      IsRowVector = _Rows==1 && _Cols!=1,\n      Options = IsColVector ? (_Options | ColMajor) & ~RowMajor\n              : IsRowVector ? (_Options | RowMajor) & ~ColMajor\n              : _Options\n    };\n  public:\n    typedef Matrix<_Scalar, _Rows, _Cols, Options, _MaxRows, _MaxCols> type;\n};\n\ntemplate<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>\nclass compute_matrix_flags\n{\n    enum { row_major_bit = Options&RowMajor ? RowMajorBit : 0 };\n  public:\n    // FIXME currently we still have to handle DirectAccessBit at the expression level to handle DenseCoeffsBase<>\n    // and then propagate this information to the evaluator's flags.\n    // However, I (Gael) think that DirectAccessBit should only matter at the evaluation stage.\n    enum { ret = DirectAccessBit | LvalueBit | NestByRefBit | row_major_bit };\n};\n\ntemplate<int _Rows, int _Cols> struct size_at_compile_time\n{\n  enum { ret = (_Rows==Dynamic || _Cols==Dynamic) ? Dynamic : _Rows * _Cols };\n};\n\ntemplate<typename XprType> struct size_of_xpr_at_compile_time\n{\n  enum { ret = size_at_compile_time<traits<XprType>::RowsAtCompileTime,traits<XprType>::ColsAtCompileTime>::ret };\n};\n\n/* plain_matrix_type : the difference from eval is that plain_matrix_type is always a plain matrix type,\n * whereas eval is a const reference in the case of a matrix\n */\n\ntemplate<typename T, typename StorageKind = typename traits<T>::StorageKind> struct plain_matrix_type;\ntemplate<typename T, typename BaseClassType, int Flags> struct plain_matrix_type_dense;\ntemplate<typename T> struct plain_matrix_type<T,Dense>\n{\n  typedef typename plain_matrix_type_dense<T,typename traits<T>::XprKind, traits<T>::Flags>::type type;\n};\ntemplate<typename T> struct plain_matrix_type<T,DiagonalShape>\n{\n  typedef typename T::PlainObject type;\n};\n\ntemplate<typename T, int Flags> struct plain_matrix_type_dense<T,MatrixXpr,Flags>\n{\n  typedef Matrix<typename traits<T>::Scalar,\n                traits<T>::RowsAtCompileTime,\n                traits<T>::ColsAtCompileTime,\n                AutoAlign | (Flags&RowMajorBit ? RowMajor : ColMajor),\n                traits<T>::MaxRowsAtCompileTime,\n                traits<T>::MaxColsAtCompileTime\n          > type;\n};\n\ntemplate<typename T, int Flags> struct plain_matrix_type_dense<T,ArrayXpr,Flags>\n{\n  typedef Array<typename traits<T>::Scalar,\n                traits<T>::RowsAtCompileTime,\n                traits<T>::ColsAtCompileTime,\n                AutoAlign | (Flags&RowMajorBit ? RowMajor : ColMajor),\n                traits<T>::MaxRowsAtCompileTime,\n                traits<T>::MaxColsAtCompileTime\n          > type;\n};\n\n/* eval : the return type of eval(). For matrices, this is just a const reference\n * in order to avoid a useless copy\n */\n\ntemplate<typename T, typename StorageKind = typename traits<T>::StorageKind> struct eval;\n\ntemplate<typename T> struct eval<T,Dense>\n{\n  typedef typename plain_matrix_type<T>::type type;\n//   typedef typename T::PlainObject type;\n//   typedef T::Matrix<typename traits<T>::Scalar,\n//                 traits<T>::RowsAtCompileTime,\n//                 traits<T>::ColsAtCompileTime,\n//                 AutoAlign | (traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor),\n//                 traits<T>::MaxRowsAtCompileTime,\n//                 traits<T>::MaxColsAtCompileTime\n//           > type;\n};\n\ntemplate<typename T> struct eval<T,DiagonalShape>\n{\n  typedef typename plain_matrix_type<T>::type type;\n};\n\n// for matrices, no need to evaluate, just use a const reference to avoid a useless copy\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>\nstruct eval<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, Dense>\n{\n  typedef const Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& type;\n};\n\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>\nstruct eval<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, Dense>\n{\n  typedef const Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& type;\n};\n\n\n/* similar to plain_matrix_type, but using the evaluator's Flags */\ntemplate<typename T, typename StorageKind = typename traits<T>::StorageKind> struct plain_object_eval;\n\ntemplate<typename T>\nstruct plain_object_eval<T,Dense>\n{\n  typedef typename plain_matrix_type_dense<T,typename traits<T>::XprKind, evaluator<T>::Flags>::type type;\n};\n\n\n/* plain_matrix_type_column_major : same as plain_matrix_type but guaranteed to be column-major\n */\ntemplate<typename T> struct plain_matrix_type_column_major\n{\n  enum { Rows = traits<T>::RowsAtCompileTime,\n         Cols = traits<T>::ColsAtCompileTime,\n         MaxRows = traits<T>::MaxRowsAtCompileTime,\n         MaxCols = traits<T>::MaxColsAtCompileTime\n  };\n  typedef Matrix<typename traits<T>::Scalar,\n                Rows,\n                Cols,\n                (MaxRows==1&&MaxCols!=1) ? RowMajor : ColMajor,\n                MaxRows,\n                MaxCols\n          > type;\n};\n\n/* plain_matrix_type_row_major : same as plain_matrix_type but guaranteed to be row-major\n */\ntemplate<typename T> struct plain_matrix_type_row_major\n{\n  enum { Rows = traits<T>::RowsAtCompileTime,\n         Cols = traits<T>::ColsAtCompileTime,\n         MaxRows = traits<T>::MaxRowsAtCompileTime,\n         MaxCols = traits<T>::MaxColsAtCompileTime\n  };\n  typedef Matrix<typename traits<T>::Scalar,\n                Rows,\n                Cols,\n                (MaxCols==1&&MaxRows!=1) ? RowMajor : ColMajor,\n                MaxRows,\n                MaxCols\n          > type;\n};\n\n/** \\internal The reference selector for template expressions. The idea is that we don't\n  * need to use references for expressions since they are light weight proxy\n  * objects which should generate no copying overhead. */\ntemplate <typename T>\nstruct ref_selector\n{\n  typedef typename conditional<\n    bool(traits<T>::Flags & NestByRefBit),\n    T const&,\n    const T\n  >::type type;\n  \n  typedef typename conditional<\n    bool(traits<T>::Flags & NestByRefBit),\n    T &,\n    T\n  >::type non_const_type;\n};\n\n/** \\internal Adds the const qualifier on the value-type of T2 if and only if T1 is a const type */\ntemplate<typename T1, typename T2>\nstruct transfer_constness\n{\n  typedef typename conditional<\n    bool(internal::is_const<T1>::value),\n    typename internal::add_const_on_value_type<T2>::type,\n    T2\n  >::type type;\n};\n\n\n// However, we still need a mechanism to detect whether an expression which is evaluated multiple time\n// has to be evaluated into a temporary.\n// That's the purpose of this new nested_eval helper:\n/** \\internal Determines how a given expression should be nested when evaluated multiple times.\n  * For example, when you do a * (b+c), Eigen will determine how the expression b+c should be\n  * evaluated into the bigger product expression. The choice is between nesting the expression b+c as-is, or\n  * evaluating that expression b+c into a temporary variable d, and nest d so that the resulting expression is\n  * a*d. Evaluating can be beneficial for example if every coefficient access in the resulting expression causes\n  * many coefficient accesses in the nested expressions -- as is the case with matrix product for example.\n  *\n  * \\tparam T the type of the expression being nested.\n  * \\tparam n the number of coefficient accesses in the nested expression for each coefficient access in the bigger expression.\n  * \\tparam PlainObject the type of the temporary if needed.\n  */\ntemplate<typename T, int n, typename PlainObject = typename plain_object_eval<T>::type> struct nested_eval\n{\n  enum {\n    ScalarReadCost = NumTraits<typename traits<T>::Scalar>::ReadCost,\n    CoeffReadCost = evaluator<T>::CoeffReadCost,  // NOTE What if an evaluator evaluate itself into a tempory?\n                                                  //      Then CoeffReadCost will be small (e.g., 1) but we still have to evaluate, especially if n>1.\n                                                  //      This situation is already taken care by the EvalBeforeNestingBit flag, which is turned ON\n                                                  //      for all evaluator creating a temporary. This flag is then propagated by the parent evaluators.\n                                                  //      Another solution could be to count the number of temps?\n    NAsInteger = n == Dynamic ? HugeCost : n,\n    CostEval   = (NAsInteger+1) * ScalarReadCost + CoeffReadCost,\n    CostNoEval = NAsInteger * CoeffReadCost,\n    Evaluate = (int(evaluator<T>::Flags) & EvalBeforeNestingBit) || (int(CostEval) < int(CostNoEval))\n  };\n\n  typedef typename conditional<Evaluate, PlainObject, typename ref_selector<T>::type>::type type;\n};\n\ntemplate<typename T>\nEIGEN_DEVICE_FUNC\ninline T* const_cast_ptr(const T* ptr)\n{\n  return const_cast<T*>(ptr);\n}\n\ntemplate<typename Derived, typename XprKind = typename traits<Derived>::XprKind>\nstruct dense_xpr_base\n{\n  /* dense_xpr_base should only ever be used on dense expressions, thus falling either into the MatrixXpr or into the ArrayXpr cases */\n};\n\ntemplate<typename Derived>\nstruct dense_xpr_base<Derived, MatrixXpr>\n{\n  typedef MatrixBase<Derived> type;\n};\n\ntemplate<typename Derived>\nstruct dense_xpr_base<Derived, ArrayXpr>\n{\n  typedef ArrayBase<Derived> type;\n};\n\ntemplate<typename Derived, typename XprKind = typename traits<Derived>::XprKind, typename StorageKind = typename traits<Derived>::StorageKind>\nstruct generic_xpr_base;\n\ntemplate<typename Derived, typename XprKind>\nstruct generic_xpr_base<Derived, XprKind, Dense>\n{\n  typedef typename dense_xpr_base<Derived,XprKind>::type type;\n};\n\ntemplate<typename XprType, typename CastType> struct cast_return_type\n{\n  typedef typename XprType::Scalar CurrentScalarType;\n  typedef typename remove_all<CastType>::type _CastType;\n  typedef typename _CastType::Scalar NewScalarType;\n  typedef typename conditional<is_same<CurrentScalarType,NewScalarType>::value,\n                              const XprType&,CastType>::type type;\n};\n\ntemplate <typename A, typename B> struct promote_storage_type;\n\ntemplate <typename A> struct promote_storage_type<A,A>\n{\n  typedef A ret;\n};\ntemplate <typename A> struct promote_storage_type<A, const A>\n{\n  typedef A ret;\n};\ntemplate <typename A> struct promote_storage_type<const A, A>\n{\n  typedef A ret;\n};\n\n/** \\internal Specify the \"storage kind\" of applying a coefficient-wise\n  * binary operations between two expressions of kinds A and B respectively.\n  * The template parameter Functor permits to specialize the resulting storage kind wrt to\n  * the functor.\n  * The default rules are as follows:\n  * \\code\n  * A      op A      -> A\n  * A      op dense  -> dense\n  * dense  op B      -> dense\n  * sparse op dense  -> sparse\n  * dense  op sparse -> sparse\n  * \\endcode\n  */\ntemplate <typename A, typename B, typename Functor> struct cwise_promote_storage_type;\n\ntemplate <typename A, typename Functor>                   struct cwise_promote_storage_type<A,A,Functor>                                      { typedef A      ret; };\ntemplate <typename Functor>                               struct cwise_promote_storage_type<Dense,Dense,Functor>                              { typedef Dense  ret; };\ntemplate <typename A, typename Functor>                   struct cwise_promote_storage_type<A,Dense,Functor>                                  { typedef Dense  ret; };\ntemplate <typename B, typename Functor>                   struct cwise_promote_storage_type<Dense,B,Functor>                                  { typedef Dense  ret; };\ntemplate <typename Functor>                               struct cwise_promote_storage_type<Sparse,Dense,Functor>                             { typedef Sparse ret; };\ntemplate <typename Functor>                               struct cwise_promote_storage_type<Dense,Sparse,Functor>                             { typedef Sparse ret; };\n\ntemplate <typename LhsKind, typename RhsKind, int LhsOrder, int RhsOrder> struct cwise_promote_storage_order {\n  enum { value = LhsOrder };\n};\n\ntemplate <typename LhsKind, int LhsOrder, int RhsOrder>   struct cwise_promote_storage_order<LhsKind,Sparse,LhsOrder,RhsOrder>                { enum { value = RhsOrder }; };\ntemplate <typename RhsKind, int LhsOrder, int RhsOrder>   struct cwise_promote_storage_order<Sparse,RhsKind,LhsOrder,RhsOrder>                { enum { value = LhsOrder }; };\ntemplate <int Order>                                      struct cwise_promote_storage_order<Sparse,Sparse,Order,Order>                       { enum { value = Order }; };\n\n\n/** \\internal Specify the \"storage kind\" of multiplying an expression of kind A with kind B.\n  * The template parameter ProductTag permits to specialize the resulting storage kind wrt to\n  * some compile-time properties of the product: GemmProduct, GemvProduct, OuterProduct, InnerProduct.\n  * The default rules are as follows:\n  * \\code\n  *  K * K            -> K\n  *  dense * K        -> dense\n  *  K * dense        -> dense\n  *  diag * K         -> K\n  *  K * diag         -> K\n  *  Perm * K         -> K\n  * K * Perm          -> K\n  * \\endcode\n  */\ntemplate <typename A, typename B, int ProductTag> struct product_promote_storage_type;\n\ntemplate <typename A, int ProductTag> struct product_promote_storage_type<A,                  A,                  ProductTag> { typedef A     ret;};\ntemplate <int ProductTag>             struct product_promote_storage_type<Dense,              Dense,              ProductTag> { typedef Dense ret;};\ntemplate <typename A, int ProductTag> struct product_promote_storage_type<A,                  Dense,              ProductTag> { typedef Dense ret; };\ntemplate <typename B, int ProductTag> struct product_promote_storage_type<Dense,              B,                  ProductTag> { typedef Dense ret; };\n\ntemplate <typename A, int ProductTag> struct product_promote_storage_type<A,                  DiagonalShape,      ProductTag> { typedef A ret; };\ntemplate <typename B, int ProductTag> struct product_promote_storage_type<DiagonalShape,      B,                  ProductTag> { typedef B ret; };\ntemplate <int ProductTag>             struct product_promote_storage_type<Dense,              DiagonalShape,      ProductTag> { typedef Dense ret; };\ntemplate <int ProductTag>             struct product_promote_storage_type<DiagonalShape,      Dense,              ProductTag> { typedef Dense ret; };\n\ntemplate <typename A, int ProductTag> struct product_promote_storage_type<A,                  PermutationStorage, ProductTag> { typedef A ret; };\ntemplate <typename B, int ProductTag> struct product_promote_storage_type<PermutationStorage, B,                  ProductTag> { typedef B ret; };\ntemplate <int ProductTag>             struct product_promote_storage_type<Dense,              PermutationStorage, ProductTag> { typedef Dense ret; };\ntemplate <int ProductTag>             struct product_promote_storage_type<PermutationStorage, Dense,              ProductTag> { typedef Dense ret; };\n\n/** \\internal gives the plain matrix or array type to store a row/column/diagonal of a matrix type.\n  * \\tparam Scalar optional parameter allowing to pass a different scalar type than the one of the MatrixType.\n  */\ntemplate<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar>\nstruct plain_row_type\n{\n  typedef Matrix<Scalar, 1, ExpressionType::ColsAtCompileTime,\n                 ExpressionType::PlainObject::Options | RowMajor, 1, ExpressionType::MaxColsAtCompileTime> MatrixRowType;\n  typedef Array<Scalar, 1, ExpressionType::ColsAtCompileTime,\n                 ExpressionType::PlainObject::Options | RowMajor, 1, ExpressionType::MaxColsAtCompileTime> ArrayRowType;\n\n  typedef typename conditional<\n    is_same< typename traits<ExpressionType>::XprKind, MatrixXpr >::value,\n    MatrixRowType,\n    ArrayRowType \n  >::type type;\n};\n\ntemplate<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar>\nstruct plain_col_type\n{\n  typedef Matrix<Scalar, ExpressionType::RowsAtCompileTime, 1,\n                 ExpressionType::PlainObject::Options & ~RowMajor, ExpressionType::MaxRowsAtCompileTime, 1> MatrixColType;\n  typedef Array<Scalar, ExpressionType::RowsAtCompileTime, 1,\n                 ExpressionType::PlainObject::Options & ~RowMajor, ExpressionType::MaxRowsAtCompileTime, 1> ArrayColType;\n\n  typedef typename conditional<\n    is_same< typename traits<ExpressionType>::XprKind, MatrixXpr >::value,\n    MatrixColType,\n    ArrayColType \n  >::type type;\n};\n\ntemplate<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar>\nstruct plain_diag_type\n{\n  enum { diag_size = EIGEN_SIZE_MIN_PREFER_DYNAMIC(ExpressionType::RowsAtCompileTime, ExpressionType::ColsAtCompileTime),\n         max_diag_size = EIGEN_SIZE_MIN_PREFER_FIXED(ExpressionType::MaxRowsAtCompileTime, ExpressionType::MaxColsAtCompileTime)\n  };\n  typedef Matrix<Scalar, diag_size, 1, ExpressionType::PlainObject::Options & ~RowMajor, max_diag_size, 1> MatrixDiagType;\n  typedef Array<Scalar, diag_size, 1, ExpressionType::PlainObject::Options & ~RowMajor, max_diag_size, 1> ArrayDiagType;\n\n  typedef typename conditional<\n    is_same< typename traits<ExpressionType>::XprKind, MatrixXpr >::value,\n    MatrixDiagType,\n    ArrayDiagType \n  >::type type;\n};\n\ntemplate<typename Expr,typename Scalar = typename Expr::Scalar>\nstruct plain_constant_type\n{\n  enum { Options = (traits<Expr>::Flags&RowMajorBit)?RowMajor:0 };\n\n  typedef Array<Scalar,  traits<Expr>::RowsAtCompileTime,   traits<Expr>::ColsAtCompileTime,\n                Options, traits<Expr>::MaxRowsAtCompileTime,traits<Expr>::MaxColsAtCompileTime> array_type;\n\n  typedef Matrix<Scalar,  traits<Expr>::RowsAtCompileTime,   traits<Expr>::ColsAtCompileTime,\n                 Options, traits<Expr>::MaxRowsAtCompileTime,traits<Expr>::MaxColsAtCompileTime> matrix_type;\n\n  typedef CwiseNullaryOp<scalar_constant_op<Scalar>, const typename conditional<is_same< typename traits<Expr>::XprKind, MatrixXpr >::value, matrix_type, array_type>::type > type;\n};\n\ntemplate<typename ExpressionType>\nstruct is_lvalue\n{\n  enum { value = (!bool(is_const<ExpressionType>::value)) &&\n                 bool(traits<ExpressionType>::Flags & LvalueBit) };\n};\n\ntemplate<typename T> struct is_diagonal\n{ enum { ret = false }; };\n\ntemplate<typename T> struct is_diagonal<DiagonalBase<T> >\n{ enum { ret = true }; };\n\ntemplate<typename T> struct is_diagonal<DiagonalWrapper<T> >\n{ enum { ret = true }; };\n\ntemplate<typename T, int S> struct is_diagonal<DiagonalMatrix<T,S> >\n{ enum { ret = true }; };\n\ntemplate<typename S1, typename S2> struct glue_shapes;\ntemplate<> struct glue_shapes<DenseShape,TriangularShape> { typedef TriangularShape type;  };\n\ntemplate<typename T1, typename T2>\nbool is_same_dense(const T1 &mat1, const T2 &mat2, typename enable_if<has_direct_access<T1>::ret&&has_direct_access<T2>::ret, T1>::type * = 0)\n{\n  return (mat1.data()==mat2.data()) && (mat1.innerStride()==mat2.innerStride()) && (mat1.outerStride()==mat2.outerStride());\n}\n\ntemplate<typename T1, typename T2>\nbool is_same_dense(const T1 &, const T2 &, typename enable_if<!(has_direct_access<T1>::ret&&has_direct_access<T2>::ret), T1>::type * = 0)\n{\n  return false;\n}\n\n// Internal helper defining the cost of a scalar division for the type T.\n// The default heuristic can be specialized for each scalar type and architecture.\ntemplate<typename T,bool Vectorized=false,typename EnaleIf = void>\nstruct scalar_div_cost {\n  enum { value = 8*NumTraits<T>::MulCost };\n};\n\ntemplate<typename T,bool Vectorized>\nstruct scalar_div_cost<std::complex<T>, Vectorized> {\n  enum { value = 2*scalar_div_cost<T>::value\n               + 6*NumTraits<T>::MulCost\n               + 3*NumTraits<T>::AddCost\n  };\n};\n\n\ntemplate<bool Vectorized>\nstruct scalar_div_cost<signed long,Vectorized,typename conditional<sizeof(long)==8,void,false_type>::type> { enum { value = 24 }; };\ntemplate<bool Vectorized>\nstruct scalar_div_cost<unsigned long,Vectorized,typename conditional<sizeof(long)==8,void,false_type>::type> { enum { value = 21 }; };\n\n\n#ifdef EIGEN_DEBUG_ASSIGN\nstd::string demangle_traversal(int t)\n{\n  if(t==DefaultTraversal) return \"DefaultTraversal\";\n  if(t==LinearTraversal) return \"LinearTraversal\";\n  if(t==InnerVectorizedTraversal) return \"InnerVectorizedTraversal\";\n  if(t==LinearVectorizedTraversal) return \"LinearVectorizedTraversal\";\n  if(t==SliceVectorizedTraversal) return \"SliceVectorizedTraversal\";\n  return \"?\";\n}\nstd::string demangle_unrolling(int t)\n{\n  if(t==NoUnrolling) return \"NoUnrolling\";\n  if(t==InnerUnrolling) return \"InnerUnrolling\";\n  if(t==CompleteUnrolling) return \"CompleteUnrolling\";\n  return \"?\";\n}\nstd::string demangle_flags(int f)\n{\n  std::string res;\n  if(f&RowMajorBit)                 res += \" | RowMajor\";\n  if(f&PacketAccessBit)             res += \" | Packet\";\n  if(f&LinearAccessBit)             res += \" | Linear\";\n  if(f&LvalueBit)                   res += \" | Lvalue\";\n  if(f&DirectAccessBit)             res += \" | Direct\";\n  if(f&NestByRefBit)                res += \" | NestByRef\";\n  if(f&NoPreferredStorageOrderBit)  res += \" | NoPreferredStorageOrderBit\";\n  \n  return res;\n}\n#endif\n\n} // end namespace internal\n\n\n/** \\class ScalarBinaryOpTraits\n  * \\ingroup Core_Module\n  *\n  * \\brief Determines whether the given binary operation of two numeric types is allowed and what the scalar return type is.\n  *\n  * This class permits to control the scalar return type of any binary operation performed on two different scalar types through (partial) template specializations.\n  *\n  * For instance, let \\c U1, \\c U2 and \\c U3 be three user defined scalar types for which most operations between instances of \\c U1 and \\c U2 returns an \\c U3.\n  * You can let %Eigen knows that by defining:\n    \\code\n    template<typename BinaryOp>\n    struct ScalarBinaryOpTraits<U1,U2,BinaryOp> { typedef U3 ReturnType;  };\n    template<typename BinaryOp>\n    struct ScalarBinaryOpTraits<U2,U1,BinaryOp> { typedef U3 ReturnType;  };\n    \\endcode\n  * You can then explicitly disable some particular operations to get more explicit error messages:\n    \\code\n    template<>\n    struct ScalarBinaryOpTraits<U1,U2,internal::scalar_max_op<U1,U2> > {};\n    \\endcode\n  * Or customize the return type for individual operation:\n    \\code\n    template<>\n    struct ScalarBinaryOpTraits<U1,U2,internal::scalar_sum_op<U1,U2> > { typedef U1 ReturnType; };\n    \\endcode\n  *\n  * By default, the following generic combinations are supported:\n  <table class=\"manual\">\n  <tr><th>ScalarA</th><th>ScalarB</th><th>BinaryOp</th><th>ReturnType</th><th>Note</th></tr>\n  <tr            ><td>\\c T </td><td>\\c T </td><td>\\c * </td><td>\\c T </td><td></td></tr>\n  <tr class=\"alt\"><td>\\c NumTraits<T>::Real </td><td>\\c T </td><td>\\c * </td><td>\\c T </td><td>Only if \\c NumTraits<T>::IsComplex </td></tr>\n  <tr            ><td>\\c T </td><td>\\c NumTraits<T>::Real </td><td>\\c * </td><td>\\c T </td><td>Only if \\c NumTraits<T>::IsComplex </td></tr>\n  </table>\n  *\n  * \\sa CwiseBinaryOp\n  */\ntemplate<typename ScalarA, typename ScalarB, typename BinaryOp=internal::scalar_product_op<ScalarA,ScalarB> >\nstruct ScalarBinaryOpTraits\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n  // for backward compatibility, use the hints given by the (deprecated) internal::scalar_product_traits class.\n  : internal::scalar_product_traits<ScalarA,ScalarB>\n#endif // EIGEN_PARSED_BY_DOXYGEN\n{};\n\ntemplate<typename T, typename BinaryOp>\nstruct ScalarBinaryOpTraits<T,T,BinaryOp>\n{\n  typedef T ReturnType;\n};\n\ntemplate <typename T, typename BinaryOp>\nstruct ScalarBinaryOpTraits<T, typename NumTraits<typename internal::enable_if<NumTraits<T>::IsComplex,T>::type>::Real, BinaryOp>\n{\n  typedef T ReturnType;\n};\ntemplate <typename T, typename BinaryOp>\nstruct ScalarBinaryOpTraits<typename NumTraits<typename internal::enable_if<NumTraits<T>::IsComplex,T>::type>::Real, T, BinaryOp>\n{\n  typedef T ReturnType;\n};\n\n// For Matrix * Permutation\ntemplate<typename T, typename BinaryOp>\nstruct ScalarBinaryOpTraits<T,void,BinaryOp>\n{\n  typedef T ReturnType;\n};\n\n// For Permutation * Matrix\ntemplate<typename T, typename BinaryOp>\nstruct ScalarBinaryOpTraits<void,T,BinaryOp>\n{\n  typedef T ReturnType;\n};\n\n// for Permutation*Permutation\ntemplate<typename BinaryOp>\nstruct ScalarBinaryOpTraits<void,void,BinaryOp>\n{\n  typedef void ReturnType;\n};\n\n// We require Lhs and Rhs to have \"compatible\" scalar types.\n// It is tempting to always allow mixing different types but remember that this is often impossible in the vectorized paths.\n// So allowing mixing different types gives very unexpected errors when enabling vectorization, when the user tries to\n// add together a float matrix and a double matrix.\n#define EIGEN_CHECK_BINARY_COMPATIBILIY(BINOP,LHS,RHS) \\\n  EIGEN_STATIC_ASSERT((Eigen::internal::has_ReturnType<ScalarBinaryOpTraits<LHS, RHS,BINOP> >::value), \\\n    YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)\n    \n} // end namespace Eigen\n\n#endif // EIGEN_XPRHELPER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/ComplexEigenSolver.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Claire Maurice\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010,2012 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COMPLEX_EIGEN_SOLVER_H\n#define EIGEN_COMPLEX_EIGEN_SOLVER_H\n\n#include \"./ComplexSchur.h\"\n\nnamespace Eigen { \n\n/** \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  *\n  * \\class ComplexEigenSolver\n  *\n  * \\brief Computes eigenvalues and eigenvectors of general complex matrices\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are\n  * computing the eigendecomposition; this is expected to be an\n  * instantiation of the Matrix class template.\n  *\n  * The eigenvalues and eigenvectors of a matrix \\f$ A \\f$ are scalars\n  * \\f$ \\lambda \\f$ and vectors \\f$ v \\f$ such that \\f$ Av = \\lambda v\n  * \\f$.  If \\f$ D \\f$ is a diagonal matrix with the eigenvalues on\n  * the diagonal, and \\f$ V \\f$ is a matrix with the eigenvectors as\n  * its columns, then \\f$ A V = V D \\f$. The matrix \\f$ V \\f$ is\n  * almost always invertible, in which case we have \\f$ A = V D V^{-1}\n  * \\f$. This is called the eigendecomposition.\n  *\n  * The main function in this class is compute(), which computes the\n  * eigenvalues and eigenvectors of a given function. The\n  * documentation for that function contains an example showing the\n  * main features of the class.\n  *\n  * \\sa class EigenSolver, class SelfAdjointEigenSolver\n  */\ntemplate<typename _MatrixType> class ComplexEigenSolver\n{\n  public:\n\n    /** \\brief Synonym for the template parameter \\p _MatrixType. */\n    typedef _MatrixType MatrixType;\n\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      Options = MatrixType::Options,\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n\n    /** \\brief Scalar type for matrices of type #MatrixType. */\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n\n    /** \\brief Complex scalar type for #MatrixType.\n      *\n      * This is \\c std::complex<Scalar> if #Scalar is real (e.g.,\n      * \\c float or \\c double) and just \\c Scalar if #Scalar is\n      * complex.\n      */\n    typedef std::complex<RealScalar> ComplexScalar;\n\n    /** \\brief Type for vector of eigenvalues as returned by eigenvalues().\n      *\n      * This is a column vector with entries of type #ComplexScalar.\n      * The length of the vector is the size of #MatrixType.\n      */\n    typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options&(~RowMajor), MaxColsAtCompileTime, 1> EigenvalueType;\n\n    /** \\brief Type for matrix of eigenvectors as returned by eigenvectors().\n      *\n      * This is a square matrix with entries of type #ComplexScalar.\n      * The size is the same as the size of #MatrixType.\n      */\n    typedef Matrix<ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime> EigenvectorType;\n\n    /** \\brief Default constructor.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via compute().\n      */\n    ComplexEigenSolver()\n            : m_eivec(),\n              m_eivalues(),\n              m_schur(),\n              m_isInitialized(false),\n              m_eigenvectorsOk(false),\n              m_matX()\n    {}\n\n    /** \\brief Default Constructor with memory preallocation\n      *\n      * Like the default constructor but with preallocation of the internal data\n      * according to the specified problem \\a size.\n      * \\sa ComplexEigenSolver()\n      */\n    explicit ComplexEigenSolver(Index size)\n            : m_eivec(size, size),\n              m_eivalues(size),\n              m_schur(size),\n              m_isInitialized(false),\n              m_eigenvectorsOk(false),\n              m_matX(size, size)\n    {}\n\n    /** \\brief Constructor; computes eigendecomposition of given matrix.\n      *\n      * \\param[in]  matrix  Square matrix whose eigendecomposition is to be computed.\n      * \\param[in]  computeEigenvectors  If true, both the eigenvectors and the\n      *    eigenvalues are computed; if false, only the eigenvalues are\n      *    computed.\n      *\n      * This constructor calls compute() to compute the eigendecomposition.\n      */\n    template<typename InputType>\n    explicit ComplexEigenSolver(const EigenBase<InputType>& matrix, bool computeEigenvectors = true)\n            : m_eivec(matrix.rows(),matrix.cols()),\n              m_eivalues(matrix.cols()),\n              m_schur(matrix.rows()),\n              m_isInitialized(false),\n              m_eigenvectorsOk(false),\n              m_matX(matrix.rows(),matrix.cols())\n    {\n      compute(matrix.derived(), computeEigenvectors);\n    }\n\n    /** \\brief Returns the eigenvectors of given matrix.\n      *\n      * \\returns  A const reference to the matrix whose columns are the eigenvectors.\n      *\n      * \\pre Either the constructor\n      * ComplexEigenSolver(const MatrixType& matrix, bool) or the member\n      * function compute(const MatrixType& matrix, bool) has been called before\n      * to compute the eigendecomposition of a matrix, and\n      * \\p computeEigenvectors was set to true (the default).\n      *\n      * This function returns a matrix whose columns are the eigenvectors. Column\n      * \\f$ k \\f$ is an eigenvector corresponding to eigenvalue number \\f$ k\n      * \\f$ as returned by eigenvalues().  The eigenvectors are normalized to\n      * have (Euclidean) norm equal to one. The matrix returned by this\n      * function is the matrix \\f$ V \\f$ in the eigendecomposition \\f$ A = V D\n      * V^{-1} \\f$, if it exists.\n      *\n      * Example: \\include ComplexEigenSolver_eigenvectors.cpp\n      * Output: \\verbinclude ComplexEigenSolver_eigenvectors.out\n      */\n    const EigenvectorType& eigenvectors() const\n    {\n      eigen_assert(m_isInitialized && \"ComplexEigenSolver is not initialized.\");\n      eigen_assert(m_eigenvectorsOk && \"The eigenvectors have not been computed together with the eigenvalues.\");\n      return m_eivec;\n    }\n\n    /** \\brief Returns the eigenvalues of given matrix.\n      *\n      * \\returns A const reference to the column vector containing the eigenvalues.\n      *\n      * \\pre Either the constructor\n      * ComplexEigenSolver(const MatrixType& matrix, bool) or the member\n      * function compute(const MatrixType& matrix, bool) has been called before\n      * to compute the eigendecomposition of a matrix.\n      *\n      * This function returns a column vector containing the\n      * eigenvalues. Eigenvalues are repeated according to their\n      * algebraic multiplicity, so there are as many eigenvalues as\n      * rows in the matrix. The eigenvalues are not sorted in any particular\n      * order.\n      *\n      * Example: \\include ComplexEigenSolver_eigenvalues.cpp\n      * Output: \\verbinclude ComplexEigenSolver_eigenvalues.out\n      */\n    const EigenvalueType& eigenvalues() const\n    {\n      eigen_assert(m_isInitialized && \"ComplexEigenSolver is not initialized.\");\n      return m_eivalues;\n    }\n\n    /** \\brief Computes eigendecomposition of given matrix.\n      *\n      * \\param[in]  matrix  Square matrix whose eigendecomposition is to be computed.\n      * \\param[in]  computeEigenvectors  If true, both the eigenvectors and the\n      *    eigenvalues are computed; if false, only the eigenvalues are\n      *    computed.\n      * \\returns    Reference to \\c *this\n      *\n      * This function computes the eigenvalues of the complex matrix \\p matrix.\n      * The eigenvalues() function can be used to retrieve them.  If\n      * \\p computeEigenvectors is true, then the eigenvectors are also computed\n      * and can be retrieved by calling eigenvectors().\n      *\n      * The matrix is first reduced to Schur form using the\n      * ComplexSchur class. The Schur decomposition is then used to\n      * compute the eigenvalues and eigenvectors.\n      *\n      * The cost of the computation is dominated by the cost of the\n      * Schur decomposition, which is \\f$ O(n^3) \\f$ where \\f$ n \\f$\n      * is the size of the matrix.\n      *\n      * Example: \\include ComplexEigenSolver_compute.cpp\n      * Output: \\verbinclude ComplexEigenSolver_compute.out\n      */\n    template<typename InputType>\n    ComplexEigenSolver& compute(const EigenBase<InputType>& matrix, bool computeEigenvectors = true);\n\n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful, \\c NoConvergence otherwise.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"ComplexEigenSolver is not initialized.\");\n      return m_schur.info();\n    }\n\n    /** \\brief Sets the maximum number of iterations allowed. */\n    ComplexEigenSolver& setMaxIterations(Index maxIters)\n    {\n      m_schur.setMaxIterations(maxIters);\n      return *this;\n    }\n\n    /** \\brief Returns the maximum number of iterations. */\n    Index getMaxIterations()\n    {\n      return m_schur.getMaxIterations();\n    }\n\n  protected:\n    \n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n    }\n    \n    EigenvectorType m_eivec;\n    EigenvalueType m_eivalues;\n    ComplexSchur<MatrixType> m_schur;\n    bool m_isInitialized;\n    bool m_eigenvectorsOk;\n    EigenvectorType m_matX;\n\n  private:\n    void doComputeEigenvectors(RealScalar matrixnorm);\n    void sortEigenvalues(bool computeEigenvectors);\n};\n\n\ntemplate<typename MatrixType>\ntemplate<typename InputType>\nComplexEigenSolver<MatrixType>& \nComplexEigenSolver<MatrixType>::compute(const EigenBase<InputType>& matrix, bool computeEigenvectors)\n{\n  check_template_parameters();\n  \n  // this code is inspired from Jampack\n  eigen_assert(matrix.cols() == matrix.rows());\n\n  // Do a complex Schur decomposition, A = U T U^*\n  // The eigenvalues are on the diagonal of T.\n  m_schur.compute(matrix.derived(), computeEigenvectors);\n\n  if(m_schur.info() == Success)\n  {\n    m_eivalues = m_schur.matrixT().diagonal();\n    if(computeEigenvectors)\n      doComputeEigenvectors(m_schur.matrixT().norm());\n    sortEigenvalues(computeEigenvectors);\n  }\n\n  m_isInitialized = true;\n  m_eigenvectorsOk = computeEigenvectors;\n  return *this;\n}\n\n\ntemplate<typename MatrixType>\nvoid ComplexEigenSolver<MatrixType>::doComputeEigenvectors(RealScalar matrixnorm)\n{\n  const Index n = m_eivalues.size();\n\n  matrixnorm = numext::maxi(matrixnorm,(std::numeric_limits<RealScalar>::min)());\n\n  // Compute X such that T = X D X^(-1), where D is the diagonal of T.\n  // The matrix X is unit triangular.\n  m_matX = EigenvectorType::Zero(n, n);\n  for(Index k=n-1 ; k>=0 ; k--)\n  {\n    m_matX.coeffRef(k,k) = ComplexScalar(1.0,0.0);\n    // Compute X(i,k) using the (i,k) entry of the equation X T = D X\n    for(Index i=k-1 ; i>=0 ; i--)\n    {\n      m_matX.coeffRef(i,k) = -m_schur.matrixT().coeff(i,k);\n      if(k-i-1>0)\n        m_matX.coeffRef(i,k) -= (m_schur.matrixT().row(i).segment(i+1,k-i-1) * m_matX.col(k).segment(i+1,k-i-1)).value();\n      ComplexScalar z = m_schur.matrixT().coeff(i,i) - m_schur.matrixT().coeff(k,k);\n      if(z==ComplexScalar(0))\n      {\n        // If the i-th and k-th eigenvalue are equal, then z equals 0.\n        // Use a small value instead, to prevent division by zero.\n        numext::real_ref(z) = NumTraits<RealScalar>::epsilon() * matrixnorm;\n      }\n      m_matX.coeffRef(i,k) = m_matX.coeff(i,k) / z;\n    }\n  }\n\n  // Compute V as V = U X; now A = U T U^* = U X D X^(-1) U^* = V D V^(-1)\n  m_eivec.noalias() = m_schur.matrixU() * m_matX;\n  // .. and normalize the eigenvectors\n  for(Index k=0 ; k<n ; k++)\n  {\n    m_eivec.col(k).normalize();\n  }\n}\n\n\ntemplate<typename MatrixType>\nvoid ComplexEigenSolver<MatrixType>::sortEigenvalues(bool computeEigenvectors)\n{\n  const Index n =  m_eivalues.size();\n  for (Index i=0; i<n; i++)\n  {\n    Index k;\n    m_eivalues.cwiseAbs().tail(n-i).minCoeff(&k);\n    if (k != 0)\n    {\n      k += i;\n      std::swap(m_eivalues[k],m_eivalues[i]);\n      if(computeEigenvectors)\n\tm_eivec.col(i).swap(m_eivec.col(k));\n    }\n  }\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_COMPLEX_EIGEN_SOLVER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/ComplexSchur.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Claire Maurice\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010,2012 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COMPLEX_SCHUR_H\n#define EIGEN_COMPLEX_SCHUR_H\n\n#include \"./HessenbergDecomposition.h\"\n\nnamespace Eigen { \n\nnamespace internal {\ntemplate<typename MatrixType, bool IsComplex> struct complex_schur_reduce_to_hessenberg;\n}\n\n/** \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  *\n  * \\class ComplexSchur\n  *\n  * \\brief Performs a complex Schur decomposition of a real or complex square matrix\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are\n  * computing the Schur decomposition; this is expected to be an\n  * instantiation of the Matrix class template.\n  *\n  * Given a real or complex square matrix A, this class computes the\n  * Schur decomposition: \\f$ A = U T U^*\\f$ where U is a unitary\n  * complex matrix, and T is a complex upper triangular matrix.  The\n  * diagonal of the matrix T corresponds to the eigenvalues of the\n  * matrix A.\n  *\n  * Call the function compute() to compute the Schur decomposition of\n  * a given matrix. Alternatively, you can use the \n  * ComplexSchur(const MatrixType&, bool) constructor which computes\n  * the Schur decomposition at construction time. Once the\n  * decomposition is computed, you can use the matrixU() and matrixT()\n  * functions to retrieve the matrices U and V in the decomposition.\n  *\n  * \\note This code is inspired from Jampack\n  *\n  * \\sa class RealSchur, class EigenSolver, class ComplexEigenSolver\n  */\ntemplate<typename _MatrixType> class ComplexSchur\n{\n  public:\n    typedef _MatrixType MatrixType;\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      Options = MatrixType::Options,\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n\n    /** \\brief Scalar type for matrices of type \\p _MatrixType. */\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n\n    /** \\brief Complex scalar type for \\p _MatrixType. \n      *\n      * This is \\c std::complex<Scalar> if #Scalar is real (e.g.,\n      * \\c float or \\c double) and just \\c Scalar if #Scalar is\n      * complex.\n      */\n    typedef std::complex<RealScalar> ComplexScalar;\n\n    /** \\brief Type for the matrices in the Schur decomposition.\n      *\n      * This is a square matrix with entries of type #ComplexScalar. \n      * The size is the same as the size of \\p _MatrixType.\n      */\n    typedef Matrix<ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime> ComplexMatrixType;\n\n    /** \\brief Default constructor.\n      *\n      * \\param [in] size  Positive integer, size of the matrix whose Schur decomposition will be computed.\n      *\n      * The default constructor is useful in cases in which the user\n      * intends to perform decompositions via compute().  The \\p size\n      * parameter is only used as a hint. It is not an error to give a\n      * wrong \\p size, but it may impair performance.\n      *\n      * \\sa compute() for an example.\n      */\n    explicit ComplexSchur(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime)\n      : m_matT(size,size),\n        m_matU(size,size),\n        m_hess(size),\n        m_isInitialized(false),\n        m_matUisUptodate(false),\n        m_maxIters(-1)\n    {}\n\n    /** \\brief Constructor; computes Schur decomposition of given matrix. \n      * \n      * \\param[in]  matrix    Square matrix whose Schur decomposition is to be computed.\n      * \\param[in]  computeU  If true, both T and U are computed; if false, only T is computed.\n      *\n      * This constructor calls compute() to compute the Schur decomposition.\n      *\n      * \\sa matrixT() and matrixU() for examples.\n      */\n    template<typename InputType>\n    explicit ComplexSchur(const EigenBase<InputType>& matrix, bool computeU = true)\n      : m_matT(matrix.rows(),matrix.cols()),\n        m_matU(matrix.rows(),matrix.cols()),\n        m_hess(matrix.rows()),\n        m_isInitialized(false),\n        m_matUisUptodate(false),\n        m_maxIters(-1)\n    {\n      compute(matrix.derived(), computeU);\n    }\n\n    /** \\brief Returns the unitary matrix in the Schur decomposition. \n      *\n      * \\returns A const reference to the matrix U.\n      *\n      * It is assumed that either the constructor\n      * ComplexSchur(const MatrixType& matrix, bool computeU) or the\n      * member function compute(const MatrixType& matrix, bool computeU)\n      * has been called before to compute the Schur decomposition of a\n      * matrix, and that \\p computeU was set to true (the default\n      * value).\n      *\n      * Example: \\include ComplexSchur_matrixU.cpp\n      * Output: \\verbinclude ComplexSchur_matrixU.out\n      */\n    const ComplexMatrixType& matrixU() const\n    {\n      eigen_assert(m_isInitialized && \"ComplexSchur is not initialized.\");\n      eigen_assert(m_matUisUptodate && \"The matrix U has not been computed during the ComplexSchur decomposition.\");\n      return m_matU;\n    }\n\n    /** \\brief Returns the triangular matrix in the Schur decomposition. \n      *\n      * \\returns A const reference to the matrix T.\n      *\n      * It is assumed that either the constructor\n      * ComplexSchur(const MatrixType& matrix, bool computeU) or the\n      * member function compute(const MatrixType& matrix, bool computeU)\n      * has been called before to compute the Schur decomposition of a\n      * matrix.\n      *\n      * Note that this function returns a plain square matrix. If you want to reference\n      * only the upper triangular part, use:\n      * \\code schur.matrixT().triangularView<Upper>() \\endcode \n      *\n      * Example: \\include ComplexSchur_matrixT.cpp\n      * Output: \\verbinclude ComplexSchur_matrixT.out\n      */\n    const ComplexMatrixType& matrixT() const\n    {\n      eigen_assert(m_isInitialized && \"ComplexSchur is not initialized.\");\n      return m_matT;\n    }\n\n    /** \\brief Computes Schur decomposition of given matrix. \n      * \n      * \\param[in]  matrix  Square matrix whose Schur decomposition is to be computed.\n      * \\param[in]  computeU  If true, both T and U are computed; if false, only T is computed.\n\n      * \\returns    Reference to \\c *this\n      *\n      * The Schur decomposition is computed by first reducing the\n      * matrix to Hessenberg form using the class\n      * HessenbergDecomposition. The Hessenberg matrix is then reduced\n      * to triangular form by performing QR iterations with a single\n      * shift. The cost of computing the Schur decomposition depends\n      * on the number of iterations; as a rough guide, it may be taken\n      * on the number of iterations; as a rough guide, it may be taken\n      * to be \\f$25n^3\\f$ complex flops, or \\f$10n^3\\f$ complex flops\n      * if \\a computeU is false.\n      *\n      * Example: \\include ComplexSchur_compute.cpp\n      * Output: \\verbinclude ComplexSchur_compute.out\n      *\n      * \\sa compute(const MatrixType&, bool, Index)\n      */\n    template<typename InputType>\n    ComplexSchur& compute(const EigenBase<InputType>& matrix, bool computeU = true);\n    \n    /** \\brief Compute Schur decomposition from a given Hessenberg matrix\n     *  \\param[in] matrixH Matrix in Hessenberg form H\n     *  \\param[in] matrixQ orthogonal matrix Q that transform a matrix A to H : A = Q H Q^T\n     *  \\param computeU Computes the matriX U of the Schur vectors\n     * \\return Reference to \\c *this\n     * \n     *  This routine assumes that the matrix is already reduced in Hessenberg form matrixH\n     *  using either the class HessenbergDecomposition or another mean. \n     *  It computes the upper quasi-triangular matrix T of the Schur decomposition of H\n     *  When computeU is true, this routine computes the matrix U such that \n     *  A = U T U^T =  (QZ) T (QZ)^T = Q H Q^T where A is the initial matrix\n     * \n     * NOTE Q is referenced if computeU is true; so, if the initial orthogonal matrix\n     * is not available, the user should give an identity matrix (Q.setIdentity())\n     * \n     * \\sa compute(const MatrixType&, bool)\n     */\n    template<typename HessMatrixType, typename OrthMatrixType>\n    ComplexSchur& computeFromHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ,  bool computeU=true);\n\n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful, \\c NoConvergence otherwise.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"ComplexSchur is not initialized.\");\n      return m_info;\n    }\n\n    /** \\brief Sets the maximum number of iterations allowed. \n      *\n      * If not specified by the user, the maximum number of iterations is m_maxIterationsPerRow times the size\n      * of the matrix.\n      */\n    ComplexSchur& setMaxIterations(Index maxIters)\n    {\n      m_maxIters = maxIters;\n      return *this;\n    }\n\n    /** \\brief Returns the maximum number of iterations. */\n    Index getMaxIterations()\n    {\n      return m_maxIters;\n    }\n\n    /** \\brief Maximum number of iterations per row.\n      *\n      * If not otherwise specified, the maximum number of iterations is this number times the size of the\n      * matrix. It is currently set to 30.\n      */\n    static const int m_maxIterationsPerRow = 30;\n\n  protected:\n    ComplexMatrixType m_matT, m_matU;\n    HessenbergDecomposition<MatrixType> m_hess;\n    ComputationInfo m_info;\n    bool m_isInitialized;\n    bool m_matUisUptodate;\n    Index m_maxIters;\n\n  private:  \n    bool subdiagonalEntryIsNeglegible(Index i);\n    ComplexScalar computeShift(Index iu, Index iter);\n    void reduceToTriangularForm(bool computeU);\n    friend struct internal::complex_schur_reduce_to_hessenberg<MatrixType, NumTraits<Scalar>::IsComplex>;\n};\n\n/** If m_matT(i+1,i) is neglegible in floating point arithmetic\n  * compared to m_matT(i,i) and m_matT(j,j), then set it to zero and\n  * return true, else return false. */\ntemplate<typename MatrixType>\ninline bool ComplexSchur<MatrixType>::subdiagonalEntryIsNeglegible(Index i)\n{\n  RealScalar d = numext::norm1(m_matT.coeff(i,i)) + numext::norm1(m_matT.coeff(i+1,i+1));\n  RealScalar sd = numext::norm1(m_matT.coeff(i+1,i));\n  if (internal::isMuchSmallerThan(sd, d, NumTraits<RealScalar>::epsilon()))\n  {\n    m_matT.coeffRef(i+1,i) = ComplexScalar(0);\n    return true;\n  }\n  return false;\n}\n\n\n/** Compute the shift in the current QR iteration. */\ntemplate<typename MatrixType>\ntypename ComplexSchur<MatrixType>::ComplexScalar ComplexSchur<MatrixType>::computeShift(Index iu, Index iter)\n{\n  using std::abs;\n  if (iter == 10 || iter == 20) \n  {\n    // exceptional shift, taken from http://www.netlib.org/eispack/comqr.f\n    return abs(numext::real(m_matT.coeff(iu,iu-1))) + abs(numext::real(m_matT.coeff(iu-1,iu-2)));\n  }\n\n  // compute the shift as one of the eigenvalues of t, the 2x2\n  // diagonal block on the bottom of the active submatrix\n  Matrix<ComplexScalar,2,2> t = m_matT.template block<2,2>(iu-1,iu-1);\n  RealScalar normt = t.cwiseAbs().sum();\n  t /= normt;     // the normalization by sf is to avoid under/overflow\n\n  ComplexScalar b = t.coeff(0,1) * t.coeff(1,0);\n  ComplexScalar c = t.coeff(0,0) - t.coeff(1,1);\n  ComplexScalar disc = sqrt(c*c + RealScalar(4)*b);\n  ComplexScalar det = t.coeff(0,0) * t.coeff(1,1) - b;\n  ComplexScalar trace = t.coeff(0,0) + t.coeff(1,1);\n  ComplexScalar eival1 = (trace + disc) / RealScalar(2);\n  ComplexScalar eival2 = (trace - disc) / RealScalar(2);\n\n  if(numext::norm1(eival1) > numext::norm1(eival2))\n    eival2 = det / eival1;\n  else\n    eival1 = det / eival2;\n\n  // choose the eigenvalue closest to the bottom entry of the diagonal\n  if(numext::norm1(eival1-t.coeff(1,1)) < numext::norm1(eival2-t.coeff(1,1)))\n    return normt * eival1;\n  else\n    return normt * eival2;\n}\n\n\ntemplate<typename MatrixType>\ntemplate<typename InputType>\nComplexSchur<MatrixType>& ComplexSchur<MatrixType>::compute(const EigenBase<InputType>& matrix, bool computeU)\n{\n  m_matUisUptodate = false;\n  eigen_assert(matrix.cols() == matrix.rows());\n\n  if(matrix.cols() == 1)\n  {\n    m_matT = matrix.derived().template cast<ComplexScalar>();\n    if(computeU)  m_matU = ComplexMatrixType::Identity(1,1);\n    m_info = Success;\n    m_isInitialized = true;\n    m_matUisUptodate = computeU;\n    return *this;\n  }\n\n  internal::complex_schur_reduce_to_hessenberg<MatrixType, NumTraits<Scalar>::IsComplex>::run(*this, matrix.derived(), computeU);\n  computeFromHessenberg(m_matT, m_matU, computeU);\n  return *this;\n}\n\ntemplate<typename MatrixType>\ntemplate<typename HessMatrixType, typename OrthMatrixType>\nComplexSchur<MatrixType>& ComplexSchur<MatrixType>::computeFromHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ, bool computeU)\n{\n  m_matT = matrixH;\n  if(computeU)\n    m_matU = matrixQ;\n  reduceToTriangularForm(computeU);\n  return *this;\n}\nnamespace internal {\n\n/* Reduce given matrix to Hessenberg form */\ntemplate<typename MatrixType, bool IsComplex>\nstruct complex_schur_reduce_to_hessenberg\n{\n  // this is the implementation for the case IsComplex = true\n  static void run(ComplexSchur<MatrixType>& _this, const MatrixType& matrix, bool computeU)\n  {\n    _this.m_hess.compute(matrix);\n    _this.m_matT = _this.m_hess.matrixH();\n    if(computeU)  _this.m_matU = _this.m_hess.matrixQ();\n  }\n};\n\ntemplate<typename MatrixType>\nstruct complex_schur_reduce_to_hessenberg<MatrixType, false>\n{\n  static void run(ComplexSchur<MatrixType>& _this, const MatrixType& matrix, bool computeU)\n  {\n    typedef typename ComplexSchur<MatrixType>::ComplexScalar ComplexScalar;\n\n    // Note: m_hess is over RealScalar; m_matT and m_matU is over ComplexScalar\n    _this.m_hess.compute(matrix);\n    _this.m_matT = _this.m_hess.matrixH().template cast<ComplexScalar>();\n    if(computeU)  \n    {\n      // This may cause an allocation which seems to be avoidable\n      MatrixType Q = _this.m_hess.matrixQ(); \n      _this.m_matU = Q.template cast<ComplexScalar>();\n    }\n  }\n};\n\n} // end namespace internal\n\n// Reduce the Hessenberg matrix m_matT to triangular form by QR iteration.\ntemplate<typename MatrixType>\nvoid ComplexSchur<MatrixType>::reduceToTriangularForm(bool computeU)\n{  \n  Index maxIters = m_maxIters;\n  if (maxIters == -1)\n    maxIters = m_maxIterationsPerRow * m_matT.rows();\n\n  // The matrix m_matT is divided in three parts. \n  // Rows 0,...,il-1 are decoupled from the rest because m_matT(il,il-1) is zero. \n  // Rows il,...,iu is the part we are working on (the active submatrix).\n  // Rows iu+1,...,end are already brought in triangular form.\n  Index iu = m_matT.cols() - 1;\n  Index il;\n  Index iter = 0; // number of iterations we are working on the (iu,iu) element\n  Index totalIter = 0; // number of iterations for whole matrix\n\n  while(true)\n  {\n    // find iu, the bottom row of the active submatrix\n    while(iu > 0)\n    {\n      if(!subdiagonalEntryIsNeglegible(iu-1)) break;\n      iter = 0;\n      --iu;\n    }\n\n    // if iu is zero then we are done; the whole matrix is triangularized\n    if(iu==0) break;\n\n    // if we spent too many iterations, we give up\n    iter++;\n    totalIter++;\n    if(totalIter > maxIters) break;\n\n    // find il, the top row of the active submatrix\n    il = iu-1;\n    while(il > 0 && !subdiagonalEntryIsNeglegible(il-1))\n    {\n      --il;\n    }\n\n    /* perform the QR step using Givens rotations. The first rotation\n       creates a bulge; the (il+2,il) element becomes nonzero. This\n       bulge is chased down to the bottom of the active submatrix. */\n\n    ComplexScalar shift = computeShift(iu, iter);\n    JacobiRotation<ComplexScalar> rot;\n    rot.makeGivens(m_matT.coeff(il,il) - shift, m_matT.coeff(il+1,il));\n    m_matT.rightCols(m_matT.cols()-il).applyOnTheLeft(il, il+1, rot.adjoint());\n    m_matT.topRows((std::min)(il+2,iu)+1).applyOnTheRight(il, il+1, rot);\n    if(computeU) m_matU.applyOnTheRight(il, il+1, rot);\n\n    for(Index i=il+1 ; i<iu ; i++)\n    {\n      rot.makeGivens(m_matT.coeffRef(i,i-1), m_matT.coeffRef(i+1,i-1), &m_matT.coeffRef(i,i-1));\n      m_matT.coeffRef(i+1,i-1) = ComplexScalar(0);\n      m_matT.rightCols(m_matT.cols()-i).applyOnTheLeft(i, i+1, rot.adjoint());\n      m_matT.topRows((std::min)(i+2,iu)+1).applyOnTheRight(i, i+1, rot);\n      if(computeU) m_matU.applyOnTheRight(i, i+1, rot);\n    }\n  }\n\n  if(totalIter <= maxIters)\n    m_info = Success;\n  else\n    m_info = NoConvergence;\n\n  m_isInitialized = true;\n  m_matUisUptodate = computeU;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_COMPLEX_SCHUR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to LAPACKe\n *    Complex Schur needed to complex unsymmetrical eigenvalues/eigenvectors.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_COMPLEX_SCHUR_LAPACKE_H\n#define EIGEN_COMPLEX_SCHUR_LAPACKE_H\n\nnamespace Eigen { \n\n/** \\internal Specialization for the data types supported by LAPACKe */\n\n#define EIGEN_LAPACKE_SCHUR_COMPLEX(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX, LAPACKE_PREFIX_U, EIGCOLROW, LAPACKE_COLROW) \\\ntemplate<> template<typename InputType> inline \\\nComplexSchur<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >& \\\nComplexSchur<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >::compute(const EigenBase<InputType>& matrix, bool computeU) \\\n{ \\\n  typedef Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> MatrixType; \\\n  typedef MatrixType::RealScalar RealScalar; \\\n  typedef std::complex<RealScalar> ComplexScalar; \\\n\\\n  eigen_assert(matrix.cols() == matrix.rows()); \\\n\\\n  m_matUisUptodate = false; \\\n  if(matrix.cols() == 1) \\\n  { \\\n    m_matT = matrix.derived().template cast<ComplexScalar>(); \\\n    if(computeU)  m_matU = ComplexMatrixType::Identity(1,1); \\\n      m_info = Success; \\\n      m_isInitialized = true; \\\n      m_matUisUptodate = computeU; \\\n      return *this; \\\n  } \\\n  lapack_int n = internal::convert_index<lapack_int>(matrix.cols()), sdim, info; \\\n  lapack_int matrix_order = LAPACKE_COLROW; \\\n  char jobvs, sort='N'; \\\n  LAPACK_##LAPACKE_PREFIX_U##_SELECT1 select = 0; \\\n  jobvs = (computeU) ? 'V' : 'N'; \\\n  m_matU.resize(n, n); \\\n  lapack_int ldvs  = internal::convert_index<lapack_int>(m_matU.outerStride()); \\\n  m_matT = matrix; \\\n  lapack_int lda = internal::convert_index<lapack_int>(m_matT.outerStride()); \\\n  Matrix<EIGTYPE, Dynamic, Dynamic> w; \\\n  w.resize(n, 1);\\\n  info = LAPACKE_##LAPACKE_PREFIX##gees( matrix_order, jobvs, sort, select, n, (LAPACKE_TYPE*)m_matT.data(), lda, &sdim, (LAPACKE_TYPE*)w.data(), (LAPACKE_TYPE*)m_matU.data(), ldvs ); \\\n  if(info == 0) \\\n    m_info = Success; \\\n  else \\\n    m_info = NoConvergence; \\\n\\\n  m_isInitialized = true; \\\n  m_matUisUptodate = computeU; \\\n  return *this; \\\n\\\n}\n\nEIGEN_LAPACKE_SCHUR_COMPLEX(dcomplex, lapack_complex_double, z, Z, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_SCHUR_COMPLEX(scomplex, lapack_complex_float,  c, C, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_SCHUR_COMPLEX(dcomplex, lapack_complex_double, z, Z, RowMajor, LAPACK_ROW_MAJOR)\nEIGEN_LAPACKE_SCHUR_COMPLEX(scomplex, lapack_complex_float,  c, C, RowMajor, LAPACK_ROW_MAJOR)\n\n} // end namespace Eigen\n\n#endif // EIGEN_COMPLEX_SCHUR_LAPACKE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/EigenSolver.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010,2012 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_EIGENSOLVER_H\n#define EIGEN_EIGENSOLVER_H\n\n#include \"./RealSchur.h\"\n\nnamespace Eigen { \n\n/** \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  *\n  * \\class EigenSolver\n  *\n  * \\brief Computes eigenvalues and eigenvectors of general matrices\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the\n  * eigendecomposition; this is expected to be an instantiation of the Matrix\n  * class template. Currently, only real matrices are supported.\n  *\n  * The eigenvalues and eigenvectors of a matrix \\f$ A \\f$ are scalars\n  * \\f$ \\lambda \\f$ and vectors \\f$ v \\f$ such that \\f$ Av = \\lambda v \\f$.  If\n  * \\f$ D \\f$ is a diagonal matrix with the eigenvalues on the diagonal, and\n  * \\f$ V \\f$ is a matrix with the eigenvectors as its columns, then \\f$ A V =\n  * V D \\f$. The matrix \\f$ V \\f$ is almost always invertible, in which case we\n  * have \\f$ A = V D V^{-1} \\f$. This is called the eigendecomposition.\n  *\n  * The eigenvalues and eigenvectors of a matrix may be complex, even when the\n  * matrix is real. However, we can choose real matrices \\f$ V \\f$ and \\f$ D\n  * \\f$ satisfying \\f$ A V = V D \\f$, just like the eigendecomposition, if the\n  * matrix \\f$ D \\f$ is not required to be diagonal, but if it is allowed to\n  * have blocks of the form\n  * \\f[ \\begin{bmatrix} u & v \\\\ -v & u \\end{bmatrix} \\f]\n  * (where \\f$ u \\f$ and \\f$ v \\f$ are real numbers) on the diagonal.  These\n  * blocks correspond to complex eigenvalue pairs \\f$ u \\pm iv \\f$. We call\n  * this variant of the eigendecomposition the pseudo-eigendecomposition.\n  *\n  * Call the function compute() to compute the eigenvalues and eigenvectors of\n  * a given matrix. Alternatively, you can use the \n  * EigenSolver(const MatrixType&, bool) constructor which computes the\n  * eigenvalues and eigenvectors at construction time. Once the eigenvalue and\n  * eigenvectors are computed, they can be retrieved with the eigenvalues() and\n  * eigenvectors() functions. The pseudoEigenvalueMatrix() and\n  * pseudoEigenvectors() methods allow the construction of the\n  * pseudo-eigendecomposition.\n  *\n  * The documentation for EigenSolver(const MatrixType&, bool) contains an\n  * example of the typical use of this class.\n  *\n  * \\note The implementation is adapted from\n  * <a href=\"http://math.nist.gov/javanumerics/jama/\">JAMA</a> (public domain).\n  * Their code is based on EISPACK.\n  *\n  * \\sa MatrixBase::eigenvalues(), class ComplexEigenSolver, class SelfAdjointEigenSolver\n  */\ntemplate<typename _MatrixType> class EigenSolver\n{\n  public:\n\n    /** \\brief Synonym for the template parameter \\p _MatrixType. */\n    typedef _MatrixType MatrixType;\n\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      Options = MatrixType::Options,\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n\n    /** \\brief Scalar type for matrices of type #MatrixType. */\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n\n    /** \\brief Complex scalar type for #MatrixType. \n      *\n      * This is \\c std::complex<Scalar> if #Scalar is real (e.g.,\n      * \\c float or \\c double) and just \\c Scalar if #Scalar is\n      * complex.\n      */\n    typedef std::complex<RealScalar> ComplexScalar;\n\n    /** \\brief Type for vector of eigenvalues as returned by eigenvalues(). \n      *\n      * This is a column vector with entries of type #ComplexScalar.\n      * The length of the vector is the size of #MatrixType.\n      */\n    typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> EigenvalueType;\n\n    /** \\brief Type for matrix of eigenvectors as returned by eigenvectors(). \n      *\n      * This is a square matrix with entries of type #ComplexScalar. \n      * The size is the same as the size of #MatrixType.\n      */\n    typedef Matrix<ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime> EigenvectorsType;\n\n    /** \\brief Default constructor.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via EigenSolver::compute(const MatrixType&, bool).\n      *\n      * \\sa compute() for an example.\n      */\n    EigenSolver() : m_eivec(), m_eivalues(), m_isInitialized(false), m_realSchur(), m_matT(), m_tmp() {}\n\n    /** \\brief Default constructor with memory preallocation\n      *\n      * Like the default constructor but with preallocation of the internal data\n      * according to the specified problem \\a size.\n      * \\sa EigenSolver()\n      */\n    explicit EigenSolver(Index size)\n      : m_eivec(size, size),\n        m_eivalues(size),\n        m_isInitialized(false),\n        m_eigenvectorsOk(false),\n        m_realSchur(size),\n        m_matT(size, size), \n        m_tmp(size)\n    {}\n\n    /** \\brief Constructor; computes eigendecomposition of given matrix. \n      * \n      * \\param[in]  matrix  Square matrix whose eigendecomposition is to be computed.\n      * \\param[in]  computeEigenvectors  If true, both the eigenvectors and the\n      *    eigenvalues are computed; if false, only the eigenvalues are\n      *    computed. \n      *\n      * This constructor calls compute() to compute the eigenvalues\n      * and eigenvectors.\n      *\n      * Example: \\include EigenSolver_EigenSolver_MatrixType.cpp\n      * Output: \\verbinclude EigenSolver_EigenSolver_MatrixType.out\n      *\n      * \\sa compute()\n      */\n    template<typename InputType>\n    explicit EigenSolver(const EigenBase<InputType>& matrix, bool computeEigenvectors = true)\n      : m_eivec(matrix.rows(), matrix.cols()),\n        m_eivalues(matrix.cols()),\n        m_isInitialized(false),\n        m_eigenvectorsOk(false),\n        m_realSchur(matrix.cols()),\n        m_matT(matrix.rows(), matrix.cols()), \n        m_tmp(matrix.cols())\n    {\n      compute(matrix.derived(), computeEigenvectors);\n    }\n\n    /** \\brief Returns the eigenvectors of given matrix. \n      *\n      * \\returns  %Matrix whose columns are the (possibly complex) eigenvectors.\n      *\n      * \\pre Either the constructor \n      * EigenSolver(const MatrixType&,bool) or the member function\n      * compute(const MatrixType&, bool) has been called before, and\n      * \\p computeEigenvectors was set to true (the default).\n      *\n      * Column \\f$ k \\f$ of the returned matrix is an eigenvector corresponding\n      * to eigenvalue number \\f$ k \\f$ as returned by eigenvalues().  The\n      * eigenvectors are normalized to have (Euclidean) norm equal to one. The\n      * matrix returned by this function is the matrix \\f$ V \\f$ in the\n      * eigendecomposition \\f$ A = V D V^{-1} \\f$, if it exists.\n      *\n      * Example: \\include EigenSolver_eigenvectors.cpp\n      * Output: \\verbinclude EigenSolver_eigenvectors.out\n      *\n      * \\sa eigenvalues(), pseudoEigenvectors()\n      */\n    EigenvectorsType eigenvectors() const;\n\n    /** \\brief Returns the pseudo-eigenvectors of given matrix. \n      *\n      * \\returns  Const reference to matrix whose columns are the pseudo-eigenvectors.\n      *\n      * \\pre Either the constructor \n      * EigenSolver(const MatrixType&,bool) or the member function\n      * compute(const MatrixType&, bool) has been called before, and\n      * \\p computeEigenvectors was set to true (the default).\n      *\n      * The real matrix \\f$ V \\f$ returned by this function and the\n      * block-diagonal matrix \\f$ D \\f$ returned by pseudoEigenvalueMatrix()\n      * satisfy \\f$ AV = VD \\f$.\n      *\n      * Example: \\include EigenSolver_pseudoEigenvectors.cpp\n      * Output: \\verbinclude EigenSolver_pseudoEigenvectors.out\n      *\n      * \\sa pseudoEigenvalueMatrix(), eigenvectors()\n      */\n    const MatrixType& pseudoEigenvectors() const\n    {\n      eigen_assert(m_isInitialized && \"EigenSolver is not initialized.\");\n      eigen_assert(m_eigenvectorsOk && \"The eigenvectors have not been computed together with the eigenvalues.\");\n      return m_eivec;\n    }\n\n    /** \\brief Returns the block-diagonal matrix in the pseudo-eigendecomposition.\n      *\n      * \\returns  A block-diagonal matrix.\n      *\n      * \\pre Either the constructor \n      * EigenSolver(const MatrixType&,bool) or the member function\n      * compute(const MatrixType&, bool) has been called before.\n      *\n      * The matrix \\f$ D \\f$ returned by this function is real and\n      * block-diagonal. The blocks on the diagonal are either 1-by-1 or 2-by-2\n      * blocks of the form\n      * \\f$ \\begin{bmatrix} u & v \\\\ -v & u \\end{bmatrix} \\f$.\n      * These blocks are not sorted in any particular order.\n      * The matrix \\f$ D \\f$ and the matrix \\f$ V \\f$ returned by\n      * pseudoEigenvectors() satisfy \\f$ AV = VD \\f$.\n      *\n      * \\sa pseudoEigenvectors() for an example, eigenvalues()\n      */\n    MatrixType pseudoEigenvalueMatrix() const;\n\n    /** \\brief Returns the eigenvalues of given matrix. \n      *\n      * \\returns A const reference to the column vector containing the eigenvalues.\n      *\n      * \\pre Either the constructor \n      * EigenSolver(const MatrixType&,bool) or the member function\n      * compute(const MatrixType&, bool) has been called before.\n      *\n      * The eigenvalues are repeated according to their algebraic multiplicity,\n      * so there are as many eigenvalues as rows in the matrix. The eigenvalues \n      * are not sorted in any particular order.\n      *\n      * Example: \\include EigenSolver_eigenvalues.cpp\n      * Output: \\verbinclude EigenSolver_eigenvalues.out\n      *\n      * \\sa eigenvectors(), pseudoEigenvalueMatrix(),\n      *     MatrixBase::eigenvalues()\n      */\n    const EigenvalueType& eigenvalues() const\n    {\n      eigen_assert(m_isInitialized && \"EigenSolver is not initialized.\");\n      return m_eivalues;\n    }\n\n    /** \\brief Computes eigendecomposition of given matrix. \n      * \n      * \\param[in]  matrix  Square matrix whose eigendecomposition is to be computed.\n      * \\param[in]  computeEigenvectors  If true, both the eigenvectors and the\n      *    eigenvalues are computed; if false, only the eigenvalues are\n      *    computed. \n      * \\returns    Reference to \\c *this\n      *\n      * This function computes the eigenvalues of the real matrix \\p matrix.\n      * The eigenvalues() function can be used to retrieve them.  If \n      * \\p computeEigenvectors is true, then the eigenvectors are also computed\n      * and can be retrieved by calling eigenvectors().\n      *\n      * The matrix is first reduced to real Schur form using the RealSchur\n      * class. The Schur decomposition is then used to compute the eigenvalues\n      * and eigenvectors.\n      *\n      * The cost of the computation is dominated by the cost of the\n      * Schur decomposition, which is very approximately \\f$ 25n^3 \\f$\n      * (where \\f$ n \\f$ is the size of the matrix) if \\p computeEigenvectors \n      * is true, and \\f$ 10n^3 \\f$ if \\p computeEigenvectors is false.\n      *\n      * This method reuses of the allocated data in the EigenSolver object.\n      *\n      * Example: \\include EigenSolver_compute.cpp\n      * Output: \\verbinclude EigenSolver_compute.out\n      */\n    template<typename InputType>\n    EigenSolver& compute(const EigenBase<InputType>& matrix, bool computeEigenvectors = true);\n\n    /** \\returns NumericalIssue if the input contains INF or NaN values or overflow occured. Returns Success otherwise. */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"EigenSolver is not initialized.\");\n      return m_info;\n    }\n\n    /** \\brief Sets the maximum number of iterations allowed. */\n    EigenSolver& setMaxIterations(Index maxIters)\n    {\n      m_realSchur.setMaxIterations(maxIters);\n      return *this;\n    }\n\n    /** \\brief Returns the maximum number of iterations. */\n    Index getMaxIterations()\n    {\n      return m_realSchur.getMaxIterations();\n    }\n\n  private:\n    void doComputeEigenvectors();\n\n  protected:\n    \n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n      EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsComplex, NUMERIC_TYPE_MUST_BE_REAL);\n    }\n    \n    MatrixType m_eivec;\n    EigenvalueType m_eivalues;\n    bool m_isInitialized;\n    bool m_eigenvectorsOk;\n    ComputationInfo m_info;\n    RealSchur<MatrixType> m_realSchur;\n    MatrixType m_matT;\n\n    typedef Matrix<Scalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> ColumnVectorType;\n    ColumnVectorType m_tmp;\n};\n\ntemplate<typename MatrixType>\nMatrixType EigenSolver<MatrixType>::pseudoEigenvalueMatrix() const\n{\n  eigen_assert(m_isInitialized && \"EigenSolver is not initialized.\");\n  const RealScalar precision = RealScalar(2)*NumTraits<RealScalar>::epsilon();\n  Index n = m_eivalues.rows();\n  MatrixType matD = MatrixType::Zero(n,n);\n  for (Index i=0; i<n; ++i)\n  {\n    if (internal::isMuchSmallerThan(numext::imag(m_eivalues.coeff(i)), numext::real(m_eivalues.coeff(i)), precision))\n      matD.coeffRef(i,i) = numext::real(m_eivalues.coeff(i));\n    else\n    {\n      matD.template block<2,2>(i,i) <<  numext::real(m_eivalues.coeff(i)), numext::imag(m_eivalues.coeff(i)),\n                                       -numext::imag(m_eivalues.coeff(i)), numext::real(m_eivalues.coeff(i));\n      ++i;\n    }\n  }\n  return matD;\n}\n\ntemplate<typename MatrixType>\ntypename EigenSolver<MatrixType>::EigenvectorsType EigenSolver<MatrixType>::eigenvectors() const\n{\n  eigen_assert(m_isInitialized && \"EigenSolver is not initialized.\");\n  eigen_assert(m_eigenvectorsOk && \"The eigenvectors have not been computed together with the eigenvalues.\");\n  const RealScalar precision = RealScalar(2)*NumTraits<RealScalar>::epsilon();\n  Index n = m_eivec.cols();\n  EigenvectorsType matV(n,n);\n  for (Index j=0; j<n; ++j)\n  {\n    if (internal::isMuchSmallerThan(numext::imag(m_eivalues.coeff(j)), numext::real(m_eivalues.coeff(j)), precision) || j+1==n)\n    {\n      // we have a real eigen value\n      matV.col(j) = m_eivec.col(j).template cast<ComplexScalar>();\n      matV.col(j).normalize();\n    }\n    else\n    {\n      // we have a pair of complex eigen values\n      for (Index i=0; i<n; ++i)\n      {\n        matV.coeffRef(i,j)   = ComplexScalar(m_eivec.coeff(i,j),  m_eivec.coeff(i,j+1));\n        matV.coeffRef(i,j+1) = ComplexScalar(m_eivec.coeff(i,j), -m_eivec.coeff(i,j+1));\n      }\n      matV.col(j).normalize();\n      matV.col(j+1).normalize();\n      ++j;\n    }\n  }\n  return matV;\n}\n\ntemplate<typename MatrixType>\ntemplate<typename InputType>\nEigenSolver<MatrixType>& \nEigenSolver<MatrixType>::compute(const EigenBase<InputType>& matrix, bool computeEigenvectors)\n{\n  check_template_parameters();\n  \n  using std::sqrt;\n  using std::abs;\n  using numext::isfinite;\n  eigen_assert(matrix.cols() == matrix.rows());\n\n  // Reduce to real Schur form.\n  m_realSchur.compute(matrix.derived(), computeEigenvectors);\n  \n  m_info = m_realSchur.info();\n\n  if (m_info == Success)\n  {\n    m_matT = m_realSchur.matrixT();\n    if (computeEigenvectors)\n      m_eivec = m_realSchur.matrixU();\n  \n    // Compute eigenvalues from matT\n    m_eivalues.resize(matrix.cols());\n    Index i = 0;\n    while (i < matrix.cols()) \n    {\n      if (i == matrix.cols() - 1 || m_matT.coeff(i+1, i) == Scalar(0)) \n      {\n        m_eivalues.coeffRef(i) = m_matT.coeff(i, i);\n        if(!(isfinite)(m_eivalues.coeffRef(i)))\n        {\n          m_isInitialized = true;\n          m_eigenvectorsOk = false;\n          m_info = NumericalIssue;\n          return *this;\n        }\n        ++i;\n      }\n      else\n      {\n        Scalar p = Scalar(0.5) * (m_matT.coeff(i, i) - m_matT.coeff(i+1, i+1));\n        Scalar z;\n        // Compute z = sqrt(abs(p * p + m_matT.coeff(i+1, i) * m_matT.coeff(i, i+1)));\n        // without overflow\n        {\n          Scalar t0 = m_matT.coeff(i+1, i);\n          Scalar t1 = m_matT.coeff(i, i+1);\n          Scalar maxval = numext::maxi<Scalar>(abs(p),numext::maxi<Scalar>(abs(t0),abs(t1)));\n          t0 /= maxval;\n          t1 /= maxval;\n          Scalar p0 = p/maxval;\n          z = maxval * sqrt(abs(p0 * p0 + t0 * t1));\n        }\n        \n        m_eivalues.coeffRef(i)   = ComplexScalar(m_matT.coeff(i+1, i+1) + p, z);\n        m_eivalues.coeffRef(i+1) = ComplexScalar(m_matT.coeff(i+1, i+1) + p, -z);\n        if(!((isfinite)(m_eivalues.coeffRef(i)) && (isfinite)(m_eivalues.coeffRef(i+1))))\n        {\n          m_isInitialized = true;\n          m_eigenvectorsOk = false;\n          m_info = NumericalIssue;\n          return *this;\n        }\n        i += 2;\n      }\n    }\n    \n    // Compute eigenvectors.\n    if (computeEigenvectors)\n      doComputeEigenvectors();\n  }\n\n  m_isInitialized = true;\n  m_eigenvectorsOk = computeEigenvectors;\n\n  return *this;\n}\n\n\ntemplate<typename MatrixType>\nvoid EigenSolver<MatrixType>::doComputeEigenvectors()\n{\n  using std::abs;\n  const Index size = m_eivec.cols();\n  const Scalar eps = NumTraits<Scalar>::epsilon();\n\n  // inefficient! this is already computed in RealSchur\n  Scalar norm(0);\n  for (Index j = 0; j < size; ++j)\n  {\n    norm += m_matT.row(j).segment((std::max)(j-1,Index(0)), size-(std::max)(j-1,Index(0))).cwiseAbs().sum();\n  }\n  \n  // Backsubstitute to find vectors of upper triangular form\n  if (norm == Scalar(0))\n  {\n    return;\n  }\n\n  for (Index n = size-1; n >= 0; n--)\n  {\n    Scalar p = m_eivalues.coeff(n).real();\n    Scalar q = m_eivalues.coeff(n).imag();\n\n    // Scalar vector\n    if (q == Scalar(0))\n    {\n      Scalar lastr(0), lastw(0);\n      Index l = n;\n\n      m_matT.coeffRef(n,n) = Scalar(1);\n      for (Index i = n-1; i >= 0; i--)\n      {\n        Scalar w = m_matT.coeff(i,i) - p;\n        Scalar r = m_matT.row(i).segment(l,n-l+1).dot(m_matT.col(n).segment(l, n-l+1));\n\n        if (m_eivalues.coeff(i).imag() < Scalar(0))\n        {\n          lastw = w;\n          lastr = r;\n        }\n        else\n        {\n          l = i;\n          if (m_eivalues.coeff(i).imag() == Scalar(0))\n          {\n            if (w != Scalar(0))\n              m_matT.coeffRef(i,n) = -r / w;\n            else\n              m_matT.coeffRef(i,n) = -r / (eps * norm);\n          }\n          else // Solve real equations\n          {\n            Scalar x = m_matT.coeff(i,i+1);\n            Scalar y = m_matT.coeff(i+1,i);\n            Scalar denom = (m_eivalues.coeff(i).real() - p) * (m_eivalues.coeff(i).real() - p) + m_eivalues.coeff(i).imag() * m_eivalues.coeff(i).imag();\n            Scalar t = (x * lastr - lastw * r) / denom;\n            m_matT.coeffRef(i,n) = t;\n            if (abs(x) > abs(lastw))\n              m_matT.coeffRef(i+1,n) = (-r - w * t) / x;\n            else\n              m_matT.coeffRef(i+1,n) = (-lastr - y * t) / lastw;\n          }\n\n          // Overflow control\n          Scalar t = abs(m_matT.coeff(i,n));\n          if ((eps * t) * t > Scalar(1))\n            m_matT.col(n).tail(size-i) /= t;\n        }\n      }\n    }\n    else if (q < Scalar(0) && n > 0) // Complex vector\n    {\n      Scalar lastra(0), lastsa(0), lastw(0);\n      Index l = n-1;\n\n      // Last vector component imaginary so matrix is triangular\n      if (abs(m_matT.coeff(n,n-1)) > abs(m_matT.coeff(n-1,n)))\n      {\n        m_matT.coeffRef(n-1,n-1) = q / m_matT.coeff(n,n-1);\n        m_matT.coeffRef(n-1,n) = -(m_matT.coeff(n,n) - p) / m_matT.coeff(n,n-1);\n      }\n      else\n      {\n        ComplexScalar cc = ComplexScalar(Scalar(0),-m_matT.coeff(n-1,n)) / ComplexScalar(m_matT.coeff(n-1,n-1)-p,q);\n        m_matT.coeffRef(n-1,n-1) = numext::real(cc);\n        m_matT.coeffRef(n-1,n) = numext::imag(cc);\n      }\n      m_matT.coeffRef(n,n-1) = Scalar(0);\n      m_matT.coeffRef(n,n) = Scalar(1);\n      for (Index i = n-2; i >= 0; i--)\n      {\n        Scalar ra = m_matT.row(i).segment(l, n-l+1).dot(m_matT.col(n-1).segment(l, n-l+1));\n        Scalar sa = m_matT.row(i).segment(l, n-l+1).dot(m_matT.col(n).segment(l, n-l+1));\n        Scalar w = m_matT.coeff(i,i) - p;\n\n        if (m_eivalues.coeff(i).imag() < Scalar(0))\n        {\n          lastw = w;\n          lastra = ra;\n          lastsa = sa;\n        }\n        else\n        {\n          l = i;\n          if (m_eivalues.coeff(i).imag() == RealScalar(0))\n          {\n            ComplexScalar cc = ComplexScalar(-ra,-sa) / ComplexScalar(w,q);\n            m_matT.coeffRef(i,n-1) = numext::real(cc);\n            m_matT.coeffRef(i,n) = numext::imag(cc);\n          }\n          else\n          {\n            // Solve complex equations\n            Scalar x = m_matT.coeff(i,i+1);\n            Scalar y = m_matT.coeff(i+1,i);\n            Scalar vr = (m_eivalues.coeff(i).real() - p) * (m_eivalues.coeff(i).real() - p) + m_eivalues.coeff(i).imag() * m_eivalues.coeff(i).imag() - q * q;\n            Scalar vi = (m_eivalues.coeff(i).real() - p) * Scalar(2) * q;\n            if ((vr == Scalar(0)) && (vi == Scalar(0)))\n              vr = eps * norm * (abs(w) + abs(q) + abs(x) + abs(y) + abs(lastw));\n\n            ComplexScalar cc = ComplexScalar(x*lastra-lastw*ra+q*sa,x*lastsa-lastw*sa-q*ra) / ComplexScalar(vr,vi);\n            m_matT.coeffRef(i,n-1) = numext::real(cc);\n            m_matT.coeffRef(i,n) = numext::imag(cc);\n            if (abs(x) > (abs(lastw) + abs(q)))\n            {\n              m_matT.coeffRef(i+1,n-1) = (-ra - w * m_matT.coeff(i,n-1) + q * m_matT.coeff(i,n)) / x;\n              m_matT.coeffRef(i+1,n) = (-sa - w * m_matT.coeff(i,n) - q * m_matT.coeff(i,n-1)) / x;\n            }\n            else\n            {\n              cc = ComplexScalar(-lastra-y*m_matT.coeff(i,n-1),-lastsa-y*m_matT.coeff(i,n)) / ComplexScalar(lastw,q);\n              m_matT.coeffRef(i+1,n-1) = numext::real(cc);\n              m_matT.coeffRef(i+1,n) = numext::imag(cc);\n            }\n          }\n\n          // Overflow control\n          Scalar t = numext::maxi<Scalar>(abs(m_matT.coeff(i,n-1)),abs(m_matT.coeff(i,n)));\n          if ((eps * t) * t > Scalar(1))\n            m_matT.block(i, n-1, size-i, 2) /= t;\n\n        }\n      }\n      \n      // We handled a pair of complex conjugate eigenvalues, so need to skip them both\n      n--;\n    }\n    else\n    {\n      eigen_assert(0 && \"Internal bug in EigenSolver (INF or NaN has not been detected)\"); // this should not happen\n    }\n  }\n\n  // Back transformation to get eigenvectors of original matrix\n  for (Index j = size-1; j >= 0; j--)\n  {\n    m_tmp.noalias() = m_eivec.leftCols(j+1) * m_matT.col(j).segment(0, j+1);\n    m_eivec.col(j) = m_tmp;\n  }\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_EIGENSOLVER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012-2016 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010,2012 Jitse Niesen <jitse@maths.leeds.ac.uk>\n// Copyright (C) 2016 Tobias Wood <tobias@spinicist.org.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_GENERALIZEDEIGENSOLVER_H\n#define EIGEN_GENERALIZEDEIGENSOLVER_H\n\n#include \"./RealQZ.h\"\n\nnamespace Eigen { \n\n/** \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  *\n  * \\class GeneralizedEigenSolver\n  *\n  * \\brief Computes the generalized eigenvalues and eigenvectors of a pair of general matrices\n  *\n  * \\tparam _MatrixType the type of the matrices of which we are computing the\n  * eigen-decomposition; this is expected to be an instantiation of the Matrix\n  * class template. Currently, only real matrices are supported.\n  *\n  * The generalized eigenvalues and eigenvectors of a matrix pair \\f$ A \\f$ and \\f$ B \\f$ are scalars\n  * \\f$ \\lambda \\f$ and vectors \\f$ v \\f$ such that \\f$ Av = \\lambda Bv \\f$.  If\n  * \\f$ D \\f$ is a diagonal matrix with the eigenvalues on the diagonal, and\n  * \\f$ V \\f$ is a matrix with the eigenvectors as its columns, then \\f$ A V =\n  * B V D \\f$. The matrix \\f$ V \\f$ is almost always invertible, in which case we\n  * have \\f$ A = B V D V^{-1} \\f$. This is called the generalized eigen-decomposition.\n  *\n  * The generalized eigenvalues and eigenvectors of a matrix pair may be complex, even when the\n  * matrices are real. Moreover, the generalized eigenvalue might be infinite if the matrix B is\n  * singular. To workaround this difficulty, the eigenvalues are provided as a pair of complex \\f$ \\alpha \\f$\n  * and real \\f$ \\beta \\f$ such that: \\f$ \\lambda_i = \\alpha_i / \\beta_i \\f$. If \\f$ \\beta_i \\f$ is (nearly) zero,\n  * then one can consider the well defined left eigenvalue \\f$ \\mu = \\beta_i / \\alpha_i\\f$ such that:\n  * \\f$ \\mu_i A v_i = B v_i \\f$, or even \\f$ \\mu_i u_i^T A  = u_i^T B \\f$ where \\f$ u_i \\f$ is\n  * called the left eigenvector.\n  *\n  * Call the function compute() to compute the generalized eigenvalues and eigenvectors of\n  * a given matrix pair. Alternatively, you can use the\n  * GeneralizedEigenSolver(const MatrixType&, const MatrixType&, bool) constructor which computes the\n  * eigenvalues and eigenvectors at construction time. Once the eigenvalue and\n  * eigenvectors are computed, they can be retrieved with the eigenvalues() and\n  * eigenvectors() functions.\n  *\n  * Here is an usage example of this class:\n  * Example: \\include GeneralizedEigenSolver.cpp\n  * Output: \\verbinclude GeneralizedEigenSolver.out\n  *\n  * \\sa MatrixBase::eigenvalues(), class ComplexEigenSolver, class SelfAdjointEigenSolver\n  */\ntemplate<typename _MatrixType> class GeneralizedEigenSolver\n{\n  public:\n\n    /** \\brief Synonym for the template parameter \\p _MatrixType. */\n    typedef _MatrixType MatrixType;\n\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      Options = MatrixType::Options,\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n\n    /** \\brief Scalar type for matrices of type #MatrixType. */\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n\n    /** \\brief Complex scalar type for #MatrixType. \n      *\n      * This is \\c std::complex<Scalar> if #Scalar is real (e.g.,\n      * \\c float or \\c double) and just \\c Scalar if #Scalar is\n      * complex.\n      */\n    typedef std::complex<RealScalar> ComplexScalar;\n\n    /** \\brief Type for vector of real scalar values eigenvalues as returned by betas().\n      *\n      * This is a column vector with entries of type #Scalar.\n      * The length of the vector is the size of #MatrixType.\n      */\n    typedef Matrix<Scalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> VectorType;\n\n    /** \\brief Type for vector of complex scalar values eigenvalues as returned by alphas().\n      *\n      * This is a column vector with entries of type #ComplexScalar.\n      * The length of the vector is the size of #MatrixType.\n      */\n    typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> ComplexVectorType;\n\n    /** \\brief Expression type for the eigenvalues as returned by eigenvalues().\n      */\n    typedef CwiseBinaryOp<internal::scalar_quotient_op<ComplexScalar,Scalar>,ComplexVectorType,VectorType> EigenvalueType;\n\n    /** \\brief Type for matrix of eigenvectors as returned by eigenvectors(). \n      *\n      * This is a square matrix with entries of type #ComplexScalar. \n      * The size is the same as the size of #MatrixType.\n      */\n    typedef Matrix<ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime> EigenvectorsType;\n\n    /** \\brief Default constructor.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via EigenSolver::compute(const MatrixType&, bool).\n      *\n      * \\sa compute() for an example.\n      */\n    GeneralizedEigenSolver()\n      : m_eivec(),\n        m_alphas(),\n        m_betas(),\n        m_valuesOkay(false),\n        m_vectorsOkay(false),\n        m_realQZ()\n    {}\n\n    /** \\brief Default constructor with memory preallocation\n      *\n      * Like the default constructor but with preallocation of the internal data\n      * according to the specified problem \\a size.\n      * \\sa GeneralizedEigenSolver()\n      */\n    explicit GeneralizedEigenSolver(Index size)\n      : m_eivec(size, size),\n        m_alphas(size),\n        m_betas(size),\n        m_valuesOkay(false),\n        m_vectorsOkay(false),\n        m_realQZ(size),\n        m_tmp(size)\n    {}\n\n    /** \\brief Constructor; computes the generalized eigendecomposition of given matrix pair.\n      * \n      * \\param[in]  A  Square matrix whose eigendecomposition is to be computed.\n      * \\param[in]  B  Square matrix whose eigendecomposition is to be computed.\n      * \\param[in]  computeEigenvectors  If true, both the eigenvectors and the\n      *    eigenvalues are computed; if false, only the eigenvalues are computed.\n      *\n      * This constructor calls compute() to compute the generalized eigenvalues\n      * and eigenvectors.\n      *\n      * \\sa compute()\n      */\n    GeneralizedEigenSolver(const MatrixType& A, const MatrixType& B, bool computeEigenvectors = true)\n      : m_eivec(A.rows(), A.cols()),\n        m_alphas(A.cols()),\n        m_betas(A.cols()),\n        m_valuesOkay(false),\n        m_vectorsOkay(false),\n        m_realQZ(A.cols()),\n        m_tmp(A.cols())\n    {\n      compute(A, B, computeEigenvectors);\n    }\n\n    /* \\brief Returns the computed generalized eigenvectors.\n      *\n      * \\returns  %Matrix whose columns are the (possibly complex) right eigenvectors.\n      * i.e. the eigenvectors that solve (A - l*B)x = 0. The ordering matches the eigenvalues.\n      *\n      * \\pre Either the constructor \n      * GeneralizedEigenSolver(const MatrixType&,const MatrixType&, bool) or the member function\n      * compute(const MatrixType&, const MatrixType& bool) has been called before, and\n      * \\p computeEigenvectors was set to true (the default).\n      *\n      * \\sa eigenvalues()\n      */\n    EigenvectorsType eigenvectors() const {\n      eigen_assert(m_vectorsOkay && \"Eigenvectors for GeneralizedEigenSolver were not calculated.\");\n      return m_eivec;\n    }\n\n    /** \\brief Returns an expression of the computed generalized eigenvalues.\n      *\n      * \\returns An expression of the column vector containing the eigenvalues.\n      *\n      * It is a shortcut for \\code this->alphas().cwiseQuotient(this->betas()); \\endcode\n      * Not that betas might contain zeros. It is therefore not recommended to use this function,\n      * but rather directly deal with the alphas and betas vectors.\n      *\n      * \\pre Either the constructor \n      * GeneralizedEigenSolver(const MatrixType&,const MatrixType&,bool) or the member function\n      * compute(const MatrixType&,const MatrixType&,bool) has been called before.\n      *\n      * The eigenvalues are repeated according to their algebraic multiplicity,\n      * so there are as many eigenvalues as rows in the matrix. The eigenvalues \n      * are not sorted in any particular order.\n      *\n      * \\sa alphas(), betas(), eigenvectors()\n      */\n    EigenvalueType eigenvalues() const\n    {\n      eigen_assert(m_valuesOkay && \"GeneralizedEigenSolver is not initialized.\");\n      return EigenvalueType(m_alphas,m_betas);\n    }\n\n    /** \\returns A const reference to the vectors containing the alpha values\n      *\n      * This vector permits to reconstruct the j-th eigenvalues as alphas(i)/betas(j).\n      *\n      * \\sa betas(), eigenvalues() */\n    ComplexVectorType alphas() const\n    {\n      eigen_assert(m_valuesOkay && \"GeneralizedEigenSolver is not initialized.\");\n      return m_alphas;\n    }\n\n    /** \\returns A const reference to the vectors containing the beta values\n      *\n      * This vector permits to reconstruct the j-th eigenvalues as alphas(i)/betas(j).\n      *\n      * \\sa alphas(), eigenvalues() */\n    VectorType betas() const\n    {\n      eigen_assert(m_valuesOkay && \"GeneralizedEigenSolver is not initialized.\");\n      return m_betas;\n    }\n\n    /** \\brief Computes generalized eigendecomposition of given matrix.\n      * \n      * \\param[in]  A  Square matrix whose eigendecomposition is to be computed.\n      * \\param[in]  B  Square matrix whose eigendecomposition is to be computed.\n      * \\param[in]  computeEigenvectors  If true, both the eigenvectors and the\n      *    eigenvalues are computed; if false, only the eigenvalues are\n      *    computed. \n      * \\returns    Reference to \\c *this\n      *\n      * This function computes the eigenvalues of the real matrix \\p matrix.\n      * The eigenvalues() function can be used to retrieve them.  If \n      * \\p computeEigenvectors is true, then the eigenvectors are also computed\n      * and can be retrieved by calling eigenvectors().\n      *\n      * The matrix is first reduced to real generalized Schur form using the RealQZ\n      * class. The generalized Schur decomposition is then used to compute the eigenvalues\n      * and eigenvectors.\n      *\n      * The cost of the computation is dominated by the cost of the\n      * generalized Schur decomposition.\n      *\n      * This method reuses of the allocated data in the GeneralizedEigenSolver object.\n      */\n    GeneralizedEigenSolver& compute(const MatrixType& A, const MatrixType& B, bool computeEigenvectors = true);\n\n    ComputationInfo info() const\n    {\n      eigen_assert(m_valuesOkay && \"EigenSolver is not initialized.\");\n      return m_realQZ.info();\n    }\n\n    /** Sets the maximal number of iterations allowed.\n    */\n    GeneralizedEigenSolver& setMaxIterations(Index maxIters)\n    {\n      m_realQZ.setMaxIterations(maxIters);\n      return *this;\n    }\n\n  protected:\n    \n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n      EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsComplex, NUMERIC_TYPE_MUST_BE_REAL);\n    }\n    \n    EigenvectorsType m_eivec;\n    ComplexVectorType m_alphas;\n    VectorType m_betas;\n    bool m_valuesOkay, m_vectorsOkay;\n    RealQZ<MatrixType> m_realQZ;\n    ComplexVectorType m_tmp;\n};\n\ntemplate<typename MatrixType>\nGeneralizedEigenSolver<MatrixType>&\nGeneralizedEigenSolver<MatrixType>::compute(const MatrixType& A, const MatrixType& B, bool computeEigenvectors)\n{\n  check_template_parameters();\n  \n  using std::sqrt;\n  using std::abs;\n  eigen_assert(A.cols() == A.rows() && B.cols() == A.rows() && B.cols() == B.rows());\n  Index size = A.cols();\n  m_valuesOkay = false;\n  m_vectorsOkay = false;\n  // Reduce to generalized real Schur form:\n  // A = Q S Z and B = Q T Z\n  m_realQZ.compute(A, B, computeEigenvectors);\n  if (m_realQZ.info() == Success)\n  {\n    // Resize storage\n    m_alphas.resize(size);\n    m_betas.resize(size);\n    if (computeEigenvectors)\n    {\n      m_eivec.resize(size,size);\n      m_tmp.resize(size);\n    }\n\n    // Aliases:\n    Map<VectorType> v(reinterpret_cast<Scalar*>(m_tmp.data()), size);\n    ComplexVectorType &cv = m_tmp;\n    const MatrixType &mZ = m_realQZ.matrixZ();\n    const MatrixType &mS = m_realQZ.matrixS();\n    const MatrixType &mT = m_realQZ.matrixT();\n\n    Index i = 0;\n    while (i < size)\n    {\n      if (i == size - 1 || mS.coeff(i+1, i) == Scalar(0))\n      {\n        // Real eigenvalue\n        m_alphas.coeffRef(i) = mS.diagonal().coeff(i);\n        m_betas.coeffRef(i)  = mT.diagonal().coeff(i);\n        if (computeEigenvectors)\n        {\n          v.setConstant(Scalar(0.0));\n          v.coeffRef(i) = Scalar(1.0);\n          // For singular eigenvalues do nothing more\n          if(abs(m_betas.coeffRef(i)) >= (std::numeric_limits<RealScalar>::min)())\n          {\n            // Non-singular eigenvalue\n            const Scalar alpha = real(m_alphas.coeffRef(i));\n            const Scalar beta = m_betas.coeffRef(i);\n            for (Index j = i-1; j >= 0; j--)\n            {\n              const Index st = j+1;\n              const Index sz = i-j;\n              if (j > 0 && mS.coeff(j, j-1) != Scalar(0))\n              {\n                // 2x2 block\n                Matrix<Scalar, 2, 1> rhs = (alpha*mT.template block<2,Dynamic>(j-1,st,2,sz) - beta*mS.template block<2,Dynamic>(j-1,st,2,sz)) .lazyProduct( v.segment(st,sz) );\n                Matrix<Scalar, 2, 2> lhs = beta * mS.template block<2,2>(j-1,j-1) - alpha * mT.template block<2,2>(j-1,j-1);\n                v.template segment<2>(j-1) = lhs.partialPivLu().solve(rhs);\n                j--;\n              }\n              else\n              {\n                v.coeffRef(j) = -v.segment(st,sz).transpose().cwiseProduct(beta*mS.block(j,st,1,sz) - alpha*mT.block(j,st,1,sz)).sum() / (beta*mS.coeffRef(j,j) - alpha*mT.coeffRef(j,j));\n              }\n            }\n          }\n          m_eivec.col(i).real().noalias() = mZ.transpose() * v;\n          m_eivec.col(i).real().normalize();\n          m_eivec.col(i).imag().setConstant(0);\n        }\n        ++i;\n      }\n      else\n      {\n        // We need to extract the generalized eigenvalues of the pair of a general 2x2 block S and a positive diagonal 2x2 block T\n        // Then taking beta=T_00*T_11, we can avoid any division, and alpha is the eigenvalues of A = (U^-1 * S * U) * diag(T_11,T_00):\n\n        // T =  [a 0]\n        //      [0 b]\n        RealScalar a = mT.diagonal().coeff(i),\n                   b = mT.diagonal().coeff(i+1);\n        const RealScalar beta = m_betas.coeffRef(i) = m_betas.coeffRef(i+1) = a*b;\n\n        // ^^ NOTE: using diagonal()(i) instead of coeff(i,i) workarounds a MSVC bug.\n        Matrix<RealScalar,2,2> S2 = mS.template block<2,2>(i,i) * Matrix<Scalar,2,1>(b,a).asDiagonal();\n\n        Scalar p = Scalar(0.5) * (S2.coeff(0,0) - S2.coeff(1,1));\n        Scalar z = sqrt(abs(p * p + S2.coeff(1,0) * S2.coeff(0,1)));\n        const ComplexScalar alpha = ComplexScalar(S2.coeff(1,1) + p, (beta > 0) ? z : -z);\n        m_alphas.coeffRef(i)   = conj(alpha);\n        m_alphas.coeffRef(i+1) = alpha;\n\n        if (computeEigenvectors) {\n          // Compute eigenvector in position (i+1) and then position (i) is just the conjugate\n          cv.setZero();\n          cv.coeffRef(i+1) = Scalar(1.0);\n          // here, the \"static_cast\" workaound expression template issues.\n          cv.coeffRef(i) = -(static_cast<Scalar>(beta*mS.coeffRef(i,i+1)) - alpha*mT.coeffRef(i,i+1))\n                          / (static_cast<Scalar>(beta*mS.coeffRef(i,i))   - alpha*mT.coeffRef(i,i));\n          for (Index j = i-1; j >= 0; j--)\n          {\n            const Index st = j+1;\n            const Index sz = i+1-j;\n            if (j > 0 && mS.coeff(j, j-1) != Scalar(0))\n            {\n              // 2x2 block\n              Matrix<ComplexScalar, 2, 1> rhs = (alpha*mT.template block<2,Dynamic>(j-1,st,2,sz) - beta*mS.template block<2,Dynamic>(j-1,st,2,sz)) .lazyProduct( cv.segment(st,sz) );\n              Matrix<ComplexScalar, 2, 2> lhs = beta * mS.template block<2,2>(j-1,j-1) - alpha * mT.template block<2,2>(j-1,j-1);\n              cv.template segment<2>(j-1) = lhs.partialPivLu().solve(rhs);\n              j--;\n            } else {\n              cv.coeffRef(j) =  cv.segment(st,sz).transpose().cwiseProduct(beta*mS.block(j,st,1,sz) - alpha*mT.block(j,st,1,sz)).sum()\n                              / (alpha*mT.coeffRef(j,j) - static_cast<Scalar>(beta*mS.coeffRef(j,j)));\n            }\n          }\n          m_eivec.col(i+1).noalias() = (mZ.transpose() * cv);\n          m_eivec.col(i+1).normalize();\n          m_eivec.col(i) = m_eivec.col(i+1).conjugate();\n        }\n        i += 2;\n      }\n    }\n\n    m_valuesOkay = true;\n    m_vectorsOkay = computeEigenvectors;\n  }\n  return *this;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_GENERALIZEDEIGENSOLVER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_GENERALIZEDSELFADJOINTEIGENSOLVER_H\n#define EIGEN_GENERALIZEDSELFADJOINTEIGENSOLVER_H\n\n#include \"./Tridiagonalization.h\"\n\nnamespace Eigen { \n\n/** \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  *\n  * \\class GeneralizedSelfAdjointEigenSolver\n  *\n  * \\brief Computes eigenvalues and eigenvectors of the generalized selfadjoint eigen problem\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the\n  * eigendecomposition; this is expected to be an instantiation of the Matrix\n  * class template.\n  *\n  * This class solves the generalized eigenvalue problem\n  * \\f$ Av = \\lambda Bv \\f$. In this case, the matrix \\f$ A \\f$ should be\n  * selfadjoint and the matrix \\f$ B \\f$ should be positive definite.\n  *\n  * Only the \\b lower \\b triangular \\b part of the input matrix is referenced.\n  *\n  * Call the function compute() to compute the eigenvalues and eigenvectors of\n  * a given matrix. Alternatively, you can use the\n  * GeneralizedSelfAdjointEigenSolver(const MatrixType&, const MatrixType&, int)\n  * constructor which computes the eigenvalues and eigenvectors at construction time.\n  * Once the eigenvalue and eigenvectors are computed, they can be retrieved with the eigenvalues()\n  * and eigenvectors() functions.\n  *\n  * The documentation for GeneralizedSelfAdjointEigenSolver(const MatrixType&, const MatrixType&, int)\n  * contains an example of the typical use of this class.\n  *\n  * \\sa class SelfAdjointEigenSolver, class EigenSolver, class ComplexEigenSolver\n  */\ntemplate<typename _MatrixType>\nclass GeneralizedSelfAdjointEigenSolver : public SelfAdjointEigenSolver<_MatrixType>\n{\n    typedef SelfAdjointEigenSolver<_MatrixType> Base;\n  public:\n\n    typedef _MatrixType MatrixType;\n\n    /** \\brief Default constructor for fixed-size matrices.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via compute(). This constructor\n      * can only be used if \\p _MatrixType is a fixed-size matrix; use\n      * GeneralizedSelfAdjointEigenSolver(Index) for dynamic-size matrices.\n      */\n    GeneralizedSelfAdjointEigenSolver() : Base() {}\n\n    /** \\brief Constructor, pre-allocates memory for dynamic-size matrices.\n      *\n      * \\param [in]  size  Positive integer, size of the matrix whose\n      * eigenvalues and eigenvectors will be computed.\n      *\n      * This constructor is useful for dynamic-size matrices, when the user\n      * intends to perform decompositions via compute(). The \\p size\n      * parameter is only used as a hint. It is not an error to give a wrong\n      * \\p size, but it may impair performance.\n      *\n      * \\sa compute() for an example\n      */\n    explicit GeneralizedSelfAdjointEigenSolver(Index size)\n        : Base(size)\n    {}\n\n    /** \\brief Constructor; computes generalized eigendecomposition of given matrix pencil.\n      *\n      * \\param[in]  matA  Selfadjoint matrix in matrix pencil.\n      *                   Only the lower triangular part of the matrix is referenced.\n      * \\param[in]  matB  Positive-definite matrix in matrix pencil.\n      *                   Only the lower triangular part of the matrix is referenced.\n      * \\param[in]  options A or-ed set of flags {#ComputeEigenvectors,#EigenvaluesOnly} | {#Ax_lBx,#ABx_lx,#BAx_lx}.\n      *                     Default is #ComputeEigenvectors|#Ax_lBx.\n      *\n      * This constructor calls compute(const MatrixType&, const MatrixType&, int)\n      * to compute the eigenvalues and (if requested) the eigenvectors of the\n      * generalized eigenproblem \\f$ Ax = \\lambda B x \\f$ with \\a matA the\n      * selfadjoint matrix \\f$ A \\f$ and \\a matB the positive definite matrix\n      * \\f$ B \\f$. Each eigenvector \\f$ x \\f$ satisfies the property\n      * \\f$ x^* B x = 1 \\f$. The eigenvectors are computed if\n      * \\a options contains ComputeEigenvectors.\n      *\n      * In addition, the two following variants can be solved via \\p options:\n      * - \\c ABx_lx: \\f$ ABx = \\lambda x \\f$\n      * - \\c BAx_lx: \\f$ BAx = \\lambda x \\f$\n      *\n      * Example: \\include SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType2.cpp\n      * Output: \\verbinclude SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType2.out\n      *\n      * \\sa compute(const MatrixType&, const MatrixType&, int)\n      */\n    GeneralizedSelfAdjointEigenSolver(const MatrixType& matA, const MatrixType& matB,\n                                      int options = ComputeEigenvectors|Ax_lBx)\n      : Base(matA.cols())\n    {\n      compute(matA, matB, options);\n    }\n\n    /** \\brief Computes generalized eigendecomposition of given matrix pencil.\n      *\n      * \\param[in]  matA  Selfadjoint matrix in matrix pencil.\n      *                   Only the lower triangular part of the matrix is referenced.\n      * \\param[in]  matB  Positive-definite matrix in matrix pencil.\n      *                   Only the lower triangular part of the matrix is referenced.\n      * \\param[in]  options A or-ed set of flags {#ComputeEigenvectors,#EigenvaluesOnly} | {#Ax_lBx,#ABx_lx,#BAx_lx}.\n      *                     Default is #ComputeEigenvectors|#Ax_lBx.\n      *\n      * \\returns    Reference to \\c *this\n      *\n      * Accoring to \\p options, this function computes eigenvalues and (if requested)\n      * the eigenvectors of one of the following three generalized eigenproblems:\n      * - \\c Ax_lBx: \\f$ Ax = \\lambda B x \\f$\n      * - \\c ABx_lx: \\f$ ABx = \\lambda x \\f$\n      * - \\c BAx_lx: \\f$ BAx = \\lambda x \\f$\n      * with \\a matA the selfadjoint matrix \\f$ A \\f$ and \\a matB the positive definite\n      * matrix \\f$ B \\f$.\n      * In addition, each eigenvector \\f$ x \\f$ satisfies the property \\f$ x^* B x = 1 \\f$.\n      *\n      * The eigenvalues() function can be used to retrieve\n      * the eigenvalues. If \\p options contains ComputeEigenvectors, then the\n      * eigenvectors are also computed and can be retrieved by calling\n      * eigenvectors().\n      *\n      * The implementation uses LLT to compute the Cholesky decomposition\n      * \\f$ B = LL^* \\f$ and computes the classical eigendecomposition\n      * of the selfadjoint matrix \\f$ L^{-1} A (L^*)^{-1} \\f$ if \\p options contains Ax_lBx\n      * and of \\f$ L^{*} A L \\f$ otherwise. This solves the\n      * generalized eigenproblem, because any solution of the generalized\n      * eigenproblem \\f$ Ax = \\lambda B x \\f$ corresponds to a solution\n      * \\f$ L^{-1} A (L^*)^{-1} (L^* x) = \\lambda (L^* x) \\f$ of the\n      * eigenproblem for \\f$ L^{-1} A (L^*)^{-1} \\f$. Similar statements\n      * can be made for the two other variants.\n      *\n      * Example: \\include SelfAdjointEigenSolver_compute_MatrixType2.cpp\n      * Output: \\verbinclude SelfAdjointEigenSolver_compute_MatrixType2.out\n      *\n      * \\sa GeneralizedSelfAdjointEigenSolver(const MatrixType&, const MatrixType&, int)\n      */\n    GeneralizedSelfAdjointEigenSolver& compute(const MatrixType& matA, const MatrixType& matB,\n                                               int options = ComputeEigenvectors|Ax_lBx);\n\n  protected:\n\n};\n\n\ntemplate<typename MatrixType>\nGeneralizedSelfAdjointEigenSolver<MatrixType>& GeneralizedSelfAdjointEigenSolver<MatrixType>::\ncompute(const MatrixType& matA, const MatrixType& matB, int options)\n{\n  eigen_assert(matA.cols()==matA.rows() && matB.rows()==matA.rows() && matB.cols()==matB.rows());\n  eigen_assert((options&~(EigVecMask|GenEigMask))==0\n          && (options&EigVecMask)!=EigVecMask\n          && ((options&GenEigMask)==0 || (options&GenEigMask)==Ax_lBx\n           || (options&GenEigMask)==ABx_lx || (options&GenEigMask)==BAx_lx)\n          && \"invalid option parameter\");\n\n  bool computeEigVecs = ((options&EigVecMask)==0) || ((options&EigVecMask)==ComputeEigenvectors);\n\n  // Compute the cholesky decomposition of matB = L L' = U'U\n  LLT<MatrixType> cholB(matB);\n\n  int type = (options&GenEigMask);\n  if(type==0)\n    type = Ax_lBx;\n\n  if(type==Ax_lBx)\n  {\n    // compute C = inv(L) A inv(L')\n    MatrixType matC = matA.template selfadjointView<Lower>();\n    cholB.matrixL().template solveInPlace<OnTheLeft>(matC);\n    cholB.matrixU().template solveInPlace<OnTheRight>(matC);\n\n    Base::compute(matC, computeEigVecs ? ComputeEigenvectors : EigenvaluesOnly );\n\n    // transform back the eigen vectors: evecs = inv(U) * evecs\n    if(computeEigVecs)\n      cholB.matrixU().solveInPlace(Base::m_eivec);\n  }\n  else if(type==ABx_lx)\n  {\n    // compute C = L' A L\n    MatrixType matC = matA.template selfadjointView<Lower>();\n    matC = matC * cholB.matrixL();\n    matC = cholB.matrixU() * matC;\n\n    Base::compute(matC, computeEigVecs ? ComputeEigenvectors : EigenvaluesOnly);\n\n    // transform back the eigen vectors: evecs = inv(U) * evecs\n    if(computeEigVecs)\n      cholB.matrixU().solveInPlace(Base::m_eivec);\n  }\n  else if(type==BAx_lx)\n  {\n    // compute C = L' A L\n    MatrixType matC = matA.template selfadjointView<Lower>();\n    matC = matC * cholB.matrixL();\n    matC = cholB.matrixU() * matC;\n\n    Base::compute(matC, computeEigVecs ? ComputeEigenvectors : EigenvaluesOnly);\n\n    // transform back the eigen vectors: evecs = L * evecs\n    if(computeEigVecs)\n      Base::m_eivec = cholB.matrixL() * Base::m_eivec;\n  }\n\n  return *this;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_GENERALIZEDSELFADJOINTEIGENSOLVER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/HessenbergDecomposition.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_HESSENBERGDECOMPOSITION_H\n#define EIGEN_HESSENBERGDECOMPOSITION_H\n\nnamespace Eigen { \n\nnamespace internal {\n  \ntemplate<typename MatrixType> struct HessenbergDecompositionMatrixHReturnType;\ntemplate<typename MatrixType>\nstruct traits<HessenbergDecompositionMatrixHReturnType<MatrixType> >\n{\n  typedef MatrixType ReturnType;\n};\n\n}\n\n/** \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  *\n  * \\class HessenbergDecomposition\n  *\n  * \\brief Reduces a square matrix to Hessenberg form by an orthogonal similarity transformation\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the Hessenberg decomposition\n  *\n  * This class performs an Hessenberg decomposition of a matrix \\f$ A \\f$. In\n  * the real case, the Hessenberg decomposition consists of an orthogonal\n  * matrix \\f$ Q \\f$ and a Hessenberg matrix \\f$ H \\f$ such that \\f$ A = Q H\n  * Q^T \\f$. An orthogonal matrix is a matrix whose inverse equals its\n  * transpose (\\f$ Q^{-1} = Q^T \\f$). A Hessenberg matrix has zeros below the\n  * subdiagonal, so it is almost upper triangular. The Hessenberg decomposition\n  * of a complex matrix is \\f$ A = Q H Q^* \\f$ with \\f$ Q \\f$ unitary (that is,\n  * \\f$ Q^{-1} = Q^* \\f$).\n  *\n  * Call the function compute() to compute the Hessenberg decomposition of a\n  * given matrix. Alternatively, you can use the\n  * HessenbergDecomposition(const MatrixType&) constructor which computes the\n  * Hessenberg decomposition at construction time. Once the decomposition is\n  * computed, you can use the matrixH() and matrixQ() functions to construct\n  * the matrices H and Q in the decomposition.\n  *\n  * The documentation for matrixH() contains an example of the typical use of\n  * this class.\n  *\n  * \\sa class ComplexSchur, class Tridiagonalization, \\ref QR_Module \"QR Module\"\n  */\ntemplate<typename _MatrixType> class HessenbergDecomposition\n{\n  public:\n\n    /** \\brief Synonym for the template parameter \\p _MatrixType. */\n    typedef _MatrixType MatrixType;\n\n    enum {\n      Size = MatrixType::RowsAtCompileTime,\n      SizeMinusOne = Size == Dynamic ? Dynamic : Size - 1,\n      Options = MatrixType::Options,\n      MaxSize = MatrixType::MaxRowsAtCompileTime,\n      MaxSizeMinusOne = MaxSize == Dynamic ? Dynamic : MaxSize - 1\n    };\n\n    /** \\brief Scalar type for matrices of type #MatrixType. */\n    typedef typename MatrixType::Scalar Scalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n\n    /** \\brief Type for vector of Householder coefficients.\n      *\n      * This is column vector with entries of type #Scalar. The length of the\n      * vector is one less than the size of #MatrixType, if it is a fixed-side\n      * type.\n      */\n    typedef Matrix<Scalar, SizeMinusOne, 1, Options & ~RowMajor, MaxSizeMinusOne, 1> CoeffVectorType;\n\n    /** \\brief Return type of matrixQ() */\n    typedef HouseholderSequence<MatrixType,typename internal::remove_all<typename CoeffVectorType::ConjugateReturnType>::type> HouseholderSequenceType;\n    \n    typedef internal::HessenbergDecompositionMatrixHReturnType<MatrixType> MatrixHReturnType;\n\n    /** \\brief Default constructor; the decomposition will be computed later.\n      *\n      * \\param [in] size  The size of the matrix whose Hessenberg decomposition will be computed.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via compute().  The \\p size parameter is only\n      * used as a hint. It is not an error to give a wrong \\p size, but it may\n      * impair performance.\n      *\n      * \\sa compute() for an example.\n      */\n    explicit HessenbergDecomposition(Index size = Size==Dynamic ? 2 : Size)\n      : m_matrix(size,size),\n        m_temp(size),\n        m_isInitialized(false)\n    {\n      if(size>1)\n        m_hCoeffs.resize(size-1);\n    }\n\n    /** \\brief Constructor; computes Hessenberg decomposition of given matrix.\n      *\n      * \\param[in]  matrix  Square matrix whose Hessenberg decomposition is to be computed.\n      *\n      * This constructor calls compute() to compute the Hessenberg\n      * decomposition.\n      *\n      * \\sa matrixH() for an example.\n      */\n    template<typename InputType>\n    explicit HessenbergDecomposition(const EigenBase<InputType>& matrix)\n      : m_matrix(matrix.derived()),\n        m_temp(matrix.rows()),\n        m_isInitialized(false)\n    {\n      if(matrix.rows()<2)\n      {\n        m_isInitialized = true;\n        return;\n      }\n      m_hCoeffs.resize(matrix.rows()-1,1);\n      _compute(m_matrix, m_hCoeffs, m_temp);\n      m_isInitialized = true;\n    }\n\n    /** \\brief Computes Hessenberg decomposition of given matrix.\n      *\n      * \\param[in]  matrix  Square matrix whose Hessenberg decomposition is to be computed.\n      * \\returns    Reference to \\c *this\n      *\n      * The Hessenberg decomposition is computed by bringing the columns of the\n      * matrix successively in the required form using Householder reflections\n      * (see, e.g., Algorithm 7.4.2 in Golub \\& Van Loan, <i>%Matrix\n      * Computations</i>). The cost is \\f$ 10n^3/3 \\f$ flops, where \\f$ n \\f$\n      * denotes the size of the given matrix.\n      *\n      * This method reuses of the allocated data in the HessenbergDecomposition\n      * object.\n      *\n      * Example: \\include HessenbergDecomposition_compute.cpp\n      * Output: \\verbinclude HessenbergDecomposition_compute.out\n      */\n    template<typename InputType>\n    HessenbergDecomposition& compute(const EigenBase<InputType>& matrix)\n    {\n      m_matrix = matrix.derived();\n      if(matrix.rows()<2)\n      {\n        m_isInitialized = true;\n        return *this;\n      }\n      m_hCoeffs.resize(matrix.rows()-1,1);\n      _compute(m_matrix, m_hCoeffs, m_temp);\n      m_isInitialized = true;\n      return *this;\n    }\n\n    /** \\brief Returns the Householder coefficients.\n      *\n      * \\returns a const reference to the vector of Householder coefficients\n      *\n      * \\pre Either the constructor HessenbergDecomposition(const MatrixType&)\n      * or the member function compute(const MatrixType&) has been called\n      * before to compute the Hessenberg decomposition of a matrix.\n      *\n      * The Householder coefficients allow the reconstruction of the matrix\n      * \\f$ Q \\f$ in the Hessenberg decomposition from the packed data.\n      *\n      * \\sa packedMatrix(), \\ref Householder_Module \"Householder module\"\n      */\n    const CoeffVectorType& householderCoefficients() const\n    {\n      eigen_assert(m_isInitialized && \"HessenbergDecomposition is not initialized.\");\n      return m_hCoeffs;\n    }\n\n    /** \\brief Returns the internal representation of the decomposition\n      *\n      *\t\\returns a const reference to a matrix with the internal representation\n      *\t         of the decomposition.\n      *\n      * \\pre Either the constructor HessenbergDecomposition(const MatrixType&)\n      * or the member function compute(const MatrixType&) has been called\n      * before to compute the Hessenberg decomposition of a matrix.\n      *\n      * The returned matrix contains the following information:\n      *  - the upper part and lower sub-diagonal represent the Hessenberg matrix H\n      *  - the rest of the lower part contains the Householder vectors that, combined with\n      *    Householder coefficients returned by householderCoefficients(),\n      *    allows to reconstruct the matrix Q as\n      *       \\f$ Q = H_{N-1} \\ldots H_1 H_0 \\f$.\n      *    Here, the matrices \\f$ H_i \\f$ are the Householder transformations\n      *       \\f$ H_i = (I - h_i v_i v_i^T) \\f$\n      *    where \\f$ h_i \\f$ is the \\f$ i \\f$th Householder coefficient and\n      *    \\f$ v_i \\f$ is the Householder vector defined by\n      *       \\f$ v_i = [ 0, \\ldots, 0, 1, M(i+2,i), \\ldots, M(N-1,i) ]^T \\f$\n      *    with M the matrix returned by this function.\n      *\n      * See LAPACK for further details on this packed storage.\n      *\n      * Example: \\include HessenbergDecomposition_packedMatrix.cpp\n      * Output: \\verbinclude HessenbergDecomposition_packedMatrix.out\n      *\n      * \\sa householderCoefficients()\n      */\n    const MatrixType& packedMatrix() const\n    {\n      eigen_assert(m_isInitialized && \"HessenbergDecomposition is not initialized.\");\n      return m_matrix;\n    }\n\n    /** \\brief Reconstructs the orthogonal matrix Q in the decomposition\n      *\n      * \\returns object representing the matrix Q\n      *\n      * \\pre Either the constructor HessenbergDecomposition(const MatrixType&)\n      * or the member function compute(const MatrixType&) has been called\n      * before to compute the Hessenberg decomposition of a matrix.\n      *\n      * This function returns a light-weight object of template class\n      * HouseholderSequence. You can either apply it directly to a matrix or\n      * you can convert it to a matrix of type #MatrixType.\n      *\n      * \\sa matrixH() for an example, class HouseholderSequence\n      */\n    HouseholderSequenceType matrixQ() const\n    {\n      eigen_assert(m_isInitialized && \"HessenbergDecomposition is not initialized.\");\n      return HouseholderSequenceType(m_matrix, m_hCoeffs.conjugate())\n             .setLength(m_matrix.rows() - 1)\n             .setShift(1);\n    }\n\n    /** \\brief Constructs the Hessenberg matrix H in the decomposition\n      *\n      * \\returns expression object representing the matrix H\n      *\n      * \\pre Either the constructor HessenbergDecomposition(const MatrixType&)\n      * or the member function compute(const MatrixType&) has been called\n      * before to compute the Hessenberg decomposition of a matrix.\n      *\n      * The object returned by this function constructs the Hessenberg matrix H\n      * when it is assigned to a matrix or otherwise evaluated. The matrix H is\n      * constructed from the packed matrix as returned by packedMatrix(): The\n      * upper part (including the subdiagonal) of the packed matrix contains\n      * the matrix H. It may sometimes be better to directly use the packed\n      * matrix instead of constructing the matrix H.\n      *\n      * Example: \\include HessenbergDecomposition_matrixH.cpp\n      * Output: \\verbinclude HessenbergDecomposition_matrixH.out\n      *\n      * \\sa matrixQ(), packedMatrix()\n      */\n    MatrixHReturnType matrixH() const\n    {\n      eigen_assert(m_isInitialized && \"HessenbergDecomposition is not initialized.\");\n      return MatrixHReturnType(*this);\n    }\n\n  private:\n\n    typedef Matrix<Scalar, 1, Size, Options | RowMajor, 1, MaxSize> VectorType;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    static void _compute(MatrixType& matA, CoeffVectorType& hCoeffs, VectorType& temp);\n\n  protected:\n    MatrixType m_matrix;\n    CoeffVectorType m_hCoeffs;\n    VectorType m_temp;\n    bool m_isInitialized;\n};\n\n/** \\internal\n  * Performs a tridiagonal decomposition of \\a matA in place.\n  *\n  * \\param matA the input selfadjoint matrix\n  * \\param hCoeffs returned Householder coefficients\n  *\n  * The result is written in the lower triangular part of \\a matA.\n  *\n  * Implemented from Golub's \"%Matrix Computations\", algorithm 8.3.1.\n  *\n  * \\sa packedMatrix()\n  */\ntemplate<typename MatrixType>\nvoid HessenbergDecomposition<MatrixType>::_compute(MatrixType& matA, CoeffVectorType& hCoeffs, VectorType& temp)\n{\n  eigen_assert(matA.rows()==matA.cols());\n  Index n = matA.rows();\n  temp.resize(n);\n  for (Index i = 0; i<n-1; ++i)\n  {\n    // let's consider the vector v = i-th column starting at position i+1\n    Index remainingSize = n-i-1;\n    RealScalar beta;\n    Scalar h;\n    matA.col(i).tail(remainingSize).makeHouseholderInPlace(h, beta);\n    matA.col(i).coeffRef(i+1) = beta;\n    hCoeffs.coeffRef(i) = h;\n\n    // Apply similarity transformation to remaining columns,\n    // i.e., compute A = H A H'\n\n    // A = H A\n    matA.bottomRightCorner(remainingSize, remainingSize)\n        .applyHouseholderOnTheLeft(matA.col(i).tail(remainingSize-1), h, &temp.coeffRef(0));\n\n    // A = A H'\n    matA.rightCols(remainingSize)\n        .applyHouseholderOnTheRight(matA.col(i).tail(remainingSize-1).conjugate(), numext::conj(h), &temp.coeffRef(0));\n  }\n}\n\nnamespace internal {\n\n/** \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  *\n  * \\brief Expression type for return value of HessenbergDecomposition::matrixH()\n  *\n  * \\tparam MatrixType type of matrix in the Hessenberg decomposition\n  *\n  * Objects of this type represent the Hessenberg matrix in the Hessenberg\n  * decomposition of some matrix. The object holds a reference to the\n  * HessenbergDecomposition class until the it is assigned or evaluated for\n  * some other reason (the reference should remain valid during the life time\n  * of this object). This class is the return type of\n  * HessenbergDecomposition::matrixH(); there is probably no other use for this\n  * class.\n  */\ntemplate<typename MatrixType> struct HessenbergDecompositionMatrixHReturnType\n: public ReturnByValue<HessenbergDecompositionMatrixHReturnType<MatrixType> >\n{\n  public:\n    /** \\brief Constructor.\n      *\n      * \\param[in] hess  Hessenberg decomposition\n      */\n    HessenbergDecompositionMatrixHReturnType(const HessenbergDecomposition<MatrixType>& hess) : m_hess(hess) { }\n\n    /** \\brief Hessenberg matrix in decomposition.\n      *\n      * \\param[out] result  Hessenberg matrix in decomposition \\p hess which\n      *                     was passed to the constructor\n      */\n    template <typename ResultType>\n    inline void evalTo(ResultType& result) const\n    {\n      result = m_hess.packedMatrix();\n      Index n = result.rows();\n      if (n>2)\n        result.bottomLeftCorner(n-2, n-2).template triangularView<Lower>().setZero();\n    }\n\n    Index rows() const { return m_hess.packedMatrix().rows(); }\n    Index cols() const { return m_hess.packedMatrix().cols(); }\n\n  protected:\n    const HessenbergDecomposition<MatrixType>& m_hess;\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_HESSENBERGDECOMPOSITION_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MATRIXBASEEIGENVALUES_H\n#define EIGEN_MATRIXBASEEIGENVALUES_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Derived, bool IsComplex>\nstruct eigenvalues_selector\n{\n  // this is the implementation for the case IsComplex = true\n  static inline typename MatrixBase<Derived>::EigenvaluesReturnType const\n  run(const MatrixBase<Derived>& m)\n  {\n    typedef typename Derived::PlainObject PlainObject;\n    PlainObject m_eval(m);\n    return ComplexEigenSolver<PlainObject>(m_eval, false).eigenvalues();\n  }\n};\n\ntemplate<typename Derived>\nstruct eigenvalues_selector<Derived, false>\n{\n  static inline typename MatrixBase<Derived>::EigenvaluesReturnType const\n  run(const MatrixBase<Derived>& m)\n  {\n    typedef typename Derived::PlainObject PlainObject;\n    PlainObject m_eval(m);\n    return EigenSolver<PlainObject>(m_eval, false).eigenvalues();\n  }\n};\n\n} // end namespace internal\n\n/** \\brief Computes the eigenvalues of a matrix \n  * \\returns Column vector containing the eigenvalues.\n  *\n  * \\eigenvalues_module\n  * This function computes the eigenvalues with the help of the EigenSolver\n  * class (for real matrices) or the ComplexEigenSolver class (for complex\n  * matrices). \n  *\n  * The eigenvalues are repeated according to their algebraic multiplicity,\n  * so there are as many eigenvalues as rows in the matrix.\n  *\n  * The SelfAdjointView class provides a better algorithm for selfadjoint\n  * matrices.\n  *\n  * Example: \\include MatrixBase_eigenvalues.cpp\n  * Output: \\verbinclude MatrixBase_eigenvalues.out\n  *\n  * \\sa EigenSolver::eigenvalues(), ComplexEigenSolver::eigenvalues(),\n  *     SelfAdjointView::eigenvalues()\n  */\ntemplate<typename Derived>\ninline typename MatrixBase<Derived>::EigenvaluesReturnType\nMatrixBase<Derived>::eigenvalues() const\n{\n  typedef typename internal::traits<Derived>::Scalar Scalar;\n  return internal::eigenvalues_selector<Derived, NumTraits<Scalar>::IsComplex>::run(derived());\n}\n\n/** \\brief Computes the eigenvalues of a matrix\n  * \\returns Column vector containing the eigenvalues.\n  *\n  * \\eigenvalues_module\n  * This function computes the eigenvalues with the help of the\n  * SelfAdjointEigenSolver class.  The eigenvalues are repeated according to\n  * their algebraic multiplicity, so there are as many eigenvalues as rows in\n  * the matrix.\n  *\n  * Example: \\include SelfAdjointView_eigenvalues.cpp\n  * Output: \\verbinclude SelfAdjointView_eigenvalues.out\n  *\n  * \\sa SelfAdjointEigenSolver::eigenvalues(), MatrixBase::eigenvalues()\n  */\ntemplate<typename MatrixType, unsigned int UpLo> \ninline typename SelfAdjointView<MatrixType, UpLo>::EigenvaluesReturnType\nSelfAdjointView<MatrixType, UpLo>::eigenvalues() const\n{\n  typedef typename SelfAdjointView<MatrixType, UpLo>::PlainObject PlainObject;\n  PlainObject thisAsMatrix(*this);\n  return SelfAdjointEigenSolver<PlainObject>(thisAsMatrix, false).eigenvalues();\n}\n\n\n\n/** \\brief Computes the L2 operator norm\n  * \\returns Operator norm of the matrix.\n  *\n  * \\eigenvalues_module\n  * This function computes the L2 operator norm of a matrix, which is also\n  * known as the spectral norm. The norm of a matrix \\f$ A \\f$ is defined to be\n  * \\f[ \\|A\\|_2 = \\max_x \\frac{\\|Ax\\|_2}{\\|x\\|_2} \\f]\n  * where the maximum is over all vectors and the norm on the right is the\n  * Euclidean vector norm. The norm equals the largest singular value, which is\n  * the square root of the largest eigenvalue of the positive semi-definite\n  * matrix \\f$ A^*A \\f$.\n  *\n  * The current implementation uses the eigenvalues of \\f$ A^*A \\f$, as computed\n  * by SelfAdjointView::eigenvalues(), to compute the operator norm of a\n  * matrix.  The SelfAdjointView class provides a better algorithm for\n  * selfadjoint matrices.\n  *\n  * Example: \\include MatrixBase_operatorNorm.cpp\n  * Output: \\verbinclude MatrixBase_operatorNorm.out\n  *\n  * \\sa SelfAdjointView::eigenvalues(), SelfAdjointView::operatorNorm()\n  */\ntemplate<typename Derived>\ninline typename MatrixBase<Derived>::RealScalar\nMatrixBase<Derived>::operatorNorm() const\n{\n  using std::sqrt;\n  typename Derived::PlainObject m_eval(derived());\n  // FIXME if it is really guaranteed that the eigenvalues are already sorted,\n  // then we don't need to compute a maxCoeff() here, comparing the 1st and last ones is enough.\n  return sqrt((m_eval*m_eval.adjoint())\n                 .eval()\n\t\t .template selfadjointView<Lower>()\n\t\t .eigenvalues()\n\t\t .maxCoeff()\n\t\t );\n}\n\n/** \\brief Computes the L2 operator norm\n  * \\returns Operator norm of the matrix.\n  *\n  * \\eigenvalues_module\n  * This function computes the L2 operator norm of a self-adjoint matrix. For a\n  * self-adjoint matrix, the operator norm is the largest eigenvalue.\n  *\n  * The current implementation uses the eigenvalues of the matrix, as computed\n  * by eigenvalues(), to compute the operator norm of the matrix.\n  *\n  * Example: \\include SelfAdjointView_operatorNorm.cpp\n  * Output: \\verbinclude SelfAdjointView_operatorNorm.out\n  *\n  * \\sa eigenvalues(), MatrixBase::operatorNorm()\n  */\ntemplate<typename MatrixType, unsigned int UpLo>\ninline typename SelfAdjointView<MatrixType, UpLo>::RealScalar\nSelfAdjointView<MatrixType, UpLo>::operatorNorm() const\n{\n  return eigenvalues().cwiseAbs().maxCoeff();\n}\n\n} // end namespace Eigen\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/RealQZ.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Alexey Korepanov <kaikaikai@yandex.ru>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_REAL_QZ_H\n#define EIGEN_REAL_QZ_H\n\nnamespace Eigen {\n\n  /** \\eigenvalues_module \\ingroup Eigenvalues_Module\n   *\n   *\n   * \\class RealQZ\n   *\n   * \\brief Performs a real QZ decomposition of a pair of square matrices\n   *\n   * \\tparam _MatrixType the type of the matrix of which we are computing the\n   * real QZ decomposition; this is expected to be an instantiation of the\n   * Matrix class template.\n   *\n   * Given a real square matrices A and B, this class computes the real QZ\n   * decomposition: \\f$ A = Q S Z \\f$, \\f$ B = Q T Z \\f$ where Q and Z are\n   * real orthogonal matrixes, T is upper-triangular matrix, and S is upper\n   * quasi-triangular matrix. An orthogonal matrix is a matrix whose\n   * inverse is equal to its transpose, \\f$ U^{-1} = U^T \\f$. A quasi-triangular\n   * matrix is a block-triangular matrix whose diagonal consists of 1-by-1\n   * blocks and 2-by-2 blocks where further reduction is impossible due to\n   * complex eigenvalues. \n   *\n   * The eigenvalues of the pencil \\f$ A - z B \\f$ can be obtained from\n   * 1x1 and 2x2 blocks on the diagonals of S and T.\n   *\n   * Call the function compute() to compute the real QZ decomposition of a\n   * given pair of matrices. Alternatively, you can use the \n   * RealQZ(const MatrixType& B, const MatrixType& B, bool computeQZ)\n   * constructor which computes the real QZ decomposition at construction\n   * time. Once the decomposition is computed, you can use the matrixS(),\n   * matrixT(), matrixQ() and matrixZ() functions to retrieve the matrices\n   * S, T, Q and Z in the decomposition. If computeQZ==false, some time\n   * is saved by not computing matrices Q and Z.\n   *\n   * Example: \\include RealQZ_compute.cpp\n   * Output: \\include RealQZ_compute.out\n   *\n   * \\note The implementation is based on the algorithm in \"Matrix Computations\"\n   * by Gene H. Golub and Charles F. Van Loan, and a paper \"An algorithm for\n   * generalized eigenvalue problems\" by C.B.Moler and G.W.Stewart.\n   *\n   * \\sa class RealSchur, class ComplexSchur, class EigenSolver, class ComplexEigenSolver\n   */\n\n  template<typename _MatrixType> class RealQZ\n  {\n    public:\n      typedef _MatrixType MatrixType;\n      enum {\n        RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n        ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n        Options = MatrixType::Options,\n        MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n        MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n      };\n      typedef typename MatrixType::Scalar Scalar;\n      typedef std::complex<typename NumTraits<Scalar>::Real> ComplexScalar;\n      typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n\n      typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> EigenvalueType;\n      typedef Matrix<Scalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> ColumnVectorType;\n\n      /** \\brief Default constructor.\n       *\n       * \\param [in] size  Positive integer, size of the matrix whose QZ decomposition will be computed.\n       *\n       * The default constructor is useful in cases in which the user intends to\n       * perform decompositions via compute().  The \\p size parameter is only\n       * used as a hint. It is not an error to give a wrong \\p size, but it may\n       * impair performance.\n       *\n       * \\sa compute() for an example.\n       */\n      explicit RealQZ(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime) :\n        m_S(size, size),\n        m_T(size, size),\n        m_Q(size, size),\n        m_Z(size, size),\n        m_workspace(size*2),\n        m_maxIters(400),\n        m_isInitialized(false)\n        { }\n\n      /** \\brief Constructor; computes real QZ decomposition of given matrices\n       * \n       * \\param[in]  A          Matrix A.\n       * \\param[in]  B          Matrix B.\n       * \\param[in]  computeQZ  If false, A and Z are not computed.\n       *\n       * This constructor calls compute() to compute the QZ decomposition.\n       */\n      RealQZ(const MatrixType& A, const MatrixType& B, bool computeQZ = true) :\n        m_S(A.rows(),A.cols()),\n        m_T(A.rows(),A.cols()),\n        m_Q(A.rows(),A.cols()),\n        m_Z(A.rows(),A.cols()),\n        m_workspace(A.rows()*2),\n        m_maxIters(400),\n        m_isInitialized(false) {\n          compute(A, B, computeQZ);\n        }\n\n      /** \\brief Returns matrix Q in the QZ decomposition. \n       *\n       * \\returns A const reference to the matrix Q.\n       */\n      const MatrixType& matrixQ() const {\n        eigen_assert(m_isInitialized && \"RealQZ is not initialized.\");\n        eigen_assert(m_computeQZ && \"The matrices Q and Z have not been computed during the QZ decomposition.\");\n        return m_Q;\n      }\n\n      /** \\brief Returns matrix Z in the QZ decomposition. \n       *\n       * \\returns A const reference to the matrix Z.\n       */\n      const MatrixType& matrixZ() const {\n        eigen_assert(m_isInitialized && \"RealQZ is not initialized.\");\n        eigen_assert(m_computeQZ && \"The matrices Q and Z have not been computed during the QZ decomposition.\");\n        return m_Z;\n      }\n\n      /** \\brief Returns matrix S in the QZ decomposition. \n       *\n       * \\returns A const reference to the matrix S.\n       */\n      const MatrixType& matrixS() const {\n        eigen_assert(m_isInitialized && \"RealQZ is not initialized.\");\n        return m_S;\n      }\n\n      /** \\brief Returns matrix S in the QZ decomposition. \n       *\n       * \\returns A const reference to the matrix S.\n       */\n      const MatrixType& matrixT() const {\n        eigen_assert(m_isInitialized && \"RealQZ is not initialized.\");\n        return m_T;\n      }\n\n      /** \\brief Computes QZ decomposition of given matrix. \n       * \n       * \\param[in]  A          Matrix A.\n       * \\param[in]  B          Matrix B.\n       * \\param[in]  computeQZ  If false, A and Z are not computed.\n       * \\returns    Reference to \\c *this\n       */\n      RealQZ& compute(const MatrixType& A, const MatrixType& B, bool computeQZ = true);\n\n      /** \\brief Reports whether previous computation was successful.\n       *\n       * \\returns \\c Success if computation was succesful, \\c NoConvergence otherwise.\n       */\n      ComputationInfo info() const\n      {\n        eigen_assert(m_isInitialized && \"RealQZ is not initialized.\");\n        return m_info;\n      }\n\n      /** \\brief Returns number of performed QR-like iterations.\n      */\n      Index iterations() const\n      {\n        eigen_assert(m_isInitialized && \"RealQZ is not initialized.\");\n        return m_global_iter;\n      }\n\n      /** Sets the maximal number of iterations allowed to converge to one eigenvalue\n       * or decouple the problem.\n      */\n      RealQZ& setMaxIterations(Index maxIters)\n      {\n        m_maxIters = maxIters;\n        return *this;\n      }\n\n    private:\n\n      MatrixType m_S, m_T, m_Q, m_Z;\n      Matrix<Scalar,Dynamic,1> m_workspace;\n      ComputationInfo m_info;\n      Index m_maxIters;\n      bool m_isInitialized;\n      bool m_computeQZ;\n      Scalar m_normOfT, m_normOfS;\n      Index m_global_iter;\n\n      typedef Matrix<Scalar,3,1> Vector3s;\n      typedef Matrix<Scalar,2,1> Vector2s;\n      typedef Matrix<Scalar,2,2> Matrix2s;\n      typedef JacobiRotation<Scalar> JRs;\n\n      void hessenbergTriangular();\n      void computeNorms();\n      Index findSmallSubdiagEntry(Index iu);\n      Index findSmallDiagEntry(Index f, Index l);\n      void splitOffTwoRows(Index i);\n      void pushDownZero(Index z, Index f, Index l);\n      void step(Index f, Index l, Index iter);\n\n  }; // RealQZ\n\n  /** \\internal Reduces S and T to upper Hessenberg - triangular form */\n  template<typename MatrixType>\n    void RealQZ<MatrixType>::hessenbergTriangular()\n    {\n\n      const Index dim = m_S.cols();\n\n      // perform QR decomposition of T, overwrite T with R, save Q\n      HouseholderQR<MatrixType> qrT(m_T);\n      m_T = qrT.matrixQR();\n      m_T.template triangularView<StrictlyLower>().setZero();\n      m_Q = qrT.householderQ();\n      // overwrite S with Q* S\n      m_S.applyOnTheLeft(m_Q.adjoint());\n      // init Z as Identity\n      if (m_computeQZ)\n        m_Z = MatrixType::Identity(dim,dim);\n      // reduce S to upper Hessenberg with Givens rotations\n      for (Index j=0; j<=dim-3; j++) {\n        for (Index i=dim-1; i>=j+2; i--) {\n          JRs G;\n          // kill S(i,j)\n          if(m_S.coeff(i,j) != 0)\n          {\n            G.makeGivens(m_S.coeff(i-1,j), m_S.coeff(i,j), &m_S.coeffRef(i-1, j));\n            m_S.coeffRef(i,j) = Scalar(0.0);\n            m_S.rightCols(dim-j-1).applyOnTheLeft(i-1,i,G.adjoint());\n            m_T.rightCols(dim-i+1).applyOnTheLeft(i-1,i,G.adjoint());\n            // update Q\n            if (m_computeQZ)\n              m_Q.applyOnTheRight(i-1,i,G);\n          }\n          // kill T(i,i-1)\n          if(m_T.coeff(i,i-1)!=Scalar(0))\n          {\n            G.makeGivens(m_T.coeff(i,i), m_T.coeff(i,i-1), &m_T.coeffRef(i,i));\n            m_T.coeffRef(i,i-1) = Scalar(0.0);\n            m_S.applyOnTheRight(i,i-1,G);\n            m_T.topRows(i).applyOnTheRight(i,i-1,G);\n            // update Z\n            if (m_computeQZ)\n              m_Z.applyOnTheLeft(i,i-1,G.adjoint());\n          }\n        }\n      }\n    }\n\n  /** \\internal Computes vector L1 norms of S and T when in Hessenberg-Triangular form already */\n  template<typename MatrixType>\n    inline void RealQZ<MatrixType>::computeNorms()\n    {\n      const Index size = m_S.cols();\n      m_normOfS = Scalar(0.0);\n      m_normOfT = Scalar(0.0);\n      for (Index j = 0; j < size; ++j)\n      {\n        m_normOfS += m_S.col(j).segment(0, (std::min)(size,j+2)).cwiseAbs().sum();\n        m_normOfT += m_T.row(j).segment(j, size - j).cwiseAbs().sum();\n      }\n    }\n\n\n  /** \\internal Look for single small sub-diagonal element S(res, res-1) and return res (or 0) */\n  template<typename MatrixType>\n    inline Index RealQZ<MatrixType>::findSmallSubdiagEntry(Index iu)\n    {\n      using std::abs;\n      Index res = iu;\n      while (res > 0)\n      {\n        Scalar s = abs(m_S.coeff(res-1,res-1)) + abs(m_S.coeff(res,res));\n        if (s == Scalar(0.0))\n          s = m_normOfS;\n        if (abs(m_S.coeff(res,res-1)) < NumTraits<Scalar>::epsilon() * s)\n          break;\n        res--;\n      }\n      return res;\n    }\n\n  /** \\internal Look for single small diagonal element T(res, res) for res between f and l, and return res (or f-1)  */\n  template<typename MatrixType>\n    inline Index RealQZ<MatrixType>::findSmallDiagEntry(Index f, Index l)\n    {\n      using std::abs;\n      Index res = l;\n      while (res >= f) {\n        if (abs(m_T.coeff(res,res)) <= NumTraits<Scalar>::epsilon() * m_normOfT)\n          break;\n        res--;\n      }\n      return res;\n    }\n\n  /** \\internal decouple 2x2 diagonal block in rows i, i+1 if eigenvalues are real */\n  template<typename MatrixType>\n    inline void RealQZ<MatrixType>::splitOffTwoRows(Index i)\n    {\n      using std::abs;\n      using std::sqrt;\n      const Index dim=m_S.cols();\n      if (abs(m_S.coeff(i+1,i))==Scalar(0))\n        return;\n      Index j = findSmallDiagEntry(i,i+1);\n      if (j==i-1)\n      {\n        // block of (S T^{-1})\n        Matrix2s STi = m_T.template block<2,2>(i,i).template triangularView<Upper>().\n          template solve<OnTheRight>(m_S.template block<2,2>(i,i));\n        Scalar p = Scalar(0.5)*(STi(0,0)-STi(1,1));\n        Scalar q = p*p + STi(1,0)*STi(0,1);\n        if (q>=0) {\n          Scalar z = sqrt(q);\n          // one QR-like iteration for ABi - lambda I\n          // is enough - when we know exact eigenvalue in advance,\n          // convergence is immediate\n          JRs G;\n          if (p>=0)\n            G.makeGivens(p + z, STi(1,0));\n          else\n            G.makeGivens(p - z, STi(1,0));\n          m_S.rightCols(dim-i).applyOnTheLeft(i,i+1,G.adjoint());\n          m_T.rightCols(dim-i).applyOnTheLeft(i,i+1,G.adjoint());\n          // update Q\n          if (m_computeQZ)\n            m_Q.applyOnTheRight(i,i+1,G);\n\n          G.makeGivens(m_T.coeff(i+1,i+1), m_T.coeff(i+1,i));\n          m_S.topRows(i+2).applyOnTheRight(i+1,i,G);\n          m_T.topRows(i+2).applyOnTheRight(i+1,i,G);\n          // update Z\n          if (m_computeQZ)\n            m_Z.applyOnTheLeft(i+1,i,G.adjoint());\n\n          m_S.coeffRef(i+1,i) = Scalar(0.0);\n          m_T.coeffRef(i+1,i) = Scalar(0.0);\n        }\n      }\n      else\n      {\n        pushDownZero(j,i,i+1);\n      }\n    }\n\n  /** \\internal use zero in T(z,z) to zero S(l,l-1), working in block f..l */\n  template<typename MatrixType>\n    inline void RealQZ<MatrixType>::pushDownZero(Index z, Index f, Index l)\n    {\n      JRs G;\n      const Index dim = m_S.cols();\n      for (Index zz=z; zz<l; zz++)\n      {\n        // push 0 down\n        Index firstColS = zz>f ? (zz-1) : zz;\n        G.makeGivens(m_T.coeff(zz, zz+1), m_T.coeff(zz+1, zz+1));\n        m_S.rightCols(dim-firstColS).applyOnTheLeft(zz,zz+1,G.adjoint());\n        m_T.rightCols(dim-zz).applyOnTheLeft(zz,zz+1,G.adjoint());\n        m_T.coeffRef(zz+1,zz+1) = Scalar(0.0);\n        // update Q\n        if (m_computeQZ)\n          m_Q.applyOnTheRight(zz,zz+1,G);\n        // kill S(zz+1, zz-1)\n        if (zz>f)\n        {\n          G.makeGivens(m_S.coeff(zz+1, zz), m_S.coeff(zz+1,zz-1));\n          m_S.topRows(zz+2).applyOnTheRight(zz, zz-1,G);\n          m_T.topRows(zz+1).applyOnTheRight(zz, zz-1,G);\n          m_S.coeffRef(zz+1,zz-1) = Scalar(0.0);\n          // update Z\n          if (m_computeQZ)\n            m_Z.applyOnTheLeft(zz,zz-1,G.adjoint());\n        }\n      }\n      // finally kill S(l,l-1)\n      G.makeGivens(m_S.coeff(l,l), m_S.coeff(l,l-1));\n      m_S.applyOnTheRight(l,l-1,G);\n      m_T.applyOnTheRight(l,l-1,G);\n      m_S.coeffRef(l,l-1)=Scalar(0.0);\n      // update Z\n      if (m_computeQZ)\n        m_Z.applyOnTheLeft(l,l-1,G.adjoint());\n    }\n\n  /** \\internal QR-like iterative step for block f..l */\n  template<typename MatrixType>\n    inline void RealQZ<MatrixType>::step(Index f, Index l, Index iter)\n    {\n      using std::abs;\n      const Index dim = m_S.cols();\n\n      // x, y, z\n      Scalar x, y, z;\n      if (iter==10)\n      {\n        // Wilkinson ad hoc shift\n        const Scalar\n          a11=m_S.coeff(f+0,f+0), a12=m_S.coeff(f+0,f+1),\n          a21=m_S.coeff(f+1,f+0), a22=m_S.coeff(f+1,f+1), a32=m_S.coeff(f+2,f+1),\n          b12=m_T.coeff(f+0,f+1),\n          b11i=Scalar(1.0)/m_T.coeff(f+0,f+0),\n          b22i=Scalar(1.0)/m_T.coeff(f+1,f+1),\n          a87=m_S.coeff(l-1,l-2),\n          a98=m_S.coeff(l-0,l-1),\n          b77i=Scalar(1.0)/m_T.coeff(l-2,l-2),\n          b88i=Scalar(1.0)/m_T.coeff(l-1,l-1);\n        Scalar ss = abs(a87*b77i) + abs(a98*b88i),\n               lpl = Scalar(1.5)*ss,\n               ll = ss*ss;\n        x = ll + a11*a11*b11i*b11i - lpl*a11*b11i + a12*a21*b11i*b22i\n          - a11*a21*b12*b11i*b11i*b22i;\n        y = a11*a21*b11i*b11i - lpl*a21*b11i + a21*a22*b11i*b22i \n          - a21*a21*b12*b11i*b11i*b22i;\n        z = a21*a32*b11i*b22i;\n      }\n      else if (iter==16)\n      {\n        // another exceptional shift\n        x = m_S.coeff(f,f)/m_T.coeff(f,f)-m_S.coeff(l,l)/m_T.coeff(l,l) + m_S.coeff(l,l-1)*m_T.coeff(l-1,l) /\n          (m_T.coeff(l-1,l-1)*m_T.coeff(l,l));\n        y = m_S.coeff(f+1,f)/m_T.coeff(f,f);\n        z = 0;\n      }\n      else if (iter>23 && !(iter%8))\n      {\n        // extremely exceptional shift\n        x = internal::random<Scalar>(-1.0,1.0);\n        y = internal::random<Scalar>(-1.0,1.0);\n        z = internal::random<Scalar>(-1.0,1.0);\n      }\n      else\n      {\n        // Compute the shifts: (x,y,z,0...) = (AB^-1 - l1 I) (AB^-1 - l2 I) e1\n        // where l1 and l2 are the eigenvalues of the 2x2 matrix C = U V^-1 where\n        // U and V are 2x2 bottom right sub matrices of A and B. Thus:\n        //  = AB^-1AB^-1 + l1 l2 I - (l1+l2)(AB^-1)\n        //  = AB^-1AB^-1 + det(M) - tr(M)(AB^-1)\n        // Since we are only interested in having x, y, z with a correct ratio, we have:\n        const Scalar\n          a11 = m_S.coeff(f,f),     a12 = m_S.coeff(f,f+1),\n          a21 = m_S.coeff(f+1,f),   a22 = m_S.coeff(f+1,f+1),\n                                    a32 = m_S.coeff(f+2,f+1),\n\n          a88 = m_S.coeff(l-1,l-1), a89 = m_S.coeff(l-1,l),\n          a98 = m_S.coeff(l,l-1),   a99 = m_S.coeff(l,l),\n\n          b11 = m_T.coeff(f,f),     b12 = m_T.coeff(f,f+1),\n                                    b22 = m_T.coeff(f+1,f+1),\n\n          b88 = m_T.coeff(l-1,l-1), b89 = m_T.coeff(l-1,l),\n                                    b99 = m_T.coeff(l,l);\n\n        x = ( (a88/b88 - a11/b11)*(a99/b99 - a11/b11) - (a89/b99)*(a98/b88) + (a98/b88)*(b89/b99)*(a11/b11) ) * (b11/a21)\n          + a12/b22 - (a11/b11)*(b12/b22);\n        y = (a22/b22-a11/b11) - (a21/b11)*(b12/b22) - (a88/b88-a11/b11) - (a99/b99-a11/b11) + (a98/b88)*(b89/b99);\n        z = a32/b22;\n      }\n\n      JRs G;\n\n      for (Index k=f; k<=l-2; k++)\n      {\n        // variables for Householder reflections\n        Vector2s essential2;\n        Scalar tau, beta;\n\n        Vector3s hr(x,y,z);\n\n        // Q_k to annihilate S(k+1,k-1) and S(k+2,k-1)\n        hr.makeHouseholderInPlace(tau, beta);\n        essential2 = hr.template bottomRows<2>();\n        Index fc=(std::max)(k-1,Index(0));  // first col to update\n        m_S.template middleRows<3>(k).rightCols(dim-fc).applyHouseholderOnTheLeft(essential2, tau, m_workspace.data());\n        m_T.template middleRows<3>(k).rightCols(dim-fc).applyHouseholderOnTheLeft(essential2, tau, m_workspace.data());\n        if (m_computeQZ)\n          m_Q.template middleCols<3>(k).applyHouseholderOnTheRight(essential2, tau, m_workspace.data());\n        if (k>f)\n          m_S.coeffRef(k+2,k-1) = m_S.coeffRef(k+1,k-1) = Scalar(0.0);\n\n        // Z_{k1} to annihilate T(k+2,k+1) and T(k+2,k)\n        hr << m_T.coeff(k+2,k+2),m_T.coeff(k+2,k),m_T.coeff(k+2,k+1);\n        hr.makeHouseholderInPlace(tau, beta);\n        essential2 = hr.template bottomRows<2>();\n        {\n          Index lr = (std::min)(k+4,dim); // last row to update\n          Map<Matrix<Scalar,Dynamic,1> > tmp(m_workspace.data(),lr);\n          // S\n          tmp = m_S.template middleCols<2>(k).topRows(lr) * essential2;\n          tmp += m_S.col(k+2).head(lr);\n          m_S.col(k+2).head(lr) -= tau*tmp;\n          m_S.template middleCols<2>(k).topRows(lr) -= (tau*tmp) * essential2.adjoint();\n          // T\n          tmp = m_T.template middleCols<2>(k).topRows(lr) * essential2;\n          tmp += m_T.col(k+2).head(lr);\n          m_T.col(k+2).head(lr) -= tau*tmp;\n          m_T.template middleCols<2>(k).topRows(lr) -= (tau*tmp) * essential2.adjoint();\n        }\n        if (m_computeQZ)\n        {\n          // Z\n          Map<Matrix<Scalar,1,Dynamic> > tmp(m_workspace.data(),dim);\n          tmp = essential2.adjoint()*(m_Z.template middleRows<2>(k));\n          tmp += m_Z.row(k+2);\n          m_Z.row(k+2) -= tau*tmp;\n          m_Z.template middleRows<2>(k) -= essential2 * (tau*tmp);\n        }\n        m_T.coeffRef(k+2,k) = m_T.coeffRef(k+2,k+1) = Scalar(0.0);\n\n        // Z_{k2} to annihilate T(k+1,k)\n        G.makeGivens(m_T.coeff(k+1,k+1), m_T.coeff(k+1,k));\n        m_S.applyOnTheRight(k+1,k,G);\n        m_T.applyOnTheRight(k+1,k,G);\n        // update Z\n        if (m_computeQZ)\n          m_Z.applyOnTheLeft(k+1,k,G.adjoint());\n        m_T.coeffRef(k+1,k) = Scalar(0.0);\n\n        // update x,y,z\n        x = m_S.coeff(k+1,k);\n        y = m_S.coeff(k+2,k);\n        if (k < l-2)\n          z = m_S.coeff(k+3,k);\n      } // loop over k\n\n      // Q_{n-1} to annihilate y = S(l,l-2)\n      G.makeGivens(x,y);\n      m_S.applyOnTheLeft(l-1,l,G.adjoint());\n      m_T.applyOnTheLeft(l-1,l,G.adjoint());\n      if (m_computeQZ)\n        m_Q.applyOnTheRight(l-1,l,G);\n      m_S.coeffRef(l,l-2) = Scalar(0.0);\n\n      // Z_{n-1} to annihilate T(l,l-1)\n      G.makeGivens(m_T.coeff(l,l),m_T.coeff(l,l-1));\n      m_S.applyOnTheRight(l,l-1,G);\n      m_T.applyOnTheRight(l,l-1,G);\n      if (m_computeQZ)\n        m_Z.applyOnTheLeft(l,l-1,G.adjoint());\n      m_T.coeffRef(l,l-1) = Scalar(0.0);\n    }\n\n  template<typename MatrixType>\n    RealQZ<MatrixType>& RealQZ<MatrixType>::compute(const MatrixType& A_in, const MatrixType& B_in, bool computeQZ)\n    {\n\n      const Index dim = A_in.cols();\n\n      eigen_assert (A_in.rows()==dim && A_in.cols()==dim \n          && B_in.rows()==dim && B_in.cols()==dim \n          && \"Need square matrices of the same dimension\");\n\n      m_isInitialized = true;\n      m_computeQZ = computeQZ;\n      m_S = A_in; m_T = B_in;\n      m_workspace.resize(dim*2);\n      m_global_iter = 0;\n\n      // entrance point: hessenberg triangular decomposition\n      hessenbergTriangular();\n      // compute L1 vector norms of T, S into m_normOfS, m_normOfT\n      computeNorms();\n\n      Index l = dim-1, \n            f, \n            local_iter = 0;\n\n      while (l>0 && local_iter<m_maxIters)\n      {\n        f = findSmallSubdiagEntry(l);\n        // now rows and columns f..l (including) decouple from the rest of the problem\n        if (f>0) m_S.coeffRef(f,f-1) = Scalar(0.0);\n        if (f == l) // One root found\n        {\n          l--;\n          local_iter = 0;\n        }\n        else if (f == l-1) // Two roots found\n        {\n          splitOffTwoRows(f);\n          l -= 2;\n          local_iter = 0;\n        }\n        else // No convergence yet\n        {\n          // if there's zero on diagonal of T, we can isolate an eigenvalue with Givens rotations\n          Index z = findSmallDiagEntry(f,l);\n          if (z>=f)\n          {\n            // zero found\n            pushDownZero(z,f,l);\n          }\n          else\n          {\n            // We are sure now that S.block(f,f, l-f+1,l-f+1) is underuced upper-Hessenberg \n            // and T.block(f,f, l-f+1,l-f+1) is invertible uper-triangular, which allows to\n            // apply a QR-like iteration to rows and columns f..l.\n            step(f,l, local_iter);\n            local_iter++;\n            m_global_iter++;\n          }\n        }\n      }\n      // check if we converged before reaching iterations limit\n      m_info = (local_iter<m_maxIters) ? Success : NoConvergence;\n\n      // For each non triangular 2x2 diagonal block of S,\n      //    reduce the respective 2x2 diagonal block of T to positive diagonal form using 2x2 SVD.\n      // This step is not mandatory for QZ, but it does help further extraction of eigenvalues/eigenvectors,\n      // and is in par with Lapack/Matlab QZ.\n      if(m_info==Success)\n      {\n        for(Index i=0; i<dim-1; ++i)\n        {\n          if(m_S.coeff(i+1, i) != Scalar(0))\n          {\n            JacobiRotation<Scalar> j_left, j_right;\n            internal::real_2x2_jacobi_svd(m_T, i, i+1, &j_left, &j_right);\n\n            // Apply resulting Jacobi rotations\n            m_S.applyOnTheLeft(i,i+1,j_left);\n            m_S.applyOnTheRight(i,i+1,j_right);\n            m_T.applyOnTheLeft(i,i+1,j_left);\n            m_T.applyOnTheRight(i,i+1,j_right);\n            m_T(i+1,i) = m_T(i,i+1) = Scalar(0);\n\n            if(m_computeQZ) {\n              m_Q.applyOnTheRight(i,i+1,j_left.transpose());\n              m_Z.applyOnTheLeft(i,i+1,j_right.transpose());\n            }\n\n            i++;\n          }\n        }\n      }\n\n      return *this;\n    } // end compute\n\n} // end namespace Eigen\n\n#endif //EIGEN_REAL_QZ\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/RealSchur.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010,2012 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_REAL_SCHUR_H\n#define EIGEN_REAL_SCHUR_H\n\n#include \"./HessenbergDecomposition.h\"\n\nnamespace Eigen { \n\n/** \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  *\n  * \\class RealSchur\n  *\n  * \\brief Performs a real Schur decomposition of a square matrix\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the\n  * real Schur decomposition; this is expected to be an instantiation of the\n  * Matrix class template.\n  *\n  * Given a real square matrix A, this class computes the real Schur\n  * decomposition: \\f$ A = U T U^T \\f$ where U is a real orthogonal matrix and\n  * T is a real quasi-triangular matrix. An orthogonal matrix is a matrix whose\n  * inverse is equal to its transpose, \\f$ U^{-1} = U^T \\f$. A quasi-triangular\n  * matrix is a block-triangular matrix whose diagonal consists of 1-by-1\n  * blocks and 2-by-2 blocks with complex eigenvalues. The eigenvalues of the\n  * blocks on the diagonal of T are the same as the eigenvalues of the matrix\n  * A, and thus the real Schur decomposition is used in EigenSolver to compute\n  * the eigendecomposition of a matrix.\n  *\n  * Call the function compute() to compute the real Schur decomposition of a\n  * given matrix. Alternatively, you can use the RealSchur(const MatrixType&, bool)\n  * constructor which computes the real Schur decomposition at construction\n  * time. Once the decomposition is computed, you can use the matrixU() and\n  * matrixT() functions to retrieve the matrices U and T in the decomposition.\n  *\n  * The documentation of RealSchur(const MatrixType&, bool) contains an example\n  * of the typical use of this class.\n  *\n  * \\note The implementation is adapted from\n  * <a href=\"http://math.nist.gov/javanumerics/jama/\">JAMA</a> (public domain).\n  * Their code is based on EISPACK.\n  *\n  * \\sa class ComplexSchur, class EigenSolver, class ComplexEigenSolver\n  */\ntemplate<typename _MatrixType> class RealSchur\n{\n  public:\n    typedef _MatrixType MatrixType;\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      Options = MatrixType::Options,\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n    typedef typename MatrixType::Scalar Scalar;\n    typedef std::complex<typename NumTraits<Scalar>::Real> ComplexScalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n\n    typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> EigenvalueType;\n    typedef Matrix<Scalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> ColumnVectorType;\n\n    /** \\brief Default constructor.\n      *\n      * \\param [in] size  Positive integer, size of the matrix whose Schur decomposition will be computed.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via compute().  The \\p size parameter is only\n      * used as a hint. It is not an error to give a wrong \\p size, but it may\n      * impair performance.\n      *\n      * \\sa compute() for an example.\n      */\n    explicit RealSchur(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime)\n            : m_matT(size, size),\n              m_matU(size, size),\n              m_workspaceVector(size),\n              m_hess(size),\n              m_isInitialized(false),\n              m_matUisUptodate(false),\n              m_maxIters(-1)\n    { }\n\n    /** \\brief Constructor; computes real Schur decomposition of given matrix. \n      * \n      * \\param[in]  matrix    Square matrix whose Schur decomposition is to be computed.\n      * \\param[in]  computeU  If true, both T and U are computed; if false, only T is computed.\n      *\n      * This constructor calls compute() to compute the Schur decomposition.\n      *\n      * Example: \\include RealSchur_RealSchur_MatrixType.cpp\n      * Output: \\verbinclude RealSchur_RealSchur_MatrixType.out\n      */\n    template<typename InputType>\n    explicit RealSchur(const EigenBase<InputType>& matrix, bool computeU = true)\n            : m_matT(matrix.rows(),matrix.cols()),\n              m_matU(matrix.rows(),matrix.cols()),\n              m_workspaceVector(matrix.rows()),\n              m_hess(matrix.rows()),\n              m_isInitialized(false),\n              m_matUisUptodate(false),\n              m_maxIters(-1)\n    {\n      compute(matrix.derived(), computeU);\n    }\n\n    /** \\brief Returns the orthogonal matrix in the Schur decomposition. \n      *\n      * \\returns A const reference to the matrix U.\n      *\n      * \\pre Either the constructor RealSchur(const MatrixType&, bool) or the\n      * member function compute(const MatrixType&, bool) has been called before\n      * to compute the Schur decomposition of a matrix, and \\p computeU was set\n      * to true (the default value).\n      *\n      * \\sa RealSchur(const MatrixType&, bool) for an example\n      */\n    const MatrixType& matrixU() const\n    {\n      eigen_assert(m_isInitialized && \"RealSchur is not initialized.\");\n      eigen_assert(m_matUisUptodate && \"The matrix U has not been computed during the RealSchur decomposition.\");\n      return m_matU;\n    }\n\n    /** \\brief Returns the quasi-triangular matrix in the Schur decomposition. \n      *\n      * \\returns A const reference to the matrix T.\n      *\n      * \\pre Either the constructor RealSchur(const MatrixType&, bool) or the\n      * member function compute(const MatrixType&, bool) has been called before\n      * to compute the Schur decomposition of a matrix.\n      *\n      * \\sa RealSchur(const MatrixType&, bool) for an example\n      */\n    const MatrixType& matrixT() const\n    {\n      eigen_assert(m_isInitialized && \"RealSchur is not initialized.\");\n      return m_matT;\n    }\n  \n    /** \\brief Computes Schur decomposition of given matrix. \n      * \n      * \\param[in]  matrix    Square matrix whose Schur decomposition is to be computed.\n      * \\param[in]  computeU  If true, both T and U are computed; if false, only T is computed.\n      * \\returns    Reference to \\c *this\n      *\n      * The Schur decomposition is computed by first reducing the matrix to\n      * Hessenberg form using the class HessenbergDecomposition. The Hessenberg\n      * matrix is then reduced to triangular form by performing Francis QR\n      * iterations with implicit double shift. The cost of computing the Schur\n      * decomposition depends on the number of iterations; as a rough guide, it\n      * may be taken to be \\f$25n^3\\f$ flops if \\a computeU is true and\n      * \\f$10n^3\\f$ flops if \\a computeU is false.\n      *\n      * Example: \\include RealSchur_compute.cpp\n      * Output: \\verbinclude RealSchur_compute.out\n      *\n      * \\sa compute(const MatrixType&, bool, Index)\n      */\n    template<typename InputType>\n    RealSchur& compute(const EigenBase<InputType>& matrix, bool computeU = true);\n\n    /** \\brief Computes Schur decomposition of a Hessenberg matrix H = Z T Z^T\n     *  \\param[in] matrixH Matrix in Hessenberg form H\n     *  \\param[in] matrixQ orthogonal matrix Q that transform a matrix A to H : A = Q H Q^T\n     *  \\param computeU Computes the matriX U of the Schur vectors\n     * \\return Reference to \\c *this\n     * \n     *  This routine assumes that the matrix is already reduced in Hessenberg form matrixH\n     *  using either the class HessenbergDecomposition or another mean. \n     *  It computes the upper quasi-triangular matrix T of the Schur decomposition of H\n     *  When computeU is true, this routine computes the matrix U such that \n     *  A = U T U^T =  (QZ) T (QZ)^T = Q H Q^T where A is the initial matrix\n     * \n     * NOTE Q is referenced if computeU is true; so, if the initial orthogonal matrix\n     * is not available, the user should give an identity matrix (Q.setIdentity())\n     * \n     * \\sa compute(const MatrixType&, bool)\n     */\n    template<typename HessMatrixType, typename OrthMatrixType>\n    RealSchur& computeFromHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ,  bool computeU);\n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful, \\c NoConvergence otherwise.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"RealSchur is not initialized.\");\n      return m_info;\n    }\n\n    /** \\brief Sets the maximum number of iterations allowed. \n      *\n      * If not specified by the user, the maximum number of iterations is m_maxIterationsPerRow times the size\n      * of the matrix.\n      */\n    RealSchur& setMaxIterations(Index maxIters)\n    {\n      m_maxIters = maxIters;\n      return *this;\n    }\n\n    /** \\brief Returns the maximum number of iterations. */\n    Index getMaxIterations()\n    {\n      return m_maxIters;\n    }\n\n    /** \\brief Maximum number of iterations per row.\n      *\n      * If not otherwise specified, the maximum number of iterations is this number times the size of the\n      * matrix. It is currently set to 40.\n      */\n    static const int m_maxIterationsPerRow = 40;\n\n  private:\n    \n    MatrixType m_matT;\n    MatrixType m_matU;\n    ColumnVectorType m_workspaceVector;\n    HessenbergDecomposition<MatrixType> m_hess;\n    ComputationInfo m_info;\n    bool m_isInitialized;\n    bool m_matUisUptodate;\n    Index m_maxIters;\n\n    typedef Matrix<Scalar,3,1> Vector3s;\n\n    Scalar computeNormOfT();\n    Index findSmallSubdiagEntry(Index iu);\n    void splitOffTwoRows(Index iu, bool computeU, const Scalar& exshift);\n    void computeShift(Index iu, Index iter, Scalar& exshift, Vector3s& shiftInfo);\n    void initFrancisQRStep(Index il, Index iu, const Vector3s& shiftInfo, Index& im, Vector3s& firstHouseholderVector);\n    void performFrancisQRStep(Index il, Index im, Index iu, bool computeU, const Vector3s& firstHouseholderVector, Scalar* workspace);\n};\n\n\ntemplate<typename MatrixType>\ntemplate<typename InputType>\nRealSchur<MatrixType>& RealSchur<MatrixType>::compute(const EigenBase<InputType>& matrix, bool computeU)\n{\n  const Scalar considerAsZero = (std::numeric_limits<Scalar>::min)();\n\n  eigen_assert(matrix.cols() == matrix.rows());\n  Index maxIters = m_maxIters;\n  if (maxIters == -1)\n    maxIters = m_maxIterationsPerRow * matrix.rows();\n\n  Scalar scale = matrix.derived().cwiseAbs().maxCoeff();\n  if(scale<considerAsZero)\n  {\n    m_matT.setZero(matrix.rows(),matrix.cols());\n    if(computeU)\n      m_matU.setIdentity(matrix.rows(),matrix.cols());\n    m_info = Success;\n    m_isInitialized = true;\n    m_matUisUptodate = computeU;\n    return *this;\n  }\n\n  // Step 1. Reduce to Hessenberg form\n  m_hess.compute(matrix.derived()/scale);\n\n  // Step 2. Reduce to real Schur form  \n  computeFromHessenberg(m_hess.matrixH(), m_hess.matrixQ(), computeU);\n\n  m_matT *= scale;\n  \n  return *this;\n}\ntemplate<typename MatrixType>\ntemplate<typename HessMatrixType, typename OrthMatrixType>\nRealSchur<MatrixType>& RealSchur<MatrixType>::computeFromHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ,  bool computeU)\n{\n  using std::abs;\n\n  m_matT = matrixH;\n  if(computeU)\n    m_matU = matrixQ;\n  \n  Index maxIters = m_maxIters;\n  if (maxIters == -1)\n    maxIters = m_maxIterationsPerRow * matrixH.rows();\n  m_workspaceVector.resize(m_matT.cols());\n  Scalar* workspace = &m_workspaceVector.coeffRef(0);\n\n  // The matrix m_matT is divided in three parts. \n  // Rows 0,...,il-1 are decoupled from the rest because m_matT(il,il-1) is zero. \n  // Rows il,...,iu is the part we are working on (the active window).\n  // Rows iu+1,...,end are already brought in triangular form.\n  Index iu = m_matT.cols() - 1;\n  Index iter = 0;      // iteration count for current eigenvalue\n  Index totalIter = 0; // iteration count for whole matrix\n  Scalar exshift(0);   // sum of exceptional shifts\n  Scalar norm = computeNormOfT();\n\n  if(norm!=0)\n  {\n    while (iu >= 0)\n    {\n      Index il = findSmallSubdiagEntry(iu);\n\n      // Check for convergence\n      if (il == iu) // One root found\n      {\n        m_matT.coeffRef(iu,iu) = m_matT.coeff(iu,iu) + exshift;\n        if (iu > 0)\n          m_matT.coeffRef(iu, iu-1) = Scalar(0);\n        iu--;\n        iter = 0;\n      }\n      else if (il == iu-1) // Two roots found\n      {\n        splitOffTwoRows(iu, computeU, exshift);\n        iu -= 2;\n        iter = 0;\n      }\n      else // No convergence yet\n      {\n        // The firstHouseholderVector vector has to be initialized to something to get rid of a silly GCC warning (-O1 -Wall -DNDEBUG )\n        Vector3s firstHouseholderVector(0,0,0), shiftInfo;\n        computeShift(iu, iter, exshift, shiftInfo);\n        iter = iter + 1;\n        totalIter = totalIter + 1;\n        if (totalIter > maxIters) break;\n        Index im;\n        initFrancisQRStep(il, iu, shiftInfo, im, firstHouseholderVector);\n        performFrancisQRStep(il, im, iu, computeU, firstHouseholderVector, workspace);\n      }\n    }\n  }\n  if(totalIter <= maxIters)\n    m_info = Success;\n  else\n    m_info = NoConvergence;\n\n  m_isInitialized = true;\n  m_matUisUptodate = computeU;\n  return *this;\n}\n\n/** \\internal Computes and returns vector L1 norm of T */\ntemplate<typename MatrixType>\ninline typename MatrixType::Scalar RealSchur<MatrixType>::computeNormOfT()\n{\n  const Index size = m_matT.cols();\n  // FIXME to be efficient the following would requires a triangular reduxion code\n  // Scalar norm = m_matT.upper().cwiseAbs().sum() \n  //               + m_matT.bottomLeftCorner(size-1,size-1).diagonal().cwiseAbs().sum();\n  Scalar norm(0);\n  for (Index j = 0; j < size; ++j)\n    norm += m_matT.col(j).segment(0, (std::min)(size,j+2)).cwiseAbs().sum();\n  return norm;\n}\n\n/** \\internal Look for single small sub-diagonal element and returns its index */\ntemplate<typename MatrixType>\ninline Index RealSchur<MatrixType>::findSmallSubdiagEntry(Index iu)\n{\n  using std::abs;\n  Index res = iu;\n  while (res > 0)\n  {\n    Scalar s = abs(m_matT.coeff(res-1,res-1)) + abs(m_matT.coeff(res,res));\n    if (abs(m_matT.coeff(res,res-1)) <= NumTraits<Scalar>::epsilon() * s)\n      break;\n    res--;\n  }\n  return res;\n}\n\n/** \\internal Update T given that rows iu-1 and iu decouple from the rest. */\ntemplate<typename MatrixType>\ninline void RealSchur<MatrixType>::splitOffTwoRows(Index iu, bool computeU, const Scalar& exshift)\n{\n  using std::sqrt;\n  using std::abs;\n  const Index size = m_matT.cols();\n\n  // The eigenvalues of the 2x2 matrix [a b; c d] are \n  // trace +/- sqrt(discr/4) where discr = tr^2 - 4*det, tr = a + d, det = ad - bc\n  Scalar p = Scalar(0.5) * (m_matT.coeff(iu-1,iu-1) - m_matT.coeff(iu,iu));\n  Scalar q = p * p + m_matT.coeff(iu,iu-1) * m_matT.coeff(iu-1,iu);   // q = tr^2 / 4 - det = discr/4\n  m_matT.coeffRef(iu,iu) += exshift;\n  m_matT.coeffRef(iu-1,iu-1) += exshift;\n\n  if (q >= Scalar(0)) // Two real eigenvalues\n  {\n    Scalar z = sqrt(abs(q));\n    JacobiRotation<Scalar> rot;\n    if (p >= Scalar(0))\n      rot.makeGivens(p + z, m_matT.coeff(iu, iu-1));\n    else\n      rot.makeGivens(p - z, m_matT.coeff(iu, iu-1));\n\n    m_matT.rightCols(size-iu+1).applyOnTheLeft(iu-1, iu, rot.adjoint());\n    m_matT.topRows(iu+1).applyOnTheRight(iu-1, iu, rot);\n    m_matT.coeffRef(iu, iu-1) = Scalar(0); \n    if (computeU)\n      m_matU.applyOnTheRight(iu-1, iu, rot);\n  }\n\n  if (iu > 1) \n    m_matT.coeffRef(iu-1, iu-2) = Scalar(0);\n}\n\n/** \\internal Form shift in shiftInfo, and update exshift if an exceptional shift is performed. */\ntemplate<typename MatrixType>\ninline void RealSchur<MatrixType>::computeShift(Index iu, Index iter, Scalar& exshift, Vector3s& shiftInfo)\n{\n  using std::sqrt;\n  using std::abs;\n  shiftInfo.coeffRef(0) = m_matT.coeff(iu,iu);\n  shiftInfo.coeffRef(1) = m_matT.coeff(iu-1,iu-1);\n  shiftInfo.coeffRef(2) = m_matT.coeff(iu,iu-1) * m_matT.coeff(iu-1,iu);\n\n  // Wilkinson's original ad hoc shift\n  if (iter == 10)\n  {\n    exshift += shiftInfo.coeff(0);\n    for (Index i = 0; i <= iu; ++i)\n      m_matT.coeffRef(i,i) -= shiftInfo.coeff(0);\n    Scalar s = abs(m_matT.coeff(iu,iu-1)) + abs(m_matT.coeff(iu-1,iu-2));\n    shiftInfo.coeffRef(0) = Scalar(0.75) * s;\n    shiftInfo.coeffRef(1) = Scalar(0.75) * s;\n    shiftInfo.coeffRef(2) = Scalar(-0.4375) * s * s;\n  }\n\n  // MATLAB's new ad hoc shift\n  if (iter == 30)\n  {\n    Scalar s = (shiftInfo.coeff(1) - shiftInfo.coeff(0)) / Scalar(2.0);\n    s = s * s + shiftInfo.coeff(2);\n    if (s > Scalar(0))\n    {\n      s = sqrt(s);\n      if (shiftInfo.coeff(1) < shiftInfo.coeff(0))\n        s = -s;\n      s = s + (shiftInfo.coeff(1) - shiftInfo.coeff(0)) / Scalar(2.0);\n      s = shiftInfo.coeff(0) - shiftInfo.coeff(2) / s;\n      exshift += s;\n      for (Index i = 0; i <= iu; ++i)\n        m_matT.coeffRef(i,i) -= s;\n      shiftInfo.setConstant(Scalar(0.964));\n    }\n  }\n}\n\n/** \\internal Compute index im at which Francis QR step starts and the first Householder vector. */\ntemplate<typename MatrixType>\ninline void RealSchur<MatrixType>::initFrancisQRStep(Index il, Index iu, const Vector3s& shiftInfo, Index& im, Vector3s& firstHouseholderVector)\n{\n  using std::abs;\n  Vector3s& v = firstHouseholderVector; // alias to save typing\n\n  for (im = iu-2; im >= il; --im)\n  {\n    const Scalar Tmm = m_matT.coeff(im,im);\n    const Scalar r = shiftInfo.coeff(0) - Tmm;\n    const Scalar s = shiftInfo.coeff(1) - Tmm;\n    v.coeffRef(0) = (r * s - shiftInfo.coeff(2)) / m_matT.coeff(im+1,im) + m_matT.coeff(im,im+1);\n    v.coeffRef(1) = m_matT.coeff(im+1,im+1) - Tmm - r - s;\n    v.coeffRef(2) = m_matT.coeff(im+2,im+1);\n    if (im == il) {\n      break;\n    }\n    const Scalar lhs = m_matT.coeff(im,im-1) * (abs(v.coeff(1)) + abs(v.coeff(2)));\n    const Scalar rhs = v.coeff(0) * (abs(m_matT.coeff(im-1,im-1)) + abs(Tmm) + abs(m_matT.coeff(im+1,im+1)));\n    if (abs(lhs) < NumTraits<Scalar>::epsilon() * rhs)\n      break;\n  }\n}\n\n/** \\internal Perform a Francis QR step involving rows il:iu and columns im:iu. */\ntemplate<typename MatrixType>\ninline void RealSchur<MatrixType>::performFrancisQRStep(Index il, Index im, Index iu, bool computeU, const Vector3s& firstHouseholderVector, Scalar* workspace)\n{\n  eigen_assert(im >= il);\n  eigen_assert(im <= iu-2);\n\n  const Index size = m_matT.cols();\n\n  for (Index k = im; k <= iu-2; ++k)\n  {\n    bool firstIteration = (k == im);\n\n    Vector3s v;\n    if (firstIteration)\n      v = firstHouseholderVector;\n    else\n      v = m_matT.template block<3,1>(k,k-1);\n\n    Scalar tau, beta;\n    Matrix<Scalar, 2, 1> ess;\n    v.makeHouseholder(ess, tau, beta);\n    \n    if (beta != Scalar(0)) // if v is not zero\n    {\n      if (firstIteration && k > il)\n        m_matT.coeffRef(k,k-1) = -m_matT.coeff(k,k-1);\n      else if (!firstIteration)\n        m_matT.coeffRef(k,k-1) = beta;\n\n      // These Householder transformations form the O(n^3) part of the algorithm\n      m_matT.block(k, k, 3, size-k).applyHouseholderOnTheLeft(ess, tau, workspace);\n      m_matT.block(0, k, (std::min)(iu,k+3) + 1, 3).applyHouseholderOnTheRight(ess, tau, workspace);\n      if (computeU)\n        m_matU.block(0, k, size, 3).applyHouseholderOnTheRight(ess, tau, workspace);\n    }\n  }\n\n  Matrix<Scalar, 2, 1> v = m_matT.template block<2,1>(iu-1, iu-2);\n  Scalar tau, beta;\n  Matrix<Scalar, 1, 1> ess;\n  v.makeHouseholder(ess, tau, beta);\n\n  if (beta != Scalar(0)) // if v is not zero\n  {\n    m_matT.coeffRef(iu-1, iu-2) = beta;\n    m_matT.block(iu-1, iu-1, 2, size-iu+1).applyHouseholderOnTheLeft(ess, tau, workspace);\n    m_matT.block(0, iu-1, iu+1, 2).applyHouseholderOnTheRight(ess, tau, workspace);\n    if (computeU)\n      m_matU.block(0, iu-1, size, 2).applyHouseholderOnTheRight(ess, tau, workspace);\n  }\n\n  // clean up pollution due to round-off errors\n  for (Index i = im+2; i <= iu; ++i)\n  {\n    m_matT.coeffRef(i,i-2) = Scalar(0);\n    if (i > im+2)\n      m_matT.coeffRef(i,i-3) = Scalar(0);\n  }\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_REAL_SCHUR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to LAPACKe\n *    Real Schur needed to real unsymmetrical eigenvalues/eigenvectors.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_REAL_SCHUR_LAPACKE_H\n#define EIGEN_REAL_SCHUR_LAPACKE_H\n\nnamespace Eigen { \n\n/** \\internal Specialization for the data types supported by LAPACKe */\n\n#define EIGEN_LAPACKE_SCHUR_REAL(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX, LAPACKE_PREFIX_U, EIGCOLROW, LAPACKE_COLROW) \\\ntemplate<> template<typename InputType> inline \\\nRealSchur<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >& \\\nRealSchur<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >::compute(const EigenBase<InputType>& matrix, bool computeU) \\\n{ \\\n  eigen_assert(matrix.cols() == matrix.rows()); \\\n\\\n  lapack_int n = internal::convert_index<lapack_int>(matrix.cols()), sdim, info; \\\n  lapack_int matrix_order = LAPACKE_COLROW; \\\n  char jobvs, sort='N'; \\\n  LAPACK_##LAPACKE_PREFIX_U##_SELECT2 select = 0; \\\n  jobvs = (computeU) ? 'V' : 'N'; \\\n  m_matU.resize(n, n); \\\n  lapack_int ldvs  = internal::convert_index<lapack_int>(m_matU.outerStride()); \\\n  m_matT = matrix; \\\n  lapack_int lda = internal::convert_index<lapack_int>(m_matT.outerStride()); \\\n  Matrix<EIGTYPE, Dynamic, Dynamic> wr, wi; \\\n  wr.resize(n, 1); wi.resize(n, 1); \\\n  info = LAPACKE_##LAPACKE_PREFIX##gees( matrix_order, jobvs, sort, select, n, (LAPACKE_TYPE*)m_matT.data(), lda, &sdim, (LAPACKE_TYPE*)wr.data(), (LAPACKE_TYPE*)wi.data(), (LAPACKE_TYPE*)m_matU.data(), ldvs ); \\\n  if(info == 0) \\\n    m_info = Success; \\\n  else \\\n    m_info = NoConvergence; \\\n\\\n  m_isInitialized = true; \\\n  m_matUisUptodate = computeU; \\\n  return *this; \\\n\\\n}\n\nEIGEN_LAPACKE_SCHUR_REAL(double,   double, d, D, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_SCHUR_REAL(float,    float,  s, S, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_SCHUR_REAL(double,   double, d, D, RowMajor, LAPACK_ROW_MAJOR)\nEIGEN_LAPACKE_SCHUR_REAL(float,    float,  s, S, RowMajor, LAPACK_ROW_MAJOR)\n\n} // end namespace Eigen\n\n#endif // EIGEN_REAL_SCHUR_LAPACKE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SELFADJOINTEIGENSOLVER_H\n#define EIGEN_SELFADJOINTEIGENSOLVER_H\n\n#include \"./Tridiagonalization.h\"\n\nnamespace Eigen { \n\ntemplate<typename _MatrixType>\nclass GeneralizedSelfAdjointEigenSolver;\n\nnamespace internal {\ntemplate<typename SolverType,int Size,bool IsComplex> struct direct_selfadjoint_eigenvalues;\ntemplate<typename MatrixType, typename DiagType, typename SubDiagType>\nComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag, const Index maxIterations, bool computeEigenvectors, MatrixType& eivec);\n}\n\n/** \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  *\n  * \\class SelfAdjointEigenSolver\n  *\n  * \\brief Computes eigenvalues and eigenvectors of selfadjoint matrices\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the\n  * eigendecomposition; this is expected to be an instantiation of the Matrix\n  * class template.\n  *\n  * A matrix \\f$ A \\f$ is selfadjoint if it equals its adjoint. For real\n  * matrices, this means that the matrix is symmetric: it equals its\n  * transpose. This class computes the eigenvalues and eigenvectors of a\n  * selfadjoint matrix. These are the scalars \\f$ \\lambda \\f$ and vectors\n  * \\f$ v \\f$ such that \\f$ Av = \\lambda v \\f$.  The eigenvalues of a\n  * selfadjoint matrix are always real. If \\f$ D \\f$ is a diagonal matrix with\n  * the eigenvalues on the diagonal, and \\f$ V \\f$ is a matrix with the\n  * eigenvectors as its columns, then \\f$ A = V D V^{-1} \\f$ (for selfadjoint\n  * matrices, the matrix \\f$ V \\f$ is always invertible). This is called the\n  * eigendecomposition.\n  *\n  * The algorithm exploits the fact that the matrix is selfadjoint, making it\n  * faster and more accurate than the general purpose eigenvalue algorithms\n  * implemented in EigenSolver and ComplexEigenSolver.\n  *\n  * Only the \\b lower \\b triangular \\b part of the input matrix is referenced.\n  *\n  * Call the function compute() to compute the eigenvalues and eigenvectors of\n  * a given matrix. Alternatively, you can use the\n  * SelfAdjointEigenSolver(const MatrixType&, int) constructor which computes\n  * the eigenvalues and eigenvectors at construction time. Once the eigenvalue\n  * and eigenvectors are computed, they can be retrieved with the eigenvalues()\n  * and eigenvectors() functions.\n  *\n  * The documentation for SelfAdjointEigenSolver(const MatrixType&, int)\n  * contains an example of the typical use of this class.\n  *\n  * To solve the \\em generalized eigenvalue problem \\f$ Av = \\lambda Bv \\f$ and\n  * the likes, see the class GeneralizedSelfAdjointEigenSolver.\n  *\n  * \\sa MatrixBase::eigenvalues(), class EigenSolver, class ComplexEigenSolver\n  */\ntemplate<typename _MatrixType> class SelfAdjointEigenSolver\n{\n  public:\n\n    typedef _MatrixType MatrixType;\n    enum {\n      Size = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      Options = MatrixType::Options,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n    \n    /** \\brief Scalar type for matrices of type \\p _MatrixType. */\n    typedef typename MatrixType::Scalar Scalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n    \n    typedef Matrix<Scalar,Size,Size,ColMajor,MaxColsAtCompileTime,MaxColsAtCompileTime> EigenvectorsType;\n\n    /** \\brief Real scalar type for \\p _MatrixType.\n      *\n      * This is just \\c Scalar if #Scalar is real (e.g., \\c float or\n      * \\c double), and the type of the real part of \\c Scalar if #Scalar is\n      * complex.\n      */\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    \n    friend struct internal::direct_selfadjoint_eigenvalues<SelfAdjointEigenSolver,Size,NumTraits<Scalar>::IsComplex>;\n\n    /** \\brief Type for vector of eigenvalues as returned by eigenvalues().\n      *\n      * This is a column vector with entries of type #RealScalar.\n      * The length of the vector is the size of \\p _MatrixType.\n      */\n    typedef typename internal::plain_col_type<MatrixType, RealScalar>::type RealVectorType;\n    typedef Tridiagonalization<MatrixType> TridiagonalizationType;\n    typedef typename TridiagonalizationType::SubDiagonalType SubDiagonalType;\n\n    /** \\brief Default constructor for fixed-size matrices.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via compute(). This constructor\n      * can only be used if \\p _MatrixType is a fixed-size matrix; use\n      * SelfAdjointEigenSolver(Index) for dynamic-size matrices.\n      *\n      * Example: \\include SelfAdjointEigenSolver_SelfAdjointEigenSolver.cpp\n      * Output: \\verbinclude SelfAdjointEigenSolver_SelfAdjointEigenSolver.out\n      */\n    EIGEN_DEVICE_FUNC\n    SelfAdjointEigenSolver()\n        : m_eivec(),\n          m_eivalues(),\n          m_subdiag(),\n          m_isInitialized(false)\n    { }\n\n    /** \\brief Constructor, pre-allocates memory for dynamic-size matrices.\n      *\n      * \\param [in]  size  Positive integer, size of the matrix whose\n      * eigenvalues and eigenvectors will be computed.\n      *\n      * This constructor is useful for dynamic-size matrices, when the user\n      * intends to perform decompositions via compute(). The \\p size\n      * parameter is only used as a hint. It is not an error to give a wrong\n      * \\p size, but it may impair performance.\n      *\n      * \\sa compute() for an example\n      */\n    EIGEN_DEVICE_FUNC\n    explicit SelfAdjointEigenSolver(Index size)\n        : m_eivec(size, size),\n          m_eivalues(size),\n          m_subdiag(size > 1 ? size - 1 : 1),\n          m_isInitialized(false)\n    {}\n\n    /** \\brief Constructor; computes eigendecomposition of given matrix.\n      *\n      * \\param[in]  matrix  Selfadjoint matrix whose eigendecomposition is to\n      *    be computed. Only the lower triangular part of the matrix is referenced.\n      * \\param[in]  options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.\n      *\n      * This constructor calls compute(const MatrixType&, int) to compute the\n      * eigenvalues of the matrix \\p matrix. The eigenvectors are computed if\n      * \\p options equals #ComputeEigenvectors.\n      *\n      * Example: \\include SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.cpp\n      * Output: \\verbinclude SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.out\n      *\n      * \\sa compute(const MatrixType&, int)\n      */\n    template<typename InputType>\n    EIGEN_DEVICE_FUNC\n    explicit SelfAdjointEigenSolver(const EigenBase<InputType>& matrix, int options = ComputeEigenvectors)\n      : m_eivec(matrix.rows(), matrix.cols()),\n        m_eivalues(matrix.cols()),\n        m_subdiag(matrix.rows() > 1 ? matrix.rows() - 1 : 1),\n        m_isInitialized(false)\n    {\n      compute(matrix.derived(), options);\n    }\n\n    /** \\brief Computes eigendecomposition of given matrix.\n      *\n      * \\param[in]  matrix  Selfadjoint matrix whose eigendecomposition is to\n      *    be computed. Only the lower triangular part of the matrix is referenced.\n      * \\param[in]  options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.\n      * \\returns    Reference to \\c *this\n      *\n      * This function computes the eigenvalues of \\p matrix.  The eigenvalues()\n      * function can be used to retrieve them.  If \\p options equals #ComputeEigenvectors,\n      * then the eigenvectors are also computed and can be retrieved by\n      * calling eigenvectors().\n      *\n      * This implementation uses a symmetric QR algorithm. The matrix is first\n      * reduced to tridiagonal form using the Tridiagonalization class. The\n      * tridiagonal matrix is then brought to diagonal form with implicit\n      * symmetric QR steps with Wilkinson shift. Details can be found in\n      * Section 8.3 of Golub \\& Van Loan, <i>%Matrix Computations</i>.\n      *\n      * The cost of the computation is about \\f$ 9n^3 \\f$ if the eigenvectors\n      * are required and \\f$ 4n^3/3 \\f$ if they are not required.\n      *\n      * This method reuses the memory in the SelfAdjointEigenSolver object that\n      * was allocated when the object was constructed, if the size of the\n      * matrix does not change.\n      *\n      * Example: \\include SelfAdjointEigenSolver_compute_MatrixType.cpp\n      * Output: \\verbinclude SelfAdjointEigenSolver_compute_MatrixType.out\n      *\n      * \\sa SelfAdjointEigenSolver(const MatrixType&, int)\n      */\n    template<typename InputType>\n    EIGEN_DEVICE_FUNC\n    SelfAdjointEigenSolver& compute(const EigenBase<InputType>& matrix, int options = ComputeEigenvectors);\n    \n    /** \\brief Computes eigendecomposition of given matrix using a closed-form algorithm\n      *\n      * This is a variant of compute(const MatrixType&, int options) which\n      * directly solves the underlying polynomial equation.\n      * \n      * Currently only 2x2 and 3x3 matrices for which the sizes are known at compile time are supported (e.g., Matrix3d).\n      * \n      * This method is usually significantly faster than the QR iterative algorithm\n      * but it might also be less accurate. It is also worth noting that\n      * for 3x3 matrices it involves trigonometric operations which are\n      * not necessarily available for all scalar types.\n      * \n      * For the 3x3 case, we observed the following worst case relative error regarding the eigenvalues:\n      *   - double: 1e-8\n      *   - float:  1e-3\n      *\n      * \\sa compute(const MatrixType&, int options)\n      */\n    EIGEN_DEVICE_FUNC\n    SelfAdjointEigenSolver& computeDirect(const MatrixType& matrix, int options = ComputeEigenvectors);\n\n    /**\n      *\\brief Computes the eigen decomposition from a tridiagonal symmetric matrix\n      *\n      * \\param[in] diag The vector containing the diagonal of the matrix.\n      * \\param[in] subdiag The subdiagonal of the matrix.\n      * \\param[in] options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.\n      * \\returns Reference to \\c *this\n      *\n      * This function assumes that the matrix has been reduced to tridiagonal form.\n      *\n      * \\sa compute(const MatrixType&, int) for more information\n      */\n    SelfAdjointEigenSolver& computeFromTridiagonal(const RealVectorType& diag, const SubDiagonalType& subdiag , int options=ComputeEigenvectors);\n\n    /** \\brief Returns the eigenvectors of given matrix.\n      *\n      * \\returns  A const reference to the matrix whose columns are the eigenvectors.\n      *\n      * \\pre The eigenvectors have been computed before.\n      *\n      * Column \\f$ k \\f$ of the returned matrix is an eigenvector corresponding\n      * to eigenvalue number \\f$ k \\f$ as returned by eigenvalues().  The\n      * eigenvectors are normalized to have (Euclidean) norm equal to one. If\n      * this object was used to solve the eigenproblem for the selfadjoint\n      * matrix \\f$ A \\f$, then the matrix returned by this function is the\n      * matrix \\f$ V \\f$ in the eigendecomposition \\f$ A = V D V^{-1} \\f$.\n      *\n      * Example: \\include SelfAdjointEigenSolver_eigenvectors.cpp\n      * Output: \\verbinclude SelfAdjointEigenSolver_eigenvectors.out\n      *\n      * \\sa eigenvalues()\n      */\n    EIGEN_DEVICE_FUNC\n    const EigenvectorsType& eigenvectors() const\n    {\n      eigen_assert(m_isInitialized && \"SelfAdjointEigenSolver is not initialized.\");\n      eigen_assert(m_eigenvectorsOk && \"The eigenvectors have not been computed together with the eigenvalues.\");\n      return m_eivec;\n    }\n\n    /** \\brief Returns the eigenvalues of given matrix.\n      *\n      * \\returns A const reference to the column vector containing the eigenvalues.\n      *\n      * \\pre The eigenvalues have been computed before.\n      *\n      * The eigenvalues are repeated according to their algebraic multiplicity,\n      * so there are as many eigenvalues as rows in the matrix. The eigenvalues\n      * are sorted in increasing order.\n      *\n      * Example: \\include SelfAdjointEigenSolver_eigenvalues.cpp\n      * Output: \\verbinclude SelfAdjointEigenSolver_eigenvalues.out\n      *\n      * \\sa eigenvectors(), MatrixBase::eigenvalues()\n      */\n    EIGEN_DEVICE_FUNC\n    const RealVectorType& eigenvalues() const\n    {\n      eigen_assert(m_isInitialized && \"SelfAdjointEigenSolver is not initialized.\");\n      return m_eivalues;\n    }\n\n    /** \\brief Computes the positive-definite square root of the matrix.\n      *\n      * \\returns the positive-definite square root of the matrix\n      *\n      * \\pre The eigenvalues and eigenvectors of a positive-definite matrix\n      * have been computed before.\n      *\n      * The square root of a positive-definite matrix \\f$ A \\f$ is the\n      * positive-definite matrix whose square equals \\f$ A \\f$. This function\n      * uses the eigendecomposition \\f$ A = V D V^{-1} \\f$ to compute the\n      * square root as \\f$ A^{1/2} = V D^{1/2} V^{-1} \\f$.\n      *\n      * Example: \\include SelfAdjointEigenSolver_operatorSqrt.cpp\n      * Output: \\verbinclude SelfAdjointEigenSolver_operatorSqrt.out\n      *\n      * \\sa operatorInverseSqrt(), <a href=\"unsupported/group__MatrixFunctions__Module.html\">MatrixFunctions Module</a>\n      */\n    EIGEN_DEVICE_FUNC\n    MatrixType operatorSqrt() const\n    {\n      eigen_assert(m_isInitialized && \"SelfAdjointEigenSolver is not initialized.\");\n      eigen_assert(m_eigenvectorsOk && \"The eigenvectors have not been computed together with the eigenvalues.\");\n      return m_eivec * m_eivalues.cwiseSqrt().asDiagonal() * m_eivec.adjoint();\n    }\n\n    /** \\brief Computes the inverse square root of the matrix.\n      *\n      * \\returns the inverse positive-definite square root of the matrix\n      *\n      * \\pre The eigenvalues and eigenvectors of a positive-definite matrix\n      * have been computed before.\n      *\n      * This function uses the eigendecomposition \\f$ A = V D V^{-1} \\f$ to\n      * compute the inverse square root as \\f$ V D^{-1/2} V^{-1} \\f$. This is\n      * cheaper than first computing the square root with operatorSqrt() and\n      * then its inverse with MatrixBase::inverse().\n      *\n      * Example: \\include SelfAdjointEigenSolver_operatorInverseSqrt.cpp\n      * Output: \\verbinclude SelfAdjointEigenSolver_operatorInverseSqrt.out\n      *\n      * \\sa operatorSqrt(), MatrixBase::inverse(), <a href=\"unsupported/group__MatrixFunctions__Module.html\">MatrixFunctions Module</a>\n      */\n    EIGEN_DEVICE_FUNC\n    MatrixType operatorInverseSqrt() const\n    {\n      eigen_assert(m_isInitialized && \"SelfAdjointEigenSolver is not initialized.\");\n      eigen_assert(m_eigenvectorsOk && \"The eigenvectors have not been computed together with the eigenvalues.\");\n      return m_eivec * m_eivalues.cwiseInverse().cwiseSqrt().asDiagonal() * m_eivec.adjoint();\n    }\n\n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful, \\c NoConvergence otherwise.\n      */\n    EIGEN_DEVICE_FUNC\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"SelfAdjointEigenSolver is not initialized.\");\n      return m_info;\n    }\n\n    /** \\brief Maximum number of iterations.\n      *\n      * The algorithm terminates if it does not converge within m_maxIterations * n iterations, where n\n      * denotes the size of the matrix. This value is currently set to 30 (copied from LAPACK).\n      */\n    static const int m_maxIterations = 30;\n\n  protected:\n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n    }\n    \n    EigenvectorsType m_eivec;\n    RealVectorType m_eivalues;\n    typename TridiagonalizationType::SubDiagonalType m_subdiag;\n    ComputationInfo m_info;\n    bool m_isInitialized;\n    bool m_eigenvectorsOk;\n};\n\nnamespace internal {\n/** \\internal\n  *\n  * \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  * Performs a QR step on a tridiagonal symmetric matrix represented as a\n  * pair of two vectors \\a diag and \\a subdiag.\n  *\n  * \\param diag the diagonal part of the input selfadjoint tridiagonal matrix\n  * \\param subdiag the sub-diagonal part of the input selfadjoint tridiagonal matrix\n  * \\param start starting index of the submatrix to work on\n  * \\param end last+1 index of the submatrix to work on\n  * \\param matrixQ pointer to the column-major matrix holding the eigenvectors, can be 0\n  * \\param n size of the input matrix\n  *\n  * For compilation efficiency reasons, this procedure does not use eigen expression\n  * for its arguments.\n  *\n  * Implemented from Golub's \"Matrix Computations\", algorithm 8.3.2:\n  * \"implicit symmetric QR step with Wilkinson shift\"\n  */\ntemplate<int StorageOrder,typename RealScalar, typename Scalar, typename Index>\nEIGEN_DEVICE_FUNC\nstatic void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end, Scalar* matrixQ, Index n);\n}\n\ntemplate<typename MatrixType>\ntemplate<typename InputType>\nEIGEN_DEVICE_FUNC\nSelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>\n::compute(const EigenBase<InputType>& a_matrix, int options)\n{\n  check_template_parameters();\n  \n  const InputType &matrix(a_matrix.derived());\n  \n  using std::abs;\n  eigen_assert(matrix.cols() == matrix.rows());\n  eigen_assert((options&~(EigVecMask|GenEigMask))==0\n          && (options&EigVecMask)!=EigVecMask\n          && \"invalid option parameter\");\n  bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;\n  Index n = matrix.cols();\n  m_eivalues.resize(n,1);\n\n  if(n==1)\n  {\n    m_eivec = matrix;\n    m_eivalues.coeffRef(0,0) = numext::real(m_eivec.coeff(0,0));\n    if(computeEigenvectors)\n      m_eivec.setOnes(n,n);\n    m_info = Success;\n    m_isInitialized = true;\n    m_eigenvectorsOk = computeEigenvectors;\n    return *this;\n  }\n\n  // declare some aliases\n  RealVectorType& diag = m_eivalues;\n  EigenvectorsType& mat = m_eivec;\n\n  // map the matrix coefficients to [-1:1] to avoid over- and underflow.\n  mat = matrix.template triangularView<Lower>();\n  RealScalar scale = mat.cwiseAbs().maxCoeff();\n  if(scale==RealScalar(0)) scale = RealScalar(1);\n  mat.template triangularView<Lower>() /= scale;\n  m_subdiag.resize(n-1);\n  internal::tridiagonalization_inplace(mat, diag, m_subdiag, computeEigenvectors);\n\n  m_info = internal::computeFromTridiagonal_impl(diag, m_subdiag, m_maxIterations, computeEigenvectors, m_eivec);\n  \n  // scale back the eigen values\n  m_eivalues *= scale;\n\n  m_isInitialized = true;\n  m_eigenvectorsOk = computeEigenvectors;\n  return *this;\n}\n\ntemplate<typename MatrixType>\nSelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>\n::computeFromTridiagonal(const RealVectorType& diag, const SubDiagonalType& subdiag , int options)\n{\n  //TODO : Add an option to scale the values beforehand\n  bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;\n\n  m_eivalues = diag;\n  m_subdiag = subdiag;\n  if (computeEigenvectors)\n  {\n    m_eivec.setIdentity(diag.size(), diag.size());\n  }\n  m_info = internal::computeFromTridiagonal_impl(m_eivalues, m_subdiag, m_maxIterations, computeEigenvectors, m_eivec);\n\n  m_isInitialized = true;\n  m_eigenvectorsOk = computeEigenvectors;\n  return *this;\n}\n\nnamespace internal {\n/**\n  * \\internal\n  * \\brief Compute the eigendecomposition from a tridiagonal matrix\n  *\n  * \\param[in,out] diag : On input, the diagonal of the matrix, on output the eigenvalues\n  * \\param[in,out] subdiag : The subdiagonal part of the matrix (entries are modified during the decomposition)\n  * \\param[in] maxIterations : the maximum number of iterations\n  * \\param[in] computeEigenvectors : whether the eigenvectors have to be computed or not\n  * \\param[out] eivec : The matrix to store the eigenvectors if computeEigenvectors==true. Must be allocated on input.\n  * \\returns \\c Success or \\c NoConvergence\n  */\ntemplate<typename MatrixType, typename DiagType, typename SubDiagType>\nComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag, const Index maxIterations, bool computeEigenvectors, MatrixType& eivec)\n{\n  using std::abs;\n\n  ComputationInfo info;\n  typedef typename MatrixType::Scalar Scalar;\n\n  Index n = diag.size();\n  Index end = n-1;\n  Index start = 0;\n  Index iter = 0; // total number of iterations\n  \n  typedef typename DiagType::RealScalar RealScalar;\n  const RealScalar considerAsZero = (std::numeric_limits<RealScalar>::min)();\n  const RealScalar precision = RealScalar(2)*NumTraits<RealScalar>::epsilon();\n  \n  while (end>0)\n  {\n    for (Index i = start; i<end; ++i)\n      if (internal::isMuchSmallerThan(abs(subdiag[i]),(abs(diag[i])+abs(diag[i+1])),precision) || abs(subdiag[i]) <= considerAsZero)\n        subdiag[i] = 0;\n\n    // find the largest unreduced block\n    while (end>0 && subdiag[end-1]==RealScalar(0))\n    {\n      end--;\n    }\n    if (end<=0)\n      break;\n\n    // if we spent too many iterations, we give up\n    iter++;\n    if(iter > maxIterations * n) break;\n\n    start = end - 1;\n    while (start>0 && subdiag[start-1]!=0)\n      start--;\n\n    internal::tridiagonal_qr_step<MatrixType::Flags&RowMajorBit ? RowMajor : ColMajor>(diag.data(), subdiag.data(), start, end, computeEigenvectors ? eivec.data() : (Scalar*)0, n);\n  }\n  if (iter <= maxIterations * n)\n    info = Success;\n  else\n    info = NoConvergence;\n\n  // Sort eigenvalues and corresponding vectors.\n  // TODO make the sort optional ?\n  // TODO use a better sort algorithm !!\n  if (info == Success)\n  {\n    for (Index i = 0; i < n-1; ++i)\n    {\n      Index k;\n      diag.segment(i,n-i).minCoeff(&k);\n      if (k > 0)\n      {\n        std::swap(diag[i], diag[k+i]);\n        if(computeEigenvectors)\n          eivec.col(i).swap(eivec.col(k+i));\n      }\n    }\n  }\n  return info;\n}\n  \ntemplate<typename SolverType,int Size,bool IsComplex> struct direct_selfadjoint_eigenvalues\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(SolverType& eig, const typename SolverType::MatrixType& A, int options)\n  { eig.compute(A,options); }\n};\n\ntemplate<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3,false>\n{\n  typedef typename SolverType::MatrixType MatrixType;\n  typedef typename SolverType::RealVectorType VectorType;\n  typedef typename SolverType::Scalar Scalar;\n  typedef typename SolverType::EigenvectorsType EigenvectorsType;\n  \n\n  /** \\internal\n   * Computes the roots of the characteristic polynomial of \\a m.\n   * For numerical stability m.trace() should be near zero and to avoid over- or underflow m should be normalized.\n   */\n  EIGEN_DEVICE_FUNC\n  static inline void computeRoots(const MatrixType& m, VectorType& roots)\n  {\n    EIGEN_USING_STD_MATH(sqrt)\n    EIGEN_USING_STD_MATH(atan2)\n    EIGEN_USING_STD_MATH(cos)\n    EIGEN_USING_STD_MATH(sin)\n    const Scalar s_inv3 = Scalar(1)/Scalar(3);\n    const Scalar s_sqrt3 = sqrt(Scalar(3));\n\n    // The characteristic equation is x^3 - c2*x^2 + c1*x - c0 = 0.  The\n    // eigenvalues are the roots to this equation, all guaranteed to be\n    // real-valued, because the matrix is symmetric.\n    Scalar c0 = m(0,0)*m(1,1)*m(2,2) + Scalar(2)*m(1,0)*m(2,0)*m(2,1) - m(0,0)*m(2,1)*m(2,1) - m(1,1)*m(2,0)*m(2,0) - m(2,2)*m(1,0)*m(1,0);\n    Scalar c1 = m(0,0)*m(1,1) - m(1,0)*m(1,0) + m(0,0)*m(2,2) - m(2,0)*m(2,0) + m(1,1)*m(2,2) - m(2,1)*m(2,1);\n    Scalar c2 = m(0,0) + m(1,1) + m(2,2);\n\n    // Construct the parameters used in classifying the roots of the equation\n    // and in solving the equation for the roots in closed form.\n    Scalar c2_over_3 = c2*s_inv3;\n    Scalar a_over_3 = (c2*c2_over_3 - c1)*s_inv3;\n    a_over_3 = numext::maxi(a_over_3, Scalar(0));\n\n    Scalar half_b = Scalar(0.5)*(c0 + c2_over_3*(Scalar(2)*c2_over_3*c2_over_3 - c1));\n\n    Scalar q = a_over_3*a_over_3*a_over_3 - half_b*half_b;\n    q = numext::maxi(q, Scalar(0));\n\n    // Compute the eigenvalues by solving for the roots of the polynomial.\n    Scalar rho = sqrt(a_over_3);\n    Scalar theta = atan2(sqrt(q),half_b)*s_inv3;  // since sqrt(q) > 0, atan2 is in [0, pi] and theta is in [0, pi/3]\n    Scalar cos_theta = cos(theta);\n    Scalar sin_theta = sin(theta);\n    // roots are already sorted, since cos is monotonically decreasing on [0, pi]\n    roots(0) = c2_over_3 - rho*(cos_theta + s_sqrt3*sin_theta); // == 2*rho*cos(theta+2pi/3)\n    roots(1) = c2_over_3 - rho*(cos_theta - s_sqrt3*sin_theta); // == 2*rho*cos(theta+ pi/3)\n    roots(2) = c2_over_3 + Scalar(2)*rho*cos_theta;\n  }\n\n  EIGEN_DEVICE_FUNC\n  static inline bool extract_kernel(MatrixType& mat, Ref<VectorType> res, Ref<VectorType> representative)\n  {\n    using std::abs;\n    Index i0;\n    // Find non-zero column i0 (by construction, there must exist a non zero coefficient on the diagonal):\n    mat.diagonal().cwiseAbs().maxCoeff(&i0);\n    // mat.col(i0) is a good candidate for an orthogonal vector to the current eigenvector,\n    // so let's save it:\n    representative = mat.col(i0);\n    Scalar n0, n1;\n    VectorType c0, c1;\n    n0 = (c0 = representative.cross(mat.col((i0+1)%3))).squaredNorm();\n    n1 = (c1 = representative.cross(mat.col((i0+2)%3))).squaredNorm();\n    if(n0>n1) res = c0/std::sqrt(n0);\n    else      res = c1/std::sqrt(n1);\n\n    return true;\n  }\n\n  EIGEN_DEVICE_FUNC\n  static inline void run(SolverType& solver, const MatrixType& mat, int options)\n  {\n    eigen_assert(mat.cols() == 3 && mat.cols() == mat.rows());\n    eigen_assert((options&~(EigVecMask|GenEigMask))==0\n            && (options&EigVecMask)!=EigVecMask\n            && \"invalid option parameter\");\n    bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;\n    \n    EigenvectorsType& eivecs = solver.m_eivec;\n    VectorType& eivals = solver.m_eivalues;\n  \n    // Shift the matrix to the mean eigenvalue and map the matrix coefficients to [-1:1] to avoid over- and underflow.\n    Scalar shift = mat.trace() / Scalar(3);\n    // TODO Avoid this copy. Currently it is necessary to suppress bogus values when determining maxCoeff and for computing the eigenvectors later\n    MatrixType scaledMat = mat.template selfadjointView<Lower>();\n    scaledMat.diagonal().array() -= shift;\n    Scalar scale = scaledMat.cwiseAbs().maxCoeff();\n    if(scale > 0) scaledMat /= scale;   // TODO for scale==0 we could save the remaining operations\n\n    // compute the eigenvalues\n    computeRoots(scaledMat,eivals);\n\n    // compute the eigenvectors\n    if(computeEigenvectors)\n    {\n      if((eivals(2)-eivals(0))<=Eigen::NumTraits<Scalar>::epsilon())\n      {\n        // All three eigenvalues are numerically the same\n        eivecs.setIdentity();\n      }\n      else\n      {\n        MatrixType tmp;\n        tmp = scaledMat;\n\n        // Compute the eigenvector of the most distinct eigenvalue\n        Scalar d0 = eivals(2) - eivals(1);\n        Scalar d1 = eivals(1) - eivals(0);\n        Index k(0), l(2);\n        if(d0 > d1)\n        {\n          numext::swap(k,l);\n          d0 = d1;\n        }\n\n        // Compute the eigenvector of index k\n        {\n          tmp.diagonal().array () -= eivals(k);\n          // By construction, 'tmp' is of rank 2, and its kernel corresponds to the respective eigenvector.\n          extract_kernel(tmp, eivecs.col(k), eivecs.col(l));\n        }\n\n        // Compute eigenvector of index l\n        if(d0<=2*Eigen::NumTraits<Scalar>::epsilon()*d1)\n        {\n          // If d0 is too small, then the two other eigenvalues are numerically the same,\n          // and thus we only have to ortho-normalize the near orthogonal vector we saved above.\n          eivecs.col(l) -= eivecs.col(k).dot(eivecs.col(l))*eivecs.col(l);\n          eivecs.col(l).normalize();\n        }\n        else\n        {\n          tmp = scaledMat;\n          tmp.diagonal().array () -= eivals(l);\n\n          VectorType dummy;\n          extract_kernel(tmp, eivecs.col(l), dummy);\n        }\n\n        // Compute last eigenvector from the other two\n        eivecs.col(1) = eivecs.col(2).cross(eivecs.col(0)).normalized();\n      }\n    }\n\n    // Rescale back to the original size.\n    eivals *= scale;\n    eivals.array() += shift;\n    \n    solver.m_info = Success;\n    solver.m_isInitialized = true;\n    solver.m_eigenvectorsOk = computeEigenvectors;\n  }\n};\n\n// 2x2 direct eigenvalues decomposition, code from Hauke Heibel\ntemplate<typename SolverType> \nstruct direct_selfadjoint_eigenvalues<SolverType,2,false>\n{\n  typedef typename SolverType::MatrixType MatrixType;\n  typedef typename SolverType::RealVectorType VectorType;\n  typedef typename SolverType::Scalar Scalar;\n  typedef typename SolverType::EigenvectorsType EigenvectorsType;\n  \n  EIGEN_DEVICE_FUNC\n  static inline void computeRoots(const MatrixType& m, VectorType& roots)\n  {\n    using std::sqrt;\n    const Scalar t0 = Scalar(0.5) * sqrt( numext::abs2(m(0,0)-m(1,1)) + Scalar(4)*numext::abs2(m(1,0)));\n    const Scalar t1 = Scalar(0.5) * (m(0,0) + m(1,1));\n    roots(0) = t1 - t0;\n    roots(1) = t1 + t0;\n  }\n  \n  EIGEN_DEVICE_FUNC\n  static inline void run(SolverType& solver, const MatrixType& mat, int options)\n  {\n    EIGEN_USING_STD_MATH(sqrt);\n    EIGEN_USING_STD_MATH(abs);\n    \n    eigen_assert(mat.cols() == 2 && mat.cols() == mat.rows());\n    eigen_assert((options&~(EigVecMask|GenEigMask))==0\n            && (options&EigVecMask)!=EigVecMask\n            && \"invalid option parameter\");\n    bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;\n    \n    EigenvectorsType& eivecs = solver.m_eivec;\n    VectorType& eivals = solver.m_eivalues;\n  \n    // Shift the matrix to the mean eigenvalue and map the matrix coefficients to [-1:1] to avoid over- and underflow.\n    Scalar shift = mat.trace() / Scalar(2);\n    MatrixType scaledMat = mat;\n    scaledMat.coeffRef(0,1) = mat.coeff(1,0);\n    scaledMat.diagonal().array() -= shift;\n    Scalar scale = scaledMat.cwiseAbs().maxCoeff();\n    if(scale > Scalar(0))\n      scaledMat /= scale;\n\n    // Compute the eigenvalues\n    computeRoots(scaledMat,eivals);\n\n    // compute the eigen vectors\n    if(computeEigenvectors)\n    {\n      if((eivals(1)-eivals(0))<=abs(eivals(1))*Eigen::NumTraits<Scalar>::epsilon())\n      {\n        eivecs.setIdentity();\n      }\n      else\n      {\n        scaledMat.diagonal().array () -= eivals(1);\n        Scalar a2 = numext::abs2(scaledMat(0,0));\n        Scalar c2 = numext::abs2(scaledMat(1,1));\n        Scalar b2 = numext::abs2(scaledMat(1,0));\n        if(a2>c2)\n        {\n          eivecs.col(1) << -scaledMat(1,0), scaledMat(0,0);\n          eivecs.col(1) /= sqrt(a2+b2);\n        }\n        else\n        {\n          eivecs.col(1) << -scaledMat(1,1), scaledMat(1,0);\n          eivecs.col(1) /= sqrt(c2+b2);\n        }\n\n        eivecs.col(0) << eivecs.col(1).unitOrthogonal();\n      }\n    }\n\n    // Rescale back to the original size.\n    eivals *= scale;\n    eivals.array() += shift;\n\n    solver.m_info = Success;\n    solver.m_isInitialized = true;\n    solver.m_eigenvectorsOk = computeEigenvectors;\n  }\n};\n\n}\n\ntemplate<typename MatrixType>\nEIGEN_DEVICE_FUNC\nSelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>\n::computeDirect(const MatrixType& matrix, int options)\n{\n  internal::direct_selfadjoint_eigenvalues<SelfAdjointEigenSolver,Size,NumTraits<Scalar>::IsComplex>::run(*this,matrix,options);\n  return *this;\n}\n\nnamespace internal {\ntemplate<int StorageOrder,typename RealScalar, typename Scalar, typename Index>\nEIGEN_DEVICE_FUNC\nstatic void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end, Scalar* matrixQ, Index n)\n{\n  using std::abs;\n  RealScalar td = (diag[end-1] - diag[end])*RealScalar(0.5);\n  RealScalar e = subdiag[end-1];\n  // Note that thanks to scaling, e^2 or td^2 cannot overflow, however they can still\n  // underflow thus leading to inf/NaN values when using the following commented code:\n//   RealScalar e2 = numext::abs2(subdiag[end-1]);\n//   RealScalar mu = diag[end] - e2 / (td + (td>0 ? 1 : -1) * sqrt(td*td + e2));\n  // This explain the following, somewhat more complicated, version:\n  RealScalar mu = diag[end];\n  if(td==RealScalar(0))\n    mu -= abs(e);\n  else\n  {\n    RealScalar e2 = numext::abs2(subdiag[end-1]);\n    RealScalar h = numext::hypot(td,e);\n    if(e2==RealScalar(0)) mu -= (e / (td + (td>RealScalar(0) ? RealScalar(1) : RealScalar(-1)))) * (e / h);\n    else                  mu -= e2 / (td + (td>RealScalar(0) ? h : -h));\n  }\n  \n  RealScalar x = diag[start] - mu;\n  RealScalar z = subdiag[start];\n  for (Index k = start; k < end; ++k)\n  {\n    JacobiRotation<RealScalar> rot;\n    rot.makeGivens(x, z);\n\n    // do T = G' T G\n    RealScalar sdk = rot.s() * diag[k] + rot.c() * subdiag[k];\n    RealScalar dkp1 = rot.s() * subdiag[k] + rot.c() * diag[k+1];\n\n    diag[k] = rot.c() * (rot.c() * diag[k] - rot.s() * subdiag[k]) - rot.s() * (rot.c() * subdiag[k] - rot.s() * diag[k+1]);\n    diag[k+1] = rot.s() * sdk + rot.c() * dkp1;\n    subdiag[k] = rot.c() * sdk - rot.s() * dkp1;\n    \n\n    if (k > start)\n      subdiag[k - 1] = rot.c() * subdiag[k-1] - rot.s() * z;\n\n    x = subdiag[k];\n\n    if (k < end - 1)\n    {\n      z = -rot.s() * subdiag[k+1];\n      subdiag[k + 1] = rot.c() * subdiag[k+1];\n    }\n    \n    // apply the givens rotation to the unit matrix Q = Q * G\n    if (matrixQ)\n    {\n      // FIXME if StorageOrder == RowMajor this operation is not very efficient\n      Map<Matrix<Scalar,Dynamic,Dynamic,StorageOrder> > q(matrixQ,n,n);\n      q.applyOnTheRight(k,k+1,rot);\n    }\n  }\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SELFADJOINTEIGENSOLVER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to LAPACKe\n *    Self-adjoint eigenvalues/eigenvectors.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_SAEIGENSOLVER_LAPACKE_H\n#define EIGEN_SAEIGENSOLVER_LAPACKE_H\n\nnamespace Eigen { \n\n/** \\internal Specialization for the data types supported by LAPACKe */\n\n#define EIGEN_LAPACKE_EIG_SELFADJ(EIGTYPE, LAPACKE_TYPE, LAPACKE_RTYPE, LAPACKE_NAME, EIGCOLROW, LAPACKE_COLROW ) \\\ntemplate<> template<typename InputType> inline \\\nSelfAdjointEigenSolver<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >& \\\nSelfAdjointEigenSolver<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >::compute(const EigenBase<InputType>& matrix, int options) \\\n{ \\\n  eigen_assert(matrix.cols() == matrix.rows()); \\\n  eigen_assert((options&~(EigVecMask|GenEigMask))==0 \\\n          && (options&EigVecMask)!=EigVecMask \\\n          && \"invalid option parameter\"); \\\n  bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors; \\\n  lapack_int n = internal::convert_index<lapack_int>(matrix.cols()), lda, matrix_order, info; \\\n  m_eivalues.resize(n,1); \\\n  m_subdiag.resize(n-1); \\\n  m_eivec = matrix; \\\n\\\n  if(n==1) \\\n  { \\\n    m_eivalues.coeffRef(0,0) = numext::real(m_eivec.coeff(0,0)); \\\n    if(computeEigenvectors) m_eivec.setOnes(n,n); \\\n    m_info = Success; \\\n    m_isInitialized = true; \\\n    m_eigenvectorsOk = computeEigenvectors; \\\n    return *this; \\\n  } \\\n\\\n  lda = internal::convert_index<lapack_int>(m_eivec.outerStride()); \\\n  matrix_order=LAPACKE_COLROW; \\\n  char jobz, uplo='L'/*, range='A'*/; \\\n  jobz = computeEigenvectors ? 'V' : 'N'; \\\n\\\n  info = LAPACKE_##LAPACKE_NAME( matrix_order, jobz, uplo, n, (LAPACKE_TYPE*)m_eivec.data(), lda, (LAPACKE_RTYPE*)m_eivalues.data() ); \\\n  m_info = (info==0) ? Success : NoConvergence; \\\n  m_isInitialized = true; \\\n  m_eigenvectorsOk = computeEigenvectors; \\\n  return *this; \\\n}\n\n\nEIGEN_LAPACKE_EIG_SELFADJ(double,   double,                double, dsyev, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_EIG_SELFADJ(float,    float,                 float,  ssyev, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_EIG_SELFADJ(dcomplex, lapack_complex_double, double, zheev, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_EIG_SELFADJ(scomplex, lapack_complex_float,  float,  cheev, ColMajor, LAPACK_COL_MAJOR)\n\nEIGEN_LAPACKE_EIG_SELFADJ(double,   double,                double, dsyev, RowMajor, LAPACK_ROW_MAJOR)\nEIGEN_LAPACKE_EIG_SELFADJ(float,    float,                 float,  ssyev, RowMajor, LAPACK_ROW_MAJOR)\nEIGEN_LAPACKE_EIG_SELFADJ(dcomplex, lapack_complex_double, double, zheev, RowMajor, LAPACK_ROW_MAJOR)\nEIGEN_LAPACKE_EIG_SELFADJ(scomplex, lapack_complex_float,  float,  cheev, RowMajor, LAPACK_ROW_MAJOR)\n\n} // end namespace Eigen\n\n#endif // EIGEN_SAEIGENSOLVER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Eigenvalues/Tridiagonalization.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010 Jitse Niesen <jitse@maths.leeds.ac.uk>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TRIDIAGONALIZATION_H\n#define EIGEN_TRIDIAGONALIZATION_H\n\nnamespace Eigen { \n\nnamespace internal {\n  \ntemplate<typename MatrixType> struct TridiagonalizationMatrixTReturnType;\ntemplate<typename MatrixType>\nstruct traits<TridiagonalizationMatrixTReturnType<MatrixType> >\n  : public traits<typename MatrixType::PlainObject>\n{\n  typedef typename MatrixType::PlainObject ReturnType; // FIXME shall it be a BandMatrix?\n  enum { Flags = 0 };\n};\n\ntemplate<typename MatrixType, typename CoeffVectorType>\nvoid tridiagonalization_inplace(MatrixType& matA, CoeffVectorType& hCoeffs);\n}\n\n/** \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  *\n  * \\class Tridiagonalization\n  *\n  * \\brief Tridiagonal decomposition of a selfadjoint matrix\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the\n  * tridiagonal decomposition; this is expected to be an instantiation of the\n  * Matrix class template.\n  *\n  * This class performs a tridiagonal decomposition of a selfadjoint matrix \\f$ A \\f$ such that:\n  * \\f$ A = Q T Q^* \\f$ where \\f$ Q \\f$ is unitary and \\f$ T \\f$ a real symmetric tridiagonal matrix.\n  *\n  * A tridiagonal matrix is a matrix which has nonzero elements only on the\n  * main diagonal and the first diagonal below and above it. The Hessenberg\n  * decomposition of a selfadjoint matrix is in fact a tridiagonal\n  * decomposition. This class is used in SelfAdjointEigenSolver to compute the\n  * eigenvalues and eigenvectors of a selfadjoint matrix.\n  *\n  * Call the function compute() to compute the tridiagonal decomposition of a\n  * given matrix. Alternatively, you can use the Tridiagonalization(const MatrixType&)\n  * constructor which computes the tridiagonal Schur decomposition at\n  * construction time. Once the decomposition is computed, you can use the\n  * matrixQ() and matrixT() functions to retrieve the matrices Q and T in the\n  * decomposition.\n  *\n  * The documentation of Tridiagonalization(const MatrixType&) contains an\n  * example of the typical use of this class.\n  *\n  * \\sa class HessenbergDecomposition, class SelfAdjointEigenSolver\n  */\ntemplate<typename _MatrixType> class Tridiagonalization\n{\n  public:\n\n    /** \\brief Synonym for the template parameter \\p _MatrixType. */\n    typedef _MatrixType MatrixType;\n\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n\n    enum {\n      Size = MatrixType::RowsAtCompileTime,\n      SizeMinusOne = Size == Dynamic ? Dynamic : (Size > 1 ? Size - 1 : 1),\n      Options = MatrixType::Options,\n      MaxSize = MatrixType::MaxRowsAtCompileTime,\n      MaxSizeMinusOne = MaxSize == Dynamic ? Dynamic : (MaxSize > 1 ? MaxSize - 1 : 1)\n    };\n\n    typedef Matrix<Scalar, SizeMinusOne, 1, Options & ~RowMajor, MaxSizeMinusOne, 1> CoeffVectorType;\n    typedef typename internal::plain_col_type<MatrixType, RealScalar>::type DiagonalType;\n    typedef Matrix<RealScalar, SizeMinusOne, 1, Options & ~RowMajor, MaxSizeMinusOne, 1> SubDiagonalType;\n    typedef typename internal::remove_all<typename MatrixType::RealReturnType>::type MatrixTypeRealView;\n    typedef internal::TridiagonalizationMatrixTReturnType<MatrixTypeRealView> MatrixTReturnType;\n\n    typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,\n              typename internal::add_const_on_value_type<typename Diagonal<const MatrixType>::RealReturnType>::type,\n              const Diagonal<const MatrixType>\n            >::type DiagonalReturnType;\n\n    typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,\n              typename internal::add_const_on_value_type<typename Diagonal<const MatrixType, -1>::RealReturnType>::type,\n              const Diagonal<const MatrixType, -1>\n            >::type SubDiagonalReturnType;\n\n    /** \\brief Return type of matrixQ() */\n    typedef HouseholderSequence<MatrixType,typename internal::remove_all<typename CoeffVectorType::ConjugateReturnType>::type> HouseholderSequenceType;\n\n    /** \\brief Default constructor.\n      *\n      * \\param [in]  size  Positive integer, size of the matrix whose tridiagonal\n      * decomposition will be computed.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via compute().  The \\p size parameter is only\n      * used as a hint. It is not an error to give a wrong \\p size, but it may\n      * impair performance.\n      *\n      * \\sa compute() for an example.\n      */\n    explicit Tridiagonalization(Index size = Size==Dynamic ? 2 : Size)\n      : m_matrix(size,size),\n        m_hCoeffs(size > 1 ? size-1 : 1),\n        m_isInitialized(false)\n    {}\n\n    /** \\brief Constructor; computes tridiagonal decomposition of given matrix.\n      *\n      * \\param[in]  matrix  Selfadjoint matrix whose tridiagonal decomposition\n      * is to be computed.\n      *\n      * This constructor calls compute() to compute the tridiagonal decomposition.\n      *\n      * Example: \\include Tridiagonalization_Tridiagonalization_MatrixType.cpp\n      * Output: \\verbinclude Tridiagonalization_Tridiagonalization_MatrixType.out\n      */\n    template<typename InputType>\n    explicit Tridiagonalization(const EigenBase<InputType>& matrix)\n      : m_matrix(matrix.derived()),\n        m_hCoeffs(matrix.cols() > 1 ? matrix.cols()-1 : 1),\n        m_isInitialized(false)\n    {\n      internal::tridiagonalization_inplace(m_matrix, m_hCoeffs);\n      m_isInitialized = true;\n    }\n\n    /** \\brief Computes tridiagonal decomposition of given matrix.\n      *\n      * \\param[in]  matrix  Selfadjoint matrix whose tridiagonal decomposition\n      * is to be computed.\n      * \\returns    Reference to \\c *this\n      *\n      * The tridiagonal decomposition is computed by bringing the columns of\n      * the matrix successively in the required form using Householder\n      * reflections. The cost is \\f$ 4n^3/3 \\f$ flops, where \\f$ n \\f$ denotes\n      * the size of the given matrix.\n      *\n      * This method reuses of the allocated data in the Tridiagonalization\n      * object, if the size of the matrix does not change.\n      *\n      * Example: \\include Tridiagonalization_compute.cpp\n      * Output: \\verbinclude Tridiagonalization_compute.out\n      */\n    template<typename InputType>\n    Tridiagonalization& compute(const EigenBase<InputType>& matrix)\n    {\n      m_matrix = matrix.derived();\n      m_hCoeffs.resize(matrix.rows()-1, 1);\n      internal::tridiagonalization_inplace(m_matrix, m_hCoeffs);\n      m_isInitialized = true;\n      return *this;\n    }\n\n    /** \\brief Returns the Householder coefficients.\n      *\n      * \\returns a const reference to the vector of Householder coefficients\n      *\n      * \\pre Either the constructor Tridiagonalization(const MatrixType&) or\n      * the member function compute(const MatrixType&) has been called before\n      * to compute the tridiagonal decomposition of a matrix.\n      *\n      * The Householder coefficients allow the reconstruction of the matrix\n      * \\f$ Q \\f$ in the tridiagonal decomposition from the packed data.\n      *\n      * Example: \\include Tridiagonalization_householderCoefficients.cpp\n      * Output: \\verbinclude Tridiagonalization_householderCoefficients.out\n      *\n      * \\sa packedMatrix(), \\ref Householder_Module \"Householder module\"\n      */\n    inline CoeffVectorType householderCoefficients() const\n    {\n      eigen_assert(m_isInitialized && \"Tridiagonalization is not initialized.\");\n      return m_hCoeffs;\n    }\n\n    /** \\brief Returns the internal representation of the decomposition\n      *\n      *\t\\returns a const reference to a matrix with the internal representation\n      *\t         of the decomposition.\n      *\n      * \\pre Either the constructor Tridiagonalization(const MatrixType&) or\n      * the member function compute(const MatrixType&) has been called before\n      * to compute the tridiagonal decomposition of a matrix.\n      *\n      * The returned matrix contains the following information:\n      *  - the strict upper triangular part is equal to the input matrix A.\n      *  - the diagonal and lower sub-diagonal represent the real tridiagonal\n      *    symmetric matrix T.\n      *  - the rest of the lower part contains the Householder vectors that,\n      *    combined with Householder coefficients returned by\n      *    householderCoefficients(), allows to reconstruct the matrix Q as\n      *       \\f$ Q = H_{N-1} \\ldots H_1 H_0 \\f$.\n      *    Here, the matrices \\f$ H_i \\f$ are the Householder transformations\n      *       \\f$ H_i = (I - h_i v_i v_i^T) \\f$\n      *    where \\f$ h_i \\f$ is the \\f$ i \\f$th Householder coefficient and\n      *    \\f$ v_i \\f$ is the Householder vector defined by\n      *       \\f$ v_i = [ 0, \\ldots, 0, 1, M(i+2,i), \\ldots, M(N-1,i) ]^T \\f$\n      *    with M the matrix returned by this function.\n      *\n      * See LAPACK for further details on this packed storage.\n      *\n      * Example: \\include Tridiagonalization_packedMatrix.cpp\n      * Output: \\verbinclude Tridiagonalization_packedMatrix.out\n      *\n      * \\sa householderCoefficients()\n      */\n    inline const MatrixType& packedMatrix() const\n    {\n      eigen_assert(m_isInitialized && \"Tridiagonalization is not initialized.\");\n      return m_matrix;\n    }\n\n    /** \\brief Returns the unitary matrix Q in the decomposition\n      *\n      * \\returns object representing the matrix Q\n      *\n      * \\pre Either the constructor Tridiagonalization(const MatrixType&) or\n      * the member function compute(const MatrixType&) has been called before\n      * to compute the tridiagonal decomposition of a matrix.\n      *\n      * This function returns a light-weight object of template class\n      * HouseholderSequence. You can either apply it directly to a matrix or\n      * you can convert it to a matrix of type #MatrixType.\n      *\n      * \\sa Tridiagonalization(const MatrixType&) for an example,\n      *     matrixT(), class HouseholderSequence\n      */\n    HouseholderSequenceType matrixQ() const\n    {\n      eigen_assert(m_isInitialized && \"Tridiagonalization is not initialized.\");\n      return HouseholderSequenceType(m_matrix, m_hCoeffs.conjugate())\n             .setLength(m_matrix.rows() - 1)\n             .setShift(1);\n    }\n\n    /** \\brief Returns an expression of the tridiagonal matrix T in the decomposition\n      *\n      * \\returns expression object representing the matrix T\n      *\n      * \\pre Either the constructor Tridiagonalization(const MatrixType&) or\n      * the member function compute(const MatrixType&) has been called before\n      * to compute the tridiagonal decomposition of a matrix.\n      *\n      * Currently, this function can be used to extract the matrix T from internal\n      * data and copy it to a dense matrix object. In most cases, it may be\n      * sufficient to directly use the packed matrix or the vector expressions\n      * returned by diagonal() and subDiagonal() instead of creating a new\n      * dense copy matrix with this function.\n      *\n      * \\sa Tridiagonalization(const MatrixType&) for an example,\n      * matrixQ(), packedMatrix(), diagonal(), subDiagonal()\n      */\n    MatrixTReturnType matrixT() const\n    {\n      eigen_assert(m_isInitialized && \"Tridiagonalization is not initialized.\");\n      return MatrixTReturnType(m_matrix.real());\n    }\n\n    /** \\brief Returns the diagonal of the tridiagonal matrix T in the decomposition.\n      *\n      * \\returns expression representing the diagonal of T\n      *\n      * \\pre Either the constructor Tridiagonalization(const MatrixType&) or\n      * the member function compute(const MatrixType&) has been called before\n      * to compute the tridiagonal decomposition of a matrix.\n      *\n      * Example: \\include Tridiagonalization_diagonal.cpp\n      * Output: \\verbinclude Tridiagonalization_diagonal.out\n      *\n      * \\sa matrixT(), subDiagonal()\n      */\n    DiagonalReturnType diagonal() const;\n\n    /** \\brief Returns the subdiagonal of the tridiagonal matrix T in the decomposition.\n      *\n      * \\returns expression representing the subdiagonal of T\n      *\n      * \\pre Either the constructor Tridiagonalization(const MatrixType&) or\n      * the member function compute(const MatrixType&) has been called before\n      * to compute the tridiagonal decomposition of a matrix.\n      *\n      * \\sa diagonal() for an example, matrixT()\n      */\n    SubDiagonalReturnType subDiagonal() const;\n\n  protected:\n\n    MatrixType m_matrix;\n    CoeffVectorType m_hCoeffs;\n    bool m_isInitialized;\n};\n\ntemplate<typename MatrixType>\ntypename Tridiagonalization<MatrixType>::DiagonalReturnType\nTridiagonalization<MatrixType>::diagonal() const\n{\n  eigen_assert(m_isInitialized && \"Tridiagonalization is not initialized.\");\n  return m_matrix.diagonal().real();\n}\n\ntemplate<typename MatrixType>\ntypename Tridiagonalization<MatrixType>::SubDiagonalReturnType\nTridiagonalization<MatrixType>::subDiagonal() const\n{\n  eigen_assert(m_isInitialized && \"Tridiagonalization is not initialized.\");\n  return m_matrix.template diagonal<-1>().real();\n}\n\nnamespace internal {\n\n/** \\internal\n  * Performs a tridiagonal decomposition of the selfadjoint matrix \\a matA in-place.\n  *\n  * \\param[in,out] matA On input the selfadjoint matrix. Only the \\b lower triangular part is referenced.\n  *                     On output, the strict upper part is left unchanged, and the lower triangular part\n  *                     represents the T and Q matrices in packed format has detailed below.\n  * \\param[out]    hCoeffs returned Householder coefficients (see below)\n  *\n  * On output, the tridiagonal selfadjoint matrix T is stored in the diagonal\n  * and lower sub-diagonal of the matrix \\a matA.\n  * The unitary matrix Q is represented in a compact way as a product of\n  * Householder reflectors \\f$ H_i \\f$ such that:\n  *       \\f$ Q = H_{N-1} \\ldots H_1 H_0 \\f$.\n  * The Householder reflectors are defined as\n  *       \\f$ H_i = (I - h_i v_i v_i^T) \\f$\n  * where \\f$ h_i = hCoeffs[i]\\f$ is the \\f$ i \\f$th Householder coefficient and\n  * \\f$ v_i \\f$ is the Householder vector defined by\n  *       \\f$ v_i = [ 0, \\ldots, 0, 1, matA(i+2,i), \\ldots, matA(N-1,i) ]^T \\f$.\n  *\n  * Implemented from Golub's \"Matrix Computations\", algorithm 8.3.1.\n  *\n  * \\sa Tridiagonalization::packedMatrix()\n  */\ntemplate<typename MatrixType, typename CoeffVectorType>\nvoid tridiagonalization_inplace(MatrixType& matA, CoeffVectorType& hCoeffs)\n{\n  using numext::conj;\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename MatrixType::RealScalar RealScalar;\n  Index n = matA.rows();\n  eigen_assert(n==matA.cols());\n  eigen_assert(n==hCoeffs.size()+1 || n==1);\n  \n  for (Index i = 0; i<n-1; ++i)\n  {\n    Index remainingSize = n-i-1;\n    RealScalar beta;\n    Scalar h;\n    matA.col(i).tail(remainingSize).makeHouseholderInPlace(h, beta);\n\n    // Apply similarity transformation to remaining columns,\n    // i.e., A = H A H' where H = I - h v v' and v = matA.col(i).tail(n-i-1)\n    matA.col(i).coeffRef(i+1) = 1;\n\n    hCoeffs.tail(n-i-1).noalias() = (matA.bottomRightCorner(remainingSize,remainingSize).template selfadjointView<Lower>()\n                                  * (conj(h) * matA.col(i).tail(remainingSize)));\n\n    hCoeffs.tail(n-i-1) += (conj(h)*RealScalar(-0.5)*(hCoeffs.tail(remainingSize).dot(matA.col(i).tail(remainingSize)))) * matA.col(i).tail(n-i-1);\n\n    matA.bottomRightCorner(remainingSize, remainingSize).template selfadjointView<Lower>()\n      .rankUpdate(matA.col(i).tail(remainingSize), hCoeffs.tail(remainingSize), Scalar(-1));\n\n    matA.col(i).coeffRef(i+1) = beta;\n    hCoeffs.coeffRef(i) = h;\n  }\n}\n\n// forward declaration, implementation at the end of this file\ntemplate<typename MatrixType,\n         int Size=MatrixType::ColsAtCompileTime,\n         bool IsComplex=NumTraits<typename MatrixType::Scalar>::IsComplex>\nstruct tridiagonalization_inplace_selector;\n\n/** \\brief Performs a full tridiagonalization in place\n  *\n  * \\param[in,out]  mat  On input, the selfadjoint matrix whose tridiagonal\n  *    decomposition is to be computed. Only the lower triangular part referenced.\n  *    The rest is left unchanged. On output, the orthogonal matrix Q\n  *    in the decomposition if \\p extractQ is true.\n  * \\param[out]  diag  The diagonal of the tridiagonal matrix T in the\n  *    decomposition.\n  * \\param[out]  subdiag  The subdiagonal of the tridiagonal matrix T in\n  *    the decomposition.\n  * \\param[in]  extractQ  If true, the orthogonal matrix Q in the\n  *    decomposition is computed and stored in \\p mat.\n  *\n  * Computes the tridiagonal decomposition of the selfadjoint matrix \\p mat in place\n  * such that \\f$ mat = Q T Q^* \\f$ where \\f$ Q \\f$ is unitary and \\f$ T \\f$ a real\n  * symmetric tridiagonal matrix.\n  *\n  * The tridiagonal matrix T is passed to the output parameters \\p diag and \\p subdiag. If\n  * \\p extractQ is true, then the orthogonal matrix Q is passed to \\p mat. Otherwise the lower\n  * part of the matrix \\p mat is destroyed.\n  *\n  * The vectors \\p diag and \\p subdiag are not resized. The function\n  * assumes that they are already of the correct size. The length of the\n  * vector \\p diag should equal the number of rows in \\p mat, and the\n  * length of the vector \\p subdiag should be one left.\n  *\n  * This implementation contains an optimized path for 3-by-3 matrices\n  * which is especially useful for plane fitting.\n  *\n  * \\note Currently, it requires two temporary vectors to hold the intermediate\n  * Householder coefficients, and to reconstruct the matrix Q from the Householder\n  * reflectors.\n  *\n  * Example (this uses the same matrix as the example in\n  *    Tridiagonalization::Tridiagonalization(const MatrixType&)):\n  *    \\include Tridiagonalization_decomposeInPlace.cpp\n  * Output: \\verbinclude Tridiagonalization_decomposeInPlace.out\n  *\n  * \\sa class Tridiagonalization\n  */\ntemplate<typename MatrixType, typename DiagonalType, typename SubDiagonalType>\nvoid tridiagonalization_inplace(MatrixType& mat, DiagonalType& diag, SubDiagonalType& subdiag, bool extractQ)\n{\n  eigen_assert(mat.cols()==mat.rows() && diag.size()==mat.rows() && subdiag.size()==mat.rows()-1);\n  tridiagonalization_inplace_selector<MatrixType>::run(mat, diag, subdiag, extractQ);\n}\n\n/** \\internal\n  * General full tridiagonalization\n  */\ntemplate<typename MatrixType, int Size, bool IsComplex>\nstruct tridiagonalization_inplace_selector\n{\n  typedef typename Tridiagonalization<MatrixType>::CoeffVectorType CoeffVectorType;\n  typedef typename Tridiagonalization<MatrixType>::HouseholderSequenceType HouseholderSequenceType;\n  template<typename DiagonalType, typename SubDiagonalType>\n  static void run(MatrixType& mat, DiagonalType& diag, SubDiagonalType& subdiag, bool extractQ)\n  {\n    CoeffVectorType hCoeffs(mat.cols()-1);\n    tridiagonalization_inplace(mat,hCoeffs);\n    diag = mat.diagonal().real();\n    subdiag = mat.template diagonal<-1>().real();\n    if(extractQ)\n      mat = HouseholderSequenceType(mat, hCoeffs.conjugate())\n            .setLength(mat.rows() - 1)\n            .setShift(1);\n  }\n};\n\n/** \\internal\n  * Specialization for 3x3 real matrices.\n  * Especially useful for plane fitting.\n  */\ntemplate<typename MatrixType>\nstruct tridiagonalization_inplace_selector<MatrixType,3,false>\n{\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename MatrixType::RealScalar RealScalar;\n\n  template<typename DiagonalType, typename SubDiagonalType>\n  static void run(MatrixType& mat, DiagonalType& diag, SubDiagonalType& subdiag, bool extractQ)\n  {\n    using std::sqrt;\n    const RealScalar tol = (std::numeric_limits<RealScalar>::min)();\n    diag[0] = mat(0,0);\n    RealScalar v1norm2 = numext::abs2(mat(2,0));\n    if(v1norm2 <= tol)\n    {\n      diag[1] = mat(1,1);\n      diag[2] = mat(2,2);\n      subdiag[0] = mat(1,0);\n      subdiag[1] = mat(2,1);\n      if (extractQ)\n        mat.setIdentity();\n    }\n    else\n    {\n      RealScalar beta = sqrt(numext::abs2(mat(1,0)) + v1norm2);\n      RealScalar invBeta = RealScalar(1)/beta;\n      Scalar m01 = mat(1,0) * invBeta;\n      Scalar m02 = mat(2,0) * invBeta;\n      Scalar q = RealScalar(2)*m01*mat(2,1) + m02*(mat(2,2) - mat(1,1));\n      diag[1] = mat(1,1) + m02*q;\n      diag[2] = mat(2,2) - m02*q;\n      subdiag[0] = beta;\n      subdiag[1] = mat(2,1) - m01 * q;\n      if (extractQ)\n      {\n        mat << 1,   0,    0,\n               0, m01,  m02,\n               0, m02, -m01;\n      }\n    }\n  }\n};\n\n/** \\internal\n  * Trivial specialization for 1x1 matrices\n  */\ntemplate<typename MatrixType, bool IsComplex>\nstruct tridiagonalization_inplace_selector<MatrixType,1,IsComplex>\n{\n  typedef typename MatrixType::Scalar Scalar;\n\n  template<typename DiagonalType, typename SubDiagonalType>\n  static void run(MatrixType& mat, DiagonalType& diag, SubDiagonalType&, bool extractQ)\n  {\n    diag(0,0) = numext::real(mat(0,0));\n    if(extractQ)\n      mat(0,0) = Scalar(1);\n  }\n};\n\n/** \\internal\n  * \\eigenvalues_module \\ingroup Eigenvalues_Module\n  *\n  * \\brief Expression type for return value of Tridiagonalization::matrixT()\n  *\n  * \\tparam MatrixType type of underlying dense matrix\n  */\ntemplate<typename MatrixType> struct TridiagonalizationMatrixTReturnType\n: public ReturnByValue<TridiagonalizationMatrixTReturnType<MatrixType> >\n{\n  public:\n    /** \\brief Constructor.\n      *\n      * \\param[in] mat The underlying dense matrix\n      */\n    TridiagonalizationMatrixTReturnType(const MatrixType& mat) : m_matrix(mat) { }\n\n    template <typename ResultType>\n    inline void evalTo(ResultType& result) const\n    {\n      result.setZero();\n      result.template diagonal<1>() = m_matrix.template diagonal<-1>().conjugate();\n      result.diagonal() = m_matrix.diagonal();\n      result.template diagonal<-1>() = m_matrix.template diagonal<-1>();\n    }\n\n    Index rows() const { return m_matrix.rows(); }\n    Index cols() const { return m_matrix.cols(); }\n\n  protected:\n    typename MatrixType::Nested m_matrix;\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRIDIAGONALIZATION_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/AlignedBox.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ALIGNEDBOX_H\n#define EIGEN_ALIGNEDBOX_H\n\nnamespace Eigen { \n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  *\n  * \\class AlignedBox\n  *\n  * \\brief An axis aligned box\n  *\n  * \\tparam _Scalar the type of the scalar coefficients\n  * \\tparam _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.\n  *\n  * This class represents an axis aligned box as a pair of the minimal and maximal corners.\n  * \\warning The result of most methods is undefined when applied to an empty box. You can check for empty boxes using isEmpty().\n  * \\sa alignedboxtypedefs\n  */\ntemplate <typename _Scalar, int _AmbientDim>\nclass AlignedBox\n{\npublic:\nEIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)\n  enum { AmbientDimAtCompileTime = _AmbientDim };\n  typedef _Scalar                                   Scalar;\n  typedef NumTraits<Scalar>                         ScalarTraits;\n  typedef Eigen::Index                              Index; ///< \\deprecated since Eigen 3.3\n  typedef typename ScalarTraits::Real               RealScalar;\n  typedef typename ScalarTraits::NonInteger         NonInteger;\n  typedef Matrix<Scalar,AmbientDimAtCompileTime,1>  VectorType;\n  typedef CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const VectorType, const VectorType> VectorTypeSum;\n\n  /** Define constants to name the corners of a 1D, 2D or 3D axis aligned bounding box */\n  enum CornerType\n  {\n    /** 1D names @{ */\n    Min=0, Max=1,\n    /** @} */\n\n    /** Identifier for 2D corner @{ */\n    BottomLeft=0, BottomRight=1,\n    TopLeft=2, TopRight=3,\n    /** @} */\n\n    /** Identifier for 3D corner  @{ */\n    BottomLeftFloor=0, BottomRightFloor=1,\n    TopLeftFloor=2, TopRightFloor=3,\n    BottomLeftCeil=4, BottomRightCeil=5,\n    TopLeftCeil=6, TopRightCeil=7\n    /** @} */\n  };\n\n\n  /** Default constructor initializing a null box. */\n  EIGEN_DEVICE_FUNC inline AlignedBox()\n  { if (AmbientDimAtCompileTime!=Dynamic) setEmpty(); }\n\n  /** Constructs a null box with \\a _dim the dimension of the ambient space. */\n  EIGEN_DEVICE_FUNC inline explicit AlignedBox(Index _dim) : m_min(_dim), m_max(_dim)\n  { setEmpty(); }\n\n  /** Constructs a box with extremities \\a _min and \\a _max.\n   * \\warning If either component of \\a _min is larger than the same component of \\a _max, the constructed box is empty. */\n  template<typename OtherVectorType1, typename OtherVectorType2>\n  EIGEN_DEVICE_FUNC inline AlignedBox(const OtherVectorType1& _min, const OtherVectorType2& _max) : m_min(_min), m_max(_max) {}\n\n  /** Constructs a box containing a single point \\a p. */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline explicit AlignedBox(const MatrixBase<Derived>& p) : m_min(p), m_max(m_min)\n  { }\n\n  EIGEN_DEVICE_FUNC ~AlignedBox() {}\n\n  /** \\returns the dimension in which the box holds */\n  EIGEN_DEVICE_FUNC inline Index dim() const { return AmbientDimAtCompileTime==Dynamic ? m_min.size() : Index(AmbientDimAtCompileTime); }\n\n  /** \\deprecated use isEmpty() */\n  EIGEN_DEVICE_FUNC inline bool isNull() const { return isEmpty(); }\n\n  /** \\deprecated use setEmpty() */\n  EIGEN_DEVICE_FUNC inline void setNull() { setEmpty(); }\n\n  /** \\returns true if the box is empty.\n   * \\sa setEmpty */\n  EIGEN_DEVICE_FUNC inline bool isEmpty() const { return (m_min.array() > m_max.array()).any(); }\n\n  /** Makes \\c *this an empty box.\n   * \\sa isEmpty */\n  EIGEN_DEVICE_FUNC inline void setEmpty()\n  {\n    m_min.setConstant( ScalarTraits::highest() );\n    m_max.setConstant( ScalarTraits::lowest() );\n  }\n\n  /** \\returns the minimal corner */\n  EIGEN_DEVICE_FUNC inline const VectorType& (min)() const { return m_min; }\n  /** \\returns a non const reference to the minimal corner */\n  EIGEN_DEVICE_FUNC inline VectorType& (min)() { return m_min; }\n  /** \\returns the maximal corner */\n  EIGEN_DEVICE_FUNC inline const VectorType& (max)() const { return m_max; }\n  /** \\returns a non const reference to the maximal corner */\n  EIGEN_DEVICE_FUNC inline VectorType& (max)() { return m_max; }\n\n  /** \\returns the center of the box */\n  EIGEN_DEVICE_FUNC inline const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(VectorTypeSum, RealScalar, quotient)\n  center() const\n  { return (m_min+m_max)/RealScalar(2); }\n\n  /** \\returns the lengths of the sides of the bounding box.\n    * Note that this function does not get the same\n    * result for integral or floating scalar types: see\n    */\n  EIGEN_DEVICE_FUNC inline const CwiseBinaryOp< internal::scalar_difference_op<Scalar,Scalar>, const VectorType, const VectorType> sizes() const\n  { return m_max - m_min; }\n\n  /** \\returns the volume of the bounding box */\n  EIGEN_DEVICE_FUNC inline Scalar volume() const\n  { return sizes().prod(); }\n\n  /** \\returns an expression for the bounding box diagonal vector\n    * if the length of the diagonal is needed: diagonal().norm()\n    * will provide it.\n    */\n  EIGEN_DEVICE_FUNC inline CwiseBinaryOp< internal::scalar_difference_op<Scalar,Scalar>, const VectorType, const VectorType> diagonal() const\n  { return sizes(); }\n\n  /** \\returns the vertex of the bounding box at the corner defined by\n    * the corner-id corner. It works only for a 1D, 2D or 3D bounding box.\n    * For 1D bounding boxes corners are named by 2 enum constants:\n    * BottomLeft and BottomRight.\n    * For 2D bounding boxes, corners are named by 4 enum constants:\n    * BottomLeft, BottomRight, TopLeft, TopRight.\n    * For 3D bounding boxes, the following names are added:\n    * BottomLeftCeil, BottomRightCeil, TopLeftCeil, TopRightCeil.\n    */\n  EIGEN_DEVICE_FUNC inline VectorType corner(CornerType corner) const\n  {\n    EIGEN_STATIC_ASSERT(_AmbientDim <= 3, THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE);\n\n    VectorType res;\n\n    Index mult = 1;\n    for(Index d=0; d<dim(); ++d)\n    {\n      if( mult & corner ) res[d] = m_max[d];\n      else                res[d] = m_min[d];\n      mult *= 2;\n    }\n    return res;\n  }\n\n  /** \\returns a random point inside the bounding box sampled with\n   * a uniform distribution */\n  EIGEN_DEVICE_FUNC inline VectorType sample() const\n  {\n    VectorType r(dim());\n    for(Index d=0; d<dim(); ++d)\n    {\n      if(!ScalarTraits::IsInteger)\n      {\n        r[d] = m_min[d] + (m_max[d]-m_min[d])\n             * internal::random<Scalar>(Scalar(0), Scalar(1));\n      }\n      else\n        r[d] = internal::random(m_min[d], m_max[d]);\n    }\n    return r;\n  }\n\n  /** \\returns true if the point \\a p is inside the box \\c *this. */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline bool contains(const MatrixBase<Derived>& p) const\n  {\n    typename internal::nested_eval<Derived,2>::type p_n(p.derived());\n    return (m_min.array()<=p_n.array()).all() && (p_n.array()<=m_max.array()).all();\n  }\n\n  /** \\returns true if the box \\a b is entirely inside the box \\c *this. */\n  EIGEN_DEVICE_FUNC inline bool contains(const AlignedBox& b) const\n  { return (m_min.array()<=(b.min)().array()).all() && ((b.max)().array()<=m_max.array()).all(); }\n\n  /** \\returns true if the box \\a b is intersecting the box \\c *this.\n   * \\sa intersection, clamp */\n  EIGEN_DEVICE_FUNC inline bool intersects(const AlignedBox& b) const\n  { return (m_min.array()<=(b.max)().array()).all() && ((b.min)().array()<=m_max.array()).all(); }\n\n  /** Extends \\c *this such that it contains the point \\a p and returns a reference to \\c *this.\n   * \\sa extend(const AlignedBox&) */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline AlignedBox& extend(const MatrixBase<Derived>& p)\n  {\n    typename internal::nested_eval<Derived,2>::type p_n(p.derived());\n    m_min = m_min.cwiseMin(p_n);\n    m_max = m_max.cwiseMax(p_n);\n    return *this;\n  }\n\n  /** Extends \\c *this such that it contains the box \\a b and returns a reference to \\c *this.\n   * \\sa merged, extend(const MatrixBase&) */\n  EIGEN_DEVICE_FUNC inline AlignedBox& extend(const AlignedBox& b)\n  {\n    m_min = m_min.cwiseMin(b.m_min);\n    m_max = m_max.cwiseMax(b.m_max);\n    return *this;\n  }\n\n  /** Clamps \\c *this by the box \\a b and returns a reference to \\c *this.\n   * \\note If the boxes don't intersect, the resulting box is empty.\n   * \\sa intersection(), intersects() */\n  EIGEN_DEVICE_FUNC inline AlignedBox& clamp(const AlignedBox& b)\n  {\n    m_min = m_min.cwiseMax(b.m_min);\n    m_max = m_max.cwiseMin(b.m_max);\n    return *this;\n  }\n\n  /** Returns an AlignedBox that is the intersection of \\a b and \\c *this\n   * \\note If the boxes don't intersect, the resulting box is empty.\n   * \\sa intersects(), clamp, contains()  */\n  EIGEN_DEVICE_FUNC inline AlignedBox intersection(const AlignedBox& b) const\n  {return AlignedBox(m_min.cwiseMax(b.m_min), m_max.cwiseMin(b.m_max)); }\n\n  /** Returns an AlignedBox that is the union of \\a b and \\c *this.\n   * \\note Merging with an empty box may result in a box bigger than \\c *this. \n   * \\sa extend(const AlignedBox&) */\n  EIGEN_DEVICE_FUNC inline AlignedBox merged(const AlignedBox& b) const\n  { return AlignedBox(m_min.cwiseMin(b.m_min), m_max.cwiseMax(b.m_max)); }\n\n  /** Translate \\c *this by the vector \\a t and returns a reference to \\c *this. */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline AlignedBox& translate(const MatrixBase<Derived>& a_t)\n  {\n    const typename internal::nested_eval<Derived,2>::type t(a_t.derived());\n    m_min += t;\n    m_max += t;\n    return *this;\n  }\n\n  /** \\returns the squared distance between the point \\a p and the box \\c *this,\n    * and zero if \\a p is inside the box.\n    * \\sa exteriorDistance(const MatrixBase&), squaredExteriorDistance(const AlignedBox&)\n    */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline Scalar squaredExteriorDistance(const MatrixBase<Derived>& p) const;\n\n  /** \\returns the squared distance between the boxes \\a b and \\c *this,\n    * and zero if the boxes intersect.\n    * \\sa exteriorDistance(const AlignedBox&), squaredExteriorDistance(const MatrixBase&)\n    */\n  EIGEN_DEVICE_FUNC inline Scalar squaredExteriorDistance(const AlignedBox& b) const;\n\n  /** \\returns the distance between the point \\a p and the box \\c *this,\n    * and zero if \\a p is inside the box.\n    * \\sa squaredExteriorDistance(const MatrixBase&), exteriorDistance(const AlignedBox&)\n    */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline NonInteger exteriorDistance(const MatrixBase<Derived>& p) const\n  { EIGEN_USING_STD_MATH(sqrt) return sqrt(NonInteger(squaredExteriorDistance(p))); }\n\n  /** \\returns the distance between the boxes \\a b and \\c *this,\n    * and zero if the boxes intersect.\n    * \\sa squaredExteriorDistance(const AlignedBox&), exteriorDistance(const MatrixBase&)\n    */\n  EIGEN_DEVICE_FUNC inline NonInteger exteriorDistance(const AlignedBox& b) const\n  { EIGEN_USING_STD_MATH(sqrt) return sqrt(NonInteger(squaredExteriorDistance(b))); }\n\n  /** \\returns \\c *this with scalar type casted to \\a NewScalarType\n    *\n    * Note that if \\a NewScalarType is equal to the current scalar type of \\c *this\n    * then this function smartly returns a const reference to \\c *this.\n    */\n  template<typename NewScalarType>\n  EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<AlignedBox,\n           AlignedBox<NewScalarType,AmbientDimAtCompileTime> >::type cast() const\n  {\n    return typename internal::cast_return_type<AlignedBox,\n                    AlignedBox<NewScalarType,AmbientDimAtCompileTime> >::type(*this);\n  }\n\n  /** Copy constructor with scalar type conversion */\n  template<typename OtherScalarType>\n  EIGEN_DEVICE_FUNC inline explicit AlignedBox(const AlignedBox<OtherScalarType,AmbientDimAtCompileTime>& other)\n  {\n    m_min = (other.min)().template cast<Scalar>();\n    m_max = (other.max)().template cast<Scalar>();\n  }\n\n  /** \\returns \\c true if \\c *this is approximately equal to \\a other, within the precision\n    * determined by \\a prec.\n    *\n    * \\sa MatrixBase::isApprox() */\n  EIGEN_DEVICE_FUNC bool isApprox(const AlignedBox& other, const RealScalar& prec = ScalarTraits::dummy_precision()) const\n  { return m_min.isApprox(other.m_min, prec) && m_max.isApprox(other.m_max, prec); }\n\nprotected:\n\n  VectorType m_min, m_max;\n};\n\n\n\ntemplate<typename Scalar,int AmbientDim>\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC inline Scalar AlignedBox<Scalar,AmbientDim>::squaredExteriorDistance(const MatrixBase<Derived>& a_p) const\n{\n  typename internal::nested_eval<Derived,2*AmbientDim>::type p(a_p.derived());\n  Scalar dist2(0);\n  Scalar aux;\n  for (Index k=0; k<dim(); ++k)\n  {\n    if( m_min[k] > p[k] )\n    {\n      aux = m_min[k] - p[k];\n      dist2 += aux*aux;\n    }\n    else if( p[k] > m_max[k] )\n    {\n      aux = p[k] - m_max[k];\n      dist2 += aux*aux;\n    }\n  }\n  return dist2;\n}\n\ntemplate<typename Scalar,int AmbientDim>\nEIGEN_DEVICE_FUNC inline Scalar AlignedBox<Scalar,AmbientDim>::squaredExteriorDistance(const AlignedBox& b) const\n{\n  Scalar dist2(0);\n  Scalar aux;\n  for (Index k=0; k<dim(); ++k)\n  {\n    if( m_min[k] > b.m_max[k] )\n    {\n      aux = m_min[k] - b.m_max[k];\n      dist2 += aux*aux;\n    }\n    else if( b.m_min[k] > m_max[k] )\n    {\n      aux = b.m_min[k] - m_max[k];\n      dist2 += aux*aux;\n    }\n  }\n  return dist2;\n}\n\n/** \\defgroup alignedboxtypedefs Global aligned box typedefs\n  *\n  * \\ingroup Geometry_Module\n  *\n  * Eigen defines several typedef shortcuts for most common aligned box types.\n  *\n  * The general patterns are the following:\n  *\n  * \\c AlignedBoxSizeType where \\c Size can be \\c 1, \\c 2,\\c 3,\\c 4 for fixed size boxes or \\c X for dynamic size,\n  * and where \\c Type can be \\c i for integer, \\c f for float, \\c d for double.\n  *\n  * For example, \\c AlignedBox3d is a fixed-size 3x3 aligned box type of doubles, and \\c AlignedBoxXf is a dynamic-size aligned box of floats.\n  *\n  * \\sa class AlignedBox\n  */\n\n#define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix)    \\\n/** \\ingroup alignedboxtypedefs */                                 \\\ntypedef AlignedBox<Type, Size>   AlignedBox##SizeSuffix##TypeSuffix;\n\n#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \\\nEIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 1, 1) \\\nEIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \\\nEIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \\\nEIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \\\nEIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X)\n\nEIGEN_MAKE_TYPEDEFS_ALL_SIZES(int,                  i)\nEIGEN_MAKE_TYPEDEFS_ALL_SIZES(float,                f)\nEIGEN_MAKE_TYPEDEFS_ALL_SIZES(double,               d)\n\n#undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES\n#undef EIGEN_MAKE_TYPEDEFS\n\n} // end namespace Eigen\n\n#endif // EIGEN_ALIGNEDBOX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/AngleAxis.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ANGLEAXIS_H\n#define EIGEN_ANGLEAXIS_H\n\nnamespace Eigen { \n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\class AngleAxis\n  *\n  * \\brief Represents a 3D rotation as a rotation angle around an arbitrary 3D axis\n  *\n  * \\param _Scalar the scalar type, i.e., the type of the coefficients.\n  *\n  * \\warning When setting up an AngleAxis object, the axis vector \\b must \\b be \\b normalized.\n  *\n  * The following two typedefs are provided for convenience:\n  * \\li \\c AngleAxisf for \\c float\n  * \\li \\c AngleAxisd for \\c double\n  *\n  * Combined with MatrixBase::Unit{X,Y,Z}, AngleAxis can be used to easily\n  * mimic Euler-angles. Here is an example:\n  * \\include AngleAxis_mimic_euler.cpp\n  * Output: \\verbinclude AngleAxis_mimic_euler.out\n  *\n  * \\note This class is not aimed to be used to store a rotation transformation,\n  * but rather to make easier the creation of other rotation (Quaternion, rotation Matrix)\n  * and transformation objects.\n  *\n  * \\sa class Quaternion, class Transform, MatrixBase::UnitX()\n  */\n\nnamespace internal {\ntemplate<typename _Scalar> struct traits<AngleAxis<_Scalar> >\n{\n  typedef _Scalar Scalar;\n};\n}\n\ntemplate<typename _Scalar>\nclass AngleAxis : public RotationBase<AngleAxis<_Scalar>,3>\n{\n  typedef RotationBase<AngleAxis<_Scalar>,3> Base;\n\npublic:\n\n  using Base::operator*;\n\n  enum { Dim = 3 };\n  /** the scalar type of the coefficients */\n  typedef _Scalar Scalar;\n  typedef Matrix<Scalar,3,3> Matrix3;\n  typedef Matrix<Scalar,3,1> Vector3;\n  typedef Quaternion<Scalar> QuaternionType;\n\nprotected:\n\n  Vector3 m_axis;\n  Scalar m_angle;\n\npublic:\n\n  /** Default constructor without initialization. */\n  EIGEN_DEVICE_FUNC AngleAxis() {}\n  /** Constructs and initialize the angle-axis rotation from an \\a angle in radian\n    * and an \\a axis which \\b must \\b be \\b normalized.\n    *\n    * \\warning If the \\a axis vector is not normalized, then the angle-axis object\n    *          represents an invalid rotation. */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC \n  inline AngleAxis(const Scalar& angle, const MatrixBase<Derived>& axis) : m_axis(axis), m_angle(angle) {}\n  /** Constructs and initialize the angle-axis rotation from a quaternion \\a q.\n    * This function implicitly normalizes the quaternion \\a q.\n    */\n  template<typename QuatDerived> \n  EIGEN_DEVICE_FUNC inline explicit AngleAxis(const QuaternionBase<QuatDerived>& q) { *this = q; }\n  /** Constructs and initialize the angle-axis rotation from a 3x3 rotation matrix. */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline explicit AngleAxis(const MatrixBase<Derived>& m) { *this = m; }\n\n  /** \\returns the value of the rotation angle in radian */\n  EIGEN_DEVICE_FUNC Scalar angle() const { return m_angle; }\n  /** \\returns a read-write reference to the stored angle in radian */\n  EIGEN_DEVICE_FUNC Scalar& angle() { return m_angle; }\n\n  /** \\returns the rotation axis */\n  EIGEN_DEVICE_FUNC const Vector3& axis() const { return m_axis; }\n  /** \\returns a read-write reference to the stored rotation axis.\n    *\n    * \\warning The rotation axis must remain a \\b unit vector.\n    */\n  EIGEN_DEVICE_FUNC Vector3& axis() { return m_axis; }\n\n  /** Concatenates two rotations */\n  EIGEN_DEVICE_FUNC inline QuaternionType operator* (const AngleAxis& other) const\n  { return QuaternionType(*this) * QuaternionType(other); }\n\n  /** Concatenates two rotations */\n  EIGEN_DEVICE_FUNC inline QuaternionType operator* (const QuaternionType& other) const\n  { return QuaternionType(*this) * other; }\n\n  /** Concatenates two rotations */\n  friend EIGEN_DEVICE_FUNC inline QuaternionType operator* (const QuaternionType& a, const AngleAxis& b)\n  { return a * QuaternionType(b); }\n\n  /** \\returns the inverse rotation, i.e., an angle-axis with opposite rotation angle */\n  EIGEN_DEVICE_FUNC AngleAxis inverse() const\n  { return AngleAxis(-m_angle, m_axis); }\n\n  template<class QuatDerived>\n  EIGEN_DEVICE_FUNC AngleAxis& operator=(const QuaternionBase<QuatDerived>& q);\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC AngleAxis& operator=(const MatrixBase<Derived>& m);\n\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC AngleAxis& fromRotationMatrix(const MatrixBase<Derived>& m);\n  EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix(void) const;\n\n  /** \\returns \\c *this with scalar type casted to \\a NewScalarType\n    *\n    * Note that if \\a NewScalarType is equal to the current scalar type of \\c *this\n    * then this function smartly returns a const reference to \\c *this.\n    */\n  template<typename NewScalarType>\n  EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type cast() const\n  { return typename internal::cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type(*this); }\n\n  /** Copy constructor with scalar type conversion */\n  template<typename OtherScalarType>\n  EIGEN_DEVICE_FUNC inline explicit AngleAxis(const AngleAxis<OtherScalarType>& other)\n  {\n    m_axis = other.axis().template cast<Scalar>();\n    m_angle = Scalar(other.angle());\n  }\n\n  EIGEN_DEVICE_FUNC static inline const AngleAxis Identity() { return AngleAxis(Scalar(0), Vector3::UnitX()); }\n\n  /** \\returns \\c true if \\c *this is approximately equal to \\a other, within the precision\n    * determined by \\a prec.\n    *\n    * \\sa MatrixBase::isApprox() */\n  EIGEN_DEVICE_FUNC bool isApprox(const AngleAxis& other, const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision()) const\n  { return m_axis.isApprox(other.m_axis, prec) && internal::isApprox(m_angle,other.m_angle, prec); }\n};\n\n/** \\ingroup Geometry_Module\n  * single precision angle-axis type */\ntypedef AngleAxis<float> AngleAxisf;\n/** \\ingroup Geometry_Module\n  * double precision angle-axis type */\ntypedef AngleAxis<double> AngleAxisd;\n\n/** Set \\c *this from a \\b unit quaternion.\n  *\n  * The resulting axis is normalized, and the computed angle is in the [0,pi] range.\n  * \n  * This function implicitly normalizes the quaternion \\a q.\n  */\ntemplate<typename Scalar>\ntemplate<typename QuatDerived>\nEIGEN_DEVICE_FUNC AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const QuaternionBase<QuatDerived>& q)\n{\n  EIGEN_USING_STD_MATH(atan2)\n  EIGEN_USING_STD_MATH(abs)\n  Scalar n = q.vec().norm();\n  if(n<NumTraits<Scalar>::epsilon())\n    n = q.vec().stableNorm();\n\n  if (n != Scalar(0))\n  {\n    m_angle = Scalar(2)*atan2(n, abs(q.w()));\n    if(q.w() < 0)\n      n = -n;\n    m_axis  = q.vec() / n;\n  }\n  else\n  {\n    m_angle = Scalar(0);\n    m_axis << Scalar(1), Scalar(0), Scalar(0);\n  }\n  return *this;\n}\n\n/** Set \\c *this from a 3x3 rotation matrix \\a mat.\n  */\ntemplate<typename Scalar>\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const MatrixBase<Derived>& mat)\n{\n  // Since a direct conversion would not be really faster,\n  // let's use the robust Quaternion implementation:\n  return *this = QuaternionType(mat);\n}\n\n/**\n* \\brief Sets \\c *this from a 3x3 rotation matrix.\n**/\ntemplate<typename Scalar>\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC AngleAxis<Scalar>& AngleAxis<Scalar>::fromRotationMatrix(const MatrixBase<Derived>& mat)\n{\n  return *this = QuaternionType(mat);\n}\n\n/** Constructs and \\returns an equivalent 3x3 rotation matrix.\n  */\ntemplate<typename Scalar>\ntypename AngleAxis<Scalar>::Matrix3\nEIGEN_DEVICE_FUNC AngleAxis<Scalar>::toRotationMatrix(void) const\n{\n  EIGEN_USING_STD_MATH(sin)\n  EIGEN_USING_STD_MATH(cos)\n  Matrix3 res;\n  Vector3 sin_axis  = sin(m_angle) * m_axis;\n  Scalar c = cos(m_angle);\n  Vector3 cos1_axis = (Scalar(1)-c) * m_axis;\n\n  Scalar tmp;\n  tmp = cos1_axis.x() * m_axis.y();\n  res.coeffRef(0,1) = tmp - sin_axis.z();\n  res.coeffRef(1,0) = tmp + sin_axis.z();\n\n  tmp = cos1_axis.x() * m_axis.z();\n  res.coeffRef(0,2) = tmp + sin_axis.y();\n  res.coeffRef(2,0) = tmp - sin_axis.y();\n\n  tmp = cos1_axis.y() * m_axis.z();\n  res.coeffRef(1,2) = tmp - sin_axis.x();\n  res.coeffRef(2,1) = tmp + sin_axis.x();\n\n  res.diagonal() = (cos1_axis.cwiseProduct(m_axis)).array() + c;\n\n  return res;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_ANGLEAXIS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/EulerAngles.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_EULERANGLES_H\n#define EIGEN_EULERANGLES_H\n\nnamespace Eigen { \n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  *\n  * \\returns the Euler-angles of the rotation matrix \\c *this using the convention defined by the triplet (\\a a0,\\a a1,\\a a2)\n  *\n  * Each of the three parameters \\a a0,\\a a1,\\a a2 represents the respective rotation axis as an integer in {0,1,2}.\n  * For instance, in:\n  * \\code Vector3f ea = mat.eulerAngles(2, 0, 2); \\endcode\n  * \"2\" represents the z axis and \"0\" the x axis, etc. The returned angles are such that\n  * we have the following equality:\n  * \\code\n  * mat == AngleAxisf(ea[0], Vector3f::UnitZ())\n  *      * AngleAxisf(ea[1], Vector3f::UnitX())\n  *      * AngleAxisf(ea[2], Vector3f::UnitZ()); \\endcode\n  * This corresponds to the right-multiply conventions (with right hand side frames).\n  * \n  * The returned angles are in the ranges [0:pi]x[-pi:pi]x[-pi:pi].\n  * \n  * \\sa class AngleAxis\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC inline Matrix<typename MatrixBase<Derived>::Scalar,3,1>\nMatrixBase<Derived>::eulerAngles(Index a0, Index a1, Index a2) const\n{\n  EIGEN_USING_STD_MATH(atan2)\n  EIGEN_USING_STD_MATH(sin)\n  EIGEN_USING_STD_MATH(cos)\n  /* Implemented from Graphics Gems IV */\n  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,3)\n\n  Matrix<Scalar,3,1> res;\n  typedef Matrix<typename Derived::Scalar,2,1> Vector2;\n\n  const Index odd = ((a0+1)%3 == a1) ? 0 : 1;\n  const Index i = a0;\n  const Index j = (a0 + 1 + odd)%3;\n  const Index k = (a0 + 2 - odd)%3;\n  \n  if (a0==a2)\n  {\n    res[0] = atan2(coeff(j,i), coeff(k,i));\n    if((odd && res[0]<Scalar(0)) || ((!odd) && res[0]>Scalar(0)))\n    {\n      if(res[0] > Scalar(0)) {\n        res[0] -= Scalar(EIGEN_PI);\n      }\n      else {\n        res[0] += Scalar(EIGEN_PI);\n      }\n      Scalar s2 = Vector2(coeff(j,i), coeff(k,i)).norm();\n      res[1] = -atan2(s2, coeff(i,i));\n    }\n    else\n    {\n      Scalar s2 = Vector2(coeff(j,i), coeff(k,i)).norm();\n      res[1] = atan2(s2, coeff(i,i));\n    }\n    \n    // With a=(0,1,0), we have i=0; j=1; k=2, and after computing the first two angles,\n    // we can compute their respective rotation, and apply its inverse to M. Since the result must\n    // be a rotation around x, we have:\n    //\n    //  c2  s1.s2 c1.s2                   1  0   0 \n    //  0   c1    -s1       *    M    =   0  c3  s3\n    //  -s2 s1.c2 c1.c2                   0 -s3  c3\n    //\n    //  Thus:  m11.c1 - m21.s1 = c3  &   m12.c1 - m22.s1 = s3\n    \n    Scalar s1 = sin(res[0]);\n    Scalar c1 = cos(res[0]);\n    res[2] = atan2(c1*coeff(j,k)-s1*coeff(k,k), c1*coeff(j,j) - s1 * coeff(k,j));\n  } \n  else\n  {\n    res[0] = atan2(coeff(j,k), coeff(k,k));\n    Scalar c2 = Vector2(coeff(i,i), coeff(i,j)).norm();\n    if((odd && res[0]<Scalar(0)) || ((!odd) && res[0]>Scalar(0))) {\n      if(res[0] > Scalar(0)) {\n        res[0] -= Scalar(EIGEN_PI);\n      }\n      else {\n        res[0] += Scalar(EIGEN_PI);\n      }\n      res[1] = atan2(-coeff(i,k), -c2);\n    }\n    else\n      res[1] = atan2(-coeff(i,k), c2);\n    Scalar s1 = sin(res[0]);\n    Scalar c1 = cos(res[0]);\n    res[2] = atan2(s1*coeff(k,i)-c1*coeff(j,i), c1*coeff(j,j) - s1 * coeff(k,j));\n  }\n  if (!odd)\n    res = -res;\n  \n  return res;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_EULERANGLES_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/Homogeneous.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_HOMOGENEOUS_H\n#define EIGEN_HOMOGENEOUS_H\n\nnamespace Eigen { \n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\class Homogeneous\n  *\n  * \\brief Expression of one (or a set of) homogeneous vector(s)\n  *\n  * \\param MatrixType the type of the object in which we are making homogeneous\n  *\n  * This class represents an expression of one (or a set of) homogeneous vector(s).\n  * It is the return type of MatrixBase::homogeneous() and most of the time\n  * this is the only way it is used.\n  *\n  * \\sa MatrixBase::homogeneous()\n  */\n\nnamespace internal {\n\ntemplate<typename MatrixType,int Direction>\nstruct traits<Homogeneous<MatrixType,Direction> >\n : traits<MatrixType>\n{\n  typedef typename traits<MatrixType>::StorageKind StorageKind;\n  typedef typename ref_selector<MatrixType>::type MatrixTypeNested;\n  typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;\n  enum {\n    RowsPlusOne = (MatrixType::RowsAtCompileTime != Dynamic) ?\n                  int(MatrixType::RowsAtCompileTime) + 1 : Dynamic,\n    ColsPlusOne = (MatrixType::ColsAtCompileTime != Dynamic) ?\n                  int(MatrixType::ColsAtCompileTime) + 1 : Dynamic,\n    RowsAtCompileTime = Direction==Vertical  ?  RowsPlusOne : MatrixType::RowsAtCompileTime,\n    ColsAtCompileTime = Direction==Horizontal ? ColsPlusOne : MatrixType::ColsAtCompileTime,\n    MaxRowsAtCompileTime = RowsAtCompileTime,\n    MaxColsAtCompileTime = ColsAtCompileTime,\n    TmpFlags = _MatrixTypeNested::Flags & HereditaryBits,\n    Flags = ColsAtCompileTime==1 ? (TmpFlags & ~RowMajorBit)\n          : RowsAtCompileTime==1 ? (TmpFlags | RowMajorBit)\n          : TmpFlags\n  };\n};\n\ntemplate<typename MatrixType,typename Lhs> struct homogeneous_left_product_impl;\ntemplate<typename MatrixType,typename Rhs> struct homogeneous_right_product_impl;\n\n} // end namespace internal\n\ntemplate<typename MatrixType,int _Direction> class Homogeneous\n  : public MatrixBase<Homogeneous<MatrixType,_Direction> >, internal::no_assignment_operator\n{\n  public:\n\n    typedef MatrixType NestedExpression;\n    enum { Direction = _Direction };\n\n    typedef MatrixBase<Homogeneous> Base;\n    EIGEN_DENSE_PUBLIC_INTERFACE(Homogeneous)\n\n    EIGEN_DEVICE_FUNC explicit inline Homogeneous(const MatrixType& matrix)\n      : m_matrix(matrix)\n    {}\n\n    EIGEN_DEVICE_FUNC inline Index rows() const { return m_matrix.rows() + (int(Direction)==Vertical   ? 1 : 0); }\n    EIGEN_DEVICE_FUNC inline Index cols() const { return m_matrix.cols() + (int(Direction)==Horizontal ? 1 : 0); }\n    \n    EIGEN_DEVICE_FUNC const NestedExpression& nestedExpression() const { return m_matrix; }\n\n    template<typename Rhs>\n    EIGEN_DEVICE_FUNC inline const Product<Homogeneous,Rhs>\n    operator* (const MatrixBase<Rhs>& rhs) const\n    {\n      eigen_assert(int(Direction)==Horizontal);\n      return Product<Homogeneous,Rhs>(*this,rhs.derived());\n    }\n\n    template<typename Lhs> friend\n    EIGEN_DEVICE_FUNC inline const Product<Lhs,Homogeneous>\n    operator* (const MatrixBase<Lhs>& lhs, const Homogeneous& rhs)\n    {\n      eigen_assert(int(Direction)==Vertical);\n      return Product<Lhs,Homogeneous>(lhs.derived(),rhs);\n    }\n\n    template<typename Scalar, int Dim, int Mode, int Options> friend\n    EIGEN_DEVICE_FUNC inline const Product<Transform<Scalar,Dim,Mode,Options>, Homogeneous >\n    operator* (const Transform<Scalar,Dim,Mode,Options>& lhs, const Homogeneous& rhs)\n    {\n      eigen_assert(int(Direction)==Vertical);\n      return Product<Transform<Scalar,Dim,Mode,Options>, Homogeneous>(lhs,rhs);\n    }\n\n    template<typename Func>\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename internal::result_of<Func(Scalar,Scalar)>::type\n    redux(const Func& func) const\n    {\n      return func(m_matrix.redux(func), Scalar(1));\n    }\n\n  protected:\n    typename MatrixType::Nested m_matrix;\n};\n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\returns a vector expression that is one longer than the vector argument, with the value 1 symbolically appended as the last coefficient.\n  *\n  * This can be used to convert affine coordinates to homogeneous coordinates.\n  *\n  * \\only_for_vectors\n  *\n  * Example: \\include MatrixBase_homogeneous.cpp\n  * Output: \\verbinclude MatrixBase_homogeneous.out\n  *\n  * \\sa VectorwiseOp::homogeneous(), class Homogeneous\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC inline typename MatrixBase<Derived>::HomogeneousReturnType\nMatrixBase<Derived>::homogeneous() const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);\n  return HomogeneousReturnType(derived());\n}\n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\returns an expression where the value 1 is symbolically appended as the final coefficient to each column (or row) of the matrix.\n  *\n  * This can be used to convert affine coordinates to homogeneous coordinates.\n  *\n  * Example: \\include VectorwiseOp_homogeneous.cpp\n  * Output: \\verbinclude VectorwiseOp_homogeneous.out\n  *\n  * \\sa MatrixBase::homogeneous(), class Homogeneous */\ntemplate<typename ExpressionType, int Direction>\nEIGEN_DEVICE_FUNC inline Homogeneous<ExpressionType,Direction>\nVectorwiseOp<ExpressionType,Direction>::homogeneous() const\n{\n  return HomogeneousReturnType(_expression());\n}\n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\brief homogeneous normalization\n  *\n  * \\returns a vector expression of the N-1 first coefficients of \\c *this divided by that last coefficient.\n  *\n  * This can be used to convert homogeneous coordinates to affine coordinates.\n  *\n  * It is essentially a shortcut for:\n  * \\code\n    this->head(this->size()-1)/this->coeff(this->size()-1);\n    \\endcode\n  *\n  * Example: \\include MatrixBase_hnormalized.cpp\n  * Output: \\verbinclude MatrixBase_hnormalized.out\n  *\n  * \\sa VectorwiseOp::hnormalized() */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC inline const typename MatrixBase<Derived>::HNormalizedReturnType\nMatrixBase<Derived>::hnormalized() const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);\n  return ConstStartMinusOne(derived(),0,0,\n    ColsAtCompileTime==1?size()-1:1,\n    ColsAtCompileTime==1?1:size()-1) / coeff(size()-1);\n}\n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\brief column or row-wise homogeneous normalization\n  *\n  * \\returns an expression of the first N-1 coefficients of each column (or row) of \\c *this divided by the last coefficient of each column (or row).\n  *\n  * This can be used to convert homogeneous coordinates to affine coordinates.\n  *\n  * It is conceptually equivalent to calling MatrixBase::hnormalized() to each column (or row) of \\c *this.\n  *\n  * Example: \\include DirectionWise_hnormalized.cpp\n  * Output: \\verbinclude DirectionWise_hnormalized.out\n  *\n  * \\sa MatrixBase::hnormalized() */\ntemplate<typename ExpressionType, int Direction>\nEIGEN_DEVICE_FUNC inline const typename VectorwiseOp<ExpressionType,Direction>::HNormalizedReturnType\nVectorwiseOp<ExpressionType,Direction>::hnormalized() const\n{\n  return HNormalized_Block(_expression(),0,0,\n      Direction==Vertical   ? _expression().rows()-1 : _expression().rows(),\n      Direction==Horizontal ? _expression().cols()-1 : _expression().cols()).cwiseQuotient(\n      Replicate<HNormalized_Factors,\n                Direction==Vertical   ? HNormalized_SizeMinusOne : 1,\n                Direction==Horizontal ? HNormalized_SizeMinusOne : 1>\n        (HNormalized_Factors(_expression(),\n          Direction==Vertical    ? _expression().rows()-1:0,\n          Direction==Horizontal  ? _expression().cols()-1:0,\n          Direction==Vertical    ? 1 : _expression().rows(),\n          Direction==Horizontal  ? 1 : _expression().cols()),\n         Direction==Vertical   ? _expression().rows()-1 : 1,\n         Direction==Horizontal ? _expression().cols()-1 : 1));\n}\n\nnamespace internal {\n\ntemplate<typename MatrixOrTransformType>\nstruct take_matrix_for_product\n{\n  typedef MatrixOrTransformType type;\n  EIGEN_DEVICE_FUNC static const type& run(const type &x) { return x; }\n};\n\ntemplate<typename Scalar, int Dim, int Mode,int Options>\nstruct take_matrix_for_product<Transform<Scalar, Dim, Mode, Options> >\n{\n  typedef Transform<Scalar, Dim, Mode, Options> TransformType;\n  typedef typename internal::add_const<typename TransformType::ConstAffinePart>::type type;\n  EIGEN_DEVICE_FUNC static type run (const TransformType& x) { return x.affine(); }\n};\n\ntemplate<typename Scalar, int Dim, int Options>\nstruct take_matrix_for_product<Transform<Scalar, Dim, Projective, Options> >\n{\n  typedef Transform<Scalar, Dim, Projective, Options> TransformType;\n  typedef typename TransformType::MatrixType type;\n  EIGEN_DEVICE_FUNC static const type& run (const TransformType& x) { return x.matrix(); }\n};\n\ntemplate<typename MatrixType,typename Lhs>\nstruct traits<homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> >\n{\n  typedef typename take_matrix_for_product<Lhs>::type LhsMatrixType;\n  typedef typename remove_all<MatrixType>::type MatrixTypeCleaned;\n  typedef typename remove_all<LhsMatrixType>::type LhsMatrixTypeCleaned;\n  typedef typename make_proper_matrix_type<\n                 typename traits<MatrixTypeCleaned>::Scalar,\n                 LhsMatrixTypeCleaned::RowsAtCompileTime,\n                 MatrixTypeCleaned::ColsAtCompileTime,\n                 MatrixTypeCleaned::PlainObject::Options,\n                 LhsMatrixTypeCleaned::MaxRowsAtCompileTime,\n                 MatrixTypeCleaned::MaxColsAtCompileTime>::type ReturnType;\n};\n\ntemplate<typename MatrixType,typename Lhs>\nstruct homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs>\n  : public ReturnByValue<homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> >\n{\n  typedef typename traits<homogeneous_left_product_impl>::LhsMatrixType LhsMatrixType;\n  typedef typename remove_all<LhsMatrixType>::type LhsMatrixTypeCleaned;\n  typedef typename remove_all<typename LhsMatrixTypeCleaned::Nested>::type LhsMatrixTypeNested;\n  EIGEN_DEVICE_FUNC homogeneous_left_product_impl(const Lhs& lhs, const MatrixType& rhs)\n    : m_lhs(take_matrix_for_product<Lhs>::run(lhs)),\n      m_rhs(rhs)\n  {}\n\n  EIGEN_DEVICE_FUNC inline Index rows() const { return m_lhs.rows(); }\n  EIGEN_DEVICE_FUNC inline Index cols() const { return m_rhs.cols(); }\n\n  template<typename Dest> EIGEN_DEVICE_FUNC void evalTo(Dest& dst) const\n  {\n    // FIXME investigate how to allow lazy evaluation of this product when possible\n    dst = Block<const LhsMatrixTypeNested,\n              LhsMatrixTypeNested::RowsAtCompileTime,\n              LhsMatrixTypeNested::ColsAtCompileTime==Dynamic?Dynamic:LhsMatrixTypeNested::ColsAtCompileTime-1>\n            (m_lhs,0,0,m_lhs.rows(),m_lhs.cols()-1) * m_rhs;\n    dst += m_lhs.col(m_lhs.cols()-1).rowwise()\n            .template replicate<MatrixType::ColsAtCompileTime>(m_rhs.cols());\n  }\n\n  typename LhsMatrixTypeCleaned::Nested m_lhs;\n  typename MatrixType::Nested m_rhs;\n};\n\ntemplate<typename MatrixType,typename Rhs>\nstruct traits<homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> >\n{\n  typedef typename make_proper_matrix_type<typename traits<MatrixType>::Scalar,\n                 MatrixType::RowsAtCompileTime,\n                 Rhs::ColsAtCompileTime,\n                 MatrixType::PlainObject::Options,\n                 MatrixType::MaxRowsAtCompileTime,\n                 Rhs::MaxColsAtCompileTime>::type ReturnType;\n};\n\ntemplate<typename MatrixType,typename Rhs>\nstruct homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs>\n  : public ReturnByValue<homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> >\n{\n  typedef typename remove_all<typename Rhs::Nested>::type RhsNested;\n  EIGEN_DEVICE_FUNC homogeneous_right_product_impl(const MatrixType& lhs, const Rhs& rhs)\n    : m_lhs(lhs), m_rhs(rhs)\n  {}\n\n  EIGEN_DEVICE_FUNC inline Index rows() const { return m_lhs.rows(); }\n  EIGEN_DEVICE_FUNC inline Index cols() const { return m_rhs.cols(); }\n\n  template<typename Dest> EIGEN_DEVICE_FUNC void evalTo(Dest& dst) const\n  {\n    // FIXME investigate how to allow lazy evaluation of this product when possible\n    dst = m_lhs * Block<const RhsNested,\n                        RhsNested::RowsAtCompileTime==Dynamic?Dynamic:RhsNested::RowsAtCompileTime-1,\n                        RhsNested::ColsAtCompileTime>\n            (m_rhs,0,0,m_rhs.rows()-1,m_rhs.cols());\n    dst += m_rhs.row(m_rhs.rows()-1).colwise()\n            .template replicate<MatrixType::RowsAtCompileTime>(m_lhs.rows());\n  }\n\n  typename MatrixType::Nested m_lhs;\n  typename Rhs::Nested m_rhs;\n};\n\ntemplate<typename ArgType,int Direction>\nstruct evaluator_traits<Homogeneous<ArgType,Direction> >\n{\n  typedef typename storage_kind_to_evaluator_kind<typename ArgType::StorageKind>::Kind Kind;\n  typedef HomogeneousShape Shape;  \n};\n\ntemplate<> struct AssignmentKind<DenseShape,HomogeneousShape> { typedef Dense2Dense Kind; };\n\n\ntemplate<typename ArgType,int Direction>\nstruct unary_evaluator<Homogeneous<ArgType,Direction>, IndexBased>\n  : evaluator<typename Homogeneous<ArgType,Direction>::PlainObject >\n{\n  typedef Homogeneous<ArgType,Direction> XprType;\n  typedef typename XprType::PlainObject PlainObject;\n  typedef evaluator<PlainObject> Base;\n\n  EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& op)\n    : Base(), m_temp(op)\n  {\n    ::new (static_cast<Base*>(this)) Base(m_temp);\n  }\n\nprotected:\n  PlainObject m_temp;\n};\n\n// dense = homogeneous\ntemplate< typename DstXprType, typename ArgType, typename Scalar>\nstruct Assignment<DstXprType, Homogeneous<ArgType,Vertical>, internal::assign_op<Scalar,typename ArgType::Scalar>, Dense2Dense>\n{\n  typedef Homogeneous<ArgType,Vertical> SrcXprType;\n  EIGEN_DEVICE_FUNC static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,typename ArgType::Scalar> &)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n\n    dst.template topRows<ArgType::RowsAtCompileTime>(src.nestedExpression().rows()) = src.nestedExpression();\n    dst.row(dst.rows()-1).setOnes();\n  }\n};\n\n// dense = homogeneous\ntemplate< typename DstXprType, typename ArgType, typename Scalar>\nstruct Assignment<DstXprType, Homogeneous<ArgType,Horizontal>, internal::assign_op<Scalar,typename ArgType::Scalar>, Dense2Dense>\n{\n  typedef Homogeneous<ArgType,Horizontal> SrcXprType;\n  EIGEN_DEVICE_FUNC static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,typename ArgType::Scalar> &)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n\n    dst.template leftCols<ArgType::ColsAtCompileTime>(src.nestedExpression().cols()) = src.nestedExpression();\n    dst.col(dst.cols()-1).setOnes();\n  }\n};\n\ntemplate<typename LhsArg, typename Rhs, int ProductTag>\nstruct generic_product_impl<Homogeneous<LhsArg,Horizontal>, Rhs, HomogeneousShape, DenseShape, ProductTag>\n{\n  template<typename Dest>\n  EIGEN_DEVICE_FUNC static void evalTo(Dest& dst, const Homogeneous<LhsArg,Horizontal>& lhs, const Rhs& rhs)\n  {\n    homogeneous_right_product_impl<Homogeneous<LhsArg,Horizontal>, Rhs>(lhs.nestedExpression(), rhs).evalTo(dst);\n  }\n};\n\ntemplate<typename Lhs,typename Rhs>\nstruct homogeneous_right_product_refactoring_helper\n{\n  enum {\n    Dim  = Lhs::ColsAtCompileTime,\n    Rows = Lhs::RowsAtCompileTime\n  };\n  typedef typename Rhs::template ConstNRowsBlockXpr<Dim>::Type          LinearBlockConst;\n  typedef typename remove_const<LinearBlockConst>::type                 LinearBlock;\n  typedef typename Rhs::ConstRowXpr                                     ConstantColumn;\n  typedef Replicate<const ConstantColumn,Rows,1>                        ConstantBlock;\n  typedef Product<Lhs,LinearBlock,LazyProduct>                          LinearProduct;\n  typedef CwiseBinaryOp<internal::scalar_sum_op<typename Lhs::Scalar,typename Rhs::Scalar>, const LinearProduct, const ConstantBlock> Xpr;\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag>\nstruct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, HomogeneousShape, DenseShape>\n : public evaluator<typename homogeneous_right_product_refactoring_helper<typename Lhs::NestedExpression,Rhs>::Xpr>\n{\n  typedef Product<Lhs, Rhs, LazyProduct> XprType;\n  typedef homogeneous_right_product_refactoring_helper<typename Lhs::NestedExpression,Rhs> helper;\n  typedef typename helper::ConstantBlock ConstantBlock;\n  typedef typename helper::Xpr RefactoredXpr;\n  typedef evaluator<RefactoredXpr> Base;\n  \n  EIGEN_DEVICE_FUNC explicit product_evaluator(const XprType& xpr)\n    : Base(  xpr.lhs().nestedExpression() .lazyProduct(  xpr.rhs().template topRows<helper::Dim>(xpr.lhs().nestedExpression().cols()) )\n            + ConstantBlock(xpr.rhs().row(xpr.rhs().rows()-1),xpr.lhs().rows(), 1) )\n  {}\n};\n\ntemplate<typename Lhs, typename RhsArg, int ProductTag>\nstruct generic_product_impl<Lhs, Homogeneous<RhsArg,Vertical>, DenseShape, HomogeneousShape, ProductTag>\n{\n  template<typename Dest>\n  EIGEN_DEVICE_FUNC static void evalTo(Dest& dst, const Lhs& lhs, const Homogeneous<RhsArg,Vertical>& rhs)\n  {\n    homogeneous_left_product_impl<Homogeneous<RhsArg,Vertical>, Lhs>(lhs, rhs.nestedExpression()).evalTo(dst);\n  }\n};\n\n// TODO: the following specialization is to address a regression from 3.2 to 3.3\n// In the future, this path should be optimized.\ntemplate<typename Lhs, typename RhsArg, int ProductTag>\nstruct generic_product_impl<Lhs, Homogeneous<RhsArg,Vertical>, TriangularShape, HomogeneousShape, ProductTag>\n{\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Lhs& lhs, const Homogeneous<RhsArg,Vertical>& rhs)\n  {\n    dst.noalias() = lhs * rhs.eval();\n  }\n};\n\ntemplate<typename Lhs,typename Rhs>\nstruct homogeneous_left_product_refactoring_helper\n{\n  enum {\n    Dim = Rhs::RowsAtCompileTime,\n    Cols = Rhs::ColsAtCompileTime\n  };\n  typedef typename Lhs::template ConstNColsBlockXpr<Dim>::Type          LinearBlockConst;\n  typedef typename remove_const<LinearBlockConst>::type                 LinearBlock;\n  typedef typename Lhs::ConstColXpr                                     ConstantColumn;\n  typedef Replicate<const ConstantColumn,1,Cols>                        ConstantBlock;\n  typedef Product<LinearBlock,Rhs,LazyProduct>                          LinearProduct;\n  typedef CwiseBinaryOp<internal::scalar_sum_op<typename Lhs::Scalar,typename Rhs::Scalar>, const LinearProduct, const ConstantBlock> Xpr;\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag>\nstruct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape, HomogeneousShape>\n : public evaluator<typename homogeneous_left_product_refactoring_helper<Lhs,typename Rhs::NestedExpression>::Xpr>\n{\n  typedef Product<Lhs, Rhs, LazyProduct> XprType;\n  typedef homogeneous_left_product_refactoring_helper<Lhs,typename Rhs::NestedExpression> helper;\n  typedef typename helper::ConstantBlock ConstantBlock;\n  typedef typename helper::Xpr RefactoredXpr;\n  typedef evaluator<RefactoredXpr> Base;\n  \n  EIGEN_DEVICE_FUNC explicit product_evaluator(const XprType& xpr)\n    : Base(   xpr.lhs().template leftCols<helper::Dim>(xpr.rhs().nestedExpression().rows()) .lazyProduct( xpr.rhs().nestedExpression() )\n            + ConstantBlock(xpr.lhs().col(xpr.lhs().cols()-1),1,xpr.rhs().cols()) )\n  {}\n};\n\ntemplate<typename Scalar, int Dim, int Mode,int Options, typename RhsArg, int ProductTag>\nstruct generic_product_impl<Transform<Scalar,Dim,Mode,Options>, Homogeneous<RhsArg,Vertical>, DenseShape, HomogeneousShape, ProductTag>\n{\n  typedef Transform<Scalar,Dim,Mode,Options> TransformType;\n  template<typename Dest>\n  EIGEN_DEVICE_FUNC static void evalTo(Dest& dst, const TransformType& lhs, const Homogeneous<RhsArg,Vertical>& rhs)\n  {\n    homogeneous_left_product_impl<Homogeneous<RhsArg,Vertical>, TransformType>(lhs, rhs.nestedExpression()).evalTo(dst);\n  }\n};\n\ntemplate<typename ExpressionType, int Side, bool Transposed>\nstruct permutation_matrix_product<ExpressionType, Side, Transposed, HomogeneousShape>\n  : public permutation_matrix_product<ExpressionType, Side, Transposed, DenseShape>\n{};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_HOMOGENEOUS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/Hyperplane.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_HYPERPLANE_H\n#define EIGEN_HYPERPLANE_H\n\nnamespace Eigen { \n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\class Hyperplane\n  *\n  * \\brief A hyperplane\n  *\n  * A hyperplane is an affine subspace of dimension n-1 in a space of dimension n.\n  * For example, a hyperplane in a plane is a line; a hyperplane in 3-space is a plane.\n  *\n  * \\tparam _Scalar the scalar type, i.e., the type of the coefficients\n  * \\tparam _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.\n  *             Notice that the dimension of the hyperplane is _AmbientDim-1.\n  *\n  * This class represents an hyperplane as the zero set of the implicit equation\n  * \\f$ n \\cdot x + d = 0 \\f$ where \\f$ n \\f$ is a unit normal vector of the plane (linear part)\n  * and \\f$ d \\f$ is the distance (offset) to the origin.\n  */\ntemplate <typename _Scalar, int _AmbientDim, int _Options>\nclass Hyperplane\n{\npublic:\n  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim==Dynamic ? Dynamic : _AmbientDim+1)\n  enum {\n    AmbientDimAtCompileTime = _AmbientDim,\n    Options = _Options\n  };\n  typedef _Scalar Scalar;\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n  typedef Matrix<Scalar,AmbientDimAtCompileTime,1> VectorType;\n  typedef Matrix<Scalar,Index(AmbientDimAtCompileTime)==Dynamic\n                        ? Dynamic\n                        : Index(AmbientDimAtCompileTime)+1,1,Options> Coefficients;\n  typedef Block<Coefficients,AmbientDimAtCompileTime,1> NormalReturnType;\n  typedef const Block<const Coefficients,AmbientDimAtCompileTime,1> ConstNormalReturnType;\n\n  /** Default constructor without initialization */\n  EIGEN_DEVICE_FUNC inline Hyperplane() {}\n  \n  template<int OtherOptions>\n  EIGEN_DEVICE_FUNC Hyperplane(const Hyperplane<Scalar,AmbientDimAtCompileTime,OtherOptions>& other)\n   : m_coeffs(other.coeffs())\n  {}\n\n  /** Constructs a dynamic-size hyperplane with \\a _dim the dimension\n    * of the ambient space */\n  EIGEN_DEVICE_FUNC inline explicit Hyperplane(Index _dim) : m_coeffs(_dim+1) {}\n\n  /** Construct a plane from its normal \\a n and a point \\a e onto the plane.\n    * \\warning the vector normal is assumed to be normalized.\n    */\n  EIGEN_DEVICE_FUNC inline Hyperplane(const VectorType& n, const VectorType& e)\n    : m_coeffs(n.size()+1)\n  {\n    normal() = n;\n    offset() = -n.dot(e);\n  }\n\n  /** Constructs a plane from its normal \\a n and distance to the origin \\a d\n    * such that the algebraic equation of the plane is \\f$ n \\cdot x + d = 0 \\f$.\n    * \\warning the vector normal is assumed to be normalized.\n    */\n  EIGEN_DEVICE_FUNC inline Hyperplane(const VectorType& n, const Scalar& d)\n    : m_coeffs(n.size()+1)\n  {\n    normal() = n;\n    offset() = d;\n  }\n\n  /** Constructs a hyperplane passing through the two points. If the dimension of the ambient space\n    * is greater than 2, then there isn't uniqueness, so an arbitrary choice is made.\n    */\n  EIGEN_DEVICE_FUNC static inline Hyperplane Through(const VectorType& p0, const VectorType& p1)\n  {\n    Hyperplane result(p0.size());\n    result.normal() = (p1 - p0).unitOrthogonal();\n    result.offset() = -p0.dot(result.normal());\n    return result;\n  }\n\n  /** Constructs a hyperplane passing through the three points. The dimension of the ambient space\n    * is required to be exactly 3.\n    */\n  EIGEN_DEVICE_FUNC static inline Hyperplane Through(const VectorType& p0, const VectorType& p1, const VectorType& p2)\n  {\n    EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 3)\n    Hyperplane result(p0.size());\n    VectorType v0(p2 - p0), v1(p1 - p0);\n    result.normal() = v0.cross(v1);\n    RealScalar norm = result.normal().norm();\n    if(norm <= v0.norm() * v1.norm() * NumTraits<RealScalar>::epsilon())\n    {\n      Matrix<Scalar,2,3> m; m << v0.transpose(), v1.transpose();\n      JacobiSVD<Matrix<Scalar,2,3> > svd(m, ComputeFullV);\n      result.normal() = svd.matrixV().col(2);\n    }\n    else\n      result.normal() /= norm;\n    result.offset() = -p0.dot(result.normal());\n    return result;\n  }\n\n  /** Constructs a hyperplane passing through the parametrized line \\a parametrized.\n    * If the dimension of the ambient space is greater than 2, then there isn't uniqueness,\n    * so an arbitrary choice is made.\n    */\n  // FIXME to be consitent with the rest this could be implemented as a static Through function ??\n  EIGEN_DEVICE_FUNC explicit Hyperplane(const ParametrizedLine<Scalar, AmbientDimAtCompileTime>& parametrized)\n  {\n    normal() = parametrized.direction().unitOrthogonal();\n    offset() = -parametrized.origin().dot(normal());\n  }\n\n  EIGEN_DEVICE_FUNC ~Hyperplane() {}\n\n  /** \\returns the dimension in which the plane holds */\n  EIGEN_DEVICE_FUNC inline Index dim() const { return AmbientDimAtCompileTime==Dynamic ? m_coeffs.size()-1 : Index(AmbientDimAtCompileTime); }\n\n  /** normalizes \\c *this */\n  EIGEN_DEVICE_FUNC void normalize(void)\n  {\n    m_coeffs /= normal().norm();\n  }\n\n  /** \\returns the signed distance between the plane \\c *this and a point \\a p.\n    * \\sa absDistance()\n    */\n  EIGEN_DEVICE_FUNC inline Scalar signedDistance(const VectorType& p) const { return normal().dot(p) + offset(); }\n\n  /** \\returns the absolute distance between the plane \\c *this and a point \\a p.\n    * \\sa signedDistance()\n    */\n  EIGEN_DEVICE_FUNC inline Scalar absDistance(const VectorType& p) const { return numext::abs(signedDistance(p)); }\n\n  /** \\returns the projection of a point \\a p onto the plane \\c *this.\n    */\n  EIGEN_DEVICE_FUNC inline VectorType projection(const VectorType& p) const { return p - signedDistance(p) * normal(); }\n\n  /** \\returns a constant reference to the unit normal vector of the plane, which corresponds\n    * to the linear part of the implicit equation.\n    */\n  EIGEN_DEVICE_FUNC inline ConstNormalReturnType normal() const { return ConstNormalReturnType(m_coeffs,0,0,dim(),1); }\n\n  /** \\returns a non-constant reference to the unit normal vector of the plane, which corresponds\n    * to the linear part of the implicit equation.\n    */\n  EIGEN_DEVICE_FUNC inline NormalReturnType normal() { return NormalReturnType(m_coeffs,0,0,dim(),1); }\n\n  /** \\returns the distance to the origin, which is also the \"constant term\" of the implicit equation\n    * \\warning the vector normal is assumed to be normalized.\n    */\n  EIGEN_DEVICE_FUNC inline const Scalar& offset() const { return m_coeffs.coeff(dim()); }\n\n  /** \\returns a non-constant reference to the distance to the origin, which is also the constant part\n    * of the implicit equation */\n  EIGEN_DEVICE_FUNC inline Scalar& offset() { return m_coeffs(dim()); }\n\n  /** \\returns a constant reference to the coefficients c_i of the plane equation:\n    * \\f$ c_0*x_0 + ... + c_{d-1}*x_{d-1} + c_d = 0 \\f$\n    */\n  EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs; }\n\n  /** \\returns a non-constant reference to the coefficients c_i of the plane equation:\n    * \\f$ c_0*x_0 + ... + c_{d-1}*x_{d-1} + c_d = 0 \\f$\n    */\n  EIGEN_DEVICE_FUNC inline Coefficients& coeffs() { return m_coeffs; }\n\n  /** \\returns the intersection of *this with \\a other.\n    *\n    * \\warning The ambient space must be a plane, i.e. have dimension 2, so that \\c *this and \\a other are lines.\n    *\n    * \\note If \\a other is approximately parallel to *this, this method will return any point on *this.\n    */\n  EIGEN_DEVICE_FUNC VectorType intersection(const Hyperplane& other) const\n  {\n    EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)\n    Scalar det = coeffs().coeff(0) * other.coeffs().coeff(1) - coeffs().coeff(1) * other.coeffs().coeff(0);\n    // since the line equations ax+by=c are normalized with a^2+b^2=1, the following tests\n    // whether the two lines are approximately parallel.\n    if(internal::isMuchSmallerThan(det, Scalar(1)))\n    {   // special case where the two lines are approximately parallel. Pick any point on the first line.\n        if(numext::abs(coeffs().coeff(1))>numext::abs(coeffs().coeff(0)))\n            return VectorType(coeffs().coeff(1), -coeffs().coeff(2)/coeffs().coeff(1)-coeffs().coeff(0));\n        else\n            return VectorType(-coeffs().coeff(2)/coeffs().coeff(0)-coeffs().coeff(1), coeffs().coeff(0));\n    }\n    else\n    {   // general case\n        Scalar invdet = Scalar(1) / det;\n        return VectorType(invdet*(coeffs().coeff(1)*other.coeffs().coeff(2)-other.coeffs().coeff(1)*coeffs().coeff(2)),\n                          invdet*(other.coeffs().coeff(0)*coeffs().coeff(2)-coeffs().coeff(0)*other.coeffs().coeff(2)));\n    }\n  }\n\n  /** Applies the transformation matrix \\a mat to \\c *this and returns a reference to \\c *this.\n    *\n    * \\param mat the Dim x Dim transformation matrix\n    * \\param traits specifies whether the matrix \\a mat represents an #Isometry\n    *               or a more generic #Affine transformation. The default is #Affine.\n    */\n  template<typename XprType>\n  EIGEN_DEVICE_FUNC inline Hyperplane& transform(const MatrixBase<XprType>& mat, TransformTraits traits = Affine)\n  {\n    if (traits==Affine)\n    {\n      normal() = mat.inverse().transpose() * normal();\n      m_coeffs /= normal().norm();\n    }\n    else if (traits==Isometry)\n      normal() = mat * normal();\n    else\n    {\n      eigen_assert(0 && \"invalid traits value in Hyperplane::transform()\");\n    }\n    return *this;\n  }\n\n  /** Applies the transformation \\a t to \\c *this and returns a reference to \\c *this.\n    *\n    * \\param t the transformation of dimension Dim\n    * \\param traits specifies whether the transformation \\a t represents an #Isometry\n    *               or a more generic #Affine transformation. The default is #Affine.\n    *               Other kind of transformations are not supported.\n    */\n  template<int TrOptions>\n  EIGEN_DEVICE_FUNC inline Hyperplane& transform(const Transform<Scalar,AmbientDimAtCompileTime,Affine,TrOptions>& t,\n                                TransformTraits traits = Affine)\n  {\n    transform(t.linear(), traits);\n    offset() -= normal().dot(t.translation());\n    return *this;\n  }\n\n  /** \\returns \\c *this with scalar type casted to \\a NewScalarType\n    *\n    * Note that if \\a NewScalarType is equal to the current scalar type of \\c *this\n    * then this function smartly returns a const reference to \\c *this.\n    */\n  template<typename NewScalarType>\n  EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<Hyperplane,\n           Hyperplane<NewScalarType,AmbientDimAtCompileTime,Options> >::type cast() const\n  {\n    return typename internal::cast_return_type<Hyperplane,\n                    Hyperplane<NewScalarType,AmbientDimAtCompileTime,Options> >::type(*this);\n  }\n\n  /** Copy constructor with scalar type conversion */\n  template<typename OtherScalarType,int OtherOptions>\n  EIGEN_DEVICE_FUNC inline explicit Hyperplane(const Hyperplane<OtherScalarType,AmbientDimAtCompileTime,OtherOptions>& other)\n  { m_coeffs = other.coeffs().template cast<Scalar>(); }\n\n  /** \\returns \\c true if \\c *this is approximately equal to \\a other, within the precision\n    * determined by \\a prec.\n    *\n    * \\sa MatrixBase::isApprox() */\n  template<int OtherOptions>\n  EIGEN_DEVICE_FUNC bool isApprox(const Hyperplane<Scalar,AmbientDimAtCompileTime,OtherOptions>& other, const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision()) const\n  { return m_coeffs.isApprox(other.m_coeffs, prec); }\n\nprotected:\n\n  Coefficients m_coeffs;\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_HYPERPLANE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/OrthoMethods.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ORTHOMETHODS_H\n#define EIGEN_ORTHOMETHODS_H\n\nnamespace Eigen { \n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\returns the cross product of \\c *this and \\a other\n  *\n  * Here is a very good explanation of cross-product: http://xkcd.com/199/\n  * \n  * With complex numbers, the cross product is implemented as\n  * \\f$ (\\mathbf{a}+i\\mathbf{b}) \\times (\\mathbf{c}+i\\mathbf{d}) = (\\mathbf{a} \\times \\mathbf{c} - \\mathbf{b} \\times \\mathbf{d}) - i(\\mathbf{a} \\times \\mathbf{d} - \\mathbf{b} \\times \\mathbf{c})\\f$\n  * \n  * \\sa MatrixBase::cross3()\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\n#ifndef EIGEN_PARSED_BY_DOXYGEN\nEIGEN_DEVICE_FUNC inline typename MatrixBase<Derived>::template cross_product_return_type<OtherDerived>::type\n#else\ninline typename MatrixBase<Derived>::PlainObject\n#endif\nMatrixBase<Derived>::cross(const MatrixBase<OtherDerived>& other) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived,3)\n  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,3)\n\n  // Note that there is no need for an expression here since the compiler\n  // optimize such a small temporary very well (even within a complex expression)\n  typename internal::nested_eval<Derived,2>::type lhs(derived());\n  typename internal::nested_eval<OtherDerived,2>::type rhs(other.derived());\n  return typename cross_product_return_type<OtherDerived>::type(\n    numext::conj(lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1)),\n    numext::conj(lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2)),\n    numext::conj(lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0))\n  );\n}\n\nnamespace internal {\n\ntemplate< int Arch,typename VectorLhs,typename VectorRhs,\n          typename Scalar = typename VectorLhs::Scalar,\n          bool Vectorizable = bool((VectorLhs::Flags&VectorRhs::Flags)&PacketAccessBit)>\nstruct cross3_impl {\n  EIGEN_DEVICE_FUNC static inline typename internal::plain_matrix_type<VectorLhs>::type\n  run(const VectorLhs& lhs, const VectorRhs& rhs)\n  {\n    return typename internal::plain_matrix_type<VectorLhs>::type(\n      numext::conj(lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1)),\n      numext::conj(lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2)),\n      numext::conj(lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0)),\n      0\n    );\n  }\n};\n\n}\n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\returns the cross product of \\c *this and \\a other using only the x, y, and z coefficients\n  *\n  * The size of \\c *this and \\a other must be four. This function is especially useful\n  * when using 4D vectors instead of 3D ones to get advantage of SSE/AltiVec vectorization.\n  *\n  * \\sa MatrixBase::cross()\n  */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC inline typename MatrixBase<Derived>::PlainObject\nMatrixBase<Derived>::cross3(const MatrixBase<OtherDerived>& other) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived,4)\n  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,4)\n\n  typedef typename internal::nested_eval<Derived,2>::type DerivedNested;\n  typedef typename internal::nested_eval<OtherDerived,2>::type OtherDerivedNested;\n  DerivedNested lhs(derived());\n  OtherDerivedNested rhs(other.derived());\n\n  return internal::cross3_impl<Architecture::Target,\n                        typename internal::remove_all<DerivedNested>::type,\n                        typename internal::remove_all<OtherDerivedNested>::type>::run(lhs,rhs);\n}\n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\returns a matrix expression of the cross product of each column or row\n  * of the referenced expression with the \\a other vector.\n  *\n  * The referenced matrix must have one dimension equal to 3.\n  * The result matrix has the same dimensions than the referenced one.\n  *\n  * \\sa MatrixBase::cross() */\ntemplate<typename ExpressionType, int Direction>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC \nconst typename VectorwiseOp<ExpressionType,Direction>::CrossReturnType\nVectorwiseOp<ExpressionType,Direction>::cross(const MatrixBase<OtherDerived>& other) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,3)\n  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),\n    YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)\n  \n  typename internal::nested_eval<ExpressionType,2>::type mat(_expression());\n  typename internal::nested_eval<OtherDerived,2>::type vec(other.derived());\n\n  CrossReturnType res(_expression().rows(),_expression().cols());\n  if(Direction==Vertical)\n  {\n    eigen_assert(CrossReturnType::RowsAtCompileTime==3 && \"the matrix must have exactly 3 rows\");\n    res.row(0) = (mat.row(1) * vec.coeff(2) - mat.row(2) * vec.coeff(1)).conjugate();\n    res.row(1) = (mat.row(2) * vec.coeff(0) - mat.row(0) * vec.coeff(2)).conjugate();\n    res.row(2) = (mat.row(0) * vec.coeff(1) - mat.row(1) * vec.coeff(0)).conjugate();\n  }\n  else\n  {\n    eigen_assert(CrossReturnType::ColsAtCompileTime==3 && \"the matrix must have exactly 3 columns\");\n    res.col(0) = (mat.col(1) * vec.coeff(2) - mat.col(2) * vec.coeff(1)).conjugate();\n    res.col(1) = (mat.col(2) * vec.coeff(0) - mat.col(0) * vec.coeff(2)).conjugate();\n    res.col(2) = (mat.col(0) * vec.coeff(1) - mat.col(1) * vec.coeff(0)).conjugate();\n  }\n  return res;\n}\n\nnamespace internal {\n\ntemplate<typename Derived, int Size = Derived::SizeAtCompileTime>\nstruct unitOrthogonal_selector\n{\n  typedef typename plain_matrix_type<Derived>::type VectorType;\n  typedef typename traits<Derived>::Scalar Scalar;\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  typedef Matrix<Scalar,2,1> Vector2;\n  EIGEN_DEVICE_FUNC\n  static inline VectorType run(const Derived& src)\n  {\n    VectorType perp = VectorType::Zero(src.size());\n    Index maxi = 0;\n    Index sndi = 0;\n    src.cwiseAbs().maxCoeff(&maxi);\n    if (maxi==0)\n      sndi = 1;\n    RealScalar invnm = RealScalar(1)/(Vector2() << src.coeff(sndi),src.coeff(maxi)).finished().norm();\n    perp.coeffRef(maxi) = -numext::conj(src.coeff(sndi)) * invnm;\n    perp.coeffRef(sndi) =  numext::conj(src.coeff(maxi)) * invnm;\n\n    return perp;\n   }\n};\n\ntemplate<typename Derived>\nstruct unitOrthogonal_selector<Derived,3>\n{\n  typedef typename plain_matrix_type<Derived>::type VectorType;\n  typedef typename traits<Derived>::Scalar Scalar;\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  EIGEN_DEVICE_FUNC\n  static inline VectorType run(const Derived& src)\n  {\n    VectorType perp;\n    /* Let us compute the crossed product of *this with a vector\n     * that is not too close to being colinear to *this.\n     */\n\n    /* unless the x and y coords are both close to zero, we can\n     * simply take ( -y, x, 0 ) and normalize it.\n     */\n    if((!isMuchSmallerThan(src.x(), src.z()))\n    || (!isMuchSmallerThan(src.y(), src.z())))\n    {\n      RealScalar invnm = RealScalar(1)/src.template head<2>().norm();\n      perp.coeffRef(0) = -numext::conj(src.y())*invnm;\n      perp.coeffRef(1) = numext::conj(src.x())*invnm;\n      perp.coeffRef(2) = 0;\n    }\n    /* if both x and y are close to zero, then the vector is close\n     * to the z-axis, so it's far from colinear to the x-axis for instance.\n     * So we take the crossed product with (1,0,0) and normalize it.\n     */\n    else\n    {\n      RealScalar invnm = RealScalar(1)/src.template tail<2>().norm();\n      perp.coeffRef(0) = 0;\n      perp.coeffRef(1) = -numext::conj(src.z())*invnm;\n      perp.coeffRef(2) = numext::conj(src.y())*invnm;\n    }\n\n    return perp;\n   }\n};\n\ntemplate<typename Derived>\nstruct unitOrthogonal_selector<Derived,2>\n{\n  typedef typename plain_matrix_type<Derived>::type VectorType;\n  EIGEN_DEVICE_FUNC\n  static inline VectorType run(const Derived& src)\n  { return VectorType(-numext::conj(src.y()), numext::conj(src.x())).normalized(); }\n};\n\n} // end namespace internal\n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\returns a unit vector which is orthogonal to \\c *this\n  *\n  * The size of \\c *this must be at least 2. If the size is exactly 2,\n  * then the returned vector is a counter clock wise rotation of \\c *this, i.e., (-y,x).normalized().\n  *\n  * \\sa cross()\n  */\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC typename MatrixBase<Derived>::PlainObject\nMatrixBase<Derived>::unitOrthogonal() const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return internal::unitOrthogonal_selector<Derived>::run(derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_ORTHOMETHODS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/ParametrizedLine.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PARAMETRIZEDLINE_H\n#define EIGEN_PARAMETRIZEDLINE_H\n\nnamespace Eigen { \n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\class ParametrizedLine\n  *\n  * \\brief A parametrized line\n  *\n  * A parametrized line is defined by an origin point \\f$ \\mathbf{o} \\f$ and a unit\n  * direction vector \\f$ \\mathbf{d} \\f$ such that the line corresponds to\n  * the set \\f$ l(t) = \\mathbf{o} + t \\mathbf{d} \\f$, \\f$ t \\in \\mathbf{R} \\f$.\n  *\n  * \\tparam _Scalar the scalar type, i.e., the type of the coefficients\n  * \\tparam _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.\n  */\ntemplate <typename _Scalar, int _AmbientDim, int _Options>\nclass ParametrizedLine\n{\npublic:\n  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)\n  enum {\n    AmbientDimAtCompileTime = _AmbientDim,\n    Options = _Options\n  };\n  typedef _Scalar Scalar;\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n  typedef Matrix<Scalar,AmbientDimAtCompileTime,1,Options> VectorType;\n\n  /** Default constructor without initialization */\n  EIGEN_DEVICE_FUNC inline ParametrizedLine() {}\n  \n  template<int OtherOptions>\n  EIGEN_DEVICE_FUNC ParametrizedLine(const ParametrizedLine<Scalar,AmbientDimAtCompileTime,OtherOptions>& other)\n   : m_origin(other.origin()), m_direction(other.direction())\n  {}\n\n  /** Constructs a dynamic-size line with \\a _dim the dimension\n    * of the ambient space */\n  EIGEN_DEVICE_FUNC inline explicit ParametrizedLine(Index _dim) : m_origin(_dim), m_direction(_dim) {}\n\n  /** Initializes a parametrized line of direction \\a direction and origin \\a origin.\n    * \\warning the vector direction is assumed to be normalized.\n    */\n  EIGEN_DEVICE_FUNC ParametrizedLine(const VectorType& origin, const VectorType& direction)\n    : m_origin(origin), m_direction(direction) {}\n\n  template <int OtherOptions>\n  EIGEN_DEVICE_FUNC explicit ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane);\n\n  /** Constructs a parametrized line going from \\a p0 to \\a p1. */\n  EIGEN_DEVICE_FUNC static inline ParametrizedLine Through(const VectorType& p0, const VectorType& p1)\n  { return ParametrizedLine(p0, (p1-p0).normalized()); }\n\n  EIGEN_DEVICE_FUNC ~ParametrizedLine() {}\n\n  /** \\returns the dimension in which the line holds */\n  EIGEN_DEVICE_FUNC inline Index dim() const { return m_direction.size(); }\n\n  EIGEN_DEVICE_FUNC const VectorType& origin() const { return m_origin; }\n  EIGEN_DEVICE_FUNC VectorType& origin() { return m_origin; }\n\n  EIGEN_DEVICE_FUNC const VectorType& direction() const { return m_direction; }\n  EIGEN_DEVICE_FUNC VectorType& direction() { return m_direction; }\n\n  /** \\returns the squared distance of a point \\a p to its projection onto the line \\c *this.\n    * \\sa distance()\n    */\n  EIGEN_DEVICE_FUNC RealScalar squaredDistance(const VectorType& p) const\n  {\n    VectorType diff = p - origin();\n    return (diff - direction().dot(diff) * direction()).squaredNorm();\n  }\n  /** \\returns the distance of a point \\a p to its projection onto the line \\c *this.\n    * \\sa squaredDistance()\n    */\n  EIGEN_DEVICE_FUNC RealScalar distance(const VectorType& p) const { EIGEN_USING_STD_MATH(sqrt) return sqrt(squaredDistance(p)); }\n\n  /** \\returns the projection of a point \\a p onto the line \\c *this. */\n  EIGEN_DEVICE_FUNC VectorType projection(const VectorType& p) const\n  { return origin() + direction().dot(p-origin()) * direction(); }\n\n  EIGEN_DEVICE_FUNC VectorType pointAt(const Scalar& t) const;\n  \n  template <int OtherOptions>\n  EIGEN_DEVICE_FUNC Scalar intersectionParameter(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;\n \n  template <int OtherOptions>\n  EIGEN_DEVICE_FUNC Scalar intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;\n  \n  template <int OtherOptions>\n  EIGEN_DEVICE_FUNC VectorType intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;\n\n  /** \\returns \\c *this with scalar type casted to \\a NewScalarType\n    *\n    * Note that if \\a NewScalarType is equal to the current scalar type of \\c *this\n    * then this function smartly returns a const reference to \\c *this.\n    */\n  template<typename NewScalarType>\n  EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<ParametrizedLine,\n           ParametrizedLine<NewScalarType,AmbientDimAtCompileTime,Options> >::type cast() const\n  {\n    return typename internal::cast_return_type<ParametrizedLine,\n                    ParametrizedLine<NewScalarType,AmbientDimAtCompileTime,Options> >::type(*this);\n  }\n\n  /** Copy constructor with scalar type conversion */\n  template<typename OtherScalarType,int OtherOptions>\n  EIGEN_DEVICE_FUNC inline explicit ParametrizedLine(const ParametrizedLine<OtherScalarType,AmbientDimAtCompileTime,OtherOptions>& other)\n  {\n    m_origin = other.origin().template cast<Scalar>();\n    m_direction = other.direction().template cast<Scalar>();\n  }\n\n  /** \\returns \\c true if \\c *this is approximately equal to \\a other, within the precision\n    * determined by \\a prec.\n    *\n    * \\sa MatrixBase::isApprox() */\n  EIGEN_DEVICE_FUNC bool isApprox(const ParametrizedLine& other, const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision()) const\n  { return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec); }\n\nprotected:\n\n  VectorType m_origin, m_direction;\n};\n\n/** Constructs a parametrized line from a 2D hyperplane\n  *\n  * \\warning the ambient space must have dimension 2 such that the hyperplane actually describes a line\n  */\ntemplate <typename _Scalar, int _AmbientDim, int _Options>\ntemplate <int OtherOptions>\nEIGEN_DEVICE_FUNC inline ParametrizedLine<_Scalar, _AmbientDim,_Options>::ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim,OtherOptions>& hyperplane)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)\n  direction() = hyperplane.normal().unitOrthogonal();\n  origin() = -hyperplane.normal()*hyperplane.offset();\n}\n\n/** \\returns the point at \\a t along this line\n  */\ntemplate <typename _Scalar, int _AmbientDim, int _Options>\nEIGEN_DEVICE_FUNC inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType\nParametrizedLine<_Scalar, _AmbientDim,_Options>::pointAt(const _Scalar& t) const\n{\n  return origin() + (direction()*t); \n}\n\n/** \\returns the parameter value of the intersection between \\c *this and the given \\a hyperplane\n  */\ntemplate <typename _Scalar, int _AmbientDim, int _Options>\ntemplate <int OtherOptions>\nEIGEN_DEVICE_FUNC inline _Scalar ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionParameter(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const\n{\n  return -(hyperplane.offset()+hyperplane.normal().dot(origin()))\n          / hyperplane.normal().dot(direction());\n}\n\n\n/** \\deprecated use intersectionParameter()\n  * \\returns the parameter value of the intersection between \\c *this and the given \\a hyperplane\n  */\ntemplate <typename _Scalar, int _AmbientDim, int _Options>\ntemplate <int OtherOptions>\nEIGEN_DEVICE_FUNC inline _Scalar ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const\n{\n  return intersectionParameter(hyperplane);\n}\n\n/** \\returns the point of the intersection between \\c *this and the given hyperplane\n  */\ntemplate <typename _Scalar, int _AmbientDim, int _Options>\ntemplate <int OtherOptions>\nEIGEN_DEVICE_FUNC inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType\nParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const\n{\n  return pointAt(intersectionParameter(hyperplane));\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_PARAMETRIZEDLINE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/Quaternion.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Mathieu Gautier <mathieu.gautier@cea.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_QUATERNION_H\n#define EIGEN_QUATERNION_H\nnamespace Eigen { \n\n\n/***************************************************************************\n* Definition of QuaternionBase<Derived>\n* The implementation is at the end of the file\n***************************************************************************/\n\nnamespace internal {\ntemplate<typename Other,\n         int OtherRows=Other::RowsAtCompileTime,\n         int OtherCols=Other::ColsAtCompileTime>\nstruct quaternionbase_assign_impl;\n}\n\n/** \\geometry_module \\ingroup Geometry_Module\n  * \\class QuaternionBase\n  * \\brief Base class for quaternion expressions\n  * \\tparam Derived derived type (CRTP)\n  * \\sa class Quaternion\n  */\ntemplate<class Derived>\nclass QuaternionBase : public RotationBase<Derived, 3>\n{\n public:\n  typedef RotationBase<Derived, 3> Base;\n\n  using Base::operator*;\n  using Base::derived;\n\n  typedef typename internal::traits<Derived>::Scalar Scalar;\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  typedef typename internal::traits<Derived>::Coefficients Coefficients;\n  enum {\n    Flags = Eigen::internal::traits<Derived>::Flags\n  };\n\n // typedef typename Matrix<Scalar,4,1> Coefficients;\n  /** the type of a 3D vector */\n  typedef Matrix<Scalar,3,1> Vector3;\n  /** the equivalent rotation matrix type */\n  typedef Matrix<Scalar,3,3> Matrix3;\n  /** the equivalent angle-axis type */\n  typedef AngleAxis<Scalar> AngleAxisType;\n\n\n\n  /** \\returns the \\c x coefficient */\n  EIGEN_DEVICE_FUNC inline Scalar x() const { return this->derived().coeffs().coeff(0); }\n  /** \\returns the \\c y coefficient */\n  EIGEN_DEVICE_FUNC inline Scalar y() const { return this->derived().coeffs().coeff(1); }\n  /** \\returns the \\c z coefficient */\n  EIGEN_DEVICE_FUNC inline Scalar z() const { return this->derived().coeffs().coeff(2); }\n  /** \\returns the \\c w coefficient */\n  EIGEN_DEVICE_FUNC inline Scalar w() const { return this->derived().coeffs().coeff(3); }\n\n  /** \\returns a reference to the \\c x coefficient */\n  EIGEN_DEVICE_FUNC inline Scalar& x() { return this->derived().coeffs().coeffRef(0); }\n  /** \\returns a reference to the \\c y coefficient */\n  EIGEN_DEVICE_FUNC inline Scalar& y() { return this->derived().coeffs().coeffRef(1); }\n  /** \\returns a reference to the \\c z coefficient */\n  EIGEN_DEVICE_FUNC inline Scalar& z() { return this->derived().coeffs().coeffRef(2); }\n  /** \\returns a reference to the \\c w coefficient */\n  EIGEN_DEVICE_FUNC inline Scalar& w() { return this->derived().coeffs().coeffRef(3); }\n\n  /** \\returns a read-only vector expression of the imaginary part (x,y,z) */\n  EIGEN_DEVICE_FUNC inline const VectorBlock<const Coefficients,3> vec() const { return coeffs().template head<3>(); }\n\n  /** \\returns a vector expression of the imaginary part (x,y,z) */\n  EIGEN_DEVICE_FUNC inline VectorBlock<Coefficients,3> vec() { return coeffs().template head<3>(); }\n\n  /** \\returns a read-only vector expression of the coefficients (x,y,z,w) */\n  EIGEN_DEVICE_FUNC inline const typename internal::traits<Derived>::Coefficients& coeffs() const { return derived().coeffs(); }\n\n  /** \\returns a vector expression of the coefficients (x,y,z,w) */\n  EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Coefficients& coeffs() { return derived().coeffs(); }\n\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE QuaternionBase<Derived>& operator=(const QuaternionBase<Derived>& other);\n  template<class OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const QuaternionBase<OtherDerived>& other);\n\n// disabled this copy operator as it is giving very strange compilation errors when compiling\n// test_stdvector with GCC 4.4.2. This looks like a GCC bug though, so feel free to re-enable it if it's\n// useful; however notice that we already have the templated operator= above and e.g. in MatrixBase\n// we didn't have to add, in addition to templated operator=, such a non-templated copy operator.\n//  Derived& operator=(const QuaternionBase& other)\n//  { return operator=<Derived>(other); }\n\n  EIGEN_DEVICE_FUNC Derived& operator=(const AngleAxisType& aa);\n  template<class OtherDerived> EIGEN_DEVICE_FUNC Derived& operator=(const MatrixBase<OtherDerived>& m);\n\n  /** \\returns a quaternion representing an identity rotation\n    * \\sa MatrixBase::Identity()\n    */\n  EIGEN_DEVICE_FUNC static inline Quaternion<Scalar> Identity() { return Quaternion<Scalar>(Scalar(1), Scalar(0), Scalar(0), Scalar(0)); }\n\n  /** \\sa QuaternionBase::Identity(), MatrixBase::setIdentity()\n    */\n  EIGEN_DEVICE_FUNC inline QuaternionBase& setIdentity() { coeffs() << Scalar(0), Scalar(0), Scalar(0), Scalar(1); return *this; }\n\n  /** \\returns the squared norm of the quaternion's coefficients\n    * \\sa QuaternionBase::norm(), MatrixBase::squaredNorm()\n    */\n  EIGEN_DEVICE_FUNC inline Scalar squaredNorm() const { return coeffs().squaredNorm(); }\n\n  /** \\returns the norm of the quaternion's coefficients\n    * \\sa QuaternionBase::squaredNorm(), MatrixBase::norm()\n    */\n  EIGEN_DEVICE_FUNC inline Scalar norm() const { return coeffs().norm(); }\n\n  /** Normalizes the quaternion \\c *this\n    * \\sa normalized(), MatrixBase::normalize() */\n  EIGEN_DEVICE_FUNC inline void normalize() { coeffs().normalize(); }\n  /** \\returns a normalized copy of \\c *this\n    * \\sa normalize(), MatrixBase::normalized() */\n  EIGEN_DEVICE_FUNC inline Quaternion<Scalar> normalized() const { return Quaternion<Scalar>(coeffs().normalized()); }\n\n    /** \\returns the dot product of \\c *this and \\a other\n    * Geometrically speaking, the dot product of two unit quaternions\n    * corresponds to the cosine of half the angle between the two rotations.\n    * \\sa angularDistance()\n    */\n  template<class OtherDerived> EIGEN_DEVICE_FUNC inline Scalar dot(const QuaternionBase<OtherDerived>& other) const { return coeffs().dot(other.coeffs()); }\n\n  template<class OtherDerived> EIGEN_DEVICE_FUNC Scalar angularDistance(const QuaternionBase<OtherDerived>& other) const;\n\n  /** \\returns an equivalent 3x3 rotation matrix */\n  EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix() const;\n\n  /** \\returns the quaternion which transform \\a a into \\a b through a rotation */\n  template<typename Derived1, typename Derived2>\n  EIGEN_DEVICE_FUNC Derived& setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);\n\n  template<class OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion<Scalar> operator* (const QuaternionBase<OtherDerived>& q) const;\n  template<class OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator*= (const QuaternionBase<OtherDerived>& q);\n\n  /** \\returns the quaternion describing the inverse rotation */\n  EIGEN_DEVICE_FUNC Quaternion<Scalar> inverse() const;\n\n  /** \\returns the conjugated quaternion */\n  EIGEN_DEVICE_FUNC Quaternion<Scalar> conjugate() const;\n\n  template<class OtherDerived> EIGEN_DEVICE_FUNC Quaternion<Scalar> slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const;\n\n  /** \\returns \\c true if \\c *this is approximately equal to \\a other, within the precision\n    * determined by \\a prec.\n    *\n    * \\sa MatrixBase::isApprox() */\n  template<class OtherDerived>\n  EIGEN_DEVICE_FUNC bool isApprox(const QuaternionBase<OtherDerived>& other, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const\n  { return coeffs().isApprox(other.coeffs(), prec); }\n\n  /** return the result vector of \\a v through the rotation*/\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Vector3 _transformVector(const Vector3& v) const;\n\n  /** \\returns \\c *this with scalar type casted to \\a NewScalarType\n    *\n    * Note that if \\a NewScalarType is equal to the current scalar type of \\c *this\n    * then this function smartly returns a const reference to \\c *this.\n    */\n  template<typename NewScalarType>\n  EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type cast() const\n  {\n    return typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type(derived());\n  }\n\n#ifdef EIGEN_QUATERNIONBASE_PLUGIN\n# include EIGEN_QUATERNIONBASE_PLUGIN\n#endif\n};\n\n/***************************************************************************\n* Definition/implementation of Quaternion<Scalar>\n***************************************************************************/\n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\class Quaternion\n  *\n  * \\brief The quaternion class used to represent 3D orientations and rotations\n  *\n  * \\tparam _Scalar the scalar type, i.e., the type of the coefficients\n  * \\tparam _Options controls the memory alignment of the coefficients. Can be \\# AutoAlign or \\# DontAlign. Default is AutoAlign.\n  *\n  * This class represents a quaternion \\f$ w+xi+yj+zk \\f$ that is a convenient representation of\n  * orientations and rotations of objects in three dimensions. Compared to other representations\n  * like Euler angles or 3x3 matrices, quaternions offer the following advantages:\n  * \\li \\b compact storage (4 scalars)\n  * \\li \\b efficient to compose (28 flops),\n  * \\li \\b stable spherical interpolation\n  *\n  * The following two typedefs are provided for convenience:\n  * \\li \\c Quaternionf for \\c float\n  * \\li \\c Quaterniond for \\c double\n  *\n  * \\warning Operations interpreting the quaternion as rotation have undefined behavior if the quaternion is not normalized.\n  *\n  * \\sa  class AngleAxis, class Transform\n  */\n\nnamespace internal {\ntemplate<typename _Scalar,int _Options>\nstruct traits<Quaternion<_Scalar,_Options> >\n{\n  typedef Quaternion<_Scalar,_Options> PlainObject;\n  typedef _Scalar Scalar;\n  typedef Matrix<_Scalar,4,1,_Options> Coefficients;\n  enum{\n    Alignment = internal::traits<Coefficients>::Alignment,\n    Flags = LvalueBit\n  };\n};\n}\n\ntemplate<typename _Scalar, int _Options>\nclass Quaternion : public QuaternionBase<Quaternion<_Scalar,_Options> >\n{\npublic:\n  typedef QuaternionBase<Quaternion<_Scalar,_Options> > Base;\n  enum { NeedsAlignment = internal::traits<Quaternion>::Alignment>0 };\n\n  typedef _Scalar Scalar;\n\n  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Quaternion)\n  using Base::operator*=;\n\n  typedef typename internal::traits<Quaternion>::Coefficients Coefficients;\n  typedef typename Base::AngleAxisType AngleAxisType;\n\n  /** Default constructor leaving the quaternion uninitialized. */\n  EIGEN_DEVICE_FUNC inline Quaternion() {}\n\n  /** Constructs and initializes the quaternion \\f$ w+xi+yj+zk \\f$ from\n    * its four coefficients \\a w, \\a x, \\a y and \\a z.\n    *\n    * \\warning Note the order of the arguments: the real \\a w coefficient first,\n    * while internally the coefficients are stored in the following order:\n    * [\\c x, \\c y, \\c z, \\c w]\n    */\n  EIGEN_DEVICE_FUNC inline Quaternion(const Scalar& w, const Scalar& x, const Scalar& y, const Scalar& z) : m_coeffs(x, y, z, w){}\n\n  /** Constructs and initialize a quaternion from the array data */\n  EIGEN_DEVICE_FUNC explicit inline Quaternion(const Scalar* data) : m_coeffs(data) {}\n\n  /** Copy constructor */\n  template<class Derived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion(const QuaternionBase<Derived>& other) { this->Base::operator=(other); }\n\n  /** Constructs and initializes a quaternion from the angle-axis \\a aa */\n  EIGEN_DEVICE_FUNC explicit inline Quaternion(const AngleAxisType& aa) { *this = aa; }\n\n  /** Constructs and initializes a quaternion from either:\n    *  - a rotation matrix expression,\n    *  - a 4D vector expression representing quaternion coefficients.\n    */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC explicit inline Quaternion(const MatrixBase<Derived>& other) { *this = other; }\n\n  /** Explicit copy constructor with scalar conversion */\n  template<typename OtherScalar, int OtherOptions>\n  EIGEN_DEVICE_FUNC explicit inline Quaternion(const Quaternion<OtherScalar, OtherOptions>& other)\n  { m_coeffs = other.coeffs().template cast<Scalar>(); }\n\n  EIGEN_DEVICE_FUNC static Quaternion UnitRandom();\n\n  template<typename Derived1, typename Derived2>\n  EIGEN_DEVICE_FUNC static Quaternion FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);\n\n  EIGEN_DEVICE_FUNC inline Coefficients& coeffs() { return m_coeffs;}\n  EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs;}\n\n  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(bool(NeedsAlignment))\n  \n#ifdef EIGEN_QUATERNION_PLUGIN\n# include EIGEN_QUATERNION_PLUGIN\n#endif\n\nprotected:\n  Coefficients m_coeffs;\n  \n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    static EIGEN_STRONG_INLINE void _check_template_params()\n    {\n      EIGEN_STATIC_ASSERT( (_Options & DontAlign) == _Options,\n        INVALID_MATRIX_TEMPLATE_PARAMETERS)\n    }\n#endif\n};\n\n/** \\ingroup Geometry_Module\n  * single precision quaternion type */\ntypedef Quaternion<float> Quaternionf;\n/** \\ingroup Geometry_Module\n  * double precision quaternion type */\ntypedef Quaternion<double> Quaterniond;\n\n/***************************************************************************\n* Specialization of Map<Quaternion<Scalar>>\n***************************************************************************/\n\nnamespace internal {\n  template<typename _Scalar, int _Options>\n  struct traits<Map<Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >\n  {\n    typedef Map<Matrix<_Scalar,4,1>, _Options> Coefficients;\n  };\n}\n\nnamespace internal {\n  template<typename _Scalar, int _Options>\n  struct traits<Map<const Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >\n  {\n    typedef Map<const Matrix<_Scalar,4,1>, _Options> Coefficients;\n    typedef traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> > TraitsBase;\n    enum {\n      Flags = TraitsBase::Flags & ~LvalueBit\n    };\n  };\n}\n\n/** \\ingroup Geometry_Module\n  * \\brief Quaternion expression mapping a constant memory buffer\n  *\n  * \\tparam _Scalar the type of the Quaternion coefficients\n  * \\tparam _Options see class Map\n  *\n  * This is a specialization of class Map for Quaternion. This class allows to view\n  * a 4 scalar memory buffer as an Eigen's Quaternion object.\n  *\n  * \\sa class Map, class Quaternion, class QuaternionBase\n  */\ntemplate<typename _Scalar, int _Options>\nclass Map<const Quaternion<_Scalar>, _Options >\n  : public QuaternionBase<Map<const Quaternion<_Scalar>, _Options> >\n{\n  public:\n    typedef QuaternionBase<Map<const Quaternion<_Scalar>, _Options> > Base;\n\n    typedef _Scalar Scalar;\n    typedef typename internal::traits<Map>::Coefficients Coefficients;\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)\n    using Base::operator*=;\n\n    /** Constructs a Mapped Quaternion object from the pointer \\a coeffs\n      *\n      * The pointer \\a coeffs must reference the four coefficients of Quaternion in the following order:\n      * \\code *coeffs == {x, y, z, w} \\endcode\n      *\n      * If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */\n    EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE Map(const Scalar* coeffs) : m_coeffs(coeffs) {}\n\n    EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs;}\n\n  protected:\n    const Coefficients m_coeffs;\n};\n\n/** \\ingroup Geometry_Module\n  * \\brief Expression of a quaternion from a memory buffer\n  *\n  * \\tparam _Scalar the type of the Quaternion coefficients\n  * \\tparam _Options see class Map\n  *\n  * This is a specialization of class Map for Quaternion. This class allows to view\n  * a 4 scalar memory buffer as an Eigen's  Quaternion object.\n  *\n  * \\sa class Map, class Quaternion, class QuaternionBase\n  */\ntemplate<typename _Scalar, int _Options>\nclass Map<Quaternion<_Scalar>, _Options >\n  : public QuaternionBase<Map<Quaternion<_Scalar>, _Options> >\n{\n  public:\n    typedef QuaternionBase<Map<Quaternion<_Scalar>, _Options> > Base;\n\n    typedef _Scalar Scalar;\n    typedef typename internal::traits<Map>::Coefficients Coefficients;\n    EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)\n    using Base::operator*=;\n\n    /** Constructs a Mapped Quaternion object from the pointer \\a coeffs\n      *\n      * The pointer \\a coeffs must reference the four coefficients of Quaternion in the following order:\n      * \\code *coeffs == {x, y, z, w} \\endcode\n      *\n      * If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */\n    EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE Map(Scalar* coeffs) : m_coeffs(coeffs) {}\n\n    EIGEN_DEVICE_FUNC inline Coefficients& coeffs() { return m_coeffs; }\n    EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs; }\n\n  protected:\n    Coefficients m_coeffs;\n};\n\n/** \\ingroup Geometry_Module\n  * Map an unaligned array of single precision scalars as a quaternion */\ntypedef Map<Quaternion<float>, 0>         QuaternionMapf;\n/** \\ingroup Geometry_Module\n  * Map an unaligned array of double precision scalars as a quaternion */\ntypedef Map<Quaternion<double>, 0>        QuaternionMapd;\n/** \\ingroup Geometry_Module\n  * Map a 16-byte aligned array of single precision scalars as a quaternion */\ntypedef Map<Quaternion<float>, Aligned>   QuaternionMapAlignedf;\n/** \\ingroup Geometry_Module\n  * Map a 16-byte aligned array of double precision scalars as a quaternion */\ntypedef Map<Quaternion<double>, Aligned>  QuaternionMapAlignedd;\n\n/***************************************************************************\n* Implementation of QuaternionBase methods\n***************************************************************************/\n\n// Generic Quaternion * Quaternion product\n// This product can be specialized for a given architecture via the Arch template argument.\nnamespace internal {\ntemplate<int Arch, class Derived1, class Derived2, typename Scalar> struct quat_product\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Quaternion<Scalar> run(const QuaternionBase<Derived1>& a, const QuaternionBase<Derived2>& b){\n    return Quaternion<Scalar>\n    (\n      a.w() * b.w() - a.x() * b.x() - a.y() * b.y() - a.z() * b.z(),\n      a.w() * b.x() + a.x() * b.w() + a.y() * b.z() - a.z() * b.y(),\n      a.w() * b.y() + a.y() * b.w() + a.z() * b.x() - a.x() * b.z(),\n      a.w() * b.z() + a.z() * b.w() + a.x() * b.y() - a.y() * b.x()\n    );\n  }\n};\n}\n\n/** \\returns the concatenation of two rotations as a quaternion-quaternion product */\ntemplate <class Derived>\ntemplate <class OtherDerived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion<typename internal::traits<Derived>::Scalar>\nQuaternionBase<Derived>::operator* (const QuaternionBase<OtherDerived>& other) const\n{\n  EIGEN_STATIC_ASSERT((internal::is_same<typename Derived::Scalar, typename OtherDerived::Scalar>::value),\n   YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)\n  return internal::quat_product<Architecture::Target, Derived, OtherDerived,\n                         typename internal::traits<Derived>::Scalar>::run(*this, other);\n}\n\n/** \\sa operator*(Quaternion) */\ntemplate <class Derived>\ntemplate <class OtherDerived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator*= (const QuaternionBase<OtherDerived>& other)\n{\n  derived() = derived() * other.derived();\n  return derived();\n}\n\n/** Rotation of a vector by a quaternion.\n  * \\remarks If the quaternion is used to rotate several points (>1)\n  * then it is much more efficient to first convert it to a 3x3 Matrix.\n  * Comparison of the operation cost for n transformations:\n  *   - Quaternion2:    30n\n  *   - Via a Matrix3: 24 + 15n\n  */\ntemplate <class Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename QuaternionBase<Derived>::Vector3\nQuaternionBase<Derived>::_transformVector(const Vector3& v) const\n{\n    // Note that this algorithm comes from the optimization by hand\n    // of the conversion to a Matrix followed by a Matrix/Vector product.\n    // It appears to be much faster than the common algorithm found\n    // in the literature (30 versus 39 flops). It also requires two\n    // Vector3 as temporaries.\n    Vector3 uv = this->vec().cross(v);\n    uv += uv;\n    return v + this->w() * uv + this->vec().cross(uv);\n}\n\ntemplate<class Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE QuaternionBase<Derived>& QuaternionBase<Derived>::operator=(const QuaternionBase<Derived>& other)\n{\n  coeffs() = other.coeffs();\n  return derived();\n}\n\ntemplate<class Derived>\ntemplate<class OtherDerived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const QuaternionBase<OtherDerived>& other)\n{\n  coeffs() = other.coeffs();\n  return derived();\n}\n\n/** Set \\c *this from an angle-axis \\a aa and returns a reference to \\c *this\n  */\ntemplate<class Derived>\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const AngleAxisType& aa)\n{\n  EIGEN_USING_STD_MATH(cos)\n  EIGEN_USING_STD_MATH(sin)\n  Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings\n  this->w() = cos(ha);\n  this->vec() = sin(ha) * aa.axis();\n  return derived();\n}\n\n/** Set \\c *this from the expression \\a xpr:\n  *   - if \\a xpr is a 4x1 vector, then \\a xpr is assumed to be a quaternion\n  *   - if \\a xpr is a 3x3 matrix, then \\a xpr is assumed to be rotation matrix\n  *     and \\a xpr is converted to a quaternion\n  */\n\ntemplate<class Derived>\ntemplate<class MatrixDerived>\nEIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::operator=(const MatrixBase<MatrixDerived>& xpr)\n{\n  EIGEN_STATIC_ASSERT((internal::is_same<typename Derived::Scalar, typename MatrixDerived::Scalar>::value),\n   YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)\n  internal::quaternionbase_assign_impl<MatrixDerived>::run(*this, xpr.derived());\n  return derived();\n}\n\n/** Convert the quaternion to a 3x3 rotation matrix. The quaternion is required to\n  * be normalized, otherwise the result is undefined.\n  */\ntemplate<class Derived>\nEIGEN_DEVICE_FUNC inline typename QuaternionBase<Derived>::Matrix3\nQuaternionBase<Derived>::toRotationMatrix(void) const\n{\n  // NOTE if inlined, then gcc 4.2 and 4.4 get rid of the temporary (not gcc 4.3 !!)\n  // if not inlined then the cost of the return by value is huge ~ +35%,\n  // however, not inlining this function is an order of magnitude slower, so\n  // it has to be inlined, and so the return by value is not an issue\n  Matrix3 res;\n\n  const Scalar tx  = Scalar(2)*this->x();\n  const Scalar ty  = Scalar(2)*this->y();\n  const Scalar tz  = Scalar(2)*this->z();\n  const Scalar twx = tx*this->w();\n  const Scalar twy = ty*this->w();\n  const Scalar twz = tz*this->w();\n  const Scalar txx = tx*this->x();\n  const Scalar txy = ty*this->x();\n  const Scalar txz = tz*this->x();\n  const Scalar tyy = ty*this->y();\n  const Scalar tyz = tz*this->y();\n  const Scalar tzz = tz*this->z();\n\n  res.coeffRef(0,0) = Scalar(1)-(tyy+tzz);\n  res.coeffRef(0,1) = txy-twz;\n  res.coeffRef(0,2) = txz+twy;\n  res.coeffRef(1,0) = txy+twz;\n  res.coeffRef(1,1) = Scalar(1)-(txx+tzz);\n  res.coeffRef(1,2) = tyz-twx;\n  res.coeffRef(2,0) = txz-twy;\n  res.coeffRef(2,1) = tyz+twx;\n  res.coeffRef(2,2) = Scalar(1)-(txx+tyy);\n\n  return res;\n}\n\n/** Sets \\c *this to be a quaternion representing a rotation between\n  * the two arbitrary vectors \\a a and \\a b. In other words, the built\n  * rotation represent a rotation sending the line of direction \\a a\n  * to the line of direction \\a b, both lines passing through the origin.\n  *\n  * \\returns a reference to \\c *this.\n  *\n  * Note that the two input vectors do \\b not have to be normalized, and\n  * do not need to have the same norm.\n  */\ntemplate<class Derived>\ntemplate<typename Derived1, typename Derived2>\nEIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)\n{\n  EIGEN_USING_STD_MATH(sqrt)\n  Vector3 v0 = a.normalized();\n  Vector3 v1 = b.normalized();\n  Scalar c = v1.dot(v0);\n\n  // if dot == -1, vectors are nearly opposites\n  // => accurately compute the rotation axis by computing the\n  //    intersection of the two planes. This is done by solving:\n  //       x^T v0 = 0\n  //       x^T v1 = 0\n  //    under the constraint:\n  //       ||x|| = 1\n  //    which yields a singular value problem\n  if (c < Scalar(-1)+NumTraits<Scalar>::dummy_precision())\n  {\n    c = numext::maxi(c,Scalar(-1));\n    Matrix<Scalar,2,3> m; m << v0.transpose(), v1.transpose();\n    JacobiSVD<Matrix<Scalar,2,3> > svd(m, ComputeFullV);\n    Vector3 axis = svd.matrixV().col(2);\n\n    Scalar w2 = (Scalar(1)+c)*Scalar(0.5);\n    this->w() = sqrt(w2);\n    this->vec() = axis * sqrt(Scalar(1) - w2);\n    return derived();\n  }\n  Vector3 axis = v0.cross(v1);\n  Scalar s = sqrt((Scalar(1)+c)*Scalar(2));\n  Scalar invs = Scalar(1)/s;\n  this->vec() = axis * invs;\n  this->w() = s * Scalar(0.5);\n\n  return derived();\n}\n\n/** \\returns a random unit quaternion following a uniform distribution law on SO(3)\n  *\n  * \\note The implementation is based on http://planning.cs.uiuc.edu/node198.html\n  */\ntemplate<typename Scalar, int Options>\nEIGEN_DEVICE_FUNC Quaternion<Scalar,Options> Quaternion<Scalar,Options>::UnitRandom()\n{\n  EIGEN_USING_STD_MATH(sqrt)\n  EIGEN_USING_STD_MATH(sin)\n  EIGEN_USING_STD_MATH(cos)\n  const Scalar u1 = internal::random<Scalar>(0, 1),\n               u2 = internal::random<Scalar>(0, 2*EIGEN_PI),\n               u3 = internal::random<Scalar>(0, 2*EIGEN_PI);\n  const Scalar a = sqrt(1 - u1),\n               b = sqrt(u1);\n  return Quaternion (a * sin(u2), a * cos(u2), b * sin(u3), b * cos(u3));\n}\n\n\n/** Returns a quaternion representing a rotation between\n  * the two arbitrary vectors \\a a and \\a b. In other words, the built\n  * rotation represent a rotation sending the line of direction \\a a\n  * to the line of direction \\a b, both lines passing through the origin.\n  *\n  * \\returns resulting quaternion\n  *\n  * Note that the two input vectors do \\b not have to be normalized, and\n  * do not need to have the same norm.\n  */\ntemplate<typename Scalar, int Options>\ntemplate<typename Derived1, typename Derived2>\nEIGEN_DEVICE_FUNC Quaternion<Scalar,Options> Quaternion<Scalar,Options>::FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)\n{\n    Quaternion quat;\n    quat.setFromTwoVectors(a, b);\n    return quat;\n}\n\n\n/** \\returns the multiplicative inverse of \\c *this\n  * Note that in most cases, i.e., if you simply want the opposite rotation,\n  * and/or the quaternion is normalized, then it is enough to use the conjugate.\n  *\n  * \\sa QuaternionBase::conjugate()\n  */\ntemplate <class Derived>\nEIGEN_DEVICE_FUNC inline Quaternion<typename internal::traits<Derived>::Scalar> QuaternionBase<Derived>::inverse() const\n{\n  // FIXME should this function be called multiplicativeInverse and conjugate() be called inverse() or opposite()  ??\n  Scalar n2 = this->squaredNorm();\n  if (n2 > Scalar(0))\n    return Quaternion<Scalar>(conjugate().coeffs() / n2);\n  else\n  {\n    // return an invalid result to flag the error\n    return Quaternion<Scalar>(Coefficients::Zero());\n  }\n}\n\n// Generic conjugate of a Quaternion\nnamespace internal {\ntemplate<int Arch, class Derived, typename Scalar> struct quat_conj\n{\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Quaternion<Scalar> run(const QuaternionBase<Derived>& q){\n    return Quaternion<Scalar>(q.w(),-q.x(),-q.y(),-q.z());\n  }\n};\n}\n                         \n/** \\returns the conjugate of the \\c *this which is equal to the multiplicative inverse\n  * if the quaternion is normalized.\n  * The conjugate of a quaternion represents the opposite rotation.\n  *\n  * \\sa Quaternion2::inverse()\n  */\ntemplate <class Derived>\nEIGEN_DEVICE_FUNC inline Quaternion<typename internal::traits<Derived>::Scalar>\nQuaternionBase<Derived>::conjugate() const\n{\n  return internal::quat_conj<Architecture::Target, Derived,\n                         typename internal::traits<Derived>::Scalar>::run(*this);\n                         \n}\n\n/** \\returns the angle (in radian) between two rotations\n  * \\sa dot()\n  */\ntemplate <class Derived>\ntemplate <class OtherDerived>\nEIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Scalar\nQuaternionBase<Derived>::angularDistance(const QuaternionBase<OtherDerived>& other) const\n{\n  EIGEN_USING_STD_MATH(atan2)\n  Quaternion<Scalar> d = (*this) * other.conjugate();\n  return Scalar(2) * atan2( d.vec().norm(), numext::abs(d.w()) );\n}\n\n \n    \n/** \\returns the spherical linear interpolation between the two quaternions\n  * \\c *this and \\a other at the parameter \\a t in [0;1].\n  * \n  * This represents an interpolation for a constant motion between \\c *this and \\a other,\n  * see also http://en.wikipedia.org/wiki/Slerp.\n  */\ntemplate <class Derived>\ntemplate <class OtherDerived>\nEIGEN_DEVICE_FUNC Quaternion<typename internal::traits<Derived>::Scalar>\nQuaternionBase<Derived>::slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const\n{\n  EIGEN_USING_STD_MATH(acos)\n  EIGEN_USING_STD_MATH(sin)\n  const Scalar one = Scalar(1) - NumTraits<Scalar>::epsilon();\n  Scalar d = this->dot(other);\n  Scalar absD = numext::abs(d);\n\n  Scalar scale0;\n  Scalar scale1;\n\n  if(absD>=one)\n  {\n    scale0 = Scalar(1) - t;\n    scale1 = t;\n  }\n  else\n  {\n    // theta is the angle between the 2 quaternions\n    Scalar theta = acos(absD);\n    Scalar sinTheta = sin(theta);\n\n    scale0 = sin( ( Scalar(1) - t ) * theta) / sinTheta;\n    scale1 = sin( ( t * theta) ) / sinTheta;\n  }\n  if(d<Scalar(0)) scale1 = -scale1;\n\n  return Quaternion<Scalar>(scale0 * coeffs() + scale1 * other.coeffs());\n}\n\nnamespace internal {\n\n// set from a rotation matrix\ntemplate<typename Other>\nstruct quaternionbase_assign_impl<Other,3,3>\n{\n  typedef typename Other::Scalar Scalar;\n  template<class Derived> EIGEN_DEVICE_FUNC static inline void run(QuaternionBase<Derived>& q, const Other& a_mat)\n  {\n    const typename internal::nested_eval<Other,2>::type mat(a_mat);\n    EIGEN_USING_STD_MATH(sqrt)\n    // This algorithm comes from  \"Quaternion Calculus and Fast Animation\",\n    // Ken Shoemake, 1987 SIGGRAPH course notes\n    Scalar t = mat.trace();\n    if (t > Scalar(0))\n    {\n      t = sqrt(t + Scalar(1.0));\n      q.w() = Scalar(0.5)*t;\n      t = Scalar(0.5)/t;\n      q.x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;\n      q.y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;\n      q.z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;\n    }\n    else\n    {\n      Index i = 0;\n      if (mat.coeff(1,1) > mat.coeff(0,0))\n        i = 1;\n      if (mat.coeff(2,2) > mat.coeff(i,i))\n        i = 2;\n      Index j = (i+1)%3;\n      Index k = (j+1)%3;\n\n      t = sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0));\n      q.coeffs().coeffRef(i) = Scalar(0.5) * t;\n      t = Scalar(0.5)/t;\n      q.w() = (mat.coeff(k,j)-mat.coeff(j,k))*t;\n      q.coeffs().coeffRef(j) = (mat.coeff(j,i)+mat.coeff(i,j))*t;\n      q.coeffs().coeffRef(k) = (mat.coeff(k,i)+mat.coeff(i,k))*t;\n    }\n  }\n};\n\n// set from a vector of coefficients assumed to be a quaternion\ntemplate<typename Other>\nstruct quaternionbase_assign_impl<Other,4,1>\n{\n  typedef typename Other::Scalar Scalar;\n  template<class Derived> EIGEN_DEVICE_FUNC static inline void run(QuaternionBase<Derived>& q, const Other& vec)\n  {\n    q.coeffs() = vec;\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_QUATERNION_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/Rotation2D.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ROTATION2D_H\n#define EIGEN_ROTATION2D_H\n\nnamespace Eigen { \n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\class Rotation2D\n  *\n  * \\brief Represents a rotation/orientation in a 2 dimensional space.\n  *\n  * \\tparam _Scalar the scalar type, i.e., the type of the coefficients\n  *\n  * This class is equivalent to a single scalar representing a counter clock wise rotation\n  * as a single angle in radian. It provides some additional features such as the automatic\n  * conversion from/to a 2x2 rotation matrix. Moreover this class aims to provide a similar\n  * interface to Quaternion in order to facilitate the writing of generic algorithms\n  * dealing with rotations.\n  *\n  * \\sa class Quaternion, class Transform\n  */\n\nnamespace internal {\n\ntemplate<typename _Scalar> struct traits<Rotation2D<_Scalar> >\n{\n  typedef _Scalar Scalar;\n};\n} // end namespace internal\n\ntemplate<typename _Scalar>\nclass Rotation2D : public RotationBase<Rotation2D<_Scalar>,2>\n{\n  typedef RotationBase<Rotation2D<_Scalar>,2> Base;\n\npublic:\n\n  using Base::operator*;\n\n  enum { Dim = 2 };\n  /** the scalar type of the coefficients */\n  typedef _Scalar Scalar;\n  typedef Matrix<Scalar,2,1> Vector2;\n  typedef Matrix<Scalar,2,2> Matrix2;\n\nprotected:\n\n  Scalar m_angle;\n\npublic:\n\n  /** Construct a 2D counter clock wise rotation from the angle \\a a in radian. */\n  EIGEN_DEVICE_FUNC explicit inline Rotation2D(const Scalar& a) : m_angle(a) {}\n  \n  /** Default constructor wihtout initialization. The represented rotation is undefined. */\n  EIGEN_DEVICE_FUNC Rotation2D() {}\n\n  /** Construct a 2D rotation from a 2x2 rotation matrix \\a mat.\n    *\n    * \\sa fromRotationMatrix()\n    */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC explicit Rotation2D(const MatrixBase<Derived>& m)\n  {\n    fromRotationMatrix(m.derived());\n  }\n\n  /** \\returns the rotation angle */\n  EIGEN_DEVICE_FUNC inline Scalar angle() const { return m_angle; }\n\n  /** \\returns a read-write reference to the rotation angle */\n  EIGEN_DEVICE_FUNC inline Scalar& angle() { return m_angle; }\n  \n  /** \\returns the rotation angle in [0,2pi] */\n  EIGEN_DEVICE_FUNC inline Scalar smallestPositiveAngle() const {\n    Scalar tmp = numext::fmod(m_angle,Scalar(2*EIGEN_PI));\n    return tmp<Scalar(0) ? tmp + Scalar(2*EIGEN_PI) : tmp;\n  }\n  \n  /** \\returns the rotation angle in [-pi,pi] */\n  EIGEN_DEVICE_FUNC inline Scalar smallestAngle() const {\n    Scalar tmp = numext::fmod(m_angle,Scalar(2*EIGEN_PI));\n    if(tmp>Scalar(EIGEN_PI))       tmp -= Scalar(2*EIGEN_PI);\n    else if(tmp<-Scalar(EIGEN_PI)) tmp += Scalar(2*EIGEN_PI);\n    return tmp;\n  }\n\n  /** \\returns the inverse rotation */\n  EIGEN_DEVICE_FUNC inline Rotation2D inverse() const { return Rotation2D(-m_angle); }\n\n  /** Concatenates two rotations */\n  EIGEN_DEVICE_FUNC inline Rotation2D operator*(const Rotation2D& other) const\n  { return Rotation2D(m_angle + other.m_angle); }\n\n  /** Concatenates two rotations */\n  EIGEN_DEVICE_FUNC inline Rotation2D& operator*=(const Rotation2D& other)\n  { m_angle += other.m_angle; return *this; }\n\n  /** Applies the rotation to a 2D vector */\n  EIGEN_DEVICE_FUNC Vector2 operator* (const Vector2& vec) const\n  { return toRotationMatrix() * vec; }\n  \n  template<typename Derived>\n  EIGEN_DEVICE_FUNC Rotation2D& fromRotationMatrix(const MatrixBase<Derived>& m);\n  EIGEN_DEVICE_FUNC Matrix2 toRotationMatrix() const;\n\n  /** Set \\c *this from a 2x2 rotation matrix \\a mat.\n    * In other words, this function extract the rotation angle from the rotation matrix.\n    *\n    * This method is an alias for fromRotationMatrix()\n    *\n    * \\sa fromRotationMatrix()\n    */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC Rotation2D& operator=(const  MatrixBase<Derived>& m)\n  { return fromRotationMatrix(m.derived()); }\n\n  /** \\returns the spherical interpolation between \\c *this and \\a other using\n    * parameter \\a t. It is in fact equivalent to a linear interpolation.\n    */\n  EIGEN_DEVICE_FUNC inline Rotation2D slerp(const Scalar& t, const Rotation2D& other) const\n  {\n    Scalar dist = Rotation2D(other.m_angle-m_angle).smallestAngle();\n    return Rotation2D(m_angle + dist*t);\n  }\n\n  /** \\returns \\c *this with scalar type casted to \\a NewScalarType\n    *\n    * Note that if \\a NewScalarType is equal to the current scalar type of \\c *this\n    * then this function smartly returns a const reference to \\c *this.\n    */\n  template<typename NewScalarType>\n  EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type cast() const\n  { return typename internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type(*this); }\n\n  /** Copy constructor with scalar type conversion */\n  template<typename OtherScalarType>\n  EIGEN_DEVICE_FUNC inline explicit Rotation2D(const Rotation2D<OtherScalarType>& other)\n  {\n    m_angle = Scalar(other.angle());\n  }\n\n  EIGEN_DEVICE_FUNC static inline Rotation2D Identity() { return Rotation2D(0); }\n\n  /** \\returns \\c true if \\c *this is approximately equal to \\a other, within the precision\n    * determined by \\a prec.\n    *\n    * \\sa MatrixBase::isApprox() */\n  EIGEN_DEVICE_FUNC bool isApprox(const Rotation2D& other, const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision()) const\n  { return internal::isApprox(m_angle,other.m_angle, prec); }\n  \n};\n\n/** \\ingroup Geometry_Module\n  * single precision 2D rotation type */\ntypedef Rotation2D<float> Rotation2Df;\n/** \\ingroup Geometry_Module\n  * double precision 2D rotation type */\ntypedef Rotation2D<double> Rotation2Dd;\n\n/** Set \\c *this from a 2x2 rotation matrix \\a mat.\n  * In other words, this function extract the rotation angle\n  * from the rotation matrix.\n  */\ntemplate<typename Scalar>\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC Rotation2D<Scalar>& Rotation2D<Scalar>::fromRotationMatrix(const MatrixBase<Derived>& mat)\n{\n  EIGEN_USING_STD_MATH(atan2)\n  EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime==2 && Derived::ColsAtCompileTime==2,YOU_MADE_A_PROGRAMMING_MISTAKE)\n  m_angle = atan2(mat.coeff(1,0), mat.coeff(0,0));\n  return *this;\n}\n\n/** Constructs and \\returns an equivalent 2x2 rotation matrix.\n  */\ntemplate<typename Scalar>\ntypename Rotation2D<Scalar>::Matrix2\nEIGEN_DEVICE_FUNC Rotation2D<Scalar>::toRotationMatrix(void) const\n{\n  EIGEN_USING_STD_MATH(sin)\n  EIGEN_USING_STD_MATH(cos)\n  Scalar sinA = sin(m_angle);\n  Scalar cosA = cos(m_angle);\n  return (Matrix2() << cosA, -sinA, sinA, cosA).finished();\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_ROTATION2D_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/RotationBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ROTATIONBASE_H\n#define EIGEN_ROTATIONBASE_H\n\nnamespace Eigen { \n\n// forward declaration\nnamespace internal {\ntemplate<typename RotationDerived, typename MatrixType, bool IsVector=MatrixType::IsVectorAtCompileTime>\nstruct rotation_base_generic_product_selector;\n}\n\n/** \\class RotationBase\n  *\n  * \\brief Common base class for compact rotation representations\n  *\n  * \\tparam Derived is the derived type, i.e., a rotation type\n  * \\tparam _Dim the dimension of the space\n  */\ntemplate<typename Derived, int _Dim>\nclass RotationBase\n{\n  public:\n    enum { Dim = _Dim };\n    /** the scalar type of the coefficients */\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n\n    /** corresponding linear transformation matrix type */\n    typedef Matrix<Scalar,Dim,Dim> RotationMatrixType;\n    typedef Matrix<Scalar,Dim,1> VectorType;\n\n  public:\n    EIGEN_DEVICE_FUNC inline const Derived& derived() const { return *static_cast<const Derived*>(this); }\n    EIGEN_DEVICE_FUNC inline Derived& derived() { return *static_cast<Derived*>(this); }\n\n    /** \\returns an equivalent rotation matrix */\n    EIGEN_DEVICE_FUNC inline RotationMatrixType toRotationMatrix() const { return derived().toRotationMatrix(); }\n\n    /** \\returns an equivalent rotation matrix \n      * This function is added to be conform with the Transform class' naming scheme.\n      */\n    EIGEN_DEVICE_FUNC inline RotationMatrixType matrix() const { return derived().toRotationMatrix(); }\n\n    /** \\returns the inverse rotation */\n    EIGEN_DEVICE_FUNC inline Derived inverse() const { return derived().inverse(); }\n\n    /** \\returns the concatenation of the rotation \\c *this with a translation \\a t */\n    EIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Isometry> operator*(const Translation<Scalar,Dim>& t) const\n    { return Transform<Scalar,Dim,Isometry>(*this) * t; }\n\n    /** \\returns the concatenation of the rotation \\c *this with a uniform scaling \\a s */\n    EIGEN_DEVICE_FUNC inline RotationMatrixType operator*(const UniformScaling<Scalar>& s) const\n    { return toRotationMatrix() * s.factor(); }\n\n    /** \\returns the concatenation of the rotation \\c *this with a generic expression \\a e\n      * \\a e can be:\n      *  - a DimxDim linear transformation matrix\n      *  - a DimxDim diagonal matrix (axis aligned scaling)\n      *  - a vector of size Dim\n      */\n    template<typename OtherDerived>\n    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename internal::rotation_base_generic_product_selector<Derived,OtherDerived,OtherDerived::IsVectorAtCompileTime>::ReturnType\n    operator*(const EigenBase<OtherDerived>& e) const\n    { return internal::rotation_base_generic_product_selector<Derived,OtherDerived>::run(derived(), e.derived()); }\n\n    /** \\returns the concatenation of a linear transformation \\a l with the rotation \\a r */\n    template<typename OtherDerived> friend\n    EIGEN_DEVICE_FUNC inline RotationMatrixType operator*(const EigenBase<OtherDerived>& l, const Derived& r)\n    { return l.derived() * r.toRotationMatrix(); }\n\n    /** \\returns the concatenation of a scaling \\a l with the rotation \\a r */\n    EIGEN_DEVICE_FUNC friend inline Transform<Scalar,Dim,Affine> operator*(const DiagonalMatrix<Scalar,Dim>& l, const Derived& r)\n    { \n      Transform<Scalar,Dim,Affine> res(r);\n      res.linear().applyOnTheLeft(l);\n      return res;\n    }\n\n    /** \\returns the concatenation of the rotation \\c *this with a transformation \\a t */\n    template<int Mode, int Options>\n    EIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode> operator*(const Transform<Scalar,Dim,Mode,Options>& t) const\n    { return toRotationMatrix() * t; }\n\n    template<typename OtherVectorType>\n    EIGEN_DEVICE_FUNC inline VectorType _transformVector(const OtherVectorType& v) const\n    { return toRotationMatrix() * v; }\n};\n\nnamespace internal {\n\n// implementation of the generic product rotation * matrix\ntemplate<typename RotationDerived, typename MatrixType>\nstruct rotation_base_generic_product_selector<RotationDerived,MatrixType,false>\n{\n  enum { Dim = RotationDerived::Dim };\n  typedef Matrix<typename RotationDerived::Scalar,Dim,Dim> ReturnType;\n  EIGEN_DEVICE_FUNC static inline ReturnType run(const RotationDerived& r, const MatrixType& m)\n  { return r.toRotationMatrix() * m; }\n};\n\ntemplate<typename RotationDerived, typename Scalar, int Dim, int MaxDim>\nstruct rotation_base_generic_product_selector< RotationDerived, DiagonalMatrix<Scalar,Dim,MaxDim>, false >\n{\n  typedef Transform<Scalar,Dim,Affine> ReturnType;\n  EIGEN_DEVICE_FUNC static inline ReturnType run(const RotationDerived& r, const DiagonalMatrix<Scalar,Dim,MaxDim>& m)\n  {\n    ReturnType res(r);\n    res.linear() *= m;\n    return res;\n  }\n};\n\ntemplate<typename RotationDerived,typename OtherVectorType>\nstruct rotation_base_generic_product_selector<RotationDerived,OtherVectorType,true>\n{\n  enum { Dim = RotationDerived::Dim };\n  typedef Matrix<typename RotationDerived::Scalar,Dim,1> ReturnType;\n  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE ReturnType run(const RotationDerived& r, const OtherVectorType& v)\n  {\n    return r._transformVector(v);\n  }\n};\n\n} // end namespace internal\n\n/** \\geometry_module\n  *\n  * \\brief Constructs a Dim x Dim rotation matrix from the rotation \\a r\n  */\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>\n::Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r)\n{\n  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))\n  *this = r.toRotationMatrix();\n}\n\n/** \\geometry_module\n  *\n  * \\brief Set a Dim x Dim rotation matrix from the rotation \\a r\n  */\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>&\nMatrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>\n::operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r)\n{\n  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))\n  return *this = r.toRotationMatrix();\n}\n\nnamespace internal {\n\n/** \\internal\n  *\n  * Helper function to return an arbitrary rotation object to a rotation matrix.\n  *\n  * \\tparam Scalar the numeric type of the matrix coefficients\n  * \\tparam Dim the dimension of the current space\n  *\n  * It returns a Dim x Dim fixed size matrix.\n  *\n  * Default specializations are provided for:\n  *   - any scalar type (2D),\n  *   - any matrix expression,\n  *   - any type based on RotationBase (e.g., Quaternion, AngleAxis, Rotation2D)\n  *\n  * Currently toRotationMatrix is only used by Transform.\n  *\n  * \\sa class Transform, class Rotation2D, class Quaternion, class AngleAxis\n  */\ntemplate<typename Scalar, int Dim>\nEIGEN_DEVICE_FUNC static inline Matrix<Scalar,2,2> toRotationMatrix(const Scalar& s)\n{\n  EIGEN_STATIC_ASSERT(Dim==2,YOU_MADE_A_PROGRAMMING_MISTAKE)\n  return Rotation2D<Scalar>(s).toRotationMatrix();\n}\n\ntemplate<typename Scalar, int Dim, typename OtherDerived>\nEIGEN_DEVICE_FUNC static inline Matrix<Scalar,Dim,Dim> toRotationMatrix(const RotationBase<OtherDerived,Dim>& r)\n{\n  return r.toRotationMatrix();\n}\n\ntemplate<typename Scalar, int Dim, typename OtherDerived>\nEIGEN_DEVICE_FUNC static inline const MatrixBase<OtherDerived>& toRotationMatrix(const MatrixBase<OtherDerived>& mat)\n{\n  EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime==Dim && OtherDerived::ColsAtCompileTime==Dim,\n    YOU_MADE_A_PROGRAMMING_MISTAKE)\n  return mat;\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_ROTATIONBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/Scaling.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SCALING_H\n#define EIGEN_SCALING_H\n\nnamespace Eigen { \n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\class Scaling\n  *\n  * \\brief Represents a generic uniform scaling transformation\n  *\n  * \\tparam _Scalar the scalar type, i.e., the type of the coefficients.\n  *\n  * This class represent a uniform scaling transformation. It is the return\n  * type of Scaling(Scalar), and most of the time this is the only way it\n  * is used. In particular, this class is not aimed to be used to store a scaling transformation,\n  * but rather to make easier the constructions and updates of Transform objects.\n  *\n  * To represent an axis aligned scaling, use the DiagonalMatrix class.\n  *\n  * \\sa Scaling(), class DiagonalMatrix, MatrixBase::asDiagonal(), class Translation, class Transform\n  */\ntemplate<typename _Scalar>\nclass UniformScaling\n{\npublic:\n  /** the scalar type of the coefficients */\n  typedef _Scalar Scalar;\n\nprotected:\n\n  Scalar m_factor;\n\npublic:\n\n  /** Default constructor without initialization. */\n  UniformScaling() {}\n  /** Constructs and initialize a uniform scaling transformation */\n  explicit inline UniformScaling(const Scalar& s) : m_factor(s) {}\n\n  inline const Scalar& factor() const { return m_factor; }\n  inline Scalar& factor() { return m_factor; }\n\n  /** Concatenates two uniform scaling */\n  inline UniformScaling operator* (const UniformScaling& other) const\n  { return UniformScaling(m_factor * other.factor()); }\n\n  /** Concatenates a uniform scaling and a translation */\n  template<int Dim>\n  inline Transform<Scalar,Dim,Affine> operator* (const Translation<Scalar,Dim>& t) const;\n\n  /** Concatenates a uniform scaling and an affine transformation */\n  template<int Dim, int Mode, int Options>\n  inline Transform<Scalar,Dim,(int(Mode)==int(Isometry)?Affine:Mode)> operator* (const Transform<Scalar,Dim, Mode, Options>& t) const\n  {\n    Transform<Scalar,Dim,(int(Mode)==int(Isometry)?Affine:Mode)> res = t;\n    res.prescale(factor());\n    return res;\n  }\n\n  /** Concatenates a uniform scaling and a linear transformation matrix */\n  // TODO returns an expression\n  template<typename Derived>\n  inline typename internal::plain_matrix_type<Derived>::type operator* (const MatrixBase<Derived>& other) const\n  { return other * m_factor; }\n\n  template<typename Derived,int Dim>\n  inline Matrix<Scalar,Dim,Dim> operator*(const RotationBase<Derived,Dim>& r) const\n  { return r.toRotationMatrix() * m_factor; }\n\n  /** \\returns the inverse scaling */\n  inline UniformScaling inverse() const\n  { return UniformScaling(Scalar(1)/m_factor); }\n\n  /** \\returns \\c *this with scalar type casted to \\a NewScalarType\n    *\n    * Note that if \\a NewScalarType is equal to the current scalar type of \\c *this\n    * then this function smartly returns a const reference to \\c *this.\n    */\n  template<typename NewScalarType>\n  inline UniformScaling<NewScalarType> cast() const\n  { return UniformScaling<NewScalarType>(NewScalarType(m_factor)); }\n\n  /** Copy constructor with scalar type conversion */\n  template<typename OtherScalarType>\n  inline explicit UniformScaling(const UniformScaling<OtherScalarType>& other)\n  { m_factor = Scalar(other.factor()); }\n\n  /** \\returns \\c true if \\c *this is approximately equal to \\a other, within the precision\n    * determined by \\a prec.\n    *\n    * \\sa MatrixBase::isApprox() */\n  bool isApprox(const UniformScaling& other, const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision()) const\n  { return internal::isApprox(m_factor, other.factor(), prec); }\n\n};\n\n/** \\addtogroup Geometry_Module */\n//@{\n\n/** Concatenates a linear transformation matrix and a uniform scaling\n  * \\relates UniformScaling\n  */\n// NOTE this operator is defiend in MatrixBase and not as a friend function\n// of UniformScaling to fix an internal crash of Intel's ICC\ntemplate<typename Derived,typename Scalar>\nEIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,Scalar,product)\noperator*(const MatrixBase<Derived>& matrix, const UniformScaling<Scalar>& s)\n{ return matrix.derived() * s.factor(); }\n\n/** Constructs a uniform scaling from scale factor \\a s */\ninline UniformScaling<float> Scaling(float s) { return UniformScaling<float>(s); }\n/** Constructs a uniform scaling from scale factor \\a s */\ninline UniformScaling<double> Scaling(double s) { return UniformScaling<double>(s); }\n/** Constructs a uniform scaling from scale factor \\a s */\ntemplate<typename RealScalar>\ninline UniformScaling<std::complex<RealScalar> > Scaling(const std::complex<RealScalar>& s)\n{ return UniformScaling<std::complex<RealScalar> >(s); }\n\n/** Constructs a 2D axis aligned scaling */\ntemplate<typename Scalar>\ninline DiagonalMatrix<Scalar,2> Scaling(const Scalar& sx, const Scalar& sy)\n{ return DiagonalMatrix<Scalar,2>(sx, sy); }\n/** Constructs a 3D axis aligned scaling */\ntemplate<typename Scalar>\ninline DiagonalMatrix<Scalar,3> Scaling(const Scalar& sx, const Scalar& sy, const Scalar& sz)\n{ return DiagonalMatrix<Scalar,3>(sx, sy, sz); }\n\n/** Constructs an axis aligned scaling expression from vector expression \\a coeffs\n  * This is an alias for coeffs.asDiagonal()\n  */\ntemplate<typename Derived>\ninline const DiagonalWrapper<const Derived> Scaling(const MatrixBase<Derived>& coeffs)\n{ return coeffs.asDiagonal(); }\n\n/** \\deprecated */\ntypedef DiagonalMatrix<float, 2> AlignedScaling2f;\n/** \\deprecated */\ntypedef DiagonalMatrix<double,2> AlignedScaling2d;\n/** \\deprecated */\ntypedef DiagonalMatrix<float, 3> AlignedScaling3f;\n/** \\deprecated */\ntypedef DiagonalMatrix<double,3> AlignedScaling3d;\n//@}\n\ntemplate<typename Scalar>\ntemplate<int Dim>\ninline Transform<Scalar,Dim,Affine>\nUniformScaling<Scalar>::operator* (const Translation<Scalar,Dim>& t) const\n{\n  Transform<Scalar,Dim,Affine> res;\n  res.matrix().setZero();\n  res.linear().diagonal().fill(factor());\n  res.translation() = factor() * t.vector();\n  res(Dim,Dim) = Scalar(1);\n  return res;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SCALING_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/Transform.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2010 Hauke Heibel <hauke.heibel@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TRANSFORM_H\n#define EIGEN_TRANSFORM_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Transform>\nstruct transform_traits\n{\n  enum\n  {\n    Dim = Transform::Dim,\n    HDim = Transform::HDim,\n    Mode = Transform::Mode,\n    IsProjective = (int(Mode)==int(Projective))\n  };\n};\n\ntemplate< typename TransformType,\n          typename MatrixType,\n          int Case = transform_traits<TransformType>::IsProjective ? 0\n                   : int(MatrixType::RowsAtCompileTime) == int(transform_traits<TransformType>::HDim) ? 1\n                   : 2,\n          int RhsCols = MatrixType::ColsAtCompileTime>\nstruct transform_right_product_impl;\n\ntemplate< typename Other,\n          int Mode,\n          int Options,\n          int Dim,\n          int HDim,\n          int OtherRows=Other::RowsAtCompileTime,\n          int OtherCols=Other::ColsAtCompileTime>\nstruct transform_left_product_impl;\n\ntemplate< typename Lhs,\n          typename Rhs,\n          bool AnyProjective = \n            transform_traits<Lhs>::IsProjective ||\n            transform_traits<Rhs>::IsProjective>\nstruct transform_transform_product_impl;\n\ntemplate< typename Other,\n          int Mode,\n          int Options,\n          int Dim,\n          int HDim,\n          int OtherRows=Other::RowsAtCompileTime,\n          int OtherCols=Other::ColsAtCompileTime>\nstruct transform_construct_from_matrix;\n\ntemplate<typename TransformType> struct transform_take_affine_part;\n\ntemplate<typename _Scalar, int _Dim, int _Mode, int _Options>\nstruct traits<Transform<_Scalar,_Dim,_Mode,_Options> >\n{\n  typedef _Scalar Scalar;\n  typedef Eigen::Index StorageIndex;\n  typedef Dense StorageKind;\n  enum {\n    Dim1 = _Dim==Dynamic ? _Dim : _Dim + 1,\n    RowsAtCompileTime = _Mode==Projective ? Dim1 : _Dim,\n    ColsAtCompileTime = Dim1,\n    MaxRowsAtCompileTime = RowsAtCompileTime,\n    MaxColsAtCompileTime = ColsAtCompileTime,\n    Flags = 0\n  };\n};\n\ntemplate<int Mode> struct transform_make_affine;\n\n} // end namespace internal\n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\class Transform\n  *\n  * \\brief Represents an homogeneous transformation in a N dimensional space\n  *\n  * \\tparam _Scalar the scalar type, i.e., the type of the coefficients\n  * \\tparam _Dim the dimension of the space\n  * \\tparam _Mode the type of the transformation. Can be:\n  *              - #Affine: the transformation is stored as a (Dim+1)^2 matrix,\n  *                         where the last row is assumed to be [0 ... 0 1].\n  *              - #AffineCompact: the transformation is stored as a (Dim)x(Dim+1) matrix.\n  *              - #Projective: the transformation is stored as a (Dim+1)^2 matrix\n  *                             without any assumption.\n  * \\tparam _Options has the same meaning as in class Matrix. It allows to specify DontAlign and/or RowMajor.\n  *                  These Options are passed directly to the underlying matrix type.\n  *\n  * The homography is internally represented and stored by a matrix which\n  * is available through the matrix() method. To understand the behavior of\n  * this class you have to think a Transform object as its internal\n  * matrix representation. The chosen convention is right multiply:\n  *\n  * \\code v' = T * v \\endcode\n  *\n  * Therefore, an affine transformation matrix M is shaped like this:\n  *\n  * \\f$ \\left( \\begin{array}{cc}\n  * linear & translation\\\\\n  * 0 ... 0 & 1\n  * \\end{array} \\right) \\f$\n  *\n  * Note that for a projective transformation the last row can be anything,\n  * and then the interpretation of different parts might be sightly different.\n  *\n  * However, unlike a plain matrix, the Transform class provides many features\n  * simplifying both its assembly and usage. In particular, it can be composed\n  * with any other transformations (Transform,Translation,RotationBase,DiagonalMatrix)\n  * and can be directly used to transform implicit homogeneous vectors. All these\n  * operations are handled via the operator*. For the composition of transformations,\n  * its principle consists to first convert the right/left hand sides of the product\n  * to a compatible (Dim+1)^2 matrix and then perform a pure matrix product.\n  * Of course, internally, operator* tries to perform the minimal number of operations\n  * according to the nature of each terms. Likewise, when applying the transform\n  * to points, the latters are automatically promoted to homogeneous vectors\n  * before doing the matrix product. The conventions to homogeneous representations\n  * are performed as follow:\n  *\n  * \\b Translation t (Dim)x(1):\n  * \\f$ \\left( \\begin{array}{cc}\n  * I & t \\\\\n  * 0\\,...\\,0 & 1\n  * \\end{array} \\right) \\f$\n  *\n  * \\b Rotation R (Dim)x(Dim):\n  * \\f$ \\left( \\begin{array}{cc}\n  * R & 0\\\\\n  * 0\\,...\\,0 & 1\n  * \\end{array} \\right) \\f$\n  *<!--\n  * \\b Linear \\b Matrix L (Dim)x(Dim):\n  * \\f$ \\left( \\begin{array}{cc}\n  * L & 0\\\\\n  * 0\\,...\\,0 & 1\n  * \\end{array} \\right) \\f$\n  *\n  * \\b Affine \\b Matrix A (Dim)x(Dim+1):\n  * \\f$ \\left( \\begin{array}{c}\n  * A\\\\\n  * 0\\,...\\,0\\,1\n  * \\end{array} \\right) \\f$\n  *-->\n  * \\b Scaling \\b DiagonalMatrix S (Dim)x(Dim):\n  * \\f$ \\left( \\begin{array}{cc}\n  * S & 0\\\\\n  * 0\\,...\\,0 & 1\n  * \\end{array} \\right) \\f$\n  *\n  * \\b Column \\b point v (Dim)x(1):\n  * \\f$ \\left( \\begin{array}{c}\n  * v\\\\\n  * 1\n  * \\end{array} \\right) \\f$\n  *\n  * \\b Set \\b of \\b column \\b points V1...Vn (Dim)x(n):\n  * \\f$ \\left( \\begin{array}{ccc}\n  * v_1 & ... & v_n\\\\\n  * 1 & ... & 1\n  * \\end{array} \\right) \\f$\n  *\n  * The concatenation of a Transform object with any kind of other transformation\n  * always returns a Transform object.\n  *\n  * A little exception to the \"as pure matrix product\" rule is the case of the\n  * transformation of non homogeneous vectors by an affine transformation. In\n  * that case the last matrix row can be ignored, and the product returns non\n  * homogeneous vectors.\n  *\n  * Since, for instance, a Dim x Dim matrix is interpreted as a linear transformation,\n  * it is not possible to directly transform Dim vectors stored in a Dim x Dim matrix.\n  * The solution is either to use a Dim x Dynamic matrix or explicitly request a\n  * vector transformation by making the vector homogeneous:\n  * \\code\n  * m' = T * m.colwise().homogeneous();\n  * \\endcode\n  * Note that there is zero overhead.\n  *\n  * Conversion methods from/to Qt's QMatrix and QTransform are available if the\n  * preprocessor token EIGEN_QT_SUPPORT is defined.\n  *\n  * This class can be extended with the help of the plugin mechanism described on the page\n  * \\ref TopicCustomizing_Plugins by defining the preprocessor symbol \\c EIGEN_TRANSFORM_PLUGIN.\n  *\n  * \\sa class Matrix, class Quaternion\n  */\ntemplate<typename _Scalar, int _Dim, int _Mode, int _Options>\nclass Transform\n{\npublic:\n  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Dim==Dynamic ? Dynamic : (_Dim+1)*(_Dim+1))\n  enum {\n    Mode = _Mode,\n    Options = _Options,\n    Dim = _Dim,     ///< space dimension in which the transformation holds\n    HDim = _Dim+1,  ///< size of a respective homogeneous vector\n    Rows = int(Mode)==(AffineCompact) ? Dim : HDim\n  };\n  /** the scalar type of the coefficients */\n  typedef _Scalar Scalar;\n  typedef Eigen::Index StorageIndex;\n  typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n  /** type of the matrix used to represent the transformation */\n  typedef typename internal::make_proper_matrix_type<Scalar,Rows,HDim,Options>::type MatrixType;\n  /** constified MatrixType */\n  typedef const MatrixType ConstMatrixType;\n  /** type of the matrix used to represent the linear part of the transformation */\n  typedef Matrix<Scalar,Dim,Dim,Options> LinearMatrixType;\n  /** type of read/write reference to the linear part of the transformation */\n  typedef Block<MatrixType,Dim,Dim,int(Mode)==(AffineCompact) && (Options&RowMajor)==0> LinearPart;\n  /** type of read reference to the linear part of the transformation */\n  typedef const Block<ConstMatrixType,Dim,Dim,int(Mode)==(AffineCompact) && (Options&RowMajor)==0> ConstLinearPart;\n  /** type of read/write reference to the affine part of the transformation */\n  typedef typename internal::conditional<int(Mode)==int(AffineCompact),\n                              MatrixType&,\n                              Block<MatrixType,Dim,HDim> >::type AffinePart;\n  /** type of read reference to the affine part of the transformation */\n  typedef typename internal::conditional<int(Mode)==int(AffineCompact),\n                              const MatrixType&,\n                              const Block<const MatrixType,Dim,HDim> >::type ConstAffinePart;\n  /** type of a vector */\n  typedef Matrix<Scalar,Dim,1> VectorType;\n  /** type of a read/write reference to the translation part of the rotation */\n  typedef Block<MatrixType,Dim,1,!(internal::traits<MatrixType>::Flags & RowMajorBit)> TranslationPart;\n  /** type of a read reference to the translation part of the rotation */\n  typedef const Block<ConstMatrixType,Dim,1,!(internal::traits<MatrixType>::Flags & RowMajorBit)> ConstTranslationPart;\n  /** corresponding translation type */\n  typedef Translation<Scalar,Dim> TranslationType;\n  \n  // this intermediate enum is needed to avoid an ICE with gcc 3.4 and 4.0\n  enum { TransformTimeDiagonalMode = ((Mode==int(Isometry))?Affine:int(Mode)) };\n  /** The return type of the product between a diagonal matrix and a transform */\n  typedef Transform<Scalar,Dim,TransformTimeDiagonalMode> TransformTimeDiagonalReturnType;\n\nprotected:\n\n  MatrixType m_matrix;\n\npublic:\n\n  /** Default constructor without initialization of the meaningful coefficients.\n    * If Mode==Affine, then the last row is set to [0 ... 0 1] */\n  EIGEN_DEVICE_FUNC inline Transform()\n  {\n    check_template_params();\n    internal::transform_make_affine<(int(Mode)==Affine) ? Affine : AffineCompact>::run(m_matrix);\n  }\n\n  EIGEN_DEVICE_FUNC inline Transform(const Transform& other)\n  {\n    check_template_params();\n    m_matrix = other.m_matrix;\n  }\n\n  EIGEN_DEVICE_FUNC inline explicit Transform(const TranslationType& t)\n  {\n    check_template_params();\n    *this = t;\n  }\n  EIGEN_DEVICE_FUNC inline explicit Transform(const UniformScaling<Scalar>& s)\n  {\n    check_template_params();\n    *this = s;\n  }\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline explicit Transform(const RotationBase<Derived, Dim>& r)\n  {\n    check_template_params();\n    *this = r;\n  }\n\n  EIGEN_DEVICE_FUNC inline Transform& operator=(const Transform& other)\n  { m_matrix = other.m_matrix; return *this; }\n\n  typedef internal::transform_take_affine_part<Transform> take_affine_part;\n\n  /** Constructs and initializes a transformation from a Dim^2 or a (Dim+1)^2 matrix. */\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC inline explicit Transform(const EigenBase<OtherDerived>& other)\n  {\n    EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),\n      YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);\n\n    check_template_params();\n    internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(this, other.derived());\n  }\n\n  /** Set \\c *this from a Dim^2 or (Dim+1)^2 matrix. */\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC inline Transform& operator=(const EigenBase<OtherDerived>& other)\n  {\n    EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),\n      YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);\n\n    internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(this, other.derived());\n    return *this;\n  }\n  \n  template<int OtherOptions>\n  EIGEN_DEVICE_FUNC inline Transform(const Transform<Scalar,Dim,Mode,OtherOptions>& other)\n  {\n    check_template_params();\n    // only the options change, we can directly copy the matrices\n    m_matrix = other.matrix();\n  }\n\n  template<int OtherMode,int OtherOptions>\n  EIGEN_DEVICE_FUNC inline Transform(const Transform<Scalar,Dim,OtherMode,OtherOptions>& other)\n  {\n    check_template_params();\n    // prevent conversions as:\n    // Affine | AffineCompact | Isometry = Projective\n    EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(OtherMode==int(Projective), Mode==int(Projective)),\n                        YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)\n\n    // prevent conversions as:\n    // Isometry = Affine | AffineCompact\n    EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(OtherMode==int(Affine)||OtherMode==int(AffineCompact), Mode!=int(Isometry)),\n                        YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)\n\n    enum { ModeIsAffineCompact = Mode == int(AffineCompact),\n           OtherModeIsAffineCompact = OtherMode == int(AffineCompact)\n    };\n\n    if(ModeIsAffineCompact == OtherModeIsAffineCompact)\n    {\n      // We need the block expression because the code is compiled for all\n      // combinations of transformations and will trigger a compile time error\n      // if one tries to assign the matrices directly\n      m_matrix.template block<Dim,Dim+1>(0,0) = other.matrix().template block<Dim,Dim+1>(0,0);\n      makeAffine();\n    }\n    else if(OtherModeIsAffineCompact)\n    {\n      typedef typename Transform<Scalar,Dim,OtherMode,OtherOptions>::MatrixType OtherMatrixType;\n      internal::transform_construct_from_matrix<OtherMatrixType,Mode,Options,Dim,HDim>::run(this, other.matrix());\n    }\n    else\n    {\n      // here we know that Mode == AffineCompact and OtherMode != AffineCompact.\n      // if OtherMode were Projective, the static assert above would already have caught it.\n      // So the only possibility is that OtherMode == Affine\n      linear() = other.linear();\n      translation() = other.translation();\n    }\n  }\n\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC Transform(const ReturnByValue<OtherDerived>& other)\n  {\n    check_template_params();\n    other.evalTo(*this);\n  }\n\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC Transform& operator=(const ReturnByValue<OtherDerived>& other)\n  {\n    other.evalTo(*this);\n    return *this;\n  }\n\n  #ifdef EIGEN_QT_SUPPORT\n  inline Transform(const QMatrix& other);\n  inline Transform& operator=(const QMatrix& other);\n  inline QMatrix toQMatrix(void) const;\n  inline Transform(const QTransform& other);\n  inline Transform& operator=(const QTransform& other);\n  inline QTransform toQTransform(void) const;\n  #endif\n  \n  EIGEN_DEVICE_FUNC Index rows() const { return int(Mode)==int(Projective) ? m_matrix.cols() : (m_matrix.cols()-1); }\n  EIGEN_DEVICE_FUNC Index cols() const { return m_matrix.cols(); }\n\n  /** shortcut for m_matrix(row,col);\n    * \\sa MatrixBase::operator(Index,Index) const */\n  EIGEN_DEVICE_FUNC inline Scalar operator() (Index row, Index col) const { return m_matrix(row,col); }\n  /** shortcut for m_matrix(row,col);\n    * \\sa MatrixBase::operator(Index,Index) */\n  EIGEN_DEVICE_FUNC inline Scalar& operator() (Index row, Index col) { return m_matrix(row,col); }\n\n  /** \\returns a read-only expression of the transformation matrix */\n  EIGEN_DEVICE_FUNC inline const MatrixType& matrix() const { return m_matrix; }\n  /** \\returns a writable expression of the transformation matrix */\n  EIGEN_DEVICE_FUNC inline MatrixType& matrix() { return m_matrix; }\n\n  /** \\returns a read-only expression of the linear part of the transformation */\n  EIGEN_DEVICE_FUNC inline ConstLinearPart linear() const { return ConstLinearPart(m_matrix,0,0); }\n  /** \\returns a writable expression of the linear part of the transformation */\n  EIGEN_DEVICE_FUNC inline LinearPart linear() { return LinearPart(m_matrix,0,0); }\n\n  /** \\returns a read-only expression of the Dim x HDim affine part of the transformation */\n  EIGEN_DEVICE_FUNC inline ConstAffinePart affine() const { return take_affine_part::run(m_matrix); }\n  /** \\returns a writable expression of the Dim x HDim affine part of the transformation */\n  EIGEN_DEVICE_FUNC inline AffinePart affine() { return take_affine_part::run(m_matrix); }\n\n  /** \\returns a read-only expression of the translation vector of the transformation */\n  EIGEN_DEVICE_FUNC inline ConstTranslationPart translation() const { return ConstTranslationPart(m_matrix,0,Dim); }\n  /** \\returns a writable expression of the translation vector of the transformation */\n  EIGEN_DEVICE_FUNC inline TranslationPart translation() { return TranslationPart(m_matrix,0,Dim); }\n\n  /** \\returns an expression of the product between the transform \\c *this and a matrix expression \\a other.\n    *\n    * The right-hand-side \\a other can be either:\n    * \\li an homogeneous vector of size Dim+1,\n    * \\li a set of homogeneous vectors of size Dim+1 x N,\n    * \\li a transformation matrix of size Dim+1 x Dim+1.\n    *\n    * Moreover, if \\c *this represents an affine transformation (i.e., Mode!=Projective), then \\a other can also be:\n    * \\li a point of size Dim (computes: \\code this->linear() * other + this->translation()\\endcode),\n    * \\li a set of N points as a Dim x N matrix (computes: \\code (this->linear() * other).colwise() + this->translation()\\endcode),\n    *\n    * In all cases, the return type is a matrix or vector of same sizes as the right-hand-side \\a other.\n    *\n    * If you want to interpret \\a other as a linear or affine transformation, then first convert it to a Transform<> type,\n    * or do your own cooking.\n    *\n    * Finally, if you want to apply Affine transformations to vectors, then explicitly apply the linear part only:\n    * \\code\n    * Affine3f A;\n    * Vector3f v1, v2;\n    * v2 = A.linear() * v1;\n    * \\endcode\n    *\n    */\n  // note: this function is defined here because some compilers cannot find the respective declaration\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename internal::transform_right_product_impl<Transform, OtherDerived>::ResultType\n  operator * (const EigenBase<OtherDerived> &other) const\n  { return internal::transform_right_product_impl<Transform, OtherDerived>::run(*this,other.derived()); }\n\n  /** \\returns the product expression of a transformation matrix \\a a times a transform \\a b\n    *\n    * The left hand side \\a other can be either:\n    * \\li a linear transformation matrix of size Dim x Dim,\n    * \\li an affine transformation matrix of size Dim x Dim+1,\n    * \\li a general transformation matrix of size Dim+1 x Dim+1.\n    */\n  template<typename OtherDerived> friend\n  EIGEN_DEVICE_FUNC inline const typename internal::transform_left_product_impl<OtherDerived,Mode,Options,_Dim,_Dim+1>::ResultType\n    operator * (const EigenBase<OtherDerived> &a, const Transform &b)\n  { return internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim,HDim>::run(a.derived(),b); }\n\n  /** \\returns The product expression of a transform \\a a times a diagonal matrix \\a b\n    *\n    * The rhs diagonal matrix is interpreted as an affine scaling transformation. The\n    * product results in a Transform of the same type (mode) as the lhs only if the lhs \n    * mode is no isometry. In that case, the returned transform is an affinity.\n    */\n  template<typename DiagonalDerived>\n  EIGEN_DEVICE_FUNC inline const TransformTimeDiagonalReturnType\n    operator * (const DiagonalBase<DiagonalDerived> &b) const\n  {\n    TransformTimeDiagonalReturnType res(*this);\n    res.linearExt() *= b;\n    return res;\n  }\n\n  /** \\returns The product expression of a diagonal matrix \\a a times a transform \\a b\n    *\n    * The lhs diagonal matrix is interpreted as an affine scaling transformation. The\n    * product results in a Transform of the same type (mode) as the lhs only if the lhs \n    * mode is no isometry. In that case, the returned transform is an affinity.\n    */\n  template<typename DiagonalDerived>\n  EIGEN_DEVICE_FUNC friend inline TransformTimeDiagonalReturnType\n    operator * (const DiagonalBase<DiagonalDerived> &a, const Transform &b)\n  {\n    TransformTimeDiagonalReturnType res;\n    res.linear().noalias() = a*b.linear();\n    res.translation().noalias() = a*b.translation();\n    if (Mode!=int(AffineCompact))\n      res.matrix().row(Dim) = b.matrix().row(Dim);\n    return res;\n  }\n\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC inline Transform& operator*=(const EigenBase<OtherDerived>& other) { return *this = *this * other; }\n\n  /** Concatenates two transformations */\n  EIGEN_DEVICE_FUNC inline const Transform operator * (const Transform& other) const\n  {\n    return internal::transform_transform_product_impl<Transform,Transform>::run(*this,other);\n  }\n  \n  #if EIGEN_COMP_ICC\nprivate:\n  // this intermediate structure permits to workaround a bug in ICC 11:\n  //   error: template instantiation resulted in unexpected function type of \"Eigen::Transform<double, 3, 32, 0>\n  //             (const Eigen::Transform<double, 3, 2, 0> &) const\"\n  //  (the meaning of a name may have changed since the template declaration -- the type of the template is:\n  // \"Eigen::internal::transform_transform_product_impl<Eigen::Transform<double, 3, 32, 0>,\n  //     Eigen::Transform<double, 3, Mode, Options>, <expression>>::ResultType (const Eigen::Transform<double, 3, Mode, Options> &) const\")\n  // \n  template<int OtherMode,int OtherOptions> struct icc_11_workaround\n  {\n    typedef internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> > ProductType;\n    typedef typename ProductType::ResultType ResultType;\n  };\n  \npublic:\n  /** Concatenates two different transformations */\n  template<int OtherMode,int OtherOptions>\n  inline typename icc_11_workaround<OtherMode,OtherOptions>::ResultType\n    operator * (const Transform<Scalar,Dim,OtherMode,OtherOptions>& other) const\n  {\n    typedef typename icc_11_workaround<OtherMode,OtherOptions>::ProductType ProductType;\n    return ProductType::run(*this,other);\n  }\n  #else\n  /** Concatenates two different transformations */\n  template<int OtherMode,int OtherOptions>\n  EIGEN_DEVICE_FUNC inline typename internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::ResultType\n    operator * (const Transform<Scalar,Dim,OtherMode,OtherOptions>& other) const\n  {\n    return internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::run(*this,other);\n  }\n  #endif\n\n  /** \\sa MatrixBase::setIdentity() */\n  EIGEN_DEVICE_FUNC void setIdentity() { m_matrix.setIdentity(); }\n\n  /**\n   * \\brief Returns an identity transformation.\n   * \\todo In the future this function should be returning a Transform expression.\n   */\n  EIGEN_DEVICE_FUNC static const Transform Identity()\n  {\n    return Transform(MatrixType::Identity());\n  }\n\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC \n  inline Transform& scale(const MatrixBase<OtherDerived> &other);\n\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC\n  inline Transform& prescale(const MatrixBase<OtherDerived> &other);\n\n  EIGEN_DEVICE_FUNC inline Transform& scale(const Scalar& s);\n  EIGEN_DEVICE_FUNC inline Transform& prescale(const Scalar& s);\n\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC\n  inline Transform& translate(const MatrixBase<OtherDerived> &other);\n\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC\n  inline Transform& pretranslate(const MatrixBase<OtherDerived> &other);\n\n  template<typename RotationType>\n  EIGEN_DEVICE_FUNC\n  inline Transform& rotate(const RotationType& rotation);\n\n  template<typename RotationType>\n  EIGEN_DEVICE_FUNC\n  inline Transform& prerotate(const RotationType& rotation);\n\n  EIGEN_DEVICE_FUNC Transform& shear(const Scalar& sx, const Scalar& sy);\n  EIGEN_DEVICE_FUNC Transform& preshear(const Scalar& sx, const Scalar& sy);\n\n  EIGEN_DEVICE_FUNC inline Transform& operator=(const TranslationType& t);\n  \n  EIGEN_DEVICE_FUNC\n  inline Transform& operator*=(const TranslationType& t) { return translate(t.vector()); }\n  \n  EIGEN_DEVICE_FUNC inline Transform operator*(const TranslationType& t) const;\n\n  EIGEN_DEVICE_FUNC \n  inline Transform& operator=(const UniformScaling<Scalar>& t);\n  \n  EIGEN_DEVICE_FUNC\n  inline Transform& operator*=(const UniformScaling<Scalar>& s) { return scale(s.factor()); }\n  \n  EIGEN_DEVICE_FUNC\n  inline TransformTimeDiagonalReturnType operator*(const UniformScaling<Scalar>& s) const\n  {\n    TransformTimeDiagonalReturnType res = *this;\n    res.scale(s.factor());\n    return res;\n  }\n\n  EIGEN_DEVICE_FUNC\n  inline Transform& operator*=(const DiagonalMatrix<Scalar,Dim>& s) { linearExt() *= s; return *this; }\n\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline Transform& operator=(const RotationBase<Derived,Dim>& r);\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline Transform& operator*=(const RotationBase<Derived,Dim>& r) { return rotate(r.toRotationMatrix()); }\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline Transform operator*(const RotationBase<Derived,Dim>& r) const;\n\n  EIGEN_DEVICE_FUNC const LinearMatrixType rotation() const;\n  template<typename RotationMatrixType, typename ScalingMatrixType>\n  EIGEN_DEVICE_FUNC\n  void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const;\n  template<typename ScalingMatrixType, typename RotationMatrixType>\n  EIGEN_DEVICE_FUNC\n  void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const;\n\n  template<typename PositionDerived, typename OrientationType, typename ScaleDerived>\n  EIGEN_DEVICE_FUNC\n  Transform& fromPositionOrientationScale(const MatrixBase<PositionDerived> &position,\n    const OrientationType& orientation, const MatrixBase<ScaleDerived> &scale);\n\n  EIGEN_DEVICE_FUNC\n  inline Transform inverse(TransformTraits traits = (TransformTraits)Mode) const;\n\n  /** \\returns a const pointer to the column major internal matrix */\n  EIGEN_DEVICE_FUNC const Scalar* data() const { return m_matrix.data(); }\n  /** \\returns a non-const pointer to the column major internal matrix */\n  EIGEN_DEVICE_FUNC Scalar* data() { return m_matrix.data(); }\n\n  /** \\returns \\c *this with scalar type casted to \\a NewScalarType\n    *\n    * Note that if \\a NewScalarType is equal to the current scalar type of \\c *this\n    * then this function smartly returns a const reference to \\c *this.\n    */\n  template<typename NewScalarType>\n  EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type cast() const\n  { return typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type(*this); }\n\n  /** Copy constructor with scalar type conversion */\n  template<typename OtherScalarType>\n  EIGEN_DEVICE_FUNC inline explicit Transform(const Transform<OtherScalarType,Dim,Mode,Options>& other)\n  {\n    check_template_params();\n    m_matrix = other.matrix().template cast<Scalar>();\n  }\n\n  /** \\returns \\c true if \\c *this is approximately equal to \\a other, within the precision\n    * determined by \\a prec.\n    *\n    * \\sa MatrixBase::isApprox() */\n  EIGEN_DEVICE_FUNC bool isApprox(const Transform& other, const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision()) const\n  { return m_matrix.isApprox(other.m_matrix, prec); }\n\n  /** Sets the last row to [0 ... 0 1]\n    */\n  EIGEN_DEVICE_FUNC void makeAffine()\n  {\n    internal::transform_make_affine<int(Mode)>::run(m_matrix);\n  }\n\n  /** \\internal\n    * \\returns the Dim x Dim linear part if the transformation is affine,\n    *          and the HDim x Dim part for projective transformations.\n    */\n  EIGEN_DEVICE_FUNC inline Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,Dim> linearExt()\n  { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }\n  /** \\internal\n    * \\returns the Dim x Dim linear part if the transformation is affine,\n    *          and the HDim x Dim part for projective transformations.\n    */\n  EIGEN_DEVICE_FUNC inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,Dim> linearExt() const\n  { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }\n\n  /** \\internal\n    * \\returns the translation part if the transformation is affine,\n    *          and the last column for projective transformations.\n    */\n  EIGEN_DEVICE_FUNC inline Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt()\n  { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }\n  /** \\internal\n    * \\returns the translation part if the transformation is affine,\n    *          and the last column for projective transformations.\n    */\n  EIGEN_DEVICE_FUNC inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt() const\n  { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }\n\n\n  #ifdef EIGEN_TRANSFORM_PLUGIN\n  #include EIGEN_TRANSFORM_PLUGIN\n  #endif\n  \nprotected:\n  #ifndef EIGEN_PARSED_BY_DOXYGEN\n    EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void check_template_params()\n    {\n      EIGEN_STATIC_ASSERT((Options & (DontAlign|RowMajor)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)\n    }\n  #endif\n\n};\n\n/** \\ingroup Geometry_Module */\ntypedef Transform<float,2,Isometry> Isometry2f;\n/** \\ingroup Geometry_Module */\ntypedef Transform<float,3,Isometry> Isometry3f;\n/** \\ingroup Geometry_Module */\ntypedef Transform<double,2,Isometry> Isometry2d;\n/** \\ingroup Geometry_Module */\ntypedef Transform<double,3,Isometry> Isometry3d;\n\n/** \\ingroup Geometry_Module */\ntypedef Transform<float,2,Affine> Affine2f;\n/** \\ingroup Geometry_Module */\ntypedef Transform<float,3,Affine> Affine3f;\n/** \\ingroup Geometry_Module */\ntypedef Transform<double,2,Affine> Affine2d;\n/** \\ingroup Geometry_Module */\ntypedef Transform<double,3,Affine> Affine3d;\n\n/** \\ingroup Geometry_Module */\ntypedef Transform<float,2,AffineCompact> AffineCompact2f;\n/** \\ingroup Geometry_Module */\ntypedef Transform<float,3,AffineCompact> AffineCompact3f;\n/** \\ingroup Geometry_Module */\ntypedef Transform<double,2,AffineCompact> AffineCompact2d;\n/** \\ingroup Geometry_Module */\ntypedef Transform<double,3,AffineCompact> AffineCompact3d;\n\n/** \\ingroup Geometry_Module */\ntypedef Transform<float,2,Projective> Projective2f;\n/** \\ingroup Geometry_Module */\ntypedef Transform<float,3,Projective> Projective3f;\n/** \\ingroup Geometry_Module */\ntypedef Transform<double,2,Projective> Projective2d;\n/** \\ingroup Geometry_Module */\ntypedef Transform<double,3,Projective> Projective3d;\n\n/**************************\n*** Optional QT support ***\n**************************/\n\n#ifdef EIGEN_QT_SUPPORT\n/** Initializes \\c *this from a QMatrix assuming the dimension is 2.\n  *\n  * This function is available only if the token EIGEN_QT_SUPPORT is defined.\n  */\ntemplate<typename Scalar, int Dim, int Mode,int Options>\nTransform<Scalar,Dim,Mode,Options>::Transform(const QMatrix& other)\n{\n  check_template_params();\n  *this = other;\n}\n\n/** Set \\c *this from a QMatrix assuming the dimension is 2.\n  *\n  * This function is available only if the token EIGEN_QT_SUPPORT is defined.\n  */\ntemplate<typename Scalar, int Dim, int Mode,int Options>\nTransform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(const QMatrix& other)\n{\n  EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)\n  if (Mode == int(AffineCompact))\n    m_matrix << other.m11(), other.m21(), other.dx(),\n                other.m12(), other.m22(), other.dy();\n  else\n    m_matrix << other.m11(), other.m21(), other.dx(),\n                other.m12(), other.m22(), other.dy(),\n                0, 0, 1;\n  return *this;\n}\n\n/** \\returns a QMatrix from \\c *this assuming the dimension is 2.\n  *\n  * \\warning this conversion might loss data if \\c *this is not affine\n  *\n  * This function is available only if the token EIGEN_QT_SUPPORT is defined.\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nQMatrix Transform<Scalar,Dim,Mode,Options>::toQMatrix(void) const\n{\n  check_template_params();\n  EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)\n  return QMatrix(m_matrix.coeff(0,0), m_matrix.coeff(1,0),\n                 m_matrix.coeff(0,1), m_matrix.coeff(1,1),\n                 m_matrix.coeff(0,2), m_matrix.coeff(1,2));\n}\n\n/** Initializes \\c *this from a QTransform assuming the dimension is 2.\n  *\n  * This function is available only if the token EIGEN_QT_SUPPORT is defined.\n  */\ntemplate<typename Scalar, int Dim, int Mode,int Options>\nTransform<Scalar,Dim,Mode,Options>::Transform(const QTransform& other)\n{\n  check_template_params();\n  *this = other;\n}\n\n/** Set \\c *this from a QTransform assuming the dimension is 2.\n  *\n  * This function is available only if the token EIGEN_QT_SUPPORT is defined.\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nTransform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(const QTransform& other)\n{\n  check_template_params();\n  EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)\n  if (Mode == int(AffineCompact))\n    m_matrix << other.m11(), other.m21(), other.dx(),\n                other.m12(), other.m22(), other.dy();\n  else\n    m_matrix << other.m11(), other.m21(), other.dx(),\n                other.m12(), other.m22(), other.dy(),\n                other.m13(), other.m23(), other.m33();\n  return *this;\n}\n\n/** \\returns a QTransform from \\c *this assuming the dimension is 2.\n  *\n  * This function is available only if the token EIGEN_QT_SUPPORT is defined.\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nQTransform Transform<Scalar,Dim,Mode,Options>::toQTransform(void) const\n{\n  EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)\n  if (Mode == int(AffineCompact))\n    return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0),\n                      m_matrix.coeff(0,1), m_matrix.coeff(1,1),\n                      m_matrix.coeff(0,2), m_matrix.coeff(1,2));\n  else\n    return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0),\n                      m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1),\n                      m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2));\n}\n#endif\n\n/*********************\n*** Procedural API ***\n*********************/\n\n/** Applies on the right the non uniform scale transformation represented\n  * by the vector \\a other to \\c *this and returns a reference to \\c *this.\n  * \\sa prescale()\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&\nTransform<Scalar,Dim,Mode,Options>::scale(const MatrixBase<OtherDerived> &other)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))\n  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)\n  linearExt().noalias() = (linearExt() * other.asDiagonal());\n  return *this;\n}\n\n/** Applies on the right a uniform scale of a factor \\a c to \\c *this\n  * and returns a reference to \\c *this.\n  * \\sa prescale(Scalar)\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nEIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::scale(const Scalar& s)\n{\n  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)\n  linearExt() *= s;\n  return *this;\n}\n\n/** Applies on the left the non uniform scale transformation represented\n  * by the vector \\a other to \\c *this and returns a reference to \\c *this.\n  * \\sa scale()\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&\nTransform<Scalar,Dim,Mode,Options>::prescale(const MatrixBase<OtherDerived> &other)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))\n  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)\n  affine().noalias() = (other.asDiagonal() * affine());\n  return *this;\n}\n\n/** Applies on the left a uniform scale of a factor \\a c to \\c *this\n  * and returns a reference to \\c *this.\n  * \\sa scale(Scalar)\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nEIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::prescale(const Scalar& s)\n{\n  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)\n  m_matrix.template topRows<Dim>() *= s;\n  return *this;\n}\n\n/** Applies on the right the translation matrix represented by the vector \\a other\n  * to \\c *this and returns a reference to \\c *this.\n  * \\sa pretranslate()\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&\nTransform<Scalar,Dim,Mode,Options>::translate(const MatrixBase<OtherDerived> &other)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))\n  translationExt() += linearExt() * other;\n  return *this;\n}\n\n/** Applies on the left the translation matrix represented by the vector \\a other\n  * to \\c *this and returns a reference to \\c *this.\n  * \\sa translate()\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&\nTransform<Scalar,Dim,Mode,Options>::pretranslate(const MatrixBase<OtherDerived> &other)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))\n  if(int(Mode)==int(Projective))\n    affine() += other * m_matrix.row(Dim);\n  else\n    translation() += other;\n  return *this;\n}\n\n/** Applies on the right the rotation represented by the rotation \\a rotation\n  * to \\c *this and returns a reference to \\c *this.\n  *\n  * The template parameter \\a RotationType is the type of the rotation which\n  * must be known by internal::toRotationMatrix<>.\n  *\n  * Natively supported types includes:\n  *   - any scalar (2D),\n  *   - a Dim x Dim matrix expression,\n  *   - a Quaternion (3D),\n  *   - a AngleAxis (3D)\n  *\n  * This mechanism is easily extendable to support user types such as Euler angles,\n  * or a pair of Quaternion for 4D rotations.\n  *\n  * \\sa rotate(Scalar), class Quaternion, class AngleAxis, prerotate(RotationType)\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\ntemplate<typename RotationType>\nEIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&\nTransform<Scalar,Dim,Mode,Options>::rotate(const RotationType& rotation)\n{\n  linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);\n  return *this;\n}\n\n/** Applies on the left the rotation represented by the rotation \\a rotation\n  * to \\c *this and returns a reference to \\c *this.\n  *\n  * See rotate() for further details.\n  *\n  * \\sa rotate()\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\ntemplate<typename RotationType>\nEIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&\nTransform<Scalar,Dim,Mode,Options>::prerotate(const RotationType& rotation)\n{\n  m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)\n                                         * m_matrix.template block<Dim,HDim>(0,0);\n  return *this;\n}\n\n/** Applies on the right the shear transformation represented\n  * by the vector \\a other to \\c *this and returns a reference to \\c *this.\n  * \\warning 2D only.\n  * \\sa preshear()\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nEIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&\nTransform<Scalar,Dim,Mode,Options>::shear(const Scalar& sx, const Scalar& sy)\n{\n  EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)\n  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)\n  VectorType tmp = linear().col(0)*sy + linear().col(1);\n  linear() << linear().col(0) + linear().col(1)*sx, tmp;\n  return *this;\n}\n\n/** Applies on the left the shear transformation represented\n  * by the vector \\a other to \\c *this and returns a reference to \\c *this.\n  * \\warning 2D only.\n  * \\sa shear()\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nEIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&\nTransform<Scalar,Dim,Mode,Options>::preshear(const Scalar& sx, const Scalar& sy)\n{\n  EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)\n  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)\n  m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);\n  return *this;\n}\n\n/******************************************************\n*** Scaling, Translation and Rotation compatibility ***\n******************************************************/\n\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nEIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(const TranslationType& t)\n{\n  linear().setIdentity();\n  translation() = t.vector();\n  makeAffine();\n  return *this;\n}\n\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nEIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options> Transform<Scalar,Dim,Mode,Options>::operator*(const TranslationType& t) const\n{\n  Transform res = *this;\n  res.translate(t.vector());\n  return res;\n}\n\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nEIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(const UniformScaling<Scalar>& s)\n{\n  m_matrix.setZero();\n  linear().diagonal().fill(s.factor());\n  makeAffine();\n  return *this;\n}\n\ntemplate<typename Scalar, int Dim, int Mode, int Options>\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(const RotationBase<Derived,Dim>& r)\n{\n  linear() = internal::toRotationMatrix<Scalar,Dim>(r);\n  translation().setZero();\n  makeAffine();\n  return *this;\n}\n\ntemplate<typename Scalar, int Dim, int Mode, int Options>\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options> Transform<Scalar,Dim,Mode,Options>::operator*(const RotationBase<Derived,Dim>& r) const\n{\n  Transform res = *this;\n  res.rotate(r.derived());\n  return res;\n}\n\n/************************\n*** Special functions ***\n************************/\n\n/** \\returns the rotation part of the transformation\n  *\n  *\n  * \\svd_module\n  *\n  * \\sa computeRotationScaling(), computeScalingRotation(), class SVD\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nEIGEN_DEVICE_FUNC const typename Transform<Scalar,Dim,Mode,Options>::LinearMatrixType\nTransform<Scalar,Dim,Mode,Options>::rotation() const\n{\n  LinearMatrixType result;\n  computeRotationScaling(&result, (LinearMatrixType*)0);\n  return result;\n}\n\n\n/** decomposes the linear part of the transformation as a product rotation x scaling, the scaling being\n  * not necessarily positive.\n  *\n  * If either pointer is zero, the corresponding computation is skipped.\n  *\n  *\n  *\n  * \\svd_module\n  *\n  * \\sa computeScalingRotation(), rotation(), class SVD\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\ntemplate<typename RotationMatrixType, typename ScalingMatrixType>\nEIGEN_DEVICE_FUNC void Transform<Scalar,Dim,Mode,Options>::computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const\n{\n  JacobiSVD<LinearMatrixType> svd(linear(), ComputeFullU | ComputeFullV);\n\n  Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant(); // so x has absolute value 1\n  VectorType sv(svd.singularValues());\n  sv.coeffRef(0) *= x;\n  if(scaling) scaling->lazyAssign(svd.matrixV() * sv.asDiagonal() * svd.matrixV().adjoint());\n  if(rotation)\n  {\n    LinearMatrixType m(svd.matrixU());\n    m.col(0) /= x;\n    rotation->lazyAssign(m * svd.matrixV().adjoint());\n  }\n}\n\n/** decomposes the linear part of the transformation as a product scaling x rotation, the scaling being\n  * not necessarily positive.\n  *\n  * If either pointer is zero, the corresponding computation is skipped.\n  *\n  *\n  *\n  * \\svd_module\n  *\n  * \\sa computeRotationScaling(), rotation(), class SVD\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\ntemplate<typename ScalingMatrixType, typename RotationMatrixType>\nEIGEN_DEVICE_FUNC void Transform<Scalar,Dim,Mode,Options>::computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const\n{\n  JacobiSVD<LinearMatrixType> svd(linear(), ComputeFullU | ComputeFullV);\n\n  Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant(); // so x has absolute value 1\n  VectorType sv(svd.singularValues());\n  sv.coeffRef(0) *= x;\n  if(scaling) scaling->lazyAssign(svd.matrixU() * sv.asDiagonal() * svd.matrixU().adjoint());\n  if(rotation)\n  {\n    LinearMatrixType m(svd.matrixU());\n    m.col(0) /= x;\n    rotation->lazyAssign(m * svd.matrixV().adjoint());\n  }\n}\n\n/** Convenient method to set \\c *this from a position, orientation and scale\n  * of a 3D object.\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\ntemplate<typename PositionDerived, typename OrientationType, typename ScaleDerived>\nEIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&\nTransform<Scalar,Dim,Mode,Options>::fromPositionOrientationScale(const MatrixBase<PositionDerived> &position,\n  const OrientationType& orientation, const MatrixBase<ScaleDerived> &scale)\n{\n  linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);\n  linear() *= scale.asDiagonal();\n  translation() = position;\n  makeAffine();\n  return *this;\n}\n\nnamespace internal {\n\ntemplate<int Mode>\nstruct transform_make_affine\n{\n  template<typename MatrixType>\n  EIGEN_DEVICE_FUNC static void run(MatrixType &mat)\n  {\n    static const int Dim = MatrixType::ColsAtCompileTime-1;\n    mat.template block<1,Dim>(Dim,0).setZero();\n    mat.coeffRef(Dim,Dim) = typename MatrixType::Scalar(1);\n  }\n};\n\ntemplate<>\nstruct transform_make_affine<AffineCompact>\n{\n  template<typename MatrixType> EIGEN_DEVICE_FUNC static void run(MatrixType &) { }\n};\n    \n// selector needed to avoid taking the inverse of a 3x4 matrix\ntemplate<typename TransformType, int Mode=TransformType::Mode>\nstruct projective_transform_inverse\n{\n  EIGEN_DEVICE_FUNC static inline void run(const TransformType&, TransformType&)\n  {}\n};\n\ntemplate<typename TransformType>\nstruct projective_transform_inverse<TransformType, Projective>\n{\n  EIGEN_DEVICE_FUNC static inline void run(const TransformType& m, TransformType& res)\n  {\n    res.matrix() = m.matrix().inverse();\n  }\n};\n\n} // end namespace internal\n\n\n/**\n  *\n  * \\returns the inverse transformation according to some given knowledge\n  * on \\c *this.\n  *\n  * \\param hint allows to optimize the inversion process when the transformation\n  * is known to be not a general transformation (optional). The possible values are:\n  *  - #Projective if the transformation is not necessarily affine, i.e., if the\n  *    last row is not guaranteed to be [0 ... 0 1]\n  *  - #Affine if the last row can be assumed to be [0 ... 0 1]\n  *  - #Isometry if the transformation is only a concatenations of translations\n  *    and rotations.\n  *  The default is the template class parameter \\c Mode.\n  *\n  * \\warning unless \\a traits is always set to NoShear or NoScaling, this function\n  * requires the generic inverse method of MatrixBase defined in the LU module. If\n  * you forget to include this module, then you will get hard to debug linking errors.\n  *\n  * \\sa MatrixBase::inverse()\n  */\ntemplate<typename Scalar, int Dim, int Mode, int Options>\nEIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>\nTransform<Scalar,Dim,Mode,Options>::inverse(TransformTraits hint) const\n{\n  Transform res;\n  if (hint == Projective)\n  {\n    internal::projective_transform_inverse<Transform>::run(*this, res);\n  }\n  else\n  {\n    if (hint == Isometry)\n    {\n      res.matrix().template topLeftCorner<Dim,Dim>() = linear().transpose();\n    }\n    else if(hint&Affine)\n    {\n      res.matrix().template topLeftCorner<Dim,Dim>() = linear().inverse();\n    }\n    else\n    {\n      eigen_assert(false && \"Invalid transform traits in Transform::Inverse\");\n    }\n    // translation and remaining parts\n    res.matrix().template topRightCorner<Dim,1>()\n      = - res.matrix().template topLeftCorner<Dim,Dim>() * translation();\n    res.makeAffine(); // we do need this, because in the beginning res is uninitialized\n  }\n  return res;\n}\n\nnamespace internal {\n\n/*****************************************************\n*** Specializations of take affine part            ***\n*****************************************************/\n\ntemplate<typename TransformType> struct transform_take_affine_part {\n  typedef typename TransformType::MatrixType MatrixType;\n  typedef typename TransformType::AffinePart AffinePart;\n  typedef typename TransformType::ConstAffinePart ConstAffinePart;\n  static inline AffinePart run(MatrixType& m)\n  { return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }\n  static inline ConstAffinePart run(const MatrixType& m)\n  { return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }\n};\n\ntemplate<typename Scalar, int Dim, int Options>\nstruct transform_take_affine_part<Transform<Scalar,Dim,AffineCompact, Options> > {\n  typedef typename Transform<Scalar,Dim,AffineCompact,Options>::MatrixType MatrixType;\n  static inline MatrixType& run(MatrixType& m) { return m; }\n  static inline const MatrixType& run(const MatrixType& m) { return m; }\n};\n\n/*****************************************************\n*** Specializations of construct from matrix       ***\n*****************************************************/\n\ntemplate<typename Other, int Mode, int Options, int Dim, int HDim>\nstruct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>\n{\n  static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform, const Other& other)\n  {\n    transform->linear() = other;\n    transform->translation().setZero();\n    transform->makeAffine();\n  }\n};\n\ntemplate<typename Other, int Mode, int Options, int Dim, int HDim>\nstruct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>\n{\n  static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform, const Other& other)\n  {\n    transform->affine() = other;\n    transform->makeAffine();\n  }\n};\n\ntemplate<typename Other, int Mode, int Options, int Dim, int HDim>\nstruct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>\n{\n  static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform, const Other& other)\n  { transform->matrix() = other; }\n};\n\ntemplate<typename Other, int Options, int Dim, int HDim>\nstruct transform_construct_from_matrix<Other, AffineCompact,Options,Dim,HDim, HDim,HDim>\n{\n  static inline void run(Transform<typename Other::Scalar,Dim,AffineCompact,Options> *transform, const Other& other)\n  { transform->matrix() = other.template block<Dim,HDim>(0,0); }\n};\n\n/**********************************************************\n***   Specializations of operator* with rhs EigenBase   ***\n**********************************************************/\n\ntemplate<int LhsMode,int RhsMode>\nstruct transform_product_result\n{\n  enum \n  { \n    Mode =\n      (LhsMode == (int)Projective    || RhsMode == (int)Projective    ) ? Projective :\n      (LhsMode == (int)Affine        || RhsMode == (int)Affine        ) ? Affine :\n      (LhsMode == (int)AffineCompact || RhsMode == (int)AffineCompact ) ? AffineCompact :\n      (LhsMode == (int)Isometry      || RhsMode == (int)Isometry      ) ? Isometry : Projective\n  };\n};\n\ntemplate< typename TransformType, typename MatrixType, int RhsCols>\nstruct transform_right_product_impl< TransformType, MatrixType, 0, RhsCols>\n{\n  typedef typename MatrixType::PlainObject ResultType;\n\n  static EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)\n  {\n    return T.matrix() * other;\n  }\n};\n\ntemplate< typename TransformType, typename MatrixType, int RhsCols>\nstruct transform_right_product_impl< TransformType, MatrixType, 1, RhsCols>\n{\n  enum { \n    Dim = TransformType::Dim, \n    HDim = TransformType::HDim,\n    OtherRows = MatrixType::RowsAtCompileTime,\n    OtherCols = MatrixType::ColsAtCompileTime\n  };\n\n  typedef typename MatrixType::PlainObject ResultType;\n\n  static EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)\n  {\n    EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);\n\n    typedef Block<ResultType, Dim, OtherCols, int(MatrixType::RowsAtCompileTime)==Dim> TopLeftLhs;\n\n    ResultType res(other.rows(),other.cols());\n    TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;\n    res.row(OtherRows-1) = other.row(OtherRows-1);\n    \n    return res;\n  }\n};\n\ntemplate< typename TransformType, typename MatrixType, int RhsCols>\nstruct transform_right_product_impl< TransformType, MatrixType, 2, RhsCols>\n{\n  enum { \n    Dim = TransformType::Dim, \n    HDim = TransformType::HDim,\n    OtherRows = MatrixType::RowsAtCompileTime,\n    OtherCols = MatrixType::ColsAtCompileTime\n  };\n\n  typedef typename MatrixType::PlainObject ResultType;\n\n  static EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)\n  {\n    EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);\n\n    typedef Block<ResultType, Dim, OtherCols, true> TopLeftLhs;\n    ResultType res(Replicate<typename TransformType::ConstTranslationPart, 1, OtherCols>(T.translation(),1,other.cols()));\n    TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;\n\n    return res;\n  }\n};\n\ntemplate< typename TransformType, typename MatrixType >\nstruct transform_right_product_impl< TransformType, MatrixType, 2, 1> // rhs is a vector of size Dim\n{\n  typedef typename TransformType::MatrixType TransformMatrix;\n  enum {\n    Dim = TransformType::Dim,\n    HDim = TransformType::HDim,\n    OtherRows = MatrixType::RowsAtCompileTime,\n    WorkingRows = EIGEN_PLAIN_ENUM_MIN(TransformMatrix::RowsAtCompileTime,HDim)\n  };\n\n  typedef typename MatrixType::PlainObject ResultType;\n\n  static EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)\n  {\n    EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);\n\n    Matrix<typename ResultType::Scalar, Dim+1, 1> rhs;\n    rhs.template head<Dim>() = other; rhs[Dim] = typename ResultType::Scalar(1);\n    Matrix<typename ResultType::Scalar, WorkingRows, 1> res(T.matrix() * rhs);\n    return res.template head<Dim>();\n  }\n};\n\n/**********************************************************\n***   Specializations of operator* with lhs EigenBase   ***\n**********************************************************/\n\n// generic HDim x HDim matrix * T => Projective\ntemplate<typename Other,int Mode, int Options, int Dim, int HDim>\nstruct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>\n{\n  typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;\n  typedef typename TransformType::MatrixType MatrixType;\n  typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;\n  static ResultType run(const Other& other,const TransformType& tr)\n  { return ResultType(other * tr.matrix()); }\n};\n\n// generic HDim x HDim matrix * AffineCompact => Projective\ntemplate<typename Other, int Options, int Dim, int HDim>\nstruct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, HDim,HDim>\n{\n  typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;\n  typedef typename TransformType::MatrixType MatrixType;\n  typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;\n  static ResultType run(const Other& other,const TransformType& tr)\n  {\n    ResultType res;\n    res.matrix().noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();\n    res.matrix().col(Dim) += other.col(Dim);\n    return res;\n  }\n};\n\n// affine matrix * T\ntemplate<typename Other,int Mode, int Options, int Dim, int HDim>\nstruct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>\n{\n  typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;\n  typedef typename TransformType::MatrixType MatrixType;\n  typedef TransformType ResultType;\n  static ResultType run(const Other& other,const TransformType& tr)\n  {\n    ResultType res;\n    res.affine().noalias() = other * tr.matrix();\n    res.matrix().row(Dim) = tr.matrix().row(Dim);\n    return res;\n  }\n};\n\n// affine matrix * AffineCompact\ntemplate<typename Other, int Options, int Dim, int HDim>\nstruct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, Dim,HDim>\n{\n  typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;\n  typedef typename TransformType::MatrixType MatrixType;\n  typedef TransformType ResultType;\n  static ResultType run(const Other& other,const TransformType& tr)\n  {\n    ResultType res;\n    res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();\n    res.translation() += other.col(Dim);\n    return res;\n  }\n};\n\n// linear matrix * T\ntemplate<typename Other,int Mode, int Options, int Dim, int HDim>\nstruct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>\n{\n  typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;\n  typedef typename TransformType::MatrixType MatrixType;\n  typedef TransformType ResultType;\n  static ResultType run(const Other& other, const TransformType& tr)\n  {\n    TransformType res;\n    if(Mode!=int(AffineCompact))\n      res.matrix().row(Dim) = tr.matrix().row(Dim);\n    res.matrix().template topRows<Dim>().noalias()\n      = other * tr.matrix().template topRows<Dim>();\n    return res;\n  }\n};\n\n/**********************************************************\n*** Specializations of operator* with another Transform ***\n**********************************************************/\n\ntemplate<typename Scalar, int Dim, int LhsMode, int LhsOptions, int RhsMode, int RhsOptions>\nstruct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >\n{\n  enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };\n  typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;\n  typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;\n  typedef Transform<Scalar,Dim,ResultMode,LhsOptions> ResultType;\n  static ResultType run(const Lhs& lhs, const Rhs& rhs)\n  {\n    ResultType res;\n    res.linear() = lhs.linear() * rhs.linear();\n    res.translation() = lhs.linear() * rhs.translation() + lhs.translation();\n    res.makeAffine();\n    return res;\n  }\n};\n\ntemplate<typename Scalar, int Dim, int LhsMode, int LhsOptions, int RhsMode, int RhsOptions>\nstruct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >\n{\n  typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;\n  typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;\n  typedef Transform<Scalar,Dim,Projective> ResultType;\n  static ResultType run(const Lhs& lhs, const Rhs& rhs)\n  {\n    return ResultType( lhs.matrix() * rhs.matrix() );\n  }\n};\n\ntemplate<typename Scalar, int Dim, int LhsOptions, int RhsOptions>\nstruct transform_transform_product_impl<Transform<Scalar,Dim,AffineCompact,LhsOptions>,Transform<Scalar,Dim,Projective,RhsOptions>,true >\n{\n  typedef Transform<Scalar,Dim,AffineCompact,LhsOptions> Lhs;\n  typedef Transform<Scalar,Dim,Projective,RhsOptions> Rhs;\n  typedef Transform<Scalar,Dim,Projective> ResultType;\n  static ResultType run(const Lhs& lhs, const Rhs& rhs)\n  {\n    ResultType res;\n    res.matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();\n    res.matrix().row(Dim) = rhs.matrix().row(Dim);\n    return res;\n  }\n};\n\ntemplate<typename Scalar, int Dim, int LhsOptions, int RhsOptions>\nstruct transform_transform_product_impl<Transform<Scalar,Dim,Projective,LhsOptions>,Transform<Scalar,Dim,AffineCompact,RhsOptions>,true >\n{\n  typedef Transform<Scalar,Dim,Projective,LhsOptions> Lhs;\n  typedef Transform<Scalar,Dim,AffineCompact,RhsOptions> Rhs;\n  typedef Transform<Scalar,Dim,Projective> ResultType;\n  static ResultType run(const Lhs& lhs, const Rhs& rhs)\n  {\n    ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());\n    res.matrix().col(Dim) += lhs.matrix().col(Dim);\n    return res;\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRANSFORM_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/Translation.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_TRANSLATION_H\n#define EIGEN_TRANSLATION_H\n\nnamespace Eigen { \n\n/** \\geometry_module \\ingroup Geometry_Module\n  *\n  * \\class Translation\n  *\n  * \\brief Represents a translation transformation\n  *\n  * \\tparam _Scalar the scalar type, i.e., the type of the coefficients.\n  * \\tparam _Dim the  dimension of the space, can be a compile time value or Dynamic\n  *\n  * \\note This class is not aimed to be used to store a translation transformation,\n  * but rather to make easier the constructions and updates of Transform objects.\n  *\n  * \\sa class Scaling, class Transform\n  */\ntemplate<typename _Scalar, int _Dim>\nclass Translation\n{\npublic:\n  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Dim)\n  /** dimension of the space */\n  enum { Dim = _Dim };\n  /** the scalar type of the coefficients */\n  typedef _Scalar Scalar;\n  /** corresponding vector type */\n  typedef Matrix<Scalar,Dim,1> VectorType;\n  /** corresponding linear transformation matrix type */\n  typedef Matrix<Scalar,Dim,Dim> LinearMatrixType;\n  /** corresponding affine transformation type */\n  typedef Transform<Scalar,Dim,Affine> AffineTransformType;\n  /** corresponding isometric transformation type */\n  typedef Transform<Scalar,Dim,Isometry> IsometryTransformType;\n\nprotected:\n\n  VectorType m_coeffs;\n\npublic:\n\n  /** Default constructor without initialization. */\n  EIGEN_DEVICE_FUNC Translation() {}\n  /**  */\n  EIGEN_DEVICE_FUNC inline Translation(const Scalar& sx, const Scalar& sy)\n  {\n    eigen_assert(Dim==2);\n    m_coeffs.x() = sx;\n    m_coeffs.y() = sy;\n  }\n  /**  */\n  EIGEN_DEVICE_FUNC inline Translation(const Scalar& sx, const Scalar& sy, const Scalar& sz)\n  {\n    eigen_assert(Dim==3);\n    m_coeffs.x() = sx;\n    m_coeffs.y() = sy;\n    m_coeffs.z() = sz;\n  }\n  /** Constructs and initialize the translation transformation from a vector of translation coefficients */\n  EIGEN_DEVICE_FUNC explicit inline Translation(const VectorType& vector) : m_coeffs(vector) {}\n\n  /** \\brief Retruns the x-translation by value. **/\n  EIGEN_DEVICE_FUNC inline Scalar x() const { return m_coeffs.x(); }\n  /** \\brief Retruns the y-translation by value. **/\n  EIGEN_DEVICE_FUNC inline Scalar y() const { return m_coeffs.y(); }\n  /** \\brief Retruns the z-translation by value. **/\n  EIGEN_DEVICE_FUNC inline Scalar z() const { return m_coeffs.z(); }\n\n  /** \\brief Retruns the x-translation as a reference. **/\n  EIGEN_DEVICE_FUNC inline Scalar& x() { return m_coeffs.x(); }\n  /** \\brief Retruns the y-translation as a reference. **/\n  EIGEN_DEVICE_FUNC inline Scalar& y() { return m_coeffs.y(); }\n  /** \\brief Retruns the z-translation as a reference. **/\n  EIGEN_DEVICE_FUNC inline Scalar& z() { return m_coeffs.z(); }\n\n  EIGEN_DEVICE_FUNC const VectorType& vector() const { return m_coeffs; }\n  EIGEN_DEVICE_FUNC VectorType& vector() { return m_coeffs; }\n\n  EIGEN_DEVICE_FUNC const VectorType& translation() const { return m_coeffs; }\n  EIGEN_DEVICE_FUNC VectorType& translation() { return m_coeffs; }\n\n  /** Concatenates two translation */\n  EIGEN_DEVICE_FUNC inline Translation operator* (const Translation& other) const\n  { return Translation(m_coeffs + other.m_coeffs); }\n\n  /** Concatenates a translation and a uniform scaling */\n  EIGEN_DEVICE_FUNC inline AffineTransformType operator* (const UniformScaling<Scalar>& other) const;\n\n  /** Concatenates a translation and a linear transformation */\n  template<typename OtherDerived>\n  EIGEN_DEVICE_FUNC inline AffineTransformType operator* (const EigenBase<OtherDerived>& linear) const;\n\n  /** Concatenates a translation and a rotation */\n  template<typename Derived>\n  EIGEN_DEVICE_FUNC inline IsometryTransformType operator*(const RotationBase<Derived,Dim>& r) const\n  { return *this * IsometryTransformType(r); }\n\n  /** \\returns the concatenation of a linear transformation \\a l with the translation \\a t */\n  // its a nightmare to define a templated friend function outside its declaration\n  template<typename OtherDerived> friend\n  EIGEN_DEVICE_FUNC inline AffineTransformType operator*(const EigenBase<OtherDerived>& linear, const Translation& t)\n  {\n    AffineTransformType res;\n    res.matrix().setZero();\n    res.linear() = linear.derived();\n    res.translation() = linear.derived() * t.m_coeffs;\n    res.matrix().row(Dim).setZero();\n    res(Dim,Dim) = Scalar(1);\n    return res;\n  }\n\n  /** Concatenates a translation and a transformation */\n  template<int Mode, int Options>\n  EIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode> operator* (const Transform<Scalar,Dim,Mode,Options>& t) const\n  {\n    Transform<Scalar,Dim,Mode> res = t;\n    res.pretranslate(m_coeffs);\n    return res;\n  }\n\n  /** Applies translation to vector */\n  template<typename Derived>\n  inline typename internal::enable_if<Derived::IsVectorAtCompileTime,VectorType>::type\n  operator* (const MatrixBase<Derived>& vec) const\n  { return m_coeffs + vec.derived(); }\n\n  /** \\returns the inverse translation (opposite) */\n  Translation inverse() const { return Translation(-m_coeffs); }\n\n  Translation& operator=(const Translation& other)\n  {\n    m_coeffs = other.m_coeffs;\n    return *this;\n  }\n\n  static const Translation Identity() { return Translation(VectorType::Zero()); }\n\n  /** \\returns \\c *this with scalar type casted to \\a NewScalarType\n    *\n    * Note that if \\a NewScalarType is equal to the current scalar type of \\c *this\n    * then this function smartly returns a const reference to \\c *this.\n    */\n  template<typename NewScalarType>\n  EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<Translation,Translation<NewScalarType,Dim> >::type cast() const\n  { return typename internal::cast_return_type<Translation,Translation<NewScalarType,Dim> >::type(*this); }\n\n  /** Copy constructor with scalar type conversion */\n  template<typename OtherScalarType>\n  EIGEN_DEVICE_FUNC inline explicit Translation(const Translation<OtherScalarType,Dim>& other)\n  { m_coeffs = other.vector().template cast<Scalar>(); }\n\n  /** \\returns \\c true if \\c *this is approximately equal to \\a other, within the precision\n    * determined by \\a prec.\n    *\n    * \\sa MatrixBase::isApprox() */\n  EIGEN_DEVICE_FUNC bool isApprox(const Translation& other, const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision()) const\n  { return m_coeffs.isApprox(other.m_coeffs, prec); }\n\n};\n\n/** \\addtogroup Geometry_Module */\n//@{\ntypedef Translation<float, 2> Translation2f;\ntypedef Translation<double,2> Translation2d;\ntypedef Translation<float, 3> Translation3f;\ntypedef Translation<double,3> Translation3d;\n//@}\n\ntemplate<typename Scalar, int Dim>\nEIGEN_DEVICE_FUNC inline typename Translation<Scalar,Dim>::AffineTransformType\nTranslation<Scalar,Dim>::operator* (const UniformScaling<Scalar>& other) const\n{\n  AffineTransformType res;\n  res.matrix().setZero();\n  res.linear().diagonal().fill(other.factor());\n  res.translation() = m_coeffs;\n  res(Dim,Dim) = Scalar(1);\n  return res;\n}\n\ntemplate<typename Scalar, int Dim>\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC inline typename Translation<Scalar,Dim>::AffineTransformType\nTranslation<Scalar,Dim>::operator* (const EigenBase<OtherDerived>& linear) const\n{\n  AffineTransformType res;\n  res.matrix().setZero();\n  res.linear() = linear.derived();\n  res.translation() = m_coeffs;\n  res.matrix().row(Dim).setZero();\n  res(Dim,Dim) = Scalar(1);\n  return res;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_TRANSLATION_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/Umeyama.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Hauke Heibel <hauke.heibel@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_UMEYAMA_H\n#define EIGEN_UMEYAMA_H\n\n// This file requires the user to include \n// * Eigen/Core\n// * Eigen/LU \n// * Eigen/SVD\n// * Eigen/Array\n\nnamespace Eigen { \n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n\n// These helpers are required since it allows to use mixed types as parameters\n// for the Umeyama. The problem with mixed parameters is that the return type\n// cannot trivially be deduced when float and double types are mixed.\nnamespace internal {\n\n// Compile time return type deduction for different MatrixBase types.\n// Different means here different alignment and parameters but the same underlying\n// real scalar type.\ntemplate<typename MatrixType, typename OtherMatrixType>\nstruct umeyama_transform_matrix_type\n{\n  enum {\n    MinRowsAtCompileTime = EIGEN_SIZE_MIN_PREFER_DYNAMIC(MatrixType::RowsAtCompileTime, OtherMatrixType::RowsAtCompileTime),\n\n    // When possible we want to choose some small fixed size value since the result\n    // is likely to fit on the stack. So here, EIGEN_SIZE_MIN_PREFER_DYNAMIC is not what we want.\n    HomogeneousDimension = int(MinRowsAtCompileTime) == Dynamic ? Dynamic : int(MinRowsAtCompileTime)+1\n  };\n\n  typedef Matrix<typename traits<MatrixType>::Scalar,\n    HomogeneousDimension,\n    HomogeneousDimension,\n    AutoAlign | (traits<MatrixType>::Flags & RowMajorBit ? RowMajor : ColMajor),\n    HomogeneousDimension,\n    HomogeneousDimension\n  > type;\n};\n\n}\n\n#endif\n\n/**\n* \\geometry_module \\ingroup Geometry_Module\n*\n* \\brief Returns the transformation between two point sets.\n*\n* The algorithm is based on:\n* \"Least-squares estimation of transformation parameters between two point patterns\",\n* Shinji Umeyama, PAMI 1991, DOI: 10.1109/34.88573\n*\n* It estimates parameters \\f$ c, \\mathbf{R}, \\f$ and \\f$ \\mathbf{t} \\f$ such that\n* \\f{align*}\n*   \\frac{1}{n} \\sum_{i=1}^n \\vert\\vert y_i - (c\\mathbf{R}x_i + \\mathbf{t}) \\vert\\vert_2^2\n* \\f}\n* is minimized.\n*\n* The algorithm is based on the analysis of the covariance matrix\n* \\f$ \\Sigma_{\\mathbf{x}\\mathbf{y}} \\in \\mathbb{R}^{d \\times d} \\f$\n* of the input point sets \\f$ \\mathbf{x} \\f$ and \\f$ \\mathbf{y} \\f$ where \n* \\f$d\\f$ is corresponding to the dimension (which is typically small).\n* The analysis is involving the SVD having a complexity of \\f$O(d^3)\\f$\n* though the actual computational effort lies in the covariance\n* matrix computation which has an asymptotic lower bound of \\f$O(dm)\\f$ when \n* the input point sets have dimension \\f$d \\times m\\f$.\n*\n* Currently the method is working only for floating point matrices.\n*\n* \\todo Should the return type of umeyama() become a Transform?\n*\n* \\param src Source points \\f$ \\mathbf{x} = \\left( x_1, \\hdots, x_n \\right) \\f$.\n* \\param dst Destination points \\f$ \\mathbf{y} = \\left( y_1, \\hdots, y_n \\right) \\f$.\n* \\param with_scaling Sets \\f$ c=1 \\f$ when <code>false</code> is passed.\n* \\return The homogeneous transformation \n* \\f{align*}\n*   T = \\begin{bmatrix} c\\mathbf{R} & \\mathbf{t} \\\\ \\mathbf{0} & 1 \\end{bmatrix}\n* \\f}\n* minimizing the resudiual above. This transformation is always returned as an \n* Eigen::Matrix.\n*/\ntemplate <typename Derived, typename OtherDerived>\ntypename internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type\numeyama(const MatrixBase<Derived>& src, const MatrixBase<OtherDerived>& dst, bool with_scaling = true)\n{\n  typedef typename internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type TransformationMatrixType;\n  typedef typename internal::traits<TransformationMatrixType>::Scalar Scalar;\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n\n  EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsComplex, NUMERIC_TYPE_MUST_BE_REAL)\n  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename internal::traits<OtherDerived>::Scalar>::value),\n    YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)\n\n  enum { Dimension = EIGEN_SIZE_MIN_PREFER_DYNAMIC(Derived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime) };\n\n  typedef Matrix<Scalar, Dimension, 1> VectorType;\n  typedef Matrix<Scalar, Dimension, Dimension> MatrixType;\n  typedef typename internal::plain_matrix_type_row_major<Derived>::type RowMajorMatrixType;\n\n  const Index m = src.rows(); // dimension\n  const Index n = src.cols(); // number of measurements\n\n  // required for demeaning ...\n  const RealScalar one_over_n = RealScalar(1) / static_cast<RealScalar>(n);\n\n  // computation of mean\n  const VectorType src_mean = src.rowwise().sum() * one_over_n;\n  const VectorType dst_mean = dst.rowwise().sum() * one_over_n;\n\n  // demeaning of src and dst points\n  const RowMajorMatrixType src_demean = src.colwise() - src_mean;\n  const RowMajorMatrixType dst_demean = dst.colwise() - dst_mean;\n\n  // Eq. (36)-(37)\n  const Scalar src_var = src_demean.rowwise().squaredNorm().sum() * one_over_n;\n\n  // Eq. (38)\n  const MatrixType sigma = one_over_n * dst_demean * src_demean.transpose();\n\n  JacobiSVD<MatrixType> svd(sigma, ComputeFullU | ComputeFullV);\n\n  // Initialize the resulting transformation with an identity matrix...\n  TransformationMatrixType Rt = TransformationMatrixType::Identity(m+1,m+1);\n\n  // Eq. (39)\n  VectorType S = VectorType::Ones(m);\n\n  if  ( svd.matrixU().determinant() * svd.matrixV().determinant() < 0 )\n    S(m-1) = -1;\n\n  // Eq. (40) and (43)\n  Rt.block(0,0,m,m).noalias() = svd.matrixU() * S.asDiagonal() * svd.matrixV().transpose();\n\n  if (with_scaling)\n  {\n    // Eq. (42)\n    const Scalar c = Scalar(1)/src_var * svd.singularValues().dot(S);\n\n    // Eq. (41)\n    Rt.col(m).head(m) = dst_mean;\n    Rt.col(m).head(m).noalias() -= c*Rt.topLeftCorner(m,m)*src_mean;\n    Rt.block(0,0,m,m) *= c;\n  }\n  else\n  {\n    Rt.col(m).head(m) = dst_mean;\n    Rt.col(m).head(m).noalias() -= Rt.topLeftCorner(m,m)*src_mean;\n  }\n\n  return Rt;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_UMEYAMA_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Geometry/arch/Geometry_SSE.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Rohit Garg <rpg.314@gmail.com>\n// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_GEOMETRY_SSE_H\n#define EIGEN_GEOMETRY_SSE_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<class Derived, class OtherDerived>\nstruct quat_product<Architecture::SSE, Derived, OtherDerived, float>\n{\n  enum {\n    AAlignment = traits<Derived>::Alignment,\n    BAlignment = traits<OtherDerived>::Alignment,\n    ResAlignment = traits<Quaternion<float> >::Alignment\n  };\n  static inline Quaternion<float> run(const QuaternionBase<Derived>& _a, const QuaternionBase<OtherDerived>& _b)\n  {\n    Quaternion<float> res;\n    const __m128 mask = _mm_setr_ps(0.f,0.f,0.f,-0.f);\n    __m128 a = _a.coeffs().template packet<AAlignment>(0);\n    __m128 b = _b.coeffs().template packet<BAlignment>(0);\n    __m128 s1 = _mm_mul_ps(vec4f_swizzle1(a,1,2,0,2),vec4f_swizzle1(b,2,0,1,2));\n    __m128 s2 = _mm_mul_ps(vec4f_swizzle1(a,3,3,3,1),vec4f_swizzle1(b,0,1,2,1));\n    pstoret<float,Packet4f,ResAlignment>(\n              &res.x(),\n              _mm_add_ps(_mm_sub_ps(_mm_mul_ps(a,vec4f_swizzle1(b,3,3,3,3)),\n                                    _mm_mul_ps(vec4f_swizzle1(a,2,0,1,0),\n                                               vec4f_swizzle1(b,1,2,0,0))),\n                         _mm_xor_ps(mask,_mm_add_ps(s1,s2))));\n    \n    return res;\n  }\n};\n\ntemplate<class Derived>\nstruct quat_conj<Architecture::SSE, Derived, float>\n{\n  enum {\n    ResAlignment = traits<Quaternion<float> >::Alignment\n  };\n  static inline Quaternion<float> run(const QuaternionBase<Derived>& q)\n  {\n    Quaternion<float> res;\n    const __m128 mask = _mm_setr_ps(-0.f,-0.f,-0.f,0.f);\n    pstoret<float,Packet4f,ResAlignment>(&res.x(), _mm_xor_ps(mask, q.coeffs().template packet<traits<Derived>::Alignment>(0)));\n    return res;\n  }\n};\n\n\ntemplate<typename VectorLhs,typename VectorRhs>\nstruct cross3_impl<Architecture::SSE,VectorLhs,VectorRhs,float,true>\n{\n  enum {\n    ResAlignment = traits<typename plain_matrix_type<VectorLhs>::type>::Alignment\n  };\n  static inline typename plain_matrix_type<VectorLhs>::type\n  run(const VectorLhs& lhs, const VectorRhs& rhs)\n  {\n    __m128 a = lhs.template packet<traits<VectorLhs>::Alignment>(0);\n    __m128 b = rhs.template packet<traits<VectorRhs>::Alignment>(0);\n    __m128 mul1=_mm_mul_ps(vec4f_swizzle1(a,1,2,0,3),vec4f_swizzle1(b,2,0,1,3));\n    __m128 mul2=_mm_mul_ps(vec4f_swizzle1(a,2,0,1,3),vec4f_swizzle1(b,1,2,0,3));\n    typename plain_matrix_type<VectorLhs>::type res;\n    pstoret<float,Packet4f,ResAlignment>(&res.x(),_mm_sub_ps(mul1,mul2));\n    return res;\n  }\n};\n\n\n\n\ntemplate<class Derived, class OtherDerived>\nstruct quat_product<Architecture::SSE, Derived, OtherDerived, double>\n{\n  enum {\n    BAlignment = traits<OtherDerived>::Alignment,\n    ResAlignment = traits<Quaternion<double> >::Alignment\n  };\n\n  static inline Quaternion<double> run(const QuaternionBase<Derived>& _a, const QuaternionBase<OtherDerived>& _b)\n  {\n  const Packet2d mask = _mm_castsi128_pd(_mm_set_epi32(0x0,0x0,0x80000000,0x0));\n\n  Quaternion<double> res;\n\n  const double* a = _a.coeffs().data();\n  Packet2d b_xy = _b.coeffs().template packet<BAlignment>(0);\n  Packet2d b_zw = _b.coeffs().template packet<BAlignment>(2);\n  Packet2d a_xx = pset1<Packet2d>(a[0]);\n  Packet2d a_yy = pset1<Packet2d>(a[1]);\n  Packet2d a_zz = pset1<Packet2d>(a[2]);\n  Packet2d a_ww = pset1<Packet2d>(a[3]);\n\n  // two temporaries:\n  Packet2d t1, t2;\n\n  /*\n   * t1 = ww*xy + yy*zw\n   * t2 = zz*xy - xx*zw\n   * res.xy = t1 +/- swap(t2)\n   */\n  t1 = padd(pmul(a_ww, b_xy), pmul(a_yy, b_zw));\n  t2 = psub(pmul(a_zz, b_xy), pmul(a_xx, b_zw));\n#ifdef EIGEN_VECTORIZE_SSE3\n  EIGEN_UNUSED_VARIABLE(mask)\n  pstoret<double,Packet2d,ResAlignment>(&res.x(), _mm_addsub_pd(t1, preverse(t2)));\n#else\n  pstoret<double,Packet2d,ResAlignment>(&res.x(), padd(t1, pxor(mask,preverse(t2))));\n#endif\n  \n  /*\n   * t1 = ww*zw - yy*xy\n   * t2 = zz*zw + xx*xy\n   * res.zw = t1 -/+ swap(t2) = swap( swap(t1) +/- t2)\n   */\n  t1 = psub(pmul(a_ww, b_zw), pmul(a_yy, b_xy));\n  t2 = padd(pmul(a_zz, b_zw), pmul(a_xx, b_xy));\n#ifdef EIGEN_VECTORIZE_SSE3\n  EIGEN_UNUSED_VARIABLE(mask)\n  pstoret<double,Packet2d,ResAlignment>(&res.z(), preverse(_mm_addsub_pd(preverse(t1), t2)));\n#else\n  pstoret<double,Packet2d,ResAlignment>(&res.z(), psub(t1, pxor(mask,preverse(t2))));\n#endif\n\n  return res;\n}\n};\n\ntemplate<class Derived>\nstruct quat_conj<Architecture::SSE, Derived, double>\n{\n  enum {\n    ResAlignment = traits<Quaternion<double> >::Alignment\n  };\n  static inline Quaternion<double> run(const QuaternionBase<Derived>& q)\n  {\n    Quaternion<double> res;\n    const __m128d mask0 = _mm_setr_pd(-0.,-0.);\n    const __m128d mask2 = _mm_setr_pd(-0.,0.);\n    pstoret<double,Packet2d,ResAlignment>(&res.x(), _mm_xor_pd(mask0, q.coeffs().template packet<traits<Derived>::Alignment>(0)));\n    pstoret<double,Packet2d,ResAlignment>(&res.z(), _mm_xor_pd(mask2, q.coeffs().template packet<traits<Derived>::Alignment>(2)));\n    return res;\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_GEOMETRY_SSE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Householder/BlockHouseholder.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010 Vincent Lejeune\n// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_BLOCK_HOUSEHOLDER_H\n#define EIGEN_BLOCK_HOUSEHOLDER_H\n\n// This file contains some helper function to deal with block householder reflectors\n\nnamespace Eigen { \n\nnamespace internal {\n  \n/** \\internal */\n// template<typename TriangularFactorType,typename VectorsType,typename CoeffsType>\n// void make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs)\n// {\n//   typedef typename VectorsType::Scalar Scalar;\n//   const Index nbVecs = vectors.cols();\n//   eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs);\n// \n//   for(Index i = 0; i < nbVecs; i++)\n//   {\n//     Index rs = vectors.rows() - i;\n//     // Warning, note that hCoeffs may alias with vectors.\n//     // It is then necessary to copy it before modifying vectors(i,i). \n//     typename CoeffsType::Scalar h = hCoeffs(i);\n//     // This hack permits to pass trough nested Block<> and Transpose<> expressions.\n//     Scalar *Vii_ptr = const_cast<Scalar*>(vectors.data() + vectors.outerStride()*i + vectors.innerStride()*i);\n//     Scalar Vii = *Vii_ptr;\n//     *Vii_ptr = Scalar(1);\n//     triFactor.col(i).head(i).noalias() = -h * vectors.block(i, 0, rs, i).adjoint()\n//                                        * vectors.col(i).tail(rs);\n//     *Vii_ptr = Vii;\n//     // FIXME add .noalias() once the triangular product can work inplace\n//     triFactor.col(i).head(i) = triFactor.block(0,0,i,i).template triangularView<Upper>()\n//                              * triFactor.col(i).head(i);\n//     triFactor(i,i) = hCoeffs(i);\n//   }\n// }\n\n/** \\internal */\n// This variant avoid modifications in vectors\ntemplate<typename TriangularFactorType,typename VectorsType,typename CoeffsType>\nvoid make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs)\n{\n  const Index nbVecs = vectors.cols();\n  eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs);\n\n  for(Index i = nbVecs-1; i >=0 ; --i)\n  {\n    Index rs = vectors.rows() - i - 1;\n    Index rt = nbVecs-i-1;\n\n    if(rt>0)\n    {\n      triFactor.row(i).tail(rt).noalias() = -hCoeffs(i) * vectors.col(i).tail(rs).adjoint()\n                                                        * vectors.bottomRightCorner(rs, rt).template triangularView<UnitLower>();\n            \n      // FIXME add .noalias() once the triangular product can work inplace\n      triFactor.row(i).tail(rt) = triFactor.row(i).tail(rt) * triFactor.bottomRightCorner(rt,rt).template triangularView<Upper>();\n      \n    }\n    triFactor(i,i) = hCoeffs(i);\n  }\n}\n\n/** \\internal\n  * if forward then perform   mat = H0 * H1 * H2 * mat\n  * otherwise perform         mat = H2 * H1 * H0 * mat\n  */\ntemplate<typename MatrixType,typename VectorsType,typename CoeffsType>\nvoid apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vectors, const CoeffsType& hCoeffs, bool forward)\n{\n  enum { TFactorSize = MatrixType::ColsAtCompileTime };\n  Index nbVecs = vectors.cols();\n  Matrix<typename MatrixType::Scalar, TFactorSize, TFactorSize, RowMajor> T(nbVecs,nbVecs);\n  \n  if(forward) make_block_householder_triangular_factor(T, vectors, hCoeffs);\n  else        make_block_householder_triangular_factor(T, vectors, hCoeffs.conjugate());  \n  const TriangularView<const VectorsType, UnitLower> V(vectors);\n\n  // A -= V T V^* A\n  Matrix<typename MatrixType::Scalar,VectorsType::ColsAtCompileTime,MatrixType::ColsAtCompileTime,\n         (VectorsType::MaxColsAtCompileTime==1 && MatrixType::MaxColsAtCompileTime!=1)?RowMajor:ColMajor,\n         VectorsType::MaxColsAtCompileTime,MatrixType::MaxColsAtCompileTime> tmp = V.adjoint() * mat;\n  // FIXME add .noalias() once the triangular product can work inplace\n  if(forward) tmp = T.template triangularView<Upper>()           * tmp;\n  else        tmp = T.template triangularView<Upper>().adjoint() * tmp;\n  mat.noalias() -= V * tmp;\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_BLOCK_HOUSEHOLDER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Householder/Householder.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_HOUSEHOLDER_H\n#define EIGEN_HOUSEHOLDER_H\n\nnamespace Eigen { \n\nnamespace internal {\ntemplate<int n> struct decrement_size\n{\n  enum {\n    ret = n==Dynamic ? n : n-1\n  };\n};\n}\n\n/** Computes the elementary reflector H such that:\n  * \\f$ H *this = [ beta 0 ... 0]^T \\f$\n  * where the transformation H is:\n  * \\f$ H = I - tau v v^*\\f$\n  * and the vector v is:\n  * \\f$ v^T = [1 essential^T] \\f$\n  *\n  * The essential part of the vector \\c v is stored in *this.\n  * \n  * On output:\n  * \\param tau the scaling factor of the Householder transformation\n  * \\param beta the result of H * \\c *this\n  *\n  * \\sa MatrixBase::makeHouseholder(), MatrixBase::applyHouseholderOnTheLeft(),\n  *     MatrixBase::applyHouseholderOnTheRight()\n  */\ntemplate<typename Derived>\nvoid MatrixBase<Derived>::makeHouseholderInPlace(Scalar& tau, RealScalar& beta)\n{\n  VectorBlock<Derived, internal::decrement_size<Base::SizeAtCompileTime>::ret> essentialPart(derived(), 1, size()-1);\n  makeHouseholder(essentialPart, tau, beta);\n}\n\n/** Computes the elementary reflector H such that:\n  * \\f$ H *this = [ beta 0 ... 0]^T \\f$\n  * where the transformation H is:\n  * \\f$ H = I - tau v v^*\\f$\n  * and the vector v is:\n  * \\f$ v^T = [1 essential^T] \\f$\n  *\n  * On output:\n  * \\param essential the essential part of the vector \\c v\n  * \\param tau the scaling factor of the Householder transformation\n  * \\param beta the result of H * \\c *this\n  *\n  * \\sa MatrixBase::makeHouseholderInPlace(), MatrixBase::applyHouseholderOnTheLeft(),\n  *     MatrixBase::applyHouseholderOnTheRight()\n  */\ntemplate<typename Derived>\ntemplate<typename EssentialPart>\nvoid MatrixBase<Derived>::makeHouseholder(\n  EssentialPart& essential,\n  Scalar& tau,\n  RealScalar& beta) const\n{\n  using std::sqrt;\n  using numext::conj;\n  \n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart)\n  VectorBlock<const Derived, EssentialPart::SizeAtCompileTime> tail(derived(), 1, size()-1);\n  \n  RealScalar tailSqNorm = size()==1 ? RealScalar(0) : tail.squaredNorm();\n  Scalar c0 = coeff(0);\n  const RealScalar tol = (std::numeric_limits<RealScalar>::min)();\n\n  if(tailSqNorm <= tol && numext::abs2(numext::imag(c0))<=tol)\n  {\n    tau = RealScalar(0);\n    beta = numext::real(c0);\n    essential.setZero();\n  }\n  else\n  {\n    beta = sqrt(numext::abs2(c0) + tailSqNorm);\n    if (numext::real(c0)>=RealScalar(0))\n      beta = -beta;\n    essential = tail / (c0 - beta);\n    tau = conj((beta - c0) / beta);\n  }\n}\n\n/** Apply the elementary reflector H given by\n  * \\f$ H = I - tau v v^*\\f$\n  * with\n  * \\f$ v^T = [1 essential^T] \\f$\n  * from the left to a vector or matrix.\n  *\n  * On input:\n  * \\param essential the essential part of the vector \\c v\n  * \\param tau the scaling factor of the Householder transformation\n  * \\param workspace a pointer to working space with at least\n  *                  this->cols() * essential.size() entries\n  *\n  * \\sa MatrixBase::makeHouseholder(), MatrixBase::makeHouseholderInPlace(), \n  *     MatrixBase::applyHouseholderOnTheRight()\n  */\ntemplate<typename Derived>\ntemplate<typename EssentialPart>\nvoid MatrixBase<Derived>::applyHouseholderOnTheLeft(\n  const EssentialPart& essential,\n  const Scalar& tau,\n  Scalar* workspace)\n{\n  if(rows() == 1)\n  {\n    *this *= Scalar(1)-tau;\n  }\n  else if(tau!=Scalar(0))\n  {\n    Map<typename internal::plain_row_type<PlainObject>::type> tmp(workspace,cols());\n    Block<Derived, EssentialPart::SizeAtCompileTime, Derived::ColsAtCompileTime> bottom(derived(), 1, 0, rows()-1, cols());\n    tmp.noalias() = essential.adjoint() * bottom;\n    tmp += this->row(0);\n    this->row(0) -= tau * tmp;\n    bottom.noalias() -= tau * essential * tmp;\n  }\n}\n\n/** Apply the elementary reflector H given by\n  * \\f$ H = I - tau v v^*\\f$\n  * with\n  * \\f$ v^T = [1 essential^T] \\f$\n  * from the right to a vector or matrix.\n  *\n  * On input:\n  * \\param essential the essential part of the vector \\c v\n  * \\param tau the scaling factor of the Householder transformation\n  * \\param workspace a pointer to working space with at least\n  *                  this->cols() * essential.size() entries\n  *\n  * \\sa MatrixBase::makeHouseholder(), MatrixBase::makeHouseholderInPlace(), \n  *     MatrixBase::applyHouseholderOnTheLeft()\n  */\ntemplate<typename Derived>\ntemplate<typename EssentialPart>\nvoid MatrixBase<Derived>::applyHouseholderOnTheRight(\n  const EssentialPart& essential,\n  const Scalar& tau,\n  Scalar* workspace)\n{\n  if(cols() == 1)\n  {\n    *this *= Scalar(1)-tau;\n  }\n  else if(tau!=Scalar(0))\n  {\n    Map<typename internal::plain_col_type<PlainObject>::type> tmp(workspace,rows());\n    Block<Derived, Derived::RowsAtCompileTime, EssentialPart::SizeAtCompileTime> right(derived(), 0, 1, rows(), cols()-1);\n    tmp.noalias() = right * essential.conjugate();\n    tmp += this->col(0);\n    this->col(0) -= tau * tmp;\n    right.noalias() -= tau * tmp * essential.transpose();\n  }\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_HOUSEHOLDER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Householder/HouseholderSequence.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_HOUSEHOLDER_SEQUENCE_H\n#define EIGEN_HOUSEHOLDER_SEQUENCE_H\n\nnamespace Eigen { \n\n/** \\ingroup Householder_Module\n  * \\householder_module\n  * \\class HouseholderSequence\n  * \\brief Sequence of Householder reflections acting on subspaces with decreasing size\n  * \\tparam VectorsType type of matrix containing the Householder vectors\n  * \\tparam CoeffsType  type of vector containing the Householder coefficients\n  * \\tparam Side        either OnTheLeft (the default) or OnTheRight\n  *\n  * This class represents a product sequence of Householder reflections where the first Householder reflection\n  * acts on the whole space, the second Householder reflection leaves the one-dimensional subspace spanned by\n  * the first unit vector invariant, the third Householder reflection leaves the two-dimensional subspace\n  * spanned by the first two unit vectors invariant, and so on up to the last reflection which leaves all but\n  * one dimensions invariant and acts only on the last dimension. Such sequences of Householder reflections\n  * are used in several algorithms to zero out certain parts of a matrix. Indeed, the methods\n  * HessenbergDecomposition::matrixQ(), Tridiagonalization::matrixQ(), HouseholderQR::householderQ(),\n  * and ColPivHouseholderQR::householderQ() all return a %HouseholderSequence.\n  *\n  * More precisely, the class %HouseholderSequence represents an \\f$ n \\times n \\f$ matrix \\f$ H \\f$ of the\n  * form \\f$ H = \\prod_{i=0}^{n-1} H_i \\f$ where the i-th Householder reflection is \\f$ H_i = I - h_i v_i\n  * v_i^* \\f$. The i-th Householder coefficient \\f$ h_i \\f$ is a scalar and the i-th Householder vector \\f$\n  * v_i \\f$ is a vector of the form\n  * \\f[ \n  * v_i = [\\underbrace{0, \\ldots, 0}_{i-1\\mbox{ zeros}}, 1, \\underbrace{*, \\ldots,*}_{n-i\\mbox{ arbitrary entries}} ]. \n  * \\f]\n  * The last \\f$ n-i \\f$ entries of \\f$ v_i \\f$ are called the essential part of the Householder vector.\n  *\n  * Typical usages are listed below, where H is a HouseholderSequence:\n  * \\code\n  * A.applyOnTheRight(H);             // A = A * H\n  * A.applyOnTheLeft(H);              // A = H * A\n  * A.applyOnTheRight(H.adjoint());   // A = A * H^*\n  * A.applyOnTheLeft(H.adjoint());    // A = H^* * A\n  * MatrixXd Q = H;                   // conversion to a dense matrix\n  * \\endcode\n  * In addition to the adjoint, you can also apply the inverse (=adjoint), the transpose, and the conjugate operators.\n  *\n  * See the documentation for HouseholderSequence(const VectorsType&, const CoeffsType&) for an example.\n  *\n  * \\sa MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()\n  */\n\nnamespace internal {\n\ntemplate<typename VectorsType, typename CoeffsType, int Side>\nstruct traits<HouseholderSequence<VectorsType,CoeffsType,Side> >\n{\n  typedef typename VectorsType::Scalar Scalar;\n  typedef typename VectorsType::StorageIndex StorageIndex;\n  typedef typename VectorsType::StorageKind StorageKind;\n  enum {\n    RowsAtCompileTime = Side==OnTheLeft ? traits<VectorsType>::RowsAtCompileTime\n                                        : traits<VectorsType>::ColsAtCompileTime,\n    ColsAtCompileTime = RowsAtCompileTime,\n    MaxRowsAtCompileTime = Side==OnTheLeft ? traits<VectorsType>::MaxRowsAtCompileTime\n                                           : traits<VectorsType>::MaxColsAtCompileTime,\n    MaxColsAtCompileTime = MaxRowsAtCompileTime,\n    Flags = 0\n  };\n};\n\nstruct HouseholderSequenceShape {};\n\ntemplate<typename VectorsType, typename CoeffsType, int Side>\nstruct evaluator_traits<HouseholderSequence<VectorsType,CoeffsType,Side> >\n  : public evaluator_traits_base<HouseholderSequence<VectorsType,CoeffsType,Side> >\n{\n  typedef HouseholderSequenceShape Shape;\n};\n\ntemplate<typename VectorsType, typename CoeffsType, int Side>\nstruct hseq_side_dependent_impl\n{\n  typedef Block<const VectorsType, Dynamic, 1> EssentialVectorType;\n  typedef HouseholderSequence<VectorsType, CoeffsType, OnTheLeft> HouseholderSequenceType;\n  static inline const EssentialVectorType essentialVector(const HouseholderSequenceType& h, Index k)\n  {\n    Index start = k+1+h.m_shift;\n    return Block<const VectorsType,Dynamic,1>(h.m_vectors, start, k, h.rows()-start, 1);\n  }\n};\n\ntemplate<typename VectorsType, typename CoeffsType>\nstruct hseq_side_dependent_impl<VectorsType, CoeffsType, OnTheRight>\n{\n  typedef Transpose<Block<const VectorsType, 1, Dynamic> > EssentialVectorType;\n  typedef HouseholderSequence<VectorsType, CoeffsType, OnTheRight> HouseholderSequenceType;\n  static inline const EssentialVectorType essentialVector(const HouseholderSequenceType& h, Index k)\n  {\n    Index start = k+1+h.m_shift;\n    return Block<const VectorsType,1,Dynamic>(h.m_vectors, k, start, 1, h.rows()-start).transpose();\n  }\n};\n\ntemplate<typename OtherScalarType, typename MatrixType> struct matrix_type_times_scalar_type\n{\n  typedef typename ScalarBinaryOpTraits<OtherScalarType, typename MatrixType::Scalar>::ReturnType\n    ResultScalar;\n  typedef Matrix<ResultScalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime,\n                 0, MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime> Type;\n};\n\n} // end namespace internal\n\ntemplate<typename VectorsType, typename CoeffsType, int Side> class HouseholderSequence\n  : public EigenBase<HouseholderSequence<VectorsType,CoeffsType,Side> >\n{\n    typedef typename internal::hseq_side_dependent_impl<VectorsType,CoeffsType,Side>::EssentialVectorType EssentialVectorType;\n  \n  public:\n    enum {\n      RowsAtCompileTime = internal::traits<HouseholderSequence>::RowsAtCompileTime,\n      ColsAtCompileTime = internal::traits<HouseholderSequence>::ColsAtCompileTime,\n      MaxRowsAtCompileTime = internal::traits<HouseholderSequence>::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = internal::traits<HouseholderSequence>::MaxColsAtCompileTime\n    };\n    typedef typename internal::traits<HouseholderSequence>::Scalar Scalar;\n\n    typedef HouseholderSequence<\n      typename internal::conditional<NumTraits<Scalar>::IsComplex,\n        typename internal::remove_all<typename VectorsType::ConjugateReturnType>::type,\n        VectorsType>::type,\n      typename internal::conditional<NumTraits<Scalar>::IsComplex,\n        typename internal::remove_all<typename CoeffsType::ConjugateReturnType>::type,\n        CoeffsType>::type,\n      Side\n    > ConjugateReturnType;\n\n    /** \\brief Constructor.\n      * \\param[in]  v      %Matrix containing the essential parts of the Householder vectors\n      * \\param[in]  h      Vector containing the Householder coefficients\n      *\n      * Constructs the Householder sequence with coefficients given by \\p h and vectors given by \\p v. The\n      * i-th Householder coefficient \\f$ h_i \\f$ is given by \\p h(i) and the essential part of the i-th\n      * Householder vector \\f$ v_i \\f$ is given by \\p v(k,i) with \\p k > \\p i (the subdiagonal part of the\n      * i-th column). If \\p v has fewer columns than rows, then the Householder sequence contains as many\n      * Householder reflections as there are columns.\n      *\n      * \\note The %HouseholderSequence object stores \\p v and \\p h by reference.\n      *\n      * Example: \\include HouseholderSequence_HouseholderSequence.cpp\n      * Output: \\verbinclude HouseholderSequence_HouseholderSequence.out\n      *\n      * \\sa setLength(), setShift()\n      */\n    HouseholderSequence(const VectorsType& v, const CoeffsType& h)\n      : m_vectors(v), m_coeffs(h), m_trans(false), m_length(v.diagonalSize()),\n        m_shift(0)\n    {\n    }\n\n    /** \\brief Copy constructor. */\n    HouseholderSequence(const HouseholderSequence& other)\n      : m_vectors(other.m_vectors),\n        m_coeffs(other.m_coeffs),\n        m_trans(other.m_trans),\n        m_length(other.m_length),\n        m_shift(other.m_shift)\n    {\n    }\n\n    /** \\brief Number of rows of transformation viewed as a matrix.\n      * \\returns Number of rows \n      * \\details This equals the dimension of the space that the transformation acts on.\n      */\n    Index rows() const { return Side==OnTheLeft ? m_vectors.rows() : m_vectors.cols(); }\n\n    /** \\brief Number of columns of transformation viewed as a matrix.\n      * \\returns Number of columns\n      * \\details This equals the dimension of the space that the transformation acts on.\n      */\n    Index cols() const { return rows(); }\n\n    /** \\brief Essential part of a Householder vector.\n      * \\param[in]  k  Index of Householder reflection\n      * \\returns    Vector containing non-trivial entries of k-th Householder vector\n      *\n      * This function returns the essential part of the Householder vector \\f$ v_i \\f$. This is a vector of\n      * length \\f$ n-i \\f$ containing the last \\f$ n-i \\f$ entries of the vector\n      * \\f[ \n      * v_i = [\\underbrace{0, \\ldots, 0}_{i-1\\mbox{ zeros}}, 1, \\underbrace{*, \\ldots,*}_{n-i\\mbox{ arbitrary entries}} ]. \n      * \\f]\n      * The index \\f$ i \\f$ equals \\p k + shift(), corresponding to the k-th column of the matrix \\p v\n      * passed to the constructor.\n      *\n      * \\sa setShift(), shift()\n      */\n    const EssentialVectorType essentialVector(Index k) const\n    {\n      eigen_assert(k >= 0 && k < m_length);\n      return internal::hseq_side_dependent_impl<VectorsType,CoeffsType,Side>::essentialVector(*this, k);\n    }\n\n    /** \\brief %Transpose of the Householder sequence. */\n    HouseholderSequence transpose() const\n    {\n      return HouseholderSequence(*this).setTrans(!m_trans);\n    }\n\n    /** \\brief Complex conjugate of the Householder sequence. */\n    ConjugateReturnType conjugate() const\n    {\n      return ConjugateReturnType(m_vectors.conjugate(), m_coeffs.conjugate())\n             .setTrans(m_trans)\n             .setLength(m_length)\n             .setShift(m_shift);\n    }\n\n    /** \\brief Adjoint (conjugate transpose) of the Householder sequence. */\n    ConjugateReturnType adjoint() const\n    {\n      return conjugate().setTrans(!m_trans);\n    }\n\n    /** \\brief Inverse of the Householder sequence (equals the adjoint). */\n    ConjugateReturnType inverse() const { return adjoint(); }\n\n    /** \\internal */\n    template<typename DestType> inline void evalTo(DestType& dst) const\n    {\n      Matrix<Scalar, DestType::RowsAtCompileTime, 1,\n             AutoAlign|ColMajor, DestType::MaxRowsAtCompileTime, 1> workspace(rows());\n      evalTo(dst, workspace);\n    }\n\n    /** \\internal */\n    template<typename Dest, typename Workspace>\n    void evalTo(Dest& dst, Workspace& workspace) const\n    {\n      workspace.resize(rows());\n      Index vecs = m_length;\n      if(internal::is_same_dense(dst,m_vectors))\n      {\n        // in-place\n        dst.diagonal().setOnes();\n        dst.template triangularView<StrictlyUpper>().setZero();\n        for(Index k = vecs-1; k >= 0; --k)\n        {\n          Index cornerSize = rows() - k - m_shift;\n          if(m_trans)\n            dst.bottomRightCorner(cornerSize, cornerSize)\n               .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), workspace.data());\n          else\n            dst.bottomRightCorner(cornerSize, cornerSize)\n               .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), workspace.data());\n\n          // clear the off diagonal vector\n          dst.col(k).tail(rows()-k-1).setZero();\n        }\n        // clear the remaining columns if needed\n        for(Index k = 0; k<cols()-vecs ; ++k)\n          dst.col(k).tail(rows()-k-1).setZero();\n      }\n      else\n      {\n        dst.setIdentity(rows(), rows());\n        for(Index k = vecs-1; k >= 0; --k)\n        {\n          Index cornerSize = rows() - k - m_shift;\n          if(m_trans)\n            dst.bottomRightCorner(cornerSize, cornerSize)\n               .applyHouseholderOnTheRight(essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0));\n          else\n            dst.bottomRightCorner(cornerSize, cornerSize)\n               .applyHouseholderOnTheLeft(essentialVector(k), m_coeffs.coeff(k), &workspace.coeffRef(0));\n        }\n      }\n    }\n\n    /** \\internal */\n    template<typename Dest> inline void applyThisOnTheRight(Dest& dst) const\n    {\n      Matrix<Scalar,1,Dest::RowsAtCompileTime,RowMajor,1,Dest::MaxRowsAtCompileTime> workspace(dst.rows());\n      applyThisOnTheRight(dst, workspace);\n    }\n\n    /** \\internal */\n    template<typename Dest, typename Workspace>\n    inline void applyThisOnTheRight(Dest& dst, Workspace& workspace) const\n    {\n      workspace.resize(dst.rows());\n      for(Index k = 0; k < m_length; ++k)\n      {\n        Index actual_k = m_trans ? m_length-k-1 : k;\n        dst.rightCols(rows()-m_shift-actual_k)\n           .applyHouseholderOnTheRight(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());\n      }\n    }\n\n    /** \\internal */\n    template<typename Dest> inline void applyThisOnTheLeft(Dest& dst) const\n    {\n      Matrix<Scalar,1,Dest::ColsAtCompileTime,RowMajor,1,Dest::MaxColsAtCompileTime> workspace;\n      applyThisOnTheLeft(dst, workspace);\n    }\n\n    /** \\internal */\n    template<typename Dest, typename Workspace>\n    inline void applyThisOnTheLeft(Dest& dst, Workspace& workspace) const\n    {\n      const Index BlockSize = 48;\n      // if the entries are large enough, then apply the reflectors by block\n      if(m_length>=BlockSize && dst.cols()>1)\n      {\n        for(Index i = 0; i < m_length; i+=BlockSize)\n        {\n          Index end = m_trans ? (std::min)(m_length,i+BlockSize) : m_length-i;\n          Index k = m_trans ? i : (std::max)(Index(0),end-BlockSize);\n          Index bs = end-k;\n          Index start = k + m_shift;\n          \n          typedef Block<typename internal::remove_all<VectorsType>::type,Dynamic,Dynamic> SubVectorsType;\n          SubVectorsType sub_vecs1(m_vectors.const_cast_derived(), Side==OnTheRight ? k : start,\n                                                                   Side==OnTheRight ? start : k,\n                                                                   Side==OnTheRight ? bs : m_vectors.rows()-start,\n                                                                   Side==OnTheRight ? m_vectors.cols()-start : bs);\n          typename internal::conditional<Side==OnTheRight, Transpose<SubVectorsType>, SubVectorsType&>::type sub_vecs(sub_vecs1);\n          Block<Dest,Dynamic,Dynamic> sub_dst(dst,dst.rows()-rows()+m_shift+k,0, rows()-m_shift-k,dst.cols());\n          apply_block_householder_on_the_left(sub_dst, sub_vecs, m_coeffs.segment(k, bs), !m_trans);\n        }\n      }\n      else\n      {\n        workspace.resize(dst.cols());\n        for(Index k = 0; k < m_length; ++k)\n        {\n          Index actual_k = m_trans ? k : m_length-k-1;\n          dst.bottomRows(rows()-m_shift-actual_k)\n            .applyHouseholderOnTheLeft(essentialVector(actual_k), m_coeffs.coeff(actual_k), workspace.data());\n        }\n      }\n    }\n\n    /** \\brief Computes the product of a Householder sequence with a matrix.\n      * \\param[in]  other  %Matrix being multiplied.\n      * \\returns    Expression object representing the product.\n      *\n      * This function computes \\f$ HM \\f$ where \\f$ H \\f$ is the Householder sequence represented by \\p *this\n      * and \\f$ M \\f$ is the matrix \\p other.\n      */\n    template<typename OtherDerived>\n    typename internal::matrix_type_times_scalar_type<Scalar, OtherDerived>::Type operator*(const MatrixBase<OtherDerived>& other) const\n    {\n      typename internal::matrix_type_times_scalar_type<Scalar, OtherDerived>::Type\n        res(other.template cast<typename internal::matrix_type_times_scalar_type<Scalar,OtherDerived>::ResultScalar>());\n      applyThisOnTheLeft(res);\n      return res;\n    }\n\n    template<typename _VectorsType, typename _CoeffsType, int _Side> friend struct internal::hseq_side_dependent_impl;\n\n    /** \\brief Sets the length of the Householder sequence.\n      * \\param [in]  length  New value for the length.\n      *\n      * By default, the length \\f$ n \\f$ of the Householder sequence \\f$ H = H_0 H_1 \\ldots H_{n-1} \\f$ is set\n      * to the number of columns of the matrix \\p v passed to the constructor, or the number of rows if that\n      * is smaller. After this function is called, the length equals \\p length.\n      *\n      * \\sa length()\n      */\n    HouseholderSequence& setLength(Index length)\n    {\n      m_length = length;\n      return *this;\n    }\n\n    /** \\brief Sets the shift of the Householder sequence.\n      * \\param [in]  shift  New value for the shift.\n      *\n      * By default, a %HouseholderSequence object represents \\f$ H = H_0 H_1 \\ldots H_{n-1} \\f$ and the i-th\n      * column of the matrix \\p v passed to the constructor corresponds to the i-th Householder\n      * reflection. After this function is called, the object represents \\f$ H = H_{\\mathrm{shift}}\n      * H_{\\mathrm{shift}+1} \\ldots H_{n-1} \\f$ and the i-th column of \\p v corresponds to the (shift+i)-th\n      * Householder reflection.\n      *\n      * \\sa shift()\n      */\n    HouseholderSequence& setShift(Index shift)\n    {\n      m_shift = shift;\n      return *this;\n    }\n\n    Index length() const { return m_length; }  /**< \\brief Returns the length of the Householder sequence. */\n    Index shift() const { return m_shift; }    /**< \\brief Returns the shift of the Householder sequence. */\n\n    /* Necessary for .adjoint() and .conjugate() */\n    template <typename VectorsType2, typename CoeffsType2, int Side2> friend class HouseholderSequence;\n\n  protected:\n\n    /** \\brief Sets the transpose flag.\n      * \\param [in]  trans  New value of the transpose flag.\n      *\n      * By default, the transpose flag is not set. If the transpose flag is set, then this object represents \n      * \\f$ H^T = H_{n-1}^T \\ldots H_1^T H_0^T \\f$ instead of \\f$ H = H_0 H_1 \\ldots H_{n-1} \\f$.\n      *\n      * \\sa trans()\n      */\n    HouseholderSequence& setTrans(bool trans)\n    {\n      m_trans = trans;\n      return *this;\n    }\n\n    bool trans() const { return m_trans; }     /**< \\brief Returns the transpose flag. */\n\n    typename VectorsType::Nested m_vectors;\n    typename CoeffsType::Nested m_coeffs;\n    bool m_trans;\n    Index m_length;\n    Index m_shift;\n};\n\n/** \\brief Computes the product of a matrix with a Householder sequence.\n  * \\param[in]  other  %Matrix being multiplied.\n  * \\param[in]  h      %HouseholderSequence being multiplied.\n  * \\returns    Expression object representing the product.\n  *\n  * This function computes \\f$ MH \\f$ where \\f$ M \\f$ is the matrix \\p other and \\f$ H \\f$ is the\n  * Householder sequence represented by \\p h.\n  */\ntemplate<typename OtherDerived, typename VectorsType, typename CoeffsType, int Side>\ntypename internal::matrix_type_times_scalar_type<typename VectorsType::Scalar,OtherDerived>::Type operator*(const MatrixBase<OtherDerived>& other, const HouseholderSequence<VectorsType,CoeffsType,Side>& h)\n{\n  typename internal::matrix_type_times_scalar_type<typename VectorsType::Scalar,OtherDerived>::Type\n    res(other.template cast<typename internal::matrix_type_times_scalar_type<typename VectorsType::Scalar,OtherDerived>::ResultScalar>());\n  h.applyThisOnTheRight(res);\n  return res;\n}\n\n/** \\ingroup Householder_Module \\householder_module\n  * \\brief Convenience function for constructing a Householder sequence. \n  * \\returns A HouseholderSequence constructed from the specified arguments.\n  */\ntemplate<typename VectorsType, typename CoeffsType>\nHouseholderSequence<VectorsType,CoeffsType> householderSequence(const VectorsType& v, const CoeffsType& h)\n{\n  return HouseholderSequence<VectorsType,CoeffsType,OnTheLeft>(v, h);\n}\n\n/** \\ingroup Householder_Module \\householder_module\n  * \\brief Convenience function for constructing a Householder sequence. \n  * \\returns A HouseholderSequence constructed from the specified arguments.\n  * \\details This function differs from householderSequence() in that the template argument \\p OnTheSide of\n  * the constructed HouseholderSequence is set to OnTheRight, instead of the default OnTheLeft.\n  */\ntemplate<typename VectorsType, typename CoeffsType>\nHouseholderSequence<VectorsType,CoeffsType,OnTheRight> rightHouseholderSequence(const VectorsType& v, const CoeffsType& h)\n{\n  return HouseholderSequence<VectorsType,CoeffsType,OnTheRight>(v, h);\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_HOUSEHOLDER_SEQUENCE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2011-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_BASIC_PRECONDITIONERS_H\n#define EIGEN_BASIC_PRECONDITIONERS_H\n\nnamespace Eigen { \n\n/** \\ingroup IterativeLinearSolvers_Module\n  * \\brief A preconditioner based on the digonal entries\n  *\n  * This class allows to approximately solve for A.x = b problems assuming A is a diagonal matrix.\n  * In other words, this preconditioner neglects all off diagonal entries and, in Eigen's language, solves for:\n    \\code\n    A.diagonal().asDiagonal() . x = b\n    \\endcode\n  *\n  * \\tparam _Scalar the type of the scalar.\n  *\n  * \\implsparsesolverconcept\n  *\n  * This preconditioner is suitable for both selfadjoint and general problems.\n  * The diagonal entries are pre-inverted and stored into a dense vector.\n  *\n  * \\note A variant that has yet to be implemented would attempt to preserve the norm of each column.\n  *\n  * \\sa class LeastSquareDiagonalPreconditioner, class ConjugateGradient\n  */\ntemplate <typename _Scalar>\nclass DiagonalPreconditioner\n{\n    typedef _Scalar Scalar;\n    typedef Matrix<Scalar,Dynamic,1> Vector;\n  public:\n    typedef typename Vector::StorageIndex StorageIndex;\n    enum {\n      ColsAtCompileTime = Dynamic,\n      MaxColsAtCompileTime = Dynamic\n    };\n\n    DiagonalPreconditioner() : m_isInitialized(false) {}\n\n    template<typename MatType>\n    explicit DiagonalPreconditioner(const MatType& mat) : m_invdiag(mat.cols())\n    {\n      compute(mat);\n    }\n\n    Index rows() const { return m_invdiag.size(); }\n    Index cols() const { return m_invdiag.size(); }\n    \n    template<typename MatType>\n    DiagonalPreconditioner& analyzePattern(const MatType& )\n    {\n      return *this;\n    }\n    \n    template<typename MatType>\n    DiagonalPreconditioner& factorize(const MatType& mat)\n    {\n      m_invdiag.resize(mat.cols());\n      for(int j=0; j<mat.outerSize(); ++j)\n      {\n        typename MatType::InnerIterator it(mat,j);\n        while(it && it.index()!=j) ++it;\n        if(it && it.index()==j && it.value()!=Scalar(0))\n          m_invdiag(j) = Scalar(1)/it.value();\n        else\n          m_invdiag(j) = Scalar(1);\n      }\n      m_isInitialized = true;\n      return *this;\n    }\n    \n    template<typename MatType>\n    DiagonalPreconditioner& compute(const MatType& mat)\n    {\n      return factorize(mat);\n    }\n\n    /** \\internal */\n    template<typename Rhs, typename Dest>\n    void _solve_impl(const Rhs& b, Dest& x) const\n    {\n      x = m_invdiag.array() * b.array() ;\n    }\n\n    template<typename Rhs> inline const Solve<DiagonalPreconditioner, Rhs>\n    solve(const MatrixBase<Rhs>& b) const\n    {\n      eigen_assert(m_isInitialized && \"DiagonalPreconditioner is not initialized.\");\n      eigen_assert(m_invdiag.size()==b.rows()\n                && \"DiagonalPreconditioner::solve(): invalid number of rows of the right hand side matrix b\");\n      return Solve<DiagonalPreconditioner, Rhs>(*this, b.derived());\n    }\n    \n    ComputationInfo info() { return Success; }\n\n  protected:\n    Vector m_invdiag;\n    bool m_isInitialized;\n};\n\n/** \\ingroup IterativeLinearSolvers_Module\n  * \\brief Jacobi preconditioner for LeastSquaresConjugateGradient\n  *\n  * This class allows to approximately solve for A' A x  = A' b problems assuming A' A is a diagonal matrix.\n  * In other words, this preconditioner neglects all off diagonal entries and, in Eigen's language, solves for:\n    \\code\n    (A.adjoint() * A).diagonal().asDiagonal() * x = b\n    \\endcode\n  *\n  * \\tparam _Scalar the type of the scalar.\n  *\n  * \\implsparsesolverconcept\n  *\n  * The diagonal entries are pre-inverted and stored into a dense vector.\n  * \n  * \\sa class LeastSquaresConjugateGradient, class DiagonalPreconditioner\n  */\ntemplate <typename _Scalar>\nclass LeastSquareDiagonalPreconditioner : public DiagonalPreconditioner<_Scalar>\n{\n    typedef _Scalar Scalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    typedef DiagonalPreconditioner<_Scalar> Base;\n    using Base::m_invdiag;\n  public:\n\n    LeastSquareDiagonalPreconditioner() : Base() {}\n\n    template<typename MatType>\n    explicit LeastSquareDiagonalPreconditioner(const MatType& mat) : Base()\n    {\n      compute(mat);\n    }\n\n    template<typename MatType>\n    LeastSquareDiagonalPreconditioner& analyzePattern(const MatType& )\n    {\n      return *this;\n    }\n    \n    template<typename MatType>\n    LeastSquareDiagonalPreconditioner& factorize(const MatType& mat)\n    {\n      // Compute the inverse squared-norm of each column of mat\n      m_invdiag.resize(mat.cols());\n      if(MatType::IsRowMajor)\n      {\n        m_invdiag.setZero();\n        for(Index j=0; j<mat.outerSize(); ++j)\n        {\n          for(typename MatType::InnerIterator it(mat,j); it; ++it)\n            m_invdiag(it.index()) += numext::abs2(it.value());\n        }\n        for(Index j=0; j<mat.cols(); ++j)\n          if(numext::real(m_invdiag(j))>RealScalar(0))\n            m_invdiag(j) = RealScalar(1)/numext::real(m_invdiag(j));\n      }\n      else\n      {\n        for(Index j=0; j<mat.outerSize(); ++j)\n        {\n          RealScalar sum = mat.innerVector(j).squaredNorm();\n          if(sum>RealScalar(0))\n            m_invdiag(j) = RealScalar(1)/sum;\n          else\n            m_invdiag(j) = RealScalar(1);\n        }\n      }\n      Base::m_isInitialized = true;\n      return *this;\n    }\n    \n    template<typename MatType>\n    LeastSquareDiagonalPreconditioner& compute(const MatType& mat)\n    {\n      return factorize(mat);\n    }\n    \n    ComputationInfo info() { return Success; }\n\n  protected:\n};\n\n/** \\ingroup IterativeLinearSolvers_Module\n  * \\brief A naive preconditioner which approximates any matrix as the identity matrix\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa class DiagonalPreconditioner\n  */\nclass IdentityPreconditioner\n{\n  public:\n\n    IdentityPreconditioner() {}\n\n    template<typename MatrixType>\n    explicit IdentityPreconditioner(const MatrixType& ) {}\n    \n    template<typename MatrixType>\n    IdentityPreconditioner& analyzePattern(const MatrixType& ) { return *this; }\n    \n    template<typename MatrixType>\n    IdentityPreconditioner& factorize(const MatrixType& ) { return *this; }\n\n    template<typename MatrixType>\n    IdentityPreconditioner& compute(const MatrixType& ) { return *this; }\n    \n    template<typename Rhs>\n    inline const Rhs& solve(const Rhs& b) const { return b; }\n    \n    ComputationInfo info() { return Success; }\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_BASIC_PRECONDITIONERS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2011-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_BICGSTAB_H\n#define EIGEN_BICGSTAB_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/** \\internal Low-level bi conjugate gradient stabilized algorithm\n  * \\param mat The matrix A\n  * \\param rhs The right hand side vector b\n  * \\param x On input and initial solution, on output the computed solution.\n  * \\param precond A preconditioner being able to efficiently solve for an\n  *                approximation of Ax=b (regardless of b)\n  * \\param iters On input the max number of iteration, on output the number of performed iterations.\n  * \\param tol_error On input the tolerance error, on output an estimation of the relative error.\n  * \\return false in the case of numerical issue, for example a break down of BiCGSTAB. \n  */\ntemplate<typename MatrixType, typename Rhs, typename Dest, typename Preconditioner>\nbool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,\n              const Preconditioner& precond, Index& iters,\n              typename Dest::RealScalar& tol_error)\n{\n  using std::sqrt;\n  using std::abs;\n  typedef typename Dest::RealScalar RealScalar;\n  typedef typename Dest::Scalar Scalar;\n  typedef Matrix<Scalar,Dynamic,1> VectorType;\n  RealScalar tol = tol_error;\n  Index maxIters = iters;\n\n  Index n = mat.cols();\n  VectorType r  = rhs - mat * x;\n  VectorType r0 = r;\n  \n  RealScalar r0_sqnorm = r0.squaredNorm();\n  RealScalar rhs_sqnorm = rhs.squaredNorm();\n  if(rhs_sqnorm == 0)\n  {\n    x.setZero();\n    return true;\n  }\n  Scalar rho    = 1;\n  Scalar alpha  = 1;\n  Scalar w      = 1;\n  \n  VectorType v = VectorType::Zero(n), p = VectorType::Zero(n);\n  VectorType y(n),  z(n);\n  VectorType kt(n), ks(n);\n\n  VectorType s(n), t(n);\n\n  RealScalar tol2 = tol*tol*rhs_sqnorm;\n  RealScalar eps2 = NumTraits<Scalar>::epsilon()*NumTraits<Scalar>::epsilon();\n  Index i = 0;\n  Index restarts = 0;\n\n  while ( r.squaredNorm() > tol2 && i<maxIters )\n  {\n    Scalar rho_old = rho;\n\n    rho = r0.dot(r);\n    if (abs(rho) < eps2*r0_sqnorm)\n    {\n      // The new residual vector became too orthogonal to the arbitrarily chosen direction r0\n      // Let's restart with a new r0:\n      r  = rhs - mat * x;\n      r0 = r;\n      rho = r0_sqnorm = r.squaredNorm();\n      if(restarts++ == 0)\n        i = 0;\n    }\n    Scalar beta = (rho/rho_old) * (alpha / w);\n    p = r + beta * (p - w * v);\n    \n    y = precond.solve(p);\n    \n    v.noalias() = mat * y;\n\n    alpha = rho / r0.dot(v);\n    s = r - alpha * v;\n\n    z = precond.solve(s);\n    t.noalias() = mat * z;\n\n    RealScalar tmp = t.squaredNorm();\n    if(tmp>RealScalar(0))\n      w = t.dot(s) / tmp;\n    else\n      w = Scalar(0);\n    x += alpha * y + w * z;\n    r = s - w * t;\n    ++i;\n  }\n  tol_error = sqrt(r.squaredNorm()/rhs_sqnorm);\n  iters = i;\n  return true; \n}\n\n}\n\ntemplate< typename _MatrixType,\n          typename _Preconditioner = DiagonalPreconditioner<typename _MatrixType::Scalar> >\nclass BiCGSTAB;\n\nnamespace internal {\n\ntemplate< typename _MatrixType, typename _Preconditioner>\nstruct traits<BiCGSTAB<_MatrixType,_Preconditioner> >\n{\n  typedef _MatrixType MatrixType;\n  typedef _Preconditioner Preconditioner;\n};\n\n}\n\n/** \\ingroup IterativeLinearSolvers_Module\n  * \\brief A bi conjugate gradient stabilized solver for sparse square problems\n  *\n  * This class allows to solve for A.x = b sparse linear problems using a bi conjugate gradient\n  * stabilized algorithm. The vectors x and b can be either dense or sparse.\n  *\n  * \\tparam _MatrixType the type of the sparse matrix A, can be a dense or a sparse matrix.\n  * \\tparam _Preconditioner the type of the preconditioner. Default is DiagonalPreconditioner\n  *\n  * \\implsparsesolverconcept\n  *\n  * The maximal number of iterations and tolerance value can be controlled via the setMaxIterations()\n  * and setTolerance() methods. The defaults are the size of the problem for the maximal number of iterations\n  * and NumTraits<Scalar>::epsilon() for the tolerance.\n  * \n  * The tolerance corresponds to the relative residual error: |Ax-b|/|b|\n  * \n  * \\b Performance: when using sparse matrices, best performance is achied for a row-major sparse matrix format.\n  * Moreover, in this case multi-threading can be exploited if the user code is compiled with OpenMP enabled.\n  * See \\ref TopicMultiThreading for details.\n  * \n  * This class can be used as the direct solver classes. Here is a typical usage example:\n  * \\include BiCGSTAB_simple.cpp\n  * \n  * By default the iterations start with x=0 as an initial guess of the solution.\n  * One can control the start using the solveWithGuess() method.\n  * \n  * BiCGSTAB can also be used in a matrix-free context, see the following \\link MatrixfreeSolverExample example \\endlink.\n  *\n  * \\sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner\n  */\ntemplate< typename _MatrixType, typename _Preconditioner>\nclass BiCGSTAB : public IterativeSolverBase<BiCGSTAB<_MatrixType,_Preconditioner> >\n{\n  typedef IterativeSolverBase<BiCGSTAB> Base;\n  using Base::matrix;\n  using Base::m_error;\n  using Base::m_iterations;\n  using Base::m_info;\n  using Base::m_isInitialized;\npublic:\n  typedef _MatrixType MatrixType;\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename MatrixType::RealScalar RealScalar;\n  typedef _Preconditioner Preconditioner;\n\npublic:\n\n  /** Default constructor. */\n  BiCGSTAB() : Base() {}\n\n  /** Initialize the solver with matrix \\a A for further \\c Ax=b solving.\n    * \n    * This constructor is a shortcut for the default constructor followed\n    * by a call to compute().\n    * \n    * \\warning this class stores a reference to the matrix A as well as some\n    * precomputed values that depend on it. Therefore, if \\a A is changed\n    * this class becomes invalid. Call compute() to update it with the new\n    * matrix A, or modify a copy of A.\n    */\n  template<typename MatrixDerived>\n  explicit BiCGSTAB(const EigenBase<MatrixDerived>& A) : Base(A.derived()) {}\n\n  ~BiCGSTAB() {}\n\n  /** \\internal */\n  template<typename Rhs,typename Dest>\n  void _solve_with_guess_impl(const Rhs& b, Dest& x) const\n  {    \n    bool failed = false;\n    for(Index j=0; j<b.cols(); ++j)\n    {\n      m_iterations = Base::maxIterations();\n      m_error = Base::m_tolerance;\n      \n      typename Dest::ColXpr xj(x,j);\n      if(!internal::bicgstab(matrix(), b.col(j), xj, Base::m_preconditioner, m_iterations, m_error))\n        failed = true;\n    }\n    m_info = failed ? NumericalIssue\n           : m_error <= Base::m_tolerance ? Success\n           : NoConvergence;\n    m_isInitialized = true;\n  }\n\n  /** \\internal */\n  using Base::_solve_impl;\n  template<typename Rhs,typename Dest>\n  void _solve_impl(const MatrixBase<Rhs>& b, Dest& x) const\n  {\n    x.resize(this->rows(),b.cols());\n    x.setZero();\n    _solve_with_guess_impl(b,x);\n  }\n\nprotected:\n\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_BICGSTAB_H\n"
  },
  {
    "path": "include/externals/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2011-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CONJUGATE_GRADIENT_H\n#define EIGEN_CONJUGATE_GRADIENT_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/** \\internal Low-level conjugate gradient algorithm\n  * \\param mat The matrix A\n  * \\param rhs The right hand side vector b\n  * \\param x On input and initial solution, on output the computed solution.\n  * \\param precond A preconditioner being able to efficiently solve for an\n  *                approximation of Ax=b (regardless of b)\n  * \\param iters On input the max number of iteration, on output the number of performed iterations.\n  * \\param tol_error On input the tolerance error, on output an estimation of the relative error.\n  */\ntemplate<typename MatrixType, typename Rhs, typename Dest, typename Preconditioner>\nEIGEN_DONT_INLINE\nvoid conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x,\n                        const Preconditioner& precond, Index& iters,\n                        typename Dest::RealScalar& tol_error)\n{\n  using std::sqrt;\n  using std::abs;\n  typedef typename Dest::RealScalar RealScalar;\n  typedef typename Dest::Scalar Scalar;\n  typedef Matrix<Scalar,Dynamic,1> VectorType;\n  \n  RealScalar tol = tol_error;\n  Index maxIters = iters;\n  \n  Index n = mat.cols();\n\n  VectorType residual = rhs - mat * x; //initial residual\n\n  RealScalar rhsNorm2 = rhs.squaredNorm();\n  if(rhsNorm2 == 0) \n  {\n    x.setZero();\n    iters = 0;\n    tol_error = 0;\n    return;\n  }\n  RealScalar threshold = tol*tol*rhsNorm2;\n  RealScalar residualNorm2 = residual.squaredNorm();\n  if (residualNorm2 < threshold)\n  {\n    iters = 0;\n    tol_error = sqrt(residualNorm2 / rhsNorm2);\n    return;\n  }\n  \n  VectorType p(n);\n  p = precond.solve(residual);      // initial search direction\n\n  VectorType z(n), tmp(n);\n  RealScalar absNew = numext::real(residual.dot(p));  // the square of the absolute value of r scaled by invM\n  Index i = 0;\n  while(i < maxIters)\n  {\n    tmp.noalias() = mat * p;                    // the bottleneck of the algorithm\n\n    Scalar alpha = absNew / p.dot(tmp);         // the amount we travel on dir\n    x += alpha * p;                             // update solution\n    residual -= alpha * tmp;                    // update residual\n    \n    residualNorm2 = residual.squaredNorm();\n    if(residualNorm2 < threshold)\n      break;\n    \n    z = precond.solve(residual);                // approximately solve for \"A z = residual\"\n\n    RealScalar absOld = absNew;\n    absNew = numext::real(residual.dot(z));     // update the absolute value of r\n    RealScalar beta = absNew / absOld;          // calculate the Gram-Schmidt value used to create the new search direction\n    p = z + beta * p;                           // update search direction\n    i++;\n  }\n  tol_error = sqrt(residualNorm2 / rhsNorm2);\n  iters = i;\n}\n\n}\n\ntemplate< typename _MatrixType, int _UpLo=Lower,\n          typename _Preconditioner = DiagonalPreconditioner<typename _MatrixType::Scalar> >\nclass ConjugateGradient;\n\nnamespace internal {\n\ntemplate< typename _MatrixType, int _UpLo, typename _Preconditioner>\nstruct traits<ConjugateGradient<_MatrixType,_UpLo,_Preconditioner> >\n{\n  typedef _MatrixType MatrixType;\n  typedef _Preconditioner Preconditioner;\n};\n\n}\n\n/** \\ingroup IterativeLinearSolvers_Module\n  * \\brief A conjugate gradient solver for sparse (or dense) self-adjoint problems\n  *\n  * This class allows to solve for A.x = b linear problems using an iterative conjugate gradient algorithm.\n  * The matrix A must be selfadjoint. The matrix A and the vectors x and b can be either dense or sparse.\n  *\n  * \\tparam _MatrixType the type of the matrix A, can be a dense or a sparse matrix.\n  * \\tparam _UpLo the triangular part that will be used for the computations. It can be Lower,\n  *               \\c Upper, or \\c Lower|Upper in which the full matrix entries will be considered.\n  *               Default is \\c Lower, best performance is \\c Lower|Upper.\n  * \\tparam _Preconditioner the type of the preconditioner. Default is DiagonalPreconditioner\n  *\n  * \\implsparsesolverconcept\n  *\n  * The maximal number of iterations and tolerance value can be controlled via the setMaxIterations()\n  * and setTolerance() methods. The defaults are the size of the problem for the maximal number of iterations\n  * and NumTraits<Scalar>::epsilon() for the tolerance.\n  * \n  * The tolerance corresponds to the relative residual error: |Ax-b|/|b|\n  * \n  * \\b Performance: Even though the default value of \\c _UpLo is \\c Lower, significantly higher performance is\n  * achieved when using a complete matrix and \\b Lower|Upper as the \\a _UpLo template parameter. Moreover, in this\n  * case multi-threading can be exploited if the user code is compiled with OpenMP enabled.\n  * See \\ref TopicMultiThreading for details.\n  * \n  * This class can be used as the direct solver classes. Here is a typical usage example:\n    \\code\n    int n = 10000;\n    VectorXd x(n), b(n);\n    SparseMatrix<double> A(n,n);\n    // fill A and b\n    ConjugateGradient<SparseMatrix<double>, Lower|Upper> cg;\n    cg.compute(A);\n    x = cg.solve(b);\n    std::cout << \"#iterations:     \" << cg.iterations() << std::endl;\n    std::cout << \"estimated error: \" << cg.error()      << std::endl;\n    // update b, and solve again\n    x = cg.solve(b);\n    \\endcode\n  * \n  * By default the iterations start with x=0 as an initial guess of the solution.\n  * One can control the start using the solveWithGuess() method.\n  * \n  * ConjugateGradient can also be used in a matrix-free context, see the following \\link MatrixfreeSolverExample example \\endlink.\n  *\n  * \\sa class LeastSquaresConjugateGradient, class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner\n  */\ntemplate< typename _MatrixType, int _UpLo, typename _Preconditioner>\nclass ConjugateGradient : public IterativeSolverBase<ConjugateGradient<_MatrixType,_UpLo,_Preconditioner> >\n{\n  typedef IterativeSolverBase<ConjugateGradient> Base;\n  using Base::matrix;\n  using Base::m_error;\n  using Base::m_iterations;\n  using Base::m_info;\n  using Base::m_isInitialized;\npublic:\n  typedef _MatrixType MatrixType;\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename MatrixType::RealScalar RealScalar;\n  typedef _Preconditioner Preconditioner;\n\n  enum {\n    UpLo = _UpLo\n  };\n\npublic:\n\n  /** Default constructor. */\n  ConjugateGradient() : Base() {}\n\n  /** Initialize the solver with matrix \\a A for further \\c Ax=b solving.\n    * \n    * This constructor is a shortcut for the default constructor followed\n    * by a call to compute().\n    * \n    * \\warning this class stores a reference to the matrix A as well as some\n    * precomputed values that depend on it. Therefore, if \\a A is changed\n    * this class becomes invalid. Call compute() to update it with the new\n    * matrix A, or modify a copy of A.\n    */\n  template<typename MatrixDerived>\n  explicit ConjugateGradient(const EigenBase<MatrixDerived>& A) : Base(A.derived()) {}\n\n  ~ConjugateGradient() {}\n\n  /** \\internal */\n  template<typename Rhs,typename Dest>\n  void _solve_with_guess_impl(const Rhs& b, Dest& x) const\n  {\n    typedef typename Base::MatrixWrapper MatrixWrapper;\n    typedef typename Base::ActualMatrixType ActualMatrixType;\n    enum {\n      TransposeInput  =   (!MatrixWrapper::MatrixFree)\n                      &&  (UpLo==(Lower|Upper))\n                      &&  (!MatrixType::IsRowMajor)\n                      &&  (!NumTraits<Scalar>::IsComplex)\n    };\n    typedef typename internal::conditional<TransposeInput,Transpose<const ActualMatrixType>, ActualMatrixType const&>::type RowMajorWrapper;\n    EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(MatrixWrapper::MatrixFree,UpLo==(Lower|Upper)),MATRIX_FREE_CONJUGATE_GRADIENT_IS_COMPATIBLE_WITH_UPPER_UNION_LOWER_MODE_ONLY);\n    typedef typename internal::conditional<UpLo==(Lower|Upper),\n                                           RowMajorWrapper,\n                                           typename MatrixWrapper::template ConstSelfAdjointViewReturnType<UpLo>::Type\n                                          >::type SelfAdjointWrapper;\n    m_iterations = Base::maxIterations();\n    m_error = Base::m_tolerance;\n\n    for(Index j=0; j<b.cols(); ++j)\n    {\n      m_iterations = Base::maxIterations();\n      m_error = Base::m_tolerance;\n\n      typename Dest::ColXpr xj(x,j);\n      RowMajorWrapper row_mat(matrix());\n      internal::conjugate_gradient(SelfAdjointWrapper(row_mat), b.col(j), xj, Base::m_preconditioner, m_iterations, m_error);\n    }\n\n    m_isInitialized = true;\n    m_info = m_error <= Base::m_tolerance ? Success : NoConvergence;\n  }\n  \n  /** \\internal */\n  using Base::_solve_impl;\n  template<typename Rhs,typename Dest>\n  void _solve_impl(const MatrixBase<Rhs>& b, Dest& x) const\n  {\n    x.setZero();\n    _solve_with_guess_impl(b.derived(),x);\n  }\n\nprotected:\n\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_CONJUGATE_GRADIENT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n// Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_INCOMPLETE_CHOlESKY_H\n#define EIGEN_INCOMPLETE_CHOlESKY_H\n\n#include <vector>\n#include <list>\n\nnamespace Eigen {  \n/** \n  * \\brief Modified Incomplete Cholesky with dual threshold\n  *\n  * References : C-J. Lin and J. J. Moré, Incomplete Cholesky Factorizations with\n  *              Limited memory, SIAM J. Sci. Comput.  21(1), pp. 24-45, 1999\n  *\n  * \\tparam Scalar the scalar type of the input matrices\n  * \\tparam _UpLo The triangular part that will be used for the computations. It can be Lower\n    *               or Upper. Default is Lower.\n  * \\tparam _OrderingType The ordering method to use, either AMDOrdering<> or NaturalOrdering<>. Default is AMDOrdering<int>,\n  *                       unless EIGEN_MPL2_ONLY is defined, in which case the default is NaturalOrdering<int>.\n  *\n  * \\implsparsesolverconcept\n  *\n  * It performs the following incomplete factorization: \\f$ S P A P' S \\approx L L' \\f$\n  * where L is a lower triangular factor, S is a diagonal scaling matrix, and P is a\n  * fill-in reducing permutation as computed by the ordering method.\n  *\n  * \\b Shifting \\b strategy: Let \\f$ B = S P A P' S \\f$  be the scaled matrix on which the factorization is carried out,\n  * and \\f$ \\beta \\f$ be the minimum value of the diagonal. If \\f$ \\beta > 0 \\f$ then, the factorization is directly performed\n  * on the matrix B. Otherwise, the factorization is performed on the shifted matrix \\f$ B + (\\sigma+|\\beta| I \\f$ where\n  * \\f$ \\sigma \\f$ is the initial shift value as returned and set by setInitialShift() method. The default value is \\f$ \\sigma = 10^{-3} \\f$.\n  * If the factorization fails, then the shift in doubled until it succeed or a maximum of ten attempts. If it still fails, as returned by\n  * the info() method, then you can either increase the initial shift, or better use another preconditioning technique.\n  *\n  */\ntemplate <typename Scalar, int _UpLo = Lower, typename _OrderingType =\n#ifndef EIGEN_MPL2_ONLY\nAMDOrdering<int>\n#else\nNaturalOrdering<int>\n#endif\n>\nclass IncompleteCholesky : public SparseSolverBase<IncompleteCholesky<Scalar,_UpLo,_OrderingType> >\n{\n  protected:\n    typedef SparseSolverBase<IncompleteCholesky<Scalar,_UpLo,_OrderingType> > Base;\n    using Base::m_isInitialized;\n  public:\n    typedef typename NumTraits<Scalar>::Real RealScalar; \n    typedef _OrderingType OrderingType;\n    typedef typename OrderingType::PermutationType PermutationType;\n    typedef typename PermutationType::StorageIndex StorageIndex; \n    typedef SparseMatrix<Scalar,ColMajor,StorageIndex> FactorType;\n    typedef Matrix<Scalar,Dynamic,1> VectorSx;\n    typedef Matrix<RealScalar,Dynamic,1> VectorRx;\n    typedef Matrix<StorageIndex,Dynamic, 1> VectorIx;\n    typedef std::vector<std::list<StorageIndex> > VectorList; \n    enum { UpLo = _UpLo };\n    enum {\n      ColsAtCompileTime = Dynamic,\n      MaxColsAtCompileTime = Dynamic\n    };\n  public:\n\n    /** Default constructor leaving the object in a partly non-initialized stage.\n      *\n      * You must call compute() or the pair analyzePattern()/factorize() to make it valid.\n      *\n      * \\sa IncompleteCholesky(const MatrixType&)\n      */\n    IncompleteCholesky() : m_initialShift(1e-3),m_factorizationIsOk(false) {}\n    \n    /** Constructor computing the incomplete factorization for the given matrix \\a matrix.\n      */\n    template<typename MatrixType>\n    IncompleteCholesky(const MatrixType& matrix) : m_initialShift(1e-3),m_factorizationIsOk(false)\n    {\n      compute(matrix);\n    }\n    \n    /** \\returns number of rows of the factored matrix */\n    Index rows() const { return m_L.rows(); }\n    \n    /** \\returns number of columns of the factored matrix */\n    Index cols() const { return m_L.cols(); }\n    \n\n    /** \\brief Reports whether previous computation was successful.\n      *\n      * It triggers an assertion if \\c *this has not been initialized through the respective constructor,\n      * or a call to compute() or analyzePattern().\n      *\n      * \\returns \\c Success if computation was successful,\n      *          \\c NumericalIssue if the matrix appears to be negative.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"IncompleteCholesky is not initialized.\");\n      return m_info;\n    }\n    \n    /** \\brief Set the initial shift parameter \\f$ \\sigma \\f$.\n      */\n    void setInitialShift(RealScalar shift) { m_initialShift = shift; }\n    \n    /** \\brief Computes the fill reducing permutation vector using the sparsity pattern of \\a mat\n      */\n    template<typename MatrixType>\n    void analyzePattern(const MatrixType& mat)\n    {\n      OrderingType ord; \n      PermutationType pinv;\n      ord(mat.template selfadjointView<UpLo>(), pinv); \n      if(pinv.size()>0) m_perm = pinv.inverse();\n      else              m_perm.resize(0);\n      m_L.resize(mat.rows(), mat.cols());\n      m_analysisIsOk = true;\n      m_isInitialized = true;\n      m_info = Success;\n    }\n    \n    /** \\brief Performs the numerical factorization of the input matrix \\a mat\n      *\n      * The method analyzePattern() or compute() must have been called beforehand\n      * with a matrix having the same pattern.\n      *\n      * \\sa compute(), analyzePattern()\n      */\n    template<typename MatrixType>\n    void factorize(const MatrixType& mat);\n    \n    /** Computes or re-computes the incomplete Cholesky factorization of the input matrix \\a mat\n      *\n      * It is a shortcut for a sequential call to the analyzePattern() and factorize() methods.\n      *\n      * \\sa analyzePattern(), factorize()\n      */\n    template<typename MatrixType>\n    void compute(const MatrixType& mat)\n    {\n      analyzePattern(mat);\n      factorize(mat);\n    }\n    \n    // internal\n    template<typename Rhs, typename Dest>\n    void _solve_impl(const Rhs& b, Dest& x) const\n    {\n      eigen_assert(m_factorizationIsOk && \"factorize() should be called first\");\n      if (m_perm.rows() == b.rows())  x = m_perm * b;\n      else                            x = b;\n      x = m_scale.asDiagonal() * x;\n      x = m_L.template triangularView<Lower>().solve(x);\n      x = m_L.adjoint().template triangularView<Upper>().solve(x);\n      x = m_scale.asDiagonal() * x;\n      if (m_perm.rows() == b.rows())\n        x = m_perm.inverse() * x;\n    }\n\n    /** \\returns the sparse lower triangular factor L */\n    const FactorType& matrixL() const { eigen_assert(\"m_factorizationIsOk\"); return m_L; }\n\n    /** \\returns a vector representing the scaling factor S */\n    const VectorRx& scalingS() const { eigen_assert(\"m_factorizationIsOk\"); return m_scale; }\n\n    /** \\returns the fill-in reducing permutation P (can be empty for a natural ordering) */\n    const PermutationType& permutationP() const { eigen_assert(\"m_analysisIsOk\"); return m_perm; }\n\n  protected:\n    FactorType m_L;              // The lower part stored in CSC\n    VectorRx m_scale;            // The vector for scaling the matrix \n    RealScalar m_initialShift;   // The initial shift parameter\n    bool m_analysisIsOk; \n    bool m_factorizationIsOk; \n    ComputationInfo m_info;\n    PermutationType m_perm; \n\n  private:\n    inline void updateList(Ref<const VectorIx> colPtr, Ref<VectorIx> rowIdx, Ref<VectorSx> vals, const Index& col, const Index& jk, VectorIx& firstElt, VectorList& listCol); \n}; \n\n// Based on the following paper:\n//   C-J. Lin and J. J. Moré, Incomplete Cholesky Factorizations with\n//   Limited memory, SIAM J. Sci. Comput.  21(1), pp. 24-45, 1999\n//   http://ftp.mcs.anl.gov/pub/tech_reports/reports/P682.pdf\ntemplate<typename Scalar, int _UpLo, typename OrderingType>\ntemplate<typename _MatrixType>\nvoid IncompleteCholesky<Scalar,_UpLo, OrderingType>::factorize(const _MatrixType& mat)\n{\n  using std::sqrt;\n  eigen_assert(m_analysisIsOk && \"analyzePattern() should be called first\"); \n    \n  // Dropping strategy : Keep only the p largest elements per column, where p is the number of elements in the column of the original matrix. Other strategies will be added\n  \n  // Apply the fill-reducing permutation computed in analyzePattern()\n  if (m_perm.rows() == mat.rows() ) // To detect the null permutation\n  {\n    // The temporary is needed to make sure that the diagonal entry is properly sorted\n    FactorType tmp(mat.rows(), mat.cols());\n    tmp = mat.template selfadjointView<_UpLo>().twistedBy(m_perm);\n    m_L.template selfadjointView<Lower>() = tmp.template selfadjointView<Lower>();\n  }\n  else\n  {\n    m_L.template selfadjointView<Lower>() = mat.template selfadjointView<_UpLo>();\n  }\n  \n  Index n = m_L.cols(); \n  Index nnz = m_L.nonZeros();\n  Map<VectorSx> vals(m_L.valuePtr(), nnz);         //values\n  Map<VectorIx> rowIdx(m_L.innerIndexPtr(), nnz);  //Row indices\n  Map<VectorIx> colPtr( m_L.outerIndexPtr(), n+1); // Pointer to the beginning of each row\n  VectorIx firstElt(n-1); // for each j, points to the next entry in vals that will be used in the factorization\n  VectorList listCol(n);  // listCol(j) is a linked list of columns to update column j\n  VectorSx col_vals(n);   // Store a  nonzero values in each column\n  VectorIx col_irow(n);   // Row indices of nonzero elements in each column\n  VectorIx col_pattern(n);\n  col_pattern.fill(-1);\n  StorageIndex col_nnz;\n  \n  \n  // Computes the scaling factors \n  m_scale.resize(n);\n  m_scale.setZero();\n  for (Index j = 0; j < n; j++)\n    for (Index k = colPtr[j]; k < colPtr[j+1]; k++)\n    {\n      m_scale(j) += numext::abs2(vals(k));\n      if(rowIdx[k]!=j)\n        m_scale(rowIdx[k]) += numext::abs2(vals(k));\n    }\n  \n  m_scale = m_scale.cwiseSqrt().cwiseSqrt();\n\n  for (Index j = 0; j < n; ++j)\n    if(m_scale(j)>(std::numeric_limits<RealScalar>::min)())\n      m_scale(j) = RealScalar(1)/m_scale(j);\n    else\n      m_scale(j) = 1;\n\n  // TODO disable scaling if not needed, i.e., if it is roughly uniform? (this will make solve() faster)\n  \n  // Scale and compute the shift for the matrix \n  RealScalar mindiag = NumTraits<RealScalar>::highest();\n  for (Index j = 0; j < n; j++)\n  {\n    for (Index k = colPtr[j]; k < colPtr[j+1]; k++)\n      vals[k] *= (m_scale(j)*m_scale(rowIdx[k]));\n    eigen_internal_assert(rowIdx[colPtr[j]]==j && \"IncompleteCholesky: only the lower triangular part must be stored\");\n    mindiag = numext::mini(numext::real(vals[colPtr[j]]), mindiag);\n  }\n\n  FactorType L_save = m_L;\n  \n  RealScalar shift = 0;\n  if(mindiag <= RealScalar(0.))\n    shift = m_initialShift - mindiag;\n\n  m_info = NumericalIssue;\n\n  // Try to perform the incomplete factorization using the current shift\n  int iter = 0;\n  do\n  {\n    // Apply the shift to the diagonal elements of the matrix\n    for (Index j = 0; j < n; j++)\n      vals[colPtr[j]] += shift;\n\n    // jki version of the Cholesky factorization\n    Index j=0;\n    for (; j < n; ++j)\n    {\n      // Left-looking factorization of the j-th column\n      // First, load the j-th column into col_vals\n      Scalar diag = vals[colPtr[j]];  // It is assumed that only the lower part is stored\n      col_nnz = 0;\n      for (Index i = colPtr[j] + 1; i < colPtr[j+1]; i++)\n      {\n        StorageIndex l = rowIdx[i];\n        col_vals(col_nnz) = vals[i];\n        col_irow(col_nnz) = l;\n        col_pattern(l) = col_nnz;\n        col_nnz++;\n      }\n      {\n        typename std::list<StorageIndex>::iterator k;\n        // Browse all previous columns that will update column j\n        for(k = listCol[j].begin(); k != listCol[j].end(); k++)\n        {\n          Index jk = firstElt(*k); // First element to use in the column\n          eigen_internal_assert(rowIdx[jk]==j);\n          Scalar v_j_jk = numext::conj(vals[jk]);\n\n          jk += 1;\n          for (Index i = jk; i < colPtr[*k+1]; i++)\n          {\n            StorageIndex l = rowIdx[i];\n            if(col_pattern[l]<0)\n            {\n              col_vals(col_nnz) = vals[i] * v_j_jk;\n              col_irow[col_nnz] = l;\n              col_pattern(l) = col_nnz;\n              col_nnz++;\n            }\n            else\n              col_vals(col_pattern[l]) -= vals[i] * v_j_jk;\n          }\n          updateList(colPtr,rowIdx,vals, *k, jk, firstElt, listCol);\n        }\n      }\n\n      // Scale the current column\n      if(numext::real(diag) <= 0)\n      {\n        if(++iter>=10)\n          return;\n\n        // increase shift\n        shift = numext::maxi(m_initialShift,RealScalar(2)*shift);\n        // restore m_L, col_pattern, and listCol\n        vals = Map<const VectorSx>(L_save.valuePtr(), nnz);\n        rowIdx = Map<const VectorIx>(L_save.innerIndexPtr(), nnz);\n        colPtr = Map<const VectorIx>(L_save.outerIndexPtr(), n+1);\n        col_pattern.fill(-1);\n        for(Index i=0; i<n; ++i)\n          listCol[i].clear();\n\n        break;\n      }\n\n      RealScalar rdiag = sqrt(numext::real(diag));\n      vals[colPtr[j]] = rdiag;\n      for (Index k = 0; k<col_nnz; ++k)\n      {\n        Index i = col_irow[k];\n        //Scale\n        col_vals(k) /= rdiag;\n        //Update the remaining diagonals with col_vals\n        vals[colPtr[i]] -= numext::abs2(col_vals(k));\n      }\n      // Select the largest p elements\n      // p is the original number of elements in the column (without the diagonal)\n      Index p = colPtr[j+1] - colPtr[j] - 1 ;\n      Ref<VectorSx> cvals = col_vals.head(col_nnz);\n      Ref<VectorIx> cirow = col_irow.head(col_nnz);\n      internal::QuickSplit(cvals,cirow, p);\n      // Insert the largest p elements in the matrix\n      Index cpt = 0;\n      for (Index i = colPtr[j]+1; i < colPtr[j+1]; i++)\n      {\n        vals[i] = col_vals(cpt);\n        rowIdx[i] = col_irow(cpt);\n        // restore col_pattern:\n        col_pattern(col_irow(cpt)) = -1;\n        cpt++;\n      }\n      // Get the first smallest row index and put it after the diagonal element\n      Index jk = colPtr(j)+1;\n      updateList(colPtr,rowIdx,vals,j,jk,firstElt,listCol);\n    }\n\n    if(j==n)\n    {\n      m_factorizationIsOk = true;\n      m_info = Success;\n    }\n  } while(m_info!=Success);\n}\n\ntemplate<typename Scalar, int _UpLo, typename OrderingType>\ninline void IncompleteCholesky<Scalar,_UpLo, OrderingType>::updateList(Ref<const VectorIx> colPtr, Ref<VectorIx> rowIdx, Ref<VectorSx> vals, const Index& col, const Index& jk, VectorIx& firstElt, VectorList& listCol)\n{\n  if (jk < colPtr(col+1) )\n  {\n    Index p = colPtr(col+1) - jk;\n    Index minpos; \n    rowIdx.segment(jk,p).minCoeff(&minpos);\n    minpos += jk;\n    if (rowIdx(minpos) != rowIdx(jk))\n    {\n      //Swap\n      std::swap(rowIdx(jk),rowIdx(minpos));\n      std::swap(vals(jk),vals(minpos));\n    }\n    firstElt(col) = internal::convert_index<StorageIndex,Index>(jk);\n    listCol[rowIdx(jk)].push_back(internal::convert_index<StorageIndex,Index>(col));\n  }\n}\n\n} // end namespace Eigen \n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n// Copyright (C) 2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_INCOMPLETE_LUT_H\n#define EIGEN_INCOMPLETE_LUT_H\n\n\nnamespace Eigen { \n\nnamespace internal {\n    \n/** \\internal\n  * Compute a quick-sort split of a vector \n  * On output, the vector row is permuted such that its elements satisfy\n  * abs(row(i)) >= abs(row(ncut)) if i<ncut\n  * abs(row(i)) <= abs(row(ncut)) if i>ncut \n  * \\param row The vector of values\n  * \\param ind The array of index for the elements in @p row\n  * \\param ncut  The number of largest elements to keep\n  **/ \ntemplate <typename VectorV, typename VectorI>\nIndex QuickSplit(VectorV &row, VectorI &ind, Index ncut)\n{\n  typedef typename VectorV::RealScalar RealScalar;\n  using std::swap;\n  using std::abs;\n  Index mid;\n  Index n = row.size(); /* length of the vector */\n  Index first, last ;\n  \n  ncut--; /* to fit the zero-based indices */\n  first = 0; \n  last = n-1; \n  if (ncut < first || ncut > last ) return 0;\n  \n  do {\n    mid = first; \n    RealScalar abskey = abs(row(mid)); \n    for (Index j = first + 1; j <= last; j++) {\n      if ( abs(row(j)) > abskey) {\n        ++mid;\n        swap(row(mid), row(j));\n        swap(ind(mid), ind(j));\n      }\n    }\n    /* Interchange for the pivot element */\n    swap(row(mid), row(first));\n    swap(ind(mid), ind(first));\n    \n    if (mid > ncut) last = mid - 1;\n    else if (mid < ncut ) first = mid + 1; \n  } while (mid != ncut );\n  \n  return 0; /* mid is equal to ncut */ \n}\n\n}// end namespace internal\n\n/** \\ingroup IterativeLinearSolvers_Module\n  * \\class IncompleteLUT\n  * \\brief Incomplete LU factorization with dual-threshold strategy\n  *\n  * \\implsparsesolverconcept\n  *\n  * During the numerical factorization, two dropping rules are used :\n  *  1) any element whose magnitude is less than some tolerance is dropped.\n  *    This tolerance is obtained by multiplying the input tolerance @p droptol \n  *    by the average magnitude of all the original elements in the current row.\n  *  2) After the elimination of the row, only the @p fill largest elements in \n  *    the L part and the @p fill largest elements in the U part are kept \n  *    (in addition to the diagonal element ). Note that @p fill is computed from \n  *    the input parameter @p fillfactor which is used the ratio to control the fill_in \n  *    relatively to the initial number of nonzero elements.\n  * \n  * The two extreme cases are when @p droptol=0 (to keep all the @p fill*2 largest elements)\n  * and when @p fill=n/2 with @p droptol being different to zero. \n  * \n  * References : Yousef Saad, ILUT: A dual threshold incomplete LU factorization, \n  *              Numerical Linear Algebra with Applications, 1(4), pp 387-402, 1994.\n  * \n  * NOTE : The following implementation is derived from the ILUT implementation\n  * in the SPARSKIT package, Copyright (C) 2005, the Regents of the University of Minnesota \n  *  released under the terms of the GNU LGPL: \n  *    http://www-users.cs.umn.edu/~saad/software/SPARSKIT/README\n  * However, Yousef Saad gave us permission to relicense his ILUT code to MPL2.\n  * See the Eigen mailing list archive, thread: ILUT, date: July 8, 2012:\n  *   http://listengine.tuxfamily.org/lists.tuxfamily.org/eigen/2012/07/msg00064.html\n  * alternatively, on GMANE:\n  *   http://comments.gmane.org/gmane.comp.lib.eigen/3302\n  */\ntemplate <typename _Scalar, typename _StorageIndex = int>\nclass IncompleteLUT : public SparseSolverBase<IncompleteLUT<_Scalar, _StorageIndex> >\n{\n  protected:\n    typedef SparseSolverBase<IncompleteLUT> Base;\n    using Base::m_isInitialized;\n  public:\n    typedef _Scalar Scalar;\n    typedef _StorageIndex StorageIndex;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n    typedef Matrix<Scalar,Dynamic,1> Vector;\n    typedef Matrix<StorageIndex,Dynamic,1> VectorI;\n    typedef SparseMatrix<Scalar,RowMajor,StorageIndex> FactorType;\n\n    enum {\n      ColsAtCompileTime = Dynamic,\n      MaxColsAtCompileTime = Dynamic\n    };\n\n  public:\n    \n    IncompleteLUT()\n      : m_droptol(NumTraits<Scalar>::dummy_precision()), m_fillfactor(10),\n        m_analysisIsOk(false), m_factorizationIsOk(false)\n    {}\n    \n    template<typename MatrixType>\n    explicit IncompleteLUT(const MatrixType& mat, const RealScalar& droptol=NumTraits<Scalar>::dummy_precision(), int fillfactor = 10)\n      : m_droptol(droptol),m_fillfactor(fillfactor),\n        m_analysisIsOk(false),m_factorizationIsOk(false)\n    {\n      eigen_assert(fillfactor != 0);\n      compute(mat); \n    }\n    \n    Index rows() const { return m_lu.rows(); }\n    \n    Index cols() const { return m_lu.cols(); }\n\n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful,\n      *          \\c NumericalIssue if the matrix.appears to be negative.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"IncompleteLUT is not initialized.\");\n      return m_info;\n    }\n    \n    template<typename MatrixType>\n    void analyzePattern(const MatrixType& amat);\n    \n    template<typename MatrixType>\n    void factorize(const MatrixType& amat);\n    \n    /**\n      * Compute an incomplete LU factorization with dual threshold on the matrix mat\n      * No pivoting is done in this version\n      * \n      **/\n    template<typename MatrixType>\n    IncompleteLUT& compute(const MatrixType& amat)\n    {\n      analyzePattern(amat); \n      factorize(amat);\n      return *this;\n    }\n\n    void setDroptol(const RealScalar& droptol); \n    void setFillfactor(int fillfactor); \n    \n    template<typename Rhs, typename Dest>\n    void _solve_impl(const Rhs& b, Dest& x) const\n    {\n      x = m_Pinv * b;\n      x = m_lu.template triangularView<UnitLower>().solve(x);\n      x = m_lu.template triangularView<Upper>().solve(x);\n      x = m_P * x; \n    }\n\nprotected:\n\n    /** keeps off-diagonal entries; drops diagonal entries */\n    struct keep_diag {\n      inline bool operator() (const Index& row, const Index& col, const Scalar&) const\n      {\n        return row!=col;\n      }\n    };\n\nprotected:\n\n    FactorType m_lu;\n    RealScalar m_droptol;\n    int m_fillfactor;\n    bool m_analysisIsOk;\n    bool m_factorizationIsOk;\n    ComputationInfo m_info;\n    PermutationMatrix<Dynamic,Dynamic,StorageIndex> m_P;     // Fill-reducing permutation\n    PermutationMatrix<Dynamic,Dynamic,StorageIndex> m_Pinv;  // Inverse permutation\n};\n\n/**\n * Set control parameter droptol\n *  \\param droptol   Drop any element whose magnitude is less than this tolerance \n **/ \ntemplate<typename Scalar, typename StorageIndex>\nvoid IncompleteLUT<Scalar,StorageIndex>::setDroptol(const RealScalar& droptol)\n{\n  this->m_droptol = droptol;   \n}\n\n/**\n * Set control parameter fillfactor\n * \\param fillfactor  This is used to compute the  number @p fill_in of largest elements to keep on each row. \n **/ \ntemplate<typename Scalar, typename StorageIndex>\nvoid IncompleteLUT<Scalar,StorageIndex>::setFillfactor(int fillfactor)\n{\n  this->m_fillfactor = fillfactor;   \n}\n\ntemplate <typename Scalar, typename StorageIndex>\ntemplate<typename _MatrixType>\nvoid IncompleteLUT<Scalar,StorageIndex>::analyzePattern(const _MatrixType& amat)\n{\n  // Compute the Fill-reducing permutation\n  // Since ILUT does not perform any numerical pivoting,\n  // it is highly preferable to keep the diagonal through symmetric permutations.\n#ifndef EIGEN_MPL2_ONLY\n  // To this end, let's symmetrize the pattern and perform AMD on it.\n  SparseMatrix<Scalar,ColMajor, StorageIndex> mat1 = amat;\n  SparseMatrix<Scalar,ColMajor, StorageIndex> mat2 = amat.transpose();\n  // FIXME for a matrix with nearly symmetric pattern, mat2+mat1 is the appropriate choice.\n  //       on the other hand for a really non-symmetric pattern, mat2*mat1 should be prefered...\n  SparseMatrix<Scalar,ColMajor, StorageIndex> AtA = mat2 + mat1;\n  AMDOrdering<StorageIndex> ordering;\n  ordering(AtA,m_P);\n  m_Pinv  = m_P.inverse(); // cache the inverse permutation\n#else\n  // If AMD is not available, (MPL2-only), then let's use the slower COLAMD routine.\n  SparseMatrix<Scalar,ColMajor, StorageIndex> mat1 = amat;\n  COLAMDOrdering<StorageIndex> ordering;\n  ordering(mat1,m_Pinv);\n  m_P = m_Pinv.inverse();\n#endif\n\n  m_analysisIsOk = true;\n  m_factorizationIsOk = false;\n  m_isInitialized = true;\n}\n\ntemplate <typename Scalar, typename StorageIndex>\ntemplate<typename _MatrixType>\nvoid IncompleteLUT<Scalar,StorageIndex>::factorize(const _MatrixType& amat)\n{\n  using std::sqrt;\n  using std::swap;\n  using std::abs;\n  using internal::convert_index;\n\n  eigen_assert((amat.rows() == amat.cols()) && \"The factorization should be done on a square matrix\");\n  Index n = amat.cols();  // Size of the matrix\n  m_lu.resize(n,n);\n  // Declare Working vectors and variables\n  Vector u(n) ;     // real values of the row -- maximum size is n --\n  VectorI ju(n);   // column position of the values in u -- maximum size  is n\n  VectorI jr(n);   // Indicate the position of the nonzero elements in the vector u -- A zero location is indicated by -1\n\n  // Apply the fill-reducing permutation\n  eigen_assert(m_analysisIsOk && \"You must first call analyzePattern()\");\n  SparseMatrix<Scalar,RowMajor, StorageIndex> mat;\n  mat = amat.twistedBy(m_Pinv);\n\n  // Initialization\n  jr.fill(-1);\n  ju.fill(0);\n  u.fill(0);\n\n  // number of largest elements to keep in each row:\n  Index fill_in = (amat.nonZeros()*m_fillfactor)/n + 1;\n  if (fill_in > n) fill_in = n;\n\n  // number of largest nonzero elements to keep in the L and the U part of the current row:\n  Index nnzL = fill_in/2;\n  Index nnzU = nnzL;\n  m_lu.reserve(n * (nnzL + nnzU + 1));\n\n  // global loop over the rows of the sparse matrix\n  for (Index ii = 0; ii < n; ii++)\n  {\n    // 1 - copy the lower and the upper part of the row i of mat in the working vector u\n\n    Index sizeu = 1; // number of nonzero elements in the upper part of the current row\n    Index sizel = 0; // number of nonzero elements in the lower part of the current row\n    ju(ii)    = convert_index<StorageIndex>(ii);\n    u(ii)     = 0;\n    jr(ii)    = convert_index<StorageIndex>(ii);\n    RealScalar rownorm = 0;\n\n    typename FactorType::InnerIterator j_it(mat, ii); // Iterate through the current row ii\n    for (; j_it; ++j_it)\n    {\n      Index k = j_it.index();\n      if (k < ii)\n      {\n        // copy the lower part\n        ju(sizel) = convert_index<StorageIndex>(k);\n        u(sizel) = j_it.value();\n        jr(k) = convert_index<StorageIndex>(sizel);\n        ++sizel;\n      }\n      else if (k == ii)\n      {\n        u(ii) = j_it.value();\n      }\n      else\n      {\n        // copy the upper part\n        Index jpos = ii + sizeu;\n        ju(jpos) = convert_index<StorageIndex>(k);\n        u(jpos) = j_it.value();\n        jr(k) = convert_index<StorageIndex>(jpos);\n        ++sizeu;\n      }\n      rownorm += numext::abs2(j_it.value());\n    }\n\n    // 2 - detect possible zero row\n    if(rownorm==0)\n    {\n      m_info = NumericalIssue;\n      return;\n    }\n    // Take the 2-norm of the current row as a relative tolerance\n    rownorm = sqrt(rownorm);\n\n    // 3 - eliminate the previous nonzero rows\n    Index jj = 0;\n    Index len = 0;\n    while (jj < sizel)\n    {\n      // In order to eliminate in the correct order,\n      // we must select first the smallest column index among  ju(jj:sizel)\n      Index k;\n      Index minrow = ju.segment(jj,sizel-jj).minCoeff(&k); // k is relative to the segment\n      k += jj;\n      if (minrow != ju(jj))\n      {\n        // swap the two locations\n        Index j = ju(jj);\n        swap(ju(jj), ju(k));\n        jr(minrow) = convert_index<StorageIndex>(jj);\n        jr(j) = convert_index<StorageIndex>(k);\n        swap(u(jj), u(k));\n      }\n      // Reset this location\n      jr(minrow) = -1;\n\n      // Start elimination\n      typename FactorType::InnerIterator ki_it(m_lu, minrow);\n      while (ki_it && ki_it.index() < minrow) ++ki_it;\n      eigen_internal_assert(ki_it && ki_it.col()==minrow);\n      Scalar fact = u(jj) / ki_it.value();\n\n      // drop too small elements\n      if(abs(fact) <= m_droptol)\n      {\n        jj++;\n        continue;\n      }\n\n      // linear combination of the current row ii and the row minrow\n      ++ki_it;\n      for (; ki_it; ++ki_it)\n      {\n        Scalar prod = fact * ki_it.value();\n        Index j     = ki_it.index();\n        Index jpos  = jr(j);\n        if (jpos == -1) // fill-in element\n        {\n          Index newpos;\n          if (j >= ii) // dealing with the upper part\n          {\n            newpos = ii + sizeu;\n            sizeu++;\n            eigen_internal_assert(sizeu<=n);\n          }\n          else // dealing with the lower part\n          {\n            newpos = sizel;\n            sizel++;\n            eigen_internal_assert(sizel<=ii);\n          }\n          ju(newpos) = convert_index<StorageIndex>(j);\n          u(newpos) = -prod;\n          jr(j) = convert_index<StorageIndex>(newpos);\n        }\n        else\n          u(jpos) -= prod;\n      }\n      // store the pivot element\n      u(len)  = fact;\n      ju(len) = convert_index<StorageIndex>(minrow);\n      ++len;\n\n      jj++;\n    } // end of the elimination on the row ii\n\n    // reset the upper part of the pointer jr to zero\n    for(Index k = 0; k <sizeu; k++) jr(ju(ii+k)) = -1;\n\n    // 4 - partially sort and insert the elements in the m_lu matrix\n\n    // sort the L-part of the row\n    sizel = len;\n    len = (std::min)(sizel, nnzL);\n    typename Vector::SegmentReturnType ul(u.segment(0, sizel));\n    typename VectorI::SegmentReturnType jul(ju.segment(0, sizel));\n    internal::QuickSplit(ul, jul, len);\n\n    // store the largest m_fill elements of the L part\n    m_lu.startVec(ii);\n    for(Index k = 0; k < len; k++)\n      m_lu.insertBackByOuterInnerUnordered(ii,ju(k)) = u(k);\n\n    // store the diagonal element\n    // apply a shifting rule to avoid zero pivots (we are doing an incomplete factorization)\n    if (u(ii) == Scalar(0))\n      u(ii) = sqrt(m_droptol) * rownorm;\n    m_lu.insertBackByOuterInnerUnordered(ii, ii) = u(ii);\n\n    // sort the U-part of the row\n    // apply the dropping rule first\n    len = 0;\n    for(Index k = 1; k < sizeu; k++)\n    {\n      if(abs(u(ii+k)) > m_droptol * rownorm )\n      {\n        ++len;\n        u(ii + len)  = u(ii + k);\n        ju(ii + len) = ju(ii + k);\n      }\n    }\n    sizeu = len + 1; // +1 to take into account the diagonal element\n    len = (std::min)(sizeu, nnzU);\n    typename Vector::SegmentReturnType uu(u.segment(ii+1, sizeu-1));\n    typename VectorI::SegmentReturnType juu(ju.segment(ii+1, sizeu-1));\n    internal::QuickSplit(uu, juu, len);\n\n    // store the largest elements of the U part\n    for(Index k = ii + 1; k < ii + len; k++)\n      m_lu.insertBackByOuterInnerUnordered(ii,ju(k)) = u(k);\n  }\n  m_lu.finalize();\n  m_lu.makeCompressed();\n\n  m_factorizationIsOk = true;\n  m_info = Success;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_INCOMPLETE_LUT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2011-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ITERATIVE_SOLVER_BASE_H\n#define EIGEN_ITERATIVE_SOLVER_BASE_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename MatrixType>\nstruct is_ref_compatible_impl\n{\nprivate:\n  template <typename T0>\n  struct any_conversion\n  {\n    template <typename T> any_conversion(const volatile T&);\n    template <typename T> any_conversion(T&);\n  };\n  struct yes {int a[1];};\n  struct no  {int a[2];};\n\n  template<typename T>\n  static yes test(const Ref<const T>&, int);\n  template<typename T>\n  static no  test(any_conversion<T>, ...);\n\npublic:\n  static MatrixType ms_from;\n  enum { value = sizeof(test<MatrixType>(ms_from, 0))==sizeof(yes) };\n};\n\ntemplate<typename MatrixType>\nstruct is_ref_compatible\n{\n  enum { value = is_ref_compatible_impl<typename remove_all<MatrixType>::type>::value };\n};\n\ntemplate<typename MatrixType, bool MatrixFree = !internal::is_ref_compatible<MatrixType>::value>\nclass generic_matrix_wrapper;\n\n// We have an explicit matrix at hand, compatible with Ref<>\ntemplate<typename MatrixType>\nclass generic_matrix_wrapper<MatrixType,false>\n{\npublic:\n  typedef Ref<const MatrixType> ActualMatrixType;\n  template<int UpLo> struct ConstSelfAdjointViewReturnType {\n    typedef typename ActualMatrixType::template ConstSelfAdjointViewReturnType<UpLo>::Type Type;\n  };\n\n  enum {\n    MatrixFree = false\n  };\n\n  generic_matrix_wrapper()\n    : m_dummy(0,0), m_matrix(m_dummy)\n  {}\n\n  template<typename InputType>\n  generic_matrix_wrapper(const InputType &mat)\n    : m_matrix(mat)\n  {}\n\n  const ActualMatrixType& matrix() const\n  {\n    return m_matrix;\n  }\n\n  template<typename MatrixDerived>\n  void grab(const EigenBase<MatrixDerived> &mat)\n  {\n    m_matrix.~Ref<const MatrixType>();\n    ::new (&m_matrix) Ref<const MatrixType>(mat.derived());\n  }\n\n  void grab(const Ref<const MatrixType> &mat)\n  {\n    if(&(mat.derived()) != &m_matrix)\n    {\n      m_matrix.~Ref<const MatrixType>();\n      ::new (&m_matrix) Ref<const MatrixType>(mat);\n    }\n  }\n\nprotected:\n  MatrixType m_dummy; // used to default initialize the Ref<> object\n  ActualMatrixType m_matrix;\n};\n\n// MatrixType is not compatible with Ref<> -> matrix-free wrapper\ntemplate<typename MatrixType>\nclass generic_matrix_wrapper<MatrixType,true>\n{\npublic:\n  typedef MatrixType ActualMatrixType;\n  template<int UpLo> struct ConstSelfAdjointViewReturnType\n  {\n    typedef ActualMatrixType Type;\n  };\n\n  enum {\n    MatrixFree = true\n  };\n\n  generic_matrix_wrapper()\n    : mp_matrix(0)\n  {}\n\n  generic_matrix_wrapper(const MatrixType &mat)\n    : mp_matrix(&mat)\n  {}\n\n  const ActualMatrixType& matrix() const\n  {\n    return *mp_matrix;\n  }\n\n  void grab(const MatrixType &mat)\n  {\n    mp_matrix = &mat;\n  }\n\nprotected:\n  const ActualMatrixType *mp_matrix;\n};\n\n}\n\n/** \\ingroup IterativeLinearSolvers_Module\n  * \\brief Base class for linear iterative solvers\n  *\n  * \\sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner\n  */\ntemplate< typename Derived>\nclass IterativeSolverBase : public SparseSolverBase<Derived>\n{\nprotected:\n  typedef SparseSolverBase<Derived> Base;\n  using Base::m_isInitialized;\n  \npublic:\n  typedef typename internal::traits<Derived>::MatrixType MatrixType;\n  typedef typename internal::traits<Derived>::Preconditioner Preconditioner;\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename MatrixType::StorageIndex StorageIndex;\n  typedef typename MatrixType::RealScalar RealScalar;\n\n  enum {\n    ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n    MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n  };\n\npublic:\n\n  using Base::derived;\n\n  /** Default constructor. */\n  IterativeSolverBase()\n  {\n    init();\n  }\n\n  /** Initialize the solver with matrix \\a A for further \\c Ax=b solving.\n    * \n    * This constructor is a shortcut for the default constructor followed\n    * by a call to compute().\n    * \n    * \\warning this class stores a reference to the matrix A as well as some\n    * precomputed values that depend on it. Therefore, if \\a A is changed\n    * this class becomes invalid. Call compute() to update it with the new\n    * matrix A, or modify a copy of A.\n    */\n  template<typename MatrixDerived>\n  explicit IterativeSolverBase(const EigenBase<MatrixDerived>& A)\n    : m_matrixWrapper(A.derived())\n  {\n    init();\n    compute(matrix());\n  }\n\n  ~IterativeSolverBase() {}\n  \n  /** Initializes the iterative solver for the sparsity pattern of the matrix \\a A for further solving \\c Ax=b problems.\n    *\n    * Currently, this function mostly calls analyzePattern on the preconditioner. In the future\n    * we might, for instance, implement column reordering for faster matrix vector products.\n    */\n  template<typename MatrixDerived>\n  Derived& analyzePattern(const EigenBase<MatrixDerived>& A)\n  {\n    grab(A.derived());\n    m_preconditioner.analyzePattern(matrix());\n    m_isInitialized = true;\n    m_analysisIsOk = true;\n    m_info = m_preconditioner.info();\n    return derived();\n  }\n  \n  /** Initializes the iterative solver with the numerical values of the matrix \\a A for further solving \\c Ax=b problems.\n    *\n    * Currently, this function mostly calls factorize on the preconditioner.\n    *\n    * \\warning this class stores a reference to the matrix A as well as some\n    * precomputed values that depend on it. Therefore, if \\a A is changed\n    * this class becomes invalid. Call compute() to update it with the new\n    * matrix A, or modify a copy of A.\n    */\n  template<typename MatrixDerived>\n  Derived& factorize(const EigenBase<MatrixDerived>& A)\n  {\n    eigen_assert(m_analysisIsOk && \"You must first call analyzePattern()\"); \n    grab(A.derived());\n    m_preconditioner.factorize(matrix());\n    m_factorizationIsOk = true;\n    m_info = m_preconditioner.info();\n    return derived();\n  }\n\n  /** Initializes the iterative solver with the matrix \\a A for further solving \\c Ax=b problems.\n    *\n    * Currently, this function mostly initializes/computes the preconditioner. In the future\n    * we might, for instance, implement column reordering for faster matrix vector products.\n    *\n    * \\warning this class stores a reference to the matrix A as well as some\n    * precomputed values that depend on it. Therefore, if \\a A is changed\n    * this class becomes invalid. Call compute() to update it with the new\n    * matrix A, or modify a copy of A.\n    */\n  template<typename MatrixDerived>\n  Derived& compute(const EigenBase<MatrixDerived>& A)\n  {\n    grab(A.derived());\n    m_preconditioner.compute(matrix());\n    m_isInitialized = true;\n    m_analysisIsOk = true;\n    m_factorizationIsOk = true;\n    m_info = m_preconditioner.info();\n    return derived();\n  }\n\n  /** \\internal */\n  Index rows() const { return matrix().rows(); }\n\n  /** \\internal */\n  Index cols() const { return matrix().cols(); }\n\n  /** \\returns the tolerance threshold used by the stopping criteria.\n    * \\sa setTolerance()\n    */\n  RealScalar tolerance() const { return m_tolerance; }\n  \n  /** Sets the tolerance threshold used by the stopping criteria.\n    *\n    * This value is used as an upper bound to the relative residual error: |Ax-b|/|b|.\n    * The default value is the machine precision given by NumTraits<Scalar>::epsilon()\n    */\n  Derived& setTolerance(const RealScalar& tolerance)\n  {\n    m_tolerance = tolerance;\n    return derived();\n  }\n\n  /** \\returns a read-write reference to the preconditioner for custom configuration. */\n  Preconditioner& preconditioner() { return m_preconditioner; }\n  \n  /** \\returns a read-only reference to the preconditioner. */\n  const Preconditioner& preconditioner() const { return m_preconditioner; }\n\n  /** \\returns the max number of iterations.\n    * It is either the value setted by setMaxIterations or, by default,\n    * twice the number of columns of the matrix.\n    */\n  Index maxIterations() const\n  {\n    return (m_maxIterations<0) ? 2*matrix().cols() : m_maxIterations;\n  }\n  \n  /** Sets the max number of iterations.\n    * Default is twice the number of columns of the matrix.\n    */\n  Derived& setMaxIterations(Index maxIters)\n  {\n    m_maxIterations = maxIters;\n    return derived();\n  }\n\n  /** \\returns the number of iterations performed during the last solve */\n  Index iterations() const\n  {\n    eigen_assert(m_isInitialized && \"ConjugateGradient is not initialized.\");\n    return m_iterations;\n  }\n\n  /** \\returns the tolerance error reached during the last solve.\n    * It is a close approximation of the true relative residual error |Ax-b|/|b|.\n    */\n  RealScalar error() const\n  {\n    eigen_assert(m_isInitialized && \"ConjugateGradient is not initialized.\");\n    return m_error;\n  }\n\n  /** \\returns the solution x of \\f$ A x = b \\f$ using the current decomposition of A\n    * and \\a x0 as an initial solution.\n    *\n    * \\sa solve(), compute()\n    */\n  template<typename Rhs,typename Guess>\n  inline const SolveWithGuess<Derived, Rhs, Guess>\n  solveWithGuess(const MatrixBase<Rhs>& b, const Guess& x0) const\n  {\n    eigen_assert(m_isInitialized && \"Solver is not initialized.\");\n    eigen_assert(derived().rows()==b.rows() && \"solve(): invalid number of rows of the right hand side matrix b\");\n    return SolveWithGuess<Derived, Rhs, Guess>(derived(), b.derived(), x0);\n  }\n\n  /** \\returns Success if the iterations converged, and NoConvergence otherwise. */\n  ComputationInfo info() const\n  {\n    eigen_assert(m_isInitialized && \"IterativeSolverBase is not initialized.\");\n    return m_info;\n  }\n  \n  /** \\internal */\n  template<typename Rhs, typename DestDerived>\n  void _solve_impl(const Rhs& b, SparseMatrixBase<DestDerived> &aDest) const\n  {\n    eigen_assert(rows()==b.rows());\n    \n    Index rhsCols = b.cols();\n    Index size = b.rows();\n    DestDerived& dest(aDest.derived());\n    typedef typename DestDerived::Scalar DestScalar;\n    Eigen::Matrix<DestScalar,Dynamic,1> tb(size);\n    Eigen::Matrix<DestScalar,Dynamic,1> tx(cols());\n    // We do not directly fill dest because sparse expressions have to be free of aliasing issue.\n    // For non square least-square problems, b and dest might not have the same size whereas they might alias each-other.\n    typename DestDerived::PlainObject tmp(cols(),rhsCols);\n    for(Index k=0; k<rhsCols; ++k)\n    {\n      tb = b.col(k);\n      tx = derived().solve(tb);\n      tmp.col(k) = tx.sparseView(0);\n    }\n    dest.swap(tmp);\n  }\n\nprotected:\n  void init()\n  {\n    m_isInitialized = false;\n    m_analysisIsOk = false;\n    m_factorizationIsOk = false;\n    m_maxIterations = -1;\n    m_tolerance = NumTraits<Scalar>::epsilon();\n  }\n\n  typedef internal::generic_matrix_wrapper<MatrixType> MatrixWrapper;\n  typedef typename MatrixWrapper::ActualMatrixType ActualMatrixType;\n\n  const ActualMatrixType& matrix() const\n  {\n    return m_matrixWrapper.matrix();\n  }\n  \n  template<typename InputType>\n  void grab(const InputType &A)\n  {\n    m_matrixWrapper.grab(A);\n  }\n  \n  MatrixWrapper m_matrixWrapper;\n  Preconditioner m_preconditioner;\n\n  Index m_maxIterations;\n  RealScalar m_tolerance;\n  \n  mutable RealScalar m_error;\n  mutable Index m_iterations;\n  mutable ComputationInfo m_info;\n  mutable bool m_analysisIsOk, m_factorizationIsOk;\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_ITERATIVE_SOLVER_BASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_LEAST_SQUARE_CONJUGATE_GRADIENT_H\n#define EIGEN_LEAST_SQUARE_CONJUGATE_GRADIENT_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/** \\internal Low-level conjugate gradient algorithm for least-square problems\n  * \\param mat The matrix A\n  * \\param rhs The right hand side vector b\n  * \\param x On input and initial solution, on output the computed solution.\n  * \\param precond A preconditioner being able to efficiently solve for an\n  *                approximation of A'Ax=b (regardless of b)\n  * \\param iters On input the max number of iteration, on output the number of performed iterations.\n  * \\param tol_error On input the tolerance error, on output an estimation of the relative error.\n  */\ntemplate<typename MatrixType, typename Rhs, typename Dest, typename Preconditioner>\nEIGEN_DONT_INLINE\nvoid least_square_conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x,\n                                     const Preconditioner& precond, Index& iters,\n                                     typename Dest::RealScalar& tol_error)\n{\n  using std::sqrt;\n  using std::abs;\n  typedef typename Dest::RealScalar RealScalar;\n  typedef typename Dest::Scalar Scalar;\n  typedef Matrix<Scalar,Dynamic,1> VectorType;\n  \n  RealScalar tol = tol_error;\n  Index maxIters = iters;\n  \n  Index m = mat.rows(), n = mat.cols();\n\n  VectorType residual        = rhs - mat * x;\n  VectorType normal_residual = mat.adjoint() * residual;\n\n  RealScalar rhsNorm2 = (mat.adjoint()*rhs).squaredNorm();\n  if(rhsNorm2 == 0) \n  {\n    x.setZero();\n    iters = 0;\n    tol_error = 0;\n    return;\n  }\n  RealScalar threshold = tol*tol*rhsNorm2;\n  RealScalar residualNorm2 = normal_residual.squaredNorm();\n  if (residualNorm2 < threshold)\n  {\n    iters = 0;\n    tol_error = sqrt(residualNorm2 / rhsNorm2);\n    return;\n  }\n  \n  VectorType p(n);\n  p = precond.solve(normal_residual);                         // initial search direction\n\n  VectorType z(n), tmp(m);\n  RealScalar absNew = numext::real(normal_residual.dot(p));  // the square of the absolute value of r scaled by invM\n  Index i = 0;\n  while(i < maxIters)\n  {\n    tmp.noalias() = mat * p;\n\n    Scalar alpha = absNew / tmp.squaredNorm();      // the amount we travel on dir\n    x += alpha * p;                                 // update solution\n    residual -= alpha * tmp;                        // update residual\n    normal_residual = mat.adjoint() * residual;     // update residual of the normal equation\n    \n    residualNorm2 = normal_residual.squaredNorm();\n    if(residualNorm2 < threshold)\n      break;\n    \n    z = precond.solve(normal_residual);             // approximately solve for \"A'A z = normal_residual\"\n\n    RealScalar absOld = absNew;\n    absNew = numext::real(normal_residual.dot(z));  // update the absolute value of r\n    RealScalar beta = absNew / absOld;              // calculate the Gram-Schmidt value used to create the new search direction\n    p = z + beta * p;                               // update search direction\n    i++;\n  }\n  tol_error = sqrt(residualNorm2 / rhsNorm2);\n  iters = i;\n}\n\n}\n\ntemplate< typename _MatrixType,\n          typename _Preconditioner = LeastSquareDiagonalPreconditioner<typename _MatrixType::Scalar> >\nclass LeastSquaresConjugateGradient;\n\nnamespace internal {\n\ntemplate< typename _MatrixType, typename _Preconditioner>\nstruct traits<LeastSquaresConjugateGradient<_MatrixType,_Preconditioner> >\n{\n  typedef _MatrixType MatrixType;\n  typedef _Preconditioner Preconditioner;\n};\n\n}\n\n/** \\ingroup IterativeLinearSolvers_Module\n  * \\brief A conjugate gradient solver for sparse (or dense) least-square problems\n  *\n  * This class allows to solve for A x = b linear problems using an iterative conjugate gradient algorithm.\n  * The matrix A can be non symmetric and rectangular, but the matrix A' A should be positive-definite to guaranty stability.\n  * Otherwise, the SparseLU or SparseQR classes might be preferable.\n  * The matrix A and the vectors x and b can be either dense or sparse.\n  *\n  * \\tparam _MatrixType the type of the matrix A, can be a dense or a sparse matrix.\n  * \\tparam _Preconditioner the type of the preconditioner. Default is LeastSquareDiagonalPreconditioner\n  *\n  * \\implsparsesolverconcept\n  * \n  * The maximal number of iterations and tolerance value can be controlled via the setMaxIterations()\n  * and setTolerance() methods. The defaults are the size of the problem for the maximal number of iterations\n  * and NumTraits<Scalar>::epsilon() for the tolerance.\n  * \n  * This class can be used as the direct solver classes. Here is a typical usage example:\n    \\code\n    int m=1000000, n = 10000;\n    VectorXd x(n), b(m);\n    SparseMatrix<double> A(m,n);\n    // fill A and b\n    LeastSquaresConjugateGradient<SparseMatrix<double> > lscg;\n    lscg.compute(A);\n    x = lscg.solve(b);\n    std::cout << \"#iterations:     \" << lscg.iterations() << std::endl;\n    std::cout << \"estimated error: \" << lscg.error()      << std::endl;\n    // update b, and solve again\n    x = lscg.solve(b);\n    \\endcode\n  * \n  * By default the iterations start with x=0 as an initial guess of the solution.\n  * One can control the start using the solveWithGuess() method.\n  * \n  * \\sa class ConjugateGradient, SparseLU, SparseQR\n  */\ntemplate< typename _MatrixType, typename _Preconditioner>\nclass LeastSquaresConjugateGradient : public IterativeSolverBase<LeastSquaresConjugateGradient<_MatrixType,_Preconditioner> >\n{\n  typedef IterativeSolverBase<LeastSquaresConjugateGradient> Base;\n  using Base::matrix;\n  using Base::m_error;\n  using Base::m_iterations;\n  using Base::m_info;\n  using Base::m_isInitialized;\npublic:\n  typedef _MatrixType MatrixType;\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename MatrixType::RealScalar RealScalar;\n  typedef _Preconditioner Preconditioner;\n\npublic:\n\n  /** Default constructor. */\n  LeastSquaresConjugateGradient() : Base() {}\n\n  /** Initialize the solver with matrix \\a A for further \\c Ax=b solving.\n    * \n    * This constructor is a shortcut for the default constructor followed\n    * by a call to compute().\n    * \n    * \\warning this class stores a reference to the matrix A as well as some\n    * precomputed values that depend on it. Therefore, if \\a A is changed\n    * this class becomes invalid. Call compute() to update it with the new\n    * matrix A, or modify a copy of A.\n    */\n  template<typename MatrixDerived>\n  explicit LeastSquaresConjugateGradient(const EigenBase<MatrixDerived>& A) : Base(A.derived()) {}\n\n  ~LeastSquaresConjugateGradient() {}\n\n  /** \\internal */\n  template<typename Rhs,typename Dest>\n  void _solve_with_guess_impl(const Rhs& b, Dest& x) const\n  {\n    m_iterations = Base::maxIterations();\n    m_error = Base::m_tolerance;\n\n    for(Index j=0; j<b.cols(); ++j)\n    {\n      m_iterations = Base::maxIterations();\n      m_error = Base::m_tolerance;\n\n      typename Dest::ColXpr xj(x,j);\n      internal::least_square_conjugate_gradient(matrix(), b.col(j), xj, Base::m_preconditioner, m_iterations, m_error);\n    }\n\n    m_isInitialized = true;\n    m_info = m_error <= Base::m_tolerance ? Success : NoConvergence;\n  }\n  \n  /** \\internal */\n  using Base::_solve_impl;\n  template<typename Rhs,typename Dest>\n  void _solve_impl(const MatrixBase<Rhs>& b, Dest& x) const\n  {\n    x.setZero();\n    _solve_with_guess_impl(b.derived(),x);\n  }\n\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_LEAST_SQUARE_CONJUGATE_GRADIENT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SOLVEWITHGUESS_H\n#define EIGEN_SOLVEWITHGUESS_H\n\nnamespace Eigen {\n\ntemplate<typename Decomposition, typename RhsType, typename GuessType> class SolveWithGuess;\n  \n/** \\class SolveWithGuess\n  * \\ingroup IterativeLinearSolvers_Module\n  *\n  * \\brief Pseudo expression representing a solving operation\n  *\n  * \\tparam Decomposition the type of the matrix or decomposion object\n  * \\tparam Rhstype the type of the right-hand side\n  *\n  * This class represents an expression of A.solve(B)\n  * and most of the time this is the only way it is used.\n  *\n  */\nnamespace internal {\n\n\ntemplate<typename Decomposition, typename RhsType, typename GuessType>\nstruct traits<SolveWithGuess<Decomposition, RhsType, GuessType> >\n  : traits<Solve<Decomposition,RhsType> >\n{};\n\n}\n\n\ntemplate<typename Decomposition, typename RhsType, typename GuessType>\nclass SolveWithGuess : public internal::generic_xpr_base<SolveWithGuess<Decomposition,RhsType,GuessType>, MatrixXpr, typename internal::traits<RhsType>::StorageKind>::type\n{\npublic:\n  typedef typename internal::traits<SolveWithGuess>::Scalar Scalar;\n  typedef typename internal::traits<SolveWithGuess>::PlainObject PlainObject;\n  typedef typename internal::generic_xpr_base<SolveWithGuess<Decomposition,RhsType,GuessType>, MatrixXpr, typename internal::traits<RhsType>::StorageKind>::type Base;\n  typedef typename internal::ref_selector<SolveWithGuess>::type Nested;\n  \n  SolveWithGuess(const Decomposition &dec, const RhsType &rhs, const GuessType &guess)\n    : m_dec(dec), m_rhs(rhs), m_guess(guess)\n  {}\n  \n  EIGEN_DEVICE_FUNC Index rows() const { return m_dec.cols(); }\n  EIGEN_DEVICE_FUNC Index cols() const { return m_rhs.cols(); }\n\n  EIGEN_DEVICE_FUNC const Decomposition& dec()   const { return m_dec; }\n  EIGEN_DEVICE_FUNC const RhsType&       rhs()   const { return m_rhs; }\n  EIGEN_DEVICE_FUNC const GuessType&     guess() const { return m_guess; }\n\nprotected:\n  const Decomposition &m_dec;\n  const RhsType       &m_rhs;\n  const GuessType     &m_guess;\n  \nprivate:\n  Scalar coeff(Index row, Index col) const;\n  Scalar coeff(Index i) const;\n};\n\nnamespace internal {\n\n// Evaluator of SolveWithGuess -> eval into a temporary\ntemplate<typename Decomposition, typename RhsType, typename GuessType>\nstruct evaluator<SolveWithGuess<Decomposition,RhsType, GuessType> >\n  : public evaluator<typename SolveWithGuess<Decomposition,RhsType,GuessType>::PlainObject>\n{\n  typedef SolveWithGuess<Decomposition,RhsType,GuessType> SolveType;\n  typedef typename SolveType::PlainObject PlainObject;\n  typedef evaluator<PlainObject> Base;\n\n  evaluator(const SolveType& solve)\n    : m_result(solve.rows(), solve.cols())\n  {\n    ::new (static_cast<Base*>(this)) Base(m_result);\n    m_result = solve.guess();\n    solve.dec()._solve_with_guess_impl(solve.rhs(), m_result);\n  }\n  \nprotected:  \n  PlainObject m_result;\n};\n\n// Specialization for \"dst = dec.solveWithGuess(rhs)\"\n// NOTE we need to specialize it for Dense2Dense to avoid ambiguous specialization error and a Sparse2Sparse specialization must exist somewhere\ntemplate<typename DstXprType, typename DecType, typename RhsType, typename GuessType, typename Scalar>\nstruct Assignment<DstXprType, SolveWithGuess<DecType,RhsType,GuessType>, internal::assign_op<Scalar,Scalar>, Dense2Dense>\n{\n  typedef SolveWithGuess<DecType,RhsType,GuessType> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,Scalar> &)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n\n    dst = src.guess();\n    src.dec()._solve_with_guess_impl(src.rhs(), dst/*, src.guess()*/);\n  }\n};\n\n} // end namepsace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SOLVEWITHGUESS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/Jacobi/Jacobi.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_JACOBI_H\n#define EIGEN_JACOBI_H\n\nnamespace Eigen { \n\n/** \\ingroup Jacobi_Module\n  * \\jacobi_module\n  * \\class JacobiRotation\n  * \\brief Rotation given by a cosine-sine pair.\n  *\n  * This class represents a Jacobi or Givens rotation.\n  * This is a 2D rotation in the plane \\c J of angle \\f$ \\theta \\f$ defined by\n  * its cosine \\c c and sine \\c s as follow:\n  * \\f$ J = \\left ( \\begin{array}{cc} c & \\overline s \\\\ -s  & \\overline c \\end{array} \\right ) \\f$\n  *\n  * You can apply the respective counter-clockwise rotation to a column vector \\c v by\n  * applying its adjoint on the left: \\f$ v = J^* v \\f$ that translates to the following Eigen code:\n  * \\code\n  * v.applyOnTheLeft(J.adjoint());\n  * \\endcode\n  *\n  * \\sa MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()\n  */\ntemplate<typename Scalar> class JacobiRotation\n{\n  public:\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n\n    /** Default constructor without any initialization. */\n    JacobiRotation() {}\n\n    /** Construct a planar rotation from a cosine-sine pair (\\a c, \\c s). */\n    JacobiRotation(const Scalar& c, const Scalar& s) : m_c(c), m_s(s) {}\n\n    Scalar& c() { return m_c; }\n    Scalar c() const { return m_c; }\n    Scalar& s() { return m_s; }\n    Scalar s() const { return m_s; }\n\n    /** Concatenates two planar rotation */\n    JacobiRotation operator*(const JacobiRotation& other)\n    {\n      using numext::conj;\n      return JacobiRotation(m_c * other.m_c - conj(m_s) * other.m_s,\n                            conj(m_c * conj(other.m_s) + conj(m_s) * conj(other.m_c)));\n    }\n\n    /** Returns the transposed transformation */\n    JacobiRotation transpose() const { using numext::conj; return JacobiRotation(m_c, -conj(m_s)); }\n\n    /** Returns the adjoint transformation */\n    JacobiRotation adjoint() const { using numext::conj; return JacobiRotation(conj(m_c), -m_s); }\n\n    template<typename Derived>\n    bool makeJacobi(const MatrixBase<Derived>&, Index p, Index q);\n    bool makeJacobi(const RealScalar& x, const Scalar& y, const RealScalar& z);\n\n    void makeGivens(const Scalar& p, const Scalar& q, Scalar* z=0);\n\n  protected:\n    void makeGivens(const Scalar& p, const Scalar& q, Scalar* z, internal::true_type);\n    void makeGivens(const Scalar& p, const Scalar& q, Scalar* z, internal::false_type);\n\n    Scalar m_c, m_s;\n};\n\n/** Makes \\c *this as a Jacobi rotation \\a J such that applying \\a J on both the right and left sides of the selfadjoint 2x2 matrix\n  * \\f$ B = \\left ( \\begin{array}{cc} x & y \\\\ \\overline y & z \\end{array} \\right )\\f$ yields a diagonal matrix \\f$ A = J^* B J \\f$\n  *\n  * \\sa MatrixBase::makeJacobi(const MatrixBase<Derived>&, Index, Index), MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()\n  */\ntemplate<typename Scalar>\nbool JacobiRotation<Scalar>::makeJacobi(const RealScalar& x, const Scalar& y, const RealScalar& z)\n{\n  using std::sqrt;\n  using std::abs;\n  typedef typename NumTraits<Scalar>::Real RealScalar;\n  RealScalar deno = RealScalar(2)*abs(y);\n  if(deno < (std::numeric_limits<RealScalar>::min)())\n  {\n    m_c = Scalar(1);\n    m_s = Scalar(0);\n    return false;\n  }\n  else\n  {\n    RealScalar tau = (x-z)/deno;\n    RealScalar w = sqrt(numext::abs2(tau) + RealScalar(1));\n    RealScalar t;\n    if(tau>RealScalar(0))\n    {\n      t = RealScalar(1) / (tau + w);\n    }\n    else\n    {\n      t = RealScalar(1) / (tau - w);\n    }\n    RealScalar sign_t = t > RealScalar(0) ? RealScalar(1) : RealScalar(-1);\n    RealScalar n = RealScalar(1) / sqrt(numext::abs2(t)+RealScalar(1));\n    m_s = - sign_t * (numext::conj(y) / abs(y)) * abs(t) * n;\n    m_c = n;\n    return true;\n  }\n}\n\n/** Makes \\c *this as a Jacobi rotation \\c J such that applying \\a J on both the right and left sides of the 2x2 selfadjoint matrix\n  * \\f$ B = \\left ( \\begin{array}{cc} \\text{this}_{pp} & \\text{this}_{pq} \\\\ (\\text{this}_{pq})^* & \\text{this}_{qq} \\end{array} \\right )\\f$ yields\n  * a diagonal matrix \\f$ A = J^* B J \\f$\n  *\n  * Example: \\include Jacobi_makeJacobi.cpp\n  * Output: \\verbinclude Jacobi_makeJacobi.out\n  *\n  * \\sa JacobiRotation::makeJacobi(RealScalar, Scalar, RealScalar), MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()\n  */\ntemplate<typename Scalar>\ntemplate<typename Derived>\ninline bool JacobiRotation<Scalar>::makeJacobi(const MatrixBase<Derived>& m, Index p, Index q)\n{\n  return makeJacobi(numext::real(m.coeff(p,p)), m.coeff(p,q), numext::real(m.coeff(q,q)));\n}\n\n/** Makes \\c *this as a Givens rotation \\c G such that applying \\f$ G^* \\f$ to the left of the vector\n  * \\f$ V = \\left ( \\begin{array}{c} p \\\\ q \\end{array} \\right )\\f$ yields:\n  * \\f$ G^* V = \\left ( \\begin{array}{c} r \\\\ 0 \\end{array} \\right )\\f$.\n  *\n  * The value of \\a z is returned if \\a z is not null (the default is null).\n  * Also note that G is built such that the cosine is always real.\n  *\n  * Example: \\include Jacobi_makeGivens.cpp\n  * Output: \\verbinclude Jacobi_makeGivens.out\n  *\n  * This function implements the continuous Givens rotation generation algorithm\n  * found in Anderson (2000), Discontinuous Plane Rotations and the Symmetric Eigenvalue Problem.\n  * LAPACK Working Note 150, University of Tennessee, UT-CS-00-454, December 4, 2000.\n  *\n  * \\sa MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()\n  */\ntemplate<typename Scalar>\nvoid JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar* z)\n{\n  makeGivens(p, q, z, typename internal::conditional<NumTraits<Scalar>::IsComplex, internal::true_type, internal::false_type>::type());\n}\n\n\n// specialization for complexes\ntemplate<typename Scalar>\nvoid JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::true_type)\n{\n  using std::sqrt;\n  using std::abs;\n  using numext::conj;\n  \n  if(q==Scalar(0))\n  {\n    m_c = numext::real(p)<0 ? Scalar(-1) : Scalar(1);\n    m_s = 0;\n    if(r) *r = m_c * p;\n  }\n  else if(p==Scalar(0))\n  {\n    m_c = 0;\n    m_s = -q/abs(q);\n    if(r) *r = abs(q);\n  }\n  else\n  {\n    RealScalar p1 = numext::norm1(p);\n    RealScalar q1 = numext::norm1(q);\n    if(p1>=q1)\n    {\n      Scalar ps = p / p1;\n      RealScalar p2 = numext::abs2(ps);\n      Scalar qs = q / p1;\n      RealScalar q2 = numext::abs2(qs);\n\n      RealScalar u = sqrt(RealScalar(1) + q2/p2);\n      if(numext::real(p)<RealScalar(0))\n        u = -u;\n\n      m_c = Scalar(1)/u;\n      m_s = -qs*conj(ps)*(m_c/p2);\n      if(r) *r = p * u;\n    }\n    else\n    {\n      Scalar ps = p / q1;\n      RealScalar p2 = numext::abs2(ps);\n      Scalar qs = q / q1;\n      RealScalar q2 = numext::abs2(qs);\n\n      RealScalar u = q1 * sqrt(p2 + q2);\n      if(numext::real(p)<RealScalar(0))\n        u = -u;\n\n      p1 = abs(p);\n      ps = p/p1;\n      m_c = p1/u;\n      m_s = -conj(ps) * (q/u);\n      if(r) *r = ps * u;\n    }\n  }\n}\n\n// specialization for reals\ntemplate<typename Scalar>\nvoid JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::false_type)\n{\n  using std::sqrt;\n  using std::abs;\n  if(q==Scalar(0))\n  {\n    m_c = p<Scalar(0) ? Scalar(-1) : Scalar(1);\n    m_s = Scalar(0);\n    if(r) *r = abs(p);\n  }\n  else if(p==Scalar(0))\n  {\n    m_c = Scalar(0);\n    m_s = q<Scalar(0) ? Scalar(1) : Scalar(-1);\n    if(r) *r = abs(q);\n  }\n  else if(abs(p) > abs(q))\n  {\n    Scalar t = q/p;\n    Scalar u = sqrt(Scalar(1) + numext::abs2(t));\n    if(p<Scalar(0))\n      u = -u;\n    m_c = Scalar(1)/u;\n    m_s = -t * m_c;\n    if(r) *r = p * u;\n  }\n  else\n  {\n    Scalar t = p/q;\n    Scalar u = sqrt(Scalar(1) + numext::abs2(t));\n    if(q<Scalar(0))\n      u = -u;\n    m_s = -Scalar(1)/u;\n    m_c = -t * m_s;\n    if(r) *r = q * u;\n  }\n\n}\n\n/****************************************************************************************\n*   Implementation of MatrixBase methods\n****************************************************************************************/\n\nnamespace internal {\n/** \\jacobi_module\n  * Applies the clock wise 2D rotation \\a j to the set of 2D vectors of cordinates \\a x and \\a y:\n  * \\f$ \\left ( \\begin{array}{cc} x \\\\ y \\end{array} \\right )  =  J \\left ( \\begin{array}{cc} x \\\\ y \\end{array} \\right ) \\f$\n  *\n  * \\sa MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()\n  */\ntemplate<typename VectorX, typename VectorY, typename OtherScalar>\nvoid apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x, DenseBase<VectorY>& xpr_y, const JacobiRotation<OtherScalar>& j);\n}\n\n/** \\jacobi_module\n  * Applies the rotation in the plane \\a j to the rows \\a p and \\a q of \\c *this, i.e., it computes B = J * B,\n  * with \\f$ B = \\left ( \\begin{array}{cc} \\text{*this.row}(p) \\\\ \\text{*this.row}(q) \\end{array} \\right ) \\f$.\n  *\n  * \\sa class JacobiRotation, MatrixBase::applyOnTheRight(), internal::apply_rotation_in_the_plane()\n  */\ntemplate<typename Derived>\ntemplate<typename OtherScalar>\ninline void MatrixBase<Derived>::applyOnTheLeft(Index p, Index q, const JacobiRotation<OtherScalar>& j)\n{\n  RowXpr x(this->row(p));\n  RowXpr y(this->row(q));\n  internal::apply_rotation_in_the_plane(x, y, j);\n}\n\n/** \\ingroup Jacobi_Module\n  * Applies the rotation in the plane \\a j to the columns \\a p and \\a q of \\c *this, i.e., it computes B = B * J\n  * with \\f$ B = \\left ( \\begin{array}{cc} \\text{*this.col}(p) & \\text{*this.col}(q) \\end{array} \\right ) \\f$.\n  *\n  * \\sa class JacobiRotation, MatrixBase::applyOnTheLeft(), internal::apply_rotation_in_the_plane()\n  */\ntemplate<typename Derived>\ntemplate<typename OtherScalar>\ninline void MatrixBase<Derived>::applyOnTheRight(Index p, Index q, const JacobiRotation<OtherScalar>& j)\n{\n  ColXpr x(this->col(p));\n  ColXpr y(this->col(q));\n  internal::apply_rotation_in_the_plane(x, y, j.transpose());\n}\n\nnamespace internal {\ntemplate<typename VectorX, typename VectorY, typename OtherScalar>\nvoid /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x, DenseBase<VectorY>& xpr_y, const JacobiRotation<OtherScalar>& j)\n{\n  typedef typename VectorX::Scalar Scalar;\n  enum {\n    PacketSize = packet_traits<Scalar>::size,\n    OtherPacketSize = packet_traits<OtherScalar>::size\n  };\n  typedef typename packet_traits<Scalar>::type Packet;\n  typedef typename packet_traits<OtherScalar>::type OtherPacket;\n  eigen_assert(xpr_x.size() == xpr_y.size());\n  Index size = xpr_x.size();\n  Index incrx = xpr_x.derived().innerStride();\n  Index incry = xpr_y.derived().innerStride();\n\n  Scalar* EIGEN_RESTRICT x = &xpr_x.derived().coeffRef(0);\n  Scalar* EIGEN_RESTRICT y = &xpr_y.derived().coeffRef(0);\n  \n  OtherScalar c = j.c();\n  OtherScalar s = j.s();\n  if (c==OtherScalar(1) && s==OtherScalar(0))\n    return;\n\n  /*** dynamic-size vectorized paths ***/\n\n  if(VectorX::SizeAtCompileTime == Dynamic &&\n    (VectorX::Flags & VectorY::Flags & PacketAccessBit) &&\n    (PacketSize == OtherPacketSize) &&\n    ((incrx==1 && incry==1) || PacketSize == 1))\n  {\n    // both vectors are sequentially stored in memory => vectorization\n    enum { Peeling = 2 };\n\n    Index alignedStart = internal::first_default_aligned(y, size);\n    Index alignedEnd = alignedStart + ((size-alignedStart)/PacketSize)*PacketSize;\n\n    const OtherPacket pc = pset1<OtherPacket>(c);\n    const OtherPacket ps = pset1<OtherPacket>(s);\n    conj_helper<OtherPacket,Packet,NumTraits<OtherScalar>::IsComplex,false> pcj;\n    conj_helper<OtherPacket,Packet,false,false> pm;\n\n    for(Index i=0; i<alignedStart; ++i)\n    {\n      Scalar xi = x[i];\n      Scalar yi = y[i];\n      x[i] =  c * xi + numext::conj(s) * yi;\n      y[i] = -s * xi + numext::conj(c) * yi;\n    }\n\n    Scalar* EIGEN_RESTRICT px = x + alignedStart;\n    Scalar* EIGEN_RESTRICT py = y + alignedStart;\n\n    if(internal::first_default_aligned(x, size)==alignedStart)\n    {\n      for(Index i=alignedStart; i<alignedEnd; i+=PacketSize)\n      {\n        Packet xi = pload<Packet>(px);\n        Packet yi = pload<Packet>(py);\n        pstore(px, padd(pm.pmul(pc,xi),pcj.pmul(ps,yi)));\n        pstore(py, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi)));\n        px += PacketSize;\n        py += PacketSize;\n      }\n    }\n    else\n    {\n      Index peelingEnd = alignedStart + ((size-alignedStart)/(Peeling*PacketSize))*(Peeling*PacketSize);\n      for(Index i=alignedStart; i<peelingEnd; i+=Peeling*PacketSize)\n      {\n        Packet xi   = ploadu<Packet>(px);\n        Packet xi1  = ploadu<Packet>(px+PacketSize);\n        Packet yi   = pload <Packet>(py);\n        Packet yi1  = pload <Packet>(py+PacketSize);\n        pstoreu(px, padd(pm.pmul(pc,xi),pcj.pmul(ps,yi)));\n        pstoreu(px+PacketSize, padd(pm.pmul(pc,xi1),pcj.pmul(ps,yi1)));\n        pstore (py, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi)));\n        pstore (py+PacketSize, psub(pcj.pmul(pc,yi1),pm.pmul(ps,xi1)));\n        px += Peeling*PacketSize;\n        py += Peeling*PacketSize;\n      }\n      if(alignedEnd!=peelingEnd)\n      {\n        Packet xi = ploadu<Packet>(x+peelingEnd);\n        Packet yi = pload <Packet>(y+peelingEnd);\n        pstoreu(x+peelingEnd, padd(pm.pmul(pc,xi),pcj.pmul(ps,yi)));\n        pstore (y+peelingEnd, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi)));\n      }\n    }\n\n    for(Index i=alignedEnd; i<size; ++i)\n    {\n      Scalar xi = x[i];\n      Scalar yi = y[i];\n      x[i] =  c * xi + numext::conj(s) * yi;\n      y[i] = -s * xi + numext::conj(c) * yi;\n    }\n  }\n\n  /*** fixed-size vectorized path ***/\n  else if(VectorX::SizeAtCompileTime != Dynamic &&\n          (VectorX::Flags & VectorY::Flags & PacketAccessBit) &&\n          (PacketSize == OtherPacketSize) &&\n          (EIGEN_PLAIN_ENUM_MIN(evaluator<VectorX>::Alignment, evaluator<VectorY>::Alignment)>0)) // FIXME should be compared to the required alignment\n  {\n    const OtherPacket pc = pset1<OtherPacket>(c);\n    const OtherPacket ps = pset1<OtherPacket>(s);\n    conj_helper<OtherPacket,Packet,NumTraits<OtherPacket>::IsComplex,false> pcj;\n    conj_helper<OtherPacket,Packet,false,false> pm;\n    Scalar* EIGEN_RESTRICT px = x;\n    Scalar* EIGEN_RESTRICT py = y;\n    for(Index i=0; i<size; i+=PacketSize)\n    {\n      Packet xi = pload<Packet>(px);\n      Packet yi = pload<Packet>(py);\n      pstore(px, padd(pm.pmul(pc,xi),pcj.pmul(ps,yi)));\n      pstore(py, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi)));\n      px += PacketSize;\n      py += PacketSize;\n    }\n  }\n\n  /*** non-vectorized path ***/\n  else\n  {\n    for(Index i=0; i<size; ++i)\n    {\n      Scalar xi = *x;\n      Scalar yi = *y;\n      *x =  c * xi + numext::conj(s) * yi;\n      *y = -s * xi + numext::conj(c) * yi;\n      x += incrx;\n      y += incry;\n    }\n  }\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_JACOBI_H\n"
  },
  {
    "path": "include/externals/Eigen/src/LU/Determinant.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_DETERMINANT_H\n#define EIGEN_DETERMINANT_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Derived>\ninline const typename Derived::Scalar bruteforce_det3_helper\n(const MatrixBase<Derived>& matrix, int a, int b, int c)\n{\n  return matrix.coeff(0,a)\n         * (matrix.coeff(1,b) * matrix.coeff(2,c) - matrix.coeff(1,c) * matrix.coeff(2,b));\n}\n\ntemplate<typename Derived>\nconst typename Derived::Scalar bruteforce_det4_helper\n(const MatrixBase<Derived>& matrix, int j, int k, int m, int n)\n{\n  return (matrix.coeff(j,0) * matrix.coeff(k,1) - matrix.coeff(k,0) * matrix.coeff(j,1))\n       * (matrix.coeff(m,2) * matrix.coeff(n,3) - matrix.coeff(n,2) * matrix.coeff(m,3));\n}\n\ntemplate<typename Derived,\n         int DeterminantType = Derived::RowsAtCompileTime\n> struct determinant_impl\n{\n  static inline typename traits<Derived>::Scalar run(const Derived& m)\n  {\n    if(Derived::ColsAtCompileTime==Dynamic && m.rows()==0)\n      return typename traits<Derived>::Scalar(1);\n    return m.partialPivLu().determinant();\n  }\n};\n\ntemplate<typename Derived> struct determinant_impl<Derived, 1>\n{\n  static inline typename traits<Derived>::Scalar run(const Derived& m)\n  {\n    return m.coeff(0,0);\n  }\n};\n\ntemplate<typename Derived> struct determinant_impl<Derived, 2>\n{\n  static inline typename traits<Derived>::Scalar run(const Derived& m)\n  {\n    return m.coeff(0,0) * m.coeff(1,1) - m.coeff(1,0) * m.coeff(0,1);\n  }\n};\n\ntemplate<typename Derived> struct determinant_impl<Derived, 3>\n{\n  static inline typename traits<Derived>::Scalar run(const Derived& m)\n  {\n    return bruteforce_det3_helper(m,0,1,2)\n          - bruteforce_det3_helper(m,1,0,2)\n          + bruteforce_det3_helper(m,2,0,1);\n  }\n};\n\ntemplate<typename Derived> struct determinant_impl<Derived, 4>\n{\n  static typename traits<Derived>::Scalar run(const Derived& m)\n  {\n    // trick by Martin Costabel to compute 4x4 det with only 30 muls\n    return bruteforce_det4_helper(m,0,1,2,3)\n          - bruteforce_det4_helper(m,0,2,1,3)\n          + bruteforce_det4_helper(m,0,3,1,2)\n          + bruteforce_det4_helper(m,1,2,0,3)\n          - bruteforce_det4_helper(m,1,3,0,2)\n          + bruteforce_det4_helper(m,2,3,0,1);\n  }\n};\n\n} // end namespace internal\n\n/** \\lu_module\n  *\n  * \\returns the determinant of this matrix\n  */\ntemplate<typename Derived>\ninline typename internal::traits<Derived>::Scalar MatrixBase<Derived>::determinant() const\n{\n  eigen_assert(rows() == cols());\n  typedef typename internal::nested_eval<Derived,Base::RowsAtCompileTime>::type Nested;\n  return internal::determinant_impl<typename internal::remove_all<Nested>::type>::run(derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_DETERMINANT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/LU/FullPivLU.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_LU_H\n#define EIGEN_LU_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate<typename _MatrixType> struct traits<FullPivLU<_MatrixType> >\n : traits<_MatrixType>\n{\n  typedef MatrixXpr XprKind;\n  typedef SolverStorage StorageKind;\n  enum { Flags = 0 };\n};\n\n} // end namespace internal\n\n/** \\ingroup LU_Module\n  *\n  * \\class FullPivLU\n  *\n  * \\brief LU decomposition of a matrix with complete pivoting, and related features\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the LU decomposition\n  *\n  * This class represents a LU decomposition of any matrix, with complete pivoting: the matrix A is\n  * decomposed as \\f$ A = P^{-1} L U Q^{-1} \\f$ where L is unit-lower-triangular, U is\n  * upper-triangular, and P and Q are permutation matrices. This is a rank-revealing LU\n  * decomposition. The eigenvalues (diagonal coefficients) of U are sorted in such a way that any\n  * zeros are at the end.\n  *\n  * This decomposition provides the generic approach to solving systems of linear equations, computing\n  * the rank, invertibility, inverse, kernel, and determinant.\n  *\n  * This LU decomposition is very stable and well tested with large matrices. However there are use cases where the SVD\n  * decomposition is inherently more stable and/or flexible. For example, when computing the kernel of a matrix,\n  * working with the SVD allows to select the smallest singular values of the matrix, something that\n  * the LU decomposition doesn't see.\n  *\n  * The data of the LU decomposition can be directly accessed through the methods matrixLU(),\n  * permutationP(), permutationQ().\n  *\n  * As an exemple, here is how the original matrix can be retrieved:\n  * \\include class_FullPivLU.cpp\n  * Output: \\verbinclude class_FullPivLU.out\n  *\n  * This class supports the \\link InplaceDecomposition inplace decomposition \\endlink mechanism.\n  * \n  * \\sa MatrixBase::fullPivLu(), MatrixBase::determinant(), MatrixBase::inverse()\n  */\ntemplate<typename _MatrixType> class FullPivLU\n  : public SolverBase<FullPivLU<_MatrixType> >\n{\n  public:\n    typedef _MatrixType MatrixType;\n    typedef SolverBase<FullPivLU> Base;\n\n    EIGEN_GENERIC_PUBLIC_INTERFACE(FullPivLU)\n    // FIXME StorageIndex defined in EIGEN_GENERIC_PUBLIC_INTERFACE should be int\n    enum {\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n    typedef typename internal::plain_row_type<MatrixType, StorageIndex>::type IntRowVectorType;\n    typedef typename internal::plain_col_type<MatrixType, StorageIndex>::type IntColVectorType;\n    typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationQType;\n    typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> PermutationPType;\n    typedef typename MatrixType::PlainObject PlainObject;\n\n    /**\n      * \\brief Default Constructor.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via LU::compute(const MatrixType&).\n      */\n    FullPivLU();\n\n    /** \\brief Default Constructor with memory preallocation\n      *\n      * Like the default constructor but with preallocation of the internal data\n      * according to the specified problem \\a size.\n      * \\sa FullPivLU()\n      */\n    FullPivLU(Index rows, Index cols);\n\n    /** Constructor.\n      *\n      * \\param matrix the matrix of which to compute the LU decomposition.\n      *               It is required to be nonzero.\n      */\n    template<typename InputType>\n    explicit FullPivLU(const EigenBase<InputType>& matrix);\n\n    /** \\brief Constructs a LU factorization from a given matrix\n      *\n      * This overloaded constructor is provided for \\link InplaceDecomposition inplace decomposition \\endlink when \\c MatrixType is a Eigen::Ref.\n      *\n      * \\sa FullPivLU(const EigenBase&)\n      */\n    template<typename InputType>\n    explicit FullPivLU(EigenBase<InputType>& matrix);\n\n    /** Computes the LU decomposition of the given matrix.\n      *\n      * \\param matrix the matrix of which to compute the LU decomposition.\n      *               It is required to be nonzero.\n      *\n      * \\returns a reference to *this\n      */\n    template<typename InputType>\n    FullPivLU& compute(const EigenBase<InputType>& matrix) {\n      m_lu = matrix.derived();\n      computeInPlace();\n      return *this;\n    }\n\n    /** \\returns the LU decomposition matrix: the upper-triangular part is U, the\n      * unit-lower-triangular part is L (at least for square matrices; in the non-square\n      * case, special care is needed, see the documentation of class FullPivLU).\n      *\n      * \\sa matrixL(), matrixU()\n      */\n    inline const MatrixType& matrixLU() const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return m_lu;\n    }\n\n    /** \\returns the number of nonzero pivots in the LU decomposition.\n      * Here nonzero is meant in the exact sense, not in a fuzzy sense.\n      * So that notion isn't really intrinsically interesting, but it is\n      * still useful when implementing algorithms.\n      *\n      * \\sa rank()\n      */\n    inline Index nonzeroPivots() const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return m_nonzero_pivots;\n    }\n\n    /** \\returns the absolute value of the biggest pivot, i.e. the biggest\n      *          diagonal coefficient of U.\n      */\n    RealScalar maxPivot() const { return m_maxpivot; }\n\n    /** \\returns the permutation matrix P\n      *\n      * \\sa permutationQ()\n      */\n    EIGEN_DEVICE_FUNC inline const PermutationPType& permutationP() const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return m_p;\n    }\n\n    /** \\returns the permutation matrix Q\n      *\n      * \\sa permutationP()\n      */\n    inline const PermutationQType& permutationQ() const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return m_q;\n    }\n\n    /** \\returns the kernel of the matrix, also called its null-space. The columns of the returned matrix\n      * will form a basis of the kernel.\n      *\n      * \\note If the kernel has dimension zero, then the returned matrix is a column-vector filled with zeros.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      *\n      * Example: \\include FullPivLU_kernel.cpp\n      * Output: \\verbinclude FullPivLU_kernel.out\n      *\n      * \\sa image()\n      */\n    inline const internal::kernel_retval<FullPivLU> kernel() const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return internal::kernel_retval<FullPivLU>(*this);\n    }\n\n    /** \\returns the image of the matrix, also called its column-space. The columns of the returned matrix\n      * will form a basis of the image (column-space).\n      *\n      * \\param originalMatrix the original matrix, of which *this is the LU decomposition.\n      *                       The reason why it is needed to pass it here, is that this allows\n      *                       a large optimization, as otherwise this method would need to reconstruct it\n      *                       from the LU decomposition.\n      *\n      * \\note If the image has dimension zero, then the returned matrix is a column-vector filled with zeros.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      *\n      * Example: \\include FullPivLU_image.cpp\n      * Output: \\verbinclude FullPivLU_image.out\n      *\n      * \\sa kernel()\n      */\n    inline const internal::image_retval<FullPivLU>\n      image(const MatrixType& originalMatrix) const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return internal::image_retval<FullPivLU>(*this, originalMatrix);\n    }\n\n    /** \\return a solution x to the equation Ax=b, where A is the matrix of which\n      * *this is the LU decomposition.\n      *\n      * \\param b the right-hand-side of the equation to solve. Can be a vector or a matrix,\n      *          the only requirement in order for the equation to make sense is that\n      *          b.rows()==A.rows(), where A is the matrix of which *this is the LU decomposition.\n      *\n      * \\returns a solution.\n      *\n      * \\note_about_checking_solutions\n      *\n      * \\note_about_arbitrary_choice_of_solution\n      * \\note_about_using_kernel_to_study_multiple_solutions\n      *\n      * Example: \\include FullPivLU_solve.cpp\n      * Output: \\verbinclude FullPivLU_solve.out\n      *\n      * \\sa TriangularView::solve(), kernel(), inverse()\n      */\n    // FIXME this is a copy-paste of the base-class member to add the isInitialized assertion.\n    template<typename Rhs>\n    inline const Solve<FullPivLU, Rhs>\n    solve(const MatrixBase<Rhs>& b) const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return Solve<FullPivLU, Rhs>(*this, b.derived());\n    }\n\n    /** \\returns an estimate of the reciprocal condition number of the matrix of which \\c *this is\n        the LU decomposition.\n      */\n    inline RealScalar rcond() const\n    {\n      eigen_assert(m_isInitialized && \"PartialPivLU is not initialized.\");\n      return internal::rcond_estimate_helper(m_l1_norm, *this);\n    }\n\n    /** \\returns the determinant of the matrix of which\n      * *this is the LU decomposition. It has only linear complexity\n      * (that is, O(n) where n is the dimension of the square matrix)\n      * as the LU decomposition has already been computed.\n      *\n      * \\note This is only for square matrices.\n      *\n      * \\note For fixed-size matrices of size up to 4, MatrixBase::determinant() offers\n      *       optimized paths.\n      *\n      * \\warning a determinant can be very big or small, so for matrices\n      * of large enough dimension, there is a risk of overflow/underflow.\n      *\n      * \\sa MatrixBase::determinant()\n      */\n    typename internal::traits<MatrixType>::Scalar determinant() const;\n\n    /** Allows to prescribe a threshold to be used by certain methods, such as rank(),\n      * who need to determine when pivots are to be considered nonzero. This is not used for the\n      * LU decomposition itself.\n      *\n      * When it needs to get the threshold value, Eigen calls threshold(). By default, this\n      * uses a formula to automatically determine a reasonable threshold.\n      * Once you have called the present method setThreshold(const RealScalar&),\n      * your value is used instead.\n      *\n      * \\param threshold The new value to use as the threshold.\n      *\n      * A pivot will be considered nonzero if its absolute value is strictly greater than\n      *  \\f$ \\vert pivot \\vert \\leqslant threshold \\times \\vert maxpivot \\vert \\f$\n      * where maxpivot is the biggest pivot.\n      *\n      * If you want to come back to the default behavior, call setThreshold(Default_t)\n      */\n    FullPivLU& setThreshold(const RealScalar& threshold)\n    {\n      m_usePrescribedThreshold = true;\n      m_prescribedThreshold = threshold;\n      return *this;\n    }\n\n    /** Allows to come back to the default behavior, letting Eigen use its default formula for\n      * determining the threshold.\n      *\n      * You should pass the special object Eigen::Default as parameter here.\n      * \\code lu.setThreshold(Eigen::Default); \\endcode\n      *\n      * See the documentation of setThreshold(const RealScalar&).\n      */\n    FullPivLU& setThreshold(Default_t)\n    {\n      m_usePrescribedThreshold = false;\n      return *this;\n    }\n\n    /** Returns the threshold that will be used by certain methods such as rank().\n      *\n      * See the documentation of setThreshold(const RealScalar&).\n      */\n    RealScalar threshold() const\n    {\n      eigen_assert(m_isInitialized || m_usePrescribedThreshold);\n      return m_usePrescribedThreshold ? m_prescribedThreshold\n      // this formula comes from experimenting (see \"LU precision tuning\" thread on the list)\n      // and turns out to be identical to Higham's formula used already in LDLt.\n                                      : NumTraits<Scalar>::epsilon() * m_lu.diagonalSize();\n    }\n\n    /** \\returns the rank of the matrix of which *this is the LU decomposition.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline Index rank() const\n    {\n      using std::abs;\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold();\n      Index result = 0;\n      for(Index i = 0; i < m_nonzero_pivots; ++i)\n        result += (abs(m_lu.coeff(i,i)) > premultiplied_threshold);\n      return result;\n    }\n\n    /** \\returns the dimension of the kernel of the matrix of which *this is the LU decomposition.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline Index dimensionOfKernel() const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return cols() - rank();\n    }\n\n    /** \\returns true if the matrix of which *this is the LU decomposition represents an injective\n      *          linear map, i.e. has trivial kernel; false otherwise.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline bool isInjective() const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return rank() == cols();\n    }\n\n    /** \\returns true if the matrix of which *this is the LU decomposition represents a surjective\n      *          linear map; false otherwise.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline bool isSurjective() const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return rank() == rows();\n    }\n\n    /** \\returns true if the matrix of which *this is the LU decomposition is invertible.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline bool isInvertible() const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return isInjective() && (m_lu.rows() == m_lu.cols());\n    }\n\n    /** \\returns the inverse of the matrix of which *this is the LU decomposition.\n      *\n      * \\note If this matrix is not invertible, the returned matrix has undefined coefficients.\n      *       Use isInvertible() to first determine whether this matrix is invertible.\n      *\n      * \\sa MatrixBase::inverse()\n      */\n    inline const Inverse<FullPivLU> inverse() const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      eigen_assert(m_lu.rows() == m_lu.cols() && \"You can't take the inverse of a non-square matrix!\");\n      return Inverse<FullPivLU>(*this);\n    }\n\n    MatrixType reconstructedMatrix() const;\n\n    EIGEN_DEVICE_FUNC inline Index rows() const { return m_lu.rows(); }\n    EIGEN_DEVICE_FUNC inline Index cols() const { return m_lu.cols(); }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename RhsType, typename DstType>\n    EIGEN_DEVICE_FUNC\n    void _solve_impl(const RhsType &rhs, DstType &dst) const;\n\n    template<bool Conjugate, typename RhsType, typename DstType>\n    EIGEN_DEVICE_FUNC\n    void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const;\n    #endif\n\n  protected:\n\n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n    }\n\n    void computeInPlace();\n\n    MatrixType m_lu;\n    PermutationPType m_p;\n    PermutationQType m_q;\n    IntColVectorType m_rowsTranspositions;\n    IntRowVectorType m_colsTranspositions;\n    Index m_nonzero_pivots;\n    RealScalar m_l1_norm;\n    RealScalar m_maxpivot, m_prescribedThreshold;\n    signed char m_det_pq;\n    bool m_isInitialized, m_usePrescribedThreshold;\n};\n\ntemplate<typename MatrixType>\nFullPivLU<MatrixType>::FullPivLU()\n  : m_isInitialized(false), m_usePrescribedThreshold(false)\n{\n}\n\ntemplate<typename MatrixType>\nFullPivLU<MatrixType>::FullPivLU(Index rows, Index cols)\n  : m_lu(rows, cols),\n    m_p(rows),\n    m_q(cols),\n    m_rowsTranspositions(rows),\n    m_colsTranspositions(cols),\n    m_isInitialized(false),\n    m_usePrescribedThreshold(false)\n{\n}\n\ntemplate<typename MatrixType>\ntemplate<typename InputType>\nFullPivLU<MatrixType>::FullPivLU(const EigenBase<InputType>& matrix)\n  : m_lu(matrix.rows(), matrix.cols()),\n    m_p(matrix.rows()),\n    m_q(matrix.cols()),\n    m_rowsTranspositions(matrix.rows()),\n    m_colsTranspositions(matrix.cols()),\n    m_isInitialized(false),\n    m_usePrescribedThreshold(false)\n{\n  compute(matrix.derived());\n}\n\ntemplate<typename MatrixType>\ntemplate<typename InputType>\nFullPivLU<MatrixType>::FullPivLU(EigenBase<InputType>& matrix)\n  : m_lu(matrix.derived()),\n    m_p(matrix.rows()),\n    m_q(matrix.cols()),\n    m_rowsTranspositions(matrix.rows()),\n    m_colsTranspositions(matrix.cols()),\n    m_isInitialized(false),\n    m_usePrescribedThreshold(false)\n{\n  computeInPlace();\n}\n\ntemplate<typename MatrixType>\nvoid FullPivLU<MatrixType>::computeInPlace()\n{\n  check_template_parameters();\n\n  // the permutations are stored as int indices, so just to be sure:\n  eigen_assert(m_lu.rows()<=NumTraits<int>::highest() && m_lu.cols()<=NumTraits<int>::highest());\n\n  m_l1_norm = m_lu.cwiseAbs().colwise().sum().maxCoeff();\n\n  const Index size = m_lu.diagonalSize();\n  const Index rows = m_lu.rows();\n  const Index cols = m_lu.cols();\n\n  // will store the transpositions, before we accumulate them at the end.\n  // can't accumulate on-the-fly because that will be done in reverse order for the rows.\n  m_rowsTranspositions.resize(m_lu.rows());\n  m_colsTranspositions.resize(m_lu.cols());\n  Index number_of_transpositions = 0; // number of NONTRIVIAL transpositions, i.e. m_rowsTranspositions[i]!=i\n\n  m_nonzero_pivots = size; // the generic case is that in which all pivots are nonzero (invertible case)\n  m_maxpivot = RealScalar(0);\n\n  for(Index k = 0; k < size; ++k)\n  {\n    // First, we need to find the pivot.\n\n    // biggest coefficient in the remaining bottom-right corner (starting at row k, col k)\n    Index row_of_biggest_in_corner, col_of_biggest_in_corner;\n    typedef internal::scalar_score_coeff_op<Scalar> Scoring;\n    typedef typename Scoring::result_type Score;\n    Score biggest_in_corner;\n    biggest_in_corner = m_lu.bottomRightCorner(rows-k, cols-k)\n                        .unaryExpr(Scoring())\n                        .maxCoeff(&row_of_biggest_in_corner, &col_of_biggest_in_corner);\n    row_of_biggest_in_corner += k; // correct the values! since they were computed in the corner,\n    col_of_biggest_in_corner += k; // need to add k to them.\n\n    if(biggest_in_corner==Score(0))\n    {\n      // before exiting, make sure to initialize the still uninitialized transpositions\n      // in a sane state without destroying what we already have.\n      m_nonzero_pivots = k;\n      for(Index i = k; i < size; ++i)\n      {\n        m_rowsTranspositions.coeffRef(i) = i;\n        m_colsTranspositions.coeffRef(i) = i;\n      }\n      break;\n    }\n\n    RealScalar abs_pivot = internal::abs_knowing_score<Scalar>()(m_lu(row_of_biggest_in_corner, col_of_biggest_in_corner), biggest_in_corner);\n    if(abs_pivot > m_maxpivot) m_maxpivot = abs_pivot;\n\n    // Now that we've found the pivot, we need to apply the row/col swaps to\n    // bring it to the location (k,k).\n\n    m_rowsTranspositions.coeffRef(k) = row_of_biggest_in_corner;\n    m_colsTranspositions.coeffRef(k) = col_of_biggest_in_corner;\n    if(k != row_of_biggest_in_corner) {\n      m_lu.row(k).swap(m_lu.row(row_of_biggest_in_corner));\n      ++number_of_transpositions;\n    }\n    if(k != col_of_biggest_in_corner) {\n      m_lu.col(k).swap(m_lu.col(col_of_biggest_in_corner));\n      ++number_of_transpositions;\n    }\n\n    // Now that the pivot is at the right location, we update the remaining\n    // bottom-right corner by Gaussian elimination.\n\n    if(k<rows-1)\n      m_lu.col(k).tail(rows-k-1) /= m_lu.coeff(k,k);\n    if(k<size-1)\n      m_lu.block(k+1,k+1,rows-k-1,cols-k-1).noalias() -= m_lu.col(k).tail(rows-k-1) * m_lu.row(k).tail(cols-k-1);\n  }\n\n  // the main loop is over, we still have to accumulate the transpositions to find the\n  // permutations P and Q\n\n  m_p.setIdentity(rows);\n  for(Index k = size-1; k >= 0; --k)\n    m_p.applyTranspositionOnTheRight(k, m_rowsTranspositions.coeff(k));\n\n  m_q.setIdentity(cols);\n  for(Index k = 0; k < size; ++k)\n    m_q.applyTranspositionOnTheRight(k, m_colsTranspositions.coeff(k));\n\n  m_det_pq = (number_of_transpositions%2) ? -1 : 1;\n\n  m_isInitialized = true;\n}\n\ntemplate<typename MatrixType>\ntypename internal::traits<MatrixType>::Scalar FullPivLU<MatrixType>::determinant() const\n{\n  eigen_assert(m_isInitialized && \"LU is not initialized.\");\n  eigen_assert(m_lu.rows() == m_lu.cols() && \"You can't take the determinant of a non-square matrix!\");\n  return Scalar(m_det_pq) * Scalar(m_lu.diagonal().prod());\n}\n\n/** \\returns the matrix represented by the decomposition,\n * i.e., it returns the product: \\f$ P^{-1} L U Q^{-1} \\f$.\n * This function is provided for debug purposes. */\ntemplate<typename MatrixType>\nMatrixType FullPivLU<MatrixType>::reconstructedMatrix() const\n{\n  eigen_assert(m_isInitialized && \"LU is not initialized.\");\n  const Index smalldim = (std::min)(m_lu.rows(), m_lu.cols());\n  // LU\n  MatrixType res(m_lu.rows(),m_lu.cols());\n  // FIXME the .toDenseMatrix() should not be needed...\n  res = m_lu.leftCols(smalldim)\n            .template triangularView<UnitLower>().toDenseMatrix()\n      * m_lu.topRows(smalldim)\n            .template triangularView<Upper>().toDenseMatrix();\n\n  // P^{-1}(LU)\n  res = m_p.inverse() * res;\n\n  // (P^{-1}LU)Q^{-1}\n  res = res * m_q.inverse();\n\n  return res;\n}\n\n/********* Implementation of kernel() **************************************************/\n\nnamespace internal {\ntemplate<typename _MatrixType>\nstruct kernel_retval<FullPivLU<_MatrixType> >\n  : kernel_retval_base<FullPivLU<_MatrixType> >\n{\n  EIGEN_MAKE_KERNEL_HELPERS(FullPivLU<_MatrixType>)\n\n  enum { MaxSmallDimAtCompileTime = EIGEN_SIZE_MIN_PREFER_FIXED(\n            MatrixType::MaxColsAtCompileTime,\n            MatrixType::MaxRowsAtCompileTime)\n  };\n\n  template<typename Dest> void evalTo(Dest& dst) const\n  {\n    using std::abs;\n    const Index cols = dec().matrixLU().cols(), dimker = cols - rank();\n    if(dimker == 0)\n    {\n      // The Kernel is just {0}, so it doesn't have a basis properly speaking, but let's\n      // avoid crashing/asserting as that depends on floating point calculations. Let's\n      // just return a single column vector filled with zeros.\n      dst.setZero();\n      return;\n    }\n\n    /* Let us use the following lemma:\n      *\n      * Lemma: If the matrix A has the LU decomposition PAQ = LU,\n      * then Ker A = Q(Ker U).\n      *\n      * Proof: trivial: just keep in mind that P, Q, L are invertible.\n      */\n\n    /* Thus, all we need to do is to compute Ker U, and then apply Q.\n      *\n      * U is upper triangular, with eigenvalues sorted so that any zeros appear at the end.\n      * Thus, the diagonal of U ends with exactly\n      * dimKer zero's. Let us use that to construct dimKer linearly\n      * independent vectors in Ker U.\n      */\n\n    Matrix<Index, Dynamic, 1, 0, MaxSmallDimAtCompileTime, 1> pivots(rank());\n    RealScalar premultiplied_threshold = dec().maxPivot() * dec().threshold();\n    Index p = 0;\n    for(Index i = 0; i < dec().nonzeroPivots(); ++i)\n      if(abs(dec().matrixLU().coeff(i,i)) > premultiplied_threshold)\n        pivots.coeffRef(p++) = i;\n    eigen_internal_assert(p == rank());\n\n    // we construct a temporaty trapezoid matrix m, by taking the U matrix and\n    // permuting the rows and cols to bring the nonnegligible pivots to the top of\n    // the main diagonal. We need that to be able to apply our triangular solvers.\n    // FIXME when we get triangularView-for-rectangular-matrices, this can be simplified\n    Matrix<typename MatrixType::Scalar, Dynamic, Dynamic, MatrixType::Options,\n           MaxSmallDimAtCompileTime, MatrixType::MaxColsAtCompileTime>\n      m(dec().matrixLU().block(0, 0, rank(), cols));\n    for(Index i = 0; i < rank(); ++i)\n    {\n      if(i) m.row(i).head(i).setZero();\n      m.row(i).tail(cols-i) = dec().matrixLU().row(pivots.coeff(i)).tail(cols-i);\n    }\n    m.block(0, 0, rank(), rank());\n    m.block(0, 0, rank(), rank()).template triangularView<StrictlyLower>().setZero();\n    for(Index i = 0; i < rank(); ++i)\n      m.col(i).swap(m.col(pivots.coeff(i)));\n\n    // ok, we have our trapezoid matrix, we can apply the triangular solver.\n    // notice that the math behind this suggests that we should apply this to the\n    // negative of the RHS, but for performance we just put the negative sign elsewhere, see below.\n    m.topLeftCorner(rank(), rank())\n     .template triangularView<Upper>().solveInPlace(\n        m.topRightCorner(rank(), dimker)\n      );\n\n    // now we must undo the column permutation that we had applied!\n    for(Index i = rank()-1; i >= 0; --i)\n      m.col(i).swap(m.col(pivots.coeff(i)));\n\n    // see the negative sign in the next line, that's what we were talking about above.\n    for(Index i = 0; i < rank(); ++i) dst.row(dec().permutationQ().indices().coeff(i)) = -m.row(i).tail(dimker);\n    for(Index i = rank(); i < cols; ++i) dst.row(dec().permutationQ().indices().coeff(i)).setZero();\n    for(Index k = 0; k < dimker; ++k) dst.coeffRef(dec().permutationQ().indices().coeff(rank()+k), k) = Scalar(1);\n  }\n};\n\n/***** Implementation of image() *****************************************************/\n\ntemplate<typename _MatrixType>\nstruct image_retval<FullPivLU<_MatrixType> >\n  : image_retval_base<FullPivLU<_MatrixType> >\n{\n  EIGEN_MAKE_IMAGE_HELPERS(FullPivLU<_MatrixType>)\n\n  enum { MaxSmallDimAtCompileTime = EIGEN_SIZE_MIN_PREFER_FIXED(\n            MatrixType::MaxColsAtCompileTime,\n            MatrixType::MaxRowsAtCompileTime)\n  };\n\n  template<typename Dest> void evalTo(Dest& dst) const\n  {\n    using std::abs;\n    if(rank() == 0)\n    {\n      // The Image is just {0}, so it doesn't have a basis properly speaking, but let's\n      // avoid crashing/asserting as that depends on floating point calculations. Let's\n      // just return a single column vector filled with zeros.\n      dst.setZero();\n      return;\n    }\n\n    Matrix<Index, Dynamic, 1, 0, MaxSmallDimAtCompileTime, 1> pivots(rank());\n    RealScalar premultiplied_threshold = dec().maxPivot() * dec().threshold();\n    Index p = 0;\n    for(Index i = 0; i < dec().nonzeroPivots(); ++i)\n      if(abs(dec().matrixLU().coeff(i,i)) > premultiplied_threshold)\n        pivots.coeffRef(p++) = i;\n    eigen_internal_assert(p == rank());\n\n    for(Index i = 0; i < rank(); ++i)\n      dst.col(i) = originalMatrix().col(dec().permutationQ().indices().coeff(pivots.coeff(i)));\n  }\n};\n\n/***** Implementation of solve() *****************************************************/\n\n} // end namespace internal\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename _MatrixType>\ntemplate<typename RhsType, typename DstType>\nvoid FullPivLU<_MatrixType>::_solve_impl(const RhsType &rhs, DstType &dst) const\n{\n  /* The decomposition PAQ = LU can be rewritten as A = P^{-1} L U Q^{-1}.\n  * So we proceed as follows:\n  * Step 1: compute c = P * rhs.\n  * Step 2: replace c by the solution x to Lx = c. Exists because L is invertible.\n  * Step 3: replace c by the solution x to Ux = c. May or may not exist.\n  * Step 4: result = Q * c;\n  */\n\n  const Index rows = this->rows(),\n              cols = this->cols(),\n              nonzero_pivots = this->rank();\n  eigen_assert(rhs.rows() == rows);\n  const Index smalldim = (std::min)(rows, cols);\n\n  if(nonzero_pivots == 0)\n  {\n    dst.setZero();\n    return;\n  }\n\n  typename RhsType::PlainObject c(rhs.rows(), rhs.cols());\n\n  // Step 1\n  c = permutationP() * rhs;\n\n  // Step 2\n  m_lu.topLeftCorner(smalldim,smalldim)\n      .template triangularView<UnitLower>()\n      .solveInPlace(c.topRows(smalldim));\n  if(rows>cols)\n    c.bottomRows(rows-cols) -= m_lu.bottomRows(rows-cols) * c.topRows(cols);\n\n  // Step 3\n  m_lu.topLeftCorner(nonzero_pivots, nonzero_pivots)\n      .template triangularView<Upper>()\n      .solveInPlace(c.topRows(nonzero_pivots));\n\n  // Step 4\n  for(Index i = 0; i < nonzero_pivots; ++i)\n    dst.row(permutationQ().indices().coeff(i)) = c.row(i);\n  for(Index i = nonzero_pivots; i < m_lu.cols(); ++i)\n    dst.row(permutationQ().indices().coeff(i)).setZero();\n}\n\ntemplate<typename _MatrixType>\ntemplate<bool Conjugate, typename RhsType, typename DstType>\nvoid FullPivLU<_MatrixType>::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const\n{\n  /* The decomposition PAQ = LU can be rewritten as A = P^{-1} L U Q^{-1},\n   * and since permutations are real and unitary, we can write this\n   * as   A^T = Q U^T L^T P,\n   * So we proceed as follows:\n   * Step 1: compute c = Q^T rhs.\n   * Step 2: replace c by the solution x to U^T x = c. May or may not exist.\n   * Step 3: replace c by the solution x to L^T x = c.\n   * Step 4: result = P^T c.\n   * If Conjugate is true, replace \"^T\" by \"^*\" above.\n   */\n\n  const Index rows = this->rows(), cols = this->cols(),\n    nonzero_pivots = this->rank();\n   eigen_assert(rhs.rows() == cols);\n  const Index smalldim = (std::min)(rows, cols);\n\n  if(nonzero_pivots == 0)\n  {\n    dst.setZero();\n    return;\n  }\n\n  typename RhsType::PlainObject c(rhs.rows(), rhs.cols());\n\n  // Step 1\n  c = permutationQ().inverse() * rhs;\n\n  if (Conjugate) {\n    // Step 2\n    m_lu.topLeftCorner(nonzero_pivots, nonzero_pivots)\n        .template triangularView<Upper>()\n        .adjoint()\n        .solveInPlace(c.topRows(nonzero_pivots));\n    // Step 3\n    m_lu.topLeftCorner(smalldim, smalldim)\n        .template triangularView<UnitLower>()\n        .adjoint()\n        .solveInPlace(c.topRows(smalldim));\n  } else {\n    // Step 2\n    m_lu.topLeftCorner(nonzero_pivots, nonzero_pivots)\n        .template triangularView<Upper>()\n        .transpose()\n        .solveInPlace(c.topRows(nonzero_pivots));\n    // Step 3\n    m_lu.topLeftCorner(smalldim, smalldim)\n        .template triangularView<UnitLower>()\n        .transpose()\n        .solveInPlace(c.topRows(smalldim));\n  }\n\n  // Step 4\n  PermutationPType invp = permutationP().inverse().eval();\n  for(Index i = 0; i < smalldim; ++i)\n    dst.row(invp.indices().coeff(i)) = c.row(i);\n  for(Index i = smalldim; i < rows; ++i)\n    dst.row(invp.indices().coeff(i)).setZero();\n}\n\n#endif\n\nnamespace internal {\n\n\n/***** Implementation of inverse() *****************************************************/\ntemplate<typename DstXprType, typename MatrixType>\nstruct Assignment<DstXprType, Inverse<FullPivLU<MatrixType> >, internal::assign_op<typename DstXprType::Scalar,typename FullPivLU<MatrixType>::Scalar>, Dense2Dense>\n{\n  typedef FullPivLU<MatrixType> LuType;\n  typedef Inverse<LuType> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename MatrixType::Scalar> &)\n  {\n    dst = src.nestedExpression().solve(MatrixType::Identity(src.rows(), src.cols()));\n  }\n};\n} // end namespace internal\n\n/******* MatrixBase methods *****************************************************************/\n\n/** \\lu_module\n  *\n  * \\return the full-pivoting LU decomposition of \\c *this.\n  *\n  * \\sa class FullPivLU\n  */\ntemplate<typename Derived>\ninline const FullPivLU<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::fullPivLu() const\n{\n  return FullPivLU<PlainObject>(eval());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_LU_H\n"
  },
  {
    "path": "include/externals/Eigen/src/LU/InverseImpl.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_INVERSE_IMPL_H\n#define EIGEN_INVERSE_IMPL_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/**********************************\n*** General case implementation ***\n**********************************/\n\ntemplate<typename MatrixType, typename ResultType, int Size = MatrixType::RowsAtCompileTime>\nstruct compute_inverse\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(const MatrixType& matrix, ResultType& result)\n  {\n    result = matrix.partialPivLu().inverse();\n  }\n};\n\ntemplate<typename MatrixType, typename ResultType, int Size = MatrixType::RowsAtCompileTime>\nstruct compute_inverse_and_det_with_check { /* nothing! general case not supported. */ };\n\n/****************************\n*** Size 1 implementation ***\n****************************/\n\ntemplate<typename MatrixType, typename ResultType>\nstruct compute_inverse<MatrixType, ResultType, 1>\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(const MatrixType& matrix, ResultType& result)\n  {\n    typedef typename MatrixType::Scalar Scalar;\n    internal::evaluator<MatrixType> matrixEval(matrix);\n    result.coeffRef(0,0) = Scalar(1) / matrixEval.coeff(0,0);\n  }\n};\n\ntemplate<typename MatrixType, typename ResultType>\nstruct compute_inverse_and_det_with_check<MatrixType, ResultType, 1>\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(\n    const MatrixType& matrix,\n    const typename MatrixType::RealScalar& absDeterminantThreshold,\n    ResultType& result,\n    typename ResultType::Scalar& determinant,\n    bool& invertible\n  )\n  {\n    using std::abs;\n    determinant = matrix.coeff(0,0);\n    invertible = abs(determinant) > absDeterminantThreshold;\n    if(invertible) result.coeffRef(0,0) = typename ResultType::Scalar(1) / determinant;\n  }\n};\n\n/****************************\n*** Size 2 implementation ***\n****************************/\n\ntemplate<typename MatrixType, typename ResultType>\nEIGEN_DEVICE_FUNC \ninline void compute_inverse_size2_helper(\n    const MatrixType& matrix, const typename ResultType::Scalar& invdet,\n    ResultType& result)\n{\n  result.coeffRef(0,0) =  matrix.coeff(1,1) * invdet;\n  result.coeffRef(1,0) = -matrix.coeff(1,0) * invdet;\n  result.coeffRef(0,1) = -matrix.coeff(0,1) * invdet;\n  result.coeffRef(1,1) =  matrix.coeff(0,0) * invdet;\n}\n\ntemplate<typename MatrixType, typename ResultType>\nstruct compute_inverse<MatrixType, ResultType, 2>\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(const MatrixType& matrix, ResultType& result)\n  {\n    typedef typename ResultType::Scalar Scalar;\n    const Scalar invdet = typename MatrixType::Scalar(1) / matrix.determinant();\n    compute_inverse_size2_helper(matrix, invdet, result);\n  }\n};\n\ntemplate<typename MatrixType, typename ResultType>\nstruct compute_inverse_and_det_with_check<MatrixType, ResultType, 2>\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(\n    const MatrixType& matrix,\n    const typename MatrixType::RealScalar& absDeterminantThreshold,\n    ResultType& inverse,\n    typename ResultType::Scalar& determinant,\n    bool& invertible\n  )\n  {\n    using std::abs;\n    typedef typename ResultType::Scalar Scalar;\n    determinant = matrix.determinant();\n    invertible = abs(determinant) > absDeterminantThreshold;\n    if(!invertible) return;\n    const Scalar invdet = Scalar(1) / determinant;\n    compute_inverse_size2_helper(matrix, invdet, inverse);\n  }\n};\n\n/****************************\n*** Size 3 implementation ***\n****************************/\n\ntemplate<typename MatrixType, int i, int j>\nEIGEN_DEVICE_FUNC \ninline typename MatrixType::Scalar cofactor_3x3(const MatrixType& m)\n{\n  enum {\n    i1 = (i+1) % 3,\n    i2 = (i+2) % 3,\n    j1 = (j+1) % 3,\n    j2 = (j+2) % 3\n  };\n  return m.coeff(i1, j1) * m.coeff(i2, j2)\n       - m.coeff(i1, j2) * m.coeff(i2, j1);\n}\n\ntemplate<typename MatrixType, typename ResultType>\nEIGEN_DEVICE_FUNC\ninline void compute_inverse_size3_helper(\n    const MatrixType& matrix,\n    const typename ResultType::Scalar& invdet,\n    const Matrix<typename ResultType::Scalar,3,1>& cofactors_col0,\n    ResultType& result)\n{\n  result.row(0) = cofactors_col0 * invdet;\n  result.coeffRef(1,0) =  cofactor_3x3<MatrixType,0,1>(matrix) * invdet;\n  result.coeffRef(1,1) =  cofactor_3x3<MatrixType,1,1>(matrix) * invdet;\n  result.coeffRef(1,2) =  cofactor_3x3<MatrixType,2,1>(matrix) * invdet;\n  result.coeffRef(2,0) =  cofactor_3x3<MatrixType,0,2>(matrix) * invdet;\n  result.coeffRef(2,1) =  cofactor_3x3<MatrixType,1,2>(matrix) * invdet;\n  result.coeffRef(2,2) =  cofactor_3x3<MatrixType,2,2>(matrix) * invdet;\n}\n\ntemplate<typename MatrixType, typename ResultType>\nstruct compute_inverse<MatrixType, ResultType, 3>\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(const MatrixType& matrix, ResultType& result)\n  {\n    typedef typename ResultType::Scalar Scalar;\n    Matrix<typename MatrixType::Scalar,3,1> cofactors_col0;\n    cofactors_col0.coeffRef(0) =  cofactor_3x3<MatrixType,0,0>(matrix);\n    cofactors_col0.coeffRef(1) =  cofactor_3x3<MatrixType,1,0>(matrix);\n    cofactors_col0.coeffRef(2) =  cofactor_3x3<MatrixType,2,0>(matrix);\n    const Scalar det = (cofactors_col0.cwiseProduct(matrix.col(0))).sum();\n    const Scalar invdet = Scalar(1) / det;\n    compute_inverse_size3_helper(matrix, invdet, cofactors_col0, result);\n  }\n};\n\ntemplate<typename MatrixType, typename ResultType>\nstruct compute_inverse_and_det_with_check<MatrixType, ResultType, 3>\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(\n    const MatrixType& matrix,\n    const typename MatrixType::RealScalar& absDeterminantThreshold,\n    ResultType& inverse,\n    typename ResultType::Scalar& determinant,\n    bool& invertible\n  )\n  {\n    using std::abs;\n    typedef typename ResultType::Scalar Scalar;\n    Matrix<Scalar,3,1> cofactors_col0;\n    cofactors_col0.coeffRef(0) =  cofactor_3x3<MatrixType,0,0>(matrix);\n    cofactors_col0.coeffRef(1) =  cofactor_3x3<MatrixType,1,0>(matrix);\n    cofactors_col0.coeffRef(2) =  cofactor_3x3<MatrixType,2,0>(matrix);\n    determinant = (cofactors_col0.cwiseProduct(matrix.col(0))).sum();\n    invertible = abs(determinant) > absDeterminantThreshold;\n    if(!invertible) return;\n    const Scalar invdet = Scalar(1) / determinant;\n    compute_inverse_size3_helper(matrix, invdet, cofactors_col0, inverse);\n  }\n};\n\n/****************************\n*** Size 4 implementation ***\n****************************/\n\ntemplate<typename Derived>\nEIGEN_DEVICE_FUNC \ninline const typename Derived::Scalar general_det3_helper\n(const MatrixBase<Derived>& matrix, int i1, int i2, int i3, int j1, int j2, int j3)\n{\n  return matrix.coeff(i1,j1)\n         * (matrix.coeff(i2,j2) * matrix.coeff(i3,j3) - matrix.coeff(i2,j3) * matrix.coeff(i3,j2));\n}\n\ntemplate<typename MatrixType, int i, int j>\nEIGEN_DEVICE_FUNC \ninline typename MatrixType::Scalar cofactor_4x4(const MatrixType& matrix)\n{\n  enum {\n    i1 = (i+1) % 4,\n    i2 = (i+2) % 4,\n    i3 = (i+3) % 4,\n    j1 = (j+1) % 4,\n    j2 = (j+2) % 4,\n    j3 = (j+3) % 4\n  };\n  return general_det3_helper(matrix, i1, i2, i3, j1, j2, j3)\n       + general_det3_helper(matrix, i2, i3, i1, j1, j2, j3)\n       + general_det3_helper(matrix, i3, i1, i2, j1, j2, j3);\n}\n\ntemplate<int Arch, typename Scalar, typename MatrixType, typename ResultType>\nstruct compute_inverse_size4\n{\n  EIGEN_DEVICE_FUNC\n  static void run(const MatrixType& matrix, ResultType& result)\n  {\n    result.coeffRef(0,0) =  cofactor_4x4<MatrixType,0,0>(matrix);\n    result.coeffRef(1,0) = -cofactor_4x4<MatrixType,0,1>(matrix);\n    result.coeffRef(2,0) =  cofactor_4x4<MatrixType,0,2>(matrix);\n    result.coeffRef(3,0) = -cofactor_4x4<MatrixType,0,3>(matrix);\n    result.coeffRef(0,2) =  cofactor_4x4<MatrixType,2,0>(matrix);\n    result.coeffRef(1,2) = -cofactor_4x4<MatrixType,2,1>(matrix);\n    result.coeffRef(2,2) =  cofactor_4x4<MatrixType,2,2>(matrix);\n    result.coeffRef(3,2) = -cofactor_4x4<MatrixType,2,3>(matrix);\n    result.coeffRef(0,1) = -cofactor_4x4<MatrixType,1,0>(matrix);\n    result.coeffRef(1,1) =  cofactor_4x4<MatrixType,1,1>(matrix);\n    result.coeffRef(2,1) = -cofactor_4x4<MatrixType,1,2>(matrix);\n    result.coeffRef(3,1) =  cofactor_4x4<MatrixType,1,3>(matrix);\n    result.coeffRef(0,3) = -cofactor_4x4<MatrixType,3,0>(matrix);\n    result.coeffRef(1,3) =  cofactor_4x4<MatrixType,3,1>(matrix);\n    result.coeffRef(2,3) = -cofactor_4x4<MatrixType,3,2>(matrix);\n    result.coeffRef(3,3) =  cofactor_4x4<MatrixType,3,3>(matrix);\n    result /= (matrix.col(0).cwiseProduct(result.row(0).transpose())).sum();\n  }\n};\n\ntemplate<typename MatrixType, typename ResultType>\nstruct compute_inverse<MatrixType, ResultType, 4>\n : compute_inverse_size4<Architecture::Target, typename MatrixType::Scalar,\n                            MatrixType, ResultType>\n{\n};\n\ntemplate<typename MatrixType, typename ResultType>\nstruct compute_inverse_and_det_with_check<MatrixType, ResultType, 4>\n{\n  EIGEN_DEVICE_FUNC\n  static inline void run(\n    const MatrixType& matrix,\n    const typename MatrixType::RealScalar& absDeterminantThreshold,\n    ResultType& inverse,\n    typename ResultType::Scalar& determinant,\n    bool& invertible\n  )\n  {\n    using std::abs;\n    determinant = matrix.determinant();\n    invertible = abs(determinant) > absDeterminantThreshold;\n    if(invertible) compute_inverse<MatrixType, ResultType>::run(matrix, inverse);\n  }\n};\n\n/*************************\n*** MatrixBase methods ***\n*************************/\n\n} // end namespace internal\n\nnamespace internal {\n\n// Specialization for \"dense = dense_xpr.inverse()\"\ntemplate<typename DstXprType, typename XprType>\nstruct Assignment<DstXprType, Inverse<XprType>, internal::assign_op<typename DstXprType::Scalar,typename XprType::Scalar>, Dense2Dense>\n{\n  typedef Inverse<XprType> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename XprType::Scalar> &)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n    \n    const int Size = EIGEN_PLAIN_ENUM_MIN(XprType::ColsAtCompileTime,DstXprType::ColsAtCompileTime);\n    EIGEN_ONLY_USED_FOR_DEBUG(Size);\n    eigen_assert(( (Size<=1) || (Size>4) || (extract_data(src.nestedExpression())!=extract_data(dst)))\n              && \"Aliasing problem detected in inverse(), you need to do inverse().eval() here.\");\n\n    typedef typename internal::nested_eval<XprType,XprType::ColsAtCompileTime>::type  ActualXprType;\n    typedef typename internal::remove_all<ActualXprType>::type                        ActualXprTypeCleanded;\n    \n    ActualXprType actual_xpr(src.nestedExpression());\n    \n    compute_inverse<ActualXprTypeCleanded, DstXprType>::run(actual_xpr, dst);\n  }\n};\n\n  \n} // end namespace internal\n\n/** \\lu_module\n  *\n  * \\returns the matrix inverse of this matrix.\n  *\n  * For small fixed sizes up to 4x4, this method uses cofactors.\n  * In the general case, this method uses class PartialPivLU.\n  *\n  * \\note This matrix must be invertible, otherwise the result is undefined. If you need an\n  * invertibility check, do the following:\n  * \\li for fixed sizes up to 4x4, use computeInverseAndDetWithCheck().\n  * \\li for the general case, use class FullPivLU.\n  *\n  * Example: \\include MatrixBase_inverse.cpp\n  * Output: \\verbinclude MatrixBase_inverse.out\n  *\n  * \\sa computeInverseAndDetWithCheck()\n  */\ntemplate<typename Derived>\ninline const Inverse<Derived> MatrixBase<Derived>::inverse() const\n{\n  EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsInteger,THIS_FUNCTION_IS_NOT_FOR_INTEGER_NUMERIC_TYPES)\n  eigen_assert(rows() == cols());\n  return Inverse<Derived>(derived());\n}\n\n/** \\lu_module\n  *\n  * Computation of matrix inverse and determinant, with invertibility check.\n  *\n  * This is only for fixed-size square matrices of size up to 4x4.\n  *\n  * \\param inverse Reference to the matrix in which to store the inverse.\n  * \\param determinant Reference to the variable in which to store the determinant.\n  * \\param invertible Reference to the bool variable in which to store whether the matrix is invertible.\n  * \\param absDeterminantThreshold Optional parameter controlling the invertibility check.\n  *                                The matrix will be declared invertible if the absolute value of its\n  *                                determinant is greater than this threshold.\n  *\n  * Example: \\include MatrixBase_computeInverseAndDetWithCheck.cpp\n  * Output: \\verbinclude MatrixBase_computeInverseAndDetWithCheck.out\n  *\n  * \\sa inverse(), computeInverseWithCheck()\n  */\ntemplate<typename Derived>\ntemplate<typename ResultType>\ninline void MatrixBase<Derived>::computeInverseAndDetWithCheck(\n    ResultType& inverse,\n    typename ResultType::Scalar& determinant,\n    bool& invertible,\n    const RealScalar& absDeterminantThreshold\n  ) const\n{\n  // i'd love to put some static assertions there, but SFINAE means that they have no effect...\n  eigen_assert(rows() == cols());\n  // for 2x2, it's worth giving a chance to avoid evaluating.\n  // for larger sizes, evaluating has negligible cost and limits code size.\n  typedef typename internal::conditional<\n    RowsAtCompileTime == 2,\n    typename internal::remove_all<typename internal::nested_eval<Derived, 2>::type>::type,\n    PlainObject\n  >::type MatrixType;\n  internal::compute_inverse_and_det_with_check<MatrixType, ResultType>::run\n    (derived(), absDeterminantThreshold, inverse, determinant, invertible);\n}\n\n/** \\lu_module\n  *\n  * Computation of matrix inverse, with invertibility check.\n  *\n  * This is only for fixed-size square matrices of size up to 4x4.\n  *\n  * \\param inverse Reference to the matrix in which to store the inverse.\n  * \\param invertible Reference to the bool variable in which to store whether the matrix is invertible.\n  * \\param absDeterminantThreshold Optional parameter controlling the invertibility check.\n  *                                The matrix will be declared invertible if the absolute value of its\n  *                                determinant is greater than this threshold.\n  *\n  * Example: \\include MatrixBase_computeInverseWithCheck.cpp\n  * Output: \\verbinclude MatrixBase_computeInverseWithCheck.out\n  *\n  * \\sa inverse(), computeInverseAndDetWithCheck()\n  */\ntemplate<typename Derived>\ntemplate<typename ResultType>\ninline void MatrixBase<Derived>::computeInverseWithCheck(\n    ResultType& inverse,\n    bool& invertible,\n    const RealScalar& absDeterminantThreshold\n  ) const\n{\n  RealScalar determinant;\n  // i'd love to put some static assertions there, but SFINAE means that they have no effect...\n  eigen_assert(rows() == cols());\n  computeInverseAndDetWithCheck(inverse,determinant,invertible,absDeterminantThreshold);\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_INVERSE_IMPL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/LU/PartialPivLU.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PARTIALLU_H\n#define EIGEN_PARTIALLU_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate<typename _MatrixType> struct traits<PartialPivLU<_MatrixType> >\n : traits<_MatrixType>\n{\n  typedef MatrixXpr XprKind;\n  typedef SolverStorage StorageKind;\n  typedef traits<_MatrixType> BaseTraits;\n  enum {\n    Flags = BaseTraits::Flags & RowMajorBit,\n    CoeffReadCost = Dynamic\n  };\n};\n\ntemplate<typename T,typename Derived>\nstruct enable_if_ref;\n// {\n//   typedef Derived type;\n// };\n\ntemplate<typename T,typename Derived>\nstruct enable_if_ref<Ref<T>,Derived> {\n  typedef Derived type;\n};\n\n} // end namespace internal\n\n/** \\ingroup LU_Module\n  *\n  * \\class PartialPivLU\n  *\n  * \\brief LU decomposition of a matrix with partial pivoting, and related features\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the LU decomposition\n  *\n  * This class represents a LU decomposition of a \\b square \\b invertible matrix, with partial pivoting: the matrix A\n  * is decomposed as A = PLU where L is unit-lower-triangular, U is upper-triangular, and P\n  * is a permutation matrix.\n  *\n  * Typically, partial pivoting LU decomposition is only considered numerically stable for square invertible\n  * matrices. Thus LAPACK's dgesv and dgesvx require the matrix to be square and invertible. The present class\n  * does the same. It will assert that the matrix is square, but it won't (actually it can't) check that the\n  * matrix is invertible: it is your task to check that you only use this decomposition on invertible matrices.\n  *\n  * The guaranteed safe alternative, working for all matrices, is the full pivoting LU decomposition, provided\n  * by class FullPivLU.\n  *\n  * This is \\b not a rank-revealing LU decomposition. Many features are intentionally absent from this class,\n  * such as rank computation. If you need these features, use class FullPivLU.\n  *\n  * This LU decomposition is suitable to invert invertible matrices. It is what MatrixBase::inverse() uses\n  * in the general case.\n  * On the other hand, it is \\b not suitable to determine whether a given matrix is invertible.\n  *\n  * The data of the LU decomposition can be directly accessed through the methods matrixLU(), permutationP().\n  *\n  * This class supports the \\link InplaceDecomposition inplace decomposition \\endlink mechanism.\n  * \n  * \\sa MatrixBase::partialPivLu(), MatrixBase::determinant(), MatrixBase::inverse(), MatrixBase::computeInverse(), class FullPivLU\n  */\ntemplate<typename _MatrixType> class PartialPivLU\n  : public SolverBase<PartialPivLU<_MatrixType> >\n{\n  public:\n\n    typedef _MatrixType MatrixType;\n    typedef SolverBase<PartialPivLU> Base;\n    EIGEN_GENERIC_PUBLIC_INTERFACE(PartialPivLU)\n    // FIXME StorageIndex defined in EIGEN_GENERIC_PUBLIC_INTERFACE should be int\n    enum {\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n    typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> PermutationType;\n    typedef Transpositions<RowsAtCompileTime, MaxRowsAtCompileTime> TranspositionType;\n    typedef typename MatrixType::PlainObject PlainObject;\n\n    /**\n      * \\brief Default Constructor.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via PartialPivLU::compute(const MatrixType&).\n      */\n    PartialPivLU();\n\n    /** \\brief Default Constructor with memory preallocation\n      *\n      * Like the default constructor but with preallocation of the internal data\n      * according to the specified problem \\a size.\n      * \\sa PartialPivLU()\n      */\n    explicit PartialPivLU(Index size);\n\n    /** Constructor.\n      *\n      * \\param matrix the matrix of which to compute the LU decomposition.\n      *\n      * \\warning The matrix should have full rank (e.g. if it's square, it should be invertible).\n      * If you need to deal with non-full rank, use class FullPivLU instead.\n      */\n    template<typename InputType>\n    explicit PartialPivLU(const EigenBase<InputType>& matrix);\n\n    /** Constructor for \\link InplaceDecomposition inplace decomposition \\endlink\n      *\n      * \\param matrix the matrix of which to compute the LU decomposition.\n      *\n      * \\warning The matrix should have full rank (e.g. if it's square, it should be invertible).\n      * If you need to deal with non-full rank, use class FullPivLU instead.\n      */\n    template<typename InputType>\n    explicit PartialPivLU(EigenBase<InputType>& matrix);\n\n    template<typename InputType>\n    PartialPivLU& compute(const EigenBase<InputType>& matrix) {\n      m_lu = matrix.derived();\n      compute();\n      return *this;\n    }\n\n    /** \\returns the LU decomposition matrix: the upper-triangular part is U, the\n      * unit-lower-triangular part is L (at least for square matrices; in the non-square\n      * case, special care is needed, see the documentation of class FullPivLU).\n      *\n      * \\sa matrixL(), matrixU()\n      */\n    inline const MatrixType& matrixLU() const\n    {\n      eigen_assert(m_isInitialized && \"PartialPivLU is not initialized.\");\n      return m_lu;\n    }\n\n    /** \\returns the permutation matrix P.\n      */\n    inline const PermutationType& permutationP() const\n    {\n      eigen_assert(m_isInitialized && \"PartialPivLU is not initialized.\");\n      return m_p;\n    }\n\n    /** This method returns the solution x to the equation Ax=b, where A is the matrix of which\n      * *this is the LU decomposition.\n      *\n      * \\param b the right-hand-side of the equation to solve. Can be a vector or a matrix,\n      *          the only requirement in order for the equation to make sense is that\n      *          b.rows()==A.rows(), where A is the matrix of which *this is the LU decomposition.\n      *\n      * \\returns the solution.\n      *\n      * Example: \\include PartialPivLU_solve.cpp\n      * Output: \\verbinclude PartialPivLU_solve.out\n      *\n      * Since this PartialPivLU class assumes anyway that the matrix A is invertible, the solution\n      * theoretically exists and is unique regardless of b.\n      *\n      * \\sa TriangularView::solve(), inverse(), computeInverse()\n      */\n    // FIXME this is a copy-paste of the base-class member to add the isInitialized assertion.\n    template<typename Rhs>\n    inline const Solve<PartialPivLU, Rhs>\n    solve(const MatrixBase<Rhs>& b) const\n    {\n      eigen_assert(m_isInitialized && \"PartialPivLU is not initialized.\");\n      return Solve<PartialPivLU, Rhs>(*this, b.derived());\n    }\n\n    /** \\returns an estimate of the reciprocal condition number of the matrix of which \\c *this is\n        the LU decomposition.\n      */\n    inline RealScalar rcond() const\n    {\n      eigen_assert(m_isInitialized && \"PartialPivLU is not initialized.\");\n      return internal::rcond_estimate_helper(m_l1_norm, *this);\n    }\n\n    /** \\returns the inverse of the matrix of which *this is the LU decomposition.\n      *\n      * \\warning The matrix being decomposed here is assumed to be invertible. If you need to check for\n      *          invertibility, use class FullPivLU instead.\n      *\n      * \\sa MatrixBase::inverse(), LU::inverse()\n      */\n    inline const Inverse<PartialPivLU> inverse() const\n    {\n      eigen_assert(m_isInitialized && \"PartialPivLU is not initialized.\");\n      return Inverse<PartialPivLU>(*this);\n    }\n\n    /** \\returns the determinant of the matrix of which\n      * *this is the LU decomposition. It has only linear complexity\n      * (that is, O(n) where n is the dimension of the square matrix)\n      * as the LU decomposition has already been computed.\n      *\n      * \\note For fixed-size matrices of size up to 4, MatrixBase::determinant() offers\n      *       optimized paths.\n      *\n      * \\warning a determinant can be very big or small, so for matrices\n      * of large enough dimension, there is a risk of overflow/underflow.\n      *\n      * \\sa MatrixBase::determinant()\n      */\n    Scalar determinant() const;\n\n    MatrixType reconstructedMatrix() const;\n\n    inline Index rows() const { return m_lu.rows(); }\n    inline Index cols() const { return m_lu.cols(); }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename RhsType, typename DstType>\n    EIGEN_DEVICE_FUNC\n    void _solve_impl(const RhsType &rhs, DstType &dst) const {\n     /* The decomposition PA = LU can be rewritten as A = P^{-1} L U.\n      * So we proceed as follows:\n      * Step 1: compute c = Pb.\n      * Step 2: replace c by the solution x to Lx = c.\n      * Step 3: replace c by the solution x to Ux = c.\n      */\n\n      eigen_assert(rhs.rows() == m_lu.rows());\n\n      // Step 1\n      dst = permutationP() * rhs;\n\n      // Step 2\n      m_lu.template triangularView<UnitLower>().solveInPlace(dst);\n\n      // Step 3\n      m_lu.template triangularView<Upper>().solveInPlace(dst);\n    }\n\n    template<bool Conjugate, typename RhsType, typename DstType>\n    EIGEN_DEVICE_FUNC\n    void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const {\n     /* The decomposition PA = LU can be rewritten as A = P^{-1} L U.\n      * So we proceed as follows:\n      * Step 1: compute c = Pb.\n      * Step 2: replace c by the solution x to Lx = c.\n      * Step 3: replace c by the solution x to Ux = c.\n      */\n\n      eigen_assert(rhs.rows() == m_lu.cols());\n\n      if (Conjugate) {\n        // Step 1\n        dst = m_lu.template triangularView<Upper>().adjoint().solve(rhs);\n        // Step 2\n        m_lu.template triangularView<UnitLower>().adjoint().solveInPlace(dst);\n      } else {\n        // Step 1\n        dst = m_lu.template triangularView<Upper>().transpose().solve(rhs);\n        // Step 2\n        m_lu.template triangularView<UnitLower>().transpose().solveInPlace(dst);\n      }\n      // Step 3\n      dst = permutationP().transpose() * dst;\n    }\n    #endif\n\n  protected:\n\n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n    }\n\n    void compute();\n\n    MatrixType m_lu;\n    PermutationType m_p;\n    TranspositionType m_rowsTranspositions;\n    RealScalar m_l1_norm;\n    signed char m_det_p;\n    bool m_isInitialized;\n};\n\ntemplate<typename MatrixType>\nPartialPivLU<MatrixType>::PartialPivLU()\n  : m_lu(),\n    m_p(),\n    m_rowsTranspositions(),\n    m_l1_norm(0),\n    m_det_p(0),\n    m_isInitialized(false)\n{\n}\n\ntemplate<typename MatrixType>\nPartialPivLU<MatrixType>::PartialPivLU(Index size)\n  : m_lu(size, size),\n    m_p(size),\n    m_rowsTranspositions(size),\n    m_l1_norm(0),\n    m_det_p(0),\n    m_isInitialized(false)\n{\n}\n\ntemplate<typename MatrixType>\ntemplate<typename InputType>\nPartialPivLU<MatrixType>::PartialPivLU(const EigenBase<InputType>& matrix)\n  : m_lu(matrix.rows(),matrix.cols()),\n    m_p(matrix.rows()),\n    m_rowsTranspositions(matrix.rows()),\n    m_l1_norm(0),\n    m_det_p(0),\n    m_isInitialized(false)\n{\n  compute(matrix.derived());\n}\n\ntemplate<typename MatrixType>\ntemplate<typename InputType>\nPartialPivLU<MatrixType>::PartialPivLU(EigenBase<InputType>& matrix)\n  : m_lu(matrix.derived()),\n    m_p(matrix.rows()),\n    m_rowsTranspositions(matrix.rows()),\n    m_l1_norm(0),\n    m_det_p(0),\n    m_isInitialized(false)\n{\n  compute();\n}\n\nnamespace internal {\n\n/** \\internal This is the blocked version of fullpivlu_unblocked() */\ntemplate<typename Scalar, int StorageOrder, typename PivIndex>\nstruct partial_lu_impl\n{\n  // FIXME add a stride to Map, so that the following mapping becomes easier,\n  // another option would be to create an expression being able to automatically\n  // warp any Map, Matrix, and Block expressions as a unique type, but since that's exactly\n  // a Map + stride, why not adding a stride to Map, and convenient ctors from a Matrix,\n  // and Block.\n  typedef Map<Matrix<Scalar, Dynamic, Dynamic, StorageOrder> > MapLU;\n  typedef Block<MapLU, Dynamic, Dynamic> MatrixType;\n  typedef Block<MatrixType,Dynamic,Dynamic> BlockType;\n  typedef typename MatrixType::RealScalar RealScalar;\n\n  /** \\internal performs the LU decomposition in-place of the matrix \\a lu\n    * using an unblocked algorithm.\n    *\n    * In addition, this function returns the row transpositions in the\n    * vector \\a row_transpositions which must have a size equal to the number\n    * of columns of the matrix \\a lu, and an integer \\a nb_transpositions\n    * which returns the actual number of transpositions.\n    *\n    * \\returns The index of the first pivot which is exactly zero if any, or a negative number otherwise.\n    */\n  static Index unblocked_lu(MatrixType& lu, PivIndex* row_transpositions, PivIndex& nb_transpositions)\n  {\n    typedef scalar_score_coeff_op<Scalar> Scoring;\n    typedef typename Scoring::result_type Score;\n    const Index rows = lu.rows();\n    const Index cols = lu.cols();\n    const Index size = (std::min)(rows,cols);\n    nb_transpositions = 0;\n    Index first_zero_pivot = -1;\n    for(Index k = 0; k < size; ++k)\n    {\n      Index rrows = rows-k-1;\n      Index rcols = cols-k-1;\n\n      Index row_of_biggest_in_col;\n      Score biggest_in_corner\n        = lu.col(k).tail(rows-k).unaryExpr(Scoring()).maxCoeff(&row_of_biggest_in_col);\n      row_of_biggest_in_col += k;\n\n      row_transpositions[k] = PivIndex(row_of_biggest_in_col);\n\n      if(biggest_in_corner != Score(0))\n      {\n        if(k != row_of_biggest_in_col)\n        {\n          lu.row(k).swap(lu.row(row_of_biggest_in_col));\n          ++nb_transpositions;\n        }\n\n        // FIXME shall we introduce a safe quotient expression in cas 1/lu.coeff(k,k)\n        // overflow but not the actual quotient?\n        lu.col(k).tail(rrows) /= lu.coeff(k,k);\n      }\n      else if(first_zero_pivot==-1)\n      {\n        // the pivot is exactly zero, we record the index of the first pivot which is exactly 0,\n        // and continue the factorization such we still have A = PLU\n        first_zero_pivot = k;\n      }\n\n      if(k<rows-1)\n        lu.bottomRightCorner(rrows,rcols).noalias() -= lu.col(k).tail(rrows) * lu.row(k).tail(rcols);\n    }\n    return first_zero_pivot;\n  }\n\n  /** \\internal performs the LU decomposition in-place of the matrix represented\n    * by the variables \\a rows, \\a cols, \\a lu_data, and \\a lu_stride using a\n    * recursive, blocked algorithm.\n    *\n    * In addition, this function returns the row transpositions in the\n    * vector \\a row_transpositions which must have a size equal to the number\n    * of columns of the matrix \\a lu, and an integer \\a nb_transpositions\n    * which returns the actual number of transpositions.\n    *\n    * \\returns The index of the first pivot which is exactly zero if any, or a negative number otherwise.\n    *\n    * \\note This very low level interface using pointers, etc. is to:\n    *   1 - reduce the number of instanciations to the strict minimum\n    *   2 - avoid infinite recursion of the instanciations with Block<Block<Block<...> > >\n    */\n  static Index blocked_lu(Index rows, Index cols, Scalar* lu_data, Index luStride, PivIndex* row_transpositions, PivIndex& nb_transpositions, Index maxBlockSize=256)\n  {\n    MapLU lu1(lu_data,StorageOrder==RowMajor?rows:luStride,StorageOrder==RowMajor?luStride:cols);\n    MatrixType lu(lu1,0,0,rows,cols);\n\n    const Index size = (std::min)(rows,cols);\n\n    // if the matrix is too small, no blocking:\n    if(size<=16)\n    {\n      return unblocked_lu(lu, row_transpositions, nb_transpositions);\n    }\n\n    // automatically adjust the number of subdivisions to the size\n    // of the matrix so that there is enough sub blocks:\n    Index blockSize;\n    {\n      blockSize = size/8;\n      blockSize = (blockSize/16)*16;\n      blockSize = (std::min)((std::max)(blockSize,Index(8)), maxBlockSize);\n    }\n\n    nb_transpositions = 0;\n    Index first_zero_pivot = -1;\n    for(Index k = 0; k < size; k+=blockSize)\n    {\n      Index bs = (std::min)(size-k,blockSize); // actual size of the block\n      Index trows = rows - k - bs; // trailing rows\n      Index tsize = size - k - bs; // trailing size\n\n      // partition the matrix:\n      //                          A00 | A01 | A02\n      // lu  = A_0 | A_1 | A_2 =  A10 | A11 | A12\n      //                          A20 | A21 | A22\n      BlockType A_0(lu,0,0,rows,k);\n      BlockType A_2(lu,0,k+bs,rows,tsize);\n      BlockType A11(lu,k,k,bs,bs);\n      BlockType A12(lu,k,k+bs,bs,tsize);\n      BlockType A21(lu,k+bs,k,trows,bs);\n      BlockType A22(lu,k+bs,k+bs,trows,tsize);\n\n      PivIndex nb_transpositions_in_panel;\n      // recursively call the blocked LU algorithm on [A11^T A21^T]^T\n      // with a very small blocking size:\n      Index ret = blocked_lu(trows+bs, bs, &lu.coeffRef(k,k), luStride,\n                   row_transpositions+k, nb_transpositions_in_panel, 16);\n      if(ret>=0 && first_zero_pivot==-1)\n        first_zero_pivot = k+ret;\n\n      nb_transpositions += nb_transpositions_in_panel;\n      // update permutations and apply them to A_0\n      for(Index i=k; i<k+bs; ++i)\n      {\n        Index piv = (row_transpositions[i] += internal::convert_index<PivIndex>(k));\n        A_0.row(i).swap(A_0.row(piv));\n      }\n\n      if(trows)\n      {\n        // apply permutations to A_2\n        for(Index i=k;i<k+bs; ++i)\n          A_2.row(i).swap(A_2.row(row_transpositions[i]));\n\n        // A12 = A11^-1 A12\n        A11.template triangularView<UnitLower>().solveInPlace(A12);\n\n        A22.noalias() -= A21 * A12;\n      }\n    }\n    return first_zero_pivot;\n  }\n};\n\n/** \\internal performs the LU decomposition with partial pivoting in-place.\n  */\ntemplate<typename MatrixType, typename TranspositionType>\nvoid partial_lu_inplace(MatrixType& lu, TranspositionType& row_transpositions, typename TranspositionType::StorageIndex& nb_transpositions)\n{\n  eigen_assert(lu.cols() == row_transpositions.size());\n  eigen_assert((&row_transpositions.coeffRef(1)-&row_transpositions.coeffRef(0)) == 1);\n\n  partial_lu_impl\n    <typename MatrixType::Scalar, MatrixType::Flags&RowMajorBit?RowMajor:ColMajor, typename TranspositionType::StorageIndex>\n    ::blocked_lu(lu.rows(), lu.cols(), &lu.coeffRef(0,0), lu.outerStride(), &row_transpositions.coeffRef(0), nb_transpositions);\n}\n\n} // end namespace internal\n\ntemplate<typename MatrixType>\nvoid PartialPivLU<MatrixType>::compute()\n{\n  check_template_parameters();\n\n  // the row permutation is stored as int indices, so just to be sure:\n  eigen_assert(m_lu.rows()<NumTraits<int>::highest());\n\n  m_l1_norm = m_lu.cwiseAbs().colwise().sum().maxCoeff();\n\n  eigen_assert(m_lu.rows() == m_lu.cols() && \"PartialPivLU is only for square (and moreover invertible) matrices\");\n  const Index size = m_lu.rows();\n\n  m_rowsTranspositions.resize(size);\n\n  typename TranspositionType::StorageIndex nb_transpositions;\n  internal::partial_lu_inplace(m_lu, m_rowsTranspositions, nb_transpositions);\n  m_det_p = (nb_transpositions%2) ? -1 : 1;\n\n  m_p = m_rowsTranspositions;\n\n  m_isInitialized = true;\n}\n\ntemplate<typename MatrixType>\ntypename PartialPivLU<MatrixType>::Scalar PartialPivLU<MatrixType>::determinant() const\n{\n  eigen_assert(m_isInitialized && \"PartialPivLU is not initialized.\");\n  return Scalar(m_det_p) * m_lu.diagonal().prod();\n}\n\n/** \\returns the matrix represented by the decomposition,\n * i.e., it returns the product: P^{-1} L U.\n * This function is provided for debug purpose. */\ntemplate<typename MatrixType>\nMatrixType PartialPivLU<MatrixType>::reconstructedMatrix() const\n{\n  eigen_assert(m_isInitialized && \"LU is not initialized.\");\n  // LU\n  MatrixType res = m_lu.template triangularView<UnitLower>().toDenseMatrix()\n                 * m_lu.template triangularView<Upper>();\n\n  // P^{-1}(LU)\n  res = m_p.inverse() * res;\n\n  return res;\n}\n\n/***** Implementation details *****************************************************/\n\nnamespace internal {\n\n/***** Implementation of inverse() *****************************************************/\ntemplate<typename DstXprType, typename MatrixType>\nstruct Assignment<DstXprType, Inverse<PartialPivLU<MatrixType> >, internal::assign_op<typename DstXprType::Scalar,typename PartialPivLU<MatrixType>::Scalar>, Dense2Dense>\n{\n  typedef PartialPivLU<MatrixType> LuType;\n  typedef Inverse<LuType> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename LuType::Scalar> &)\n  {\n    dst = src.nestedExpression().solve(MatrixType::Identity(src.rows(), src.cols()));\n  }\n};\n} // end namespace internal\n\n/******** MatrixBase methods *******/\n\n/** \\lu_module\n  *\n  * \\return the partial-pivoting LU decomposition of \\c *this.\n  *\n  * \\sa class PartialPivLU\n  */\ntemplate<typename Derived>\ninline const PartialPivLU<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::partialPivLu() const\n{\n  return PartialPivLU<PlainObject>(eval());\n}\n\n/** \\lu_module\n  *\n  * Synonym of partialPivLu().\n  *\n  * \\return the partial-pivoting LU decomposition of \\c *this.\n  *\n  * \\sa class PartialPivLU\n  */\ntemplate<typename Derived>\ninline const PartialPivLU<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::lu() const\n{\n  return PartialPivLU<PlainObject>(eval());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_PARTIALLU_H\n"
  },
  {
    "path": "include/externals/Eigen/src/LU/PartialPivLU_LAPACKE.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to LAPACKe\n *     LU decomposition with partial pivoting based on LAPACKE_?getrf function.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_PARTIALLU_LAPACK_H\n#define EIGEN_PARTIALLU_LAPACK_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/** \\internal Specialization for the data types supported by LAPACKe */\n\n#define EIGEN_LAPACKE_LU_PARTPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX) \\\ntemplate<int StorageOrder> \\\nstruct partial_lu_impl<EIGTYPE, StorageOrder, lapack_int> \\\n{ \\\n  /* \\internal performs the LU decomposition in-place of the matrix represented */ \\\n  static lapack_int blocked_lu(Index rows, Index cols, EIGTYPE* lu_data, Index luStride, lapack_int* row_transpositions, lapack_int& nb_transpositions, lapack_int maxBlockSize=256) \\\n  { \\\n    EIGEN_UNUSED_VARIABLE(maxBlockSize);\\\n    lapack_int matrix_order, first_zero_pivot; \\\n    lapack_int m, n, lda, *ipiv, info; \\\n    EIGTYPE* a; \\\n/* Set up parameters for ?getrf */ \\\n    matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \\\n    lda = convert_index<lapack_int>(luStride); \\\n    a = lu_data; \\\n    ipiv = row_transpositions; \\\n    m = convert_index<lapack_int>(rows); \\\n    n = convert_index<lapack_int>(cols); \\\n    nb_transpositions = 0; \\\n\\\n    info = LAPACKE_##LAPACKE_PREFIX##getrf( matrix_order, m, n, (LAPACKE_TYPE*)a, lda, ipiv ); \\\n\\\n    for(int i=0;i<m;i++) { ipiv[i]--; if (ipiv[i]!=i) nb_transpositions++; } \\\n\\\n    eigen_assert(info >= 0); \\\n/* something should be done with nb_transpositions */ \\\n\\\n    first_zero_pivot = info; \\\n    return first_zero_pivot; \\\n  } \\\n};\n\nEIGEN_LAPACKE_LU_PARTPIV(double, double, d)\nEIGEN_LAPACKE_LU_PARTPIV(float, float, s)\nEIGEN_LAPACKE_LU_PARTPIV(dcomplex, lapack_complex_double, z)\nEIGEN_LAPACKE_LU_PARTPIV(scomplex, lapack_complex_float,  c)\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_PARTIALLU_LAPACK_H\n"
  },
  {
    "path": "include/externals/Eigen/src/LU/arch/Inverse_SSE.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2001 Intel Corporation\n// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n// The SSE code for the 4x4 float and double matrix inverse in this file\n// comes from the following Intel's library:\n// http://software.intel.com/en-us/articles/optimized-matrix-library-for-use-with-the-intel-pentiumr-4-processors-sse2-instructions/\n//\n// Here is the respective copyright and license statement:\n//\n//   Copyright (c) 2001 Intel Corporation.\n//\n// Permition is granted to use, copy, distribute and prepare derivative works\n// of this library for any purpose and without fee, provided, that the above\n// copyright notice and this statement appear in all copies.\n// Intel makes no representations about the suitability of this software for\n// any purpose, and specifically disclaims all warranties.\n// See LEGAL.TXT for all the legal information.\n\n#ifndef EIGEN_INVERSE_SSE_H\n#define EIGEN_INVERSE_SSE_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename MatrixType, typename ResultType>\nstruct compute_inverse_size4<Architecture::SSE, float, MatrixType, ResultType>\n{\n  enum {\n    MatrixAlignment     = traits<MatrixType>::Alignment,\n    ResultAlignment     = traits<ResultType>::Alignment,\n    StorageOrdersMatch  = (MatrixType::Flags&RowMajorBit) == (ResultType::Flags&RowMajorBit)\n  };\n  typedef typename conditional<(MatrixType::Flags&LinearAccessBit),MatrixType const &,typename MatrixType::PlainObject>::type ActualMatrixType;\n  \n  static void run(const MatrixType& mat, ResultType& result)\n  {\n    ActualMatrixType matrix(mat);\n    EIGEN_ALIGN16 const unsigned int _Sign_PNNP[4] = { 0x00000000, 0x80000000, 0x80000000, 0x00000000 };\n\n    // Load the full matrix into registers\n    __m128 _L1 = matrix.template packet<MatrixAlignment>( 0);\n    __m128 _L2 = matrix.template packet<MatrixAlignment>( 4);\n    __m128 _L3 = matrix.template packet<MatrixAlignment>( 8);\n    __m128 _L4 = matrix.template packet<MatrixAlignment>(12);\n\n    // The inverse is calculated using \"Divide and Conquer\" technique. The\n    // original matrix is divide into four 2x2 sub-matrices. Since each\n    // register holds four matrix element, the smaller matrices are\n    // represented as a registers. Hence we get a better locality of the\n    // calculations.\n\n    __m128 A, B, C, D; // the four sub-matrices\n    if(!StorageOrdersMatch)\n    {\n      A = _mm_unpacklo_ps(_L1, _L2);\n      B = _mm_unpacklo_ps(_L3, _L4);\n      C = _mm_unpackhi_ps(_L1, _L2);\n      D = _mm_unpackhi_ps(_L3, _L4);\n    }\n    else\n    {\n      A = _mm_movelh_ps(_L1, _L2);\n      B = _mm_movehl_ps(_L2, _L1);\n      C = _mm_movelh_ps(_L3, _L4);\n      D = _mm_movehl_ps(_L4, _L3);\n    }\n\n    __m128 iA, iB, iC, iD,                 // partial inverse of the sub-matrices\n            DC, AB;\n    __m128 dA, dB, dC, dD;                 // determinant of the sub-matrices\n    __m128 det, d, d1, d2;\n    __m128 rd;                             // reciprocal of the determinant\n\n    //  AB = A# * B\n    AB = _mm_mul_ps(_mm_shuffle_ps(A,A,0x0F), B);\n    AB = _mm_sub_ps(AB,_mm_mul_ps(_mm_shuffle_ps(A,A,0xA5), _mm_shuffle_ps(B,B,0x4E)));\n    //  DC = D# * C\n    DC = _mm_mul_ps(_mm_shuffle_ps(D,D,0x0F), C);\n    DC = _mm_sub_ps(DC,_mm_mul_ps(_mm_shuffle_ps(D,D,0xA5), _mm_shuffle_ps(C,C,0x4E)));\n\n    //  dA = |A|\n    dA = _mm_mul_ps(_mm_shuffle_ps(A, A, 0x5F),A);\n    dA = _mm_sub_ss(dA, _mm_movehl_ps(dA,dA));\n    //  dB = |B|\n    dB = _mm_mul_ps(_mm_shuffle_ps(B, B, 0x5F),B);\n    dB = _mm_sub_ss(dB, _mm_movehl_ps(dB,dB));\n\n    //  dC = |C|\n    dC = _mm_mul_ps(_mm_shuffle_ps(C, C, 0x5F),C);\n    dC = _mm_sub_ss(dC, _mm_movehl_ps(dC,dC));\n    //  dD = |D|\n    dD = _mm_mul_ps(_mm_shuffle_ps(D, D, 0x5F),D);\n    dD = _mm_sub_ss(dD, _mm_movehl_ps(dD,dD));\n\n    //  d = trace(AB*DC) = trace(A#*B*D#*C)\n    d = _mm_mul_ps(_mm_shuffle_ps(DC,DC,0xD8),AB);\n\n    //  iD = C*A#*B\n    iD = _mm_mul_ps(_mm_shuffle_ps(C,C,0xA0), _mm_movelh_ps(AB,AB));\n    iD = _mm_add_ps(iD,_mm_mul_ps(_mm_shuffle_ps(C,C,0xF5), _mm_movehl_ps(AB,AB)));\n    //  iA = B*D#*C\n    iA = _mm_mul_ps(_mm_shuffle_ps(B,B,0xA0), _mm_movelh_ps(DC,DC));\n    iA = _mm_add_ps(iA,_mm_mul_ps(_mm_shuffle_ps(B,B,0xF5), _mm_movehl_ps(DC,DC)));\n\n    //  d = trace(AB*DC) = trace(A#*B*D#*C) [continue]\n    d  = _mm_add_ps(d, _mm_movehl_ps(d, d));\n    d  = _mm_add_ss(d, _mm_shuffle_ps(d, d, 1));\n    d1 = _mm_mul_ss(dA,dD);\n    d2 = _mm_mul_ss(dB,dC);\n\n    //  iD = D*|A| - C*A#*B\n    iD = _mm_sub_ps(_mm_mul_ps(D,_mm_shuffle_ps(dA,dA,0)), iD);\n\n    //  iA = A*|D| - B*D#*C;\n    iA = _mm_sub_ps(_mm_mul_ps(A,_mm_shuffle_ps(dD,dD,0)), iA);\n\n    //  det = |A|*|D| + |B|*|C| - trace(A#*B*D#*C)\n    det = _mm_sub_ss(_mm_add_ss(d1,d2),d);\n    rd  = _mm_div_ss(_mm_set_ss(1.0f), det);\n\n//     #ifdef ZERO_SINGULAR\n//         rd = _mm_and_ps(_mm_cmpneq_ss(det,_mm_setzero_ps()), rd);\n//     #endif\n\n    //  iB = D * (A#B)# = D*B#*A\n    iB = _mm_mul_ps(D, _mm_shuffle_ps(AB,AB,0x33));\n    iB = _mm_sub_ps(iB, _mm_mul_ps(_mm_shuffle_ps(D,D,0xB1), _mm_shuffle_ps(AB,AB,0x66)));\n    //  iC = A * (D#C)# = A*C#*D\n    iC = _mm_mul_ps(A, _mm_shuffle_ps(DC,DC,0x33));\n    iC = _mm_sub_ps(iC, _mm_mul_ps(_mm_shuffle_ps(A,A,0xB1), _mm_shuffle_ps(DC,DC,0x66)));\n\n    rd = _mm_shuffle_ps(rd,rd,0);\n    rd = _mm_xor_ps(rd, _mm_load_ps((float*)_Sign_PNNP));\n\n    //  iB = C*|B| - D*B#*A\n    iB = _mm_sub_ps(_mm_mul_ps(C,_mm_shuffle_ps(dB,dB,0)), iB);\n\n    //  iC = B*|C| - A*C#*D;\n    iC = _mm_sub_ps(_mm_mul_ps(B,_mm_shuffle_ps(dC,dC,0)), iC);\n\n    //  iX = iX / det\n    iA = _mm_mul_ps(rd,iA);\n    iB = _mm_mul_ps(rd,iB);\n    iC = _mm_mul_ps(rd,iC);\n    iD = _mm_mul_ps(rd,iD);\n\n    Index res_stride = result.outerStride();\n    float* res = result.data();\n    pstoret<float, Packet4f, ResultAlignment>(res+0,            _mm_shuffle_ps(iA,iB,0x77));\n    pstoret<float, Packet4f, ResultAlignment>(res+res_stride,   _mm_shuffle_ps(iA,iB,0x22));\n    pstoret<float, Packet4f, ResultAlignment>(res+2*res_stride, _mm_shuffle_ps(iC,iD,0x77));\n    pstoret<float, Packet4f, ResultAlignment>(res+3*res_stride, _mm_shuffle_ps(iC,iD,0x22));\n  }\n\n};\n\ntemplate<typename MatrixType, typename ResultType>\nstruct compute_inverse_size4<Architecture::SSE, double, MatrixType, ResultType>\n{\n  enum {\n    MatrixAlignment     = traits<MatrixType>::Alignment,\n    ResultAlignment     = traits<ResultType>::Alignment,\n    StorageOrdersMatch  = (MatrixType::Flags&RowMajorBit) == (ResultType::Flags&RowMajorBit)\n  };\n  typedef typename conditional<(MatrixType::Flags&LinearAccessBit),MatrixType const &,typename MatrixType::PlainObject>::type ActualMatrixType;\n  \n  static void run(const MatrixType& mat, ResultType& result)\n  {\n    ActualMatrixType matrix(mat);\n    const __m128d _Sign_NP = _mm_castsi128_pd(_mm_set_epi32(0x0,0x0,0x80000000,0x0));\n    const __m128d _Sign_PN = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));\n\n    // The inverse is calculated using \"Divide and Conquer\" technique. The\n    // original matrix is divide into four 2x2 sub-matrices. Since each\n    // register of the matrix holds two elements, the smaller matrices are\n    // consisted of two registers. Hence we get a better locality of the\n    // calculations.\n\n    // the four sub-matrices\n    __m128d A1, A2, B1, B2, C1, C2, D1, D2;\n    \n    if(StorageOrdersMatch)\n    {\n      A1 = matrix.template packet<MatrixAlignment>( 0); B1 = matrix.template packet<MatrixAlignment>( 2);\n      A2 = matrix.template packet<MatrixAlignment>( 4); B2 = matrix.template packet<MatrixAlignment>( 6);\n      C1 = matrix.template packet<MatrixAlignment>( 8); D1 = matrix.template packet<MatrixAlignment>(10);\n      C2 = matrix.template packet<MatrixAlignment>(12); D2 = matrix.template packet<MatrixAlignment>(14);\n    }\n    else\n    {\n      __m128d tmp;\n      A1 = matrix.template packet<MatrixAlignment>( 0); C1 = matrix.template packet<MatrixAlignment>( 2);\n      A2 = matrix.template packet<MatrixAlignment>( 4); C2 = matrix.template packet<MatrixAlignment>( 6);\n      tmp = A1;\n      A1 = _mm_unpacklo_pd(A1,A2);\n      A2 = _mm_unpackhi_pd(tmp,A2);\n      tmp = C1;\n      C1 = _mm_unpacklo_pd(C1,C2);\n      C2 = _mm_unpackhi_pd(tmp,C2);\n      \n      B1 = matrix.template packet<MatrixAlignment>( 8); D1 = matrix.template packet<MatrixAlignment>(10);\n      B2 = matrix.template packet<MatrixAlignment>(12); D2 = matrix.template packet<MatrixAlignment>(14);\n      tmp = B1;\n      B1 = _mm_unpacklo_pd(B1,B2);\n      B2 = _mm_unpackhi_pd(tmp,B2);\n      tmp = D1;\n      D1 = _mm_unpacklo_pd(D1,D2);\n      D2 = _mm_unpackhi_pd(tmp,D2);\n    }\n    \n    __m128d iA1, iA2, iB1, iB2, iC1, iC2, iD1, iD2,     // partial invese of the sub-matrices\n            DC1, DC2, AB1, AB2;\n    __m128d dA, dB, dC, dD;     // determinant of the sub-matrices\n    __m128d det, d1, d2, rd;\n\n    //  dA = |A|\n    dA = _mm_shuffle_pd(A2, A2, 1);\n    dA = _mm_mul_pd(A1, dA);\n    dA = _mm_sub_sd(dA, _mm_shuffle_pd(dA,dA,3));\n    //  dB = |B|\n    dB = _mm_shuffle_pd(B2, B2, 1);\n    dB = _mm_mul_pd(B1, dB);\n    dB = _mm_sub_sd(dB, _mm_shuffle_pd(dB,dB,3));\n\n    //  AB = A# * B\n    AB1 = _mm_mul_pd(B1, _mm_shuffle_pd(A2,A2,3));\n    AB2 = _mm_mul_pd(B2, _mm_shuffle_pd(A1,A1,0));\n    AB1 = _mm_sub_pd(AB1, _mm_mul_pd(B2, _mm_shuffle_pd(A1,A1,3)));\n    AB2 = _mm_sub_pd(AB2, _mm_mul_pd(B1, _mm_shuffle_pd(A2,A2,0)));\n\n    //  dC = |C|\n    dC = _mm_shuffle_pd(C2, C2, 1);\n    dC = _mm_mul_pd(C1, dC);\n    dC = _mm_sub_sd(dC, _mm_shuffle_pd(dC,dC,3));\n    //  dD = |D|\n    dD = _mm_shuffle_pd(D2, D2, 1);\n    dD = _mm_mul_pd(D1, dD);\n    dD = _mm_sub_sd(dD, _mm_shuffle_pd(dD,dD,3));\n\n    //  DC = D# * C\n    DC1 = _mm_mul_pd(C1, _mm_shuffle_pd(D2,D2,3));\n    DC2 = _mm_mul_pd(C2, _mm_shuffle_pd(D1,D1,0));\n    DC1 = _mm_sub_pd(DC1, _mm_mul_pd(C2, _mm_shuffle_pd(D1,D1,3)));\n    DC2 = _mm_sub_pd(DC2, _mm_mul_pd(C1, _mm_shuffle_pd(D2,D2,0)));\n\n    //  rd = trace(AB*DC) = trace(A#*B*D#*C)\n    d1 = _mm_mul_pd(AB1, _mm_shuffle_pd(DC1, DC2, 0));\n    d2 = _mm_mul_pd(AB2, _mm_shuffle_pd(DC1, DC2, 3));\n    rd = _mm_add_pd(d1, d2);\n    rd = _mm_add_sd(rd, _mm_shuffle_pd(rd, rd,3));\n\n    //  iD = C*A#*B\n    iD1 = _mm_mul_pd(AB1, _mm_shuffle_pd(C1,C1,0));\n    iD2 = _mm_mul_pd(AB1, _mm_shuffle_pd(C2,C2,0));\n    iD1 = _mm_add_pd(iD1, _mm_mul_pd(AB2, _mm_shuffle_pd(C1,C1,3)));\n    iD2 = _mm_add_pd(iD2, _mm_mul_pd(AB2, _mm_shuffle_pd(C2,C2,3)));\n\n    //  iA = B*D#*C\n    iA1 = _mm_mul_pd(DC1, _mm_shuffle_pd(B1,B1,0));\n    iA2 = _mm_mul_pd(DC1, _mm_shuffle_pd(B2,B2,0));\n    iA1 = _mm_add_pd(iA1, _mm_mul_pd(DC2, _mm_shuffle_pd(B1,B1,3)));\n    iA2 = _mm_add_pd(iA2, _mm_mul_pd(DC2, _mm_shuffle_pd(B2,B2,3)));\n\n    //  iD = D*|A| - C*A#*B\n    dA = _mm_shuffle_pd(dA,dA,0);\n    iD1 = _mm_sub_pd(_mm_mul_pd(D1, dA), iD1);\n    iD2 = _mm_sub_pd(_mm_mul_pd(D2, dA), iD2);\n\n    //  iA = A*|D| - B*D#*C;\n    dD = _mm_shuffle_pd(dD,dD,0);\n    iA1 = _mm_sub_pd(_mm_mul_pd(A1, dD), iA1);\n    iA2 = _mm_sub_pd(_mm_mul_pd(A2, dD), iA2);\n\n    d1 = _mm_mul_sd(dA, dD);\n    d2 = _mm_mul_sd(dB, dC);\n\n    //  iB = D * (A#B)# = D*B#*A\n    iB1 = _mm_mul_pd(D1, _mm_shuffle_pd(AB2,AB1,1));\n    iB2 = _mm_mul_pd(D2, _mm_shuffle_pd(AB2,AB1,1));\n    iB1 = _mm_sub_pd(iB1, _mm_mul_pd(_mm_shuffle_pd(D1,D1,1), _mm_shuffle_pd(AB2,AB1,2)));\n    iB2 = _mm_sub_pd(iB2, _mm_mul_pd(_mm_shuffle_pd(D2,D2,1), _mm_shuffle_pd(AB2,AB1,2)));\n\n    //  det = |A|*|D| + |B|*|C| - trace(A#*B*D#*C)\n    det = _mm_add_sd(d1, d2);\n    det = _mm_sub_sd(det, rd);\n\n    //  iC = A * (D#C)# = A*C#*D\n    iC1 = _mm_mul_pd(A1, _mm_shuffle_pd(DC2,DC1,1));\n    iC2 = _mm_mul_pd(A2, _mm_shuffle_pd(DC2,DC1,1));\n    iC1 = _mm_sub_pd(iC1, _mm_mul_pd(_mm_shuffle_pd(A1,A1,1), _mm_shuffle_pd(DC2,DC1,2)));\n    iC2 = _mm_sub_pd(iC2, _mm_mul_pd(_mm_shuffle_pd(A2,A2,1), _mm_shuffle_pd(DC2,DC1,2)));\n\n    rd = _mm_div_sd(_mm_set_sd(1.0), det);\n//     #ifdef ZERO_SINGULAR\n//         rd = _mm_and_pd(_mm_cmpneq_sd(det,_mm_setzero_pd()), rd);\n//     #endif\n    rd = _mm_shuffle_pd(rd,rd,0);\n\n    //  iB = C*|B| - D*B#*A\n    dB = _mm_shuffle_pd(dB,dB,0);\n    iB1 = _mm_sub_pd(_mm_mul_pd(C1, dB), iB1);\n    iB2 = _mm_sub_pd(_mm_mul_pd(C2, dB), iB2);\n\n    d1 = _mm_xor_pd(rd, _Sign_PN);\n    d2 = _mm_xor_pd(rd, _Sign_NP);\n\n    //  iC = B*|C| - A*C#*D;\n    dC = _mm_shuffle_pd(dC,dC,0);\n    iC1 = _mm_sub_pd(_mm_mul_pd(B1, dC), iC1);\n    iC2 = _mm_sub_pd(_mm_mul_pd(B2, dC), iC2);\n\n    Index res_stride = result.outerStride();\n    double* res = result.data();\n    pstoret<double, Packet2d, ResultAlignment>(res+0,             _mm_mul_pd(_mm_shuffle_pd(iA2, iA1, 3), d1));\n    pstoret<double, Packet2d, ResultAlignment>(res+res_stride,    _mm_mul_pd(_mm_shuffle_pd(iA2, iA1, 0), d2));\n    pstoret<double, Packet2d, ResultAlignment>(res+2,             _mm_mul_pd(_mm_shuffle_pd(iB2, iB1, 3), d1));\n    pstoret<double, Packet2d, ResultAlignment>(res+res_stride+2,  _mm_mul_pd(_mm_shuffle_pd(iB2, iB1, 0), d2));\n    pstoret<double, Packet2d, ResultAlignment>(res+2*res_stride,  _mm_mul_pd(_mm_shuffle_pd(iC2, iC1, 3), d1));\n    pstoret<double, Packet2d, ResultAlignment>(res+3*res_stride,  _mm_mul_pd(_mm_shuffle_pd(iC2, iC1, 0), d2));\n    pstoret<double, Packet2d, ResultAlignment>(res+2*res_stride+2,_mm_mul_pd(_mm_shuffle_pd(iD2, iD1, 3), d1));\n    pstoret<double, Packet2d, ResultAlignment>(res+3*res_stride+2,_mm_mul_pd(_mm_shuffle_pd(iD2, iD1, 0), d2));\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_INVERSE_SSE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/MetisSupport/MetisSupport.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n#ifndef METIS_SUPPORT_H\n#define METIS_SUPPORT_H\n\nnamespace Eigen {\n/**\n * Get the fill-reducing ordering from the METIS package\n * \n * If A is the original matrix and Ap is the permuted matrix, \n * the fill-reducing permutation is defined as follows :\n * Row (column) i of A is the matperm(i) row (column) of Ap. \n * WARNING: As computed by METIS, this corresponds to the vector iperm (instead of perm)\n */\ntemplate <typename StorageIndex>\nclass MetisOrdering\n{\npublic:\n  typedef PermutationMatrix<Dynamic,Dynamic,StorageIndex> PermutationType;\n  typedef Matrix<StorageIndex,Dynamic,1> IndexVector; \n  \n  template <typename MatrixType>\n  void get_symmetrized_graph(const MatrixType& A)\n  {\n    Index m = A.cols(); \n    eigen_assert((A.rows() == A.cols()) && \"ONLY FOR SQUARED MATRICES\");\n    // Get the transpose of the input matrix \n    MatrixType At = A.transpose(); \n    // Get the number of nonzeros elements in each row/col of At+A\n    Index TotNz = 0; \n    IndexVector visited(m); \n    visited.setConstant(-1); \n    for (StorageIndex j = 0; j < m; j++)\n    {\n      // Compute the union structure of of A(j,:) and At(j,:)\n      visited(j) = j; // Do not include the diagonal element\n      // Get the nonzeros in row/column j of A\n      for (typename MatrixType::InnerIterator it(A, j); it; ++it)\n      {\n        Index idx = it.index(); // Get the row index (for column major) or column index (for row major)\n        if (visited(idx) != j ) \n        {\n          visited(idx) = j; \n          ++TotNz; \n        }\n      }\n      //Get the nonzeros in row/column j of At\n      for (typename MatrixType::InnerIterator it(At, j); it; ++it)\n      {\n        Index idx = it.index(); \n        if(visited(idx) != j)\n        {\n          visited(idx) = j; \n          ++TotNz; \n        }\n      }\n    }\n    // Reserve place for A + At\n    m_indexPtr.resize(m+1);\n    m_innerIndices.resize(TotNz); \n\n    // Now compute the real adjacency list of each column/row \n    visited.setConstant(-1); \n    StorageIndex CurNz = 0; \n    for (StorageIndex j = 0; j < m; j++)\n    {\n      m_indexPtr(j) = CurNz; \n      \n      visited(j) = j; // Do not include the diagonal element\n      // Add the pattern of row/column j of A to A+At\n      for (typename MatrixType::InnerIterator it(A,j); it; ++it)\n      {\n        StorageIndex idx = it.index(); // Get the row index (for column major) or column index (for row major)\n        if (visited(idx) != j ) \n        {\n          visited(idx) = j; \n          m_innerIndices(CurNz) = idx; \n          CurNz++; \n        }\n      }\n      //Add the pattern of row/column j of At to A+At\n      for (typename MatrixType::InnerIterator it(At, j); it; ++it)\n      {\n        StorageIndex idx = it.index(); \n        if(visited(idx) != j)\n        {\n          visited(idx) = j; \n          m_innerIndices(CurNz) = idx; \n          ++CurNz; \n        }\n      }\n    }\n    m_indexPtr(m) = CurNz;    \n  }\n  \n  template <typename MatrixType>\n  void operator() (const MatrixType& A, PermutationType& matperm)\n  {\n     StorageIndex m = internal::convert_index<StorageIndex>(A.cols()); // must be StorageIndex, because it is passed by address to METIS\n     IndexVector perm(m),iperm(m); \n    // First, symmetrize the matrix graph. \n     get_symmetrized_graph(A); \n     int output_error;\n     \n     // Call the fill-reducing routine from METIS \n     output_error = METIS_NodeND(&m, m_indexPtr.data(), m_innerIndices.data(), NULL, NULL, perm.data(), iperm.data());\n     \n    if(output_error != METIS_OK) \n    {\n      //FIXME The ordering interface should define a class of possible errors \n     std::cerr << \"ERROR WHILE CALLING THE METIS PACKAGE \\n\"; \n     return; \n    }\n    \n    // Get the fill-reducing permutation \n    //NOTE:  If Ap is the permuted matrix then perm and iperm vectors are defined as follows \n    // Row (column) i of Ap is the perm(i) row(column) of A, and row (column) i of A is the iperm(i) row(column) of Ap\n    \n     matperm.resize(m);\n     for (int j = 0; j < m; j++)\n       matperm.indices()(iperm(j)) = j;\n   \n  }\n  \n  protected:\n    IndexVector m_indexPtr; // Pointer to the adjacenccy list of each row/column\n    IndexVector m_innerIndices; // Adjacency list \n};\n\n}// end namespace eigen \n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/OrderingMethods/Amd.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n\n/*\n\nNOTE: this routine has been adapted from the CSparse library:\n\nCopyright (c) 2006, Timothy A. Davis.\nhttp://www.suitesparse.com\n\nCSparse is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 2.1 of the License, or (at your option) any later version.\n\nCSparse is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this Module; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n*/\n\n#include \"../Core/util/NonMPL2.h\"\n\n#ifndef EIGEN_SPARSE_AMD_H\n#define EIGEN_SPARSE_AMD_H\n\nnamespace Eigen { \n\nnamespace internal {\n  \ntemplate<typename T> inline T amd_flip(const T& i) { return -i-2; }\ntemplate<typename T> inline T amd_unflip(const T& i) { return i<0 ? amd_flip(i) : i; }\ntemplate<typename T0, typename T1> inline bool amd_marked(const T0* w, const T1& j) { return w[j]<0; }\ntemplate<typename T0, typename T1> inline void amd_mark(const T0* w, const T1& j) { return w[j] = amd_flip(w[j]); }\n\n/* clear w */\ntemplate<typename StorageIndex>\nstatic StorageIndex cs_wclear (StorageIndex mark, StorageIndex lemax, StorageIndex *w, StorageIndex n)\n{\n  StorageIndex k;\n  if(mark < 2 || (mark + lemax < 0))\n  {\n    for(k = 0; k < n; k++)\n      if(w[k] != 0)\n        w[k] = 1;\n    mark = 2;\n  }\n  return (mark);     /* at this point, w[0..n-1] < mark holds */\n}\n\n/* depth-first search and postorder of a tree rooted at node j */\ntemplate<typename StorageIndex>\nStorageIndex cs_tdfs(StorageIndex j, StorageIndex k, StorageIndex *head, const StorageIndex *next, StorageIndex *post, StorageIndex *stack)\n{\n  StorageIndex i, p, top = 0;\n  if(!head || !next || !post || !stack) return (-1);    /* check inputs */\n  stack[0] = j;                 /* place j on the stack */\n  while (top >= 0)                /* while (stack is not empty) */\n  {\n    p = stack[top];           /* p = top of stack */\n    i = head[p];              /* i = youngest child of p */\n    if(i == -1)\n    {\n      top--;                 /* p has no unordered children left */\n      post[k++] = p;        /* node p is the kth postordered node */\n    }\n    else\n    {\n      head[p] = next[i];   /* remove i from children of p */\n      stack[++top] = i;     /* start dfs on child node i */\n    }\n  }\n  return k;\n}\n\n\n/** \\internal\n  * \\ingroup OrderingMethods_Module \n  * Approximate minimum degree ordering algorithm.\n  *\n  * \\param[in] C the input selfadjoint matrix stored in compressed column major format.\n  * \\param[out] perm the permutation P reducing the fill-in of the input matrix \\a C\n  *\n  * Note that the input matrix \\a C must be complete, that is both the upper and lower parts have to be stored, as well as the diagonal entries.\n  * On exit the values of C are destroyed */\ntemplate<typename Scalar, typename StorageIndex>\nvoid minimum_degree_ordering(SparseMatrix<Scalar,ColMajor,StorageIndex>& C, PermutationMatrix<Dynamic,Dynamic,StorageIndex>& perm)\n{\n  using std::sqrt;\n  \n  StorageIndex d, dk, dext, lemax = 0, e, elenk, eln, i, j, k, k1,\n                k2, k3, jlast, ln, dense, nzmax, mindeg = 0, nvi, nvj, nvk, mark, wnvi,\n                ok, nel = 0, p, p1, p2, p3, p4, pj, pk, pk1, pk2, pn, q, t, h;\n  \n  StorageIndex n = StorageIndex(C.cols());\n  dense = std::max<StorageIndex> (16, StorageIndex(10 * sqrt(double(n))));   /* find dense threshold */\n  dense = (std::min)(n-2, dense);\n  \n  StorageIndex cnz = StorageIndex(C.nonZeros());\n  perm.resize(n+1);\n  t = cnz + cnz/5 + 2*n;                 /* add elbow room to C */\n  C.resizeNonZeros(t);\n  \n  // get workspace\n  ei_declare_aligned_stack_constructed_variable(StorageIndex,W,8*(n+1),0);\n  StorageIndex* len     = W;\n  StorageIndex* nv      = W +   (n+1);\n  StorageIndex* next    = W + 2*(n+1);\n  StorageIndex* head    = W + 3*(n+1);\n  StorageIndex* elen    = W + 4*(n+1);\n  StorageIndex* degree  = W + 5*(n+1);\n  StorageIndex* w       = W + 6*(n+1);\n  StorageIndex* hhead   = W + 7*(n+1);\n  StorageIndex* last    = perm.indices().data();                              /* use P as workspace for last */\n  \n  /* --- Initialize quotient graph ---------------------------------------- */\n  StorageIndex* Cp = C.outerIndexPtr();\n  StorageIndex* Ci = C.innerIndexPtr();\n  for(k = 0; k < n; k++)\n    len[k] = Cp[k+1] - Cp[k];\n  len[n] = 0;\n  nzmax = t;\n  \n  for(i = 0; i <= n; i++)\n  {\n    head[i]   = -1;                     // degree list i is empty\n    last[i]   = -1;\n    next[i]   = -1;\n    hhead[i]  = -1;                     // hash list i is empty \n    nv[i]     = 1;                      // node i is just one node\n    w[i]      = 1;                      // node i is alive\n    elen[i]   = 0;                      // Ek of node i is empty\n    degree[i] = len[i];                 // degree of node i\n  }\n  mark = internal::cs_wclear<StorageIndex>(0, 0, w, n);         /* clear w */\n  \n  /* --- Initialize degree lists ------------------------------------------ */\n  for(i = 0; i < n; i++)\n  {\n    bool has_diag = false;\n    for(p = Cp[i]; p<Cp[i+1]; ++p)\n      if(Ci[p]==i)\n      {\n        has_diag = true;\n        break;\n      }\n   \n    d = degree[i];\n    if(d == 1 && has_diag)           /* node i is empty */\n    {\n      elen[i] = -2;                 /* element i is dead */\n      nel++;\n      Cp[i] = -1;                   /* i is a root of assembly tree */\n      w[i] = 0;\n    }\n    else if(d > dense || !has_diag)  /* node i is dense or has no structural diagonal element */\n    {\n      nv[i] = 0;                    /* absorb i into element n */\n      elen[i] = -1;                 /* node i is dead */\n      nel++;\n      Cp[i] = amd_flip (n);\n      nv[n]++;\n    }\n    else\n    {\n      if(head[d] != -1) last[head[d]] = i;\n      next[i] = head[d];           /* put node i in degree list d */\n      head[d] = i;\n    }\n  }\n  \n  elen[n] = -2;                         /* n is a dead element */\n  Cp[n] = -1;                           /* n is a root of assembly tree */\n  w[n] = 0;                             /* n is a dead element */\n  \n  while (nel < n)                         /* while (selecting pivots) do */\n  {\n    /* --- Select node of minimum approximate degree -------------------- */\n    for(k = -1; mindeg < n && (k = head[mindeg]) == -1; mindeg++) {}\n    if(next[k] != -1) last[next[k]] = -1;\n    head[mindeg] = next[k];          /* remove k from degree list */\n    elenk = elen[k];                  /* elenk = |Ek| */\n    nvk = nv[k];                      /* # of nodes k represents */\n    nel += nvk;                        /* nv[k] nodes of A eliminated */\n    \n    /* --- Garbage collection ------------------------------------------- */\n    if(elenk > 0 && cnz + mindeg >= nzmax)\n    {\n      for(j = 0; j < n; j++)\n      {\n        if((p = Cp[j]) >= 0)      /* j is a live node or element */\n        {\n          Cp[j] = Ci[p];          /* save first entry of object */\n          Ci[p] = amd_flip (j);    /* first entry is now amd_flip(j) */\n        }\n      }\n      for(q = 0, p = 0; p < cnz; ) /* scan all of memory */\n      {\n        if((j = amd_flip (Ci[p++])) >= 0)  /* found object j */\n        {\n          Ci[q] = Cp[j];       /* restore first entry of object */\n          Cp[j] = q++;          /* new pointer to object j */\n          for(k3 = 0; k3 < len[j]-1; k3++) Ci[q++] = Ci[p++];\n        }\n      }\n      cnz = q;                       /* Ci[cnz...nzmax-1] now free */\n    }\n    \n    /* --- Construct new element ---------------------------------------- */\n    dk = 0;\n    nv[k] = -nvk;                     /* flag k as in Lk */\n    p = Cp[k];\n    pk1 = (elenk == 0) ? p : cnz;      /* do in place if elen[k] == 0 */\n    pk2 = pk1;\n    for(k1 = 1; k1 <= elenk + 1; k1++)\n    {\n      if(k1 > elenk)\n      {\n        e = k;                     /* search the nodes in k */\n        pj = p;                    /* list of nodes starts at Ci[pj]*/\n        ln = len[k] - elenk;      /* length of list of nodes in k */\n      }\n      else\n      {\n        e = Ci[p++];              /* search the nodes in e */\n        pj = Cp[e];\n        ln = len[e];              /* length of list of nodes in e */\n      }\n      for(k2 = 1; k2 <= ln; k2++)\n      {\n        i = Ci[pj++];\n        if((nvi = nv[i]) <= 0) continue; /* node i dead, or seen */\n        dk += nvi;                 /* degree[Lk] += size of node i */\n        nv[i] = -nvi;             /* negate nv[i] to denote i in Lk*/\n        Ci[pk2++] = i;            /* place i in Lk */\n        if(next[i] != -1) last[next[i]] = last[i];\n        if(last[i] != -1)         /* remove i from degree list */\n        {\n          next[last[i]] = next[i];\n        }\n        else\n        {\n          head[degree[i]] = next[i];\n        }\n      }\n      if(e != k)\n      {\n        Cp[e] = amd_flip (k);      /* absorb e into k */\n        w[e] = 0;                 /* e is now a dead element */\n      }\n    }\n    if(elenk != 0) cnz = pk2;         /* Ci[cnz...nzmax] is free */\n    degree[k] = dk;                   /* external degree of k - |Lk\\i| */\n    Cp[k] = pk1;                      /* element k is in Ci[pk1..pk2-1] */\n    len[k] = pk2 - pk1;\n    elen[k] = -2;                     /* k is now an element */\n    \n    /* --- Find set differences ----------------------------------------- */\n    mark = internal::cs_wclear<StorageIndex>(mark, lemax, w, n);  /* clear w if necessary */\n    for(pk = pk1; pk < pk2; pk++)    /* scan 1: find |Le\\Lk| */\n    {\n      i = Ci[pk];\n      if((eln = elen[i]) <= 0) continue;/* skip if elen[i] empty */\n      nvi = -nv[i];                      /* nv[i] was negated */\n      wnvi = mark - nvi;\n      for(p = Cp[i]; p <= Cp[i] + eln - 1; p++)  /* scan Ei */\n      {\n        e = Ci[p];\n        if(w[e] >= mark)\n        {\n          w[e] -= nvi;          /* decrement |Le\\Lk| */\n        }\n        else if(w[e] != 0)        /* ensure e is a live element */\n        {\n          w[e] = degree[e] + wnvi; /* 1st time e seen in scan 1 */\n        }\n      }\n    }\n    \n    /* --- Degree update ------------------------------------------------ */\n    for(pk = pk1; pk < pk2; pk++)    /* scan2: degree update */\n    {\n      i = Ci[pk];                   /* consider node i in Lk */\n      p1 = Cp[i];\n      p2 = p1 + elen[i] - 1;\n      pn = p1;\n      for(h = 0, d = 0, p = p1; p <= p2; p++)    /* scan Ei */\n      {\n        e = Ci[p];\n        if(w[e] != 0)             /* e is an unabsorbed element */\n        {\n          dext = w[e] - mark;   /* dext = |Le\\Lk| */\n          if(dext > 0)\n          {\n            d += dext;         /* sum up the set differences */\n            Ci[pn++] = e;     /* keep e in Ei */\n            h += e;            /* compute the hash of node i */\n          }\n          else\n          {\n            Cp[e] = amd_flip (k);  /* aggressive absorb. e->k */\n            w[e] = 0;             /* e is a dead element */\n          }\n        }\n      }\n      elen[i] = pn - p1 + 1;        /* elen[i] = |Ei| */\n      p3 = pn;\n      p4 = p1 + len[i];\n      for(p = p2 + 1; p < p4; p++) /* prune edges in Ai */\n      {\n        j = Ci[p];\n        if((nvj = nv[j]) <= 0) continue; /* node j dead or in Lk */\n        d += nvj;                  /* degree(i) += |j| */\n        Ci[pn++] = j;             /* place j in node list of i */\n        h += j;                    /* compute hash for node i */\n      }\n      if(d == 0)                     /* check for mass elimination */\n      {\n        Cp[i] = amd_flip (k);      /* absorb i into k */\n        nvi = -nv[i];\n        dk -= nvi;                 /* |Lk| -= |i| */\n        nvk += nvi;                /* |k| += nv[i] */\n        nel += nvi;\n        nv[i] = 0;\n        elen[i] = -1;             /* node i is dead */\n      }\n      else\n      {\n        degree[i] = std::min<StorageIndex> (degree[i], d);   /* update degree(i) */\n        Ci[pn] = Ci[p3];         /* move first node to end */\n        Ci[p3] = Ci[p1];         /* move 1st el. to end of Ei */\n        Ci[p1] = k;               /* add k as 1st element in of Ei */\n        len[i] = pn - p1 + 1;     /* new len of adj. list of node i */\n        h %= n;                    /* finalize hash of i */\n        next[i] = hhead[h];      /* place i in hash bucket */\n        hhead[h] = i;\n        last[i] = h;      /* save hash of i in last[i] */\n      }\n    }                                   /* scan2 is done */\n    degree[k] = dk;                   /* finalize |Lk| */\n    lemax = std::max<StorageIndex>(lemax, dk);\n    mark = internal::cs_wclear<StorageIndex>(mark+lemax, lemax, w, n);    /* clear w */\n    \n    /* --- Supernode detection ------------------------------------------ */\n    for(pk = pk1; pk < pk2; pk++)\n    {\n      i = Ci[pk];\n      if(nv[i] >= 0) continue;         /* skip if i is dead */\n      h = last[i];                      /* scan hash bucket of node i */\n      i = hhead[h];\n      hhead[h] = -1;                    /* hash bucket will be empty */\n      for(; i != -1 && next[i] != -1; i = next[i], mark++)\n      {\n        ln = len[i];\n        eln = elen[i];\n        for(p = Cp[i]+1; p <= Cp[i] + ln-1; p++) w[Ci[p]] = mark;\n        jlast = i;\n        for(j = next[i]; j != -1; ) /* compare i with all j */\n        {\n          ok = (len[j] == ln) && (elen[j] == eln);\n          for(p = Cp[j] + 1; ok && p <= Cp[j] + ln - 1; p++)\n          {\n            if(w[Ci[p]] != mark) ok = 0;    /* compare i and j*/\n          }\n          if(ok)                     /* i and j are identical */\n          {\n            Cp[j] = amd_flip (i);  /* absorb j into i */\n            nv[i] += nv[j];\n            nv[j] = 0;\n            elen[j] = -1;         /* node j is dead */\n            j = next[j];          /* delete j from hash bucket */\n            next[jlast] = j;\n          }\n          else\n          {\n            jlast = j;             /* j and i are different */\n            j = next[j];\n          }\n        }\n      }\n    }\n    \n    /* --- Finalize new element------------------------------------------ */\n    for(p = pk1, pk = pk1; pk < pk2; pk++)   /* finalize Lk */\n    {\n      i = Ci[pk];\n      if((nvi = -nv[i]) <= 0) continue;/* skip if i is dead */\n      nv[i] = nvi;                      /* restore nv[i] */\n      d = degree[i] + dk - nvi;         /* compute external degree(i) */\n      d = std::min<StorageIndex> (d, n - nel - nvi);\n      if(head[d] != -1) last[head[d]] = i;\n      next[i] = head[d];               /* put i back in degree list */\n      last[i] = -1;\n      head[d] = i;\n      mindeg = std::min<StorageIndex> (mindeg, d);       /* find new minimum degree */\n      degree[i] = d;\n      Ci[p++] = i;                      /* place i in Lk */\n    }\n    nv[k] = nvk;                      /* # nodes absorbed into k */\n    if((len[k] = p-pk1) == 0)         /* length of adj list of element k*/\n    {\n      Cp[k] = -1;                   /* k is a root of the tree */\n      w[k] = 0;                     /* k is now a dead element */\n    }\n    if(elenk != 0) cnz = p;           /* free unused space in Lk */\n  }\n  \n  /* --- Postordering ----------------------------------------------------- */\n  for(i = 0; i < n; i++) Cp[i] = amd_flip (Cp[i]);/* fix assembly tree */\n  for(j = 0; j <= n; j++) head[j] = -1;\n  for(j = n; j >= 0; j--)              /* place unordered nodes in lists */\n  {\n    if(nv[j] > 0) continue;          /* skip if j is an element */\n    next[j] = head[Cp[j]];          /* place j in list of its parent */\n    head[Cp[j]] = j;\n  }\n  for(e = n; e >= 0; e--)              /* place elements in lists */\n  {\n    if(nv[e] <= 0) continue;         /* skip unless e is an element */\n    if(Cp[e] != -1)\n    {\n      next[e] = head[Cp[e]];      /* place e in list of its parent */\n      head[Cp[e]] = e;\n    }\n  }\n  for(k = 0, i = 0; i <= n; i++)       /* postorder the assembly tree */\n  {\n    if(Cp[i] == -1) k = internal::cs_tdfs<StorageIndex>(i, k, head, next, perm.indices().data(), w);\n  }\n  \n  perm.indices().conservativeResize(n);\n}\n\n} // namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_AMD_H\n"
  },
  {
    "path": "include/externals/Eigen/src/OrderingMethods/Eigen_Colamd.h",
    "content": "// // This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Desire Nuentsa Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n// This file is modified from the colamd/symamd library. The copyright is below\n\n//   The authors of the code itself are Stefan I. Larimore and Timothy A.\n//   Davis (davis@cise.ufl.edu), University of Florida.  The algorithm was\n//   developed in collaboration with John Gilbert, Xerox PARC, and Esmond\n//   Ng, Oak Ridge National Laboratory.\n// \n//     Date:\n// \n//   September 8, 2003.  Version 2.3.\n// \n//     Acknowledgements:\n// \n//   This work was supported by the National Science Foundation, under\n//   grants DMS-9504974 and DMS-9803599.\n// \n//     Notice:\n// \n//   Copyright (c) 1998-2003 by the University of Florida.\n//   All Rights Reserved.\n// \n//   THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n//   EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n// \n//   Permission is hereby granted to use, copy, modify, and/or distribute\n//   this program, provided that the Copyright, this License, and the\n//   Availability of the original version is retained on all copies and made\n//   accessible to the end-user of any code or package that includes COLAMD\n//   or any modified version of COLAMD. \n// \n//     Availability:\n// \n//   The colamd/symamd library is available at\n// \n//       http://www.suitesparse.com\n\n  \n#ifndef EIGEN_COLAMD_H\n#define EIGEN_COLAMD_H\n\nnamespace internal {\n/* Ensure that debugging is turned off: */\n#ifndef COLAMD_NDEBUG\n#define COLAMD_NDEBUG\n#endif /* NDEBUG */\n/* ========================================================================== */\n/* === Knob and statistics definitions ====================================== */\n/* ========================================================================== */\n\n/* size of the knobs [ ] array.  Only knobs [0..1] are currently used. */\n#define COLAMD_KNOBS 20\n\n/* number of output statistics.  Only stats [0..6] are currently used. */\n#define COLAMD_STATS 20 \n\n/* knobs [0] and stats [0]: dense row knob and output statistic. */\n#define COLAMD_DENSE_ROW 0\n\n/* knobs [1] and stats [1]: dense column knob and output statistic. */\n#define COLAMD_DENSE_COL 1\n\n/* stats [2]: memory defragmentation count output statistic */\n#define COLAMD_DEFRAG_COUNT 2\n\n/* stats [3]: colamd status:  zero OK, > 0 warning or notice, < 0 error */\n#define COLAMD_STATUS 3\n\n/* stats [4..6]: error info, or info on jumbled columns */ \n#define COLAMD_INFO1 4\n#define COLAMD_INFO2 5\n#define COLAMD_INFO3 6\n\n/* error codes returned in stats [3]: */\n#define COLAMD_OK       (0)\n#define COLAMD_OK_BUT_JUMBLED     (1)\n#define COLAMD_ERROR_A_not_present    (-1)\n#define COLAMD_ERROR_p_not_present    (-2)\n#define COLAMD_ERROR_nrow_negative    (-3)\n#define COLAMD_ERROR_ncol_negative    (-4)\n#define COLAMD_ERROR_nnz_negative   (-5)\n#define COLAMD_ERROR_p0_nonzero     (-6)\n#define COLAMD_ERROR_A_too_small    (-7)\n#define COLAMD_ERROR_col_length_negative  (-8)\n#define COLAMD_ERROR_row_index_out_of_bounds  (-9)\n#define COLAMD_ERROR_out_of_memory    (-10)\n#define COLAMD_ERROR_internal_error   (-999)\n\n/* ========================================================================== */\n/* === Definitions ========================================================== */\n/* ========================================================================== */\n\n#define ONES_COMPLEMENT(r) (-(r)-1)\n\n/* -------------------------------------------------------------------------- */\n\n#define COLAMD_EMPTY (-1)\n\n/* Row and column status */\n#define ALIVE (0)\n#define DEAD  (-1)\n\n/* Column status */\n#define DEAD_PRINCIPAL    (-1)\n#define DEAD_NON_PRINCIPAL  (-2)\n\n/* Macros for row and column status update and checking. */\n#define ROW_IS_DEAD(r)      ROW_IS_MARKED_DEAD (Row[r].shared2.mark)\n#define ROW_IS_MARKED_DEAD(row_mark)  (row_mark < ALIVE)\n#define ROW_IS_ALIVE(r)     (Row [r].shared2.mark >= ALIVE)\n#define COL_IS_DEAD(c)      (Col [c].start < ALIVE)\n#define COL_IS_ALIVE(c)     (Col [c].start >= ALIVE)\n#define COL_IS_DEAD_PRINCIPAL(c)  (Col [c].start == DEAD_PRINCIPAL)\n#define KILL_ROW(r)     { Row [r].shared2.mark = DEAD ; }\n#define KILL_PRINCIPAL_COL(c)   { Col [c].start = DEAD_PRINCIPAL ; }\n#define KILL_NON_PRINCIPAL_COL(c) { Col [c].start = DEAD_NON_PRINCIPAL ; }\n\n/* ========================================================================== */\n/* === Colamd reporting mechanism =========================================== */\n/* ========================================================================== */\n\n// == Row and Column structures ==\ntemplate <typename IndexType>\nstruct colamd_col\n{\n  IndexType start ;   /* index for A of first row in this column, or DEAD */\n  /* if column is dead */\n  IndexType length ;  /* number of rows in this column */\n  union\n  {\n    IndexType thickness ; /* number of original columns represented by this */\n    /* col, if the column is alive */\n    IndexType parent ;  /* parent in parent tree super-column structure, if */\n    /* the column is dead */\n  } shared1 ;\n  union\n  {\n    IndexType score ; /* the score used to maintain heap, if col is alive */\n    IndexType order ; /* pivot ordering of this column, if col is dead */\n  } shared2 ;\n  union\n  {\n    IndexType headhash ;  /* head of a hash bucket, if col is at the head of */\n    /* a degree list */\n    IndexType hash ;  /* hash value, if col is not in a degree list */\n    IndexType prev ;  /* previous column in degree list, if col is in a */\n    /* degree list (but not at the head of a degree list) */\n  } shared3 ;\n  union\n  {\n    IndexType degree_next ; /* next column, if col is in a degree list */\n    IndexType hash_next ;   /* next column, if col is in a hash list */\n  } shared4 ;\n  \n};\n \ntemplate <typename IndexType>\nstruct Colamd_Row\n{\n  IndexType start ;   /* index for A of first col in this row */\n  IndexType length ;  /* number of principal columns in this row */\n  union\n  {\n    IndexType degree ;  /* number of principal & non-principal columns in row */\n    IndexType p ;   /* used as a row pointer in init_rows_cols () */\n  } shared1 ;\n  union\n  {\n    IndexType mark ;  /* for computing set differences and marking dead rows*/\n    IndexType first_column ;/* first column in row (used in garbage collection) */\n  } shared2 ;\n  \n};\n \n/* ========================================================================== */\n/* === Colamd recommended memory size ======================================= */\n/* ========================================================================== */\n \n/*\n  The recommended length Alen of the array A passed to colamd is given by\n  the COLAMD_RECOMMENDED (nnz, n_row, n_col) macro.  It returns -1 if any\n  argument is negative.  2*nnz space is required for the row and column\n  indices of the matrix. colamd_c (n_col) + colamd_r (n_row) space is\n  required for the Col and Row arrays, respectively, which are internal to\n  colamd.  An additional n_col space is the minimal amount of \"elbow room\",\n  and nnz/5 more space is recommended for run time efficiency.\n  \n  This macro is not needed when using symamd.\n  \n  Explicit typecast to IndexType added Sept. 23, 2002, COLAMD version 2.2, to avoid\n  gcc -pedantic warning messages.\n*/\ntemplate <typename IndexType>\ninline IndexType colamd_c(IndexType n_col) \n{ return IndexType( ((n_col) + 1) * sizeof (colamd_col<IndexType>) / sizeof (IndexType) ) ; }\n\ntemplate <typename IndexType>\ninline IndexType  colamd_r(IndexType n_row)\n{ return IndexType(((n_row) + 1) * sizeof (Colamd_Row<IndexType>) / sizeof (IndexType)); }\n\n// Prototypes of non-user callable routines\ntemplate <typename IndexType>\nstatic IndexType init_rows_cols (IndexType n_row, IndexType n_col, Colamd_Row<IndexType> Row [], colamd_col<IndexType> col [], IndexType A [], IndexType p [], IndexType stats[COLAMD_STATS] ); \n\ntemplate <typename IndexType>\nstatic void init_scoring (IndexType n_row, IndexType n_col, Colamd_Row<IndexType> Row [], colamd_col<IndexType> Col [], IndexType A [], IndexType head [], double knobs[COLAMD_KNOBS], IndexType *p_n_row2, IndexType *p_n_col2, IndexType *p_max_deg);\n\ntemplate <typename IndexType>\nstatic IndexType find_ordering (IndexType n_row, IndexType n_col, IndexType Alen, Colamd_Row<IndexType> Row [], colamd_col<IndexType> Col [], IndexType A [], IndexType head [], IndexType n_col2, IndexType max_deg, IndexType pfree);\n\ntemplate <typename IndexType>\nstatic void order_children (IndexType n_col, colamd_col<IndexType> Col [], IndexType p []);\n\ntemplate <typename IndexType>\nstatic void detect_super_cols (colamd_col<IndexType> Col [], IndexType A [], IndexType head [], IndexType row_start, IndexType row_length ) ;\n\ntemplate <typename IndexType>\nstatic IndexType garbage_collection (IndexType n_row, IndexType n_col, Colamd_Row<IndexType> Row [], colamd_col<IndexType> Col [], IndexType A [], IndexType *pfree) ;\n\ntemplate <typename IndexType>\nstatic inline  IndexType clear_mark (IndexType n_row, Colamd_Row<IndexType> Row [] ) ;\n\n/* === No debugging ========================================================= */\n\n#define COLAMD_DEBUG0(params) ;\n#define COLAMD_DEBUG1(params) ;\n#define COLAMD_DEBUG2(params) ;\n#define COLAMD_DEBUG3(params) ;\n#define COLAMD_DEBUG4(params) ;\n\n#define COLAMD_ASSERT(expression) ((void) 0)\n\n\n/**\n * \\brief Returns the recommended value of Alen \n * \n * Returns recommended value of Alen for use by colamd.  \n * Returns -1 if any input argument is negative.  \n * The use of this routine or macro is optional.  \n * Note that the macro uses its arguments   more than once, \n * so be careful for side effects, if you pass expressions as arguments to COLAMD_RECOMMENDED.  \n * \n * \\param nnz nonzeros in A\n * \\param n_row number of rows in A\n * \\param n_col number of columns in A\n * \\return recommended value of Alen for use by colamd\n */\ntemplate <typename IndexType>\ninline IndexType colamd_recommended ( IndexType nnz, IndexType n_row, IndexType n_col)\n{\n  if ((nnz) < 0 || (n_row) < 0 || (n_col) < 0)\n    return (-1);\n  else\n    return (2 * (nnz) + colamd_c (n_col) + colamd_r (n_row) + (n_col) + ((nnz) / 5)); \n}\n\n/**\n * \\brief set default parameters  The use of this routine is optional.\n * \n * Colamd: rows with more than (knobs [COLAMD_DENSE_ROW] * n_col)\n * entries are removed prior to ordering.  Columns with more than\n * (knobs [COLAMD_DENSE_COL] * n_row) entries are removed prior to\n * ordering, and placed last in the output column ordering. \n *\n * COLAMD_DENSE_ROW and COLAMD_DENSE_COL are defined as 0 and 1,\n * respectively, in colamd.h.  Default values of these two knobs\n * are both 0.5.  Currently, only knobs [0] and knobs [1] are\n * used, but future versions may use more knobs.  If so, they will\n * be properly set to their defaults by the future version of\n * colamd_set_defaults, so that the code that calls colamd will\n * not need to change, assuming that you either use\n * colamd_set_defaults, or pass a (double *) NULL pointer as the\n * knobs array to colamd or symamd.\n * \n * \\param knobs parameter settings for colamd\n */\n\nstatic inline void colamd_set_defaults(double knobs[COLAMD_KNOBS])\n{\n  /* === Local variables ================================================== */\n  \n  int i ;\n\n  if (!knobs)\n  {\n    return ;      /* no knobs to initialize */\n  }\n  for (i = 0 ; i < COLAMD_KNOBS ; i++)\n  {\n    knobs [i] = 0 ;\n  }\n  knobs [COLAMD_DENSE_ROW] = 0.5 ;  /* ignore rows over 50% dense */\n  knobs [COLAMD_DENSE_COL] = 0.5 ;  /* ignore columns over 50% dense */\n}\n\n/** \n * \\brief  Computes a column ordering using the column approximate minimum degree ordering\n * \n * Computes a column ordering (Q) of A such that P(AQ)=LU or\n * (AQ)'AQ=LL' have less fill-in and require fewer floating point\n * operations than factorizing the unpermuted matrix A or A'A,\n * respectively.\n * \n * \n * \\param n_row number of rows in A\n * \\param n_col number of columns in A\n * \\param Alen, size of the array A\n * \\param A row indices of the matrix, of size ALen\n * \\param p column pointers of A, of size n_col+1\n * \\param knobs parameter settings for colamd\n * \\param stats colamd output statistics and error codes\n */\ntemplate <typename IndexType>\nstatic bool colamd(IndexType n_row, IndexType n_col, IndexType Alen, IndexType *A, IndexType *p, double knobs[COLAMD_KNOBS], IndexType stats[COLAMD_STATS])\n{\n  /* === Local variables ================================================== */\n  \n  IndexType i ;     /* loop index */\n  IndexType nnz ;     /* nonzeros in A */\n  IndexType Row_size ;    /* size of Row [], in integers */\n  IndexType Col_size ;    /* size of Col [], in integers */\n  IndexType need ;      /* minimum required length of A */\n  Colamd_Row<IndexType> *Row ;   /* pointer into A of Row [0..n_row] array */\n  colamd_col<IndexType> *Col ;   /* pointer into A of Col [0..n_col] array */\n  IndexType n_col2 ;    /* number of non-dense, non-empty columns */\n  IndexType n_row2 ;    /* number of non-dense, non-empty rows */\n  IndexType ngarbage ;    /* number of garbage collections performed */\n  IndexType max_deg ;   /* maximum row degree */\n  double default_knobs [COLAMD_KNOBS] ; /* default knobs array */\n  \n  \n  /* === Check the input arguments ======================================== */\n  \n  if (!stats)\n  {\n    COLAMD_DEBUG0 ((\"colamd: stats not present\\n\")) ;\n    return (false) ;\n  }\n  for (i = 0 ; i < COLAMD_STATS ; i++)\n  {\n    stats [i] = 0 ;\n  }\n  stats [COLAMD_STATUS] = COLAMD_OK ;\n  stats [COLAMD_INFO1] = -1 ;\n  stats [COLAMD_INFO2] = -1 ;\n  \n  if (!A)   /* A is not present */\n  {\n    stats [COLAMD_STATUS] = COLAMD_ERROR_A_not_present ;\n    COLAMD_DEBUG0 ((\"colamd: A not present\\n\")) ;\n    return (false) ;\n  }\n  \n  if (!p)   /* p is not present */\n  {\n    stats [COLAMD_STATUS] = COLAMD_ERROR_p_not_present ;\n    COLAMD_DEBUG0 ((\"colamd: p not present\\n\")) ;\n    return (false) ;\n  }\n  \n  if (n_row < 0)  /* n_row must be >= 0 */\n  {\n    stats [COLAMD_STATUS] = COLAMD_ERROR_nrow_negative ;\n    stats [COLAMD_INFO1] = n_row ;\n    COLAMD_DEBUG0 ((\"colamd: nrow negative %d\\n\", n_row)) ;\n    return (false) ;\n  }\n  \n  if (n_col < 0)  /* n_col must be >= 0 */\n  {\n    stats [COLAMD_STATUS] = COLAMD_ERROR_ncol_negative ;\n    stats [COLAMD_INFO1] = n_col ;\n    COLAMD_DEBUG0 ((\"colamd: ncol negative %d\\n\", n_col)) ;\n    return (false) ;\n  }\n  \n  nnz = p [n_col] ;\n  if (nnz < 0)  /* nnz must be >= 0 */\n  {\n    stats [COLAMD_STATUS] = COLAMD_ERROR_nnz_negative ;\n    stats [COLAMD_INFO1] = nnz ;\n    COLAMD_DEBUG0 ((\"colamd: number of entries negative %d\\n\", nnz)) ;\n    return (false) ;\n  }\n  \n  if (p [0] != 0)\n  {\n    stats [COLAMD_STATUS] = COLAMD_ERROR_p0_nonzero ;\n    stats [COLAMD_INFO1] = p [0] ;\n    COLAMD_DEBUG0 ((\"colamd: p[0] not zero %d\\n\", p [0])) ;\n    return (false) ;\n  }\n  \n  /* === If no knobs, set default knobs =================================== */\n  \n  if (!knobs)\n  {\n    colamd_set_defaults (default_knobs) ;\n    knobs = default_knobs ;\n  }\n  \n  /* === Allocate the Row and Col arrays from array A ===================== */\n  \n  Col_size = colamd_c (n_col) ;\n  Row_size = colamd_r (n_row) ;\n  need = 2*nnz + n_col + Col_size + Row_size ;\n  \n  if (need > Alen)\n  {\n    /* not enough space in array A to perform the ordering */\n    stats [COLAMD_STATUS] = COLAMD_ERROR_A_too_small ;\n    stats [COLAMD_INFO1] = need ;\n    stats [COLAMD_INFO2] = Alen ;\n    COLAMD_DEBUG0 ((\"colamd: Need Alen >= %d, given only Alen = %d\\n\", need,Alen));\n    return (false) ;\n  }\n  \n  Alen -= Col_size + Row_size ;\n  Col = (colamd_col<IndexType> *) &A [Alen] ;\n  Row = (Colamd_Row<IndexType> *) &A [Alen + Col_size] ;\n\n  /* === Construct the row and column data structures ===================== */\n  \n  if (!Eigen::internal::init_rows_cols (n_row, n_col, Row, Col, A, p, stats))\n  {\n    /* input matrix is invalid */\n    COLAMD_DEBUG0 ((\"colamd: Matrix invalid\\n\")) ;\n    return (false) ;\n  }\n  \n  /* === Initialize scores, kill dense rows/columns ======================= */\n\n  Eigen::internal::init_scoring (n_row, n_col, Row, Col, A, p, knobs,\n\t\t&n_row2, &n_col2, &max_deg) ;\n  \n  /* === Order the supercolumns =========================================== */\n  \n  ngarbage = Eigen::internal::find_ordering (n_row, n_col, Alen, Row, Col, A, p,\n\t\t\t    n_col2, max_deg, 2*nnz) ;\n  \n  /* === Order the non-principal columns ================================== */\n  \n  Eigen::internal::order_children (n_col, Col, p) ;\n  \n  /* === Return statistics in stats ======================================= */\n  \n  stats [COLAMD_DENSE_ROW] = n_row - n_row2 ;\n  stats [COLAMD_DENSE_COL] = n_col - n_col2 ;\n  stats [COLAMD_DEFRAG_COUNT] = ngarbage ;\n  COLAMD_DEBUG0 ((\"colamd: done.\\n\")) ; \n  return (true) ;\n}\n\n/* ========================================================================== */\n/* === NON-USER-CALLABLE ROUTINES: ========================================== */\n/* ========================================================================== */\n\n/* There are no user-callable routines beyond this point in the file */\n\n\n/* ========================================================================== */\n/* === init_rows_cols ======================================================= */\n/* ========================================================================== */\n\n/*\n  Takes the column form of the matrix in A and creates the row form of the\n  matrix.  Also, row and column attributes are stored in the Col and Row\n  structs.  If the columns are un-sorted or contain duplicate row indices,\n  this routine will also sort and remove duplicate row indices from the\n  column form of the matrix.  Returns false if the matrix is invalid,\n  true otherwise.  Not user-callable.\n*/\ntemplate <typename IndexType>\nstatic IndexType init_rows_cols  /* returns true if OK, or false otherwise */\n  (\n    /* === Parameters ======================================================= */\n\n    IndexType n_row,      /* number of rows of A */\n    IndexType n_col,      /* number of columns of A */\n    Colamd_Row<IndexType> Row [],    /* of size n_row+1 */\n    colamd_col<IndexType> Col [],    /* of size n_col+1 */\n    IndexType A [],     /* row indices of A, of size Alen */\n    IndexType p [],     /* pointers to columns in A, of size n_col+1 */\n    IndexType stats [COLAMD_STATS]  /* colamd statistics */ \n    )\n{\n  /* === Local variables ================================================== */\n\n  IndexType col ;     /* a column index */\n  IndexType row ;     /* a row index */\n  IndexType *cp ;     /* a column pointer */\n  IndexType *cp_end ;   /* a pointer to the end of a column */\n  IndexType *rp ;     /* a row pointer */\n  IndexType *rp_end ;   /* a pointer to the end of a row */\n  IndexType last_row ;    /* previous row */\n\n  /* === Initialize columns, and check column pointers ==================== */\n\n  for (col = 0 ; col < n_col ; col++)\n  {\n    Col [col].start = p [col] ;\n    Col [col].length = p [col+1] - p [col] ;\n\n    if ((Col [col].length) < 0) // extra parentheses to work-around gcc bug 10200\n    {\n      /* column pointers must be non-decreasing */\n      stats [COLAMD_STATUS] = COLAMD_ERROR_col_length_negative ;\n      stats [COLAMD_INFO1] = col ;\n      stats [COLAMD_INFO2] = Col [col].length ;\n      COLAMD_DEBUG0 ((\"colamd: col %d length %d < 0\\n\", col, Col [col].length)) ;\n      return (false) ;\n    }\n\n    Col [col].shared1.thickness = 1 ;\n    Col [col].shared2.score = 0 ;\n    Col [col].shared3.prev = COLAMD_EMPTY ;\n    Col [col].shared4.degree_next = COLAMD_EMPTY ;\n  }\n\n  /* p [0..n_col] no longer needed, used as \"head\" in subsequent routines */\n\n  /* === Scan columns, compute row degrees, and check row indices ========= */\n\n  stats [COLAMD_INFO3] = 0 ;  /* number of duplicate or unsorted row indices*/\n\n  for (row = 0 ; row < n_row ; row++)\n  {\n    Row [row].length = 0 ;\n    Row [row].shared2.mark = -1 ;\n  }\n\n  for (col = 0 ; col < n_col ; col++)\n  {\n    last_row = -1 ;\n\n    cp = &A [p [col]] ;\n    cp_end = &A [p [col+1]] ;\n\n    while (cp < cp_end)\n    {\n      row = *cp++ ;\n\n      /* make sure row indices within range */\n      if (row < 0 || row >= n_row)\n      {\n\tstats [COLAMD_STATUS] = COLAMD_ERROR_row_index_out_of_bounds ;\n\tstats [COLAMD_INFO1] = col ;\n\tstats [COLAMD_INFO2] = row ;\n\tstats [COLAMD_INFO3] = n_row ;\n\tCOLAMD_DEBUG0 ((\"colamd: row %d col %d out of bounds\\n\", row, col)) ;\n\treturn (false) ;\n      }\n\n      if (row <= last_row || Row [row].shared2.mark == col)\n      {\n\t/* row index are unsorted or repeated (or both), thus col */\n\t/* is jumbled.  This is a notice, not an error condition. */\n\tstats [COLAMD_STATUS] = COLAMD_OK_BUT_JUMBLED ;\n\tstats [COLAMD_INFO1] = col ;\n\tstats [COLAMD_INFO2] = row ;\n\t(stats [COLAMD_INFO3]) ++ ;\n\tCOLAMD_DEBUG1 ((\"colamd: row %d col %d unsorted/duplicate\\n\",row,col));\n      }\n\n      if (Row [row].shared2.mark != col)\n      {\n\tRow [row].length++ ;\n      }\n      else\n      {\n\t/* this is a repeated entry in the column, */\n\t/* it will be removed */\n\tCol [col].length-- ;\n      }\n\n      /* mark the row as having been seen in this column */\n      Row [row].shared2.mark = col ;\n\n      last_row = row ;\n    }\n  }\n\n  /* === Compute row pointers ============================================= */\n\n  /* row form of the matrix starts directly after the column */\n  /* form of matrix in A */\n  Row [0].start = p [n_col] ;\n  Row [0].shared1.p = Row [0].start ;\n  Row [0].shared2.mark = -1 ;\n  for (row = 1 ; row < n_row ; row++)\n  {\n    Row [row].start = Row [row-1].start + Row [row-1].length ;\n    Row [row].shared1.p = Row [row].start ;\n    Row [row].shared2.mark = -1 ;\n  }\n\n  /* === Create row form ================================================== */\n\n  if (stats [COLAMD_STATUS] == COLAMD_OK_BUT_JUMBLED)\n  {\n    /* if cols jumbled, watch for repeated row indices */\n    for (col = 0 ; col < n_col ; col++)\n    {\n      cp = &A [p [col]] ;\n      cp_end = &A [p [col+1]] ;\n      while (cp < cp_end)\n      {\n\trow = *cp++ ;\n\tif (Row [row].shared2.mark != col)\n\t{\n\t  A [(Row [row].shared1.p)++] = col ;\n\t  Row [row].shared2.mark = col ;\n\t}\n      }\n    }\n  }\n  else\n  {\n    /* if cols not jumbled, we don't need the mark (this is faster) */\n    for (col = 0 ; col < n_col ; col++)\n    {\n      cp = &A [p [col]] ;\n      cp_end = &A [p [col+1]] ;\n      while (cp < cp_end)\n      {\n\tA [(Row [*cp++].shared1.p)++] = col ;\n      }\n    }\n  }\n\n  /* === Clear the row marks and set row degrees ========================== */\n\n  for (row = 0 ; row < n_row ; row++)\n  {\n    Row [row].shared2.mark = 0 ;\n    Row [row].shared1.degree = Row [row].length ;\n  }\n\n  /* === See if we need to re-create columns ============================== */\n\n  if (stats [COLAMD_STATUS] == COLAMD_OK_BUT_JUMBLED)\n  {\n    COLAMD_DEBUG0 ((\"colamd: reconstructing column form, matrix jumbled\\n\")) ;\n\n\n    /* === Compute col pointers ========================================= */\n\n    /* col form of the matrix starts at A [0]. */\n    /* Note, we may have a gap between the col form and the row */\n    /* form if there were duplicate entries, if so, it will be */\n    /* removed upon the first garbage collection */\n    Col [0].start = 0 ;\n    p [0] = Col [0].start ;\n    for (col = 1 ; col < n_col ; col++)\n    {\n      /* note that the lengths here are for pruned columns, i.e. */\n      /* no duplicate row indices will exist for these columns */\n      Col [col].start = Col [col-1].start + Col [col-1].length ;\n      p [col] = Col [col].start ;\n    }\n\n    /* === Re-create col form =========================================== */\n\n    for (row = 0 ; row < n_row ; row++)\n    {\n      rp = &A [Row [row].start] ;\n      rp_end = rp + Row [row].length ;\n      while (rp < rp_end)\n      {\n\tA [(p [*rp++])++] = row ;\n      }\n    }\n  }\n\n  /* === Done.  Matrix is not (or no longer) jumbled ====================== */\n\n  return (true) ;\n}\n\n\n/* ========================================================================== */\n/* === init_scoring ========================================================= */\n/* ========================================================================== */\n\n/*\n  Kills dense or empty columns and rows, calculates an initial score for\n  each column, and places all columns in the degree lists.  Not user-callable.\n*/\ntemplate <typename IndexType>\nstatic void init_scoring\n  (\n    /* === Parameters ======================================================= */\n\n    IndexType n_row,      /* number of rows of A */\n    IndexType n_col,      /* number of columns of A */\n    Colamd_Row<IndexType> Row [],    /* of size n_row+1 */\n    colamd_col<IndexType> Col [],    /* of size n_col+1 */\n    IndexType A [],     /* column form and row form of A */\n    IndexType head [],    /* of size n_col+1 */\n    double knobs [COLAMD_KNOBS],/* parameters */\n    IndexType *p_n_row2,    /* number of non-dense, non-empty rows */\n    IndexType *p_n_col2,    /* number of non-dense, non-empty columns */\n    IndexType *p_max_deg    /* maximum row degree */\n    )\n{\n  /* === Local variables ================================================== */\n\n  IndexType c ;     /* a column index */\n  IndexType r, row ;    /* a row index */\n  IndexType *cp ;     /* a column pointer */\n  IndexType deg ;     /* degree of a row or column */\n  IndexType *cp_end ;   /* a pointer to the end of a column */\n  IndexType *new_cp ;   /* new column pointer */\n  IndexType col_length ;    /* length of pruned column */\n  IndexType score ;     /* current column score */\n  IndexType n_col2 ;    /* number of non-dense, non-empty columns */\n  IndexType n_row2 ;    /* number of non-dense, non-empty rows */\n  IndexType dense_row_count ; /* remove rows with more entries than this */\n  IndexType dense_col_count ; /* remove cols with more entries than this */\n  IndexType min_score ;   /* smallest column score */\n  IndexType max_deg ;   /* maximum row degree */\n  IndexType next_col ;    /* Used to add to degree list.*/\n\n\n  /* === Extract knobs ==================================================== */\n\n  dense_row_count = numext::maxi(IndexType(0), numext::mini(IndexType(knobs [COLAMD_DENSE_ROW] * n_col), n_col)) ;\n  dense_col_count = numext::maxi(IndexType(0), numext::mini(IndexType(knobs [COLAMD_DENSE_COL] * n_row), n_row)) ;\n  COLAMD_DEBUG1 ((\"colamd: densecount: %d %d\\n\", dense_row_count, dense_col_count)) ;\n  max_deg = 0 ;\n  n_col2 = n_col ;\n  n_row2 = n_row ;\n\n  /* === Kill empty columns =============================================== */\n\n  /* Put the empty columns at the end in their natural order, so that LU */\n  /* factorization can proceed as far as possible. */\n  for (c = n_col-1 ; c >= 0 ; c--)\n  {\n    deg = Col [c].length ;\n    if (deg == 0)\n    {\n      /* this is a empty column, kill and order it last */\n      Col [c].shared2.order = --n_col2 ;\n      KILL_PRINCIPAL_COL (c) ;\n    }\n  }\n  COLAMD_DEBUG1 ((\"colamd: null columns killed: %d\\n\", n_col - n_col2)) ;\n\n  /* === Kill dense columns =============================================== */\n\n  /* Put the dense columns at the end, in their natural order */\n  for (c = n_col-1 ; c >= 0 ; c--)\n  {\n    /* skip any dead columns */\n    if (COL_IS_DEAD (c))\n    {\n      continue ;\n    }\n    deg = Col [c].length ;\n    if (deg > dense_col_count)\n    {\n      /* this is a dense column, kill and order it last */\n      Col [c].shared2.order = --n_col2 ;\n      /* decrement the row degrees */\n      cp = &A [Col [c].start] ;\n      cp_end = cp + Col [c].length ;\n      while (cp < cp_end)\n      {\n\tRow [*cp++].shared1.degree-- ;\n      }\n      KILL_PRINCIPAL_COL (c) ;\n    }\n  }\n  COLAMD_DEBUG1 ((\"colamd: Dense and null columns killed: %d\\n\", n_col - n_col2)) ;\n\n  /* === Kill dense and empty rows ======================================== */\n\n  for (r = 0 ; r < n_row ; r++)\n  {\n    deg = Row [r].shared1.degree ;\n    COLAMD_ASSERT (deg >= 0 && deg <= n_col) ;\n    if (deg > dense_row_count || deg == 0)\n    {\n      /* kill a dense or empty row */\n      KILL_ROW (r) ;\n      --n_row2 ;\n    }\n    else\n    {\n      /* keep track of max degree of remaining rows */\n      max_deg = numext::maxi(max_deg, deg) ;\n    }\n  }\n  COLAMD_DEBUG1 ((\"colamd: Dense and null rows killed: %d\\n\", n_row - n_row2)) ;\n\n  /* === Compute initial column scores ==================================== */\n\n  /* At this point the row degrees are accurate.  They reflect the number */\n  /* of \"live\" (non-dense) columns in each row.  No empty rows exist. */\n  /* Some \"live\" columns may contain only dead rows, however.  These are */\n  /* pruned in the code below. */\n\n  /* now find the initial matlab score for each column */\n  for (c = n_col-1 ; c >= 0 ; c--)\n  {\n    /* skip dead column */\n    if (COL_IS_DEAD (c))\n    {\n      continue ;\n    }\n    score = 0 ;\n    cp = &A [Col [c].start] ;\n    new_cp = cp ;\n    cp_end = cp + Col [c].length ;\n    while (cp < cp_end)\n    {\n      /* get a row */\n      row = *cp++ ;\n      /* skip if dead */\n      if (ROW_IS_DEAD (row))\n      {\n\tcontinue ;\n      }\n      /* compact the column */\n      *new_cp++ = row ;\n      /* add row's external degree */\n      score += Row [row].shared1.degree - 1 ;\n      /* guard against integer overflow */\n      score = numext::mini(score, n_col) ;\n    }\n    /* determine pruned column length */\n    col_length = (IndexType) (new_cp - &A [Col [c].start]) ;\n    if (col_length == 0)\n    {\n      /* a newly-made null column (all rows in this col are \"dense\" */\n      /* and have already been killed) */\n      COLAMD_DEBUG2 ((\"Newly null killed: %d\\n\", c)) ;\n      Col [c].shared2.order = --n_col2 ;\n      KILL_PRINCIPAL_COL (c) ;\n    }\n    else\n    {\n      /* set column length and set score */\n      COLAMD_ASSERT (score >= 0) ;\n      COLAMD_ASSERT (score <= n_col) ;\n      Col [c].length = col_length ;\n      Col [c].shared2.score = score ;\n    }\n  }\n  COLAMD_DEBUG1 ((\"colamd: Dense, null, and newly-null columns killed: %d\\n\",\n\t\t  n_col-n_col2)) ;\n\n  /* At this point, all empty rows and columns are dead.  All live columns */\n  /* are \"clean\" (containing no dead rows) and simplicial (no supercolumns */\n  /* yet).  Rows may contain dead columns, but all live rows contain at */\n  /* least one live column. */\n\n  /* === Initialize degree lists ========================================== */\n\n\n  /* clear the hash buckets */\n  for (c = 0 ; c <= n_col ; c++)\n  {\n    head [c] = COLAMD_EMPTY ;\n  }\n  min_score = n_col ;\n  /* place in reverse order, so low column indices are at the front */\n  /* of the lists.  This is to encourage natural tie-breaking */\n  for (c = n_col-1 ; c >= 0 ; c--)\n  {\n    /* only add principal columns to degree lists */\n    if (COL_IS_ALIVE (c))\n    {\n      COLAMD_DEBUG4 ((\"place %d score %d minscore %d ncol %d\\n\",\n\t\t      c, Col [c].shared2.score, min_score, n_col)) ;\n\n      /* === Add columns score to DList =============================== */\n\n      score = Col [c].shared2.score ;\n\n      COLAMD_ASSERT (min_score >= 0) ;\n      COLAMD_ASSERT (min_score <= n_col) ;\n      COLAMD_ASSERT (score >= 0) ;\n      COLAMD_ASSERT (score <= n_col) ;\n      COLAMD_ASSERT (head [score] >= COLAMD_EMPTY) ;\n\n      /* now add this column to dList at proper score location */\n      next_col = head [score] ;\n      Col [c].shared3.prev = COLAMD_EMPTY ;\n      Col [c].shared4.degree_next = next_col ;\n\n      /* if there already was a column with the same score, set its */\n      /* previous pointer to this new column */\n      if (next_col != COLAMD_EMPTY)\n      {\n\tCol [next_col].shared3.prev = c ;\n      }\n      head [score] = c ;\n\n      /* see if this score is less than current min */\n      min_score = numext::mini(min_score, score) ;\n\n\n    }\n  }\n\n\n  /* === Return number of remaining columns, and max row degree =========== */\n\n  *p_n_col2 = n_col2 ;\n  *p_n_row2 = n_row2 ;\n  *p_max_deg = max_deg ;\n}\n\n\n/* ========================================================================== */\n/* === find_ordering ======================================================== */\n/* ========================================================================== */\n\n/*\n  Order the principal columns of the supercolumn form of the matrix\n  (no supercolumns on input).  Uses a minimum approximate column minimum\n  degree ordering method.  Not user-callable.\n*/\ntemplate <typename IndexType>\nstatic IndexType find_ordering /* return the number of garbage collections */\n  (\n    /* === Parameters ======================================================= */\n\n    IndexType n_row,      /* number of rows of A */\n    IndexType n_col,      /* number of columns of A */\n    IndexType Alen,     /* size of A, 2*nnz + n_col or larger */\n    Colamd_Row<IndexType> Row [],    /* of size n_row+1 */\n    colamd_col<IndexType> Col [],    /* of size n_col+1 */\n    IndexType A [],     /* column form and row form of A */\n    IndexType head [],    /* of size n_col+1 */\n    IndexType n_col2,     /* Remaining columns to order */\n    IndexType max_deg,    /* Maximum row degree */\n    IndexType pfree     /* index of first free slot (2*nnz on entry) */\n    )\n{\n  /* === Local variables ================================================== */\n\n  IndexType k ;     /* current pivot ordering step */\n  IndexType pivot_col ;   /* current pivot column */\n  IndexType *cp ;     /* a column pointer */\n  IndexType *rp ;     /* a row pointer */\n  IndexType pivot_row ;   /* current pivot row */\n  IndexType *new_cp ;   /* modified column pointer */\n  IndexType *new_rp ;   /* modified row pointer */\n  IndexType pivot_row_start ; /* pointer to start of pivot row */\n  IndexType pivot_row_degree ;  /* number of columns in pivot row */\n  IndexType pivot_row_length ;  /* number of supercolumns in pivot row */\n  IndexType pivot_col_score ; /* score of pivot column */\n  IndexType needed_memory ;   /* free space needed for pivot row */\n  IndexType *cp_end ;   /* pointer to the end of a column */\n  IndexType *rp_end ;   /* pointer to the end of a row */\n  IndexType row ;     /* a row index */\n  IndexType col ;     /* a column index */\n  IndexType max_score ;   /* maximum possible score */\n  IndexType cur_score ;   /* score of current column */\n  unsigned int hash ;   /* hash value for supernode detection */\n  IndexType head_column ;   /* head of hash bucket */\n  IndexType first_col ;   /* first column in hash bucket */\n  IndexType tag_mark ;    /* marker value for mark array */\n  IndexType row_mark ;    /* Row [row].shared2.mark */\n  IndexType set_difference ;  /* set difference size of row with pivot row */\n  IndexType min_score ;   /* smallest column score */\n  IndexType col_thickness ;   /* \"thickness\" (no. of columns in a supercol) */\n  IndexType max_mark ;    /* maximum value of tag_mark */\n  IndexType pivot_col_thickness ; /* number of columns represented by pivot col */\n  IndexType prev_col ;    /* Used by Dlist operations. */\n  IndexType next_col ;    /* Used by Dlist operations. */\n  IndexType ngarbage ;    /* number of garbage collections performed */\n\n\n  /* === Initialization and clear mark ==================================== */\n\n  max_mark = INT_MAX - n_col ;  /* INT_MAX defined in <limits.h> */\n  tag_mark = Eigen::internal::clear_mark (n_row, Row) ;\n  min_score = 0 ;\n  ngarbage = 0 ;\n  COLAMD_DEBUG1 ((\"colamd: Ordering, n_col2=%d\\n\", n_col2)) ;\n\n  /* === Order the columns ================================================ */\n\n  for (k = 0 ; k < n_col2 ; /* 'k' is incremented below */)\n  {\n\n    /* === Select pivot column, and order it ============================ */\n\n    /* make sure degree list isn't empty */\n    COLAMD_ASSERT (min_score >= 0) ;\n    COLAMD_ASSERT (min_score <= n_col) ;\n    COLAMD_ASSERT (head [min_score] >= COLAMD_EMPTY) ;\n\n    /* get pivot column from head of minimum degree list */\n    while (min_score < n_col && head [min_score] == COLAMD_EMPTY)\n    {\n      min_score++ ;\n    }\n    pivot_col = head [min_score] ;\n    COLAMD_ASSERT (pivot_col >= 0 && pivot_col <= n_col) ;\n    next_col = Col [pivot_col].shared4.degree_next ;\n    head [min_score] = next_col ;\n    if (next_col != COLAMD_EMPTY)\n    {\n      Col [next_col].shared3.prev = COLAMD_EMPTY ;\n    }\n\n    COLAMD_ASSERT (COL_IS_ALIVE (pivot_col)) ;\n    COLAMD_DEBUG3 ((\"Pivot col: %d\\n\", pivot_col)) ;\n\n    /* remember score for defrag check */\n    pivot_col_score = Col [pivot_col].shared2.score ;\n\n    /* the pivot column is the kth column in the pivot order */\n    Col [pivot_col].shared2.order = k ;\n\n    /* increment order count by column thickness */\n    pivot_col_thickness = Col [pivot_col].shared1.thickness ;\n    k += pivot_col_thickness ;\n    COLAMD_ASSERT (pivot_col_thickness > 0) ;\n\n    /* === Garbage_collection, if necessary ============================= */\n\n    needed_memory = numext::mini(pivot_col_score, n_col - k) ;\n    if (pfree + needed_memory >= Alen)\n    {\n      pfree = Eigen::internal::garbage_collection (n_row, n_col, Row, Col, A, &A [pfree]) ;\n      ngarbage++ ;\n      /* after garbage collection we will have enough */\n      COLAMD_ASSERT (pfree + needed_memory < Alen) ;\n      /* garbage collection has wiped out the Row[].shared2.mark array */\n      tag_mark = Eigen::internal::clear_mark (n_row, Row) ;\n\n    }\n\n    /* === Compute pivot row pattern ==================================== */\n\n    /* get starting location for this new merged row */\n    pivot_row_start = pfree ;\n\n    /* initialize new row counts to zero */\n    pivot_row_degree = 0 ;\n\n    /* tag pivot column as having been visited so it isn't included */\n    /* in merged pivot row */\n    Col [pivot_col].shared1.thickness = -pivot_col_thickness ;\n\n    /* pivot row is the union of all rows in the pivot column pattern */\n    cp = &A [Col [pivot_col].start] ;\n    cp_end = cp + Col [pivot_col].length ;\n    while (cp < cp_end)\n    {\n      /* get a row */\n      row = *cp++ ;\n      COLAMD_DEBUG4 ((\"Pivot col pattern %d %d\\n\", ROW_IS_ALIVE (row), row)) ;\n      /* skip if row is dead */\n      if (ROW_IS_DEAD (row))\n      {\n\tcontinue ;\n      }\n      rp = &A [Row [row].start] ;\n      rp_end = rp + Row [row].length ;\n      while (rp < rp_end)\n      {\n\t/* get a column */\n\tcol = *rp++ ;\n\t/* add the column, if alive and untagged */\n\tcol_thickness = Col [col].shared1.thickness ;\n\tif (col_thickness > 0 && COL_IS_ALIVE (col))\n\t{\n\t  /* tag column in pivot row */\n\t  Col [col].shared1.thickness = -col_thickness ;\n\t  COLAMD_ASSERT (pfree < Alen) ;\n\t  /* place column in pivot row */\n\t  A [pfree++] = col ;\n\t  pivot_row_degree += col_thickness ;\n\t}\n      }\n    }\n\n    /* clear tag on pivot column */\n    Col [pivot_col].shared1.thickness = pivot_col_thickness ;\n    max_deg = numext::maxi(max_deg, pivot_row_degree) ;\n\n\n    /* === Kill all rows used to construct pivot row ==================== */\n\n    /* also kill pivot row, temporarily */\n    cp = &A [Col [pivot_col].start] ;\n    cp_end = cp + Col [pivot_col].length ;\n    while (cp < cp_end)\n    {\n      /* may be killing an already dead row */\n      row = *cp++ ;\n      COLAMD_DEBUG3 ((\"Kill row in pivot col: %d\\n\", row)) ;\n      KILL_ROW (row) ;\n    }\n\n    /* === Select a row index to use as the new pivot row =============== */\n\n    pivot_row_length = pfree - pivot_row_start ;\n    if (pivot_row_length > 0)\n    {\n      /* pick the \"pivot\" row arbitrarily (first row in col) */\n      pivot_row = A [Col [pivot_col].start] ;\n      COLAMD_DEBUG3 ((\"Pivotal row is %d\\n\", pivot_row)) ;\n    }\n    else\n    {\n      /* there is no pivot row, since it is of zero length */\n      pivot_row = COLAMD_EMPTY ;\n      COLAMD_ASSERT (pivot_row_length == 0) ;\n    }\n    COLAMD_ASSERT (Col [pivot_col].length > 0 || pivot_row_length == 0) ;\n\n    /* === Approximate degree computation =============================== */\n\n    /* Here begins the computation of the approximate degree.  The column */\n    /* score is the sum of the pivot row \"length\", plus the size of the */\n    /* set differences of each row in the column minus the pattern of the */\n    /* pivot row itself.  The column (\"thickness\") itself is also */\n    /* excluded from the column score (we thus use an approximate */\n    /* external degree). */\n\n    /* The time taken by the following code (compute set differences, and */\n    /* add them up) is proportional to the size of the data structure */\n    /* being scanned - that is, the sum of the sizes of each column in */\n    /* the pivot row.  Thus, the amortized time to compute a column score */\n    /* is proportional to the size of that column (where size, in this */\n    /* context, is the column \"length\", or the number of row indices */\n    /* in that column).  The number of row indices in a column is */\n    /* monotonically non-decreasing, from the length of the original */\n    /* column on input to colamd. */\n\n    /* === Compute set differences ====================================== */\n\n    COLAMD_DEBUG3 ((\"** Computing set differences phase. **\\n\")) ;\n\n    /* pivot row is currently dead - it will be revived later. */\n\n    COLAMD_DEBUG3 ((\"Pivot row: \")) ;\n    /* for each column in pivot row */\n    rp = &A [pivot_row_start] ;\n    rp_end = rp + pivot_row_length ;\n    while (rp < rp_end)\n    {\n      col = *rp++ ;\n      COLAMD_ASSERT (COL_IS_ALIVE (col) && col != pivot_col) ;\n      COLAMD_DEBUG3 ((\"Col: %d\\n\", col)) ;\n\n      /* clear tags used to construct pivot row pattern */\n      col_thickness = -Col [col].shared1.thickness ;\n      COLAMD_ASSERT (col_thickness > 0) ;\n      Col [col].shared1.thickness = col_thickness ;\n\n      /* === Remove column from degree list =========================== */\n\n      cur_score = Col [col].shared2.score ;\n      prev_col = Col [col].shared3.prev ;\n      next_col = Col [col].shared4.degree_next ;\n      COLAMD_ASSERT (cur_score >= 0) ;\n      COLAMD_ASSERT (cur_score <= n_col) ;\n      COLAMD_ASSERT (cur_score >= COLAMD_EMPTY) ;\n      if (prev_col == COLAMD_EMPTY)\n      {\n\thead [cur_score] = next_col ;\n      }\n      else\n      {\n\tCol [prev_col].shared4.degree_next = next_col ;\n      }\n      if (next_col != COLAMD_EMPTY)\n      {\n\tCol [next_col].shared3.prev = prev_col ;\n      }\n\n      /* === Scan the column ========================================== */\n\n      cp = &A [Col [col].start] ;\n      cp_end = cp + Col [col].length ;\n      while (cp < cp_end)\n      {\n\t/* get a row */\n\trow = *cp++ ;\n\trow_mark = Row [row].shared2.mark ;\n\t/* skip if dead */\n\tif (ROW_IS_MARKED_DEAD (row_mark))\n\t{\n\t  continue ;\n\t}\n\tCOLAMD_ASSERT (row != pivot_row) ;\n\tset_difference = row_mark - tag_mark ;\n\t/* check if the row has been seen yet */\n\tif (set_difference < 0)\n\t{\n\t  COLAMD_ASSERT (Row [row].shared1.degree <= max_deg) ;\n\t  set_difference = Row [row].shared1.degree ;\n\t}\n\t/* subtract column thickness from this row's set difference */\n\tset_difference -= col_thickness ;\n\tCOLAMD_ASSERT (set_difference >= 0) ;\n\t/* absorb this row if the set difference becomes zero */\n\tif (set_difference == 0)\n\t{\n\t  COLAMD_DEBUG3 ((\"aggressive absorption. Row: %d\\n\", row)) ;\n\t  KILL_ROW (row) ;\n\t}\n\telse\n\t{\n\t  /* save the new mark */\n\t  Row [row].shared2.mark = set_difference + tag_mark ;\n\t}\n      }\n    }\n\n\n    /* === Add up set differences for each column ======================= */\n\n    COLAMD_DEBUG3 ((\"** Adding set differences phase. **\\n\")) ;\n\n    /* for each column in pivot row */\n    rp = &A [pivot_row_start] ;\n    rp_end = rp + pivot_row_length ;\n    while (rp < rp_end)\n    {\n      /* get a column */\n      col = *rp++ ;\n      COLAMD_ASSERT (COL_IS_ALIVE (col) && col != pivot_col) ;\n      hash = 0 ;\n      cur_score = 0 ;\n      cp = &A [Col [col].start] ;\n      /* compact the column */\n      new_cp = cp ;\n      cp_end = cp + Col [col].length ;\n\n      COLAMD_DEBUG4 ((\"Adding set diffs for Col: %d.\\n\", col)) ;\n\n      while (cp < cp_end)\n      {\n\t/* get a row */\n\trow = *cp++ ;\n\tCOLAMD_ASSERT(row >= 0 && row < n_row) ;\n\trow_mark = Row [row].shared2.mark ;\n\t/* skip if dead */\n\tif (ROW_IS_MARKED_DEAD (row_mark))\n\t{\n\t  continue ;\n\t}\n\tCOLAMD_ASSERT (row_mark > tag_mark) ;\n\t/* compact the column */\n\t*new_cp++ = row ;\n\t/* compute hash function */\n\thash += row ;\n\t/* add set difference */\n\tcur_score += row_mark - tag_mark ;\n\t/* integer overflow... */\n\tcur_score = numext::mini(cur_score, n_col) ;\n      }\n\n      /* recompute the column's length */\n      Col [col].length = (IndexType) (new_cp - &A [Col [col].start]) ;\n\n      /* === Further mass elimination ================================= */\n\n      if (Col [col].length == 0)\n      {\n\tCOLAMD_DEBUG4 ((\"further mass elimination. Col: %d\\n\", col)) ;\n\t/* nothing left but the pivot row in this column */\n\tKILL_PRINCIPAL_COL (col) ;\n\tpivot_row_degree -= Col [col].shared1.thickness ;\n\tCOLAMD_ASSERT (pivot_row_degree >= 0) ;\n\t/* order it */\n\tCol [col].shared2.order = k ;\n\t/* increment order count by column thickness */\n\tk += Col [col].shared1.thickness ;\n      }\n      else\n      {\n\t/* === Prepare for supercolumn detection ==================== */\n\n\tCOLAMD_DEBUG4 ((\"Preparing supercol detection for Col: %d.\\n\", col)) ;\n\n\t/* save score so far */\n\tCol [col].shared2.score = cur_score ;\n\n\t/* add column to hash table, for supercolumn detection */\n\thash %= n_col + 1 ;\n\n\tCOLAMD_DEBUG4 ((\" Hash = %d, n_col = %d.\\n\", hash, n_col)) ;\n\tCOLAMD_ASSERT (hash <= n_col) ;\n\n\thead_column = head [hash] ;\n\tif (head_column > COLAMD_EMPTY)\n\t{\n\t  /* degree list \"hash\" is non-empty, use prev (shared3) of */\n\t  /* first column in degree list as head of hash bucket */\n\t  first_col = Col [head_column].shared3.headhash ;\n\t  Col [head_column].shared3.headhash = col ;\n\t}\n\telse\n\t{\n\t  /* degree list \"hash\" is empty, use head as hash bucket */\n\t  first_col = - (head_column + 2) ;\n\t  head [hash] = - (col + 2) ;\n\t}\n\tCol [col].shared4.hash_next = first_col ;\n\n\t/* save hash function in Col [col].shared3.hash */\n\tCol [col].shared3.hash = (IndexType) hash ;\n\tCOLAMD_ASSERT (COL_IS_ALIVE (col)) ;\n      }\n    }\n\n    /* The approximate external column degree is now computed.  */\n\n    /* === Supercolumn detection ======================================== */\n\n    COLAMD_DEBUG3 ((\"** Supercolumn detection phase. **\\n\")) ;\n\n    Eigen::internal::detect_super_cols (Col, A, head, pivot_row_start, pivot_row_length) ;\n\n    /* === Kill the pivotal column ====================================== */\n\n    KILL_PRINCIPAL_COL (pivot_col) ;\n\n    /* === Clear mark =================================================== */\n\n    tag_mark += (max_deg + 1) ;\n    if (tag_mark >= max_mark)\n    {\n      COLAMD_DEBUG2 ((\"clearing tag_mark\\n\")) ;\n      tag_mark = Eigen::internal::clear_mark (n_row, Row) ;\n    }\n\n    /* === Finalize the new pivot row, and column scores ================ */\n\n    COLAMD_DEBUG3 ((\"** Finalize scores phase. **\\n\")) ;\n\n    /* for each column in pivot row */\n    rp = &A [pivot_row_start] ;\n    /* compact the pivot row */\n    new_rp = rp ;\n    rp_end = rp + pivot_row_length ;\n    while (rp < rp_end)\n    {\n      col = *rp++ ;\n      /* skip dead columns */\n      if (COL_IS_DEAD (col))\n      {\n\tcontinue ;\n      }\n      *new_rp++ = col ;\n      /* add new pivot row to column */\n      A [Col [col].start + (Col [col].length++)] = pivot_row ;\n\n      /* retrieve score so far and add on pivot row's degree. */\n      /* (we wait until here for this in case the pivot */\n      /* row's degree was reduced due to mass elimination). */\n      cur_score = Col [col].shared2.score + pivot_row_degree ;\n\n      /* calculate the max possible score as the number of */\n      /* external columns minus the 'k' value minus the */\n      /* columns thickness */\n      max_score = n_col - k - Col [col].shared1.thickness ;\n\n      /* make the score the external degree of the union-of-rows */\n      cur_score -= Col [col].shared1.thickness ;\n\n      /* make sure score is less or equal than the max score */\n      cur_score = numext::mini(cur_score, max_score) ;\n      COLAMD_ASSERT (cur_score >= 0) ;\n\n      /* store updated score */\n      Col [col].shared2.score = cur_score ;\n\n      /* === Place column back in degree list ========================= */\n\n      COLAMD_ASSERT (min_score >= 0) ;\n      COLAMD_ASSERT (min_score <= n_col) ;\n      COLAMD_ASSERT (cur_score >= 0) ;\n      COLAMD_ASSERT (cur_score <= n_col) ;\n      COLAMD_ASSERT (head [cur_score] >= COLAMD_EMPTY) ;\n      next_col = head [cur_score] ;\n      Col [col].shared4.degree_next = next_col ;\n      Col [col].shared3.prev = COLAMD_EMPTY ;\n      if (next_col != COLAMD_EMPTY)\n      {\n\tCol [next_col].shared3.prev = col ;\n      }\n      head [cur_score] = col ;\n\n      /* see if this score is less than current min */\n      min_score = numext::mini(min_score, cur_score) ;\n\n    }\n\n    /* === Resurrect the new pivot row ================================== */\n\n    if (pivot_row_degree > 0)\n    {\n      /* update pivot row length to reflect any cols that were killed */\n      /* during super-col detection and mass elimination */\n      Row [pivot_row].start  = pivot_row_start ;\n      Row [pivot_row].length = (IndexType) (new_rp - &A[pivot_row_start]) ;\n      Row [pivot_row].shared1.degree = pivot_row_degree ;\n      Row [pivot_row].shared2.mark = 0 ;\n      /* pivot row is no longer dead */\n    }\n  }\n\n  /* === All principal columns have now been ordered ====================== */\n\n  return (ngarbage) ;\n}\n\n\n/* ========================================================================== */\n/* === order_children ======================================================= */\n/* ========================================================================== */\n\n/*\n  The find_ordering routine has ordered all of the principal columns (the\n  representatives of the supercolumns).  The non-principal columns have not\n  yet been ordered.  This routine orders those columns by walking up the\n  parent tree (a column is a child of the column which absorbed it).  The\n  final permutation vector is then placed in p [0 ... n_col-1], with p [0]\n  being the first column, and p [n_col-1] being the last.  It doesn't look\n  like it at first glance, but be assured that this routine takes time linear\n  in the number of columns.  Although not immediately obvious, the time\n  taken by this routine is O (n_col), that is, linear in the number of\n  columns.  Not user-callable.\n*/\ntemplate <typename IndexType>\nstatic inline  void order_children\n(\n  /* === Parameters ======================================================= */\n\n  IndexType n_col,      /* number of columns of A */\n  colamd_col<IndexType> Col [],    /* of size n_col+1 */\n  IndexType p []      /* p [0 ... n_col-1] is the column permutation*/\n  )\n{\n  /* === Local variables ================================================== */\n\n  IndexType i ;     /* loop counter for all columns */\n  IndexType c ;     /* column index */\n  IndexType parent ;    /* index of column's parent */\n  IndexType order ;     /* column's order */\n\n  /* === Order each non-principal column ================================== */\n\n  for (i = 0 ; i < n_col ; i++)\n  {\n    /* find an un-ordered non-principal column */\n    COLAMD_ASSERT (COL_IS_DEAD (i)) ;\n    if (!COL_IS_DEAD_PRINCIPAL (i) && Col [i].shared2.order == COLAMD_EMPTY)\n    {\n      parent = i ;\n      /* once found, find its principal parent */\n      do\n      {\n\tparent = Col [parent].shared1.parent ;\n      } while (!COL_IS_DEAD_PRINCIPAL (parent)) ;\n\n      /* now, order all un-ordered non-principal columns along path */\n      /* to this parent.  collapse tree at the same time */\n      c = i ;\n      /* get order of parent */\n      order = Col [parent].shared2.order ;\n\n      do\n      {\n\tCOLAMD_ASSERT (Col [c].shared2.order == COLAMD_EMPTY) ;\n\n\t/* order this column */\n\tCol [c].shared2.order = order++ ;\n\t/* collaps tree */\n\tCol [c].shared1.parent = parent ;\n\n\t/* get immediate parent of this column */\n\tc = Col [c].shared1.parent ;\n\n\t/* continue until we hit an ordered column.  There are */\n\t/* guarranteed not to be anymore unordered columns */\n\t/* above an ordered column */\n      } while (Col [c].shared2.order == COLAMD_EMPTY) ;\n\n      /* re-order the super_col parent to largest order for this group */\n      Col [parent].shared2.order = order ;\n    }\n  }\n\n  /* === Generate the permutation ========================================= */\n\n  for (c = 0 ; c < n_col ; c++)\n  {\n    p [Col [c].shared2.order] = c ;\n  }\n}\n\n\n/* ========================================================================== */\n/* === detect_super_cols ==================================================== */\n/* ========================================================================== */\n\n/*\n  Detects supercolumns by finding matches between columns in the hash buckets.\n  Check amongst columns in the set A [row_start ... row_start + row_length-1].\n  The columns under consideration are currently *not* in the degree lists,\n  and have already been placed in the hash buckets.\n\n  The hash bucket for columns whose hash function is equal to h is stored\n  as follows:\n\n  if head [h] is >= 0, then head [h] contains a degree list, so:\n\n  head [h] is the first column in degree bucket h.\n  Col [head [h]].headhash gives the first column in hash bucket h.\n\n  otherwise, the degree list is empty, and:\n\n  -(head [h] + 2) is the first column in hash bucket h.\n\n  For a column c in a hash bucket, Col [c].shared3.prev is NOT a \"previous\n  column\" pointer.  Col [c].shared3.hash is used instead as the hash number\n  for that column.  The value of Col [c].shared4.hash_next is the next column\n  in the same hash bucket.\n\n  Assuming no, or \"few\" hash collisions, the time taken by this routine is\n  linear in the sum of the sizes (lengths) of each column whose score has\n  just been computed in the approximate degree computation.\n  Not user-callable.\n*/\ntemplate <typename IndexType>\nstatic void detect_super_cols\n(\n  /* === Parameters ======================================================= */\n  \n  colamd_col<IndexType> Col [],    /* of size n_col+1 */\n  IndexType A [],     /* row indices of A */\n  IndexType head [],    /* head of degree lists and hash buckets */\n  IndexType row_start,    /* pointer to set of columns to check */\n  IndexType row_length    /* number of columns to check */\n)\n{\n  /* === Local variables ================================================== */\n\n  IndexType hash ;      /* hash value for a column */\n  IndexType *rp ;     /* pointer to a row */\n  IndexType c ;     /* a column index */\n  IndexType super_c ;   /* column index of the column to absorb into */\n  IndexType *cp1 ;      /* column pointer for column super_c */\n  IndexType *cp2 ;      /* column pointer for column c */\n  IndexType length ;    /* length of column super_c */\n  IndexType prev_c ;    /* column preceding c in hash bucket */\n  IndexType i ;     /* loop counter */\n  IndexType *rp_end ;   /* pointer to the end of the row */\n  IndexType col ;     /* a column index in the row to check */\n  IndexType head_column ;   /* first column in hash bucket or degree list */\n  IndexType first_col ;   /* first column in hash bucket */\n\n  /* === Consider each column in the row ================================== */\n\n  rp = &A [row_start] ;\n  rp_end = rp + row_length ;\n  while (rp < rp_end)\n  {\n    col = *rp++ ;\n    if (COL_IS_DEAD (col))\n    {\n      continue ;\n    }\n\n    /* get hash number for this column */\n    hash = Col [col].shared3.hash ;\n    COLAMD_ASSERT (hash <= n_col) ;\n\n    /* === Get the first column in this hash bucket ===================== */\n\n    head_column = head [hash] ;\n    if (head_column > COLAMD_EMPTY)\n    {\n      first_col = Col [head_column].shared3.headhash ;\n    }\n    else\n    {\n      first_col = - (head_column + 2) ;\n    }\n\n    /* === Consider each column in the hash bucket ====================== */\n\n    for (super_c = first_col ; super_c != COLAMD_EMPTY ;\n\t super_c = Col [super_c].shared4.hash_next)\n    {\n      COLAMD_ASSERT (COL_IS_ALIVE (super_c)) ;\n      COLAMD_ASSERT (Col [super_c].shared3.hash == hash) ;\n      length = Col [super_c].length ;\n\n      /* prev_c is the column preceding column c in the hash bucket */\n      prev_c = super_c ;\n\n      /* === Compare super_c with all columns after it ================ */\n\n      for (c = Col [super_c].shared4.hash_next ;\n\t   c != COLAMD_EMPTY ; c = Col [c].shared4.hash_next)\n      {\n\tCOLAMD_ASSERT (c != super_c) ;\n\tCOLAMD_ASSERT (COL_IS_ALIVE (c)) ;\n\tCOLAMD_ASSERT (Col [c].shared3.hash == hash) ;\n\n\t/* not identical if lengths or scores are different */\n\tif (Col [c].length != length ||\n\t    Col [c].shared2.score != Col [super_c].shared2.score)\n\t{\n\t  prev_c = c ;\n\t  continue ;\n\t}\n\n\t/* compare the two columns */\n\tcp1 = &A [Col [super_c].start] ;\n\tcp2 = &A [Col [c].start] ;\n\n\tfor (i = 0 ; i < length ; i++)\n\t{\n\t  /* the columns are \"clean\" (no dead rows) */\n\t  COLAMD_ASSERT (ROW_IS_ALIVE (*cp1))  ;\n\t  COLAMD_ASSERT (ROW_IS_ALIVE (*cp2))  ;\n\t  /* row indices will same order for both supercols, */\n\t  /* no gather scatter nessasary */\n\t  if (*cp1++ != *cp2++)\n\t  {\n\t    break ;\n\t  }\n\t}\n\n\t/* the two columns are different if the for-loop \"broke\" */\n\tif (i != length)\n\t{\n\t  prev_c = c ;\n\t  continue ;\n\t}\n\n\t/* === Got it!  two columns are identical =================== */\n\n\tCOLAMD_ASSERT (Col [c].shared2.score == Col [super_c].shared2.score) ;\n\n\tCol [super_c].shared1.thickness += Col [c].shared1.thickness ;\n\tCol [c].shared1.parent = super_c ;\n\tKILL_NON_PRINCIPAL_COL (c) ;\n\t/* order c later, in order_children() */\n\tCol [c].shared2.order = COLAMD_EMPTY ;\n\t/* remove c from hash bucket */\n\tCol [prev_c].shared4.hash_next = Col [c].shared4.hash_next ;\n      }\n    }\n\n    /* === Empty this hash bucket ======================================= */\n\n    if (head_column > COLAMD_EMPTY)\n    {\n      /* corresponding degree list \"hash\" is not empty */\n      Col [head_column].shared3.headhash = COLAMD_EMPTY ;\n    }\n    else\n    {\n      /* corresponding degree list \"hash\" is empty */\n      head [hash] = COLAMD_EMPTY ;\n    }\n  }\n}\n\n\n/* ========================================================================== */\n/* === garbage_collection =================================================== */\n/* ========================================================================== */\n\n/*\n  Defragments and compacts columns and rows in the workspace A.  Used when\n  all avaliable memory has been used while performing row merging.  Returns\n  the index of the first free position in A, after garbage collection.  The\n  time taken by this routine is linear is the size of the array A, which is\n  itself linear in the number of nonzeros in the input matrix.\n  Not user-callable.\n*/\ntemplate <typename IndexType>\nstatic IndexType garbage_collection  /* returns the new value of pfree */\n  (\n    /* === Parameters ======================================================= */\n    \n    IndexType n_row,      /* number of rows */\n    IndexType n_col,      /* number of columns */\n    Colamd_Row<IndexType> Row [],    /* row info */\n    colamd_col<IndexType> Col [],    /* column info */\n    IndexType A [],     /* A [0 ... Alen-1] holds the matrix */\n    IndexType *pfree      /* &A [0] ... pfree is in use */\n    )\n{\n  /* === Local variables ================================================== */\n\n  IndexType *psrc ;     /* source pointer */\n  IndexType *pdest ;    /* destination pointer */\n  IndexType j ;     /* counter */\n  IndexType r ;     /* a row index */\n  IndexType c ;     /* a column index */\n  IndexType length ;    /* length of a row or column */\n\n  /* === Defragment the columns =========================================== */\n\n  pdest = &A[0] ;\n  for (c = 0 ; c < n_col ; c++)\n  {\n    if (COL_IS_ALIVE (c))\n    {\n      psrc = &A [Col [c].start] ;\n\n      /* move and compact the column */\n      COLAMD_ASSERT (pdest <= psrc) ;\n      Col [c].start = (IndexType) (pdest - &A [0]) ;\n      length = Col [c].length ;\n      for (j = 0 ; j < length ; j++)\n      {\n\tr = *psrc++ ;\n\tif (ROW_IS_ALIVE (r))\n\t{\n\t  *pdest++ = r ;\n\t}\n      }\n      Col [c].length = (IndexType) (pdest - &A [Col [c].start]) ;\n    }\n  }\n\n  /* === Prepare to defragment the rows =================================== */\n\n  for (r = 0 ; r < n_row ; r++)\n  {\n    if (ROW_IS_ALIVE (r))\n    {\n      if (Row [r].length == 0)\n      {\n\t/* this row is of zero length.  cannot compact it, so kill it */\n\tCOLAMD_DEBUG3 ((\"Defrag row kill\\n\")) ;\n\tKILL_ROW (r) ;\n      }\n      else\n      {\n\t/* save first column index in Row [r].shared2.first_column */\n\tpsrc = &A [Row [r].start] ;\n\tRow [r].shared2.first_column = *psrc ;\n\tCOLAMD_ASSERT (ROW_IS_ALIVE (r)) ;\n\t/* flag the start of the row with the one's complement of row */\n\t*psrc = ONES_COMPLEMENT (r) ;\n\n      }\n    }\n  }\n\n  /* === Defragment the rows ============================================== */\n\n  psrc = pdest ;\n  while (psrc < pfree)\n  {\n    /* find a negative number ... the start of a row */\n    if (*psrc++ < 0)\n    {\n      psrc-- ;\n      /* get the row index */\n      r = ONES_COMPLEMENT (*psrc) ;\n      COLAMD_ASSERT (r >= 0 && r < n_row) ;\n      /* restore first column index */\n      *psrc = Row [r].shared2.first_column ;\n      COLAMD_ASSERT (ROW_IS_ALIVE (r)) ;\n\n      /* move and compact the row */\n      COLAMD_ASSERT (pdest <= psrc) ;\n      Row [r].start = (IndexType) (pdest - &A [0]) ;\n      length = Row [r].length ;\n      for (j = 0 ; j < length ; j++)\n      {\n\tc = *psrc++ ;\n\tif (COL_IS_ALIVE (c))\n\t{\n\t  *pdest++ = c ;\n\t}\n      }\n      Row [r].length = (IndexType) (pdest - &A [Row [r].start]) ;\n\n    }\n  }\n  /* ensure we found all the rows */\n  COLAMD_ASSERT (debug_rows == 0) ;\n\n  /* === Return the new value of pfree ==================================== */\n\n  return ((IndexType) (pdest - &A [0])) ;\n}\n\n\n/* ========================================================================== */\n/* === clear_mark =========================================================== */\n/* ========================================================================== */\n\n/*\n  Clears the Row [].shared2.mark array, and returns the new tag_mark.\n  Return value is the new tag_mark.  Not user-callable.\n*/\ntemplate <typename IndexType>\nstatic inline  IndexType clear_mark  /* return the new value for tag_mark */\n  (\n      /* === Parameters ======================================================= */\n\n    IndexType n_row,    /* number of rows in A */\n    Colamd_Row<IndexType> Row [] /* Row [0 ... n_row-1].shared2.mark is set to zero */\n    )\n{\n  /* === Local variables ================================================== */\n\n  IndexType r ;\n\n  for (r = 0 ; r < n_row ; r++)\n  {\n    if (ROW_IS_ALIVE (r))\n    {\n      Row [r].shared2.mark = 0 ;\n    }\n  }\n  return (1) ;\n}\n\n\n} // namespace internal \n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/OrderingMethods/Ordering.h",
    "content": " \n// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012  Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_ORDERING_H\n#define EIGEN_ORDERING_H\n\nnamespace Eigen {\n  \n#include \"Eigen_Colamd.h\"\n\nnamespace internal {\n    \n/** \\internal\n  * \\ingroup OrderingMethods_Module\n  * \\param[in] A the input non-symmetric matrix\n  * \\param[out] symmat the symmetric pattern A^T+A from the input matrix \\a A.\n  * FIXME: The values should not be considered here\n  */\ntemplate<typename MatrixType> \nvoid ordering_helper_at_plus_a(const MatrixType& A, MatrixType& symmat)\n{\n  MatrixType C;\n  C = A.transpose(); // NOTE: Could be  costly\n  for (int i = 0; i < C.rows(); i++) \n  {\n      for (typename MatrixType::InnerIterator it(C, i); it; ++it)\n        it.valueRef() = 0.0;\n  }\n  symmat = C + A;\n}\n    \n}\n\n#ifndef EIGEN_MPL2_ONLY\n\n/** \\ingroup OrderingMethods_Module\n  * \\class AMDOrdering\n  *\n  * Functor computing the \\em approximate \\em minimum \\em degree ordering\n  * If the matrix is not structurally symmetric, an ordering of A^T+A is computed\n  * \\tparam  StorageIndex The type of indices of the matrix \n  * \\sa COLAMDOrdering\n  */\ntemplate <typename StorageIndex>\nclass AMDOrdering\n{\n  public:\n    typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType;\n    \n    /** Compute the permutation vector from a sparse matrix\n     * This routine is much faster if the input matrix is column-major     \n     */\n    template <typename MatrixType>\n    void operator()(const MatrixType& mat, PermutationType& perm)\n    {\n      // Compute the symmetric pattern\n      SparseMatrix<typename MatrixType::Scalar, ColMajor, StorageIndex> symm;\n      internal::ordering_helper_at_plus_a(mat,symm); \n    \n      // Call the AMD routine \n      //m_mat.prune(keep_diag());\n      internal::minimum_degree_ordering(symm, perm);\n    }\n    \n    /** Compute the permutation with a selfadjoint matrix */\n    template <typename SrcType, unsigned int SrcUpLo> \n    void operator()(const SparseSelfAdjointView<SrcType, SrcUpLo>& mat, PermutationType& perm)\n    { \n      SparseMatrix<typename SrcType::Scalar, ColMajor, StorageIndex> C; C = mat;\n      \n      // Call the AMD routine \n      // m_mat.prune(keep_diag()); //Remove the diagonal elements \n      internal::minimum_degree_ordering(C, perm);\n    }\n};\n\n#endif // EIGEN_MPL2_ONLY\n\n/** \\ingroup OrderingMethods_Module\n  * \\class NaturalOrdering\n  *\n  * Functor computing the natural ordering (identity)\n  * \n  * \\note Returns an empty permutation matrix\n  * \\tparam  StorageIndex The type of indices of the matrix \n  */\ntemplate <typename StorageIndex>\nclass NaturalOrdering\n{\n  public:\n    typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType;\n    \n    /** Compute the permutation vector from a column-major sparse matrix */\n    template <typename MatrixType>\n    void operator()(const MatrixType& /*mat*/, PermutationType& perm)\n    {\n      perm.resize(0); \n    }\n    \n};\n\n/** \\ingroup OrderingMethods_Module\n  * \\class COLAMDOrdering\n  *\n  * \\tparam  StorageIndex The type of indices of the matrix \n  * \n  * Functor computing the \\em column \\em approximate \\em minimum \\em degree ordering \n  * The matrix should be in column-major and \\b compressed format (see SparseMatrix::makeCompressed()).\n  */\ntemplate<typename StorageIndex>\nclass COLAMDOrdering\n{\n  public:\n    typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType; \n    typedef Matrix<StorageIndex, Dynamic, 1> IndexVector;\n    \n    /** Compute the permutation vector \\a perm form the sparse matrix \\a mat\n      * \\warning The input sparse matrix \\a mat must be in compressed mode (see SparseMatrix::makeCompressed()).\n      */\n    template <typename MatrixType>\n    void operator() (const MatrixType& mat, PermutationType& perm)\n    {\n      eigen_assert(mat.isCompressed() && \"COLAMDOrdering requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it to COLAMDOrdering\");\n      \n      StorageIndex m = StorageIndex(mat.rows());\n      StorageIndex n = StorageIndex(mat.cols());\n      StorageIndex nnz = StorageIndex(mat.nonZeros());\n      // Get the recommended value of Alen to be used by colamd\n      StorageIndex Alen = internal::colamd_recommended(nnz, m, n); \n      // Set the default parameters\n      double knobs [COLAMD_KNOBS]; \n      StorageIndex stats [COLAMD_STATS];\n      internal::colamd_set_defaults(knobs);\n      \n      IndexVector p(n+1), A(Alen); \n      for(StorageIndex i=0; i <= n; i++)   p(i) = mat.outerIndexPtr()[i];\n      for(StorageIndex i=0; i < nnz; i++)  A(i) = mat.innerIndexPtr()[i];\n      // Call Colamd routine to compute the ordering \n      StorageIndex info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats); \n      EIGEN_UNUSED_VARIABLE(info);\n      eigen_assert( info && \"COLAMD failed \" );\n      \n      perm.resize(n);\n      for (StorageIndex i = 0; i < n; i++) perm.indices()(p(i)) = i;\n    }\n};\n\n} // end namespace Eigen\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/PaStiXSupport/PaStiXSupport.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PASTIXSUPPORT_H\n#define EIGEN_PASTIXSUPPORT_H\n\nnamespace Eigen { \n\n#if defined(DCOMPLEX)\n  #define PASTIX_COMPLEX  COMPLEX\n  #define PASTIX_DCOMPLEX DCOMPLEX\n#else\n  #define PASTIX_COMPLEX  std::complex<float>\n  #define PASTIX_DCOMPLEX std::complex<double>\n#endif\n\n/** \\ingroup PaStiXSupport_Module\n  * \\brief Interface to the PaStix solver\n  * \n  * This class is used to solve the linear systems A.X = B via the PaStix library. \n  * The matrix can be either real or complex, symmetric or not.\n  *\n  * \\sa TutorialSparseDirectSolvers\n  */\ntemplate<typename _MatrixType, bool IsStrSym = false> class PastixLU;\ntemplate<typename _MatrixType, int Options> class PastixLLT;\ntemplate<typename _MatrixType, int Options> class PastixLDLT;\n\nnamespace internal\n{\n    \n  template<class Pastix> struct pastix_traits;\n\n  template<typename _MatrixType>\n  struct pastix_traits< PastixLU<_MatrixType> >\n  {\n    typedef _MatrixType MatrixType;\n    typedef typename _MatrixType::Scalar Scalar;\n    typedef typename _MatrixType::RealScalar RealScalar;\n    typedef typename _MatrixType::StorageIndex StorageIndex;\n  };\n\n  template<typename _MatrixType, int Options>\n  struct pastix_traits< PastixLLT<_MatrixType,Options> >\n  {\n    typedef _MatrixType MatrixType;\n    typedef typename _MatrixType::Scalar Scalar;\n    typedef typename _MatrixType::RealScalar RealScalar;\n    typedef typename _MatrixType::StorageIndex StorageIndex;\n  };\n\n  template<typename _MatrixType, int Options>\n  struct pastix_traits< PastixLDLT<_MatrixType,Options> >\n  {\n    typedef _MatrixType MatrixType;\n    typedef typename _MatrixType::Scalar Scalar;\n    typedef typename _MatrixType::RealScalar RealScalar;\n    typedef typename _MatrixType::StorageIndex StorageIndex;\n  };\n  \n  void eigen_pastix(pastix_data_t **pastix_data, int pastix_comm, int n, int *ptr, int *idx, float *vals, int *perm, int * invp, float *x, int nbrhs, int *iparm, double *dparm)\n  {\n    if (n == 0) { ptr = NULL; idx = NULL; vals = NULL; }\n    if (nbrhs == 0) {x = NULL; nbrhs=1;}\n    s_pastix(pastix_data, pastix_comm, n, ptr, idx, vals, perm, invp, x, nbrhs, iparm, dparm); \n  }\n  \n  void eigen_pastix(pastix_data_t **pastix_data, int pastix_comm, int n, int *ptr, int *idx, double *vals, int *perm, int * invp, double *x, int nbrhs, int *iparm, double *dparm)\n  {\n    if (n == 0) { ptr = NULL; idx = NULL; vals = NULL; }\n    if (nbrhs == 0) {x = NULL; nbrhs=1;}\n    d_pastix(pastix_data, pastix_comm, n, ptr, idx, vals, perm, invp, x, nbrhs, iparm, dparm); \n  }\n  \n  void eigen_pastix(pastix_data_t **pastix_data, int pastix_comm, int n, int *ptr, int *idx, std::complex<float> *vals, int *perm, int * invp, std::complex<float> *x, int nbrhs, int *iparm, double *dparm)\n  {\n    if (n == 0) { ptr = NULL; idx = NULL; vals = NULL; }\n    if (nbrhs == 0) {x = NULL; nbrhs=1;}\n    c_pastix(pastix_data, pastix_comm, n, ptr, idx, reinterpret_cast<PASTIX_COMPLEX*>(vals), perm, invp, reinterpret_cast<PASTIX_COMPLEX*>(x), nbrhs, iparm, dparm); \n  }\n  \n  void eigen_pastix(pastix_data_t **pastix_data, int pastix_comm, int n, int *ptr, int *idx, std::complex<double> *vals, int *perm, int * invp, std::complex<double> *x, int nbrhs, int *iparm, double *dparm)\n  {\n    if (n == 0) { ptr = NULL; idx = NULL; vals = NULL; }\n    if (nbrhs == 0) {x = NULL; nbrhs=1;}\n    z_pastix(pastix_data, pastix_comm, n, ptr, idx, reinterpret_cast<PASTIX_DCOMPLEX*>(vals), perm, invp, reinterpret_cast<PASTIX_DCOMPLEX*>(x), nbrhs, iparm, dparm); \n  }\n\n  // Convert the matrix  to Fortran-style Numbering\n  template <typename MatrixType>\n  void c_to_fortran_numbering (MatrixType& mat)\n  {\n    if ( !(mat.outerIndexPtr()[0]) ) \n    { \n      int i;\n      for(i = 0; i <= mat.rows(); ++i)\n        ++mat.outerIndexPtr()[i];\n      for(i = 0; i < mat.nonZeros(); ++i)\n        ++mat.innerIndexPtr()[i];\n    }\n  }\n  \n  // Convert to C-style Numbering\n  template <typename MatrixType>\n  void fortran_to_c_numbering (MatrixType& mat)\n  {\n    // Check the Numbering\n    if ( mat.outerIndexPtr()[0] == 1 ) \n    { // Convert to C-style numbering\n      int i;\n      for(i = 0; i <= mat.rows(); ++i)\n        --mat.outerIndexPtr()[i];\n      for(i = 0; i < mat.nonZeros(); ++i)\n        --mat.innerIndexPtr()[i];\n    }\n  }\n}\n\n// This is the base class to interface with PaStiX functions. \n// Users should not used this class directly. \ntemplate <class Derived>\nclass PastixBase : public SparseSolverBase<Derived>\n{\n  protected:\n    typedef SparseSolverBase<Derived> Base;\n    using Base::derived;\n    using Base::m_isInitialized;\n  public:\n    using Base::_solve_impl;\n    \n    typedef typename internal::pastix_traits<Derived>::MatrixType _MatrixType;\n    typedef _MatrixType MatrixType;\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef Matrix<Scalar,Dynamic,1> Vector;\n    typedef SparseMatrix<Scalar, ColMajor> ColSpMatrix;\n    enum {\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n    \n  public:\n    \n    PastixBase() : m_initisOk(false), m_analysisIsOk(false), m_factorizationIsOk(false), m_pastixdata(0), m_size(0)\n    {\n      init();\n    }\n    \n    ~PastixBase() \n    {\n      clean();\n    }\n    \n    template<typename Rhs,typename Dest>\n    bool _solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &x) const;\n    \n    /** Returns a reference to the integer vector IPARM of PaStiX parameters\n      * to modify the default parameters. \n      * The statistics related to the different phases of factorization and solve are saved here as well\n      * \\sa analyzePattern() factorize()\n      */\n    Array<StorageIndex,IPARM_SIZE,1>& iparm()\n    {\n      return m_iparm; \n    }\n    \n    /** Return a reference to a particular index parameter of the IPARM vector \n     * \\sa iparm()\n     */\n    \n    int& iparm(int idxparam)\n    {\n      return m_iparm(idxparam);\n    }\n    \n     /** Returns a reference to the double vector DPARM of PaStiX parameters \n      * The statistics related to the different phases of factorization and solve are saved here as well\n      * \\sa analyzePattern() factorize()\n      */\n    Array<double,DPARM_SIZE,1>& dparm()\n    {\n      return m_dparm; \n    }\n    \n    \n    /** Return a reference to a particular index parameter of the DPARM vector \n     * \\sa dparm()\n     */\n    double& dparm(int idxparam)\n    {\n      return m_dparm(idxparam);\n    }\n    \n    inline Index cols() const { return m_size; }\n    inline Index rows() const { return m_size; }\n    \n     /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful,\n      *          \\c NumericalIssue if the PaStiX reports a problem\n      *          \\c InvalidInput if the input matrix is invalid\n      *\n      * \\sa iparm()          \n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return m_info;\n    }\n    \n  protected:\n\n    // Initialize the Pastix data structure, check the matrix\n    void init(); \n    \n    // Compute the ordering and the symbolic factorization\n    void analyzePattern(ColSpMatrix& mat);\n    \n    // Compute the numerical factorization\n    void factorize(ColSpMatrix& mat);\n    \n    // Free all the data allocated by Pastix\n    void clean()\n    {\n      eigen_assert(m_initisOk && \"The Pastix structure should be allocated first\"); \n      m_iparm(IPARM_START_TASK) = API_TASK_CLEAN;\n      m_iparm(IPARM_END_TASK) = API_TASK_CLEAN;\n      internal::eigen_pastix(&m_pastixdata, MPI_COMM_WORLD, 0, 0, 0, (Scalar*)0,\n                             m_perm.data(), m_invp.data(), 0, 0, m_iparm.data(), m_dparm.data());\n    }\n    \n    void compute(ColSpMatrix& mat);\n    \n    int m_initisOk; \n    int m_analysisIsOk;\n    int m_factorizationIsOk;\n    mutable ComputationInfo m_info; \n    mutable pastix_data_t *m_pastixdata; // Data structure for pastix\n    mutable int m_comm; // The MPI communicator identifier\n    mutable Array<int,IPARM_SIZE,1> m_iparm; // integer vector for the input parameters\n    mutable Array<double,DPARM_SIZE,1> m_dparm; // Scalar vector for the input parameters\n    mutable Matrix<StorageIndex,Dynamic,1> m_perm;  // Permutation vector\n    mutable Matrix<StorageIndex,Dynamic,1> m_invp;  // Inverse permutation vector\n    mutable int m_size; // Size of the matrix \n}; \n\n /** Initialize the PaStiX data structure. \n   *A first call to this function fills iparm and dparm with the default PaStiX parameters\n   * \\sa iparm() dparm()\n   */\ntemplate <class Derived>\nvoid PastixBase<Derived>::init()\n{\n  m_size = 0; \n  m_iparm.setZero(IPARM_SIZE);\n  m_dparm.setZero(DPARM_SIZE);\n  \n  m_iparm(IPARM_MODIFY_PARAMETER) = API_NO;\n  pastix(&m_pastixdata, MPI_COMM_WORLD,\n         0, 0, 0, 0,\n         0, 0, 0, 1, m_iparm.data(), m_dparm.data());\n  \n  m_iparm[IPARM_MATRIX_VERIFICATION] = API_NO;\n  m_iparm[IPARM_VERBOSE]             = API_VERBOSE_NOT;\n  m_iparm[IPARM_ORDERING]            = API_ORDER_SCOTCH;\n  m_iparm[IPARM_INCOMPLETE]          = API_NO;\n  m_iparm[IPARM_OOC_LIMIT]           = 2000;\n  m_iparm[IPARM_RHS_MAKING]          = API_RHS_B;\n  m_iparm(IPARM_MATRIX_VERIFICATION) = API_NO;\n  \n  m_iparm(IPARM_START_TASK) = API_TASK_INIT;\n  m_iparm(IPARM_END_TASK) = API_TASK_INIT;\n  internal::eigen_pastix(&m_pastixdata, MPI_COMM_WORLD, 0, 0, 0, (Scalar*)0,\n                         0, 0, 0, 0, m_iparm.data(), m_dparm.data());\n  \n  // Check the returned error\n  if(m_iparm(IPARM_ERROR_NUMBER)) {\n    m_info = InvalidInput;\n    m_initisOk = false;\n  }\n  else { \n    m_info = Success;\n    m_initisOk = true;\n  }\n}\n\ntemplate <class Derived>\nvoid PastixBase<Derived>::compute(ColSpMatrix& mat)\n{\n  eigen_assert(mat.rows() == mat.cols() && \"The input matrix should be squared\");\n  \n  analyzePattern(mat);  \n  factorize(mat);\n  \n  m_iparm(IPARM_MATRIX_VERIFICATION) = API_NO;\n}\n\n\ntemplate <class Derived>\nvoid PastixBase<Derived>::analyzePattern(ColSpMatrix& mat)\n{                         \n  eigen_assert(m_initisOk && \"The initialization of PaSTiX failed\");\n  \n  // clean previous calls\n  if(m_size>0)\n    clean();\n  \n  m_size = internal::convert_index<int>(mat.rows());\n  m_perm.resize(m_size);\n  m_invp.resize(m_size);\n  \n  m_iparm(IPARM_START_TASK) = API_TASK_ORDERING;\n  m_iparm(IPARM_END_TASK) = API_TASK_ANALYSE;\n  internal::eigen_pastix(&m_pastixdata, MPI_COMM_WORLD, m_size, mat.outerIndexPtr(), mat.innerIndexPtr(),\n               mat.valuePtr(), m_perm.data(), m_invp.data(), 0, 0, m_iparm.data(), m_dparm.data());\n  \n  // Check the returned error\n  if(m_iparm(IPARM_ERROR_NUMBER))\n  {\n    m_info = NumericalIssue;\n    m_analysisIsOk = false;\n  }\n  else\n  { \n    m_info = Success;\n    m_analysisIsOk = true;\n  }\n}\n\ntemplate <class Derived>\nvoid PastixBase<Derived>::factorize(ColSpMatrix& mat)\n{\n//   if(&m_cpyMat != &mat) m_cpyMat = mat;\n  eigen_assert(m_analysisIsOk && \"The analysis phase should be called before the factorization phase\");\n  m_iparm(IPARM_START_TASK) = API_TASK_NUMFACT;\n  m_iparm(IPARM_END_TASK) = API_TASK_NUMFACT;\n  m_size = internal::convert_index<int>(mat.rows());\n  \n  internal::eigen_pastix(&m_pastixdata, MPI_COMM_WORLD, m_size, mat.outerIndexPtr(), mat.innerIndexPtr(),\n               mat.valuePtr(), m_perm.data(), m_invp.data(), 0, 0, m_iparm.data(), m_dparm.data());\n  \n  // Check the returned error\n  if(m_iparm(IPARM_ERROR_NUMBER))\n  {\n    m_info = NumericalIssue;\n    m_factorizationIsOk = false;\n    m_isInitialized = false;\n  }\n  else\n  {\n    m_info = Success;\n    m_factorizationIsOk = true;\n    m_isInitialized = true;\n  }\n}\n\n/* Solve the system */\ntemplate<typename Base>\ntemplate<typename Rhs,typename Dest>\nbool PastixBase<Base>::_solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &x) const\n{\n  eigen_assert(m_isInitialized && \"The matrix should be factorized first\");\n  EIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0,\n                     THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);\n  int rhs = 1;\n  \n  x = b; /* on return, x is overwritten by the computed solution */\n  \n  for (int i = 0; i < b.cols(); i++){\n    m_iparm[IPARM_START_TASK]          = API_TASK_SOLVE;\n    m_iparm[IPARM_END_TASK]            = API_TASK_REFINE;\n  \n    internal::eigen_pastix(&m_pastixdata, MPI_COMM_WORLD, internal::convert_index<int>(x.rows()), 0, 0, 0,\n                           m_perm.data(), m_invp.data(), &x(0, i), rhs, m_iparm.data(), m_dparm.data());\n  }\n  \n  // Check the returned error\n  m_info = m_iparm(IPARM_ERROR_NUMBER)==0 ? Success : NumericalIssue;\n  \n  return m_iparm(IPARM_ERROR_NUMBER)==0;\n}\n\n/** \\ingroup PaStiXSupport_Module\n  * \\class PastixLU\n  * \\brief Sparse direct LU solver based on PaStiX library\n  * \n  * This class is used to solve the linear systems A.X = B with a supernodal LU \n  * factorization in the PaStiX library. The matrix A should be squared and nonsingular\n  * PaStiX requires that the matrix A has a symmetric structural pattern. \n  * This interface can symmetrize the input matrix otherwise. \n  * The vectors or matrices X and B can be either dense or sparse.\n  * \n  * \\tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  * \\tparam IsStrSym Indicates if the input matrix has a symmetric pattern, default is false\n  * NOTE : Note that if the analysis and factorization phase are called separately, \n  * the input matrix will be symmetrized at each call, hence it is advised to \n  * symmetrize the matrix in a end-user program and set \\p IsStrSym to true\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa \\ref TutorialSparseSolverConcept, class SparseLU\n  * \n  */\ntemplate<typename _MatrixType, bool IsStrSym>\nclass PastixLU : public PastixBase< PastixLU<_MatrixType> >\n{\n  public:\n    typedef _MatrixType MatrixType;\n    typedef PastixBase<PastixLU<MatrixType> > Base;\n    typedef typename Base::ColSpMatrix ColSpMatrix;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    \n  public:\n    PastixLU() : Base()\n    {\n      init();\n    }\n    \n    explicit PastixLU(const MatrixType& matrix):Base()\n    {\n      init();\n      compute(matrix);\n    }\n    /** Compute the LU supernodal factorization of \\p matrix. \n      * iparm and dparm can be used to tune the PaStiX parameters. \n      * see the PaStiX user's manual\n      * \\sa analyzePattern() factorize()\n      */\n    void compute (const MatrixType& matrix)\n    {\n      m_structureIsUptodate = false;\n      ColSpMatrix temp;\n      grabMatrix(matrix, temp);\n      Base::compute(temp);\n    }\n    /** Compute the LU symbolic factorization of \\p matrix using its sparsity pattern. \n      * Several ordering methods can be used at this step. See the PaStiX user's manual. \n      * The result of this operation can be used with successive matrices having the same pattern as \\p matrix\n      * \\sa factorize()\n      */\n    void analyzePattern(const MatrixType& matrix)\n    {\n      m_structureIsUptodate = false;\n      ColSpMatrix temp;\n      grabMatrix(matrix, temp);\n      Base::analyzePattern(temp);\n    }\n\n    /** Compute the LU supernodal factorization of \\p matrix\n      * WARNING The matrix \\p matrix should have the same structural pattern \n      * as the same used in the analysis phase.\n      * \\sa analyzePattern()\n      */ \n    void factorize(const MatrixType& matrix)\n    {\n      ColSpMatrix temp;\n      grabMatrix(matrix, temp);\n      Base::factorize(temp);\n    }\n  protected:\n    \n    void init()\n    {\n      m_structureIsUptodate = false;\n      m_iparm(IPARM_SYM) = API_SYM_NO;\n      m_iparm(IPARM_FACTORIZATION) = API_FACT_LU;\n    }\n    \n    void grabMatrix(const MatrixType& matrix, ColSpMatrix& out)\n    {\n      if(IsStrSym)\n        out = matrix;\n      else\n      {\n        if(!m_structureIsUptodate)\n        {\n          // update the transposed structure\n          m_transposedStructure = matrix.transpose();\n          \n          // Set the elements of the matrix to zero \n          for (Index j=0; j<m_transposedStructure.outerSize(); ++j) \n            for(typename ColSpMatrix::InnerIterator it(m_transposedStructure, j); it; ++it)\n              it.valueRef() = 0.0;\n\n          m_structureIsUptodate = true;\n        }\n        \n        out = m_transposedStructure + matrix;\n      }\n      internal::c_to_fortran_numbering(out);\n    }\n    \n    using Base::m_iparm;\n    using Base::m_dparm;\n    \n    ColSpMatrix m_transposedStructure;\n    bool m_structureIsUptodate;\n};\n\n/** \\ingroup PaStiXSupport_Module\n  * \\class PastixLLT\n  * \\brief A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library\n  * \n  * This class is used to solve the linear systems A.X = B via a LL^T supernodal Cholesky factorization\n  * available in the PaStiX library. The matrix A should be symmetric and positive definite\n  * WARNING Selfadjoint complex matrices are not supported in the current version of PaStiX\n  * The vectors or matrices X and B can be either dense or sparse\n  * \n  * \\tparam MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  * \\tparam UpLo The part of the matrix to use : Lower or Upper. The default is Lower as required by PaStiX\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa \\ref TutorialSparseSolverConcept, class SimplicialLLT\n  */\ntemplate<typename _MatrixType, int _UpLo>\nclass PastixLLT : public PastixBase< PastixLLT<_MatrixType, _UpLo> >\n{\n  public:\n    typedef _MatrixType MatrixType;\n    typedef PastixBase<PastixLLT<MatrixType, _UpLo> > Base;\n    typedef typename Base::ColSpMatrix ColSpMatrix;\n    \n  public:\n    enum { UpLo = _UpLo };\n    PastixLLT() : Base()\n    {\n      init();\n    }\n    \n    explicit PastixLLT(const MatrixType& matrix):Base()\n    {\n      init();\n      compute(matrix);\n    }\n\n    /** Compute the L factor of the LL^T supernodal factorization of \\p matrix \n      * \\sa analyzePattern() factorize()\n      */\n    void compute (const MatrixType& matrix)\n    {\n      ColSpMatrix temp;\n      grabMatrix(matrix, temp);\n      Base::compute(temp);\n    }\n\n     /** Compute the LL^T symbolic factorization of \\p matrix using its sparsity pattern\n      * The result of this operation can be used with successive matrices having the same pattern as \\p matrix\n      * \\sa factorize()\n      */\n    void analyzePattern(const MatrixType& matrix)\n    {\n      ColSpMatrix temp;\n      grabMatrix(matrix, temp);\n      Base::analyzePattern(temp);\n    }\n      /** Compute the LL^T supernodal numerical factorization of \\p matrix \n        * \\sa analyzePattern()\n        */\n    void factorize(const MatrixType& matrix)\n    {\n      ColSpMatrix temp;\n      grabMatrix(matrix, temp);\n      Base::factorize(temp);\n    }\n  protected:\n    using Base::m_iparm;\n    \n    void init()\n    {\n      m_iparm(IPARM_SYM) = API_SYM_YES;\n      m_iparm(IPARM_FACTORIZATION) = API_FACT_LLT;\n    }\n    \n    void grabMatrix(const MatrixType& matrix, ColSpMatrix& out)\n    {\n      out.resize(matrix.rows(), matrix.cols());\n      // Pastix supports only lower, column-major matrices \n      out.template selfadjointView<Lower>() = matrix.template selfadjointView<UpLo>();\n      internal::c_to_fortran_numbering(out);\n    }\n};\n\n/** \\ingroup PaStiXSupport_Module\n  * \\class PastixLDLT\n  * \\brief A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library\n  * \n  * This class is used to solve the linear systems A.X = B via a LDL^T supernodal Cholesky factorization\n  * available in the PaStiX library. The matrix A should be symmetric and positive definite\n  * WARNING Selfadjoint complex matrices are not supported in the current version of PaStiX\n  * The vectors or matrices X and B can be either dense or sparse\n  * \n  * \\tparam MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  * \\tparam UpLo The part of the matrix to use : Lower or Upper. The default is Lower as required by PaStiX\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa \\ref TutorialSparseSolverConcept, class SimplicialLDLT\n  */\ntemplate<typename _MatrixType, int _UpLo>\nclass PastixLDLT : public PastixBase< PastixLDLT<_MatrixType, _UpLo> >\n{\n  public:\n    typedef _MatrixType MatrixType;\n    typedef PastixBase<PastixLDLT<MatrixType, _UpLo> > Base; \n    typedef typename Base::ColSpMatrix ColSpMatrix;\n    \n  public:\n    enum { UpLo = _UpLo };\n    PastixLDLT():Base()\n    {\n      init();\n    }\n    \n    explicit PastixLDLT(const MatrixType& matrix):Base()\n    {\n      init();\n      compute(matrix);\n    }\n\n    /** Compute the L and D factors of the LDL^T factorization of \\p matrix \n      * \\sa analyzePattern() factorize()\n      */\n    void compute (const MatrixType& matrix)\n    {\n      ColSpMatrix temp;\n      grabMatrix(matrix, temp);\n      Base::compute(temp);\n    }\n\n    /** Compute the LDL^T symbolic factorization of \\p matrix using its sparsity pattern\n      * The result of this operation can be used with successive matrices having the same pattern as \\p matrix\n      * \\sa factorize()\n      */\n    void analyzePattern(const MatrixType& matrix)\n    { \n      ColSpMatrix temp;\n      grabMatrix(matrix, temp);\n      Base::analyzePattern(temp);\n    }\n    /** Compute the LDL^T supernodal numerical factorization of \\p matrix \n      * \n      */\n    void factorize(const MatrixType& matrix)\n    {\n      ColSpMatrix temp;\n      grabMatrix(matrix, temp);\n      Base::factorize(temp);\n    }\n\n  protected:\n    using Base::m_iparm;\n    \n    void init()\n    {\n      m_iparm(IPARM_SYM) = API_SYM_YES;\n      m_iparm(IPARM_FACTORIZATION) = API_FACT_LDLT;\n    }\n    \n    void grabMatrix(const MatrixType& matrix, ColSpMatrix& out)\n    {\n      // Pastix supports only lower, column-major matrices \n      out.resize(matrix.rows(), matrix.cols());\n      out.template selfadjointView<Lower>() = matrix.template selfadjointView<UpLo>();\n      internal::c_to_fortran_numbering(out);\n    }\n};\n\n} // end namespace Eigen\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/PardisoSupport/PardisoSupport.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to Intel(R) MKL PARDISO\n ********************************************************************************\n*/\n\n#ifndef EIGEN_PARDISOSUPPORT_H\n#define EIGEN_PARDISOSUPPORT_H\n\nnamespace Eigen { \n\ntemplate<typename _MatrixType> class PardisoLU;\ntemplate<typename _MatrixType, int Options=Upper> class PardisoLLT;\ntemplate<typename _MatrixType, int Options=Upper> class PardisoLDLT;\n\nnamespace internal\n{\n  template<typename IndexType>\n  struct pardiso_run_selector\n  {\n    static IndexType run( _MKL_DSS_HANDLE_t pt, IndexType maxfct, IndexType mnum, IndexType type, IndexType phase, IndexType n, void *a,\n                      IndexType *ia, IndexType *ja, IndexType *perm, IndexType nrhs, IndexType *iparm, IndexType msglvl, void *b, void *x)\n    {\n      IndexType error = 0;\n      ::pardiso(pt, &maxfct, &mnum, &type, &phase, &n, a, ia, ja, perm, &nrhs, iparm, &msglvl, b, x, &error);\n      return error;\n    }\n  };\n  template<>\n  struct pardiso_run_selector<long long int>\n  {\n    typedef long long int IndexType;\n    static IndexType run( _MKL_DSS_HANDLE_t pt, IndexType maxfct, IndexType mnum, IndexType type, IndexType phase, IndexType n, void *a,\n                      IndexType *ia, IndexType *ja, IndexType *perm, IndexType nrhs, IndexType *iparm, IndexType msglvl, void *b, void *x)\n    {\n      IndexType error = 0;\n      ::pardiso_64(pt, &maxfct, &mnum, &type, &phase, &n, a, ia, ja, perm, &nrhs, iparm, &msglvl, b, x, &error);\n      return error;\n    }\n  };\n\n  template<class Pardiso> struct pardiso_traits;\n\n  template<typename _MatrixType>\n  struct pardiso_traits< PardisoLU<_MatrixType> >\n  {\n    typedef _MatrixType MatrixType;\n    typedef typename _MatrixType::Scalar Scalar;\n    typedef typename _MatrixType::RealScalar RealScalar;\n    typedef typename _MatrixType::StorageIndex StorageIndex;\n  };\n\n  template<typename _MatrixType, int Options>\n  struct pardiso_traits< PardisoLLT<_MatrixType, Options> >\n  {\n    typedef _MatrixType MatrixType;\n    typedef typename _MatrixType::Scalar Scalar;\n    typedef typename _MatrixType::RealScalar RealScalar;\n    typedef typename _MatrixType::StorageIndex StorageIndex;\n  };\n\n  template<typename _MatrixType, int Options>\n  struct pardiso_traits< PardisoLDLT<_MatrixType, Options> >\n  {\n    typedef _MatrixType MatrixType;\n    typedef typename _MatrixType::Scalar Scalar;\n    typedef typename _MatrixType::RealScalar RealScalar;\n    typedef typename _MatrixType::StorageIndex StorageIndex;    \n  };\n\n} // end namespace internal\n\ntemplate<class Derived>\nclass PardisoImpl : public SparseSolverBase<Derived>\n{\n  protected:\n    typedef SparseSolverBase<Derived> Base;\n    using Base::derived;\n    using Base::m_isInitialized;\n    \n    typedef internal::pardiso_traits<Derived> Traits;\n  public:\n    using Base::_solve_impl;\n    \n    typedef typename Traits::MatrixType MatrixType;\n    typedef typename Traits::Scalar Scalar;\n    typedef typename Traits::RealScalar RealScalar;\n    typedef typename Traits::StorageIndex StorageIndex;\n    typedef SparseMatrix<Scalar,RowMajor,StorageIndex> SparseMatrixType;\n    typedef Matrix<Scalar,Dynamic,1> VectorType;\n    typedef Matrix<StorageIndex, 1, MatrixType::ColsAtCompileTime> IntRowVectorType;\n    typedef Matrix<StorageIndex, MatrixType::RowsAtCompileTime, 1> IntColVectorType;\n    typedef Array<StorageIndex,64,1,DontAlign> ParameterType;\n    enum {\n      ScalarIsComplex = NumTraits<Scalar>::IsComplex,\n      ColsAtCompileTime = Dynamic,\n      MaxColsAtCompileTime = Dynamic\n    };\n\n    PardisoImpl()\n    {\n      eigen_assert((sizeof(StorageIndex) >= sizeof(_INTEGER_t) && sizeof(StorageIndex) <= 8) && \"Non-supported index type\");\n      m_iparm.setZero();\n      m_msglvl = 0; // No output\n      m_isInitialized = false;\n    }\n\n    ~PardisoImpl()\n    {\n      pardisoRelease();\n    }\n\n    inline Index cols() const { return m_size; }\n    inline Index rows() const { return m_size; }\n  \n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful,\n      *          \\c NumericalIssue if the matrix appears to be negative.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return m_info;\n    }\n\n    /** \\warning for advanced usage only.\n      * \\returns a reference to the parameter array controlling PARDISO.\n      * See the PARDISO manual to know how to use it. */\n    ParameterType& pardisoParameterArray()\n    {\n      return m_iparm;\n    }\n    \n    /** Performs a symbolic decomposition on the sparcity of \\a matrix.\n      *\n      * This function is particularly useful when solving for several problems having the same structure.\n      * \n      * \\sa factorize()\n      */\n    Derived& analyzePattern(const MatrixType& matrix);\n    \n    /** Performs a numeric decomposition of \\a matrix\n      *\n      * The given matrix must has the same sparcity than the matrix on which the symbolic decomposition has been performed.\n      *\n      * \\sa analyzePattern()\n      */\n    Derived& factorize(const MatrixType& matrix);\n\n    Derived& compute(const MatrixType& matrix);\n\n    template<typename Rhs,typename Dest>\n    void _solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &dest) const;\n\n  protected:\n    void pardisoRelease()\n    {\n      if(m_isInitialized) // Factorization ran at least once\n      {\n        internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, -1, internal::convert_index<StorageIndex>(m_size),0, 0, 0, m_perm.data(), 0,\n                                                          m_iparm.data(), m_msglvl, NULL, NULL);\n        m_isInitialized = false;\n      }\n    }\n\n    void pardisoInit(int type)\n    {\n      m_type = type;\n      bool symmetric = std::abs(m_type) < 10;\n      m_iparm[0] = 1;   // No solver default\n      m_iparm[1] = 2;   // use Metis for the ordering\n      m_iparm[2] = 0;   // Reserved. Set to zero. (??Numbers of processors, value of OMP_NUM_THREADS??)\n      m_iparm[3] = 0;   // No iterative-direct algorithm\n      m_iparm[4] = 0;   // No user fill-in reducing permutation\n      m_iparm[5] = 0;   // Write solution into x, b is left unchanged\n      m_iparm[6] = 0;   // Not in use\n      m_iparm[7] = 2;   // Max numbers of iterative refinement steps\n      m_iparm[8] = 0;   // Not in use\n      m_iparm[9] = 13;  // Perturb the pivot elements with 1E-13\n      m_iparm[10] = symmetric ? 0 : 1; // Use nonsymmetric permutation and scaling MPS\n      m_iparm[11] = 0;  // Not in use\n      m_iparm[12] = symmetric ? 0 : 1;  // Maximum weighted matching algorithm is switched-off (default for symmetric).\n                                        // Try m_iparm[12] = 1 in case of inappropriate accuracy\n      m_iparm[13] = 0;  // Output: Number of perturbed pivots\n      m_iparm[14] = 0;  // Not in use\n      m_iparm[15] = 0;  // Not in use\n      m_iparm[16] = 0;  // Not in use\n      m_iparm[17] = -1; // Output: Number of nonzeros in the factor LU\n      m_iparm[18] = -1; // Output: Mflops for LU factorization\n      m_iparm[19] = 0;  // Output: Numbers of CG Iterations\n      \n      m_iparm[20] = 0;  // 1x1 pivoting\n      m_iparm[26] = 0;  // No matrix checker\n      m_iparm[27] = (sizeof(RealScalar) == 4) ? 1 : 0;\n      m_iparm[34] = 1;  // C indexing\n      m_iparm[36] = 0;  // CSR\n      m_iparm[59] = 0;  // 0 - In-Core ; 1 - Automatic switch between In-Core and Out-of-Core modes ; 2 - Out-of-Core\n      \n      memset(m_pt, 0, sizeof(m_pt));\n    }\n\n  protected:\n    // cached data to reduce reallocation, etc.\n    \n    void manageErrorCode(Index error) const\n    {\n      switch(error)\n      {\n        case 0:\n          m_info = Success;\n          break;\n        case -4:\n        case -7:\n          m_info = NumericalIssue;\n          break;\n        default:\n          m_info = InvalidInput;\n      }\n    }\n\n    mutable SparseMatrixType m_matrix;\n    mutable ComputationInfo m_info;\n    bool m_analysisIsOk, m_factorizationIsOk;\n    StorageIndex m_type, m_msglvl;\n    mutable void *m_pt[64];\n    mutable ParameterType m_iparm;\n    mutable IntColVectorType m_perm;\n    Index m_size;\n    \n};\n\ntemplate<class Derived>\nDerived& PardisoImpl<Derived>::compute(const MatrixType& a)\n{\n  m_size = a.rows();\n  eigen_assert(a.rows() == a.cols());\n\n  pardisoRelease();\n  m_perm.setZero(m_size);\n  derived().getMatrix(a);\n  \n  Index error;\n  error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 12, internal::convert_index<StorageIndex>(m_size),\n                                                            m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),\n                                                            m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL);\n  manageErrorCode(error);\n  m_analysisIsOk = true;\n  m_factorizationIsOk = true;\n  m_isInitialized = true;\n  return derived();\n}\n\ntemplate<class Derived>\nDerived& PardisoImpl<Derived>::analyzePattern(const MatrixType& a)\n{\n  m_size = a.rows();\n  eigen_assert(m_size == a.cols());\n\n  pardisoRelease();\n  m_perm.setZero(m_size);\n  derived().getMatrix(a);\n  \n  Index error;\n  error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 11, internal::convert_index<StorageIndex>(m_size),\n                                                            m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),\n                                                            m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL);\n  \n  manageErrorCode(error);\n  m_analysisIsOk = true;\n  m_factorizationIsOk = false;\n  m_isInitialized = true;\n  return derived();\n}\n\ntemplate<class Derived>\nDerived& PardisoImpl<Derived>::factorize(const MatrixType& a)\n{\n  eigen_assert(m_analysisIsOk && \"You must first call analyzePattern()\");\n  eigen_assert(m_size == a.rows() && m_size == a.cols());\n  \n  derived().getMatrix(a);\n\n  Index error;\n  error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 22, internal::convert_index<StorageIndex>(m_size),\n                                                            m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),\n                                                            m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL);\n  \n  manageErrorCode(error);\n  m_factorizationIsOk = true;\n  return derived();\n}\n\ntemplate<class Derived>\ntemplate<typename BDerived,typename XDerived>\nvoid PardisoImpl<Derived>::_solve_impl(const MatrixBase<BDerived> &b, MatrixBase<XDerived>& x) const\n{\n  if(m_iparm[0] == 0) // Factorization was not computed\n  {\n    m_info = InvalidInput;\n    return;\n  }\n\n  //Index n = m_matrix.rows();\n  Index nrhs = Index(b.cols());\n  eigen_assert(m_size==b.rows());\n  eigen_assert(((MatrixBase<BDerived>::Flags & RowMajorBit) == 0 || nrhs == 1) && \"Row-major right hand sides are not supported\");\n  eigen_assert(((MatrixBase<XDerived>::Flags & RowMajorBit) == 0 || nrhs == 1) && \"Row-major matrices of unknowns are not supported\");\n  eigen_assert(((nrhs == 1) || b.outerStride() == b.rows()));\n\n\n//  switch (transposed) {\n//    case SvNoTrans    : m_iparm[11] = 0 ; break;\n//    case SvTranspose  : m_iparm[11] = 2 ; break;\n//    case SvAdjoint    : m_iparm[11] = 1 ; break;\n//    default:\n//      //std::cerr << \"Eigen: transposition  option \\\"\" << transposed << \"\\\" not supported by the PARDISO backend\\n\";\n//      m_iparm[11] = 0;\n//  }\n\n  Scalar* rhs_ptr = const_cast<Scalar*>(b.derived().data());\n  Matrix<Scalar,Dynamic,Dynamic,ColMajor> tmp;\n  \n  // Pardiso cannot solve in-place\n  if(rhs_ptr == x.derived().data())\n  {\n    tmp = b;\n    rhs_ptr = tmp.data();\n  }\n  \n  Index error;\n  error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 33, internal::convert_index<StorageIndex>(m_size),\n                                                            m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(),\n                                                            m_perm.data(), internal::convert_index<StorageIndex>(nrhs), m_iparm.data(), m_msglvl,\n                                                            rhs_ptr, x.derived().data());\n\n  manageErrorCode(error);\n}\n\n\n/** \\ingroup PardisoSupport_Module\n  * \\class PardisoLU\n  * \\brief A sparse direct LU factorization and solver based on the PARDISO library\n  *\n  * This class allows to solve for A.X = B sparse linear problems via a direct LU factorization\n  * using the Intel MKL PARDISO library. The sparse matrix A must be squared and invertible.\n  * The vectors or matrices X and B can be either dense or sparse.\n  *\n  * By default, it runs in in-core mode. To enable PARDISO's out-of-core feature, set:\n  * \\code solver.pardisoParameterArray()[59] = 1; \\endcode\n  *\n  * \\tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa \\ref TutorialSparseSolverConcept, class SparseLU\n  */\ntemplate<typename MatrixType>\nclass PardisoLU : public PardisoImpl< PardisoLU<MatrixType> >\n{\n  protected:\n    typedef PardisoImpl<PardisoLU> Base;\n    typedef typename Base::Scalar Scalar;\n    typedef typename Base::RealScalar RealScalar;\n    using Base::pardisoInit;\n    using Base::m_matrix;\n    friend class PardisoImpl< PardisoLU<MatrixType> >;\n\n  public:\n\n    using Base::compute;\n    using Base::solve;\n\n    PardisoLU()\n      : Base()\n    {\n      pardisoInit(Base::ScalarIsComplex ? 13 : 11);\n    }\n\n    explicit PardisoLU(const MatrixType& matrix)\n      : Base()\n    {\n      pardisoInit(Base::ScalarIsComplex ? 13 : 11);\n      compute(matrix);\n    }\n  protected:\n    void getMatrix(const MatrixType& matrix)\n    {\n      m_matrix = matrix;\n      m_matrix.makeCompressed();\n    }\n};\n\n/** \\ingroup PardisoSupport_Module\n  * \\class PardisoLLT\n  * \\brief A sparse direct Cholesky (LLT) factorization and solver based on the PARDISO library\n  *\n  * This class allows to solve for A.X = B sparse linear problems via a LL^T Cholesky factorization\n  * using the Intel MKL PARDISO library. The sparse matrix A must be selfajoint and positive definite.\n  * The vectors or matrices X and B can be either dense or sparse.\n  *\n  * By default, it runs in in-core mode. To enable PARDISO's out-of-core feature, set:\n  * \\code solver.pardisoParameterArray()[59] = 1; \\endcode\n  *\n  * \\tparam MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  * \\tparam UpLo can be any bitwise combination of Upper, Lower. The default is Upper, meaning only the upper triangular part has to be used.\n  *         Upper|Lower can be used to tell both triangular parts can be used as input.\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa \\ref TutorialSparseSolverConcept, class SimplicialLLT\n  */\ntemplate<typename MatrixType, int _UpLo>\nclass PardisoLLT : public PardisoImpl< PardisoLLT<MatrixType,_UpLo> >\n{\n  protected:\n    typedef PardisoImpl< PardisoLLT<MatrixType,_UpLo> > Base;\n    typedef typename Base::Scalar Scalar;\n    typedef typename Base::RealScalar RealScalar;\n    using Base::pardisoInit;\n    using Base::m_matrix;\n    friend class PardisoImpl< PardisoLLT<MatrixType,_UpLo> >;\n\n  public:\n\n    typedef typename Base::StorageIndex StorageIndex;\n    enum { UpLo = _UpLo };\n    using Base::compute;\n\n    PardisoLLT()\n      : Base()\n    {\n      pardisoInit(Base::ScalarIsComplex ? 4 : 2);\n    }\n\n    explicit PardisoLLT(const MatrixType& matrix)\n      : Base()\n    {\n      pardisoInit(Base::ScalarIsComplex ? 4 : 2);\n      compute(matrix);\n    }\n    \n  protected:\n    \n    void getMatrix(const MatrixType& matrix)\n    {\n      // PARDISO supports only upper, row-major matrices\n      PermutationMatrix<Dynamic,Dynamic,StorageIndex> p_null;\n      m_matrix.resize(matrix.rows(), matrix.cols());\n      m_matrix.template selfadjointView<Upper>() = matrix.template selfadjointView<UpLo>().twistedBy(p_null);\n      m_matrix.makeCompressed();\n    }\n};\n\n/** \\ingroup PardisoSupport_Module\n  * \\class PardisoLDLT\n  * \\brief A sparse direct Cholesky (LDLT) factorization and solver based on the PARDISO library\n  *\n  * This class allows to solve for A.X = B sparse linear problems via a LDL^T Cholesky factorization\n  * using the Intel MKL PARDISO library. The sparse matrix A is assumed to be selfajoint and positive definite.\n  * For complex matrices, A can also be symmetric only, see the \\a Options template parameter.\n  * The vectors or matrices X and B can be either dense or sparse.\n  *\n  * By default, it runs in in-core mode. To enable PARDISO's out-of-core feature, set:\n  * \\code solver.pardisoParameterArray()[59] = 1; \\endcode\n  *\n  * \\tparam MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  * \\tparam Options can be any bitwise combination of Upper, Lower, and Symmetric. The default is Upper, meaning only the upper triangular part has to be used.\n  *         Symmetric can be used for symmetric, non-selfadjoint complex matrices, the default being to assume a selfadjoint matrix.\n  *         Upper|Lower can be used to tell both triangular parts can be used as input.\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa \\ref TutorialSparseSolverConcept, class SimplicialLDLT\n  */\ntemplate<typename MatrixType, int Options>\nclass PardisoLDLT : public PardisoImpl< PardisoLDLT<MatrixType,Options> >\n{\n  protected:\n    typedef PardisoImpl< PardisoLDLT<MatrixType,Options> > Base;\n    typedef typename Base::Scalar Scalar;\n    typedef typename Base::RealScalar RealScalar;\n    using Base::pardisoInit;\n    using Base::m_matrix;\n    friend class PardisoImpl< PardisoLDLT<MatrixType,Options> >;\n\n  public:\n\n    typedef typename Base::StorageIndex StorageIndex;\n    using Base::compute;\n    enum { UpLo = Options&(Upper|Lower) };\n\n    PardisoLDLT()\n      : Base()\n    {\n      pardisoInit(Base::ScalarIsComplex ? ( bool(Options&Symmetric) ? 6 : -4 ) : -2);\n    }\n\n    explicit PardisoLDLT(const MatrixType& matrix)\n      : Base()\n    {\n      pardisoInit(Base::ScalarIsComplex ? ( bool(Options&Symmetric) ? 6 : -4 ) : -2);\n      compute(matrix);\n    }\n    \n    void getMatrix(const MatrixType& matrix)\n    {\n      // PARDISO supports only upper, row-major matrices\n      PermutationMatrix<Dynamic,Dynamic,StorageIndex> p_null;\n      m_matrix.resize(matrix.rows(), matrix.cols());\n      m_matrix.template selfadjointView<Upper>() = matrix.template selfadjointView<UpLo>().twistedBy(p_null);\n      m_matrix.makeCompressed();\n    }\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_PARDISOSUPPORT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/QR/ColPivHouseholderQR.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COLPIVOTINGHOUSEHOLDERQR_H\n#define EIGEN_COLPIVOTINGHOUSEHOLDERQR_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate<typename _MatrixType> struct traits<ColPivHouseholderQR<_MatrixType> >\n : traits<_MatrixType>\n{\n  enum { Flags = 0 };\n};\n\n} // end namespace internal\n\n/** \\ingroup QR_Module\n  *\n  * \\class ColPivHouseholderQR\n  *\n  * \\brief Householder rank-revealing QR decomposition of a matrix with column-pivoting\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the QR decomposition\n  *\n  * This class performs a rank-revealing QR decomposition of a matrix \\b A into matrices \\b P, \\b Q and \\b R\n  * such that\n  * \\f[\n  *  \\mathbf{A} \\, \\mathbf{P} = \\mathbf{Q} \\, \\mathbf{R}\n  * \\f]\n  * by using Householder transformations. Here, \\b P is a permutation matrix, \\b Q a unitary matrix and \\b R an\n  * upper triangular matrix.\n  *\n  * This decomposition performs column pivoting in order to be rank-revealing and improve\n  * numerical stability. It is slower than HouseholderQR, and faster than FullPivHouseholderQR.\n  *\n  * This class supports the \\link InplaceDecomposition inplace decomposition \\endlink mechanism.\n  * \n  * \\sa MatrixBase::colPivHouseholderQr()\n  */\ntemplate<typename _MatrixType> class ColPivHouseholderQR\n{\n  public:\n\n    typedef _MatrixType MatrixType;\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    // FIXME should be int\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType;\n    typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationType;\n    typedef typename internal::plain_row_type<MatrixType, Index>::type IntRowVectorType;\n    typedef typename internal::plain_row_type<MatrixType>::type RowVectorType;\n    typedef typename internal::plain_row_type<MatrixType, RealScalar>::type RealRowVectorType;\n    typedef HouseholderSequence<MatrixType,typename internal::remove_all<typename HCoeffsType::ConjugateReturnType>::type> HouseholderSequenceType;\n    typedef typename MatrixType::PlainObject PlainObject;\n\n  private:\n\n    typedef typename PermutationType::StorageIndex PermIndexType;\n\n  public:\n\n    /**\n    * \\brief Default Constructor.\n    *\n    * The default constructor is useful in cases in which the user intends to\n    * perform decompositions via ColPivHouseholderQR::compute(const MatrixType&).\n    */\n    ColPivHouseholderQR()\n      : m_qr(),\n        m_hCoeffs(),\n        m_colsPermutation(),\n        m_colsTranspositions(),\n        m_temp(),\n        m_colNormsUpdated(),\n        m_colNormsDirect(),\n        m_isInitialized(false),\n        m_usePrescribedThreshold(false) {}\n\n    /** \\brief Default Constructor with memory preallocation\n      *\n      * Like the default constructor but with preallocation of the internal data\n      * according to the specified problem \\a size.\n      * \\sa ColPivHouseholderQR()\n      */\n    ColPivHouseholderQR(Index rows, Index cols)\n      : m_qr(rows, cols),\n        m_hCoeffs((std::min)(rows,cols)),\n        m_colsPermutation(PermIndexType(cols)),\n        m_colsTranspositions(cols),\n        m_temp(cols),\n        m_colNormsUpdated(cols),\n        m_colNormsDirect(cols),\n        m_isInitialized(false),\n        m_usePrescribedThreshold(false) {}\n\n    /** \\brief Constructs a QR factorization from a given matrix\n      *\n      * This constructor computes the QR factorization of the matrix \\a matrix by calling\n      * the method compute(). It is a short cut for:\n      *\n      * \\code\n      * ColPivHouseholderQR<MatrixType> qr(matrix.rows(), matrix.cols());\n      * qr.compute(matrix);\n      * \\endcode\n      *\n      * \\sa compute()\n      */\n    template<typename InputType>\n    explicit ColPivHouseholderQR(const EigenBase<InputType>& matrix)\n      : m_qr(matrix.rows(), matrix.cols()),\n        m_hCoeffs((std::min)(matrix.rows(),matrix.cols())),\n        m_colsPermutation(PermIndexType(matrix.cols())),\n        m_colsTranspositions(matrix.cols()),\n        m_temp(matrix.cols()),\n        m_colNormsUpdated(matrix.cols()),\n        m_colNormsDirect(matrix.cols()),\n        m_isInitialized(false),\n        m_usePrescribedThreshold(false)\n    {\n      compute(matrix.derived());\n    }\n\n    /** \\brief Constructs a QR factorization from a given matrix\n      *\n      * This overloaded constructor is provided for \\link InplaceDecomposition inplace decomposition \\endlink when \\c MatrixType is a Eigen::Ref.\n      *\n      * \\sa ColPivHouseholderQR(const EigenBase&)\n      */\n    template<typename InputType>\n    explicit ColPivHouseholderQR(EigenBase<InputType>& matrix)\n      : m_qr(matrix.derived()),\n        m_hCoeffs((std::min)(matrix.rows(),matrix.cols())),\n        m_colsPermutation(PermIndexType(matrix.cols())),\n        m_colsTranspositions(matrix.cols()),\n        m_temp(matrix.cols()),\n        m_colNormsUpdated(matrix.cols()),\n        m_colNormsDirect(matrix.cols()),\n        m_isInitialized(false),\n        m_usePrescribedThreshold(false)\n    {\n      computeInPlace();\n    }\n\n    /** This method finds a solution x to the equation Ax=b, where A is the matrix of which\n      * *this is the QR decomposition, if any exists.\n      *\n      * \\param b the right-hand-side of the equation to solve.\n      *\n      * \\returns a solution.\n      *\n      * \\note_about_checking_solutions\n      *\n      * \\note_about_arbitrary_choice_of_solution\n      *\n      * Example: \\include ColPivHouseholderQR_solve.cpp\n      * Output: \\verbinclude ColPivHouseholderQR_solve.out\n      */\n    template<typename Rhs>\n    inline const Solve<ColPivHouseholderQR, Rhs>\n    solve(const MatrixBase<Rhs>& b) const\n    {\n      eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n      return Solve<ColPivHouseholderQR, Rhs>(*this, b.derived());\n    }\n\n    HouseholderSequenceType householderQ() const;\n    HouseholderSequenceType matrixQ() const\n    {\n      return householderQ();\n    }\n\n    /** \\returns a reference to the matrix where the Householder QR decomposition is stored\n      */\n    const MatrixType& matrixQR() const\n    {\n      eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n      return m_qr;\n    }\n\n    /** \\returns a reference to the matrix where the result Householder QR is stored\n     * \\warning The strict lower part of this matrix contains internal values.\n     * Only the upper triangular part should be referenced. To get it, use\n     * \\code matrixR().template triangularView<Upper>() \\endcode\n     * For rank-deficient matrices, use\n     * \\code\n     * matrixR().topLeftCorner(rank(), rank()).template triangularView<Upper>()\n     * \\endcode\n     */\n    const MatrixType& matrixR() const\n    {\n      eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n      return m_qr;\n    }\n\n    template<typename InputType>\n    ColPivHouseholderQR& compute(const EigenBase<InputType>& matrix);\n\n    /** \\returns a const reference to the column permutation matrix */\n    const PermutationType& colsPermutation() const\n    {\n      eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n      return m_colsPermutation;\n    }\n\n    /** \\returns the absolute value of the determinant of the matrix of which\n      * *this is the QR decomposition. It has only linear complexity\n      * (that is, O(n) where n is the dimension of the square matrix)\n      * as the QR decomposition has already been computed.\n      *\n      * \\note This is only for square matrices.\n      *\n      * \\warning a determinant can be very big or small, so for matrices\n      * of large enough dimension, there is a risk of overflow/underflow.\n      * One way to work around that is to use logAbsDeterminant() instead.\n      *\n      * \\sa logAbsDeterminant(), MatrixBase::determinant()\n      */\n    typename MatrixType::RealScalar absDeterminant() const;\n\n    /** \\returns the natural log of the absolute value of the determinant of the matrix of which\n      * *this is the QR decomposition. It has only linear complexity\n      * (that is, O(n) where n is the dimension of the square matrix)\n      * as the QR decomposition has already been computed.\n      *\n      * \\note This is only for square matrices.\n      *\n      * \\note This method is useful to work around the risk of overflow/underflow that's inherent\n      * to determinant computation.\n      *\n      * \\sa absDeterminant(), MatrixBase::determinant()\n      */\n    typename MatrixType::RealScalar logAbsDeterminant() const;\n\n    /** \\returns the rank of the matrix of which *this is the QR decomposition.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline Index rank() const\n    {\n      using std::abs;\n      eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n      RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold();\n      Index result = 0;\n      for(Index i = 0; i < m_nonzero_pivots; ++i)\n        result += (abs(m_qr.coeff(i,i)) > premultiplied_threshold);\n      return result;\n    }\n\n    /** \\returns the dimension of the kernel of the matrix of which *this is the QR decomposition.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline Index dimensionOfKernel() const\n    {\n      eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n      return cols() - rank();\n    }\n\n    /** \\returns true if the matrix of which *this is the QR decomposition represents an injective\n      *          linear map, i.e. has trivial kernel; false otherwise.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline bool isInjective() const\n    {\n      eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n      return rank() == cols();\n    }\n\n    /** \\returns true if the matrix of which *this is the QR decomposition represents a surjective\n      *          linear map; false otherwise.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline bool isSurjective() const\n    {\n      eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n      return rank() == rows();\n    }\n\n    /** \\returns true if the matrix of which *this is the QR decomposition is invertible.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline bool isInvertible() const\n    {\n      eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n      return isInjective() && isSurjective();\n    }\n\n    /** \\returns the inverse of the matrix of which *this is the QR decomposition.\n      *\n      * \\note If this matrix is not invertible, the returned matrix has undefined coefficients.\n      *       Use isInvertible() to first determine whether this matrix is invertible.\n      */\n    inline const Inverse<ColPivHouseholderQR> inverse() const\n    {\n      eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n      return Inverse<ColPivHouseholderQR>(*this);\n    }\n\n    inline Index rows() const { return m_qr.rows(); }\n    inline Index cols() const { return m_qr.cols(); }\n\n    /** \\returns a const reference to the vector of Householder coefficients used to represent the factor \\c Q.\n      *\n      * For advanced uses only.\n      */\n    const HCoeffsType& hCoeffs() const { return m_hCoeffs; }\n\n    /** Allows to prescribe a threshold to be used by certain methods, such as rank(),\n      * who need to determine when pivots are to be considered nonzero. This is not used for the\n      * QR decomposition itself.\n      *\n      * When it needs to get the threshold value, Eigen calls threshold(). By default, this\n      * uses a formula to automatically determine a reasonable threshold.\n      * Once you have called the present method setThreshold(const RealScalar&),\n      * your value is used instead.\n      *\n      * \\param threshold The new value to use as the threshold.\n      *\n      * A pivot will be considered nonzero if its absolute value is strictly greater than\n      *  \\f$ \\vert pivot \\vert \\leqslant threshold \\times \\vert maxpivot \\vert \\f$\n      * where maxpivot is the biggest pivot.\n      *\n      * If you want to come back to the default behavior, call setThreshold(Default_t)\n      */\n    ColPivHouseholderQR& setThreshold(const RealScalar& threshold)\n    {\n      m_usePrescribedThreshold = true;\n      m_prescribedThreshold = threshold;\n      return *this;\n    }\n\n    /** Allows to come back to the default behavior, letting Eigen use its default formula for\n      * determining the threshold.\n      *\n      * You should pass the special object Eigen::Default as parameter here.\n      * \\code qr.setThreshold(Eigen::Default); \\endcode\n      *\n      * See the documentation of setThreshold(const RealScalar&).\n      */\n    ColPivHouseholderQR& setThreshold(Default_t)\n    {\n      m_usePrescribedThreshold = false;\n      return *this;\n    }\n\n    /** Returns the threshold that will be used by certain methods such as rank().\n      *\n      * See the documentation of setThreshold(const RealScalar&).\n      */\n    RealScalar threshold() const\n    {\n      eigen_assert(m_isInitialized || m_usePrescribedThreshold);\n      return m_usePrescribedThreshold ? m_prescribedThreshold\n      // this formula comes from experimenting (see \"LU precision tuning\" thread on the list)\n      // and turns out to be identical to Higham's formula used already in LDLt.\n                                      : NumTraits<Scalar>::epsilon() * RealScalar(m_qr.diagonalSize());\n    }\n\n    /** \\returns the number of nonzero pivots in the QR decomposition.\n      * Here nonzero is meant in the exact sense, not in a fuzzy sense.\n      * So that notion isn't really intrinsically interesting, but it is\n      * still useful when implementing algorithms.\n      *\n      * \\sa rank()\n      */\n    inline Index nonzeroPivots() const\n    {\n      eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n      return m_nonzero_pivots;\n    }\n\n    /** \\returns the absolute value of the biggest pivot, i.e. the biggest\n      *          diagonal coefficient of R.\n      */\n    RealScalar maxPivot() const { return m_maxpivot; }\n\n    /** \\brief Reports whether the QR factorization was succesful.\n      *\n      * \\note This function always returns \\c Success. It is provided for compatibility\n      * with other factorization routines.\n      * \\returns \\c Success\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return Success;\n    }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename RhsType, typename DstType>\n    EIGEN_DEVICE_FUNC\n    void _solve_impl(const RhsType &rhs, DstType &dst) const;\n    #endif\n\n  protected:\n\n    friend class CompleteOrthogonalDecomposition<MatrixType>;\n\n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n    }\n\n    void computeInPlace();\n\n    MatrixType m_qr;\n    HCoeffsType m_hCoeffs;\n    PermutationType m_colsPermutation;\n    IntRowVectorType m_colsTranspositions;\n    RowVectorType m_temp;\n    RealRowVectorType m_colNormsUpdated;\n    RealRowVectorType m_colNormsDirect;\n    bool m_isInitialized, m_usePrescribedThreshold;\n    RealScalar m_prescribedThreshold, m_maxpivot;\n    Index m_nonzero_pivots;\n    Index m_det_pq;\n};\n\ntemplate<typename MatrixType>\ntypename MatrixType::RealScalar ColPivHouseholderQR<MatrixType>::absDeterminant() const\n{\n  using std::abs;\n  eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n  eigen_assert(m_qr.rows() == m_qr.cols() && \"You can't take the determinant of a non-square matrix!\");\n  return abs(m_qr.diagonal().prod());\n}\n\ntemplate<typename MatrixType>\ntypename MatrixType::RealScalar ColPivHouseholderQR<MatrixType>::logAbsDeterminant() const\n{\n  eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n  eigen_assert(m_qr.rows() == m_qr.cols() && \"You can't take the determinant of a non-square matrix!\");\n  return m_qr.diagonal().cwiseAbs().array().log().sum();\n}\n\n/** Performs the QR factorization of the given matrix \\a matrix. The result of\n  * the factorization is stored into \\c *this, and a reference to \\c *this\n  * is returned.\n  *\n  * \\sa class ColPivHouseholderQR, ColPivHouseholderQR(const MatrixType&)\n  */\ntemplate<typename MatrixType>\ntemplate<typename InputType>\nColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const EigenBase<InputType>& matrix)\n{\n  m_qr = matrix.derived();\n  computeInPlace();\n  return *this;\n}\n\ntemplate<typename MatrixType>\nvoid ColPivHouseholderQR<MatrixType>::computeInPlace()\n{\n  check_template_parameters();\n\n  // the column permutation is stored as int indices, so just to be sure:\n  eigen_assert(m_qr.cols()<=NumTraits<int>::highest());\n\n  using std::abs;\n\n  Index rows = m_qr.rows();\n  Index cols = m_qr.cols();\n  Index size = m_qr.diagonalSize();\n\n  m_hCoeffs.resize(size);\n\n  m_temp.resize(cols);\n\n  m_colsTranspositions.resize(m_qr.cols());\n  Index number_of_transpositions = 0;\n\n  m_colNormsUpdated.resize(cols);\n  m_colNormsDirect.resize(cols);\n  for (Index k = 0; k < cols; ++k) {\n    // colNormsDirect(k) caches the most recent directly computed norm of\n    // column k.\n    m_colNormsDirect.coeffRef(k) = m_qr.col(k).norm();\n    m_colNormsUpdated.coeffRef(k) = m_colNormsDirect.coeffRef(k);\n  }\n\n  RealScalar threshold_helper =  numext::abs2<RealScalar>(m_colNormsUpdated.maxCoeff() * NumTraits<RealScalar>::epsilon()) / RealScalar(rows);\n  RealScalar norm_downdate_threshold = numext::sqrt(NumTraits<RealScalar>::epsilon());\n\n  m_nonzero_pivots = size; // the generic case is that in which all pivots are nonzero (invertible case)\n  m_maxpivot = RealScalar(0);\n\n  for(Index k = 0; k < size; ++k)\n  {\n    // first, we look up in our table m_colNormsUpdated which column has the biggest norm\n    Index biggest_col_index;\n    RealScalar biggest_col_sq_norm = numext::abs2(m_colNormsUpdated.tail(cols-k).maxCoeff(&biggest_col_index));\n    biggest_col_index += k;\n\n    // Track the number of meaningful pivots but do not stop the decomposition to make\n    // sure that the initial matrix is properly reproduced. See bug 941.\n    if(m_nonzero_pivots==size && biggest_col_sq_norm < threshold_helper * RealScalar(rows-k))\n      m_nonzero_pivots = k;\n\n    // apply the transposition to the columns\n    m_colsTranspositions.coeffRef(k) = biggest_col_index;\n    if(k != biggest_col_index) {\n      m_qr.col(k).swap(m_qr.col(biggest_col_index));\n      std::swap(m_colNormsUpdated.coeffRef(k), m_colNormsUpdated.coeffRef(biggest_col_index));\n      std::swap(m_colNormsDirect.coeffRef(k), m_colNormsDirect.coeffRef(biggest_col_index));\n      ++number_of_transpositions;\n    }\n\n    // generate the householder vector, store it below the diagonal\n    RealScalar beta;\n    m_qr.col(k).tail(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta);\n\n    // apply the householder transformation to the diagonal coefficient\n    m_qr.coeffRef(k,k) = beta;\n\n    // remember the maximum absolute value of diagonal coefficients\n    if(abs(beta) > m_maxpivot) m_maxpivot = abs(beta);\n\n    // apply the householder transformation\n    m_qr.bottomRightCorner(rows-k, cols-k-1)\n        .applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), m_hCoeffs.coeffRef(k), &m_temp.coeffRef(k+1));\n\n    // update our table of norms of the columns\n    for (Index j = k + 1; j < cols; ++j) {\n      // The following implements the stable norm downgrade step discussed in\n      // http://www.netlib.org/lapack/lawnspdf/lawn176.pdf\n      // and used in LAPACK routines xGEQPF and xGEQP3.\n      // See lines 278-297 in http://www.netlib.org/lapack/explore-html/dc/df4/sgeqpf_8f_source.html\n      if (m_colNormsUpdated.coeffRef(j) != RealScalar(0)) {\n        RealScalar temp = abs(m_qr.coeffRef(k, j)) / m_colNormsUpdated.coeffRef(j);\n        temp = (RealScalar(1) + temp) * (RealScalar(1) - temp);\n        temp = temp <  RealScalar(0) ? RealScalar(0) : temp;\n        RealScalar temp2 = temp * numext::abs2<RealScalar>(m_colNormsUpdated.coeffRef(j) /\n                                                           m_colNormsDirect.coeffRef(j));\n        if (temp2 <= norm_downdate_threshold) {\n          // The updated norm has become too inaccurate so re-compute the column\n          // norm directly.\n          m_colNormsDirect.coeffRef(j) = m_qr.col(j).tail(rows - k - 1).norm();\n          m_colNormsUpdated.coeffRef(j) = m_colNormsDirect.coeffRef(j);\n        } else {\n          m_colNormsUpdated.coeffRef(j) *= numext::sqrt(temp);\n        }\n      }\n    }\n  }\n\n  m_colsPermutation.setIdentity(PermIndexType(cols));\n  for(PermIndexType k = 0; k < size/*m_nonzero_pivots*/; ++k)\n    m_colsPermutation.applyTranspositionOnTheRight(k, PermIndexType(m_colsTranspositions.coeff(k)));\n\n  m_det_pq = (number_of_transpositions%2) ? -1 : 1;\n  m_isInitialized = true;\n}\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename _MatrixType>\ntemplate<typename RhsType, typename DstType>\nvoid ColPivHouseholderQR<_MatrixType>::_solve_impl(const RhsType &rhs, DstType &dst) const\n{\n  eigen_assert(rhs.rows() == rows());\n\n  const Index nonzero_pivots = nonzeroPivots();\n\n  if(nonzero_pivots == 0)\n  {\n    dst.setZero();\n    return;\n  }\n\n  typename RhsType::PlainObject c(rhs);\n\n  // Note that the matrix Q = H_0^* H_1^*... so its inverse is Q^* = (H_0 H_1 ...)^T\n  c.applyOnTheLeft(householderSequence(m_qr, m_hCoeffs)\n                    .setLength(nonzero_pivots)\n                    .transpose()\n    );\n\n  m_qr.topLeftCorner(nonzero_pivots, nonzero_pivots)\n      .template triangularView<Upper>()\n      .solveInPlace(c.topRows(nonzero_pivots));\n\n  for(Index i = 0; i < nonzero_pivots; ++i) dst.row(m_colsPermutation.indices().coeff(i)) = c.row(i);\n  for(Index i = nonzero_pivots; i < cols(); ++i) dst.row(m_colsPermutation.indices().coeff(i)).setZero();\n}\n#endif\n\nnamespace internal {\n\ntemplate<typename DstXprType, typename MatrixType>\nstruct Assignment<DstXprType, Inverse<ColPivHouseholderQR<MatrixType> >, internal::assign_op<typename DstXprType::Scalar,typename ColPivHouseholderQR<MatrixType>::Scalar>, Dense2Dense>\n{\n  typedef ColPivHouseholderQR<MatrixType> QrType;\n  typedef Inverse<QrType> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename QrType::Scalar> &)\n  {\n    dst = src.nestedExpression().solve(MatrixType::Identity(src.rows(), src.cols()));\n  }\n};\n\n} // end namespace internal\n\n/** \\returns the matrix Q as a sequence of householder transformations.\n  * You can extract the meaningful part only by using:\n  * \\code qr.householderQ().setLength(qr.nonzeroPivots()) \\endcode*/\ntemplate<typename MatrixType>\ntypename ColPivHouseholderQR<MatrixType>::HouseholderSequenceType ColPivHouseholderQR<MatrixType>\n  ::householderQ() const\n{\n  eigen_assert(m_isInitialized && \"ColPivHouseholderQR is not initialized.\");\n  return HouseholderSequenceType(m_qr, m_hCoeffs.conjugate());\n}\n\n/** \\return the column-pivoting Householder QR decomposition of \\c *this.\n  *\n  * \\sa class ColPivHouseholderQR\n  */\ntemplate<typename Derived>\nconst ColPivHouseholderQR<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::colPivHouseholderQr() const\n{\n  return ColPivHouseholderQR<PlainObject>(eval());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_COLPIVOTINGHOUSEHOLDERQR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to LAPACKe\n *    Householder QR decomposition of a matrix with column pivoting based on\n *    LAPACKE_?geqp3 function.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_COLPIVOTINGHOUSEHOLDERQR_LAPACKE_H\n#define EIGEN_COLPIVOTINGHOUSEHOLDERQR_LAPACKE_H\n\nnamespace Eigen { \n\n/** \\internal Specialization for the data types supported by LAPACKe */\n\n#define EIGEN_LAPACKE_QR_COLPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX, EIGCOLROW, LAPACKE_COLROW) \\\ntemplate<> template<typename InputType> inline \\\nColPivHouseholderQR<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> >& \\\nColPivHouseholderQR<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> >::compute( \\\n              const EigenBase<InputType>& matrix) \\\n\\\n{ \\\n  using std::abs; \\\n  typedef Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> MatrixType; \\\n  typedef MatrixType::RealScalar RealScalar; \\\n  Index rows = matrix.rows();\\\n  Index cols = matrix.cols();\\\n\\\n  m_qr = matrix;\\\n  Index size = m_qr.diagonalSize();\\\n  m_hCoeffs.resize(size);\\\n\\\n  m_colsTranspositions.resize(cols);\\\n  /*Index number_of_transpositions = 0;*/ \\\n\\\n  m_nonzero_pivots = 0; \\\n  m_maxpivot = RealScalar(0);\\\n  m_colsPermutation.resize(cols); \\\n  m_colsPermutation.indices().setZero(); \\\n\\\n  lapack_int lda = internal::convert_index<lapack_int,Index>(m_qr.outerStride()); \\\n  lapack_int matrix_order = LAPACKE_COLROW; \\\n  LAPACKE_##LAPACKE_PREFIX##geqp3( matrix_order, internal::convert_index<lapack_int,Index>(rows), internal::convert_index<lapack_int,Index>(cols), \\\n                              (LAPACKE_TYPE*)m_qr.data(), lda, (lapack_int*)m_colsPermutation.indices().data(), (LAPACKE_TYPE*)m_hCoeffs.data()); \\\n  m_isInitialized = true; \\\n  m_maxpivot=m_qr.diagonal().cwiseAbs().maxCoeff(); \\\n  m_hCoeffs.adjointInPlace(); \\\n  RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold(); \\\n  lapack_int *perm = m_colsPermutation.indices().data(); \\\n  for(Index i=0;i<size;i++) { \\\n    m_nonzero_pivots += (abs(m_qr.coeff(i,i)) > premultiplied_threshold);\\\n  } \\\n  for(Index i=0;i<cols;i++) perm[i]--;\\\n\\\n  /*m_det_pq = (number_of_transpositions%2) ? -1 : 1;  // TODO: It's not needed now; fix upon availability in Eigen */ \\\n\\\n  return *this; \\\n}\n\nEIGEN_LAPACKE_QR_COLPIV(double,   double,        d, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_QR_COLPIV(float,    float,         s, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_QR_COLPIV(dcomplex, lapack_complex_double, z, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_QR_COLPIV(scomplex, lapack_complex_float,  c, ColMajor, LAPACK_COL_MAJOR)\n\nEIGEN_LAPACKE_QR_COLPIV(double,   double,        d, RowMajor, LAPACK_ROW_MAJOR)\nEIGEN_LAPACKE_QR_COLPIV(float,    float,         s, RowMajor, LAPACK_ROW_MAJOR)\nEIGEN_LAPACKE_QR_COLPIV(dcomplex, lapack_complex_double, z, RowMajor, LAPACK_ROW_MAJOR)\nEIGEN_LAPACKE_QR_COLPIV(scomplex, lapack_complex_float,  c, RowMajor, LAPACK_ROW_MAJOR)\n\n} // end namespace Eigen\n\n#endif // EIGEN_COLPIVOTINGHOUSEHOLDERQR_LAPACKE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/QR/CompleteOrthogonalDecomposition.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2016 Rasmus Munk Larsen <rmlarsen@google.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COMPLETEORTHOGONALDECOMPOSITION_H\n#define EIGEN_COMPLETEORTHOGONALDECOMPOSITION_H\n\nnamespace Eigen {\n\nnamespace internal {\ntemplate <typename _MatrixType>\nstruct traits<CompleteOrthogonalDecomposition<_MatrixType> >\n    : traits<_MatrixType> {\n  enum { Flags = 0 };\n};\n\n}  // end namespace internal\n\n/** \\ingroup QR_Module\n  *\n  * \\class CompleteOrthogonalDecomposition\n  *\n  * \\brief Complete orthogonal decomposition (COD) of a matrix.\n  *\n  * \\param MatrixType the type of the matrix of which we are computing the COD.\n  *\n  * This class performs a rank-revealing complete orthogonal decomposition of a\n  * matrix  \\b A into matrices \\b P, \\b Q, \\b T, and \\b Z such that\n  * \\f[\n  *  \\mathbf{A} \\, \\mathbf{P} = \\mathbf{Q} \\,\n  *                     \\begin{bmatrix} \\mathbf{T} &  \\mathbf{0} \\\\\n  *                                     \\mathbf{0} & \\mathbf{0} \\end{bmatrix} \\, \\mathbf{Z}\n  * \\f]\n  * by using Householder transformations. Here, \\b P is a permutation matrix,\n  * \\b Q and \\b Z are unitary matrices and \\b T an upper triangular matrix of\n  * size rank-by-rank. \\b A may be rank deficient.\n  *\n  * This class supports the \\link InplaceDecomposition inplace decomposition \\endlink mechanism.\n  * \n  * \\sa MatrixBase::completeOrthogonalDecomposition()\n  */\ntemplate <typename _MatrixType>\nclass CompleteOrthogonalDecomposition {\n public:\n  typedef _MatrixType MatrixType;\n  enum {\n    RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n    ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n    MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n  };\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename MatrixType::RealScalar RealScalar;\n  typedef typename MatrixType::StorageIndex StorageIndex;\n  typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType;\n  typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime>\n      PermutationType;\n  typedef typename internal::plain_row_type<MatrixType, Index>::type\n      IntRowVectorType;\n  typedef typename internal::plain_row_type<MatrixType>::type RowVectorType;\n  typedef typename internal::plain_row_type<MatrixType, RealScalar>::type\n      RealRowVectorType;\n  typedef HouseholderSequence<\n      MatrixType, typename internal::remove_all<\n                      typename HCoeffsType::ConjugateReturnType>::type>\n      HouseholderSequenceType;\n  typedef typename MatrixType::PlainObject PlainObject;\n\n private:\n  typedef typename PermutationType::Index PermIndexType;\n\n public:\n  /**\n   * \\brief Default Constructor.\n   *\n   * The default constructor is useful in cases in which the user intends to\n   * perform decompositions via\n   * \\c CompleteOrthogonalDecomposition::compute(const* MatrixType&).\n   */\n  CompleteOrthogonalDecomposition() : m_cpqr(), m_zCoeffs(), m_temp() {}\n\n  /** \\brief Default Constructor with memory preallocation\n   *\n   * Like the default constructor but with preallocation of the internal data\n   * according to the specified problem \\a size.\n   * \\sa CompleteOrthogonalDecomposition()\n   */\n  CompleteOrthogonalDecomposition(Index rows, Index cols)\n      : m_cpqr(rows, cols), m_zCoeffs((std::min)(rows, cols)), m_temp(cols) {}\n\n  /** \\brief Constructs a complete orthogonal decomposition from a given\n   * matrix.\n   *\n   * This constructor computes the complete orthogonal decomposition of the\n   * matrix \\a matrix by calling the method compute(). The default\n   * threshold for rank determination will be used. It is a short cut for:\n   *\n   * \\code\n   * CompleteOrthogonalDecomposition<MatrixType> cod(matrix.rows(),\n   *                                                 matrix.cols());\n   * cod.setThreshold(Default);\n   * cod.compute(matrix);\n   * \\endcode\n   *\n   * \\sa compute()\n   */\n  template <typename InputType>\n  explicit CompleteOrthogonalDecomposition(const EigenBase<InputType>& matrix)\n      : m_cpqr(matrix.rows(), matrix.cols()),\n        m_zCoeffs((std::min)(matrix.rows(), matrix.cols())),\n        m_temp(matrix.cols())\n  {\n    compute(matrix.derived());\n  }\n\n  /** \\brief Constructs a complete orthogonal decomposition from a given matrix\n    *\n    * This overloaded constructor is provided for \\link InplaceDecomposition inplace decomposition \\endlink when \\c MatrixType is a Eigen::Ref.\n    *\n    * \\sa CompleteOrthogonalDecomposition(const EigenBase&)\n    */\n  template<typename InputType>\n  explicit CompleteOrthogonalDecomposition(EigenBase<InputType>& matrix)\n    : m_cpqr(matrix.derived()),\n      m_zCoeffs((std::min)(matrix.rows(), matrix.cols())),\n      m_temp(matrix.cols())\n  {\n    computeInPlace();\n  }\n\n\n  /** This method computes the minimum-norm solution X to a least squares\n   * problem \\f[\\mathrm{minimize} \\|A X - B\\|, \\f] where \\b A is the matrix of\n   * which \\c *this is the complete orthogonal decomposition.\n   *\n   * \\param b the right-hand sides of the problem to solve.\n   *\n   * \\returns a solution.\n   *\n   */\n  template <typename Rhs>\n  inline const Solve<CompleteOrthogonalDecomposition, Rhs> solve(\n      const MatrixBase<Rhs>& b) const {\n    eigen_assert(m_cpqr.m_isInitialized &&\n                 \"CompleteOrthogonalDecomposition is not initialized.\");\n    return Solve<CompleteOrthogonalDecomposition, Rhs>(*this, b.derived());\n  }\n\n  HouseholderSequenceType householderQ(void) const;\n  HouseholderSequenceType matrixQ(void) const { return m_cpqr.householderQ(); }\n\n  /** \\returns the matrix \\b Z.\n   */\n  MatrixType matrixZ() const {\n    MatrixType Z = MatrixType::Identity(m_cpqr.cols(), m_cpqr.cols());\n    applyZAdjointOnTheLeftInPlace(Z);\n    return Z.adjoint();\n  }\n\n  /** \\returns a reference to the matrix where the complete orthogonal\n   * decomposition is stored\n   */\n  const MatrixType& matrixQTZ() const { return m_cpqr.matrixQR(); }\n\n  /** \\returns a reference to the matrix where the complete orthogonal\n   * decomposition is stored.\n   * \\warning The strict lower part and \\code cols() - rank() \\endcode right\n   * columns of this matrix contains internal values.\n   * Only the upper triangular part should be referenced. To get it, use\n   * \\code matrixT().template triangularView<Upper>() \\endcode\n   * For rank-deficient matrices, use\n   * \\code\n   * matrixR().topLeftCorner(rank(), rank()).template triangularView<Upper>()\n   * \\endcode\n   */\n  const MatrixType& matrixT() const { return m_cpqr.matrixQR(); }\n\n  template <typename InputType>\n  CompleteOrthogonalDecomposition& compute(const EigenBase<InputType>& matrix) {\n    // Compute the column pivoted QR factorization A P = Q R.\n    m_cpqr.compute(matrix);\n    computeInPlace();\n    return *this;\n  }\n\n  /** \\returns a const reference to the column permutation matrix */\n  const PermutationType& colsPermutation() const {\n    return m_cpqr.colsPermutation();\n  }\n\n  /** \\returns the absolute value of the determinant of the matrix of which\n   * *this is the complete orthogonal decomposition. It has only linear\n   * complexity (that is, O(n) where n is the dimension of the square matrix)\n   * as the complete orthogonal decomposition has already been computed.\n   *\n   * \\note This is only for square matrices.\n   *\n   * \\warning a determinant can be very big or small, so for matrices\n   * of large enough dimension, there is a risk of overflow/underflow.\n   * One way to work around that is to use logAbsDeterminant() instead.\n   *\n   * \\sa logAbsDeterminant(), MatrixBase::determinant()\n   */\n  typename MatrixType::RealScalar absDeterminant() const;\n\n  /** \\returns the natural log of the absolute value of the determinant of the\n   * matrix of which *this is the complete orthogonal decomposition. It has\n   * only linear complexity (that is, O(n) where n is the dimension of the\n   * square matrix) as the complete orthogonal decomposition has already been\n   * computed.\n   *\n   * \\note This is only for square matrices.\n   *\n   * \\note This method is useful to work around the risk of overflow/underflow\n   * that's inherent to determinant computation.\n   *\n   * \\sa absDeterminant(), MatrixBase::determinant()\n   */\n  typename MatrixType::RealScalar logAbsDeterminant() const;\n\n  /** \\returns the rank of the matrix of which *this is the complete orthogonal\n   * decomposition.\n   *\n   * \\note This method has to determine which pivots should be considered\n   * nonzero. For that, it uses the threshold value that you can control by\n   * calling setThreshold(const RealScalar&).\n   */\n  inline Index rank() const { return m_cpqr.rank(); }\n\n  /** \\returns the dimension of the kernel of the matrix of which *this is the\n   * complete orthogonal decomposition.\n   *\n   * \\note This method has to determine which pivots should be considered\n   * nonzero. For that, it uses the threshold value that you can control by\n   * calling setThreshold(const RealScalar&).\n   */\n  inline Index dimensionOfKernel() const { return m_cpqr.dimensionOfKernel(); }\n\n  /** \\returns true if the matrix of which *this is the decomposition represents\n   * an injective linear map, i.e. has trivial kernel; false otherwise.\n   *\n   * \\note This method has to determine which pivots should be considered\n   * nonzero. For that, it uses the threshold value that you can control by\n   * calling setThreshold(const RealScalar&).\n   */\n  inline bool isInjective() const { return m_cpqr.isInjective(); }\n\n  /** \\returns true if the matrix of which *this is the decomposition represents\n   * a surjective linear map; false otherwise.\n   *\n   * \\note This method has to determine which pivots should be considered\n   * nonzero. For that, it uses the threshold value that you can control by\n   * calling setThreshold(const RealScalar&).\n   */\n  inline bool isSurjective() const { return m_cpqr.isSurjective(); }\n\n  /** \\returns true if the matrix of which *this is the complete orthogonal\n   * decomposition is invertible.\n   *\n   * \\note This method has to determine which pivots should be considered\n   * nonzero. For that, it uses the threshold value that you can control by\n   * calling setThreshold(const RealScalar&).\n   */\n  inline bool isInvertible() const { return m_cpqr.isInvertible(); }\n\n  /** \\returns the pseudo-inverse of the matrix of which *this is the complete\n   * orthogonal decomposition.\n   * \\warning: Do not compute \\c this->pseudoInverse()*rhs to solve a linear systems.\n   * It is more efficient and numerically stable to call \\c this->solve(rhs).\n   */\n  inline const Inverse<CompleteOrthogonalDecomposition> pseudoInverse() const\n  {\n    return Inverse<CompleteOrthogonalDecomposition>(*this);\n  }\n\n  inline Index rows() const { return m_cpqr.rows(); }\n  inline Index cols() const { return m_cpqr.cols(); }\n\n  /** \\returns a const reference to the vector of Householder coefficients used\n   * to represent the factor \\c Q.\n   *\n   * For advanced uses only.\n   */\n  inline const HCoeffsType& hCoeffs() const { return m_cpqr.hCoeffs(); }\n\n  /** \\returns a const reference to the vector of Householder coefficients\n   * used to represent the factor \\c Z.\n   *\n   * For advanced uses only.\n   */\n  const HCoeffsType& zCoeffs() const { return m_zCoeffs; }\n\n  /** Allows to prescribe a threshold to be used by certain methods, such as\n   * rank(), who need to determine when pivots are to be considered nonzero.\n   * Most be called before calling compute().\n   *\n   * When it needs to get the threshold value, Eigen calls threshold(). By\n   * default, this uses a formula to automatically determine a reasonable\n   * threshold. Once you have called the present method\n   * setThreshold(const RealScalar&), your value is used instead.\n   *\n   * \\param threshold The new value to use as the threshold.\n   *\n   * A pivot will be considered nonzero if its absolute value is strictly\n   * greater than\n   *  \\f$ \\vert pivot \\vert \\leqslant threshold \\times \\vert maxpivot \\vert \\f$\n   * where maxpivot is the biggest pivot.\n   *\n   * If you want to come back to the default behavior, call\n   * setThreshold(Default_t)\n   */\n  CompleteOrthogonalDecomposition& setThreshold(const RealScalar& threshold) {\n    m_cpqr.setThreshold(threshold);\n    return *this;\n  }\n\n  /** Allows to come back to the default behavior, letting Eigen use its default\n   * formula for determining the threshold.\n   *\n   * You should pass the special object Eigen::Default as parameter here.\n   * \\code qr.setThreshold(Eigen::Default); \\endcode\n   *\n   * See the documentation of setThreshold(const RealScalar&).\n   */\n  CompleteOrthogonalDecomposition& setThreshold(Default_t) {\n    m_cpqr.setThreshold(Default);\n    return *this;\n  }\n\n  /** Returns the threshold that will be used by certain methods such as rank().\n   *\n   * See the documentation of setThreshold(const RealScalar&).\n   */\n  RealScalar threshold() const { return m_cpqr.threshold(); }\n\n  /** \\returns the number of nonzero pivots in the complete orthogonal\n   * decomposition. Here nonzero is meant in the exact sense, not in a\n   * fuzzy sense. So that notion isn't really intrinsically interesting,\n   * but it is still useful when implementing algorithms.\n   *\n   * \\sa rank()\n   */\n  inline Index nonzeroPivots() const { return m_cpqr.nonzeroPivots(); }\n\n  /** \\returns the absolute value of the biggest pivot, i.e. the biggest\n   *          diagonal coefficient of R.\n   */\n  inline RealScalar maxPivot() const { return m_cpqr.maxPivot(); }\n\n  /** \\brief Reports whether the complete orthogonal decomposition was\n   * succesful.\n   *\n   * \\note This function always returns \\c Success. It is provided for\n   * compatibility\n   * with other factorization routines.\n   * \\returns \\c Success\n   */\n  ComputationInfo info() const {\n    eigen_assert(m_cpqr.m_isInitialized && \"Decomposition is not initialized.\");\n    return Success;\n  }\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n  template <typename RhsType, typename DstType>\n  EIGEN_DEVICE_FUNC void _solve_impl(const RhsType& rhs, DstType& dst) const;\n#endif\n\n protected:\n  static void check_template_parameters() {\n    EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n  }\n\n  void computeInPlace();\n\n  /** Overwrites \\b rhs with \\f$ \\mathbf{Z}^* * \\mathbf{rhs} \\f$.\n   */\n  template <typename Rhs>\n  void applyZAdjointOnTheLeftInPlace(Rhs& rhs) const;\n\n  ColPivHouseholderQR<MatrixType> m_cpqr;\n  HCoeffsType m_zCoeffs;\n  RowVectorType m_temp;\n};\n\ntemplate <typename MatrixType>\ntypename MatrixType::RealScalar\nCompleteOrthogonalDecomposition<MatrixType>::absDeterminant() const {\n  return m_cpqr.absDeterminant();\n}\n\ntemplate <typename MatrixType>\ntypename MatrixType::RealScalar\nCompleteOrthogonalDecomposition<MatrixType>::logAbsDeterminant() const {\n  return m_cpqr.logAbsDeterminant();\n}\n\n/** Performs the complete orthogonal decomposition of the given matrix \\a\n * matrix. The result of the factorization is stored into \\c *this, and a\n * reference to \\c *this is returned.\n *\n * \\sa class CompleteOrthogonalDecomposition,\n * CompleteOrthogonalDecomposition(const MatrixType&)\n */\ntemplate <typename MatrixType>\nvoid CompleteOrthogonalDecomposition<MatrixType>::computeInPlace()\n{\n  check_template_parameters();\n\n  // the column permutation is stored as int indices, so just to be sure:\n  eigen_assert(m_cpqr.cols() <= NumTraits<int>::highest());\n\n  const Index rank = m_cpqr.rank();\n  const Index cols = m_cpqr.cols();\n  const Index rows = m_cpqr.rows();\n  m_zCoeffs.resize((std::min)(rows, cols));\n  m_temp.resize(cols);\n\n  if (rank < cols) {\n    // We have reduced the (permuted) matrix to the form\n    //   [R11 R12]\n    //   [ 0  R22]\n    // where R11 is r-by-r (r = rank) upper triangular, R12 is\n    // r-by-(n-r), and R22 is empty or the norm of R22 is negligible.\n    // We now compute the complete orthogonal decomposition by applying\n    // Householder transformations from the right to the upper trapezoidal\n    // matrix X = [R11 R12] to zero out R12 and obtain the factorization\n    // [R11 R12] = [T11 0] * Z, where T11 is r-by-r upper triangular and\n    // Z = Z(0) * Z(1) ... Z(r-1) is an n-by-n orthogonal matrix.\n    // We store the data representing Z in R12 and m_zCoeffs.\n    for (Index k = rank - 1; k >= 0; --k) {\n      if (k != rank - 1) {\n        // Given the API for Householder reflectors, it is more convenient if\n        // we swap the leading parts of columns k and r-1 (zero-based) to form\n        // the matrix X_k = [X(0:k, k), X(0:k, r:n)]\n        m_cpqr.m_qr.col(k).head(k + 1).swap(\n            m_cpqr.m_qr.col(rank - 1).head(k + 1));\n      }\n      // Construct Householder reflector Z(k) to zero out the last row of X_k,\n      // i.e. choose Z(k) such that\n      // [X(k, k), X(k, r:n)] * Z(k) = [beta, 0, .., 0].\n      RealScalar beta;\n      m_cpqr.m_qr.row(k)\n          .tail(cols - rank + 1)\n          .makeHouseholderInPlace(m_zCoeffs(k), beta);\n      m_cpqr.m_qr(k, rank - 1) = beta;\n      if (k > 0) {\n        // Apply Z(k) to the first k rows of X_k\n        m_cpqr.m_qr.topRightCorner(k, cols - rank + 1)\n            .applyHouseholderOnTheRight(\n                m_cpqr.m_qr.row(k).tail(cols - rank).transpose(), m_zCoeffs(k),\n                &m_temp(0));\n      }\n      if (k != rank - 1) {\n        // Swap X(0:k,k) back to its proper location.\n        m_cpqr.m_qr.col(k).head(k + 1).swap(\n            m_cpqr.m_qr.col(rank - 1).head(k + 1));\n      }\n    }\n  }\n}\n\ntemplate <typename MatrixType>\ntemplate <typename Rhs>\nvoid CompleteOrthogonalDecomposition<MatrixType>::applyZAdjointOnTheLeftInPlace(\n    Rhs& rhs) const {\n  const Index cols = this->cols();\n  const Index nrhs = rhs.cols();\n  const Index rank = this->rank();\n  Matrix<typename MatrixType::Scalar, Dynamic, 1> temp((std::max)(cols, nrhs));\n  for (Index k = 0; k < rank; ++k) {\n    if (k != rank - 1) {\n      rhs.row(k).swap(rhs.row(rank - 1));\n    }\n    rhs.middleRows(rank - 1, cols - rank + 1)\n        .applyHouseholderOnTheLeft(\n            matrixQTZ().row(k).tail(cols - rank).adjoint(), zCoeffs()(k),\n            &temp(0));\n    if (k != rank - 1) {\n      rhs.row(k).swap(rhs.row(rank - 1));\n    }\n  }\n}\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate <typename _MatrixType>\ntemplate <typename RhsType, typename DstType>\nvoid CompleteOrthogonalDecomposition<_MatrixType>::_solve_impl(\n    const RhsType& rhs, DstType& dst) const {\n  eigen_assert(rhs.rows() == this->rows());\n\n  const Index rank = this->rank();\n  if (rank == 0) {\n    dst.setZero();\n    return;\n  }\n\n  // Compute c = Q^* * rhs\n  // Note that the matrix Q = H_0^* H_1^*... so its inverse is\n  // Q^* = (H_0 H_1 ...)^T\n  typename RhsType::PlainObject c(rhs);\n  c.applyOnTheLeft(\n      householderSequence(matrixQTZ(), hCoeffs()).setLength(rank).transpose());\n\n  // Solve T z = c(1:rank, :)\n  dst.topRows(rank) = matrixT()\n                          .topLeftCorner(rank, rank)\n                          .template triangularView<Upper>()\n                          .solve(c.topRows(rank));\n\n  const Index cols = this->cols();\n  if (rank < cols) {\n    // Compute y = Z^* * [ z ]\n    //                   [ 0 ]\n    dst.bottomRows(cols - rank).setZero();\n    applyZAdjointOnTheLeftInPlace(dst);\n  }\n\n  // Undo permutation to get x = P^{-1} * y.\n  dst = colsPermutation() * dst;\n}\n#endif\n\nnamespace internal {\n\ntemplate<typename DstXprType, typename MatrixType>\nstruct Assignment<DstXprType, Inverse<CompleteOrthogonalDecomposition<MatrixType> >, internal::assign_op<typename DstXprType::Scalar,typename CompleteOrthogonalDecomposition<MatrixType>::Scalar>, Dense2Dense>\n{\n  typedef CompleteOrthogonalDecomposition<MatrixType> CodType;\n  typedef Inverse<CodType> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename CodType::Scalar> &)\n  {\n    dst = src.nestedExpression().solve(MatrixType::Identity(src.rows(), src.rows()));\n  }\n};\n\n} // end namespace internal\n\n/** \\returns the matrix Q as a sequence of householder transformations */\ntemplate <typename MatrixType>\ntypename CompleteOrthogonalDecomposition<MatrixType>::HouseholderSequenceType\nCompleteOrthogonalDecomposition<MatrixType>::householderQ() const {\n  return m_cpqr.householderQ();\n}\n\n/** \\return the complete orthogonal decomposition of \\c *this.\n  *\n  * \\sa class CompleteOrthogonalDecomposition\n  */\ntemplate <typename Derived>\nconst CompleteOrthogonalDecomposition<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::completeOrthogonalDecomposition() const {\n  return CompleteOrthogonalDecomposition<PlainObject>(eval());\n}\n\n}  // end namespace Eigen\n\n#endif  // EIGEN_COMPLETEORTHOGONALDECOMPOSITION_H\n"
  },
  {
    "path": "include/externals/Eigen/src/QR/FullPivHouseholderQR.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_FULLPIVOTINGHOUSEHOLDERQR_H\n#define EIGEN_FULLPIVOTINGHOUSEHOLDERQR_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename _MatrixType> struct traits<FullPivHouseholderQR<_MatrixType> >\n : traits<_MatrixType>\n{\n  enum { Flags = 0 };\n};\n\ntemplate<typename MatrixType> struct FullPivHouseholderQRMatrixQReturnType;\n\ntemplate<typename MatrixType>\nstruct traits<FullPivHouseholderQRMatrixQReturnType<MatrixType> >\n{\n  typedef typename MatrixType::PlainObject ReturnType;\n};\n\n} // end namespace internal\n\n/** \\ingroup QR_Module\n  *\n  * \\class FullPivHouseholderQR\n  *\n  * \\brief Householder rank-revealing QR decomposition of a matrix with full pivoting\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the QR decomposition\n  *\n  * This class performs a rank-revealing QR decomposition of a matrix \\b A into matrices \\b P, \\b P', \\b Q and \\b R\n  * such that \n  * \\f[\n  *  \\mathbf{P} \\, \\mathbf{A} \\, \\mathbf{P}' = \\mathbf{Q} \\, \\mathbf{R}\n  * \\f]\n  * by using Householder transformations. Here, \\b P and \\b P' are permutation matrices, \\b Q a unitary matrix \n  * and \\b R an upper triangular matrix.\n  *\n  * This decomposition performs a very prudent full pivoting in order to be rank-revealing and achieve optimal\n  * numerical stability. The trade-off is that it is slower than HouseholderQR and ColPivHouseholderQR.\n  *\n  * This class supports the \\link InplaceDecomposition inplace decomposition \\endlink mechanism.\n  * \n  * \\sa MatrixBase::fullPivHouseholderQr()\n  */\ntemplate<typename _MatrixType> class FullPivHouseholderQR\n{\n  public:\n\n    typedef _MatrixType MatrixType;\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    // FIXME should be int\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef internal::FullPivHouseholderQRMatrixQReturnType<MatrixType> MatrixQReturnType;\n    typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType;\n    typedef Matrix<StorageIndex, 1,\n                   EIGEN_SIZE_MIN_PREFER_DYNAMIC(ColsAtCompileTime,RowsAtCompileTime), RowMajor, 1,\n                   EIGEN_SIZE_MIN_PREFER_FIXED(MaxColsAtCompileTime,MaxRowsAtCompileTime)> IntDiagSizeVectorType;\n    typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationType;\n    typedef typename internal::plain_row_type<MatrixType>::type RowVectorType;\n    typedef typename internal::plain_col_type<MatrixType>::type ColVectorType;\n    typedef typename MatrixType::PlainObject PlainObject;\n\n    /** \\brief Default Constructor.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via FullPivHouseholderQR::compute(const MatrixType&).\n      */\n    FullPivHouseholderQR()\n      : m_qr(),\n        m_hCoeffs(),\n        m_rows_transpositions(),\n        m_cols_transpositions(),\n        m_cols_permutation(),\n        m_temp(),\n        m_isInitialized(false),\n        m_usePrescribedThreshold(false) {}\n\n    /** \\brief Default Constructor with memory preallocation\n      *\n      * Like the default constructor but with preallocation of the internal data\n      * according to the specified problem \\a size.\n      * \\sa FullPivHouseholderQR()\n      */\n    FullPivHouseholderQR(Index rows, Index cols)\n      : m_qr(rows, cols),\n        m_hCoeffs((std::min)(rows,cols)),\n        m_rows_transpositions((std::min)(rows,cols)),\n        m_cols_transpositions((std::min)(rows,cols)),\n        m_cols_permutation(cols),\n        m_temp(cols),\n        m_isInitialized(false),\n        m_usePrescribedThreshold(false) {}\n\n    /** \\brief Constructs a QR factorization from a given matrix\n      *\n      * This constructor computes the QR factorization of the matrix \\a matrix by calling\n      * the method compute(). It is a short cut for:\n      * \n      * \\code\n      * FullPivHouseholderQR<MatrixType> qr(matrix.rows(), matrix.cols());\n      * qr.compute(matrix);\n      * \\endcode\n      * \n      * \\sa compute()\n      */\n    template<typename InputType>\n    explicit FullPivHouseholderQR(const EigenBase<InputType>& matrix)\n      : m_qr(matrix.rows(), matrix.cols()),\n        m_hCoeffs((std::min)(matrix.rows(), matrix.cols())),\n        m_rows_transpositions((std::min)(matrix.rows(), matrix.cols())),\n        m_cols_transpositions((std::min)(matrix.rows(), matrix.cols())),\n        m_cols_permutation(matrix.cols()),\n        m_temp(matrix.cols()),\n        m_isInitialized(false),\n        m_usePrescribedThreshold(false)\n    {\n      compute(matrix.derived());\n    }\n\n    /** \\brief Constructs a QR factorization from a given matrix\n      *\n      * This overloaded constructor is provided for \\link InplaceDecomposition inplace decomposition \\endlink when \\c MatrixType is a Eigen::Ref.\n      *\n      * \\sa FullPivHouseholderQR(const EigenBase&)\n      */\n    template<typename InputType>\n    explicit FullPivHouseholderQR(EigenBase<InputType>& matrix)\n      : m_qr(matrix.derived()),\n        m_hCoeffs((std::min)(matrix.rows(), matrix.cols())),\n        m_rows_transpositions((std::min)(matrix.rows(), matrix.cols())),\n        m_cols_transpositions((std::min)(matrix.rows(), matrix.cols())),\n        m_cols_permutation(matrix.cols()),\n        m_temp(matrix.cols()),\n        m_isInitialized(false),\n        m_usePrescribedThreshold(false)\n    {\n      computeInPlace();\n    }\n\n    /** This method finds a solution x to the equation Ax=b, where A is the matrix of which\n      * \\c *this is the QR decomposition.\n      *\n      * \\param b the right-hand-side of the equation to solve.\n      *\n      * \\returns the exact or least-square solution if the rank is greater or equal to the number of columns of A,\n      * and an arbitrary solution otherwise.\n      *\n      * \\note_about_checking_solutions\n      *\n      * \\note_about_arbitrary_choice_of_solution\n      *\n      * Example: \\include FullPivHouseholderQR_solve.cpp\n      * Output: \\verbinclude FullPivHouseholderQR_solve.out\n      */\n    template<typename Rhs>\n    inline const Solve<FullPivHouseholderQR, Rhs>\n    solve(const MatrixBase<Rhs>& b) const\n    {\n      eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n      return Solve<FullPivHouseholderQR, Rhs>(*this, b.derived());\n    }\n\n    /** \\returns Expression object representing the matrix Q\n      */\n    MatrixQReturnType matrixQ(void) const;\n\n    /** \\returns a reference to the matrix where the Householder QR decomposition is stored\n      */\n    const MatrixType& matrixQR() const\n    {\n      eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n      return m_qr;\n    }\n\n    template<typename InputType>\n    FullPivHouseholderQR& compute(const EigenBase<InputType>& matrix);\n\n    /** \\returns a const reference to the column permutation matrix */\n    const PermutationType& colsPermutation() const\n    {\n      eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n      return m_cols_permutation;\n    }\n\n    /** \\returns a const reference to the vector of indices representing the rows transpositions */\n    const IntDiagSizeVectorType& rowsTranspositions() const\n    {\n      eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n      return m_rows_transpositions;\n    }\n\n    /** \\returns the absolute value of the determinant of the matrix of which\n      * *this is the QR decomposition. It has only linear complexity\n      * (that is, O(n) where n is the dimension of the square matrix)\n      * as the QR decomposition has already been computed.\n      *\n      * \\note This is only for square matrices.\n      *\n      * \\warning a determinant can be very big or small, so for matrices\n      * of large enough dimension, there is a risk of overflow/underflow.\n      * One way to work around that is to use logAbsDeterminant() instead.\n      *\n      * \\sa logAbsDeterminant(), MatrixBase::determinant()\n      */\n    typename MatrixType::RealScalar absDeterminant() const;\n\n    /** \\returns the natural log of the absolute value of the determinant of the matrix of which\n      * *this is the QR decomposition. It has only linear complexity\n      * (that is, O(n) where n is the dimension of the square matrix)\n      * as the QR decomposition has already been computed.\n      *\n      * \\note This is only for square matrices.\n      *\n      * \\note This method is useful to work around the risk of overflow/underflow that's inherent\n      * to determinant computation.\n      *\n      * \\sa absDeterminant(), MatrixBase::determinant()\n      */\n    typename MatrixType::RealScalar logAbsDeterminant() const;\n\n    /** \\returns the rank of the matrix of which *this is the QR decomposition.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline Index rank() const\n    {\n      using std::abs;\n      eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n      RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold();\n      Index result = 0;\n      for(Index i = 0; i < m_nonzero_pivots; ++i)\n        result += (abs(m_qr.coeff(i,i)) > premultiplied_threshold);\n      return result;\n    }\n\n    /** \\returns the dimension of the kernel of the matrix of which *this is the QR decomposition.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline Index dimensionOfKernel() const\n    {\n      eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n      return cols() - rank();\n    }\n\n    /** \\returns true if the matrix of which *this is the QR decomposition represents an injective\n      *          linear map, i.e. has trivial kernel; false otherwise.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline bool isInjective() const\n    {\n      eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n      return rank() == cols();\n    }\n\n    /** \\returns true if the matrix of which *this is the QR decomposition represents a surjective\n      *          linear map; false otherwise.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline bool isSurjective() const\n    {\n      eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n      return rank() == rows();\n    }\n\n    /** \\returns true if the matrix of which *this is the QR decomposition is invertible.\n      *\n      * \\note This method has to determine which pivots should be considered nonzero.\n      *       For that, it uses the threshold value that you can control by calling\n      *       setThreshold(const RealScalar&).\n      */\n    inline bool isInvertible() const\n    {\n      eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n      return isInjective() && isSurjective();\n    }\n\n    /** \\returns the inverse of the matrix of which *this is the QR decomposition.\n      *\n      * \\note If this matrix is not invertible, the returned matrix has undefined coefficients.\n      *       Use isInvertible() to first determine whether this matrix is invertible.\n      */\n    inline const Inverse<FullPivHouseholderQR> inverse() const\n    {\n      eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n      return Inverse<FullPivHouseholderQR>(*this);\n    }\n\n    inline Index rows() const { return m_qr.rows(); }\n    inline Index cols() const { return m_qr.cols(); }\n    \n    /** \\returns a const reference to the vector of Householder coefficients used to represent the factor \\c Q.\n      * \n      * For advanced uses only.\n      */\n    const HCoeffsType& hCoeffs() const { return m_hCoeffs; }\n\n    /** Allows to prescribe a threshold to be used by certain methods, such as rank(),\n      * who need to determine when pivots are to be considered nonzero. This is not used for the\n      * QR decomposition itself.\n      *\n      * When it needs to get the threshold value, Eigen calls threshold(). By default, this\n      * uses a formula to automatically determine a reasonable threshold.\n      * Once you have called the present method setThreshold(const RealScalar&),\n      * your value is used instead.\n      *\n      * \\param threshold The new value to use as the threshold.\n      *\n      * A pivot will be considered nonzero if its absolute value is strictly greater than\n      *  \\f$ \\vert pivot \\vert \\leqslant threshold \\times \\vert maxpivot \\vert \\f$\n      * where maxpivot is the biggest pivot.\n      *\n      * If you want to come back to the default behavior, call setThreshold(Default_t)\n      */\n    FullPivHouseholderQR& setThreshold(const RealScalar& threshold)\n    {\n      m_usePrescribedThreshold = true;\n      m_prescribedThreshold = threshold;\n      return *this;\n    }\n\n    /** Allows to come back to the default behavior, letting Eigen use its default formula for\n      * determining the threshold.\n      *\n      * You should pass the special object Eigen::Default as parameter here.\n      * \\code qr.setThreshold(Eigen::Default); \\endcode\n      *\n      * See the documentation of setThreshold(const RealScalar&).\n      */\n    FullPivHouseholderQR& setThreshold(Default_t)\n    {\n      m_usePrescribedThreshold = false;\n      return *this;\n    }\n\n    /** Returns the threshold that will be used by certain methods such as rank().\n      *\n      * See the documentation of setThreshold(const RealScalar&).\n      */\n    RealScalar threshold() const\n    {\n      eigen_assert(m_isInitialized || m_usePrescribedThreshold);\n      return m_usePrescribedThreshold ? m_prescribedThreshold\n      // this formula comes from experimenting (see \"LU precision tuning\" thread on the list)\n      // and turns out to be identical to Higham's formula used already in LDLt.\n                                      : NumTraits<Scalar>::epsilon() * RealScalar(m_qr.diagonalSize());\n    }\n\n    /** \\returns the number of nonzero pivots in the QR decomposition.\n      * Here nonzero is meant in the exact sense, not in a fuzzy sense.\n      * So that notion isn't really intrinsically interesting, but it is\n      * still useful when implementing algorithms.\n      *\n      * \\sa rank()\n      */\n    inline Index nonzeroPivots() const\n    {\n      eigen_assert(m_isInitialized && \"LU is not initialized.\");\n      return m_nonzero_pivots;\n    }\n\n    /** \\returns the absolute value of the biggest pivot, i.e. the biggest\n      *          diagonal coefficient of U.\n      */\n    RealScalar maxPivot() const { return m_maxpivot; }\n    \n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename RhsType, typename DstType>\n    EIGEN_DEVICE_FUNC\n    void _solve_impl(const RhsType &rhs, DstType &dst) const;\n    #endif\n\n  protected:\n    \n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n    }\n    \n    void computeInPlace();\n    \n    MatrixType m_qr;\n    HCoeffsType m_hCoeffs;\n    IntDiagSizeVectorType m_rows_transpositions;\n    IntDiagSizeVectorType m_cols_transpositions;\n    PermutationType m_cols_permutation;\n    RowVectorType m_temp;\n    bool m_isInitialized, m_usePrescribedThreshold;\n    RealScalar m_prescribedThreshold, m_maxpivot;\n    Index m_nonzero_pivots;\n    RealScalar m_precision;\n    Index m_det_pq;\n};\n\ntemplate<typename MatrixType>\ntypename MatrixType::RealScalar FullPivHouseholderQR<MatrixType>::absDeterminant() const\n{\n  using std::abs;\n  eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n  eigen_assert(m_qr.rows() == m_qr.cols() && \"You can't take the determinant of a non-square matrix!\");\n  return abs(m_qr.diagonal().prod());\n}\n\ntemplate<typename MatrixType>\ntypename MatrixType::RealScalar FullPivHouseholderQR<MatrixType>::logAbsDeterminant() const\n{\n  eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n  eigen_assert(m_qr.rows() == m_qr.cols() && \"You can't take the determinant of a non-square matrix!\");\n  return m_qr.diagonal().cwiseAbs().array().log().sum();\n}\n\n/** Performs the QR factorization of the given matrix \\a matrix. The result of\n  * the factorization is stored into \\c *this, and a reference to \\c *this\n  * is returned.\n  *\n  * \\sa class FullPivHouseholderQR, FullPivHouseholderQR(const MatrixType&)\n  */\ntemplate<typename MatrixType>\ntemplate<typename InputType>\nFullPivHouseholderQR<MatrixType>& FullPivHouseholderQR<MatrixType>::compute(const EigenBase<InputType>& matrix)\n{\n  m_qr = matrix.derived();\n  computeInPlace();\n  return *this;\n}\n\ntemplate<typename MatrixType>\nvoid FullPivHouseholderQR<MatrixType>::computeInPlace()\n{\n  check_template_parameters();\n\n  using std::abs;\n  Index rows = m_qr.rows();\n  Index cols = m_qr.cols();\n  Index size = (std::min)(rows,cols);\n\n  \n  m_hCoeffs.resize(size);\n\n  m_temp.resize(cols);\n\n  m_precision = NumTraits<Scalar>::epsilon() * RealScalar(size);\n\n  m_rows_transpositions.resize(size);\n  m_cols_transpositions.resize(size);\n  Index number_of_transpositions = 0;\n\n  RealScalar biggest(0);\n\n  m_nonzero_pivots = size; // the generic case is that in which all pivots are nonzero (invertible case)\n  m_maxpivot = RealScalar(0);\n\n  for (Index k = 0; k < size; ++k)\n  {\n    Index row_of_biggest_in_corner, col_of_biggest_in_corner;\n    typedef internal::scalar_score_coeff_op<Scalar> Scoring;\n    typedef typename Scoring::result_type Score;\n\n    Score score = m_qr.bottomRightCorner(rows-k, cols-k)\n                      .unaryExpr(Scoring())\n                      .maxCoeff(&row_of_biggest_in_corner, &col_of_biggest_in_corner);\n    row_of_biggest_in_corner += k;\n    col_of_biggest_in_corner += k;\n    RealScalar biggest_in_corner = internal::abs_knowing_score<Scalar>()(m_qr(row_of_biggest_in_corner, col_of_biggest_in_corner), score);\n    if(k==0) biggest = biggest_in_corner;\n\n    // if the corner is negligible, then we have less than full rank, and we can finish early\n    if(internal::isMuchSmallerThan(biggest_in_corner, biggest, m_precision))\n    {\n      m_nonzero_pivots = k;\n      for(Index i = k; i < size; i++)\n      {\n        m_rows_transpositions.coeffRef(i) = i;\n        m_cols_transpositions.coeffRef(i) = i;\n        m_hCoeffs.coeffRef(i) = Scalar(0);\n      }\n      break;\n    }\n\n    m_rows_transpositions.coeffRef(k) = row_of_biggest_in_corner;\n    m_cols_transpositions.coeffRef(k) = col_of_biggest_in_corner;\n    if(k != row_of_biggest_in_corner) {\n      m_qr.row(k).tail(cols-k).swap(m_qr.row(row_of_biggest_in_corner).tail(cols-k));\n      ++number_of_transpositions;\n    }\n    if(k != col_of_biggest_in_corner) {\n      m_qr.col(k).swap(m_qr.col(col_of_biggest_in_corner));\n      ++number_of_transpositions;\n    }\n\n    RealScalar beta;\n    m_qr.col(k).tail(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta);\n    m_qr.coeffRef(k,k) = beta;\n\n    // remember the maximum absolute value of diagonal coefficients\n    if(abs(beta) > m_maxpivot) m_maxpivot = abs(beta);\n\n    m_qr.bottomRightCorner(rows-k, cols-k-1)\n        .applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), m_hCoeffs.coeffRef(k), &m_temp.coeffRef(k+1));\n  }\n\n  m_cols_permutation.setIdentity(cols);\n  for(Index k = 0; k < size; ++k)\n    m_cols_permutation.applyTranspositionOnTheRight(k, m_cols_transpositions.coeff(k));\n\n  m_det_pq = (number_of_transpositions%2) ? -1 : 1;\n  m_isInitialized = true;\n}\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename _MatrixType>\ntemplate<typename RhsType, typename DstType>\nvoid FullPivHouseholderQR<_MatrixType>::_solve_impl(const RhsType &rhs, DstType &dst) const\n{\n  eigen_assert(rhs.rows() == rows());\n  const Index l_rank = rank();\n\n  // FIXME introduce nonzeroPivots() and use it here. and more generally,\n  // make the same improvements in this dec as in FullPivLU.\n  if(l_rank==0)\n  {\n    dst.setZero();\n    return;\n  }\n\n  typename RhsType::PlainObject c(rhs);\n\n  Matrix<Scalar,1,RhsType::ColsAtCompileTime> temp(rhs.cols());\n  for (Index k = 0; k < l_rank; ++k)\n  {\n    Index remainingSize = rows()-k;\n    c.row(k).swap(c.row(m_rows_transpositions.coeff(k)));\n    c.bottomRightCorner(remainingSize, rhs.cols())\n      .applyHouseholderOnTheLeft(m_qr.col(k).tail(remainingSize-1),\n                               m_hCoeffs.coeff(k), &temp.coeffRef(0));\n  }\n\n  m_qr.topLeftCorner(l_rank, l_rank)\n      .template triangularView<Upper>()\n      .solveInPlace(c.topRows(l_rank));\n\n  for(Index i = 0; i < l_rank; ++i) dst.row(m_cols_permutation.indices().coeff(i)) = c.row(i);\n  for(Index i = l_rank; i < cols(); ++i) dst.row(m_cols_permutation.indices().coeff(i)).setZero();\n}\n#endif\n\nnamespace internal {\n  \ntemplate<typename DstXprType, typename MatrixType>\nstruct Assignment<DstXprType, Inverse<FullPivHouseholderQR<MatrixType> >, internal::assign_op<typename DstXprType::Scalar,typename FullPivHouseholderQR<MatrixType>::Scalar>, Dense2Dense>\n{\n  typedef FullPivHouseholderQR<MatrixType> QrType;\n  typedef Inverse<QrType> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename QrType::Scalar> &)\n  {    \n    dst = src.nestedExpression().solve(MatrixType::Identity(src.rows(), src.cols()));\n  }\n};\n\n/** \\ingroup QR_Module\n  *\n  * \\brief Expression type for return value of FullPivHouseholderQR::matrixQ()\n  *\n  * \\tparam MatrixType type of underlying dense matrix\n  */\ntemplate<typename MatrixType> struct FullPivHouseholderQRMatrixQReturnType\n  : public ReturnByValue<FullPivHouseholderQRMatrixQReturnType<MatrixType> >\n{\npublic:\n  typedef typename FullPivHouseholderQR<MatrixType>::IntDiagSizeVectorType IntDiagSizeVectorType;\n  typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType;\n  typedef Matrix<typename MatrixType::Scalar, 1, MatrixType::RowsAtCompileTime, RowMajor, 1,\n                 MatrixType::MaxRowsAtCompileTime> WorkVectorType;\n\n  FullPivHouseholderQRMatrixQReturnType(const MatrixType&       qr,\n                                        const HCoeffsType&      hCoeffs,\n                                        const IntDiagSizeVectorType& rowsTranspositions)\n    : m_qr(qr),\n      m_hCoeffs(hCoeffs),\n      m_rowsTranspositions(rowsTranspositions)\n  {}\n\n  template <typename ResultType>\n  void evalTo(ResultType& result) const\n  {\n    const Index rows = m_qr.rows();\n    WorkVectorType workspace(rows);\n    evalTo(result, workspace);\n  }\n\n  template <typename ResultType>\n  void evalTo(ResultType& result, WorkVectorType& workspace) const\n  {\n    using numext::conj;\n    // compute the product H'_0 H'_1 ... H'_n-1,\n    // where H_k is the k-th Householder transformation I - h_k v_k v_k'\n    // and v_k is the k-th Householder vector [1,m_qr(k+1,k), m_qr(k+2,k), ...]\n    const Index rows = m_qr.rows();\n    const Index cols = m_qr.cols();\n    const Index size = (std::min)(rows, cols);\n    workspace.resize(rows);\n    result.setIdentity(rows, rows);\n    for (Index k = size-1; k >= 0; k--)\n    {\n      result.block(k, k, rows-k, rows-k)\n            .applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), conj(m_hCoeffs.coeff(k)), &workspace.coeffRef(k));\n      result.row(k).swap(result.row(m_rowsTranspositions.coeff(k)));\n    }\n  }\n\n  Index rows() const { return m_qr.rows(); }\n  Index cols() const { return m_qr.rows(); }\n\nprotected:\n  typename MatrixType::Nested m_qr;\n  typename HCoeffsType::Nested m_hCoeffs;\n  typename IntDiagSizeVectorType::Nested m_rowsTranspositions;\n};\n\n// template<typename MatrixType>\n// struct evaluator<FullPivHouseholderQRMatrixQReturnType<MatrixType> >\n//  : public evaluator<ReturnByValue<FullPivHouseholderQRMatrixQReturnType<MatrixType> > >\n// {};\n\n} // end namespace internal\n\ntemplate<typename MatrixType>\ninline typename FullPivHouseholderQR<MatrixType>::MatrixQReturnType FullPivHouseholderQR<MatrixType>::matrixQ() const\n{\n  eigen_assert(m_isInitialized && \"FullPivHouseholderQR is not initialized.\");\n  return MatrixQReturnType(m_qr, m_hCoeffs, m_rows_transpositions);\n}\n\n/** \\return the full-pivoting Householder QR decomposition of \\c *this.\n  *\n  * \\sa class FullPivHouseholderQR\n  */\ntemplate<typename Derived>\nconst FullPivHouseholderQR<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::fullPivHouseholderQr() const\n{\n  return FullPivHouseholderQR<PlainObject>(eval());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_FULLPIVOTINGHOUSEHOLDERQR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/QR/HouseholderQR.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2010 Vincent Lejeune\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_QR_H\n#define EIGEN_QR_H\n\nnamespace Eigen { \n\n/** \\ingroup QR_Module\n  *\n  *\n  * \\class HouseholderQR\n  *\n  * \\brief Householder QR decomposition of a matrix\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the QR decomposition\n  *\n  * This class performs a QR decomposition of a matrix \\b A into matrices \\b Q and \\b R\n  * such that \n  * \\f[\n  *  \\mathbf{A} = \\mathbf{Q} \\, \\mathbf{R}\n  * \\f]\n  * by using Householder transformations. Here, \\b Q a unitary matrix and \\b R an upper triangular matrix.\n  * The result is stored in a compact way compatible with LAPACK.\n  *\n  * Note that no pivoting is performed. This is \\b not a rank-revealing decomposition.\n  * If you want that feature, use FullPivHouseholderQR or ColPivHouseholderQR instead.\n  *\n  * This Householder QR decomposition is faster, but less numerically stable and less feature-full than\n  * FullPivHouseholderQR or ColPivHouseholderQR.\n  *\n  * This class supports the \\link InplaceDecomposition inplace decomposition \\endlink mechanism.\n  *\n  * \\sa MatrixBase::householderQr()\n  */\ntemplate<typename _MatrixType> class HouseholderQR\n{\n  public:\n\n    typedef _MatrixType MatrixType;\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    // FIXME should be int\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime, (MatrixType::Flags&RowMajorBit) ? RowMajor : ColMajor, MaxRowsAtCompileTime, MaxRowsAtCompileTime> MatrixQType;\n    typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType;\n    typedef typename internal::plain_row_type<MatrixType>::type RowVectorType;\n    typedef HouseholderSequence<MatrixType,typename internal::remove_all<typename HCoeffsType::ConjugateReturnType>::type> HouseholderSequenceType;\n\n    /**\n      * \\brief Default Constructor.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via HouseholderQR::compute(const MatrixType&).\n      */\n    HouseholderQR() : m_qr(), m_hCoeffs(), m_temp(), m_isInitialized(false) {}\n\n    /** \\brief Default Constructor with memory preallocation\n      *\n      * Like the default constructor but with preallocation of the internal data\n      * according to the specified problem \\a size.\n      * \\sa HouseholderQR()\n      */\n    HouseholderQR(Index rows, Index cols)\n      : m_qr(rows, cols),\n        m_hCoeffs((std::min)(rows,cols)),\n        m_temp(cols),\n        m_isInitialized(false) {}\n\n    /** \\brief Constructs a QR factorization from a given matrix\n      *\n      * This constructor computes the QR factorization of the matrix \\a matrix by calling\n      * the method compute(). It is a short cut for:\n      * \n      * \\code\n      * HouseholderQR<MatrixType> qr(matrix.rows(), matrix.cols());\n      * qr.compute(matrix);\n      * \\endcode\n      * \n      * \\sa compute()\n      */\n    template<typename InputType>\n    explicit HouseholderQR(const EigenBase<InputType>& matrix)\n      : m_qr(matrix.rows(), matrix.cols()),\n        m_hCoeffs((std::min)(matrix.rows(),matrix.cols())),\n        m_temp(matrix.cols()),\n        m_isInitialized(false)\n    {\n      compute(matrix.derived());\n    }\n\n\n    /** \\brief Constructs a QR factorization from a given matrix\n      *\n      * This overloaded constructor is provided for \\link InplaceDecomposition inplace decomposition \\endlink when\n      * \\c MatrixType is a Eigen::Ref.\n      *\n      * \\sa HouseholderQR(const EigenBase&)\n      */\n    template<typename InputType>\n    explicit HouseholderQR(EigenBase<InputType>& matrix)\n      : m_qr(matrix.derived()),\n        m_hCoeffs((std::min)(matrix.rows(),matrix.cols())),\n        m_temp(matrix.cols()),\n        m_isInitialized(false)\n    {\n      computeInPlace();\n    }\n\n    /** This method finds a solution x to the equation Ax=b, where A is the matrix of which\n      * *this is the QR decomposition, if any exists.\n      *\n      * \\param b the right-hand-side of the equation to solve.\n      *\n      * \\returns a solution.\n      *\n      * \\note_about_checking_solutions\n      *\n      * \\note_about_arbitrary_choice_of_solution\n      *\n      * Example: \\include HouseholderQR_solve.cpp\n      * Output: \\verbinclude HouseholderQR_solve.out\n      */\n    template<typename Rhs>\n    inline const Solve<HouseholderQR, Rhs>\n    solve(const MatrixBase<Rhs>& b) const\n    {\n      eigen_assert(m_isInitialized && \"HouseholderQR is not initialized.\");\n      return Solve<HouseholderQR, Rhs>(*this, b.derived());\n    }\n\n    /** This method returns an expression of the unitary matrix Q as a sequence of Householder transformations.\n      *\n      * The returned expression can directly be used to perform matrix products. It can also be assigned to a dense Matrix object.\n      * Here is an example showing how to recover the full or thin matrix Q, as well as how to perform matrix products using operator*:\n      *\n      * Example: \\include HouseholderQR_householderQ.cpp\n      * Output: \\verbinclude HouseholderQR_householderQ.out\n      */\n    HouseholderSequenceType householderQ() const\n    {\n      eigen_assert(m_isInitialized && \"HouseholderQR is not initialized.\");\n      return HouseholderSequenceType(m_qr, m_hCoeffs.conjugate());\n    }\n\n    /** \\returns a reference to the matrix where the Householder QR decomposition is stored\n      * in a LAPACK-compatible way.\n      */\n    const MatrixType& matrixQR() const\n    {\n        eigen_assert(m_isInitialized && \"HouseholderQR is not initialized.\");\n        return m_qr;\n    }\n\n    template<typename InputType>\n    HouseholderQR& compute(const EigenBase<InputType>& matrix) {\n      m_qr = matrix.derived();\n      computeInPlace();\n      return *this;\n    }\n\n    /** \\returns the absolute value of the determinant of the matrix of which\n      * *this is the QR decomposition. It has only linear complexity\n      * (that is, O(n) where n is the dimension of the square matrix)\n      * as the QR decomposition has already been computed.\n      *\n      * \\note This is only for square matrices.\n      *\n      * \\warning a determinant can be very big or small, so for matrices\n      * of large enough dimension, there is a risk of overflow/underflow.\n      * One way to work around that is to use logAbsDeterminant() instead.\n      *\n      * \\sa logAbsDeterminant(), MatrixBase::determinant()\n      */\n    typename MatrixType::RealScalar absDeterminant() const;\n\n    /** \\returns the natural log of the absolute value of the determinant of the matrix of which\n      * *this is the QR decomposition. It has only linear complexity\n      * (that is, O(n) where n is the dimension of the square matrix)\n      * as the QR decomposition has already been computed.\n      *\n      * \\note This is only for square matrices.\n      *\n      * \\note This method is useful to work around the risk of overflow/underflow that's inherent\n      * to determinant computation.\n      *\n      * \\sa absDeterminant(), MatrixBase::determinant()\n      */\n    typename MatrixType::RealScalar logAbsDeterminant() const;\n\n    inline Index rows() const { return m_qr.rows(); }\n    inline Index cols() const { return m_qr.cols(); }\n    \n    /** \\returns a const reference to the vector of Householder coefficients used to represent the factor \\c Q.\n      * \n      * For advanced uses only.\n      */\n    const HCoeffsType& hCoeffs() const { return m_hCoeffs; }\n    \n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename RhsType, typename DstType>\n    EIGEN_DEVICE_FUNC\n    void _solve_impl(const RhsType &rhs, DstType &dst) const;\n    #endif\n\n  protected:\n    \n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n    }\n\n    void computeInPlace();\n    \n    MatrixType m_qr;\n    HCoeffsType m_hCoeffs;\n    RowVectorType m_temp;\n    bool m_isInitialized;\n};\n\ntemplate<typename MatrixType>\ntypename MatrixType::RealScalar HouseholderQR<MatrixType>::absDeterminant() const\n{\n  using std::abs;\n  eigen_assert(m_isInitialized && \"HouseholderQR is not initialized.\");\n  eigen_assert(m_qr.rows() == m_qr.cols() && \"You can't take the determinant of a non-square matrix!\");\n  return abs(m_qr.diagonal().prod());\n}\n\ntemplate<typename MatrixType>\ntypename MatrixType::RealScalar HouseholderQR<MatrixType>::logAbsDeterminant() const\n{\n  eigen_assert(m_isInitialized && \"HouseholderQR is not initialized.\");\n  eigen_assert(m_qr.rows() == m_qr.cols() && \"You can't take the determinant of a non-square matrix!\");\n  return m_qr.diagonal().cwiseAbs().array().log().sum();\n}\n\nnamespace internal {\n\n/** \\internal */\ntemplate<typename MatrixQR, typename HCoeffs>\nvoid householder_qr_inplace_unblocked(MatrixQR& mat, HCoeffs& hCoeffs, typename MatrixQR::Scalar* tempData = 0)\n{\n  typedef typename MatrixQR::Scalar Scalar;\n  typedef typename MatrixQR::RealScalar RealScalar;\n  Index rows = mat.rows();\n  Index cols = mat.cols();\n  Index size = (std::min)(rows,cols);\n\n  eigen_assert(hCoeffs.size() == size);\n\n  typedef Matrix<Scalar,MatrixQR::ColsAtCompileTime,1> TempType;\n  TempType tempVector;\n  if(tempData==0)\n  {\n    tempVector.resize(cols);\n    tempData = tempVector.data();\n  }\n\n  for(Index k = 0; k < size; ++k)\n  {\n    Index remainingRows = rows - k;\n    Index remainingCols = cols - k - 1;\n\n    RealScalar beta;\n    mat.col(k).tail(remainingRows).makeHouseholderInPlace(hCoeffs.coeffRef(k), beta);\n    mat.coeffRef(k,k) = beta;\n\n    // apply H to remaining part of m_qr from the left\n    mat.bottomRightCorner(remainingRows, remainingCols)\n        .applyHouseholderOnTheLeft(mat.col(k).tail(remainingRows-1), hCoeffs.coeffRef(k), tempData+k+1);\n  }\n}\n\n/** \\internal */\ntemplate<typename MatrixQR, typename HCoeffs,\n  typename MatrixQRScalar = typename MatrixQR::Scalar,\n  bool InnerStrideIsOne = (MatrixQR::InnerStrideAtCompileTime == 1 && HCoeffs::InnerStrideAtCompileTime == 1)>\nstruct householder_qr_inplace_blocked\n{\n  // This is specialized for MKL-supported Scalar types in HouseholderQR_MKL.h\n  static void run(MatrixQR& mat, HCoeffs& hCoeffs, Index maxBlockSize=32,\n      typename MatrixQR::Scalar* tempData = 0)\n  {\n    typedef typename MatrixQR::Scalar Scalar;\n    typedef Block<MatrixQR,Dynamic,Dynamic> BlockType;\n\n    Index rows = mat.rows();\n    Index cols = mat.cols();\n    Index size = (std::min)(rows, cols);\n\n    typedef Matrix<Scalar,Dynamic,1,ColMajor,MatrixQR::MaxColsAtCompileTime,1> TempType;\n    TempType tempVector;\n    if(tempData==0)\n    {\n      tempVector.resize(cols);\n      tempData = tempVector.data();\n    }\n\n    Index blockSize = (std::min)(maxBlockSize,size);\n\n    Index k = 0;\n    for (k = 0; k < size; k += blockSize)\n    {\n      Index bs = (std::min)(size-k,blockSize);  // actual size of the block\n      Index tcols = cols - k - bs;              // trailing columns\n      Index brows = rows-k;                     // rows of the block\n\n      // partition the matrix:\n      //        A00 | A01 | A02\n      // mat  = A10 | A11 | A12\n      //        A20 | A21 | A22\n      // and performs the qr dec of [A11^T A12^T]^T\n      // and update [A21^T A22^T]^T using level 3 operations.\n      // Finally, the algorithm continue on A22\n\n      BlockType A11_21 = mat.block(k,k,brows,bs);\n      Block<HCoeffs,Dynamic,1> hCoeffsSegment = hCoeffs.segment(k,bs);\n\n      householder_qr_inplace_unblocked(A11_21, hCoeffsSegment, tempData);\n\n      if(tcols)\n      {\n        BlockType A21_22 = mat.block(k,k+bs,brows,tcols);\n        apply_block_householder_on_the_left(A21_22,A11_21,hCoeffsSegment, false); // false == backward\n      }\n    }\n  }\n};\n\n} // end namespace internal\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename _MatrixType>\ntemplate<typename RhsType, typename DstType>\nvoid HouseholderQR<_MatrixType>::_solve_impl(const RhsType &rhs, DstType &dst) const\n{\n  const Index rank = (std::min)(rows(), cols());\n  eigen_assert(rhs.rows() == rows());\n\n  typename RhsType::PlainObject c(rhs);\n\n  // Note that the matrix Q = H_0^* H_1^*... so its inverse is Q^* = (H_0 H_1 ...)^T\n  c.applyOnTheLeft(householderSequence(\n    m_qr.leftCols(rank),\n    m_hCoeffs.head(rank)).transpose()\n  );\n\n  m_qr.topLeftCorner(rank, rank)\n      .template triangularView<Upper>()\n      .solveInPlace(c.topRows(rank));\n\n  dst.topRows(rank) = c.topRows(rank);\n  dst.bottomRows(cols()-rank).setZero();\n}\n#endif\n\n/** Performs the QR factorization of the given matrix \\a matrix. The result of\n  * the factorization is stored into \\c *this, and a reference to \\c *this\n  * is returned.\n  *\n  * \\sa class HouseholderQR, HouseholderQR(const MatrixType&)\n  */\ntemplate<typename MatrixType>\nvoid HouseholderQR<MatrixType>::computeInPlace()\n{\n  check_template_parameters();\n  \n  Index rows = m_qr.rows();\n  Index cols = m_qr.cols();\n  Index size = (std::min)(rows,cols);\n\n  m_hCoeffs.resize(size);\n\n  m_temp.resize(cols);\n\n  internal::householder_qr_inplace_blocked<MatrixType, HCoeffsType>::run(m_qr, m_hCoeffs, 48, m_temp.data());\n\n  m_isInitialized = true;\n}\n\n/** \\return the Householder QR decomposition of \\c *this.\n  *\n  * \\sa class HouseholderQR\n  */\ntemplate<typename Derived>\nconst HouseholderQR<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::householderQr() const\n{\n  return HouseholderQR<PlainObject>(eval());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_QR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/QR/HouseholderQR_LAPACKE.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to LAPACKe\n *    Householder QR decomposition of a matrix w/o pivoting based on\n *    LAPACKE_?geqrf function.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_QR_LAPACKE_H\n#define EIGEN_QR_LAPACKE_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/** \\internal Specialization for the data types supported by LAPACKe */\n\n#define EIGEN_LAPACKE_QR_NOPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX) \\\ntemplate<typename MatrixQR, typename HCoeffs> \\\nstruct householder_qr_inplace_blocked<MatrixQR, HCoeffs, EIGTYPE, true> \\\n{ \\\n  static void run(MatrixQR& mat, HCoeffs& hCoeffs, Index = 32, \\\n      typename MatrixQR::Scalar* = 0) \\\n  { \\\n    lapack_int m = (lapack_int) mat.rows(); \\\n    lapack_int n = (lapack_int) mat.cols(); \\\n    lapack_int lda = (lapack_int) mat.outerStride(); \\\n    lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \\\n    LAPACKE_##LAPACKE_PREFIX##geqrf( matrix_order, m, n, (LAPACKE_TYPE*)mat.data(), lda, (LAPACKE_TYPE*)hCoeffs.data()); \\\n    hCoeffs.adjointInPlace(); \\\n  } \\\n};\n\nEIGEN_LAPACKE_QR_NOPIV(double, double, d)\nEIGEN_LAPACKE_QR_NOPIV(float, float, s)\nEIGEN_LAPACKE_QR_NOPIV(dcomplex, lapack_complex_double, z)\nEIGEN_LAPACKE_QR_NOPIV(scomplex, lapack_complex_float, c)\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_QR_LAPACKE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Desire Nuentsa <desire.nuentsa_wakam@inria.fr>\n// Copyright (C) 2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SUITESPARSEQRSUPPORT_H\n#define EIGEN_SUITESPARSEQRSUPPORT_H\n\nnamespace Eigen {\n  \n  template<typename MatrixType> class SPQR; \n  template<typename SPQRType> struct SPQRMatrixQReturnType; \n  template<typename SPQRType> struct SPQRMatrixQTransposeReturnType; \n  template <typename SPQRType, typename Derived> struct SPQR_QProduct;\n  namespace internal {\n    template <typename SPQRType> struct traits<SPQRMatrixQReturnType<SPQRType> >\n    {\n      typedef typename SPQRType::MatrixType ReturnType;\n    };\n    template <typename SPQRType> struct traits<SPQRMatrixQTransposeReturnType<SPQRType> >\n    {\n      typedef typename SPQRType::MatrixType ReturnType;\n    };\n    template <typename SPQRType, typename Derived> struct traits<SPQR_QProduct<SPQRType, Derived> >\n    {\n      typedef typename Derived::PlainObject ReturnType;\n    };\n  } // End namespace internal\n  \n/**\n  * \\ingroup SPQRSupport_Module\n  * \\class SPQR\n  * \\brief Sparse QR factorization based on SuiteSparseQR library\n  *\n  * This class is used to perform a multithreaded and multifrontal rank-revealing QR decomposition\n  * of sparse matrices. The result is then used to solve linear leasts_square systems.\n  * Clearly, a QR factorization is returned such that A*P = Q*R where :\n  *\n  * P is the column permutation. Use colsPermutation() to get it.\n  *\n  * Q is the orthogonal matrix represented as Householder reflectors.\n  * Use matrixQ() to get an expression and matrixQ().transpose() to get the transpose.\n  * You can then apply it to a vector.\n  *\n  * R is the sparse triangular factor. Use matrixQR() to get it as SparseMatrix.\n  * NOTE : The Index type of R is always SuiteSparse_long. You can get it with SPQR::Index\n  *\n  * \\tparam _MatrixType The type of the sparse matrix A, must be a column-major SparseMatrix<>\n  *\n  * \\implsparsesolverconcept\n  *\n  *\n  */\ntemplate<typename _MatrixType>\nclass SPQR : public SparseSolverBase<SPQR<_MatrixType> >\n{\n  protected:\n    typedef SparseSolverBase<SPQR<_MatrixType> > Base;\n    using Base::m_isInitialized;\n  public:\n    typedef typename _MatrixType::Scalar Scalar;\n    typedef typename _MatrixType::RealScalar RealScalar;\n    typedef SuiteSparse_long StorageIndex ;\n    typedef SparseMatrix<Scalar, ColMajor, StorageIndex> MatrixType;\n    typedef Map<PermutationMatrix<Dynamic, Dynamic, StorageIndex> > PermutationType;\n    enum {\n      ColsAtCompileTime = Dynamic,\n      MaxColsAtCompileTime = Dynamic\n    };\n  public:\n    SPQR() \n      : m_ordering(SPQR_ORDERING_DEFAULT), m_allow_tol(SPQR_DEFAULT_TOL), m_tolerance (NumTraits<Scalar>::epsilon()), m_useDefaultThreshold(true)\n    { \n      cholmod_l_start(&m_cc);\n    }\n    \n    explicit SPQR(const _MatrixType& matrix)\n    : m_ordering(SPQR_ORDERING_DEFAULT), m_allow_tol(SPQR_DEFAULT_TOL), m_tolerance (NumTraits<Scalar>::epsilon()), m_useDefaultThreshold(true)\n    {\n      cholmod_l_start(&m_cc);\n      compute(matrix);\n    }\n    \n    ~SPQR()\n    {\n      SPQR_free();\n      cholmod_l_finish(&m_cc);\n    }\n    void SPQR_free()\n    {\n      cholmod_l_free_sparse(&m_H, &m_cc);\n      cholmod_l_free_sparse(&m_cR, &m_cc);\n      cholmod_l_free_dense(&m_HTau, &m_cc);\n      std::free(m_E);\n      std::free(m_HPinv);\n    }\n\n    void compute(const _MatrixType& matrix)\n    {\n      if(m_isInitialized) SPQR_free();\n\n      MatrixType mat(matrix);\n      \n      /* Compute the default threshold as in MatLab, see:\n       * Tim Davis, \"Algorithm 915, SuiteSparseQR: Multifrontal Multithreaded Rank-Revealing\n       * Sparse QR Factorization, ACM Trans. on Math. Soft. 38(1), 2011, Page 8:3 \n       */\n      RealScalar pivotThreshold = m_tolerance;\n      if(m_useDefaultThreshold) \n      {\n        RealScalar max2Norm = 0.0;\n        for (int j = 0; j < mat.cols(); j++) max2Norm = numext::maxi(max2Norm, mat.col(j).norm());\n        if(max2Norm==RealScalar(0))\n          max2Norm = RealScalar(1);\n        pivotThreshold = 20 * (mat.rows() + mat.cols()) * max2Norm * NumTraits<RealScalar>::epsilon();\n      }\n      cholmod_sparse A; \n      A = viewAsCholmod(mat);\n      m_rows = matrix.rows();\n      Index col = matrix.cols();\n      m_rank = SuiteSparseQR<Scalar>(m_ordering, pivotThreshold, col, &A, \n                             &m_cR, &m_E, &m_H, &m_HPinv, &m_HTau, &m_cc);\n\n      if (!m_cR)\n      {\n        m_info = NumericalIssue;\n        m_isInitialized = false;\n        return;\n      }\n      m_info = Success;\n      m_isInitialized = true;\n      m_isRUpToDate = false;\n    }\n    /** \n     * Get the number of rows of the input matrix and the Q matrix\n     */\n    inline Index rows() const {return m_rows; }\n    \n    /** \n     * Get the number of columns of the input matrix. \n     */\n    inline Index cols() const { return m_cR->ncol; }\n    \n    template<typename Rhs, typename Dest>\n    void _solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &dest) const\n    {\n      eigen_assert(m_isInitialized && \" The QR factorization should be computed first, call compute()\");\n      eigen_assert(b.cols()==1 && \"This method is for vectors only\");\n\n      //Compute Q^T * b\n      typename Dest::PlainObject y, y2;\n      y = matrixQ().transpose() * b;\n      \n      // Solves with the triangular matrix R\n      Index rk = this->rank();\n      y2 = y;\n      y.resize((std::max)(cols(),Index(y.rows())),y.cols());\n      y.topRows(rk) = this->matrixR().topLeftCorner(rk, rk).template triangularView<Upper>().solve(y2.topRows(rk));\n\n      // Apply the column permutation \n      // colsPermutation() performs a copy of the permutation,\n      // so let's apply it manually:\n      for(Index i = 0; i < rk; ++i) dest.row(m_E[i]) = y.row(i);\n      for(Index i = rk; i < cols(); ++i) dest.row(m_E[i]).setZero();\n      \n//       y.bottomRows(y.rows()-rk).setZero();\n//       dest = colsPermutation() * y.topRows(cols());\n      \n      m_info = Success;\n    }\n    \n    /** \\returns the sparse triangular factor R. It is a sparse matrix\n     */\n    const MatrixType matrixR() const\n    {\n      eigen_assert(m_isInitialized && \" The QR factorization should be computed first, call compute()\");\n      if(!m_isRUpToDate) {\n        m_R = viewAsEigen<Scalar,ColMajor, typename MatrixType::StorageIndex>(*m_cR);\n        m_isRUpToDate = true;\n      }\n      return m_R;\n    }\n    /// Get an expression of the matrix Q\n    SPQRMatrixQReturnType<SPQR> matrixQ() const\n    {\n      return SPQRMatrixQReturnType<SPQR>(*this);\n    }\n    /// Get the permutation that was applied to columns of A\n    PermutationType colsPermutation() const\n    { \n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return PermutationType(m_E, m_cR->ncol);\n    }\n    /**\n     * Gets the rank of the matrix. \n     * It should be equal to matrixQR().cols if the matrix is full-rank\n     */\n    Index rank() const\n    {\n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return m_cc.SPQR_istat[4];\n    }\n    /// Set the fill-reducing ordering method to be used\n    void setSPQROrdering(int ord) { m_ordering = ord;}\n    /// Set the tolerance tol to treat columns with 2-norm < =tol as zero\n    void setPivotThreshold(const RealScalar& tol)\n    {\n      m_useDefaultThreshold = false;\n      m_tolerance = tol;\n    }\n    \n    /** \\returns a pointer to the SPQR workspace */\n    cholmod_common *cholmodCommon() const { return &m_cc; }\n    \n    \n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful,\n      *          \\c NumericalIssue if the sparse QR can not be computed\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return m_info;\n    }\n  protected:\n    bool m_analysisIsOk;\n    bool m_factorizationIsOk;\n    mutable bool m_isRUpToDate;\n    mutable ComputationInfo m_info;\n    int m_ordering; // Ordering method to use, see SPQR's manual\n    int m_allow_tol; // Allow to use some tolerance during numerical factorization.\n    RealScalar m_tolerance; // treat columns with 2-norm below this tolerance as zero\n    mutable cholmod_sparse *m_cR; // The sparse R factor in cholmod format\n    mutable MatrixType m_R; // The sparse matrix R in Eigen format\n    mutable StorageIndex *m_E; // The permutation applied to columns\n    mutable cholmod_sparse *m_H;  //The householder vectors\n    mutable StorageIndex *m_HPinv; // The row permutation of H\n    mutable cholmod_dense *m_HTau; // The Householder coefficients\n    mutable Index m_rank; // The rank of the matrix\n    mutable cholmod_common m_cc; // Workspace and parameters\n    bool m_useDefaultThreshold;     // Use default threshold\n    Index m_rows;\n    template<typename ,typename > friend struct SPQR_QProduct;\n};\n\ntemplate <typename SPQRType, typename Derived>\nstruct SPQR_QProduct : ReturnByValue<SPQR_QProduct<SPQRType,Derived> >\n{\n  typedef typename SPQRType::Scalar Scalar;\n  typedef typename SPQRType::StorageIndex StorageIndex;\n  //Define the constructor to get reference to argument types\n  SPQR_QProduct(const SPQRType& spqr, const Derived& other, bool transpose) : m_spqr(spqr),m_other(other),m_transpose(transpose) {}\n  \n  inline Index rows() const { return m_transpose ? m_spqr.rows() : m_spqr.cols(); }\n  inline Index cols() const { return m_other.cols(); }\n  // Assign to a vector\n  template<typename ResType>\n  void evalTo(ResType& res) const\n  {\n    cholmod_dense y_cd;\n    cholmod_dense *x_cd; \n    int method = m_transpose ? SPQR_QTX : SPQR_QX; \n    cholmod_common *cc = m_spqr.cholmodCommon();\n    y_cd = viewAsCholmod(m_other.const_cast_derived());\n    x_cd = SuiteSparseQR_qmult<Scalar>(method, m_spqr.m_H, m_spqr.m_HTau, m_spqr.m_HPinv, &y_cd, cc);\n    res = Matrix<Scalar,ResType::RowsAtCompileTime,ResType::ColsAtCompileTime>::Map(reinterpret_cast<Scalar*>(x_cd->x), x_cd->nrow, x_cd->ncol);\n    cholmod_l_free_dense(&x_cd, cc);\n  }\n  const SPQRType& m_spqr; \n  const Derived& m_other; \n  bool m_transpose; \n  \n};\ntemplate<typename SPQRType>\nstruct SPQRMatrixQReturnType{\n  \n  SPQRMatrixQReturnType(const SPQRType& spqr) : m_spqr(spqr) {}\n  template<typename Derived>\n  SPQR_QProduct<SPQRType, Derived> operator*(const MatrixBase<Derived>& other)\n  {\n    return SPQR_QProduct<SPQRType,Derived>(m_spqr,other.derived(),false);\n  }\n  SPQRMatrixQTransposeReturnType<SPQRType> adjoint() const\n  {\n    return SPQRMatrixQTransposeReturnType<SPQRType>(m_spqr);\n  }\n  // To use for operations with the transpose of Q\n  SPQRMatrixQTransposeReturnType<SPQRType> transpose() const\n  {\n    return SPQRMatrixQTransposeReturnType<SPQRType>(m_spqr);\n  }\n  const SPQRType& m_spqr;\n};\n\ntemplate<typename SPQRType>\nstruct SPQRMatrixQTransposeReturnType{\n  SPQRMatrixQTransposeReturnType(const SPQRType& spqr) : m_spqr(spqr) {}\n  template<typename Derived>\n  SPQR_QProduct<SPQRType,Derived> operator*(const MatrixBase<Derived>& other)\n  {\n    return SPQR_QProduct<SPQRType,Derived>(m_spqr,other.derived(), true);\n  }\n  const SPQRType& m_spqr;\n};\n\n}// End namespace Eigen\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/SVD/BDCSVD.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n// \n// We used the \"A Divide-And-Conquer Algorithm for the Bidiagonal SVD\"\n// research report written by Ming Gu and Stanley C.Eisenstat\n// The code variable names correspond to the names they used in their \n// report\n//\n// Copyright (C) 2013 Gauthier Brun <brun.gauthier@gmail.com>\n// Copyright (C) 2013 Nicolas Carre <nicolas.carre@ensimag.fr>\n// Copyright (C) 2013 Jean Ceccato <jean.ceccato@ensimag.fr>\n// Copyright (C) 2013 Pierre Zoppitelli <pierre.zoppitelli@ensimag.fr>\n// Copyright (C) 2013 Jitse Niesen <jitse@maths.leeds.ac.uk>\n// Copyright (C) 2014-2016 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_BDCSVD_H\n#define EIGEN_BDCSVD_H\n// #define EIGEN_BDCSVD_DEBUG_VERBOSE\n// #define EIGEN_BDCSVD_SANITY_CHECKS\n\nnamespace Eigen {\n\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\nIOFormat bdcsvdfmt(8, 0, \", \", \"\\n\", \"  [\", \"]\");\n#endif\n  \ntemplate<typename _MatrixType> class BDCSVD;\n\nnamespace internal {\n\ntemplate<typename _MatrixType> \nstruct traits<BDCSVD<_MatrixType> >\n{\n  typedef _MatrixType MatrixType;\n};  \n\n} // end namespace internal\n  \n  \n/** \\ingroup SVD_Module\n *\n *\n * \\class BDCSVD\n *\n * \\brief class Bidiagonal Divide and Conquer SVD\n *\n * \\tparam _MatrixType the type of the matrix of which we are computing the SVD decomposition\n *\n * This class first reduces the input matrix to bi-diagonal form using class UpperBidiagonalization,\n * and then performs a divide-and-conquer diagonalization. Small blocks are diagonalized using class JacobiSVD.\n * You can control the switching size with the setSwitchSize() method, default is 16.\n * For small matrice (<16), it is thus preferable to directly use JacobiSVD. For larger ones, BDCSVD is highly\n * recommended and can several order of magnitude faster.\n *\n * \\warning this algorithm is unlikely to provide accurate result when compiled with unsafe math optimizations.\n * For instance, this concerns Intel's compiler (ICC), which perfroms such optimization by default unless\n * you compile with the \\c -fp-model \\c precise option. Likewise, the \\c -ffast-math option of GCC or clang will\n * significantly degrade the accuracy.\n *\n * \\sa class JacobiSVD\n */\ntemplate<typename _MatrixType> \nclass BDCSVD : public SVDBase<BDCSVD<_MatrixType> >\n{\n  typedef SVDBase<BDCSVD> Base;\n    \npublic:\n  using Base::rows;\n  using Base::cols;\n  using Base::computeU;\n  using Base::computeV;\n  \n  typedef _MatrixType MatrixType;\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;\n  typedef typename NumTraits<RealScalar>::Literal Literal;\n  enum {\n    RowsAtCompileTime = MatrixType::RowsAtCompileTime, \n    ColsAtCompileTime = MatrixType::ColsAtCompileTime, \n    DiagSizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime, ColsAtCompileTime), \n    MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, \n    MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, \n    MaxDiagSizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_FIXED(MaxRowsAtCompileTime, MaxColsAtCompileTime), \n    MatrixOptions = MatrixType::Options\n  };\n\n  typedef typename Base::MatrixUType MatrixUType;\n  typedef typename Base::MatrixVType MatrixVType;\n  typedef typename Base::SingularValuesType SingularValuesType;\n  \n  typedef Matrix<Scalar, Dynamic, Dynamic, ColMajor> MatrixX;\n  typedef Matrix<RealScalar, Dynamic, Dynamic, ColMajor> MatrixXr;\n  typedef Matrix<RealScalar, Dynamic, 1> VectorType;\n  typedef Array<RealScalar, Dynamic, 1> ArrayXr;\n  typedef Array<Index,1,Dynamic> ArrayXi;\n  typedef Ref<ArrayXr> ArrayRef;\n  typedef Ref<ArrayXi> IndicesRef;\n\n  /** \\brief Default Constructor.\n   *\n   * The default constructor is useful in cases in which the user intends to\n   * perform decompositions via BDCSVD::compute(const MatrixType&).\n   */\n  BDCSVD() : m_algoswap(16), m_numIters(0)\n  {}\n\n\n  /** \\brief Default Constructor with memory preallocation\n   *\n   * Like the default constructor but with preallocation of the internal data\n   * according to the specified problem size.\n   * \\sa BDCSVD()\n   */\n  BDCSVD(Index rows, Index cols, unsigned int computationOptions = 0)\n    : m_algoswap(16), m_numIters(0)\n  {\n    allocate(rows, cols, computationOptions);\n  }\n\n  /** \\brief Constructor performing the decomposition of given matrix.\n   *\n   * \\param matrix the matrix to decompose\n   * \\param computationOptions optional parameter allowing to specify if you want full or thin U or V unitaries to be computed.\n   *                           By default, none is computed. This is a bit - field, the possible bits are #ComputeFullU, #ComputeThinU, \n   *                           #ComputeFullV, #ComputeThinV.\n   *\n   * Thin unitaries are only available if your matrix type has a Dynamic number of columns (for example MatrixXf). They also are not\n   * available with the (non - default) FullPivHouseholderQR preconditioner.\n   */\n  BDCSVD(const MatrixType& matrix, unsigned int computationOptions = 0)\n    : m_algoswap(16), m_numIters(0)\n  {\n    compute(matrix, computationOptions);\n  }\n\n  ~BDCSVD() \n  {\n  }\n  \n  /** \\brief Method performing the decomposition of given matrix using custom options.\n   *\n   * \\param matrix the matrix to decompose\n   * \\param computationOptions optional parameter allowing to specify if you want full or thin U or V unitaries to be computed.\n   *                           By default, none is computed. This is a bit - field, the possible bits are #ComputeFullU, #ComputeThinU, \n   *                           #ComputeFullV, #ComputeThinV.\n   *\n   * Thin unitaries are only available if your matrix type has a Dynamic number of columns (for example MatrixXf). They also are not\n   * available with the (non - default) FullPivHouseholderQR preconditioner.\n   */\n  BDCSVD& compute(const MatrixType& matrix, unsigned int computationOptions);\n\n  /** \\brief Method performing the decomposition of given matrix using current options.\n   *\n   * \\param matrix the matrix to decompose\n   *\n   * This method uses the current \\a computationOptions, as already passed to the constructor or to compute(const MatrixType&, unsigned int).\n   */\n  BDCSVD& compute(const MatrixType& matrix)\n  {\n    return compute(matrix, this->m_computationOptions);\n  }\n\n  void setSwitchSize(int s) \n  {\n    eigen_assert(s>3 && \"BDCSVD the size of the algo switch has to be greater than 3\");\n    m_algoswap = s;\n  }\n \nprivate:\n  void allocate(Index rows, Index cols, unsigned int computationOptions);\n  void divide(Index firstCol, Index lastCol, Index firstRowW, Index firstColW, Index shift);\n  void computeSVDofM(Index firstCol, Index n, MatrixXr& U, VectorType& singVals, MatrixXr& V);\n  void computeSingVals(const ArrayRef& col0, const ArrayRef& diag, const IndicesRef& perm, VectorType& singVals, ArrayRef shifts, ArrayRef mus);\n  void perturbCol0(const ArrayRef& col0, const ArrayRef& diag, const IndicesRef& perm, const VectorType& singVals, const ArrayRef& shifts, const ArrayRef& mus, ArrayRef zhat);\n  void computeSingVecs(const ArrayRef& zhat, const ArrayRef& diag, const IndicesRef& perm, const VectorType& singVals, const ArrayRef& shifts, const ArrayRef& mus, MatrixXr& U, MatrixXr& V);\n  void deflation43(Index firstCol, Index shift, Index i, Index size);\n  void deflation44(Index firstColu , Index firstColm, Index firstRowW, Index firstColW, Index i, Index j, Index size);\n  void deflation(Index firstCol, Index lastCol, Index k, Index firstRowW, Index firstColW, Index shift);\n  template<typename HouseholderU, typename HouseholderV, typename NaiveU, typename NaiveV>\n  void copyUV(const HouseholderU &householderU, const HouseholderV &householderV, const NaiveU &naiveU, const NaiveV &naivev);\n  void structured_update(Block<MatrixXr,Dynamic,Dynamic> A, const MatrixXr &B, Index n1);\n  static RealScalar secularEq(RealScalar x, const ArrayRef& col0, const ArrayRef& diag, const IndicesRef &perm, const ArrayRef& diagShifted, RealScalar shift);\n\nprotected:\n  MatrixXr m_naiveU, m_naiveV;\n  MatrixXr m_computed;\n  Index m_nRec;\n  ArrayXr m_workspace;\n  ArrayXi m_workspaceI;\n  int m_algoswap;\n  bool m_isTranspose, m_compU, m_compV;\n  \n  using Base::m_singularValues;\n  using Base::m_diagSize;\n  using Base::m_computeFullU;\n  using Base::m_computeFullV;\n  using Base::m_computeThinU;\n  using Base::m_computeThinV;\n  using Base::m_matrixU;\n  using Base::m_matrixV;\n  using Base::m_isInitialized;\n  using Base::m_nonzeroSingularValues;\n\npublic:  \n  int m_numIters;\n}; //end class BDCSVD\n\n\n// Method to allocate and initialize matrix and attributes\ntemplate<typename MatrixType>\nvoid BDCSVD<MatrixType>::allocate(Index rows, Index cols, unsigned int computationOptions)\n{\n  m_isTranspose = (cols > rows);\n\n  if (Base::allocate(rows, cols, computationOptions))\n    return;\n  \n  m_computed = MatrixXr::Zero(m_diagSize + 1, m_diagSize );\n  m_compU = computeV();\n  m_compV = computeU();\n  if (m_isTranspose)\n    std::swap(m_compU, m_compV);\n  \n  if (m_compU) m_naiveU = MatrixXr::Zero(m_diagSize + 1, m_diagSize + 1 );\n  else         m_naiveU = MatrixXr::Zero(2, m_diagSize + 1 );\n  \n  if (m_compV) m_naiveV = MatrixXr::Zero(m_diagSize, m_diagSize);\n  \n  m_workspace.resize((m_diagSize+1)*(m_diagSize+1)*3);\n  m_workspaceI.resize(3*m_diagSize);\n}// end allocate\n\ntemplate<typename MatrixType>\nBDCSVD<MatrixType>& BDCSVD<MatrixType>::compute(const MatrixType& matrix, unsigned int computationOptions) \n{\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n  std::cout << \"\\n\\n\\n======================================================================================================================\\n\\n\\n\";\n#endif\n  allocate(matrix.rows(), matrix.cols(), computationOptions);\n  using std::abs;\n\n  const RealScalar considerZero = (std::numeric_limits<RealScalar>::min)();\n  \n  //**** step -1 - If the problem is too small, directly falls back to JacobiSVD and return\n  if(matrix.cols() < m_algoswap)\n  {\n    // FIXME this line involves temporaries\n    JacobiSVD<MatrixType> jsvd(matrix,computationOptions);\n    if(computeU()) m_matrixU = jsvd.matrixU();\n    if(computeV()) m_matrixV = jsvd.matrixV();\n    m_singularValues = jsvd.singularValues();\n    m_nonzeroSingularValues = jsvd.nonzeroSingularValues();\n    m_isInitialized = true;\n    return *this;\n  }\n  \n  //**** step 0 - Copy the input matrix and apply scaling to reduce over/under-flows\n  RealScalar scale = matrix.cwiseAbs().maxCoeff();\n  if(scale==Literal(0)) scale = Literal(1);\n  MatrixX copy;\n  if (m_isTranspose) copy = matrix.adjoint()/scale;\n  else               copy = matrix/scale;\n  \n  //**** step 1 - Bidiagonalization\n  // FIXME this line involves temporaries\n  internal::UpperBidiagonalization<MatrixX> bid(copy);\n\n  //**** step 2 - Divide & Conquer\n  m_naiveU.setZero();\n  m_naiveV.setZero();\n  // FIXME this line involves a temporary matrix\n  m_computed.topRows(m_diagSize) = bid.bidiagonal().toDenseMatrix().transpose();\n  m_computed.template bottomRows<1>().setZero();\n  divide(0, m_diagSize - 1, 0, 0, 0);\n\n  //**** step 3 - Copy singular values and vectors\n  for (int i=0; i<m_diagSize; i++)\n  {\n    RealScalar a = abs(m_computed.coeff(i, i));\n    m_singularValues.coeffRef(i) = a * scale;\n    if (a<considerZero)\n    {\n      m_nonzeroSingularValues = i;\n      m_singularValues.tail(m_diagSize - i - 1).setZero();\n      break;\n    }\n    else if (i == m_diagSize - 1)\n    {\n      m_nonzeroSingularValues = i + 1;\n      break;\n    }\n  }\n\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n//   std::cout << \"m_naiveU\\n\" << m_naiveU << \"\\n\\n\";\n//   std::cout << \"m_naiveV\\n\" << m_naiveV << \"\\n\\n\";\n#endif\n  if(m_isTranspose) copyUV(bid.householderV(), bid.householderU(), m_naiveV, m_naiveU);\n  else              copyUV(bid.householderU(), bid.householderV(), m_naiveU, m_naiveV);\n\n  m_isInitialized = true;\n  return *this;\n}// end compute\n\n\ntemplate<typename MatrixType>\ntemplate<typename HouseholderU, typename HouseholderV, typename NaiveU, typename NaiveV>\nvoid BDCSVD<MatrixType>::copyUV(const HouseholderU &householderU, const HouseholderV &householderV, const NaiveU &naiveU, const NaiveV &naiveV)\n{\n  // Note exchange of U and V: m_matrixU is set from m_naiveV and vice versa\n  if (computeU())\n  {\n    Index Ucols = m_computeThinU ? m_diagSize : householderU.cols();\n    m_matrixU = MatrixX::Identity(householderU.cols(), Ucols);\n    m_matrixU.topLeftCorner(m_diagSize, m_diagSize) = naiveV.template cast<Scalar>().topLeftCorner(m_diagSize, m_diagSize);\n    householderU.applyThisOnTheLeft(m_matrixU); // FIXME this line involves a temporary buffer\n  }\n  if (computeV())\n  {\n    Index Vcols = m_computeThinV ? m_diagSize : householderV.cols();\n    m_matrixV = MatrixX::Identity(householderV.cols(), Vcols);\n    m_matrixV.topLeftCorner(m_diagSize, m_diagSize) = naiveU.template cast<Scalar>().topLeftCorner(m_diagSize, m_diagSize);\n    householderV.applyThisOnTheLeft(m_matrixV); // FIXME this line involves a temporary buffer\n  }\n}\n\n/** \\internal\n  * Performs A = A * B exploiting the special structure of the matrix A. Splitting A as:\n  *  A = [A1]\n  *      [A2]\n  * such that A1.rows()==n1, then we assume that at least half of the columns of A1 and A2 are zeros.\n  * We can thus pack them prior to the the matrix product. However, this is only worth the effort if the matrix is large\n  * enough.\n  */\ntemplate<typename MatrixType>\nvoid BDCSVD<MatrixType>::structured_update(Block<MatrixXr,Dynamic,Dynamic> A, const MatrixXr &B, Index n1)\n{\n  Index n = A.rows();\n  if(n>100)\n  {\n    // If the matrices are large enough, let's exploit the sparse structure of A by\n    // splitting it in half (wrt n1), and packing the non-zero columns.\n    Index n2 = n - n1;\n    Map<MatrixXr> A1(m_workspace.data()      , n1, n);\n    Map<MatrixXr> A2(m_workspace.data()+ n1*n, n2, n);\n    Map<MatrixXr> B1(m_workspace.data()+  n*n, n,  n);\n    Map<MatrixXr> B2(m_workspace.data()+2*n*n, n,  n);\n    Index k1=0, k2=0;\n    for(Index j=0; j<n; ++j)\n    {\n      if( (A.col(j).head(n1).array()!=Literal(0)).any() )\n      {\n        A1.col(k1) = A.col(j).head(n1);\n        B1.row(k1) = B.row(j);\n        ++k1;\n      }\n      if( (A.col(j).tail(n2).array()!=Literal(0)).any() )\n      {\n        A2.col(k2) = A.col(j).tail(n2);\n        B2.row(k2) = B.row(j);\n        ++k2;\n      }\n    }\n  \n    A.topRows(n1).noalias()    = A1.leftCols(k1) * B1.topRows(k1);\n    A.bottomRows(n2).noalias() = A2.leftCols(k2) * B2.topRows(k2);\n  }\n  else\n  {\n    Map<MatrixXr,Aligned> tmp(m_workspace.data(),n,n);\n    tmp.noalias() = A*B;\n    A = tmp;\n  }\n}\n\n// The divide algorithm is done \"in place\", we are always working on subsets of the same matrix. The divide methods takes as argument the \n// place of the submatrix we are currently working on.\n\n//@param firstCol : The Index of the first column of the submatrix of m_computed and for m_naiveU;\n//@param lastCol : The Index of the last column of the submatrix of m_computed and for m_naiveU; \n// lastCol + 1 - firstCol is the size of the submatrix.\n//@param firstRowW : The Index of the first row of the matrix W that we are to change. (see the reference paper section 1 for more information on W)\n//@param firstRowW : Same as firstRowW with the column.\n//@param shift : Each time one takes the left submatrix, one must add 1 to the shift. Why? Because! We actually want the last column of the U submatrix \n// to become the first column (*coeff) and to shift all the other columns to the right. There are more details on the reference paper.\ntemplate<typename MatrixType>\nvoid BDCSVD<MatrixType>::divide (Index firstCol, Index lastCol, Index firstRowW, Index firstColW, Index shift)\n{\n  // requires rows = cols + 1;\n  using std::pow;\n  using std::sqrt;\n  using std::abs;\n  const Index n = lastCol - firstCol + 1;\n  const Index k = n/2;\n  const RealScalar considerZero = (std::numeric_limits<RealScalar>::min)();\n  RealScalar alphaK;\n  RealScalar betaK; \n  RealScalar r0; \n  RealScalar lambda, phi, c0, s0;\n  VectorType l, f;\n  // We use the other algorithm which is more efficient for small \n  // matrices.\n  if (n < m_algoswap)\n  {\n    // FIXME this line involves temporaries\n    JacobiSVD<MatrixXr> b(m_computed.block(firstCol, firstCol, n + 1, n), ComputeFullU | (m_compV ? ComputeFullV : 0));\n    if (m_compU)\n      m_naiveU.block(firstCol, firstCol, n + 1, n + 1).real() = b.matrixU();\n    else \n    {\n      m_naiveU.row(0).segment(firstCol, n + 1).real() = b.matrixU().row(0);\n      m_naiveU.row(1).segment(firstCol, n + 1).real() = b.matrixU().row(n);\n    }\n    if (m_compV) m_naiveV.block(firstRowW, firstColW, n, n).real() = b.matrixV();\n    m_computed.block(firstCol + shift, firstCol + shift, n + 1, n).setZero();\n    m_computed.diagonal().segment(firstCol + shift, n) = b.singularValues().head(n);\n    return;\n  }\n  // We use the divide and conquer algorithm\n  alphaK =  m_computed(firstCol + k, firstCol + k);\n  betaK = m_computed(firstCol + k + 1, firstCol + k);\n  // The divide must be done in that order in order to have good results. Divide change the data inside the submatrices\n  // and the divide of the right submatrice reads one column of the left submatrice. That's why we need to treat the \n  // right submatrix before the left one. \n  divide(k + 1 + firstCol, lastCol, k + 1 + firstRowW, k + 1 + firstColW, shift);\n  divide(firstCol, k - 1 + firstCol, firstRowW, firstColW + 1, shift + 1);\n\n  if (m_compU)\n  {\n    lambda = m_naiveU(firstCol + k, firstCol + k);\n    phi = m_naiveU(firstCol + k + 1, lastCol + 1);\n  } \n  else \n  {\n    lambda = m_naiveU(1, firstCol + k);\n    phi = m_naiveU(0, lastCol + 1);\n  }\n  r0 = sqrt((abs(alphaK * lambda) * abs(alphaK * lambda)) + abs(betaK * phi) * abs(betaK * phi));\n  if (m_compU)\n  {\n    l = m_naiveU.row(firstCol + k).segment(firstCol, k);\n    f = m_naiveU.row(firstCol + k + 1).segment(firstCol + k + 1, n - k - 1);\n  } \n  else \n  {\n    l = m_naiveU.row(1).segment(firstCol, k);\n    f = m_naiveU.row(0).segment(firstCol + k + 1, n - k - 1);\n  }\n  if (m_compV) m_naiveV(firstRowW+k, firstColW) = Literal(1);\n  if (r0<considerZero)\n  {\n    c0 = Literal(1);\n    s0 = Literal(0);\n  }\n  else\n  {\n    c0 = alphaK * lambda / r0;\n    s0 = betaK * phi / r0;\n  }\n  \n#ifdef EIGEN_BDCSVD_SANITY_CHECKS\n  assert(m_naiveU.allFinite());\n  assert(m_naiveV.allFinite());\n  assert(m_computed.allFinite());\n#endif\n  \n  if (m_compU)\n  {\n    MatrixXr q1 (m_naiveU.col(firstCol + k).segment(firstCol, k + 1));     \n    // we shiftW Q1 to the right\n    for (Index i = firstCol + k - 1; i >= firstCol; i--) \n      m_naiveU.col(i + 1).segment(firstCol, k + 1) = m_naiveU.col(i).segment(firstCol, k + 1);\n    // we shift q1 at the left with a factor c0\n    m_naiveU.col(firstCol).segment( firstCol, k + 1) = (q1 * c0);\n    // last column = q1 * - s0\n    m_naiveU.col(lastCol + 1).segment(firstCol, k + 1) = (q1 * ( - s0));\n    // first column = q2 * s0\n    m_naiveU.col(firstCol).segment(firstCol + k + 1, n - k) = m_naiveU.col(lastCol + 1).segment(firstCol + k + 1, n - k) * s0; \n    // q2 *= c0\n    m_naiveU.col(lastCol + 1).segment(firstCol + k + 1, n - k) *= c0;\n  } \n  else \n  {\n    RealScalar q1 = m_naiveU(0, firstCol + k);\n    // we shift Q1 to the right\n    for (Index i = firstCol + k - 1; i >= firstCol; i--) \n      m_naiveU(0, i + 1) = m_naiveU(0, i);\n    // we shift q1 at the left with a factor c0\n    m_naiveU(0, firstCol) = (q1 * c0);\n    // last column = q1 * - s0\n    m_naiveU(0, lastCol + 1) = (q1 * ( - s0));\n    // first column = q2 * s0\n    m_naiveU(1, firstCol) = m_naiveU(1, lastCol + 1) *s0; \n    // q2 *= c0\n    m_naiveU(1, lastCol + 1) *= c0;\n    m_naiveU.row(1).segment(firstCol + 1, k).setZero();\n    m_naiveU.row(0).segment(firstCol + k + 1, n - k - 1).setZero();\n  }\n  \n#ifdef EIGEN_BDCSVD_SANITY_CHECKS\n  assert(m_naiveU.allFinite());\n  assert(m_naiveV.allFinite());\n  assert(m_computed.allFinite());\n#endif\n  \n  m_computed(firstCol + shift, firstCol + shift) = r0;\n  m_computed.col(firstCol + shift).segment(firstCol + shift + 1, k) = alphaK * l.transpose().real();\n  m_computed.col(firstCol + shift).segment(firstCol + shift + k + 1, n - k - 1) = betaK * f.transpose().real();\n\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n  ArrayXr tmp1 = (m_computed.block(firstCol+shift, firstCol+shift, n, n)).jacobiSvd().singularValues();\n#endif\n  // Second part: try to deflate singular values in combined matrix\n  deflation(firstCol, lastCol, k, firstRowW, firstColW, shift);\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n  ArrayXr tmp2 = (m_computed.block(firstCol+shift, firstCol+shift, n, n)).jacobiSvd().singularValues();\n  std::cout << \"\\n\\nj1 = \" << tmp1.transpose().format(bdcsvdfmt) << \"\\n\";\n  std::cout << \"j2 = \" << tmp2.transpose().format(bdcsvdfmt) << \"\\n\\n\";\n  std::cout << \"err:      \" << ((tmp1-tmp2).abs()>1e-12*tmp2.abs()).transpose() << \"\\n\";\n  static int count = 0;\n  std::cout << \"# \" << ++count << \"\\n\\n\";\n  assert((tmp1-tmp2).matrix().norm() < 1e-14*tmp2.matrix().norm());\n//   assert(count<681);\n//   assert(((tmp1-tmp2).abs()<1e-13*tmp2.abs()).all());\n#endif\n  \n  // Third part: compute SVD of combined matrix\n  MatrixXr UofSVD, VofSVD;\n  VectorType singVals;\n  computeSVDofM(firstCol + shift, n, UofSVD, singVals, VofSVD);\n  \n#ifdef EIGEN_BDCSVD_SANITY_CHECKS\n  assert(UofSVD.allFinite());\n  assert(VofSVD.allFinite());\n#endif\n  \n  if (m_compU)\n    structured_update(m_naiveU.block(firstCol, firstCol, n + 1, n + 1), UofSVD, (n+2)/2);\n  else\n  {\n    Map<Matrix<RealScalar,2,Dynamic>,Aligned> tmp(m_workspace.data(),2,n+1);\n    tmp.noalias() = m_naiveU.middleCols(firstCol, n+1) * UofSVD;\n    m_naiveU.middleCols(firstCol, n + 1) = tmp;\n  }\n  \n  if (m_compV)  structured_update(m_naiveV.block(firstRowW, firstColW, n, n), VofSVD, (n+1)/2);\n  \n#ifdef EIGEN_BDCSVD_SANITY_CHECKS\n  assert(m_naiveU.allFinite());\n  assert(m_naiveV.allFinite());\n  assert(m_computed.allFinite());\n#endif\n  \n  m_computed.block(firstCol + shift, firstCol + shift, n, n).setZero();\n  m_computed.block(firstCol + shift, firstCol + shift, n, n).diagonal() = singVals;\n}// end divide\n\n// Compute SVD of m_computed.block(firstCol, firstCol, n + 1, n); this block only has non-zeros in\n// the first column and on the diagonal and has undergone deflation, so diagonal is in increasing\n// order except for possibly the (0,0) entry. The computed SVD is stored U, singVals and V, except\n// that if m_compV is false, then V is not computed. Singular values are sorted in decreasing order.\n//\n// TODO Opportunities for optimization: better root finding algo, better stopping criterion, better\n// handling of round-off errors, be consistent in ordering\n// For instance, to solve the secular equation using FMM, see http://www.stat.uchicago.edu/~lekheng/courses/302/classics/greengard-rokhlin.pdf\ntemplate <typename MatrixType>\nvoid BDCSVD<MatrixType>::computeSVDofM(Index firstCol, Index n, MatrixXr& U, VectorType& singVals, MatrixXr& V)\n{\n  const RealScalar considerZero = (std::numeric_limits<RealScalar>::min)();\n  using std::abs;\n  ArrayRef col0 = m_computed.col(firstCol).segment(firstCol, n);\n  m_workspace.head(n) =  m_computed.block(firstCol, firstCol, n, n).diagonal();\n  ArrayRef diag = m_workspace.head(n);\n  diag(0) = Literal(0);\n\n  // Allocate space for singular values and vectors\n  singVals.resize(n);\n  U.resize(n+1, n+1);\n  if (m_compV) V.resize(n, n);\n\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n  if (col0.hasNaN() || diag.hasNaN())\n    std::cout << \"\\n\\nHAS NAN\\n\\n\";\n#endif\n  \n  // Many singular values might have been deflated, the zero ones have been moved to the end,\n  // but others are interleaved and we must ignore them at this stage.\n  // To this end, let's compute a permutation skipping them:\n  Index actual_n = n;\n  while(actual_n>1 && diag(actual_n-1)==Literal(0)) --actual_n;\n  Index m = 0; // size of the deflated problem\n  for(Index k=0;k<actual_n;++k)\n    if(abs(col0(k))>considerZero)\n      m_workspaceI(m++) = k;\n  Map<ArrayXi> perm(m_workspaceI.data(),m);\n  \n  Map<ArrayXr> shifts(m_workspace.data()+1*n, n);\n  Map<ArrayXr> mus(m_workspace.data()+2*n, n);\n  Map<ArrayXr> zhat(m_workspace.data()+3*n, n);\n\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n  std::cout << \"computeSVDofM using:\\n\";\n  std::cout << \"  z: \" << col0.transpose() << \"\\n\";\n  std::cout << \"  d: \" << diag.transpose() << \"\\n\";\n#endif\n  \n  // Compute singVals, shifts, and mus\n  computeSingVals(col0, diag, perm, singVals, shifts, mus);\n  \n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n  std::cout << \"  j:        \" << (m_computed.block(firstCol, firstCol, n, n)).jacobiSvd().singularValues().transpose().reverse() << \"\\n\\n\";\n  std::cout << \"  sing-val: \" << singVals.transpose() << \"\\n\";\n  std::cout << \"  mu:       \" << mus.transpose() << \"\\n\";\n  std::cout << \"  shift:    \" << shifts.transpose() << \"\\n\";\n  \n  {\n    Index actual_n = n;\n    while(actual_n>1 && abs(col0(actual_n-1))<considerZero) --actual_n;\n    std::cout << \"\\n\\n    mus:    \" << mus.head(actual_n).transpose() << \"\\n\\n\";\n    std::cout << \"    check1 (expect0) : \" << ((singVals.array()-(shifts+mus)) / singVals.array()).head(actual_n).transpose() << \"\\n\\n\";\n    std::cout << \"    check2 (>0)      : \" << ((singVals.array()-diag) / singVals.array()).head(actual_n).transpose() << \"\\n\\n\";\n    std::cout << \"    check3 (>0)      : \" << ((diag.segment(1,actual_n-1)-singVals.head(actual_n-1).array()) / singVals.head(actual_n-1).array()).transpose() << \"\\n\\n\\n\";\n    std::cout << \"    check4 (>0)      : \" << ((singVals.segment(1,actual_n-1)-singVals.head(actual_n-1))).transpose() << \"\\n\\n\\n\";\n  }\n#endif\n  \n#ifdef EIGEN_BDCSVD_SANITY_CHECKS\n  assert(singVals.allFinite());\n  assert(mus.allFinite());\n  assert(shifts.allFinite());\n#endif\n  \n  // Compute zhat\n  perturbCol0(col0, diag, perm, singVals, shifts, mus, zhat);\n#ifdef  EIGEN_BDCSVD_DEBUG_VERBOSE\n  std::cout << \"  zhat: \" << zhat.transpose() << \"\\n\";\n#endif\n  \n#ifdef EIGEN_BDCSVD_SANITY_CHECKS\n  assert(zhat.allFinite());\n#endif\n  \n  computeSingVecs(zhat, diag, perm, singVals, shifts, mus, U, V);\n  \n#ifdef  EIGEN_BDCSVD_DEBUG_VERBOSE\n  std::cout << \"U^T U: \" << (U.transpose() * U - MatrixXr(MatrixXr::Identity(U.cols(),U.cols()))).norm() << \"\\n\";\n  std::cout << \"V^T V: \" << (V.transpose() * V - MatrixXr(MatrixXr::Identity(V.cols(),V.cols()))).norm() << \"\\n\";\n#endif\n  \n#ifdef EIGEN_BDCSVD_SANITY_CHECKS\n  assert(U.allFinite());\n  assert(V.allFinite());\n  assert((U.transpose() * U - MatrixXr(MatrixXr::Identity(U.cols(),U.cols()))).norm() < 1e-14 * n);\n  assert((V.transpose() * V - MatrixXr(MatrixXr::Identity(V.cols(),V.cols()))).norm() < 1e-14 * n);\n  assert(m_naiveU.allFinite());\n  assert(m_naiveV.allFinite());\n  assert(m_computed.allFinite());\n#endif\n  \n  // Because of deflation, the singular values might not be completely sorted.\n  // Fortunately, reordering them is a O(n) problem\n  for(Index i=0; i<actual_n-1; ++i)\n  {\n    if(singVals(i)>singVals(i+1))\n    {\n      using std::swap;\n      swap(singVals(i),singVals(i+1));\n      U.col(i).swap(U.col(i+1));\n      if(m_compV) V.col(i).swap(V.col(i+1));\n    }\n  }\n  \n  // Reverse order so that singular values in increased order\n  // Because of deflation, the zeros singular-values are already at the end\n  singVals.head(actual_n).reverseInPlace();\n  U.leftCols(actual_n).rowwise().reverseInPlace();\n  if (m_compV) V.leftCols(actual_n).rowwise().reverseInPlace();\n  \n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n  JacobiSVD<MatrixXr> jsvd(m_computed.block(firstCol, firstCol, n, n) );\n  std::cout << \"  * j:        \" << jsvd.singularValues().transpose() << \"\\n\\n\";\n  std::cout << \"  * sing-val: \" << singVals.transpose() << \"\\n\";\n//   std::cout << \"  * err:      \" << ((jsvd.singularValues()-singVals)>1e-13*singVals.norm()).transpose() << \"\\n\";\n#endif\n}\n\ntemplate <typename MatrixType>\ntypename BDCSVD<MatrixType>::RealScalar BDCSVD<MatrixType>::secularEq(RealScalar mu, const ArrayRef& col0, const ArrayRef& diag, const IndicesRef &perm, const ArrayRef& diagShifted, RealScalar shift)\n{\n  Index m = perm.size();\n  RealScalar res = Literal(1);\n  for(Index i=0; i<m; ++i)\n  {\n    Index j = perm(i);\n    res += numext::abs2(col0(j)) / ((diagShifted(j) - mu) * (diag(j) + shift + mu));\n  }\n  return res;\n\n}\n\ntemplate <typename MatrixType>\nvoid BDCSVD<MatrixType>::computeSingVals(const ArrayRef& col0, const ArrayRef& diag, const IndicesRef &perm,\n                                         VectorType& singVals, ArrayRef shifts, ArrayRef mus)\n{\n  using std::abs;\n  using std::swap;\n\n  Index n = col0.size();\n  Index actual_n = n;\n  while(actual_n>1 && col0(actual_n-1)==Literal(0)) --actual_n;\n\n  for (Index k = 0; k < n; ++k)\n  {\n    if (col0(k) == Literal(0) || actual_n==1)\n    {\n      // if col0(k) == 0, then entry is deflated, so singular value is on diagonal\n      // if actual_n==1, then the deflated problem is already diagonalized\n      singVals(k) = k==0 ? col0(0) : diag(k);\n      mus(k) = Literal(0);\n      shifts(k) = k==0 ? col0(0) : diag(k);\n      continue;\n    } \n\n    // otherwise, use secular equation to find singular value\n    RealScalar left = diag(k);\n    RealScalar right; // was: = (k != actual_n-1) ? diag(k+1) : (diag(actual_n-1) + col0.matrix().norm());\n    if(k==actual_n-1)\n      right = (diag(actual_n-1) + col0.matrix().norm());\n    else\n    {\n      // Skip deflated singular values\n      Index l = k+1;\n      while(col0(l)==Literal(0)) { ++l; eigen_internal_assert(l<actual_n); }\n      right = diag(l);\n    }\n\n    // first decide whether it's closer to the left end or the right end\n    RealScalar mid = left + (right-left) / Literal(2);\n    RealScalar fMid = secularEq(mid, col0, diag, perm, diag, Literal(0));\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n    std::cout << right-left << \"\\n\";\n    std::cout << \"fMid = \" << fMid << \" \" << secularEq(mid-left, col0, diag, perm, diag-left, left) << \" \" << secularEq(mid-right, col0, diag, perm, diag-right, right)   << \"\\n\";\n    std::cout << \"     = \" << secularEq(0.1*(left+right), col0, diag, perm, diag, 0)\n              << \" \"       << secularEq(0.2*(left+right), col0, diag, perm, diag, 0)\n              << \" \"       << secularEq(0.3*(left+right), col0, diag, perm, diag, 0)\n              << \" \"       << secularEq(0.4*(left+right), col0, diag, perm, diag, 0)\n              << \" \"       << secularEq(0.49*(left+right), col0, diag, perm, diag, 0)\n              << \" \"       << secularEq(0.5*(left+right), col0, diag, perm, diag, 0)\n              << \" \"       << secularEq(0.51*(left+right), col0, diag, perm, diag, 0)\n              << \" \"       << secularEq(0.6*(left+right), col0, diag, perm, diag, 0)\n              << \" \"       << secularEq(0.7*(left+right), col0, diag, perm, diag, 0)\n              << \" \"       << secularEq(0.8*(left+right), col0, diag, perm, diag, 0)\n              << \" \"       << secularEq(0.9*(left+right), col0, diag, perm, diag, 0) << \"\\n\";\n#endif\n    RealScalar shift = (k == actual_n-1 || fMid > Literal(0)) ? left : right;\n    \n    // measure everything relative to shift\n    Map<ArrayXr> diagShifted(m_workspace.data()+4*n, n);\n    diagShifted = diag - shift;\n    \n    // initial guess\n    RealScalar muPrev, muCur;\n    if (shift == left)\n    {\n      muPrev = (right - left) * RealScalar(0.1);\n      if (k == actual_n-1) muCur = right - left;\n      else                 muCur = (right - left) * RealScalar(0.5);\n    }\n    else\n    {\n      muPrev = -(right - left) * RealScalar(0.1);\n      muCur = -(right - left) * RealScalar(0.5);\n    }\n\n    RealScalar fPrev = secularEq(muPrev, col0, diag, perm, diagShifted, shift);\n    RealScalar fCur = secularEq(muCur, col0, diag, perm, diagShifted, shift);\n    if (abs(fPrev) < abs(fCur))\n    {\n      swap(fPrev, fCur);\n      swap(muPrev, muCur);\n    }\n\n    // rational interpolation: fit a function of the form a / mu + b through the two previous\n    // iterates and use its zero to compute the next iterate\n    bool useBisection = fPrev*fCur>Literal(0);\n    while (fCur!=Literal(0) && abs(muCur - muPrev) > Literal(8) * NumTraits<RealScalar>::epsilon() * numext::maxi<RealScalar>(abs(muCur), abs(muPrev)) && abs(fCur - fPrev)>NumTraits<RealScalar>::epsilon() && !useBisection)\n    {\n      ++m_numIters;\n\n      // Find a and b such that the function f(mu) = a / mu + b matches the current and previous samples.\n      RealScalar a = (fCur - fPrev) / (Literal(1)/muCur - Literal(1)/muPrev);\n      RealScalar b = fCur - a / muCur;\n      // And find mu such that f(mu)==0:\n      RealScalar muZero = -a/b;\n      RealScalar fZero = secularEq(muZero, col0, diag, perm, diagShifted, shift);\n      \n      muPrev = muCur;\n      fPrev = fCur;\n      muCur = muZero;\n      fCur = fZero;\n      \n      \n      if (shift == left  && (muCur < Literal(0) || muCur > right - left)) useBisection = true;\n      if (shift == right && (muCur < -(right - left) || muCur > Literal(0))) useBisection = true;\n      if (abs(fCur)>abs(fPrev)) useBisection = true;\n    }\n\n    // fall back on bisection method if rational interpolation did not work\n    if (useBisection)\n    {\n#ifdef  EIGEN_BDCSVD_DEBUG_VERBOSE\n      std::cout << \"useBisection for k = \" << k << \", actual_n = \" << actual_n << \"\\n\";\n#endif\n      RealScalar leftShifted, rightShifted;\n      if (shift == left)\n      {\n        leftShifted = (std::numeric_limits<RealScalar>::min)();\n        // I don't understand why the case k==0 would be special there:\n        // if (k == 0) rightShifted = right - left; else \n        rightShifted = (k==actual_n-1) ? right : ((right - left) * RealScalar(0.6)); // theoretically we can take 0.5, but let's be safe\n      }\n      else\n      {\n        leftShifted = -(right - left) * RealScalar(0.6);\n        rightShifted = -(std::numeric_limits<RealScalar>::min)();\n      }\n      \n      RealScalar fLeft = secularEq(leftShifted, col0, diag, perm, diagShifted, shift);\n\n#if defined EIGEN_INTERNAL_DEBUGGING || defined EIGEN_BDCSVD_DEBUG_VERBOSE\n      RealScalar fRight = secularEq(rightShifted, col0, diag, perm, diagShifted, shift);\n#endif\n\n#ifdef  EIGEN_BDCSVD_DEBUG_VERBOSE\n      if(!(fLeft * fRight<0))\n      {\n        std::cout << \"fLeft: \" << leftShifted << \" - \" << diagShifted.head(10).transpose()  << \"\\n ; \" << bool(left==shift) << \" \" << (left-shift) << \"\\n\";\n        std::cout << k << \" : \" <<  fLeft << \" * \" << fRight << \" == \" << fLeft * fRight << \"  ;  \" << left << \" - \" << right << \" -> \" <<  leftShifted << \" \" << rightShifted << \"   shift=\" << shift << \"\\n\";\n      }\n#endif\n      eigen_internal_assert(fLeft * fRight < Literal(0));\n      \n      while (rightShifted - leftShifted > Literal(2) * NumTraits<RealScalar>::epsilon() * numext::maxi<RealScalar>(abs(leftShifted), abs(rightShifted)))\n      {\n        RealScalar midShifted = (leftShifted + rightShifted) / Literal(2);\n        fMid = secularEq(midShifted, col0, diag, perm, diagShifted, shift);\n        if (fLeft * fMid < Literal(0))\n        {\n          rightShifted = midShifted;\n        }\n        else\n        {\n          leftShifted = midShifted;\n          fLeft = fMid;\n        }\n      }\n\n      muCur = (leftShifted + rightShifted) / Literal(2);\n    }\n      \n    singVals[k] = shift + muCur;\n    shifts[k] = shift;\n    mus[k] = muCur;\n\n    // perturb singular value slightly if it equals diagonal entry to avoid division by zero later\n    // (deflation is supposed to avoid this from happening)\n    // - this does no seem to be necessary anymore -\n//     if (singVals[k] == left) singVals[k] *= 1 + NumTraits<RealScalar>::epsilon();\n//     if (singVals[k] == right) singVals[k] *= 1 - NumTraits<RealScalar>::epsilon();\n  }\n}\n\n\n// zhat is perturbation of col0 for which singular vectors can be computed stably (see Section 3.1)\ntemplate <typename MatrixType>\nvoid BDCSVD<MatrixType>::perturbCol0\n   (const ArrayRef& col0, const ArrayRef& diag, const IndicesRef &perm, const VectorType& singVals,\n    const ArrayRef& shifts, const ArrayRef& mus, ArrayRef zhat)\n{\n  using std::sqrt;\n  Index n = col0.size();\n  Index m = perm.size();\n  if(m==0)\n  {\n    zhat.setZero();\n    return;\n  }\n  Index last = perm(m-1);\n  // The offset permits to skip deflated entries while computing zhat\n  for (Index k = 0; k < n; ++k)\n  {\n    if (col0(k) == Literal(0)) // deflated\n      zhat(k) = Literal(0);\n    else\n    {\n      // see equation (3.6)\n      RealScalar dk = diag(k);\n      RealScalar prod = (singVals(last) + dk) * (mus(last) + (shifts(last) - dk));\n\n      for(Index l = 0; l<m; ++l)\n      {\n        Index i = perm(l);\n        if(i!=k)\n        {\n          Index j = i<k ? i : perm(l-1);\n          prod *= ((singVals(j)+dk) / ((diag(i)+dk))) * ((mus(j)+(shifts(j)-dk)) / ((diag(i)-dk)));\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n          if(i!=k && std::abs(((singVals(j)+dk)*(mus(j)+(shifts(j)-dk)))/((diag(i)+dk)*(diag(i)-dk)) - 1) > 0.9 )\n            std::cout << \"     \" << ((singVals(j)+dk)*(mus(j)+(shifts(j)-dk)))/((diag(i)+dk)*(diag(i)-dk)) << \" == (\" << (singVals(j)+dk) << \" * \" << (mus(j)+(shifts(j)-dk))\n                       << \") / (\" << (diag(i)+dk) << \" * \" << (diag(i)-dk) << \")\\n\";\n#endif\n        }\n      }\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n      std::cout << \"zhat(\" << k << \") =  sqrt( \" << prod << \")  ;  \" << (singVals(last) + dk) << \" * \" << mus(last) + shifts(last) << \" - \" << dk << \"\\n\";\n#endif\n      RealScalar tmp = sqrt(prod);\n      zhat(k) = col0(k) > Literal(0) ? tmp : -tmp;\n    }\n  }\n}\n\n// compute singular vectors\ntemplate <typename MatrixType>\nvoid BDCSVD<MatrixType>::computeSingVecs\n   (const ArrayRef& zhat, const ArrayRef& diag, const IndicesRef &perm, const VectorType& singVals,\n    const ArrayRef& shifts, const ArrayRef& mus, MatrixXr& U, MatrixXr& V)\n{\n  Index n = zhat.size();\n  Index m = perm.size();\n  \n  for (Index k = 0; k < n; ++k)\n  {\n    if (zhat(k) == Literal(0))\n    {\n      U.col(k) = VectorType::Unit(n+1, k);\n      if (m_compV) V.col(k) = VectorType::Unit(n, k);\n    }\n    else\n    {\n      U.col(k).setZero();\n      for(Index l=0;l<m;++l)\n      {\n        Index i = perm(l);\n        U(i,k) = zhat(i)/(((diag(i) - shifts(k)) - mus(k)) )/( (diag(i) + singVals[k]));\n      }\n      U(n,k) = Literal(0);\n      U.col(k).normalize();\n    \n      if (m_compV)\n      {\n        V.col(k).setZero();\n        for(Index l=1;l<m;++l)\n        {\n          Index i = perm(l);\n          V(i,k) = diag(i) * zhat(i) / (((diag(i) - shifts(k)) - mus(k)) )/( (diag(i) + singVals[k]));\n        }\n        V(0,k) = Literal(-1);\n        V.col(k).normalize();\n      }\n    }\n  }\n  U.col(n) = VectorType::Unit(n+1, n);\n}\n\n\n// page 12_13\n// i >= 1, di almost null and zi non null.\n// We use a rotation to zero out zi applied to the left of M\ntemplate <typename MatrixType>\nvoid BDCSVD<MatrixType>::deflation43(Index firstCol, Index shift, Index i, Index size)\n{\n  using std::abs;\n  using std::sqrt;\n  using std::pow;\n  Index start = firstCol + shift;\n  RealScalar c = m_computed(start, start);\n  RealScalar s = m_computed(start+i, start);\n  RealScalar r = sqrt(numext::abs2(c) + numext::abs2(s));\n  if (r == Literal(0))\n  {\n    m_computed(start+i, start+i) = Literal(0);\n    return;\n  }\n  m_computed(start,start) = r;  \n  m_computed(start+i, start) = Literal(0);\n  m_computed(start+i, start+i) = Literal(0);\n  \n  JacobiRotation<RealScalar> J(c/r,-s/r);\n  if (m_compU)  m_naiveU.middleRows(firstCol, size+1).applyOnTheRight(firstCol, firstCol+i, J);\n  else          m_naiveU.applyOnTheRight(firstCol, firstCol+i, J);\n}// end deflation 43\n\n\n// page 13\n// i,j >= 1, i!=j and |di - dj| < epsilon * norm2(M)\n// We apply two rotations to have zj = 0;\n// TODO deflation44 is still broken and not properly tested\ntemplate <typename MatrixType>\nvoid BDCSVD<MatrixType>::deflation44(Index firstColu , Index firstColm, Index firstRowW, Index firstColW, Index i, Index j, Index size)\n{\n  using std::abs;\n  using std::sqrt;\n  using std::conj;\n  using std::pow;\n  RealScalar c = m_computed(firstColm+i, firstColm);\n  RealScalar s = m_computed(firstColm+j, firstColm);\n  RealScalar r = sqrt(numext::abs2(c) + numext::abs2(s));\n#ifdef  EIGEN_BDCSVD_DEBUG_VERBOSE\n  std::cout << \"deflation 4.4: \" << i << \",\" << j << \" -> \" << c << \" \" << s << \" \" << r << \" ; \"\n    << m_computed(firstColm + i-1, firstColm)  << \" \"\n    << m_computed(firstColm + i, firstColm)  << \" \"\n    << m_computed(firstColm + i+1, firstColm) << \" \"\n    << m_computed(firstColm + i+2, firstColm) << \"\\n\";\n  std::cout << m_computed(firstColm + i-1, firstColm + i-1)  << \" \"\n    << m_computed(firstColm + i, firstColm+i)  << \" \"\n    << m_computed(firstColm + i+1, firstColm+i+1) << \" \"\n    << m_computed(firstColm + i+2, firstColm+i+2) << \"\\n\";\n#endif\n  if (r==Literal(0))\n  {\n    m_computed(firstColm + i, firstColm + i) = m_computed(firstColm + j, firstColm + j);\n    return;\n  }\n  c/=r;\n  s/=r;\n  m_computed(firstColm + i, firstColm) = r;  \n  m_computed(firstColm + j, firstColm + j) = m_computed(firstColm + i, firstColm + i);\n  m_computed(firstColm + j, firstColm) = Literal(0);\n\n  JacobiRotation<RealScalar> J(c,-s);\n  if (m_compU)  m_naiveU.middleRows(firstColu, size+1).applyOnTheRight(firstColu + i, firstColu + j, J);\n  else          m_naiveU.applyOnTheRight(firstColu+i, firstColu+j, J);\n  if (m_compV)  m_naiveV.middleRows(firstRowW, size).applyOnTheRight(firstColW + i, firstColW + j, J);\n}// end deflation 44\n\n\n// acts on block from (firstCol+shift, firstCol+shift) to (lastCol+shift, lastCol+shift) [inclusive]\ntemplate <typename MatrixType>\nvoid BDCSVD<MatrixType>::deflation(Index firstCol, Index lastCol, Index k, Index firstRowW, Index firstColW, Index shift)\n{\n  using std::sqrt;\n  using std::abs;\n  const Index length = lastCol + 1 - firstCol;\n  \n  Block<MatrixXr,Dynamic,1> col0(m_computed, firstCol+shift, firstCol+shift, length, 1);\n  Diagonal<MatrixXr> fulldiag(m_computed);\n  VectorBlock<Diagonal<MatrixXr>,Dynamic> diag(fulldiag, firstCol+shift, length);\n  \n  const RealScalar considerZero = (std::numeric_limits<RealScalar>::min)();\n  RealScalar maxDiag = diag.tail((std::max)(Index(1),length-1)).cwiseAbs().maxCoeff();\n  RealScalar epsilon_strict = numext::maxi<RealScalar>(considerZero,NumTraits<RealScalar>::epsilon() * maxDiag);\n  RealScalar epsilon_coarse = Literal(8) * NumTraits<RealScalar>::epsilon() * numext::maxi<RealScalar>(col0.cwiseAbs().maxCoeff(), maxDiag);\n  \n#ifdef EIGEN_BDCSVD_SANITY_CHECKS\n  assert(m_naiveU.allFinite());\n  assert(m_naiveV.allFinite());\n  assert(m_computed.allFinite());\n#endif\n\n#ifdef  EIGEN_BDCSVD_DEBUG_VERBOSE  \n  std::cout << \"\\ndeflate:\" << diag.head(k+1).transpose() << \"  |  \" << diag.segment(k+1,length-k-1).transpose() << \"\\n\";\n#endif\n  \n  //condition 4.1\n  if (diag(0) < epsilon_coarse)\n  { \n#ifdef  EIGEN_BDCSVD_DEBUG_VERBOSE\n    std::cout << \"deflation 4.1, because \" << diag(0) << \" < \" << epsilon_coarse << \"\\n\";\n#endif\n    diag(0) = epsilon_coarse;\n  }\n\n  //condition 4.2\n  for (Index i=1;i<length;++i)\n    if (abs(col0(i)) < epsilon_strict)\n    {\n#ifdef  EIGEN_BDCSVD_DEBUG_VERBOSE\n      std::cout << \"deflation 4.2, set z(\" << i << \") to zero because \" << abs(col0(i)) << \" < \" << epsilon_strict << \"  (diag(\" << i << \")=\" << diag(i) << \")\\n\";\n#endif\n      col0(i) = Literal(0);\n    }\n\n  //condition 4.3\n  for (Index i=1;i<length; i++)\n    if (diag(i) < epsilon_coarse)\n    {\n#ifdef  EIGEN_BDCSVD_DEBUG_VERBOSE\n      std::cout << \"deflation 4.3, cancel z(\" << i << \")=\" << col0(i) << \" because diag(\" << i << \")=\" << diag(i) << \" < \" << epsilon_coarse << \"\\n\";\n#endif\n      deflation43(firstCol, shift, i, length);\n    }\n\n#ifdef EIGEN_BDCSVD_SANITY_CHECKS\n  assert(m_naiveU.allFinite());\n  assert(m_naiveV.allFinite());\n  assert(m_computed.allFinite());\n#endif\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n  std::cout << \"to be sorted: \" << diag.transpose() << \"\\n\\n\";\n#endif\n  {\n    // Check for total deflation\n    // If we have a total deflation, then we have to consider col0(0)==diag(0) as a singular value during sorting\n    bool total_deflation = (col0.tail(length-1).array()<considerZero).all();\n    \n    // Sort the diagonal entries, since diag(1:k-1) and diag(k:length) are already sorted, let's do a sorted merge.\n    // First, compute the respective permutation.\n    Index *permutation = m_workspaceI.data();\n    {\n      permutation[0] = 0;\n      Index p = 1;\n      \n      // Move deflated diagonal entries at the end.\n      for(Index i=1; i<length; ++i)\n        if(abs(diag(i))<considerZero)\n          permutation[p++] = i;\n        \n      Index i=1, j=k+1;\n      for( ; p < length; ++p)\n      {\n             if (i > k)             permutation[p] = j++;\n        else if (j >= length)       permutation[p] = i++;\n        else if (diag(i) < diag(j)) permutation[p] = j++;\n        else                        permutation[p] = i++;\n      }\n    }\n    \n    // If we have a total deflation, then we have to insert diag(0) at the right place\n    if(total_deflation)\n    {\n      for(Index i=1; i<length; ++i)\n      {\n        Index pi = permutation[i];\n        if(abs(diag(pi))<considerZero || diag(0)<diag(pi))\n          permutation[i-1] = permutation[i];\n        else\n        {\n          permutation[i-1] = 0;\n          break;\n        }\n      }\n    }\n    \n    // Current index of each col, and current column of each index\n    Index *realInd = m_workspaceI.data()+length;\n    Index *realCol = m_workspaceI.data()+2*length;\n    \n    for(int pos = 0; pos< length; pos++)\n    {\n      realCol[pos] = pos;\n      realInd[pos] = pos;\n    }\n    \n    for(Index i = total_deflation?0:1; i < length; i++)\n    {\n      const Index pi = permutation[length - (total_deflation ? i+1 : i)];\n      const Index J = realCol[pi];\n      \n      using std::swap;\n      // swap diagonal and first column entries:\n      swap(diag(i), diag(J));\n      if(i!=0 && J!=0) swap(col0(i), col0(J));\n\n      // change columns\n      if (m_compU) m_naiveU.col(firstCol+i).segment(firstCol, length + 1).swap(m_naiveU.col(firstCol+J).segment(firstCol, length + 1));\n      else         m_naiveU.col(firstCol+i).segment(0, 2)                .swap(m_naiveU.col(firstCol+J).segment(0, 2));\n      if (m_compV) m_naiveV.col(firstColW + i).segment(firstRowW, length).swap(m_naiveV.col(firstColW + J).segment(firstRowW, length));\n\n      //update real pos\n      const Index realI = realInd[i];\n      realCol[realI] = J;\n      realCol[pi] = i;\n      realInd[J] = realI;\n      realInd[i] = pi;\n    }\n  }\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n  std::cout << \"sorted: \" << diag.transpose().format(bdcsvdfmt) << \"\\n\";\n  std::cout << \"      : \" << col0.transpose() << \"\\n\\n\";\n#endif\n    \n  //condition 4.4\n  {\n    Index i = length-1;\n    while(i>0 && (abs(diag(i))<considerZero || abs(col0(i))<considerZero)) --i;\n    for(; i>1;--i)\n       if( (diag(i) - diag(i-1)) < NumTraits<RealScalar>::epsilon()*maxDiag )\n      {\n#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE\n        std::cout << \"deflation 4.4 with i = \" << i << \" because \" << (diag(i) - diag(i-1)) << \" < \" << NumTraits<RealScalar>::epsilon()*diag(i) << \"\\n\";\n#endif\n        eigen_internal_assert(abs(diag(i) - diag(i-1))<epsilon_coarse && \" diagonal entries are not properly sorted\");\n        deflation44(firstCol, firstCol + shift, firstRowW, firstColW, i-1, i, length);\n      }\n  }\n  \n#ifdef EIGEN_BDCSVD_SANITY_CHECKS\n  for(Index j=2;j<length;++j)\n    assert(diag(j-1)<=diag(j) || abs(diag(j))<considerZero);\n#endif\n  \n#ifdef EIGEN_BDCSVD_SANITY_CHECKS\n  assert(m_naiveU.allFinite());\n  assert(m_naiveV.allFinite());\n  assert(m_computed.allFinite());\n#endif\n}//end deflation\n\n#ifndef __CUDACC__\n/** \\svd_module\n  *\n  * \\return the singular value decomposition of \\c *this computed by Divide & Conquer algorithm\n  *\n  * \\sa class BDCSVD\n  */\ntemplate<typename Derived>\nBDCSVD<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::bdcSvd(unsigned int computationOptions) const\n{\n  return BDCSVD<PlainObject>(*this, computationOptions);\n}\n#endif\n\n} // end namespace Eigen\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/SVD/JacobiSVD.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2013-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_JACOBISVD_H\n#define EIGEN_JACOBISVD_H\n\nnamespace Eigen { \n\nnamespace internal {\n// forward declaration (needed by ICC)\n// the empty body is required by MSVC\ntemplate<typename MatrixType, int QRPreconditioner,\n         bool IsComplex = NumTraits<typename MatrixType::Scalar>::IsComplex>\nstruct svd_precondition_2x2_block_to_be_real {};\n\n/*** QR preconditioners (R-SVD)\n ***\n *** Their role is to reduce the problem of computing the SVD to the case of a square matrix.\n *** This approach, known as R-SVD, is an optimization for rectangular-enough matrices, and is a requirement for\n *** JacobiSVD which by itself is only able to work on square matrices.\n ***/\n\nenum { PreconditionIfMoreColsThanRows, PreconditionIfMoreRowsThanCols };\n\ntemplate<typename MatrixType, int QRPreconditioner, int Case>\nstruct qr_preconditioner_should_do_anything\n{\n  enum { a = MatrixType::RowsAtCompileTime != Dynamic &&\n             MatrixType::ColsAtCompileTime != Dynamic &&\n             MatrixType::ColsAtCompileTime <= MatrixType::RowsAtCompileTime,\n         b = MatrixType::RowsAtCompileTime != Dynamic &&\n             MatrixType::ColsAtCompileTime != Dynamic &&\n             MatrixType::RowsAtCompileTime <= MatrixType::ColsAtCompileTime,\n         ret = !( (QRPreconditioner == NoQRPreconditioner) ||\n                  (Case == PreconditionIfMoreColsThanRows && bool(a)) ||\n                  (Case == PreconditionIfMoreRowsThanCols && bool(b)) )\n  };\n};\n\ntemplate<typename MatrixType, int QRPreconditioner, int Case,\n         bool DoAnything = qr_preconditioner_should_do_anything<MatrixType, QRPreconditioner, Case>::ret\n> struct qr_preconditioner_impl {};\n\ntemplate<typename MatrixType, int QRPreconditioner, int Case>\nclass qr_preconditioner_impl<MatrixType, QRPreconditioner, Case, false>\n{\npublic:\n  void allocate(const JacobiSVD<MatrixType, QRPreconditioner>&) {}\n  bool run(JacobiSVD<MatrixType, QRPreconditioner>&, const MatrixType&)\n  {\n    return false;\n  }\n};\n\n/*** preconditioner using FullPivHouseholderQR ***/\n\ntemplate<typename MatrixType>\nclass qr_preconditioner_impl<MatrixType, FullPivHouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true>\n{\npublic:\n  typedef typename MatrixType::Scalar Scalar;\n  enum\n  {\n    RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n    MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime\n  };\n  typedef Matrix<Scalar, 1, RowsAtCompileTime, RowMajor, 1, MaxRowsAtCompileTime> WorkspaceType;\n\n  void allocate(const JacobiSVD<MatrixType, FullPivHouseholderQRPreconditioner>& svd)\n  {\n    if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols())\n    {\n      m_qr.~QRType();\n      ::new (&m_qr) QRType(svd.rows(), svd.cols());\n    }\n    if (svd.m_computeFullU) m_workspace.resize(svd.rows());\n  }\n\n  bool run(JacobiSVD<MatrixType, FullPivHouseholderQRPreconditioner>& svd, const MatrixType& matrix)\n  {\n    if(matrix.rows() > matrix.cols())\n    {\n      m_qr.compute(matrix);\n      svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.cols(),matrix.cols()).template triangularView<Upper>();\n      if(svd.m_computeFullU) m_qr.matrixQ().evalTo(svd.m_matrixU, m_workspace);\n      if(svd.computeV()) svd.m_matrixV = m_qr.colsPermutation();\n      return true;\n    }\n    return false;\n  }\nprivate:\n  typedef FullPivHouseholderQR<MatrixType> QRType;\n  QRType m_qr;\n  WorkspaceType m_workspace;\n};\n\ntemplate<typename MatrixType>\nclass qr_preconditioner_impl<MatrixType, FullPivHouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true>\n{\npublic:\n  typedef typename MatrixType::Scalar Scalar;\n  enum\n  {\n    RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n    ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n    MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,\n    TrOptions = RowsAtCompileTime==1 ? (MatrixType::Options & ~(RowMajor))\n              : ColsAtCompileTime==1 ? (MatrixType::Options |   RowMajor)\n              : MatrixType::Options\n  };\n  typedef Matrix<Scalar, ColsAtCompileTime, RowsAtCompileTime, TrOptions, MaxColsAtCompileTime, MaxRowsAtCompileTime>\n          TransposeTypeWithSameStorageOrder;\n\n  void allocate(const JacobiSVD<MatrixType, FullPivHouseholderQRPreconditioner>& svd)\n  {\n    if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols())\n    {\n      m_qr.~QRType();\n      ::new (&m_qr) QRType(svd.cols(), svd.rows());\n    }\n    m_adjoint.resize(svd.cols(), svd.rows());\n    if (svd.m_computeFullV) m_workspace.resize(svd.cols());\n  }\n\n  bool run(JacobiSVD<MatrixType, FullPivHouseholderQRPreconditioner>& svd, const MatrixType& matrix)\n  {\n    if(matrix.cols() > matrix.rows())\n    {\n      m_adjoint = matrix.adjoint();\n      m_qr.compute(m_adjoint);\n      svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.rows(),matrix.rows()).template triangularView<Upper>().adjoint();\n      if(svd.m_computeFullV) m_qr.matrixQ().evalTo(svd.m_matrixV, m_workspace);\n      if(svd.computeU()) svd.m_matrixU = m_qr.colsPermutation();\n      return true;\n    }\n    else return false;\n  }\nprivate:\n  typedef FullPivHouseholderQR<TransposeTypeWithSameStorageOrder> QRType;\n  QRType m_qr;\n  TransposeTypeWithSameStorageOrder m_adjoint;\n  typename internal::plain_row_type<MatrixType>::type m_workspace;\n};\n\n/*** preconditioner using ColPivHouseholderQR ***/\n\ntemplate<typename MatrixType>\nclass qr_preconditioner_impl<MatrixType, ColPivHouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true>\n{\npublic:\n  void allocate(const JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd)\n  {\n    if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols())\n    {\n      m_qr.~QRType();\n      ::new (&m_qr) QRType(svd.rows(), svd.cols());\n    }\n    if (svd.m_computeFullU) m_workspace.resize(svd.rows());\n    else if (svd.m_computeThinU) m_workspace.resize(svd.cols());\n  }\n\n  bool run(JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd, const MatrixType& matrix)\n  {\n    if(matrix.rows() > matrix.cols())\n    {\n      m_qr.compute(matrix);\n      svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.cols(),matrix.cols()).template triangularView<Upper>();\n      if(svd.m_computeFullU) m_qr.householderQ().evalTo(svd.m_matrixU, m_workspace);\n      else if(svd.m_computeThinU)\n      {\n        svd.m_matrixU.setIdentity(matrix.rows(), matrix.cols());\n        m_qr.householderQ().applyThisOnTheLeft(svd.m_matrixU, m_workspace);\n      }\n      if(svd.computeV()) svd.m_matrixV = m_qr.colsPermutation();\n      return true;\n    }\n    return false;\n  }\n\nprivate:\n  typedef ColPivHouseholderQR<MatrixType> QRType;\n  QRType m_qr;\n  typename internal::plain_col_type<MatrixType>::type m_workspace;\n};\n\ntemplate<typename MatrixType>\nclass qr_preconditioner_impl<MatrixType, ColPivHouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true>\n{\npublic:\n  typedef typename MatrixType::Scalar Scalar;\n  enum\n  {\n    RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n    ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n    MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,\n    TrOptions = RowsAtCompileTime==1 ? (MatrixType::Options & ~(RowMajor))\n              : ColsAtCompileTime==1 ? (MatrixType::Options |   RowMajor)\n              : MatrixType::Options\n  };\n\n  typedef Matrix<Scalar, ColsAtCompileTime, RowsAtCompileTime, TrOptions, MaxColsAtCompileTime, MaxRowsAtCompileTime>\n          TransposeTypeWithSameStorageOrder;\n\n  void allocate(const JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd)\n  {\n    if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols())\n    {\n      m_qr.~QRType();\n      ::new (&m_qr) QRType(svd.cols(), svd.rows());\n    }\n    if (svd.m_computeFullV) m_workspace.resize(svd.cols());\n    else if (svd.m_computeThinV) m_workspace.resize(svd.rows());\n    m_adjoint.resize(svd.cols(), svd.rows());\n  }\n\n  bool run(JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd, const MatrixType& matrix)\n  {\n    if(matrix.cols() > matrix.rows())\n    {\n      m_adjoint = matrix.adjoint();\n      m_qr.compute(m_adjoint);\n\n      svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.rows(),matrix.rows()).template triangularView<Upper>().adjoint();\n      if(svd.m_computeFullV) m_qr.householderQ().evalTo(svd.m_matrixV, m_workspace);\n      else if(svd.m_computeThinV)\n      {\n        svd.m_matrixV.setIdentity(matrix.cols(), matrix.rows());\n        m_qr.householderQ().applyThisOnTheLeft(svd.m_matrixV, m_workspace);\n      }\n      if(svd.computeU()) svd.m_matrixU = m_qr.colsPermutation();\n      return true;\n    }\n    else return false;\n  }\n\nprivate:\n  typedef ColPivHouseholderQR<TransposeTypeWithSameStorageOrder> QRType;\n  QRType m_qr;\n  TransposeTypeWithSameStorageOrder m_adjoint;\n  typename internal::plain_row_type<MatrixType>::type m_workspace;\n};\n\n/*** preconditioner using HouseholderQR ***/\n\ntemplate<typename MatrixType>\nclass qr_preconditioner_impl<MatrixType, HouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true>\n{\npublic:\n  void allocate(const JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd)\n  {\n    if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols())\n    {\n      m_qr.~QRType();\n      ::new (&m_qr) QRType(svd.rows(), svd.cols());\n    }\n    if (svd.m_computeFullU) m_workspace.resize(svd.rows());\n    else if (svd.m_computeThinU) m_workspace.resize(svd.cols());\n  }\n\n  bool run(JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd, const MatrixType& matrix)\n  {\n    if(matrix.rows() > matrix.cols())\n    {\n      m_qr.compute(matrix);\n      svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.cols(),matrix.cols()).template triangularView<Upper>();\n      if(svd.m_computeFullU) m_qr.householderQ().evalTo(svd.m_matrixU, m_workspace);\n      else if(svd.m_computeThinU)\n      {\n        svd.m_matrixU.setIdentity(matrix.rows(), matrix.cols());\n        m_qr.householderQ().applyThisOnTheLeft(svd.m_matrixU, m_workspace);\n      }\n      if(svd.computeV()) svd.m_matrixV.setIdentity(matrix.cols(), matrix.cols());\n      return true;\n    }\n    return false;\n  }\nprivate:\n  typedef HouseholderQR<MatrixType> QRType;\n  QRType m_qr;\n  typename internal::plain_col_type<MatrixType>::type m_workspace;\n};\n\ntemplate<typename MatrixType>\nclass qr_preconditioner_impl<MatrixType, HouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true>\n{\npublic:\n  typedef typename MatrixType::Scalar Scalar;\n  enum\n  {\n    RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n    ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n    MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,\n    Options = MatrixType::Options\n  };\n\n  typedef Matrix<Scalar, ColsAtCompileTime, RowsAtCompileTime, Options, MaxColsAtCompileTime, MaxRowsAtCompileTime>\n          TransposeTypeWithSameStorageOrder;\n\n  void allocate(const JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd)\n  {\n    if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols())\n    {\n      m_qr.~QRType();\n      ::new (&m_qr) QRType(svd.cols(), svd.rows());\n    }\n    if (svd.m_computeFullV) m_workspace.resize(svd.cols());\n    else if (svd.m_computeThinV) m_workspace.resize(svd.rows());\n    m_adjoint.resize(svd.cols(), svd.rows());\n  }\n\n  bool run(JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd, const MatrixType& matrix)\n  {\n    if(matrix.cols() > matrix.rows())\n    {\n      m_adjoint = matrix.adjoint();\n      m_qr.compute(m_adjoint);\n\n      svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.rows(),matrix.rows()).template triangularView<Upper>().adjoint();\n      if(svd.m_computeFullV) m_qr.householderQ().evalTo(svd.m_matrixV, m_workspace);\n      else if(svd.m_computeThinV)\n      {\n        svd.m_matrixV.setIdentity(matrix.cols(), matrix.rows());\n        m_qr.householderQ().applyThisOnTheLeft(svd.m_matrixV, m_workspace);\n      }\n      if(svd.computeU()) svd.m_matrixU.setIdentity(matrix.rows(), matrix.rows());\n      return true;\n    }\n    else return false;\n  }\n\nprivate:\n  typedef HouseholderQR<TransposeTypeWithSameStorageOrder> QRType;\n  QRType m_qr;\n  TransposeTypeWithSameStorageOrder m_adjoint;\n  typename internal::plain_row_type<MatrixType>::type m_workspace;\n};\n\n/*** 2x2 SVD implementation\n ***\n *** JacobiSVD consists in performing a series of 2x2 SVD subproblems\n ***/\n\ntemplate<typename MatrixType, int QRPreconditioner>\nstruct svd_precondition_2x2_block_to_be_real<MatrixType, QRPreconditioner, false>\n{\n  typedef JacobiSVD<MatrixType, QRPreconditioner> SVD;\n  typedef typename MatrixType::RealScalar RealScalar;\n  static bool run(typename SVD::WorkMatrixType&, SVD&, Index, Index, RealScalar&) { return true; }\n};\n\ntemplate<typename MatrixType, int QRPreconditioner>\nstruct svd_precondition_2x2_block_to_be_real<MatrixType, QRPreconditioner, true>\n{\n  typedef JacobiSVD<MatrixType, QRPreconditioner> SVD;\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename MatrixType::RealScalar RealScalar;\n  static bool run(typename SVD::WorkMatrixType& work_matrix, SVD& svd, Index p, Index q, RealScalar& maxDiagEntry)\n  {\n    using std::sqrt;\n    using std::abs;\n    Scalar z;\n    JacobiRotation<Scalar> rot;\n    RealScalar n = sqrt(numext::abs2(work_matrix.coeff(p,p)) + numext::abs2(work_matrix.coeff(q,p)));\n\n    const RealScalar considerAsZero = (std::numeric_limits<RealScalar>::min)();\n    const RealScalar precision = NumTraits<Scalar>::epsilon();\n\n    if(n==0)\n    {\n      // make sure first column is zero\n      work_matrix.coeffRef(p,p) = work_matrix.coeffRef(q,p) = Scalar(0);\n\n      if(abs(numext::imag(work_matrix.coeff(p,q)))>considerAsZero)\n      {\n        // work_matrix.coeff(p,q) can be zero if work_matrix.coeff(q,p) is not zero but small enough to underflow when computing n\n        z = abs(work_matrix.coeff(p,q)) / work_matrix.coeff(p,q);\n        work_matrix.row(p) *= z;\n        if(svd.computeU()) svd.m_matrixU.col(p) *= conj(z);\n      }\n      if(abs(numext::imag(work_matrix.coeff(q,q)))>considerAsZero)\n      {\n        z = abs(work_matrix.coeff(q,q)) / work_matrix.coeff(q,q);\n        work_matrix.row(q) *= z;\n        if(svd.computeU()) svd.m_matrixU.col(q) *= conj(z);\n      }\n      // otherwise the second row is already zero, so we have nothing to do.\n    }\n    else\n    {\n      rot.c() = conj(work_matrix.coeff(p,p)) / n;\n      rot.s() = work_matrix.coeff(q,p) / n;\n      work_matrix.applyOnTheLeft(p,q,rot);\n      if(svd.computeU()) svd.m_matrixU.applyOnTheRight(p,q,rot.adjoint());\n      if(abs(numext::imag(work_matrix.coeff(p,q)))>considerAsZero)\n      {\n        z = abs(work_matrix.coeff(p,q)) / work_matrix.coeff(p,q);\n        work_matrix.col(q) *= z;\n        if(svd.computeV()) svd.m_matrixV.col(q) *= z;\n      }\n      if(abs(numext::imag(work_matrix.coeff(q,q)))>considerAsZero)\n      {\n        z = abs(work_matrix.coeff(q,q)) / work_matrix.coeff(q,q);\n        work_matrix.row(q) *= z;\n        if(svd.computeU()) svd.m_matrixU.col(q) *= conj(z);\n      }\n    }\n\n    // update largest diagonal entry\n    maxDiagEntry = numext::maxi<RealScalar>(maxDiagEntry,numext::maxi<RealScalar>(abs(work_matrix.coeff(p,p)), abs(work_matrix.coeff(q,q))));\n    // and check whether the 2x2 block is already diagonal\n    RealScalar threshold = numext::maxi<RealScalar>(considerAsZero, precision * maxDiagEntry);\n    return abs(work_matrix.coeff(p,q))>threshold || abs(work_matrix.coeff(q,p)) > threshold;\n  }\n};\n\ntemplate<typename _MatrixType, int QRPreconditioner> \nstruct traits<JacobiSVD<_MatrixType,QRPreconditioner> >\n{\n  typedef _MatrixType MatrixType;\n};\n\n} // end namespace internal\n\n/** \\ingroup SVD_Module\n  *\n  *\n  * \\class JacobiSVD\n  *\n  * \\brief Two-sided Jacobi SVD decomposition of a rectangular matrix\n  *\n  * \\tparam _MatrixType the type of the matrix of which we are computing the SVD decomposition\n  * \\tparam QRPreconditioner this optional parameter allows to specify the type of QR decomposition that will be used internally\n  *                        for the R-SVD step for non-square matrices. See discussion of possible values below.\n  *\n  * SVD decomposition consists in decomposing any n-by-p matrix \\a A as a product\n  *   \\f[ A = U S V^* \\f]\n  * where \\a U is a n-by-n unitary, \\a V is a p-by-p unitary, and \\a S is a n-by-p real positive matrix which is zero outside of its main diagonal;\n  * the diagonal entries of S are known as the \\em singular \\em values of \\a A and the columns of \\a U and \\a V are known as the left\n  * and right \\em singular \\em vectors of \\a A respectively.\n  *\n  * Singular values are always sorted in decreasing order.\n  *\n  * This JacobiSVD decomposition computes only the singular values by default. If you want \\a U or \\a V, you need to ask for them explicitly.\n  *\n  * You can ask for only \\em thin \\a U or \\a V to be computed, meaning the following. In case of a rectangular n-by-p matrix, letting \\a m be the\n  * smaller value among \\a n and \\a p, there are only \\a m singular vectors; the remaining columns of \\a U and \\a V do not correspond to actual\n  * singular vectors. Asking for \\em thin \\a U or \\a V means asking for only their \\a m first columns to be formed. So \\a U is then a n-by-m matrix,\n  * and \\a V is then a p-by-m matrix. Notice that thin \\a U and \\a V are all you need for (least squares) solving.\n  *\n  * Here's an example demonstrating basic usage:\n  * \\include JacobiSVD_basic.cpp\n  * Output: \\verbinclude JacobiSVD_basic.out\n  *\n  * This JacobiSVD class is a two-sided Jacobi R-SVD decomposition, ensuring optimal reliability and accuracy. The downside is that it's slower than\n  * bidiagonalizing SVD algorithms for large square matrices; however its complexity is still \\f$ O(n^2p) \\f$ where \\a n is the smaller dimension and\n  * \\a p is the greater dimension, meaning that it is still of the same order of complexity as the faster bidiagonalizing R-SVD algorithms.\n  * In particular, like any R-SVD, it takes advantage of non-squareness in that its complexity is only linear in the greater dimension.\n  *\n  * If the input matrix has inf or nan coefficients, the result of the computation is undefined, but the computation is guaranteed to\n  * terminate in finite (and reasonable) time.\n  *\n  * The possible values for QRPreconditioner are:\n  * \\li ColPivHouseholderQRPreconditioner is the default. In practice it's very safe. It uses column-pivoting QR.\n  * \\li FullPivHouseholderQRPreconditioner, is the safest and slowest. It uses full-pivoting QR.\n  *     Contrary to other QRs, it doesn't allow computing thin unitaries.\n  * \\li HouseholderQRPreconditioner is the fastest, and less safe and accurate than the pivoting variants. It uses non-pivoting QR.\n  *     This is very similar in safety and accuracy to the bidiagonalization process used by bidiagonalizing SVD algorithms (since bidiagonalization\n  *     is inherently non-pivoting). However the resulting SVD is still more reliable than bidiagonalizing SVDs because the Jacobi-based iterarive\n  *     process is more reliable than the optimized bidiagonal SVD iterations.\n  * \\li NoQRPreconditioner allows not to use a QR preconditioner at all. This is useful if you know that you will only be computing\n  *     JacobiSVD decompositions of square matrices. Non-square matrices require a QR preconditioner. Using this option will result in\n  *     faster compilation and smaller executable code. It won't significantly speed up computation, since JacobiSVD is always checking\n  *     if QR preconditioning is needed before applying it anyway.\n  *\n  * \\sa MatrixBase::jacobiSvd()\n  */\ntemplate<typename _MatrixType, int QRPreconditioner> class JacobiSVD\n : public SVDBase<JacobiSVD<_MatrixType,QRPreconditioner> >\n{\n    typedef SVDBase<JacobiSVD> Base;\n  public:\n\n    typedef _MatrixType MatrixType;\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      DiagSizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime,ColsAtCompileTime),\n      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,\n      MaxDiagSizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_FIXED(MaxRowsAtCompileTime,MaxColsAtCompileTime),\n      MatrixOptions = MatrixType::Options\n    };\n\n    typedef typename Base::MatrixUType MatrixUType;\n    typedef typename Base::MatrixVType MatrixVType;\n    typedef typename Base::SingularValuesType SingularValuesType;\n    \n    typedef typename internal::plain_row_type<MatrixType>::type RowType;\n    typedef typename internal::plain_col_type<MatrixType>::type ColType;\n    typedef Matrix<Scalar, DiagSizeAtCompileTime, DiagSizeAtCompileTime,\n                   MatrixOptions, MaxDiagSizeAtCompileTime, MaxDiagSizeAtCompileTime>\n            WorkMatrixType;\n\n    /** \\brief Default Constructor.\n      *\n      * The default constructor is useful in cases in which the user intends to\n      * perform decompositions via JacobiSVD::compute(const MatrixType&).\n      */\n    JacobiSVD()\n    {}\n\n\n    /** \\brief Default Constructor with memory preallocation\n      *\n      * Like the default constructor but with preallocation of the internal data\n      * according to the specified problem size.\n      * \\sa JacobiSVD()\n      */\n    JacobiSVD(Index rows, Index cols, unsigned int computationOptions = 0)\n    {\n      allocate(rows, cols, computationOptions);\n    }\n\n    /** \\brief Constructor performing the decomposition of given matrix.\n     *\n     * \\param matrix the matrix to decompose\n     * \\param computationOptions optional parameter allowing to specify if you want full or thin U or V unitaries to be computed.\n     *                           By default, none is computed. This is a bit-field, the possible bits are #ComputeFullU, #ComputeThinU,\n     *                           #ComputeFullV, #ComputeThinV.\n     *\n     * Thin unitaries are only available if your matrix type has a Dynamic number of columns (for example MatrixXf). They also are not\n     * available with the (non-default) FullPivHouseholderQR preconditioner.\n     */\n    explicit JacobiSVD(const MatrixType& matrix, unsigned int computationOptions = 0)\n    {\n      compute(matrix, computationOptions);\n    }\n\n    /** \\brief Method performing the decomposition of given matrix using custom options.\n     *\n     * \\param matrix the matrix to decompose\n     * \\param computationOptions optional parameter allowing to specify if you want full or thin U or V unitaries to be computed.\n     *                           By default, none is computed. This is a bit-field, the possible bits are #ComputeFullU, #ComputeThinU,\n     *                           #ComputeFullV, #ComputeThinV.\n     *\n     * Thin unitaries are only available if your matrix type has a Dynamic number of columns (for example MatrixXf). They also are not\n     * available with the (non-default) FullPivHouseholderQR preconditioner.\n     */\n    JacobiSVD& compute(const MatrixType& matrix, unsigned int computationOptions);\n\n    /** \\brief Method performing the decomposition of given matrix using current options.\n     *\n     * \\param matrix the matrix to decompose\n     *\n     * This method uses the current \\a computationOptions, as already passed to the constructor or to compute(const MatrixType&, unsigned int).\n     */\n    JacobiSVD& compute(const MatrixType& matrix)\n    {\n      return compute(matrix, m_computationOptions);\n    }\n\n    using Base::computeU;\n    using Base::computeV;\n    using Base::rows;\n    using Base::cols;\n    using Base::rank;\n\n  private:\n    void allocate(Index rows, Index cols, unsigned int computationOptions);\n\n  protected:\n    using Base::m_matrixU;\n    using Base::m_matrixV;\n    using Base::m_singularValues;\n    using Base::m_isInitialized;\n    using Base::m_isAllocated;\n    using Base::m_usePrescribedThreshold;\n    using Base::m_computeFullU;\n    using Base::m_computeThinU;\n    using Base::m_computeFullV;\n    using Base::m_computeThinV;\n    using Base::m_computationOptions;\n    using Base::m_nonzeroSingularValues;\n    using Base::m_rows;\n    using Base::m_cols;\n    using Base::m_diagSize;\n    using Base::m_prescribedThreshold;\n    WorkMatrixType m_workMatrix;\n\n    template<typename __MatrixType, int _QRPreconditioner, bool _IsComplex>\n    friend struct internal::svd_precondition_2x2_block_to_be_real;\n    template<typename __MatrixType, int _QRPreconditioner, int _Case, bool _DoAnything>\n    friend struct internal::qr_preconditioner_impl;\n\n    internal::qr_preconditioner_impl<MatrixType, QRPreconditioner, internal::PreconditionIfMoreColsThanRows> m_qr_precond_morecols;\n    internal::qr_preconditioner_impl<MatrixType, QRPreconditioner, internal::PreconditionIfMoreRowsThanCols> m_qr_precond_morerows;\n    MatrixType m_scaledMatrix;\n};\n\ntemplate<typename MatrixType, int QRPreconditioner>\nvoid JacobiSVD<MatrixType, QRPreconditioner>::allocate(Index rows, Index cols, unsigned int computationOptions)\n{\n  eigen_assert(rows >= 0 && cols >= 0);\n\n  if (m_isAllocated &&\n      rows == m_rows &&\n      cols == m_cols &&\n      computationOptions == m_computationOptions)\n  {\n    return;\n  }\n\n  m_rows = rows;\n  m_cols = cols;\n  m_isInitialized = false;\n  m_isAllocated = true;\n  m_computationOptions = computationOptions;\n  m_computeFullU = (computationOptions & ComputeFullU) != 0;\n  m_computeThinU = (computationOptions & ComputeThinU) != 0;\n  m_computeFullV = (computationOptions & ComputeFullV) != 0;\n  m_computeThinV = (computationOptions & ComputeThinV) != 0;\n  eigen_assert(!(m_computeFullU && m_computeThinU) && \"JacobiSVD: you can't ask for both full and thin U\");\n  eigen_assert(!(m_computeFullV && m_computeThinV) && \"JacobiSVD: you can't ask for both full and thin V\");\n  eigen_assert(EIGEN_IMPLIES(m_computeThinU || m_computeThinV, MatrixType::ColsAtCompileTime==Dynamic) &&\n              \"JacobiSVD: thin U and V are only available when your matrix has a dynamic number of columns.\");\n  if (QRPreconditioner == FullPivHouseholderQRPreconditioner)\n  {\n      eigen_assert(!(m_computeThinU || m_computeThinV) &&\n              \"JacobiSVD: can't compute thin U or thin V with the FullPivHouseholderQR preconditioner. \"\n              \"Use the ColPivHouseholderQR preconditioner instead.\");\n  }\n  m_diagSize = (std::min)(m_rows, m_cols);\n  m_singularValues.resize(m_diagSize);\n  if(RowsAtCompileTime==Dynamic)\n    m_matrixU.resize(m_rows, m_computeFullU ? m_rows\n                            : m_computeThinU ? m_diagSize\n                            : 0);\n  if(ColsAtCompileTime==Dynamic)\n    m_matrixV.resize(m_cols, m_computeFullV ? m_cols\n                            : m_computeThinV ? m_diagSize\n                            : 0);\n  m_workMatrix.resize(m_diagSize, m_diagSize);\n  \n  if(m_cols>m_rows)   m_qr_precond_morecols.allocate(*this);\n  if(m_rows>m_cols)   m_qr_precond_morerows.allocate(*this);\n  if(m_rows!=m_cols)  m_scaledMatrix.resize(rows,cols);\n}\n\ntemplate<typename MatrixType, int QRPreconditioner>\nJacobiSVD<MatrixType, QRPreconditioner>&\nJacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsigned int computationOptions)\n{\n  using std::abs;\n  allocate(matrix.rows(), matrix.cols(), computationOptions);\n\n  // currently we stop when we reach precision 2*epsilon as the last bit of precision can require an unreasonable number of iterations,\n  // only worsening the precision of U and V as we accumulate more rotations\n  const RealScalar precision = RealScalar(2) * NumTraits<Scalar>::epsilon();\n\n  // limit for denormal numbers to be considered zero in order to avoid infinite loops (see bug 286)\n  const RealScalar considerAsZero = (std::numeric_limits<RealScalar>::min)();\n\n  // Scaling factor to reduce over/under-flows\n  RealScalar scale = matrix.cwiseAbs().maxCoeff();\n  if(scale==RealScalar(0)) scale = RealScalar(1);\n  \n  /*** step 1. The R-SVD step: we use a QR decomposition to reduce to the case of a square matrix */\n\n  if(m_rows!=m_cols)\n  {\n    m_scaledMatrix = matrix / scale;\n    m_qr_precond_morecols.run(*this, m_scaledMatrix);\n    m_qr_precond_morerows.run(*this, m_scaledMatrix);\n  }\n  else\n  {\n    m_workMatrix = matrix.block(0,0,m_diagSize,m_diagSize) / scale;\n    if(m_computeFullU) m_matrixU.setIdentity(m_rows,m_rows);\n    if(m_computeThinU) m_matrixU.setIdentity(m_rows,m_diagSize);\n    if(m_computeFullV) m_matrixV.setIdentity(m_cols,m_cols);\n    if(m_computeThinV) m_matrixV.setIdentity(m_cols, m_diagSize);\n  }\n\n  /*** step 2. The main Jacobi SVD iteration. ***/\n  RealScalar maxDiagEntry = m_workMatrix.cwiseAbs().diagonal().maxCoeff();\n\n  bool finished = false;\n  while(!finished)\n  {\n    finished = true;\n\n    // do a sweep: for all index pairs (p,q), perform SVD of the corresponding 2x2 sub-matrix\n\n    for(Index p = 1; p < m_diagSize; ++p)\n    {\n      for(Index q = 0; q < p; ++q)\n      {\n        // if this 2x2 sub-matrix is not diagonal already...\n        // notice that this comparison will evaluate to false if any NaN is involved, ensuring that NaN's don't\n        // keep us iterating forever. Similarly, small denormal numbers are considered zero.\n        RealScalar threshold = numext::maxi<RealScalar>(considerAsZero, precision * maxDiagEntry);\n        if(abs(m_workMatrix.coeff(p,q))>threshold || abs(m_workMatrix.coeff(q,p)) > threshold)\n        {\n          finished = false;\n          // perform SVD decomposition of 2x2 sub-matrix corresponding to indices p,q to make it diagonal\n          // the complex to real operation returns true if the updated 2x2 block is not already diagonal\n          if(internal::svd_precondition_2x2_block_to_be_real<MatrixType, QRPreconditioner>::run(m_workMatrix, *this, p, q, maxDiagEntry))\n          {\n            JacobiRotation<RealScalar> j_left, j_right;\n            internal::real_2x2_jacobi_svd(m_workMatrix, p, q, &j_left, &j_right);\n\n            // accumulate resulting Jacobi rotations\n            m_workMatrix.applyOnTheLeft(p,q,j_left);\n            if(computeU()) m_matrixU.applyOnTheRight(p,q,j_left.transpose());\n\n            m_workMatrix.applyOnTheRight(p,q,j_right);\n            if(computeV()) m_matrixV.applyOnTheRight(p,q,j_right);\n\n            // keep track of the largest diagonal coefficient\n            maxDiagEntry = numext::maxi<RealScalar>(maxDiagEntry,numext::maxi<RealScalar>(abs(m_workMatrix.coeff(p,p)), abs(m_workMatrix.coeff(q,q))));\n          }\n        }\n      }\n    }\n  }\n\n  /*** step 3. The work matrix is now diagonal, so ensure it's positive so its diagonal entries are the singular values ***/\n\n  for(Index i = 0; i < m_diagSize; ++i)\n  {\n    // For a complex matrix, some diagonal coefficients might note have been\n    // treated by svd_precondition_2x2_block_to_be_real, and the imaginary part\n    // of some diagonal entry might not be null.\n    if(NumTraits<Scalar>::IsComplex && abs(numext::imag(m_workMatrix.coeff(i,i)))>considerAsZero)\n    {\n      RealScalar a = abs(m_workMatrix.coeff(i,i));\n      m_singularValues.coeffRef(i) = abs(a);\n      if(computeU()) m_matrixU.col(i) *= m_workMatrix.coeff(i,i)/a;\n    }\n    else\n    {\n      // m_workMatrix.coeff(i,i) is already real, no difficulty:\n      RealScalar a = numext::real(m_workMatrix.coeff(i,i));\n      m_singularValues.coeffRef(i) = abs(a);\n      if(computeU() && (a<RealScalar(0))) m_matrixU.col(i) = -m_matrixU.col(i);\n    }\n  }\n  \n  m_singularValues *= scale;\n\n  /*** step 4. Sort singular values in descending order and compute the number of nonzero singular values ***/\n\n  m_nonzeroSingularValues = m_diagSize;\n  for(Index i = 0; i < m_diagSize; i++)\n  {\n    Index pos;\n    RealScalar maxRemainingSingularValue = m_singularValues.tail(m_diagSize-i).maxCoeff(&pos);\n    if(maxRemainingSingularValue == RealScalar(0))\n    {\n      m_nonzeroSingularValues = i;\n      break;\n    }\n    if(pos)\n    {\n      pos += i;\n      std::swap(m_singularValues.coeffRef(i), m_singularValues.coeffRef(pos));\n      if(computeU()) m_matrixU.col(pos).swap(m_matrixU.col(i));\n      if(computeV()) m_matrixV.col(pos).swap(m_matrixV.col(i));\n    }\n  }\n\n  m_isInitialized = true;\n  return *this;\n}\n\n/** \\svd_module\n  *\n  * \\return the singular value decomposition of \\c *this computed by two-sided\n  * Jacobi transformations.\n  *\n  * \\sa class JacobiSVD\n  */\ntemplate<typename Derived>\nJacobiSVD<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::jacobiSvd(unsigned int computationOptions) const\n{\n  return JacobiSVD<PlainObject>(*this, computationOptions);\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_JACOBISVD_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SVD/JacobiSVD_LAPACKE.h",
    "content": "/*\n Copyright (c) 2011, Intel Corporation. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without modification,\n are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n * Neither the name of Intel Corporation nor the names of its contributors may\n   be used to endorse or promote products derived from this software without\n   specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ********************************************************************************\n *   Content : Eigen bindings to LAPACKe\n *    Singular Value Decomposition - SVD.\n ********************************************************************************\n*/\n\n#ifndef EIGEN_JACOBISVD_LAPACKE_H\n#define EIGEN_JACOBISVD_LAPACKE_H\n\nnamespace Eigen { \n\n/** \\internal Specialization for the data types supported by LAPACKe */\n\n#define EIGEN_LAPACKE_SVD(EIGTYPE, LAPACKE_TYPE, LAPACKE_RTYPE, LAPACKE_PREFIX, EIGCOLROW, LAPACKE_COLROW) \\\ntemplate<> inline \\\nJacobiSVD<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>, ColPivHouseholderQRPreconditioner>& \\\nJacobiSVD<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>, ColPivHouseholderQRPreconditioner>::compute(const Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>& matrix, unsigned int computationOptions) \\\n{ \\\n  typedef Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> MatrixType; \\\n  /*typedef MatrixType::Scalar Scalar;*/ \\\n  /*typedef MatrixType::RealScalar RealScalar;*/ \\\n  allocate(matrix.rows(), matrix.cols(), computationOptions); \\\n\\\n  /*const RealScalar precision = RealScalar(2) * NumTraits<Scalar>::epsilon();*/ \\\n  m_nonzeroSingularValues = m_diagSize; \\\n\\\n  lapack_int lda = internal::convert_index<lapack_int>(matrix.outerStride()), ldu, ldvt; \\\n  lapack_int matrix_order = LAPACKE_COLROW; \\\n  char jobu, jobvt; \\\n  LAPACKE_TYPE *u, *vt, dummy; \\\n  jobu  = (m_computeFullU) ? 'A' : (m_computeThinU) ? 'S' : 'N'; \\\n  jobvt = (m_computeFullV) ? 'A' : (m_computeThinV) ? 'S' : 'N'; \\\n  if (computeU()) { \\\n    ldu  = internal::convert_index<lapack_int>(m_matrixU.outerStride()); \\\n    u    = (LAPACKE_TYPE*)m_matrixU.data(); \\\n  } else { ldu=1; u=&dummy; }\\\n  MatrixType localV; \\\n  ldvt = (m_computeFullV) ? internal::convert_index<lapack_int>(m_cols) : (m_computeThinV) ? internal::convert_index<lapack_int>(m_diagSize) : 1; \\\n  if (computeV()) { \\\n    localV.resize(ldvt, m_cols); \\\n    vt   = (LAPACKE_TYPE*)localV.data(); \\\n  } else { ldvt=1; vt=&dummy; }\\\n  Matrix<LAPACKE_RTYPE, Dynamic, Dynamic> superb; superb.resize(m_diagSize, 1); \\\n  MatrixType m_temp; m_temp = matrix; \\\n  LAPACKE_##LAPACKE_PREFIX##gesvd( matrix_order, jobu, jobvt, internal::convert_index<lapack_int>(m_rows), internal::convert_index<lapack_int>(m_cols), (LAPACKE_TYPE*)m_temp.data(), lda, (LAPACKE_RTYPE*)m_singularValues.data(), u, ldu, vt, ldvt, superb.data()); \\\n  if (computeV()) m_matrixV = localV.adjoint(); \\\n /* for(int i=0;i<m_diagSize;i++) if (m_singularValues.coeffRef(i) < precision) { m_nonzeroSingularValues--; m_singularValues.coeffRef(i)=RealScalar(0);}*/ \\\n  m_isInitialized = true; \\\n  return *this; \\\n}\n\nEIGEN_LAPACKE_SVD(double,   double,                double, d, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_SVD(float,    float,                 float , s, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_SVD(dcomplex, lapack_complex_double, double, z, ColMajor, LAPACK_COL_MAJOR)\nEIGEN_LAPACKE_SVD(scomplex, lapack_complex_float,  float , c, ColMajor, LAPACK_COL_MAJOR)\n\nEIGEN_LAPACKE_SVD(double,   double,                double, d, RowMajor, LAPACK_ROW_MAJOR)\nEIGEN_LAPACKE_SVD(float,    float,                 float , s, RowMajor, LAPACK_ROW_MAJOR)\nEIGEN_LAPACKE_SVD(dcomplex, lapack_complex_double, double, z, RowMajor, LAPACK_ROW_MAJOR)\nEIGEN_LAPACKE_SVD(scomplex, lapack_complex_float,  float , c, RowMajor, LAPACK_ROW_MAJOR)\n\n} // end namespace Eigen\n\n#endif // EIGEN_JACOBISVD_LAPACKE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SVD/SVDBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// Copyright (C) 2013 Gauthier Brun <brun.gauthier@gmail.com>\n// Copyright (C) 2013 Nicolas Carre <nicolas.carre@ensimag.fr>\n// Copyright (C) 2013 Jean Ceccato <jean.ceccato@ensimag.fr>\n// Copyright (C) 2013 Pierre Zoppitelli <pierre.zoppitelli@ensimag.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SVDBASE_H\n#define EIGEN_SVDBASE_H\n\nnamespace Eigen {\n/** \\ingroup SVD_Module\n *\n *\n * \\class SVDBase\n *\n * \\brief Base class of SVD algorithms\n *\n * \\tparam Derived the type of the actual SVD decomposition\n *\n * SVD decomposition consists in decomposing any n-by-p matrix \\a A as a product\n *   \\f[ A = U S V^* \\f]\n * where \\a U is a n-by-n unitary, \\a V is a p-by-p unitary, and \\a S is a n-by-p real positive matrix which is zero outside of its main diagonal;\n * the diagonal entries of S are known as the \\em singular \\em values of \\a A and the columns of \\a U and \\a V are known as the left\n * and right \\em singular \\em vectors of \\a A respectively.\n *\n * Singular values are always sorted in decreasing order.\n *\n * \n * You can ask for only \\em thin \\a U or \\a V to be computed, meaning the following. In case of a rectangular n-by-p matrix, letting \\a m be the\n * smaller value among \\a n and \\a p, there are only \\a m singular vectors; the remaining columns of \\a U and \\a V do not correspond to actual\n * singular vectors. Asking for \\em thin \\a U or \\a V means asking for only their \\a m first columns to be formed. So \\a U is then a n-by-m matrix,\n * and \\a V is then a p-by-m matrix. Notice that thin \\a U and \\a V are all you need for (least squares) solving.\n *  \n * If the input matrix has inf or nan coefficients, the result of the computation is undefined, but the computation is guaranteed to\n * terminate in finite (and reasonable) time.\n * \\sa class BDCSVD, class JacobiSVD\n */\ntemplate<typename Derived>\nclass SVDBase\n{\n\npublic:\n  typedef typename internal::traits<Derived>::MatrixType MatrixType;\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;\n  typedef typename MatrixType::StorageIndex StorageIndex;\n  typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n  enum {\n    RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n    ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n    DiagSizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime,ColsAtCompileTime),\n    MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n    MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,\n    MaxDiagSizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_FIXED(MaxRowsAtCompileTime,MaxColsAtCompileTime),\n    MatrixOptions = MatrixType::Options\n  };\n\n  typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime, MatrixOptions, MaxRowsAtCompileTime, MaxRowsAtCompileTime> MatrixUType;\n  typedef Matrix<Scalar, ColsAtCompileTime, ColsAtCompileTime, MatrixOptions, MaxColsAtCompileTime, MaxColsAtCompileTime> MatrixVType;\n  typedef typename internal::plain_diag_type<MatrixType, RealScalar>::type SingularValuesType;\n  \n  Derived& derived() { return *static_cast<Derived*>(this); }\n  const Derived& derived() const { return *static_cast<const Derived*>(this); }\n\n  /** \\returns the \\a U matrix.\n   *\n   * For the SVD decomposition of a n-by-p matrix, letting \\a m be the minimum of \\a n and \\a p,\n   * the U matrix is n-by-n if you asked for \\link Eigen::ComputeFullU ComputeFullU \\endlink, and is n-by-m if you asked for \\link Eigen::ComputeThinU ComputeThinU \\endlink.\n   *\n   * The \\a m first columns of \\a U are the left singular vectors of the matrix being decomposed.\n   *\n   * This method asserts that you asked for \\a U to be computed.\n   */\n  const MatrixUType& matrixU() const\n  {\n    eigen_assert(m_isInitialized && \"SVD is not initialized.\");\n    eigen_assert(computeU() && \"This SVD decomposition didn't compute U. Did you ask for it?\");\n    return m_matrixU;\n  }\n\n  /** \\returns the \\a V matrix.\n   *\n   * For the SVD decomposition of a n-by-p matrix, letting \\a m be the minimum of \\a n and \\a p,\n   * the V matrix is p-by-p if you asked for \\link Eigen::ComputeFullV ComputeFullV \\endlink, and is p-by-m if you asked for \\link Eigen::ComputeThinV ComputeThinV \\endlink.\n   *\n   * The \\a m first columns of \\a V are the right singular vectors of the matrix being decomposed.\n   *\n   * This method asserts that you asked for \\a V to be computed.\n   */\n  const MatrixVType& matrixV() const\n  {\n    eigen_assert(m_isInitialized && \"SVD is not initialized.\");\n    eigen_assert(computeV() && \"This SVD decomposition didn't compute V. Did you ask for it?\");\n    return m_matrixV;\n  }\n\n  /** \\returns the vector of singular values.\n   *\n   * For the SVD decomposition of a n-by-p matrix, letting \\a m be the minimum of \\a n and \\a p, the\n   * returned vector has size \\a m.  Singular values are always sorted in decreasing order.\n   */\n  const SingularValuesType& singularValues() const\n  {\n    eigen_assert(m_isInitialized && \"SVD is not initialized.\");\n    return m_singularValues;\n  }\n\n  /** \\returns the number of singular values that are not exactly 0 */\n  Index nonzeroSingularValues() const\n  {\n    eigen_assert(m_isInitialized && \"SVD is not initialized.\");\n    return m_nonzeroSingularValues;\n  }\n  \n  /** \\returns the rank of the matrix of which \\c *this is the SVD.\n    *\n    * \\note This method has to determine which singular values should be considered nonzero.\n    *       For that, it uses the threshold value that you can control by calling\n    *       setThreshold(const RealScalar&).\n    */\n  inline Index rank() const\n  {\n    using std::abs;\n    eigen_assert(m_isInitialized && \"JacobiSVD is not initialized.\");\n    if(m_singularValues.size()==0) return 0;\n    RealScalar premultiplied_threshold = numext::maxi<RealScalar>(m_singularValues.coeff(0) * threshold(), (std::numeric_limits<RealScalar>::min)());\n    Index i = m_nonzeroSingularValues-1;\n    while(i>=0 && m_singularValues.coeff(i) < premultiplied_threshold) --i;\n    return i+1;\n  }\n  \n  /** Allows to prescribe a threshold to be used by certain methods, such as rank() and solve(),\n    * which need to determine when singular values are to be considered nonzero.\n    * This is not used for the SVD decomposition itself.\n    *\n    * When it needs to get the threshold value, Eigen calls threshold().\n    * The default is \\c NumTraits<Scalar>::epsilon()\n    *\n    * \\param threshold The new value to use as the threshold.\n    *\n    * A singular value will be considered nonzero if its value is strictly greater than\n    *  \\f$ \\vert singular value \\vert \\leqslant threshold \\times \\vert max singular value \\vert \\f$.\n    *\n    * If you want to come back to the default behavior, call setThreshold(Default_t)\n    */\n  Derived& setThreshold(const RealScalar& threshold)\n  {\n    m_usePrescribedThreshold = true;\n    m_prescribedThreshold = threshold;\n    return derived();\n  }\n\n  /** Allows to come back to the default behavior, letting Eigen use its default formula for\n    * determining the threshold.\n    *\n    * You should pass the special object Eigen::Default as parameter here.\n    * \\code svd.setThreshold(Eigen::Default); \\endcode\n    *\n    * See the documentation of setThreshold(const RealScalar&).\n    */\n  Derived& setThreshold(Default_t)\n  {\n    m_usePrescribedThreshold = false;\n    return derived();\n  }\n\n  /** Returns the threshold that will be used by certain methods such as rank().\n    *\n    * See the documentation of setThreshold(const RealScalar&).\n    */\n  RealScalar threshold() const\n  {\n    eigen_assert(m_isInitialized || m_usePrescribedThreshold);\n    return m_usePrescribedThreshold ? m_prescribedThreshold\n                                    : (std::max<Index>)(1,m_diagSize)*NumTraits<Scalar>::epsilon();\n  }\n\n  /** \\returns true if \\a U (full or thin) is asked for in this SVD decomposition */\n  inline bool computeU() const { return m_computeFullU || m_computeThinU; }\n  /** \\returns true if \\a V (full or thin) is asked for in this SVD decomposition */\n  inline bool computeV() const { return m_computeFullV || m_computeThinV; }\n\n  inline Index rows() const { return m_rows; }\n  inline Index cols() const { return m_cols; }\n  \n  /** \\returns a (least squares) solution of \\f$ A x = b \\f$ using the current SVD decomposition of A.\n    *\n    * \\param b the right-hand-side of the equation to solve.\n    *\n    * \\note Solving requires both U and V to be computed. Thin U and V are enough, there is no need for full U or V.\n    *\n    * \\note SVD solving is implicitly least-squares. Thus, this method serves both purposes of exact solving and least-squares solving.\n    * In other words, the returned solution is guaranteed to minimize the Euclidean norm \\f$ \\Vert A x - b \\Vert \\f$.\n    */\n  template<typename Rhs>\n  inline const Solve<Derived, Rhs>\n  solve(const MatrixBase<Rhs>& b) const\n  {\n    eigen_assert(m_isInitialized && \"SVD is not initialized.\");\n    eigen_assert(computeU() && computeV() && \"SVD::solve() requires both unitaries U and V to be computed (thin unitaries suffice).\");\n    return Solve<Derived, Rhs>(derived(), b.derived());\n  }\n  \n  #ifndef EIGEN_PARSED_BY_DOXYGEN\n  template<typename RhsType, typename DstType>\n  EIGEN_DEVICE_FUNC\n  void _solve_impl(const RhsType &rhs, DstType &dst) const;\n  #endif\n\nprotected:\n  \n  static void check_template_parameters()\n  {\n    EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);\n  }\n  \n  // return true if already allocated\n  bool allocate(Index rows, Index cols, unsigned int computationOptions) ;\n\n  MatrixUType m_matrixU;\n  MatrixVType m_matrixV;\n  SingularValuesType m_singularValues;\n  bool m_isInitialized, m_isAllocated, m_usePrescribedThreshold;\n  bool m_computeFullU, m_computeThinU;\n  bool m_computeFullV, m_computeThinV;\n  unsigned int m_computationOptions;\n  Index m_nonzeroSingularValues, m_rows, m_cols, m_diagSize;\n  RealScalar m_prescribedThreshold;\n\n  /** \\brief Default Constructor.\n   *\n   * Default constructor of SVDBase\n   */\n  SVDBase()\n    : m_isInitialized(false),\n      m_isAllocated(false),\n      m_usePrescribedThreshold(false),\n      m_computationOptions(0),\n      m_rows(-1), m_cols(-1), m_diagSize(0)\n  {\n    check_template_parameters();\n  }\n\n\n};\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename Derived>\ntemplate<typename RhsType, typename DstType>\nvoid SVDBase<Derived>::_solve_impl(const RhsType &rhs, DstType &dst) const\n{\n  eigen_assert(rhs.rows() == rows());\n\n  // A = U S V^*\n  // So A^{-1} = V S^{-1} U^*\n\n  Matrix<Scalar, Dynamic, RhsType::ColsAtCompileTime, 0, MatrixType::MaxRowsAtCompileTime, RhsType::MaxColsAtCompileTime> tmp;\n  Index l_rank = rank();\n  tmp.noalias() =  m_matrixU.leftCols(l_rank).adjoint() * rhs;\n  tmp = m_singularValues.head(l_rank).asDiagonal().inverse() * tmp;\n  dst = m_matrixV.leftCols(l_rank) * tmp;\n}\n#endif\n\ntemplate<typename MatrixType>\nbool SVDBase<MatrixType>::allocate(Index rows, Index cols, unsigned int computationOptions)\n{\n  eigen_assert(rows >= 0 && cols >= 0);\n\n  if (m_isAllocated &&\n      rows == m_rows &&\n      cols == m_cols &&\n      computationOptions == m_computationOptions)\n  {\n    return true;\n  }\n\n  m_rows = rows;\n  m_cols = cols;\n  m_isInitialized = false;\n  m_isAllocated = true;\n  m_computationOptions = computationOptions;\n  m_computeFullU = (computationOptions & ComputeFullU) != 0;\n  m_computeThinU = (computationOptions & ComputeThinU) != 0;\n  m_computeFullV = (computationOptions & ComputeFullV) != 0;\n  m_computeThinV = (computationOptions & ComputeThinV) != 0;\n  eigen_assert(!(m_computeFullU && m_computeThinU) && \"SVDBase: you can't ask for both full and thin U\");\n  eigen_assert(!(m_computeFullV && m_computeThinV) && \"SVDBase: you can't ask for both full and thin V\");\n  eigen_assert(EIGEN_IMPLIES(m_computeThinU || m_computeThinV, MatrixType::ColsAtCompileTime==Dynamic) &&\n\t       \"SVDBase: thin U and V are only available when your matrix has a dynamic number of columns.\");\n\n  m_diagSize = (std::min)(m_rows, m_cols);\n  m_singularValues.resize(m_diagSize);\n  if(RowsAtCompileTime==Dynamic)\n    m_matrixU.resize(m_rows, m_computeFullU ? m_rows : m_computeThinU ? m_diagSize : 0);\n  if(ColsAtCompileTime==Dynamic)\n    m_matrixV.resize(m_cols, m_computeFullV ? m_cols : m_computeThinV ? m_diagSize : 0);\n\n  return false;\n}\n\n}// end namespace\n\n#endif // EIGEN_SVDBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SVD/UpperBidiagonalization.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2013-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_BIDIAGONALIZATION_H\n#define EIGEN_BIDIAGONALIZATION_H\n\nnamespace Eigen { \n\nnamespace internal {\n// UpperBidiagonalization will probably be replaced by a Bidiagonalization class, don't want to make it stable API.\n// At the same time, it's useful to keep for now as it's about the only thing that is testing the BandMatrix class.\n\ntemplate<typename _MatrixType> class UpperBidiagonalization\n{\n  public:\n\n    typedef _MatrixType MatrixType;\n    enum {\n      RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      ColsAtCompileTimeMinusOne = internal::decrement_size<ColsAtCompileTime>::ret\n    };\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    typedef Eigen::Index Index; ///< \\deprecated since Eigen 3.3\n    typedef Matrix<Scalar, 1, ColsAtCompileTime> RowVectorType;\n    typedef Matrix<Scalar, RowsAtCompileTime, 1> ColVectorType;\n    typedef BandMatrix<RealScalar, ColsAtCompileTime, ColsAtCompileTime, 1, 0, RowMajor> BidiagonalType;\n    typedef Matrix<Scalar, ColsAtCompileTime, 1> DiagVectorType;\n    typedef Matrix<Scalar, ColsAtCompileTimeMinusOne, 1> SuperDiagVectorType;\n    typedef HouseholderSequence<\n              const MatrixType,\n              const typename internal::remove_all<typename Diagonal<const MatrixType,0>::ConjugateReturnType>::type\n            > HouseholderUSequenceType;\n    typedef HouseholderSequence<\n              const typename internal::remove_all<typename MatrixType::ConjugateReturnType>::type,\n              Diagonal<const MatrixType,1>,\n              OnTheRight\n            > HouseholderVSequenceType;\n    \n    /**\n    * \\brief Default Constructor.\n    *\n    * The default constructor is useful in cases in which the user intends to\n    * perform decompositions via Bidiagonalization::compute(const MatrixType&).\n    */\n    UpperBidiagonalization() : m_householder(), m_bidiagonal(), m_isInitialized(false) {}\n\n    explicit UpperBidiagonalization(const MatrixType& matrix)\n      : m_householder(matrix.rows(), matrix.cols()),\n        m_bidiagonal(matrix.cols(), matrix.cols()),\n        m_isInitialized(false)\n    {\n      compute(matrix);\n    }\n    \n    UpperBidiagonalization& compute(const MatrixType& matrix);\n    UpperBidiagonalization& computeUnblocked(const MatrixType& matrix);\n    \n    const MatrixType& householder() const { return m_householder; }\n    const BidiagonalType& bidiagonal() const { return m_bidiagonal; }\n    \n    const HouseholderUSequenceType householderU() const\n    {\n      eigen_assert(m_isInitialized && \"UpperBidiagonalization is not initialized.\");\n      return HouseholderUSequenceType(m_householder, m_householder.diagonal().conjugate());\n    }\n\n    const HouseholderVSequenceType householderV() // const here gives nasty errors and i'm lazy\n    {\n      eigen_assert(m_isInitialized && \"UpperBidiagonalization is not initialized.\");\n      return HouseholderVSequenceType(m_householder.conjugate(), m_householder.const_derived().template diagonal<1>())\n             .setLength(m_householder.cols()-1)\n             .setShift(1);\n    }\n    \n  protected:\n    MatrixType m_householder;\n    BidiagonalType m_bidiagonal;\n    bool m_isInitialized;\n};\n\n// Standard upper bidiagonalization without fancy optimizations\n// This version should be faster for small matrix size\ntemplate<typename MatrixType>\nvoid upperbidiagonalization_inplace_unblocked(MatrixType& mat,\n                                              typename MatrixType::RealScalar *diagonal,\n                                              typename MatrixType::RealScalar *upper_diagonal,\n                                              typename MatrixType::Scalar* tempData = 0)\n{\n  typedef typename MatrixType::Scalar Scalar;\n\n  Index rows = mat.rows();\n  Index cols = mat.cols();\n\n  typedef Matrix<Scalar,Dynamic,1,ColMajor,MatrixType::MaxRowsAtCompileTime,1> TempType;\n  TempType tempVector;\n  if(tempData==0)\n  {\n    tempVector.resize(rows);\n    tempData = tempVector.data();\n  }\n\n  for (Index k = 0; /* breaks at k==cols-1 below */ ; ++k)\n  {\n    Index remainingRows = rows - k;\n    Index remainingCols = cols - k - 1;\n\n    // construct left householder transform in-place in A\n    mat.col(k).tail(remainingRows)\n       .makeHouseholderInPlace(mat.coeffRef(k,k), diagonal[k]);\n    // apply householder transform to remaining part of A on the left\n    mat.bottomRightCorner(remainingRows, remainingCols)\n       .applyHouseholderOnTheLeft(mat.col(k).tail(remainingRows-1), mat.coeff(k,k), tempData);\n\n    if(k == cols-1) break;\n\n    // construct right householder transform in-place in mat\n    mat.row(k).tail(remainingCols)\n       .makeHouseholderInPlace(mat.coeffRef(k,k+1), upper_diagonal[k]);\n    // apply householder transform to remaining part of mat on the left\n    mat.bottomRightCorner(remainingRows-1, remainingCols)\n       .applyHouseholderOnTheRight(mat.row(k).tail(remainingCols-1).transpose(), mat.coeff(k,k+1), tempData);\n  }\n}\n\n/** \\internal\n  * Helper routine for the block reduction to upper bidiagonal form.\n  *\n  * Let's partition the matrix A:\n  * \n  *      | A00 A01 |\n  *  A = |         |\n  *      | A10 A11 |\n  *\n  * This function reduces to bidiagonal form the left \\c rows x \\a blockSize vertical panel [A00/A10]\n  * and the \\a blockSize x \\c cols horizontal panel [A00 A01] of the matrix \\a A. The bottom-right block A11\n  * is updated using matrix-matrix products:\n  *   A22 -= V * Y^T - X * U^T\n  * where V and U contains the left and right Householder vectors. U and V are stored in A10, and A01\n  * respectively, and the update matrices X and Y are computed during the reduction.\n  * \n  */\ntemplate<typename MatrixType>\nvoid upperbidiagonalization_blocked_helper(MatrixType& A,\n                                           typename MatrixType::RealScalar *diagonal,\n                                           typename MatrixType::RealScalar *upper_diagonal,\n                                           Index bs,\n                                           Ref<Matrix<typename MatrixType::Scalar, Dynamic, Dynamic,\n                                                      traits<MatrixType>::Flags & RowMajorBit> > X,\n                                           Ref<Matrix<typename MatrixType::Scalar, Dynamic, Dynamic,\n                                                      traits<MatrixType>::Flags & RowMajorBit> > Y)\n{\n  typedef typename MatrixType::Scalar Scalar;\n  typedef typename MatrixType::RealScalar RealScalar;\n  typedef typename NumTraits<RealScalar>::Literal Literal;\n  enum { StorageOrder = traits<MatrixType>::Flags & RowMajorBit };\n  typedef InnerStride<int(StorageOrder) == int(ColMajor) ? 1 : Dynamic> ColInnerStride;\n  typedef InnerStride<int(StorageOrder) == int(ColMajor) ? Dynamic : 1> RowInnerStride;\n  typedef Ref<Matrix<Scalar, Dynamic, 1>, 0, ColInnerStride>    SubColumnType;\n  typedef Ref<Matrix<Scalar, 1, Dynamic>, 0, RowInnerStride>    SubRowType;\n  typedef Ref<Matrix<Scalar, Dynamic, Dynamic, StorageOrder > > SubMatType;\n  \n  Index brows = A.rows();\n  Index bcols = A.cols();\n\n  Scalar tau_u, tau_u_prev(0), tau_v;\n\n  for(Index k = 0; k < bs; ++k)\n  {\n    Index remainingRows = brows - k;\n    Index remainingCols = bcols - k - 1;\n\n    SubMatType X_k1( X.block(k,0, remainingRows,k) );\n    SubMatType V_k1( A.block(k,0, remainingRows,k) );\n\n    // 1 - update the k-th column of A\n    SubColumnType v_k = A.col(k).tail(remainingRows);\n          v_k -= V_k1 * Y.row(k).head(k).adjoint();\n    if(k) v_k -= X_k1 * A.col(k).head(k);\n    \n    // 2 - construct left Householder transform in-place\n    v_k.makeHouseholderInPlace(tau_v, diagonal[k]);\n       \n    if(k+1<bcols)\n    {\n      SubMatType Y_k  ( Y.block(k+1,0, remainingCols, k+1) );\n      SubMatType U_k1 ( A.block(0,k+1, k,remainingCols) );\n      \n      // this eases the application of Householder transforAions\n      // A(k,k) will store tau_v later\n      A(k,k) = Scalar(1);\n\n      // 3 - Compute y_k^T = tau_v * ( A^T*v_k - Y_k-1*V_k-1^T*v_k - U_k-1*X_k-1^T*v_k )\n      {\n        SubColumnType y_k( Y.col(k).tail(remainingCols) );\n        \n        // let's use the begining of column k of Y as a temporary vector\n        SubColumnType tmp( Y.col(k).head(k) );\n        y_k.noalias()  = A.block(k,k+1, remainingRows,remainingCols).adjoint() * v_k; // bottleneck\n        tmp.noalias()  = V_k1.adjoint()  * v_k;\n        y_k.noalias() -= Y_k.leftCols(k) * tmp;\n        tmp.noalias()  = X_k1.adjoint()  * v_k;\n        y_k.noalias() -= U_k1.adjoint()  * tmp;\n        y_k *= numext::conj(tau_v);\n      }\n\n      // 4 - update k-th row of A (it will become u_k)\n      SubRowType u_k( A.row(k).tail(remainingCols) );\n      u_k = u_k.conjugate();\n      {\n        u_k -= Y_k * A.row(k).head(k+1).adjoint();\n        if(k) u_k -= U_k1.adjoint() * X.row(k).head(k).adjoint();\n      }\n\n      // 5 - construct right Householder transform in-place\n      u_k.makeHouseholderInPlace(tau_u, upper_diagonal[k]);\n\n      // this eases the application of Householder transformations\n      // A(k,k+1) will store tau_u later\n      A(k,k+1) = Scalar(1);\n\n      // 6 - Compute x_k = tau_u * ( A*u_k - X_k-1*U_k-1^T*u_k - V_k*Y_k^T*u_k )\n      {\n        SubColumnType x_k ( X.col(k).tail(remainingRows-1) );\n        \n        // let's use the begining of column k of X as a temporary vectors\n        // note that tmp0 and tmp1 overlaps\n        SubColumnType tmp0 ( X.col(k).head(k) ),\n                      tmp1 ( X.col(k).head(k+1) );\n                    \n        x_k.noalias()   = A.block(k+1,k+1, remainingRows-1,remainingCols) * u_k.transpose(); // bottleneck\n        tmp0.noalias()  = U_k1 * u_k.transpose();\n        x_k.noalias()  -= X_k1.bottomRows(remainingRows-1) * tmp0;\n        tmp1.noalias()  = Y_k.adjoint() * u_k.transpose();\n        x_k.noalias()  -= A.block(k+1,0, remainingRows-1,k+1) * tmp1;\n        x_k *= numext::conj(tau_u);\n        tau_u = numext::conj(tau_u);\n        u_k = u_k.conjugate();\n      }\n\n      if(k>0) A.coeffRef(k-1,k) = tau_u_prev;\n      tau_u_prev = tau_u;\n    }\n    else\n      A.coeffRef(k-1,k) = tau_u_prev;\n\n    A.coeffRef(k,k) = tau_v;\n  }\n  \n  if(bs<bcols)\n    A.coeffRef(bs-1,bs) = tau_u_prev;\n\n  // update A22\n  if(bcols>bs && brows>bs)\n  {\n    SubMatType A11( A.bottomRightCorner(brows-bs,bcols-bs) );\n    SubMatType A10( A.block(bs,0, brows-bs,bs) );\n    SubMatType A01( A.block(0,bs, bs,bcols-bs) );\n    Scalar tmp = A01(bs-1,0);\n    A01(bs-1,0) = Literal(1);\n    A11.noalias() -= A10 * Y.topLeftCorner(bcols,bs).bottomRows(bcols-bs).adjoint();\n    A11.noalias() -= X.topLeftCorner(brows,bs).bottomRows(brows-bs) * A01;\n    A01(bs-1,0) = tmp;\n  }\n}\n\n/** \\internal\n  *\n  * Implementation of a block-bidiagonal reduction.\n  * It is based on the following paper:\n  *   The Design of a Parallel Dense Linear Algebra Software Library: Reduction to Hessenberg, Tridiagonal, and Bidiagonal Form.\n  *   by Jaeyoung Choi, Jack J. Dongarra, David W. Walker. (1995)\n  *   section 3.3\n  */\ntemplate<typename MatrixType, typename BidiagType>\nvoid upperbidiagonalization_inplace_blocked(MatrixType& A, BidiagType& bidiagonal,\n                                            Index maxBlockSize=32,\n                                            typename MatrixType::Scalar* /*tempData*/ = 0)\n{\n  typedef typename MatrixType::Scalar Scalar;\n  typedef Block<MatrixType,Dynamic,Dynamic> BlockType;\n\n  Index rows = A.rows();\n  Index cols = A.cols();\n  Index size = (std::min)(rows, cols);\n\n  // X and Y are work space\n  enum { StorageOrder = traits<MatrixType>::Flags & RowMajorBit };\n  Matrix<Scalar,\n         MatrixType::RowsAtCompileTime,\n         Dynamic,\n         StorageOrder,\n         MatrixType::MaxRowsAtCompileTime> X(rows,maxBlockSize);\n  Matrix<Scalar,\n         MatrixType::ColsAtCompileTime,\n         Dynamic,\n         StorageOrder,\n         MatrixType::MaxColsAtCompileTime> Y(cols,maxBlockSize);\n  Index blockSize = (std::min)(maxBlockSize,size);\n\n  Index k = 0;\n  for(k = 0; k < size; k += blockSize)\n  {\n    Index bs = (std::min)(size-k,blockSize);  // actual size of the block\n    Index brows = rows - k;                   // rows of the block\n    Index bcols = cols - k;                   // columns of the block\n\n    // partition the matrix A:\n    // \n    //      | A00 A01 A02 |\n    //      |             |\n    // A  = | A10 A11 A12 |\n    //      |             |\n    //      | A20 A21 A22 |\n    //\n    // where A11 is a bs x bs diagonal block,\n    // and let:\n    //      | A11 A12 |\n    //  B = |         |\n    //      | A21 A22 |\n\n    BlockType B = A.block(k,k,brows,bcols);\n    \n    // This stage performs the bidiagonalization of A11, A21, A12, and updating of A22.\n    // Finally, the algorithm continue on the updated A22.\n    //\n    // However, if B is too small, or A22 empty, then let's use an unblocked strategy\n    if(k+bs==cols || bcols<48) // somewhat arbitrary threshold\n    {\n      upperbidiagonalization_inplace_unblocked(B,\n                                               &(bidiagonal.template diagonal<0>().coeffRef(k)),\n                                               &(bidiagonal.template diagonal<1>().coeffRef(k)),\n                                               X.data()\n                                              );\n      break; // We're done\n    }\n    else\n    {\n      upperbidiagonalization_blocked_helper<BlockType>( B,\n                                                        &(bidiagonal.template diagonal<0>().coeffRef(k)),\n                                                        &(bidiagonal.template diagonal<1>().coeffRef(k)),\n                                                        bs,\n                                                        X.topLeftCorner(brows,bs),\n                                                        Y.topLeftCorner(bcols,bs)\n                                                      );\n    }\n  }\n}\n\ntemplate<typename _MatrixType>\nUpperBidiagonalization<_MatrixType>& UpperBidiagonalization<_MatrixType>::computeUnblocked(const _MatrixType& matrix)\n{\n  Index rows = matrix.rows();\n  Index cols = matrix.cols();\n  EIGEN_ONLY_USED_FOR_DEBUG(cols);\n\n  eigen_assert(rows >= cols && \"UpperBidiagonalization is only for Arices satisfying rows>=cols.\");\n\n  m_householder = matrix;\n\n  ColVectorType temp(rows);\n\n  upperbidiagonalization_inplace_unblocked(m_householder,\n                                           &(m_bidiagonal.template diagonal<0>().coeffRef(0)),\n                                           &(m_bidiagonal.template diagonal<1>().coeffRef(0)),\n                                           temp.data());\n\n  m_isInitialized = true;\n  return *this;\n}\n\ntemplate<typename _MatrixType>\nUpperBidiagonalization<_MatrixType>& UpperBidiagonalization<_MatrixType>::compute(const _MatrixType& matrix)\n{\n  Index rows = matrix.rows();\n  Index cols = matrix.cols();\n  EIGEN_ONLY_USED_FOR_DEBUG(rows);\n  EIGEN_ONLY_USED_FOR_DEBUG(cols);\n\n  eigen_assert(rows >= cols && \"UpperBidiagonalization is only for Arices satisfying rows>=cols.\");\n\n  m_householder = matrix;\n  upperbidiagonalization_inplace_blocked(m_householder, m_bidiagonal);\n            \n  m_isInitialized = true;\n  return *this;\n}\n\n#if 0\n/** \\return the Householder QR decomposition of \\c *this.\n  *\n  * \\sa class Bidiagonalization\n  */\ntemplate<typename Derived>\nconst UpperBidiagonalization<typename MatrixBase<Derived>::PlainObject>\nMatrixBase<Derived>::bidiagonalization() const\n{\n  return UpperBidiagonalization<PlainObject>(eval());\n}\n#endif\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_BIDIAGONALIZATION_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCholesky/SimplicialCholesky.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2012 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SIMPLICIAL_CHOLESKY_H\n#define EIGEN_SIMPLICIAL_CHOLESKY_H\n\nnamespace Eigen { \n\nenum SimplicialCholeskyMode {\n  SimplicialCholeskyLLT,\n  SimplicialCholeskyLDLT\n};\n\nnamespace internal {\n  template<typename CholMatrixType, typename InputMatrixType>\n  struct simplicial_cholesky_grab_input {\n    typedef CholMatrixType const * ConstCholMatrixPtr;\n    static void run(const InputMatrixType& input, ConstCholMatrixPtr &pmat, CholMatrixType &tmp)\n    {\n      tmp = input;\n      pmat = &tmp;\n    }\n  };\n  \n  template<typename MatrixType>\n  struct simplicial_cholesky_grab_input<MatrixType,MatrixType> {\n    typedef MatrixType const * ConstMatrixPtr;\n    static void run(const MatrixType& input, ConstMatrixPtr &pmat, MatrixType &/*tmp*/)\n    {\n      pmat = &input;\n    }\n  };\n} // end namespace internal\n\n/** \\ingroup SparseCholesky_Module\n  * \\brief A base class for direct sparse Cholesky factorizations\n  *\n  * This is a base class for LL^T and LDL^T Cholesky factorizations of sparse matrices that are\n  * selfadjoint and positive definite. These factorizations allow for solving A.X = B where\n  * X and B can be either dense or sparse.\n  * \n  * In order to reduce the fill-in, a symmetric permutation P is applied prior to the factorization\n  * such that the factorized matrix is P A P^-1.\n  *\n  * \\tparam Derived the type of the derived class, that is the actual factorization type.\n  *\n  */\ntemplate<typename Derived>\nclass SimplicialCholeskyBase : public SparseSolverBase<Derived>\n{\n    typedef SparseSolverBase<Derived> Base;\n    using Base::m_isInitialized;\n    \n  public:\n    typedef typename internal::traits<Derived>::MatrixType MatrixType;\n    typedef typename internal::traits<Derived>::OrderingType OrderingType;\n    enum { UpLo = internal::traits<Derived>::UpLo };\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef SparseMatrix<Scalar,ColMajor,StorageIndex> CholMatrixType;\n    typedef CholMatrixType const * ConstCholMatrixPtr;\n    typedef Matrix<Scalar,Dynamic,1> VectorType;\n    typedef Matrix<StorageIndex,Dynamic,1> VectorI;\n\n    enum {\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n\n  public:\n    \n    using Base::derived;\n\n    /** Default constructor */\n    SimplicialCholeskyBase()\n      : m_info(Success), m_shiftOffset(0), m_shiftScale(1)\n    {}\n\n    explicit SimplicialCholeskyBase(const MatrixType& matrix)\n      : m_info(Success), m_shiftOffset(0), m_shiftScale(1)\n    {\n      derived().compute(matrix);\n    }\n\n    ~SimplicialCholeskyBase()\n    {\n    }\n\n    Derived& derived() { return *static_cast<Derived*>(this); }\n    const Derived& derived() const { return *static_cast<const Derived*>(this); }\n    \n    inline Index cols() const { return m_matrix.cols(); }\n    inline Index rows() const { return m_matrix.rows(); }\n    \n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful,\n      *          \\c NumericalIssue if the matrix.appears to be negative.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return m_info;\n    }\n    \n    /** \\returns the permutation P\n      * \\sa permutationPinv() */\n    const PermutationMatrix<Dynamic,Dynamic,StorageIndex>& permutationP() const\n    { return m_P; }\n    \n    /** \\returns the inverse P^-1 of the permutation P\n      * \\sa permutationP() */\n    const PermutationMatrix<Dynamic,Dynamic,StorageIndex>& permutationPinv() const\n    { return m_Pinv; }\n\n    /** Sets the shift parameters that will be used to adjust the diagonal coefficients during the numerical factorization.\n      *\n      * During the numerical factorization, the diagonal coefficients are transformed by the following linear model:\\n\n      * \\c d_ii = \\a offset + \\a scale * \\c d_ii\n      *\n      * The default is the identity transformation with \\a offset=0, and \\a scale=1.\n      *\n      * \\returns a reference to \\c *this.\n      */\n    Derived& setShift(const RealScalar& offset, const RealScalar& scale = 1)\n    {\n      m_shiftOffset = offset;\n      m_shiftScale = scale;\n      return derived();\n    }\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** \\internal */\n    template<typename Stream>\n    void dumpMemory(Stream& s)\n    {\n      int total = 0;\n      s << \"  L:        \" << ((total+=(m_matrix.cols()+1) * sizeof(int) + m_matrix.nonZeros()*(sizeof(int)+sizeof(Scalar))) >> 20) << \"Mb\" << \"\\n\";\n      s << \"  diag:     \" << ((total+=m_diag.size() * sizeof(Scalar)) >> 20) << \"Mb\" << \"\\n\";\n      s << \"  tree:     \" << ((total+=m_parent.size() * sizeof(int)) >> 20) << \"Mb\" << \"\\n\";\n      s << \"  nonzeros: \" << ((total+=m_nonZerosPerCol.size() * sizeof(int)) >> 20) << \"Mb\" << \"\\n\";\n      s << \"  perm:     \" << ((total+=m_P.size() * sizeof(int)) >> 20) << \"Mb\" << \"\\n\";\n      s << \"  perm^-1:  \" << ((total+=m_Pinv.size() * sizeof(int)) >> 20) << \"Mb\" << \"\\n\";\n      s << \"  TOTAL:    \" << (total>> 20) << \"Mb\" << \"\\n\";\n    }\n\n    /** \\internal */\n    template<typename Rhs,typename Dest>\n    void _solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &dest) const\n    {\n      eigen_assert(m_factorizationIsOk && \"The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()\");\n      eigen_assert(m_matrix.rows()==b.rows());\n\n      if(m_info!=Success)\n        return;\n\n      if(m_P.size()>0)\n        dest = m_P * b;\n      else\n        dest = b;\n\n      if(m_matrix.nonZeros()>0) // otherwise L==I\n        derived().matrixL().solveInPlace(dest);\n\n      if(m_diag.size()>0)\n        dest = m_diag.asDiagonal().inverse() * dest;\n\n      if (m_matrix.nonZeros()>0) // otherwise U==I\n        derived().matrixU().solveInPlace(dest);\n\n      if(m_P.size()>0)\n        dest = m_Pinv * dest;\n    }\n    \n    template<typename Rhs,typename Dest>\n    void _solve_impl(const SparseMatrixBase<Rhs> &b, SparseMatrixBase<Dest> &dest) const\n    {\n      internal::solve_sparse_through_dense_panels(derived(), b, dest);\n    }\n\n#endif // EIGEN_PARSED_BY_DOXYGEN\n\n  protected:\n    \n    /** Computes the sparse Cholesky decomposition of \\a matrix */\n    template<bool DoLDLT>\n    void compute(const MatrixType& matrix)\n    {\n      eigen_assert(matrix.rows()==matrix.cols());\n      Index size = matrix.cols();\n      CholMatrixType tmp(size,size);\n      ConstCholMatrixPtr pmat;\n      ordering(matrix, pmat, tmp);\n      analyzePattern_preordered(*pmat, DoLDLT);\n      factorize_preordered<DoLDLT>(*pmat);\n    }\n    \n    template<bool DoLDLT>\n    void factorize(const MatrixType& a)\n    {\n      eigen_assert(a.rows()==a.cols());\n      Index size = a.cols();\n      CholMatrixType tmp(size,size);\n      ConstCholMatrixPtr pmat;\n      \n      if(m_P.size()==0 && (UpLo&Upper)==Upper)\n      {\n        // If there is no ordering, try to directly use the input matrix without any copy\n        internal::simplicial_cholesky_grab_input<CholMatrixType,MatrixType>::run(a, pmat, tmp);\n      }\n      else\n      {\n        tmp.template selfadjointView<Upper>() = a.template selfadjointView<UpLo>().twistedBy(m_P);\n        pmat = &tmp;\n      }\n      \n      factorize_preordered<DoLDLT>(*pmat);\n    }\n\n    template<bool DoLDLT>\n    void factorize_preordered(const CholMatrixType& a);\n\n    void analyzePattern(const MatrixType& a, bool doLDLT)\n    {\n      eigen_assert(a.rows()==a.cols());\n      Index size = a.cols();\n      CholMatrixType tmp(size,size);\n      ConstCholMatrixPtr pmat;\n      ordering(a, pmat, tmp);\n      analyzePattern_preordered(*pmat,doLDLT);\n    }\n    void analyzePattern_preordered(const CholMatrixType& a, bool doLDLT);\n    \n    void ordering(const MatrixType& a, ConstCholMatrixPtr &pmat, CholMatrixType& ap);\n\n    /** keeps off-diagonal entries; drops diagonal entries */\n    struct keep_diag {\n      inline bool operator() (const Index& row, const Index& col, const Scalar&) const\n      {\n        return row!=col;\n      }\n    };\n\n    mutable ComputationInfo m_info;\n    bool m_factorizationIsOk;\n    bool m_analysisIsOk;\n    \n    CholMatrixType m_matrix;\n    VectorType m_diag;                                // the diagonal coefficients (LDLT mode)\n    VectorI m_parent;                                 // elimination tree\n    VectorI m_nonZerosPerCol;\n    PermutationMatrix<Dynamic,Dynamic,StorageIndex> m_P;     // the permutation\n    PermutationMatrix<Dynamic,Dynamic,StorageIndex> m_Pinv;  // the inverse permutation\n\n    RealScalar m_shiftOffset;\n    RealScalar m_shiftScale;\n};\n\ntemplate<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::StorageIndex> > class SimplicialLLT;\ntemplate<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::StorageIndex> > class SimplicialLDLT;\ntemplate<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::StorageIndex> > class SimplicialCholesky;\n\nnamespace internal {\n\ntemplate<typename _MatrixType, int _UpLo, typename _Ordering> struct traits<SimplicialLLT<_MatrixType,_UpLo,_Ordering> >\n{\n  typedef _MatrixType MatrixType;\n  typedef _Ordering OrderingType;\n  enum { UpLo = _UpLo };\n  typedef typename MatrixType::Scalar                         Scalar;\n  typedef typename MatrixType::StorageIndex                   StorageIndex;\n  typedef SparseMatrix<Scalar, ColMajor, StorageIndex>        CholMatrixType;\n  typedef TriangularView<const CholMatrixType, Eigen::Lower>  MatrixL;\n  typedef TriangularView<const typename CholMatrixType::AdjointReturnType, Eigen::Upper>   MatrixU;\n  static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); }\n  static inline MatrixU getU(const MatrixType& m) { return MatrixU(m.adjoint()); }\n};\n\ntemplate<typename _MatrixType,int _UpLo, typename _Ordering> struct traits<SimplicialLDLT<_MatrixType,_UpLo,_Ordering> >\n{\n  typedef _MatrixType MatrixType;\n  typedef _Ordering OrderingType;\n  enum { UpLo = _UpLo };\n  typedef typename MatrixType::Scalar                             Scalar;\n  typedef typename MatrixType::StorageIndex                       StorageIndex;\n  typedef SparseMatrix<Scalar, ColMajor, StorageIndex>            CholMatrixType;\n  typedef TriangularView<const CholMatrixType, Eigen::UnitLower>  MatrixL;\n  typedef TriangularView<const typename CholMatrixType::AdjointReturnType, Eigen::UnitUpper> MatrixU;\n  static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); }\n  static inline MatrixU getU(const MatrixType& m) { return MatrixU(m.adjoint()); }\n};\n\ntemplate<typename _MatrixType, int _UpLo, typename _Ordering> struct traits<SimplicialCholesky<_MatrixType,_UpLo,_Ordering> >\n{\n  typedef _MatrixType MatrixType;\n  typedef _Ordering OrderingType;\n  enum { UpLo = _UpLo };\n};\n\n}\n\n/** \\ingroup SparseCholesky_Module\n  * \\class SimplicialLLT\n  * \\brief A direct sparse LLT Cholesky factorizations\n  *\n  * This class provides a LL^T Cholesky factorizations of sparse matrices that are\n  * selfadjoint and positive definite. The factorization allows for solving A.X = B where\n  * X and B can be either dense or sparse.\n  * \n  * In order to reduce the fill-in, a symmetric permutation P is applied prior to the factorization\n  * such that the factorized matrix is P A P^-1.\n  *\n  * \\tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  * \\tparam _UpLo the triangular part that will be used for the computations. It can be Lower\n  *               or Upper. Default is Lower.\n  * \\tparam _Ordering The ordering method to use, either AMDOrdering<> or NaturalOrdering<>. Default is AMDOrdering<>\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa class SimplicialLDLT, class AMDOrdering, class NaturalOrdering\n  */\ntemplate<typename _MatrixType, int _UpLo, typename _Ordering>\n    class SimplicialLLT : public SimplicialCholeskyBase<SimplicialLLT<_MatrixType,_UpLo,_Ordering> >\n{\npublic:\n    typedef _MatrixType MatrixType;\n    enum { UpLo = _UpLo };\n    typedef SimplicialCholeskyBase<SimplicialLLT> Base;\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef SparseMatrix<Scalar,ColMajor,Index> CholMatrixType;\n    typedef Matrix<Scalar,Dynamic,1> VectorType;\n    typedef internal::traits<SimplicialLLT> Traits;\n    typedef typename Traits::MatrixL  MatrixL;\n    typedef typename Traits::MatrixU  MatrixU;\npublic:\n    /** Default constructor */\n    SimplicialLLT() : Base() {}\n    /** Constructs and performs the LLT factorization of \\a matrix */\n    explicit SimplicialLLT(const MatrixType& matrix)\n        : Base(matrix) {}\n\n    /** \\returns an expression of the factor L */\n    inline const MatrixL matrixL() const {\n        eigen_assert(Base::m_factorizationIsOk && \"Simplicial LLT not factorized\");\n        return Traits::getL(Base::m_matrix);\n    }\n\n    /** \\returns an expression of the factor U (= L^*) */\n    inline const MatrixU matrixU() const {\n        eigen_assert(Base::m_factorizationIsOk && \"Simplicial LLT not factorized\");\n        return Traits::getU(Base::m_matrix);\n    }\n    \n    /** Computes the sparse Cholesky decomposition of \\a matrix */\n    SimplicialLLT& compute(const MatrixType& matrix)\n    {\n      Base::template compute<false>(matrix);\n      return *this;\n    }\n\n    /** Performs a symbolic decomposition on the sparcity of \\a matrix.\n      *\n      * This function is particularly useful when solving for several problems having the same structure.\n      *\n      * \\sa factorize()\n      */\n    void analyzePattern(const MatrixType& a)\n    {\n      Base::analyzePattern(a, false);\n    }\n\n    /** Performs a numeric decomposition of \\a matrix\n      *\n      * The given matrix must has the same sparcity than the matrix on which the symbolic decomposition has been performed.\n      *\n      * \\sa analyzePattern()\n      */\n    void factorize(const MatrixType& a)\n    {\n      Base::template factorize<false>(a);\n    }\n\n    /** \\returns the determinant of the underlying matrix from the current factorization */\n    Scalar determinant() const\n    {\n      Scalar detL = Base::m_matrix.diagonal().prod();\n      return numext::abs2(detL);\n    }\n};\n\n/** \\ingroup SparseCholesky_Module\n  * \\class SimplicialLDLT\n  * \\brief A direct sparse LDLT Cholesky factorizations without square root.\n  *\n  * This class provides a LDL^T Cholesky factorizations without square root of sparse matrices that are\n  * selfadjoint and positive definite. The factorization allows for solving A.X = B where\n  * X and B can be either dense or sparse.\n  * \n  * In order to reduce the fill-in, a symmetric permutation P is applied prior to the factorization\n  * such that the factorized matrix is P A P^-1.\n  *\n  * \\tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  * \\tparam _UpLo the triangular part that will be used for the computations. It can be Lower\n  *               or Upper. Default is Lower.\n  * \\tparam _Ordering The ordering method to use, either AMDOrdering<> or NaturalOrdering<>. Default is AMDOrdering<>\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa class SimplicialLLT, class AMDOrdering, class NaturalOrdering\n  */\ntemplate<typename _MatrixType, int _UpLo, typename _Ordering>\n    class SimplicialLDLT : public SimplicialCholeskyBase<SimplicialLDLT<_MatrixType,_UpLo,_Ordering> >\n{\npublic:\n    typedef _MatrixType MatrixType;\n    enum { UpLo = _UpLo };\n    typedef SimplicialCholeskyBase<SimplicialLDLT> Base;\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef SparseMatrix<Scalar,ColMajor,StorageIndex> CholMatrixType;\n    typedef Matrix<Scalar,Dynamic,1> VectorType;\n    typedef internal::traits<SimplicialLDLT> Traits;\n    typedef typename Traits::MatrixL  MatrixL;\n    typedef typename Traits::MatrixU  MatrixU;\npublic:\n    /** Default constructor */\n    SimplicialLDLT() : Base() {}\n\n    /** Constructs and performs the LLT factorization of \\a matrix */\n    explicit SimplicialLDLT(const MatrixType& matrix)\n        : Base(matrix) {}\n\n    /** \\returns a vector expression of the diagonal D */\n    inline const VectorType vectorD() const {\n        eigen_assert(Base::m_factorizationIsOk && \"Simplicial LDLT not factorized\");\n        return Base::m_diag;\n    }\n    /** \\returns an expression of the factor L */\n    inline const MatrixL matrixL() const {\n        eigen_assert(Base::m_factorizationIsOk && \"Simplicial LDLT not factorized\");\n        return Traits::getL(Base::m_matrix);\n    }\n\n    /** \\returns an expression of the factor U (= L^*) */\n    inline const MatrixU matrixU() const {\n        eigen_assert(Base::m_factorizationIsOk && \"Simplicial LDLT not factorized\");\n        return Traits::getU(Base::m_matrix);\n    }\n\n    /** Computes the sparse Cholesky decomposition of \\a matrix */\n    SimplicialLDLT& compute(const MatrixType& matrix)\n    {\n      Base::template compute<true>(matrix);\n      return *this;\n    }\n    \n    /** Performs a symbolic decomposition on the sparcity of \\a matrix.\n      *\n      * This function is particularly useful when solving for several problems having the same structure.\n      *\n      * \\sa factorize()\n      */\n    void analyzePattern(const MatrixType& a)\n    {\n      Base::analyzePattern(a, true);\n    }\n\n    /** Performs a numeric decomposition of \\a matrix\n      *\n      * The given matrix must has the same sparcity than the matrix on which the symbolic decomposition has been performed.\n      *\n      * \\sa analyzePattern()\n      */\n    void factorize(const MatrixType& a)\n    {\n      Base::template factorize<true>(a);\n    }\n\n    /** \\returns the determinant of the underlying matrix from the current factorization */\n    Scalar determinant() const\n    {\n      return Base::m_diag.prod();\n    }\n};\n\n/** \\deprecated use SimplicialLDLT or class SimplicialLLT\n  * \\ingroup SparseCholesky_Module\n  * \\class SimplicialCholesky\n  *\n  * \\sa class SimplicialLDLT, class SimplicialLLT\n  */\ntemplate<typename _MatrixType, int _UpLo, typename _Ordering>\n    class SimplicialCholesky : public SimplicialCholeskyBase<SimplicialCholesky<_MatrixType,_UpLo,_Ordering> >\n{\npublic:\n    typedef _MatrixType MatrixType;\n    enum { UpLo = _UpLo };\n    typedef SimplicialCholeskyBase<SimplicialCholesky> Base;\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef SparseMatrix<Scalar,ColMajor,StorageIndex> CholMatrixType;\n    typedef Matrix<Scalar,Dynamic,1> VectorType;\n    typedef internal::traits<SimplicialCholesky> Traits;\n    typedef internal::traits<SimplicialLDLT<MatrixType,UpLo> > LDLTTraits;\n    typedef internal::traits<SimplicialLLT<MatrixType,UpLo>  > LLTTraits;\n  public:\n    SimplicialCholesky() : Base(), m_LDLT(true) {}\n\n    explicit SimplicialCholesky(const MatrixType& matrix)\n      : Base(), m_LDLT(true)\n    {\n      compute(matrix);\n    }\n\n    SimplicialCholesky& setMode(SimplicialCholeskyMode mode)\n    {\n      switch(mode)\n      {\n      case SimplicialCholeskyLLT:\n        m_LDLT = false;\n        break;\n      case SimplicialCholeskyLDLT:\n        m_LDLT = true;\n        break;\n      default:\n        break;\n      }\n\n      return *this;\n    }\n\n    inline const VectorType vectorD() const {\n        eigen_assert(Base::m_factorizationIsOk && \"Simplicial Cholesky not factorized\");\n        return Base::m_diag;\n    }\n    inline const CholMatrixType rawMatrix() const {\n        eigen_assert(Base::m_factorizationIsOk && \"Simplicial Cholesky not factorized\");\n        return Base::m_matrix;\n    }\n    \n    /** Computes the sparse Cholesky decomposition of \\a matrix */\n    SimplicialCholesky& compute(const MatrixType& matrix)\n    {\n      if(m_LDLT)\n        Base::template compute<true>(matrix);\n      else\n        Base::template compute<false>(matrix);\n      return *this;\n    }\n\n    /** Performs a symbolic decomposition on the sparcity of \\a matrix.\n      *\n      * This function is particularly useful when solving for several problems having the same structure.\n      *\n      * \\sa factorize()\n      */\n    void analyzePattern(const MatrixType& a)\n    {\n      Base::analyzePattern(a, m_LDLT);\n    }\n\n    /** Performs a numeric decomposition of \\a matrix\n      *\n      * The given matrix must has the same sparcity than the matrix on which the symbolic decomposition has been performed.\n      *\n      * \\sa analyzePattern()\n      */\n    void factorize(const MatrixType& a)\n    {\n      if(m_LDLT)\n        Base::template factorize<true>(a);\n      else\n        Base::template factorize<false>(a);\n    }\n\n    /** \\internal */\n    template<typename Rhs,typename Dest>\n    void _solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &dest) const\n    {\n      eigen_assert(Base::m_factorizationIsOk && \"The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()\");\n      eigen_assert(Base::m_matrix.rows()==b.rows());\n\n      if(Base::m_info!=Success)\n        return;\n\n      if(Base::m_P.size()>0)\n        dest = Base::m_P * b;\n      else\n        dest = b;\n\n      if(Base::m_matrix.nonZeros()>0) // otherwise L==I\n      {\n        if(m_LDLT)\n          LDLTTraits::getL(Base::m_matrix).solveInPlace(dest);\n        else\n          LLTTraits::getL(Base::m_matrix).solveInPlace(dest);\n      }\n\n      if(Base::m_diag.size()>0)\n        dest = Base::m_diag.asDiagonal().inverse() * dest;\n\n      if (Base::m_matrix.nonZeros()>0) // otherwise I==I\n      {\n        if(m_LDLT)\n          LDLTTraits::getU(Base::m_matrix).solveInPlace(dest);\n        else\n          LLTTraits::getU(Base::m_matrix).solveInPlace(dest);\n      }\n\n      if(Base::m_P.size()>0)\n        dest = Base::m_Pinv * dest;\n    }\n    \n    /** \\internal */\n    template<typename Rhs,typename Dest>\n    void _solve_impl(const SparseMatrixBase<Rhs> &b, SparseMatrixBase<Dest> &dest) const\n    {\n      internal::solve_sparse_through_dense_panels(*this, b, dest);\n    }\n    \n    Scalar determinant() const\n    {\n      if(m_LDLT)\n      {\n        return Base::m_diag.prod();\n      }\n      else\n      {\n        Scalar detL = Diagonal<const CholMatrixType>(Base::m_matrix).prod();\n        return numext::abs2(detL);\n      }\n    }\n    \n  protected:\n    bool m_LDLT;\n};\n\ntemplate<typename Derived>\nvoid SimplicialCholeskyBase<Derived>::ordering(const MatrixType& a, ConstCholMatrixPtr &pmat, CholMatrixType& ap)\n{\n  eigen_assert(a.rows()==a.cols());\n  const Index size = a.rows();\n  pmat = &ap;\n  // Note that ordering methods compute the inverse permutation\n  if(!internal::is_same<OrderingType,NaturalOrdering<Index> >::value)\n  {\n    {\n      CholMatrixType C;\n      C = a.template selfadjointView<UpLo>();\n      \n      OrderingType ordering;\n      ordering(C,m_Pinv);\n    }\n\n    if(m_Pinv.size()>0) m_P = m_Pinv.inverse();\n    else                m_P.resize(0);\n    \n    ap.resize(size,size);\n    ap.template selfadjointView<Upper>() = a.template selfadjointView<UpLo>().twistedBy(m_P);\n  }\n  else\n  {\n    m_Pinv.resize(0);\n    m_P.resize(0);\n    if(int(UpLo)==int(Lower) || MatrixType::IsRowMajor)\n    {\n      // we have to transpose the lower part to to the upper one\n      ap.resize(size,size);\n      ap.template selfadjointView<Upper>() = a.template selfadjointView<UpLo>();\n    }\n    else\n      internal::simplicial_cholesky_grab_input<CholMatrixType,MatrixType>::run(a, pmat, ap);\n  }  \n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SIMPLICIAL_CHOLESKY_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2012 Gael Guennebaud <gael.guennebaud@inria.fr>\n\n/*\n\nNOTE: thes functions vave been adapted from the LDL library:\n\nLDL Copyright (c) 2005 by Timothy A. Davis.  All Rights Reserved.\n\nLDL License:\n\n    Your use or distribution of LDL or any modified version of\n    LDL implies that you agree to this License.\n\n    This library is free software; you can redistribute it and/or\n    modify it under the terms of the GNU Lesser General Public\n    License as published by the Free Software Foundation; either\n    version 2.1 of the License, or (at your option) any later version.\n\n    This library is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public\n    License along with this library; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301\n    USA\n\n    Permission is hereby granted to use or copy this program under the\n    terms of the GNU LGPL, provided that the Copyright, this License,\n    and the Availability of the original version is retained on all copies.\n    User documentation of any code that uses this code or any modified\n    version of this code must cite the Copyright, this License, the\n    Availability note, and \"Used by permission.\" Permission to modify\n    the code and to distribute modified code is granted, provided the\n    Copyright, this License, and the Availability note are retained,\n    and a notice that the code was modified is included.\n */\n\n#include \"../Core/util/NonMPL2.h\"\n\n#ifndef EIGEN_SIMPLICIAL_CHOLESKY_IMPL_H\n#define EIGEN_SIMPLICIAL_CHOLESKY_IMPL_H\n\nnamespace Eigen {\n\ntemplate<typename Derived>\nvoid SimplicialCholeskyBase<Derived>::analyzePattern_preordered(const CholMatrixType& ap, bool doLDLT)\n{\n  const StorageIndex size = StorageIndex(ap.rows());\n  m_matrix.resize(size, size);\n  m_parent.resize(size);\n  m_nonZerosPerCol.resize(size);\n\n  ei_declare_aligned_stack_constructed_variable(StorageIndex, tags, size, 0);\n\n  for(StorageIndex k = 0; k < size; ++k)\n  {\n    /* L(k,:) pattern: all nodes reachable in etree from nz in A(0:k-1,k) */\n    m_parent[k] = -1;             /* parent of k is not yet known */\n    tags[k] = k;                  /* mark node k as visited */\n    m_nonZerosPerCol[k] = 0;      /* count of nonzeros in column k of L */\n    for(typename CholMatrixType::InnerIterator it(ap,k); it; ++it)\n    {\n      StorageIndex i = it.index();\n      if(i < k)\n      {\n        /* follow path from i to root of etree, stop at flagged node */\n        for(; tags[i] != k; i = m_parent[i])\n        {\n          /* find parent of i if not yet determined */\n          if (m_parent[i] == -1)\n            m_parent[i] = k;\n          m_nonZerosPerCol[i]++;        /* L (k,i) is nonzero */\n          tags[i] = k;                  /* mark i as visited */\n        }\n      }\n    }\n  }\n\n  /* construct Lp index array from m_nonZerosPerCol column counts */\n  StorageIndex* Lp = m_matrix.outerIndexPtr();\n  Lp[0] = 0;\n  for(StorageIndex k = 0; k < size; ++k)\n    Lp[k+1] = Lp[k] + m_nonZerosPerCol[k] + (doLDLT ? 0 : 1);\n\n  m_matrix.resizeNonZeros(Lp[size]);\n\n  m_isInitialized     = true;\n  m_info              = Success;\n  m_analysisIsOk      = true;\n  m_factorizationIsOk = false;\n}\n\n\ntemplate<typename Derived>\ntemplate<bool DoLDLT>\nvoid SimplicialCholeskyBase<Derived>::factorize_preordered(const CholMatrixType& ap)\n{\n  using std::sqrt;\n\n  eigen_assert(m_analysisIsOk && \"You must first call analyzePattern()\");\n  eigen_assert(ap.rows()==ap.cols());\n  eigen_assert(m_parent.size()==ap.rows());\n  eigen_assert(m_nonZerosPerCol.size()==ap.rows());\n\n  const StorageIndex size = StorageIndex(ap.rows());\n  const StorageIndex* Lp = m_matrix.outerIndexPtr();\n  StorageIndex* Li = m_matrix.innerIndexPtr();\n  Scalar* Lx = m_matrix.valuePtr();\n\n  ei_declare_aligned_stack_constructed_variable(Scalar, y, size, 0);\n  ei_declare_aligned_stack_constructed_variable(StorageIndex,  pattern, size, 0);\n  ei_declare_aligned_stack_constructed_variable(StorageIndex,  tags, size, 0);\n\n  bool ok = true;\n  m_diag.resize(DoLDLT ? size : 0);\n\n  for(StorageIndex k = 0; k < size; ++k)\n  {\n    // compute nonzero pattern of kth row of L, in topological order\n    y[k] = 0.0;                     // Y(0:k) is now all zero\n    StorageIndex top = size;               // stack for pattern is empty\n    tags[k] = k;                    // mark node k as visited\n    m_nonZerosPerCol[k] = 0;        // count of nonzeros in column k of L\n    for(typename CholMatrixType::InnerIterator it(ap,k); it; ++it)\n    {\n      StorageIndex i = it.index();\n      if(i <= k)\n      {\n        y[i] += numext::conj(it.value());            /* scatter A(i,k) into Y (sum duplicates) */\n        Index len;\n        for(len = 0; tags[i] != k; i = m_parent[i])\n        {\n          pattern[len++] = i;     /* L(k,i) is nonzero */\n          tags[i] = k;            /* mark i as visited */\n        }\n        while(len > 0)\n          pattern[--top] = pattern[--len];\n      }\n    }\n\n    /* compute numerical values kth row of L (a sparse triangular solve) */\n\n    RealScalar d = numext::real(y[k]) * m_shiftScale + m_shiftOffset;    // get D(k,k), apply the shift function, and clear Y(k)\n    y[k] = 0.0;\n    for(; top < size; ++top)\n    {\n      Index i = pattern[top];       /* pattern[top:n-1] is pattern of L(:,k) */\n      Scalar yi = y[i];             /* get and clear Y(i) */\n      y[i] = 0.0;\n\n      /* the nonzero entry L(k,i) */\n      Scalar l_ki;\n      if(DoLDLT)\n        l_ki = yi / m_diag[i];\n      else\n        yi = l_ki = yi / Lx[Lp[i]];\n\n      Index p2 = Lp[i] + m_nonZerosPerCol[i];\n      Index p;\n      for(p = Lp[i] + (DoLDLT ? 0 : 1); p < p2; ++p)\n        y[Li[p]] -= numext::conj(Lx[p]) * yi;\n      d -= numext::real(l_ki * numext::conj(yi));\n      Li[p] = k;                          /* store L(k,i) in column form of L */\n      Lx[p] = l_ki;\n      ++m_nonZerosPerCol[i];              /* increment count of nonzeros in col i */\n    }\n    if(DoLDLT)\n    {\n      m_diag[k] = d;\n      if(d == RealScalar(0))\n      {\n        ok = false;                         /* failure, D(k,k) is zero */\n        break;\n      }\n    }\n    else\n    {\n      Index p = Lp[k] + m_nonZerosPerCol[k]++;\n      Li[p] = k ;                /* store L(k,k) = sqrt (d) in column k */\n      if(d <= RealScalar(0)) {\n        ok = false;              /* failure, matrix is not positive definite */\n        break;\n      }\n      Lx[p] = sqrt(d) ;\n    }\n  }\n\n  m_info = ok ? Success : NumericalIssue;\n  m_factorizationIsOk = true;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SIMPLICIAL_CHOLESKY_IMPL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/AmbiVector.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_AMBIVECTOR_H\n#define EIGEN_AMBIVECTOR_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/** \\internal\n  * Hybrid sparse/dense vector class designed for intensive read-write operations.\n  *\n  * See BasicSparseLLT and SparseProduct for usage examples.\n  */\ntemplate<typename _Scalar, typename _StorageIndex>\nclass AmbiVector\n{\n  public:\n    typedef _Scalar Scalar;\n    typedef _StorageIndex StorageIndex;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n\n    explicit AmbiVector(Index size)\n      : m_buffer(0), m_zero(0), m_size(0), m_allocatedSize(0), m_allocatedElements(0), m_mode(-1)\n    {\n      resize(size);\n    }\n\n    void init(double estimatedDensity);\n    void init(int mode);\n\n    Index nonZeros() const;\n\n    /** Specifies a sub-vector to work on */\n    void setBounds(Index start, Index end) { m_start = convert_index(start); m_end = convert_index(end); }\n\n    void setZero();\n\n    void restart();\n    Scalar& coeffRef(Index i);\n    Scalar& coeff(Index i);\n\n    class Iterator;\n\n    ~AmbiVector() { delete[] m_buffer; }\n\n    void resize(Index size)\n    {\n      if (m_allocatedSize < size)\n        reallocate(size);\n      m_size = convert_index(size);\n    }\n\n    StorageIndex size() const { return m_size; }\n\n  protected:\n    StorageIndex convert_index(Index idx)\n    {\n      return internal::convert_index<StorageIndex>(idx);\n    }\n\n    void reallocate(Index size)\n    {\n      // if the size of the matrix is not too large, let's allocate a bit more than needed such\n      // that we can handle dense vector even in sparse mode.\n      delete[] m_buffer;\n      if (size<1000)\n      {\n        Index allocSize = (size * sizeof(ListEl) + sizeof(Scalar) - 1)/sizeof(Scalar);\n        m_allocatedElements = convert_index((allocSize*sizeof(Scalar))/sizeof(ListEl));\n        m_buffer = new Scalar[allocSize];\n      }\n      else\n      {\n        m_allocatedElements = convert_index((size*sizeof(Scalar))/sizeof(ListEl));\n        m_buffer = new Scalar[size];\n      }\n      m_size = convert_index(size);\n      m_start = 0;\n      m_end = m_size;\n    }\n\n    void reallocateSparse()\n    {\n      Index copyElements = m_allocatedElements;\n      m_allocatedElements = (std::min)(StorageIndex(m_allocatedElements*1.5),m_size);\n      Index allocSize = m_allocatedElements * sizeof(ListEl);\n      allocSize = (allocSize + sizeof(Scalar) - 1)/sizeof(Scalar);\n      Scalar* newBuffer = new Scalar[allocSize];\n      memcpy(newBuffer,  m_buffer,  copyElements * sizeof(ListEl));\n      delete[] m_buffer;\n      m_buffer = newBuffer;\n    }\n\n  protected:\n    // element type of the linked list\n    struct ListEl\n    {\n      StorageIndex next;\n      StorageIndex index;\n      Scalar value;\n    };\n\n    // used to store data in both mode\n    Scalar* m_buffer;\n    Scalar m_zero;\n    StorageIndex m_size;\n    StorageIndex m_start;\n    StorageIndex m_end;\n    StorageIndex m_allocatedSize;\n    StorageIndex m_allocatedElements;\n    StorageIndex m_mode;\n\n    // linked list mode\n    StorageIndex m_llStart;\n    StorageIndex m_llCurrent;\n    StorageIndex m_llSize;\n};\n\n/** \\returns the number of non zeros in the current sub vector */\ntemplate<typename _Scalar,typename _StorageIndex>\nIndex AmbiVector<_Scalar,_StorageIndex>::nonZeros() const\n{\n  if (m_mode==IsSparse)\n    return m_llSize;\n  else\n    return m_end - m_start;\n}\n\ntemplate<typename _Scalar,typename _StorageIndex>\nvoid AmbiVector<_Scalar,_StorageIndex>::init(double estimatedDensity)\n{\n  if (estimatedDensity>0.1)\n    init(IsDense);\n  else\n    init(IsSparse);\n}\n\ntemplate<typename _Scalar,typename _StorageIndex>\nvoid AmbiVector<_Scalar,_StorageIndex>::init(int mode)\n{\n  m_mode = mode;\n  if (m_mode==IsSparse)\n  {\n    m_llSize = 0;\n    m_llStart = -1;\n  }\n}\n\n/** Must be called whenever we might perform a write access\n  * with an index smaller than the previous one.\n  *\n  * Don't worry, this function is extremely cheap.\n  */\ntemplate<typename _Scalar,typename _StorageIndex>\nvoid AmbiVector<_Scalar,_StorageIndex>::restart()\n{\n  m_llCurrent = m_llStart;\n}\n\n/** Set all coefficients of current subvector to zero */\ntemplate<typename _Scalar,typename _StorageIndex>\nvoid AmbiVector<_Scalar,_StorageIndex>::setZero()\n{\n  if (m_mode==IsDense)\n  {\n    for (Index i=m_start; i<m_end; ++i)\n      m_buffer[i] = Scalar(0);\n  }\n  else\n  {\n    eigen_assert(m_mode==IsSparse);\n    m_llSize = 0;\n    m_llStart = -1;\n  }\n}\n\ntemplate<typename _Scalar,typename _StorageIndex>\n_Scalar& AmbiVector<_Scalar,_StorageIndex>::coeffRef(Index i)\n{\n  if (m_mode==IsDense)\n    return m_buffer[i];\n  else\n  {\n    ListEl* EIGEN_RESTRICT llElements = reinterpret_cast<ListEl*>(m_buffer);\n    // TODO factorize the following code to reduce code generation\n    eigen_assert(m_mode==IsSparse);\n    if (m_llSize==0)\n    {\n      // this is the first element\n      m_llStart = 0;\n      m_llCurrent = 0;\n      ++m_llSize;\n      llElements[0].value = Scalar(0);\n      llElements[0].index = convert_index(i);\n      llElements[0].next = -1;\n      return llElements[0].value;\n    }\n    else if (i<llElements[m_llStart].index)\n    {\n      // this is going to be the new first element of the list\n      ListEl& el = llElements[m_llSize];\n      el.value = Scalar(0);\n      el.index = convert_index(i);\n      el.next = m_llStart;\n      m_llStart = m_llSize;\n      ++m_llSize;\n      m_llCurrent = m_llStart;\n      return el.value;\n    }\n    else\n    {\n      StorageIndex nextel = llElements[m_llCurrent].next;\n      eigen_assert(i>=llElements[m_llCurrent].index && \"you must call restart() before inserting an element with lower or equal index\");\n      while (nextel >= 0 && llElements[nextel].index<=i)\n      {\n        m_llCurrent = nextel;\n        nextel = llElements[nextel].next;\n      }\n\n      if (llElements[m_llCurrent].index==i)\n      {\n        // the coefficient already exists and we found it !\n        return llElements[m_llCurrent].value;\n      }\n      else\n      {\n        if (m_llSize>=m_allocatedElements)\n        {\n          reallocateSparse();\n          llElements = reinterpret_cast<ListEl*>(m_buffer);\n        }\n        eigen_internal_assert(m_llSize<m_allocatedElements && \"internal error: overflow in sparse mode\");\n        // let's insert a new coefficient\n        ListEl& el = llElements[m_llSize];\n        el.value = Scalar(0);\n        el.index = convert_index(i);\n        el.next = llElements[m_llCurrent].next;\n        llElements[m_llCurrent].next = m_llSize;\n        ++m_llSize;\n        return el.value;\n      }\n    }\n  }\n}\n\ntemplate<typename _Scalar,typename _StorageIndex>\n_Scalar& AmbiVector<_Scalar,_StorageIndex>::coeff(Index i)\n{\n  if (m_mode==IsDense)\n    return m_buffer[i];\n  else\n  {\n    ListEl* EIGEN_RESTRICT llElements = reinterpret_cast<ListEl*>(m_buffer);\n    eigen_assert(m_mode==IsSparse);\n    if ((m_llSize==0) || (i<llElements[m_llStart].index))\n    {\n      return m_zero;\n    }\n    else\n    {\n      Index elid = m_llStart;\n      while (elid >= 0 && llElements[elid].index<i)\n        elid = llElements[elid].next;\n\n      if (llElements[elid].index==i)\n        return llElements[m_llCurrent].value;\n      else\n        return m_zero;\n    }\n  }\n}\n\n/** Iterator over the nonzero coefficients */\ntemplate<typename _Scalar,typename _StorageIndex>\nclass AmbiVector<_Scalar,_StorageIndex>::Iterator\n{\n  public:\n    typedef _Scalar Scalar;\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n\n    /** Default constructor\n      * \\param vec the vector on which we iterate\n      * \\param epsilon the minimal value used to prune zero coefficients.\n      * In practice, all coefficients having a magnitude smaller than \\a epsilon\n      * are skipped.\n      */\n    explicit Iterator(const AmbiVector& vec, const RealScalar& epsilon = 0)\n      : m_vector(vec)\n    {\n      using std::abs;\n      m_epsilon = epsilon;\n      m_isDense = m_vector.m_mode==IsDense;\n      if (m_isDense)\n      {\n        m_currentEl = 0;   // this is to avoid a compilation warning\n        m_cachedValue = 0; // this is to avoid a compilation warning\n        m_cachedIndex = m_vector.m_start-1;\n        ++(*this);\n      }\n      else\n      {\n        ListEl* EIGEN_RESTRICT llElements = reinterpret_cast<ListEl*>(m_vector.m_buffer);\n        m_currentEl = m_vector.m_llStart;\n        while (m_currentEl>=0 && abs(llElements[m_currentEl].value)<=m_epsilon)\n          m_currentEl = llElements[m_currentEl].next;\n        if (m_currentEl<0)\n        {\n          m_cachedValue = 0; // this is to avoid a compilation warning\n          m_cachedIndex = -1;\n        }\n        else\n        {\n          m_cachedIndex = llElements[m_currentEl].index;\n          m_cachedValue = llElements[m_currentEl].value;\n        }\n      }\n    }\n\n    StorageIndex index() const { return m_cachedIndex; }\n    Scalar value() const { return m_cachedValue; }\n\n    operator bool() const { return m_cachedIndex>=0; }\n\n    Iterator& operator++()\n    {\n      using std::abs;\n      if (m_isDense)\n      {\n        do {\n          ++m_cachedIndex;\n        } while (m_cachedIndex<m_vector.m_end && abs(m_vector.m_buffer[m_cachedIndex])<=m_epsilon);\n        if (m_cachedIndex<m_vector.m_end)\n          m_cachedValue = m_vector.m_buffer[m_cachedIndex];\n        else\n          m_cachedIndex=-1;\n      }\n      else\n      {\n        ListEl* EIGEN_RESTRICT llElements = reinterpret_cast<ListEl*>(m_vector.m_buffer);\n        do {\n          m_currentEl = llElements[m_currentEl].next;\n        } while (m_currentEl>=0 && abs(llElements[m_currentEl].value)<=m_epsilon);\n        if (m_currentEl<0)\n        {\n          m_cachedIndex = -1;\n        }\n        else\n        {\n          m_cachedIndex = llElements[m_currentEl].index;\n          m_cachedValue = llElements[m_currentEl].value;\n        }\n      }\n      return *this;\n    }\n\n  protected:\n    const AmbiVector& m_vector; // the target vector\n    StorageIndex m_currentEl;   // the current element in sparse/linked-list mode\n    RealScalar m_epsilon;       // epsilon used to prune zero coefficients\n    StorageIndex m_cachedIndex; // current coordinate\n    Scalar m_cachedValue;       // current value\n    bool m_isDense;             // mode of the vector\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_AMBIVECTOR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/CompressedStorage.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_COMPRESSED_STORAGE_H\n#define EIGEN_COMPRESSED_STORAGE_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/** \\internal\n  * Stores a sparse set of values as a list of values and a list of indices.\n  *\n  */\ntemplate<typename _Scalar,typename _StorageIndex>\nclass CompressedStorage\n{\n  public:\n\n    typedef _Scalar Scalar;\n    typedef _StorageIndex StorageIndex;\n\n  protected:\n\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n\n  public:\n\n    CompressedStorage()\n      : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0)\n    {}\n\n    explicit CompressedStorage(Index size)\n      : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0)\n    {\n      resize(size);\n    }\n\n    CompressedStorage(const CompressedStorage& other)\n      : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0)\n    {\n      *this = other;\n    }\n\n    CompressedStorage& operator=(const CompressedStorage& other)\n    {\n      resize(other.size());\n      if(other.size()>0)\n      {\n        internal::smart_copy(other.m_values,  other.m_values  + m_size, m_values);\n        internal::smart_copy(other.m_indices, other.m_indices + m_size, m_indices);\n      }\n      return *this;\n    }\n\n    void swap(CompressedStorage& other)\n    {\n      std::swap(m_values, other.m_values);\n      std::swap(m_indices, other.m_indices);\n      std::swap(m_size, other.m_size);\n      std::swap(m_allocatedSize, other.m_allocatedSize);\n    }\n\n    ~CompressedStorage()\n    {\n      delete[] m_values;\n      delete[] m_indices;\n    }\n\n    void reserve(Index size)\n    {\n      Index newAllocatedSize = m_size + size;\n      if (newAllocatedSize > m_allocatedSize)\n        reallocate(newAllocatedSize);\n    }\n\n    void squeeze()\n    {\n      if (m_allocatedSize>m_size)\n        reallocate(m_size);\n    }\n\n    void resize(Index size, double reserveSizeFactor = 0)\n    {\n      if (m_allocatedSize<size)\n      {\n        Index realloc_size = (std::min<Index>)(NumTraits<StorageIndex>::highest(),  size + Index(reserveSizeFactor*double(size)));\n        if(realloc_size<size)\n          internal::throw_std_bad_alloc();\n        reallocate(realloc_size);\n      }\n      m_size = size;\n    }\n\n    void append(const Scalar& v, Index i)\n    {\n      Index id = m_size;\n      resize(m_size+1, 1);\n      m_values[id] = v;\n      m_indices[id] = internal::convert_index<StorageIndex>(i);\n    }\n\n    inline Index size() const { return m_size; }\n    inline Index allocatedSize() const { return m_allocatedSize; }\n    inline void clear() { m_size = 0; }\n\n    const Scalar* valuePtr() const { return m_values; }\n    Scalar* valuePtr() { return m_values; }\n    const StorageIndex* indexPtr() const { return m_indices; }\n    StorageIndex* indexPtr() { return m_indices; }\n\n    inline Scalar& value(Index i) { eigen_internal_assert(m_values!=0); return m_values[i]; }\n    inline const Scalar& value(Index i) const { eigen_internal_assert(m_values!=0); return m_values[i]; }\n\n    inline StorageIndex& index(Index i) { eigen_internal_assert(m_indices!=0); return m_indices[i]; }\n    inline const StorageIndex& index(Index i) const { eigen_internal_assert(m_indices!=0); return m_indices[i]; }\n\n    /** \\returns the largest \\c k such that for all \\c j in [0,k) index[\\c j]\\<\\a key */\n    inline Index searchLowerIndex(Index key) const\n    {\n      return searchLowerIndex(0, m_size, key);\n    }\n\n    /** \\returns the largest \\c k in [start,end) such that for all \\c j in [start,k) index[\\c j]\\<\\a key */\n    inline Index searchLowerIndex(Index start, Index end, Index key) const\n    {\n      while(end>start)\n      {\n        Index mid = (end+start)>>1;\n        if (m_indices[mid]<key)\n          start = mid+1;\n        else\n          end = mid;\n      }\n      return start;\n    }\n\n    /** \\returns the stored value at index \\a key\n      * If the value does not exist, then the value \\a defaultValue is returned without any insertion. */\n    inline Scalar at(Index key, const Scalar& defaultValue = Scalar(0)) const\n    {\n      if (m_size==0)\n        return defaultValue;\n      else if (key==m_indices[m_size-1])\n        return m_values[m_size-1];\n      // ^^  optimization: let's first check if it is the last coefficient\n      // (very common in high level algorithms)\n      const Index id = searchLowerIndex(0,m_size-1,key);\n      return ((id<m_size) && (m_indices[id]==key)) ? m_values[id] : defaultValue;\n    }\n\n    /** Like at(), but the search is performed in the range [start,end) */\n    inline Scalar atInRange(Index start, Index end, Index key, const Scalar &defaultValue = Scalar(0)) const\n    {\n      if (start>=end)\n        return defaultValue;\n      else if (end>start && key==m_indices[end-1])\n        return m_values[end-1];\n      // ^^  optimization: let's first check if it is the last coefficient\n      // (very common in high level algorithms)\n      const Index id = searchLowerIndex(start,end-1,key);\n      return ((id<end) && (m_indices[id]==key)) ? m_values[id] : defaultValue;\n    }\n\n    /** \\returns a reference to the value at index \\a key\n      * If the value does not exist, then the value \\a defaultValue is inserted\n      * such that the keys are sorted. */\n    inline Scalar& atWithInsertion(Index key, const Scalar& defaultValue = Scalar(0))\n    {\n      Index id = searchLowerIndex(0,m_size,key);\n      if (id>=m_size || m_indices[id]!=key)\n      {\n        if (m_allocatedSize<m_size+1)\n        {\n          m_allocatedSize = 2*(m_size+1);\n          internal::scoped_array<Scalar> newValues(m_allocatedSize);\n          internal::scoped_array<StorageIndex> newIndices(m_allocatedSize);\n\n          // copy first chunk\n          internal::smart_copy(m_values,  m_values +id, newValues.ptr());\n          internal::smart_copy(m_indices, m_indices+id, newIndices.ptr());\n\n          // copy the rest\n          if(m_size>id)\n          {\n            internal::smart_copy(m_values +id,  m_values +m_size, newValues.ptr() +id+1);\n            internal::smart_copy(m_indices+id,  m_indices+m_size, newIndices.ptr()+id+1);\n          }\n          std::swap(m_values,newValues.ptr());\n          std::swap(m_indices,newIndices.ptr());\n        }\n        else if(m_size>id)\n        {\n          internal::smart_memmove(m_values +id, m_values +m_size, m_values +id+1);\n          internal::smart_memmove(m_indices+id, m_indices+m_size, m_indices+id+1);\n        }\n        m_size++;\n        m_indices[id] = internal::convert_index<StorageIndex>(key);\n        m_values[id] = defaultValue;\n      }\n      return m_values[id];\n    }\n\n    void prune(const Scalar& reference, const RealScalar& epsilon = NumTraits<RealScalar>::dummy_precision())\n    {\n      Index k = 0;\n      Index n = size();\n      for (Index i=0; i<n; ++i)\n      {\n        if (!internal::isMuchSmallerThan(value(i), reference, epsilon))\n        {\n          value(k) = value(i);\n          index(k) = index(i);\n          ++k;\n        }\n      }\n      resize(k,0);\n    }\n\n  protected:\n\n    inline void reallocate(Index size)\n    {\n      #ifdef EIGEN_SPARSE_COMPRESSED_STORAGE_REALLOCATE_PLUGIN\n        EIGEN_SPARSE_COMPRESSED_STORAGE_REALLOCATE_PLUGIN\n      #endif\n      eigen_internal_assert(size!=m_allocatedSize);\n      internal::scoped_array<Scalar> newValues(size);\n      internal::scoped_array<StorageIndex> newIndices(size);\n      Index copySize = (std::min)(size, m_size);\n      if (copySize>0) {\n        internal::smart_copy(m_values, m_values+copySize, newValues.ptr());\n        internal::smart_copy(m_indices, m_indices+copySize, newIndices.ptr());\n      }\n      std::swap(m_values,newValues.ptr());\n      std::swap(m_indices,newIndices.ptr());\n      m_allocatedSize = size;\n    }\n\n  protected:\n    Scalar* m_values;\n    StorageIndex* m_indices;\n    Index m_size;\n    Index m_allocatedSize;\n\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_COMPRESSED_STORAGE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_CONSERVATIVESPARSESPARSEPRODUCT_H\n#define EIGEN_CONSERVATIVESPARSESPARSEPRODUCT_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstatic void conservative_sparse_sparse_product_impl(const Lhs& lhs, const Rhs& rhs, ResultType& res, bool sortedInsertion = false)\n{\n  typedef typename remove_all<Lhs>::type::Scalar Scalar;\n\n  // make sure to call innerSize/outerSize since we fake the storage order.\n  Index rows = lhs.innerSize();\n  Index cols = rhs.outerSize();\n  eigen_assert(lhs.outerSize() == rhs.innerSize());\n  \n  ei_declare_aligned_stack_constructed_variable(bool,   mask,     rows, 0);\n  ei_declare_aligned_stack_constructed_variable(Scalar, values,   rows, 0);\n  ei_declare_aligned_stack_constructed_variable(Index,  indices,  rows, 0);\n  \n  std::memset(mask,0,sizeof(bool)*rows);\n\n  evaluator<Lhs> lhsEval(lhs);\n  evaluator<Rhs> rhsEval(rhs);\n  \n  // estimate the number of non zero entries\n  // given a rhs column containing Y non zeros, we assume that the respective Y columns\n  // of the lhs differs in average of one non zeros, thus the number of non zeros for\n  // the product of a rhs column with the lhs is X+Y where X is the average number of non zero\n  // per column of the lhs.\n  // Therefore, we have nnz(lhs*rhs) = nnz(lhs) + nnz(rhs)\n  Index estimated_nnz_prod = lhsEval.nonZerosEstimate() + rhsEval.nonZerosEstimate();\n\n  res.setZero();\n  res.reserve(Index(estimated_nnz_prod));\n  // we compute each column of the result, one after the other\n  for (Index j=0; j<cols; ++j)\n  {\n\n    res.startVec(j);\n    Index nnz = 0;\n    for (typename evaluator<Rhs>::InnerIterator rhsIt(rhsEval, j); rhsIt; ++rhsIt)\n    {\n      Scalar y = rhsIt.value();\n      Index k = rhsIt.index();\n      for (typename evaluator<Lhs>::InnerIterator lhsIt(lhsEval, k); lhsIt; ++lhsIt)\n      {\n        Index i = lhsIt.index();\n        Scalar x = lhsIt.value();\n        if(!mask[i])\n        {\n          mask[i] = true;\n          values[i] = x * y;\n          indices[nnz] = i;\n          ++nnz;\n        }\n        else\n          values[i] += x * y;\n      }\n    }\n    if(!sortedInsertion)\n    {\n      // unordered insertion\n      for(Index k=0; k<nnz; ++k)\n      {\n        Index i = indices[k];\n        res.insertBackByOuterInnerUnordered(j,i) = values[i];\n        mask[i] = false;\n      }\n    }\n    else\n    {\n      // alternative ordered insertion code:\n      const Index t200 = rows/11; // 11 == (log2(200)*1.39)\n      const Index t = (rows*100)/139;\n\n      // FIXME reserve nnz non zeros\n      // FIXME implement faster sorting algorithms for very small nnz\n      // if the result is sparse enough => use a quick sort\n      // otherwise => loop through the entire vector\n      // In order to avoid to perform an expensive log2 when the\n      // result is clearly very sparse we use a linear bound up to 200.\n      if((nnz<200 && nnz<t200) || nnz * numext::log2(int(nnz)) < t)\n      {\n        if(nnz>1) std::sort(indices,indices+nnz);\n        for(Index k=0; k<nnz; ++k)\n        {\n          Index i = indices[k];\n          res.insertBackByOuterInner(j,i) = values[i];\n          mask[i] = false;\n        }\n      }\n      else\n      {\n        // dense path\n        for(Index i=0; i<rows; ++i)\n        {\n          if(mask[i])\n          {\n            mask[i] = false;\n            res.insertBackByOuterInner(j,i) = values[i];\n          }\n        }\n      }\n    }\n  }\n  res.finalize();\n}\n\n\n} // end namespace internal\n\nnamespace internal {\n\ntemplate<typename Lhs, typename Rhs, typename ResultType,\n  int LhsStorageOrder = (traits<Lhs>::Flags&RowMajorBit) ? RowMajor : ColMajor,\n  int RhsStorageOrder = (traits<Rhs>::Flags&RowMajorBit) ? RowMajor : ColMajor,\n  int ResStorageOrder = (traits<ResultType>::Flags&RowMajorBit) ? RowMajor : ColMajor>\nstruct conservative_sparse_sparse_product_selector;\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,ColMajor,ColMajor>\n{\n  typedef typename remove_all<Lhs>::type LhsCleaned;\n  typedef typename LhsCleaned::Scalar Scalar;\n\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::StorageIndex> RowMajorMatrix;\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrixAux;\n    typedef typename sparse_eval<ColMajorMatrixAux,ResultType::RowsAtCompileTime,ResultType::ColsAtCompileTime,ColMajorMatrixAux::Flags>::type ColMajorMatrix;\n    \n    // If the result is tall and thin (in the extreme case a column vector)\n    // then it is faster to sort the coefficients inplace instead of transposing twice.\n    // FIXME, the following heuristic is probably not very good.\n    if(lhs.rows()>rhs.cols())\n    {\n      ColMajorMatrix resCol(lhs.rows(),rhs.cols());\n      // perform sorted insertion\n      internal::conservative_sparse_sparse_product_impl<Lhs,Rhs,ColMajorMatrix>(lhs, rhs, resCol, true);\n      res = resCol.markAsRValue();\n    }\n    else\n    {\n      ColMajorMatrixAux resCol(lhs.rows(),rhs.cols());\n      // ressort to transpose to sort the entries\n      internal::conservative_sparse_sparse_product_impl<Lhs,Rhs,ColMajorMatrixAux>(lhs, rhs, resCol, false);\n      RowMajorMatrix resRow(resCol);\n      res = resRow.markAsRValue();\n    }\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,ColMajor,ColMajor>\n{\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n     typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::StorageIndex> RowMajorMatrix;\n     RowMajorMatrix rhsRow = rhs;\n     RowMajorMatrix resRow(lhs.rows(), rhs.cols());\n     internal::conservative_sparse_sparse_product_impl<RowMajorMatrix,Lhs,RowMajorMatrix>(rhsRow, lhs, resRow);\n     res = resRow;\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,RowMajor,ColMajor>\n{\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::StorageIndex> RowMajorMatrix;\n    RowMajorMatrix lhsRow = lhs;\n    RowMajorMatrix resRow(lhs.rows(), rhs.cols());\n    internal::conservative_sparse_sparse_product_impl<Rhs,RowMajorMatrix,RowMajorMatrix>(rhs, lhsRow, resRow);\n    res = resRow;\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,RowMajor,ColMajor>\n{\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::StorageIndex> RowMajorMatrix;\n    RowMajorMatrix resRow(lhs.rows(), rhs.cols());\n    internal::conservative_sparse_sparse_product_impl<Rhs,Lhs,RowMajorMatrix>(rhs, lhs, resRow);\n    res = resRow;\n  }\n};\n\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,ColMajor,RowMajor>\n{\n  typedef typename traits<typename remove_all<Lhs>::type>::Scalar Scalar;\n\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrix;\n    ColMajorMatrix resCol(lhs.rows(), rhs.cols());\n    internal::conservative_sparse_sparse_product_impl<Lhs,Rhs,ColMajorMatrix>(lhs, rhs, resCol);\n    res = resCol;\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,ColMajor,RowMajor>\n{\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrix;\n    ColMajorMatrix lhsCol = lhs;\n    ColMajorMatrix resCol(lhs.rows(), rhs.cols());\n    internal::conservative_sparse_sparse_product_impl<ColMajorMatrix,Rhs,ColMajorMatrix>(lhsCol, rhs, resCol);\n    res = resCol;\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,RowMajor,RowMajor>\n{\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrix;\n    ColMajorMatrix rhsCol = rhs;\n    ColMajorMatrix resCol(lhs.rows(), rhs.cols());\n    internal::conservative_sparse_sparse_product_impl<Lhs,ColMajorMatrix,ColMajorMatrix>(lhs, rhsCol, resCol);\n    res = resCol;\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,RowMajor,RowMajor>\n{\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::StorageIndex> RowMajorMatrix;\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrix;\n    RowMajorMatrix resRow(lhs.rows(),rhs.cols());\n    internal::conservative_sparse_sparse_product_impl<Rhs,Lhs,RowMajorMatrix>(rhs, lhs, resRow);\n    // sort the non zeros:\n    ColMajorMatrix resCol(resRow);\n    res = resCol;\n  }\n};\n\n} // end namespace internal\n\n\nnamespace internal {\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstatic void sparse_sparse_to_dense_product_impl(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n{\n  typedef typename remove_all<Lhs>::type::Scalar Scalar;\n  Index cols = rhs.outerSize();\n  eigen_assert(lhs.outerSize() == rhs.innerSize());\n\n  evaluator<Lhs> lhsEval(lhs);\n  evaluator<Rhs> rhsEval(rhs);\n\n  for (Index j=0; j<cols; ++j)\n  {\n    for (typename evaluator<Rhs>::InnerIterator rhsIt(rhsEval, j); rhsIt; ++rhsIt)\n    {\n      Scalar y = rhsIt.value();\n      Index k = rhsIt.index();\n      for (typename evaluator<Lhs>::InnerIterator lhsIt(lhsEval, k); lhsIt; ++lhsIt)\n      {\n        Index i = lhsIt.index();\n        Scalar x = lhsIt.value();\n        res.coeffRef(i,j) += x * y;\n      }\n    }\n  }\n}\n\n\n} // end namespace internal\n\nnamespace internal {\n\ntemplate<typename Lhs, typename Rhs, typename ResultType,\n  int LhsStorageOrder = (traits<Lhs>::Flags&RowMajorBit) ? RowMajor : ColMajor,\n  int RhsStorageOrder = (traits<Rhs>::Flags&RowMajorBit) ? RowMajor : ColMajor>\nstruct sparse_sparse_to_dense_product_selector;\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_to_dense_product_selector<Lhs,Rhs,ResultType,ColMajor,ColMajor>\n{\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n    internal::sparse_sparse_to_dense_product_impl<Lhs,Rhs,ResultType>(lhs, rhs, res);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_to_dense_product_selector<Lhs,Rhs,ResultType,RowMajor,ColMajor>\n{\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrix;\n    ColMajorMatrix lhsCol(lhs);\n    internal::sparse_sparse_to_dense_product_impl<ColMajorMatrix,Rhs,ResultType>(lhsCol, rhs, res);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_to_dense_product_selector<Lhs,Rhs,ResultType,ColMajor,RowMajor>\n{\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrix;\n    ColMajorMatrix rhsCol(rhs);\n    internal::sparse_sparse_to_dense_product_impl<Lhs,ColMajorMatrix,ResultType>(lhs, rhsCol, res);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_to_dense_product_selector<Lhs,Rhs,ResultType,RowMajor,RowMajor>\n{\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)\n  {\n    Transpose<ResultType> trRes(res);\n    internal::sparse_sparse_to_dense_product_impl<Rhs,Lhs,Transpose<ResultType> >(rhs, lhs, trRes);\n  }\n};\n\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_CONSERVATIVESPARSESPARSEPRODUCT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/MappedSparseMatrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MAPPED_SPARSEMATRIX_H\n#define EIGEN_MAPPED_SPARSEMATRIX_H\n\nnamespace Eigen {\n\n/** \\deprecated Use Map<SparseMatrix<> >\n  * \\class MappedSparseMatrix\n  *\n  * \\brief Sparse matrix\n  *\n  * \\param _Scalar the scalar type, i.e. the type of the coefficients\n  *\n  * See http://www.netlib.org/linalg/html_templates/node91.html for details on the storage scheme.\n  *\n  */\nnamespace internal {\ntemplate<typename _Scalar, int _Flags, typename _StorageIndex>\nstruct traits<MappedSparseMatrix<_Scalar, _Flags, _StorageIndex> > : traits<SparseMatrix<_Scalar, _Flags, _StorageIndex> >\n{};\n} // end namespace internal\n\ntemplate<typename _Scalar, int _Flags, typename _StorageIndex>\nclass MappedSparseMatrix\n  : public Map<SparseMatrix<_Scalar, _Flags, _StorageIndex> >\n{\n    typedef Map<SparseMatrix<_Scalar, _Flags, _StorageIndex> > Base;\n\n  public:\n    \n    typedef typename Base::StorageIndex StorageIndex;\n    typedef typename Base::Scalar Scalar;\n\n    inline MappedSparseMatrix(Index rows, Index cols, Index nnz, StorageIndex* outerIndexPtr, StorageIndex* innerIndexPtr, Scalar* valuePtr, StorageIndex* innerNonZeroPtr = 0)\n      : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZeroPtr)\n    {}\n\n    /** Empty destructor */\n    inline ~MappedSparseMatrix() {}\n};\n\nnamespace internal {\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex>\nstruct evaluator<MappedSparseMatrix<_Scalar,_Options,_StorageIndex> >\n  : evaluator<SparseCompressedBase<MappedSparseMatrix<_Scalar,_Options,_StorageIndex> > >\n{\n  typedef MappedSparseMatrix<_Scalar,_Options,_StorageIndex> XprType;\n  typedef evaluator<SparseCompressedBase<XprType> > Base;\n  \n  evaluator() : Base() {}\n  explicit evaluator(const XprType &mat) : Base(mat) {}\n};\n\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_MAPPED_SPARSEMATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseAssign.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSEASSIGN_H\n#define EIGEN_SPARSEASSIGN_H\n\nnamespace Eigen { \n\ntemplate<typename Derived>    \ntemplate<typename OtherDerived>\nDerived& SparseMatrixBase<Derived>::operator=(const EigenBase<OtherDerived> &other)\n{\n  internal::call_assignment_no_alias(derived(), other.derived());\n  return derived();\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nDerived& SparseMatrixBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)\n{\n  // TODO use the evaluator mechanism\n  other.evalTo(derived());\n  return derived();\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\ninline Derived& SparseMatrixBase<Derived>::operator=(const SparseMatrixBase<OtherDerived>& other)\n{\n  // by default sparse evaluation do not alias, so we can safely bypass the generic call_assignment routine\n  internal::Assignment<Derived,OtherDerived,internal::assign_op<Scalar,typename OtherDerived::Scalar> >\n          ::run(derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\ntemplate<typename Derived>\ninline Derived& SparseMatrixBase<Derived>::operator=(const Derived& other)\n{\n  internal::call_assignment_no_alias(derived(), other.derived());\n  return derived();\n}\n\nnamespace internal {\n\ntemplate<>\nstruct storage_kind_to_evaluator_kind<Sparse> {\n  typedef IteratorBased Kind;\n};\n\ntemplate<>\nstruct storage_kind_to_shape<Sparse> {\n  typedef SparseShape Shape;\n};\n\nstruct Sparse2Sparse {};\nstruct Sparse2Dense  {};\n\ntemplate<> struct AssignmentKind<SparseShape, SparseShape>           { typedef Sparse2Sparse Kind; };\ntemplate<> struct AssignmentKind<SparseShape, SparseTriangularShape> { typedef Sparse2Sparse Kind; };\ntemplate<> struct AssignmentKind<DenseShape,  SparseShape>           { typedef Sparse2Dense  Kind; };\ntemplate<> struct AssignmentKind<DenseShape,  SparseTriangularShape> { typedef Sparse2Dense  Kind; };\n\n\ntemplate<typename DstXprType, typename SrcXprType>\nvoid assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src)\n{\n  typedef typename DstXprType::Scalar Scalar;\n  typedef internal::evaluator<DstXprType> DstEvaluatorType;\n  typedef internal::evaluator<SrcXprType> SrcEvaluatorType;\n\n  SrcEvaluatorType srcEvaluator(src);\n\n  const bool transpose = (DstEvaluatorType::Flags & RowMajorBit) != (SrcEvaluatorType::Flags & RowMajorBit);\n  const Index outerEvaluationSize = (SrcEvaluatorType::Flags&RowMajorBit) ? src.rows() : src.cols();\n  if ((!transpose) && src.isRValue())\n  {\n    // eval without temporary\n    dst.resize(src.rows(), src.cols());\n    dst.setZero();\n    dst.reserve((std::max)(src.rows(),src.cols())*2);\n    for (Index j=0; j<outerEvaluationSize; ++j)\n    {\n      dst.startVec(j);\n      for (typename SrcEvaluatorType::InnerIterator it(srcEvaluator, j); it; ++it)\n      {\n        Scalar v = it.value();\n        dst.insertBackByOuterInner(j,it.index()) = v;\n      }\n    }\n    dst.finalize();\n  }\n  else\n  {\n    // eval through a temporary\n    eigen_assert(( ((internal::traits<DstXprType>::SupportedAccessPatterns & OuterRandomAccessPattern)==OuterRandomAccessPattern) ||\n              (!((DstEvaluatorType::Flags & RowMajorBit) != (SrcEvaluatorType::Flags & RowMajorBit)))) &&\n              \"the transpose operation is supposed to be handled in SparseMatrix::operator=\");\n\n    enum { Flip = (DstEvaluatorType::Flags & RowMajorBit) != (SrcEvaluatorType::Flags & RowMajorBit) };\n\n    \n    DstXprType temp(src.rows(), src.cols());\n\n    temp.reserve((std::max)(src.rows(),src.cols())*2);\n    for (Index j=0; j<outerEvaluationSize; ++j)\n    {\n      temp.startVec(j);\n      for (typename SrcEvaluatorType::InnerIterator it(srcEvaluator, j); it; ++it)\n      {\n        Scalar v = it.value();\n        temp.insertBackByOuterInner(Flip?it.index():j,Flip?j:it.index()) = v;\n      }\n    }\n    temp.finalize();\n\n    dst = temp.markAsRValue();\n  }\n}\n\n// Generic Sparse to Sparse assignment\ntemplate< typename DstXprType, typename SrcXprType, typename Functor>\nstruct Assignment<DstXprType, SrcXprType, Functor, Sparse2Sparse>\n{\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)\n  {\n    assign_sparse_to_sparse(dst.derived(), src.derived());\n  }\n};\n\n// Generic Sparse to Dense assignment\ntemplate< typename DstXprType, typename SrcXprType, typename Functor>\nstruct Assignment<DstXprType, SrcXprType, Functor, Sparse2Dense>\n{\n  static void run(DstXprType &dst, const SrcXprType &src, const Functor &func)\n  {\n    if(internal::is_same<Functor,internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> >::value)\n      dst.setZero();\n    \n    internal::evaluator<SrcXprType> srcEval(src);\n    resize_if_allowed(dst, src, func);\n    internal::evaluator<DstXprType> dstEval(dst);\n    \n    const Index outerEvaluationSize = (internal::evaluator<SrcXprType>::Flags&RowMajorBit) ? src.rows() : src.cols();\n    for (Index j=0; j<outerEvaluationSize; ++j)\n      for (typename internal::evaluator<SrcXprType>::InnerIterator i(srcEval,j); i; ++i)\n        func.assignCoeff(dstEval.coeffRef(i.row(),i.col()), i.value());\n  }\n};\n\n// Specialization for \"dst = dec.solve(rhs)\"\n// NOTE we need to specialize it for Sparse2Sparse to avoid ambiguous specialization error\ntemplate<typename DstXprType, typename DecType, typename RhsType, typename Scalar>\nstruct Assignment<DstXprType, Solve<DecType,RhsType>, internal::assign_op<Scalar,Scalar>, Sparse2Sparse>\n{\n  typedef Solve<DecType,RhsType> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,Scalar> &)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n\n    src.dec()._solve_impl(src.rhs(), dst);\n  }\n};\n\nstruct Diagonal2Sparse {};\n\ntemplate<> struct AssignmentKind<SparseShape,DiagonalShape> { typedef Diagonal2Sparse Kind; };\n\ntemplate< typename DstXprType, typename SrcXprType, typename Functor>\nstruct Assignment<DstXprType, SrcXprType, Functor, Diagonal2Sparse>\n{\n  typedef typename DstXprType::StorageIndex StorageIndex;\n  typedef typename DstXprType::Scalar Scalar;\n  typedef Array<StorageIndex,Dynamic,1> ArrayXI;\n  typedef Array<Scalar,Dynamic,1> ArrayXS;\n  template<int Options>\n  static void run(SparseMatrix<Scalar,Options,StorageIndex> &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n\n    Index size = src.diagonal().size();\n    dst.makeCompressed();\n    dst.resizeNonZeros(size);\n    Map<ArrayXI>(dst.innerIndexPtr(), size).setLinSpaced(0,StorageIndex(size)-1);\n    Map<ArrayXI>(dst.outerIndexPtr(), size+1).setLinSpaced(0,StorageIndex(size));\n    Map<ArrayXS>(dst.valuePtr(), size) = src.diagonal();\n  }\n  \n  template<typename DstDerived>\n  static void run(SparseMatrixBase<DstDerived> &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)\n  {\n    dst.diagonal() = src.diagonal();\n  }\n  \n  static void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)\n  { dst.diagonal() += src.diagonal(); }\n  \n  static void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)\n  { dst.diagonal() -= src.diagonal(); }\n};\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSEASSIGN_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseBlock.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_BLOCK_H\n#define EIGEN_SPARSE_BLOCK_H\n\nnamespace Eigen {\n\n// Subset of columns or rows\ntemplate<typename XprType, int BlockRows, int BlockCols>\nclass BlockImpl<XprType,BlockRows,BlockCols,true,Sparse>\n  : public SparseMatrixBase<Block<XprType,BlockRows,BlockCols,true> >\n{\n    typedef typename internal::remove_all<typename XprType::Nested>::type _MatrixTypeNested;\n    typedef Block<XprType, BlockRows, BlockCols, true> BlockType;\npublic:\n    enum { IsRowMajor = internal::traits<BlockType>::IsRowMajor };\nprotected:\n    enum { OuterSize = IsRowMajor ? BlockRows : BlockCols };\n    typedef SparseMatrixBase<BlockType> Base;\n    using Base::convert_index;\npublic:\n    EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)\n\n    inline BlockImpl(XprType& xpr, Index i)\n      : m_matrix(xpr), m_outerStart(convert_index(i)), m_outerSize(OuterSize)\n    {}\n\n    inline BlockImpl(XprType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)\n      : m_matrix(xpr), m_outerStart(convert_index(IsRowMajor ? startRow : startCol)), m_outerSize(convert_index(IsRowMajor ? blockRows : blockCols))\n    {}\n\n    EIGEN_STRONG_INLINE Index rows() const { return IsRowMajor ? m_outerSize.value() : m_matrix.rows(); }\n    EIGEN_STRONG_INLINE Index cols() const { return IsRowMajor ? m_matrix.cols() : m_outerSize.value(); }\n\n    Index nonZeros() const\n    {\n      typedef internal::evaluator<XprType> EvaluatorType;\n      EvaluatorType matEval(m_matrix);\n      Index nnz = 0;\n      Index end = m_outerStart + m_outerSize.value();\n      for(Index j=m_outerStart; j<end; ++j)\n        for(typename EvaluatorType::InnerIterator it(matEval, j); it; ++it)\n          ++nnz;\n      return nnz;\n    }\n\n    inline const Scalar coeff(Index row, Index col) const\n    {\n      return m_matrix.coeff(row + (IsRowMajor ? m_outerStart : 0), col + (IsRowMajor ? 0 :  m_outerStart));\n    }\n\n    inline const Scalar coeff(Index index) const\n    {\n      return m_matrix.coeff(IsRowMajor ? m_outerStart : index, IsRowMajor ? index :  m_outerStart);\n    }\n\n    inline const XprType& nestedExpression() const { return m_matrix; }\n    inline XprType& nestedExpression() { return m_matrix; }\n    Index startRow() const { return IsRowMajor ? m_outerStart : 0; }\n    Index startCol() const { return IsRowMajor ? 0 : m_outerStart; }\n    Index blockRows() const { return IsRowMajor ? m_outerSize.value() : m_matrix.rows(); }\n    Index blockCols() const { return IsRowMajor ? m_matrix.cols() : m_outerSize.value(); }\n\n  protected:\n\n    typename internal::ref_selector<XprType>::non_const_type m_matrix;\n    Index m_outerStart;\n    const internal::variable_if_dynamic<Index, OuterSize> m_outerSize;\n\n  protected:\n    // Disable assignment with clear error message.\n    // Note that simply removing operator= yields compilation errors with ICC+MSVC\n    template<typename T>\n    BlockImpl& operator=(const T&)\n    {\n      EIGEN_STATIC_ASSERT(sizeof(T)==0, THIS_SPARSE_BLOCK_SUBEXPRESSION_IS_READ_ONLY);\n      return *this;\n    }\n};\n\n\n/***************************************************************************\n* specialization for SparseMatrix\n***************************************************************************/\n\nnamespace internal {\n\ntemplate<typename SparseMatrixType, int BlockRows, int BlockCols>\nclass sparse_matrix_block_impl\n  : public SparseCompressedBase<Block<SparseMatrixType,BlockRows,BlockCols,true> >\n{\n    typedef typename internal::remove_all<typename SparseMatrixType::Nested>::type _MatrixTypeNested;\n    typedef Block<SparseMatrixType, BlockRows, BlockCols, true> BlockType;\n    typedef SparseCompressedBase<Block<SparseMatrixType,BlockRows,BlockCols,true> > Base;\n    using Base::convert_index;\npublic:\n    enum { IsRowMajor = internal::traits<BlockType>::IsRowMajor };\n    EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)\nprotected:\n    typedef typename Base::IndexVector IndexVector;\n    enum { OuterSize = IsRowMajor ? BlockRows : BlockCols };\npublic:\n\n    inline sparse_matrix_block_impl(SparseMatrixType& xpr, Index i)\n      : m_matrix(xpr), m_outerStart(convert_index(i)), m_outerSize(OuterSize)\n    {}\n\n    inline sparse_matrix_block_impl(SparseMatrixType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)\n      : m_matrix(xpr), m_outerStart(convert_index(IsRowMajor ? startRow : startCol)), m_outerSize(convert_index(IsRowMajor ? blockRows : blockCols))\n    {}\n\n    template<typename OtherDerived>\n    inline BlockType& operator=(const SparseMatrixBase<OtherDerived>& other)\n    {\n      typedef typename internal::remove_all<typename SparseMatrixType::Nested>::type _NestedMatrixType;\n      _NestedMatrixType& matrix = m_matrix;\n      // This assignment is slow if this vector set is not empty\n      // and/or it is not at the end of the nonzeros of the underlying matrix.\n\n      // 1 - eval to a temporary to avoid transposition and/or aliasing issues\n      Ref<const SparseMatrix<Scalar, IsRowMajor ? RowMajor : ColMajor, StorageIndex> > tmp(other.derived());\n      eigen_internal_assert(tmp.outerSize()==m_outerSize.value());\n\n      // 2 - let's check whether there is enough allocated memory\n      Index nnz           = tmp.nonZeros();\n      Index start         = m_outerStart==0 ? 0 : m_matrix.outerIndexPtr()[m_outerStart]; // starting position of the current block\n      Index end           = m_matrix.outerIndexPtr()[m_outerStart+m_outerSize.value()]; // ending position of the current block\n      Index block_size    = end - start;                                                // available room in the current block\n      Index tail_size     = m_matrix.outerIndexPtr()[m_matrix.outerSize()] - end;\n\n      Index free_size     = m_matrix.isCompressed()\n                          ? Index(matrix.data().allocatedSize()) + block_size\n                          : block_size;\n\n      Index tmp_start = tmp.outerIndexPtr()[0];\n\n      bool update_trailing_pointers = false;\n      if(nnz>free_size)\n      {\n        // realloc manually to reduce copies\n        typename SparseMatrixType::Storage newdata(m_matrix.data().allocatedSize() - block_size + nnz);\n\n        internal::smart_copy(m_matrix.valuePtr(),       m_matrix.valuePtr() + start,      newdata.valuePtr());\n        internal::smart_copy(m_matrix.innerIndexPtr(),  m_matrix.innerIndexPtr() + start, newdata.indexPtr());\n\n        internal::smart_copy(tmp.valuePtr() + tmp_start,      tmp.valuePtr() + tmp_start + nnz,       newdata.valuePtr() + start);\n        internal::smart_copy(tmp.innerIndexPtr() + tmp_start, tmp.innerIndexPtr() + tmp_start + nnz,  newdata.indexPtr() + start);\n\n        internal::smart_copy(matrix.valuePtr()+end,       matrix.valuePtr()+end + tail_size,      newdata.valuePtr()+start+nnz);\n        internal::smart_copy(matrix.innerIndexPtr()+end,  matrix.innerIndexPtr()+end + tail_size, newdata.indexPtr()+start+nnz);\n\n        newdata.resize(m_matrix.outerIndexPtr()[m_matrix.outerSize()] - block_size + nnz);\n\n        matrix.data().swap(newdata);\n\n        update_trailing_pointers = true;\n      }\n      else\n      {\n        if(m_matrix.isCompressed())\n        {\n          // no need to realloc, simply copy the tail at its respective position and insert tmp\n          matrix.data().resize(start + nnz + tail_size);\n\n          internal::smart_memmove(matrix.valuePtr()+end,      matrix.valuePtr() + end+tail_size,      matrix.valuePtr() + start+nnz);\n          internal::smart_memmove(matrix.innerIndexPtr()+end, matrix.innerIndexPtr() + end+tail_size, matrix.innerIndexPtr() + start+nnz);\n\n          update_trailing_pointers = true;\n        }\n\n        internal::smart_copy(tmp.valuePtr() + tmp_start,      tmp.valuePtr() + tmp_start + nnz,       matrix.valuePtr() + start);\n        internal::smart_copy(tmp.innerIndexPtr() + tmp_start, tmp.innerIndexPtr() + tmp_start + nnz,  matrix.innerIndexPtr() + start);\n      }\n\n      // update outer index pointers and innerNonZeros\n      if(IsVectorAtCompileTime)\n      {\n        if(!m_matrix.isCompressed())\n          matrix.innerNonZeroPtr()[m_outerStart] = StorageIndex(nnz);\n        matrix.outerIndexPtr()[m_outerStart] = StorageIndex(start);\n      }\n      else\n      {\n        StorageIndex p = StorageIndex(start);\n        for(Index k=0; k<m_outerSize.value(); ++k)\n        {\n          StorageIndex nnz_k = internal::convert_index<StorageIndex>(tmp.innerVector(k).nonZeros());\n          if(!m_matrix.isCompressed())\n            matrix.innerNonZeroPtr()[m_outerStart+k] = nnz_k;\n          matrix.outerIndexPtr()[m_outerStart+k] = p;\n          p += nnz_k;\n        }\n      }\n\n      if(update_trailing_pointers)\n      {\n        StorageIndex offset = internal::convert_index<StorageIndex>(nnz - block_size);\n        for(Index k = m_outerStart + m_outerSize.value(); k<=matrix.outerSize(); ++k)\n        {\n          matrix.outerIndexPtr()[k] += offset;\n        }\n      }\n\n      return derived();\n    }\n\n    inline BlockType& operator=(const BlockType& other)\n    {\n      return operator=<BlockType>(other);\n    }\n\n    inline const Scalar* valuePtr() const\n    { return m_matrix.valuePtr(); }\n    inline Scalar* valuePtr()\n    { return m_matrix.valuePtr(); }\n\n    inline const StorageIndex* innerIndexPtr() const\n    { return m_matrix.innerIndexPtr(); }\n    inline StorageIndex* innerIndexPtr()\n    { return m_matrix.innerIndexPtr(); }\n\n    inline const StorageIndex* outerIndexPtr() const\n    { return m_matrix.outerIndexPtr() + m_outerStart; }\n    inline StorageIndex* outerIndexPtr()\n    { return m_matrix.outerIndexPtr() + m_outerStart; }\n\n    inline const StorageIndex* innerNonZeroPtr() const\n    { return isCompressed() ? 0 : (m_matrix.innerNonZeroPtr()+m_outerStart); }\n    inline StorageIndex* innerNonZeroPtr()\n    { return isCompressed() ? 0 : (m_matrix.innerNonZeroPtr()+m_outerStart); }\n\n    bool isCompressed() const { return m_matrix.innerNonZeroPtr()==0; }\n\n    inline Scalar& coeffRef(Index row, Index col)\n    {\n      return m_matrix.coeffRef(row + (IsRowMajor ? m_outerStart : 0), col + (IsRowMajor ? 0 :  m_outerStart));\n    }\n\n    inline const Scalar coeff(Index row, Index col) const\n    {\n      return m_matrix.coeff(row + (IsRowMajor ? m_outerStart : 0), col + (IsRowMajor ? 0 :  m_outerStart));\n    }\n\n    inline const Scalar coeff(Index index) const\n    {\n      return m_matrix.coeff(IsRowMajor ? m_outerStart : index, IsRowMajor ? index :  m_outerStart);\n    }\n\n    const Scalar& lastCoeff() const\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(sparse_matrix_block_impl);\n      eigen_assert(Base::nonZeros()>0);\n      if(m_matrix.isCompressed())\n        return m_matrix.valuePtr()[m_matrix.outerIndexPtr()[m_outerStart+1]-1];\n      else\n        return m_matrix.valuePtr()[m_matrix.outerIndexPtr()[m_outerStart]+m_matrix.innerNonZeroPtr()[m_outerStart]-1];\n    }\n\n    EIGEN_STRONG_INLINE Index rows() const { return IsRowMajor ? m_outerSize.value() : m_matrix.rows(); }\n    EIGEN_STRONG_INLINE Index cols() const { return IsRowMajor ? m_matrix.cols() : m_outerSize.value(); }\n\n    inline const SparseMatrixType& nestedExpression() const { return m_matrix; }\n    inline SparseMatrixType& nestedExpression() { return m_matrix; }\n    Index startRow() const { return IsRowMajor ? m_outerStart : 0; }\n    Index startCol() const { return IsRowMajor ? 0 : m_outerStart; }\n    Index blockRows() const { return IsRowMajor ? m_outerSize.value() : m_matrix.rows(); }\n    Index blockCols() const { return IsRowMajor ? m_matrix.cols() : m_outerSize.value(); }\n\n  protected:\n\n    typename internal::ref_selector<SparseMatrixType>::non_const_type m_matrix;\n    Index m_outerStart;\n    const internal::variable_if_dynamic<Index, OuterSize> m_outerSize;\n\n};\n\n} // namespace internal\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex, int BlockRows, int BlockCols>\nclass BlockImpl<SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true,Sparse>\n  : public internal::sparse_matrix_block_impl<SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols>\n{\npublic:\n  typedef _StorageIndex StorageIndex;\n  typedef SparseMatrix<_Scalar, _Options, _StorageIndex> SparseMatrixType;\n  typedef internal::sparse_matrix_block_impl<SparseMatrixType,BlockRows,BlockCols> Base;\n  inline BlockImpl(SparseMatrixType& xpr, Index i)\n    : Base(xpr, i)\n  {}\n\n  inline BlockImpl(SparseMatrixType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)\n    : Base(xpr, startRow, startCol, blockRows, blockCols)\n  {}\n\n  using Base::operator=;\n};\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex, int BlockRows, int BlockCols>\nclass BlockImpl<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true,Sparse>\n  : public internal::sparse_matrix_block_impl<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols>\n{\npublic:\n  typedef _StorageIndex StorageIndex;\n  typedef const SparseMatrix<_Scalar, _Options, _StorageIndex> SparseMatrixType;\n  typedef internal::sparse_matrix_block_impl<SparseMatrixType,BlockRows,BlockCols> Base;\n  inline BlockImpl(SparseMatrixType& xpr, Index i)\n    : Base(xpr, i)\n  {}\n\n  inline BlockImpl(SparseMatrixType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)\n    : Base(xpr, startRow, startCol, blockRows, blockCols)\n  {}\n\n  using Base::operator=;\nprivate:\n  template<typename Derived> BlockImpl(const SparseMatrixBase<Derived>& xpr, Index i);\n  template<typename Derived> BlockImpl(const SparseMatrixBase<Derived>& xpr);\n};\n\n//----------\n\n/** \\returns the \\a outer -th column (resp. row) of the matrix \\c *this if \\c *this\n  * is col-major (resp. row-major).\n  */\ntemplate<typename Derived>\ntypename SparseMatrixBase<Derived>::InnerVectorReturnType SparseMatrixBase<Derived>::innerVector(Index outer)\n{ return InnerVectorReturnType(derived(), outer); }\n\n/** \\returns the \\a outer -th column (resp. row) of the matrix \\c *this if \\c *this\n  * is col-major (resp. row-major). Read-only.\n  */\ntemplate<typename Derived>\nconst typename SparseMatrixBase<Derived>::ConstInnerVectorReturnType SparseMatrixBase<Derived>::innerVector(Index outer) const\n{ return ConstInnerVectorReturnType(derived(), outer); }\n\n/** \\returns the \\a outer -th column (resp. row) of the matrix \\c *this if \\c *this\n  * is col-major (resp. row-major).\n  */\ntemplate<typename Derived>\ntypename SparseMatrixBase<Derived>::InnerVectorsReturnType\nSparseMatrixBase<Derived>::innerVectors(Index outerStart, Index outerSize)\n{\n  return Block<Derived,Dynamic,Dynamic,true>(derived(),\n                                             IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart,\n                                             IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize);\n\n}\n\n/** \\returns the \\a outer -th column (resp. row) of the matrix \\c *this if \\c *this\n  * is col-major (resp. row-major). Read-only.\n  */\ntemplate<typename Derived>\nconst typename SparseMatrixBase<Derived>::ConstInnerVectorsReturnType\nSparseMatrixBase<Derived>::innerVectors(Index outerStart, Index outerSize) const\n{\n  return Block<const Derived,Dynamic,Dynamic,true>(derived(),\n                                                  IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart,\n                                                  IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize);\n\n}\n\n/** Generic implementation of sparse Block expression.\n  * Real-only.\n  */\ntemplate<typename XprType, int BlockRows, int BlockCols, bool InnerPanel>\nclass BlockImpl<XprType,BlockRows,BlockCols,InnerPanel,Sparse>\n  : public SparseMatrixBase<Block<XprType,BlockRows,BlockCols,InnerPanel> >, internal::no_assignment_operator\n{\n    typedef Block<XprType, BlockRows, BlockCols, InnerPanel> BlockType;\n    typedef SparseMatrixBase<BlockType> Base;\n    using Base::convert_index;\npublic:\n    enum { IsRowMajor = internal::traits<BlockType>::IsRowMajor };\n    EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)\n\n    typedef typename internal::remove_all<typename XprType::Nested>::type _MatrixTypeNested;\n\n    /** Column or Row constructor\n      */\n    inline BlockImpl(XprType& xpr, Index i)\n      : m_matrix(xpr),\n        m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? convert_index(i) : 0),\n        m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? convert_index(i) : 0),\n        m_blockRows(BlockRows==1 ? 1 : xpr.rows()),\n        m_blockCols(BlockCols==1 ? 1 : xpr.cols())\n    {}\n\n    /** Dynamic-size constructor\n      */\n    inline BlockImpl(XprType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)\n      : m_matrix(xpr), m_startRow(convert_index(startRow)), m_startCol(convert_index(startCol)), m_blockRows(convert_index(blockRows)), m_blockCols(convert_index(blockCols))\n    {}\n\n    inline Index rows() const { return m_blockRows.value(); }\n    inline Index cols() const { return m_blockCols.value(); }\n\n    inline Scalar& coeffRef(Index row, Index col)\n    {\n      return m_matrix.coeffRef(row + m_startRow.value(), col + m_startCol.value());\n    }\n\n    inline const Scalar coeff(Index row, Index col) const\n    {\n      return m_matrix.coeff(row + m_startRow.value(), col + m_startCol.value());\n    }\n\n    inline Scalar& coeffRef(Index index)\n    {\n      return m_matrix.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),\n                               m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));\n    }\n\n    inline const Scalar coeff(Index index) const\n    {\n      return m_matrix.coeff(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),\n                            m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));\n    }\n\n    inline const XprType& nestedExpression() const { return m_matrix; }\n    inline XprType& nestedExpression() { return m_matrix; }\n    Index startRow() const { return m_startRow.value(); }\n    Index startCol() const { return m_startCol.value(); }\n    Index blockRows() const { return m_blockRows.value(); }\n    Index blockCols() const { return m_blockCols.value(); }\n\n  protected:\n//     friend class internal::GenericSparseBlockInnerIteratorImpl<XprType,BlockRows,BlockCols,InnerPanel>;\n    friend struct internal::unary_evaluator<Block<XprType,BlockRows,BlockCols,InnerPanel>, internal::IteratorBased, Scalar >;\n\n    Index nonZeros() const { return Dynamic; }\n\n    typename internal::ref_selector<XprType>::non_const_type m_matrix;\n    const internal::variable_if_dynamic<Index, XprType::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow;\n    const internal::variable_if_dynamic<Index, XprType::ColsAtCompileTime == 1 ? 0 : Dynamic> m_startCol;\n    const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_blockRows;\n    const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_blockCols;\n\n  protected:\n    // Disable assignment with clear error message.\n    // Note that simply removing operator= yields compilation errors with ICC+MSVC\n    template<typename T>\n    BlockImpl& operator=(const T&)\n    {\n      EIGEN_STATIC_ASSERT(sizeof(T)==0, THIS_SPARSE_BLOCK_SUBEXPRESSION_IS_READ_ONLY);\n      return *this;\n    }\n\n};\n\nnamespace internal {\n\ntemplate<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>\nstruct unary_evaluator<Block<ArgType,BlockRows,BlockCols,InnerPanel>, IteratorBased >\n : public evaluator_base<Block<ArgType,BlockRows,BlockCols,InnerPanel> >\n{\n    class InnerVectorInnerIterator;\n    class OuterVectorInnerIterator;\n  public:\n    typedef Block<ArgType,BlockRows,BlockCols,InnerPanel> XprType;\n    typedef typename XprType::StorageIndex StorageIndex;\n    typedef typename XprType::Scalar Scalar;\n\n    enum {\n      IsRowMajor = XprType::IsRowMajor,\n\n      OuterVector =  (BlockCols==1 && ArgType::IsRowMajor)\n                    | // FIXME | instead of || to please GCC 4.4.0 stupid warning \"suggest parentheses around &&\".\n                      // revert to || as soon as not needed anymore.\n                     (BlockRows==1 && !ArgType::IsRowMajor),\n\n      CoeffReadCost = evaluator<ArgType>::CoeffReadCost,\n      Flags = XprType::Flags\n    };\n\n    typedef typename internal::conditional<OuterVector,OuterVectorInnerIterator,InnerVectorInnerIterator>::type InnerIterator;\n\n    explicit unary_evaluator(const XprType& op)\n      : m_argImpl(op.nestedExpression()), m_block(op)\n    {}\n\n    inline Index nonZerosEstimate() const {\n      Index nnz = m_block.nonZeros();\n      if(nnz<0)\n        return m_argImpl.nonZerosEstimate() * m_block.size() / m_block.nestedExpression().size();\n      return nnz;\n    }\n\n  protected:\n    typedef typename evaluator<ArgType>::InnerIterator EvalIterator;\n\n    evaluator<ArgType> m_argImpl;\n    const XprType &m_block;\n};\n\ntemplate<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>\nclass unary_evaluator<Block<ArgType,BlockRows,BlockCols,InnerPanel>, IteratorBased>::InnerVectorInnerIterator\n : public EvalIterator\n{\n  enum { IsRowMajor = unary_evaluator::IsRowMajor };\n  const XprType& m_block;\n  Index m_end;\npublic:\n\n  EIGEN_STRONG_INLINE InnerVectorInnerIterator(const unary_evaluator& aEval, Index outer)\n    : EvalIterator(aEval.m_argImpl, outer + (IsRowMajor ? aEval.m_block.startRow() : aEval.m_block.startCol())),\n      m_block(aEval.m_block),\n      m_end(IsRowMajor ? aEval.m_block.startCol()+aEval.m_block.blockCols() : aEval.m_block.startRow()+aEval.m_block.blockRows())\n  {\n    while( (EvalIterator::operator bool()) && (EvalIterator::index() < (IsRowMajor ? m_block.startCol() : m_block.startRow())) )\n      EvalIterator::operator++();\n  }\n\n  inline StorageIndex index() const { return EvalIterator::index() - convert_index<StorageIndex>(IsRowMajor ? m_block.startCol() : m_block.startRow()); }\n  inline Index outer()  const { return EvalIterator::outer() - (IsRowMajor ? m_block.startRow() : m_block.startCol()); }\n  inline Index row()    const { return EvalIterator::row()   - m_block.startRow(); }\n  inline Index col()    const { return EvalIterator::col()   - m_block.startCol(); }\n\n  inline operator bool() const { return EvalIterator::operator bool() && EvalIterator::index() < m_end; }\n};\n\ntemplate<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>\nclass unary_evaluator<Block<ArgType,BlockRows,BlockCols,InnerPanel>, IteratorBased>::OuterVectorInnerIterator\n{\n  enum { IsRowMajor = unary_evaluator::IsRowMajor };\n  const unary_evaluator& m_eval;\n  Index m_outerPos;\n  const Index m_innerIndex;\n  Index m_end;\n  EvalIterator m_it;\npublic:\n\n  EIGEN_STRONG_INLINE OuterVectorInnerIterator(const unary_evaluator& aEval, Index outer)\n    : m_eval(aEval),\n      m_outerPos( (IsRowMajor ? aEval.m_block.startCol() : aEval.m_block.startRow()) ),\n      m_innerIndex(IsRowMajor ? aEval.m_block.startRow() : aEval.m_block.startCol()),\n      m_end(IsRowMajor ? aEval.m_block.startCol()+aEval.m_block.blockCols() : aEval.m_block.startRow()+aEval.m_block.blockRows()),\n      m_it(m_eval.m_argImpl, m_outerPos)\n  {\n    EIGEN_UNUSED_VARIABLE(outer);\n    eigen_assert(outer==0);\n\n    while(m_it && m_it.index() < m_innerIndex) ++m_it;\n    if((!m_it) || (m_it.index()!=m_innerIndex))\n      ++(*this);\n  }\n\n  inline StorageIndex index() const { return convert_index<StorageIndex>(m_outerPos - (IsRowMajor ? m_eval.m_block.startCol() : m_eval.m_block.startRow())); }\n  inline Index outer()  const { return 0; }\n  inline Index row()    const { return IsRowMajor ? 0 : index(); }\n  inline Index col()    const { return IsRowMajor ? index() : 0; }\n\n  inline Scalar value() const { return m_it.value(); }\n  inline Scalar& valueRef() { return m_it.valueRef(); }\n\n  inline OuterVectorInnerIterator& operator++()\n  {\n    // search next non-zero entry\n    while(++m_outerPos<m_end)\n    {\n      // Restart iterator at the next inner-vector:\n      m_it.~EvalIterator();\n      ::new (&m_it) EvalIterator(m_eval.m_argImpl, m_outerPos);\n      // search for the key m_innerIndex in the current outer-vector\n      while(m_it && m_it.index() < m_innerIndex) ++m_it;\n      if(m_it && m_it.index()==m_innerIndex) break;\n    }\n    return *this;\n  }\n\n  inline operator bool() const { return m_outerPos < m_end; }\n};\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex, int BlockRows, int BlockCols>\nstruct unary_evaluator<Block<SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true>, IteratorBased>\n  : evaluator<SparseCompressedBase<Block<SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true> > >\n{\n  typedef Block<SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true> XprType;\n  typedef evaluator<SparseCompressedBase<XprType> > Base;\n  explicit unary_evaluator(const XprType &xpr) : Base(xpr) {}\n};\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex, int BlockRows, int BlockCols>\nstruct unary_evaluator<Block<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true>, IteratorBased>\n  : evaluator<SparseCompressedBase<Block<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true> > >\n{\n  typedef Block<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true> XprType;\n  typedef evaluator<SparseCompressedBase<XprType> > Base;\n  explicit unary_evaluator(const XprType &xpr) : Base(xpr) {}\n};\n\n} // end namespace internal\n\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_BLOCK_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseColEtree.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n\n/* \n \n * NOTE: This file is the modified version of sp_coletree.c file in SuperLU \n \n * -- SuperLU routine (version 3.1) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * August 1, 2008\n *\n * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n *\n * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n *\n * Permission is hereby granted to use or copy this program for any\n * purpose, provided the above notices are retained on all copies.\n * Permission to modify the code and to distribute modified code is\n * granted, provided the above notices are retained, and a notice that\n * the code was modified is included with the above copyright notice.\n */\n#ifndef SPARSE_COLETREE_H\n#define SPARSE_COLETREE_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n/** Find the root of the tree/set containing the vertex i : Use Path halving */ \ntemplate<typename Index, typename IndexVector>\nIndex etree_find (Index i, IndexVector& pp)\n{\n  Index p = pp(i); // Parent \n  Index gp = pp(p); // Grand parent \n  while (gp != p) \n  {\n    pp(i) = gp; // Parent pointer on find path is changed to former grand parent\n    i = gp; \n    p = pp(i);\n    gp = pp(p);\n  }\n  return p; \n}\n\n/** Compute the column elimination tree of a sparse matrix\n  * \\param mat The matrix in column-major format. \n  * \\param parent The elimination tree\n  * \\param firstRowElt The column index of the first element in each row\n  * \\param perm The permutation to apply to the column of \\b mat\n  */\ntemplate <typename MatrixType, typename IndexVector>\nint coletree(const MatrixType& mat, IndexVector& parent, IndexVector& firstRowElt, typename MatrixType::StorageIndex *perm=0)\n{\n  typedef typename MatrixType::StorageIndex StorageIndex;\n  StorageIndex nc = convert_index<StorageIndex>(mat.cols()); // Number of columns\n  StorageIndex m = convert_index<StorageIndex>(mat.rows());\n  StorageIndex diagSize = (std::min)(nc,m);\n  IndexVector root(nc); // root of subtree of etree \n  root.setZero();\n  IndexVector pp(nc); // disjoint sets \n  pp.setZero(); // Initialize disjoint sets \n  parent.resize(mat.cols());\n  //Compute first nonzero column in each row \n  firstRowElt.resize(m);\n  firstRowElt.setConstant(nc);\n  firstRowElt.segment(0, diagSize).setLinSpaced(diagSize, 0, diagSize-1);\n  bool found_diag;\n  for (StorageIndex col = 0; col < nc; col++)\n  {\n    StorageIndex pcol = col;\n    if(perm) pcol  = perm[col];\n    for (typename MatrixType::InnerIterator it(mat, pcol); it; ++it)\n    { \n      Index row = it.row();\n      firstRowElt(row) = (std::min)(firstRowElt(row), col);\n    }\n  }\n  /* Compute etree by Liu's algorithm for symmetric matrices,\n          except use (firstRowElt[r],c) in place of an edge (r,c) of A.\n    Thus each row clique in A'*A is replaced by a star\n    centered at its first vertex, which has the same fill. */\n  StorageIndex rset, cset, rroot;\n  for (StorageIndex col = 0; col < nc; col++) \n  {\n    found_diag = col>=m;\n    pp(col) = col; \n    cset = col; \n    root(cset) = col; \n    parent(col) = nc; \n    /* The diagonal element is treated here even if it does not exist in the matrix\n     * hence the loop is executed once more */ \n    StorageIndex pcol = col;\n    if(perm) pcol  = perm[col];\n    for (typename MatrixType::InnerIterator it(mat, pcol); it||!found_diag; ++it)\n    { //  A sequence of interleaved find and union is performed \n      Index i = col;\n      if(it) i = it.index();\n      if (i == col) found_diag = true;\n      \n      StorageIndex row = firstRowElt(i);\n      if (row >= col) continue; \n      rset = internal::etree_find(row, pp); // Find the name of the set containing row\n      rroot = root(rset);\n      if (rroot != col) \n      {\n        parent(rroot) = col; \n        pp(cset) = rset; \n        cset = rset; \n        root(cset) = col; \n      }\n    }\n  }\n  return 0;  \n}\n\n/** \n  * Depth-first search from vertex n.  No recursion.\n  * This routine was contributed by Cédric Doucet, CEDRAT Group, Meylan, France.\n*/\ntemplate <typename IndexVector>\nvoid nr_etdfs (typename IndexVector::Scalar n, IndexVector& parent, IndexVector& first_kid, IndexVector& next_kid, IndexVector& post, typename IndexVector::Scalar postnum)\n{\n  typedef typename IndexVector::Scalar StorageIndex;\n  StorageIndex current = n, first, next;\n  while (postnum != n) \n  {\n    // No kid for the current node\n    first = first_kid(current);\n    \n    // no kid for the current node\n    if (first == -1) \n    {\n      // Numbering this node because it has no kid \n      post(current) = postnum++;\n      \n      // looking for the next kid \n      next = next_kid(current); \n      while (next == -1) \n      {\n        // No more kids : back to the parent node\n        current = parent(current); \n        // numbering the parent node \n        post(current) = postnum++;\n        \n        // Get the next kid \n        next = next_kid(current); \n      }\n      // stopping criterion \n      if (postnum == n+1) return; \n      \n      // Updating current node \n      current = next; \n    }\n    else \n    {\n      current = first; \n    }\n  }\n}\n\n\n/**\n  * \\brief Post order a tree \n  * \\param n the number of nodes\n  * \\param parent Input tree\n  * \\param post postordered tree\n  */\ntemplate <typename IndexVector>\nvoid treePostorder(typename IndexVector::Scalar n, IndexVector& parent, IndexVector& post)\n{\n  typedef typename IndexVector::Scalar StorageIndex;\n  IndexVector first_kid, next_kid; // Linked list of children \n  StorageIndex postnum; \n  // Allocate storage for working arrays and results \n  first_kid.resize(n+1); \n  next_kid.setZero(n+1);\n  post.setZero(n+1);\n  \n  // Set up structure describing children\n  first_kid.setConstant(-1); \n  for (StorageIndex v = n-1; v >= 0; v--) \n  {\n    StorageIndex dad = parent(v);\n    next_kid(v) = first_kid(dad); \n    first_kid(dad) = v; \n  }\n  \n  // Depth-first search from dummy root vertex #n\n  postnum = 0; \n  internal::nr_etdfs(n, parent, first_kid, next_kid, post, postnum);\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // SPARSE_COLETREE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseCompressedBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_COMPRESSED_BASE_H\n#define EIGEN_SPARSE_COMPRESSED_BASE_H\n\nnamespace Eigen { \n\ntemplate<typename Derived> class SparseCompressedBase;\n  \nnamespace internal {\n\ntemplate<typename Derived>\nstruct traits<SparseCompressedBase<Derived> > : traits<Derived>\n{};\n\n} // end namespace internal\n\n/** \\ingroup SparseCore_Module\n  * \\class SparseCompressedBase\n  * \\brief Common base class for sparse [compressed]-{row|column}-storage format.\n  *\n  * This class defines the common interface for all derived classes implementing the compressed sparse storage format, such as:\n  *  - SparseMatrix\n  *  - Ref<SparseMatrixType,Options>\n  *  - Map<SparseMatrixType>\n  *\n  */\ntemplate<typename Derived>\nclass SparseCompressedBase\n  : public SparseMatrixBase<Derived>\n{\n  public:\n    typedef SparseMatrixBase<Derived> Base;\n    EIGEN_SPARSE_PUBLIC_INTERFACE(SparseCompressedBase)\n    using Base::operator=;\n    using Base::IsRowMajor;\n    \n    class InnerIterator;\n    class ReverseInnerIterator;\n    \n  protected:\n    typedef typename Base::IndexVector IndexVector;\n    Eigen::Map<IndexVector> innerNonZeros() { return Eigen::Map<IndexVector>(innerNonZeroPtr(), isCompressed()?0:derived().outerSize()); }\n    const  Eigen::Map<const IndexVector> innerNonZeros() const { return Eigen::Map<const IndexVector>(innerNonZeroPtr(), isCompressed()?0:derived().outerSize()); }\n        \n  public:\n    \n    /** \\returns the number of non zero coefficients */\n    inline Index nonZeros() const\n    {\n      if(Derived::IsVectorAtCompileTime && outerIndexPtr()==0)\n        return derived().nonZeros();\n      else if(isCompressed())\n        return outerIndexPtr()[derived().outerSize()]-outerIndexPtr()[0];\n      else if(derived().outerSize()==0)\n        return 0;\n      else\n        return innerNonZeros().sum();\n    }\n    \n    /** \\returns a const pointer to the array of values.\n      * This function is aimed at interoperability with other libraries.\n      * \\sa innerIndexPtr(), outerIndexPtr() */\n    inline const Scalar* valuePtr() const { return derived().valuePtr(); }\n    /** \\returns a non-const pointer to the array of values.\n      * This function is aimed at interoperability with other libraries.\n      * \\sa innerIndexPtr(), outerIndexPtr() */\n    inline Scalar* valuePtr() { return derived().valuePtr(); }\n\n    /** \\returns a const pointer to the array of inner indices.\n      * This function is aimed at interoperability with other libraries.\n      * \\sa valuePtr(), outerIndexPtr() */\n    inline const StorageIndex* innerIndexPtr() const { return derived().innerIndexPtr(); }\n    /** \\returns a non-const pointer to the array of inner indices.\n      * This function is aimed at interoperability with other libraries.\n      * \\sa valuePtr(), outerIndexPtr() */\n    inline StorageIndex* innerIndexPtr() { return derived().innerIndexPtr(); }\n\n    /** \\returns a const pointer to the array of the starting positions of the inner vectors.\n      * This function is aimed at interoperability with other libraries.\n      * \\warning it returns the null pointer 0 for SparseVector\n      * \\sa valuePtr(), innerIndexPtr() */\n    inline const StorageIndex* outerIndexPtr() const { return derived().outerIndexPtr(); }\n    /** \\returns a non-const pointer to the array of the starting positions of the inner vectors.\n      * This function is aimed at interoperability with other libraries.\n      * \\warning it returns the null pointer 0 for SparseVector\n      * \\sa valuePtr(), innerIndexPtr() */\n    inline StorageIndex* outerIndexPtr() { return derived().outerIndexPtr(); }\n\n    /** \\returns a const pointer to the array of the number of non zeros of the inner vectors.\n      * This function is aimed at interoperability with other libraries.\n      * \\warning it returns the null pointer 0 in compressed mode */\n    inline const StorageIndex* innerNonZeroPtr() const { return derived().innerNonZeroPtr(); }\n    /** \\returns a non-const pointer to the array of the number of non zeros of the inner vectors.\n      * This function is aimed at interoperability with other libraries.\n      * \\warning it returns the null pointer 0 in compressed mode */\n    inline StorageIndex* innerNonZeroPtr() { return derived().innerNonZeroPtr(); }\n    \n    /** \\returns whether \\c *this is in compressed form. */\n    inline bool isCompressed() const { return innerNonZeroPtr()==0; }\n\n    /** \\returns a read-only view of the stored coefficients as a 1D array expression.\n      *\n      * \\warning this method is for \\b compressed \\b storage \\b only, and it will trigger an assertion otherwise.\n      *\n      * \\sa valuePtr(), isCompressed() */\n    const Map<const Array<Scalar,Dynamic,1> > coeffs() const { eigen_assert(isCompressed()); return Array<Scalar,Dynamic,1>::Map(valuePtr(),nonZeros()); }\n\n    /** \\returns a read-write view of the stored coefficients as a 1D array expression\n      *\n      * \\warning this method is for \\b compressed \\b storage \\b only, and it will trigger an assertion otherwise.\n      *\n      * Here is an example:\n      * \\include SparseMatrix_coeffs.cpp\n      * and the output is:\n      * \\include SparseMatrix_coeffs.out\n      *\n      * \\sa valuePtr(), isCompressed() */\n    Map<Array<Scalar,Dynamic,1> > coeffs() { eigen_assert(isCompressed()); return Array<Scalar,Dynamic,1>::Map(valuePtr(),nonZeros()); }\n\n  protected:\n    /** Default constructor. Do nothing. */\n    SparseCompressedBase() {}\n  private:\n    template<typename OtherDerived> explicit SparseCompressedBase(const SparseCompressedBase<OtherDerived>&);\n};\n\ntemplate<typename Derived>\nclass SparseCompressedBase<Derived>::InnerIterator\n{\n  public:\n    InnerIterator()\n      : m_values(0), m_indices(0), m_outer(0), m_id(0), m_end(0)\n    {}\n\n    InnerIterator(const InnerIterator& other)\n      : m_values(other.m_values), m_indices(other.m_indices), m_outer(other.m_outer), m_id(other.m_id), m_end(other.m_end)\n    {}\n\n    InnerIterator& operator=(const InnerIterator& other)\n    {\n      m_values = other.m_values;\n      m_indices = other.m_indices;\n      const_cast<OuterType&>(m_outer).setValue(other.m_outer.value());\n      m_id = other.m_id;\n      m_end = other.m_end;\n      return *this;\n    }\n\n    InnerIterator(const SparseCompressedBase& mat, Index outer)\n      : m_values(mat.valuePtr()), m_indices(mat.innerIndexPtr()), m_outer(outer)\n    {\n      if(Derived::IsVectorAtCompileTime && mat.outerIndexPtr()==0)\n      {\n        m_id = 0;\n        m_end = mat.nonZeros();\n      }\n      else\n      {\n        m_id = mat.outerIndexPtr()[outer];\n        if(mat.isCompressed())\n          m_end = mat.outerIndexPtr()[outer+1];\n        else\n          m_end = m_id + mat.innerNonZeroPtr()[outer];\n      }\n    }\n\n    explicit InnerIterator(const SparseCompressedBase& mat)\n      : m_values(mat.valuePtr()), m_indices(mat.innerIndexPtr()), m_outer(0), m_id(0), m_end(mat.nonZeros())\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);\n    }\n\n    explicit InnerIterator(const internal::CompressedStorage<Scalar,StorageIndex>& data)\n      : m_values(data.valuePtr()), m_indices(data.indexPtr()), m_outer(0), m_id(0), m_end(data.size())\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);\n    }\n\n    inline InnerIterator& operator++() { m_id++; return *this; }\n\n    inline const Scalar& value() const { return m_values[m_id]; }\n    inline Scalar& valueRef() { return const_cast<Scalar&>(m_values[m_id]); }\n\n    inline StorageIndex index() const { return m_indices[m_id]; }\n    inline Index outer() const { return m_outer.value(); }\n    inline Index row() const { return IsRowMajor ? m_outer.value() : index(); }\n    inline Index col() const { return IsRowMajor ? index() : m_outer.value(); }\n\n    inline operator bool() const { return (m_id < m_end); }\n\n  protected:\n    const Scalar* m_values;\n    const StorageIndex* m_indices;\n    typedef internal::variable_if_dynamic<Index,Derived::IsVectorAtCompileTime?0:Dynamic> OuterType;\n    const OuterType m_outer;\n    Index m_id;\n    Index m_end;\n  private:\n    // If you get here, then you're not using the right InnerIterator type, e.g.:\n    //   SparseMatrix<double,RowMajor> A;\n    //   SparseMatrix<double>::InnerIterator it(A,0);\n    template<typename T> InnerIterator(const SparseMatrixBase<T>&, Index outer);\n};\n\ntemplate<typename Derived>\nclass SparseCompressedBase<Derived>::ReverseInnerIterator\n{\n  public:\n    ReverseInnerIterator(const SparseCompressedBase& mat, Index outer)\n      : m_values(mat.valuePtr()), m_indices(mat.innerIndexPtr()), m_outer(outer)\n    {\n      if(Derived::IsVectorAtCompileTime && mat.outerIndexPtr()==0)\n      {\n        m_start = 0;\n        m_id = mat.nonZeros();\n      }\n      else\n      {\n        m_start = mat.outerIndexPtr()[outer];\n        if(mat.isCompressed())\n          m_id = mat.outerIndexPtr()[outer+1];\n        else\n          m_id = m_start + mat.innerNonZeroPtr()[outer];\n      }\n    }\n\n    explicit ReverseInnerIterator(const SparseCompressedBase& mat)\n      : m_values(mat.valuePtr()), m_indices(mat.innerIndexPtr()), m_outer(0), m_start(0), m_id(mat.nonZeros())\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);\n    }\n\n    explicit ReverseInnerIterator(const internal::CompressedStorage<Scalar,StorageIndex>& data)\n      : m_values(data.valuePtr()), m_indices(data.indexPtr()), m_outer(0), m_start(0), m_id(data.size())\n    {\n      EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);\n    }\n\n    inline ReverseInnerIterator& operator--() { --m_id; return *this; }\n\n    inline const Scalar& value() const { return m_values[m_id-1]; }\n    inline Scalar& valueRef() { return const_cast<Scalar&>(m_values[m_id-1]); }\n\n    inline StorageIndex index() const { return m_indices[m_id-1]; }\n    inline Index outer() const { return m_outer.value(); }\n    inline Index row() const { return IsRowMajor ? m_outer.value() : index(); }\n    inline Index col() const { return IsRowMajor ? index() : m_outer.value(); }\n\n    inline operator bool() const { return (m_id > m_start); }\n\n  protected:\n    const Scalar* m_values;\n    const StorageIndex* m_indices;\n    typedef internal::variable_if_dynamic<Index,Derived::IsVectorAtCompileTime?0:Dynamic> OuterType;\n    const OuterType m_outer;\n    Index m_start;\n    Index m_id;\n};\n\nnamespace internal {\n\ntemplate<typename Derived>\nstruct evaluator<SparseCompressedBase<Derived> >\n  : evaluator_base<Derived>\n{\n  typedef typename Derived::Scalar Scalar;\n  typedef typename Derived::InnerIterator InnerIterator;\n  \n  enum {\n    CoeffReadCost = NumTraits<Scalar>::ReadCost,\n    Flags = Derived::Flags\n  };\n  \n  evaluator() : m_matrix(0), m_zero(0)\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n  explicit evaluator(const Derived &mat) : m_matrix(&mat), m_zero(0)\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n  \n  inline Index nonZerosEstimate() const {\n    return m_matrix->nonZeros();\n  }\n  \n  operator Derived&() { return m_matrix->const_cast_derived(); }\n  operator const Derived&() const { return *m_matrix; }\n  \n  typedef typename DenseCoeffsBase<Derived,ReadOnlyAccessors>::CoeffReturnType CoeffReturnType;\n  const Scalar& coeff(Index row, Index col) const\n  {\n    Index p = find(row,col);\n\n    if(p==Dynamic)\n      return m_zero;\n    else\n      return m_matrix->const_cast_derived().valuePtr()[p];\n  }\n\n  Scalar& coeffRef(Index row, Index col)\n  {\n    Index p = find(row,col);\n    eigen_assert(p!=Dynamic && \"written coefficient does not exist\");\n    return m_matrix->const_cast_derived().valuePtr()[p];\n  }\n\nprotected:\n\n  Index find(Index row, Index col) const\n  {\n    eigen_internal_assert(row>=0 && row<m_matrix->rows() && col>=0 && col<m_matrix->cols());\n\n    const Index outer = Derived::IsRowMajor ? row : col;\n    const Index inner = Derived::IsRowMajor ? col : row;\n\n    Index start = m_matrix->outerIndexPtr()[outer];\n    Index end = m_matrix->isCompressed() ? m_matrix->outerIndexPtr()[outer+1] : m_matrix->outerIndexPtr()[outer] + m_matrix->innerNonZeroPtr()[outer];\n    eigen_assert(end>=start && \"you are using a non finalized sparse matrix or written coefficient does not exist\");\n    const Index p = std::lower_bound(m_matrix->innerIndexPtr()+start, m_matrix->innerIndexPtr()+end,inner) - m_matrix->innerIndexPtr();\n\n    return ((p<end) && (m_matrix->innerIndexPtr()[p]==inner)) ? p : Dynamic;\n  }\n\n  const Derived *m_matrix;\n  const Scalar m_zero;\n};\n\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_COMPRESSED_BASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseCwiseBinaryOp.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_CWISE_BINARY_OP_H\n#define EIGEN_SPARSE_CWISE_BINARY_OP_H\n\nnamespace Eigen { \n\n// Here we have to handle 3 cases:\n//  1 - sparse op dense\n//  2 - dense op sparse\n//  3 - sparse op sparse\n// We also need to implement a 4th iterator for:\n//  4 - dense op dense\n// Finally, we also need to distinguish between the product and other operations :\n//                configuration      returned mode\n//  1 - sparse op dense    product      sparse\n//                         generic      dense\n//  2 - dense op sparse    product      sparse\n//                         generic      dense\n//  3 - sparse op sparse   product      sparse\n//                         generic      sparse\n//  4 - dense op dense     product      dense\n//                         generic      dense\n//\n// TODO to ease compiler job, we could specialize product/quotient with a scalar\n//      and fallback to cwise-unary evaluator using bind1st_op and bind2nd_op.\n\ntemplate<typename BinaryOp, typename Lhs, typename Rhs>\nclass CwiseBinaryOpImpl<BinaryOp, Lhs, Rhs, Sparse>\n  : public SparseMatrixBase<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >\n{\n  public:\n    typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> Derived;\n    typedef SparseMatrixBase<Derived> Base;\n    EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)\n    CwiseBinaryOpImpl()\n    {\n      EIGEN_STATIC_ASSERT((\n                (!internal::is_same<typename internal::traits<Lhs>::StorageKind,\n                                    typename internal::traits<Rhs>::StorageKind>::value)\n            ||  ((internal::evaluator<Lhs>::Flags&RowMajorBit) == (internal::evaluator<Rhs>::Flags&RowMajorBit))),\n            THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH);\n    }\n};\n\nnamespace internal {\n\n  \n// Generic \"sparse OP sparse\"\ntemplate<typename XprType> struct binary_sparse_evaluator;\n\ntemplate<typename BinaryOp, typename Lhs, typename Rhs>\nstruct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IteratorBased, IteratorBased>\n  : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >\n{\nprotected:\n  typedef typename evaluator<Lhs>::InnerIterator  LhsIterator;\n  typedef typename evaluator<Rhs>::InnerIterator  RhsIterator;\n  typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;\n  typedef typename traits<XprType>::Scalar Scalar;\n  typedef typename XprType::StorageIndex StorageIndex;\npublic:\n\n  class InnerIterator\n  {\n  public:\n    \n    EIGEN_STRONG_INLINE InnerIterator(const binary_evaluator& aEval, Index outer)\n      : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor)\n    {\n      this->operator++();\n    }\n\n    EIGEN_STRONG_INLINE InnerIterator& operator++()\n    {\n      if (m_lhsIter && m_rhsIter && (m_lhsIter.index() == m_rhsIter.index()))\n      {\n        m_id = m_lhsIter.index();\n        m_value = m_functor(m_lhsIter.value(), m_rhsIter.value());\n        ++m_lhsIter;\n        ++m_rhsIter;\n      }\n      else if (m_lhsIter && (!m_rhsIter || (m_lhsIter.index() < m_rhsIter.index())))\n      {\n        m_id = m_lhsIter.index();\n        m_value = m_functor(m_lhsIter.value(), Scalar(0));\n        ++m_lhsIter;\n      }\n      else if (m_rhsIter && (!m_lhsIter || (m_lhsIter.index() > m_rhsIter.index())))\n      {\n        m_id = m_rhsIter.index();\n        m_value = m_functor(Scalar(0), m_rhsIter.value());\n        ++m_rhsIter;\n      }\n      else\n      {\n        m_value = 0; // this is to avoid a compilation warning\n        m_id = -1;\n      }\n      return *this;\n    }\n\n    EIGEN_STRONG_INLINE Scalar value() const { return m_value; }\n\n    EIGEN_STRONG_INLINE StorageIndex index() const { return m_id; }\n    EIGEN_STRONG_INLINE Index outer() const { return m_lhsIter.outer(); }\n    EIGEN_STRONG_INLINE Index row() const { return Lhs::IsRowMajor ? m_lhsIter.row() : index(); }\n    EIGEN_STRONG_INLINE Index col() const { return Lhs::IsRowMajor ? index() : m_lhsIter.col(); }\n\n    EIGEN_STRONG_INLINE operator bool() const { return m_id>=0; }\n\n  protected:\n    LhsIterator m_lhsIter;\n    RhsIterator m_rhsIter;\n    const BinaryOp& m_functor;\n    Scalar m_value;\n    StorageIndex m_id;\n  };\n  \n  \n  enum {\n    CoeffReadCost = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + functor_traits<BinaryOp>::Cost,\n    Flags = XprType::Flags\n  };\n  \n  explicit binary_evaluator(const XprType& xpr)\n    : m_functor(xpr.functor()),\n      m_lhsImpl(xpr.lhs()), \n      m_rhsImpl(xpr.rhs())  \n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n  \n  inline Index nonZerosEstimate() const {\n    return m_lhsImpl.nonZerosEstimate() + m_rhsImpl.nonZerosEstimate();\n  }\n\nprotected:\n  const BinaryOp m_functor;\n  evaluator<Lhs> m_lhsImpl;\n  evaluator<Rhs> m_rhsImpl;\n};\n\n// dense op sparse\ntemplate<typename BinaryOp, typename Lhs, typename Rhs>\nstruct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IteratorBased>\n  : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >\n{\nprotected:\n  typedef typename evaluator<Rhs>::InnerIterator  RhsIterator;\n  typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;\n  typedef typename traits<XprType>::Scalar Scalar;\n  typedef typename XprType::StorageIndex StorageIndex;\npublic:\n\n  class InnerIterator\n  {\n    enum { IsRowMajor = (int(Rhs::Flags)&RowMajorBit)==RowMajorBit };\n  public:\n\n    EIGEN_STRONG_INLINE InnerIterator(const binary_evaluator& aEval, Index outer)\n      : m_lhsEval(aEval.m_lhsImpl), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor), m_value(0), m_id(-1), m_innerSize(aEval.m_expr.rhs().innerSize())\n    {\n      this->operator++();\n    }\n\n    EIGEN_STRONG_INLINE InnerIterator& operator++()\n    {\n      ++m_id;\n      if(m_id<m_innerSize)\n      {\n        Scalar lhsVal = m_lhsEval.coeff(IsRowMajor?m_rhsIter.outer():m_id,\n                                        IsRowMajor?m_id:m_rhsIter.outer());\n        if(m_rhsIter && m_rhsIter.index()==m_id)\n        {\n          m_value = m_functor(lhsVal, m_rhsIter.value());\n          ++m_rhsIter;\n        }\n        else\n          m_value = m_functor(lhsVal, Scalar(0));\n      }\n\n      return *this;\n    }\n\n    EIGEN_STRONG_INLINE Scalar value() const { eigen_internal_assert(m_id<m_innerSize); return m_value; }\n\n    EIGEN_STRONG_INLINE StorageIndex index() const { return m_id; }\n    EIGEN_STRONG_INLINE Index outer() const { return m_rhsIter.outer(); }\n    EIGEN_STRONG_INLINE Index row() const { return IsRowMajor ? m_rhsIter.outer() : m_id; }\n    EIGEN_STRONG_INLINE Index col() const { return IsRowMajor ? m_id : m_rhsIter.outer(); }\n\n    EIGEN_STRONG_INLINE operator bool() const { return m_id<m_innerSize; }\n\n  protected:\n    const evaluator<Lhs> &m_lhsEval;\n    RhsIterator m_rhsIter;\n    const BinaryOp& m_functor;\n    Scalar m_value;\n    StorageIndex m_id;\n    StorageIndex m_innerSize;\n  };\n\n\n  enum {\n    CoeffReadCost = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + functor_traits<BinaryOp>::Cost,\n    // Expose storage order of the sparse expression\n    Flags = (XprType::Flags & ~RowMajorBit) | (int(Rhs::Flags)&RowMajorBit)\n  };\n\n  explicit binary_evaluator(const XprType& xpr)\n    : m_functor(xpr.functor()),\n      m_lhsImpl(xpr.lhs()),\n      m_rhsImpl(xpr.rhs()),\n      m_expr(xpr)\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n\n  inline Index nonZerosEstimate() const {\n    return m_expr.size();\n  }\n\nprotected:\n  const BinaryOp m_functor;\n  evaluator<Lhs> m_lhsImpl;\n  evaluator<Rhs> m_rhsImpl;\n  const XprType &m_expr;\n};\n\n// sparse op dense\ntemplate<typename BinaryOp, typename Lhs, typename Rhs>\nstruct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IteratorBased, IndexBased>\n  : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >\n{\nprotected:\n  typedef typename evaluator<Lhs>::InnerIterator  LhsIterator;\n  typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;\n  typedef typename traits<XprType>::Scalar Scalar;\n  typedef typename XprType::StorageIndex StorageIndex;\npublic:\n\n  class InnerIterator\n  {\n    enum { IsRowMajor = (int(Lhs::Flags)&RowMajorBit)==RowMajorBit };\n  public:\n\n    EIGEN_STRONG_INLINE InnerIterator(const binary_evaluator& aEval, Index outer)\n      : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsEval(aEval.m_rhsImpl), m_functor(aEval.m_functor), m_value(0), m_id(-1), m_innerSize(aEval.m_expr.lhs().innerSize())\n    {\n      this->operator++();\n    }\n\n    EIGEN_STRONG_INLINE InnerIterator& operator++()\n    {\n      ++m_id;\n      if(m_id<m_innerSize)\n      {\n        Scalar rhsVal = m_rhsEval.coeff(IsRowMajor?m_lhsIter.outer():m_id,\n                                        IsRowMajor?m_id:m_lhsIter.outer());\n        if(m_lhsIter && m_lhsIter.index()==m_id)\n        {\n          m_value = m_functor(m_lhsIter.value(), rhsVal);\n          ++m_lhsIter;\n        }\n        else\n          m_value = m_functor(Scalar(0),rhsVal);\n      }\n\n      return *this;\n    }\n\n    EIGEN_STRONG_INLINE Scalar value() const { eigen_internal_assert(m_id<m_innerSize); return m_value; }\n\n    EIGEN_STRONG_INLINE StorageIndex index() const { return m_id; }\n    EIGEN_STRONG_INLINE Index outer() const { return m_lhsIter.outer(); }\n    EIGEN_STRONG_INLINE Index row() const { return IsRowMajor ? m_lhsIter.outer() : m_id; }\n    EIGEN_STRONG_INLINE Index col() const { return IsRowMajor ? m_id : m_lhsIter.outer(); }\n\n    EIGEN_STRONG_INLINE operator bool() const { return m_id<m_innerSize; }\n\n  protected:\n    LhsIterator m_lhsIter;\n    const evaluator<Rhs> &m_rhsEval;\n    const BinaryOp& m_functor;\n    Scalar m_value;\n    StorageIndex m_id;\n    StorageIndex m_innerSize;\n  };\n\n\n  enum {\n    CoeffReadCost = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + functor_traits<BinaryOp>::Cost,\n    // Expose storage order of the sparse expression\n    Flags = (XprType::Flags & ~RowMajorBit) | (int(Lhs::Flags)&RowMajorBit)\n  };\n\n  explicit binary_evaluator(const XprType& xpr)\n    : m_functor(xpr.functor()),\n      m_lhsImpl(xpr.lhs()),\n      m_rhsImpl(xpr.rhs()),\n      m_expr(xpr)\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n\n  inline Index nonZerosEstimate() const {\n    return m_expr.size();\n  }\n\nprotected:\n  const BinaryOp m_functor;\n  evaluator<Lhs> m_lhsImpl;\n  evaluator<Rhs> m_rhsImpl;\n  const XprType &m_expr;\n};\n\ntemplate<typename T,\n         typename LhsKind   = typename evaluator_traits<typename T::Lhs>::Kind,\n         typename RhsKind   = typename evaluator_traits<typename T::Rhs>::Kind,\n         typename LhsScalar = typename traits<typename T::Lhs>::Scalar,\n         typename RhsScalar = typename traits<typename T::Rhs>::Scalar> struct sparse_conjunction_evaluator;\n\n// \"sparse .* sparse\"\ntemplate<typename T1, typename T2, typename Lhs, typename Rhs>\nstruct binary_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs>, IteratorBased, IteratorBased>\n  : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> >\n{\n  typedef CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> XprType;\n  typedef sparse_conjunction_evaluator<XprType> Base;\n  explicit binary_evaluator(const XprType& xpr) : Base(xpr) {}\n};\n// \"dense .* sparse\"\ntemplate<typename T1, typename T2, typename Lhs, typename Rhs>\nstruct binary_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs>, IndexBased, IteratorBased>\n  : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> >\n{\n  typedef CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> XprType;\n  typedef sparse_conjunction_evaluator<XprType> Base;\n  explicit binary_evaluator(const XprType& xpr) : Base(xpr) {}\n};\n// \"sparse .* dense\"\ntemplate<typename T1, typename T2, typename Lhs, typename Rhs>\nstruct binary_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs>, IteratorBased, IndexBased>\n  : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> >\n{\n  typedef CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> XprType;\n  typedef sparse_conjunction_evaluator<XprType> Base;\n  explicit binary_evaluator(const XprType& xpr) : Base(xpr) {}\n};\n\n// \"sparse ./ dense\"\ntemplate<typename T1, typename T2, typename Lhs, typename Rhs>\nstruct binary_evaluator<CwiseBinaryOp<scalar_quotient_op<T1,T2>, Lhs, Rhs>, IteratorBased, IndexBased>\n  : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_quotient_op<T1,T2>, Lhs, Rhs> >\n{\n  typedef CwiseBinaryOp<scalar_quotient_op<T1,T2>, Lhs, Rhs> XprType;\n  typedef sparse_conjunction_evaluator<XprType> Base;\n  explicit binary_evaluator(const XprType& xpr) : Base(xpr) {}\n};\n\n// \"sparse && sparse\"\ntemplate<typename Lhs, typename Rhs>\nstruct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IteratorBased, IteratorBased>\n  : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >\n{\n  typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;\n  typedef sparse_conjunction_evaluator<XprType> Base;\n  explicit binary_evaluator(const XprType& xpr) : Base(xpr) {}\n};\n// \"dense && sparse\"\ntemplate<typename Lhs, typename Rhs>\nstruct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IndexBased, IteratorBased>\n  : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >\n{\n  typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;\n  typedef sparse_conjunction_evaluator<XprType> Base;\n  explicit binary_evaluator(const XprType& xpr) : Base(xpr) {}\n};\n// \"sparse && dense\"\ntemplate<typename Lhs, typename Rhs>\nstruct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IteratorBased, IndexBased>\n  : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >\n{\n  typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;\n  typedef sparse_conjunction_evaluator<XprType> Base;\n  explicit binary_evaluator(const XprType& xpr) : Base(xpr) {}\n};\n\n// \"sparse ^ sparse\"\ntemplate<typename XprType>\nstruct sparse_conjunction_evaluator<XprType, IteratorBased, IteratorBased>\n  : evaluator_base<XprType>\n{\nprotected:\n  typedef typename XprType::Functor BinaryOp;\n  typedef typename XprType::Lhs LhsArg;\n  typedef typename XprType::Rhs RhsArg;\n  typedef typename evaluator<LhsArg>::InnerIterator  LhsIterator;\n  typedef typename evaluator<RhsArg>::InnerIterator  RhsIterator;\n  typedef typename XprType::StorageIndex StorageIndex;\n  typedef typename traits<XprType>::Scalar Scalar;\npublic:\n\n  class InnerIterator\n  {\n  public:\n    \n    EIGEN_STRONG_INLINE InnerIterator(const sparse_conjunction_evaluator& aEval, Index outer)\n      : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor)\n    {\n      while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))\n      {\n        if (m_lhsIter.index() < m_rhsIter.index())\n          ++m_lhsIter;\n        else\n          ++m_rhsIter;\n      }\n    }\n\n    EIGEN_STRONG_INLINE InnerIterator& operator++()\n    {\n      ++m_lhsIter;\n      ++m_rhsIter;\n      while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))\n      {\n        if (m_lhsIter.index() < m_rhsIter.index())\n          ++m_lhsIter;\n        else\n          ++m_rhsIter;\n      }\n      return *this;\n    }\n    \n    EIGEN_STRONG_INLINE Scalar value() const { return m_functor(m_lhsIter.value(), m_rhsIter.value()); }\n\n    EIGEN_STRONG_INLINE StorageIndex index() const { return m_lhsIter.index(); }\n    EIGEN_STRONG_INLINE Index outer() const { return m_lhsIter.outer(); }\n    EIGEN_STRONG_INLINE Index row() const { return m_lhsIter.row(); }\n    EIGEN_STRONG_INLINE Index col() const { return m_lhsIter.col(); }\n\n    EIGEN_STRONG_INLINE operator bool() const { return (m_lhsIter && m_rhsIter); }\n\n  protected:\n    LhsIterator m_lhsIter;\n    RhsIterator m_rhsIter;\n    const BinaryOp& m_functor;\n  };\n  \n  \n  enum {\n    CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,\n    Flags = XprType::Flags\n  };\n  \n  explicit sparse_conjunction_evaluator(const XprType& xpr)\n    : m_functor(xpr.functor()),\n      m_lhsImpl(xpr.lhs()), \n      m_rhsImpl(xpr.rhs())  \n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n  \n  inline Index nonZerosEstimate() const {\n    return (std::min)(m_lhsImpl.nonZerosEstimate(), m_rhsImpl.nonZerosEstimate());\n  }\n\nprotected:\n  const BinaryOp m_functor;\n  evaluator<LhsArg> m_lhsImpl;\n  evaluator<RhsArg> m_rhsImpl;\n};\n\n// \"dense ^ sparse\"\ntemplate<typename XprType>\nstruct sparse_conjunction_evaluator<XprType, IndexBased, IteratorBased>\n  : evaluator_base<XprType>\n{\nprotected:\n  typedef typename XprType::Functor BinaryOp;\n  typedef typename XprType::Lhs LhsArg;\n  typedef typename XprType::Rhs RhsArg;\n  typedef evaluator<LhsArg> LhsEvaluator;\n  typedef typename evaluator<RhsArg>::InnerIterator  RhsIterator;\n  typedef typename XprType::StorageIndex StorageIndex;\n  typedef typename traits<XprType>::Scalar Scalar;\npublic:\n\n  class InnerIterator\n  {\n    enum { IsRowMajor = (int(RhsArg::Flags)&RowMajorBit)==RowMajorBit };\n\n  public:\n    \n    EIGEN_STRONG_INLINE InnerIterator(const sparse_conjunction_evaluator& aEval, Index outer)\n      : m_lhsEval(aEval.m_lhsImpl), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor), m_outer(outer)\n    {}\n\n    EIGEN_STRONG_INLINE InnerIterator& operator++()\n    {\n      ++m_rhsIter;\n      return *this;\n    }\n\n    EIGEN_STRONG_INLINE Scalar value() const\n    { return m_functor(m_lhsEval.coeff(IsRowMajor?m_outer:m_rhsIter.index(),IsRowMajor?m_rhsIter.index():m_outer), m_rhsIter.value()); }\n\n    EIGEN_STRONG_INLINE StorageIndex index() const { return m_rhsIter.index(); }\n    EIGEN_STRONG_INLINE Index outer() const { return m_rhsIter.outer(); }\n    EIGEN_STRONG_INLINE Index row() const { return m_rhsIter.row(); }\n    EIGEN_STRONG_INLINE Index col() const { return m_rhsIter.col(); }\n\n    EIGEN_STRONG_INLINE operator bool() const { return m_rhsIter; }\n    \n  protected:\n    const LhsEvaluator &m_lhsEval;\n    RhsIterator m_rhsIter;\n    const BinaryOp& m_functor;\n    const Index m_outer;\n  };\n  \n  \n  enum {\n    CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,\n    // Expose storage order of the sparse expression\n    Flags = (XprType::Flags & ~RowMajorBit) | (int(RhsArg::Flags)&RowMajorBit)\n  };\n  \n  explicit sparse_conjunction_evaluator(const XprType& xpr)\n    : m_functor(xpr.functor()),\n      m_lhsImpl(xpr.lhs()), \n      m_rhsImpl(xpr.rhs())  \n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n  \n  inline Index nonZerosEstimate() const {\n    return m_rhsImpl.nonZerosEstimate();\n  }\n\nprotected:\n  const BinaryOp m_functor;\n  evaluator<LhsArg> m_lhsImpl;\n  evaluator<RhsArg> m_rhsImpl;\n};\n\n// \"sparse ^ dense\"\ntemplate<typename XprType>\nstruct sparse_conjunction_evaluator<XprType, IteratorBased, IndexBased>\n  : evaluator_base<XprType>\n{\nprotected:\n  typedef typename XprType::Functor BinaryOp;\n  typedef typename XprType::Lhs LhsArg;\n  typedef typename XprType::Rhs RhsArg;\n  typedef typename evaluator<LhsArg>::InnerIterator LhsIterator;\n  typedef evaluator<RhsArg> RhsEvaluator;\n  typedef typename XprType::StorageIndex StorageIndex;\n  typedef typename traits<XprType>::Scalar Scalar;\npublic:\n\n  class InnerIterator\n  {\n    enum { IsRowMajor = (int(LhsArg::Flags)&RowMajorBit)==RowMajorBit };\n\n  public:\n    \n    EIGEN_STRONG_INLINE InnerIterator(const sparse_conjunction_evaluator& aEval, Index outer)\n      : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsEval(aEval.m_rhsImpl), m_functor(aEval.m_functor), m_outer(outer)\n    {}\n\n    EIGEN_STRONG_INLINE InnerIterator& operator++()\n    {\n      ++m_lhsIter;\n      return *this;\n    }\n\n    EIGEN_STRONG_INLINE Scalar value() const\n    { return m_functor(m_lhsIter.value(),\n                       m_rhsEval.coeff(IsRowMajor?m_outer:m_lhsIter.index(),IsRowMajor?m_lhsIter.index():m_outer)); }\n\n    EIGEN_STRONG_INLINE StorageIndex index() const { return m_lhsIter.index(); }\n    EIGEN_STRONG_INLINE Index outer() const { return m_lhsIter.outer(); }\n    EIGEN_STRONG_INLINE Index row() const { return m_lhsIter.row(); }\n    EIGEN_STRONG_INLINE Index col() const { return m_lhsIter.col(); }\n\n    EIGEN_STRONG_INLINE operator bool() const { return m_lhsIter; }\n    \n  protected:\n    LhsIterator m_lhsIter;\n    const evaluator<RhsArg> &m_rhsEval;\n    const BinaryOp& m_functor;\n    const Index m_outer;\n  };\n  \n  \n  enum {\n    CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,\n    // Expose storage order of the sparse expression\n    Flags = (XprType::Flags & ~RowMajorBit) | (int(LhsArg::Flags)&RowMajorBit)\n  };\n  \n  explicit sparse_conjunction_evaluator(const XprType& xpr)\n    : m_functor(xpr.functor()),\n      m_lhsImpl(xpr.lhs()), \n      m_rhsImpl(xpr.rhs())  \n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n  \n  inline Index nonZerosEstimate() const {\n    return m_lhsImpl.nonZerosEstimate();\n  }\n\nprotected:\n  const BinaryOp m_functor;\n  evaluator<LhsArg> m_lhsImpl;\n  evaluator<RhsArg> m_rhsImpl;\n};\n\n}\n\n/***************************************************************************\n* Implementation of SparseMatrixBase and SparseCwise functions/operators\n***************************************************************************/\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nDerived& SparseMatrixBase<Derived>::operator+=(const EigenBase<OtherDerived> &other)\n{\n  call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nDerived& SparseMatrixBase<Derived>::operator-=(const EigenBase<OtherDerived> &other)\n{\n  call_assignment(derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_STRONG_INLINE Derived &\nSparseMatrixBase<Derived>::operator-=(const SparseMatrixBase<OtherDerived> &other)\n{\n  return derived() = derived() - other.derived();\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_STRONG_INLINE Derived &\nSparseMatrixBase<Derived>::operator+=(const SparseMatrixBase<OtherDerived>& other)\n{\n  return derived() = derived() + other.derived();\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nDerived& SparseMatrixBase<Derived>::operator+=(const DiagonalBase<OtherDerived>& other)\n{\n  call_assignment_no_alias(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nDerived& SparseMatrixBase<Derived>::operator-=(const DiagonalBase<OtherDerived>& other)\n{\n  call_assignment_no_alias(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());\n  return derived();\n}\n    \ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nEIGEN_STRONG_INLINE const typename SparseMatrixBase<Derived>::template CwiseProductDenseReturnType<OtherDerived>::Type\nSparseMatrixBase<Derived>::cwiseProduct(const MatrixBase<OtherDerived> &other) const\n{\n  return typename CwiseProductDenseReturnType<OtherDerived>::Type(derived(), other.derived());\n}\n\ntemplate<typename DenseDerived, typename SparseDerived>\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_sum_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>, const DenseDerived, const SparseDerived>\noperator+(const MatrixBase<DenseDerived> &a, const SparseMatrixBase<SparseDerived> &b)\n{\n  return CwiseBinaryOp<internal::scalar_sum_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>, const DenseDerived, const SparseDerived>(a.derived(), b.derived());\n}\n\ntemplate<typename SparseDerived, typename DenseDerived>\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_sum_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>, const SparseDerived, const DenseDerived>\noperator+(const SparseMatrixBase<SparseDerived> &a, const MatrixBase<DenseDerived> &b)\n{\n  return CwiseBinaryOp<internal::scalar_sum_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>, const SparseDerived, const DenseDerived>(a.derived(), b.derived());\n}\n\ntemplate<typename DenseDerived, typename SparseDerived>\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_difference_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>, const DenseDerived, const SparseDerived>\noperator-(const MatrixBase<DenseDerived> &a, const SparseMatrixBase<SparseDerived> &b)\n{\n  return CwiseBinaryOp<internal::scalar_difference_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>, const DenseDerived, const SparseDerived>(a.derived(), b.derived());\n}\n\ntemplate<typename SparseDerived, typename DenseDerived>\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_difference_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>, const SparseDerived, const DenseDerived>\noperator-(const SparseMatrixBase<SparseDerived> &a, const MatrixBase<DenseDerived> &b)\n{\n  return CwiseBinaryOp<internal::scalar_difference_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>, const SparseDerived, const DenseDerived>(a.derived(), b.derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_CWISE_BINARY_OP_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseCwiseUnaryOp.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_CWISE_UNARY_OP_H\n#define EIGEN_SPARSE_CWISE_UNARY_OP_H\n\nnamespace Eigen { \n\nnamespace internal {\n  \ntemplate<typename UnaryOp, typename ArgType>\nstruct unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>\n  : public evaluator_base<CwiseUnaryOp<UnaryOp,ArgType> >\n{\n  public:\n    typedef CwiseUnaryOp<UnaryOp, ArgType> XprType;\n\n    class InnerIterator;\n    \n    enum {\n      CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<UnaryOp>::Cost,\n      Flags = XprType::Flags\n    };\n    \n    explicit unary_evaluator(const XprType& op) : m_functor(op.functor()), m_argImpl(op.nestedExpression())\n    {\n      EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<UnaryOp>::Cost);\n      EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n    }\n    \n    inline Index nonZerosEstimate() const {\n      return m_argImpl.nonZerosEstimate();\n    }\n\n  protected:\n    typedef typename evaluator<ArgType>::InnerIterator        EvalIterator;\n    \n    const UnaryOp m_functor;\n    evaluator<ArgType> m_argImpl;\n};\n\ntemplate<typename UnaryOp, typename ArgType>\nclass unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::InnerIterator\n    : public unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::EvalIterator\n{\n    typedef typename XprType::Scalar Scalar;\n    typedef typename unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::EvalIterator Base;\n  public:\n\n    EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer)\n      : Base(unaryOp.m_argImpl,outer), m_functor(unaryOp.m_functor)\n    {}\n\n    EIGEN_STRONG_INLINE InnerIterator& operator++()\n    { Base::operator++(); return *this; }\n\n    EIGEN_STRONG_INLINE Scalar value() const { return m_functor(Base::value()); }\n\n  protected:\n    const UnaryOp m_functor;\n  private:\n    Scalar& valueRef();\n};\n\ntemplate<typename ViewOp, typename ArgType>\nstruct unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>\n  : public evaluator_base<CwiseUnaryView<ViewOp,ArgType> >\n{\n  public:\n    typedef CwiseUnaryView<ViewOp, ArgType> XprType;\n\n    class InnerIterator;\n    \n    enum {\n      CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<ViewOp>::Cost,\n      Flags = XprType::Flags\n    };\n    \n    explicit unary_evaluator(const XprType& op) : m_functor(op.functor()), m_argImpl(op.nestedExpression())\n    {\n      EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<ViewOp>::Cost);\n      EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n    }\n\n  protected:\n    typedef typename evaluator<ArgType>::InnerIterator        EvalIterator;\n    \n    const ViewOp m_functor;\n    evaluator<ArgType> m_argImpl;\n};\n\ntemplate<typename ViewOp, typename ArgType>\nclass unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::InnerIterator\n    : public unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::EvalIterator\n{\n    typedef typename XprType::Scalar Scalar;\n    typedef typename unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::EvalIterator Base;\n  public:\n\n    EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer)\n      : Base(unaryOp.m_argImpl,outer), m_functor(unaryOp.m_functor)\n    {}\n\n    EIGEN_STRONG_INLINE InnerIterator& operator++()\n    { Base::operator++(); return *this; }\n\n    EIGEN_STRONG_INLINE Scalar value() const { return m_functor(Base::value()); }\n    EIGEN_STRONG_INLINE Scalar& valueRef() { return m_functor(Base::valueRef()); }\n\n  protected:\n    const ViewOp m_functor;\n};\n\n} // end namespace internal\n\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE Derived&\nSparseMatrixBase<Derived>::operator*=(const Scalar& other)\n{\n  typedef typename internal::evaluator<Derived>::InnerIterator EvalIterator;\n  internal::evaluator<Derived> thisEval(derived());\n  for (Index j=0; j<outerSize(); ++j)\n    for (EvalIterator i(thisEval,j); i; ++i)\n      i.valueRef() *= other;\n  return derived();\n}\n\ntemplate<typename Derived>\nEIGEN_STRONG_INLINE Derived&\nSparseMatrixBase<Derived>::operator/=(const Scalar& other)\n{\n  typedef typename internal::evaluator<Derived>::InnerIterator EvalIterator;\n  internal::evaluator<Derived> thisEval(derived());\n  for (Index j=0; j<outerSize(); ++j)\n    for (EvalIterator i(thisEval,j); i; ++i)\n      i.valueRef() /= other;\n  return derived();\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_CWISE_UNARY_OP_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseDenseProduct.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSEDENSEPRODUCT_H\n#define EIGEN_SPARSEDENSEPRODUCT_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate <> struct product_promote_storage_type<Sparse,Dense, OuterProduct> { typedef Sparse ret; };\ntemplate <> struct product_promote_storage_type<Dense,Sparse, OuterProduct> { typedef Sparse ret; };\n\ntemplate<typename SparseLhsType, typename DenseRhsType, typename DenseResType,\n         typename AlphaType,\n         int LhsStorageOrder = ((SparseLhsType::Flags&RowMajorBit)==RowMajorBit) ? RowMajor : ColMajor,\n         bool ColPerCol = ((DenseRhsType::Flags&RowMajorBit)==0) || DenseRhsType::ColsAtCompileTime==1>\nstruct sparse_time_dense_product_impl;\n\ntemplate<typename SparseLhsType, typename DenseRhsType, typename DenseResType>\nstruct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, typename DenseResType::Scalar, RowMajor, true>\n{\n  typedef typename internal::remove_all<SparseLhsType>::type Lhs;\n  typedef typename internal::remove_all<DenseRhsType>::type Rhs;\n  typedef typename internal::remove_all<DenseResType>::type Res;\n  typedef typename evaluator<Lhs>::InnerIterator LhsInnerIterator;\n  typedef evaluator<Lhs> LhsEval;\n  static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const typename Res::Scalar& alpha)\n  {\n    LhsEval lhsEval(lhs);\n    \n    Index n = lhs.outerSize();\n#ifdef EIGEN_HAS_OPENMP\n    Eigen::initParallel();\n    Index threads = Eigen::nbThreads();\n#endif\n    \n    for(Index c=0; c<rhs.cols(); ++c)\n    {\n#ifdef EIGEN_HAS_OPENMP\n      // This 20000 threshold has been found experimentally on 2D and 3D Poisson problems.\n      // It basically represents the minimal amount of work to be done to be worth it.\n      if(threads>1 && lhsEval.nonZerosEstimate() > 20000)\n      {\n        #pragma omp parallel for schedule(dynamic,(n+threads*4-1)/(threads*4)) num_threads(threads)\n        for(Index i=0; i<n; ++i)\n          processRow(lhsEval,rhs,res,alpha,i,c);\n      }\n      else\n#endif\n      {\n        for(Index i=0; i<n; ++i)\n          processRow(lhsEval,rhs,res,alpha,i,c);\n      }\n    }\n  }\n  \n  static void processRow(const LhsEval& lhsEval, const DenseRhsType& rhs, DenseResType& res, const typename Res::Scalar& alpha, Index i, Index col)\n  {\n    typename Res::Scalar tmp(0);\n    for(LhsInnerIterator it(lhsEval,i); it ;++it)\n      tmp += it.value() * rhs.coeff(it.index(),col);\n    res.coeffRef(i,col) += alpha * tmp;\n  }\n  \n};\n\n// FIXME: what is the purpose of the following specialization? Is it for the BlockedSparse format?\n// -> let's disable it for now as it is conflicting with generic scalar*matrix and matrix*scalar operators\n// template<typename T1, typename T2/*, int _Options, typename _StrideType*/>\n// struct ScalarBinaryOpTraits<T1, Ref<T2/*, _Options, _StrideType*/> >\n// {\n//   enum {\n//     Defined = 1\n//   };\n//   typedef typename CwiseUnaryOp<scalar_multiple2_op<T1, typename T2::Scalar>, T2>::PlainObject ReturnType;\n// };\n\ntemplate<typename SparseLhsType, typename DenseRhsType, typename DenseResType, typename AlphaType>\nstruct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, AlphaType, ColMajor, true>\n{\n  typedef typename internal::remove_all<SparseLhsType>::type Lhs;\n  typedef typename internal::remove_all<DenseRhsType>::type Rhs;\n  typedef typename internal::remove_all<DenseResType>::type Res;\n  typedef typename evaluator<Lhs>::InnerIterator LhsInnerIterator;\n  static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const AlphaType& alpha)\n  {\n    evaluator<Lhs> lhsEval(lhs);\n    for(Index c=0; c<rhs.cols(); ++c)\n    {\n      for(Index j=0; j<lhs.outerSize(); ++j)\n      {\n//        typename Res::Scalar rhs_j = alpha * rhs.coeff(j,c);\n        typename ScalarBinaryOpTraits<AlphaType, typename Rhs::Scalar>::ReturnType rhs_j(alpha * rhs.coeff(j,c));\n        for(LhsInnerIterator it(lhsEval,j); it ;++it)\n          res.coeffRef(it.index(),c) += it.value() * rhs_j;\n      }\n    }\n  }\n};\n\ntemplate<typename SparseLhsType, typename DenseRhsType, typename DenseResType>\nstruct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, typename DenseResType::Scalar, RowMajor, false>\n{\n  typedef typename internal::remove_all<SparseLhsType>::type Lhs;\n  typedef typename internal::remove_all<DenseRhsType>::type Rhs;\n  typedef typename internal::remove_all<DenseResType>::type Res;\n  typedef typename evaluator<Lhs>::InnerIterator LhsInnerIterator;\n  static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const typename Res::Scalar& alpha)\n  {\n    evaluator<Lhs> lhsEval(lhs);\n    for(Index j=0; j<lhs.outerSize(); ++j)\n    {\n      typename Res::RowXpr res_j(res.row(j));\n      for(LhsInnerIterator it(lhsEval,j); it ;++it)\n        res_j += (alpha*it.value()) * rhs.row(it.index());\n    }\n  }\n};\n\ntemplate<typename SparseLhsType, typename DenseRhsType, typename DenseResType>\nstruct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, typename DenseResType::Scalar, ColMajor, false>\n{\n  typedef typename internal::remove_all<SparseLhsType>::type Lhs;\n  typedef typename internal::remove_all<DenseRhsType>::type Rhs;\n  typedef typename internal::remove_all<DenseResType>::type Res;\n  typedef typename evaluator<Lhs>::InnerIterator LhsInnerIterator;\n  static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const typename Res::Scalar& alpha)\n  {\n    evaluator<Lhs> lhsEval(lhs);\n    for(Index j=0; j<lhs.outerSize(); ++j)\n    {\n      typename Rhs::ConstRowXpr rhs_j(rhs.row(j));\n      for(LhsInnerIterator it(lhsEval,j); it ;++it)\n        res.row(it.index()) += (alpha*it.value()) * rhs_j;\n    }\n  }\n};\n\ntemplate<typename SparseLhsType, typename DenseRhsType, typename DenseResType,typename AlphaType>\ninline void sparse_time_dense_product(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const AlphaType& alpha)\n{\n  sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, AlphaType>::run(lhs, rhs, res, alpha);\n}\n\n} // end namespace internal\n\nnamespace internal {\n\ntemplate<typename Lhs, typename Rhs, int ProductType>\nstruct generic_product_impl<Lhs, Rhs, SparseShape, DenseShape, ProductType>\n : generic_product_impl_base<Lhs,Rhs,generic_product_impl<Lhs,Rhs,SparseShape,DenseShape,ProductType> >\n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  \n  template<typename Dest>\n  static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)\n  {\n    typedef typename nested_eval<Lhs,((Rhs::Flags&RowMajorBit)==0) ? 1 : Rhs::ColsAtCompileTime>::type LhsNested;\n    typedef typename nested_eval<Rhs,((Lhs::Flags&RowMajorBit)==0) ? 1 : Dynamic>::type RhsNested;\n    LhsNested lhsNested(lhs);\n    RhsNested rhsNested(rhs);\n    internal::sparse_time_dense_product(lhsNested, rhsNested, dst, alpha);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductType>\nstruct generic_product_impl<Lhs, Rhs, SparseTriangularShape, DenseShape, ProductType>\n  : generic_product_impl<Lhs, Rhs, SparseShape, DenseShape, ProductType>\n{};\n\ntemplate<typename Lhs, typename Rhs, int ProductType>\nstruct generic_product_impl<Lhs, Rhs, DenseShape, SparseShape, ProductType>\n  : generic_product_impl_base<Lhs,Rhs,generic_product_impl<Lhs,Rhs,DenseShape,SparseShape,ProductType> >\n{\n  typedef typename Product<Lhs,Rhs>::Scalar Scalar;\n  \n  template<typename Dst>\n  static void scaleAndAddTo(Dst& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)\n  {\n    typedef typename nested_eval<Lhs,((Rhs::Flags&RowMajorBit)==0) ? Dynamic : 1>::type LhsNested;\n    typedef typename nested_eval<Rhs,((Lhs::Flags&RowMajorBit)==RowMajorBit) ? 1 : Lhs::RowsAtCompileTime>::type RhsNested;\n    LhsNested lhsNested(lhs);\n    RhsNested rhsNested(rhs);\n    \n    // transpose everything\n    Transpose<Dst> dstT(dst);\n    internal::sparse_time_dense_product(rhsNested.transpose(), lhsNested.transpose(), dstT, alpha);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductType>\nstruct generic_product_impl<Lhs, Rhs, DenseShape, SparseTriangularShape, ProductType>\n  : generic_product_impl<Lhs, Rhs, DenseShape, SparseShape, ProductType>\n{};\n\ntemplate<typename LhsT, typename RhsT, bool NeedToTranspose>\nstruct sparse_dense_outer_product_evaluator\n{\nprotected:\n  typedef typename conditional<NeedToTranspose,RhsT,LhsT>::type Lhs1;\n  typedef typename conditional<NeedToTranspose,LhsT,RhsT>::type ActualRhs;\n  typedef Product<LhsT,RhsT,DefaultProduct> ProdXprType;\n  \n  // if the actual left-hand side is a dense vector,\n  // then build a sparse-view so that we can seamlessly iterate over it.\n  typedef typename conditional<is_same<typename internal::traits<Lhs1>::StorageKind,Sparse>::value,\n            Lhs1, SparseView<Lhs1> >::type ActualLhs;\n  typedef typename conditional<is_same<typename internal::traits<Lhs1>::StorageKind,Sparse>::value,\n            Lhs1 const&, SparseView<Lhs1> >::type LhsArg;\n            \n  typedef evaluator<ActualLhs> LhsEval;\n  typedef evaluator<ActualRhs> RhsEval;\n  typedef typename evaluator<ActualLhs>::InnerIterator LhsIterator;\n  typedef typename ProdXprType::Scalar Scalar;\n  \npublic:\n  enum {\n    Flags = NeedToTranspose ? RowMajorBit : 0,\n    CoeffReadCost = HugeCost\n  };\n  \n  class InnerIterator : public LhsIterator\n  {\n  public:\n    InnerIterator(const sparse_dense_outer_product_evaluator &xprEval, Index outer)\n      : LhsIterator(xprEval.m_lhsXprImpl, 0),\n        m_outer(outer),\n        m_empty(false),\n        m_factor(get(xprEval.m_rhsXprImpl, outer, typename internal::traits<ActualRhs>::StorageKind() ))\n    {}\n    \n    EIGEN_STRONG_INLINE Index outer() const { return m_outer; }\n    EIGEN_STRONG_INLINE Index row()   const { return NeedToTranspose ? m_outer : LhsIterator::index(); }\n    EIGEN_STRONG_INLINE Index col()   const { return NeedToTranspose ? LhsIterator::index() : m_outer; }\n\n    EIGEN_STRONG_INLINE Scalar value() const { return LhsIterator::value() * m_factor; }\n    EIGEN_STRONG_INLINE operator bool() const { return LhsIterator::operator bool() && (!m_empty); }\n    \n  protected:\n    Scalar get(const RhsEval &rhs, Index outer, Dense = Dense()) const\n    {\n      return rhs.coeff(outer);\n    }\n    \n    Scalar get(const RhsEval &rhs, Index outer, Sparse = Sparse())\n    {\n      typename RhsEval::InnerIterator it(rhs, outer);\n      if (it && it.index()==0 && it.value()!=Scalar(0))\n        return it.value();\n      m_empty = true;\n      return Scalar(0);\n    }\n    \n    Index m_outer;\n    bool m_empty;\n    Scalar m_factor;\n  };\n  \n  sparse_dense_outer_product_evaluator(const Lhs1 &lhs, const ActualRhs &rhs)\n     : m_lhs(lhs), m_lhsXprImpl(m_lhs), m_rhsXprImpl(rhs)\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n  \n  // transpose case\n  sparse_dense_outer_product_evaluator(const ActualRhs &rhs, const Lhs1 &lhs)\n     : m_lhs(lhs), m_lhsXprImpl(m_lhs), m_rhsXprImpl(rhs)\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n    \nprotected:\n  const LhsArg m_lhs;\n  evaluator<ActualLhs> m_lhsXprImpl;\n  evaluator<ActualRhs> m_rhsXprImpl;\n};\n\n// sparse * dense outer product\ntemplate<typename Lhs, typename Rhs>\nstruct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, OuterProduct, SparseShape, DenseShape>\n  : sparse_dense_outer_product_evaluator<Lhs,Rhs, Lhs::IsRowMajor>\n{\n  typedef sparse_dense_outer_product_evaluator<Lhs,Rhs, Lhs::IsRowMajor> Base;\n  \n  typedef Product<Lhs, Rhs> XprType;\n  typedef typename XprType::PlainObject PlainObject;\n\n  explicit product_evaluator(const XprType& xpr)\n    : Base(xpr.lhs(), xpr.rhs())\n  {}\n  \n};\n\ntemplate<typename Lhs, typename Rhs>\nstruct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, OuterProduct, DenseShape, SparseShape>\n  : sparse_dense_outer_product_evaluator<Lhs,Rhs, Rhs::IsRowMajor>\n{\n  typedef sparse_dense_outer_product_evaluator<Lhs,Rhs, Rhs::IsRowMajor> Base;\n  \n  typedef Product<Lhs, Rhs> XprType;\n  typedef typename XprType::PlainObject PlainObject;\n\n  explicit product_evaluator(const XprType& xpr)\n    : Base(xpr.lhs(), xpr.rhs())\n  {}\n  \n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSEDENSEPRODUCT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseDiagonalProduct.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_DIAGONAL_PRODUCT_H\n#define EIGEN_SPARSE_DIAGONAL_PRODUCT_H\n\nnamespace Eigen { \n\n// The product of a diagonal matrix with a sparse matrix can be easily\n// implemented using expression template.\n// We have two consider very different cases:\n// 1 - diag * row-major sparse\n//     => each inner vector <=> scalar * sparse vector product\n//     => so we can reuse CwiseUnaryOp::InnerIterator\n// 2 - diag * col-major sparse\n//     => each inner vector <=> densevector * sparse vector cwise product\n//     => again, we can reuse specialization of CwiseBinaryOp::InnerIterator\n//        for that particular case\n// The two other cases are symmetric.\n\nnamespace internal {\n\nenum {\n  SDP_AsScalarProduct,\n  SDP_AsCwiseProduct\n};\n  \ntemplate<typename SparseXprType, typename DiagonalCoeffType, int SDP_Tag>\nstruct sparse_diagonal_product_evaluator;\n\ntemplate<typename Lhs, typename Rhs, int ProductTag>\nstruct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, DiagonalShape, SparseShape>\n  : public sparse_diagonal_product_evaluator<Rhs, typename Lhs::DiagonalVectorType, Rhs::Flags&RowMajorBit?SDP_AsScalarProduct:SDP_AsCwiseProduct>\n{\n  typedef Product<Lhs, Rhs, DefaultProduct> XprType;\n  enum { CoeffReadCost = HugeCost, Flags = Rhs::Flags&RowMajorBit, Alignment = 0 }; // FIXME CoeffReadCost & Flags\n  \n  typedef sparse_diagonal_product_evaluator<Rhs, typename Lhs::DiagonalVectorType, Rhs::Flags&RowMajorBit?SDP_AsScalarProduct:SDP_AsCwiseProduct> Base;\n  explicit product_evaluator(const XprType& xpr) : Base(xpr.rhs(), xpr.lhs().diagonal()) {}\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag>\nstruct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, SparseShape, DiagonalShape>\n  : public sparse_diagonal_product_evaluator<Lhs, Transpose<const typename Rhs::DiagonalVectorType>, Lhs::Flags&RowMajorBit?SDP_AsCwiseProduct:SDP_AsScalarProduct>\n{\n  typedef Product<Lhs, Rhs, DefaultProduct> XprType;\n  enum { CoeffReadCost = HugeCost, Flags = Lhs::Flags&RowMajorBit, Alignment = 0 }; // FIXME CoeffReadCost & Flags\n  \n  typedef sparse_diagonal_product_evaluator<Lhs, Transpose<const typename Rhs::DiagonalVectorType>, Lhs::Flags&RowMajorBit?SDP_AsCwiseProduct:SDP_AsScalarProduct> Base;\n  explicit product_evaluator(const XprType& xpr) : Base(xpr.lhs(), xpr.rhs().diagonal().transpose()) {}\n};\n\ntemplate<typename SparseXprType, typename DiagonalCoeffType>\nstruct sparse_diagonal_product_evaluator<SparseXprType, DiagonalCoeffType, SDP_AsScalarProduct>\n{\nprotected:\n  typedef typename evaluator<SparseXprType>::InnerIterator SparseXprInnerIterator;\n  typedef typename SparseXprType::Scalar Scalar;\n  \npublic:\n  class InnerIterator : public SparseXprInnerIterator\n  {\n  public:\n    InnerIterator(const sparse_diagonal_product_evaluator &xprEval, Index outer)\n      : SparseXprInnerIterator(xprEval.m_sparseXprImpl, outer),\n        m_coeff(xprEval.m_diagCoeffImpl.coeff(outer))\n    {}\n    \n    EIGEN_STRONG_INLINE Scalar value() const { return m_coeff * SparseXprInnerIterator::value(); }\n  protected:\n    typename DiagonalCoeffType::Scalar m_coeff;\n  };\n  \n  sparse_diagonal_product_evaluator(const SparseXprType &sparseXpr, const DiagonalCoeffType &diagCoeff)\n    : m_sparseXprImpl(sparseXpr), m_diagCoeffImpl(diagCoeff)\n  {}\n\n  Index nonZerosEstimate() const { return m_sparseXprImpl.nonZerosEstimate(); }\n    \nprotected:\n  evaluator<SparseXprType> m_sparseXprImpl;\n  evaluator<DiagonalCoeffType> m_diagCoeffImpl;\n};\n\n\ntemplate<typename SparseXprType, typename DiagCoeffType>\nstruct sparse_diagonal_product_evaluator<SparseXprType, DiagCoeffType, SDP_AsCwiseProduct>\n{\n  typedef typename SparseXprType::Scalar Scalar;\n  typedef typename SparseXprType::StorageIndex StorageIndex;\n  \n  typedef typename nested_eval<DiagCoeffType,SparseXprType::IsRowMajor ? SparseXprType::RowsAtCompileTime\n                                                                       : SparseXprType::ColsAtCompileTime>::type DiagCoeffNested;\n  \n  class InnerIterator\n  {\n    typedef typename evaluator<SparseXprType>::InnerIterator SparseXprIter;\n  public:\n    InnerIterator(const sparse_diagonal_product_evaluator &xprEval, Index outer)\n      : m_sparseIter(xprEval.m_sparseXprEval, outer), m_diagCoeffNested(xprEval.m_diagCoeffNested)\n    {}\n    \n    inline Scalar value() const { return m_sparseIter.value() * m_diagCoeffNested.coeff(index()); }\n    inline StorageIndex index() const  { return m_sparseIter.index(); }\n    inline Index outer() const  { return m_sparseIter.outer(); }\n    inline Index col() const    { return SparseXprType::IsRowMajor ? m_sparseIter.index() : m_sparseIter.outer(); }\n    inline Index row() const    { return SparseXprType::IsRowMajor ? m_sparseIter.outer() : m_sparseIter.index(); }\n    \n    EIGEN_STRONG_INLINE InnerIterator& operator++() { ++m_sparseIter; return *this; }\n    inline operator bool() const  { return m_sparseIter; }\n    \n  protected:\n    SparseXprIter m_sparseIter;\n    DiagCoeffNested m_diagCoeffNested;\n  };\n  \n  sparse_diagonal_product_evaluator(const SparseXprType &sparseXpr, const DiagCoeffType &diagCoeff)\n    : m_sparseXprEval(sparseXpr), m_diagCoeffNested(diagCoeff)\n  {}\n\n  Index nonZerosEstimate() const { return m_sparseXprEval.nonZerosEstimate(); }\n    \nprotected:\n  evaluator<SparseXprType> m_sparseXprEval;\n  DiagCoeffNested m_diagCoeffNested;\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_DIAGONAL_PRODUCT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseDot.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_DOT_H\n#define EIGEN_SPARSE_DOT_H\n\nnamespace Eigen { \n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\ntypename internal::traits<Derived>::Scalar\nSparseMatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n  EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)\n  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),\n    YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)\n\n  eigen_assert(size() == other.size());\n  eigen_assert(other.size()>0 && \"you are using a non initialized vector\");\n\n  internal::evaluator<Derived> thisEval(derived());\n  typename internal::evaluator<Derived>::InnerIterator i(thisEval, 0);\n  Scalar res(0);\n  while (i)\n  {\n    res += numext::conj(i.value()) * other.coeff(i.index());\n    ++i;\n  }\n  return res;\n}\n\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\ntypename internal::traits<Derived>::Scalar\nSparseMatrixBase<Derived>::dot(const SparseMatrixBase<OtherDerived>& other) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)\n  EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)\n  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),\n    YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)\n\n  eigen_assert(size() == other.size());\n\n  internal::evaluator<Derived> thisEval(derived());\n  typename internal::evaluator<Derived>::InnerIterator i(thisEval, 0);\n  \n  internal::evaluator<OtherDerived>  otherEval(other.derived());\n  typename internal::evaluator<OtherDerived>::InnerIterator j(otherEval, 0);\n\n  Scalar res(0);\n  while (i && j)\n  {\n    if (i.index()==j.index())\n    {\n      res += numext::conj(i.value()) * j.value();\n      ++i; ++j;\n    }\n    else if (i.index()<j.index())\n      ++i;\n    else\n      ++j;\n  }\n  return res;\n}\n\ntemplate<typename Derived>\ninline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real\nSparseMatrixBase<Derived>::squaredNorm() const\n{\n  return numext::real((*this).cwiseAbs2().sum());\n}\n\ntemplate<typename Derived>\ninline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real\nSparseMatrixBase<Derived>::norm() const\n{\n  using std::sqrt;\n  return sqrt(squaredNorm());\n}\n\ntemplate<typename Derived>\ninline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real\nSparseMatrixBase<Derived>::blueNorm() const\n{\n  return internal::blueNorm_impl(*this);\n}\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_DOT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseFuzzy.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_FUZZY_H\n#define EIGEN_SPARSE_FUZZY_H\n\nnamespace Eigen {\n  \ntemplate<typename Derived>\ntemplate<typename OtherDerived>\nbool SparseMatrixBase<Derived>::isApprox(const SparseMatrixBase<OtherDerived>& other, const RealScalar &prec) const\n{\n  const typename internal::nested_eval<Derived,2,PlainObject>::type actualA(derived());\n  typename internal::conditional<bool(IsRowMajor)==bool(OtherDerived::IsRowMajor),\n    const typename internal::nested_eval<OtherDerived,2,PlainObject>::type,\n    const PlainObject>::type actualB(other.derived());\n\n  return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_FUZZY_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseMap.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_MAP_H\n#define EIGEN_SPARSE_MAP_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nstruct traits<Map<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n  : public traits<SparseMatrix<MatScalar,MatOptions,MatIndex> >\n{\n  typedef SparseMatrix<MatScalar,MatOptions,MatIndex> PlainObjectType;\n  typedef traits<PlainObjectType> TraitsBase;\n  enum {\n    Flags = TraitsBase::Flags & (~NestByRefBit)\n  };\n};\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nstruct traits<Map<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n  : public traits<SparseMatrix<MatScalar,MatOptions,MatIndex> >\n{\n  typedef SparseMatrix<MatScalar,MatOptions,MatIndex> PlainObjectType;\n  typedef traits<PlainObjectType> TraitsBase;\n  enum {\n    Flags = TraitsBase::Flags & (~ (NestByRefBit | LvalueBit))\n  };\n};\n\n} // end namespace internal\n\ntemplate<typename Derived,\n         int Level = internal::accessors_level<Derived>::has_write_access ? WriteAccessors : ReadOnlyAccessors\n> class SparseMapBase;\n\n/** \\ingroup SparseCore_Module\n  * class SparseMapBase\n  * \\brief Common base class for Map and Ref instance of sparse matrix and vector.\n  */\ntemplate<typename Derived>\nclass SparseMapBase<Derived,ReadOnlyAccessors>\n  : public SparseCompressedBase<Derived>\n{\n  public:\n    typedef SparseCompressedBase<Derived> Base;\n    typedef typename Base::Scalar Scalar;\n    typedef typename Base::StorageIndex StorageIndex;\n    enum { IsRowMajor = Base::IsRowMajor };\n    using Base::operator=;\n  protected:\n    \n    typedef typename internal::conditional<\n                         bool(internal::is_lvalue<Derived>::value),\n                         Scalar *, const Scalar *>::type ScalarPointer;\n    typedef typename internal::conditional<\n                         bool(internal::is_lvalue<Derived>::value),\n                         StorageIndex *, const StorageIndex *>::type IndexPointer;\n\n    Index   m_outerSize;\n    Index   m_innerSize;\n    Array<StorageIndex,2,1>  m_zero_nnz;\n    IndexPointer  m_outerIndex;\n    IndexPointer  m_innerIndices;\n    ScalarPointer m_values;\n    IndexPointer  m_innerNonZeros;\n\n  public:\n\n    /** \\copydoc SparseMatrixBase::rows() */\n    inline Index rows() const { return IsRowMajor ? m_outerSize : m_innerSize; }\n    /** \\copydoc SparseMatrixBase::cols() */\n    inline Index cols() const { return IsRowMajor ? m_innerSize : m_outerSize; }\n    /** \\copydoc SparseMatrixBase::innerSize() */\n    inline Index innerSize() const { return m_innerSize; }\n    /** \\copydoc SparseMatrixBase::outerSize() */\n    inline Index outerSize() const { return m_outerSize; }\n    /** \\copydoc SparseCompressedBase::nonZeros */\n    inline Index nonZeros() const { return m_zero_nnz[1]; }\n    \n    /** \\copydoc SparseCompressedBase::isCompressed */\n    bool isCompressed() const { return m_innerNonZeros==0; }\n\n    //----------------------------------------\n    // direct access interface\n    /** \\copydoc SparseMatrix::valuePtr */\n    inline const Scalar* valuePtr() const { return m_values; }\n    /** \\copydoc SparseMatrix::innerIndexPtr */\n    inline const StorageIndex* innerIndexPtr() const { return m_innerIndices; }\n    /** \\copydoc SparseMatrix::outerIndexPtr */\n    inline const StorageIndex* outerIndexPtr() const { return m_outerIndex; }\n    /** \\copydoc SparseMatrix::innerNonZeroPtr */\n    inline const StorageIndex* innerNonZeroPtr() const { return m_innerNonZeros; }\n    //----------------------------------------\n\n    /** \\copydoc SparseMatrix::coeff */\n    inline Scalar coeff(Index row, Index col) const\n    {\n      const Index outer = IsRowMajor ? row : col;\n      const Index inner = IsRowMajor ? col : row;\n\n      Index start = m_outerIndex[outer];\n      Index end = isCompressed() ? m_outerIndex[outer+1] : start + m_innerNonZeros[outer];\n      if (start==end)\n        return Scalar(0);\n      else if (end>0 && inner==m_innerIndices[end-1])\n        return m_values[end-1];\n      // ^^  optimization: let's first check if it is the last coefficient\n      // (very common in high level algorithms)\n\n      const StorageIndex* r = std::lower_bound(&m_innerIndices[start],&m_innerIndices[end-1],inner);\n      const Index id = r-&m_innerIndices[0];\n      return ((*r==inner) && (id<end)) ? m_values[id] : Scalar(0);\n    }\n\n    inline SparseMapBase(Index rows, Index cols, Index nnz, IndexPointer outerIndexPtr, IndexPointer innerIndexPtr,\n                              ScalarPointer valuePtr, IndexPointer innerNonZerosPtr = 0)\n      : m_outerSize(IsRowMajor?rows:cols), m_innerSize(IsRowMajor?cols:rows), m_zero_nnz(0,internal::convert_index<StorageIndex>(nnz)), m_outerIndex(outerIndexPtr),\n        m_innerIndices(innerIndexPtr), m_values(valuePtr), m_innerNonZeros(innerNonZerosPtr)\n    {}\n\n    // for vectors\n    inline SparseMapBase(Index size, Index nnz, IndexPointer innerIndexPtr, ScalarPointer valuePtr)\n      : m_outerSize(1), m_innerSize(size), m_zero_nnz(0,internal::convert_index<StorageIndex>(nnz)), m_outerIndex(m_zero_nnz.data()),\n        m_innerIndices(innerIndexPtr), m_values(valuePtr), m_innerNonZeros(0)\n    {}\n\n    /** Empty destructor */\n    inline ~SparseMapBase() {}\n\n  protected:\n    inline SparseMapBase() {}\n};\n\n/** \\ingroup SparseCore_Module\n  * class SparseMapBase\n  * \\brief Common base class for writable Map and Ref instance of sparse matrix and vector.\n  */\ntemplate<typename Derived>\nclass SparseMapBase<Derived,WriteAccessors>\n  : public SparseMapBase<Derived,ReadOnlyAccessors>\n{\n    typedef MapBase<Derived, ReadOnlyAccessors> ReadOnlyMapBase;\n    \n  public:\n    typedef SparseMapBase<Derived, ReadOnlyAccessors> Base;\n    typedef typename Base::Scalar Scalar;\n    typedef typename Base::StorageIndex StorageIndex;\n    enum { IsRowMajor = Base::IsRowMajor };\n    \n    using Base::operator=;\n\n  public:\n    \n    //----------------------------------------\n    // direct access interface\n    using Base::valuePtr;\n    using Base::innerIndexPtr;\n    using Base::outerIndexPtr;\n    using Base::innerNonZeroPtr;\n    /** \\copydoc SparseMatrix::valuePtr */\n    inline Scalar* valuePtr()              { return Base::m_values; }\n    /** \\copydoc SparseMatrix::innerIndexPtr */\n    inline StorageIndex* innerIndexPtr()   { return Base::m_innerIndices; }\n    /** \\copydoc SparseMatrix::outerIndexPtr */\n    inline StorageIndex* outerIndexPtr()   { return Base::m_outerIndex; }\n    /** \\copydoc SparseMatrix::innerNonZeroPtr */\n    inline StorageIndex* innerNonZeroPtr() { return Base::m_innerNonZeros; }\n    //----------------------------------------\n\n    /** \\copydoc SparseMatrix::coeffRef */\n    inline Scalar& coeffRef(Index row, Index col)\n    {\n      const Index outer = IsRowMajor ? row : col;\n      const Index inner = IsRowMajor ? col : row;\n\n      Index start = Base::m_outerIndex[outer];\n      Index end = Base::isCompressed() ? Base::m_outerIndex[outer+1] : start + Base::m_innerNonZeros[outer];\n      eigen_assert(end>=start && \"you probably called coeffRef on a non finalized matrix\");\n      eigen_assert(end>start && \"coeffRef cannot be called on a zero coefficient\");\n      StorageIndex* r = std::lower_bound(&Base::m_innerIndices[start],&Base::m_innerIndices[end],inner);\n      const Index id = r - &Base::m_innerIndices[0];\n      eigen_assert((*r==inner) && (id<end) && \"coeffRef cannot be called on a zero coefficient\");\n      return const_cast<Scalar*>(Base::m_values)[id];\n    }\n    \n    inline SparseMapBase(Index rows, Index cols, Index nnz, StorageIndex* outerIndexPtr, StorageIndex* innerIndexPtr,\n                         Scalar* valuePtr, StorageIndex* innerNonZerosPtr = 0)\n      : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZerosPtr)\n    {}\n\n    // for vectors\n    inline SparseMapBase(Index size, Index nnz, StorageIndex* innerIndexPtr, Scalar* valuePtr)\n      : Base(size, nnz, innerIndexPtr, valuePtr)\n    {}\n\n    /** Empty destructor */\n    inline ~SparseMapBase() {}\n\n  protected:\n    inline SparseMapBase() {}\n};\n\n/** \\ingroup SparseCore_Module\n  *\n  * \\brief Specialization of class Map for SparseMatrix-like storage.\n  *\n  * \\tparam SparseMatrixType the equivalent sparse matrix type of the referenced data, it must be a template instance of class SparseMatrix.\n  *\n  * \\sa class Map, class SparseMatrix, class Ref<SparseMatrixType,Options>\n  */\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nclass Map<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType>\n  : public SparseMapBase<Map<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n#else\ntemplate<typename SparseMatrixType>\nclass Map<SparseMatrixType>\n  : public SparseMapBase<Derived,WriteAccessors>\n#endif\n{\n  public:\n    typedef SparseMapBase<Map> Base;\n    EIGEN_SPARSE_PUBLIC_INTERFACE(Map)\n    enum { IsRowMajor = Base::IsRowMajor };\n\n  public:\n\n    /** Constructs a read-write Map to a sparse matrix of size \\a rows x \\a cols, containing \\a nnz non-zero coefficients,\n      * stored as a sparse format as defined by the pointers \\a outerIndexPtr, \\a innerIndexPtr, and \\a valuePtr.\n      * If the optional parameter \\a innerNonZerosPtr is the null pointer, then a standard compressed format is assumed.\n      *\n      * This constructor is available only if \\c SparseMatrixType is non-const.\n      *\n      * More details on the expected storage schemes are given in the \\ref TutorialSparse \"manual pages\".\n      */\n    inline Map(Index rows, Index cols, Index nnz, StorageIndex* outerIndexPtr,\n               StorageIndex* innerIndexPtr, Scalar* valuePtr, StorageIndex* innerNonZerosPtr = 0)\n      : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZerosPtr)\n    {}\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** Empty destructor */\n    inline ~Map() {}\n};\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nclass Map<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType>\n  : public SparseMapBase<Map<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n{\n  public:\n    typedef SparseMapBase<Map> Base;\n    EIGEN_SPARSE_PUBLIC_INTERFACE(Map)\n    enum { IsRowMajor = Base::IsRowMajor };\n\n  public:\n#endif\n    /** This is the const version of the above constructor.\n      *\n      * This constructor is available only if \\c SparseMatrixType is const, e.g.:\n      * \\code Map<const SparseMatrix<double> >  \\endcode\n      */\n    inline Map(Index rows, Index cols, Index nnz, const StorageIndex* outerIndexPtr,\n               const StorageIndex* innerIndexPtr, const Scalar* valuePtr, const StorageIndex* innerNonZerosPtr = 0)\n      : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZerosPtr)\n    {}\n\n    /** Empty destructor */\n    inline ~Map() {}\n};\n\nnamespace internal {\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nstruct evaluator<Map<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n  : evaluator<SparseCompressedBase<Map<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >\n{\n  typedef evaluator<SparseCompressedBase<Map<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;\n  typedef Map<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> XprType;  \n  evaluator() : Base() {}\n  explicit evaluator(const XprType &mat) : Base(mat) {}\n};\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nstruct evaluator<Map<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n  : evaluator<SparseCompressedBase<Map<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >\n{\n  typedef evaluator<SparseCompressedBase<Map<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;\n  typedef Map<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> XprType;  \n  evaluator() : Base() {}\n  explicit evaluator(const XprType &mat) : Base(mat) {}\n};\n\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_MAP_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseMatrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSEMATRIX_H\n#define EIGEN_SPARSEMATRIX_H\n\nnamespace Eigen { \n\n/** \\ingroup SparseCore_Module\n  *\n  * \\class SparseMatrix\n  *\n  * \\brief A versatible sparse matrix representation\n  *\n  * This class implements a more versatile variants of the common \\em compressed row/column storage format.\n  * Each colmun's (resp. row) non zeros are stored as a pair of value with associated row (resp. colmiun) index.\n  * All the non zeros are stored in a single large buffer. Unlike the \\em compressed format, there might be extra\n  * space inbetween the nonzeros of two successive colmuns (resp. rows) such that insertion of new non-zero\n  * can be done with limited memory reallocation and copies.\n  *\n  * A call to the function makeCompressed() turns the matrix into the standard \\em compressed format\n  * compatible with many library.\n  *\n  * More details on this storage sceheme are given in the \\ref TutorialSparse \"manual pages\".\n  *\n  * \\tparam _Scalar the scalar type, i.e. the type of the coefficients\n  * \\tparam _Options Union of bit flags controlling the storage scheme. Currently the only possibility\n  *                 is ColMajor or RowMajor. The default is 0 which means column-major.\n  * \\tparam _StorageIndex the type of the indices. It has to be a \\b signed type (e.g., short, int, std::ptrdiff_t). Default is \\c int.\n  *\n  * \\warning In %Eigen 3.2, the undocumented type \\c SparseMatrix::Index was improperly defined as the storage index type (e.g., int),\n  *          whereas it is now (starting from %Eigen 3.3) deprecated and always defined as Eigen::Index.\n  *          Codes making use of \\c SparseMatrix::Index, might thus likely have to be changed to use \\c SparseMatrix::StorageIndex instead.\n  *\n  * This class can be extended with the help of the plugin mechanism described on the page\n  * \\ref TopicCustomizing_Plugins by defining the preprocessor symbol \\c EIGEN_SPARSEMATRIX_PLUGIN.\n  */\n\nnamespace internal {\ntemplate<typename _Scalar, int _Options, typename _StorageIndex>\nstruct traits<SparseMatrix<_Scalar, _Options, _StorageIndex> >\n{\n  typedef _Scalar Scalar;\n  typedef _StorageIndex StorageIndex;\n  typedef Sparse StorageKind;\n  typedef MatrixXpr XprKind;\n  enum {\n    RowsAtCompileTime = Dynamic,\n    ColsAtCompileTime = Dynamic,\n    MaxRowsAtCompileTime = Dynamic,\n    MaxColsAtCompileTime = Dynamic,\n    Flags = _Options | NestByRefBit | LvalueBit | CompressedAccessBit,\n    SupportedAccessPatterns = InnerRandomAccessPattern\n  };\n};\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex, int DiagIndex>\nstruct traits<Diagonal<SparseMatrix<_Scalar, _Options, _StorageIndex>, DiagIndex> >\n{\n  typedef SparseMatrix<_Scalar, _Options, _StorageIndex> MatrixType;\n  typedef typename ref_selector<MatrixType>::type MatrixTypeNested;\n  typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;\n\n  typedef _Scalar Scalar;\n  typedef Dense StorageKind;\n  typedef _StorageIndex StorageIndex;\n  typedef MatrixXpr XprKind;\n\n  enum {\n    RowsAtCompileTime = Dynamic,\n    ColsAtCompileTime = 1,\n    MaxRowsAtCompileTime = Dynamic,\n    MaxColsAtCompileTime = 1,\n    Flags = LvalueBit\n  };\n};\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex, int DiagIndex>\nstruct traits<Diagonal<const SparseMatrix<_Scalar, _Options, _StorageIndex>, DiagIndex> >\n : public traits<Diagonal<SparseMatrix<_Scalar, _Options, _StorageIndex>, DiagIndex> >\n{\n  enum {\n    Flags = 0\n  };\n};\n\n} // end namespace internal\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex>\nclass SparseMatrix\n  : public SparseCompressedBase<SparseMatrix<_Scalar, _Options, _StorageIndex> >\n{\n    typedef SparseCompressedBase<SparseMatrix> Base;\n    using Base::convert_index;\n    friend class SparseVector<_Scalar,0,_StorageIndex>;\n  public:\n    using Base::isCompressed;\n    using Base::nonZeros;\n    EIGEN_SPARSE_PUBLIC_INTERFACE(SparseMatrix)\n    using Base::operator+=;\n    using Base::operator-=;\n\n    typedef MappedSparseMatrix<Scalar,Flags> Map;\n    typedef Diagonal<SparseMatrix> DiagonalReturnType;\n    typedef Diagonal<const SparseMatrix> ConstDiagonalReturnType;\n    typedef typename Base::InnerIterator InnerIterator;\n    typedef typename Base::ReverseInnerIterator ReverseInnerIterator;\n    \n\n    using Base::IsRowMajor;\n    typedef internal::CompressedStorage<Scalar,StorageIndex> Storage;\n    enum {\n      Options = _Options\n    };\n\n    typedef typename Base::IndexVector IndexVector;\n    typedef typename Base::ScalarVector ScalarVector;\n  protected:\n    typedef SparseMatrix<Scalar,(Flags&~RowMajorBit)|(IsRowMajor?RowMajorBit:0)> TransposedSparseMatrix;\n\n    Index m_outerSize;\n    Index m_innerSize;\n    StorageIndex* m_outerIndex;\n    StorageIndex* m_innerNonZeros;     // optional, if null then the data is compressed\n    Storage m_data;\n\n  public:\n    \n    /** \\returns the number of rows of the matrix */\n    inline Index rows() const { return IsRowMajor ? m_outerSize : m_innerSize; }\n    /** \\returns the number of columns of the matrix */\n    inline Index cols() const { return IsRowMajor ? m_innerSize : m_outerSize; }\n\n    /** \\returns the number of rows (resp. columns) of the matrix if the storage order column major (resp. row major) */\n    inline Index innerSize() const { return m_innerSize; }\n    /** \\returns the number of columns (resp. rows) of the matrix if the storage order column major (resp. row major) */\n    inline Index outerSize() const { return m_outerSize; }\n    \n    /** \\returns a const pointer to the array of values.\n      * This function is aimed at interoperability with other libraries.\n      * \\sa innerIndexPtr(), outerIndexPtr() */\n    inline const Scalar* valuePtr() const { return m_data.valuePtr(); }\n    /** \\returns a non-const pointer to the array of values.\n      * This function is aimed at interoperability with other libraries.\n      * \\sa innerIndexPtr(), outerIndexPtr() */\n    inline Scalar* valuePtr() { return m_data.valuePtr(); }\n\n    /** \\returns a const pointer to the array of inner indices.\n      * This function is aimed at interoperability with other libraries.\n      * \\sa valuePtr(), outerIndexPtr() */\n    inline const StorageIndex* innerIndexPtr() const { return m_data.indexPtr(); }\n    /** \\returns a non-const pointer to the array of inner indices.\n      * This function is aimed at interoperability with other libraries.\n      * \\sa valuePtr(), outerIndexPtr() */\n    inline StorageIndex* innerIndexPtr() { return m_data.indexPtr(); }\n\n    /** \\returns a const pointer to the array of the starting positions of the inner vectors.\n      * This function is aimed at interoperability with other libraries.\n      * \\sa valuePtr(), innerIndexPtr() */\n    inline const StorageIndex* outerIndexPtr() const { return m_outerIndex; }\n    /** \\returns a non-const pointer to the array of the starting positions of the inner vectors.\n      * This function is aimed at interoperability with other libraries.\n      * \\sa valuePtr(), innerIndexPtr() */\n    inline StorageIndex* outerIndexPtr() { return m_outerIndex; }\n\n    /** \\returns a const pointer to the array of the number of non zeros of the inner vectors.\n      * This function is aimed at interoperability with other libraries.\n      * \\warning it returns the null pointer 0 in compressed mode */\n    inline const StorageIndex* innerNonZeroPtr() const { return m_innerNonZeros; }\n    /** \\returns a non-const pointer to the array of the number of non zeros of the inner vectors.\n      * This function is aimed at interoperability with other libraries.\n      * \\warning it returns the null pointer 0 in compressed mode */\n    inline StorageIndex* innerNonZeroPtr() { return m_innerNonZeros; }\n\n    /** \\internal */\n    inline Storage& data() { return m_data; }\n    /** \\internal */\n    inline const Storage& data() const { return m_data; }\n\n    /** \\returns the value of the matrix at position \\a i, \\a j\n      * This function returns Scalar(0) if the element is an explicit \\em zero */\n    inline Scalar coeff(Index row, Index col) const\n    {\n      eigen_assert(row>=0 && row<rows() && col>=0 && col<cols());\n      \n      const Index outer = IsRowMajor ? row : col;\n      const Index inner = IsRowMajor ? col : row;\n      Index end = m_innerNonZeros ? m_outerIndex[outer] + m_innerNonZeros[outer] : m_outerIndex[outer+1];\n      return m_data.atInRange(m_outerIndex[outer], end, StorageIndex(inner));\n    }\n\n    /** \\returns a non-const reference to the value of the matrix at position \\a i, \\a j\n      *\n      * If the element does not exist then it is inserted via the insert(Index,Index) function\n      * which itself turns the matrix into a non compressed form if that was not the case.\n      *\n      * This is a O(log(nnz_j)) operation (binary search) plus the cost of insert(Index,Index)\n      * function if the element does not already exist.\n      */\n    inline Scalar& coeffRef(Index row, Index col)\n    {\n      eigen_assert(row>=0 && row<rows() && col>=0 && col<cols());\n      \n      const Index outer = IsRowMajor ? row : col;\n      const Index inner = IsRowMajor ? col : row;\n\n      Index start = m_outerIndex[outer];\n      Index end = m_innerNonZeros ? m_outerIndex[outer] + m_innerNonZeros[outer] : m_outerIndex[outer+1];\n      eigen_assert(end>=start && \"you probably called coeffRef on a non finalized matrix\");\n      if(end<=start)\n        return insert(row,col);\n      const Index p = m_data.searchLowerIndex(start,end-1,StorageIndex(inner));\n      if((p<end) && (m_data.index(p)==inner))\n        return m_data.value(p);\n      else\n        return insert(row,col);\n    }\n\n    /** \\returns a reference to a novel non zero coefficient with coordinates \\a row x \\a col.\n      * The non zero coefficient must \\b not already exist.\n      *\n      * If the matrix \\c *this is in compressed mode, then \\c *this is turned into uncompressed\n      * mode while reserving room for 2 x this->innerSize() non zeros if reserve(Index) has not been called earlier.\n      * In this case, the insertion procedure is optimized for a \\e sequential insertion mode where elements are assumed to be\n      * inserted by increasing outer-indices.\n      * \n      * If that's not the case, then it is strongly recommended to either use a triplet-list to assemble the matrix, or to first\n      * call reserve(const SizesType &) to reserve the appropriate number of non-zero elements per inner vector.\n      *\n      * Assuming memory has been appropriately reserved, this function performs a sorted insertion in O(1)\n      * if the elements of each inner vector are inserted in increasing inner index order, and in O(nnz_j) for a random insertion.\n      *\n      */\n    Scalar& insert(Index row, Index col);\n\n  public:\n\n    /** Removes all non zeros but keep allocated memory\n      *\n      * This function does not free the currently allocated memory. To release as much as memory as possible,\n      * call \\code mat.data().squeeze(); \\endcode after resizing it.\n      * \n      * \\sa resize(Index,Index), data()\n      */\n    inline void setZero()\n    {\n      m_data.clear();\n      memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(StorageIndex));\n      if(m_innerNonZeros)\n        memset(m_innerNonZeros, 0, (m_outerSize)*sizeof(StorageIndex));\n    }\n\n    /** Preallocates \\a reserveSize non zeros.\n      *\n      * Precondition: the matrix must be in compressed mode. */\n    inline void reserve(Index reserveSize)\n    {\n      eigen_assert(isCompressed() && \"This function does not make sense in non compressed mode.\");\n      m_data.reserve(reserveSize);\n    }\n    \n    #ifdef EIGEN_PARSED_BY_DOXYGEN\n    /** Preallocates \\a reserveSize[\\c j] non zeros for each column (resp. row) \\c j.\n      *\n      * This function turns the matrix in non-compressed mode.\n      * \n      * The type \\c SizesType must expose the following interface:\n        \\code\n        typedef value_type;\n        const value_type& operator[](i) const;\n        \\endcode\n      * for \\c i in the [0,this->outerSize()[ range.\n      * Typical choices include std::vector<int>, Eigen::VectorXi, Eigen::VectorXi::Constant, etc.\n      */\n    template<class SizesType>\n    inline void reserve(const SizesType& reserveSizes);\n    #else\n    template<class SizesType>\n    inline void reserve(const SizesType& reserveSizes, const typename SizesType::value_type& enableif =\n    #if (!EIGEN_COMP_MSVC) || (EIGEN_COMP_MSVC>=1500) // MSVC 2005 fails to compile with this typename\n        typename\n    #endif\n        SizesType::value_type())\n    {\n      EIGEN_UNUSED_VARIABLE(enableif);\n      reserveInnerVectors(reserveSizes);\n    }\n    #endif // EIGEN_PARSED_BY_DOXYGEN\n  protected:\n    template<class SizesType>\n    inline void reserveInnerVectors(const SizesType& reserveSizes)\n    {\n      if(isCompressed())\n      {\n        Index totalReserveSize = 0;\n        // turn the matrix into non-compressed mode\n        m_innerNonZeros = static_cast<StorageIndex*>(std::malloc(m_outerSize * sizeof(StorageIndex)));\n        if (!m_innerNonZeros) internal::throw_std_bad_alloc();\n        \n        // temporarily use m_innerSizes to hold the new starting points.\n        StorageIndex* newOuterIndex = m_innerNonZeros;\n        \n        StorageIndex count = 0;\n        for(Index j=0; j<m_outerSize; ++j)\n        {\n          newOuterIndex[j] = count;\n          count += reserveSizes[j] + (m_outerIndex[j+1]-m_outerIndex[j]);\n          totalReserveSize += reserveSizes[j];\n        }\n        m_data.reserve(totalReserveSize);\n        StorageIndex previousOuterIndex = m_outerIndex[m_outerSize];\n        for(Index j=m_outerSize-1; j>=0; --j)\n        {\n          StorageIndex innerNNZ = previousOuterIndex - m_outerIndex[j];\n          for(Index i=innerNNZ-1; i>=0; --i)\n          {\n            m_data.index(newOuterIndex[j]+i) = m_data.index(m_outerIndex[j]+i);\n            m_data.value(newOuterIndex[j]+i) = m_data.value(m_outerIndex[j]+i);\n          }\n          previousOuterIndex = m_outerIndex[j];\n          m_outerIndex[j] = newOuterIndex[j];\n          m_innerNonZeros[j] = innerNNZ;\n        }\n        m_outerIndex[m_outerSize] = m_outerIndex[m_outerSize-1] + m_innerNonZeros[m_outerSize-1] + reserveSizes[m_outerSize-1];\n        \n        m_data.resize(m_outerIndex[m_outerSize]);\n      }\n      else\n      {\n        StorageIndex* newOuterIndex = static_cast<StorageIndex*>(std::malloc((m_outerSize+1)*sizeof(StorageIndex)));\n        if (!newOuterIndex) internal::throw_std_bad_alloc();\n        \n        StorageIndex count = 0;\n        for(Index j=0; j<m_outerSize; ++j)\n        {\n          newOuterIndex[j] = count;\n          StorageIndex alreadyReserved = (m_outerIndex[j+1]-m_outerIndex[j]) - m_innerNonZeros[j];\n          StorageIndex toReserve = std::max<StorageIndex>(reserveSizes[j], alreadyReserved);\n          count += toReserve + m_innerNonZeros[j];\n        }\n        newOuterIndex[m_outerSize] = count;\n        \n        m_data.resize(count);\n        for(Index j=m_outerSize-1; j>=0; --j)\n        {\n          Index offset = newOuterIndex[j] - m_outerIndex[j];\n          if(offset>0)\n          {\n            StorageIndex innerNNZ = m_innerNonZeros[j];\n            for(Index i=innerNNZ-1; i>=0; --i)\n            {\n              m_data.index(newOuterIndex[j]+i) = m_data.index(m_outerIndex[j]+i);\n              m_data.value(newOuterIndex[j]+i) = m_data.value(m_outerIndex[j]+i);\n            }\n          }\n        }\n        \n        std::swap(m_outerIndex, newOuterIndex);\n        std::free(newOuterIndex);\n      }\n      \n    }\n  public:\n\n    //--- low level purely coherent filling ---\n\n    /** \\internal\n      * \\returns a reference to the non zero coefficient at position \\a row, \\a col assuming that:\n      * - the nonzero does not already exist\n      * - the new coefficient is the last one according to the storage order\n      *\n      * Before filling a given inner vector you must call the statVec(Index) function.\n      *\n      * After an insertion session, you should call the finalize() function.\n      *\n      * \\sa insert, insertBackByOuterInner, startVec */\n    inline Scalar& insertBack(Index row, Index col)\n    {\n      return insertBackByOuterInner(IsRowMajor?row:col, IsRowMajor?col:row);\n    }\n\n    /** \\internal\n      * \\sa insertBack, startVec */\n    inline Scalar& insertBackByOuterInner(Index outer, Index inner)\n    {\n      eigen_assert(Index(m_outerIndex[outer+1]) == m_data.size() && \"Invalid ordered insertion (invalid outer index)\");\n      eigen_assert( (m_outerIndex[outer+1]-m_outerIndex[outer]==0 || m_data.index(m_data.size()-1)<inner) && \"Invalid ordered insertion (invalid inner index)\");\n      Index p = m_outerIndex[outer+1];\n      ++m_outerIndex[outer+1];\n      m_data.append(Scalar(0), inner);\n      return m_data.value(p);\n    }\n\n    /** \\internal\n      * \\warning use it only if you know what you are doing */\n    inline Scalar& insertBackByOuterInnerUnordered(Index outer, Index inner)\n    {\n      Index p = m_outerIndex[outer+1];\n      ++m_outerIndex[outer+1];\n      m_data.append(Scalar(0), inner);\n      return m_data.value(p);\n    }\n\n    /** \\internal\n      * \\sa insertBack, insertBackByOuterInner */\n    inline void startVec(Index outer)\n    {\n      eigen_assert(m_outerIndex[outer]==Index(m_data.size()) && \"You must call startVec for each inner vector sequentially\");\n      eigen_assert(m_outerIndex[outer+1]==0 && \"You must call startVec for each inner vector sequentially\");\n      m_outerIndex[outer+1] = m_outerIndex[outer];\n    }\n\n    /** \\internal\n      * Must be called after inserting a set of non zero entries using the low level compressed API.\n      */\n    inline void finalize()\n    {\n      if(isCompressed())\n      {\n        StorageIndex size = internal::convert_index<StorageIndex>(m_data.size());\n        Index i = m_outerSize;\n        // find the last filled column\n        while (i>=0 && m_outerIndex[i]==0)\n          --i;\n        ++i;\n        while (i<=m_outerSize)\n        {\n          m_outerIndex[i] = size;\n          ++i;\n        }\n      }\n    }\n\n    //---\n\n    template<typename InputIterators>\n    void setFromTriplets(const InputIterators& begin, const InputIterators& end);\n\n    template<typename InputIterators,typename DupFunctor>\n    void setFromTriplets(const InputIterators& begin, const InputIterators& end, DupFunctor dup_func);\n\n    void sumupDuplicates() { collapseDuplicates(internal::scalar_sum_op<Scalar,Scalar>()); }\n\n    template<typename DupFunctor>\n    void collapseDuplicates(DupFunctor dup_func = DupFunctor());\n\n    //---\n    \n    /** \\internal\n      * same as insert(Index,Index) except that the indices are given relative to the storage order */\n    Scalar& insertByOuterInner(Index j, Index i)\n    {\n      return insert(IsRowMajor ? j : i, IsRowMajor ? i : j);\n    }\n\n    /** Turns the matrix into the \\em compressed format.\n      */\n    void makeCompressed()\n    {\n      if(isCompressed())\n        return;\n      \n      eigen_internal_assert(m_outerIndex!=0 && m_outerSize>0);\n      \n      Index oldStart = m_outerIndex[1];\n      m_outerIndex[1] = m_innerNonZeros[0];\n      for(Index j=1; j<m_outerSize; ++j)\n      {\n        Index nextOldStart = m_outerIndex[j+1];\n        Index offset = oldStart - m_outerIndex[j];\n        if(offset>0)\n        {\n          for(Index k=0; k<m_innerNonZeros[j]; ++k)\n          {\n            m_data.index(m_outerIndex[j]+k) = m_data.index(oldStart+k);\n            m_data.value(m_outerIndex[j]+k) = m_data.value(oldStart+k);\n          }\n        }\n        m_outerIndex[j+1] = m_outerIndex[j] + m_innerNonZeros[j];\n        oldStart = nextOldStart;\n      }\n      std::free(m_innerNonZeros);\n      m_innerNonZeros = 0;\n      m_data.resize(m_outerIndex[m_outerSize]);\n      m_data.squeeze();\n    }\n\n    /** Turns the matrix into the uncompressed mode */\n    void uncompress()\n    {\n      if(m_innerNonZeros != 0)\n        return; \n      m_innerNonZeros = static_cast<StorageIndex*>(std::malloc(m_outerSize * sizeof(StorageIndex)));\n      for (Index i = 0; i < m_outerSize; i++)\n      {\n        m_innerNonZeros[i] = m_outerIndex[i+1] - m_outerIndex[i]; \n      }\n    }\n    \n    /** Suppresses all nonzeros which are \\b much \\b smaller \\b than \\a reference under the tolerence \\a epsilon */\n    void prune(const Scalar& reference, const RealScalar& epsilon = NumTraits<RealScalar>::dummy_precision())\n    {\n      prune(default_prunning_func(reference,epsilon));\n    }\n    \n    /** Turns the matrix into compressed format, and suppresses all nonzeros which do not satisfy the predicate \\a keep.\n      * The functor type \\a KeepFunc must implement the following function:\n      * \\code\n      * bool operator() (const Index& row, const Index& col, const Scalar& value) const;\n      * \\endcode\n      * \\sa prune(Scalar,RealScalar)\n      */\n    template<typename KeepFunc>\n    void prune(const KeepFunc& keep = KeepFunc())\n    {\n      // TODO optimize the uncompressed mode to avoid moving and allocating the data twice\n      makeCompressed();\n\n      StorageIndex k = 0;\n      for(Index j=0; j<m_outerSize; ++j)\n      {\n        Index previousStart = m_outerIndex[j];\n        m_outerIndex[j] = k;\n        Index end = m_outerIndex[j+1];\n        for(Index i=previousStart; i<end; ++i)\n        {\n          if(keep(IsRowMajor?j:m_data.index(i), IsRowMajor?m_data.index(i):j, m_data.value(i)))\n          {\n            m_data.value(k) = m_data.value(i);\n            m_data.index(k) = m_data.index(i);\n            ++k;\n          }\n        }\n      }\n      m_outerIndex[m_outerSize] = k;\n      m_data.resize(k,0);\n    }\n\n    /** Resizes the matrix to a \\a rows x \\a cols matrix leaving old values untouched.\n      *\n      * If the sizes of the matrix are decreased, then the matrix is turned to \\b uncompressed-mode\n      * and the storage of the out of bounds coefficients is kept and reserved.\n      * Call makeCompressed() to pack the entries and squeeze extra memory.\n      *\n      * \\sa reserve(), setZero(), makeCompressed()\n      */\n    void conservativeResize(Index rows, Index cols) \n    {\n      // No change\n      if (this->rows() == rows && this->cols() == cols) return;\n      \n      // If one dimension is null, then there is nothing to be preserved\n      if(rows==0 || cols==0) return resize(rows,cols);\n\n      Index innerChange = IsRowMajor ? cols - this->cols() : rows - this->rows();\n      Index outerChange = IsRowMajor ? rows - this->rows() : cols - this->cols();\n      StorageIndex newInnerSize = convert_index(IsRowMajor ? cols : rows);\n\n      // Deals with inner non zeros\n      if (m_innerNonZeros)\n      {\n        // Resize m_innerNonZeros\n        StorageIndex *newInnerNonZeros = static_cast<StorageIndex*>(std::realloc(m_innerNonZeros, (m_outerSize + outerChange) * sizeof(StorageIndex)));\n        if (!newInnerNonZeros) internal::throw_std_bad_alloc();\n        m_innerNonZeros = newInnerNonZeros;\n        \n        for(Index i=m_outerSize; i<m_outerSize+outerChange; i++)          \n          m_innerNonZeros[i] = 0;\n      } \n      else if (innerChange < 0) \n      {\n        // Inner size decreased: allocate a new m_innerNonZeros\n        m_innerNonZeros = static_cast<StorageIndex*>(std::malloc((m_outerSize+outerChange+1) * sizeof(StorageIndex)));\n        if (!m_innerNonZeros) internal::throw_std_bad_alloc();\n        for(Index i = 0; i < m_outerSize; i++)\n          m_innerNonZeros[i] = m_outerIndex[i+1] - m_outerIndex[i];\n      }\n      \n      // Change the m_innerNonZeros in case of a decrease of inner size\n      if (m_innerNonZeros && innerChange < 0)\n      {\n        for(Index i = 0; i < m_outerSize + (std::min)(outerChange, Index(0)); i++)\n        {\n          StorageIndex &n = m_innerNonZeros[i];\n          StorageIndex start = m_outerIndex[i];\n          while (n > 0 && m_data.index(start+n-1) >= newInnerSize) --n; \n        }\n      }\n      \n      m_innerSize = newInnerSize;\n\n      // Re-allocate outer index structure if necessary\n      if (outerChange == 0)\n        return;\n          \n      StorageIndex *newOuterIndex = static_cast<StorageIndex*>(std::realloc(m_outerIndex, (m_outerSize + outerChange + 1) * sizeof(StorageIndex)));\n      if (!newOuterIndex) internal::throw_std_bad_alloc();\n      m_outerIndex = newOuterIndex;\n      if (outerChange > 0)\n      {\n        StorageIndex last = m_outerSize == 0 ? 0 : m_outerIndex[m_outerSize];\n        for(Index i=m_outerSize; i<m_outerSize+outerChange+1; i++)          \n          m_outerIndex[i] = last; \n      }\n      m_outerSize += outerChange;\n    }\n    \n    /** Resizes the matrix to a \\a rows x \\a cols matrix and initializes it to zero.\n      * \n      * This function does not free the currently allocated memory. To release as much as memory as possible,\n      * call \\code mat.data().squeeze(); \\endcode after resizing it.\n      * \n      * \\sa reserve(), setZero()\n      */\n    void resize(Index rows, Index cols)\n    {\n      const Index outerSize = IsRowMajor ? rows : cols;\n      m_innerSize = IsRowMajor ? cols : rows;\n      m_data.clear();\n      if (m_outerSize != outerSize || m_outerSize==0)\n      {\n        std::free(m_outerIndex);\n        m_outerIndex = static_cast<StorageIndex*>(std::malloc((outerSize + 1) * sizeof(StorageIndex)));\n        if (!m_outerIndex) internal::throw_std_bad_alloc();\n        \n        m_outerSize = outerSize;\n      }\n      if(m_innerNonZeros)\n      {\n        std::free(m_innerNonZeros);\n        m_innerNonZeros = 0;\n      }\n      memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(StorageIndex));\n    }\n\n    /** \\internal\n      * Resize the nonzero vector to \\a size */\n    void resizeNonZeros(Index size)\n    {\n      m_data.resize(size);\n    }\n\n    /** \\returns a const expression of the diagonal coefficients. */\n    const ConstDiagonalReturnType diagonal() const { return ConstDiagonalReturnType(*this); }\n    \n    /** \\returns a read-write expression of the diagonal coefficients.\n      * \\warning If the diagonal entries are written, then all diagonal\n      * entries \\b must already exist, otherwise an assertion will be raised.\n      */\n    DiagonalReturnType diagonal() { return DiagonalReturnType(*this); }\n\n    /** Default constructor yielding an empty \\c 0 \\c x \\c 0 matrix */\n    inline SparseMatrix()\n      : m_outerSize(-1), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)\n    {\n      check_template_parameters();\n      resize(0, 0);\n    }\n\n    /** Constructs a \\a rows \\c x \\a cols empty matrix */\n    inline SparseMatrix(Index rows, Index cols)\n      : m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)\n    {\n      check_template_parameters();\n      resize(rows, cols);\n    }\n\n    /** Constructs a sparse matrix from the sparse expression \\a other */\n    template<typename OtherDerived>\n    inline SparseMatrix(const SparseMatrixBase<OtherDerived>& other)\n      : m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)\n    {\n      EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),\n        YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)\n      check_template_parameters();\n      const bool needToTranspose = (Flags & RowMajorBit) != (internal::evaluator<OtherDerived>::Flags & RowMajorBit);\n      if (needToTranspose)\n        *this = other.derived();\n      else\n      {\n        #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN\n          EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN\n        #endif\n        internal::call_assignment_no_alias(*this, other.derived());\n      }\n    }\n    \n    /** Constructs a sparse matrix from the sparse selfadjoint view \\a other */\n    template<typename OtherDerived, unsigned int UpLo>\n    inline SparseMatrix(const SparseSelfAdjointView<OtherDerived, UpLo>& other)\n      : m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)\n    {\n      check_template_parameters();\n      Base::operator=(other);\n    }\n\n    /** Copy constructor (it performs a deep copy) */\n    inline SparseMatrix(const SparseMatrix& other)\n      : Base(), m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)\n    {\n      check_template_parameters();\n      *this = other.derived();\n    }\n\n    /** \\brief Copy constructor with in-place evaluation */\n    template<typename OtherDerived>\n    SparseMatrix(const ReturnByValue<OtherDerived>& other)\n      : Base(), m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)\n    {\n      check_template_parameters();\n      initAssignment(other);\n      other.evalTo(*this);\n    }\n    \n    /** \\brief Copy constructor with in-place evaluation */\n    template<typename OtherDerived>\n    explicit SparseMatrix(const DiagonalBase<OtherDerived>& other)\n      : Base(), m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)\n    {\n      check_template_parameters();\n      *this = other.derived();\n    }\n\n    /** Swaps the content of two sparse matrices of the same type.\n      * This is a fast operation that simply swaps the underlying pointers and parameters. */\n    inline void swap(SparseMatrix& other)\n    {\n      //EIGEN_DBG_SPARSE(std::cout << \"SparseMatrix:: swap\\n\");\n      std::swap(m_outerIndex, other.m_outerIndex);\n      std::swap(m_innerSize, other.m_innerSize);\n      std::swap(m_outerSize, other.m_outerSize);\n      std::swap(m_innerNonZeros, other.m_innerNonZeros);\n      m_data.swap(other.m_data);\n    }\n\n    /** Sets *this to the identity matrix.\n      * This function also turns the matrix into compressed mode, and drop any reserved memory. */\n    inline void setIdentity()\n    {\n      eigen_assert(rows() == cols() && \"ONLY FOR SQUARED MATRICES\");\n      this->m_data.resize(rows());\n      Eigen::Map<IndexVector>(this->m_data.indexPtr(), rows()).setLinSpaced(0, StorageIndex(rows()-1));\n      Eigen::Map<ScalarVector>(this->m_data.valuePtr(), rows()).setOnes();\n      Eigen::Map<IndexVector>(this->m_outerIndex, rows()+1).setLinSpaced(0, StorageIndex(rows()));\n      std::free(m_innerNonZeros);\n      m_innerNonZeros = 0;\n    }\n    inline SparseMatrix& operator=(const SparseMatrix& other)\n    {\n      if (other.isRValue())\n      {\n        swap(other.const_cast_derived());\n      }\n      else if(this!=&other)\n      {\n        #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN\n          EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN\n        #endif\n        initAssignment(other);\n        if(other.isCompressed())\n        {\n          internal::smart_copy(other.m_outerIndex, other.m_outerIndex + m_outerSize + 1, m_outerIndex);\n          m_data = other.m_data;\n        }\n        else\n        {\n          Base::operator=(other);\n        }\n      }\n      return *this;\n    }\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename OtherDerived>\n    inline SparseMatrix& operator=(const EigenBase<OtherDerived>& other)\n    { return Base::operator=(other.derived()); }\n#endif // EIGEN_PARSED_BY_DOXYGEN\n\n    template<typename OtherDerived>\n    EIGEN_DONT_INLINE SparseMatrix& operator=(const SparseMatrixBase<OtherDerived>& other);\n\n    friend std::ostream & operator << (std::ostream & s, const SparseMatrix& m)\n    {\n      EIGEN_DBG_SPARSE(\n        s << \"Nonzero entries:\\n\";\n        if(m.isCompressed())\n        {\n          for (Index i=0; i<m.nonZeros(); ++i)\n            s << \"(\" << m.m_data.value(i) << \",\" << m.m_data.index(i) << \") \";\n        }\n        else\n        {\n          for (Index i=0; i<m.outerSize(); ++i)\n          {\n            Index p = m.m_outerIndex[i];\n            Index pe = m.m_outerIndex[i]+m.m_innerNonZeros[i];\n            Index k=p;\n            for (; k<pe; ++k) {\n              s << \"(\" << m.m_data.value(k) << \",\" << m.m_data.index(k) << \") \";\n            }\n            for (; k<m.m_outerIndex[i+1]; ++k) {\n              s << \"(_,_) \";\n            }\n          }\n        }\n        s << std::endl;\n        s << std::endl;\n        s << \"Outer pointers:\\n\";\n        for (Index i=0; i<m.outerSize(); ++i) {\n          s << m.m_outerIndex[i] << \" \";\n        }\n        s << \" $\" << std::endl;\n        if(!m.isCompressed())\n        {\n          s << \"Inner non zeros:\\n\";\n          for (Index i=0; i<m.outerSize(); ++i) {\n            s << m.m_innerNonZeros[i] << \" \";\n          }\n          s << \" $\" << std::endl;\n        }\n        s << std::endl;\n      );\n      s << static_cast<const SparseMatrixBase<SparseMatrix>&>(m);\n      return s;\n    }\n\n    /** Destructor */\n    inline ~SparseMatrix()\n    {\n      std::free(m_outerIndex);\n      std::free(m_innerNonZeros);\n    }\n\n    /** Overloaded for performance */\n    Scalar sum() const;\n    \n#   ifdef EIGEN_SPARSEMATRIX_PLUGIN\n#     include EIGEN_SPARSEMATRIX_PLUGIN\n#   endif\n\nprotected:\n\n    template<typename Other>\n    void initAssignment(const Other& other)\n    {\n      resize(other.rows(), other.cols());\n      if(m_innerNonZeros)\n      {\n        std::free(m_innerNonZeros);\n        m_innerNonZeros = 0;\n      }\n    }\n\n    /** \\internal\n      * \\sa insert(Index,Index) */\n    EIGEN_DONT_INLINE Scalar& insertCompressed(Index row, Index col);\n\n    /** \\internal\n      * A vector object that is equal to 0 everywhere but v at the position i */\n    class SingletonVector\n    {\n        StorageIndex m_index;\n        StorageIndex m_value;\n      public:\n        typedef StorageIndex value_type;\n        SingletonVector(Index i, Index v)\n          : m_index(convert_index(i)), m_value(convert_index(v))\n        {}\n\n        StorageIndex operator[](Index i) const { return i==m_index ? m_value : 0; }\n    };\n\n    /** \\internal\n      * \\sa insert(Index,Index) */\n    EIGEN_DONT_INLINE Scalar& insertUncompressed(Index row, Index col);\n\npublic:\n    /** \\internal\n      * \\sa insert(Index,Index) */\n    EIGEN_STRONG_INLINE Scalar& insertBackUncompressed(Index row, Index col)\n    {\n      const Index outer = IsRowMajor ? row : col;\n      const Index inner = IsRowMajor ? col : row;\n\n      eigen_assert(!isCompressed());\n      eigen_assert(m_innerNonZeros[outer]<=(m_outerIndex[outer+1] - m_outerIndex[outer]));\n\n      Index p = m_outerIndex[outer] + m_innerNonZeros[outer]++;\n      m_data.index(p) = convert_index(inner);\n      return (m_data.value(p) = 0);\n    }\n\nprivate:\n  static void check_template_parameters()\n  {\n    EIGEN_STATIC_ASSERT(NumTraits<StorageIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE);\n    EIGEN_STATIC_ASSERT((Options&(ColMajor|RowMajor))==Options,INVALID_MATRIX_TEMPLATE_PARAMETERS);\n  }\n\n  struct default_prunning_func {\n    default_prunning_func(const Scalar& ref, const RealScalar& eps) : reference(ref), epsilon(eps) {}\n    inline bool operator() (const Index&, const Index&, const Scalar& value) const\n    {\n      return !internal::isMuchSmallerThan(value, reference, epsilon);\n    }\n    Scalar reference;\n    RealScalar epsilon;\n  };\n};\n\nnamespace internal {\n\ntemplate<typename InputIterator, typename SparseMatrixType, typename DupFunctor>\nvoid set_from_triplets(const InputIterator& begin, const InputIterator& end, SparseMatrixType& mat, DupFunctor dup_func)\n{\n  enum { IsRowMajor = SparseMatrixType::IsRowMajor };\n  typedef typename SparseMatrixType::Scalar Scalar;\n  typedef typename SparseMatrixType::StorageIndex StorageIndex;\n  SparseMatrix<Scalar,IsRowMajor?ColMajor:RowMajor,StorageIndex> trMat(mat.rows(),mat.cols());\n\n  if(begin!=end)\n  {\n    // pass 1: count the nnz per inner-vector\n    typename SparseMatrixType::IndexVector wi(trMat.outerSize());\n    wi.setZero();\n    for(InputIterator it(begin); it!=end; ++it)\n    {\n      eigen_assert(it->row()>=0 && it->row()<mat.rows() && it->col()>=0 && it->col()<mat.cols());\n      wi(IsRowMajor ? it->col() : it->row())++;\n    }\n\n    // pass 2: insert all the elements into trMat\n    trMat.reserve(wi);\n    for(InputIterator it(begin); it!=end; ++it)\n      trMat.insertBackUncompressed(it->row(),it->col()) = it->value();\n\n    // pass 3:\n    trMat.collapseDuplicates(dup_func);\n  }\n\n  // pass 4: transposed copy -> implicit sorting\n  mat = trMat;\n}\n\n}\n\n\n/** Fill the matrix \\c *this with the list of \\em triplets defined by the iterator range \\a begin - \\a end.\n  *\n  * A \\em triplet is a tuple (i,j,value) defining a non-zero element.\n  * The input list of triplets does not have to be sorted, and can contains duplicated elements.\n  * In any case, the result is a \\b sorted and \\b compressed sparse matrix where the duplicates have been summed up.\n  * This is a \\em O(n) operation, with \\em n the number of triplet elements.\n  * The initial contents of \\c *this is destroyed.\n  * The matrix \\c *this must be properly resized beforehand using the SparseMatrix(Index,Index) constructor,\n  * or the resize(Index,Index) method. The sizes are not extracted from the triplet list.\n  *\n  * The \\a InputIterators value_type must provide the following interface:\n  * \\code\n  * Scalar value() const; // the value\n  * Scalar row() const;   // the row index i\n  * Scalar col() const;   // the column index j\n  * \\endcode\n  * See for instance the Eigen::Triplet template class.\n  *\n  * Here is a typical usage example:\n  * \\code\n    typedef Triplet<double> T;\n    std::vector<T> tripletList;\n    triplets.reserve(estimation_of_entries);\n    for(...)\n    {\n      // ...\n      tripletList.push_back(T(i,j,v_ij));\n    }\n    SparseMatrixType m(rows,cols);\n    m.setFromTriplets(tripletList.begin(), tripletList.end());\n    // m is ready to go!\n  * \\endcode\n  *\n  * \\warning The list of triplets is read multiple times (at least twice). Therefore, it is not recommended to define\n  * an abstract iterator over a complex data-structure that would be expensive to evaluate. The triplets should rather\n  * be explicitely stored into a std::vector for instance.\n  */\ntemplate<typename Scalar, int _Options, typename _StorageIndex>\ntemplate<typename InputIterators>\nvoid SparseMatrix<Scalar,_Options,_StorageIndex>::setFromTriplets(const InputIterators& begin, const InputIterators& end)\n{\n  internal::set_from_triplets<InputIterators, SparseMatrix<Scalar,_Options,_StorageIndex> >(begin, end, *this, internal::scalar_sum_op<Scalar,Scalar>());\n}\n\n/** The same as setFromTriplets but when duplicates are met the functor \\a dup_func is applied:\n  * \\code\n  * value = dup_func(OldValue, NewValue)\n  * \\endcode \n  * Here is a C++11 example keeping the latest entry only:\n  * \\code\n  * mat.setFromTriplets(triplets.begin(), triplets.end(), [] (const Scalar&,const Scalar &b) { return b; });\n  * \\endcode\n  */\ntemplate<typename Scalar, int _Options, typename _StorageIndex>\ntemplate<typename InputIterators,typename DupFunctor>\nvoid SparseMatrix<Scalar,_Options,_StorageIndex>::setFromTriplets(const InputIterators& begin, const InputIterators& end, DupFunctor dup_func)\n{\n  internal::set_from_triplets<InputIterators, SparseMatrix<Scalar,_Options,_StorageIndex>, DupFunctor>(begin, end, *this, dup_func);\n}\n\n/** \\internal */\ntemplate<typename Scalar, int _Options, typename _StorageIndex>\ntemplate<typename DupFunctor>\nvoid SparseMatrix<Scalar,_Options,_StorageIndex>::collapseDuplicates(DupFunctor dup_func)\n{\n  eigen_assert(!isCompressed());\n  // TODO, in practice we should be able to use m_innerNonZeros for that task\n  IndexVector wi(innerSize());\n  wi.fill(-1);\n  StorageIndex count = 0;\n  // for each inner-vector, wi[inner_index] will hold the position of first element into the index/value buffers\n  for(Index j=0; j<outerSize(); ++j)\n  {\n    StorageIndex start   = count;\n    Index oldEnd  = m_outerIndex[j]+m_innerNonZeros[j];\n    for(Index k=m_outerIndex[j]; k<oldEnd; ++k)\n    {\n      Index i = m_data.index(k);\n      if(wi(i)>=start)\n      {\n        // we already meet this entry => accumulate it\n        m_data.value(wi(i)) = dup_func(m_data.value(wi(i)), m_data.value(k));\n      }\n      else\n      {\n        m_data.value(count) = m_data.value(k);\n        m_data.index(count) = m_data.index(k);\n        wi(i) = count;\n        ++count;\n      }\n    }\n    m_outerIndex[j] = start;\n  }\n  m_outerIndex[m_outerSize] = count;\n\n  // turn the matrix into compressed form\n  std::free(m_innerNonZeros);\n  m_innerNonZeros = 0;\n  m_data.resize(m_outerIndex[m_outerSize]);\n}\n\ntemplate<typename Scalar, int _Options, typename _StorageIndex>\ntemplate<typename OtherDerived>\nEIGEN_DONT_INLINE SparseMatrix<Scalar,_Options,_StorageIndex>& SparseMatrix<Scalar,_Options,_StorageIndex>::operator=(const SparseMatrixBase<OtherDerived>& other)\n{\n  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),\n        YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)\n\n  #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN\n    EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN\n  #endif\n      \n  const bool needToTranspose = (Flags & RowMajorBit) != (internal::evaluator<OtherDerived>::Flags & RowMajorBit);\n  if (needToTranspose)\n  {\n    #ifdef EIGEN_SPARSE_TRANSPOSED_COPY_PLUGIN\n      EIGEN_SPARSE_TRANSPOSED_COPY_PLUGIN\n    #endif\n    // two passes algorithm:\n    //  1 - compute the number of coeffs per dest inner vector\n    //  2 - do the actual copy/eval\n    // Since each coeff of the rhs has to be evaluated twice, let's evaluate it if needed\n    typedef typename internal::nested_eval<OtherDerived,2,typename internal::plain_matrix_type<OtherDerived>::type >::type OtherCopy;\n    typedef typename internal::remove_all<OtherCopy>::type _OtherCopy;\n    typedef internal::evaluator<_OtherCopy> OtherCopyEval;\n    OtherCopy otherCopy(other.derived());\n    OtherCopyEval otherCopyEval(otherCopy);\n\n    SparseMatrix dest(other.rows(),other.cols());\n    Eigen::Map<IndexVector> (dest.m_outerIndex,dest.outerSize()).setZero();\n\n    // pass 1\n    // FIXME the above copy could be merged with that pass\n    for (Index j=0; j<otherCopy.outerSize(); ++j)\n      for (typename OtherCopyEval::InnerIterator it(otherCopyEval, j); it; ++it)\n        ++dest.m_outerIndex[it.index()];\n\n    // prefix sum\n    StorageIndex count = 0;\n    IndexVector positions(dest.outerSize());\n    for (Index j=0; j<dest.outerSize(); ++j)\n    {\n      StorageIndex tmp = dest.m_outerIndex[j];\n      dest.m_outerIndex[j] = count;\n      positions[j] = count;\n      count += tmp;\n    }\n    dest.m_outerIndex[dest.outerSize()] = count;\n    // alloc\n    dest.m_data.resize(count);\n    // pass 2\n    for (StorageIndex j=0; j<otherCopy.outerSize(); ++j)\n    {\n      for (typename OtherCopyEval::InnerIterator it(otherCopyEval, j); it; ++it)\n      {\n        Index pos = positions[it.index()]++;\n        dest.m_data.index(pos) = j;\n        dest.m_data.value(pos) = it.value();\n      }\n    }\n    this->swap(dest);\n    return *this;\n  }\n  else\n  {\n    if(other.isRValue())\n    {\n      initAssignment(other.derived());\n    }\n    // there is no special optimization\n    return Base::operator=(other.derived());\n  }\n}\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex>\ntypename SparseMatrix<_Scalar,_Options,_StorageIndex>::Scalar& SparseMatrix<_Scalar,_Options,_StorageIndex>::insert(Index row, Index col)\n{\n  eigen_assert(row>=0 && row<rows() && col>=0 && col<cols());\n  \n  const Index outer = IsRowMajor ? row : col;\n  const Index inner = IsRowMajor ? col : row;\n  \n  if(isCompressed())\n  {\n    if(nonZeros()==0)\n    {\n      // reserve space if not already done\n      if(m_data.allocatedSize()==0)\n        m_data.reserve(2*m_innerSize);\n      \n      // turn the matrix into non-compressed mode\n      m_innerNonZeros = static_cast<StorageIndex*>(std::malloc(m_outerSize * sizeof(StorageIndex)));\n      if(!m_innerNonZeros) internal::throw_std_bad_alloc();\n      \n      memset(m_innerNonZeros, 0, (m_outerSize)*sizeof(StorageIndex));\n      \n      // pack all inner-vectors to the end of the pre-allocated space\n      // and allocate the entire free-space to the first inner-vector\n      StorageIndex end = convert_index(m_data.allocatedSize());\n      for(Index j=1; j<=m_outerSize; ++j)\n        m_outerIndex[j] = end;\n    }\n    else\n    {\n      // turn the matrix into non-compressed mode\n      m_innerNonZeros = static_cast<StorageIndex*>(std::malloc(m_outerSize * sizeof(StorageIndex)));\n      if(!m_innerNonZeros) internal::throw_std_bad_alloc();\n      for(Index j=0; j<m_outerSize; ++j)\n        m_innerNonZeros[j] = m_outerIndex[j+1]-m_outerIndex[j];\n    }\n  }\n  \n  // check whether we can do a fast \"push back\" insertion\n  Index data_end = m_data.allocatedSize();\n  \n  // First case: we are filling a new inner vector which is packed at the end.\n  // We assume that all remaining inner-vectors are also empty and packed to the end.\n  if(m_outerIndex[outer]==data_end)\n  {\n    eigen_internal_assert(m_innerNonZeros[outer]==0);\n    \n    // pack previous empty inner-vectors to end of the used-space\n    // and allocate the entire free-space to the current inner-vector.\n    StorageIndex p = convert_index(m_data.size());\n    Index j = outer;\n    while(j>=0 && m_innerNonZeros[j]==0)\n      m_outerIndex[j--] = p;\n    \n    // push back the new element\n    ++m_innerNonZeros[outer];\n    m_data.append(Scalar(0), inner);\n    \n    // check for reallocation\n    if(data_end != m_data.allocatedSize())\n    {\n      // m_data has been reallocated\n      //  -> move remaining inner-vectors back to the end of the free-space\n      //     so that the entire free-space is allocated to the current inner-vector.\n      eigen_internal_assert(data_end < m_data.allocatedSize());\n      StorageIndex new_end = convert_index(m_data.allocatedSize());\n      for(Index k=outer+1; k<=m_outerSize; ++k)\n        if(m_outerIndex[k]==data_end)\n          m_outerIndex[k] = new_end;\n    }\n    return m_data.value(p);\n  }\n  \n  // Second case: the next inner-vector is packed to the end\n  // and the current inner-vector end match the used-space.\n  if(m_outerIndex[outer+1]==data_end && m_outerIndex[outer]+m_innerNonZeros[outer]==m_data.size())\n  {\n    eigen_internal_assert(outer+1==m_outerSize || m_innerNonZeros[outer+1]==0);\n    \n    // add space for the new element\n    ++m_innerNonZeros[outer];\n    m_data.resize(m_data.size()+1);\n    \n    // check for reallocation\n    if(data_end != m_data.allocatedSize())\n    {\n      // m_data has been reallocated\n      //  -> move remaining inner-vectors back to the end of the free-space\n      //     so that the entire free-space is allocated to the current inner-vector.\n      eigen_internal_assert(data_end < m_data.allocatedSize());\n      StorageIndex new_end = convert_index(m_data.allocatedSize());\n      for(Index k=outer+1; k<=m_outerSize; ++k)\n        if(m_outerIndex[k]==data_end)\n          m_outerIndex[k] = new_end;\n    }\n    \n    // and insert it at the right position (sorted insertion)\n    Index startId = m_outerIndex[outer];\n    Index p = m_outerIndex[outer]+m_innerNonZeros[outer]-1;\n    while ( (p > startId) && (m_data.index(p-1) > inner) )\n    {\n      m_data.index(p) = m_data.index(p-1);\n      m_data.value(p) = m_data.value(p-1);\n      --p;\n    }\n    \n    m_data.index(p) = convert_index(inner);\n    return (m_data.value(p) = 0);\n  }\n  \n  if(m_data.size() != m_data.allocatedSize())\n  {\n    // make sure the matrix is compatible to random un-compressed insertion:\n    m_data.resize(m_data.allocatedSize());\n    this->reserveInnerVectors(Array<StorageIndex,Dynamic,1>::Constant(m_outerSize, 2));\n  }\n  \n  return insertUncompressed(row,col);\n}\n    \ntemplate<typename _Scalar, int _Options, typename _StorageIndex>\nEIGEN_DONT_INLINE typename SparseMatrix<_Scalar,_Options,_StorageIndex>::Scalar& SparseMatrix<_Scalar,_Options,_StorageIndex>::insertUncompressed(Index row, Index col)\n{\n  eigen_assert(!isCompressed());\n\n  const Index outer = IsRowMajor ? row : col;\n  const StorageIndex inner = convert_index(IsRowMajor ? col : row);\n\n  Index room = m_outerIndex[outer+1] - m_outerIndex[outer];\n  StorageIndex innerNNZ = m_innerNonZeros[outer];\n  if(innerNNZ>=room)\n  {\n    // this inner vector is full, we need to reallocate the whole buffer :(\n    reserve(SingletonVector(outer,std::max<StorageIndex>(2,innerNNZ)));\n  }\n\n  Index startId = m_outerIndex[outer];\n  Index p = startId + m_innerNonZeros[outer];\n  while ( (p > startId) && (m_data.index(p-1) > inner) )\n  {\n    m_data.index(p) = m_data.index(p-1);\n    m_data.value(p) = m_data.value(p-1);\n    --p;\n  }\n  eigen_assert((p<=startId || m_data.index(p-1)!=inner) && \"you cannot insert an element that already exists, you must call coeffRef to this end\");\n\n  m_innerNonZeros[outer]++;\n\n  m_data.index(p) = inner;\n  return (m_data.value(p) = 0);\n}\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex>\nEIGEN_DONT_INLINE typename SparseMatrix<_Scalar,_Options,_StorageIndex>::Scalar& SparseMatrix<_Scalar,_Options,_StorageIndex>::insertCompressed(Index row, Index col)\n{\n  eigen_assert(isCompressed());\n\n  const Index outer = IsRowMajor ? row : col;\n  const Index inner = IsRowMajor ? col : row;\n\n  Index previousOuter = outer;\n  if (m_outerIndex[outer+1]==0)\n  {\n    // we start a new inner vector\n    while (previousOuter>=0 && m_outerIndex[previousOuter]==0)\n    {\n      m_outerIndex[previousOuter] = convert_index(m_data.size());\n      --previousOuter;\n    }\n    m_outerIndex[outer+1] = m_outerIndex[outer];\n  }\n\n  // here we have to handle the tricky case where the outerIndex array\n  // starts with: [ 0 0 0 0 0 1 ...] and we are inserted in, e.g.,\n  // the 2nd inner vector...\n  bool isLastVec = (!(previousOuter==-1 && m_data.size()!=0))\n                && (std::size_t(m_outerIndex[outer+1]) == m_data.size());\n\n  std::size_t startId = m_outerIndex[outer];\n  // FIXME let's make sure sizeof(long int) == sizeof(std::size_t)\n  std::size_t p = m_outerIndex[outer+1];\n  ++m_outerIndex[outer+1];\n\n  double reallocRatio = 1;\n  if (m_data.allocatedSize()<=m_data.size())\n  {\n    // if there is no preallocated memory, let's reserve a minimum of 32 elements\n    if (m_data.size()==0)\n    {\n      m_data.reserve(32);\n    }\n    else\n    {\n      // we need to reallocate the data, to reduce multiple reallocations\n      // we use a smart resize algorithm based on the current filling ratio\n      // in addition, we use double to avoid integers overflows\n      double nnzEstimate = double(m_outerIndex[outer])*double(m_outerSize)/double(outer+1);\n      reallocRatio = (nnzEstimate-double(m_data.size()))/double(m_data.size());\n      // furthermore we bound the realloc ratio to:\n      //   1) reduce multiple minor realloc when the matrix is almost filled\n      //   2) avoid to allocate too much memory when the matrix is almost empty\n      reallocRatio = (std::min)((std::max)(reallocRatio,1.5),8.);\n    }\n  }\n  m_data.resize(m_data.size()+1,reallocRatio);\n\n  if (!isLastVec)\n  {\n    if (previousOuter==-1)\n    {\n      // oops wrong guess.\n      // let's correct the outer offsets\n      for (Index k=0; k<=(outer+1); ++k)\n        m_outerIndex[k] = 0;\n      Index k=outer+1;\n      while(m_outerIndex[k]==0)\n        m_outerIndex[k++] = 1;\n      while (k<=m_outerSize && m_outerIndex[k]!=0)\n        m_outerIndex[k++]++;\n      p = 0;\n      --k;\n      k = m_outerIndex[k]-1;\n      while (k>0)\n      {\n        m_data.index(k) = m_data.index(k-1);\n        m_data.value(k) = m_data.value(k-1);\n        k--;\n      }\n    }\n    else\n    {\n      // we are not inserting into the last inner vec\n      // update outer indices:\n      Index j = outer+2;\n      while (j<=m_outerSize && m_outerIndex[j]!=0)\n        m_outerIndex[j++]++;\n      --j;\n      // shift data of last vecs:\n      Index k = m_outerIndex[j]-1;\n      while (k>=Index(p))\n      {\n        m_data.index(k) = m_data.index(k-1);\n        m_data.value(k) = m_data.value(k-1);\n        k--;\n      }\n    }\n  }\n\n  while ( (p > startId) && (m_data.index(p-1) > inner) )\n  {\n    m_data.index(p) = m_data.index(p-1);\n    m_data.value(p) = m_data.value(p-1);\n    --p;\n  }\n\n  m_data.index(p) = inner;\n  return (m_data.value(p) = 0);\n}\n\nnamespace internal {\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex>\nstruct evaluator<SparseMatrix<_Scalar,_Options,_StorageIndex> >\n  : evaluator<SparseCompressedBase<SparseMatrix<_Scalar,_Options,_StorageIndex> > >\n{\n  typedef evaluator<SparseCompressedBase<SparseMatrix<_Scalar,_Options,_StorageIndex> > > Base;\n  typedef SparseMatrix<_Scalar,_Options,_StorageIndex> SparseMatrixType;\n  evaluator() : Base() {}\n  explicit evaluator(const SparseMatrixType &mat) : Base(mat) {}\n};\n\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSEMATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseMatrixBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSEMATRIXBASE_H\n#define EIGEN_SPARSEMATRIXBASE_H\n\nnamespace Eigen { \n\n/** \\ingroup SparseCore_Module\n  *\n  * \\class SparseMatrixBase\n  *\n  * \\brief Base class of any sparse matrices or sparse expressions\n  *\n  * \\tparam Derived is the derived type, e.g. a sparse matrix type, or an expression, etc.\n  *\n  * This class can be extended with the help of the plugin mechanism described on the page\n  * \\ref TopicCustomizing_Plugins by defining the preprocessor symbol \\c EIGEN_SPARSEMATRIXBASE_PLUGIN.\n  */\ntemplate<typename Derived> class SparseMatrixBase\n  : public EigenBase<Derived>\n{\n  public:\n\n    typedef typename internal::traits<Derived>::Scalar Scalar;\n    \n    /** The numeric type of the expression' coefficients, e.g. float, double, int or std::complex<float>, etc.\n      *\n      * It is an alias for the Scalar type */\n    typedef Scalar value_type;\n    \n    typedef typename internal::packet_traits<Scalar>::type PacketScalar;\n    typedef typename internal::traits<Derived>::StorageKind StorageKind;\n\n    /** The integer type used to \\b store indices within a SparseMatrix.\n      * For a \\c SparseMatrix<Scalar,Options,IndexType> it an alias of the third template parameter \\c IndexType. */\n    typedef typename internal::traits<Derived>::StorageIndex StorageIndex;\n\n    typedef typename internal::add_const_on_value_type_if_arithmetic<\n                         typename internal::packet_traits<Scalar>::type\n                     >::type PacketReturnType;\n\n    typedef SparseMatrixBase StorageBaseType;\n\n    typedef Matrix<StorageIndex,Dynamic,1> IndexVector;\n    typedef Matrix<Scalar,Dynamic,1> ScalarVector;\n    \n    template<typename OtherDerived>\n    Derived& operator=(const EigenBase<OtherDerived> &other);\n\n    enum {\n\n      RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,\n        /**< The number of rows at compile-time. This is just a copy of the value provided\n          * by the \\a Derived type. If a value is not known at compile-time,\n          * it is set to the \\a Dynamic constant.\n          * \\sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */\n\n      ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,\n        /**< The number of columns at compile-time. This is just a copy of the value provided\n          * by the \\a Derived type. If a value is not known at compile-time,\n          * it is set to the \\a Dynamic constant.\n          * \\sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */\n\n\n      SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,\n                                                   internal::traits<Derived>::ColsAtCompileTime>::ret),\n        /**< This is equal to the number of coefficients, i.e. the number of\n          * rows times the number of columns, or to \\a Dynamic if this is not\n          * known at compile-time. \\sa RowsAtCompileTime, ColsAtCompileTime */\n\n      MaxRowsAtCompileTime = RowsAtCompileTime,\n      MaxColsAtCompileTime = ColsAtCompileTime,\n\n      MaxSizeAtCompileTime = (internal::size_at_compile_time<MaxRowsAtCompileTime,\n                                                      MaxColsAtCompileTime>::ret),\n\n      IsVectorAtCompileTime = RowsAtCompileTime == 1 || ColsAtCompileTime == 1,\n        /**< This is set to true if either the number of rows or the number of\n          * columns is known at compile-time to be equal to 1. Indeed, in that case,\n          * we are dealing with a column-vector (if there is only one column) or with\n          * a row-vector (if there is only one row). */\n\n      Flags = internal::traits<Derived>::Flags,\n        /**< This stores expression \\ref flags flags which may or may not be inherited by new expressions\n          * constructed from this one. See the \\ref flags \"list of flags\".\n          */\n\n      IsRowMajor = Flags&RowMajorBit ? 1 : 0,\n      \n      InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? int(SizeAtCompileTime)\n                             : int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime),\n\n      #ifndef EIGEN_PARSED_BY_DOXYGEN\n      _HasDirectAccess = (int(Flags)&DirectAccessBit) ? 1 : 0 // workaround sunCC\n      #endif\n    };\n\n    /** \\internal the return type of MatrixBase::adjoint() */\n    typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,\n                        CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, Eigen::Transpose<const Derived> >,\n                        Transpose<const Derived>\n                     >::type AdjointReturnType;\n    typedef Transpose<Derived> TransposeReturnType;\n    typedef typename internal::add_const<Transpose<const Derived> >::type ConstTransposeReturnType;\n\n    // FIXME storage order do not match evaluator storage order\n    typedef SparseMatrix<Scalar, Flags&RowMajorBit ? RowMajor : ColMajor, StorageIndex> PlainObject;\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** This is the \"real scalar\" type; if the \\a Scalar type is already real numbers\n      * (e.g. int, float or double) then \\a RealScalar is just the same as \\a Scalar. If\n      * \\a Scalar is \\a std::complex<T> then RealScalar is \\a T.\n      *\n      * \\sa class NumTraits\n      */\n    typedef typename NumTraits<Scalar>::Real RealScalar;\n\n    /** \\internal the return type of coeff()\n      */\n    typedef typename internal::conditional<_HasDirectAccess, const Scalar&, Scalar>::type CoeffReturnType;\n\n    /** \\internal Represents a matrix with all coefficients equal to one another*/\n    typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Matrix<Scalar,Dynamic,Dynamic> > ConstantReturnType;\n\n    /** type of the equivalent dense matrix */\n    typedef Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime> DenseMatrixType;\n    /** type of the equivalent square matrix */\n    typedef Matrix<Scalar,EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime),\n                          EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime)> SquareMatrixType;\n\n    inline const Derived& derived() const { return *static_cast<const Derived*>(this); }\n    inline Derived& derived() { return *static_cast<Derived*>(this); }\n    inline Derived& const_cast_derived() const\n    { return *static_cast<Derived*>(const_cast<SparseMatrixBase*>(this)); }\n\n    typedef EigenBase<Derived> Base;\n\n#endif // not EIGEN_PARSED_BY_DOXYGEN\n\n#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase\n#ifdef EIGEN_PARSED_BY_DOXYGEN\n#define EIGEN_DOC_UNARY_ADDONS(METHOD,OP)           /** <p>This method does not change the sparsity of \\c *this: the OP is applied to explicitly stored coefficients only. \\sa SparseCompressedBase::coeffs() </p> */\n#define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL      /** <p> \\warning This method returns a read-only expression for any sparse matrices. \\sa \\ref TutorialSparse_SubMatrices \"Sparse block operations\" </p> */\n#define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND) /** <p> \\warning This method returns a read-write expression for COND sparse matrices only. Otherwise, the returned expression is read-only. \\sa \\ref TutorialSparse_SubMatrices \"Sparse block operations\" </p> */\n#else\n#define EIGEN_DOC_UNARY_ADDONS(X,Y)\n#define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n#define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND)\n#endif\n#   include \"../plugins/CommonCwiseUnaryOps.h\"\n#   include \"../plugins/CommonCwiseBinaryOps.h\"\n#   include \"../plugins/MatrixCwiseUnaryOps.h\"\n#   include \"../plugins/MatrixCwiseBinaryOps.h\"\n#   include \"../plugins/BlockMethods.h\"\n#   ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN\n#     include EIGEN_SPARSEMATRIXBASE_PLUGIN\n#   endif\n#undef EIGEN_CURRENT_STORAGE_BASE_CLASS\n#undef EIGEN_DOC_UNARY_ADDONS\n#undef EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n#undef EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF\n\n    /** \\returns the number of rows. \\sa cols() */\n    inline Index rows() const { return derived().rows(); }\n    /** \\returns the number of columns. \\sa rows() */\n    inline Index cols() const { return derived().cols(); }\n    /** \\returns the number of coefficients, which is \\a rows()*cols().\n      * \\sa rows(), cols(). */\n    inline Index size() const { return rows() * cols(); }\n    /** \\returns true if either the number of rows or the number of columns is equal to 1.\n      * In other words, this function returns\n      * \\code rows()==1 || cols()==1 \\endcode\n      * \\sa rows(), cols(), IsVectorAtCompileTime. */\n    inline bool isVector() const { return rows()==1 || cols()==1; }\n    /** \\returns the size of the storage major dimension,\n      * i.e., the number of columns for a columns major matrix, and the number of rows otherwise */\n    Index outerSize() const { return (int(Flags)&RowMajorBit) ? this->rows() : this->cols(); }\n    /** \\returns the size of the inner dimension according to the storage order,\n      * i.e., the number of rows for a columns major matrix, and the number of cols otherwise */\n    Index innerSize() const { return (int(Flags)&RowMajorBit) ? this->cols() : this->rows(); }\n\n    bool isRValue() const { return m_isRValue; }\n    Derived& markAsRValue() { m_isRValue = true; return derived(); }\n\n    SparseMatrixBase() : m_isRValue(false) { /* TODO check flags */ }\n\n    \n    template<typename OtherDerived>\n    Derived& operator=(const ReturnByValue<OtherDerived>& other);\n\n    template<typename OtherDerived>\n    inline Derived& operator=(const SparseMatrixBase<OtherDerived>& other);\n\n    inline Derived& operator=(const Derived& other);\n\n  protected:\n\n    template<typename OtherDerived>\n    inline Derived& assign(const OtherDerived& other);\n\n    template<typename OtherDerived>\n    inline void assignGeneric(const OtherDerived& other);\n\n  public:\n\n    friend std::ostream & operator << (std::ostream & s, const SparseMatrixBase& m)\n    {\n      typedef typename Derived::Nested Nested;\n      typedef typename internal::remove_all<Nested>::type NestedCleaned;\n\n      if (Flags&RowMajorBit)\n      {\n        Nested nm(m.derived());\n        internal::evaluator<NestedCleaned> thisEval(nm);\n        for (Index row=0; row<nm.outerSize(); ++row)\n        {\n          Index col = 0;\n          for (typename internal::evaluator<NestedCleaned>::InnerIterator it(thisEval, row); it; ++it)\n          {\n            for ( ; col<it.index(); ++col)\n              s << \"0 \";\n            s << it.value() << \" \";\n            ++col;\n          }\n          for ( ; col<m.cols(); ++col)\n            s << \"0 \";\n          s << std::endl;\n        }\n      }\n      else\n      {\n        Nested nm(m.derived());\n        internal::evaluator<NestedCleaned> thisEval(nm);\n        if (m.cols() == 1) {\n          Index row = 0;\n          for (typename internal::evaluator<NestedCleaned>::InnerIterator it(thisEval, 0); it; ++it)\n          {\n            for ( ; row<it.index(); ++row)\n              s << \"0\" << std::endl;\n            s << it.value() << std::endl;\n            ++row;\n          }\n          for ( ; row<m.rows(); ++row)\n            s << \"0\" << std::endl;\n        }\n        else\n        {\n          SparseMatrix<Scalar, RowMajorBit, StorageIndex> trans = m;\n          s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit, StorageIndex> >&>(trans);\n        }\n      }\n      return s;\n    }\n\n    template<typename OtherDerived>\n    Derived& operator+=(const SparseMatrixBase<OtherDerived>& other);\n    template<typename OtherDerived>\n    Derived& operator-=(const SparseMatrixBase<OtherDerived>& other);\n    \n    template<typename OtherDerived>\n    Derived& operator+=(const DiagonalBase<OtherDerived>& other);\n    template<typename OtherDerived>\n    Derived& operator-=(const DiagonalBase<OtherDerived>& other);\n\n    template<typename OtherDerived>\n    Derived& operator+=(const EigenBase<OtherDerived> &other);\n    template<typename OtherDerived>\n    Derived& operator-=(const EigenBase<OtherDerived> &other);\n\n    Derived& operator*=(const Scalar& other);\n    Derived& operator/=(const Scalar& other);\n\n    template<typename OtherDerived> struct CwiseProductDenseReturnType {\n      typedef CwiseBinaryOp<internal::scalar_product_op<typename ScalarBinaryOpTraits<\n                                                          typename internal::traits<Derived>::Scalar,\n                                                          typename internal::traits<OtherDerived>::Scalar\n                                                        >::ReturnType>,\n                            const Derived,\n                            const OtherDerived\n                          > Type;\n    };\n\n    template<typename OtherDerived>\n    EIGEN_STRONG_INLINE const typename CwiseProductDenseReturnType<OtherDerived>::Type\n    cwiseProduct(const MatrixBase<OtherDerived> &other) const;\n\n    // sparse * diagonal\n    template<typename OtherDerived>\n    const Product<Derived,OtherDerived>\n    operator*(const DiagonalBase<OtherDerived> &other) const\n    { return Product<Derived,OtherDerived>(derived(), other.derived()); }\n\n    // diagonal * sparse\n    template<typename OtherDerived> friend\n    const Product<OtherDerived,Derived>\n    operator*(const DiagonalBase<OtherDerived> &lhs, const SparseMatrixBase& rhs)\n    { return Product<OtherDerived,Derived>(lhs.derived(), rhs.derived()); }\n    \n    // sparse * sparse\n    template<typename OtherDerived>\n    const Product<Derived,OtherDerived,AliasFreeProduct>\n    operator*(const SparseMatrixBase<OtherDerived> &other) const;\n    \n    // sparse * dense\n    template<typename OtherDerived>\n    const Product<Derived,OtherDerived>\n    operator*(const MatrixBase<OtherDerived> &other) const\n    { return Product<Derived,OtherDerived>(derived(), other.derived()); }\n    \n    // dense * sparse\n    template<typename OtherDerived> friend\n    const Product<OtherDerived,Derived>\n    operator*(const MatrixBase<OtherDerived> &lhs, const SparseMatrixBase& rhs)\n    { return Product<OtherDerived,Derived>(lhs.derived(), rhs.derived()); }\n    \n     /** \\returns an expression of P H P^-1 where H is the matrix represented by \\c *this */\n    SparseSymmetricPermutationProduct<Derived,Upper|Lower> twistedBy(const PermutationMatrix<Dynamic,Dynamic,StorageIndex>& perm) const\n    {\n      return SparseSymmetricPermutationProduct<Derived,Upper|Lower>(derived(), perm);\n    }\n\n    template<typename OtherDerived>\n    Derived& operator*=(const SparseMatrixBase<OtherDerived>& other);\n\n    template<int Mode>\n    inline const TriangularView<const Derived, Mode> triangularView() const;\n    \n    template<unsigned int UpLo> struct SelfAdjointViewReturnType { typedef SparseSelfAdjointView<Derived, UpLo> Type; };\n    template<unsigned int UpLo> struct ConstSelfAdjointViewReturnType { typedef const SparseSelfAdjointView<const Derived, UpLo> Type; };\n\n    template<unsigned int UpLo> inline \n    typename ConstSelfAdjointViewReturnType<UpLo>::Type selfadjointView() const;\n    template<unsigned int UpLo> inline\n    typename SelfAdjointViewReturnType<UpLo>::Type selfadjointView();\n\n    template<typename OtherDerived> Scalar dot(const MatrixBase<OtherDerived>& other) const;\n    template<typename OtherDerived> Scalar dot(const SparseMatrixBase<OtherDerived>& other) const;\n    RealScalar squaredNorm() const;\n    RealScalar norm()  const;\n    RealScalar blueNorm() const;\n\n    TransposeReturnType transpose() { return TransposeReturnType(derived()); }\n    const ConstTransposeReturnType transpose() const { return ConstTransposeReturnType(derived()); }\n    const AdjointReturnType adjoint() const { return AdjointReturnType(transpose()); }\n\n    // inner-vector\n    typedef Block<Derived,IsRowMajor?1:Dynamic,IsRowMajor?Dynamic:1,true>       InnerVectorReturnType;\n    typedef Block<const Derived,IsRowMajor?1:Dynamic,IsRowMajor?Dynamic:1,true> ConstInnerVectorReturnType;\n    InnerVectorReturnType innerVector(Index outer);\n    const ConstInnerVectorReturnType innerVector(Index outer) const;\n\n    // set of inner-vectors\n    typedef Block<Derived,Dynamic,Dynamic,true> InnerVectorsReturnType;\n    typedef Block<const Derived,Dynamic,Dynamic,true> ConstInnerVectorsReturnType;\n    InnerVectorsReturnType innerVectors(Index outerStart, Index outerSize);\n    const ConstInnerVectorsReturnType innerVectors(Index outerStart, Index outerSize) const;\n\n    DenseMatrixType toDense() const\n    {\n      return DenseMatrixType(derived());\n    }\n\n    template<typename OtherDerived>\n    bool isApprox(const SparseMatrixBase<OtherDerived>& other,\n                  const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;\n\n    template<typename OtherDerived>\n    bool isApprox(const MatrixBase<OtherDerived>& other,\n                  const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const\n    { return toDense().isApprox(other,prec); }\n\n    /** \\returns the matrix or vector obtained by evaluating this expression.\n      *\n      * Notice that in the case of a plain matrix or vector (not an expression) this function just returns\n      * a const reference, in order to avoid a useless copy.\n      */\n    inline const typename internal::eval<Derived>::type eval() const\n    { return typename internal::eval<Derived>::type(derived()); }\n\n    Scalar sum() const;\n    \n    inline const SparseView<Derived>\n    pruned(const Scalar& reference = Scalar(0), const RealScalar& epsilon = NumTraits<Scalar>::dummy_precision()) const;\n\n  protected:\n\n    bool m_isRValue;\n\n    static inline StorageIndex convert_index(const Index idx) {\n      return internal::convert_index<StorageIndex>(idx);\n    }\n  private:\n    template<typename Dest> void evalTo(Dest &) const;\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSEMATRIXBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparsePermutation.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_PERMUTATION_H\n#define EIGEN_SPARSE_PERMUTATION_H\n\n// This file implements sparse * permutation products\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename ExpressionType, int Side, bool Transposed>\nstruct permutation_matrix_product<ExpressionType, Side, Transposed, SparseShape>\n{\n    typedef typename nested_eval<ExpressionType, 1>::type MatrixType;\n    typedef typename remove_all<MatrixType>::type MatrixTypeCleaned;\n\n    typedef typename MatrixTypeCleaned::Scalar Scalar;\n    typedef typename MatrixTypeCleaned::StorageIndex StorageIndex;\n\n    enum {\n      SrcStorageOrder = MatrixTypeCleaned::Flags&RowMajorBit ? RowMajor : ColMajor,\n      MoveOuter = SrcStorageOrder==RowMajor ? Side==OnTheLeft : Side==OnTheRight\n    };\n    \n    typedef typename internal::conditional<MoveOuter,\n        SparseMatrix<Scalar,SrcStorageOrder,StorageIndex>,\n        SparseMatrix<Scalar,int(SrcStorageOrder)==RowMajor?ColMajor:RowMajor,StorageIndex> >::type ReturnType;\n\n    template<typename Dest,typename PermutationType>\n    static inline void run(Dest& dst, const PermutationType& perm, const ExpressionType& xpr)\n    {\n      MatrixType mat(xpr);\n      if(MoveOuter)\n      {\n        SparseMatrix<Scalar,SrcStorageOrder,StorageIndex> tmp(mat.rows(), mat.cols());\n        Matrix<StorageIndex,Dynamic,1> sizes(mat.outerSize());\n        for(Index j=0; j<mat.outerSize(); ++j)\n        {\n          Index jp = perm.indices().coeff(j);\n          sizes[((Side==OnTheLeft) ^ Transposed) ? jp : j] = StorageIndex(mat.innerVector(((Side==OnTheRight) ^ Transposed) ? jp : j).nonZeros());\n        }\n        tmp.reserve(sizes);\n        for(Index j=0; j<mat.outerSize(); ++j)\n        {\n          Index jp = perm.indices().coeff(j);\n          Index jsrc = ((Side==OnTheRight) ^ Transposed) ? jp : j;\n          Index jdst = ((Side==OnTheLeft) ^ Transposed) ? jp : j;\n          for(typename MatrixTypeCleaned::InnerIterator it(mat,jsrc); it; ++it)\n            tmp.insertByOuterInner(jdst,it.index()) = it.value();\n        }\n        dst = tmp;\n      }\n      else\n      {\n        SparseMatrix<Scalar,int(SrcStorageOrder)==RowMajor?ColMajor:RowMajor,StorageIndex> tmp(mat.rows(), mat.cols());\n        Matrix<StorageIndex,Dynamic,1> sizes(tmp.outerSize());\n        sizes.setZero();\n        PermutationMatrix<Dynamic,Dynamic,StorageIndex> perm_cpy;\n        if((Side==OnTheLeft) ^ Transposed)\n          perm_cpy = perm;\n        else\n          perm_cpy = perm.transpose();\n\n        for(Index j=0; j<mat.outerSize(); ++j)\n          for(typename MatrixTypeCleaned::InnerIterator it(mat,j); it; ++it)\n            sizes[perm_cpy.indices().coeff(it.index())]++;\n        tmp.reserve(sizes);\n        for(Index j=0; j<mat.outerSize(); ++j)\n          for(typename MatrixTypeCleaned::InnerIterator it(mat,j); it; ++it)\n            tmp.insertByOuterInner(perm_cpy.indices().coeff(it.index()),j) = it.value();\n        dst = tmp;\n      }\n    }\n};\n\n}\n\nnamespace internal {\n\ntemplate <int ProductTag> struct product_promote_storage_type<Sparse,             PermutationStorage, ProductTag> { typedef Sparse ret; };\ntemplate <int ProductTag> struct product_promote_storage_type<PermutationStorage, Sparse,             ProductTag> { typedef Sparse ret; };\n\n// TODO, the following two overloads are only needed to define the right temporary type through \n// typename traits<permutation_sparse_matrix_product<Rhs,Lhs,OnTheRight,false> >::ReturnType\n// whereas it should be correctly handled by traits<Product<> >::PlainObject\n\ntemplate<typename Lhs, typename Rhs, int ProductTag>\nstruct product_evaluator<Product<Lhs, Rhs, AliasFreeProduct>, ProductTag, PermutationShape, SparseShape>\n  : public evaluator<typename permutation_matrix_product<Rhs,OnTheLeft,false,SparseShape>::ReturnType>\n{\n  typedef Product<Lhs, Rhs, AliasFreeProduct> XprType;\n  typedef typename permutation_matrix_product<Rhs,OnTheLeft,false,SparseShape>::ReturnType PlainObject;\n  typedef evaluator<PlainObject> Base;\n\n  enum {\n    Flags = Base::Flags | EvalBeforeNestingBit\n  };\n\n  explicit product_evaluator(const XprType& xpr)\n    : m_result(xpr.rows(), xpr.cols())\n  {\n    ::new (static_cast<Base*>(this)) Base(m_result);\n    generic_product_impl<Lhs, Rhs, PermutationShape, SparseShape, ProductTag>::evalTo(m_result, xpr.lhs(), xpr.rhs());\n  }\n\nprotected:\n  PlainObject m_result;\n};\n\ntemplate<typename Lhs, typename Rhs, int ProductTag>\nstruct product_evaluator<Product<Lhs, Rhs, AliasFreeProduct>, ProductTag, SparseShape, PermutationShape >\n  : public evaluator<typename permutation_matrix_product<Lhs,OnTheRight,false,SparseShape>::ReturnType>\n{\n  typedef Product<Lhs, Rhs, AliasFreeProduct> XprType;\n  typedef typename permutation_matrix_product<Lhs,OnTheRight,false,SparseShape>::ReturnType PlainObject;\n  typedef evaluator<PlainObject> Base;\n\n  enum {\n    Flags = Base::Flags | EvalBeforeNestingBit\n  };\n\n  explicit product_evaluator(const XprType& xpr)\n    : m_result(xpr.rows(), xpr.cols())\n  {\n    ::new (static_cast<Base*>(this)) Base(m_result);\n    generic_product_impl<Lhs, Rhs, SparseShape, PermutationShape, ProductTag>::evalTo(m_result, xpr.lhs(), xpr.rhs());\n  }\n\nprotected:\n  PlainObject m_result;\n};\n\n} // end namespace internal\n\n/** \\returns the matrix with the permutation applied to the columns\n  */\ntemplate<typename SparseDerived, typename PermDerived>\ninline const Product<SparseDerived, PermDerived, AliasFreeProduct>\noperator*(const SparseMatrixBase<SparseDerived>& matrix, const PermutationBase<PermDerived>& perm)\n{ return Product<SparseDerived, PermDerived, AliasFreeProduct>(matrix.derived(), perm.derived()); }\n\n/** \\returns the matrix with the permutation applied to the rows\n  */\ntemplate<typename SparseDerived, typename PermDerived>\ninline const Product<PermDerived, SparseDerived, AliasFreeProduct>\noperator*( const PermutationBase<PermDerived>& perm, const SparseMatrixBase<SparseDerived>& matrix)\n{ return  Product<PermDerived, SparseDerived, AliasFreeProduct>(perm.derived(), matrix.derived()); }\n\n\n/** \\returns the matrix with the inverse permutation applied to the columns.\n  */\ntemplate<typename SparseDerived, typename PermutationType>\ninline const Product<SparseDerived, Inverse<PermutationType>, AliasFreeProduct>\noperator*(const SparseMatrixBase<SparseDerived>& matrix, const InverseImpl<PermutationType, PermutationStorage>& tperm)\n{\n  return Product<SparseDerived, Inverse<PermutationType>, AliasFreeProduct>(matrix.derived(), tperm.derived());\n}\n\n/** \\returns the matrix with the inverse permutation applied to the rows.\n  */\ntemplate<typename SparseDerived, typename PermutationType>\ninline const Product<Inverse<PermutationType>, SparseDerived, AliasFreeProduct>\noperator*(const InverseImpl<PermutationType,PermutationStorage>& tperm, const SparseMatrixBase<SparseDerived>& matrix)\n{\n  return Product<Inverse<PermutationType>, SparseDerived, AliasFreeProduct>(tperm.derived(), matrix.derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_SELFADJOINTVIEW_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseProduct.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSEPRODUCT_H\n#define EIGEN_SPARSEPRODUCT_H\n\nnamespace Eigen { \n\n/** \\returns an expression of the product of two sparse matrices.\n  * By default a conservative product preserving the symbolic non zeros is performed.\n  * The automatic pruning of the small values can be achieved by calling the pruned() function\n  * in which case a totally different product algorithm is employed:\n  * \\code\n  * C = (A*B).pruned();             // supress numerical zeros (exact)\n  * C = (A*B).pruned(ref);\n  * C = (A*B).pruned(ref,epsilon);\n  * \\endcode\n  * where \\c ref is a meaningful non zero reference value.\n  * */\ntemplate<typename Derived>\ntemplate<typename OtherDerived>\ninline const Product<Derived,OtherDerived,AliasFreeProduct>\nSparseMatrixBase<Derived>::operator*(const SparseMatrixBase<OtherDerived> &other) const\n{\n  return Product<Derived,OtherDerived,AliasFreeProduct>(derived(), other.derived());\n}\n\nnamespace internal {\n\n// sparse * sparse\ntemplate<typename Lhs, typename Rhs, int ProductType>\nstruct generic_product_impl<Lhs, Rhs, SparseShape, SparseShape, ProductType>\n{\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Lhs& lhs, const Rhs& rhs)\n  {\n    evalTo(dst, lhs, rhs, typename evaluator_traits<Dest>::Shape());\n  }\n\n  // dense += sparse * sparse\n  template<typename Dest,typename ActualLhs>\n  static void addTo(Dest& dst, const ActualLhs& lhs, const Rhs& rhs, typename enable_if<is_same<typename evaluator_traits<Dest>::Shape,DenseShape>::value,int*>::type* = 0)\n  {\n    typedef typename nested_eval<ActualLhs,Dynamic>::type LhsNested;\n    typedef typename nested_eval<Rhs,Dynamic>::type RhsNested;\n    LhsNested lhsNested(lhs);\n    RhsNested rhsNested(rhs);\n    internal::sparse_sparse_to_dense_product_selector<typename remove_all<LhsNested>::type,\n                                                      typename remove_all<RhsNested>::type, Dest>::run(lhsNested,rhsNested,dst);\n  }\n\n  // dense -= sparse * sparse\n  template<typename Dest>\n  static void subTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, typename enable_if<is_same<typename evaluator_traits<Dest>::Shape,DenseShape>::value,int*>::type* = 0)\n  {\n    addTo(dst, -lhs, rhs);\n  }\n\nprotected:\n\n  // sparse = sparse * sparse\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, SparseShape)\n  {\n    typedef typename nested_eval<Lhs,Dynamic>::type LhsNested;\n    typedef typename nested_eval<Rhs,Dynamic>::type RhsNested;\n    LhsNested lhsNested(lhs);\n    RhsNested rhsNested(rhs);\n    internal::conservative_sparse_sparse_product_selector<typename remove_all<LhsNested>::type,\n                                                          typename remove_all<RhsNested>::type, Dest>::run(lhsNested,rhsNested,dst);\n  }\n\n  // dense = sparse * sparse\n  template<typename Dest>\n  static void evalTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, DenseShape)\n  {\n    dst.setZero();\n    addTo(dst, lhs, rhs);\n  }\n};\n\n// sparse * sparse-triangular\ntemplate<typename Lhs, typename Rhs, int ProductType>\nstruct generic_product_impl<Lhs, Rhs, SparseShape, SparseTriangularShape, ProductType>\n : public generic_product_impl<Lhs, Rhs, SparseShape, SparseShape, ProductType>\n{};\n\n// sparse-triangular * sparse\ntemplate<typename Lhs, typename Rhs, int ProductType>\nstruct generic_product_impl<Lhs, Rhs, SparseTriangularShape, SparseShape, ProductType>\n : public generic_product_impl<Lhs, Rhs, SparseShape, SparseShape, ProductType>\n{};\n\n// dense = sparse-product (can be sparse*sparse, sparse*perm, etc.)\ntemplate< typename DstXprType, typename Lhs, typename Rhs>\nstruct Assignment<DstXprType, Product<Lhs,Rhs,AliasFreeProduct>, internal::assign_op<typename DstXprType::Scalar,typename Product<Lhs,Rhs,AliasFreeProduct>::Scalar>, Sparse2Dense>\n{\n  typedef Product<Lhs,Rhs,AliasFreeProduct> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &)\n  {\n    Index dstRows = src.rows();\n    Index dstCols = src.cols();\n    if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))\n      dst.resize(dstRows, dstCols);\n    \n    generic_product_impl<Lhs, Rhs>::evalTo(dst,src.lhs(),src.rhs());\n  }\n};\n\n// dense += sparse-product (can be sparse*sparse, sparse*perm, etc.)\ntemplate< typename DstXprType, typename Lhs, typename Rhs>\nstruct Assignment<DstXprType, Product<Lhs,Rhs,AliasFreeProduct>, internal::add_assign_op<typename DstXprType::Scalar,typename Product<Lhs,Rhs,AliasFreeProduct>::Scalar>, Sparse2Dense>\n{\n  typedef Product<Lhs,Rhs,AliasFreeProduct> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &)\n  {\n    generic_product_impl<Lhs, Rhs>::addTo(dst,src.lhs(),src.rhs());\n  }\n};\n\n// dense -= sparse-product (can be sparse*sparse, sparse*perm, etc.)\ntemplate< typename DstXprType, typename Lhs, typename Rhs>\nstruct Assignment<DstXprType, Product<Lhs,Rhs,AliasFreeProduct>, internal::sub_assign_op<typename DstXprType::Scalar,typename Product<Lhs,Rhs,AliasFreeProduct>::Scalar>, Sparse2Dense>\n{\n  typedef Product<Lhs,Rhs,AliasFreeProduct> SrcXprType;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &)\n  {\n    generic_product_impl<Lhs, Rhs>::subTo(dst,src.lhs(),src.rhs());\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, int Options>\nstruct unary_evaluator<SparseView<Product<Lhs, Rhs, Options> >, IteratorBased>\n : public evaluator<typename Product<Lhs, Rhs, DefaultProduct>::PlainObject>\n{\n  typedef SparseView<Product<Lhs, Rhs, Options> > XprType;\n  typedef typename XprType::PlainObject PlainObject;\n  typedef evaluator<PlainObject> Base;\n\n  explicit unary_evaluator(const XprType& xpr)\n    : m_result(xpr.rows(), xpr.cols())\n  {\n    using std::abs;\n    ::new (static_cast<Base*>(this)) Base(m_result);\n    typedef typename nested_eval<Lhs,Dynamic>::type LhsNested;\n    typedef typename nested_eval<Rhs,Dynamic>::type RhsNested;\n    LhsNested lhsNested(xpr.nestedExpression().lhs());\n    RhsNested rhsNested(xpr.nestedExpression().rhs());\n\n    internal::sparse_sparse_product_with_pruning_selector<typename remove_all<LhsNested>::type,\n                                                          typename remove_all<RhsNested>::type, PlainObject>::run(lhsNested,rhsNested,m_result,\n                                                                                                                  abs(xpr.reference())*xpr.epsilon());\n  }\n\nprotected:\n  PlainObject m_result;\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSEPRODUCT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseRedux.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSEREDUX_H\n#define EIGEN_SPARSEREDUX_H\n\nnamespace Eigen { \n\ntemplate<typename Derived>\ntypename internal::traits<Derived>::Scalar\nSparseMatrixBase<Derived>::sum() const\n{\n  eigen_assert(rows()>0 && cols()>0 && \"you are using a non initialized matrix\");\n  Scalar res(0);\n  internal::evaluator<Derived> thisEval(derived());\n  for (Index j=0; j<outerSize(); ++j)\n    for (typename internal::evaluator<Derived>::InnerIterator iter(thisEval,j); iter; ++iter)\n      res += iter.value();\n  return res;\n}\n\ntemplate<typename _Scalar, int _Options, typename _Index>\ntypename internal::traits<SparseMatrix<_Scalar,_Options,_Index> >::Scalar\nSparseMatrix<_Scalar,_Options,_Index>::sum() const\n{\n  eigen_assert(rows()>0 && cols()>0 && \"you are using a non initialized matrix\");\n  if(this->isCompressed())\n    return Matrix<Scalar,1,Dynamic>::Map(m_data.valuePtr(), m_data.size()).sum();\n  else\n    return Base::sum();\n}\n\ntemplate<typename _Scalar, int _Options, typename _Index>\ntypename internal::traits<SparseVector<_Scalar,_Options, _Index> >::Scalar\nSparseVector<_Scalar,_Options,_Index>::sum() const\n{\n  eigen_assert(rows()>0 && cols()>0 && \"you are using a non initialized matrix\");\n  return Matrix<Scalar,1,Dynamic>::Map(m_data.valuePtr(), m_data.size()).sum();\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSEREDUX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseRef.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_REF_H\n#define EIGEN_SPARSE_REF_H\n\nnamespace Eigen {\n\nenum {\n  StandardCompressedFormat = 2 /**< used by Ref<SparseMatrix> to specify whether the input storage must be in standard compressed form */\n};\n  \nnamespace internal {\n\ntemplate<typename Derived> class SparseRefBase;\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int _Options, typename _StrideType>\nstruct traits<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, _Options, _StrideType> >\n  : public traits<SparseMatrix<MatScalar,MatOptions,MatIndex> >\n{\n  typedef SparseMatrix<MatScalar,MatOptions,MatIndex> PlainObjectType;\n  enum {\n    Options = _Options,\n    Flags = traits<PlainObjectType>::Flags | CompressedAccessBit | NestByRefBit\n  };\n\n  template<typename Derived> struct match {\n    enum {\n      StorageOrderMatch = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime || ((PlainObjectType::Flags&RowMajorBit)==(Derived::Flags&RowMajorBit)),\n      MatchAtCompileTime = (Derived::Flags&CompressedAccessBit) && StorageOrderMatch\n    };\n    typedef typename internal::conditional<MatchAtCompileTime,internal::true_type,internal::false_type>::type type;\n  };\n  \n};\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int _Options, typename _StrideType>\nstruct traits<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, _Options, _StrideType> >\n  : public traits<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, _Options, _StrideType> >\n{\n  enum {\n    Flags = (traits<SparseMatrix<MatScalar,MatOptions,MatIndex> >::Flags | CompressedAccessBit | NestByRefBit) & ~LvalueBit\n  };\n};\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int _Options, typename _StrideType>\nstruct traits<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, _Options, _StrideType> >\n  : public traits<SparseVector<MatScalar,MatOptions,MatIndex> >\n{\n  typedef SparseVector<MatScalar,MatOptions,MatIndex> PlainObjectType;\n  enum {\n    Options = _Options,\n    Flags = traits<PlainObjectType>::Flags | CompressedAccessBit | NestByRefBit\n  };\n\n  template<typename Derived> struct match {\n    enum {\n      MatchAtCompileTime = (Derived::Flags&CompressedAccessBit) && Derived::IsVectorAtCompileTime\n    };\n    typedef typename internal::conditional<MatchAtCompileTime,internal::true_type,internal::false_type>::type type;\n  };\n\n};\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int _Options, typename _StrideType>\nstruct traits<Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, _Options, _StrideType> >\n  : public traits<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, _Options, _StrideType> >\n{\n  enum {\n    Flags = (traits<SparseVector<MatScalar,MatOptions,MatIndex> >::Flags | CompressedAccessBit | NestByRefBit) & ~LvalueBit\n  };\n};\n\ntemplate<typename Derived>\nstruct traits<SparseRefBase<Derived> > : public traits<Derived> {};\n\ntemplate<typename Derived> class SparseRefBase\n  : public SparseMapBase<Derived>\n{\npublic:\n\n  typedef SparseMapBase<Derived> Base;\n  EIGEN_SPARSE_PUBLIC_INTERFACE(SparseRefBase)\n\n  SparseRefBase()\n    : Base(RowsAtCompileTime==Dynamic?0:RowsAtCompileTime,ColsAtCompileTime==Dynamic?0:ColsAtCompileTime, 0, 0, 0, 0, 0)\n  {}\n  \nprotected:\n\n  template<typename Expression>\n  void construct(Expression& expr)\n  {\n    if(expr.outerIndexPtr()==0)\n      ::new (static_cast<Base*>(this)) Base(expr.size(), expr.nonZeros(), expr.innerIndexPtr(), expr.valuePtr());\n    else\n      ::new (static_cast<Base*>(this)) Base(expr.rows(), expr.cols(), expr.nonZeros(), expr.outerIndexPtr(), expr.innerIndexPtr(), expr.valuePtr(), expr.innerNonZeroPtr());\n  }\n};\n\n} // namespace internal\n\n\n/** \n  * \\ingroup SparseCore_Module\n  *\n  * \\brief A sparse matrix expression referencing an existing sparse expression\n  *\n  * \\tparam SparseMatrixType the equivalent sparse matrix type of the referenced data, it must be a template instance of class SparseMatrix.\n  * \\tparam Options specifies whether the a standard compressed format is required \\c Options is  \\c #StandardCompressedFormat, or \\c 0.\n  *                The default is \\c 0.\n  *\n  * \\sa class Ref\n  */\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nclass Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType >\n  : public internal::SparseRefBase<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType > >\n#else\ntemplate<typename SparseMatrixType, int Options>\nclass Ref<SparseMatrixType, Options>\n  : public SparseMapBase<Derived,WriteAccessors> // yes, that's weird to use Derived here, but that works!\n#endif\n{\n    typedef SparseMatrix<MatScalar,MatOptions,MatIndex> PlainObjectType;\n    typedef internal::traits<Ref> Traits;\n    template<int OtherOptions>\n    inline Ref(const SparseMatrix<MatScalar,OtherOptions,MatIndex>& expr);\n    template<int OtherOptions>\n    inline Ref(const MappedSparseMatrix<MatScalar,OtherOptions,MatIndex>& expr);\n  public:\n\n    typedef internal::SparseRefBase<Ref> Base;\n    EIGEN_SPARSE_PUBLIC_INTERFACE(Ref)\n\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<int OtherOptions>\n    inline Ref(SparseMatrix<MatScalar,OtherOptions,MatIndex>& expr)\n    {\n      EIGEN_STATIC_ASSERT(bool(Traits::template match<SparseMatrix<MatScalar,OtherOptions,MatIndex> >::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);\n      eigen_assert( ((Options & int(StandardCompressedFormat))==0) || (expr.isCompressed()) );\n      Base::construct(expr.derived());\n    }\n    \n    template<int OtherOptions>\n    inline Ref(MappedSparseMatrix<MatScalar,OtherOptions,MatIndex>& expr)\n    {\n      EIGEN_STATIC_ASSERT(bool(Traits::template match<SparseMatrix<MatScalar,OtherOptions,MatIndex> >::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);\n      eigen_assert( ((Options & int(StandardCompressedFormat))==0) || (expr.isCompressed()) );\n      Base::construct(expr.derived());\n    }\n    \n    template<typename Derived>\n    inline Ref(const SparseCompressedBase<Derived>& expr)\n    #else\n    /** Implicit constructor from any sparse expression (2D matrix or 1D vector) */\n    template<typename Derived>\n    inline Ref(SparseCompressedBase<Derived>& expr)\n    #endif\n    {\n      EIGEN_STATIC_ASSERT(bool(internal::is_lvalue<Derived>::value), THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);\n      EIGEN_STATIC_ASSERT(bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);\n      eigen_assert( ((Options & int(StandardCompressedFormat))==0) || (expr.isCompressed()) );\n      Base::construct(expr.const_cast_derived());\n    }\n};\n\n// this is the const ref version\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nclass Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType>\n  : public internal::SparseRefBase<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n{\n    typedef SparseMatrix<MatScalar,MatOptions,MatIndex> TPlainObjectType;\n    typedef internal::traits<Ref> Traits;\n  public:\n\n    typedef internal::SparseRefBase<Ref> Base;\n    EIGEN_SPARSE_PUBLIC_INTERFACE(Ref)\n\n    template<typename Derived>\n    inline Ref(const SparseMatrixBase<Derived>& expr) : m_hasCopy(false)\n    {\n      construct(expr.derived(), typename Traits::template match<Derived>::type());\n    }\n\n    inline Ref(const Ref& other) : Base(other), m_hasCopy(false) {\n      // copy constructor shall not copy the m_object, to avoid unnecessary malloc and copy\n    }\n\n    template<typename OtherRef>\n    inline Ref(const RefBase<OtherRef>& other) : m_hasCopy(false) {\n      construct(other.derived(), typename Traits::template match<OtherRef>::type());\n    }\n\n    ~Ref() {\n      if(m_hasCopy) {\n        TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);\n        obj->~TPlainObjectType();\n      }\n    }\n\n  protected:\n\n    template<typename Expression>\n    void construct(const Expression& expr,internal::true_type)\n    {\n      if((Options & int(StandardCompressedFormat)) && (!expr.isCompressed()))\n      {\n        TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);\n        ::new (obj) TPlainObjectType(expr);\n        m_hasCopy = true;\n        Base::construct(*obj);\n      }\n      else\n      {\n        Base::construct(expr);\n      }\n    }\n\n    template<typename Expression>\n    void construct(const Expression& expr, internal::false_type)\n    {\n      TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);\n      ::new (obj) TPlainObjectType(expr);\n      m_hasCopy = true;\n      Base::construct(*obj);\n    }\n\n  protected:\n    char m_object_bytes[sizeof(TPlainObjectType)];\n    bool m_hasCopy;\n};\n\n\n\n/**\n  * \\ingroup SparseCore_Module\n  *\n  * \\brief A sparse vector expression referencing an existing sparse vector expression\n  *\n  * \\tparam SparseVectorType the equivalent sparse vector type of the referenced data, it must be a template instance of class SparseVector.\n  *\n  * \\sa class Ref\n  */\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nclass Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType >\n  : public internal::SparseRefBase<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType > >\n#else\ntemplate<typename SparseVectorType>\nclass Ref<SparseVectorType>\n  : public SparseMapBase<Derived,WriteAccessors>\n#endif\n{\n    typedef SparseVector<MatScalar,MatOptions,MatIndex> PlainObjectType;\n    typedef internal::traits<Ref> Traits;\n    template<int OtherOptions>\n    inline Ref(const SparseVector<MatScalar,OtherOptions,MatIndex>& expr);\n  public:\n\n    typedef internal::SparseRefBase<Ref> Base;\n    EIGEN_SPARSE_PUBLIC_INTERFACE(Ref)\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<int OtherOptions>\n    inline Ref(SparseVector<MatScalar,OtherOptions,MatIndex>& expr)\n    {\n      EIGEN_STATIC_ASSERT(bool(Traits::template match<SparseVector<MatScalar,OtherOptions,MatIndex> >::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);\n      Base::construct(expr.derived());\n    }\n\n    template<typename Derived>\n    inline Ref(const SparseCompressedBase<Derived>& expr)\n    #else\n    /** Implicit constructor from any 1D sparse vector expression */\n    template<typename Derived>\n    inline Ref(SparseCompressedBase<Derived>& expr)\n    #endif\n    {\n      EIGEN_STATIC_ASSERT(bool(internal::is_lvalue<Derived>::value), THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);\n      EIGEN_STATIC_ASSERT(bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);\n      Base::construct(expr.const_cast_derived());\n    }\n};\n\n// this is the const ref version\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nclass Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType>\n  : public internal::SparseRefBase<Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n{\n    typedef SparseVector<MatScalar,MatOptions,MatIndex> TPlainObjectType;\n    typedef internal::traits<Ref> Traits;\n  public:\n\n    typedef internal::SparseRefBase<Ref> Base;\n    EIGEN_SPARSE_PUBLIC_INTERFACE(Ref)\n\n    template<typename Derived>\n    inline Ref(const SparseMatrixBase<Derived>& expr) : m_hasCopy(false)\n    {\n      construct(expr.derived(), typename Traits::template match<Derived>::type());\n    }\n\n    inline Ref(const Ref& other) : Base(other), m_hasCopy(false) {\n      // copy constructor shall not copy the m_object, to avoid unnecessary malloc and copy\n    }\n\n    template<typename OtherRef>\n    inline Ref(const RefBase<OtherRef>& other) : m_hasCopy(false) {\n      construct(other.derived(), typename Traits::template match<OtherRef>::type());\n    }\n\n    ~Ref() {\n      if(m_hasCopy) {\n        TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);\n        obj->~TPlainObjectType();\n      }\n    }\n\n  protected:\n\n    template<typename Expression>\n    void construct(const Expression& expr,internal::true_type)\n    {\n      Base::construct(expr);\n    }\n\n    template<typename Expression>\n    void construct(const Expression& expr, internal::false_type)\n    {\n      TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);\n      ::new (obj) TPlainObjectType(expr);\n      m_hasCopy = true;\n      Base::construct(*obj);\n    }\n\n  protected:\n    char m_object_bytes[sizeof(TPlainObjectType)];\n    bool m_hasCopy;\n};\n\nnamespace internal {\n\n// FIXME shall we introduce a general evaluatior_ref that we can specialize for any sparse object once, and thus remove this copy-pasta thing...\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nstruct evaluator<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n  : evaluator<SparseCompressedBase<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >\n{\n  typedef evaluator<SparseCompressedBase<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;\n  typedef Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> XprType;  \n  evaluator() : Base() {}\n  explicit evaluator(const XprType &mat) : Base(mat) {}\n};\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nstruct evaluator<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n  : evaluator<SparseCompressedBase<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >\n{\n  typedef evaluator<SparseCompressedBase<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;\n  typedef Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> XprType;  \n  evaluator() : Base() {}\n  explicit evaluator(const XprType &mat) : Base(mat) {}\n};\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nstruct evaluator<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n  : evaluator<SparseCompressedBase<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >\n{\n  typedef evaluator<SparseCompressedBase<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;\n  typedef Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> XprType;\n  evaluator() : Base() {}\n  explicit evaluator(const XprType &mat) : Base(mat) {}\n};\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\nstruct evaluator<Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n  : evaluator<SparseCompressedBase<Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >\n{\n  typedef evaluator<SparseCompressedBase<Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;\n  typedef Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> XprType;\n  evaluator() : Base() {}\n  explicit evaluator(const XprType &mat) : Base(mat) {}\n};\n\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_REF_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseSelfAdjointView.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_SELFADJOINTVIEW_H\n#define EIGEN_SPARSE_SELFADJOINTVIEW_H\n\nnamespace Eigen { \n  \n/** \\ingroup SparseCore_Module\n  * \\class SparseSelfAdjointView\n  *\n  * \\brief Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.\n  *\n  * \\param MatrixType the type of the dense matrix storing the coefficients\n  * \\param Mode can be either \\c #Lower or \\c #Upper\n  *\n  * This class is an expression of a sefladjoint matrix from a triangular part of a matrix\n  * with given dense storage of the coefficients. It is the return type of MatrixBase::selfadjointView()\n  * and most of the time this is the only way that it is used.\n  *\n  * \\sa SparseMatrixBase::selfadjointView()\n  */\nnamespace internal {\n  \ntemplate<typename MatrixType, unsigned int Mode>\nstruct traits<SparseSelfAdjointView<MatrixType,Mode> > : traits<MatrixType> {\n};\n\ntemplate<int SrcMode,int DstMode,typename MatrixType,int DestOrder>\nvoid permute_symm_to_symm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::StorageIndex>& _dest, const typename MatrixType::StorageIndex* perm = 0);\n\ntemplate<int Mode,typename MatrixType,int DestOrder>\nvoid permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::StorageIndex>& _dest, const typename MatrixType::StorageIndex* perm = 0);\n\n}\n\ntemplate<typename MatrixType, unsigned int _Mode> class SparseSelfAdjointView\n  : public EigenBase<SparseSelfAdjointView<MatrixType,_Mode> >\n{\n  public:\n    \n    enum {\n      Mode = _Mode,\n      TransposeMode = ((Mode & Upper) ? Lower : 0) | ((Mode & Lower) ? Upper : 0),\n      RowsAtCompileTime = internal::traits<SparseSelfAdjointView>::RowsAtCompileTime,\n      ColsAtCompileTime = internal::traits<SparseSelfAdjointView>::ColsAtCompileTime\n    };\n\n    typedef EigenBase<SparseSelfAdjointView> Base;\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef Matrix<StorageIndex,Dynamic,1> VectorI;\n    typedef typename internal::ref_selector<MatrixType>::non_const_type MatrixTypeNested;\n    typedef typename internal::remove_all<MatrixTypeNested>::type _MatrixTypeNested;\n    \n    explicit inline SparseSelfAdjointView(MatrixType& matrix) : m_matrix(matrix)\n    {\n      eigen_assert(rows()==cols() && \"SelfAdjointView is only for squared matrices\");\n    }\n\n    inline Index rows() const { return m_matrix.rows(); }\n    inline Index cols() const { return m_matrix.cols(); }\n\n    /** \\internal \\returns a reference to the nested matrix */\n    const _MatrixTypeNested& matrix() const { return m_matrix; }\n    typename internal::remove_reference<MatrixTypeNested>::type& matrix() { return m_matrix; }\n\n    /** \\returns an expression of the matrix product between a sparse self-adjoint matrix \\c *this and a sparse matrix \\a rhs.\n      *\n      * Note that there is no algorithmic advantage of performing such a product compared to a general sparse-sparse matrix product.\n      * Indeed, the SparseSelfadjointView operand is first copied into a temporary SparseMatrix before computing the product.\n      */\n    template<typename OtherDerived>\n    Product<SparseSelfAdjointView, OtherDerived>\n    operator*(const SparseMatrixBase<OtherDerived>& rhs) const\n    {\n      return Product<SparseSelfAdjointView, OtherDerived>(*this, rhs.derived());\n    }\n\n    /** \\returns an expression of the matrix product between a sparse matrix \\a lhs and a sparse self-adjoint matrix \\a rhs.\n      *\n      * Note that there is no algorithmic advantage of performing such a product compared to a general sparse-sparse matrix product.\n      * Indeed, the SparseSelfadjointView operand is first copied into a temporary SparseMatrix before computing the product.\n      */\n    template<typename OtherDerived> friend\n    Product<OtherDerived, SparseSelfAdjointView>\n    operator*(const SparseMatrixBase<OtherDerived>& lhs, const SparseSelfAdjointView& rhs)\n    {\n      return Product<OtherDerived, SparseSelfAdjointView>(lhs.derived(), rhs);\n    }\n    \n    /** Efficient sparse self-adjoint matrix times dense vector/matrix product */\n    template<typename OtherDerived>\n    Product<SparseSelfAdjointView,OtherDerived>\n    operator*(const MatrixBase<OtherDerived>& rhs) const\n    {\n      return Product<SparseSelfAdjointView,OtherDerived>(*this, rhs.derived());\n    }\n\n    /** Efficient dense vector/matrix times sparse self-adjoint matrix product */\n    template<typename OtherDerived> friend\n    Product<OtherDerived,SparseSelfAdjointView>\n    operator*(const MatrixBase<OtherDerived>& lhs, const SparseSelfAdjointView& rhs)\n    {\n      return Product<OtherDerived,SparseSelfAdjointView>(lhs.derived(), rhs);\n    }\n\n    /** Perform a symmetric rank K update of the selfadjoint matrix \\c *this:\n      * \\f$ this = this + \\alpha ( u u^* ) \\f$ where \\a u is a vector or matrix.\n      *\n      * \\returns a reference to \\c *this\n      *\n      * To perform \\f$ this = this + \\alpha ( u^* u ) \\f$ you can simply\n      * call this function with u.adjoint().\n      */\n    template<typename DerivedU>\n    SparseSelfAdjointView& rankUpdate(const SparseMatrixBase<DerivedU>& u, const Scalar& alpha = Scalar(1));\n    \n    /** \\returns an expression of P H P^-1 */\n    // TODO implement twists in a more evaluator friendly fashion\n    SparseSymmetricPermutationProduct<_MatrixTypeNested,Mode> twistedBy(const PermutationMatrix<Dynamic,Dynamic,StorageIndex>& perm) const\n    {\n      return SparseSymmetricPermutationProduct<_MatrixTypeNested,Mode>(m_matrix, perm);\n    }\n\n    template<typename SrcMatrixType,int SrcMode>\n    SparseSelfAdjointView& operator=(const SparseSymmetricPermutationProduct<SrcMatrixType,SrcMode>& permutedMatrix)\n    {\n      internal::call_assignment_no_alias_no_transpose(*this, permutedMatrix);\n      return *this;\n    }\n\n    SparseSelfAdjointView& operator=(const SparseSelfAdjointView& src)\n    {\n      PermutationMatrix<Dynamic,Dynamic,StorageIndex> pnull;\n      return *this = src.twistedBy(pnull);\n    }\n\n    template<typename SrcMatrixType,unsigned int SrcMode>\n    SparseSelfAdjointView& operator=(const SparseSelfAdjointView<SrcMatrixType,SrcMode>& src)\n    {\n      PermutationMatrix<Dynamic,Dynamic,StorageIndex> pnull;\n      return *this = src.twistedBy(pnull);\n    }\n    \n    void resize(Index rows, Index cols)\n    {\n      EIGEN_ONLY_USED_FOR_DEBUG(rows);\n      EIGEN_ONLY_USED_FOR_DEBUG(cols);\n      eigen_assert(rows == this->rows() && cols == this->cols()\n                && \"SparseSelfadjointView::resize() does not actually allow to resize.\");\n    }\n    \n  protected:\n\n    MatrixTypeNested m_matrix;\n    //mutable VectorI m_countPerRow;\n    //mutable VectorI m_countPerCol;\n  private:\n    template<typename Dest> void evalTo(Dest &) const;\n};\n\n/***************************************************************************\n* Implementation of SparseMatrixBase methods\n***************************************************************************/\n\ntemplate<typename Derived>\ntemplate<unsigned int UpLo>\ntypename SparseMatrixBase<Derived>::template ConstSelfAdjointViewReturnType<UpLo>::Type SparseMatrixBase<Derived>::selfadjointView() const\n{\n  return SparseSelfAdjointView<const Derived, UpLo>(derived());\n}\n\ntemplate<typename Derived>\ntemplate<unsigned int UpLo>\ntypename SparseMatrixBase<Derived>::template SelfAdjointViewReturnType<UpLo>::Type SparseMatrixBase<Derived>::selfadjointView()\n{\n  return SparseSelfAdjointView<Derived, UpLo>(derived());\n}\n\n/***************************************************************************\n* Implementation of SparseSelfAdjointView methods\n***************************************************************************/\n\ntemplate<typename MatrixType, unsigned int Mode>\ntemplate<typename DerivedU>\nSparseSelfAdjointView<MatrixType,Mode>&\nSparseSelfAdjointView<MatrixType,Mode>::rankUpdate(const SparseMatrixBase<DerivedU>& u, const Scalar& alpha)\n{\n  SparseMatrix<Scalar,(MatrixType::Flags&RowMajorBit)?RowMajor:ColMajor> tmp = u * u.adjoint();\n  if(alpha==Scalar(0))\n    m_matrix = tmp.template triangularView<Mode>();\n  else\n    m_matrix += alpha * tmp.template triangularView<Mode>();\n\n  return *this;\n}\n\nnamespace internal {\n  \n// TODO currently a selfadjoint expression has the form SelfAdjointView<.,.>\n//      in the future selfadjoint-ness should be defined by the expression traits\n//      such that Transpose<SelfAdjointView<.,.> > is valid. (currently TriangularBase::transpose() is overloaded to make it work)\ntemplate<typename MatrixType, unsigned int Mode>\nstruct evaluator_traits<SparseSelfAdjointView<MatrixType,Mode> >\n{\n  typedef typename storage_kind_to_evaluator_kind<typename MatrixType::StorageKind>::Kind Kind;\n  typedef SparseSelfAdjointShape Shape;\n};\n\nstruct SparseSelfAdjoint2Sparse {};\n\ntemplate<> struct AssignmentKind<SparseShape,SparseSelfAdjointShape> { typedef SparseSelfAdjoint2Sparse Kind; };\ntemplate<> struct AssignmentKind<SparseSelfAdjointShape,SparseShape> { typedef Sparse2Sparse Kind; };\n\ntemplate< typename DstXprType, typename SrcXprType, typename Functor>\nstruct Assignment<DstXprType, SrcXprType, Functor, SparseSelfAdjoint2Sparse>\n{\n  typedef typename DstXprType::StorageIndex StorageIndex;\n  typedef internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> AssignOpType;\n\n  template<typename DestScalar,int StorageOrder>\n  static void run(SparseMatrix<DestScalar,StorageOrder,StorageIndex> &dst, const SrcXprType &src, const AssignOpType&/*func*/)\n  {\n    internal::permute_symm_to_fullsymm<SrcXprType::Mode>(src.matrix(), dst);\n  }\n\n  // FIXME: the handling of += and -= in sparse matrices should be cleanup so that next two overloads could be reduced to:\n  template<typename DestScalar,int StorageOrder,typename AssignFunc>\n  static void run(SparseMatrix<DestScalar,StorageOrder,StorageIndex> &dst, const SrcXprType &src, const AssignFunc& func)\n  {\n    SparseMatrix<DestScalar,StorageOrder,StorageIndex> tmp(src.rows(),src.cols());\n    run(tmp, src, AssignOpType());\n    call_assignment_no_alias_no_transpose(dst, tmp, func);\n  }\n\n  template<typename DestScalar,int StorageOrder>\n  static void run(SparseMatrix<DestScalar,StorageOrder,StorageIndex> &dst, const SrcXprType &src,\n                  const internal::add_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar>& /* func */)\n  {\n    SparseMatrix<DestScalar,StorageOrder,StorageIndex> tmp(src.rows(),src.cols());\n    run(tmp, src, AssignOpType());\n    dst += tmp;\n  }\n\n  template<typename DestScalar,int StorageOrder>\n  static void run(SparseMatrix<DestScalar,StorageOrder,StorageIndex> &dst, const SrcXprType &src,\n                  const internal::sub_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar>& /* func */)\n  {\n    SparseMatrix<DestScalar,StorageOrder,StorageIndex> tmp(src.rows(),src.cols());\n    run(tmp, src, AssignOpType());\n    dst -= tmp;\n  }\n  \n  template<typename DestScalar>\n  static void run(DynamicSparseMatrix<DestScalar,ColMajor,StorageIndex>& dst, const SrcXprType &src, const AssignOpType&/*func*/)\n  {\n    // TODO directly evaluate into dst;\n    SparseMatrix<DestScalar,ColMajor,StorageIndex> tmp(dst.rows(),dst.cols());\n    internal::permute_symm_to_fullsymm<SrcXprType::Mode>(src.matrix(), tmp);\n    dst = tmp;\n  }\n};\n\n} // end namespace internal\n\n/***************************************************************************\n* Implementation of sparse self-adjoint time dense matrix\n***************************************************************************/\n\nnamespace internal {\n\ntemplate<int Mode, typename SparseLhsType, typename DenseRhsType, typename DenseResType, typename AlphaType>\ninline void sparse_selfadjoint_time_dense_product(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const AlphaType& alpha)\n{\n  EIGEN_ONLY_USED_FOR_DEBUG(alpha);\n  \n  typedef typename internal::nested_eval<SparseLhsType,DenseRhsType::MaxColsAtCompileTime>::type SparseLhsTypeNested;\n  typedef typename internal::remove_all<SparseLhsTypeNested>::type SparseLhsTypeNestedCleaned;\n  typedef evaluator<SparseLhsTypeNestedCleaned> LhsEval;\n  typedef typename LhsEval::InnerIterator LhsIterator;\n  typedef typename SparseLhsType::Scalar LhsScalar;\n  \n  enum {\n    LhsIsRowMajor = (LhsEval::Flags&RowMajorBit)==RowMajorBit,\n    ProcessFirstHalf =\n              ((Mode&(Upper|Lower))==(Upper|Lower))\n          || ( (Mode&Upper) && !LhsIsRowMajor)\n          || ( (Mode&Lower) && LhsIsRowMajor),\n    ProcessSecondHalf = !ProcessFirstHalf\n  };\n  \n  SparseLhsTypeNested lhs_nested(lhs);\n  LhsEval lhsEval(lhs_nested);\n\n  // work on one column at once\n  for (Index k=0; k<rhs.cols(); ++k)\n  {\n    for (Index j=0; j<lhs.outerSize(); ++j)\n    {\n      LhsIterator i(lhsEval,j);\n      // handle diagonal coeff\n      if (ProcessSecondHalf)\n      {\n        while (i && i.index()<j) ++i;\n        if(i && i.index()==j)\n        {\n          res(j,k) += alpha * i.value() * rhs(j,k);\n          ++i;\n        }\n      }\n\n      // premultiplied rhs for scatters\n      typename ScalarBinaryOpTraits<AlphaType, typename DenseRhsType::Scalar>::ReturnType rhs_j(alpha*rhs(j,k));\n      // accumulator for partial scalar product\n      typename DenseResType::Scalar res_j(0);\n      for(; (ProcessFirstHalf ? i && i.index() < j : i) ; ++i)\n      {\n        LhsScalar lhs_ij = i.value();\n        if(!LhsIsRowMajor) lhs_ij = numext::conj(lhs_ij);\n        res_j += lhs_ij * rhs(i.index(),k);\n        res(i.index(),k) += numext::conj(lhs_ij) * rhs_j;\n      }\n      res(j,k) += alpha * res_j;\n\n      // handle diagonal coeff\n      if (ProcessFirstHalf && i && (i.index()==j))\n        res(j,k) += alpha * i.value() * rhs(j,k);\n    }\n  }\n}\n\n\ntemplate<typename LhsView, typename Rhs, int ProductType>\nstruct generic_product_impl<LhsView, Rhs, SparseSelfAdjointShape, DenseShape, ProductType>\n: generic_product_impl_base<LhsView, Rhs, generic_product_impl<LhsView, Rhs, SparseSelfAdjointShape, DenseShape, ProductType> >\n{\n  template<typename Dest>\n  static void scaleAndAddTo(Dest& dst, const LhsView& lhsView, const Rhs& rhs, const typename Dest::Scalar& alpha)\n  {\n    typedef typename LhsView::_MatrixTypeNested Lhs;\n    typedef typename nested_eval<Lhs,Dynamic>::type LhsNested;\n    typedef typename nested_eval<Rhs,Dynamic>::type RhsNested;\n    LhsNested lhsNested(lhsView.matrix());\n    RhsNested rhsNested(rhs);\n    \n    internal::sparse_selfadjoint_time_dense_product<LhsView::Mode>(lhsNested, rhsNested, dst, alpha);\n  }\n};\n\ntemplate<typename Lhs, typename RhsView, int ProductType>\nstruct generic_product_impl<Lhs, RhsView, DenseShape, SparseSelfAdjointShape, ProductType>\n: generic_product_impl_base<Lhs, RhsView, generic_product_impl<Lhs, RhsView, DenseShape, SparseSelfAdjointShape, ProductType> >\n{\n  template<typename Dest>\n  static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const RhsView& rhsView, const typename Dest::Scalar& alpha)\n  {\n    typedef typename RhsView::_MatrixTypeNested Rhs;\n    typedef typename nested_eval<Lhs,Dynamic>::type LhsNested;\n    typedef typename nested_eval<Rhs,Dynamic>::type RhsNested;\n    LhsNested lhsNested(lhs);\n    RhsNested rhsNested(rhsView.matrix());\n    \n    // transpose everything\n    Transpose<Dest> dstT(dst);\n    internal::sparse_selfadjoint_time_dense_product<RhsView::TransposeMode>(rhsNested.transpose(), lhsNested.transpose(), dstT, alpha);\n  }\n};\n\n// NOTE: these two overloads are needed to evaluate the sparse selfadjoint view into a full sparse matrix\n// TODO: maybe the copy could be handled by generic_product_impl so that these overloads would not be needed anymore\n\ntemplate<typename LhsView, typename Rhs, int ProductTag>\nstruct product_evaluator<Product<LhsView, Rhs, DefaultProduct>, ProductTag, SparseSelfAdjointShape, SparseShape>\n  : public evaluator<typename Product<typename Rhs::PlainObject, Rhs, DefaultProduct>::PlainObject>\n{\n  typedef Product<LhsView, Rhs, DefaultProduct> XprType;\n  typedef typename XprType::PlainObject PlainObject;\n  typedef evaluator<PlainObject> Base;\n\n  product_evaluator(const XprType& xpr)\n    : m_lhs(xpr.lhs()), m_result(xpr.rows(), xpr.cols())\n  {\n    ::new (static_cast<Base*>(this)) Base(m_result);\n    generic_product_impl<typename Rhs::PlainObject, Rhs, SparseShape, SparseShape, ProductTag>::evalTo(m_result, m_lhs, xpr.rhs());\n  }\n  \nprotected:\n  typename Rhs::PlainObject m_lhs;\n  PlainObject m_result;\n};\n\ntemplate<typename Lhs, typename RhsView, int ProductTag>\nstruct product_evaluator<Product<Lhs, RhsView, DefaultProduct>, ProductTag, SparseShape, SparseSelfAdjointShape>\n  : public evaluator<typename Product<Lhs, typename Lhs::PlainObject, DefaultProduct>::PlainObject>\n{\n  typedef Product<Lhs, RhsView, DefaultProduct> XprType;\n  typedef typename XprType::PlainObject PlainObject;\n  typedef evaluator<PlainObject> Base;\n\n  product_evaluator(const XprType& xpr)\n    : m_rhs(xpr.rhs()), m_result(xpr.rows(), xpr.cols())\n  {\n    ::new (static_cast<Base*>(this)) Base(m_result);\n    generic_product_impl<Lhs, typename Lhs::PlainObject, SparseShape, SparseShape, ProductTag>::evalTo(m_result, xpr.lhs(), m_rhs);\n  }\n  \nprotected:\n  typename Lhs::PlainObject m_rhs;\n  PlainObject m_result;\n};\n\n} // namespace internal\n\n/***************************************************************************\n* Implementation of symmetric copies and permutations\n***************************************************************************/\nnamespace internal {\n\ntemplate<int Mode,typename MatrixType,int DestOrder>\nvoid permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::StorageIndex>& _dest, const typename MatrixType::StorageIndex* perm)\n{\n  typedef typename MatrixType::StorageIndex StorageIndex;\n  typedef typename MatrixType::Scalar Scalar;\n  typedef SparseMatrix<Scalar,DestOrder,StorageIndex> Dest;\n  typedef Matrix<StorageIndex,Dynamic,1> VectorI;\n  typedef evaluator<MatrixType> MatEval;\n  typedef typename evaluator<MatrixType>::InnerIterator MatIterator;\n  \n  MatEval matEval(mat);\n  Dest& dest(_dest.derived());\n  enum {\n    StorageOrderMatch = int(Dest::IsRowMajor) == int(MatrixType::IsRowMajor)\n  };\n  \n  Index size = mat.rows();\n  VectorI count;\n  count.resize(size);\n  count.setZero();\n  dest.resize(size,size);\n  for(Index j = 0; j<size; ++j)\n  {\n    Index jp = perm ? perm[j] : j;\n    for(MatIterator it(matEval,j); it; ++it)\n    {\n      Index i = it.index();\n      Index r = it.row();\n      Index c = it.col();\n      Index ip = perm ? perm[i] : i;\n      if(Mode==(Upper|Lower))\n        count[StorageOrderMatch ? jp : ip]++;\n      else if(r==c)\n        count[ip]++;\n      else if(( Mode==Lower && r>c) || ( Mode==Upper && r<c))\n      {\n        count[ip]++;\n        count[jp]++;\n      }\n    }\n  }\n  Index nnz = count.sum();\n  \n  // reserve space\n  dest.resizeNonZeros(nnz);\n  dest.outerIndexPtr()[0] = 0;\n  for(Index j=0; j<size; ++j)\n    dest.outerIndexPtr()[j+1] = dest.outerIndexPtr()[j] + count[j];\n  for(Index j=0; j<size; ++j)\n    count[j] = dest.outerIndexPtr()[j];\n  \n  // copy data\n  for(StorageIndex j = 0; j<size; ++j)\n  {\n    for(MatIterator it(matEval,j); it; ++it)\n    {\n      StorageIndex i = internal::convert_index<StorageIndex>(it.index());\n      Index r = it.row();\n      Index c = it.col();\n      \n      StorageIndex jp = perm ? perm[j] : j;\n      StorageIndex ip = perm ? perm[i] : i;\n      \n      if(Mode==(Upper|Lower))\n      {\n        Index k = count[StorageOrderMatch ? jp : ip]++;\n        dest.innerIndexPtr()[k] = StorageOrderMatch ? ip : jp;\n        dest.valuePtr()[k] = it.value();\n      }\n      else if(r==c)\n      {\n        Index k = count[ip]++;\n        dest.innerIndexPtr()[k] = ip;\n        dest.valuePtr()[k] = it.value();\n      }\n      else if(( (Mode&Lower)==Lower && r>c) || ( (Mode&Upper)==Upper && r<c))\n      {\n        if(!StorageOrderMatch)\n          std::swap(ip,jp);\n        Index k = count[jp]++;\n        dest.innerIndexPtr()[k] = ip;\n        dest.valuePtr()[k] = it.value();\n        k = count[ip]++;\n        dest.innerIndexPtr()[k] = jp;\n        dest.valuePtr()[k] = numext::conj(it.value());\n      }\n    }\n  }\n}\n\ntemplate<int _SrcMode,int _DstMode,typename MatrixType,int DstOrder>\nvoid permute_symm_to_symm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DstOrder,typename MatrixType::StorageIndex>& _dest, const typename MatrixType::StorageIndex* perm)\n{\n  typedef typename MatrixType::StorageIndex StorageIndex;\n  typedef typename MatrixType::Scalar Scalar;\n  SparseMatrix<Scalar,DstOrder,StorageIndex>& dest(_dest.derived());\n  typedef Matrix<StorageIndex,Dynamic,1> VectorI;\n  typedef evaluator<MatrixType> MatEval;\n  typedef typename evaluator<MatrixType>::InnerIterator MatIterator;\n\n  enum {\n    SrcOrder = MatrixType::IsRowMajor ? RowMajor : ColMajor,\n    StorageOrderMatch = int(SrcOrder) == int(DstOrder),\n    DstMode = DstOrder==RowMajor ? (_DstMode==Upper ? Lower : Upper) : _DstMode,\n    SrcMode = SrcOrder==RowMajor ? (_SrcMode==Upper ? Lower : Upper) : _SrcMode\n  };\n\n  MatEval matEval(mat);\n  \n  Index size = mat.rows();\n  VectorI count(size);\n  count.setZero();\n  dest.resize(size,size);\n  for(StorageIndex j = 0; j<size; ++j)\n  {\n    StorageIndex jp = perm ? perm[j] : j;\n    for(MatIterator it(matEval,j); it; ++it)\n    {\n      StorageIndex i = it.index();\n      if((int(SrcMode)==int(Lower) && i<j) || (int(SrcMode)==int(Upper) && i>j))\n        continue;\n                  \n      StorageIndex ip = perm ? perm[i] : i;\n      count[int(DstMode)==int(Lower) ? (std::min)(ip,jp) : (std::max)(ip,jp)]++;\n    }\n  }\n  dest.outerIndexPtr()[0] = 0;\n  for(Index j=0; j<size; ++j)\n    dest.outerIndexPtr()[j+1] = dest.outerIndexPtr()[j] + count[j];\n  dest.resizeNonZeros(dest.outerIndexPtr()[size]);\n  for(Index j=0; j<size; ++j)\n    count[j] = dest.outerIndexPtr()[j];\n  \n  for(StorageIndex j = 0; j<size; ++j)\n  {\n    \n    for(MatIterator it(matEval,j); it; ++it)\n    {\n      StorageIndex i = it.index();\n      if((int(SrcMode)==int(Lower) && i<j) || (int(SrcMode)==int(Upper) && i>j))\n        continue;\n                  \n      StorageIndex jp = perm ? perm[j] : j;\n      StorageIndex ip = perm? perm[i] : i;\n      \n      Index k = count[int(DstMode)==int(Lower) ? (std::min)(ip,jp) : (std::max)(ip,jp)]++;\n      dest.innerIndexPtr()[k] = int(DstMode)==int(Lower) ? (std::max)(ip,jp) : (std::min)(ip,jp);\n      \n      if(!StorageOrderMatch) std::swap(ip,jp);\n      if( ((int(DstMode)==int(Lower) && ip<jp) || (int(DstMode)==int(Upper) && ip>jp)))\n        dest.valuePtr()[k] = numext::conj(it.value());\n      else\n        dest.valuePtr()[k] = it.value();\n    }\n  }\n}\n\n}\n\n// TODO implement twists in a more evaluator friendly fashion\n\nnamespace internal {\n\ntemplate<typename MatrixType, int Mode>\nstruct traits<SparseSymmetricPermutationProduct<MatrixType,Mode> > : traits<MatrixType> {\n};\n\n}\n\ntemplate<typename MatrixType,int Mode>\nclass SparseSymmetricPermutationProduct\n  : public EigenBase<SparseSymmetricPermutationProduct<MatrixType,Mode> >\n{\n  public:\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    enum {\n      RowsAtCompileTime = internal::traits<SparseSymmetricPermutationProduct>::RowsAtCompileTime,\n      ColsAtCompileTime = internal::traits<SparseSymmetricPermutationProduct>::ColsAtCompileTime\n    };\n  protected:\n    typedef PermutationMatrix<Dynamic,Dynamic,StorageIndex> Perm;\n  public:\n    typedef Matrix<StorageIndex,Dynamic,1> VectorI;\n    typedef typename MatrixType::Nested MatrixTypeNested;\n    typedef typename internal::remove_all<MatrixTypeNested>::type NestedExpression;\n    \n    SparseSymmetricPermutationProduct(const MatrixType& mat, const Perm& perm)\n      : m_matrix(mat), m_perm(perm)\n    {}\n    \n    inline Index rows() const { return m_matrix.rows(); }\n    inline Index cols() const { return m_matrix.cols(); }\n        \n    const NestedExpression& matrix() const { return m_matrix; }\n    const Perm& perm() const { return m_perm; }\n    \n  protected:\n    MatrixTypeNested m_matrix;\n    const Perm& m_perm;\n\n};\n\nnamespace internal {\n  \ntemplate<typename DstXprType, typename MatrixType, int Mode, typename Scalar>\nstruct Assignment<DstXprType, SparseSymmetricPermutationProduct<MatrixType,Mode>, internal::assign_op<Scalar,typename MatrixType::Scalar>, Sparse2Sparse>\n{\n  typedef SparseSymmetricPermutationProduct<MatrixType,Mode> SrcXprType;\n  typedef typename DstXprType::StorageIndex DstIndex;\n  template<int Options>\n  static void run(SparseMatrix<Scalar,Options,DstIndex> &dst, const SrcXprType &src, const internal::assign_op<Scalar,typename MatrixType::Scalar> &)\n  {\n    // internal::permute_symm_to_fullsymm<Mode>(m_matrix,_dest,m_perm.indices().data());\n    SparseMatrix<Scalar,(Options&RowMajor)==RowMajor ? ColMajor : RowMajor, DstIndex> tmp;\n    internal::permute_symm_to_fullsymm<Mode>(src.matrix(),tmp,src.perm().indices().data());\n    dst = tmp;\n  }\n  \n  template<typename DestType,unsigned int DestMode>\n  static void run(SparseSelfAdjointView<DestType,DestMode>& dst, const SrcXprType &src, const internal::assign_op<Scalar,typename MatrixType::Scalar> &)\n  {\n    internal::permute_symm_to_symm<Mode,DestMode>(src.matrix(),dst.matrix(),src.perm().indices().data());\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_SELFADJOINTVIEW_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseSolverBase.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSESOLVERBASE_H\n#define EIGEN_SPARSESOLVERBASE_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n  /** \\internal\n  * Helper functions to solve with a sparse right-hand-side and result.\n  * The rhs is decomposed into small vertical panels which are solved through dense temporaries.\n  */\ntemplate<typename Decomposition, typename Rhs, typename Dest>\ntypename enable_if<Rhs::ColsAtCompileTime!=1 && Dest::ColsAtCompileTime!=1>::type\nsolve_sparse_through_dense_panels(const Decomposition &dec, const Rhs& rhs, Dest &dest)\n{\n  EIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);\n  typedef typename Dest::Scalar DestScalar;\n  // we process the sparse rhs per block of NbColsAtOnce columns temporarily stored into a dense matrix.\n  static const Index NbColsAtOnce = 4;\n  Index rhsCols = rhs.cols();\n  Index size = rhs.rows();\n  // the temporary matrices do not need more columns than NbColsAtOnce:\n  Index tmpCols = (std::min)(rhsCols, NbColsAtOnce); \n  Eigen::Matrix<DestScalar,Dynamic,Dynamic> tmp(size,tmpCols);\n  Eigen::Matrix<DestScalar,Dynamic,Dynamic> tmpX(size,tmpCols);\n  for(Index k=0; k<rhsCols; k+=NbColsAtOnce)\n  {\n    Index actualCols = std::min<Index>(rhsCols-k, NbColsAtOnce);\n    tmp.leftCols(actualCols) = rhs.middleCols(k,actualCols);\n    tmpX.leftCols(actualCols) = dec.solve(tmp.leftCols(actualCols));\n    dest.middleCols(k,actualCols) = tmpX.leftCols(actualCols).sparseView();\n  }\n}\n\n// Overload for vector as rhs\ntemplate<typename Decomposition, typename Rhs, typename Dest>\ntypename enable_if<Rhs::ColsAtCompileTime==1 || Dest::ColsAtCompileTime==1>::type\nsolve_sparse_through_dense_panels(const Decomposition &dec, const Rhs& rhs, Dest &dest)\n{\n  typedef typename Dest::Scalar DestScalar;\n  Index size = rhs.rows();\n  Eigen::Matrix<DestScalar,Dynamic,1> rhs_dense(rhs);\n  Eigen::Matrix<DestScalar,Dynamic,1> dest_dense(size);\n  dest_dense = dec.solve(rhs_dense);\n  dest = dest_dense.sparseView();\n}\n\n} // end namespace internal\n\n/** \\class SparseSolverBase\n  * \\ingroup SparseCore_Module\n  * \\brief A base class for sparse solvers\n  *\n  * \\tparam Derived the actual type of the solver.\n  *\n  */\ntemplate<typename Derived>\nclass SparseSolverBase : internal::noncopyable\n{\n  public:\n\n    /** Default constructor */\n    SparseSolverBase()\n      : m_isInitialized(false)\n    {}\n\n    ~SparseSolverBase()\n    {}\n\n    Derived& derived() { return *static_cast<Derived*>(this); }\n    const Derived& derived() const { return *static_cast<const Derived*>(this); }\n    \n    /** \\returns an expression of the solution x of \\f$ A x = b \\f$ using the current decomposition of A.\n      *\n      * \\sa compute()\n      */\n    template<typename Rhs>\n    inline const Solve<Derived, Rhs>\n    solve(const MatrixBase<Rhs>& b) const\n    {\n      eigen_assert(m_isInitialized && \"Solver is not initialized.\");\n      eigen_assert(derived().rows()==b.rows() && \"solve(): invalid number of rows of the right hand side matrix b\");\n      return Solve<Derived, Rhs>(derived(), b.derived());\n    }\n    \n    /** \\returns an expression of the solution x of \\f$ A x = b \\f$ using the current decomposition of A.\n      *\n      * \\sa compute()\n      */\n    template<typename Rhs>\n    inline const Solve<Derived, Rhs>\n    solve(const SparseMatrixBase<Rhs>& b) const\n    {\n      eigen_assert(m_isInitialized && \"Solver is not initialized.\");\n      eigen_assert(derived().rows()==b.rows() && \"solve(): invalid number of rows of the right hand side matrix b\");\n      return Solve<Derived, Rhs>(derived(), b.derived());\n    }\n    \n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** \\internal default implementation of solving with a sparse rhs */\n    template<typename Rhs,typename Dest>\n    void _solve_impl(const SparseMatrixBase<Rhs> &b, SparseMatrixBase<Dest> &dest) const\n    {\n      internal::solve_sparse_through_dense_panels(derived(), b.derived(), dest.derived());\n    }\n    #endif // EIGEN_PARSED_BY_DOXYGEN\n\n  protected:\n    \n    mutable bool m_isInitialized;\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSESOLVERBASE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseSparseProductWithPruning.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H\n#define EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n\n// perform a pseudo in-place sparse * sparse product assuming all matrices are col major\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstatic void sparse_sparse_product_with_pruning_impl(const Lhs& lhs, const Rhs& rhs, ResultType& res, const typename ResultType::RealScalar& tolerance)\n{\n  // return sparse_sparse_product_with_pruning_impl2(lhs,rhs,res);\n\n  typedef typename remove_all<Lhs>::type::Scalar Scalar;\n  typedef typename remove_all<Lhs>::type::StorageIndex StorageIndex;\n\n  // make sure to call innerSize/outerSize since we fake the storage order.\n  Index rows = lhs.innerSize();\n  Index cols = rhs.outerSize();\n  //Index size = lhs.outerSize();\n  eigen_assert(lhs.outerSize() == rhs.innerSize());\n\n  // allocate a temporary buffer\n  AmbiVector<Scalar,StorageIndex> tempVector(rows);\n\n  // mimics a resizeByInnerOuter:\n  if(ResultType::IsRowMajor)\n    res.resize(cols, rows);\n  else\n    res.resize(rows, cols);\n  \n  evaluator<Lhs> lhsEval(lhs);\n  evaluator<Rhs> rhsEval(rhs);\n  \n  // estimate the number of non zero entries\n  // given a rhs column containing Y non zeros, we assume that the respective Y columns\n  // of the lhs differs in average of one non zeros, thus the number of non zeros for\n  // the product of a rhs column with the lhs is X+Y where X is the average number of non zero\n  // per column of the lhs.\n  // Therefore, we have nnz(lhs*rhs) = nnz(lhs) + nnz(rhs)\n  Index estimated_nnz_prod = lhsEval.nonZerosEstimate() + rhsEval.nonZerosEstimate();\n\n  res.reserve(estimated_nnz_prod);\n  double ratioColRes = double(estimated_nnz_prod)/(double(lhs.rows())*double(rhs.cols()));\n  for (Index j=0; j<cols; ++j)\n  {\n    // FIXME:\n    //double ratioColRes = (double(rhs.innerVector(j).nonZeros()) + double(lhs.nonZeros())/double(lhs.cols()))/double(lhs.rows());\n    // let's do a more accurate determination of the nnz ratio for the current column j of res\n    tempVector.init(ratioColRes);\n    tempVector.setZero();\n    for (typename evaluator<Rhs>::InnerIterator rhsIt(rhsEval, j); rhsIt; ++rhsIt)\n    {\n      // FIXME should be written like this: tmp += rhsIt.value() * lhs.col(rhsIt.index())\n      tempVector.restart();\n      Scalar x = rhsIt.value();\n      for (typename evaluator<Lhs>::InnerIterator lhsIt(lhsEval, rhsIt.index()); lhsIt; ++lhsIt)\n      {\n        tempVector.coeffRef(lhsIt.index()) += lhsIt.value() * x;\n      }\n    }\n    res.startVec(j);\n    for (typename AmbiVector<Scalar,StorageIndex>::Iterator it(tempVector,tolerance); it; ++it)\n      res.insertBackByOuterInner(j,it.index()) = it.value();\n  }\n  res.finalize();\n}\n\ntemplate<typename Lhs, typename Rhs, typename ResultType,\n  int LhsStorageOrder = traits<Lhs>::Flags&RowMajorBit,\n  int RhsStorageOrder = traits<Rhs>::Flags&RowMajorBit,\n  int ResStorageOrder = traits<ResultType>::Flags&RowMajorBit>\nstruct sparse_sparse_product_with_pruning_selector;\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,ColMajor,ColMajor,ColMajor>\n{\n  typedef typename traits<typename remove_all<Lhs>::type>::Scalar Scalar;\n  typedef typename ResultType::RealScalar RealScalar;\n\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance)\n  {\n    typename remove_all<ResultType>::type _res(res.rows(), res.cols());\n    internal::sparse_sparse_product_with_pruning_impl<Lhs,Rhs,ResultType>(lhs, rhs, _res, tolerance);\n    res.swap(_res);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,ColMajor,ColMajor,RowMajor>\n{\n  typedef typename ResultType::RealScalar RealScalar;\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance)\n  {\n    // we need a col-major matrix to hold the result\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> SparseTemporaryType;\n    SparseTemporaryType _res(res.rows(), res.cols());\n    internal::sparse_sparse_product_with_pruning_impl<Lhs,Rhs,SparseTemporaryType>(lhs, rhs, _res, tolerance);\n    res = _res;\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,RowMajor,RowMajor,RowMajor>\n{\n  typedef typename ResultType::RealScalar RealScalar;\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance)\n  {\n    // let's transpose the product to get a column x column product\n    typename remove_all<ResultType>::type _res(res.rows(), res.cols());\n    internal::sparse_sparse_product_with_pruning_impl<Rhs,Lhs,ResultType>(rhs, lhs, _res, tolerance);\n    res.swap(_res);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,RowMajor,RowMajor,ColMajor>\n{\n  typedef typename ResultType::RealScalar RealScalar;\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::StorageIndex> ColMajorMatrixLhs;\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::StorageIndex> ColMajorMatrixRhs;\n    ColMajorMatrixLhs colLhs(lhs);\n    ColMajorMatrixRhs colRhs(rhs);\n    internal::sparse_sparse_product_with_pruning_impl<ColMajorMatrixLhs,ColMajorMatrixRhs,ResultType>(colLhs, colRhs, res, tolerance);\n\n    // let's transpose the product to get a column x column product\n//     typedef SparseMatrix<typename ResultType::Scalar> SparseTemporaryType;\n//     SparseTemporaryType _res(res.cols(), res.rows());\n//     sparse_sparse_product_with_pruning_impl<Rhs,Lhs,SparseTemporaryType>(rhs, lhs, _res);\n//     res = _res.transpose();\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,ColMajor,RowMajor,RowMajor>\n{\n  typedef typename ResultType::RealScalar RealScalar;\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename Lhs::StorageIndex> RowMajorMatrixLhs;\n    RowMajorMatrixLhs rowLhs(lhs);\n    sparse_sparse_product_with_pruning_selector<RowMajorMatrixLhs,Rhs,ResultType,RowMajor,RowMajor>(rowLhs,rhs,res,tolerance);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,RowMajor,ColMajor,RowMajor>\n{\n  typedef typename ResultType::RealScalar RealScalar;\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename Lhs::StorageIndex> RowMajorMatrixRhs;\n    RowMajorMatrixRhs rowRhs(rhs);\n    sparse_sparse_product_with_pruning_selector<Lhs,RowMajorMatrixRhs,ResultType,RowMajor,RowMajor,RowMajor>(lhs,rowRhs,res,tolerance);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,ColMajor,RowMajor,ColMajor>\n{\n  typedef typename ResultType::RealScalar RealScalar;\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::StorageIndex> ColMajorMatrixRhs;\n    ColMajorMatrixRhs colRhs(rhs);\n    internal::sparse_sparse_product_with_pruning_impl<Lhs,ColMajorMatrixRhs,ResultType>(lhs, colRhs, res, tolerance);\n  }\n};\n\ntemplate<typename Lhs, typename Rhs, typename ResultType>\nstruct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,RowMajor,ColMajor,ColMajor>\n{\n  typedef typename ResultType::RealScalar RealScalar;\n  static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance)\n  {\n    typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::StorageIndex> ColMajorMatrixLhs;\n    ColMajorMatrixLhs colLhs(lhs);\n    internal::sparse_sparse_product_with_pruning_impl<ColMajorMatrixLhs,Rhs,ResultType>(colLhs, rhs, res, tolerance);\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSESPARSEPRODUCTWITHPRUNING_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseTranspose.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSETRANSPOSE_H\n#define EIGEN_SPARSETRANSPOSE_H\n\nnamespace Eigen { \n\nnamespace internal {\n  template<typename MatrixType,int CompressedAccess=int(MatrixType::Flags&CompressedAccessBit)>\n  class SparseTransposeImpl\n    : public SparseMatrixBase<Transpose<MatrixType> >\n  {};\n  \n  template<typename MatrixType>\n  class SparseTransposeImpl<MatrixType,CompressedAccessBit>\n    : public SparseCompressedBase<Transpose<MatrixType> >\n  {\n    typedef SparseCompressedBase<Transpose<MatrixType> > Base;\n  public:\n    using Base::derived;\n    typedef typename Base::Scalar Scalar;\n    typedef typename Base::StorageIndex StorageIndex;\n\n    inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); }\n    \n    inline const Scalar* valuePtr() const { return derived().nestedExpression().valuePtr(); }\n    inline const StorageIndex* innerIndexPtr() const { return derived().nestedExpression().innerIndexPtr(); }\n    inline const StorageIndex* outerIndexPtr() const { return derived().nestedExpression().outerIndexPtr(); }\n    inline const StorageIndex* innerNonZeroPtr() const { return derived().nestedExpression().innerNonZeroPtr(); }\n\n    inline Scalar* valuePtr() { return derived().nestedExpression().valuePtr(); }\n    inline StorageIndex* innerIndexPtr() { return derived().nestedExpression().innerIndexPtr(); }\n    inline StorageIndex* outerIndexPtr() { return derived().nestedExpression().outerIndexPtr(); }\n    inline StorageIndex* innerNonZeroPtr() { return derived().nestedExpression().innerNonZeroPtr(); }\n  };\n}\n  \ntemplate<typename MatrixType> class TransposeImpl<MatrixType,Sparse>\n  : public internal::SparseTransposeImpl<MatrixType>\n{\n  protected:\n    typedef internal::SparseTransposeImpl<MatrixType> Base;\n};\n\nnamespace internal {\n  \ntemplate<typename ArgType>\nstruct unary_evaluator<Transpose<ArgType>, IteratorBased>\n  : public evaluator_base<Transpose<ArgType> >\n{\n    typedef typename evaluator<ArgType>::InnerIterator        EvalIterator;\n  public:\n    typedef Transpose<ArgType> XprType;\n    \n    inline Index nonZerosEstimate() const {\n      return m_argImpl.nonZerosEstimate();\n    }\n\n    class InnerIterator : public EvalIterator\n    {\n    public:\n      EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer)\n        : EvalIterator(unaryOp.m_argImpl,outer)\n      {}\n      \n      Index row() const { return EvalIterator::col(); }\n      Index col() const { return EvalIterator::row(); }\n    };\n    \n    enum {\n      CoeffReadCost = evaluator<ArgType>::CoeffReadCost,\n      Flags = XprType::Flags\n    };\n    \n    explicit unary_evaluator(const XprType& op) :m_argImpl(op.nestedExpression()) {}\n\n  protected:\n    evaluator<ArgType> m_argImpl;\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSETRANSPOSE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseTriangularView.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_TRIANGULARVIEW_H\n#define EIGEN_SPARSE_TRIANGULARVIEW_H\n\nnamespace Eigen {\n\n/** \\ingroup SparseCore_Module\n  *\n  * \\brief Base class for a triangular part in a \\b sparse matrix\n  *\n  * This class is an abstract base class of class TriangularView, and objects of type TriangularViewImpl cannot be instantiated.\n  * It extends class TriangularView with additional methods which are available for sparse expressions only.\n  *\n  * \\sa class TriangularView, SparseMatrixBase::triangularView()\n  */\ntemplate<typename MatrixType, unsigned int Mode> class TriangularViewImpl<MatrixType,Mode,Sparse>\n  : public SparseMatrixBase<TriangularView<MatrixType,Mode> >\n{\n    enum { SkipFirst = ((Mode&Lower) && !(MatrixType::Flags&RowMajorBit))\n                    || ((Mode&Upper) &&  (MatrixType::Flags&RowMajorBit)),\n           SkipLast = !SkipFirst,\n           SkipDiag = (Mode&ZeroDiag) ? 1 : 0,\n           HasUnitDiag = (Mode&UnitDiag) ? 1 : 0\n    };\n    \n    typedef TriangularView<MatrixType,Mode> TriangularViewType;\n    \n  protected:\n    // dummy solve function to make TriangularView happy.\n    void solve() const;\n\n    typedef SparseMatrixBase<TriangularViewType> Base;\n  public:\n    \n    EIGEN_SPARSE_PUBLIC_INTERFACE(TriangularViewType)\n    \n    typedef typename MatrixType::Nested MatrixTypeNested;\n    typedef typename internal::remove_reference<MatrixTypeNested>::type MatrixTypeNestedNonRef;\n    typedef typename internal::remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;\n\n    template<typename RhsType, typename DstType>\n    EIGEN_DEVICE_FUNC\n    EIGEN_STRONG_INLINE void _solve_impl(const RhsType &rhs, DstType &dst) const {\n      if(!(internal::is_same<RhsType,DstType>::value && internal::extract_data(dst) == internal::extract_data(rhs)))\n        dst = rhs;\n      this->solveInPlace(dst);\n    }\n\n    /** Applies the inverse of \\c *this to the dense vector or matrix \\a other, \"in-place\" */\n    template<typename OtherDerived> void solveInPlace(MatrixBase<OtherDerived>& other) const;\n\n    /** Applies the inverse of \\c *this to the sparse vector or matrix \\a other, \"in-place\" */\n    template<typename OtherDerived> void solveInPlace(SparseMatrixBase<OtherDerived>& other) const;\n  \n};\n\nnamespace internal {\n\ntemplate<typename ArgType, unsigned int Mode>\nstruct unary_evaluator<TriangularView<ArgType,Mode>, IteratorBased>\n : evaluator_base<TriangularView<ArgType,Mode> >\n{\n  typedef TriangularView<ArgType,Mode> XprType;\n  \nprotected:\n  \n  typedef typename XprType::Scalar Scalar;\n  typedef typename XprType::StorageIndex StorageIndex;\n  typedef typename evaluator<ArgType>::InnerIterator EvalIterator;\n  \n  enum { SkipFirst = ((Mode&Lower) && !(ArgType::Flags&RowMajorBit))\n                    || ((Mode&Upper) &&  (ArgType::Flags&RowMajorBit)),\n         SkipLast = !SkipFirst,\n         SkipDiag = (Mode&ZeroDiag) ? 1 : 0,\n         HasUnitDiag = (Mode&UnitDiag) ? 1 : 0\n  };\n  \npublic:\n  \n  enum {\n    CoeffReadCost = evaluator<ArgType>::CoeffReadCost,\n    Flags = XprType::Flags\n  };\n    \n  explicit unary_evaluator(const XprType &xpr) : m_argImpl(xpr.nestedExpression()), m_arg(xpr.nestedExpression()) {}\n  \n  inline Index nonZerosEstimate() const {\n    return m_argImpl.nonZerosEstimate();\n  }\n  \n  class InnerIterator : public EvalIterator\n  {\n      typedef EvalIterator Base;\n    public:\n\n      EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& xprEval, Index outer)\n        : Base(xprEval.m_argImpl,outer), m_returnOne(false), m_containsDiag(Base::outer()<xprEval.m_arg.innerSize())\n      {\n        if(SkipFirst)\n        {\n          while((*this) && ((HasUnitDiag||SkipDiag)  ? this->index()<=outer : this->index()<outer))\n            Base::operator++();\n          if(HasUnitDiag)\n            m_returnOne = m_containsDiag;\n        }\n        else if(HasUnitDiag && ((!Base::operator bool()) || Base::index()>=Base::outer()))\n        {\n          if((!SkipFirst) && Base::operator bool())\n            Base::operator++();\n          m_returnOne = m_containsDiag;\n        }\n      }\n\n      EIGEN_STRONG_INLINE InnerIterator& operator++()\n      {\n        if(HasUnitDiag && m_returnOne)\n          m_returnOne = false;\n        else\n        {\n          Base::operator++();\n          if(HasUnitDiag && (!SkipFirst) && ((!Base::operator bool()) || Base::index()>=Base::outer()))\n          {\n            if((!SkipFirst) && Base::operator bool())\n              Base::operator++();\n            m_returnOne = m_containsDiag;\n          }\n        }\n        return *this;\n      }\n      \n      EIGEN_STRONG_INLINE operator bool() const\n      {\n        if(HasUnitDiag && m_returnOne)\n          return true;\n        if(SkipFirst) return  Base::operator bool();\n        else\n        {\n          if (SkipDiag) return (Base::operator bool() && this->index() < this->outer());\n          else return (Base::operator bool() && this->index() <= this->outer());\n        }\n      }\n\n//       inline Index row() const { return (ArgType::Flags&RowMajorBit ? Base::outer() : this->index()); }\n//       inline Index col() const { return (ArgType::Flags&RowMajorBit ? this->index() : Base::outer()); }\n      inline StorageIndex index() const\n      {\n        if(HasUnitDiag && m_returnOne)  return internal::convert_index<StorageIndex>(Base::outer());\n        else                            return Base::index();\n      }\n      inline Scalar value() const\n      {\n        if(HasUnitDiag && m_returnOne)  return Scalar(1);\n        else                            return Base::value();\n      }\n\n    protected:\n      bool m_returnOne;\n      bool m_containsDiag;\n    private:\n      Scalar& valueRef();\n  };\n  \nprotected:\n  evaluator<ArgType> m_argImpl;\n  const ArgType& m_arg;\n};\n\n} // end namespace internal\n\ntemplate<typename Derived>\ntemplate<int Mode>\ninline const TriangularView<const Derived, Mode>\nSparseMatrixBase<Derived>::triangularView() const\n{\n  return TriangularView<const Derived, Mode>(derived());\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSE_TRIANGULARVIEW_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseUtil.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSEUTIL_H\n#define EIGEN_SPARSEUTIL_H\n\nnamespace Eigen { \n\n#ifdef NDEBUG\n#define EIGEN_DBG_SPARSE(X)\n#else\n#define EIGEN_DBG_SPARSE(X) X\n#endif\n\n#define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \\\ntemplate<typename OtherDerived> \\\nEIGEN_STRONG_INLINE Derived& operator Op(const Eigen::SparseMatrixBase<OtherDerived>& other) \\\n{ \\\n  return Base::operator Op(other.derived()); \\\n} \\\nEIGEN_STRONG_INLINE Derived& operator Op(const Derived& other) \\\n{ \\\n  return Base::operator Op(other); \\\n}\n\n#define EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \\\ntemplate<typename Other> \\\nEIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \\\n{ \\\n  return Base::operator Op(scalar); \\\n}\n\n#define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATORS(Derived) \\\nEIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, =)\n\n\n#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \\\n  EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)\n\n  \nconst int CoherentAccessPattern     = 0x1;\nconst int InnerRandomAccessPattern  = 0x2 | CoherentAccessPattern;\nconst int OuterRandomAccessPattern  = 0x4 | CoherentAccessPattern;\nconst int RandomAccessPattern       = 0x8 | OuterRandomAccessPattern | InnerRandomAccessPattern;\n\ntemplate<typename _Scalar, int _Flags = 0, typename _StorageIndex = int>  class SparseMatrix;\ntemplate<typename _Scalar, int _Flags = 0, typename _StorageIndex = int>  class DynamicSparseMatrix;\ntemplate<typename _Scalar, int _Flags = 0, typename _StorageIndex = int>  class SparseVector;\ntemplate<typename _Scalar, int _Flags = 0, typename _StorageIndex = int>  class MappedSparseMatrix;\n\ntemplate<typename MatrixType, unsigned int UpLo>  class SparseSelfAdjointView;\ntemplate<typename Lhs, typename Rhs>              class SparseDiagonalProduct;\ntemplate<typename MatrixType> class SparseView;\n\ntemplate<typename Lhs, typename Rhs>        class SparseSparseProduct;\ntemplate<typename Lhs, typename Rhs>        class SparseTimeDenseProduct;\ntemplate<typename Lhs, typename Rhs>        class DenseTimeSparseProduct;\ntemplate<typename Lhs, typename Rhs, bool Transpose> class SparseDenseOuterProduct;\n\ntemplate<typename Lhs, typename Rhs> struct SparseSparseProductReturnType;\ntemplate<typename Lhs, typename Rhs,\n         int InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(internal::traits<Lhs>::ColsAtCompileTime,internal::traits<Rhs>::RowsAtCompileTime)> struct DenseSparseProductReturnType;\n         \ntemplate<typename Lhs, typename Rhs,\n         int InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(internal::traits<Lhs>::ColsAtCompileTime,internal::traits<Rhs>::RowsAtCompileTime)> struct SparseDenseProductReturnType;\ntemplate<typename MatrixType,int UpLo> class SparseSymmetricPermutationProduct;\n\nnamespace internal {\n\ntemplate<typename T,int Rows,int Cols,int Flags> struct sparse_eval;\n\ntemplate<typename T> struct eval<T,Sparse>\n  : sparse_eval<T, traits<T>::RowsAtCompileTime,traits<T>::ColsAtCompileTime,traits<T>::Flags>\n{};\n\ntemplate<typename T,int Cols,int Flags> struct sparse_eval<T,1,Cols,Flags> {\n    typedef typename traits<T>::Scalar _Scalar;\n    typedef typename traits<T>::StorageIndex _StorageIndex;\n  public:\n    typedef SparseVector<_Scalar, RowMajor, _StorageIndex> type;\n};\n\ntemplate<typename T,int Rows,int Flags> struct sparse_eval<T,Rows,1,Flags> {\n    typedef typename traits<T>::Scalar _Scalar;\n    typedef typename traits<T>::StorageIndex _StorageIndex;\n  public:\n    typedef SparseVector<_Scalar, ColMajor, _StorageIndex> type;\n};\n\n// TODO this seems almost identical to plain_matrix_type<T, Sparse>\ntemplate<typename T,int Rows,int Cols,int Flags> struct sparse_eval {\n    typedef typename traits<T>::Scalar _Scalar;\n    typedef typename traits<T>::StorageIndex _StorageIndex;\n    enum { _Options = ((Flags&RowMajorBit)==RowMajorBit) ? RowMajor : ColMajor };\n  public:\n    typedef SparseMatrix<_Scalar, _Options, _StorageIndex> type;\n};\n\ntemplate<typename T,int Flags> struct sparse_eval<T,1,1,Flags> {\n    typedef typename traits<T>::Scalar _Scalar;\n  public:\n    typedef Matrix<_Scalar, 1, 1> type;\n};\n\ntemplate<typename T> struct plain_matrix_type<T,Sparse>\n{\n  typedef typename traits<T>::Scalar _Scalar;\n  typedef typename traits<T>::StorageIndex _StorageIndex;\n  enum { _Options = ((evaluator<T>::Flags&RowMajorBit)==RowMajorBit) ? RowMajor : ColMajor };\n  public:\n    typedef SparseMatrix<_Scalar, _Options, _StorageIndex> type;\n};\n\ntemplate<typename T>\nstruct plain_object_eval<T,Sparse>\n  : sparse_eval<T, traits<T>::RowsAtCompileTime,traits<T>::ColsAtCompileTime, evaluator<T>::Flags>\n{};\n\ntemplate<typename Decomposition, typename RhsType>\nstruct solve_traits<Decomposition,RhsType,Sparse>\n{\n  typedef typename sparse_eval<RhsType, RhsType::RowsAtCompileTime, RhsType::ColsAtCompileTime,traits<RhsType>::Flags>::type PlainObject;\n};\n\ntemplate<typename Derived>\nstruct generic_xpr_base<Derived, MatrixXpr, Sparse>\n{\n  typedef SparseMatrixBase<Derived> type;\n};\n\nstruct SparseTriangularShape  { static std::string debugName() { return \"SparseTriangularShape\"; } };\nstruct SparseSelfAdjointShape { static std::string debugName() { return \"SparseSelfAdjointShape\"; } };\n\ntemplate<> struct glue_shapes<SparseShape,SelfAdjointShape> { typedef SparseSelfAdjointShape type;  };\ntemplate<> struct glue_shapes<SparseShape,TriangularShape > { typedef SparseTriangularShape  type;  };\n\n} // end namespace internal\n\n/** \\ingroup SparseCore_Module\n  *\n  * \\class Triplet\n  *\n  * \\brief A small structure to hold a non zero as a triplet (i,j,value).\n  *\n  * \\sa SparseMatrix::setFromTriplets()\n  */\ntemplate<typename Scalar, typename StorageIndex=typename SparseMatrix<Scalar>::StorageIndex >\nclass Triplet\n{\npublic:\n  Triplet() : m_row(0), m_col(0), m_value(0) {}\n\n  Triplet(const StorageIndex& i, const StorageIndex& j, const Scalar& v = Scalar(0))\n    : m_row(i), m_col(j), m_value(v)\n  {}\n\n  /** \\returns the row index of the element */\n  const StorageIndex& row() const { return m_row; }\n\n  /** \\returns the column index of the element */\n  const StorageIndex& col() const { return m_col; }\n\n  /** \\returns the value of the element */\n  const Scalar& value() const { return m_value; }\nprotected:\n  StorageIndex m_row, m_col;\n  Scalar m_value;\n};\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSEUTIL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseVector.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSEVECTOR_H\n#define EIGEN_SPARSEVECTOR_H\n\nnamespace Eigen { \n\n/** \\ingroup SparseCore_Module\n  * \\class SparseVector\n  *\n  * \\brief a sparse vector class\n  *\n  * \\tparam _Scalar the scalar type, i.e. the type of the coefficients\n  *\n  * See http://www.netlib.org/linalg/html_templates/node91.html for details on the storage scheme.\n  *\n  * This class can be extended with the help of the plugin mechanism described on the page\n  * \\ref TopicCustomizing_Plugins by defining the preprocessor symbol \\c EIGEN_SPARSEVECTOR_PLUGIN.\n  */\n\nnamespace internal {\ntemplate<typename _Scalar, int _Options, typename _StorageIndex>\nstruct traits<SparseVector<_Scalar, _Options, _StorageIndex> >\n{\n  typedef _Scalar Scalar;\n  typedef _StorageIndex StorageIndex;\n  typedef Sparse StorageKind;\n  typedef MatrixXpr XprKind;\n  enum {\n    IsColVector = (_Options & RowMajorBit) ? 0 : 1,\n\n    RowsAtCompileTime = IsColVector ? Dynamic : 1,\n    ColsAtCompileTime = IsColVector ? 1 : Dynamic,\n    MaxRowsAtCompileTime = RowsAtCompileTime,\n    MaxColsAtCompileTime = ColsAtCompileTime,\n    Flags = _Options | NestByRefBit | LvalueBit | (IsColVector ? 0 : RowMajorBit) | CompressedAccessBit,\n    SupportedAccessPatterns = InnerRandomAccessPattern\n  };\n};\n\n// Sparse-Vector-Assignment kinds:\nenum {\n  SVA_RuntimeSwitch,\n  SVA_Inner,\n  SVA_Outer\n};\n\ntemplate< typename Dest, typename Src,\n          int AssignmentKind = !bool(Src::IsVectorAtCompileTime) ? SVA_RuntimeSwitch\n                             : Src::InnerSizeAtCompileTime==1 ? SVA_Outer\n                             : SVA_Inner>\nstruct sparse_vector_assign_selector;\n\n}\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex>\nclass SparseVector\n  : public SparseCompressedBase<SparseVector<_Scalar, _Options, _StorageIndex> >\n{\n    typedef SparseCompressedBase<SparseVector> Base;\n    using Base::convert_index;\n  public:\n    EIGEN_SPARSE_PUBLIC_INTERFACE(SparseVector)\n    EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(SparseVector, +=)\n    EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(SparseVector, -=)\n    \n    typedef internal::CompressedStorage<Scalar,StorageIndex> Storage;\n    enum { IsColVector = internal::traits<SparseVector>::IsColVector };\n    \n    enum {\n      Options = _Options\n    };\n    \n    EIGEN_STRONG_INLINE Index rows() const { return IsColVector ? m_size : 1; }\n    EIGEN_STRONG_INLINE Index cols() const { return IsColVector ? 1 : m_size; }\n    EIGEN_STRONG_INLINE Index innerSize() const { return m_size; }\n    EIGEN_STRONG_INLINE Index outerSize() const { return 1; }\n\n    EIGEN_STRONG_INLINE const Scalar* valuePtr() const { return m_data.valuePtr(); }\n    EIGEN_STRONG_INLINE Scalar* valuePtr() { return m_data.valuePtr(); }\n\n    EIGEN_STRONG_INLINE const StorageIndex* innerIndexPtr() const { return m_data.indexPtr(); }\n    EIGEN_STRONG_INLINE StorageIndex* innerIndexPtr() { return m_data.indexPtr(); }\n\n    inline const StorageIndex* outerIndexPtr() const { return 0; }\n    inline StorageIndex* outerIndexPtr() { return 0; }\n    inline const StorageIndex* innerNonZeroPtr() const { return 0; }\n    inline StorageIndex* innerNonZeroPtr() { return 0; }\n    \n    /** \\internal */\n    inline Storage& data() { return m_data; }\n    /** \\internal */\n    inline const Storage& data() const { return m_data; }\n\n    inline Scalar coeff(Index row, Index col) const\n    {\n      eigen_assert(IsColVector ? (col==0 && row>=0 && row<m_size) : (row==0 && col>=0 && col<m_size));\n      return coeff(IsColVector ? row : col);\n    }\n    inline Scalar coeff(Index i) const\n    {\n      eigen_assert(i>=0 && i<m_size);\n      return m_data.at(StorageIndex(i));\n    }\n\n    inline Scalar& coeffRef(Index row, Index col)\n    {\n      eigen_assert(IsColVector ? (col==0 && row>=0 && row<m_size) : (row==0 && col>=0 && col<m_size));\n      return coeffRef(IsColVector ? row : col);\n    }\n\n    /** \\returns a reference to the coefficient value at given index \\a i\n      * This operation involes a log(rho*size) binary search. If the coefficient does not\n      * exist yet, then a sorted insertion into a sequential buffer is performed.\n      *\n      * This insertion might be very costly if the number of nonzeros above \\a i is large.\n      */\n    inline Scalar& coeffRef(Index i)\n    {\n      eigen_assert(i>=0 && i<m_size);\n\n      return m_data.atWithInsertion(StorageIndex(i));\n    }\n\n  public:\n\n    typedef typename Base::InnerIterator InnerIterator;\n    typedef typename Base::ReverseInnerIterator ReverseInnerIterator;\n\n    inline void setZero() { m_data.clear(); }\n\n    /** \\returns the number of non zero coefficients */\n    inline Index nonZeros() const  { return m_data.size(); }\n\n    inline void startVec(Index outer)\n    {\n      EIGEN_UNUSED_VARIABLE(outer);\n      eigen_assert(outer==0);\n    }\n\n    inline Scalar& insertBackByOuterInner(Index outer, Index inner)\n    {\n      EIGEN_UNUSED_VARIABLE(outer);\n      eigen_assert(outer==0);\n      return insertBack(inner);\n    }\n    inline Scalar& insertBack(Index i)\n    {\n      m_data.append(0, i);\n      return m_data.value(m_data.size()-1);\n    }\n    \n    Scalar& insertBackByOuterInnerUnordered(Index outer, Index inner)\n    {\n      EIGEN_UNUSED_VARIABLE(outer);\n      eigen_assert(outer==0);\n      return insertBackUnordered(inner);\n    }\n    inline Scalar& insertBackUnordered(Index i)\n    {\n      m_data.append(0, i);\n      return m_data.value(m_data.size()-1);\n    }\n\n    inline Scalar& insert(Index row, Index col)\n    {\n      eigen_assert(IsColVector ? (col==0 && row>=0 && row<m_size) : (row==0 && col>=0 && col<m_size));\n      \n      Index inner = IsColVector ? row : col;\n      Index outer = IsColVector ? col : row;\n      EIGEN_ONLY_USED_FOR_DEBUG(outer);\n      eigen_assert(outer==0);\n      return insert(inner);\n    }\n    Scalar& insert(Index i)\n    {\n      eigen_assert(i>=0 && i<m_size);\n      \n      Index startId = 0;\n      Index p = Index(m_data.size()) - 1;\n      // TODO smart realloc\n      m_data.resize(p+2,1);\n\n      while ( (p >= startId) && (m_data.index(p) > i) )\n      {\n        m_data.index(p+1) = m_data.index(p);\n        m_data.value(p+1) = m_data.value(p);\n        --p;\n      }\n      m_data.index(p+1) = convert_index(i);\n      m_data.value(p+1) = 0;\n      return m_data.value(p+1);\n    }\n\n    /**\n      */\n    inline void reserve(Index reserveSize) { m_data.reserve(reserveSize); }\n\n\n    inline void finalize() {}\n\n    /** \\copydoc SparseMatrix::prune(const Scalar&,const RealScalar&) */\n    void prune(const Scalar& reference, const RealScalar& epsilon = NumTraits<RealScalar>::dummy_precision())\n    {\n      m_data.prune(reference,epsilon);\n    }\n\n    /** Resizes the sparse vector to \\a rows x \\a cols\n      *\n      * This method is provided for compatibility with matrices.\n      * For a column vector, \\a cols must be equal to 1.\n      * For a row vector, \\a rows must be equal to 1.\n      *\n      * \\sa resize(Index)\n      */\n    void resize(Index rows, Index cols)\n    {\n      eigen_assert((IsColVector ? cols : rows)==1 && \"Outer dimension must equal 1\");\n      resize(IsColVector ? rows : cols);\n    }\n\n    /** Resizes the sparse vector to \\a newSize\n      * This method deletes all entries, thus leaving an empty sparse vector\n      *\n      * \\sa  conservativeResize(), setZero() */\n    void resize(Index newSize)\n    {\n      m_size = newSize;\n      m_data.clear();\n    }\n\n    /** Resizes the sparse vector to \\a newSize, while leaving old values untouched.\n      *\n      * If the size of the vector is decreased, then the storage of the out-of bounds coefficients is kept and reserved.\n      * Call .data().squeeze() to free extra memory.\n      *\n      * \\sa reserve(), setZero()\n      */\n    void conservativeResize(Index newSize)\n    {\n      if (newSize < m_size)\n      {\n        Index i = 0;\n        while (i<m_data.size() && m_data.index(i)<newSize) ++i;\n        m_data.resize(i);\n      }\n      m_size = newSize;\n    }\n\n    void resizeNonZeros(Index size) { m_data.resize(size); }\n\n    inline SparseVector() : m_size(0) { check_template_parameters(); resize(0); }\n\n    explicit inline SparseVector(Index size) : m_size(0) { check_template_parameters(); resize(size); }\n\n    inline SparseVector(Index rows, Index cols) : m_size(0) { check_template_parameters(); resize(rows,cols); }\n\n    template<typename OtherDerived>\n    inline SparseVector(const SparseMatrixBase<OtherDerived>& other)\n      : m_size(0)\n    {\n      #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN\n        EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN\n      #endif\n      check_template_parameters();\n      *this = other.derived();\n    }\n\n    inline SparseVector(const SparseVector& other)\n      : Base(other), m_size(0)\n    {\n      check_template_parameters();\n      *this = other.derived();\n    }\n\n    /** Swaps the values of \\c *this and \\a other.\n      * Overloaded for performance: this version performs a \\em shallow swap by swaping pointers and attributes only.\n      * \\sa SparseMatrixBase::swap()\n      */\n    inline void swap(SparseVector& other)\n    {\n      std::swap(m_size, other.m_size);\n      m_data.swap(other.m_data);\n    }\n\n    template<int OtherOptions>\n    inline void swap(SparseMatrix<Scalar,OtherOptions,StorageIndex>& other)\n    {\n      eigen_assert(other.outerSize()==1);\n      std::swap(m_size, other.m_innerSize);\n      m_data.swap(other.m_data);\n    }\n\n    inline SparseVector& operator=(const SparseVector& other)\n    {\n      if (other.isRValue())\n      {\n        swap(other.const_cast_derived());\n      }\n      else\n      {\n        resize(other.size());\n        m_data = other.m_data;\n      }\n      return *this;\n    }\n\n    template<typename OtherDerived>\n    inline SparseVector& operator=(const SparseMatrixBase<OtherDerived>& other)\n    {\n      SparseVector tmp(other.size());\n      internal::sparse_vector_assign_selector<SparseVector,OtherDerived>::run(tmp,other.derived());\n      this->swap(tmp);\n      return *this;\n    }\n\n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    template<typename Lhs, typename Rhs>\n    inline SparseVector& operator=(const SparseSparseProduct<Lhs,Rhs>& product)\n    {\n      return Base::operator=(product);\n    }\n    #endif\n\n    friend std::ostream & operator << (std::ostream & s, const SparseVector& m)\n    {\n      for (Index i=0; i<m.nonZeros(); ++i)\n        s << \"(\" << m.m_data.value(i) << \",\" << m.m_data.index(i) << \") \";\n      s << std::endl;\n      return s;\n    }\n\n    /** Destructor */\n    inline ~SparseVector() {}\n\n    /** Overloaded for performance */\n    Scalar sum() const;\n\n  public:\n\n    /** \\internal \\deprecated use setZero() and reserve() */\n    EIGEN_DEPRECATED void startFill(Index reserve)\n    {\n      setZero();\n      m_data.reserve(reserve);\n    }\n\n    /** \\internal \\deprecated use insertBack(Index,Index) */\n    EIGEN_DEPRECATED Scalar& fill(Index r, Index c)\n    {\n      eigen_assert(r==0 || c==0);\n      return fill(IsColVector ? r : c);\n    }\n\n    /** \\internal \\deprecated use insertBack(Index) */\n    EIGEN_DEPRECATED Scalar& fill(Index i)\n    {\n      m_data.append(0, i);\n      return m_data.value(m_data.size()-1);\n    }\n\n    /** \\internal \\deprecated use insert(Index,Index) */\n    EIGEN_DEPRECATED Scalar& fillrand(Index r, Index c)\n    {\n      eigen_assert(r==0 || c==0);\n      return fillrand(IsColVector ? r : c);\n    }\n\n    /** \\internal \\deprecated use insert(Index) */\n    EIGEN_DEPRECATED Scalar& fillrand(Index i)\n    {\n      return insert(i);\n    }\n\n    /** \\internal \\deprecated use finalize() */\n    EIGEN_DEPRECATED void endFill() {}\n    \n    // These two functions were here in the 3.1 release, so let's keep them in case some code rely on them.\n    /** \\internal \\deprecated use data() */\n    EIGEN_DEPRECATED Storage& _data() { return m_data; }\n    /** \\internal \\deprecated use data() */\n    EIGEN_DEPRECATED const Storage& _data() const { return m_data; }\n    \n#   ifdef EIGEN_SPARSEVECTOR_PLUGIN\n#     include EIGEN_SPARSEVECTOR_PLUGIN\n#   endif\n\nprotected:\n  \n    static void check_template_parameters()\n    {\n      EIGEN_STATIC_ASSERT(NumTraits<StorageIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE);\n      EIGEN_STATIC_ASSERT((_Options&(ColMajor|RowMajor))==Options,INVALID_MATRIX_TEMPLATE_PARAMETERS);\n    }\n    \n    Storage m_data;\n    Index m_size;\n};\n\nnamespace internal {\n\ntemplate<typename _Scalar, int _Options, typename _Index>\nstruct evaluator<SparseVector<_Scalar,_Options,_Index> >\n  : evaluator_base<SparseVector<_Scalar,_Options,_Index> >\n{\n  typedef SparseVector<_Scalar,_Options,_Index> SparseVectorType;\n  typedef evaluator_base<SparseVectorType> Base;\n  typedef typename SparseVectorType::InnerIterator InnerIterator;\n  typedef typename SparseVectorType::ReverseInnerIterator ReverseInnerIterator;\n  \n  enum {\n    CoeffReadCost = NumTraits<_Scalar>::ReadCost,\n    Flags = SparseVectorType::Flags\n  };\n\n  evaluator() : Base() {}\n  \n  explicit evaluator(const SparseVectorType &mat) : m_matrix(&mat)\n  {\n    EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);\n  }\n  \n  inline Index nonZerosEstimate() const {\n    return m_matrix->nonZeros();\n  }\n  \n  operator SparseVectorType&() { return m_matrix->const_cast_derived(); }\n  operator const SparseVectorType&() const { return *m_matrix; }\n  \n  const SparseVectorType *m_matrix;\n};\n\ntemplate< typename Dest, typename Src>\nstruct sparse_vector_assign_selector<Dest,Src,SVA_Inner> {\n  static void run(Dest& dst, const Src& src) {\n    eigen_internal_assert(src.innerSize()==src.size());\n    typedef internal::evaluator<Src> SrcEvaluatorType;\n    SrcEvaluatorType srcEval(src);\n    for(typename SrcEvaluatorType::InnerIterator it(srcEval, 0); it; ++it)\n      dst.insert(it.index()) = it.value();\n  }\n};\n\ntemplate< typename Dest, typename Src>\nstruct sparse_vector_assign_selector<Dest,Src,SVA_Outer> {\n  static void run(Dest& dst, const Src& src) {\n    eigen_internal_assert(src.outerSize()==src.size());\n    typedef internal::evaluator<Src> SrcEvaluatorType;\n    SrcEvaluatorType srcEval(src);\n    for(Index i=0; i<src.size(); ++i)\n    {\n      typename SrcEvaluatorType::InnerIterator it(srcEval, i);\n      if(it)\n        dst.insert(i) = it.value();\n    }\n  }\n};\n\ntemplate< typename Dest, typename Src>\nstruct sparse_vector_assign_selector<Dest,Src,SVA_RuntimeSwitch> {\n  static void run(Dest& dst, const Src& src) {\n    if(src.outerSize()==1)  sparse_vector_assign_selector<Dest,Src,SVA_Inner>::run(dst, src);\n    else                    sparse_vector_assign_selector<Dest,Src,SVA_Outer>::run(dst, src);\n  }\n};\n\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSEVECTOR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/SparseView.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2011-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2010 Daniel Lowengrub <lowdanie@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSEVIEW_H\n#define EIGEN_SPARSEVIEW_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename MatrixType>\nstruct traits<SparseView<MatrixType> > : traits<MatrixType>\n{\n  typedef typename MatrixType::StorageIndex StorageIndex;\n  typedef Sparse StorageKind;\n  enum {\n    Flags = int(traits<MatrixType>::Flags) & (RowMajorBit)\n  };\n};\n\n} // end namespace internal\n\n/** \\ingroup SparseCore_Module\n  * \\class SparseView\n  *\n  * \\brief Expression of a dense or sparse matrix with zero or too small values removed\n  *\n  * \\tparam MatrixType the type of the object of which we are removing the small entries\n  *\n  * This class represents an expression of a given dense or sparse matrix with\n  * entries smaller than \\c reference * \\c epsilon are removed.\n  * It is the return type of MatrixBase::sparseView() and SparseMatrixBase::pruned()\n  * and most of the time this is the only way it is used.\n  *\n  * \\sa MatrixBase::sparseView(), SparseMatrixBase::pruned()\n  */\ntemplate<typename MatrixType>\nclass SparseView : public SparseMatrixBase<SparseView<MatrixType> >\n{\n  typedef typename MatrixType::Nested MatrixTypeNested;\n  typedef typename internal::remove_all<MatrixTypeNested>::type _MatrixTypeNested;\n  typedef SparseMatrixBase<SparseView > Base;\npublic:\n  EIGEN_SPARSE_PUBLIC_INTERFACE(SparseView)\n  typedef typename internal::remove_all<MatrixType>::type NestedExpression;\n\n  explicit SparseView(const MatrixType& mat, const Scalar& reference = Scalar(0),\n                      const RealScalar &epsilon = NumTraits<Scalar>::dummy_precision())\n    : m_matrix(mat), m_reference(reference), m_epsilon(epsilon) {}\n\n  inline Index rows() const { return m_matrix.rows(); }\n  inline Index cols() const { return m_matrix.cols(); }\n\n  inline Index innerSize() const { return m_matrix.innerSize(); }\n  inline Index outerSize() const { return m_matrix.outerSize(); }\n  \n  /** \\returns the nested expression */\n  const typename internal::remove_all<MatrixTypeNested>::type&\n  nestedExpression() const { return m_matrix; }\n  \n  Scalar reference() const { return m_reference; }\n  RealScalar epsilon() const { return m_epsilon; }\n  \nprotected:\n  MatrixTypeNested m_matrix;\n  Scalar m_reference;\n  RealScalar m_epsilon;\n};\n\nnamespace internal {\n\n// TODO find a way to unify the two following variants\n// This is tricky because implementing an inner iterator on top of an IndexBased evaluator is\n// not easy because the evaluators do not expose the sizes of the underlying expression.\n  \ntemplate<typename ArgType>\nstruct unary_evaluator<SparseView<ArgType>, IteratorBased>\n  : public evaluator_base<SparseView<ArgType> >\n{\n    typedef typename evaluator<ArgType>::InnerIterator EvalIterator;\n  public:\n    typedef SparseView<ArgType> XprType;\n    \n    class InnerIterator : public EvalIterator\n    {\n        typedef typename XprType::Scalar Scalar;\n      public:\n\n        EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& sve, Index outer)\n          : EvalIterator(sve.m_argImpl,outer), m_view(sve.m_view)\n        {\n          incrementToNonZero();\n        }\n\n        EIGEN_STRONG_INLINE InnerIterator& operator++()\n        {\n          EvalIterator::operator++();\n          incrementToNonZero();\n          return *this;\n        }\n\n        using EvalIterator::value;\n\n      protected:\n        const XprType &m_view;\n\n      private:\n        void incrementToNonZero()\n        {\n          while((bool(*this)) && internal::isMuchSmallerThan(value(), m_view.reference(), m_view.epsilon()))\n          {\n            EvalIterator::operator++();\n          }\n        }\n    };\n    \n    enum {\n      CoeffReadCost = evaluator<ArgType>::CoeffReadCost,\n      Flags = XprType::Flags\n    };\n    \n    explicit unary_evaluator(const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_view(xpr) {}\n\n  protected:\n    evaluator<ArgType> m_argImpl;\n    const XprType &m_view;\n};\n\ntemplate<typename ArgType>\nstruct unary_evaluator<SparseView<ArgType>, IndexBased>\n  : public evaluator_base<SparseView<ArgType> >\n{\n  public:\n    typedef SparseView<ArgType> XprType;\n  protected:\n    enum { IsRowMajor = (XprType::Flags&RowMajorBit)==RowMajorBit };\n    typedef typename XprType::Scalar Scalar;\n    typedef typename XprType::StorageIndex StorageIndex;\n  public:\n    \n    class InnerIterator\n    {\n      public:\n\n        EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& sve, Index outer)\n          : m_sve(sve), m_inner(0), m_outer(outer), m_end(sve.m_view.innerSize())\n        {\n          incrementToNonZero();\n        }\n\n        EIGEN_STRONG_INLINE InnerIterator& operator++()\n        {\n          m_inner++;\n          incrementToNonZero();\n          return *this;\n        }\n\n        EIGEN_STRONG_INLINE Scalar value() const\n        {\n          return (IsRowMajor) ? m_sve.m_argImpl.coeff(m_outer, m_inner)\n                              : m_sve.m_argImpl.coeff(m_inner, m_outer);\n        }\n\n        EIGEN_STRONG_INLINE StorageIndex index() const { return m_inner; }\n        inline Index row() const { return IsRowMajor ? m_outer : index(); }\n        inline Index col() const { return IsRowMajor ? index() : m_outer; }\n\n        EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; }\n\n      protected:\n        const unary_evaluator &m_sve;\n        Index m_inner;\n        const Index m_outer;\n        const Index m_end;\n\n      private:\n        void incrementToNonZero()\n        {\n          while((bool(*this)) && internal::isMuchSmallerThan(value(), m_sve.m_view.reference(), m_sve.m_view.epsilon()))\n          {\n            m_inner++;\n          }\n        }\n    };\n    \n    enum {\n      CoeffReadCost = evaluator<ArgType>::CoeffReadCost,\n      Flags = XprType::Flags\n    };\n    \n    explicit unary_evaluator(const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_view(xpr) {}\n\n  protected:\n    evaluator<ArgType> m_argImpl;\n    const XprType &m_view;\n};\n\n} // end namespace internal\n\n/** \\ingroup SparseCore_Module\n  *\n  * \\returns a sparse expression of the dense expression \\c *this with values smaller than\n  * \\a reference * \\a epsilon removed.\n  *\n  * This method is typically used when prototyping to convert a quickly assembled dense Matrix \\c D to a SparseMatrix \\c S:\n  * \\code\n  * MatrixXd D(n,m);\n  * SparseMatrix<double> S;\n  * S = D.sparseView();             // suppress numerical zeros (exact)\n  * S = D.sparseView(reference);\n  * S = D.sparseView(reference,epsilon);\n  * \\endcode\n  * where \\a reference is a meaningful non zero reference value,\n  * and \\a epsilon is a tolerance factor defaulting to NumTraits<Scalar>::dummy_precision().\n  *\n  * \\sa SparseMatrixBase::pruned(), class SparseView */\ntemplate<typename Derived>\nconst SparseView<Derived> MatrixBase<Derived>::sparseView(const Scalar& reference,\n                                                          const typename NumTraits<Scalar>::Real& epsilon) const\n{\n  return SparseView<Derived>(derived(), reference, epsilon);\n}\n\n/** \\returns an expression of \\c *this with values smaller than\n  * \\a reference * \\a epsilon removed.\n  *\n  * This method is typically used in conjunction with the product of two sparse matrices\n  * to automatically prune the smallest values as follows:\n  * \\code\n  * C = (A*B).pruned();             // suppress numerical zeros (exact)\n  * C = (A*B).pruned(ref);\n  * C = (A*B).pruned(ref,epsilon);\n  * \\endcode\n  * where \\c ref is a meaningful non zero reference value.\n  * */\ntemplate<typename Derived>\nconst SparseView<Derived>\nSparseMatrixBase<Derived>::pruned(const Scalar& reference,\n                                  const RealScalar& epsilon) const\n{\n  return SparseView<Derived>(derived(), reference, epsilon);\n}\n\n} // end namespace Eigen\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseCore/TriangularSolver.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSETRIANGULARSOLVER_H\n#define EIGEN_SPARSETRIANGULARSOLVER_H\n\nnamespace Eigen { \n\nnamespace internal {\n\ntemplate<typename Lhs, typename Rhs, int Mode,\n  int UpLo = (Mode & Lower)\n           ? Lower\n           : (Mode & Upper)\n           ? Upper\n           : -1,\n  int StorageOrder = int(traits<Lhs>::Flags) & RowMajorBit>\nstruct sparse_solve_triangular_selector;\n\n// forward substitution, row-major\ntemplate<typename Lhs, typename Rhs, int Mode>\nstruct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Lower,RowMajor>\n{\n  typedef typename Rhs::Scalar Scalar;\n  typedef evaluator<Lhs> LhsEval;\n  typedef typename evaluator<Lhs>::InnerIterator LhsIterator;\n  static void run(const Lhs& lhs, Rhs& other)\n  {\n    LhsEval lhsEval(lhs);\n    for(Index col=0 ; col<other.cols() ; ++col)\n    {\n      for(Index i=0; i<lhs.rows(); ++i)\n      {\n        Scalar tmp = other.coeff(i,col);\n        Scalar lastVal(0);\n        Index lastIndex = 0;\n        for(LhsIterator it(lhsEval, i); it; ++it)\n        {\n          lastVal = it.value();\n          lastIndex = it.index();\n          if(lastIndex==i)\n            break;\n          tmp -= lastVal * other.coeff(lastIndex,col);\n        }\n        if (Mode & UnitDiag)\n          other.coeffRef(i,col) = tmp;\n        else\n        {\n          eigen_assert(lastIndex==i);\n          other.coeffRef(i,col) = tmp/lastVal;\n        }\n      }\n    }\n  }\n};\n\n// backward substitution, row-major\ntemplate<typename Lhs, typename Rhs, int Mode>\nstruct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Upper,RowMajor>\n{\n  typedef typename Rhs::Scalar Scalar;\n  typedef evaluator<Lhs> LhsEval;\n  typedef typename evaluator<Lhs>::InnerIterator LhsIterator;\n  static void run(const Lhs& lhs, Rhs& other)\n  {\n    LhsEval lhsEval(lhs);\n    for(Index col=0 ; col<other.cols() ; ++col)\n    {\n      for(Index i=lhs.rows()-1 ; i>=0 ; --i)\n      {\n        Scalar tmp = other.coeff(i,col);\n        Scalar l_ii(0);\n        LhsIterator it(lhsEval, i);\n        while(it && it.index()<i)\n          ++it;\n        if(!(Mode & UnitDiag))\n        {\n          eigen_assert(it && it.index()==i);\n          l_ii = it.value();\n          ++it;\n        }\n        else if (it && it.index() == i)\n          ++it;\n        for(; it; ++it)\n        {\n          tmp -= it.value() * other.coeff(it.index(),col);\n        }\n\n        if (Mode & UnitDiag)  other.coeffRef(i,col) = tmp;\n        else                  other.coeffRef(i,col) = tmp/l_ii;\n      }\n    }\n  }\n};\n\n// forward substitution, col-major\ntemplate<typename Lhs, typename Rhs, int Mode>\nstruct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Lower,ColMajor>\n{\n  typedef typename Rhs::Scalar Scalar;\n  typedef evaluator<Lhs> LhsEval;\n  typedef typename evaluator<Lhs>::InnerIterator LhsIterator;\n  static void run(const Lhs& lhs, Rhs& other)\n  {\n    LhsEval lhsEval(lhs);\n    for(Index col=0 ; col<other.cols() ; ++col)\n    {\n      for(Index i=0; i<lhs.cols(); ++i)\n      {\n        Scalar& tmp = other.coeffRef(i,col);\n        if (tmp!=Scalar(0)) // optimization when other is actually sparse\n        {\n          LhsIterator it(lhsEval, i);\n          while(it && it.index()<i)\n            ++it;\n          if(!(Mode & UnitDiag))\n          {\n            eigen_assert(it && it.index()==i);\n            tmp /= it.value();\n          }\n          if (it && it.index()==i)\n            ++it;\n          for(; it; ++it)\n            other.coeffRef(it.index(), col) -= tmp * it.value();\n        }\n      }\n    }\n  }\n};\n\n// backward substitution, col-major\ntemplate<typename Lhs, typename Rhs, int Mode>\nstruct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Upper,ColMajor>\n{\n  typedef typename Rhs::Scalar Scalar;\n  typedef evaluator<Lhs> LhsEval;\n  typedef typename evaluator<Lhs>::InnerIterator LhsIterator;\n  static void run(const Lhs& lhs, Rhs& other)\n  {\n    LhsEval lhsEval(lhs);\n    for(Index col=0 ; col<other.cols() ; ++col)\n    {\n      for(Index i=lhs.cols()-1; i>=0; --i)\n      {\n        Scalar& tmp = other.coeffRef(i,col);\n        if (tmp!=Scalar(0)) // optimization when other is actually sparse\n        {\n          if(!(Mode & UnitDiag))\n          {\n            // TODO replace this by a binary search. make sure the binary search is safe for partially sorted elements\n            LhsIterator it(lhsEval, i);\n            while(it && it.index()!=i)\n              ++it;\n            eigen_assert(it && it.index()==i);\n            other.coeffRef(i,col) /= it.value();\n          }\n          LhsIterator it(lhsEval, i);\n          for(; it && it.index()<i; ++it)\n            other.coeffRef(it.index(), col) -= tmp * it.value();\n        }\n      }\n    }\n  }\n};\n\n} // end namespace internal\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n\ntemplate<typename ExpressionType,unsigned int Mode>\ntemplate<typename OtherDerived>\nvoid TriangularViewImpl<ExpressionType,Mode,Sparse>::solveInPlace(MatrixBase<OtherDerived>& other) const\n{\n  eigen_assert(derived().cols() == derived().rows() && derived().cols() == other.rows());\n  eigen_assert((!(Mode & ZeroDiag)) && bool(Mode & (Upper|Lower)));\n\n  enum { copy = internal::traits<OtherDerived>::Flags & RowMajorBit };\n\n  typedef typename internal::conditional<copy,\n    typename internal::plain_matrix_type_column_major<OtherDerived>::type, OtherDerived&>::type OtherCopy;\n  OtherCopy otherCopy(other.derived());\n\n  internal::sparse_solve_triangular_selector<ExpressionType, typename internal::remove_reference<OtherCopy>::type, Mode>::run(derived().nestedExpression(), otherCopy);\n\n  if (copy)\n    other = otherCopy;\n}\n#endif\n\n// pure sparse path\n\nnamespace internal {\n\ntemplate<typename Lhs, typename Rhs, int Mode,\n  int UpLo = (Mode & Lower)\n           ? Lower\n           : (Mode & Upper)\n           ? Upper\n           : -1,\n  int StorageOrder = int(Lhs::Flags) & (RowMajorBit)>\nstruct sparse_solve_triangular_sparse_selector;\n\n// forward substitution, col-major\ntemplate<typename Lhs, typename Rhs, int Mode, int UpLo>\nstruct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>\n{\n  typedef typename Rhs::Scalar Scalar;\n  typedef typename promote_index_type<typename traits<Lhs>::StorageIndex,\n                                      typename traits<Rhs>::StorageIndex>::type StorageIndex;\n  static void run(const Lhs& lhs, Rhs& other)\n  {\n    const bool IsLower = (UpLo==Lower);\n    AmbiVector<Scalar,StorageIndex> tempVector(other.rows()*2);\n    tempVector.setBounds(0,other.rows());\n\n    Rhs res(other.rows(), other.cols());\n    res.reserve(other.nonZeros());\n\n    for(Index col=0 ; col<other.cols() ; ++col)\n    {\n      // FIXME estimate number of non zeros\n      tempVector.init(.99/*float(other.col(col).nonZeros())/float(other.rows())*/);\n      tempVector.setZero();\n      tempVector.restart();\n      for (typename Rhs::InnerIterator rhsIt(other, col); rhsIt; ++rhsIt)\n      {\n        tempVector.coeffRef(rhsIt.index()) = rhsIt.value();\n      }\n\n      for(Index i=IsLower?0:lhs.cols()-1;\n          IsLower?i<lhs.cols():i>=0;\n          i+=IsLower?1:-1)\n      {\n        tempVector.restart();\n        Scalar& ci = tempVector.coeffRef(i);\n        if (ci!=Scalar(0))\n        {\n          // find\n          typename Lhs::InnerIterator it(lhs, i);\n          if(!(Mode & UnitDiag))\n          {\n            if (IsLower)\n            {\n              eigen_assert(it.index()==i);\n              ci /= it.value();\n            }\n            else\n              ci /= lhs.coeff(i,i);\n          }\n          tempVector.restart();\n          if (IsLower)\n          {\n            if (it.index()==i)\n              ++it;\n            for(; it; ++it)\n              tempVector.coeffRef(it.index()) -= ci * it.value();\n          }\n          else\n          {\n            for(; it && it.index()<i; ++it)\n              tempVector.coeffRef(it.index()) -= ci * it.value();\n          }\n        }\n      }\n\n\n      Index count = 0;\n      // FIXME compute a reference value to filter zeros\n      for (typename AmbiVector<Scalar,StorageIndex>::Iterator it(tempVector/*,1e-12*/); it; ++it)\n      {\n        ++ count;\n//         std::cerr << \"fill \" << it.index() << \", \" << col << \"\\n\";\n//         std::cout << it.value() << \"  \";\n        // FIXME use insertBack\n        res.insert(it.index(), col) = it.value();\n      }\n//       std::cout << \"tempVector.nonZeros() == \" << int(count) << \" / \" << (other.rows()) << \"\\n\";\n    }\n    res.finalize();\n    other = res.markAsRValue();\n  }\n};\n\n} // end namespace internal\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename ExpressionType,unsigned int Mode>\ntemplate<typename OtherDerived>\nvoid TriangularViewImpl<ExpressionType,Mode,Sparse>::solveInPlace(SparseMatrixBase<OtherDerived>& other) const\n{\n  eigen_assert(derived().cols() == derived().rows() && derived().cols() == other.rows());\n  eigen_assert( (!(Mode & ZeroDiag)) && bool(Mode & (Upper|Lower)));\n\n//   enum { copy = internal::traits<OtherDerived>::Flags & RowMajorBit };\n\n//   typedef typename internal::conditional<copy,\n//     typename internal::plain_matrix_type_column_major<OtherDerived>::type, OtherDerived&>::type OtherCopy;\n//   OtherCopy otherCopy(other.derived());\n\n  internal::sparse_solve_triangular_sparse_selector<ExpressionType, OtherDerived, Mode>::run(derived().nestedExpression(), other.derived());\n\n//   if (copy)\n//     other = otherCopy;\n}\n#endif\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSETRIANGULARSOLVER_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n// Copyright (C) 2012-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n\n#ifndef EIGEN_SPARSE_LU_H\n#define EIGEN_SPARSE_LU_H\n\nnamespace Eigen {\n\ntemplate <typename _MatrixType, typename _OrderingType = COLAMDOrdering<typename _MatrixType::StorageIndex> > class SparseLU;\ntemplate <typename MappedSparseMatrixType> struct SparseLUMatrixLReturnType;\ntemplate <typename MatrixLType, typename MatrixUType> struct SparseLUMatrixUReturnType;\n\n/** \\ingroup SparseLU_Module\n  * \\class SparseLU\n  * \n  * \\brief Sparse supernodal LU factorization for general matrices\n  * \n  * This class implements the supernodal LU factorization for general matrices.\n  * It uses the main techniques from the sequential SuperLU package \n  * (http://crd-legacy.lbl.gov/~xiaoye/SuperLU/). It handles transparently real \n  * and complex arithmetics with single and double precision, depending on the \n  * scalar type of your input matrix. \n  * The code has been optimized to provide BLAS-3 operations during supernode-panel updates. \n  * It benefits directly from the built-in high-performant Eigen BLAS routines. \n  * Moreover, when the size of a supernode is very small, the BLAS calls are avoided to \n  * enable a better optimization from the compiler. For best performance, \n  * you should compile it with NDEBUG flag to avoid the numerous bounds checking on vectors. \n  * \n  * An important parameter of this class is the ordering method. It is used to reorder the columns \n  * (and eventually the rows) of the matrix to reduce the number of new elements that are created during \n  * numerical factorization. The cheapest method available is COLAMD. \n  * See  \\link OrderingMethods_Module the OrderingMethods module \\endlink for the list of \n  * built-in and external ordering methods. \n  *\n  * Simple example with key steps \n  * \\code\n  * VectorXd x(n), b(n);\n  * SparseMatrix<double, ColMajor> A;\n  * SparseLU<SparseMatrix<scalar, ColMajor>, COLAMDOrdering<Index> >   solver;\n  * // fill A and b;\n  * // Compute the ordering permutation vector from the structural pattern of A\n  * solver.analyzePattern(A); \n  * // Compute the numerical factorization \n  * solver.factorize(A); \n  * //Use the factors to solve the linear system \n  * x = solver.solve(b); \n  * \\endcode\n  * \n  * \\warning The input matrix A should be in a \\b compressed and \\b column-major form.\n  * Otherwise an expensive copy will be made. You can call the inexpensive makeCompressed() to get a compressed matrix.\n  * \n  * \\note Unlike the initial SuperLU implementation, there is no step to equilibrate the matrix. \n  * For badly scaled matrices, this step can be useful to reduce the pivoting during factorization. \n  * If this is the case for your matrices, you can try the basic scaling method at\n  *  \"unsupported/Eigen/src/IterativeSolvers/Scaling.h\"\n  * \n  * \\tparam _MatrixType The type of the sparse matrix. It must be a column-major SparseMatrix<>\n  * \\tparam _OrderingType The ordering method to use, either AMD, COLAMD or METIS. Default is COLMAD\n  *\n  * \\implsparsesolverconcept\n  * \n  * \\sa \\ref TutorialSparseSolverConcept\n  * \\sa \\ref OrderingMethods_Module\n  */\ntemplate <typename _MatrixType, typename _OrderingType>\nclass SparseLU : public SparseSolverBase<SparseLU<_MatrixType,_OrderingType> >, public internal::SparseLUImpl<typename _MatrixType::Scalar, typename _MatrixType::StorageIndex>\n{\n  protected:\n    typedef SparseSolverBase<SparseLU<_MatrixType,_OrderingType> > APIBase;\n    using APIBase::m_isInitialized;\n  public:\n    using APIBase::_solve_impl;\n    \n    typedef _MatrixType MatrixType; \n    typedef _OrderingType OrderingType;\n    typedef typename MatrixType::Scalar Scalar; \n    typedef typename MatrixType::RealScalar RealScalar; \n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef SparseMatrix<Scalar,ColMajor,StorageIndex> NCMatrix;\n    typedef internal::MappedSuperNodalMatrix<Scalar, StorageIndex> SCMatrix;\n    typedef Matrix<Scalar,Dynamic,1> ScalarVector;\n    typedef Matrix<StorageIndex,Dynamic,1> IndexVector;\n    typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType;\n    typedef internal::SparseLUImpl<Scalar, StorageIndex> Base;\n\n    enum {\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n    \n  public:\n    SparseLU():m_lastError(\"\"),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0),m_detPermR(1)\n    {\n      initperfvalues(); \n    }\n    explicit SparseLU(const MatrixType& matrix)\n      : m_lastError(\"\"),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0),m_detPermR(1)\n    {\n      initperfvalues(); \n      compute(matrix);\n    }\n    \n    ~SparseLU()\n    {\n      // Free all explicit dynamic pointers \n    }\n    \n    void analyzePattern (const MatrixType& matrix);\n    void factorize (const MatrixType& matrix);\n    void simplicialfactorize(const MatrixType& matrix);\n    \n    /**\n      * Compute the symbolic and numeric factorization of the input sparse matrix.\n      * The input matrix should be in column-major storage. \n      */\n    void compute (const MatrixType& matrix)\n    {\n      // Analyze \n      analyzePattern(matrix); \n      //Factorize\n      factorize(matrix);\n    } \n    \n    inline Index rows() const { return m_mat.rows(); }\n    inline Index cols() const { return m_mat.cols(); }\n    /** Indicate that the pattern of the input matrix is symmetric */\n    void isSymmetric(bool sym)\n    {\n      m_symmetricmode = sym;\n    }\n    \n    /** \\returns an expression of the matrix L, internally stored as supernodes\n      * The only operation available with this expression is the triangular solve\n      * \\code\n      * y = b; matrixL().solveInPlace(y);\n      * \\endcode\n      */\n    SparseLUMatrixLReturnType<SCMatrix> matrixL() const\n    {\n      return SparseLUMatrixLReturnType<SCMatrix>(m_Lstore);\n    }\n    /** \\returns an expression of the matrix U,\n      * The only operation available with this expression is the triangular solve\n      * \\code\n      * y = b; matrixU().solveInPlace(y);\n      * \\endcode\n      */\n    SparseLUMatrixUReturnType<SCMatrix,MappedSparseMatrix<Scalar,ColMajor,StorageIndex> > matrixU() const\n    {\n      return SparseLUMatrixUReturnType<SCMatrix, MappedSparseMatrix<Scalar,ColMajor,StorageIndex> >(m_Lstore, m_Ustore);\n    }\n\n    /**\n      * \\returns a reference to the row matrix permutation \\f$ P_r \\f$ such that \\f$P_r A P_c^T = L U\\f$\n      * \\sa colsPermutation()\n      */\n    inline const PermutationType& rowsPermutation() const\n    {\n      return m_perm_r;\n    }\n    /**\n      * \\returns a reference to the column matrix permutation\\f$ P_c^T \\f$ such that \\f$P_r A P_c^T = L U\\f$\n      * \\sa rowsPermutation()\n      */\n    inline const PermutationType& colsPermutation() const\n    {\n      return m_perm_c;\n    }\n    /** Set the threshold used for a diagonal entry to be an acceptable pivot. */\n    void setPivotThreshold(const RealScalar& thresh)\n    {\n      m_diagpivotthresh = thresh; \n    }\n\n#ifdef EIGEN_PARSED_BY_DOXYGEN\n    /** \\returns the solution X of \\f$ A X = B \\f$ using the current decomposition of A.\n      *\n      * \\warning the destination matrix X in X = this->solve(B) must be colmun-major.\n      *\n      * \\sa compute()\n      */\n    template<typename Rhs>\n    inline const Solve<SparseLU, Rhs> solve(const MatrixBase<Rhs>& B) const;\n#endif // EIGEN_PARSED_BY_DOXYGEN\n    \n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful,\n      *          \\c NumericalIssue if the LU factorization reports a problem, zero diagonal for instance\n      *          \\c InvalidInput if the input matrix is invalid\n      *\n      * \\sa iparm()          \n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return m_info;\n    }\n    \n    /**\n      * \\returns A string describing the type of error\n      */\n    std::string lastErrorMessage() const\n    {\n      return m_lastError; \n    }\n\n    template<typename Rhs, typename Dest>\n    bool _solve_impl(const MatrixBase<Rhs> &B, MatrixBase<Dest> &X_base) const\n    {\n      Dest& X(X_base.derived());\n      eigen_assert(m_factorizationIsOk && \"The matrix should be factorized first\");\n      EIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0,\n                        THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);\n      \n      // Permute the right hand side to form X = Pr*B\n      // on return, X is overwritten by the computed solution\n      X.resize(B.rows(),B.cols());\n\n      // this ugly const_cast_derived() helps to detect aliasing when applying the permutations\n      for(Index j = 0; j < B.cols(); ++j)\n        X.col(j) = rowsPermutation() * B.const_cast_derived().col(j);\n      \n      //Forward substitution with L\n      this->matrixL().solveInPlace(X);\n      this->matrixU().solveInPlace(X);\n      \n      // Permute back the solution \n      for (Index j = 0; j < B.cols(); ++j)\n        X.col(j) = colsPermutation().inverse() * X.col(j);\n      \n      return true; \n    }\n    \n    /**\n      * \\returns the absolute value of the determinant of the matrix of which\n      * *this is the QR decomposition.\n      *\n      * \\warning a determinant can be very big or small, so for matrices\n      * of large enough dimension, there is a risk of overflow/underflow.\n      * One way to work around that is to use logAbsDeterminant() instead.\n      *\n      * \\sa logAbsDeterminant(), signDeterminant()\n      */\n    Scalar absDeterminant()\n    {\n      using std::abs;\n      eigen_assert(m_factorizationIsOk && \"The matrix should be factorized first.\");\n      // Initialize with the determinant of the row matrix\n      Scalar det = Scalar(1.);\n      // Note that the diagonal blocks of U are stored in supernodes,\n      // which are available in the  L part :)\n      for (Index j = 0; j < this->cols(); ++j)\n      {\n        for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)\n        {\n          if(it.index() == j)\n          {\n            det *= abs(it.value());\n            break;\n          }\n        }\n      }\n      return det;\n    }\n\n    /** \\returns the natural log of the absolute value of the determinant of the matrix\n      * of which **this is the QR decomposition\n      *\n      * \\note This method is useful to work around the risk of overflow/underflow that's\n      * inherent to the determinant computation.\n      *\n      * \\sa absDeterminant(), signDeterminant()\n      */\n    Scalar logAbsDeterminant() const\n    {\n      using std::log;\n      using std::abs;\n\n      eigen_assert(m_factorizationIsOk && \"The matrix should be factorized first.\");\n      Scalar det = Scalar(0.);\n      for (Index j = 0; j < this->cols(); ++j)\n      {\n        for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)\n        {\n          if(it.row() < j) continue;\n          if(it.row() == j)\n          {\n            det += log(abs(it.value()));\n            break;\n          }\n        }\n      }\n      return det;\n    }\n\n    /** \\returns A number representing the sign of the determinant\n      *\n      * \\sa absDeterminant(), logAbsDeterminant()\n      */\n    Scalar signDeterminant()\n    {\n      eigen_assert(m_factorizationIsOk && \"The matrix should be factorized first.\");\n      // Initialize with the determinant of the row matrix\n      Index det = 1;\n      // Note that the diagonal blocks of U are stored in supernodes,\n      // which are available in the  L part :)\n      for (Index j = 0; j < this->cols(); ++j)\n      {\n        for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)\n        {\n          if(it.index() == j)\n          {\n            if(it.value()<0)\n              det = -det;\n            else if(it.value()==0)\n              return 0;\n            break;\n          }\n        }\n      }\n      return det * m_detPermR * m_detPermC;\n    }\n    \n    /** \\returns The determinant of the matrix.\n      *\n      * \\sa absDeterminant(), logAbsDeterminant()\n      */\n    Scalar determinant()\n    {\n      eigen_assert(m_factorizationIsOk && \"The matrix should be factorized first.\");\n      // Initialize with the determinant of the row matrix\n      Scalar det = Scalar(1.);\n      // Note that the diagonal blocks of U are stored in supernodes,\n      // which are available in the  L part :)\n      for (Index j = 0; j < this->cols(); ++j)\n      {\n        for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)\n        {\n          if(it.index() == j)\n          {\n            det *= it.value();\n            break;\n          }\n        }\n      }\n      return (m_detPermR * m_detPermC) > 0 ? det : -det;\n    }\n\n  protected:\n    // Functions \n    void initperfvalues()\n    {\n      m_perfv.panel_size = 16;\n      m_perfv.relax = 1; \n      m_perfv.maxsuper = 128; \n      m_perfv.rowblk = 16; \n      m_perfv.colblk = 8; \n      m_perfv.fillfactor = 20;  \n    }\n      \n    // Variables \n    mutable ComputationInfo m_info;\n    bool m_factorizationIsOk;\n    bool m_analysisIsOk;\n    std::string m_lastError;\n    NCMatrix m_mat; // The input (permuted ) matrix \n    SCMatrix m_Lstore; // The lower triangular matrix (supernodal)\n    MappedSparseMatrix<Scalar,ColMajor,StorageIndex> m_Ustore; // The upper triangular matrix\n    PermutationType m_perm_c; // Column permutation \n    PermutationType m_perm_r ; // Row permutation\n    IndexVector m_etree; // Column elimination tree \n    \n    typename Base::GlobalLU_t m_glu; \n                               \n    // SparseLU options \n    bool m_symmetricmode;\n    // values for performance \n    internal::perfvalues m_perfv;\n    RealScalar m_diagpivotthresh; // Specifies the threshold used for a diagonal entry to be an acceptable pivot\n    Index m_nnzL, m_nnzU; // Nonzeros in L and U factors\n    Index m_detPermR, m_detPermC; // Determinants of the permutation matrices\n  private:\n    // Disable copy constructor \n    SparseLU (const SparseLU& );\n  \n}; // End class SparseLU\n\n\n\n// Functions needed by the anaysis phase\n/** \n  * Compute the column permutation to minimize the fill-in\n  * \n  *  - Apply this permutation to the input matrix - \n  * \n  *  - Compute the column elimination tree on the permuted matrix \n  * \n  *  - Postorder the elimination tree and the column permutation\n  * \n  */\ntemplate <typename MatrixType, typename OrderingType>\nvoid SparseLU<MatrixType, OrderingType>::analyzePattern(const MatrixType& mat)\n{\n  \n  //TODO  It is possible as in SuperLU to compute row and columns scaling vectors to equilibrate the matrix mat.\n  \n  // Firstly, copy the whole input matrix. \n  m_mat = mat;\n  \n  // Compute fill-in ordering\n  OrderingType ord; \n  ord(m_mat,m_perm_c);\n  \n  // Apply the permutation to the column of the input  matrix\n  if (m_perm_c.size())\n  {\n    m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers. FIXME : This vector is filled but not subsequently used.  \n    // Then, permute only the column pointers\n    ei_declare_aligned_stack_constructed_variable(StorageIndex,outerIndexPtr,mat.cols()+1,mat.isCompressed()?const_cast<StorageIndex*>(mat.outerIndexPtr()):0);\n    \n    // If the input matrix 'mat' is uncompressed, then the outer-indices do not match the ones of m_mat, and a copy is thus needed.\n    if(!mat.isCompressed()) \n      IndexVector::Map(outerIndexPtr, mat.cols()+1) = IndexVector::Map(m_mat.outerIndexPtr(),mat.cols()+1);\n    \n    // Apply the permutation and compute the nnz per column.\n    for (Index i = 0; i < mat.cols(); i++)\n    {\n      m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];\n      m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];\n    }\n  }\n  \n  // Compute the column elimination tree of the permuted matrix \n  IndexVector firstRowElt;\n  internal::coletree(m_mat, m_etree,firstRowElt); \n     \n  // In symmetric mode, do not do postorder here\n  if (!m_symmetricmode) {\n    IndexVector post, iwork; \n    // Post order etree\n    internal::treePostorder(StorageIndex(m_mat.cols()), m_etree, post); \n      \n   \n    // Renumber etree in postorder \n    Index m = m_mat.cols(); \n    iwork.resize(m+1);\n    for (Index i = 0; i < m; ++i) iwork(post(i)) = post(m_etree(i));\n    m_etree = iwork;\n    \n    // Postmultiply A*Pc by post, i.e reorder the matrix according to the postorder of the etree\n    PermutationType post_perm(m); \n    for (Index i = 0; i < m; i++) \n      post_perm.indices()(i) = post(i); \n        \n    // Combine the two permutations : postorder the permutation for future use\n    if(m_perm_c.size()) {\n      m_perm_c = post_perm * m_perm_c;\n    }\n    \n  } // end postordering \n  \n  m_analysisIsOk = true; \n}\n\n// Functions needed by the numerical factorization phase\n\n\n/** \n  *  - Numerical factorization \n  *  - Interleaved with the symbolic factorization \n  * On exit,  info is \n  * \n  *    = 0: successful factorization\n  * \n  *    > 0: if info = i, and i is\n  * \n  *       <= A->ncol: U(i,i) is exactly zero. The factorization has\n  *          been completed, but the factor U is exactly singular,\n  *          and division by zero will occur if it is used to solve a\n  *          system of equations.\n  * \n  *       > A->ncol: number of bytes allocated when memory allocation\n  *         failure occurred, plus A->ncol. If lwork = -1, it is\n  *         the estimated amount of space needed, plus A->ncol.  \n  */\ntemplate <typename MatrixType, typename OrderingType>\nvoid SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)\n{\n  using internal::emptyIdxLU;\n  eigen_assert(m_analysisIsOk && \"analyzePattern() should be called first\"); \n  eigen_assert((matrix.rows() == matrix.cols()) && \"Only for squared matrices\");\n  \n  typedef typename IndexVector::Scalar StorageIndex; \n  \n  m_isInitialized = true;\n  \n  \n  // Apply the column permutation computed in analyzepattern()\n  //   m_mat = matrix * m_perm_c.inverse(); \n  m_mat = matrix;\n  if (m_perm_c.size()) \n  {\n    m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers.\n    //Then, permute only the column pointers\n    const StorageIndex * outerIndexPtr;\n    if (matrix.isCompressed()) outerIndexPtr = matrix.outerIndexPtr();\n    else\n    {\n      StorageIndex* outerIndexPtr_t = new StorageIndex[matrix.cols()+1];\n      for(Index i = 0; i <= matrix.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i];\n      outerIndexPtr = outerIndexPtr_t;\n    }\n    for (Index i = 0; i < matrix.cols(); i++)\n    {\n      m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];\n      m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];\n    }\n    if(!matrix.isCompressed()) delete[] outerIndexPtr;\n  } \n  else \n  { //FIXME This should not be needed if the empty permutation is handled transparently\n    m_perm_c.resize(matrix.cols());\n    for(StorageIndex i = 0; i < matrix.cols(); ++i) m_perm_c.indices()(i) = i;\n  }\n  \n  Index m = m_mat.rows();\n  Index n = m_mat.cols();\n  Index nnz = m_mat.nonZeros();\n  Index maxpanel = m_perfv.panel_size * m;\n  // Allocate working storage common to the factor routines\n  Index lwork = 0;\n  Index info = Base::memInit(m, n, nnz, lwork, m_perfv.fillfactor, m_perfv.panel_size, m_glu); \n  if (info) \n  {\n    m_lastError = \"UNABLE TO ALLOCATE WORKING MEMORY\\n\\n\" ;\n    m_factorizationIsOk = false;\n    return ; \n  }\n  \n  // Set up pointers for integer working arrays \n  IndexVector segrep(m); segrep.setZero();\n  IndexVector parent(m); parent.setZero();\n  IndexVector xplore(m); xplore.setZero();\n  IndexVector repfnz(maxpanel);\n  IndexVector panel_lsub(maxpanel);\n  IndexVector xprune(n); xprune.setZero();\n  IndexVector marker(m*internal::LUNoMarker); marker.setZero();\n  \n  repfnz.setConstant(-1); \n  panel_lsub.setConstant(-1);\n  \n  // Set up pointers for scalar working arrays \n  ScalarVector dense; \n  dense.setZero(maxpanel);\n  ScalarVector tempv; \n  tempv.setZero(internal::LUnumTempV(m, m_perfv.panel_size, m_perfv.maxsuper, /*m_perfv.rowblk*/m) );\n  \n  // Compute the inverse of perm_c\n  PermutationType iperm_c(m_perm_c.inverse()); \n  \n  // Identify initial relaxed snodes\n  IndexVector relax_end(n);\n  if ( m_symmetricmode == true ) \n    Base::heap_relax_snode(n, m_etree, m_perfv.relax, marker, relax_end);\n  else\n    Base::relax_snode(n, m_etree, m_perfv.relax, marker, relax_end);\n  \n  \n  m_perm_r.resize(m); \n  m_perm_r.indices().setConstant(-1);\n  marker.setConstant(-1);\n  m_detPermR = 1; // Record the determinant of the row permutation\n  \n  m_glu.supno(0) = emptyIdxLU; m_glu.xsup.setConstant(0);\n  m_glu.xsup(0) = m_glu.xlsub(0) = m_glu.xusub(0) = m_glu.xlusup(0) = Index(0);\n  \n  // Work on one 'panel' at a time. A panel is one of the following :\n  //  (a) a relaxed supernode at the bottom of the etree, or\n  //  (b) panel_size contiguous columns, <panel_size> defined by the user\n  Index jcol; \n  IndexVector panel_histo(n);\n  Index pivrow; // Pivotal row number in the original row matrix\n  Index nseg1; // Number of segments in U-column above panel row jcol\n  Index nseg; // Number of segments in each U-column \n  Index irep; \n  Index i, k, jj; \n  for (jcol = 0; jcol < n; )\n  {\n    // Adjust panel size so that a panel won't overlap with the next relaxed snode. \n    Index panel_size = m_perfv.panel_size; // upper bound on panel width\n    for (k = jcol + 1; k < (std::min)(jcol+panel_size, n); k++)\n    {\n      if (relax_end(k) != emptyIdxLU) \n      {\n        panel_size = k - jcol; \n        break; \n      }\n    }\n    if (k == n) \n      panel_size = n - jcol; \n      \n    // Symbolic outer factorization on a panel of columns \n    Base::panel_dfs(m, panel_size, jcol, m_mat, m_perm_r.indices(), nseg1, dense, panel_lsub, segrep, repfnz, xprune, marker, parent, xplore, m_glu); \n    \n    // Numeric sup-panel updates in topological order \n    Base::panel_bmod(m, panel_size, jcol, nseg1, dense, tempv, segrep, repfnz, m_glu); \n    \n    // Sparse LU within the panel, and below the panel diagonal \n    for ( jj = jcol; jj< jcol + panel_size; jj++) \n    {\n      k = (jj - jcol) * m; // Column index for w-wide arrays \n      \n      nseg = nseg1; // begin after all the panel segments\n      //Depth-first-search for the current column\n      VectorBlock<IndexVector> panel_lsubk(panel_lsub, k, m);\n      VectorBlock<IndexVector> repfnz_k(repfnz, k, m); \n      info = Base::column_dfs(m, jj, m_perm_r.indices(), m_perfv.maxsuper, nseg, panel_lsubk, segrep, repfnz_k, xprune, marker, parent, xplore, m_glu); \n      if ( info ) \n      {\n        m_lastError =  \"UNABLE TO EXPAND MEMORY IN COLUMN_DFS() \";\n        m_info = NumericalIssue; \n        m_factorizationIsOk = false; \n        return; \n      }\n      // Numeric updates to this column \n      VectorBlock<ScalarVector> dense_k(dense, k, m); \n      VectorBlock<IndexVector> segrep_k(segrep, nseg1, m-nseg1); \n      info = Base::column_bmod(jj, (nseg - nseg1), dense_k, tempv, segrep_k, repfnz_k, jcol, m_glu); \n      if ( info ) \n      {\n        m_lastError = \"UNABLE TO EXPAND MEMORY IN COLUMN_BMOD() \";\n        m_info = NumericalIssue; \n        m_factorizationIsOk = false; \n        return; \n      }\n      \n      // Copy the U-segments to ucol(*)\n      info = Base::copy_to_ucol(jj, nseg, segrep, repfnz_k ,m_perm_r.indices(), dense_k, m_glu); \n      if ( info ) \n      {\n        m_lastError = \"UNABLE TO EXPAND MEMORY IN COPY_TO_UCOL() \";\n        m_info = NumericalIssue; \n        m_factorizationIsOk = false; \n        return; \n      }\n      \n      // Form the L-segment \n      info = Base::pivotL(jj, m_diagpivotthresh, m_perm_r.indices(), iperm_c.indices(), pivrow, m_glu);\n      if ( info ) \n      {\n        m_lastError = \"THE MATRIX IS STRUCTURALLY SINGULAR ... ZERO COLUMN AT \";\n        std::ostringstream returnInfo;\n        returnInfo << info; \n        m_lastError += returnInfo.str();\n        m_info = NumericalIssue; \n        m_factorizationIsOk = false; \n        return; \n      }\n      \n      // Update the determinant of the row permutation matrix\n      // FIXME: the following test is not correct, we should probably take iperm_c into account and pivrow is not directly the row pivot.\n      if (pivrow != jj) m_detPermR = -m_detPermR;\n\n      // Prune columns (0:jj-1) using column jj\n      Base::pruneL(jj, m_perm_r.indices(), pivrow, nseg, segrep, repfnz_k, xprune, m_glu); \n      \n      // Reset repfnz for this column \n      for (i = 0; i < nseg; i++)\n      {\n        irep = segrep(i); \n        repfnz_k(irep) = emptyIdxLU; \n      }\n    } // end SparseLU within the panel  \n    jcol += panel_size;  // Move to the next panel\n  } // end for -- end elimination \n  \n  m_detPermR = m_perm_r.determinant();\n  m_detPermC = m_perm_c.determinant();\n  \n  // Count the number of nonzeros in factors \n  Base::countnz(n, m_nnzL, m_nnzU, m_glu); \n  // Apply permutation  to the L subscripts \n  Base::fixupL(n, m_perm_r.indices(), m_glu);\n  \n  // Create supernode matrix L \n  m_Lstore.setInfos(m, n, m_glu.lusup, m_glu.xlusup, m_glu.lsub, m_glu.xlsub, m_glu.supno, m_glu.xsup); \n  // Create the column major upper sparse matrix  U; \n  new (&m_Ustore) MappedSparseMatrix<Scalar, ColMajor, StorageIndex> ( m, n, m_nnzU, m_glu.xusub.data(), m_glu.usub.data(), m_glu.ucol.data() );\n  \n  m_info = Success;\n  m_factorizationIsOk = true;\n}\n\ntemplate<typename MappedSupernodalType>\nstruct SparseLUMatrixLReturnType : internal::no_assignment_operator\n{\n  typedef typename MappedSupernodalType::Scalar Scalar;\n  explicit SparseLUMatrixLReturnType(const MappedSupernodalType& mapL) : m_mapL(mapL)\n  { }\n  Index rows() { return m_mapL.rows(); }\n  Index cols() { return m_mapL.cols(); }\n  template<typename Dest>\n  void solveInPlace( MatrixBase<Dest> &X) const\n  {\n    m_mapL.solveInPlace(X);\n  }\n  const MappedSupernodalType& m_mapL;\n};\n\ntemplate<typename MatrixLType, typename MatrixUType>\nstruct SparseLUMatrixUReturnType : internal::no_assignment_operator\n{\n  typedef typename MatrixLType::Scalar Scalar;\n  SparseLUMatrixUReturnType(const MatrixLType& mapL, const MatrixUType& mapU)\n  : m_mapL(mapL),m_mapU(mapU)\n  { }\n  Index rows() { return m_mapL.rows(); }\n  Index cols() { return m_mapL.cols(); }\n\n  template<typename Dest>   void solveInPlace(MatrixBase<Dest> &X) const\n  {\n    Index nrhs = X.cols();\n    Index n    = X.rows();\n    // Backward solve with U\n    for (Index k = m_mapL.nsuper(); k >= 0; k--)\n    {\n      Index fsupc = m_mapL.supToCol()[k];\n      Index lda = m_mapL.colIndexPtr()[fsupc+1] - m_mapL.colIndexPtr()[fsupc]; // leading dimension\n      Index nsupc = m_mapL.supToCol()[k+1] - fsupc;\n      Index luptr = m_mapL.colIndexPtr()[fsupc];\n\n      if (nsupc == 1)\n      {\n        for (Index j = 0; j < nrhs; j++)\n        {\n          X(fsupc, j) /= m_mapL.valuePtr()[luptr];\n        }\n      }\n      else\n      {\n        Map<const Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > A( &(m_mapL.valuePtr()[luptr]), nsupc, nsupc, OuterStride<>(lda) );\n        Map< Matrix<Scalar,Dynamic,Dest::ColsAtCompileTime, ColMajor>, 0, OuterStride<> > U (&(X(fsupc,0)), nsupc, nrhs, OuterStride<>(n) );\n        U = A.template triangularView<Upper>().solve(U);\n      }\n\n      for (Index j = 0; j < nrhs; ++j)\n      {\n        for (Index jcol = fsupc; jcol < fsupc + nsupc; jcol++)\n        {\n          typename MatrixUType::InnerIterator it(m_mapU, jcol);\n          for ( ; it; ++it)\n          {\n            Index irow = it.index();\n            X(irow, j) -= X(jcol, j) * it.value();\n          }\n        }\n      }\n    } // End For U-solve\n  }\n  const MatrixLType& m_mapL;\n  const MatrixUType& m_mapU;\n};\n\n} // End namespace Eigen \n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLUImpl.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n#ifndef SPARSELU_IMPL_H\n#define SPARSELU_IMPL_H\n\nnamespace Eigen {\nnamespace internal {\n  \n/** \\ingroup SparseLU_Module\n  * \\class SparseLUImpl\n  * Base class for sparseLU\n  */\ntemplate <typename Scalar, typename StorageIndex>\nclass SparseLUImpl\n{\n  public:\n    typedef Matrix<Scalar,Dynamic,1> ScalarVector;\n    typedef Matrix<StorageIndex,Dynamic,1> IndexVector; \n    typedef Matrix<Scalar,Dynamic,Dynamic,ColMajor> ScalarMatrix;\n    typedef Map<ScalarMatrix, 0,  OuterStride<> > MappedMatrixBlock;\n    typedef typename ScalarVector::RealScalar RealScalar; \n    typedef Ref<Matrix<Scalar,Dynamic,1> > BlockScalarVector;\n    typedef Ref<Matrix<StorageIndex,Dynamic,1> > BlockIndexVector;\n    typedef LU_GlobalLU_t<IndexVector, ScalarVector> GlobalLU_t; \n    typedef SparseMatrix<Scalar,ColMajor,StorageIndex> MatrixType; \n    \n  protected:\n     template <typename VectorType>\n     Index expand(VectorType& vec, Index& length, Index nbElts, Index keep_prev, Index& num_expansions);\n     Index memInit(Index m, Index n, Index annz, Index lwork, Index fillratio, Index panel_size,  GlobalLU_t& glu); \n     template <typename VectorType>\n     Index memXpand(VectorType& vec, Index& maxlen, Index nbElts, MemType memtype, Index& num_expansions);\n     void heap_relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end); \n     void relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end); \n     Index snode_dfs(const Index jcol, const Index kcol,const MatrixType& mat,  IndexVector& xprune, IndexVector& marker, GlobalLU_t& glu); \n     Index snode_bmod (const Index jcol, const Index fsupc, ScalarVector& dense, GlobalLU_t& glu);\n     Index pivotL(const Index jcol, const RealScalar& diagpivotthresh, IndexVector& perm_r, IndexVector& iperm_c, Index& pivrow, GlobalLU_t& glu);\n     template <typename Traits>\n     void dfs_kernel(const StorageIndex jj, IndexVector& perm_r,\n                    Index& nseg, IndexVector& panel_lsub, IndexVector& segrep,\n                    Ref<IndexVector> repfnz_col, IndexVector& xprune, Ref<IndexVector> marker, IndexVector& parent,\n                    IndexVector& xplore, GlobalLU_t& glu, Index& nextl_col, Index krow, Traits& traits);\n     void panel_dfs(const Index m, const Index w, const Index jcol, MatrixType& A, IndexVector& perm_r, Index& nseg, ScalarVector& dense, IndexVector& panel_lsub, IndexVector& segrep, IndexVector& repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu);\n    \n     void panel_bmod(const Index m, const Index w, const Index jcol, const Index nseg, ScalarVector& dense, ScalarVector& tempv, IndexVector& segrep, IndexVector& repfnz, GlobalLU_t& glu);\n     Index column_dfs(const Index m, const Index jcol, IndexVector& perm_r, Index maxsuper, Index& nseg,  BlockIndexVector lsub_col, IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu);\n     Index column_bmod(const Index jcol, const Index nseg, BlockScalarVector dense, ScalarVector& tempv, BlockIndexVector segrep, BlockIndexVector repfnz, Index fpanelc, GlobalLU_t& glu); \n     Index copy_to_ucol(const Index jcol, const Index nseg, IndexVector& segrep, BlockIndexVector repfnz ,IndexVector& perm_r, BlockScalarVector dense, GlobalLU_t& glu); \n     void pruneL(const Index jcol, const IndexVector& perm_r, const Index pivrow, const Index nseg, const IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, GlobalLU_t& glu);\n     void countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu); \n     void fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu); \n     \n     template<typename , typename >\n     friend struct column_dfs_traits;\n}; \n\n} // end namespace internal\n} // namespace Eigen\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_Memory.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* \n \n * NOTE: This file is the modified version of [s,d,c,z]memory.c files in SuperLU \n \n * -- SuperLU routine (version 3.1) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * August 1, 2008\n *\n * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n *\n * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n *\n * Permission is hereby granted to use or copy this program for any\n * purpose, provided the above notices are retained on all copies.\n * Permission to modify the code and to distribute modified code is\n * granted, provided the above notices are retained, and a notice that\n * the code was modified is included with the above copyright notice.\n */\n\n#ifndef EIGEN_SPARSELU_MEMORY\n#define EIGEN_SPARSELU_MEMORY\n\nnamespace Eigen {\nnamespace internal {\n  \nenum { LUNoMarker = 3 };\nenum {emptyIdxLU = -1};\ninline Index LUnumTempV(Index& m, Index& w, Index& t, Index& b)\n{\n  return (std::max)(m, (t+b)*w);\n}\n\ntemplate< typename Scalar>\ninline Index LUTempSpace(Index&m, Index& w)\n{\n  return (2*w + 4 + LUNoMarker) * m * sizeof(Index) + (w + 1) * m * sizeof(Scalar);\n}\n\n\n\n\n/** \n  * Expand the existing storage to accomodate more fill-ins\n  * \\param vec Valid pointer to the vector to allocate or expand\n  * \\param[in,out] length  At input, contain the current length of the vector that is to be increased. At output, length of the newly allocated vector\n  * \\param[in] nbElts Current number of elements in the factors\n  * \\param keep_prev  1: use length  and do not expand the vector; 0: compute new_len and expand\n  * \\param[in,out] num_expansions Number of times the memory has been expanded\n  */\ntemplate <typename Scalar, typename StorageIndex>\ntemplate <typename VectorType>\nIndex  SparseLUImpl<Scalar,StorageIndex>::expand(VectorType& vec, Index& length, Index nbElts, Index keep_prev, Index& num_expansions) \n{\n  \n  float alpha = 1.5; // Ratio of the memory increase \n  Index new_len; // New size of the allocated memory\n  \n  if(num_expansions == 0 || keep_prev) \n    new_len = length ; // First time allocate requested\n  else \n    new_len = (std::max)(length+1,Index(alpha * length));\n  \n  VectorType old_vec; // Temporary vector to hold the previous values   \n  if (nbElts > 0 )\n    old_vec = vec.segment(0,nbElts); \n  \n  //Allocate or expand the current vector\n#ifdef EIGEN_EXCEPTIONS\n  try\n#endif\n  {\n    vec.resize(new_len); \n  }\n#ifdef EIGEN_EXCEPTIONS\n  catch(std::bad_alloc& )\n#else\n  if(!vec.size())\n#endif\n  {\n    if (!num_expansions)\n    {\n      // First time to allocate from LUMemInit()\n      // Let LUMemInit() deals with it.\n      return -1;\n    }\n    if (keep_prev)\n    {\n      // In this case, the memory length should not not be reduced\n      return new_len;\n    }\n    else \n    {\n      // Reduce the size and increase again \n      Index tries = 0; // Number of attempts\n      do \n      {\n        alpha = (alpha + 1)/2;\n        new_len = (std::max)(length+1,Index(alpha * length));\n#ifdef EIGEN_EXCEPTIONS\n        try\n#endif\n        {\n          vec.resize(new_len); \n        }\n#ifdef EIGEN_EXCEPTIONS\n        catch(std::bad_alloc& )\n#else\n        if (!vec.size())\n#endif\n        {\n          tries += 1; \n          if ( tries > 10) return new_len; \n        }\n      } while (!vec.size());\n    }\n  }\n  //Copy the previous values to the newly allocated space \n  if (nbElts > 0)\n    vec.segment(0, nbElts) = old_vec;   \n   \n  \n  length  = new_len;\n  if(num_expansions) ++num_expansions;\n  return 0; \n}\n\n/**\n * \\brief  Allocate various working space for the numerical factorization phase.\n * \\param m number of rows of the input matrix \n * \\param n number of columns \n * \\param annz number of initial nonzeros in the matrix \n * \\param lwork  if lwork=-1, this routine returns an estimated size of the required memory\n * \\param glu persistent data to facilitate multiple factors : will be deleted later ??\n * \\param fillratio estimated ratio of fill in the factors\n * \\param panel_size Size of a panel\n * \\return an estimated size of the required memory if lwork = -1; otherwise, return the size of actually allocated memory when allocation failed, and 0 on success\n * \\note Unlike SuperLU, this routine does not support successive factorization with the same pattern and the same row permutation\n */\ntemplate <typename Scalar, typename StorageIndex>\nIndex SparseLUImpl<Scalar,StorageIndex>::memInit(Index m, Index n, Index annz, Index lwork, Index fillratio, Index panel_size,  GlobalLU_t& glu)\n{\n  Index& num_expansions = glu.num_expansions; //No memory expansions so far\n  num_expansions = 0;\n  glu.nzumax = glu.nzlumax = (std::min)(fillratio * (annz+1) / n, m) * n; // estimated number of nonzeros in U \n  glu.nzlmax = (std::max)(Index(4), fillratio) * (annz+1) / 4; // estimated  nnz in L factor\n  // Return the estimated size to the user if necessary\n  Index tempSpace;\n  tempSpace = (2*panel_size + 4 + LUNoMarker) * m * sizeof(Index) + (panel_size + 1) * m * sizeof(Scalar);\n  if (lwork == emptyIdxLU) \n  {\n    Index estimated_size;\n    estimated_size = (5 * n + 5) * sizeof(Index)  + tempSpace\n                    + (glu.nzlmax + glu.nzumax) * sizeof(Index) + (glu.nzlumax+glu.nzumax) *  sizeof(Scalar) + n; \n    return estimated_size;\n  }\n  \n  // Setup the required space \n  \n  // First allocate Integer pointers for L\\U factors\n  glu.xsup.resize(n+1);\n  glu.supno.resize(n+1);\n  glu.xlsub.resize(n+1);\n  glu.xlusup.resize(n+1);\n  glu.xusub.resize(n+1);\n\n  // Reserve memory for L/U factors\n  do \n  {\n    if(     (expand<ScalarVector>(glu.lusup, glu.nzlumax, 0, 0, num_expansions)<0)\n        ||  (expand<ScalarVector>(glu.ucol,  glu.nzumax,  0, 0, num_expansions)<0)\n        ||  (expand<IndexVector> (glu.lsub,  glu.nzlmax,  0, 0, num_expansions)<0)\n        ||  (expand<IndexVector> (glu.usub,  glu.nzumax,  0, 1, num_expansions)<0) )\n    {\n      //Reduce the estimated size and retry\n      glu.nzlumax /= 2;\n      glu.nzumax /= 2;\n      glu.nzlmax /= 2;\n      if (glu.nzlumax < annz ) return glu.nzlumax; \n    }\n  } while (!glu.lusup.size() || !glu.ucol.size() || !glu.lsub.size() || !glu.usub.size());\n  \n  ++num_expansions;\n  return 0;\n  \n} // end LuMemInit\n\n/** \n * \\brief Expand the existing storage \n * \\param vec vector to expand \n * \\param[in,out] maxlen On input, previous size of vec (Number of elements to copy ). on output, new size\n * \\param nbElts current number of elements in the vector.\n * \\param memtype Type of the element to expand\n * \\param num_expansions Number of expansions \n * \\return 0 on success, > 0 size of the memory allocated so far\n */\ntemplate <typename Scalar, typename StorageIndex>\ntemplate <typename VectorType>\nIndex SparseLUImpl<Scalar,StorageIndex>::memXpand(VectorType& vec, Index& maxlen, Index nbElts, MemType memtype, Index& num_expansions)\n{\n  Index failed_size; \n  if (memtype == USUB)\n     failed_size = this->expand<VectorType>(vec, maxlen, nbElts, 1, num_expansions);\n  else\n    failed_size = this->expand<VectorType>(vec, maxlen, nbElts, 0, num_expansions);\n\n  if (failed_size)\n    return failed_size; \n  \n  return 0 ;  \n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n#endif // EIGEN_SPARSELU_MEMORY\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_Structs.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* \n * NOTE: This file comes from a partly modified version of files slu_[s,d,c,z]defs.h\n * -- SuperLU routine (version 4.1) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * November, 2010\n * \n * Global data structures used in LU factorization -\n * \n *   nsuper: #supernodes = nsuper + 1, numbered [0, nsuper].\n *   (xsup,supno): supno[i] is the supernode no to which i belongs;\n *  xsup(s) points to the beginning of the s-th supernode.\n *  e.g.   supno 0 1 2 2 3 3 3 4 4 4 4 4   (n=12)\n *          xsup 0 1 2 4 7 12\n *  Note: dfs will be performed on supernode rep. relative to the new \n *        row pivoting ordering\n *\n *   (xlsub,lsub): lsub[*] contains the compressed subscript of\n *  rectangular supernodes; xlsub[j] points to the starting\n *  location of the j-th column in lsub[*]. Note that xlsub \n *  is indexed by column.\n *  Storage: original row subscripts\n *\n *      During the course of sparse LU factorization, we also use\n *  (xlsub,lsub) for the purpose of symmetric pruning. For each\n *  supernode {s,s+1,...,t=s+r} with first column s and last\n *  column t, the subscript set\n *    lsub[j], j=xlsub[s], .., xlsub[s+1]-1\n *  is the structure of column s (i.e. structure of this supernode).\n *  It is used for the storage of numerical values.\n *  Furthermore,\n *    lsub[j], j=xlsub[t], .., xlsub[t+1]-1\n *  is the structure of the last column t of this supernode.\n *  It is for the purpose of symmetric pruning. Therefore, the\n *  structural subscripts can be rearranged without making physical\n *  interchanges among the numerical values.\n *\n *  However, if the supernode has only one column, then we\n *  only keep one set of subscripts. For any subscript interchange\n *  performed, similar interchange must be done on the numerical\n *  values.\n *\n *  The last column structures (for pruning) will be removed\n *  after the numercial LU factorization phase.\n *\n *   (xlusup,lusup): lusup[*] contains the numerical values of the\n *  rectangular supernodes; xlusup[j] points to the starting\n *  location of the j-th column in storage vector lusup[*]\n *  Note: xlusup is indexed by column.\n *  Each rectangular supernode is stored by column-major\n *  scheme, consistent with Fortran 2-dim array storage.\n *\n *   (xusub,ucol,usub): ucol[*] stores the numerical values of\n *  U-columns outside the rectangular supernodes. The row\n *  subscript of nonzero ucol[k] is stored in usub[k].\n *  xusub[i] points to the starting location of column i in ucol.\n *  Storage: new row subscripts; that is subscripts of PA.\n */\n\n#ifndef EIGEN_LU_STRUCTS\n#define EIGEN_LU_STRUCTS\nnamespace Eigen {\nnamespace internal {\n  \ntypedef enum {LUSUP, UCOL, LSUB, USUB, LLVL, ULVL} MemType; \n\ntemplate <typename IndexVector, typename ScalarVector>\nstruct LU_GlobalLU_t {\n  typedef typename IndexVector::Scalar StorageIndex; \n  IndexVector xsup; //First supernode column ... xsup(s) points to the beginning of the s-th supernode\n  IndexVector supno; // Supernode number corresponding to this column (column to supernode mapping)\n  ScalarVector  lusup; // nonzero values of L ordered by columns \n  IndexVector lsub; // Compressed row indices of L rectangular supernodes. \n  IndexVector xlusup; // pointers to the beginning of each column in lusup\n  IndexVector xlsub; // pointers to the beginning of each column in lsub\n  Index   nzlmax; // Current max size of lsub\n  Index   nzlumax; // Current max size of lusup\n  ScalarVector  ucol; // nonzero values of U ordered by columns \n  IndexVector usub; // row indices of U columns in ucol\n  IndexVector xusub; // Pointers to the beginning of each column of U in ucol \n  Index   nzumax; // Current max size of ucol\n  Index   n; // Number of columns in the matrix  \n  Index   num_expansions; \n};\n\n// Values to set for performance\nstruct perfvalues {\n  Index panel_size; // a panel consists of at most <panel_size> consecutive columns\n  Index relax; // To control degree of relaxing supernodes. If the number of nodes (columns) \n                // in a subtree of the elimination tree is less than relax, this subtree is considered \n                // as one supernode regardless of the row structures of those columns\n  Index maxsuper; // The maximum size for a supernode in complete LU\n  Index rowblk; // The minimum row dimension for 2-D blocking to be used;\n  Index colblk; // The minimum column dimension for 2-D blocking to be used;\n  Index fillfactor; // The estimated fills factors for L and U, compared with A\n}; \n\n} // end namespace internal\n\n} // end namespace Eigen\n#endif // EIGEN_LU_STRUCTS\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n// Copyright (C) 2012 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSELU_SUPERNODAL_MATRIX_H\n#define EIGEN_SPARSELU_SUPERNODAL_MATRIX_H\n\nnamespace Eigen {\nnamespace internal {\n\n/** \\ingroup SparseLU_Module\n * \\brief a class to manipulate the L supernodal factor from the SparseLU factorization\n * \n * This class  contain the data to easily store \n * and manipulate the supernodes during the factorization and solution phase of Sparse LU. \n * Only the lower triangular matrix has supernodes.\n * \n * NOTE : This class corresponds to the SCformat structure in SuperLU\n * \n */\n/* TODO\n * InnerIterator as for sparsematrix \n * SuperInnerIterator to iterate through all supernodes \n * Function for triangular solve\n */\ntemplate <typename _Scalar, typename _StorageIndex>\nclass MappedSuperNodalMatrix\n{\n  public:\n    typedef _Scalar Scalar; \n    typedef _StorageIndex StorageIndex;\n    typedef Matrix<StorageIndex,Dynamic,1> IndexVector;\n    typedef Matrix<Scalar,Dynamic,1> ScalarVector;\n  public:\n    MappedSuperNodalMatrix()\n    {\n      \n    }\n    MappedSuperNodalMatrix(Index m, Index n,  ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind,\n             IndexVector& rowind_colptr, IndexVector& col_to_sup, IndexVector& sup_to_col )\n    {\n      setInfos(m, n, nzval, nzval_colptr, rowind, rowind_colptr, col_to_sup, sup_to_col);\n    }\n    \n    ~MappedSuperNodalMatrix()\n    {\n      \n    }\n    /**\n     * Set appropriate pointers for the lower triangular supernodal matrix\n     * These infos are available at the end of the numerical factorization\n     * FIXME This class will be modified such that it can be use in the course \n     * of the factorization.\n     */\n    void setInfos(Index m, Index n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind,\n             IndexVector& rowind_colptr, IndexVector& col_to_sup, IndexVector& sup_to_col )\n    {\n      m_row = m;\n      m_col = n; \n      m_nzval = nzval.data(); \n      m_nzval_colptr = nzval_colptr.data(); \n      m_rowind = rowind.data(); \n      m_rowind_colptr = rowind_colptr.data(); \n      m_nsuper = col_to_sup(n); \n      m_col_to_sup = col_to_sup.data(); \n      m_sup_to_col = sup_to_col.data(); \n    }\n    \n    /**\n     * Number of rows\n     */\n    Index rows() { return m_row; }\n    \n    /**\n     * Number of columns\n     */\n    Index cols() { return m_col; }\n    \n    /**\n     * Return the array of nonzero values packed by column\n     * \n     * The size is nnz\n     */\n    Scalar* valuePtr() {  return m_nzval; }\n    \n    const Scalar* valuePtr() const \n    {\n      return m_nzval; \n    }\n    /**\n     * Return the pointers to the beginning of each column in \\ref valuePtr()\n     */\n    StorageIndex* colIndexPtr()\n    {\n      return m_nzval_colptr; \n    }\n    \n    const StorageIndex* colIndexPtr() const\n    {\n      return m_nzval_colptr; \n    }\n    \n    /**\n     * Return the array of compressed row indices of all supernodes\n     */\n    StorageIndex* rowIndex()  { return m_rowind; }\n    \n    const StorageIndex* rowIndex() const\n    {\n      return m_rowind; \n    }\n    \n    /**\n     * Return the location in \\em rowvaluePtr() which starts each column\n     */\n    StorageIndex* rowIndexPtr() { return m_rowind_colptr; }\n    \n    const StorageIndex* rowIndexPtr() const\n    {\n      return m_rowind_colptr; \n    }\n    \n    /** \n     * Return the array of column-to-supernode mapping \n     */\n    StorageIndex* colToSup()  { return m_col_to_sup; }\n    \n    const StorageIndex* colToSup() const\n    {\n      return m_col_to_sup;       \n    }\n    /**\n     * Return the array of supernode-to-column mapping\n     */\n    StorageIndex* supToCol() { return m_sup_to_col; }\n    \n    const StorageIndex* supToCol() const\n    {\n      return m_sup_to_col;\n    }\n    \n    /**\n     * Return the number of supernodes\n     */\n    Index nsuper() const\n    {\n      return m_nsuper; \n    }\n    \n    class InnerIterator; \n    template<typename Dest>\n    void solveInPlace( MatrixBase<Dest>&X) const;\n    \n      \n      \n    \n  protected:\n    Index m_row; // Number of rows\n    Index m_col; // Number of columns\n    Index m_nsuper; // Number of supernodes\n    Scalar* m_nzval; //array of nonzero values packed by column\n    StorageIndex* m_nzval_colptr; //nzval_colptr[j] Stores the location in nzval[] which starts column j\n    StorageIndex* m_rowind; // Array of compressed row indices of rectangular supernodes\n    StorageIndex* m_rowind_colptr; //rowind_colptr[j] stores the location in rowind[] which starts column j\n    StorageIndex* m_col_to_sup; // col_to_sup[j] is the supernode number to which column j belongs\n    StorageIndex* m_sup_to_col; //sup_to_col[s] points to the starting column of the s-th supernode\n    \n  private :\n};\n\n/**\n  * \\brief InnerIterator class to iterate over nonzero values of the current column in the supernodal matrix L\n  * \n  */\ntemplate<typename Scalar, typename StorageIndex>\nclass MappedSuperNodalMatrix<Scalar,StorageIndex>::InnerIterator\n{\n  public:\n     InnerIterator(const MappedSuperNodalMatrix& mat, Index outer)\n      : m_matrix(mat),\n        m_outer(outer),\n        m_supno(mat.colToSup()[outer]),\n        m_idval(mat.colIndexPtr()[outer]),\n        m_startidval(m_idval),\n        m_endidval(mat.colIndexPtr()[outer+1]),\n        m_idrow(mat.rowIndexPtr()[mat.supToCol()[mat.colToSup()[outer]]]),\n        m_endidrow(mat.rowIndexPtr()[mat.supToCol()[mat.colToSup()[outer]]+1])\n    {}\n    inline InnerIterator& operator++()\n    { \n      m_idval++; \n      m_idrow++;\n      return *this;\n    }\n    inline Scalar value() const { return m_matrix.valuePtr()[m_idval]; }\n    \n    inline Scalar& valueRef() { return const_cast<Scalar&>(m_matrix.valuePtr()[m_idval]); }\n    \n    inline Index index() const { return m_matrix.rowIndex()[m_idrow]; }\n    inline Index row() const { return index(); }\n    inline Index col() const { return m_outer; }\n    \n    inline Index supIndex() const { return m_supno; }\n    \n    inline operator bool() const \n    { \n      return ( (m_idval < m_endidval) && (m_idval >= m_startidval)\n                && (m_idrow < m_endidrow) );\n    }\n    \n  protected:\n    const MappedSuperNodalMatrix& m_matrix; // Supernodal lower triangular matrix \n    const Index m_outer;                    // Current column \n    const Index m_supno;                    // Current SuperNode number\n    Index m_idval;                          // Index to browse the values in the current column\n    const Index m_startidval;               // Start of the column value\n    const Index m_endidval;                 // End of the column value\n    Index m_idrow;                          // Index to browse the row indices \n    Index m_endidrow;                       // End index of row indices of the current column\n};\n\n/**\n * \\brief Solve with the supernode triangular matrix\n * \n */\ntemplate<typename Scalar, typename Index_>\ntemplate<typename Dest>\nvoid MappedSuperNodalMatrix<Scalar,Index_>::solveInPlace( MatrixBase<Dest>&X) const\n{\n    /* Explicit type conversion as the Index type of MatrixBase<Dest> may be wider than Index */\n//    eigen_assert(X.rows() <= NumTraits<Index>::highest());\n//    eigen_assert(X.cols() <= NumTraits<Index>::highest());\n    Index n    = int(X.rows());\n    Index nrhs = Index(X.cols());\n    const Scalar * Lval = valuePtr();                 // Nonzero values \n    Matrix<Scalar,Dynamic,Dest::ColsAtCompileTime, ColMajor> work(n, nrhs);     // working vector\n    work.setZero();\n    for (Index k = 0; k <= nsuper(); k ++)\n    {\n      Index fsupc = supToCol()[k];                    // First column of the current supernode \n      Index istart = rowIndexPtr()[fsupc];            // Pointer index to the subscript of the current column\n      Index nsupr = rowIndexPtr()[fsupc+1] - istart;  // Number of rows in the current supernode\n      Index nsupc = supToCol()[k+1] - fsupc;          // Number of columns in the current supernode\n      Index nrow = nsupr - nsupc;                     // Number of rows in the non-diagonal part of the supernode\n      Index irow;                                     //Current index row\n      \n      if (nsupc == 1 )\n      {\n        for (Index j = 0; j < nrhs; j++)\n        {\n          InnerIterator it(*this, fsupc);\n          ++it; // Skip the diagonal element\n          for (; it; ++it)\n          {\n            irow = it.row();\n            X(irow, j) -= X(fsupc, j) * it.value();\n          }\n        }\n      }\n      else\n      {\n        // The supernode has more than one column \n        Index luptr = colIndexPtr()[fsupc]; \n        Index lda = colIndexPtr()[fsupc+1] - luptr;\n        \n        // Triangular solve \n        Map<const Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > A( &(Lval[luptr]), nsupc, nsupc, OuterStride<>(lda) );\n        Map< Matrix<Scalar,Dynamic,Dest::ColsAtCompileTime, ColMajor>, 0, OuterStride<> > U (&(X(fsupc,0)), nsupc, nrhs, OuterStride<>(n) );\n        U = A.template triangularView<UnitLower>().solve(U); \n        \n        // Matrix-vector product \n        new (&A) Map<const Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > ( &(Lval[luptr+nsupc]), nrow, nsupc, OuterStride<>(lda) );\n        work.topRows(nrow).noalias() = A * U;\n        \n        //Begin Scatter \n        for (Index j = 0; j < nrhs; j++)\n        {\n          Index iptr = istart + nsupc; \n          for (Index i = 0; i < nrow; i++)\n          {\n            irow = rowIndex()[iptr]; \n            X(irow, j) -= work(i, j); // Scatter operation\n            work(i, j) = Scalar(0); \n            iptr++;\n          }\n        }\n      }\n    } \n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_SPARSELU_MATRIX_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_Utils.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n\n#ifndef EIGEN_SPARSELU_UTILS_H\n#define EIGEN_SPARSELU_UTILS_H\n\nnamespace Eigen {\nnamespace internal {\n\n/**\n * \\brief Count Nonzero elements in the factors\n */\ntemplate <typename Scalar, typename StorageIndex>\nvoid SparseLUImpl<Scalar,StorageIndex>::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu)\n{\n nnzL = 0; \n nnzU = (glu.xusub)(n); \n Index nsuper = (glu.supno)(n); \n Index jlen; \n Index i, j, fsupc;\n if (n <= 0 ) return; \n // For each supernode\n for (i = 0; i <= nsuper; i++)\n {\n   fsupc = glu.xsup(i); \n   jlen = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); \n   \n   for (j = fsupc; j < glu.xsup(i+1); j++)\n   {\n     nnzL += jlen; \n     nnzU += j - fsupc + 1; \n     jlen--; \n   }\n }\n}\n\n/**\n * \\brief Fix up the data storage lsub for L-subscripts. \n * \n * It removes the subscripts sets for structural pruning, \n * and applies permutation to the remaining subscripts\n * \n */\ntemplate <typename Scalar, typename StorageIndex>\nvoid SparseLUImpl<Scalar,StorageIndex>::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu)\n{\n  Index fsupc, i, j, k, jstart; \n  \n  StorageIndex nextl = 0; \n  Index nsuper = (glu.supno)(n); \n  \n  // For each supernode \n  for (i = 0; i <= nsuper; i++)\n  {\n    fsupc = glu.xsup(i); \n    jstart = glu.xlsub(fsupc); \n    glu.xlsub(fsupc) = nextl; \n    for (j = jstart; j < glu.xlsub(fsupc + 1); j++)\n    {\n      glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A\n      nextl++;\n    }\n    for (k = fsupc+1; k < glu.xsup(i+1); k++)\n      glu.xlsub(k) = nextl; // other columns in supernode i\n  }\n  \n  glu.xlsub(n) = nextl; \n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n#endif // EIGEN_SPARSELU_UTILS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_column_bmod.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n// Copyright (C) 2012 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* \n \n * NOTE: This file is the modified version of xcolumn_bmod.c file in SuperLU \n \n * -- SuperLU routine (version 3.0) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * October 15, 2003\n *\n * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n *\n * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n *\n * Permission is hereby granted to use or copy this program for any\n * purpose, provided the above notices are retained on all copies.\n * Permission to modify the code and to distribute modified code is\n * granted, provided the above notices are retained, and a notice that\n * the code was modified is included with the above copyright notice.\n */\n#ifndef SPARSELU_COLUMN_BMOD_H\n#define SPARSELU_COLUMN_BMOD_H\n\nnamespace Eigen {\n\nnamespace internal {\n/**\n * \\brief Performs numeric block updates (sup-col) in topological order\n * \n * \\param jcol current column to update\n * \\param nseg Number of segments in the U part\n * \\param dense Store the full representation of the column\n * \\param tempv working array \n * \\param segrep segment representative ...\n * \\param repfnz ??? First nonzero column in each row ???  ...\n * \\param fpanelc First column in the current panel\n * \\param glu Global LU data. \n * \\return 0 - successful return \n *         > 0 - number of bytes allocated when run out of space\n * \n */\ntemplate <typename Scalar, typename StorageIndex>\nIndex SparseLUImpl<Scalar,StorageIndex>::column_bmod(const Index jcol, const Index nseg, BlockScalarVector dense, ScalarVector& tempv,\n                                                     BlockIndexVector segrep, BlockIndexVector repfnz, Index fpanelc, GlobalLU_t& glu)\n{\n  Index  jsupno, k, ksub, krep, ksupno; \n  Index lptr, nrow, isub, irow, nextlu, new_next, ufirst; \n  Index fsupc, nsupc, nsupr, luptr, kfnz, no_zeros; \n  /* krep = representative of current k-th supernode\n    * fsupc =  first supernodal column\n    * nsupc = number of columns in a supernode\n    * nsupr = number of rows in a supernode\n    * luptr = location of supernodal LU-block in storage\n    * kfnz = first nonz in the k-th supernodal segment\n    * no_zeros = no lf leading zeros in a supernodal U-segment\n    */\n  \n  jsupno = glu.supno(jcol);\n  // For each nonzero supernode segment of U[*,j] in topological order \n  k = nseg - 1; \n  Index d_fsupc; // distance between the first column of the current panel and the \n               // first column of the current snode\n  Index fst_col; // First column within small LU update\n  Index segsize; \n  for (ksub = 0; ksub < nseg; ksub++)\n  {\n    krep = segrep(k); k--; \n    ksupno = glu.supno(krep); \n    if (jsupno != ksupno )\n    {\n      // outside the rectangular supernode \n      fsupc = glu.xsup(ksupno); \n      fst_col = (std::max)(fsupc, fpanelc); \n      \n      // Distance from the current supernode to the current panel; \n      // d_fsupc = 0 if fsupc > fpanelc\n      d_fsupc = fst_col - fsupc; \n      \n      luptr = glu.xlusup(fst_col) + d_fsupc; \n      lptr = glu.xlsub(fsupc) + d_fsupc; \n      \n      kfnz = repfnz(krep); \n      kfnz = (std::max)(kfnz, fpanelc); \n      \n      segsize = krep - kfnz + 1; \n      nsupc = krep - fst_col + 1; \n      nsupr = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); \n      nrow = nsupr - d_fsupc - nsupc;\n      Index lda = glu.xlusup(fst_col+1) - glu.xlusup(fst_col);\n      \n      \n      // Perform a triangular solver and block update, \n      // then scatter the result of sup-col update to dense\n      no_zeros = kfnz - fst_col; \n      if(segsize==1)\n        LU_kernel_bmod<1>::run(segsize, dense, tempv, glu.lusup, luptr, lda, nrow, glu.lsub, lptr, no_zeros);\n      else\n        LU_kernel_bmod<Dynamic>::run(segsize, dense, tempv, glu.lusup, luptr, lda, nrow, glu.lsub, lptr, no_zeros);\n    } // end if jsupno \n  } // end for each segment\n  \n  // Process the supernodal portion of  L\\U[*,j]\n  nextlu = glu.xlusup(jcol); \n  fsupc = glu.xsup(jsupno);\n  \n  // copy the SPA dense into L\\U[*,j]\n  Index mem; \n  new_next = nextlu + glu.xlsub(fsupc + 1) - glu.xlsub(fsupc); \n  Index offset = internal::first_multiple<Index>(new_next, internal::packet_traits<Scalar>::size) - new_next;\n  if(offset)\n    new_next += offset;\n  while (new_next > glu.nzlumax )\n  {\n    mem = memXpand<ScalarVector>(glu.lusup, glu.nzlumax, nextlu, LUSUP, glu.num_expansions);  \n    if (mem) return mem; \n  }\n  \n  for (isub = glu.xlsub(fsupc); isub < glu.xlsub(fsupc+1); isub++)\n  {\n    irow = glu.lsub(isub);\n    glu.lusup(nextlu) = dense(irow);\n    dense(irow) = Scalar(0.0); \n    ++nextlu; \n  }\n  \n  if(offset)\n  {\n    glu.lusup.segment(nextlu,offset).setZero();\n    nextlu += offset;\n  }\n  glu.xlusup(jcol + 1) = StorageIndex(nextlu);  // close L\\U(*,jcol); \n  \n  /* For more updates within the panel (also within the current supernode),\n   * should start from the first column of the panel, or the first column\n   * of the supernode, whichever is bigger. There are two cases:\n   *  1) fsupc < fpanelc, then fst_col <-- fpanelc\n   *  2) fsupc >= fpanelc, then fst_col <-- fsupc\n   */\n  fst_col = (std::max)(fsupc, fpanelc); \n  \n  if (fst_col  < jcol)\n  {\n    // Distance between the current supernode and the current panel\n    // d_fsupc = 0 if fsupc >= fpanelc\n    d_fsupc = fst_col - fsupc; \n    \n    lptr = glu.xlsub(fsupc) + d_fsupc; \n    luptr = glu.xlusup(fst_col) + d_fsupc; \n    nsupr = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); // leading dimension\n    nsupc = jcol - fst_col; // excluding jcol \n    nrow = nsupr - d_fsupc - nsupc; \n    \n    // points to the beginning of jcol in snode L\\U(jsupno) \n    ufirst = glu.xlusup(jcol) + d_fsupc; \n    Index lda = glu.xlusup(jcol+1) - glu.xlusup(jcol);\n    MappedMatrixBlock A( &(glu.lusup.data()[luptr]), nsupc, nsupc, OuterStride<>(lda) );\n    VectorBlock<ScalarVector> u(glu.lusup, ufirst, nsupc); \n    u = A.template triangularView<UnitLower>().solve(u); \n    \n    new (&A) MappedMatrixBlock ( &(glu.lusup.data()[luptr+nsupc]), nrow, nsupc, OuterStride<>(lda) );\n    VectorBlock<ScalarVector> l(glu.lusup, ufirst+nsupc, nrow); \n    l.noalias() -= A * u;\n    \n  } // End if fst_col\n  return 0; \n}\n\n} // end namespace internal\n} // end namespace Eigen\n\n#endif // SPARSELU_COLUMN_BMOD_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_column_dfs.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* \n \n * NOTE: This file is the modified version of [s,d,c,z]column_dfs.c file in SuperLU \n \n * -- SuperLU routine (version 2.0) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * November 15, 1997\n *\n * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n *\n * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n *\n * Permission is hereby granted to use or copy this program for any\n * purpose, provided the above notices are retained on all copies.\n * Permission to modify the code and to distribute modified code is\n * granted, provided the above notices are retained, and a notice that\n * the code was modified is included with the above copyright notice.\n */\n#ifndef SPARSELU_COLUMN_DFS_H\n#define SPARSELU_COLUMN_DFS_H\n\ntemplate <typename Scalar, typename StorageIndex> class SparseLUImpl;\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<typename IndexVector, typename ScalarVector>\nstruct column_dfs_traits : no_assignment_operator\n{\n  typedef typename ScalarVector::Scalar Scalar;\n  typedef typename IndexVector::Scalar StorageIndex;\n  column_dfs_traits(Index jcol, Index& jsuper, typename SparseLUImpl<Scalar, StorageIndex>::GlobalLU_t& glu, SparseLUImpl<Scalar, StorageIndex>& luImpl)\n   : m_jcol(jcol), m_jsuper_ref(jsuper), m_glu(glu), m_luImpl(luImpl)\n {}\n  bool update_segrep(Index /*krep*/, Index /*jj*/)\n  {\n    return true;\n  }\n  void mem_expand(IndexVector& lsub, Index& nextl, Index chmark)\n  {\n    if (nextl >= m_glu.nzlmax)\n      m_luImpl.memXpand(lsub, m_glu.nzlmax, nextl, LSUB, m_glu.num_expansions); \n    if (chmark != (m_jcol-1)) m_jsuper_ref = emptyIdxLU;\n  }\n  enum { ExpandMem = true };\n  \n  Index m_jcol;\n  Index& m_jsuper_ref;\n  typename SparseLUImpl<Scalar, StorageIndex>::GlobalLU_t& m_glu;\n  SparseLUImpl<Scalar, StorageIndex>& m_luImpl;\n};\n\n\n/**\n * \\brief Performs a symbolic factorization on column jcol and decide the supernode boundary\n * \n * A supernode representative is the last column of a supernode.\n * The nonzeros in U[*,j] are segments that end at supernodes representatives. \n * The routine returns a list of the supernodal representatives \n * in topological order of the dfs that generates them. \n * The location of the first nonzero in each supernodal segment \n * (supernodal entry location) is also returned. \n * \n * \\param m number of rows in the matrix\n * \\param jcol Current column \n * \\param perm_r Row permutation\n * \\param maxsuper  Maximum number of column allowed in a supernode\n * \\param [in,out] nseg Number of segments in current U[*,j] - new segments appended\n * \\param lsub_col defines the rhs vector to start the dfs\n * \\param [in,out] segrep Segment representatives - new segments appended \n * \\param repfnz  First nonzero location in each row\n * \\param xprune \n * \\param marker  marker[i] == jj, if i was visited during dfs of current column jj;\n * \\param parent\n * \\param xplore working array\n * \\param glu global LU data \n * \\return 0 success\n *         > 0 number of bytes allocated when run out of space\n * \n */\ntemplate <typename Scalar, typename StorageIndex>\nIndex SparseLUImpl<Scalar,StorageIndex>::column_dfs(const Index m, const Index jcol, IndexVector& perm_r, Index maxsuper, Index& nseg,\n                                                    BlockIndexVector lsub_col, IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune,\n                                                    IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu)\n{\n  \n  Index jsuper = glu.supno(jcol); \n  Index nextl = glu.xlsub(jcol); \n  VectorBlock<IndexVector> marker2(marker, 2*m, m); \n  \n  \n  column_dfs_traits<IndexVector, ScalarVector> traits(jcol, jsuper, glu, *this);\n  \n  // For each nonzero in A(*,jcol) do dfs \n  for (Index k = 0; ((k < m) ? lsub_col[k] != emptyIdxLU : false) ; k++)\n  {\n    Index krow = lsub_col(k); \n    lsub_col(k) = emptyIdxLU; \n    Index kmark = marker2(krow); \n    \n    // krow was visited before, go to the next nonz; \n    if (kmark == jcol) continue;\n    \n    dfs_kernel(StorageIndex(jcol), perm_r, nseg, glu.lsub, segrep, repfnz, xprune, marker2, parent,\n                   xplore, glu, nextl, krow, traits);\n  } // for each nonzero ... \n  \n  Index fsupc;\n  StorageIndex nsuper = glu.supno(jcol);\n  StorageIndex jcolp1 = StorageIndex(jcol) + 1;\n  Index jcolm1 = jcol - 1;\n  \n  // check to see if j belongs in the same supernode as j-1\n  if ( jcol == 0 )\n  { // Do nothing for column 0 \n    nsuper = glu.supno(0) = 0 ;\n  }\n  else \n  {\n    fsupc = glu.xsup(nsuper); \n    StorageIndex jptr = glu.xlsub(jcol); // Not yet compressed\n    StorageIndex jm1ptr = glu.xlsub(jcolm1); \n    \n    // Use supernodes of type T2 : see SuperLU paper\n    if ( (nextl-jptr != jptr-jm1ptr-1) ) jsuper = emptyIdxLU;\n    \n    // Make sure the number of columns in a supernode doesn't\n    // exceed threshold\n    if ( (jcol - fsupc) >= maxsuper) jsuper = emptyIdxLU; \n    \n    /* If jcol starts a new supernode, reclaim storage space in\n     * glu.lsub from previous supernode. Note we only store \n     * the subscript set of the first and last columns of \n     * a supernode. (first for num values, last for pruning)\n     */\n    if (jsuper == emptyIdxLU)\n    { // starts a new supernode \n      if ( (fsupc < jcolm1-1) ) \n      { // >= 3 columns in nsuper\n        StorageIndex ito = glu.xlsub(fsupc+1);\n        glu.xlsub(jcolm1) = ito; \n        StorageIndex istop = ito + jptr - jm1ptr; \n        xprune(jcolm1) = istop; // intialize xprune(jcol-1)\n        glu.xlsub(jcol) = istop; \n        \n        for (StorageIndex ifrom = jm1ptr; ifrom < nextl; ++ifrom, ++ito)\n          glu.lsub(ito) = glu.lsub(ifrom); \n        nextl = ito;  // = istop + length(jcol)\n      }\n      nsuper++; \n      glu.supno(jcol) = nsuper; \n    } // if a new supernode \n  } // end else:  jcol > 0\n  \n  // Tidy up the pointers before exit\n  glu.xsup(nsuper+1) = jcolp1; \n  glu.supno(jcolp1) = nsuper; \n  xprune(jcol) = StorageIndex(nextl);  // Intialize upper bound for pruning\n  glu.xlsub(jcolp1) = StorageIndex(nextl); \n  \n  return 0; \n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n/* \n \n * NOTE: This file is the modified version of [s,d,c,z]copy_to_ucol.c file in SuperLU \n \n * -- SuperLU routine (version 2.0) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * November 15, 1997\n *\n * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n *\n * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n *\n * Permission is hereby granted to use or copy this program for any\n * purpose, provided the above notices are retained on all copies.\n * Permission to modify the code and to distribute modified code is\n * granted, provided the above notices are retained, and a notice that\n * the code was modified is included with the above copyright notice.\n */\n#ifndef SPARSELU_COPY_TO_UCOL_H\n#define SPARSELU_COPY_TO_UCOL_H\n\nnamespace Eigen {\nnamespace internal {\n\n/**\n * \\brief Performs numeric block updates (sup-col) in topological order\n * \n * \\param jcol current column to update\n * \\param nseg Number of segments in the U part\n * \\param segrep segment representative ...\n * \\param repfnz First nonzero column in each row  ...\n * \\param perm_r Row permutation \n * \\param dense Store the full representation of the column\n * \\param glu Global LU data. \n * \\return 0 - successful return \n *         > 0 - number of bytes allocated when run out of space\n * \n */\ntemplate <typename Scalar, typename StorageIndex>\nIndex SparseLUImpl<Scalar,StorageIndex>::copy_to_ucol(const Index jcol, const Index nseg, IndexVector& segrep,\n                                                      BlockIndexVector repfnz ,IndexVector& perm_r, BlockScalarVector dense, GlobalLU_t& glu)\n{  \n  Index ksub, krep, ksupno; \n    \n  Index jsupno = glu.supno(jcol);\n  \n  // For each nonzero supernode segment of U[*,j] in topological order \n  Index k = nseg - 1, i; \n  StorageIndex nextu = glu.xusub(jcol); \n  Index kfnz, isub, segsize; \n  Index new_next,irow; \n  Index fsupc, mem; \n  for (ksub = 0; ksub < nseg; ksub++)\n  {\n    krep = segrep(k); k--; \n    ksupno = glu.supno(krep); \n    if (jsupno != ksupno ) // should go into ucol(); \n    {\n      kfnz = repfnz(krep); \n      if (kfnz != emptyIdxLU)\n      { // Nonzero U-segment \n        fsupc = glu.xsup(ksupno); \n        isub = glu.xlsub(fsupc) + kfnz - fsupc; \n        segsize = krep - kfnz + 1; \n        new_next = nextu + segsize; \n        while (new_next > glu.nzumax) \n        {\n          mem = memXpand<ScalarVector>(glu.ucol, glu.nzumax, nextu, UCOL, glu.num_expansions); \n          if (mem) return mem; \n          mem = memXpand<IndexVector>(glu.usub, glu.nzumax, nextu, USUB, glu.num_expansions); \n          if (mem) return mem; \n          \n        }\n        \n        for (i = 0; i < segsize; i++)\n        {\n          irow = glu.lsub(isub); \n          glu.usub(nextu) = perm_r(irow); // Unlike the L part, the U part is stored in its final order\n          glu.ucol(nextu) = dense(irow); \n          dense(irow) = Scalar(0.0); \n          nextu++;\n          isub++;\n        }\n        \n      } // end nonzero U-segment \n      \n    } // end if jsupno \n    \n  } // end for each segment\n  glu.xusub(jcol + 1) = nextu; // close U(*,jcol)\n  return 0; \n}\n\n} // namespace internal\n} // end namespace Eigen\n\n#endif // SPARSELU_COPY_TO_UCOL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_gemm_kernel.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSELU_GEMM_KERNEL_H\n#define EIGEN_SPARSELU_GEMM_KERNEL_H\n\nnamespace Eigen {\n\nnamespace internal {\n\n\n/** \\internal\n  * A general matrix-matrix product kernel optimized for the SparseLU factorization.\n  *  - A, B, and C must be column major\n  *  - lda and ldc must be multiples of the respective packet size\n  *  - C must have the same alignment as A\n  */\ntemplate<typename Scalar>\nEIGEN_DONT_INLINE\nvoid sparselu_gemm(Index m, Index n, Index d, const Scalar* A, Index lda, const Scalar* B, Index ldb, Scalar* C, Index ldc)\n{\n  using namespace Eigen::internal;\n  \n  typedef typename packet_traits<Scalar>::type Packet;\n  enum {\n    NumberOfRegisters = EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS,\n    PacketSize = packet_traits<Scalar>::size,\n    PM = 8,                             // peeling in M\n    RN = 2,                             // register blocking\n    RK = NumberOfRegisters>=16 ? 4 : 2, // register blocking\n    BM = 4096/sizeof(Scalar),           // number of rows of A-C per chunk\n    SM = PM*PacketSize                  // step along M\n  };\n  Index d_end = (d/RK)*RK;    // number of columns of A (rows of B) suitable for full register blocking\n  Index n_end = (n/RN)*RN;    // number of columns of B-C suitable for processing RN columns at once\n  Index i0 = internal::first_default_aligned(A,m);\n  \n  eigen_internal_assert(((lda%PacketSize)==0) && ((ldc%PacketSize)==0) && (i0==internal::first_default_aligned(C,m)));\n  \n  // handle the non aligned rows of A and C without any optimization:\n  for(Index i=0; i<i0; ++i)\n  {\n    for(Index j=0; j<n; ++j)\n    {\n      Scalar c = C[i+j*ldc];\n      for(Index k=0; k<d; ++k)\n        c += B[k+j*ldb] * A[i+k*lda];\n      C[i+j*ldc] = c;\n    }\n  }\n  // process the remaining rows per chunk of BM rows\n  for(Index ib=i0; ib<m; ib+=BM)\n  {\n    Index actual_b = std::min<Index>(BM, m-ib);                 // actual number of rows\n    Index actual_b_end1 = (actual_b/SM)*SM;                   // actual number of rows suitable for peeling\n    Index actual_b_end2 = (actual_b/PacketSize)*PacketSize;   // actual number of rows suitable for vectorization\n    \n    // Let's process two columns of B-C at once\n    for(Index j=0; j<n_end; j+=RN)\n    {\n      const Scalar* Bc0 = B+(j+0)*ldb;\n      const Scalar* Bc1 = B+(j+1)*ldb;\n      \n      for(Index k=0; k<d_end; k+=RK)\n      {\n        \n        // load and expand a RN x RK block of B\n        Packet b00, b10, b20, b30, b01, b11, b21, b31;\n                  { b00 = pset1<Packet>(Bc0[0]); }\n                  { b10 = pset1<Packet>(Bc0[1]); }\n        if(RK==4) { b20 = pset1<Packet>(Bc0[2]); }\n        if(RK==4) { b30 = pset1<Packet>(Bc0[3]); }\n                  { b01 = pset1<Packet>(Bc1[0]); }\n                  { b11 = pset1<Packet>(Bc1[1]); }\n        if(RK==4) { b21 = pset1<Packet>(Bc1[2]); }\n        if(RK==4) { b31 = pset1<Packet>(Bc1[3]); }\n        \n        Packet a0, a1, a2, a3, c0, c1, t0, t1;\n        \n        const Scalar* A0 = A+ib+(k+0)*lda;\n        const Scalar* A1 = A+ib+(k+1)*lda;\n        const Scalar* A2 = A+ib+(k+2)*lda;\n        const Scalar* A3 = A+ib+(k+3)*lda;\n        \n        Scalar* C0 = C+ib+(j+0)*ldc;\n        Scalar* C1 = C+ib+(j+1)*ldc;\n        \n                  a0 = pload<Packet>(A0);\n                  a1 = pload<Packet>(A1);\n        if(RK==4)\n        {\n          a2 = pload<Packet>(A2);\n          a3 = pload<Packet>(A3);\n        }\n        else\n        {\n          // workaround \"may be used uninitialized in this function\" warning\n          a2 = a3 = a0;\n        }\n        \n#define KMADD(c, a, b, tmp) {tmp = b; tmp = pmul(a,tmp); c = padd(c,tmp);}\n#define WORK(I)  \\\n                     c0 = pload<Packet>(C0+i+(I)*PacketSize);    \\\n                     c1 = pload<Packet>(C1+i+(I)*PacketSize);    \\\n                     KMADD(c0, a0, b00, t0)                      \\\n                     KMADD(c1, a0, b01, t1)                      \\\n                     a0 = pload<Packet>(A0+i+(I+1)*PacketSize);  \\\n                     KMADD(c0, a1, b10, t0)                      \\\n                     KMADD(c1, a1, b11, t1)                      \\\n                     a1 = pload<Packet>(A1+i+(I+1)*PacketSize);  \\\n          if(RK==4){ KMADD(c0, a2, b20, t0)                     }\\\n          if(RK==4){ KMADD(c1, a2, b21, t1)                     }\\\n          if(RK==4){ a2 = pload<Packet>(A2+i+(I+1)*PacketSize); }\\\n          if(RK==4){ KMADD(c0, a3, b30, t0)                     }\\\n          if(RK==4){ KMADD(c1, a3, b31, t1)                     }\\\n          if(RK==4){ a3 = pload<Packet>(A3+i+(I+1)*PacketSize); }\\\n                     pstore(C0+i+(I)*PacketSize, c0);            \\\n                     pstore(C1+i+(I)*PacketSize, c1)\n        \n        // process rows of A' - C' with aggressive vectorization and peeling \n        for(Index i=0; i<actual_b_end1; i+=PacketSize*8)\n        {\n          EIGEN_ASM_COMMENT(\"SPARSELU_GEMML_KERNEL1\");\n                    prefetch((A0+i+(5)*PacketSize));\n                    prefetch((A1+i+(5)*PacketSize));\n          if(RK==4) prefetch((A2+i+(5)*PacketSize));\n          if(RK==4) prefetch((A3+i+(5)*PacketSize));\n\n          WORK(0);\n          WORK(1);\n          WORK(2);\n          WORK(3);\n          WORK(4);\n          WORK(5);\n          WORK(6);\n          WORK(7);\n        }\n        // process the remaining rows with vectorization only\n        for(Index i=actual_b_end1; i<actual_b_end2; i+=PacketSize)\n        {\n          WORK(0);\n        }\n#undef WORK\n        // process the remaining rows without vectorization\n        for(Index i=actual_b_end2; i<actual_b; ++i)\n        {\n          if(RK==4)\n          {\n            C0[i] += A0[i]*Bc0[0]+A1[i]*Bc0[1]+A2[i]*Bc0[2]+A3[i]*Bc0[3];\n            C1[i] += A0[i]*Bc1[0]+A1[i]*Bc1[1]+A2[i]*Bc1[2]+A3[i]*Bc1[3];\n          }\n          else\n          {\n            C0[i] += A0[i]*Bc0[0]+A1[i]*Bc0[1];\n            C1[i] += A0[i]*Bc1[0]+A1[i]*Bc1[1];\n          }\n        }\n        \n        Bc0 += RK;\n        Bc1 += RK;\n      } // peeled loop on k\n    } // peeled loop on the columns j\n    // process the last column (we now perform a matrix-vector product)\n    if((n-n_end)>0)\n    {\n      const Scalar* Bc0 = B+(n-1)*ldb;\n      \n      for(Index k=0; k<d_end; k+=RK)\n      {\n        \n        // load and expand a 1 x RK block of B\n        Packet b00, b10, b20, b30;\n                  b00 = pset1<Packet>(Bc0[0]);\n                  b10 = pset1<Packet>(Bc0[1]);\n        if(RK==4) b20 = pset1<Packet>(Bc0[2]);\n        if(RK==4) b30 = pset1<Packet>(Bc0[3]);\n        \n        Packet a0, a1, a2, a3, c0, t0/*, t1*/;\n        \n        const Scalar* A0 = A+ib+(k+0)*lda;\n        const Scalar* A1 = A+ib+(k+1)*lda;\n        const Scalar* A2 = A+ib+(k+2)*lda;\n        const Scalar* A3 = A+ib+(k+3)*lda;\n        \n        Scalar* C0 = C+ib+(n_end)*ldc;\n        \n                  a0 = pload<Packet>(A0);\n                  a1 = pload<Packet>(A1);\n        if(RK==4)\n        {\n          a2 = pload<Packet>(A2);\n          a3 = pload<Packet>(A3);\n        }\n        else\n        {\n          // workaround \"may be used uninitialized in this function\" warning\n          a2 = a3 = a0;\n        }\n        \n#define WORK(I) \\\n                   c0 = pload<Packet>(C0+i+(I)*PacketSize);     \\\n                   KMADD(c0, a0, b00, t0)                       \\\n                   a0 = pload<Packet>(A0+i+(I+1)*PacketSize);   \\\n                   KMADD(c0, a1, b10, t0)                       \\\n                   a1 = pload<Packet>(A1+i+(I+1)*PacketSize);   \\\n        if(RK==4){ KMADD(c0, a2, b20, t0)                      }\\\n        if(RK==4){ a2 = pload<Packet>(A2+i+(I+1)*PacketSize);  }\\\n        if(RK==4){ KMADD(c0, a3, b30, t0)                      }\\\n        if(RK==4){ a3 = pload<Packet>(A3+i+(I+1)*PacketSize);  }\\\n                   pstore(C0+i+(I)*PacketSize, c0);\n        \n        // agressive vectorization and peeling\n        for(Index i=0; i<actual_b_end1; i+=PacketSize*8)\n        {\n          EIGEN_ASM_COMMENT(\"SPARSELU_GEMML_KERNEL2\");\n          WORK(0);\n          WORK(1);\n          WORK(2);\n          WORK(3);\n          WORK(4);\n          WORK(5);\n          WORK(6);\n          WORK(7);\n        }\n        // vectorization only\n        for(Index i=actual_b_end1; i<actual_b_end2; i+=PacketSize)\n        {\n          WORK(0);\n        }\n        // remaining scalars\n        for(Index i=actual_b_end2; i<actual_b; ++i)\n        {\n          if(RK==4) \n            C0[i] += A0[i]*Bc0[0]+A1[i]*Bc0[1]+A2[i]*Bc0[2]+A3[i]*Bc0[3];\n          else\n            C0[i] += A0[i]*Bc0[0]+A1[i]*Bc0[1];\n        }\n        \n        Bc0 += RK;\n#undef WORK\n      }\n    }\n    \n    // process the last columns of A, corresponding to the last rows of B\n    Index rd = d-d_end;\n    if(rd>0)\n    {\n      for(Index j=0; j<n; ++j)\n      {\n        enum {\n          Alignment = PacketSize>1 ? Aligned : 0\n        };\n        typedef Map<Matrix<Scalar,Dynamic,1>, Alignment > MapVector;\n        typedef Map<const Matrix<Scalar,Dynamic,1>, Alignment > ConstMapVector;\n        if(rd==1)       MapVector(C+j*ldc+ib,actual_b) += B[0+d_end+j*ldb] * ConstMapVector(A+(d_end+0)*lda+ib, actual_b);\n        \n        else if(rd==2)  MapVector(C+j*ldc+ib,actual_b) += B[0+d_end+j*ldb] * ConstMapVector(A+(d_end+0)*lda+ib, actual_b)\n                                                        + B[1+d_end+j*ldb] * ConstMapVector(A+(d_end+1)*lda+ib, actual_b);\n        \n        else            MapVector(C+j*ldc+ib,actual_b) += B[0+d_end+j*ldb] * ConstMapVector(A+(d_end+0)*lda+ib, actual_b)\n                                                        + B[1+d_end+j*ldb] * ConstMapVector(A+(d_end+1)*lda+ib, actual_b)\n                                                        + B[2+d_end+j*ldb] * ConstMapVector(A+(d_end+2)*lda+ib, actual_b);\n      }\n    }\n  \n  } // blocking on the rows of A and C\n}\n#undef KMADD\n\n} // namespace internal\n\n} // namespace Eigen\n\n#endif // EIGEN_SPARSELU_GEMM_KERNEL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* This file is a modified version of heap_relax_snode.c file in SuperLU\n * -- SuperLU routine (version 3.0) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * October 15, 2003\n *\n * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n *\n * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n *\n * Permission is hereby granted to use or copy this program for any\n * purpose, provided the above notices are retained on all copies.\n * Permission to modify the code and to distribute modified code is\n * granted, provided the above notices are retained, and a notice that\n * the code was modified is included with the above copyright notice.\n */\n\n#ifndef SPARSELU_HEAP_RELAX_SNODE_H\n#define SPARSELU_HEAP_RELAX_SNODE_H\n\nnamespace Eigen {\nnamespace internal {\n\n/** \n * \\brief Identify the initial relaxed supernodes\n * \n * This routine applied to a symmetric elimination tree. \n * It assumes that the matrix has been reordered according to the postorder of the etree\n * \\param n The number of columns\n * \\param et elimination tree \n * \\param relax_columns Maximum number of columns allowed in a relaxed snode \n * \\param descendants Number of descendants of each node in the etree\n * \\param relax_end last column in a supernode\n */\ntemplate <typename Scalar, typename StorageIndex>\nvoid SparseLUImpl<Scalar,StorageIndex>::heap_relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end)\n{\n  \n  // The etree may not be postordered, but its heap ordered  \n  IndexVector post;\n  internal::treePostorder(StorageIndex(n), et, post); // Post order etree\n  IndexVector inv_post(n+1); \n  for (StorageIndex i = 0; i < n+1; ++i) inv_post(post(i)) = i; // inv_post = post.inverse()???\n  \n  // Renumber etree in postorder \n  IndexVector iwork(n);\n  IndexVector et_save(n+1);\n  for (Index i = 0; i < n; ++i)\n  {\n    iwork(post(i)) = post(et(i));\n  }\n  et_save = et; // Save the original etree\n  et = iwork; \n  \n  // compute the number of descendants of each node in the etree\n  relax_end.setConstant(emptyIdxLU);\n  Index j, parent; \n  descendants.setZero();\n  for (j = 0; j < n; j++) \n  {\n    parent = et(j);\n    if (parent != n) // not the dummy root\n      descendants(parent) += descendants(j) + 1;\n  }\n  // Identify the relaxed supernodes by postorder traversal of the etree\n  Index snode_start; // beginning of a snode \n  StorageIndex k;\n  Index nsuper_et_post = 0; // Number of relaxed snodes in postordered etree \n  Index nsuper_et = 0; // Number of relaxed snodes in the original etree \n  StorageIndex l; \n  for (j = 0; j < n; )\n  {\n    parent = et(j);\n    snode_start = j; \n    while ( parent != n && descendants(parent) < relax_columns ) \n    {\n      j = parent; \n      parent = et(j);\n    }\n    // Found a supernode in postordered etree, j is the last column \n    ++nsuper_et_post;\n    k = StorageIndex(n);\n    for (Index i = snode_start; i <= j; ++i)\n      k = (std::min)(k, inv_post(i));\n    l = inv_post(j);\n    if ( (l - k) == (j - snode_start) )  // Same number of columns in the snode\n    {\n      // This is also a supernode in the original etree\n      relax_end(k) = l; // Record last column \n      ++nsuper_et; \n    }\n    else \n    {\n      for (Index i = snode_start; i <= j; ++i) \n      {\n        l = inv_post(i);\n        if (descendants(i) == 0) \n        {\n          relax_end(l) = l;\n          ++nsuper_et;\n        }\n      }\n    }\n    j++;\n    // Search for a new leaf\n    while (descendants(j) != 0 && j < n) j++;\n  } // End postorder traversal of the etree\n  \n  // Recover the original etree\n  et = et_save; \n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n#endif // SPARSELU_HEAP_RELAX_SNODE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_kernel_bmod.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n// Copyright (C) 2012 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef SPARSELU_KERNEL_BMOD_H\n#define SPARSELU_KERNEL_BMOD_H\n\nnamespace Eigen {\nnamespace internal {\n  \ntemplate <int SegSizeAtCompileTime> struct LU_kernel_bmod\n{\n  /** \\internal\n    * \\brief Performs numeric block updates from a given supernode to a single column\n    *\n    * \\param segsize Size of the segment (and blocks ) to use for updates\n    * \\param[in,out] dense Packed values of the original matrix\n    * \\param tempv temporary vector to use for updates\n    * \\param lusup array containing the supernodes\n    * \\param lda Leading dimension in the supernode\n    * \\param nrow Number of rows in the rectangular part of the supernode\n    * \\param lsub compressed row subscripts of supernodes\n    * \\param lptr pointer to the first column of the current supernode in lsub\n    * \\param no_zeros Number of nonzeros elements before the diagonal part of the supernode\n    */\n  template <typename BlockScalarVector, typename ScalarVector, typename IndexVector>\n  static EIGEN_DONT_INLINE void run(const Index segsize, BlockScalarVector& dense, ScalarVector& tempv, ScalarVector& lusup, Index& luptr, const Index lda,\n                                    const Index nrow, IndexVector& lsub, const Index lptr, const Index no_zeros);\n};\n\ntemplate <int SegSizeAtCompileTime>\ntemplate <typename BlockScalarVector, typename ScalarVector, typename IndexVector>\nEIGEN_DONT_INLINE void LU_kernel_bmod<SegSizeAtCompileTime>::run(const Index segsize, BlockScalarVector& dense, ScalarVector& tempv, ScalarVector& lusup, Index& luptr, const Index lda,\n                                                                  const Index nrow, IndexVector& lsub, const Index lptr, const Index no_zeros)\n{\n  typedef typename ScalarVector::Scalar Scalar;\n  // First, copy U[*,j] segment from dense(*) to tempv(*)\n  // The result of triangular solve is in tempv[*]; \n    // The result of matric-vector update is in dense[*]\n  Index isub = lptr + no_zeros; \n  Index i;\n  Index irow;\n  for (i = 0; i < ((SegSizeAtCompileTime==Dynamic)?segsize:SegSizeAtCompileTime); i++)\n  {\n    irow = lsub(isub); \n    tempv(i) = dense(irow); \n    ++isub; \n  }\n  // Dense triangular solve -- start effective triangle\n  luptr += lda * no_zeros + no_zeros; \n  // Form Eigen matrix and vector \n  Map<Matrix<Scalar,SegSizeAtCompileTime,SegSizeAtCompileTime, ColMajor>, 0, OuterStride<> > A( &(lusup.data()[luptr]), segsize, segsize, OuterStride<>(lda) );\n  Map<Matrix<Scalar,SegSizeAtCompileTime,1> > u(tempv.data(), segsize);\n  \n  u = A.template triangularView<UnitLower>().solve(u); \n  \n  // Dense matrix-vector product y <-- B*x \n  luptr += segsize;\n  const Index PacketSize = internal::packet_traits<Scalar>::size;\n  Index ldl = internal::first_multiple(nrow, PacketSize);\n  Map<Matrix<Scalar,Dynamic,SegSizeAtCompileTime, ColMajor>, 0, OuterStride<> > B( &(lusup.data()[luptr]), nrow, segsize, OuterStride<>(lda) );\n  Index aligned_offset = internal::first_default_aligned(tempv.data()+segsize, PacketSize);\n  Index aligned_with_B_offset = (PacketSize-internal::first_default_aligned(B.data(), PacketSize))%PacketSize;\n  Map<Matrix<Scalar,Dynamic,1>, 0, OuterStride<> > l(tempv.data()+segsize+aligned_offset+aligned_with_B_offset, nrow, OuterStride<>(ldl) );\n  \n  l.setZero();\n  internal::sparselu_gemm<Scalar>(l.rows(), l.cols(), B.cols(), B.data(), B.outerStride(), u.data(), u.outerStride(), l.data(), l.outerStride());\n  \n  // Scatter tempv[] into SPA dense[] as a temporary storage \n  isub = lptr + no_zeros;\n  for (i = 0; i < ((SegSizeAtCompileTime==Dynamic)?segsize:SegSizeAtCompileTime); i++)\n  {\n    irow = lsub(isub++); \n    dense(irow) = tempv(i);\n  }\n  \n  // Scatter l into SPA dense[]\n  for (i = 0; i < nrow; i++)\n  {\n    irow = lsub(isub++); \n    dense(irow) -= l(i);\n  } \n}\n\ntemplate <> struct LU_kernel_bmod<1>\n{\n  template <typename BlockScalarVector, typename ScalarVector, typename IndexVector>\n  static EIGEN_DONT_INLINE void run(const Index /*segsize*/, BlockScalarVector& dense, ScalarVector& /*tempv*/, ScalarVector& lusup, Index& luptr,\n                                    const Index lda, const Index nrow, IndexVector& lsub, const Index lptr, const Index no_zeros);\n};\n\n\ntemplate <typename BlockScalarVector, typename ScalarVector, typename IndexVector>\nEIGEN_DONT_INLINE void LU_kernel_bmod<1>::run(const Index /*segsize*/, BlockScalarVector& dense, ScalarVector& /*tempv*/, ScalarVector& lusup, Index& luptr,\n                                              const Index lda, const Index nrow, IndexVector& lsub, const Index lptr, const Index no_zeros)\n{\n  typedef typename ScalarVector::Scalar Scalar;\n  typedef typename IndexVector::Scalar StorageIndex;\n  Scalar f = dense(lsub(lptr + no_zeros));\n  luptr += lda * no_zeros + no_zeros + 1;\n  const Scalar* a(lusup.data() + luptr);\n  const StorageIndex*  irow(lsub.data()+lptr + no_zeros + 1);\n  Index i = 0;\n  for (; i+1 < nrow; i+=2)\n  {\n    Index i0 = *(irow++);\n    Index i1 = *(irow++);\n    Scalar a0 = *(a++);\n    Scalar a1 = *(a++);\n    Scalar d0 = dense.coeff(i0);\n    Scalar d1 = dense.coeff(i1);\n    d0 -= f*a0;\n    d1 -= f*a1;\n    dense.coeffRef(i0) = d0;\n    dense.coeffRef(i1) = d1;\n  }\n  if(i<nrow)\n    dense.coeffRef(*(irow++)) -= f * *(a++);\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n#endif // SPARSELU_KERNEL_BMOD_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_panel_bmod.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n// Copyright (C) 2012 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* \n \n * NOTE: This file is the modified version of [s,d,c,z]panel_bmod.c file in SuperLU \n \n * -- SuperLU routine (version 3.0) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * October 15, 2003\n *\n * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n *\n * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n *\n * Permission is hereby granted to use or copy this program for any\n * purpose, provided the above notices are retained on all copies.\n * Permission to modify the code and to distribute modified code is\n * granted, provided the above notices are retained, and a notice that\n * the code was modified is included with the above copyright notice.\n */\n#ifndef SPARSELU_PANEL_BMOD_H\n#define SPARSELU_PANEL_BMOD_H\n\nnamespace Eigen {\nnamespace internal {\n\n/**\n * \\brief Performs numeric block updates (sup-panel) in topological order.\n * \n * Before entering this routine, the original nonzeros in the panel\n * were already copied i nto the spa[m,w]\n * \n * \\param m number of rows in the matrix\n * \\param w Panel size\n * \\param jcol Starting  column of the panel\n * \\param nseg Number of segments in the U part\n * \\param dense Store the full representation of the panel \n * \\param tempv working array \n * \\param segrep segment representative... first row in the segment\n * \\param repfnz First nonzero rows\n * \\param glu Global LU data. \n * \n * \n */\ntemplate <typename Scalar, typename StorageIndex>\nvoid SparseLUImpl<Scalar,StorageIndex>::panel_bmod(const Index m, const Index w, const Index jcol, \n                                            const Index nseg, ScalarVector& dense, ScalarVector& tempv,\n                                            IndexVector& segrep, IndexVector& repfnz, GlobalLU_t& glu)\n{\n  \n  Index ksub,jj,nextl_col; \n  Index fsupc, nsupc, nsupr, nrow; \n  Index krep, kfnz; \n  Index lptr; // points to the row subscripts of a supernode \n  Index luptr; // ...\n  Index segsize,no_zeros ; \n  // For each nonz supernode segment of U[*,j] in topological order\n  Index k = nseg - 1; \n  const Index PacketSize = internal::packet_traits<Scalar>::size;\n  \n  for (ksub = 0; ksub < nseg; ksub++)\n  { // For each updating supernode\n    /* krep = representative of current k-th supernode\n     * fsupc =  first supernodal column\n     * nsupc = number of columns in a supernode\n     * nsupr = number of rows in a supernode\n     */\n    krep = segrep(k); k--; \n    fsupc = glu.xsup(glu.supno(krep)); \n    nsupc = krep - fsupc + 1; \n    nsupr = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); \n    nrow = nsupr - nsupc; \n    lptr = glu.xlsub(fsupc); \n    \n    // loop over the panel columns to detect the actual number of columns and rows\n    Index u_rows = 0;\n    Index u_cols = 0;\n    for (jj = jcol; jj < jcol + w; jj++)\n    {\n      nextl_col = (jj-jcol) * m; \n      VectorBlock<IndexVector> repfnz_col(repfnz, nextl_col, m); // First nonzero column index for each row\n      \n      kfnz = repfnz_col(krep); \n      if ( kfnz == emptyIdxLU ) \n        continue; // skip any zero segment\n      \n      segsize = krep - kfnz + 1;\n      u_cols++;\n      u_rows = (std::max)(segsize,u_rows);\n    }\n    \n    if(nsupc >= 2)\n    { \n      Index ldu = internal::first_multiple<Index>(u_rows, PacketSize);\n      Map<ScalarMatrix, Aligned,  OuterStride<> > U(tempv.data(), u_rows, u_cols, OuterStride<>(ldu));\n      \n      // gather U\n      Index u_col = 0;\n      for (jj = jcol; jj < jcol + w; jj++)\n      {\n        nextl_col = (jj-jcol) * m; \n        VectorBlock<IndexVector> repfnz_col(repfnz, nextl_col, m); // First nonzero column index for each row\n        VectorBlock<ScalarVector> dense_col(dense, nextl_col, m); // Scatter/gather entire matrix column from/to here\n        \n        kfnz = repfnz_col(krep); \n        if ( kfnz == emptyIdxLU ) \n          continue; // skip any zero segment\n        \n        segsize = krep - kfnz + 1;\n        luptr = glu.xlusup(fsupc);    \n        no_zeros = kfnz - fsupc; \n        \n        Index isub = lptr + no_zeros;\n        Index off = u_rows-segsize;\n        for (Index i = 0; i < off; i++) U(i,u_col) = 0;\n        for (Index i = 0; i < segsize; i++)\n        {\n          Index irow = glu.lsub(isub); \n          U(i+off,u_col) = dense_col(irow); \n          ++isub; \n        }\n        u_col++;\n      }\n      // solve U = A^-1 U\n      luptr = glu.xlusup(fsupc);\n      Index lda = glu.xlusup(fsupc+1) - glu.xlusup(fsupc);\n      no_zeros = (krep - u_rows + 1) - fsupc;\n      luptr += lda * no_zeros + no_zeros;\n      MappedMatrixBlock A(glu.lusup.data()+luptr, u_rows, u_rows, OuterStride<>(lda) );\n      U = A.template triangularView<UnitLower>().solve(U);\n      \n      // update\n      luptr += u_rows;\n      MappedMatrixBlock B(glu.lusup.data()+luptr, nrow, u_rows, OuterStride<>(lda) );\n      eigen_assert(tempv.size()>w*ldu + nrow*w + 1);\n      \n      Index ldl = internal::first_multiple<Index>(nrow, PacketSize);\n      Index offset = (PacketSize-internal::first_default_aligned(B.data(), PacketSize)) % PacketSize;\n      MappedMatrixBlock L(tempv.data()+w*ldu+offset, nrow, u_cols, OuterStride<>(ldl));\n      \n      L.setZero();\n      internal::sparselu_gemm<Scalar>(L.rows(), L.cols(), B.cols(), B.data(), B.outerStride(), U.data(), U.outerStride(), L.data(), L.outerStride());\n      \n      // scatter U and L\n      u_col = 0;\n      for (jj = jcol; jj < jcol + w; jj++)\n      {\n        nextl_col = (jj-jcol) * m; \n        VectorBlock<IndexVector> repfnz_col(repfnz, nextl_col, m); // First nonzero column index for each row\n        VectorBlock<ScalarVector> dense_col(dense, nextl_col, m); // Scatter/gather entire matrix column from/to here\n        \n        kfnz = repfnz_col(krep); \n        if ( kfnz == emptyIdxLU ) \n          continue; // skip any zero segment\n        \n        segsize = krep - kfnz + 1;\n        no_zeros = kfnz - fsupc; \n        Index isub = lptr + no_zeros;\n        \n        Index off = u_rows-segsize;\n        for (Index i = 0; i < segsize; i++)\n        {\n          Index irow = glu.lsub(isub++); \n          dense_col(irow) = U.coeff(i+off,u_col);\n          U.coeffRef(i+off,u_col) = 0;\n        }\n        \n        // Scatter l into SPA dense[]\n        for (Index i = 0; i < nrow; i++)\n        {\n          Index irow = glu.lsub(isub++); \n          dense_col(irow) -= L.coeff(i,u_col);\n          L.coeffRef(i,u_col) = 0;\n        }\n        u_col++;\n      }\n    }\n    else // level 2 only\n    {\n      // Sequence through each column in the panel\n      for (jj = jcol; jj < jcol + w; jj++)\n      {\n        nextl_col = (jj-jcol) * m; \n        VectorBlock<IndexVector> repfnz_col(repfnz, nextl_col, m); // First nonzero column index for each row\n        VectorBlock<ScalarVector> dense_col(dense, nextl_col, m); // Scatter/gather entire matrix column from/to here\n        \n        kfnz = repfnz_col(krep); \n        if ( kfnz == emptyIdxLU ) \n          continue; // skip any zero segment\n        \n        segsize = krep - kfnz + 1;\n        luptr = glu.xlusup(fsupc);\n        \n        Index lda = glu.xlusup(fsupc+1)-glu.xlusup(fsupc);// nsupr\n        \n        // Perform a trianglar solve and block update, \n        // then scatter the result of sup-col update to dense[]\n        no_zeros = kfnz - fsupc; \n              if(segsize==1)  LU_kernel_bmod<1>::run(segsize, dense_col, tempv, glu.lusup, luptr, lda, nrow, glu.lsub, lptr, no_zeros);\n        else  if(segsize==2)  LU_kernel_bmod<2>::run(segsize, dense_col, tempv, glu.lusup, luptr, lda, nrow, glu.lsub, lptr, no_zeros);\n        else  if(segsize==3)  LU_kernel_bmod<3>::run(segsize, dense_col, tempv, glu.lusup, luptr, lda, nrow, glu.lsub, lptr, no_zeros);\n        else                  LU_kernel_bmod<Dynamic>::run(segsize, dense_col, tempv, glu.lusup, luptr, lda, nrow, glu.lsub, lptr, no_zeros); \n      } // End for each column in the panel \n    }\n    \n  } // End for each updating supernode\n} // end panel bmod\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // SPARSELU_PANEL_BMOD_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_panel_dfs.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* \n \n * NOTE: This file is the modified version of [s,d,c,z]panel_dfs.c file in SuperLU \n \n * -- SuperLU routine (version 2.0) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * November 15, 1997\n *\n * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n *\n * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n *\n * Permission is hereby granted to use or copy this program for any\n * purpose, provided the above notices are retained on all copies.\n * Permission to modify the code and to distribute modified code is\n * granted, provided the above notices are retained, and a notice that\n * the code was modified is included with the above copyright notice.\n */\n#ifndef SPARSELU_PANEL_DFS_H\n#define SPARSELU_PANEL_DFS_H\n\nnamespace Eigen {\n\nnamespace internal {\n  \ntemplate<typename IndexVector>\nstruct panel_dfs_traits\n{\n  typedef typename IndexVector::Scalar StorageIndex;\n  panel_dfs_traits(Index jcol, StorageIndex* marker)\n    : m_jcol(jcol), m_marker(marker)\n  {}\n  bool update_segrep(Index krep, StorageIndex jj)\n  {\n    if(m_marker[krep]<m_jcol)\n    {\n      m_marker[krep] = jj; \n      return true;\n    }\n    return false;\n  }\n  void mem_expand(IndexVector& /*glu.lsub*/, Index /*nextl*/, Index /*chmark*/) {}\n  enum { ExpandMem = false };\n  Index m_jcol;\n  StorageIndex* m_marker;\n};\n\n\ntemplate <typename Scalar, typename StorageIndex>\ntemplate <typename Traits>\nvoid SparseLUImpl<Scalar,StorageIndex>::dfs_kernel(const StorageIndex jj, IndexVector& perm_r,\n                   Index& nseg, IndexVector& panel_lsub, IndexVector& segrep,\n                   Ref<IndexVector> repfnz_col, IndexVector& xprune, Ref<IndexVector> marker, IndexVector& parent,\n                   IndexVector& xplore, GlobalLU_t& glu,\n                   Index& nextl_col, Index krow, Traits& traits\n                  )\n{\n  \n  StorageIndex kmark = marker(krow);\n      \n  // For each unmarked krow of jj\n  marker(krow) = jj; \n  StorageIndex kperm = perm_r(krow); \n  if (kperm == emptyIdxLU ) {\n    // krow is in L : place it in structure of L(*, jj)\n    panel_lsub(nextl_col++) = StorageIndex(krow);  // krow is indexed into A\n    \n    traits.mem_expand(panel_lsub, nextl_col, kmark);\n  }\n  else \n  {\n    // krow is in U : if its supernode-representative krep\n    // has been explored, update repfnz(*)\n    // krep = supernode representative of the current row\n    StorageIndex krep = glu.xsup(glu.supno(kperm)+1) - 1; \n    // First nonzero element in the current column:\n    StorageIndex myfnz = repfnz_col(krep); \n    \n    if (myfnz != emptyIdxLU )\n    {\n      // Representative visited before\n      if (myfnz > kperm ) repfnz_col(krep) = kperm; \n      \n    }\n    else \n    {\n      // Otherwise, perform dfs starting at krep\n      StorageIndex oldrep = emptyIdxLU; \n      parent(krep) = oldrep; \n      repfnz_col(krep) = kperm; \n      StorageIndex xdfs =  glu.xlsub(krep); \n      Index maxdfs = xprune(krep); \n      \n      StorageIndex kpar;\n      do \n      {\n        // For each unmarked kchild of krep\n        while (xdfs < maxdfs) \n        {\n          StorageIndex kchild = glu.lsub(xdfs); \n          xdfs++; \n          StorageIndex chmark = marker(kchild); \n          \n          if (chmark != jj ) \n          {\n            marker(kchild) = jj; \n            StorageIndex chperm = perm_r(kchild); \n            \n            if (chperm == emptyIdxLU) \n            {\n              // case kchild is in L: place it in L(*, j)\n              panel_lsub(nextl_col++) = kchild;\n              traits.mem_expand(panel_lsub, nextl_col, chmark);\n            }\n            else\n            {\n              // case kchild is in U :\n              // chrep = its supernode-rep. If its rep has been explored, \n              // update its repfnz(*)\n              StorageIndex chrep = glu.xsup(glu.supno(chperm)+1) - 1; \n              myfnz = repfnz_col(chrep); \n              \n              if (myfnz != emptyIdxLU) \n              { // Visited before \n                if (myfnz > chperm) \n                  repfnz_col(chrep) = chperm; \n              }\n              else \n              { // Cont. dfs at snode-rep of kchild\n                xplore(krep) = xdfs; \n                oldrep = krep; \n                krep = chrep; // Go deeper down G(L)\n                parent(krep) = oldrep; \n                repfnz_col(krep) = chperm; \n                xdfs = glu.xlsub(krep); \n                maxdfs = xprune(krep); \n                \n              } // end if myfnz != -1\n            } // end if chperm == -1 \n                \n          } // end if chmark !=jj\n        } // end while xdfs < maxdfs\n        \n        // krow has no more unexplored nbrs :\n        //    Place snode-rep krep in postorder DFS, if this \n        //    segment is seen for the first time. (Note that \n        //    \"repfnz(krep)\" may change later.)\n        //    Baktrack dfs to its parent\n        if(traits.update_segrep(krep,jj))\n        //if (marker1(krep) < jcol )\n        {\n          segrep(nseg) = krep; \n          ++nseg; \n          //marker1(krep) = jj; \n        }\n        \n        kpar = parent(krep); // Pop recursion, mimic recursion \n        if (kpar == emptyIdxLU) \n          break; // dfs done \n        krep = kpar; \n        xdfs = xplore(krep); \n        maxdfs = xprune(krep); \n\n      } while (kpar != emptyIdxLU); // Do until empty stack \n      \n    } // end if (myfnz = -1)\n\n  } // end if (kperm == -1)   \n}\n\n/**\n * \\brief Performs a symbolic factorization on a panel of columns [jcol, jcol+w)\n * \n * A supernode representative is the last column of a supernode.\n * The nonzeros in U[*,j] are segments that end at supernodes representatives\n * \n * The routine returns a list of the supernodal representatives \n * in topological order of the dfs that generates them. This list is \n * a superset of the topological order of each individual column within \n * the panel.\n * The location of the first nonzero in each supernodal segment \n * (supernodal entry location) is also returned. Each column has \n * a separate list for this purpose. \n * \n * Two markers arrays are used for dfs :\n *    marker[i] == jj, if i was visited during dfs of current column jj;\n *    marker1[i] >= jcol, if i was visited by earlier columns in this panel; \n * \n * \\param[in] m number of rows in the matrix\n * \\param[in] w Panel size\n * \\param[in] jcol Starting  column of the panel\n * \\param[in] A Input matrix in column-major storage\n * \\param[in] perm_r Row permutation\n * \\param[out] nseg Number of U segments\n * \\param[out] dense Accumulate the column vectors of the panel\n * \\param[out] panel_lsub Subscripts of the row in the panel \n * \\param[out] segrep Segment representative i.e first nonzero row of each segment\n * \\param[out] repfnz First nonzero location in each row\n * \\param[out] xprune The pruned elimination tree\n * \\param[out] marker work vector\n * \\param  parent The elimination tree\n * \\param xplore work vector\n * \\param glu The global data structure\n * \n */\n\ntemplate <typename Scalar, typename StorageIndex>\nvoid SparseLUImpl<Scalar,StorageIndex>::panel_dfs(const Index m, const Index w, const Index jcol, MatrixType& A, IndexVector& perm_r, Index& nseg, ScalarVector& dense, IndexVector& panel_lsub, IndexVector& segrep, IndexVector& repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu)\n{\n  Index nextl_col; // Next available position in panel_lsub[*,jj] \n  \n  // Initialize pointers \n  VectorBlock<IndexVector> marker1(marker, m, m); \n  nseg = 0; \n  \n  panel_dfs_traits<IndexVector> traits(jcol, marker1.data());\n  \n  // For each column in the panel \n  for (StorageIndex jj = StorageIndex(jcol); jj < jcol + w; jj++) \n  {\n    nextl_col = (jj - jcol) * m; \n    \n    VectorBlock<IndexVector> repfnz_col(repfnz, nextl_col, m); // First nonzero location in each row\n    VectorBlock<ScalarVector> dense_col(dense,nextl_col, m); // Accumulate a column vector here\n    \n    \n    // For each nnz in A[*, jj] do depth first search\n    for (typename MatrixType::InnerIterator it(A, jj); it; ++it)\n    {\n      Index krow = it.row(); \n      dense_col(krow) = it.value();\n      \n      StorageIndex kmark = marker(krow); \n      if (kmark == jj) \n        continue; // krow visited before, go to the next nonzero\n      \n      dfs_kernel(jj, perm_r, nseg, panel_lsub, segrep, repfnz_col, xprune, marker, parent,\n                   xplore, glu, nextl_col, krow, traits);\n    }// end for nonzeros in column jj\n    \n  } // end for column jj\n}\n\n} // end namespace internal\n} // end namespace Eigen\n\n#endif // SPARSELU_PANEL_DFS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_pivotL.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* \n \n * NOTE: This file is the modified version of xpivotL.c file in SuperLU \n \n * -- SuperLU routine (version 3.0) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * October 15, 2003\n *\n * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n *\n * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n *\n * Permission is hereby granted to use or copy this program for any\n * purpose, provided the above notices are retained on all copies.\n * Permission to modify the code and to distribute modified code is\n * granted, provided the above notices are retained, and a notice that\n * the code was modified is included with the above copyright notice.\n */\n#ifndef SPARSELU_PIVOTL_H\n#define SPARSELU_PIVOTL_H\n\nnamespace Eigen {\nnamespace internal {\n  \n/**\n * \\brief Performs the numerical pivotin on the current column of L, and the CDIV operation.\n * \n * Pivot policy :\n * (1) Compute thresh = u * max_(i>=j) abs(A_ij);\n * (2) IF user specifies pivot row k and abs(A_kj) >= thresh THEN\n *           pivot row = k;\n *       ELSE IF abs(A_jj) >= thresh THEN\n *           pivot row = j;\n *       ELSE\n *           pivot row = m;\n * \n *   Note: If you absolutely want to use a given pivot order, then set u=0.0.\n * \n * \\param jcol The current column of L\n * \\param diagpivotthresh diagonal pivoting threshold\n * \\param[in,out] perm_r Row permutation (threshold pivoting)\n * \\param[in] iperm_c column permutation - used to finf diagonal of Pc*A*Pc'\n * \\param[out] pivrow  The pivot row\n * \\param glu Global LU data\n * \\return 0 if success, i > 0 if U(i,i) is exactly zero \n * \n */\ntemplate <typename Scalar, typename StorageIndex>\nIndex SparseLUImpl<Scalar,StorageIndex>::pivotL(const Index jcol, const RealScalar& diagpivotthresh, IndexVector& perm_r, IndexVector& iperm_c, Index& pivrow, GlobalLU_t& glu)\n{\n  \n  Index fsupc = (glu.xsup)((glu.supno)(jcol)); // First column in the supernode containing the column jcol\n  Index nsupc = jcol - fsupc; // Number of columns in the supernode portion, excluding jcol; nsupc >=0\n  Index lptr = glu.xlsub(fsupc); // pointer to the starting location of the row subscripts for this supernode portion\n  Index nsupr = glu.xlsub(fsupc+1) - lptr; // Number of rows in the supernode\n  Index lda = glu.xlusup(fsupc+1) - glu.xlusup(fsupc); // leading dimension\n  Scalar* lu_sup_ptr = &(glu.lusup.data()[glu.xlusup(fsupc)]); // Start of the current supernode\n  Scalar* lu_col_ptr = &(glu.lusup.data()[glu.xlusup(jcol)]); // Start of jcol in the supernode\n  StorageIndex* lsub_ptr = &(glu.lsub.data()[lptr]); // Start of row indices of the supernode\n  \n  // Determine the largest abs numerical value for partial pivoting \n  Index diagind = iperm_c(jcol); // diagonal index \n  RealScalar pivmax(-1.0);\n  Index pivptr = nsupc; \n  Index diag = emptyIdxLU; \n  RealScalar rtemp;\n  Index isub, icol, itemp, k; \n  for (isub = nsupc; isub < nsupr; ++isub) {\n    using std::abs;\n    rtemp = abs(lu_col_ptr[isub]);\n    if (rtemp > pivmax) {\n      pivmax = rtemp; \n      pivptr = isub;\n    } \n    if (lsub_ptr[isub] == diagind) diag = isub;\n  }\n  \n  // Test for singularity\n  if ( pivmax <= RealScalar(0.0) ) {\n    // if pivmax == -1, the column is structurally empty, otherwise it is only numerically zero\n    pivrow = pivmax < RealScalar(0.0) ? diagind : lsub_ptr[pivptr];\n    perm_r(pivrow) = StorageIndex(jcol);\n    return (jcol+1);\n  }\n  \n  RealScalar thresh = diagpivotthresh * pivmax; \n  \n  // Choose appropriate pivotal element \n  \n  {\n    // Test if the diagonal element can be used as a pivot (given the threshold value)\n    if (diag >= 0 ) \n    {\n      // Diagonal element exists\n      using std::abs;\n      rtemp = abs(lu_col_ptr[diag]);\n      if (rtemp != RealScalar(0.0) && rtemp >= thresh) pivptr = diag;\n    }\n    pivrow = lsub_ptr[pivptr];\n  }\n  \n  // Record pivot row\n  perm_r(pivrow) = StorageIndex(jcol);\n  // Interchange row subscripts\n  if (pivptr != nsupc )\n  {\n    std::swap( lsub_ptr[pivptr], lsub_ptr[nsupc] );\n    // Interchange numerical values as well, for the two rows in the whole snode\n    // such that L is indexed the same way as A\n    for (icol = 0; icol <= nsupc; icol++)\n    {\n      itemp = pivptr + icol * lda; \n      std::swap(lu_sup_ptr[itemp], lu_sup_ptr[nsupc + icol * lda]);\n    }\n  }\n  // cdiv operations\n  Scalar temp = Scalar(1.0) / lu_col_ptr[nsupc];\n  for (k = nsupc+1; k < nsupr; k++)\n    lu_col_ptr[k] *= temp; \n  return 0;\n}\n\n} // end namespace internal\n} // end namespace Eigen\n\n#endif // SPARSELU_PIVOTL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_pruneL.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* \n \n * NOTE: This file is the modified version of [s,d,c,z]pruneL.c file in SuperLU \n \n * -- SuperLU routine (version 2.0) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * November 15, 1997\n *\n * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n *\n * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n *\n * Permission is hereby granted to use or copy this program for any\n * purpose, provided the above notices are retained on all copies.\n * Permission to modify the code and to distribute modified code is\n * granted, provided the above notices are retained, and a notice that\n * the code was modified is included with the above copyright notice.\n */\n#ifndef SPARSELU_PRUNEL_H\n#define SPARSELU_PRUNEL_H\n\nnamespace Eigen {\nnamespace internal {\n\n/**\n * \\brief Prunes the L-structure.\n *\n * It prunes the L-structure  of supernodes whose L-structure contains the current pivot row \"pivrow\"\n * \n * \n * \\param jcol The current column of L\n * \\param[in] perm_r Row permutation\n * \\param[out] pivrow  The pivot row\n * \\param nseg Number of segments\n * \\param segrep \n * \\param repfnz\n * \\param[out] xprune \n * \\param glu Global LU data\n * \n */\ntemplate <typename Scalar, typename StorageIndex>\nvoid SparseLUImpl<Scalar,StorageIndex>::pruneL(const Index jcol, const IndexVector& perm_r, const Index pivrow, const Index nseg,\n                                               const IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, GlobalLU_t& glu)\n{\n  // For each supernode-rep irep in U(*,j]\n  Index jsupno = glu.supno(jcol); \n  Index i,irep,irep1; \n  bool movnum, do_prune = false; \n  Index kmin = 0, kmax = 0, minloc, maxloc,krow; \n  for (i = 0; i < nseg; i++)\n  {\n    irep = segrep(i); \n    irep1 = irep + 1; \n    do_prune = false; \n    \n    // Don't prune with a zero U-segment \n    if (repfnz(irep) == emptyIdxLU) continue; \n    \n    // If a snode overlaps with the next panel, then the U-segment\n    // is fragmented into two parts -- irep and irep1. We should let \n    // pruning occur at the rep-column in irep1s snode. \n    if (glu.supno(irep) == glu.supno(irep1) ) continue; // don't prune \n    \n    // If it has not been pruned & it has a nonz in row L(pivrow,i)\n    if (glu.supno(irep) != jsupno )\n    {\n      if ( xprune (irep) >= glu.xlsub(irep1) )\n      {\n        kmin = glu.xlsub(irep);\n        kmax = glu.xlsub(irep1) - 1; \n        for (krow = kmin; krow <= kmax; krow++)\n        {\n          if (glu.lsub(krow) == pivrow) \n          {\n            do_prune = true; \n            break; \n          }\n        }\n      }\n      \n      if (do_prune) \n      {\n        // do a quicksort-type partition\n        // movnum=true means that the num values have to be exchanged\n        movnum = false; \n        if (irep == glu.xsup(glu.supno(irep)) ) // Snode of size 1 \n          movnum = true; \n        \n        while (kmin <= kmax)\n        {\n          if (perm_r(glu.lsub(kmax)) == emptyIdxLU)\n            kmax--; \n          else if ( perm_r(glu.lsub(kmin)) != emptyIdxLU)\n            kmin++;\n          else \n          {\n            // kmin below pivrow (not yet pivoted), and kmax\n            // above pivrow: interchange the two suscripts\n            std::swap(glu.lsub(kmin), glu.lsub(kmax)); \n            \n            // If the supernode has only one column, then we \n            // only keep one set of subscripts. For any subscript\n            // intercnahge performed, similar interchange must be \n            // done on the numerical values. \n            if (movnum) \n            {\n              minloc = glu.xlusup(irep) + ( kmin - glu.xlsub(irep) ); \n              maxloc = glu.xlusup(irep) + ( kmax - glu.xlsub(irep) ); \n              std::swap(glu.lusup(minloc), glu.lusup(maxloc)); \n            }\n            kmin++;\n            kmax--;\n          }\n        } // end while \n        \n        xprune(irep) = StorageIndex(kmin);  //Pruning \n      } // end if do_prune \n    } // end pruning \n  } // End for each U-segment\n}\n\n} // end namespace internal\n} // end namespace Eigen\n\n#endif // SPARSELU_PRUNEL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseLU/SparseLU_relax_snode.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n/* This file is a modified version of heap_relax_snode.c file in SuperLU\n * -- SuperLU routine (version 3.0) --\n * Univ. of California Berkeley, Xerox Palo Alto Research Center,\n * and Lawrence Berkeley National Lab.\n * October 15, 2003\n *\n * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n *\n * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n *\n * Permission is hereby granted to use or copy this program for any\n * purpose, provided the above notices are retained on all copies.\n * Permission to modify the code and to distribute modified code is\n * granted, provided the above notices are retained, and a notice that\n * the code was modified is included with the above copyright notice.\n */\n\n#ifndef SPARSELU_RELAX_SNODE_H\n#define SPARSELU_RELAX_SNODE_H\n\nnamespace Eigen {\n\nnamespace internal {\n \n/** \n * \\brief Identify the initial relaxed supernodes\n * \n * This routine is applied to a column elimination tree. \n * It assumes that the matrix has been reordered according to the postorder of the etree\n * \\param n  the number of columns\n * \\param et elimination tree \n * \\param relax_columns Maximum number of columns allowed in a relaxed snode \n * \\param descendants Number of descendants of each node in the etree\n * \\param relax_end last column in a supernode\n */\ntemplate <typename Scalar, typename StorageIndex>\nvoid SparseLUImpl<Scalar,StorageIndex>::relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end)\n{\n  \n  // compute the number of descendants of each node in the etree\n  Index parent; \n  relax_end.setConstant(emptyIdxLU);\n  descendants.setZero();\n  for (Index j = 0; j < n; j++) \n  {\n    parent = et(j);\n    if (parent != n) // not the dummy root\n      descendants(parent) += descendants(j) + 1;\n  }\n  // Identify the relaxed supernodes by postorder traversal of the etree\n  Index snode_start; // beginning of a snode \n  for (Index j = 0; j < n; )\n  {\n    parent = et(j);\n    snode_start = j; \n    while ( parent != n && descendants(parent) < relax_columns ) \n    {\n      j = parent; \n      parent = et(j);\n    }\n    // Found a supernode in postordered etree, j is the last column \n    relax_end(snode_start) = StorageIndex(j); // Record last column\n    j++;\n    // Search for a new leaf\n    while (descendants(j) != 0 && j < n) j++;\n  } // End postorder traversal of the etree\n  \n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/SparseQR/SparseQR.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2012-2013 Desire Nuentsa <desire.nuentsa_wakam@inria.fr>\n// Copyright (C) 2012-2014 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SPARSE_QR_H\n#define EIGEN_SPARSE_QR_H\n\nnamespace Eigen {\n\ntemplate<typename MatrixType, typename OrderingType> class SparseQR;\ntemplate<typename SparseQRType> struct SparseQRMatrixQReturnType;\ntemplate<typename SparseQRType> struct SparseQRMatrixQTransposeReturnType;\ntemplate<typename SparseQRType, typename Derived> struct SparseQR_QProduct;\nnamespace internal {\n  template <typename SparseQRType> struct traits<SparseQRMatrixQReturnType<SparseQRType> >\n  {\n    typedef typename SparseQRType::MatrixType ReturnType;\n    typedef typename ReturnType::StorageIndex StorageIndex;\n    typedef typename ReturnType::StorageKind StorageKind;\n    enum {\n      RowsAtCompileTime = Dynamic,\n      ColsAtCompileTime = Dynamic\n    };\n  };\n  template <typename SparseQRType> struct traits<SparseQRMatrixQTransposeReturnType<SparseQRType> >\n  {\n    typedef typename SparseQRType::MatrixType ReturnType;\n  };\n  template <typename SparseQRType, typename Derived> struct traits<SparseQR_QProduct<SparseQRType, Derived> >\n  {\n    typedef typename Derived::PlainObject ReturnType;\n  };\n} // End namespace internal\n\n/**\n  * \\ingroup SparseQR_Module\n  * \\class SparseQR\n  * \\brief Sparse left-looking rank-revealing QR factorization\n  * \n  * This class implements a left-looking rank-revealing QR decomposition \n  * of sparse matrices. When a column has a norm less than a given tolerance\n  * it is implicitly permuted to the end. The QR factorization thus obtained is \n  * given by A*P = Q*R where R is upper triangular or trapezoidal. \n  * \n  * P is the column permutation which is the product of the fill-reducing and the\n  * rank-revealing permutations. Use colsPermutation() to get it.\n  * \n  * Q is the orthogonal matrix represented as products of Householder reflectors. \n  * Use matrixQ() to get an expression and matrixQ().transpose() to get the transpose.\n  * You can then apply it to a vector.\n  * \n  * R is the sparse triangular or trapezoidal matrix. The later occurs when A is rank-deficient.\n  * matrixR().topLeftCorner(rank(), rank()) always returns a triangular factor of full rank.\n  * \n  * \\tparam _MatrixType The type of the sparse matrix A, must be a column-major SparseMatrix<>\n  * \\tparam _OrderingType The fill-reducing ordering method. See the \\link OrderingMethods_Module \n  *  OrderingMethods \\endlink module for the list of built-in and external ordering methods.\n  * \n  * \\implsparsesolverconcept\n  *\n  * \\warning The input sparse matrix A must be in compressed mode (see SparseMatrix::makeCompressed()).\n  * \n  */\ntemplate<typename _MatrixType, typename _OrderingType>\nclass SparseQR : public SparseSolverBase<SparseQR<_MatrixType,_OrderingType> >\n{\n  protected:\n    typedef SparseSolverBase<SparseQR<_MatrixType,_OrderingType> > Base;\n    using Base::m_isInitialized;\n  public:\n    using Base::_solve_impl;\n    typedef _MatrixType MatrixType;\n    typedef _OrderingType OrderingType;\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef SparseMatrix<Scalar,ColMajor,StorageIndex> QRMatrixType;\n    typedef Matrix<StorageIndex, Dynamic, 1> IndexVector;\n    typedef Matrix<Scalar, Dynamic, 1> ScalarVector;\n    typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType;\n\n    enum {\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n    \n  public:\n    SparseQR () :  m_analysisIsok(false), m_lastError(\"\"), m_useDefaultThreshold(true),m_isQSorted(false),m_isEtreeOk(false)\n    { }\n    \n    /** Construct a QR factorization of the matrix \\a mat.\n      * \n      * \\warning The matrix \\a mat must be in compressed mode (see SparseMatrix::makeCompressed()).\n      * \n      * \\sa compute()\n      */\n    explicit SparseQR(const MatrixType& mat) : m_analysisIsok(false), m_lastError(\"\"), m_useDefaultThreshold(true),m_isQSorted(false),m_isEtreeOk(false)\n    {\n      compute(mat);\n    }\n    \n    /** Computes the QR factorization of the sparse matrix \\a mat.\n      * \n      * \\warning The matrix \\a mat must be in compressed mode (see SparseMatrix::makeCompressed()).\n      * \n      * \\sa analyzePattern(), factorize()\n      */\n    void compute(const MatrixType& mat)\n    {\n      analyzePattern(mat);\n      factorize(mat);\n    }\n    void analyzePattern(const MatrixType& mat);\n    void factorize(const MatrixType& mat);\n    \n    /** \\returns the number of rows of the represented matrix. \n      */\n    inline Index rows() const { return m_pmat.rows(); }\n    \n    /** \\returns the number of columns of the represented matrix. \n      */\n    inline Index cols() const { return m_pmat.cols();}\n    \n    /** \\returns a const reference to the \\b sparse upper triangular matrix R of the QR factorization.\n      * \\warning The entries of the returned matrix are not sorted. This means that using it in algorithms\n      *          expecting sorted entries will fail. This include random coefficient accesses (SpaseMatrix::coeff()),\n      *          and coefficient-wise operations. Matrix products and triangular solves are fine though.\n      *\n      * To sort the entries, you can assign it to a row-major matrix, and if a column-major matrix\n      * is required, you can copy it again:\n      * \\code\n      * SparseMatrix<double>          R  = qr.matrixR();  // column-major, not sorted!\n      * SparseMatrix<double,RowMajor> Rr = qr.matrixR();  // row-major, sorted\n      * SparseMatrix<double>          Rc = Rr;            // column-major, sorted\n      * \\endcode\n      */\n    const QRMatrixType& matrixR() const { return m_R; }\n    \n    /** \\returns the number of non linearly dependent columns as determined by the pivoting threshold.\n      *\n      * \\sa setPivotThreshold()\n      */\n    Index rank() const\n    {\n      eigen_assert(m_isInitialized && \"The factorization should be called first, use compute()\");\n      return m_nonzeropivots; \n    }\n    \n    /** \\returns an expression of the matrix Q as products of sparse Householder reflectors.\n    * The common usage of this function is to apply it to a dense matrix or vector\n    * \\code\n    * VectorXd B1, B2;\n    * // Initialize B1\n    * B2 = matrixQ() * B1;\n    * \\endcode\n    *\n    * To get a plain SparseMatrix representation of Q:\n    * \\code\n    * SparseMatrix<double> Q;\n    * Q = SparseQR<SparseMatrix<double> >(A).matrixQ();\n    * \\endcode\n    * Internally, this call simply performs a sparse product between the matrix Q\n    * and a sparse identity matrix. However, due to the fact that the sparse\n    * reflectors are stored unsorted, two transpositions are needed to sort\n    * them before performing the product.\n    */\n    SparseQRMatrixQReturnType<SparseQR> matrixQ() const \n    { return SparseQRMatrixQReturnType<SparseQR>(*this); }\n    \n    /** \\returns a const reference to the column permutation P that was applied to A such that A*P = Q*R\n      * It is the combination of the fill-in reducing permutation and numerical column pivoting.\n      */\n    const PermutationType& colsPermutation() const\n    { \n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return m_outputPerm_c;\n    }\n    \n    /** \\returns A string describing the type of error.\n      * This method is provided to ease debugging, not to handle errors.\n      */\n    std::string lastErrorMessage() const { return m_lastError; }\n    \n    /** \\internal */\n    template<typename Rhs, typename Dest>\n    bool _solve_impl(const MatrixBase<Rhs> &B, MatrixBase<Dest> &dest) const\n    {\n      eigen_assert(m_isInitialized && \"The factorization should be called first, use compute()\");\n      eigen_assert(this->rows() == B.rows() && \"SparseQR::solve() : invalid number of rows in the right hand side matrix\");\n\n      Index rank = this->rank();\n      \n      // Compute Q^T * b;\n      typename Dest::PlainObject y, b;\n      y = this->matrixQ().transpose() * B; \n      b = y;\n      \n      // Solve with the triangular matrix R\n      y.resize((std::max<Index>)(cols(),y.rows()),y.cols());\n      y.topRows(rank) = this->matrixR().topLeftCorner(rank, rank).template triangularView<Upper>().solve(b.topRows(rank));\n      y.bottomRows(y.rows()-rank).setZero();\n      \n      // Apply the column permutation\n      if (m_perm_c.size())  dest = colsPermutation() * y.topRows(cols());\n      else                  dest = y.topRows(cols());\n      \n      m_info = Success;\n      return true;\n    }\n\n    /** Sets the threshold that is used to determine linearly dependent columns during the factorization.\n      *\n      * In practice, if during the factorization the norm of the column that has to be eliminated is below\n      * this threshold, then the entire column is treated as zero, and it is moved at the end.\n      */\n    void setPivotThreshold(const RealScalar& threshold)\n    {\n      m_useDefaultThreshold = false;\n      m_threshold = threshold;\n    }\n    \n    /** \\returns the solution X of \\f$ A X = B \\f$ using the current decomposition of A.\n      *\n      * \\sa compute()\n      */\n    template<typename Rhs>\n    inline const Solve<SparseQR, Rhs> solve(const MatrixBase<Rhs>& B) const \n    {\n      eigen_assert(m_isInitialized && \"The factorization should be called first, use compute()\");\n      eigen_assert(this->rows() == B.rows() && \"SparseQR::solve() : invalid number of rows in the right hand side matrix\");\n      return Solve<SparseQR, Rhs>(*this, B.derived());\n    }\n    template<typename Rhs>\n    inline const Solve<SparseQR, Rhs> solve(const SparseMatrixBase<Rhs>& B) const\n    {\n          eigen_assert(m_isInitialized && \"The factorization should be called first, use compute()\");\n          eigen_assert(this->rows() == B.rows() && \"SparseQR::solve() : invalid number of rows in the right hand side matrix\");\n          return Solve<SparseQR, Rhs>(*this, B.derived());\n    }\n    \n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was successful,\n      *          \\c NumericalIssue if the QR factorization reports a numerical problem\n      *          \\c InvalidInput if the input matrix is invalid\n      *\n      * \\sa iparm()          \n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return m_info;\n    }\n\n\n    /** \\internal */\n    inline void _sort_matrix_Q()\n    {\n      if(this->m_isQSorted) return;\n      // The matrix Q is sorted during the transposition\n      SparseMatrix<Scalar, RowMajor, Index> mQrm(this->m_Q);\n      this->m_Q = mQrm;\n      this->m_isQSorted = true;\n    }\n\n    \n  protected:\n    bool m_analysisIsok;\n    bool m_factorizationIsok;\n    mutable ComputationInfo m_info;\n    std::string m_lastError;\n    QRMatrixType m_pmat;            // Temporary matrix\n    QRMatrixType m_R;               // The triangular factor matrix\n    QRMatrixType m_Q;               // The orthogonal reflectors\n    ScalarVector m_hcoeffs;         // The Householder coefficients\n    PermutationType m_perm_c;       // Fill-reducing  Column  permutation\n    PermutationType m_pivotperm;    // The permutation for rank revealing\n    PermutationType m_outputPerm_c; // The final column permutation\n    RealScalar m_threshold;         // Threshold to determine null Householder reflections\n    bool m_useDefaultThreshold;     // Use default threshold\n    Index m_nonzeropivots;          // Number of non zero pivots found\n    IndexVector m_etree;            // Column elimination tree\n    IndexVector m_firstRowElt;      // First element in each row\n    bool m_isQSorted;               // whether Q is sorted or not\n    bool m_isEtreeOk;               // whether the elimination tree match the initial input matrix\n    \n    template <typename, typename > friend struct SparseQR_QProduct;\n    \n};\n\n/** \\brief Preprocessing step of a QR factorization \n  * \n  * \\warning The matrix \\a mat must be in compressed mode (see SparseMatrix::makeCompressed()).\n  * \n  * In this step, the fill-reducing permutation is computed and applied to the columns of A\n  * and the column elimination tree is computed as well. Only the sparsity pattern of \\a mat is exploited.\n  * \n  * \\note In this step it is assumed that there is no empty row in the matrix \\a mat.\n  */\ntemplate <typename MatrixType, typename OrderingType>\nvoid SparseQR<MatrixType,OrderingType>::analyzePattern(const MatrixType& mat)\n{\n  eigen_assert(mat.isCompressed() && \"SparseQR requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it to SparseQR\");\n  // Copy to a column major matrix if the input is rowmajor\n  typename internal::conditional<MatrixType::IsRowMajor,QRMatrixType,const MatrixType&>::type matCpy(mat);\n  // Compute the column fill reducing ordering\n  OrderingType ord; \n  ord(matCpy, m_perm_c); \n  Index n = mat.cols();\n  Index m = mat.rows();\n  Index diagSize = (std::min)(m,n);\n  \n  if (!m_perm_c.size())\n  {\n    m_perm_c.resize(n);\n    m_perm_c.indices().setLinSpaced(n, 0,StorageIndex(n-1));\n  }\n  \n  // Compute the column elimination tree of the permuted matrix\n  m_outputPerm_c = m_perm_c.inverse();\n  internal::coletree(matCpy, m_etree, m_firstRowElt, m_outputPerm_c.indices().data());\n  m_isEtreeOk = true;\n  \n  m_R.resize(m, n);\n  m_Q.resize(m, diagSize);\n  \n  // Allocate space for nonzero elements : rough estimation\n  m_R.reserve(2*mat.nonZeros()); //FIXME Get a more accurate estimation through symbolic factorization with the etree\n  m_Q.reserve(2*mat.nonZeros());\n  m_hcoeffs.resize(diagSize);\n  m_analysisIsok = true;\n}\n\n/** \\brief Performs the numerical QR factorization of the input matrix\n  * \n  * The function SparseQR::analyzePattern(const MatrixType&) must have been called beforehand with\n  * a matrix having the same sparsity pattern than \\a mat.\n  * \n  * \\param mat The sparse column-major matrix\n  */\ntemplate <typename MatrixType, typename OrderingType>\nvoid SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat)\n{\n  using std::abs;\n  \n  eigen_assert(m_analysisIsok && \"analyzePattern() should be called before this step\");\n  StorageIndex m = StorageIndex(mat.rows());\n  StorageIndex n = StorageIndex(mat.cols());\n  StorageIndex diagSize = (std::min)(m,n);\n  IndexVector mark((std::max)(m,n)); mark.setConstant(-1);  // Record the visited nodes\n  IndexVector Ridx(n), Qidx(m);                             // Store temporarily the row indexes for the current column of R and Q\n  Index nzcolR, nzcolQ;                                     // Number of nonzero for the current column of R and Q\n  ScalarVector tval(m);                                     // The dense vector used to compute the current column\n  RealScalar pivotThreshold = m_threshold;\n  \n  m_R.setZero();\n  m_Q.setZero();\n  m_pmat = mat;\n  if(!m_isEtreeOk)\n  {\n    m_outputPerm_c = m_perm_c.inverse();\n    internal::coletree(m_pmat, m_etree, m_firstRowElt, m_outputPerm_c.indices().data());\n    m_isEtreeOk = true;\n  }\n\n  m_pmat.uncompress(); // To have the innerNonZeroPtr allocated\n  \n  // Apply the fill-in reducing permutation lazily:\n  {\n    // If the input is row major, copy the original column indices,\n    // otherwise directly use the input matrix\n    // \n    IndexVector originalOuterIndicesCpy;\n    const StorageIndex *originalOuterIndices = mat.outerIndexPtr();\n    if(MatrixType::IsRowMajor)\n    {\n      originalOuterIndicesCpy = IndexVector::Map(m_pmat.outerIndexPtr(),n+1);\n      originalOuterIndices = originalOuterIndicesCpy.data();\n    }\n    \n    for (int i = 0; i < n; i++)\n    {\n      Index p = m_perm_c.size() ? m_perm_c.indices()(i) : i;\n      m_pmat.outerIndexPtr()[p] = originalOuterIndices[i]; \n      m_pmat.innerNonZeroPtr()[p] = originalOuterIndices[i+1] - originalOuterIndices[i]; \n    }\n  }\n  \n  /* Compute the default threshold as in MatLab, see:\n   * Tim Davis, \"Algorithm 915, SuiteSparseQR: Multifrontal Multithreaded Rank-Revealing\n   * Sparse QR Factorization, ACM Trans. on Math. Soft. 38(1), 2011, Page 8:3 \n   */\n  if(m_useDefaultThreshold) \n  {\n    RealScalar max2Norm = 0.0;\n    for (int j = 0; j < n; j++) max2Norm = numext::maxi(max2Norm, m_pmat.col(j).norm());\n    if(max2Norm==RealScalar(0))\n      max2Norm = RealScalar(1);\n    pivotThreshold = 20 * (m + n) * max2Norm * NumTraits<RealScalar>::epsilon();\n  }\n  \n  // Initialize the numerical permutation\n  m_pivotperm.setIdentity(n);\n  \n  StorageIndex nonzeroCol = 0; // Record the number of valid pivots\n  m_Q.startVec(0);\n\n  // Left looking rank-revealing QR factorization: compute a column of R and Q at a time\n  for (StorageIndex col = 0; col < n; ++col)\n  {\n    mark.setConstant(-1);\n    m_R.startVec(col);\n    mark(nonzeroCol) = col;\n    Qidx(0) = nonzeroCol;\n    nzcolR = 0; nzcolQ = 1;\n    bool found_diag = nonzeroCol>=m;\n    tval.setZero(); \n    \n    // Symbolic factorization: find the nonzero locations of the column k of the factors R and Q, i.e.,\n    // all the nodes (with indexes lower than rank) reachable through the column elimination tree (etree) rooted at node k.\n    // Note: if the diagonal entry does not exist, then its contribution must be explicitly added,\n    // thus the trick with found_diag that permits to do one more iteration on the diagonal element if this one has not been found.\n    for (typename QRMatrixType::InnerIterator itp(m_pmat, col); itp || !found_diag; ++itp)\n    {\n      StorageIndex curIdx = nonzeroCol;\n      if(itp) curIdx = StorageIndex(itp.row());\n      if(curIdx == nonzeroCol) found_diag = true;\n      \n      // Get the nonzeros indexes of the current column of R\n      StorageIndex st = m_firstRowElt(curIdx); // The traversal of the etree starts here\n      if (st < 0 )\n      {\n        m_lastError = \"Empty row found during numerical factorization\";\n        m_info = InvalidInput;\n        return;\n      }\n\n      // Traverse the etree \n      Index bi = nzcolR;\n      for (; mark(st) != col; st = m_etree(st))\n      {\n        Ridx(nzcolR) = st;  // Add this row to the list,\n        mark(st) = col;     // and mark this row as visited\n        nzcolR++;\n      }\n\n      // Reverse the list to get the topological ordering\n      Index nt = nzcolR-bi;\n      for(Index i = 0; i < nt/2; i++) std::swap(Ridx(bi+i), Ridx(nzcolR-i-1));\n       \n      // Copy the current (curIdx,pcol) value of the input matrix\n      if(itp) tval(curIdx) = itp.value();\n      else    tval(curIdx) = Scalar(0);\n      \n      // Compute the pattern of Q(:,k)\n      if(curIdx > nonzeroCol && mark(curIdx) != col ) \n      {\n        Qidx(nzcolQ) = curIdx;  // Add this row to the pattern of Q,\n        mark(curIdx) = col;     // and mark it as visited\n        nzcolQ++;\n      }\n    }\n\n    // Browse all the indexes of R(:,col) in reverse order\n    for (Index i = nzcolR-1; i >= 0; i--)\n    {\n      Index curIdx = Ridx(i);\n      \n      // Apply the curIdx-th householder vector to the current column (temporarily stored into tval)\n      Scalar tdot(0);\n      \n      // First compute q' * tval\n      tdot = m_Q.col(curIdx).dot(tval);\n\n      tdot *= m_hcoeffs(curIdx);\n      \n      // Then update tval = tval - q * tau\n      // FIXME: tval -= tdot * m_Q.col(curIdx) should amount to the same (need to check/add support for efficient \"dense ?= sparse\")\n      for (typename QRMatrixType::InnerIterator itq(m_Q, curIdx); itq; ++itq)\n        tval(itq.row()) -= itq.value() * tdot;\n\n      // Detect fill-in for the current column of Q\n      if(m_etree(Ridx(i)) == nonzeroCol)\n      {\n        for (typename QRMatrixType::InnerIterator itq(m_Q, curIdx); itq; ++itq)\n        {\n          StorageIndex iQ = StorageIndex(itq.row());\n          if (mark(iQ) != col)\n          {\n            Qidx(nzcolQ++) = iQ;  // Add this row to the pattern of Q,\n            mark(iQ) = col;       // and mark it as visited\n          }\n        }\n      }\n    } // End update current column\n    \n    Scalar tau = RealScalar(0);\n    RealScalar beta = 0;\n    \n    if(nonzeroCol < diagSize)\n    {\n      // Compute the Householder reflection that eliminate the current column\n      // FIXME this step should call the Householder module.\n      Scalar c0 = nzcolQ ? tval(Qidx(0)) : Scalar(0);\n      \n      // First, the squared norm of Q((col+1):m, col)\n      RealScalar sqrNorm = 0.;\n      for (Index itq = 1; itq < nzcolQ; ++itq) sqrNorm += numext::abs2(tval(Qidx(itq)));\n      if(sqrNorm == RealScalar(0) && numext::imag(c0) == RealScalar(0))\n      {\n        beta = numext::real(c0);\n        tval(Qidx(0)) = 1;\n      }\n      else\n      {\n        using std::sqrt;\n        beta = sqrt(numext::abs2(c0) + sqrNorm);\n        if(numext::real(c0) >= RealScalar(0))\n          beta = -beta;\n        tval(Qidx(0)) = 1;\n        for (Index itq = 1; itq < nzcolQ; ++itq)\n          tval(Qidx(itq)) /= (c0 - beta);\n        tau = numext::conj((beta-c0) / beta);\n          \n      }\n    }\n\n    // Insert values in R\n    for (Index  i = nzcolR-1; i >= 0; i--)\n    {\n      Index curIdx = Ridx(i);\n      if(curIdx < nonzeroCol) \n      {\n        m_R.insertBackByOuterInnerUnordered(col, curIdx) = tval(curIdx);\n        tval(curIdx) = Scalar(0.);\n      }\n    }\n\n    if(nonzeroCol < diagSize && abs(beta) >= pivotThreshold)\n    {\n      m_R.insertBackByOuterInner(col, nonzeroCol) = beta;\n      // The householder coefficient\n      m_hcoeffs(nonzeroCol) = tau;\n      // Record the householder reflections\n      for (Index itq = 0; itq < nzcolQ; ++itq)\n      {\n        Index iQ = Qidx(itq);\n        m_Q.insertBackByOuterInnerUnordered(nonzeroCol,iQ) = tval(iQ);\n        tval(iQ) = Scalar(0.);\n      }\n      nonzeroCol++;\n      if(nonzeroCol<diagSize)\n        m_Q.startVec(nonzeroCol);\n    }\n    else\n    {\n      // Zero pivot found: move implicitly this column to the end\n      for (Index j = nonzeroCol; j < n-1; j++) \n        std::swap(m_pivotperm.indices()(j), m_pivotperm.indices()[j+1]);\n      \n      // Recompute the column elimination tree\n      internal::coletree(m_pmat, m_etree, m_firstRowElt, m_pivotperm.indices().data());\n      m_isEtreeOk = false;\n    }\n  }\n  \n  m_hcoeffs.tail(diagSize-nonzeroCol).setZero();\n  \n  // Finalize the column pointers of the sparse matrices R and Q\n  m_Q.finalize();\n  m_Q.makeCompressed();\n  m_R.finalize();\n  m_R.makeCompressed();\n  m_isQSorted = false;\n\n  m_nonzeropivots = nonzeroCol;\n  \n  if(nonzeroCol<n)\n  {\n    // Permute the triangular factor to put the 'dead' columns to the end\n    QRMatrixType tempR(m_R);\n    m_R = tempR * m_pivotperm;\n    \n    // Update the column permutation\n    m_outputPerm_c = m_outputPerm_c * m_pivotperm;\n  }\n  \n  m_isInitialized = true; \n  m_factorizationIsok = true;\n  m_info = Success;\n}\n\ntemplate <typename SparseQRType, typename Derived>\nstruct SparseQR_QProduct : ReturnByValue<SparseQR_QProduct<SparseQRType, Derived> >\n{\n  typedef typename SparseQRType::QRMatrixType MatrixType;\n  typedef typename SparseQRType::Scalar Scalar;\n  // Get the references \n  SparseQR_QProduct(const SparseQRType& qr, const Derived& other, bool transpose) : \n  m_qr(qr),m_other(other),m_transpose(transpose) {}\n  inline Index rows() const { return m_transpose ? m_qr.rows() : m_qr.cols(); }\n  inline Index cols() const { return m_other.cols(); }\n  \n  // Assign to a vector\n  template<typename DesType>\n  void evalTo(DesType& res) const\n  {\n    Index m = m_qr.rows();\n    Index n = m_qr.cols();\n    Index diagSize = (std::min)(m,n);\n    res = m_other;\n    if (m_transpose)\n    {\n      eigen_assert(m_qr.m_Q.rows() == m_other.rows() && \"Non conforming object sizes\");\n      //Compute res = Q' * other column by column\n      for(Index j = 0; j < res.cols(); j++){\n        for (Index k = 0; k < diagSize; k++)\n        {\n          Scalar tau = Scalar(0);\n          tau = m_qr.m_Q.col(k).dot(res.col(j));\n          if(tau==Scalar(0)) continue;\n          tau = tau * m_qr.m_hcoeffs(k);\n          res.col(j) -= tau * m_qr.m_Q.col(k);\n        }\n      }\n    }\n    else\n    {\n      eigen_assert(m_qr.m_Q.rows() == m_other.rows() && \"Non conforming object sizes\");\n      // Compute res = Q * other column by column\n      for(Index j = 0; j < res.cols(); j++)\n      {\n        for (Index k = diagSize-1; k >=0; k--)\n        {\n          Scalar tau = Scalar(0);\n          tau = m_qr.m_Q.col(k).dot(res.col(j));\n          if(tau==Scalar(0)) continue;\n          tau = tau * m_qr.m_hcoeffs(k);\n          res.col(j) -= tau * m_qr.m_Q.col(k);\n        }\n      }\n    }\n  }\n  \n  const SparseQRType& m_qr;\n  const Derived& m_other;\n  bool m_transpose;\n};\n\ntemplate<typename SparseQRType>\nstruct SparseQRMatrixQReturnType : public EigenBase<SparseQRMatrixQReturnType<SparseQRType> >\n{  \n  typedef typename SparseQRType::Scalar Scalar;\n  typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;\n  enum {\n    RowsAtCompileTime = Dynamic,\n    ColsAtCompileTime = Dynamic\n  };\n  explicit SparseQRMatrixQReturnType(const SparseQRType& qr) : m_qr(qr) {}\n  template<typename Derived>\n  SparseQR_QProduct<SparseQRType, Derived> operator*(const MatrixBase<Derived>& other)\n  {\n    return SparseQR_QProduct<SparseQRType,Derived>(m_qr,other.derived(),false);\n  }\n  SparseQRMatrixQTransposeReturnType<SparseQRType> adjoint() const\n  {\n    return SparseQRMatrixQTransposeReturnType<SparseQRType>(m_qr);\n  }\n  inline Index rows() const { return m_qr.rows(); }\n  inline Index cols() const { return (std::min)(m_qr.rows(),m_qr.cols()); }\n  // To use for operations with the transpose of Q\n  SparseQRMatrixQTransposeReturnType<SparseQRType> transpose() const\n  {\n    return SparseQRMatrixQTransposeReturnType<SparseQRType>(m_qr);\n  }\n  const SparseQRType& m_qr;\n};\n\ntemplate<typename SparseQRType>\nstruct SparseQRMatrixQTransposeReturnType\n{\n  explicit SparseQRMatrixQTransposeReturnType(const SparseQRType& qr) : m_qr(qr) {}\n  template<typename Derived>\n  SparseQR_QProduct<SparseQRType,Derived> operator*(const MatrixBase<Derived>& other)\n  {\n    return SparseQR_QProduct<SparseQRType,Derived>(m_qr,other.derived(), true);\n  }\n  const SparseQRType& m_qr;\n};\n\nnamespace internal {\n  \ntemplate<typename SparseQRType>\nstruct evaluator_traits<SparseQRMatrixQReturnType<SparseQRType> >\n{\n  typedef typename SparseQRType::MatrixType MatrixType;\n  typedef typename storage_kind_to_evaluator_kind<typename MatrixType::StorageKind>::Kind Kind;\n  typedef SparseShape Shape;\n};\n\ntemplate< typename DstXprType, typename SparseQRType>\nstruct Assignment<DstXprType, SparseQRMatrixQReturnType<SparseQRType>, internal::assign_op<typename DstXprType::Scalar,typename DstXprType::Scalar>, Sparse2Sparse>\n{\n  typedef SparseQRMatrixQReturnType<SparseQRType> SrcXprType;\n  typedef typename DstXprType::Scalar Scalar;\n  typedef typename DstXprType::StorageIndex StorageIndex;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,Scalar> &/*func*/)\n  {\n    typename DstXprType::PlainObject idMat(src.m_qr.rows(), src.m_qr.rows());\n    idMat.setIdentity();\n    // Sort the sparse householder reflectors if needed\n    const_cast<SparseQRType *>(&src.m_qr)->_sort_matrix_Q();\n    dst = SparseQR_QProduct<SparseQRType, DstXprType>(src.m_qr, idMat, false);\n  }\n};\n\ntemplate< typename DstXprType, typename SparseQRType>\nstruct Assignment<DstXprType, SparseQRMatrixQReturnType<SparseQRType>, internal::assign_op<typename DstXprType::Scalar,typename DstXprType::Scalar>, Sparse2Dense>\n{\n  typedef SparseQRMatrixQReturnType<SparseQRType> SrcXprType;\n  typedef typename DstXprType::Scalar Scalar;\n  typedef typename DstXprType::StorageIndex StorageIndex;\n  static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,Scalar> &/*func*/)\n  {\n    dst = src.m_qr.matrixQ() * DstXprType::Identity(src.m_qr.rows(), src.m_qr.rows());\n  }\n};\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/StlSupport/StdDeque.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_STDDEQUE_H\n#define EIGEN_STDDEQUE_H\n\n#include \"details.h\"\n\n/**\n * This section contains a convenience MACRO which allows an easy specialization of\n * std::deque such that for data types with alignment issues the correct allocator\n * is used automatically.\n */\n#define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) \\\nnamespace std \\\n{ \\\n  template<> \\\n  class deque<__VA_ARGS__, std::allocator<__VA_ARGS__> >           \\\n    : public deque<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \\\n  { \\\n    typedef deque<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > deque_base; \\\n  public: \\\n    typedef __VA_ARGS__ value_type; \\\n    typedef deque_base::allocator_type allocator_type; \\\n    typedef deque_base::size_type size_type;  \\\n    typedef deque_base::iterator iterator;  \\\n    explicit deque(const allocator_type& a = allocator_type()) : deque_base(a) {}  \\\n    template<typename InputIterator> \\\n    deque(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : deque_base(first, last, a) {} \\\n    deque(const deque& c) : deque_base(c) {}  \\\n    explicit deque(size_type num, const value_type& val = value_type()) : deque_base(num, val) {} \\\n    deque(iterator start, iterator end) : deque_base(start, end) {}  \\\n    deque& operator=(const deque& x) {  \\\n      deque_base::operator=(x);  \\\n      return *this;  \\\n    } \\\n  }; \\\n}\n\n// check whether we really need the std::deque specialization\n#if !EIGEN_HAS_CXX11_CONTAINERS && !(defined(_GLIBCXX_DEQUE) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::deque::resize(size_type,const T&). */\n\nnamespace std {\n\n#define EIGEN_STD_DEQUE_SPECIALIZATION_BODY \\\n  public:  \\\n    typedef T value_type; \\\n    typedef typename deque_base::allocator_type allocator_type; \\\n    typedef typename deque_base::size_type size_type;  \\\n    typedef typename deque_base::iterator iterator;  \\\n    typedef typename deque_base::const_iterator const_iterator;  \\\n    explicit deque(const allocator_type& a = allocator_type()) : deque_base(a) {}  \\\n    template<typename InputIterator> \\\n    deque(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \\\n    : deque_base(first, last, a) {} \\\n    deque(const deque& c) : deque_base(c) {}  \\\n    explicit deque(size_type num, const value_type& val = value_type()) : deque_base(num, val) {} \\\n    deque(iterator start, iterator end) : deque_base(start, end) {}  \\\n    deque& operator=(const deque& x) {  \\\n      deque_base::operator=(x);  \\\n      return *this;  \\\n    }\n\n  template<typename T>\n  class deque<T,EIGEN_ALIGNED_ALLOCATOR<T> >\n    : public deque<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n                   Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >\n{\n  typedef deque<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n                Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > deque_base;\n  EIGEN_STD_DEQUE_SPECIALIZATION_BODY\n\n  void resize(size_type new_size)\n  { resize(new_size, T()); }\n\n#if defined(_DEQUE_)\n  // workaround MSVC std::deque implementation\n  void resize(size_type new_size, const value_type& x)\n  {\n    if (deque_base::size() < new_size)\n      deque_base::_Insert_n(deque_base::end(), new_size - deque_base::size(), x);\n    else if (new_size < deque_base::size())\n      deque_base::erase(deque_base::begin() + new_size, deque_base::end());\n  }\n  void push_back(const value_type& x)\n  { deque_base::push_back(x); } \n  void push_front(const value_type& x)\n  { deque_base::push_front(x); }\n  using deque_base::insert;  \n  iterator insert(const_iterator position, const value_type& x)\n  { return deque_base::insert(position,x); }\n  void insert(const_iterator position, size_type new_size, const value_type& x)\n  { deque_base::insert(position, new_size, x); }\n#elif defined(_GLIBCXX_DEQUE) && EIGEN_GNUC_AT_LEAST(4,2)\n  // workaround GCC std::deque implementation\n  void resize(size_type new_size, const value_type& x)\n  {\n    if (new_size < deque_base::size())\n      deque_base::_M_erase_at_end(this->_M_impl._M_start + new_size);\n    else\n      deque_base::insert(deque_base::end(), new_size - deque_base::size(), x);\n  }\n#else\n  // either GCC 4.1 or non-GCC\n  // default implementation which should always work.\n  void resize(size_type new_size, const value_type& x)\n  {\n    if (new_size < deque_base::size())\n      deque_base::erase(deque_base::begin() + new_size, deque_base::end());\n    else if (new_size > deque_base::size())\n      deque_base::insert(deque_base::end(), new_size - deque_base::size(), x);\n  }\n#endif\n  };\n}\n\n#endif // check whether specialization is actually required\n\n#endif // EIGEN_STDDEQUE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/StlSupport/StdList.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_STDLIST_H\n#define EIGEN_STDLIST_H\n\n#include \"details.h\"\n\n/**\n * This section contains a convenience MACRO which allows an easy specialization of\n * std::list such that for data types with alignment issues the correct allocator\n * is used automatically.\n */\n#define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) \\\nnamespace std \\\n{ \\\n  template<> \\\n  class list<__VA_ARGS__, std::allocator<__VA_ARGS__> >           \\\n    : public list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \\\n  { \\\n    typedef list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > list_base; \\\n  public: \\\n    typedef __VA_ARGS__ value_type; \\\n    typedef list_base::allocator_type allocator_type; \\\n    typedef list_base::size_type size_type;  \\\n    typedef list_base::iterator iterator;  \\\n    explicit list(const allocator_type& a = allocator_type()) : list_base(a) {}  \\\n    template<typename InputIterator> \\\n    list(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : list_base(first, last, a) {} \\\n    list(const list& c) : list_base(c) {}  \\\n    explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \\\n    list(iterator start, iterator end) : list_base(start, end) {}  \\\n    list& operator=(const list& x) {  \\\n      list_base::operator=(x);  \\\n      return *this;  \\\n    } \\\n  }; \\\n}\n\n// check whether we really need the std::list specialization\n#if !EIGEN_HAS_CXX11_CONTAINERS && !(defined(_GLIBCXX_LIST) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::list::resize(size_type,const T&). */\n\nnamespace std\n{\n\n#define EIGEN_STD_LIST_SPECIALIZATION_BODY \\\n  public:  \\\n    typedef T value_type; \\\n    typedef typename list_base::allocator_type allocator_type; \\\n    typedef typename list_base::size_type size_type;  \\\n    typedef typename list_base::iterator iterator;  \\\n    typedef typename list_base::const_iterator const_iterator;  \\\n    explicit list(const allocator_type& a = allocator_type()) : list_base(a) {}  \\\n    template<typename InputIterator> \\\n    list(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \\\n    : list_base(first, last, a) {} \\\n    list(const list& c) : list_base(c) {}  \\\n    explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \\\n    list(iterator start, iterator end) : list_base(start, end) {}  \\\n    list& operator=(const list& x) {  \\\n    list_base::operator=(x);  \\\n    return *this; \\\n  }\n\n  template<typename T>\n  class list<T,EIGEN_ALIGNED_ALLOCATOR<T> >\n    : public list<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n                  Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >\n  {\n    typedef list<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n                 Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > list_base;\n    EIGEN_STD_LIST_SPECIALIZATION_BODY\n\n    void resize(size_type new_size)\n    { resize(new_size, T()); }\n\n    void resize(size_type new_size, const value_type& x)\n    {\n      if (list_base::size() < new_size)\n        list_base::insert(list_base::end(), new_size - list_base::size(), x);\n      else\n        while (new_size < list_base::size()) list_base::pop_back();\n    }\n\n#if defined(_LIST_)\n    // workaround MSVC std::list implementation\n    void push_back(const value_type& x)\n    { list_base::push_back(x); } \n    using list_base::insert;  \n    iterator insert(const_iterator position, const value_type& x)\n    { return list_base::insert(position,x); }\n    void insert(const_iterator position, size_type new_size, const value_type& x)\n    { list_base::insert(position, new_size, x); }\n#endif\n  };\n}\n\n#endif // check whether specialization is actually required\n\n#endif // EIGEN_STDLIST_H\n"
  },
  {
    "path": "include/externals/Eigen/src/StlSupport/StdVector.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_STDVECTOR_H\n#define EIGEN_STDVECTOR_H\n\n#include \"details.h\"\n\n/**\n * This section contains a convenience MACRO which allows an easy specialization of\n * std::vector such that for data types with alignment issues the correct allocator\n * is used automatically.\n */\n#define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) \\\nnamespace std \\\n{ \\\n  template<> \\\n  class vector<__VA_ARGS__, std::allocator<__VA_ARGS__> >  \\\n    : public vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \\\n  { \\\n    typedef vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > vector_base; \\\n  public: \\\n    typedef __VA_ARGS__ value_type; \\\n    typedef vector_base::allocator_type allocator_type; \\\n    typedef vector_base::size_type size_type;  \\\n    typedef vector_base::iterator iterator;  \\\n    explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {}  \\\n    template<typename InputIterator> \\\n    vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : vector_base(first, last, a) {} \\\n    vector(const vector& c) : vector_base(c) {}  \\\n    explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \\\n    vector(iterator start, iterator end) : vector_base(start, end) {}  \\\n    vector& operator=(const vector& x) {  \\\n      vector_base::operator=(x);  \\\n      return *this;  \\\n    } \\\n  }; \\\n}\n\n// Don't specialize if containers are implemented according to C++11\n#if !EIGEN_HAS_CXX11_CONTAINERS\n\nnamespace std {\n\n#define EIGEN_STD_VECTOR_SPECIALIZATION_BODY \\\n  public:  \\\n    typedef T value_type; \\\n    typedef typename vector_base::allocator_type allocator_type; \\\n    typedef typename vector_base::size_type size_type;  \\\n    typedef typename vector_base::iterator iterator;  \\\n    typedef typename vector_base::const_iterator const_iterator;  \\\n    explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {}  \\\n    template<typename InputIterator> \\\n    vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \\\n    : vector_base(first, last, a) {} \\\n    vector(const vector& c) : vector_base(c) {}  \\\n    explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \\\n    vector(iterator start, iterator end) : vector_base(start, end) {}  \\\n    vector& operator=(const vector& x) {  \\\n      vector_base::operator=(x);  \\\n      return *this;  \\\n    }\n\n  template<typename T>\n  class vector<T,EIGEN_ALIGNED_ALLOCATOR<T> >\n    : public vector<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n                    Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >\n{\n  typedef vector<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n                 Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > vector_base;\n  EIGEN_STD_VECTOR_SPECIALIZATION_BODY\n\n  void resize(size_type new_size)\n  { resize(new_size, T()); }\n\n#if defined(_VECTOR_)\n  // workaround MSVC std::vector implementation\n  void resize(size_type new_size, const value_type& x)\n  {\n    if (vector_base::size() < new_size)\n      vector_base::_Insert_n(vector_base::end(), new_size - vector_base::size(), x);\n    else if (new_size < vector_base::size())\n      vector_base::erase(vector_base::begin() + new_size, vector_base::end());\n  }\n  void push_back(const value_type& x)\n  { vector_base::push_back(x); } \n  using vector_base::insert;  \n  iterator insert(const_iterator position, const value_type& x)\n  { return vector_base::insert(position,x); }\n  void insert(const_iterator position, size_type new_size, const value_type& x)\n  { vector_base::insert(position, new_size, x); }\n#elif defined(_GLIBCXX_VECTOR) && (!(EIGEN_GNUC_AT_LEAST(4,1)))\n  /* Note that before gcc-4.1 we already have: std::vector::resize(size_type,const T&).\n   * However, this specialization is still needed to make the above EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION trick to work. */\n  void resize(size_type new_size, const value_type& x)\n  {\n    vector_base::resize(new_size,x);\n  }\n#elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,2)\n  // workaround GCC std::vector implementation\n  void resize(size_type new_size, const value_type& x)\n  {\n    if (new_size < vector_base::size())\n      vector_base::_M_erase_at_end(this->_M_impl._M_start + new_size);\n    else\n      vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);\n  }\n#else\n  // either GCC 4.1 or non-GCC\n  // default implementation which should always work.\n  void resize(size_type new_size, const value_type& x)\n  {\n    if (new_size < vector_base::size())\n      vector_base::erase(vector_base::begin() + new_size, vector_base::end());\n    else if (new_size > vector_base::size())\n      vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);\n  }\n#endif\n  };\n}\n#endif // !EIGEN_HAS_CXX11_CONTAINERS\n\n\n#endif // EIGEN_STDVECTOR_H\n"
  },
  {
    "path": "include/externals/Eigen/src/StlSupport/details.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_STL_DETAILS_H\n#define EIGEN_STL_DETAILS_H\n\n#ifndef EIGEN_ALIGNED_ALLOCATOR\n  #define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator\n#endif\n\nnamespace Eigen {\n\n  // This one is needed to prevent reimplementing the whole std::vector.\n  template <class T>\n  class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR<T>\n  {\n  public:\n    typedef std::size_t     size_type;\n    typedef std::ptrdiff_t  difference_type;\n    typedef T*              pointer;\n    typedef const T*        const_pointer;\n    typedef T&              reference;\n    typedef const T&        const_reference;\n    typedef T               value_type;\n\n    template<class U>\n    struct rebind\n    {\n      typedef aligned_allocator_indirection<U> other;\n    };\n\n    aligned_allocator_indirection() {}\n    aligned_allocator_indirection(const aligned_allocator_indirection& ) : EIGEN_ALIGNED_ALLOCATOR<T>() {}\n    aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR<T>& ) {}\n    template<class U>\n    aligned_allocator_indirection(const aligned_allocator_indirection<U>& ) {}\n    template<class U>\n    aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR<U>& ) {}\n    ~aligned_allocator_indirection() {}\n  };\n\n#if EIGEN_COMP_MSVC\n\n  // sometimes, MSVC detects, at compile time, that the argument x\n  // in std::vector::resize(size_t s,T x) won't be aligned and generate an error\n  // even if this function is never called. Whence this little wrapper.\n#define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \\\n  typename Eigen::internal::conditional< \\\n    Eigen::internal::is_arithmetic<T>::value, \\\n    T, \\\n    Eigen::internal::workaround_msvc_stl_support<T> \\\n  >::type\n\n  namespace internal {\n  template<typename T> struct workaround_msvc_stl_support : public T\n  {\n    inline workaround_msvc_stl_support() : T() {}\n    inline workaround_msvc_stl_support(const T& other) : T(other) {}\n    inline operator T& () { return *static_cast<T*>(this); }\n    inline operator const T& () const { return *static_cast<const T*>(this); }\n    template<typename OtherT>\n    inline T& operator=(const OtherT& other)\n    { T::operator=(other); return *this; }\n    inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other)\n    { T::operator=(other); return *this; }\n  };\n  }\n\n#else\n\n#define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T\n\n#endif\n\n}\n\n#endif // EIGEN_STL_DETAILS_H\n"
  },
  {
    "path": "include/externals/Eigen/src/SuperLUSupport/SuperLUSupport.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_SUPERLUSUPPORT_H\n#define EIGEN_SUPERLUSUPPORT_H\n\nnamespace Eigen {\n\n#if defined(SUPERLU_MAJOR_VERSION) && (SUPERLU_MAJOR_VERSION >= 5)\n#define DECL_GSSVX(PREFIX,FLOATTYPE,KEYTYPE)\t\t\\\n    extern \"C\" {                                                                                          \\\n      extern void PREFIX##gssvx(superlu_options_t *, SuperMatrix *, int *, int *, int *,                  \\\n                                char *, FLOATTYPE *, FLOATTYPE *, SuperMatrix *, SuperMatrix *,           \\\n                                void *, int, SuperMatrix *, SuperMatrix *,                                \\\n                                FLOATTYPE *, FLOATTYPE *, FLOATTYPE *, FLOATTYPE *,                       \\\n                                GlobalLU_t *, mem_usage_t *, SuperLUStat_t *, int *);                     \\\n    }                                                                                                     \\\n    inline float SuperLU_gssvx(superlu_options_t *options, SuperMatrix *A,                                \\\n         int *perm_c, int *perm_r, int *etree, char *equed,                                               \\\n         FLOATTYPE *R, FLOATTYPE *C, SuperMatrix *L,                                                      \\\n         SuperMatrix *U, void *work, int lwork,                                                           \\\n         SuperMatrix *B, SuperMatrix *X,                                                                  \\\n         FLOATTYPE *recip_pivot_growth,                                                                   \\\n         FLOATTYPE *rcond, FLOATTYPE *ferr, FLOATTYPE *berr,                                              \\\n         SuperLUStat_t *stats, int *info, KEYTYPE) {                                                      \\\n    mem_usage_t mem_usage;                                                                                \\\n    GlobalLU_t gLU;                                                                                       \\\n    PREFIX##gssvx(options, A, perm_c, perm_r, etree, equed, R, C, L,                                      \\\n         U, work, lwork, B, X, recip_pivot_growth, rcond,                                                 \\\n         ferr, berr, &gLU, &mem_usage, stats, info);                                                      \\\n    return mem_usage.for_lu; /* bytes used by the factor storage */                                       \\\n  }\n#else // version < 5.0\n#define DECL_GSSVX(PREFIX,FLOATTYPE,KEYTYPE)\t\t\\\n    extern \"C\" {                                                                                          \\\n      extern void PREFIX##gssvx(superlu_options_t *, SuperMatrix *, int *, int *, int *,                  \\\n                                char *, FLOATTYPE *, FLOATTYPE *, SuperMatrix *, SuperMatrix *,           \\\n                                void *, int, SuperMatrix *, SuperMatrix *,                                \\\n                                FLOATTYPE *, FLOATTYPE *, FLOATTYPE *, FLOATTYPE *,                       \\\n                                mem_usage_t *, SuperLUStat_t *, int *);                                   \\\n    }                                                                                                     \\\n    inline float SuperLU_gssvx(superlu_options_t *options, SuperMatrix *A,                                \\\n         int *perm_c, int *perm_r, int *etree, char *equed,                                               \\\n         FLOATTYPE *R, FLOATTYPE *C, SuperMatrix *L,                                                      \\\n         SuperMatrix *U, void *work, int lwork,                                                           \\\n         SuperMatrix *B, SuperMatrix *X,                                                                  \\\n         FLOATTYPE *recip_pivot_growth,                                                                   \\\n         FLOATTYPE *rcond, FLOATTYPE *ferr, FLOATTYPE *berr,                                              \\\n         SuperLUStat_t *stats, int *info, KEYTYPE) {                                                      \\\n    mem_usage_t mem_usage;                                                                                \\\n    PREFIX##gssvx(options, A, perm_c, perm_r, etree, equed, R, C, L,                                      \\\n         U, work, lwork, B, X, recip_pivot_growth, rcond,                                                 \\\n         ferr, berr, &mem_usage, stats, info);                                                            \\\n    return mem_usage.for_lu; /* bytes used by the factor storage */                                       \\\n  }\n#endif\n\nDECL_GSSVX(s,float,float)\nDECL_GSSVX(c,float,std::complex<float>)\nDECL_GSSVX(d,double,double)\nDECL_GSSVX(z,double,std::complex<double>)\n\n#ifdef MILU_ALPHA\n#define EIGEN_SUPERLU_HAS_ILU\n#endif\n\n#ifdef EIGEN_SUPERLU_HAS_ILU\n\n// similarly for the incomplete factorization using gsisx\n#define DECL_GSISX(PREFIX,FLOATTYPE,KEYTYPE)                                                    \\\n    extern \"C\" {                                                                                \\\n      extern void PREFIX##gsisx(superlu_options_t *, SuperMatrix *, int *, int *, int *,        \\\n                         char *, FLOATTYPE *, FLOATTYPE *, SuperMatrix *, SuperMatrix *,        \\\n                         void *, int, SuperMatrix *, SuperMatrix *, FLOATTYPE *, FLOATTYPE *,   \\\n                         mem_usage_t *, SuperLUStat_t *, int *);                        \\\n    }                                                                                           \\\n    inline float SuperLU_gsisx(superlu_options_t *options, SuperMatrix *A,                      \\\n         int *perm_c, int *perm_r, int *etree, char *equed,                                     \\\n         FLOATTYPE *R, FLOATTYPE *C, SuperMatrix *L,                                            \\\n         SuperMatrix *U, void *work, int lwork,                                                 \\\n         SuperMatrix *B, SuperMatrix *X,                                                        \\\n         FLOATTYPE *recip_pivot_growth,                                                         \\\n         FLOATTYPE *rcond,                                                                      \\\n         SuperLUStat_t *stats, int *info, KEYTYPE) {                                            \\\n    mem_usage_t mem_usage;                                                              \\\n    PREFIX##gsisx(options, A, perm_c, perm_r, etree, equed, R, C, L,                            \\\n         U, work, lwork, B, X, recip_pivot_growth, rcond,                                       \\\n         &mem_usage, stats, info);                                                              \\\n    return mem_usage.for_lu; /* bytes used by the factor storage */                             \\\n  }\n\nDECL_GSISX(s,float,float)\nDECL_GSISX(c,float,std::complex<float>)\nDECL_GSISX(d,double,double)\nDECL_GSISX(z,double,std::complex<double>)\n\n#endif\n\ntemplate<typename MatrixType>\nstruct SluMatrixMapHelper;\n\n/** \\internal\n  *\n  * A wrapper class for SuperLU matrices. It supports only compressed sparse matrices\n  * and dense matrices. Supernodal and other fancy format are not supported by this wrapper.\n  *\n  * This wrapper class mainly aims to avoids the need of dynamic allocation of the storage structure.\n  */\nstruct SluMatrix : SuperMatrix\n{\n  SluMatrix()\n  {\n    Store = &storage;\n  }\n\n  SluMatrix(const SluMatrix& other)\n    : SuperMatrix(other)\n  {\n    Store = &storage;\n    storage = other.storage;\n  }\n\n  SluMatrix& operator=(const SluMatrix& other)\n  {\n    SuperMatrix::operator=(static_cast<const SuperMatrix&>(other));\n    Store = &storage;\n    storage = other.storage;\n    return *this;\n  }\n\n  struct\n  {\n    union {int nnz;int lda;};\n    void *values;\n    int *innerInd;\n    int *outerInd;\n  } storage;\n\n  void setStorageType(Stype_t t)\n  {\n    Stype = t;\n    if (t==SLU_NC || t==SLU_NR || t==SLU_DN)\n      Store = &storage;\n    else\n    {\n      eigen_assert(false && \"storage type not supported\");\n      Store = 0;\n    }\n  }\n\n  template<typename Scalar>\n  void setScalarType()\n  {\n    if (internal::is_same<Scalar,float>::value)\n      Dtype = SLU_S;\n    else if (internal::is_same<Scalar,double>::value)\n      Dtype = SLU_D;\n    else if (internal::is_same<Scalar,std::complex<float> >::value)\n      Dtype = SLU_C;\n    else if (internal::is_same<Scalar,std::complex<double> >::value)\n      Dtype = SLU_Z;\n    else\n    {\n      eigen_assert(false && \"Scalar type not supported by SuperLU\");\n    }\n  }\n\n  template<typename MatrixType>\n  static SluMatrix Map(MatrixBase<MatrixType>& _mat)\n  {\n    MatrixType& mat(_mat.derived());\n    eigen_assert( ((MatrixType::Flags&RowMajorBit)!=RowMajorBit) && \"row-major dense matrices are not supported by SuperLU\");\n    SluMatrix res;\n    res.setStorageType(SLU_DN);\n    res.setScalarType<typename MatrixType::Scalar>();\n    res.Mtype     = SLU_GE;\n\n    res.nrow      = internal::convert_index<int>(mat.rows());\n    res.ncol      = internal::convert_index<int>(mat.cols());\n\n    res.storage.lda       = internal::convert_index<int>(MatrixType::IsVectorAtCompileTime ? mat.size() : mat.outerStride());\n    res.storage.values    = (void*)(mat.data());\n    return res;\n  }\n\n  template<typename MatrixType>\n  static SluMatrix Map(SparseMatrixBase<MatrixType>& a_mat)\n  {\n    MatrixType &mat(a_mat.derived());\n    SluMatrix res;\n    if ((MatrixType::Flags&RowMajorBit)==RowMajorBit)\n    {\n      res.setStorageType(SLU_NR);\n      res.nrow      = internal::convert_index<int>(mat.cols());\n      res.ncol      = internal::convert_index<int>(mat.rows());\n    }\n    else\n    {\n      res.setStorageType(SLU_NC);\n      res.nrow      = internal::convert_index<int>(mat.rows());\n      res.ncol      = internal::convert_index<int>(mat.cols());\n    }\n\n    res.Mtype       = SLU_GE;\n\n    res.storage.nnz       = internal::convert_index<int>(mat.nonZeros());\n    res.storage.values    = mat.valuePtr();\n    res.storage.innerInd  = mat.innerIndexPtr();\n    res.storage.outerInd  = mat.outerIndexPtr();\n\n    res.setScalarType<typename MatrixType::Scalar>();\n\n    // FIXME the following is not very accurate\n    if (MatrixType::Flags & Upper)\n      res.Mtype = SLU_TRU;\n    if (MatrixType::Flags & Lower)\n      res.Mtype = SLU_TRL;\n\n    eigen_assert(((MatrixType::Flags & SelfAdjoint)==0) && \"SelfAdjoint matrix shape not supported by SuperLU\");\n\n    return res;\n  }\n};\n\ntemplate<typename Scalar, int Rows, int Cols, int Options, int MRows, int MCols>\nstruct SluMatrixMapHelper<Matrix<Scalar,Rows,Cols,Options,MRows,MCols> >\n{\n  typedef Matrix<Scalar,Rows,Cols,Options,MRows,MCols> MatrixType;\n  static void run(MatrixType& mat, SluMatrix& res)\n  {\n    eigen_assert( ((Options&RowMajor)!=RowMajor) && \"row-major dense matrices is not supported by SuperLU\");\n    res.setStorageType(SLU_DN);\n    res.setScalarType<Scalar>();\n    res.Mtype     = SLU_GE;\n\n    res.nrow      = mat.rows();\n    res.ncol      = mat.cols();\n\n    res.storage.lda       = mat.outerStride();\n    res.storage.values    = mat.data();\n  }\n};\n\ntemplate<typename Derived>\nstruct SluMatrixMapHelper<SparseMatrixBase<Derived> >\n{\n  typedef Derived MatrixType;\n  static void run(MatrixType& mat, SluMatrix& res)\n  {\n    if ((MatrixType::Flags&RowMajorBit)==RowMajorBit)\n    {\n      res.setStorageType(SLU_NR);\n      res.nrow      = mat.cols();\n      res.ncol      = mat.rows();\n    }\n    else\n    {\n      res.setStorageType(SLU_NC);\n      res.nrow      = mat.rows();\n      res.ncol      = mat.cols();\n    }\n\n    res.Mtype       = SLU_GE;\n\n    res.storage.nnz       = mat.nonZeros();\n    res.storage.values    = mat.valuePtr();\n    res.storage.innerInd  = mat.innerIndexPtr();\n    res.storage.outerInd  = mat.outerIndexPtr();\n\n    res.setScalarType<typename MatrixType::Scalar>();\n\n    // FIXME the following is not very accurate\n    if (MatrixType::Flags & Upper)\n      res.Mtype = SLU_TRU;\n    if (MatrixType::Flags & Lower)\n      res.Mtype = SLU_TRL;\n\n    eigen_assert(((MatrixType::Flags & SelfAdjoint)==0) && \"SelfAdjoint matrix shape not supported by SuperLU\");\n  }\n};\n\nnamespace internal {\n\ntemplate<typename MatrixType>\nSluMatrix asSluMatrix(MatrixType& mat)\n{\n  return SluMatrix::Map(mat);\n}\n\n/** View a Super LU matrix as an Eigen expression */\ntemplate<typename Scalar, int Flags, typename Index>\nMappedSparseMatrix<Scalar,Flags,Index> map_superlu(SluMatrix& sluMat)\n{\n  eigen_assert((Flags&RowMajor)==RowMajor && sluMat.Stype == SLU_NR\n         || (Flags&ColMajor)==ColMajor && sluMat.Stype == SLU_NC);\n\n  Index outerSize = (Flags&RowMajor)==RowMajor ? sluMat.ncol : sluMat.nrow;\n\n  return MappedSparseMatrix<Scalar,Flags,Index>(\n    sluMat.nrow, sluMat.ncol, sluMat.storage.outerInd[outerSize],\n    sluMat.storage.outerInd, sluMat.storage.innerInd, reinterpret_cast<Scalar*>(sluMat.storage.values) );\n}\n\n} // end namespace internal\n\n/** \\ingroup SuperLUSupport_Module\n  * \\class SuperLUBase\n  * \\brief The base class for the direct and incomplete LU factorization of SuperLU\n  */\ntemplate<typename _MatrixType, typename Derived>\nclass SuperLUBase : public SparseSolverBase<Derived>\n{\n  protected:\n    typedef SparseSolverBase<Derived> Base;\n    using Base::derived;\n    using Base::m_isInitialized;\n  public:\n    typedef _MatrixType MatrixType;\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef Matrix<Scalar,Dynamic,1> Vector;\n    typedef Matrix<int, 1, MatrixType::ColsAtCompileTime> IntRowVectorType;\n    typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> IntColVectorType;    \n    typedef Map<PermutationMatrix<Dynamic,Dynamic,int> > PermutationMap;\n    typedef SparseMatrix<Scalar> LUMatrixType;\n    enum {\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n\n  public:\n\n    SuperLUBase() {}\n\n    ~SuperLUBase()\n    {\n      clearFactors();\n    }\n    \n    inline Index rows() const { return m_matrix.rows(); }\n    inline Index cols() const { return m_matrix.cols(); }\n    \n    /** \\returns a reference to the Super LU option object to configure the  Super LU algorithms. */\n    inline superlu_options_t& options() { return m_sluOptions; }\n    \n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful,\n      *          \\c NumericalIssue if the matrix.appears to be negative.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return m_info;\n    }\n\n    /** Computes the sparse Cholesky decomposition of \\a matrix */\n    void compute(const MatrixType& matrix)\n    {\n      derived().analyzePattern(matrix);\n      derived().factorize(matrix);\n    }\n\n    /** Performs a symbolic decomposition on the sparcity of \\a matrix.\n      *\n      * This function is particularly useful when solving for several problems having the same structure.\n      * \n      * \\sa factorize()\n      */\n    void analyzePattern(const MatrixType& /*matrix*/)\n    {\n      m_isInitialized = true;\n      m_info = Success;\n      m_analysisIsOk = true;\n      m_factorizationIsOk = false;\n    }\n    \n    template<typename Stream>\n    void dumpMemory(Stream& /*s*/)\n    {}\n    \n  protected:\n    \n    void initFactorization(const MatrixType& a)\n    {\n      set_default_options(&this->m_sluOptions);\n      \n      const Index size = a.rows();\n      m_matrix = a;\n\n      m_sluA = internal::asSluMatrix(m_matrix);\n      clearFactors();\n\n      m_p.resize(size);\n      m_q.resize(size);\n      m_sluRscale.resize(size);\n      m_sluCscale.resize(size);\n      m_sluEtree.resize(size);\n\n      // set empty B and X\n      m_sluB.setStorageType(SLU_DN);\n      m_sluB.setScalarType<Scalar>();\n      m_sluB.Mtype          = SLU_GE;\n      m_sluB.storage.values = 0;\n      m_sluB.nrow           = 0;\n      m_sluB.ncol           = 0;\n      m_sluB.storage.lda    = internal::convert_index<int>(size);\n      m_sluX                = m_sluB;\n      \n      m_extractedDataAreDirty = true;\n    }\n    \n    void init()\n    {\n      m_info = InvalidInput;\n      m_isInitialized = false;\n      m_sluL.Store = 0;\n      m_sluU.Store = 0;\n    }\n    \n    void extractData() const;\n\n    void clearFactors()\n    {\n      if(m_sluL.Store)\n        Destroy_SuperNode_Matrix(&m_sluL);\n      if(m_sluU.Store)\n        Destroy_CompCol_Matrix(&m_sluU);\n\n      m_sluL.Store = 0;\n      m_sluU.Store = 0;\n\n      memset(&m_sluL,0,sizeof m_sluL);\n      memset(&m_sluU,0,sizeof m_sluU);\n    }\n\n    // cached data to reduce reallocation, etc.\n    mutable LUMatrixType m_l;\n    mutable LUMatrixType m_u;\n    mutable IntColVectorType m_p;\n    mutable IntRowVectorType m_q;\n\n    mutable LUMatrixType m_matrix;  // copy of the factorized matrix\n    mutable SluMatrix m_sluA;\n    mutable SuperMatrix m_sluL, m_sluU;\n    mutable SluMatrix m_sluB, m_sluX;\n    mutable SuperLUStat_t m_sluStat;\n    mutable superlu_options_t m_sluOptions;\n    mutable std::vector<int> m_sluEtree;\n    mutable Matrix<RealScalar,Dynamic,1> m_sluRscale, m_sluCscale;\n    mutable Matrix<RealScalar,Dynamic,1> m_sluFerr, m_sluBerr;\n    mutable char m_sluEqued;\n\n    mutable ComputationInfo m_info;\n    int m_factorizationIsOk;\n    int m_analysisIsOk;\n    mutable bool m_extractedDataAreDirty;\n    \n  private:\n    SuperLUBase(SuperLUBase& ) { }\n};\n\n\n/** \\ingroup SuperLUSupport_Module\n  * \\class SuperLU\n  * \\brief A sparse direct LU factorization and solver based on the SuperLU library\n  *\n  * This class allows to solve for A.X = B sparse linear problems via a direct LU factorization\n  * using the SuperLU library. The sparse matrix A must be squared and invertible. The vectors or matrices\n  * X and B can be either dense or sparse.\n  *\n  * \\tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  *\n  * \\warning This class is only for the 4.x versions of SuperLU. The 3.x and 5.x versions are not supported.\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa \\ref TutorialSparseSolverConcept, class SparseLU\n  */\ntemplate<typename _MatrixType>\nclass SuperLU : public SuperLUBase<_MatrixType,SuperLU<_MatrixType> >\n{\n  public:\n    typedef SuperLUBase<_MatrixType,SuperLU> Base;\n    typedef _MatrixType MatrixType;\n    typedef typename Base::Scalar Scalar;\n    typedef typename Base::RealScalar RealScalar;\n    typedef typename Base::StorageIndex StorageIndex;\n    typedef typename Base::IntRowVectorType IntRowVectorType;\n    typedef typename Base::IntColVectorType IntColVectorType;   \n    typedef typename Base::PermutationMap PermutationMap;\n    typedef typename Base::LUMatrixType LUMatrixType;\n    typedef TriangularView<LUMatrixType, Lower|UnitDiag>  LMatrixType;\n    typedef TriangularView<LUMatrixType,  Upper>          UMatrixType;\n\n  public:\n    using Base::_solve_impl;\n\n    SuperLU() : Base() { init(); }\n\n    explicit SuperLU(const MatrixType& matrix) : Base()\n    {\n      init();\n      Base::compute(matrix);\n    }\n\n    ~SuperLU()\n    {\n    }\n    \n    /** Performs a symbolic decomposition on the sparcity of \\a matrix.\n      *\n      * This function is particularly useful when solving for several problems having the same structure.\n      * \n      * \\sa factorize()\n      */\n    void analyzePattern(const MatrixType& matrix)\n    {\n      m_info = InvalidInput;\n      m_isInitialized = false;\n      Base::analyzePattern(matrix);\n    }\n    \n    /** Performs a numeric decomposition of \\a matrix\n      *\n      * The given matrix must has the same sparcity than the matrix on which the symbolic decomposition has been performed.\n      *\n      * \\sa analyzePattern()\n      */\n    void factorize(const MatrixType& matrix);\n    \n    /** \\internal */\n    template<typename Rhs,typename Dest>\n    void _solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &dest) const;\n    \n    inline const LMatrixType& matrixL() const\n    {\n      if (m_extractedDataAreDirty) this->extractData();\n      return m_l;\n    }\n\n    inline const UMatrixType& matrixU() const\n    {\n      if (m_extractedDataAreDirty) this->extractData();\n      return m_u;\n    }\n\n    inline const IntColVectorType& permutationP() const\n    {\n      if (m_extractedDataAreDirty) this->extractData();\n      return m_p;\n    }\n\n    inline const IntRowVectorType& permutationQ() const\n    {\n      if (m_extractedDataAreDirty) this->extractData();\n      return m_q;\n    }\n    \n    Scalar determinant() const;\n    \n  protected:\n    \n    using Base::m_matrix;\n    using Base::m_sluOptions;\n    using Base::m_sluA;\n    using Base::m_sluB;\n    using Base::m_sluX;\n    using Base::m_p;\n    using Base::m_q;\n    using Base::m_sluEtree;\n    using Base::m_sluEqued;\n    using Base::m_sluRscale;\n    using Base::m_sluCscale;\n    using Base::m_sluL;\n    using Base::m_sluU;\n    using Base::m_sluStat;\n    using Base::m_sluFerr;\n    using Base::m_sluBerr;\n    using Base::m_l;\n    using Base::m_u;\n    \n    using Base::m_analysisIsOk;\n    using Base::m_factorizationIsOk;\n    using Base::m_extractedDataAreDirty;\n    using Base::m_isInitialized;\n    using Base::m_info;\n    \n    void init()\n    {\n      Base::init();\n      \n      set_default_options(&this->m_sluOptions);\n      m_sluOptions.PrintStat        = NO;\n      m_sluOptions.ConditionNumber  = NO;\n      m_sluOptions.Trans            = NOTRANS;\n      m_sluOptions.ColPerm          = COLAMD;\n    }\n    \n    \n  private:\n    SuperLU(SuperLU& ) { }\n};\n\ntemplate<typename MatrixType>\nvoid SuperLU<MatrixType>::factorize(const MatrixType& a)\n{\n  eigen_assert(m_analysisIsOk && \"You must first call analyzePattern()\");\n  if(!m_analysisIsOk)\n  {\n    m_info = InvalidInput;\n    return;\n  }\n  \n  this->initFactorization(a);\n  \n  m_sluOptions.ColPerm = COLAMD;\n  int info = 0;\n  RealScalar recip_pivot_growth, rcond;\n  RealScalar ferr, berr;\n\n  StatInit(&m_sluStat);\n  SuperLU_gssvx(&m_sluOptions, &m_sluA, m_q.data(), m_p.data(), &m_sluEtree[0],\n                &m_sluEqued, &m_sluRscale[0], &m_sluCscale[0],\n                &m_sluL, &m_sluU,\n                NULL, 0,\n                &m_sluB, &m_sluX,\n                &recip_pivot_growth, &rcond,\n                &ferr, &berr,\n                &m_sluStat, &info, Scalar());\n  StatFree(&m_sluStat);\n\n  m_extractedDataAreDirty = true;\n\n  // FIXME how to better check for errors ???\n  m_info = info == 0 ? Success : NumericalIssue;\n  m_factorizationIsOk = true;\n}\n\ntemplate<typename MatrixType>\ntemplate<typename Rhs,typename Dest>\nvoid SuperLU<MatrixType>::_solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest>& x) const\n{\n  eigen_assert(m_factorizationIsOk && \"The decomposition is not in a valid state for solving, you must first call either compute() or analyzePattern()/factorize()\");\n\n  const Index size = m_matrix.rows();\n  const Index rhsCols = b.cols();\n  eigen_assert(size==b.rows());\n\n  m_sluOptions.Trans = NOTRANS;\n  m_sluOptions.Fact = FACTORED;\n  m_sluOptions.IterRefine = NOREFINE;\n  \n\n  m_sluFerr.resize(rhsCols);\n  m_sluBerr.resize(rhsCols);\n  \n  Ref<const Matrix<typename Rhs::Scalar,Dynamic,Dynamic,ColMajor> > b_ref(b);\n  Ref<const Matrix<typename Dest::Scalar,Dynamic,Dynamic,ColMajor> > x_ref(x);\n  \n  m_sluB = SluMatrix::Map(b_ref.const_cast_derived());\n  m_sluX = SluMatrix::Map(x_ref.const_cast_derived());\n  \n  typename Rhs::PlainObject b_cpy;\n  if(m_sluEqued!='N')\n  {\n    b_cpy = b;\n    m_sluB = SluMatrix::Map(b_cpy.const_cast_derived());  \n  }\n\n  StatInit(&m_sluStat);\n  int info = 0;\n  RealScalar recip_pivot_growth, rcond;\n  SuperLU_gssvx(&m_sluOptions, &m_sluA,\n                m_q.data(), m_p.data(),\n                &m_sluEtree[0], &m_sluEqued,\n                &m_sluRscale[0], &m_sluCscale[0],\n                &m_sluL, &m_sluU,\n                NULL, 0,\n                &m_sluB, &m_sluX,\n                &recip_pivot_growth, &rcond,\n                &m_sluFerr[0], &m_sluBerr[0],\n                &m_sluStat, &info, Scalar());\n  StatFree(&m_sluStat);\n  \n  if(x.derived().data() != x_ref.data())\n    x = x_ref;\n  \n  m_info = info==0 ? Success : NumericalIssue;\n}\n\n// the code of this extractData() function has been adapted from the SuperLU's Matlab support code,\n//\n//  Copyright (c) 1994 by Xerox Corporation.  All rights reserved.\n//\n//  THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n//  EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.\n//\ntemplate<typename MatrixType, typename Derived>\nvoid SuperLUBase<MatrixType,Derived>::extractData() const\n{\n  eigen_assert(m_factorizationIsOk && \"The decomposition is not in a valid state for extracting factors, you must first call either compute() or analyzePattern()/factorize()\");\n  if (m_extractedDataAreDirty)\n  {\n    int         upper;\n    int         fsupc, istart, nsupr;\n    int         lastl = 0, lastu = 0;\n    SCformat    *Lstore = static_cast<SCformat*>(m_sluL.Store);\n    NCformat    *Ustore = static_cast<NCformat*>(m_sluU.Store);\n    Scalar      *SNptr;\n\n    const Index size = m_matrix.rows();\n    m_l.resize(size,size);\n    m_l.resizeNonZeros(Lstore->nnz);\n    m_u.resize(size,size);\n    m_u.resizeNonZeros(Ustore->nnz);\n\n    int* Lcol = m_l.outerIndexPtr();\n    int* Lrow = m_l.innerIndexPtr();\n    Scalar* Lval = m_l.valuePtr();\n\n    int* Ucol = m_u.outerIndexPtr();\n    int* Urow = m_u.innerIndexPtr();\n    Scalar* Uval = m_u.valuePtr();\n\n    Ucol[0] = 0;\n    Ucol[0] = 0;\n\n    /* for each supernode */\n    for (int k = 0; k <= Lstore->nsuper; ++k)\n    {\n      fsupc   = L_FST_SUPC(k);\n      istart  = L_SUB_START(fsupc);\n      nsupr   = L_SUB_START(fsupc+1) - istart;\n      upper   = 1;\n\n      /* for each column in the supernode */\n      for (int j = fsupc; j < L_FST_SUPC(k+1); ++j)\n      {\n        SNptr = &((Scalar*)Lstore->nzval)[L_NZ_START(j)];\n\n        /* Extract U */\n        for (int i = U_NZ_START(j); i < U_NZ_START(j+1); ++i)\n        {\n          Uval[lastu] = ((Scalar*)Ustore->nzval)[i];\n          /* Matlab doesn't like explicit zero. */\n          if (Uval[lastu] != 0.0)\n            Urow[lastu++] = U_SUB(i);\n        }\n        for (int i = 0; i < upper; ++i)\n        {\n          /* upper triangle in the supernode */\n          Uval[lastu] = SNptr[i];\n          /* Matlab doesn't like explicit zero. */\n          if (Uval[lastu] != 0.0)\n            Urow[lastu++] = L_SUB(istart+i);\n        }\n        Ucol[j+1] = lastu;\n\n        /* Extract L */\n        Lval[lastl] = 1.0; /* unit diagonal */\n        Lrow[lastl++] = L_SUB(istart + upper - 1);\n        for (int i = upper; i < nsupr; ++i)\n        {\n          Lval[lastl] = SNptr[i];\n          /* Matlab doesn't like explicit zero. */\n          if (Lval[lastl] != 0.0)\n            Lrow[lastl++] = L_SUB(istart+i);\n        }\n        Lcol[j+1] = lastl;\n\n        ++upper;\n      } /* for j ... */\n\n    } /* for k ... */\n\n    // squeeze the matrices :\n    m_l.resizeNonZeros(lastl);\n    m_u.resizeNonZeros(lastu);\n\n    m_extractedDataAreDirty = false;\n  }\n}\n\ntemplate<typename MatrixType>\ntypename SuperLU<MatrixType>::Scalar SuperLU<MatrixType>::determinant() const\n{\n  eigen_assert(m_factorizationIsOk && \"The decomposition is not in a valid state for computing the determinant, you must first call either compute() or analyzePattern()/factorize()\");\n  \n  if (m_extractedDataAreDirty)\n    this->extractData();\n\n  Scalar det = Scalar(1);\n  for (int j=0; j<m_u.cols(); ++j)\n  {\n    if (m_u.outerIndexPtr()[j+1]-m_u.outerIndexPtr()[j] > 0)\n    {\n      int lastId = m_u.outerIndexPtr()[j+1]-1;\n      eigen_assert(m_u.innerIndexPtr()[lastId]<=j);\n      if (m_u.innerIndexPtr()[lastId]==j)\n        det *= m_u.valuePtr()[lastId];\n    }\n  }\n  if(PermutationMap(m_p.data(),m_p.size()).determinant()*PermutationMap(m_q.data(),m_q.size()).determinant()<0)\n    det = -det;\n  if(m_sluEqued!='N')\n    return det/m_sluRscale.prod()/m_sluCscale.prod();\n  else\n    return det;\n}\n\n#ifdef EIGEN_PARSED_BY_DOXYGEN\n#define EIGEN_SUPERLU_HAS_ILU\n#endif\n\n#ifdef EIGEN_SUPERLU_HAS_ILU\n\n/** \\ingroup SuperLUSupport_Module\n  * \\class SuperILU\n  * \\brief A sparse direct \\b incomplete LU factorization and solver based on the SuperLU library\n  *\n  * This class allows to solve for an approximate solution of A.X = B sparse linear problems via an incomplete LU factorization\n  * using the SuperLU library. This class is aimed to be used as a preconditioner of the iterative linear solvers.\n  *\n  * \\warning This class is only for the 4.x versions of SuperLU. The 3.x and 5.x versions are not supported.\n  *\n  * \\tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa \\ref TutorialSparseSolverConcept, class IncompleteLUT, class ConjugateGradient, class BiCGSTAB\n  */\n\ntemplate<typename _MatrixType>\nclass SuperILU : public SuperLUBase<_MatrixType,SuperILU<_MatrixType> >\n{\n  public:\n    typedef SuperLUBase<_MatrixType,SuperILU> Base;\n    typedef _MatrixType MatrixType;\n    typedef typename Base::Scalar Scalar;\n    typedef typename Base::RealScalar RealScalar;\n\n  public:\n    using Base::_solve_impl;\n\n    SuperILU() : Base() { init(); }\n\n    SuperILU(const MatrixType& matrix) : Base()\n    {\n      init();\n      Base::compute(matrix);\n    }\n\n    ~SuperILU()\n    {\n    }\n    \n    /** Performs a symbolic decomposition on the sparcity of \\a matrix.\n      *\n      * This function is particularly useful when solving for several problems having the same structure.\n      * \n      * \\sa factorize()\n      */\n    void analyzePattern(const MatrixType& matrix)\n    {\n      Base::analyzePattern(matrix);\n    }\n    \n    /** Performs a numeric decomposition of \\a matrix\n      *\n      * The given matrix must has the same sparcity than the matrix on which the symbolic decomposition has been performed.\n      *\n      * \\sa analyzePattern()\n      */\n    void factorize(const MatrixType& matrix);\n    \n    #ifndef EIGEN_PARSED_BY_DOXYGEN\n    /** \\internal */\n    template<typename Rhs,typename Dest>\n    void _solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &dest) const;\n    #endif // EIGEN_PARSED_BY_DOXYGEN\n    \n  protected:\n    \n    using Base::m_matrix;\n    using Base::m_sluOptions;\n    using Base::m_sluA;\n    using Base::m_sluB;\n    using Base::m_sluX;\n    using Base::m_p;\n    using Base::m_q;\n    using Base::m_sluEtree;\n    using Base::m_sluEqued;\n    using Base::m_sluRscale;\n    using Base::m_sluCscale;\n    using Base::m_sluL;\n    using Base::m_sluU;\n    using Base::m_sluStat;\n    using Base::m_sluFerr;\n    using Base::m_sluBerr;\n    using Base::m_l;\n    using Base::m_u;\n    \n    using Base::m_analysisIsOk;\n    using Base::m_factorizationIsOk;\n    using Base::m_extractedDataAreDirty;\n    using Base::m_isInitialized;\n    using Base::m_info;\n\n    void init()\n    {\n      Base::init();\n      \n      ilu_set_default_options(&m_sluOptions);\n      m_sluOptions.PrintStat        = NO;\n      m_sluOptions.ConditionNumber  = NO;\n      m_sluOptions.Trans            = NOTRANS;\n      m_sluOptions.ColPerm          = MMD_AT_PLUS_A;\n      \n      // no attempt to preserve column sum\n      m_sluOptions.ILU_MILU = SILU;\n      // only basic ILU(k) support -- no direct control over memory consumption\n      // better to use ILU_DropRule = DROP_BASIC | DROP_AREA\n      // and set ILU_FillFactor to max memory growth\n      m_sluOptions.ILU_DropRule = DROP_BASIC;\n      m_sluOptions.ILU_DropTol = NumTraits<Scalar>::dummy_precision()*10;\n    }\n    \n  private:\n    SuperILU(SuperILU& ) { }\n};\n\ntemplate<typename MatrixType>\nvoid SuperILU<MatrixType>::factorize(const MatrixType& a)\n{\n  eigen_assert(m_analysisIsOk && \"You must first call analyzePattern()\");\n  if(!m_analysisIsOk)\n  {\n    m_info = InvalidInput;\n    return;\n  }\n  \n  this->initFactorization(a);\n\n  int info = 0;\n  RealScalar recip_pivot_growth, rcond;\n\n  StatInit(&m_sluStat);\n  SuperLU_gsisx(&m_sluOptions, &m_sluA, m_q.data(), m_p.data(), &m_sluEtree[0],\n                &m_sluEqued, &m_sluRscale[0], &m_sluCscale[0],\n                &m_sluL, &m_sluU,\n                NULL, 0,\n                &m_sluB, &m_sluX,\n                &recip_pivot_growth, &rcond,\n                &m_sluStat, &info, Scalar());\n  StatFree(&m_sluStat);\n\n  // FIXME how to better check for errors ???\n  m_info = info == 0 ? Success : NumericalIssue;\n  m_factorizationIsOk = true;\n}\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\ntemplate<typename MatrixType>\ntemplate<typename Rhs,typename Dest>\nvoid SuperILU<MatrixType>::_solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest>& x) const\n{\n  eigen_assert(m_factorizationIsOk && \"The decomposition is not in a valid state for solving, you must first call either compute() or analyzePattern()/factorize()\");\n\n  const int size = m_matrix.rows();\n  const int rhsCols = b.cols();\n  eigen_assert(size==b.rows());\n\n  m_sluOptions.Trans = NOTRANS;\n  m_sluOptions.Fact = FACTORED;\n  m_sluOptions.IterRefine = NOREFINE;\n\n  m_sluFerr.resize(rhsCols);\n  m_sluBerr.resize(rhsCols);\n  \n  Ref<const Matrix<typename Rhs::Scalar,Dynamic,Dynamic,ColMajor> > b_ref(b);\n  Ref<const Matrix<typename Dest::Scalar,Dynamic,Dynamic,ColMajor> > x_ref(x);\n  \n  m_sluB = SluMatrix::Map(b_ref.const_cast_derived());\n  m_sluX = SluMatrix::Map(x_ref.const_cast_derived());\n\n  typename Rhs::PlainObject b_cpy;\n  if(m_sluEqued!='N')\n  {\n    b_cpy = b;\n    m_sluB = SluMatrix::Map(b_cpy.const_cast_derived());  \n  }\n  \n  int info = 0;\n  RealScalar recip_pivot_growth, rcond;\n\n  StatInit(&m_sluStat);\n  SuperLU_gsisx(&m_sluOptions, &m_sluA,\n                m_q.data(), m_p.data(),\n                &m_sluEtree[0], &m_sluEqued,\n                &m_sluRscale[0], &m_sluCscale[0],\n                &m_sluL, &m_sluU,\n                NULL, 0,\n                &m_sluB, &m_sluX,\n                &recip_pivot_growth, &rcond,\n                &m_sluStat, &info, Scalar());\n  StatFree(&m_sluStat);\n  \n  if(x.derived().data() != x_ref.data())\n    x = x_ref;\n\n  m_info = info==0 ? Success : NumericalIssue;\n}\n#endif\n\n#endif\n\n} // end namespace Eigen\n\n#endif // EIGEN_SUPERLUSUPPORT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/UmfPackSupport/UmfPackSupport.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2011 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_UMFPACKSUPPORT_H\n#define EIGEN_UMFPACKSUPPORT_H\n\nnamespace Eigen {\n\n/* TODO extract L, extract U, compute det, etc... */\n\n// generic double/complex<double> wrapper functions:\n\n\ninline void umfpack_defaults(double control[UMFPACK_CONTROL], double)\n{ umfpack_di_defaults(control); }\n\ninline void umfpack_defaults(double control[UMFPACK_CONTROL], std::complex<double>)\n{ umfpack_zi_defaults(control); }\n\ninline void umfpack_report_info(double control[UMFPACK_CONTROL], double info[UMFPACK_INFO], double)\n{ umfpack_di_report_info(control, info);}\n\ninline void umfpack_report_info(double control[UMFPACK_CONTROL], double info[UMFPACK_INFO], std::complex<double>)\n{ umfpack_zi_report_info(control, info);}\n\ninline void umfpack_report_status(double control[UMFPACK_CONTROL], int status, double)\n{ umfpack_di_report_status(control, status);}\n\ninline void umfpack_report_status(double control[UMFPACK_CONTROL], int status, std::complex<double>)\n{ umfpack_zi_report_status(control, status);}\n\ninline void umfpack_report_control(double control[UMFPACK_CONTROL], double)\n{ umfpack_di_report_control(control);}\n\ninline void umfpack_report_control(double control[UMFPACK_CONTROL], std::complex<double>)\n{ umfpack_zi_report_control(control);}\n\ninline void umfpack_free_numeric(void **Numeric, double)\n{ umfpack_di_free_numeric(Numeric); *Numeric = 0; }\n\ninline void umfpack_free_numeric(void **Numeric, std::complex<double>)\n{ umfpack_zi_free_numeric(Numeric); *Numeric = 0; }\n\ninline void umfpack_free_symbolic(void **Symbolic, double)\n{ umfpack_di_free_symbolic(Symbolic); *Symbolic = 0; }\n\ninline void umfpack_free_symbolic(void **Symbolic, std::complex<double>)\n{ umfpack_zi_free_symbolic(Symbolic); *Symbolic = 0; }\n\ninline int umfpack_symbolic(int n_row,int n_col,\n                            const int Ap[], const int Ai[], const double Ax[], void **Symbolic,\n                            const double Control [UMFPACK_CONTROL], double Info [UMFPACK_INFO])\n{\n  return umfpack_di_symbolic(n_row,n_col,Ap,Ai,Ax,Symbolic,Control,Info);\n}\n\ninline int umfpack_symbolic(int n_row,int n_col,\n                            const int Ap[], const int Ai[], const std::complex<double> Ax[], void **Symbolic,\n                            const double Control [UMFPACK_CONTROL], double Info [UMFPACK_INFO])\n{\n  return umfpack_zi_symbolic(n_row,n_col,Ap,Ai,&numext::real_ref(Ax[0]),0,Symbolic,Control,Info);\n}\n\ninline int umfpack_numeric( const int Ap[], const int Ai[], const double Ax[],\n                            void *Symbolic, void **Numeric,\n                            const double Control[UMFPACK_CONTROL],double Info [UMFPACK_INFO])\n{\n  return umfpack_di_numeric(Ap,Ai,Ax,Symbolic,Numeric,Control,Info);\n}\n\ninline int umfpack_numeric( const int Ap[], const int Ai[], const std::complex<double> Ax[],\n                            void *Symbolic, void **Numeric,\n                            const double Control[UMFPACK_CONTROL],double Info [UMFPACK_INFO])\n{\n  return umfpack_zi_numeric(Ap,Ai,&numext::real_ref(Ax[0]),0,Symbolic,Numeric,Control,Info);\n}\n\ninline int umfpack_solve( int sys, const int Ap[], const int Ai[], const double Ax[],\n                          double X[], const double B[], void *Numeric,\n                          const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO])\n{\n  return umfpack_di_solve(sys,Ap,Ai,Ax,X,B,Numeric,Control,Info);\n}\n\ninline int umfpack_solve( int sys, const int Ap[], const int Ai[], const std::complex<double> Ax[],\n                          std::complex<double> X[], const std::complex<double> B[], void *Numeric,\n                          const double Control[UMFPACK_CONTROL], double Info[UMFPACK_INFO])\n{\n  return umfpack_zi_solve(sys,Ap,Ai,&numext::real_ref(Ax[0]),0,&numext::real_ref(X[0]),0,&numext::real_ref(B[0]),0,Numeric,Control,Info);\n}\n\ninline int umfpack_get_lunz(int *lnz, int *unz, int *n_row, int *n_col, int *nz_udiag, void *Numeric, double)\n{\n  return umfpack_di_get_lunz(lnz,unz,n_row,n_col,nz_udiag,Numeric);\n}\n\ninline int umfpack_get_lunz(int *lnz, int *unz, int *n_row, int *n_col, int *nz_udiag, void *Numeric, std::complex<double>)\n{\n  return umfpack_zi_get_lunz(lnz,unz,n_row,n_col,nz_udiag,Numeric);\n}\n\ninline int umfpack_get_numeric(int Lp[], int Lj[], double Lx[], int Up[], int Ui[], double Ux[],\n                               int P[], int Q[], double Dx[], int *do_recip, double Rs[], void *Numeric)\n{\n  return umfpack_di_get_numeric(Lp,Lj,Lx,Up,Ui,Ux,P,Q,Dx,do_recip,Rs,Numeric);\n}\n\ninline int umfpack_get_numeric(int Lp[], int Lj[], std::complex<double> Lx[], int Up[], int Ui[], std::complex<double> Ux[],\n                               int P[], int Q[], std::complex<double> Dx[], int *do_recip, double Rs[], void *Numeric)\n{\n  double& lx0_real = numext::real_ref(Lx[0]);\n  double& ux0_real = numext::real_ref(Ux[0]);\n  double& dx0_real = numext::real_ref(Dx[0]);\n  return umfpack_zi_get_numeric(Lp,Lj,Lx?&lx0_real:0,0,Up,Ui,Ux?&ux0_real:0,0,P,Q,\n                                Dx?&dx0_real:0,0,do_recip,Rs,Numeric);\n}\n\ninline int umfpack_get_determinant(double *Mx, double *Ex, void *NumericHandle, double User_Info [UMFPACK_INFO])\n{\n  return umfpack_di_get_determinant(Mx,Ex,NumericHandle,User_Info);\n}\n\ninline int umfpack_get_determinant(std::complex<double> *Mx, double *Ex, void *NumericHandle, double User_Info [UMFPACK_INFO])\n{\n  double& mx_real = numext::real_ref(*Mx);\n  return umfpack_zi_get_determinant(&mx_real,0,Ex,NumericHandle,User_Info);\n}\n\n\n/** \\ingroup UmfPackSupport_Module\n  * \\brief A sparse LU factorization and solver based on UmfPack\n  *\n  * This class allows to solve for A.X = B sparse linear problems via a LU factorization\n  * using the UmfPack library. The sparse matrix A must be squared and full rank.\n  * The vectors or matrices X and B can be either dense or sparse.\n  *\n  * \\warning The input matrix A should be in a \\b compressed and \\b column-major form.\n  * Otherwise an expensive copy will be made. You can call the inexpensive makeCompressed() to get a compressed matrix.\n  * \\tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>\n  *\n  * \\implsparsesolverconcept\n  *\n  * \\sa \\ref TutorialSparseSolverConcept, class SparseLU\n  */\ntemplate<typename _MatrixType>\nclass UmfPackLU : public SparseSolverBase<UmfPackLU<_MatrixType> >\n{\n  protected:\n    typedef SparseSolverBase<UmfPackLU<_MatrixType> > Base;\n    using Base::m_isInitialized;\n  public:\n    using Base::_solve_impl;\n    typedef _MatrixType MatrixType;\n    typedef typename MatrixType::Scalar Scalar;\n    typedef typename MatrixType::RealScalar RealScalar;\n    typedef typename MatrixType::StorageIndex StorageIndex;\n    typedef Matrix<Scalar,Dynamic,1> Vector;\n    typedef Matrix<int, 1, MatrixType::ColsAtCompileTime> IntRowVectorType;\n    typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> IntColVectorType;\n    typedef SparseMatrix<Scalar> LUMatrixType;\n    typedef SparseMatrix<Scalar,ColMajor,int> UmfpackMatrixType;\n    typedef Ref<const UmfpackMatrixType, StandardCompressedFormat> UmfpackMatrixRef;\n    enum {\n      ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime\n    };\n\n  public:\n\n    typedef Array<double, UMFPACK_CONTROL, 1> UmfpackControl;\n    typedef Array<double, UMFPACK_INFO, 1> UmfpackInfo;\n\n    UmfPackLU()\n      : m_dummy(0,0), mp_matrix(m_dummy)\n    {\n      init();\n    }\n\n    template<typename InputMatrixType>\n    explicit UmfPackLU(const InputMatrixType& matrix)\n      : mp_matrix(matrix)\n    {\n      init();\n      compute(matrix);\n    }\n\n    ~UmfPackLU()\n    {\n      if(m_symbolic) umfpack_free_symbolic(&m_symbolic,Scalar());\n      if(m_numeric)  umfpack_free_numeric(&m_numeric,Scalar());\n    }\n\n    inline Index rows() const { return mp_matrix.rows(); }\n    inline Index cols() const { return mp_matrix.cols(); }\n\n    /** \\brief Reports whether previous computation was successful.\n      *\n      * \\returns \\c Success if computation was succesful,\n      *          \\c NumericalIssue if the matrix.appears to be negative.\n      */\n    ComputationInfo info() const\n    {\n      eigen_assert(m_isInitialized && \"Decomposition is not initialized.\");\n      return m_info;\n    }\n\n    inline const LUMatrixType& matrixL() const\n    {\n      if (m_extractedDataAreDirty) extractData();\n      return m_l;\n    }\n\n    inline const LUMatrixType& matrixU() const\n    {\n      if (m_extractedDataAreDirty) extractData();\n      return m_u;\n    }\n\n    inline const IntColVectorType& permutationP() const\n    {\n      if (m_extractedDataAreDirty) extractData();\n      return m_p;\n    }\n\n    inline const IntRowVectorType& permutationQ() const\n    {\n      if (m_extractedDataAreDirty) extractData();\n      return m_q;\n    }\n\n    /** Computes the sparse Cholesky decomposition of \\a matrix\n     *  Note that the matrix should be column-major, and in compressed format for best performance.\n     *  \\sa SparseMatrix::makeCompressed().\n     */\n    template<typename InputMatrixType>\n    void compute(const InputMatrixType& matrix)\n    {\n      if(m_symbolic) umfpack_free_symbolic(&m_symbolic,Scalar());\n      if(m_numeric)  umfpack_free_numeric(&m_numeric,Scalar());\n      grab(matrix.derived());\n      analyzePattern_impl();\n      factorize_impl();\n    }\n\n    /** Performs a symbolic decomposition on the sparcity of \\a matrix.\n      *\n      * This function is particularly useful when solving for several problems having the same structure.\n      *\n      * \\sa factorize(), compute()\n      */\n    template<typename InputMatrixType>\n    void analyzePattern(const InputMatrixType& matrix)\n    {\n      if(m_symbolic) umfpack_free_symbolic(&m_symbolic,Scalar());\n      if(m_numeric)  umfpack_free_numeric(&m_numeric,Scalar());\n\n      grab(matrix.derived());\n\n      analyzePattern_impl();\n    }\n\n    /** Provides the return status code returned by UmfPack during the numeric\n      * factorization.\n      *\n      * \\sa factorize(), compute()\n      */\n    inline int umfpackFactorizeReturncode() const\n    {\n      eigen_assert(m_numeric && \"UmfPackLU: you must first call factorize()\");\n      return m_fact_errorCode;\n    }\n\n    /** Provides access to the control settings array used by UmfPack.\n      *\n      * If this array contains NaN's, the default values are used.\n      *\n      * See UMFPACK documentation for details.\n      */\n    inline const UmfpackControl& umfpackControl() const\n    {\n      return m_control;\n    }\n\n    /** Provides access to the control settings array used by UmfPack.\n      *\n      * If this array contains NaN's, the default values are used.\n      *\n      * See UMFPACK documentation for details.\n      */\n    inline UmfpackControl& umfpackControl()\n    {\n      return m_control;\n    }\n\n    /** Performs a numeric decomposition of \\a matrix\n      *\n      * The given matrix must has the same sparcity than the matrix on which the pattern anylysis has been performed.\n      *\n      * \\sa analyzePattern(), compute()\n      */\n    template<typename InputMatrixType>\n    void factorize(const InputMatrixType& matrix)\n    {\n      eigen_assert(m_analysisIsOk && \"UmfPackLU: you must first call analyzePattern()\");\n      if(m_numeric)\n        umfpack_free_numeric(&m_numeric,Scalar());\n\n      grab(matrix.derived());\n\n      factorize_impl();\n    }\n\n    /** Prints the current UmfPack control settings.\n      *\n      * \\sa umfpackControl()\n      */\n    void umfpackReportControl()\n    {\n      umfpack_report_control(m_control.data(), Scalar());\n    }\n\n    /** Prints statistics collected by UmfPack.\n      *\n      * \\sa analyzePattern(), compute()\n      */\n    void umfpackReportInfo()\n    {\n      eigen_assert(m_analysisIsOk && \"UmfPackLU: you must first call analyzePattern()\");\n      umfpack_report_info(m_control.data(), m_umfpackInfo.data(), Scalar());\n    }\n\n    /** Prints the status of the previous factorization operation performed by UmfPack (symbolic or numerical factorization).\n      *\n      * \\sa analyzePattern(), compute()\n      */\n    void umfpackReportStatus() {\n      eigen_assert(m_analysisIsOk && \"UmfPackLU: you must first call analyzePattern()\");\n      umfpack_report_status(m_control.data(), m_fact_errorCode, Scalar());\n    }\n\n    /** \\internal */\n    template<typename BDerived,typename XDerived>\n    bool _solve_impl(const MatrixBase<BDerived> &b, MatrixBase<XDerived> &x) const;\n\n    Scalar determinant() const;\n\n    void extractData() const;\n\n  protected:\n\n    void init()\n    {\n      m_info                  = InvalidInput;\n      m_isInitialized         = false;\n      m_numeric               = 0;\n      m_symbolic              = 0;\n      m_extractedDataAreDirty = true;\n\n      umfpack_defaults(m_control.data(), Scalar());\n    }\n\n    void analyzePattern_impl()\n    {\n      m_fact_errorCode = umfpack_symbolic(internal::convert_index<int>(mp_matrix.rows()),\n                                          internal::convert_index<int>(mp_matrix.cols()),\n                                          mp_matrix.outerIndexPtr(), mp_matrix.innerIndexPtr(), mp_matrix.valuePtr(),\n                                          &m_symbolic, m_control.data(), m_umfpackInfo.data());\n\n      m_isInitialized = true;\n      m_info = m_fact_errorCode ? InvalidInput : Success;\n      m_analysisIsOk = true;\n      m_factorizationIsOk = false;\n      m_extractedDataAreDirty = true;\n    }\n\n    void factorize_impl()\n    {\n\n      m_fact_errorCode = umfpack_numeric(mp_matrix.outerIndexPtr(), mp_matrix.innerIndexPtr(), mp_matrix.valuePtr(),\n                                         m_symbolic, &m_numeric, m_control.data(), m_umfpackInfo.data());\n\n      m_info = m_fact_errorCode == UMFPACK_OK ? Success : NumericalIssue;\n      m_factorizationIsOk = true;\n      m_extractedDataAreDirty = true;\n    }\n\n    template<typename MatrixDerived>\n    void grab(const EigenBase<MatrixDerived> &A)\n    {\n      mp_matrix.~UmfpackMatrixRef();\n      ::new (&mp_matrix) UmfpackMatrixRef(A.derived());\n    }\n\n    void grab(const UmfpackMatrixRef &A)\n    {\n      if(&(A.derived()) != &mp_matrix)\n      {\n        mp_matrix.~UmfpackMatrixRef();\n        ::new (&mp_matrix) UmfpackMatrixRef(A);\n      }\n    }\n\n    // cached data to reduce reallocation, etc.\n    mutable LUMatrixType m_l;\n    int m_fact_errorCode;\n    UmfpackControl m_control;\n    mutable UmfpackInfo m_umfpackInfo;\n\n    mutable LUMatrixType m_u;\n    mutable IntColVectorType m_p;\n    mutable IntRowVectorType m_q;\n\n    UmfpackMatrixType m_dummy;\n    UmfpackMatrixRef mp_matrix;\n\n    void* m_numeric;\n    void* m_symbolic;\n\n    mutable ComputationInfo m_info;\n    int m_factorizationIsOk;\n    int m_analysisIsOk;\n    mutable bool m_extractedDataAreDirty;\n\n  private:\n    UmfPackLU(const UmfPackLU& ) { }\n};\n\n\ntemplate<typename MatrixType>\nvoid UmfPackLU<MatrixType>::extractData() const\n{\n  if (m_extractedDataAreDirty)\n  {\n    // get size of the data\n    int lnz, unz, rows, cols, nz_udiag;\n    umfpack_get_lunz(&lnz, &unz, &rows, &cols, &nz_udiag, m_numeric, Scalar());\n\n    // allocate data\n    m_l.resize(rows,(std::min)(rows,cols));\n    m_l.resizeNonZeros(lnz);\n\n    m_u.resize((std::min)(rows,cols),cols);\n    m_u.resizeNonZeros(unz);\n\n    m_p.resize(rows);\n    m_q.resize(cols);\n\n    // extract\n    umfpack_get_numeric(m_l.outerIndexPtr(), m_l.innerIndexPtr(), m_l.valuePtr(),\n                        m_u.outerIndexPtr(), m_u.innerIndexPtr(), m_u.valuePtr(),\n                        m_p.data(), m_q.data(), 0, 0, 0, m_numeric);\n\n    m_extractedDataAreDirty = false;\n  }\n}\n\ntemplate<typename MatrixType>\ntypename UmfPackLU<MatrixType>::Scalar UmfPackLU<MatrixType>::determinant() const\n{\n  Scalar det;\n  umfpack_get_determinant(&det, 0, m_numeric, 0);\n  return det;\n}\n\ntemplate<typename MatrixType>\ntemplate<typename BDerived,typename XDerived>\nbool UmfPackLU<MatrixType>::_solve_impl(const MatrixBase<BDerived> &b, MatrixBase<XDerived> &x) const\n{\n  Index rhsCols = b.cols();\n  eigen_assert((BDerived::Flags&RowMajorBit)==0 && \"UmfPackLU backend does not support non col-major rhs yet\");\n  eigen_assert((XDerived::Flags&RowMajorBit)==0 && \"UmfPackLU backend does not support non col-major result yet\");\n  eigen_assert(b.derived().data() != x.derived().data() && \" Umfpack does not support inplace solve\");\n\n  int errorCode;\n  Scalar* x_ptr = 0;\n  Matrix<Scalar,Dynamic,1> x_tmp;\n  if(x.innerStride()!=1)\n  {\n    x_tmp.resize(x.rows());\n    x_ptr = x_tmp.data();\n  }\n  for (int j=0; j<rhsCols; ++j)\n  {\n    if(x.innerStride()==1)\n      x_ptr = &x.col(j).coeffRef(0);\n    errorCode = umfpack_solve(UMFPACK_A,\n        mp_matrix.outerIndexPtr(), mp_matrix.innerIndexPtr(), mp_matrix.valuePtr(),\n        x_ptr, &b.const_cast_derived().col(j).coeffRef(0), m_numeric, m_control.data(), m_umfpackInfo.data());\n    if(x.innerStride()!=1)\n      x.col(j) = x_tmp;\n    if (errorCode!=0)\n      return false;\n  }\n\n  return true;\n}\n\n} // end namespace Eigen\n\n#endif // EIGEN_UMFPACKSUPPORT_H\n"
  },
  {
    "path": "include/externals/Eigen/src/misc/Image.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MISC_IMAGE_H\n#define EIGEN_MISC_IMAGE_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/** \\class image_retval_base\n  *\n  */\ntemplate<typename DecompositionType>\nstruct traits<image_retval_base<DecompositionType> >\n{\n  typedef typename DecompositionType::MatrixType MatrixType;\n  typedef Matrix<\n    typename MatrixType::Scalar,\n    MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose\n                                   // dimension is the number of rows of the original matrix\n    Dynamic,                       // we don't know at compile time the dimension of the image (the rank)\n    MatrixType::Options,\n    MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix,\n    MatrixType::MaxColsAtCompileTime  // so it has the same number of rows and at most as many columns.\n  > ReturnType;\n};\n\ntemplate<typename _DecompositionType> struct image_retval_base\n : public ReturnByValue<image_retval_base<_DecompositionType> >\n{\n  typedef _DecompositionType DecompositionType;\n  typedef typename DecompositionType::MatrixType MatrixType;\n  typedef ReturnByValue<image_retval_base> Base;\n\n  image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix)\n    : m_dec(dec), m_rank(dec.rank()),\n      m_cols(m_rank == 0 ? 1 : m_rank),\n      m_originalMatrix(originalMatrix)\n  {}\n\n  inline Index rows() const { return m_dec.rows(); }\n  inline Index cols() const { return m_cols; }\n  inline Index rank() const { return m_rank; }\n  inline const DecompositionType& dec() const { return m_dec; }\n  inline const MatrixType& originalMatrix() const { return m_originalMatrix; }\n\n  template<typename Dest> inline void evalTo(Dest& dst) const\n  {\n    static_cast<const image_retval<DecompositionType>*>(this)->evalTo(dst);\n  }\n\n  protected:\n    const DecompositionType& m_dec;\n    Index m_rank, m_cols;\n    const MatrixType& m_originalMatrix;\n};\n\n} // end namespace internal\n\n#define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \\\n  typedef typename DecompositionType::MatrixType MatrixType; \\\n  typedef typename MatrixType::Scalar Scalar; \\\n  typedef typename MatrixType::RealScalar RealScalar; \\\n  typedef Eigen::internal::image_retval_base<DecompositionType> Base; \\\n  using Base::dec; \\\n  using Base::originalMatrix; \\\n  using Base::rank; \\\n  using Base::rows; \\\n  using Base::cols; \\\n  image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \\\n    : Base(dec, originalMatrix) {}\n\n} // end namespace Eigen\n\n#endif // EIGEN_MISC_IMAGE_H\n"
  },
  {
    "path": "include/externals/Eigen/src/misc/Kernel.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_MISC_KERNEL_H\n#define EIGEN_MISC_KERNEL_H\n\nnamespace Eigen { \n\nnamespace internal {\n\n/** \\class kernel_retval_base\n  *\n  */\ntemplate<typename DecompositionType>\nstruct traits<kernel_retval_base<DecompositionType> >\n{\n  typedef typename DecompositionType::MatrixType MatrixType;\n  typedef Matrix<\n    typename MatrixType::Scalar,\n    MatrixType::ColsAtCompileTime, // the number of rows in the \"kernel matrix\"\n                                   // is the number of cols of the original matrix\n                                   // so that the product \"matrix * kernel = zero\" makes sense\n    Dynamic,                       // we don't know at compile-time the dimension of the kernel\n    MatrixType::Options,\n    MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter\n    MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space,\n                                     // whose dimension is the number of columns of the original matrix\n  > ReturnType;\n};\n\ntemplate<typename _DecompositionType> struct kernel_retval_base\n : public ReturnByValue<kernel_retval_base<_DecompositionType> >\n{\n  typedef _DecompositionType DecompositionType;\n  typedef ReturnByValue<kernel_retval_base> Base;\n\n  explicit kernel_retval_base(const DecompositionType& dec)\n    : m_dec(dec),\n      m_rank(dec.rank()),\n      m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank)\n  {}\n\n  inline Index rows() const { return m_dec.cols(); }\n  inline Index cols() const { return m_cols; }\n  inline Index rank() const { return m_rank; }\n  inline const DecompositionType& dec() const { return m_dec; }\n\n  template<typename Dest> inline void evalTo(Dest& dst) const\n  {\n    static_cast<const kernel_retval<DecompositionType>*>(this)->evalTo(dst);\n  }\n\n  protected:\n    const DecompositionType& m_dec;\n    Index m_rank, m_cols;\n};\n\n} // end namespace internal\n\n#define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \\\n  typedef typename DecompositionType::MatrixType MatrixType; \\\n  typedef typename MatrixType::Scalar Scalar; \\\n  typedef typename MatrixType::RealScalar RealScalar; \\\n  typedef Eigen::internal::kernel_retval_base<DecompositionType> Base; \\\n  using Base::dec; \\\n  using Base::rank; \\\n  using Base::rows; \\\n  using Base::cols; \\\n  kernel_retval(const DecompositionType& dec) : Base(dec) {}\n\n} // end namespace Eigen\n\n#endif // EIGEN_MISC_KERNEL_H\n"
  },
  {
    "path": "include/externals/Eigen/src/misc/RealSvd2x2.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2009-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n// Copyright (C) 2013-2016 Gael Guennebaud <gael.guennebaud@inria.fr>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_REALSVD2X2_H\n#define EIGEN_REALSVD2X2_H\n\nnamespace Eigen {\n\nnamespace internal {\n\ntemplate<typename MatrixType, typename RealScalar, typename Index>\nvoid real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q,\n                         JacobiRotation<RealScalar> *j_left,\n                         JacobiRotation<RealScalar> *j_right)\n{\n  using std::sqrt;\n  using std::abs;\n  Matrix<RealScalar,2,2> m;\n  m << numext::real(matrix.coeff(p,p)), numext::real(matrix.coeff(p,q)),\n       numext::real(matrix.coeff(q,p)), numext::real(matrix.coeff(q,q));\n  JacobiRotation<RealScalar> rot1;\n  RealScalar t = m.coeff(0,0) + m.coeff(1,1);\n  RealScalar d = m.coeff(1,0) - m.coeff(0,1);\n\n  if(abs(d) < (std::numeric_limits<RealScalar>::min)())\n  {\n    rot1.s() = RealScalar(0);\n    rot1.c() = RealScalar(1);\n  }\n  else\n  {\n    // If d!=0, then t/d cannot overflow because the magnitude of the\n    // entries forming d are not too small compared to the ones forming t.\n    RealScalar u = t / d;\n    RealScalar tmp = sqrt(RealScalar(1) + numext::abs2(u));\n    rot1.s() = RealScalar(1) / tmp;\n    rot1.c() = u / tmp;\n  }\n  m.applyOnTheLeft(0,1,rot1);\n  j_right->makeJacobi(m,0,1);\n  *j_left = rot1 * j_right->transpose();\n}\n\n} // end namespace internal\n\n} // end namespace Eigen\n\n#endif // EIGEN_REALSVD2X2_H\n"
  },
  {
    "path": "include/externals/Eigen/src/misc/blas.h",
    "content": "#ifndef BLAS_H\n#define BLAS_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n#define BLASFUNC(FUNC) FUNC##_\n\n#ifdef __WIN64__\ntypedef long long BLASLONG;\ntypedef unsigned long long BLASULONG;\n#else\ntypedef long BLASLONG;\ntypedef unsigned long BLASULONG;\n#endif\n\nint    BLASFUNC(xerbla)(const char *, int *info, int);\n\nfloat  BLASFUNC(sdot)  (int *, float  *, int *, float  *, int *);\nfloat  BLASFUNC(sdsdot)(int *, float  *,        float  *, int *, float  *, int *);\n\ndouble BLASFUNC(dsdot) (int *, float  *, int *, float  *, int *);\ndouble BLASFUNC(ddot)  (int *, double *, int *, double *, int *);\ndouble BLASFUNC(qdot)  (int *, double *, int *, double *, int *);\n\nint  BLASFUNC(cdotuw)  (int *, float  *, int *, float  *, int *, float*);\nint  BLASFUNC(cdotcw)  (int *, float  *, int *, float  *, int *, float*);\nint  BLASFUNC(zdotuw)  (int *, double  *, int *, double  *, int *, double*);\nint  BLASFUNC(zdotcw)  (int *, double  *, int *, double  *, int *, double*);\n\nint    BLASFUNC(saxpy) (const int *, const float  *, const float  *, const int *, float  *, const int *);\nint    BLASFUNC(daxpy) (const int *, const double *, const double *, const int *, double *, const int *);\nint    BLASFUNC(qaxpy) (const int *, const double *, const double *, const int *, double *, const int *);\nint    BLASFUNC(caxpy) (const int *, const float  *, const float  *, const int *, float  *, const int *);\nint    BLASFUNC(zaxpy) (const int *, const double *, const double *, const int *, double *, const int *);\nint    BLASFUNC(xaxpy) (const int *, const double *, const double *, const int *, double *, const int *);\nint    BLASFUNC(caxpyc)(const int *, const float  *, const float  *, const int *, float  *, const int *);\nint    BLASFUNC(zaxpyc)(const int *, const double *, const double *, const int *, double *, const int *);\nint    BLASFUNC(xaxpyc)(const int *, const double *, const double *, const int *, double *, const int *);\n\nint    BLASFUNC(scopy) (int *, float  *, int *, float  *, int *);\nint    BLASFUNC(dcopy) (int *, double *, int *, double *, int *);\nint    BLASFUNC(qcopy) (int *, double *, int *, double *, int *);\nint    BLASFUNC(ccopy) (int *, float  *, int *, float  *, int *);\nint    BLASFUNC(zcopy) (int *, double *, int *, double *, int *);\nint    BLASFUNC(xcopy) (int *, double *, int *, double *, int *);\n\nint    BLASFUNC(sswap) (int *, float  *, int *, float  *, int *);\nint    BLASFUNC(dswap) (int *, double *, int *, double *, int *);\nint    BLASFUNC(qswap) (int *, double *, int *, double *, int *);\nint    BLASFUNC(cswap) (int *, float  *, int *, float  *, int *);\nint    BLASFUNC(zswap) (int *, double *, int *, double *, int *);\nint    BLASFUNC(xswap) (int *, double *, int *, double *, int *);\n\nfloat  BLASFUNC(sasum) (int *, float  *, int *);\nfloat  BLASFUNC(scasum)(int *, float  *, int *);\ndouble BLASFUNC(dasum) (int *, double *, int *);\ndouble BLASFUNC(qasum) (int *, double *, int *);\ndouble BLASFUNC(dzasum)(int *, double *, int *);\ndouble BLASFUNC(qxasum)(int *, double *, int *);\n\nint    BLASFUNC(isamax)(int *, float  *, int *);\nint    BLASFUNC(idamax)(int *, double *, int *);\nint    BLASFUNC(iqamax)(int *, double *, int *);\nint    BLASFUNC(icamax)(int *, float  *, int *);\nint    BLASFUNC(izamax)(int *, double *, int *);\nint    BLASFUNC(ixamax)(int *, double *, int *);\n\nint    BLASFUNC(ismax) (int *, float  *, int *);\nint    BLASFUNC(idmax) (int *, double *, int *);\nint    BLASFUNC(iqmax) (int *, double *, int *);\nint    BLASFUNC(icmax) (int *, float  *, int *);\nint    BLASFUNC(izmax) (int *, double *, int *);\nint    BLASFUNC(ixmax) (int *, double *, int *);\n\nint    BLASFUNC(isamin)(int *, float  *, int *);\nint    BLASFUNC(idamin)(int *, double *, int *);\nint    BLASFUNC(iqamin)(int *, double *, int *);\nint    BLASFUNC(icamin)(int *, float  *, int *);\nint    BLASFUNC(izamin)(int *, double *, int *);\nint    BLASFUNC(ixamin)(int *, double *, int *);\n\nint    BLASFUNC(ismin)(int *, float  *, int *);\nint    BLASFUNC(idmin)(int *, double *, int *);\nint    BLASFUNC(iqmin)(int *, double *, int *);\nint    BLASFUNC(icmin)(int *, float  *, int *);\nint    BLASFUNC(izmin)(int *, double *, int *);\nint    BLASFUNC(ixmin)(int *, double *, int *);\n\nfloat  BLASFUNC(samax) (int *, float  *, int *);\ndouble BLASFUNC(damax) (int *, double *, int *);\ndouble BLASFUNC(qamax) (int *, double *, int *);\nfloat  BLASFUNC(scamax)(int *, float  *, int *);\ndouble BLASFUNC(dzamax)(int *, double *, int *);\ndouble BLASFUNC(qxamax)(int *, double *, int *);\n\nfloat  BLASFUNC(samin) (int *, float  *, int *);\ndouble BLASFUNC(damin) (int *, double *, int *);\ndouble BLASFUNC(qamin) (int *, double *, int *);\nfloat  BLASFUNC(scamin)(int *, float  *, int *);\ndouble BLASFUNC(dzamin)(int *, double *, int *);\ndouble BLASFUNC(qxamin)(int *, double *, int *);\n\nfloat  BLASFUNC(smax)  (int *, float  *, int *);\ndouble BLASFUNC(dmax)  (int *, double *, int *);\ndouble BLASFUNC(qmax)  (int *, double *, int *);\nfloat  BLASFUNC(scmax) (int *, float  *, int *);\ndouble BLASFUNC(dzmax) (int *, double *, int *);\ndouble BLASFUNC(qxmax) (int *, double *, int *);\n\nfloat  BLASFUNC(smin)  (int *, float  *, int *);\ndouble BLASFUNC(dmin)  (int *, double *, int *);\ndouble BLASFUNC(qmin)  (int *, double *, int *);\nfloat  BLASFUNC(scmin) (int *, float  *, int *);\ndouble BLASFUNC(dzmin) (int *, double *, int *);\ndouble BLASFUNC(qxmin) (int *, double *, int *);\n\nint    BLASFUNC(sscal) (int *,  float  *, float  *, int *);\nint    BLASFUNC(dscal) (int *,  double *, double *, int *);\nint    BLASFUNC(qscal) (int *,  double *, double *, int *);\nint    BLASFUNC(cscal) (int *,  float  *, float  *, int *);\nint    BLASFUNC(zscal) (int *,  double *, double *, int *);\nint    BLASFUNC(xscal) (int *,  double *, double *, int *);\nint    BLASFUNC(csscal)(int *,  float  *, float  *, int *);\nint    BLASFUNC(zdscal)(int *,  double *, double *, int *);\nint    BLASFUNC(xqscal)(int *,  double *, double *, int *);\n\nfloat  BLASFUNC(snrm2) (int *, float  *, int *);\nfloat  BLASFUNC(scnrm2)(int *, float  *, int *);\n\ndouble BLASFUNC(dnrm2) (int *, double *, int *);\ndouble BLASFUNC(qnrm2) (int *, double *, int *);\ndouble BLASFUNC(dznrm2)(int *, double *, int *);\ndouble BLASFUNC(qxnrm2)(int *, double *, int *);\n\nint    BLASFUNC(srot)  (int *, float  *, int *, float  *, int *, float  *, float  *);\nint    BLASFUNC(drot)  (int *, double *, int *, double *, int *, double *, double *);\nint    BLASFUNC(qrot)  (int *, double *, int *, double *, int *, double *, double *);\nint    BLASFUNC(csrot) (int *, float  *, int *, float  *, int *, float  *, float  *);\nint    BLASFUNC(zdrot) (int *, double *, int *, double *, int *, double *, double *);\nint    BLASFUNC(xqrot) (int *, double *, int *, double *, int *, double *, double *);\n\nint    BLASFUNC(srotg) (float  *, float  *, float  *, float  *);\nint    BLASFUNC(drotg) (double *, double *, double *, double *);\nint    BLASFUNC(qrotg) (double *, double *, double *, double *);\nint    BLASFUNC(crotg) (float  *, float  *, float  *, float  *);\nint    BLASFUNC(zrotg) (double *, double *, double *, double *);\nint    BLASFUNC(xrotg) (double *, double *, double *, double *);\n\nint    BLASFUNC(srotmg)(float  *, float  *, float  *, float  *, float  *);\nint    BLASFUNC(drotmg)(double *, double *, double *, double *, double *);\n\nint    BLASFUNC(srotm) (int *, float  *, int *, float  *, int *, float  *);\nint    BLASFUNC(drotm) (int *, double *, int *, double *, int *, double *);\nint    BLASFUNC(qrotm) (int *, double *, int *, double *, int *, double *);\n\n/* Level 2 routines */\n\nint BLASFUNC(sger)(int *,    int *, float *,  float *, int *,\n\t\t   float *,  int *, float *,  int *);\nint BLASFUNC(dger)(int *,    int *, double *, double *, int *,\n\t\t   double *, int *, double *, int *);\nint BLASFUNC(qger)(int *,    int *, double *, double *, int *,\n\t\t   double *, int *, double *, int *);\nint BLASFUNC(cgeru)(int *,    int *, float *,  float *, int *,\n\t\t    float *,  int *, float *,  int *);\nint BLASFUNC(cgerc)(int *,    int *, float *,  float *, int *,\n\t\t    float *,  int *, float *,  int *);\nint BLASFUNC(zgeru)(int *,    int *, double *, double *, int *,\n\t\t    double *, int *, double *, int *);\nint BLASFUNC(zgerc)(int *,    int *, double *, double *, int *,\n\t\t    double *, int *, double *, int *);\nint BLASFUNC(xgeru)(int *,    int *, double *, double *, int *,\n\t\t    double *, int *, double *, int *);\nint BLASFUNC(xgerc)(int *,    int *, double *, double *, int *,\n\t\t    double *, int *, double *, int *);\n\nint BLASFUNC(sgemv)(const char *, const int *, const int *, const float  *, const float  *, const int *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(dgemv)(const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(qgemv)(const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(cgemv)(const char *, const int *, const int *, const float  *, const float  *, const int *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(zgemv)(const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(xgemv)(const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\n\nint BLASFUNC(strsv) (const char *, const char *, const char *, const int *, const float  *, const int *, float  *, const int *);\nint BLASFUNC(dtrsv) (const char *, const char *, const char *, const int *, const double *, const int *, double *, const int *);\nint BLASFUNC(qtrsv) (const char *, const char *, const char *, const int *, const double *, const int *, double *, const int *);\nint BLASFUNC(ctrsv) (const char *, const char *, const char *, const int *, const float  *, const int *, float  *, const int *);\nint BLASFUNC(ztrsv) (const char *, const char *, const char *, const int *, const double *, const int *, double *, const int *);\nint BLASFUNC(xtrsv) (const char *, const char *, const char *, const int *, const double *, const int *, double *, const int *);\n\nint BLASFUNC(stpsv) (char *, char *, char *, int *, float  *, float  *, int *);\nint BLASFUNC(dtpsv) (char *, char *, char *, int *, double *, double *, int *);\nint BLASFUNC(qtpsv) (char *, char *, char *, int *, double *, double *, int *);\nint BLASFUNC(ctpsv) (char *, char *, char *, int *, float  *, float  *, int *);\nint BLASFUNC(ztpsv) (char *, char *, char *, int *, double *, double *, int *);\nint BLASFUNC(xtpsv) (char *, char *, char *, int *, double *, double *, int *);\n\nint BLASFUNC(strmv) (const char *, const char *, const char *, const int *, const float  *, const int *, float  *, const int *);\nint BLASFUNC(dtrmv) (const char *, const char *, const char *, const int *, const double *, const int *, double *, const int *);\nint BLASFUNC(qtrmv) (const char *, const char *, const char *, const int *, const double *, const int *, double *, const int *);\nint BLASFUNC(ctrmv) (const char *, const char *, const char *, const int *, const float  *, const int *, float  *, const int *);\nint BLASFUNC(ztrmv) (const char *, const char *, const char *, const int *, const double *, const int *, double *, const int *);\nint BLASFUNC(xtrmv) (const char *, const char *, const char *, const int *, const double *, const int *, double *, const int *);\n\nint BLASFUNC(stpmv) (char *, char *, char *, int *, float  *, float  *, int *);\nint BLASFUNC(dtpmv) (char *, char *, char *, int *, double *, double *, int *);\nint BLASFUNC(qtpmv) (char *, char *, char *, int *, double *, double *, int *);\nint BLASFUNC(ctpmv) (char *, char *, char *, int *, float  *, float  *, int *);\nint BLASFUNC(ztpmv) (char *, char *, char *, int *, double *, double *, int *);\nint BLASFUNC(xtpmv) (char *, char *, char *, int *, double *, double *, int *);\n\nint BLASFUNC(stbmv) (char *, char *, char *, int *, int *, float  *, int *, float  *, int *);\nint BLASFUNC(dtbmv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);\nint BLASFUNC(qtbmv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);\nint BLASFUNC(ctbmv) (char *, char *, char *, int *, int *, float  *, int *, float  *, int *);\nint BLASFUNC(ztbmv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);\nint BLASFUNC(xtbmv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);\n\nint BLASFUNC(stbsv) (char *, char *, char *, int *, int *, float  *, int *, float  *, int *);\nint BLASFUNC(dtbsv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);\nint BLASFUNC(qtbsv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);\nint BLASFUNC(ctbsv) (char *, char *, char *, int *, int *, float  *, int *, float  *, int *);\nint BLASFUNC(ztbsv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);\nint BLASFUNC(xtbsv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);\n\nint BLASFUNC(ssymv) (const char *, const int *, const float  *, const float  *, const int *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(dsymv) (const char *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(qsymv) (const char *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\n\nint BLASFUNC(sspmv) (char *, int *, float  *, float *,\n\t\t     float  *, int *, float *, float *, int *);\nint BLASFUNC(dspmv) (char *, int *, double  *, double *,\n\t\t     double  *, int *, double *, double *, int *);\nint BLASFUNC(qspmv) (char *, int *, double  *, double *,\n\t\t     double  *, int *, double *, double *, int *);\n\nint BLASFUNC(ssyr) (const char *, const int *, const float   *, const float  *, const int *, float  *, const int *);\nint BLASFUNC(dsyr) (const char *, const int *, const double  *, const double *, const int *, double *, const int *);\nint BLASFUNC(qsyr) (const char *, const int *, const double  *, const double *, const int *, double *, const int *);\n\nint BLASFUNC(ssyr2) (const char *, const int *, const float   *, const float  *, const int *, const float  *, const int *, float  *, const int *);\nint BLASFUNC(dsyr2) (const char *, const int *, const double  *, const double *, const int *, const double *, const int *, double *, const int *);\nint BLASFUNC(qsyr2) (const char *, const int *, const double  *, const double *, const int *, const double *, const int *, double *, const int *);\nint BLASFUNC(csyr2) (const char *, const int *, const float   *, const float  *, const int *, const float  *, const int *, float  *, const int *);\nint BLASFUNC(zsyr2) (const char *, const int *, const double  *, const double *, const int *, const double *, const int *, double *, const int *);\nint BLASFUNC(xsyr2) (const char *, const int *, const double  *, const double *, const int *, const double *, const int *, double *, const int *);\n\nint BLASFUNC(sspr) (char *, int *, float   *, float  *, int *,\n\t\t    float  *);\nint BLASFUNC(dspr) (char *, int *, double  *, double *, int *,\n\t\t    double *);\nint BLASFUNC(qspr) (char *, int *, double  *, double *, int *,\n\t\t    double *);\n\nint BLASFUNC(sspr2) (char *, int *, float   *,\n\t\t     float  *, int *, float  *, int *, float  *);\nint BLASFUNC(dspr2) (char *, int *, double  *,\n\t\t     double *, int *, double *, int *, double *);\nint BLASFUNC(qspr2) (char *, int *, double  *,\n\t\t     double *, int *, double *, int *, double *);\nint BLASFUNC(cspr2) (char *, int *, float   *,\n\t\t     float  *, int *, float  *, int *, float  *);\nint BLASFUNC(zspr2) (char *, int *, double  *,\n\t\t     double *, int *, double *, int *, double *);\nint BLASFUNC(xspr2) (char *, int *, double  *,\n\t\t     double *, int *, double *, int *, double *);\n\nint BLASFUNC(cher) (char *, int *, float   *, float  *, int *,\n\t\t    float  *, int *);\nint BLASFUNC(zher) (char *, int *, double  *, double *, int *,\n\t\t    double *, int *);\nint BLASFUNC(xher) (char *, int *, double  *, double *, int *,\n\t\t    double *, int *);\n\nint BLASFUNC(chpr) (char *, int *, float   *, float  *, int *, float  *);\nint BLASFUNC(zhpr) (char *, int *, double  *, double *, int *, double *);\nint BLASFUNC(xhpr) (char *, int *, double  *, double *, int *, double *);\n\nint BLASFUNC(cher2) (char *, int *, float   *,\n\t\t     float  *, int *, float  *, int *, float  *, int *);\nint BLASFUNC(zher2) (char *, int *, double  *,\n\t\t     double *, int *, double *, int *, double *, int *);\nint BLASFUNC(xher2) (char *, int *, double  *,\n\t\t     double *, int *, double *, int *, double *, int *);\n\nint BLASFUNC(chpr2) (char *, int *, float   *,\n\t\t     float  *, int *, float  *, int *, float  *);\nint BLASFUNC(zhpr2) (char *, int *, double  *,\n\t\t     double *, int *, double *, int *, double *);\nint BLASFUNC(xhpr2) (char *, int *, double  *,\n\t\t     double *, int *, double *, int *, double *);\n\nint BLASFUNC(chemv) (const char *, const int *, const float  *, const float  *, const int *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(zhemv) (const char *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(xhemv) (const char *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\n\nint BLASFUNC(chpmv) (char *, int *, float  *, float *,\n\t\t     float  *, int *, float *, float *, int *);\nint BLASFUNC(zhpmv) (char *, int *, double  *, double *,\n\t\t     double  *, int *, double *, double *, int *);\nint BLASFUNC(xhpmv) (char *, int *, double  *, double *,\n\t\t     double  *, int *, double *, double *, int *);\n\nint BLASFUNC(snorm)(char *, int *, int *, float  *, int *);\nint BLASFUNC(dnorm)(char *, int *, int *, double *, int *);\nint BLASFUNC(cnorm)(char *, int *, int *, float  *, int *);\nint BLASFUNC(znorm)(char *, int *, int *, double *, int *);\n\nint BLASFUNC(sgbmv)(char *, int *, int *, int *, int *, float  *, float  *, int *,\n\t\t    float  *, int *, float  *, float  *, int *);\nint BLASFUNC(dgbmv)(char *, int *, int *, int *, int *, double *, double *, int *,\n\t\t    double *, int *, double *, double *, int *);\nint BLASFUNC(qgbmv)(char *, int *, int *, int *, int *, double *, double *, int *,\n\t\t    double *, int *, double *, double *, int *);\nint BLASFUNC(cgbmv)(char *, int *, int *, int *, int *, float  *, float  *, int *,\n\t\t    float  *, int *, float  *, float  *, int *);\nint BLASFUNC(zgbmv)(char *, int *, int *, int *, int *, double *, double *, int *,\n\t\t    double *, int *, double *, double *, int *);\nint BLASFUNC(xgbmv)(char *, int *, int *, int *, int *, double *, double *, int *,\n\t\t    double *, int *, double *, double *, int *);\n\nint BLASFUNC(ssbmv)(char *, int *, int *, float  *, float  *, int *,\n\t\t    float  *, int *, float  *, float  *, int *);\nint BLASFUNC(dsbmv)(char *, int *, int *, double *, double *, int *,\n\t\t    double *, int *, double *, double *, int *);\nint BLASFUNC(qsbmv)(char *, int *, int *, double *, double *, int *,\n\t\t    double *, int *, double *, double *, int *);\nint BLASFUNC(csbmv)(char *, int *, int *, float  *, float  *, int *,\n\t\t    float  *, int *, float  *, float  *, int *);\nint BLASFUNC(zsbmv)(char *, int *, int *, double *, double *, int *,\n\t\t    double *, int *, double *, double *, int *);\nint BLASFUNC(xsbmv)(char *, int *, int *, double *, double *, int *,\n\t\t    double *, int *, double *, double *, int *);\n\nint BLASFUNC(chbmv)(char *, int *, int *, float  *, float  *, int *,\n\t\t    float  *, int *, float  *, float  *, int *);\nint BLASFUNC(zhbmv)(char *, int *, int *, double *, double *, int *,\n\t\t    double *, int *, double *, double *, int *);\nint BLASFUNC(xhbmv)(char *, int *, int *, double *, double *, int *,\n\t\t    double *, int *, double *, double *, int *);\n\n/* Level 3 routines */\n\nint BLASFUNC(sgemm)(const char *, const char *, const int *, const int *, const int *, const float  *, const float  *, const int *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(dgemm)(const char *, const char *, const int *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(qgemm)(const char *, const char *, const int *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(cgemm)(const char *, const char *, const int *, const int *, const int *, const float  *, const float  *, const int *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(zgemm)(const char *, const char *, const int *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(xgemm)(const char *, const char *, const int *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\n\nint BLASFUNC(cgemm3m)(char *, char *, int *, int *, int *, float *,\n\t   float  *, int *, float  *, int *, float  *, float  *, int *);\nint BLASFUNC(zgemm3m)(char *, char *, int *, int *, int *, double *,\n\t   double *, int *, double *, int *, double *, double *, int *);\nint BLASFUNC(xgemm3m)(char *, char *, int *, int *, int *, double *,\n\t   double *, int *, double *, int *, double *, double *, int *);\n\nint BLASFUNC(sge2mm)(char *, char *, char *, int *, int *,\n\t\t     float *, float  *, int *, float  *, int *,\n\t\t     float *, float  *, int *);\nint BLASFUNC(dge2mm)(char *, char *, char *, int *, int *,\n\t\t     double *, double  *, int *, double  *, int *,\n\t\t     double *, double  *, int *);\nint BLASFUNC(cge2mm)(char *, char *, char *, int *, int *,\n\t\t     float *, float  *, int *, float  *, int *,\n\t\t     float *, float  *, int *);\nint BLASFUNC(zge2mm)(char *, char *, char *, int *, int *,\n\t\t     double *, double  *, int *, double  *, int *,\n\t\t     double *, double  *, int *);\n\nint BLASFUNC(strsm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,  const float *,  const int *, float *,  const int *);\nint BLASFUNC(dtrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);\nint BLASFUNC(qtrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);\nint BLASFUNC(ctrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,  const float *,  const int *, float *,  const int *);\nint BLASFUNC(ztrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);\nint BLASFUNC(xtrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);\n\nint BLASFUNC(strmm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,  const float *,  const int *, float *,  const int *);\nint BLASFUNC(dtrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);\nint BLASFUNC(qtrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);\nint BLASFUNC(ctrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,  const float *,  const int *, float *,  const int *);\nint BLASFUNC(ztrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);\nint BLASFUNC(xtrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);\n\nint BLASFUNC(ssymm)(const char *, const char *, const int *, const int *, const float  *, const float  *, const int *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(dsymm)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(qsymm)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(csymm)(const char *, const char *, const int *, const int *, const float  *, const float  *, const int *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(zsymm)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(xsymm)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\n\nint BLASFUNC(csymm3m)(char *, char *, int *, int *, float  *, float  *, int *, float  *, int *, float  *, float  *, int *);\nint BLASFUNC(zsymm3m)(char *, char *, int *, int *, double *, double *, int *, double *, int *, double *, double *, int *);\nint BLASFUNC(xsymm3m)(char *, char *, int *, int *, double *, double *, int *, double *, int *, double *, double *, int *);\n\nint BLASFUNC(ssyrk)(const char *, const char *, const int *, const int *, const float  *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(dsyrk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(qsyrk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(csyrk)(const char *, const char *, const int *, const int *, const float  *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(zsyrk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(xsyrk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, double *, const int *);\n\nint BLASFUNC(ssyr2k)(const char *, const char *, const int *, const int *, const float  *, const float  *, const int *, const float *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(dsyr2k)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double*, const int *, const double *, double *, const int *);\nint BLASFUNC(qsyr2k)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double*, const int *, const double *, double *, const int *);\nint BLASFUNC(csyr2k)(const char *, const char *, const int *, const int *, const float  *, const float  *, const int *, const float *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(zsyr2k)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double*, const int *, const double *, double *, const int *);\nint BLASFUNC(xsyr2k)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double*, const int *, const double *, double *, const int *);\n\nint BLASFUNC(chemm)(const char *, const char *, const int *, const int *, const float  *, const float  *, const int *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(zhemm)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(xhemm)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\n\nint BLASFUNC(chemm3m)(char *, char *, int *, int *, float  *, float  *, int *,\n\t   float  *, int *, float  *, float  *, int *);\nint BLASFUNC(zhemm3m)(char *, char *, int *, int *, double *, double *, int *,\n\t   double *, int *, double *, double *, int *);\nint BLASFUNC(xhemm3m)(char *, char *, int *, int *, double *, double *, int *,\n\t   double *, int *, double *, double *, int *);\n\nint BLASFUNC(cherk)(const char *, const char *, const int *, const int *, const float  *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(zherk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(xherk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, double *, const int *);\n\nint BLASFUNC(cher2k)(const char *, const char *, const int *, const int *, const float  *, const float  *, const int *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(zher2k)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(xher2k)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(cher2m)(const char *, const char *, const char *, const int *, const int *, const float  *, const float  *, const int *, const float *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(zher2m)(const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double*, const int *, const double *, double *, const int *);\nint BLASFUNC(xher2m)(const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double*, const int *, const double *, double *, const int *);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/misc/lapack.h",
    "content": "#ifndef LAPACK_H\n#define LAPACK_H\n\n#include \"blas.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\nint BLASFUNC(csymv) (const char *, const int *, const float  *, const float  *, const int *, const float  *, const int *, const float  *, float  *, const int *);\nint BLASFUNC(zsymv) (const char *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\nint BLASFUNC(xsymv) (const char *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);\n\n\nint BLASFUNC(cspmv) (char *, int *, float  *, float *,\n         float  *, int *, float *, float *, int *);\nint BLASFUNC(zspmv) (char *, int *, double  *, double *,\n         double  *, int *, double *, double *, int *);\nint BLASFUNC(xspmv) (char *, int *, double  *, double *,\n         double  *, int *, double *, double *, int *);\n\nint BLASFUNC(csyr) (char *, int *, float   *, float  *, int *,\n        float  *, int *);\nint BLASFUNC(zsyr) (char *, int *, double  *, double *, int *,\n        double *, int *);\nint BLASFUNC(xsyr) (char *, int *, double  *, double *, int *,\n        double *, int *);\n\nint BLASFUNC(cspr) (char *, int *, float   *, float  *, int *,\n        float  *);\nint BLASFUNC(zspr) (char *, int *, double  *, double *, int *,\n        double *);\nint BLASFUNC(xspr) (char *, int *, double  *, double *, int *,\n        double *);\n\nint BLASFUNC(sgemt)(char *, int *, int *, float  *, float  *, int *,\n        float  *, int *);\nint BLASFUNC(dgemt)(char *, int *, int *, double *, double *, int *,\n        double *, int *);\nint BLASFUNC(cgemt)(char *, int *, int *, float  *, float  *, int *,\n        float  *, int *);\nint BLASFUNC(zgemt)(char *, int *, int *, double *, double *, int *,\n        double *, int *);\n\nint BLASFUNC(sgema)(char *, char *, int *, int *, float  *,\n        float  *, int *, float *, float  *, int *, float *, int *);\nint BLASFUNC(dgema)(char *, char *, int *, int *, double *,\n        double *, int *, double*, double *, int *, double*, int *);\nint BLASFUNC(cgema)(char *, char *, int *, int *, float  *,\n        float  *, int *, float *, float  *, int *, float *, int *);\nint BLASFUNC(zgema)(char *, char *, int *, int *, double *,\n        double *, int *, double*, double *, int *, double*, int *);\n\nint BLASFUNC(sgems)(char *, char *, int *, int *, float  *,\n        float  *, int *, float *, float  *, int *, float *, int *);\nint BLASFUNC(dgems)(char *, char *, int *, int *, double *,\n        double *, int *, double*, double *, int *, double*, int *);\nint BLASFUNC(cgems)(char *, char *, int *, int *, float  *,\n        float  *, int *, float *, float  *, int *, float *, int *);\nint BLASFUNC(zgems)(char *, char *, int *, int *, double *,\n        double *, int *, double*, double *, int *, double*, int *);\n\nint BLASFUNC(sgetf2)(int *, int *, float  *, int *, int *, int *);\nint BLASFUNC(dgetf2)(int *, int *, double *, int *, int *, int *);\nint BLASFUNC(qgetf2)(int *, int *, double *, int *, int *, int *);\nint BLASFUNC(cgetf2)(int *, int *, float  *, int *, int *, int *);\nint BLASFUNC(zgetf2)(int *, int *, double *, int *, int *, int *);\nint BLASFUNC(xgetf2)(int *, int *, double *, int *, int *, int *);\n\nint BLASFUNC(sgetrf)(int *, int *, float  *, int *, int *, int *);\nint BLASFUNC(dgetrf)(int *, int *, double *, int *, int *, int *);\nint BLASFUNC(qgetrf)(int *, int *, double *, int *, int *, int *);\nint BLASFUNC(cgetrf)(int *, int *, float  *, int *, int *, int *);\nint BLASFUNC(zgetrf)(int *, int *, double *, int *, int *, int *);\nint BLASFUNC(xgetrf)(int *, int *, double *, int *, int *, int *);\n\nint BLASFUNC(slaswp)(int *, float  *, int *, int *, int *, int *, int *);\nint BLASFUNC(dlaswp)(int *, double *, int *, int *, int *, int *, int *);\nint BLASFUNC(qlaswp)(int *, double *, int *, int *, int *, int *, int *);\nint BLASFUNC(claswp)(int *, float  *, int *, int *, int *, int *, int *);\nint BLASFUNC(zlaswp)(int *, double *, int *, int *, int *, int *, int *);\nint BLASFUNC(xlaswp)(int *, double *, int *, int *, int *, int *, int *);\n\nint BLASFUNC(sgetrs)(char *, int *, int *, float  *, int *, int *, float  *, int *, int *);\nint BLASFUNC(dgetrs)(char *, int *, int *, double *, int *, int *, double *, int *, int *);\nint BLASFUNC(qgetrs)(char *, int *, int *, double *, int *, int *, double *, int *, int *);\nint BLASFUNC(cgetrs)(char *, int *, int *, float  *, int *, int *, float  *, int *, int *);\nint BLASFUNC(zgetrs)(char *, int *, int *, double *, int *, int *, double *, int *, int *);\nint BLASFUNC(xgetrs)(char *, int *, int *, double *, int *, int *, double *, int *, int *);\n\nint BLASFUNC(sgesv)(int *, int *, float  *, int *, int *, float *, int *, int *);\nint BLASFUNC(dgesv)(int *, int *, double *, int *, int *, double*, int *, int *);\nint BLASFUNC(qgesv)(int *, int *, double *, int *, int *, double*, int *, int *);\nint BLASFUNC(cgesv)(int *, int *, float  *, int *, int *, float *, int *, int *);\nint BLASFUNC(zgesv)(int *, int *, double *, int *, int *, double*, int *, int *);\nint BLASFUNC(xgesv)(int *, int *, double *, int *, int *, double*, int *, int *);\n\nint BLASFUNC(spotf2)(char *, int *, float  *, int *, int *);\nint BLASFUNC(dpotf2)(char *, int *, double *, int *, int *);\nint BLASFUNC(qpotf2)(char *, int *, double *, int *, int *);\nint BLASFUNC(cpotf2)(char *, int *, float  *, int *, int *);\nint BLASFUNC(zpotf2)(char *, int *, double *, int *, int *);\nint BLASFUNC(xpotf2)(char *, int *, double *, int *, int *);\n\nint BLASFUNC(spotrf)(char *, int *, float  *, int *, int *);\nint BLASFUNC(dpotrf)(char *, int *, double *, int *, int *);\nint BLASFUNC(qpotrf)(char *, int *, double *, int *, int *);\nint BLASFUNC(cpotrf)(char *, int *, float  *, int *, int *);\nint BLASFUNC(zpotrf)(char *, int *, double *, int *, int *);\nint BLASFUNC(xpotrf)(char *, int *, double *, int *, int *);\n\nint BLASFUNC(slauu2)(char *, int *, float  *, int *, int *);\nint BLASFUNC(dlauu2)(char *, int *, double *, int *, int *);\nint BLASFUNC(qlauu2)(char *, int *, double *, int *, int *);\nint BLASFUNC(clauu2)(char *, int *, float  *, int *, int *);\nint BLASFUNC(zlauu2)(char *, int *, double *, int *, int *);\nint BLASFUNC(xlauu2)(char *, int *, double *, int *, int *);\n\nint BLASFUNC(slauum)(char *, int *, float  *, int *, int *);\nint BLASFUNC(dlauum)(char *, int *, double *, int *, int *);\nint BLASFUNC(qlauum)(char *, int *, double *, int *, int *);\nint BLASFUNC(clauum)(char *, int *, float  *, int *, int *);\nint BLASFUNC(zlauum)(char *, int *, double *, int *, int *);\nint BLASFUNC(xlauum)(char *, int *, double *, int *, int *);\n\nint BLASFUNC(strti2)(char *, char *, int *, float  *, int *, int *);\nint BLASFUNC(dtrti2)(char *, char *, int *, double *, int *, int *);\nint BLASFUNC(qtrti2)(char *, char *, int *, double *, int *, int *);\nint BLASFUNC(ctrti2)(char *, char *, int *, float  *, int *, int *);\nint BLASFUNC(ztrti2)(char *, char *, int *, double *, int *, int *);\nint BLASFUNC(xtrti2)(char *, char *, int *, double *, int *, int *);\n\nint BLASFUNC(strtri)(char *, char *, int *, float  *, int *, int *);\nint BLASFUNC(dtrtri)(char *, char *, int *, double *, int *, int *);\nint BLASFUNC(qtrtri)(char *, char *, int *, double *, int *, int *);\nint BLASFUNC(ctrtri)(char *, char *, int *, float  *, int *, int *);\nint BLASFUNC(ztrtri)(char *, char *, int *, double *, int *, int *);\nint BLASFUNC(xtrtri)(char *, char *, int *, double *, int *, int *);\n\nint BLASFUNC(spotri)(char *, int *, float  *, int *, int *);\nint BLASFUNC(dpotri)(char *, int *, double *, int *, int *);\nint BLASFUNC(qpotri)(char *, int *, double *, int *, int *);\nint BLASFUNC(cpotri)(char *, int *, float  *, int *, int *);\nint BLASFUNC(zpotri)(char *, int *, double *, int *, int *);\nint BLASFUNC(xpotri)(char *, int *, double *, int *, int *);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "include/externals/Eigen/src/misc/lapacke.h",
    "content": "/*****************************************************************************\n  Copyright (c) 2010, Intel Corp.\n  All rights reserved.\n\n  Redistribution and use in source and binary forms, with or without\n  modification, are permitted provided that the following conditions are met:\n\n    * Redistributions of source code must retain the above copyright notice,\n      this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of Intel Corporation nor the names of its contributors\n      may be used to endorse or promote products derived from this software\n      without specific prior written permission.\n\n  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n  THE POSSIBILITY OF SUCH DAMAGE.\n******************************************************************************\n* Contents: Native C interface to LAPACK\n* Author: Intel Corporation\n* Generated November, 2011\n*****************************************************************************/\n\n#ifndef _MKL_LAPACKE_H_\n\n#ifndef _LAPACKE_H_\n#define _LAPACKE_H_\n\n/*\n*  Turn on HAVE_LAPACK_CONFIG_H to redefine C-LAPACK datatypes\n*/\n#ifdef HAVE_LAPACK_CONFIG_H\n#include \"lapacke_config.h\"\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n#include <stdlib.h>\n\n#ifndef lapack_int\n#define lapack_int     int\n#endif\n\n#ifndef lapack_logical\n#define lapack_logical lapack_int\n#endif\n\n/* Complex types are structures equivalent to the\n* Fortran complex types COMPLEX(4) and COMPLEX(8).\n*\n* One can also redefine the types with his own types\n* for example by including in the code definitions like\n*\n* #define lapack_complex_float std::complex<float>\n* #define lapack_complex_double std::complex<double>\n*\n* or define these types in the command line:\n*\n* -Dlapack_complex_float=\"std::complex<float>\"\n* -Dlapack_complex_double=\"std::complex<double>\"\n*/\n\n#ifndef LAPACK_COMPLEX_CUSTOM\n\n/* Complex type (single precision) */\n#ifndef lapack_complex_float\n#include <complex.h>\n#define lapack_complex_float    float _Complex\n#endif\n\n#ifndef lapack_complex_float_real\n#define lapack_complex_float_real(z)       (creal(z))\n#endif\n\n#ifndef lapack_complex_float_imag\n#define lapack_complex_float_imag(z)       (cimag(z))\n#endif\n\nlapack_complex_float lapack_make_complex_float( float re, float im );\n\n/* Complex type (double precision) */\n#ifndef lapack_complex_double\n#include <complex.h>\n#define lapack_complex_double   double _Complex\n#endif\n\n#ifndef lapack_complex_double_real\n#define lapack_complex_double_real(z)      (creal(z))\n#endif\n\n#ifndef lapack_complex_double_imag\n#define lapack_complex_double_imag(z)       (cimag(z))\n#endif\n\nlapack_complex_double lapack_make_complex_double( double re, double im );\n\n#endif\n\n#ifndef LAPACKE_malloc\n#define LAPACKE_malloc( size ) malloc( size )\n#endif\n#ifndef LAPACKE_free\n#define LAPACKE_free( p )      free( p )\n#endif\n\n#define LAPACK_C2INT( x ) (lapack_int)(*((float*)&x ))\n#define LAPACK_Z2INT( x ) (lapack_int)(*((double*)&x ))\n\n#define LAPACK_ROW_MAJOR               101\n#define LAPACK_COL_MAJOR               102\n\n#define LAPACK_WORK_MEMORY_ERROR       -1010\n#define LAPACK_TRANSPOSE_MEMORY_ERROR  -1011\n\n/* Callback logical functions of one, two, or three arguments are used\n*  to select eigenvalues to sort to the top left of the Schur form.\n*  The value is selected if function returns TRUE (non-zero). */\n\ntypedef lapack_logical (*LAPACK_S_SELECT2) ( const float*, const float* );\ntypedef lapack_logical (*LAPACK_S_SELECT3)\n    ( const float*, const float*, const float* );\ntypedef lapack_logical (*LAPACK_D_SELECT2) ( const double*, const double* );\ntypedef lapack_logical (*LAPACK_D_SELECT3)\n    ( const double*, const double*, const double* );\n\ntypedef lapack_logical (*LAPACK_C_SELECT1) ( const lapack_complex_float* );\ntypedef lapack_logical (*LAPACK_C_SELECT2)\n    ( const lapack_complex_float*, const lapack_complex_float* );\ntypedef lapack_logical (*LAPACK_Z_SELECT1) ( const lapack_complex_double* );\ntypedef lapack_logical (*LAPACK_Z_SELECT2)\n    ( const lapack_complex_double*, const lapack_complex_double* );\n\n#include \"lapacke_mangling.h\"\n\n#define LAPACK_lsame LAPACK_GLOBAL(lsame,LSAME)\nlapack_logical LAPACK_lsame( char* ca,  char* cb,\n                              lapack_int lca, lapack_int lcb );\n\n/* C-LAPACK function prototypes */\n\nlapack_int LAPACKE_sbdsdc( int matrix_order, char uplo, char compq,\n                           lapack_int n, float* d, float* e, float* u,\n                           lapack_int ldu, float* vt, lapack_int ldvt, float* q,\n                           lapack_int* iq );\nlapack_int LAPACKE_dbdsdc( int matrix_order, char uplo, char compq,\n                           lapack_int n, double* d, double* e, double* u,\n                           lapack_int ldu, double* vt, lapack_int ldvt,\n                           double* q, lapack_int* iq );\n\nlapack_int LAPACKE_sbdsqr( int matrix_order, char uplo, lapack_int n,\n                           lapack_int ncvt, lapack_int nru, lapack_int ncc,\n                           float* d, float* e, float* vt, lapack_int ldvt,\n                           float* u, lapack_int ldu, float* c, lapack_int ldc );\nlapack_int LAPACKE_dbdsqr( int matrix_order, char uplo, lapack_int n,\n                           lapack_int ncvt, lapack_int nru, lapack_int ncc,\n                           double* d, double* e, double* vt, lapack_int ldvt,\n                           double* u, lapack_int ldu, double* c,\n                           lapack_int ldc );\nlapack_int LAPACKE_cbdsqr( int matrix_order, char uplo, lapack_int n,\n                           lapack_int ncvt, lapack_int nru, lapack_int ncc,\n                           float* d, float* e, lapack_complex_float* vt,\n                           lapack_int ldvt, lapack_complex_float* u,\n                           lapack_int ldu, lapack_complex_float* c,\n                           lapack_int ldc );\nlapack_int LAPACKE_zbdsqr( int matrix_order, char uplo, lapack_int n,\n                           lapack_int ncvt, lapack_int nru, lapack_int ncc,\n                           double* d, double* e, lapack_complex_double* vt,\n                           lapack_int ldvt, lapack_complex_double* u,\n                           lapack_int ldu, lapack_complex_double* c,\n                           lapack_int ldc );\n\nlapack_int LAPACKE_sdisna( char job, lapack_int m, lapack_int n, const float* d,\n                           float* sep );\nlapack_int LAPACKE_ddisna( char job, lapack_int m, lapack_int n,\n                           const double* d, double* sep );\n\nlapack_int LAPACKE_sgbbrd( int matrix_order, char vect, lapack_int m,\n                           lapack_int n, lapack_int ncc, lapack_int kl,\n                           lapack_int ku, float* ab, lapack_int ldab, float* d,\n                           float* e, float* q, lapack_int ldq, float* pt,\n                           lapack_int ldpt, float* c, lapack_int ldc );\nlapack_int LAPACKE_dgbbrd( int matrix_order, char vect, lapack_int m,\n                           lapack_int n, lapack_int ncc, lapack_int kl,\n                           lapack_int ku, double* ab, lapack_int ldab,\n                           double* d, double* e, double* q, lapack_int ldq,\n                           double* pt, lapack_int ldpt, double* c,\n                           lapack_int ldc );\nlapack_int LAPACKE_cgbbrd( int matrix_order, char vect, lapack_int m,\n                           lapack_int n, lapack_int ncc, lapack_int kl,\n                           lapack_int ku, lapack_complex_float* ab,\n                           lapack_int ldab, float* d, float* e,\n                           lapack_complex_float* q, lapack_int ldq,\n                           lapack_complex_float* pt, lapack_int ldpt,\n                           lapack_complex_float* c, lapack_int ldc );\nlapack_int LAPACKE_zgbbrd( int matrix_order, char vect, lapack_int m,\n                           lapack_int n, lapack_int ncc, lapack_int kl,\n                           lapack_int ku, lapack_complex_double* ab,\n                           lapack_int ldab, double* d, double* e,\n                           lapack_complex_double* q, lapack_int ldq,\n                           lapack_complex_double* pt, lapack_int ldpt,\n                           lapack_complex_double* c, lapack_int ldc );\n\nlapack_int LAPACKE_sgbcon( int matrix_order, char norm, lapack_int n,\n                           lapack_int kl, lapack_int ku, const float* ab,\n                           lapack_int ldab, const lapack_int* ipiv, float anorm,\n                           float* rcond );\nlapack_int LAPACKE_dgbcon( int matrix_order, char norm, lapack_int n,\n                           lapack_int kl, lapack_int ku, const double* ab,\n                           lapack_int ldab, const lapack_int* ipiv,\n                           double anorm, double* rcond );\nlapack_int LAPACKE_cgbcon( int matrix_order, char norm, lapack_int n,\n                           lapack_int kl, lapack_int ku,\n                           const lapack_complex_float* ab, lapack_int ldab,\n                           const lapack_int* ipiv, float anorm, float* rcond );\nlapack_int LAPACKE_zgbcon( int matrix_order, char norm, lapack_int n,\n                           lapack_int kl, lapack_int ku,\n                           const lapack_complex_double* ab, lapack_int ldab,\n                           const lapack_int* ipiv, double anorm,\n                           double* rcond );\n\nlapack_int LAPACKE_sgbequ( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku, const float* ab,\n                           lapack_int ldab, float* r, float* c, float* rowcnd,\n                           float* colcnd, float* amax );\nlapack_int LAPACKE_dgbequ( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku, const double* ab,\n                           lapack_int ldab, double* r, double* c,\n                           double* rowcnd, double* colcnd, double* amax );\nlapack_int LAPACKE_cgbequ( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku,\n                           const lapack_complex_float* ab, lapack_int ldab,\n                           float* r, float* c, float* rowcnd, float* colcnd,\n                           float* amax );\nlapack_int LAPACKE_zgbequ( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku,\n                           const lapack_complex_double* ab, lapack_int ldab,\n                           double* r, double* c, double* rowcnd, double* colcnd,\n                           double* amax );\n\nlapack_int LAPACKE_sgbequb( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_int kl, lapack_int ku, const float* ab,\n                            lapack_int ldab, float* r, float* c, float* rowcnd,\n                            float* colcnd, float* amax );\nlapack_int LAPACKE_dgbequb( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_int kl, lapack_int ku, const double* ab,\n                            lapack_int ldab, double* r, double* c,\n                            double* rowcnd, double* colcnd, double* amax );\nlapack_int LAPACKE_cgbequb( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_int kl, lapack_int ku,\n                            const lapack_complex_float* ab, lapack_int ldab,\n                            float* r, float* c, float* rowcnd, float* colcnd,\n                            float* amax );\nlapack_int LAPACKE_zgbequb( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_int kl, lapack_int ku,\n                            const lapack_complex_double* ab, lapack_int ldab,\n                            double* r, double* c, double* rowcnd,\n                            double* colcnd, double* amax );\n\nlapack_int LAPACKE_sgbrfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int kl, lapack_int ku, lapack_int nrhs,\n                           const float* ab, lapack_int ldab, const float* afb,\n                           lapack_int ldafb, const lapack_int* ipiv,\n                           const float* b, lapack_int ldb, float* x,\n                           lapack_int ldx, float* ferr, float* berr );\nlapack_int LAPACKE_dgbrfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int kl, lapack_int ku, lapack_int nrhs,\n                           const double* ab, lapack_int ldab, const double* afb,\n                           lapack_int ldafb, const lapack_int* ipiv,\n                           const double* b, lapack_int ldb, double* x,\n                           lapack_int ldx, double* ferr, double* berr );\nlapack_int LAPACKE_cgbrfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int kl, lapack_int ku, lapack_int nrhs,\n                           const lapack_complex_float* ab, lapack_int ldab,\n                           const lapack_complex_float* afb, lapack_int ldafb,\n                           const lapack_int* ipiv,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zgbrfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int kl, lapack_int ku, lapack_int nrhs,\n                           const lapack_complex_double* ab, lapack_int ldab,\n                           const lapack_complex_double* afb, lapack_int ldafb,\n                           const lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_sgbrfsx( int matrix_order, char trans, char equed,\n                            lapack_int n, lapack_int kl, lapack_int ku,\n                            lapack_int nrhs, const float* ab, lapack_int ldab,\n                            const float* afb, lapack_int ldafb,\n                            const lapack_int* ipiv, const float* r,\n                            const float* c, const float* b, lapack_int ldb,\n                            float* x, lapack_int ldx, float* rcond, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_dgbrfsx( int matrix_order, char trans, char equed,\n                            lapack_int n, lapack_int kl, lapack_int ku,\n                            lapack_int nrhs, const double* ab, lapack_int ldab,\n                            const double* afb, lapack_int ldafb,\n                            const lapack_int* ipiv, const double* r,\n                            const double* c, const double* b, lapack_int ldb,\n                            double* x, lapack_int ldx, double* rcond,\n                            double* berr, lapack_int n_err_bnds,\n                            double* err_bnds_norm, double* err_bnds_comp,\n                            lapack_int nparams, double* params );\nlapack_int LAPACKE_cgbrfsx( int matrix_order, char trans, char equed,\n                            lapack_int n, lapack_int kl, lapack_int ku,\n                            lapack_int nrhs, const lapack_complex_float* ab,\n                            lapack_int ldab, const lapack_complex_float* afb,\n                            lapack_int ldafb, const lapack_int* ipiv,\n                            const float* r, const float* c,\n                            const lapack_complex_float* b, lapack_int ldb,\n                            lapack_complex_float* x, lapack_int ldx,\n                            float* rcond, float* berr, lapack_int n_err_bnds,\n                            float* err_bnds_norm, float* err_bnds_comp,\n                            lapack_int nparams, float* params );\nlapack_int LAPACKE_zgbrfsx( int matrix_order, char trans, char equed,\n                            lapack_int n, lapack_int kl, lapack_int ku,\n                            lapack_int nrhs, const lapack_complex_double* ab,\n                            lapack_int ldab, const lapack_complex_double* afb,\n                            lapack_int ldafb, const lapack_int* ipiv,\n                            const double* r, const double* c,\n                            const lapack_complex_double* b, lapack_int ldb,\n                            lapack_complex_double* x, lapack_int ldx,\n                            double* rcond, double* berr, lapack_int n_err_bnds,\n                            double* err_bnds_norm, double* err_bnds_comp,\n                            lapack_int nparams, double* params );\n\nlapack_int LAPACKE_sgbsv( int matrix_order, lapack_int n, lapack_int kl,\n                          lapack_int ku, lapack_int nrhs, float* ab,\n                          lapack_int ldab, lapack_int* ipiv, float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_dgbsv( int matrix_order, lapack_int n, lapack_int kl,\n                          lapack_int ku, lapack_int nrhs, double* ab,\n                          lapack_int ldab, lapack_int* ipiv, double* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_cgbsv( int matrix_order, lapack_int n, lapack_int kl,\n                          lapack_int ku, lapack_int nrhs,\n                          lapack_complex_float* ab, lapack_int ldab,\n                          lapack_int* ipiv, lapack_complex_float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_zgbsv( int matrix_order, lapack_int n, lapack_int kl,\n                          lapack_int ku, lapack_int nrhs,\n                          lapack_complex_double* ab, lapack_int ldab,\n                          lapack_int* ipiv, lapack_complex_double* b,\n                          lapack_int ldb );\n\nlapack_int LAPACKE_sgbsvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int kl, lapack_int ku,\n                           lapack_int nrhs, float* ab, lapack_int ldab,\n                           float* afb, lapack_int ldafb, lapack_int* ipiv,\n                           char* equed, float* r, float* c, float* b,\n                           lapack_int ldb, float* x, lapack_int ldx,\n                           float* rcond, float* ferr, float* berr,\n                           float* rpivot );\nlapack_int LAPACKE_dgbsvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int kl, lapack_int ku,\n                           lapack_int nrhs, double* ab, lapack_int ldab,\n                           double* afb, lapack_int ldafb, lapack_int* ipiv,\n                           char* equed, double* r, double* c, double* b,\n                           lapack_int ldb, double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr,\n                           double* rpivot );\nlapack_int LAPACKE_cgbsvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int kl, lapack_int ku,\n                           lapack_int nrhs, lapack_complex_float* ab,\n                           lapack_int ldab, lapack_complex_float* afb,\n                           lapack_int ldafb, lapack_int* ipiv, char* equed,\n                           float* r, float* c, lapack_complex_float* b,\n                           lapack_int ldb, lapack_complex_float* x,\n                           lapack_int ldx, float* rcond, float* ferr,\n                           float* berr, float* rpivot );\nlapack_int LAPACKE_zgbsvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int kl, lapack_int ku,\n                           lapack_int nrhs, lapack_complex_double* ab,\n                           lapack_int ldab, lapack_complex_double* afb,\n                           lapack_int ldafb, lapack_int* ipiv, char* equed,\n                           double* r, double* c, lapack_complex_double* b,\n                           lapack_int ldb, lapack_complex_double* x,\n                           lapack_int ldx, double* rcond, double* ferr,\n                           double* berr, double* rpivot );\n\nlapack_int LAPACKE_sgbsvxx( int matrix_order, char fact, char trans,\n                            lapack_int n, lapack_int kl, lapack_int ku,\n                            lapack_int nrhs, float* ab, lapack_int ldab,\n                            float* afb, lapack_int ldafb, lapack_int* ipiv,\n                            char* equed, float* r, float* c, float* b,\n                            lapack_int ldb, float* x, lapack_int ldx,\n                            float* rcond, float* rpvgrw, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_dgbsvxx( int matrix_order, char fact, char trans,\n                            lapack_int n, lapack_int kl, lapack_int ku,\n                            lapack_int nrhs, double* ab, lapack_int ldab,\n                            double* afb, lapack_int ldafb, lapack_int* ipiv,\n                            char* equed, double* r, double* c, double* b,\n                            lapack_int ldb, double* x, lapack_int ldx,\n                            double* rcond, double* rpvgrw, double* berr,\n                            lapack_int n_err_bnds, double* err_bnds_norm,\n                            double* err_bnds_comp, lapack_int nparams,\n                            double* params );\nlapack_int LAPACKE_cgbsvxx( int matrix_order, char fact, char trans,\n                            lapack_int n, lapack_int kl, lapack_int ku,\n                            lapack_int nrhs, lapack_complex_float* ab,\n                            lapack_int ldab, lapack_complex_float* afb,\n                            lapack_int ldafb, lapack_int* ipiv, char* equed,\n                            float* r, float* c, lapack_complex_float* b,\n                            lapack_int ldb, lapack_complex_float* x,\n                            lapack_int ldx, float* rcond, float* rpvgrw,\n                            float* berr, lapack_int n_err_bnds,\n                            float* err_bnds_norm, float* err_bnds_comp,\n                            lapack_int nparams, float* params );\nlapack_int LAPACKE_zgbsvxx( int matrix_order, char fact, char trans,\n                            lapack_int n, lapack_int kl, lapack_int ku,\n                            lapack_int nrhs, lapack_complex_double* ab,\n                            lapack_int ldab, lapack_complex_double* afb,\n                            lapack_int ldafb, lapack_int* ipiv, char* equed,\n                            double* r, double* c, lapack_complex_double* b,\n                            lapack_int ldb, lapack_complex_double* x,\n                            lapack_int ldx, double* rcond, double* rpvgrw,\n                            double* berr, lapack_int n_err_bnds,\n                            double* err_bnds_norm, double* err_bnds_comp,\n                            lapack_int nparams, double* params );\n\nlapack_int LAPACKE_sgbtrf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku, float* ab,\n                           lapack_int ldab, lapack_int* ipiv );\nlapack_int LAPACKE_dgbtrf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku, double* ab,\n                           lapack_int ldab, lapack_int* ipiv );\nlapack_int LAPACKE_cgbtrf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku,\n                           lapack_complex_float* ab, lapack_int ldab,\n                           lapack_int* ipiv );\nlapack_int LAPACKE_zgbtrf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku,\n                           lapack_complex_double* ab, lapack_int ldab,\n                           lapack_int* ipiv );\n\nlapack_int LAPACKE_sgbtrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int kl, lapack_int ku, lapack_int nrhs,\n                           const float* ab, lapack_int ldab,\n                           const lapack_int* ipiv, float* b, lapack_int ldb );\nlapack_int LAPACKE_dgbtrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int kl, lapack_int ku, lapack_int nrhs,\n                           const double* ab, lapack_int ldab,\n                           const lapack_int* ipiv, double* b, lapack_int ldb );\nlapack_int LAPACKE_cgbtrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int kl, lapack_int ku, lapack_int nrhs,\n                           const lapack_complex_float* ab, lapack_int ldab,\n                           const lapack_int* ipiv, lapack_complex_float* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_zgbtrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int kl, lapack_int ku, lapack_int nrhs,\n                           const lapack_complex_double* ab, lapack_int ldab,\n                           const lapack_int* ipiv, lapack_complex_double* b,\n                           lapack_int ldb );\n\nlapack_int LAPACKE_sgebak( int matrix_order, char job, char side, lapack_int n,\n                           lapack_int ilo, lapack_int ihi, const float* scale,\n                           lapack_int m, float* v, lapack_int ldv );\nlapack_int LAPACKE_dgebak( int matrix_order, char job, char side, lapack_int n,\n                           lapack_int ilo, lapack_int ihi, const double* scale,\n                           lapack_int m, double* v, lapack_int ldv );\nlapack_int LAPACKE_cgebak( int matrix_order, char job, char side, lapack_int n,\n                           lapack_int ilo, lapack_int ihi, const float* scale,\n                           lapack_int m, lapack_complex_float* v,\n                           lapack_int ldv );\nlapack_int LAPACKE_zgebak( int matrix_order, char job, char side, lapack_int n,\n                           lapack_int ilo, lapack_int ihi, const double* scale,\n                           lapack_int m, lapack_complex_double* v,\n                           lapack_int ldv );\n\nlapack_int LAPACKE_sgebal( int matrix_order, char job, lapack_int n, float* a,\n                           lapack_int lda, lapack_int* ilo, lapack_int* ihi,\n                           float* scale );\nlapack_int LAPACKE_dgebal( int matrix_order, char job, lapack_int n, double* a,\n                           lapack_int lda, lapack_int* ilo, lapack_int* ihi,\n                           double* scale );\nlapack_int LAPACKE_cgebal( int matrix_order, char job, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_int* ilo, lapack_int* ihi, float* scale );\nlapack_int LAPACKE_zgebal( int matrix_order, char job, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int* ilo, lapack_int* ihi, double* scale );\n\nlapack_int LAPACKE_sgebrd( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, float* d, float* e,\n                           float* tauq, float* taup );\nlapack_int LAPACKE_dgebrd( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, double* d, double* e,\n                           double* tauq, double* taup );\nlapack_int LAPACKE_cgebrd( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda, float* d,\n                           float* e, lapack_complex_float* tauq,\n                           lapack_complex_float* taup );\nlapack_int LAPACKE_zgebrd( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda, double* d,\n                           double* e, lapack_complex_double* tauq,\n                           lapack_complex_double* taup );\n\nlapack_int LAPACKE_sgecon( int matrix_order, char norm, lapack_int n,\n                           const float* a, lapack_int lda, float anorm,\n                           float* rcond );\nlapack_int LAPACKE_dgecon( int matrix_order, char norm, lapack_int n,\n                           const double* a, lapack_int lda, double anorm,\n                           double* rcond );\nlapack_int LAPACKE_cgecon( int matrix_order, char norm, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda,\n                           float anorm, float* rcond );\nlapack_int LAPACKE_zgecon( int matrix_order, char norm, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           double anorm, double* rcond );\n\nlapack_int LAPACKE_sgeequ( int matrix_order, lapack_int m, lapack_int n,\n                           const float* a, lapack_int lda, float* r, float* c,\n                           float* rowcnd, float* colcnd, float* amax );\nlapack_int LAPACKE_dgeequ( int matrix_order, lapack_int m, lapack_int n,\n                           const double* a, lapack_int lda, double* r,\n                           double* c, double* rowcnd, double* colcnd,\n                           double* amax );\nlapack_int LAPACKE_cgeequ( int matrix_order, lapack_int m, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda,\n                           float* r, float* c, float* rowcnd, float* colcnd,\n                           float* amax );\nlapack_int LAPACKE_zgeequ( int matrix_order, lapack_int m, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           double* r, double* c, double* rowcnd, double* colcnd,\n                           double* amax );\n\nlapack_int LAPACKE_sgeequb( int matrix_order, lapack_int m, lapack_int n,\n                            const float* a, lapack_int lda, float* r, float* c,\n                            float* rowcnd, float* colcnd, float* amax );\nlapack_int LAPACKE_dgeequb( int matrix_order, lapack_int m, lapack_int n,\n                            const double* a, lapack_int lda, double* r,\n                            double* c, double* rowcnd, double* colcnd,\n                            double* amax );\nlapack_int LAPACKE_cgeequb( int matrix_order, lapack_int m, lapack_int n,\n                            const lapack_complex_float* a, lapack_int lda,\n                            float* r, float* c, float* rowcnd, float* colcnd,\n                            float* amax );\nlapack_int LAPACKE_zgeequb( int matrix_order, lapack_int m, lapack_int n,\n                            const lapack_complex_double* a, lapack_int lda,\n                            double* r, double* c, double* rowcnd,\n                            double* colcnd, double* amax );\n\nlapack_int LAPACKE_sgees( int matrix_order, char jobvs, char sort,\n                          LAPACK_S_SELECT2 select, lapack_int n, float* a,\n                          lapack_int lda, lapack_int* sdim, float* wr,\n                          float* wi, float* vs, lapack_int ldvs );\nlapack_int LAPACKE_dgees( int matrix_order, char jobvs, char sort,\n                          LAPACK_D_SELECT2 select, lapack_int n, double* a,\n                          lapack_int lda, lapack_int* sdim, double* wr,\n                          double* wi, double* vs, lapack_int ldvs );\nlapack_int LAPACKE_cgees( int matrix_order, char jobvs, char sort,\n                          LAPACK_C_SELECT1 select, lapack_int n,\n                          lapack_complex_float* a, lapack_int lda,\n                          lapack_int* sdim, lapack_complex_float* w,\n                          lapack_complex_float* vs, lapack_int ldvs );\nlapack_int LAPACKE_zgees( int matrix_order, char jobvs, char sort,\n                          LAPACK_Z_SELECT1 select, lapack_int n,\n                          lapack_complex_double* a, lapack_int lda,\n                          lapack_int* sdim, lapack_complex_double* w,\n                          lapack_complex_double* vs, lapack_int ldvs );\n\nlapack_int LAPACKE_sgeesx( int matrix_order, char jobvs, char sort,\n                           LAPACK_S_SELECT2 select, char sense, lapack_int n,\n                           float* a, lapack_int lda, lapack_int* sdim,\n                           float* wr, float* wi, float* vs, lapack_int ldvs,\n                           float* rconde, float* rcondv );\nlapack_int LAPACKE_dgeesx( int matrix_order, char jobvs, char sort,\n                           LAPACK_D_SELECT2 select, char sense, lapack_int n,\n                           double* a, lapack_int lda, lapack_int* sdim,\n                           double* wr, double* wi, double* vs, lapack_int ldvs,\n                           double* rconde, double* rcondv );\nlapack_int LAPACKE_cgeesx( int matrix_order, char jobvs, char sort,\n                           LAPACK_C_SELECT1 select, char sense, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_int* sdim, lapack_complex_float* w,\n                           lapack_complex_float* vs, lapack_int ldvs,\n                           float* rconde, float* rcondv );\nlapack_int LAPACKE_zgeesx( int matrix_order, char jobvs, char sort,\n                           LAPACK_Z_SELECT1 select, char sense, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int* sdim, lapack_complex_double* w,\n                           lapack_complex_double* vs, lapack_int ldvs,\n                           double* rconde, double* rcondv );\n\nlapack_int LAPACKE_sgeev( int matrix_order, char jobvl, char jobvr,\n                          lapack_int n, float* a, lapack_int lda, float* wr,\n                          float* wi, float* vl, lapack_int ldvl, float* vr,\n                          lapack_int ldvr );\nlapack_int LAPACKE_dgeev( int matrix_order, char jobvl, char jobvr,\n                          lapack_int n, double* a, lapack_int lda, double* wr,\n                          double* wi, double* vl, lapack_int ldvl, double* vr,\n                          lapack_int ldvr );\nlapack_int LAPACKE_cgeev( int matrix_order, char jobvl, char jobvr,\n                          lapack_int n, lapack_complex_float* a, lapack_int lda,\n                          lapack_complex_float* w, lapack_complex_float* vl,\n                          lapack_int ldvl, lapack_complex_float* vr,\n                          lapack_int ldvr );\nlapack_int LAPACKE_zgeev( int matrix_order, char jobvl, char jobvr,\n                          lapack_int n, lapack_complex_double* a,\n                          lapack_int lda, lapack_complex_double* w,\n                          lapack_complex_double* vl, lapack_int ldvl,\n                          lapack_complex_double* vr, lapack_int ldvr );\n\nlapack_int LAPACKE_sgeevx( int matrix_order, char balanc, char jobvl,\n                           char jobvr, char sense, lapack_int n, float* a,\n                           lapack_int lda, float* wr, float* wi, float* vl,\n                           lapack_int ldvl, float* vr, lapack_int ldvr,\n                           lapack_int* ilo, lapack_int* ihi, float* scale,\n                           float* abnrm, float* rconde, float* rcondv );\nlapack_int LAPACKE_dgeevx( int matrix_order, char balanc, char jobvl,\n                           char jobvr, char sense, lapack_int n, double* a,\n                           lapack_int lda, double* wr, double* wi, double* vl,\n                           lapack_int ldvl, double* vr, lapack_int ldvr,\n                           lapack_int* ilo, lapack_int* ihi, double* scale,\n                           double* abnrm, double* rconde, double* rcondv );\nlapack_int LAPACKE_cgeevx( int matrix_order, char balanc, char jobvl,\n                           char jobvr, char sense, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* w, lapack_complex_float* vl,\n                           lapack_int ldvl, lapack_complex_float* vr,\n                           lapack_int ldvr, lapack_int* ilo, lapack_int* ihi,\n                           float* scale, float* abnrm, float* rconde,\n                           float* rcondv );\nlapack_int LAPACKE_zgeevx( int matrix_order, char balanc, char jobvl,\n                           char jobvr, char sense, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* w, lapack_complex_double* vl,\n                           lapack_int ldvl, lapack_complex_double* vr,\n                           lapack_int ldvr, lapack_int* ilo, lapack_int* ihi,\n                           double* scale, double* abnrm, double* rconde,\n                           double* rcondv );\n\nlapack_int LAPACKE_sgehrd( int matrix_order, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, float* a, lapack_int lda,\n                           float* tau );\nlapack_int LAPACKE_dgehrd( int matrix_order, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, double* a, lapack_int lda,\n                           double* tau );\nlapack_int LAPACKE_cgehrd( int matrix_order, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* tau );\nlapack_int LAPACKE_zgehrd( int matrix_order, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* tau );\n\nlapack_int LAPACKE_sgejsv( int matrix_order, char joba, char jobu, char jobv,\n                           char jobr, char jobt, char jobp, lapack_int m,\n                           lapack_int n, float* a, lapack_int lda, float* sva,\n                           float* u, lapack_int ldu, float* v, lapack_int ldv,\n                           float* stat, lapack_int* istat );\nlapack_int LAPACKE_dgejsv( int matrix_order, char joba, char jobu, char jobv,\n                           char jobr, char jobt, char jobp, lapack_int m,\n                           lapack_int n, double* a, lapack_int lda, double* sva,\n                           double* u, lapack_int ldu, double* v, lapack_int ldv,\n                           double* stat, lapack_int* istat );\n\nlapack_int LAPACKE_sgelq2( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, float* tau );\nlapack_int LAPACKE_dgelq2( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, double* tau );\nlapack_int LAPACKE_cgelq2( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* tau );\nlapack_int LAPACKE_zgelq2( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* tau );\n\nlapack_int LAPACKE_sgelqf( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, float* tau );\nlapack_int LAPACKE_dgelqf( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, double* tau );\nlapack_int LAPACKE_cgelqf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* tau );\nlapack_int LAPACKE_zgelqf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* tau );\n\nlapack_int LAPACKE_sgels( int matrix_order, char trans, lapack_int m,\n                          lapack_int n, lapack_int nrhs, float* a,\n                          lapack_int lda, float* b, lapack_int ldb );\nlapack_int LAPACKE_dgels( int matrix_order, char trans, lapack_int m,\n                          lapack_int n, lapack_int nrhs, double* a,\n                          lapack_int lda, double* b, lapack_int ldb );\nlapack_int LAPACKE_cgels( int matrix_order, char trans, lapack_int m,\n                          lapack_int n, lapack_int nrhs,\n                          lapack_complex_float* a, lapack_int lda,\n                          lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zgels( int matrix_order, char trans, lapack_int m,\n                          lapack_int n, lapack_int nrhs,\n                          lapack_complex_double* a, lapack_int lda,\n                          lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_sgelsd( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, float* a, lapack_int lda, float* b,\n                           lapack_int ldb, float* s, float rcond,\n                           lapack_int* rank );\nlapack_int LAPACKE_dgelsd( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, double* a, lapack_int lda,\n                           double* b, lapack_int ldb, double* s, double rcond,\n                           lapack_int* rank );\nlapack_int LAPACKE_cgelsd( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* b,\n                           lapack_int ldb, float* s, float rcond,\n                           lapack_int* rank );\nlapack_int LAPACKE_zgelsd( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* b,\n                           lapack_int ldb, double* s, double rcond,\n                           lapack_int* rank );\n\nlapack_int LAPACKE_sgelss( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, float* a, lapack_int lda, float* b,\n                           lapack_int ldb, float* s, float rcond,\n                           lapack_int* rank );\nlapack_int LAPACKE_dgelss( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, double* a, lapack_int lda,\n                           double* b, lapack_int ldb, double* s, double rcond,\n                           lapack_int* rank );\nlapack_int LAPACKE_cgelss( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* b,\n                           lapack_int ldb, float* s, float rcond,\n                           lapack_int* rank );\nlapack_int LAPACKE_zgelss( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* b,\n                           lapack_int ldb, double* s, double rcond,\n                           lapack_int* rank );\n\nlapack_int LAPACKE_sgelsy( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, float* a, lapack_int lda, float* b,\n                           lapack_int ldb, lapack_int* jpvt, float rcond,\n                           lapack_int* rank );\nlapack_int LAPACKE_dgelsy( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, double* a, lapack_int lda,\n                           double* b, lapack_int ldb, lapack_int* jpvt,\n                           double rcond, lapack_int* rank );\nlapack_int LAPACKE_cgelsy( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* b,\n                           lapack_int ldb, lapack_int* jpvt, float rcond,\n                           lapack_int* rank );\nlapack_int LAPACKE_zgelsy( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nrhs, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* b,\n                           lapack_int ldb, lapack_int* jpvt, double rcond,\n                           lapack_int* rank );\n\nlapack_int LAPACKE_sgeqlf( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, float* tau );\nlapack_int LAPACKE_dgeqlf( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, double* tau );\nlapack_int LAPACKE_cgeqlf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* tau );\nlapack_int LAPACKE_zgeqlf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* tau );\n\nlapack_int LAPACKE_sgeqp3( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, lapack_int* jpvt,\n                           float* tau );\nlapack_int LAPACKE_dgeqp3( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, lapack_int* jpvt,\n                           double* tau );\nlapack_int LAPACKE_cgeqp3( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_int* jpvt, lapack_complex_float* tau );\nlapack_int LAPACKE_zgeqp3( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int* jpvt, lapack_complex_double* tau );\n\nlapack_int LAPACKE_sgeqpf( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, lapack_int* jpvt,\n                           float* tau );\nlapack_int LAPACKE_dgeqpf( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, lapack_int* jpvt,\n                           double* tau );\nlapack_int LAPACKE_cgeqpf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_int* jpvt, lapack_complex_float* tau );\nlapack_int LAPACKE_zgeqpf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int* jpvt, lapack_complex_double* tau );\n\nlapack_int LAPACKE_sgeqr2( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, float* tau );\nlapack_int LAPACKE_dgeqr2( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, double* tau );\nlapack_int LAPACKE_cgeqr2( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* tau );\nlapack_int LAPACKE_zgeqr2( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* tau );\n\nlapack_int LAPACKE_sgeqrf( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, float* tau );\nlapack_int LAPACKE_dgeqrf( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, double* tau );\nlapack_int LAPACKE_cgeqrf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* tau );\nlapack_int LAPACKE_zgeqrf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* tau );\n\nlapack_int LAPACKE_sgeqrfp( int matrix_order, lapack_int m, lapack_int n,\n                            float* a, lapack_int lda, float* tau );\nlapack_int LAPACKE_dgeqrfp( int matrix_order, lapack_int m, lapack_int n,\n                            double* a, lapack_int lda, double* tau );\nlapack_int LAPACKE_cgeqrfp( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_complex_float* a, lapack_int lda,\n                            lapack_complex_float* tau );\nlapack_int LAPACKE_zgeqrfp( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_complex_double* a, lapack_int lda,\n                            lapack_complex_double* tau );\n\nlapack_int LAPACKE_sgerfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const float* a, lapack_int lda,\n                           const float* af, lapack_int ldaf,\n                           const lapack_int* ipiv, const float* b,\n                           lapack_int ldb, float* x, lapack_int ldx,\n                           float* ferr, float* berr );\nlapack_int LAPACKE_dgerfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const double* a, lapack_int lda,\n                           const double* af, lapack_int ldaf,\n                           const lapack_int* ipiv, const double* b,\n                           lapack_int ldb, double* x, lapack_int ldx,\n                           double* ferr, double* berr );\nlapack_int LAPACKE_cgerfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* af,\n                           lapack_int ldaf, const lapack_int* ipiv,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zgerfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* af,\n                           lapack_int ldaf, const lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_sgerfsx( int matrix_order, char trans, char equed,\n                            lapack_int n, lapack_int nrhs, const float* a,\n                            lapack_int lda, const float* af, lapack_int ldaf,\n                            const lapack_int* ipiv, const float* r,\n                            const float* c, const float* b, lapack_int ldb,\n                            float* x, lapack_int ldx, float* rcond, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_dgerfsx( int matrix_order, char trans, char equed,\n                            lapack_int n, lapack_int nrhs, const double* a,\n                            lapack_int lda, const double* af, lapack_int ldaf,\n                            const lapack_int* ipiv, const double* r,\n                            const double* c, const double* b, lapack_int ldb,\n                            double* x, lapack_int ldx, double* rcond,\n                            double* berr, lapack_int n_err_bnds,\n                            double* err_bnds_norm, double* err_bnds_comp,\n                            lapack_int nparams, double* params );\nlapack_int LAPACKE_cgerfsx( int matrix_order, char trans, char equed,\n                            lapack_int n, lapack_int nrhs,\n                            const lapack_complex_float* a, lapack_int lda,\n                            const lapack_complex_float* af, lapack_int ldaf,\n                            const lapack_int* ipiv, const float* r,\n                            const float* c, const lapack_complex_float* b,\n                            lapack_int ldb, lapack_complex_float* x,\n                            lapack_int ldx, float* rcond, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_zgerfsx( int matrix_order, char trans, char equed,\n                            lapack_int n, lapack_int nrhs,\n                            const lapack_complex_double* a, lapack_int lda,\n                            const lapack_complex_double* af, lapack_int ldaf,\n                            const lapack_int* ipiv, const double* r,\n                            const double* c, const lapack_complex_double* b,\n                            lapack_int ldb, lapack_complex_double* x,\n                            lapack_int ldx, double* rcond, double* berr,\n                            lapack_int n_err_bnds, double* err_bnds_norm,\n                            double* err_bnds_comp, lapack_int nparams,\n                            double* params );\n\nlapack_int LAPACKE_sgerqf( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, float* tau );\nlapack_int LAPACKE_dgerqf( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, double* tau );\nlapack_int LAPACKE_cgerqf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* tau );\nlapack_int LAPACKE_zgerqf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* tau );\n\nlapack_int LAPACKE_sgesdd( int matrix_order, char jobz, lapack_int m,\n                           lapack_int n, float* a, lapack_int lda, float* s,\n                           float* u, lapack_int ldu, float* vt,\n                           lapack_int ldvt );\nlapack_int LAPACKE_dgesdd( int matrix_order, char jobz, lapack_int m,\n                           lapack_int n, double* a, lapack_int lda, double* s,\n                           double* u, lapack_int ldu, double* vt,\n                           lapack_int ldvt );\nlapack_int LAPACKE_cgesdd( int matrix_order, char jobz, lapack_int m,\n                           lapack_int n, lapack_complex_float* a,\n                           lapack_int lda, float* s, lapack_complex_float* u,\n                           lapack_int ldu, lapack_complex_float* vt,\n                           lapack_int ldvt );\nlapack_int LAPACKE_zgesdd( int matrix_order, char jobz, lapack_int m,\n                           lapack_int n, lapack_complex_double* a,\n                           lapack_int lda, double* s, lapack_complex_double* u,\n                           lapack_int ldu, lapack_complex_double* vt,\n                           lapack_int ldvt );\n\nlapack_int LAPACKE_sgesv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          float* a, lapack_int lda, lapack_int* ipiv, float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_dgesv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          double* a, lapack_int lda, lapack_int* ipiv,\n                          double* b, lapack_int ldb );\nlapack_int LAPACKE_cgesv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          lapack_complex_float* a, lapack_int lda,\n                          lapack_int* ipiv, lapack_complex_float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_zgesv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          lapack_complex_double* a, lapack_int lda,\n                          lapack_int* ipiv, lapack_complex_double* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_dsgesv( int matrix_order, lapack_int n, lapack_int nrhs,\n                           double* a, lapack_int lda, lapack_int* ipiv,\n                           double* b, lapack_int ldb, double* x, lapack_int ldx,\n                           lapack_int* iter );\nlapack_int LAPACKE_zcgesv( int matrix_order, lapack_int n, lapack_int nrhs,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int* ipiv, lapack_complex_double* b,\n                           lapack_int ldb, lapack_complex_double* x,\n                           lapack_int ldx, lapack_int* iter );\n\nlapack_int LAPACKE_sgesvd( int matrix_order, char jobu, char jobvt,\n                           lapack_int m, lapack_int n, float* a, lapack_int lda,\n                           float* s, float* u, lapack_int ldu, float* vt,\n                           lapack_int ldvt, float* superb );\nlapack_int LAPACKE_dgesvd( int matrix_order, char jobu, char jobvt,\n                           lapack_int m, lapack_int n, double* a,\n                           lapack_int lda, double* s, double* u, lapack_int ldu,\n                           double* vt, lapack_int ldvt, double* superb );\nlapack_int LAPACKE_cgesvd( int matrix_order, char jobu, char jobvt,\n                           lapack_int m, lapack_int n, lapack_complex_float* a,\n                           lapack_int lda, float* s, lapack_complex_float* u,\n                           lapack_int ldu, lapack_complex_float* vt,\n                           lapack_int ldvt, float* superb );\nlapack_int LAPACKE_zgesvd( int matrix_order, char jobu, char jobvt,\n                           lapack_int m, lapack_int n, lapack_complex_double* a,\n                           lapack_int lda, double* s, lapack_complex_double* u,\n                           lapack_int ldu, lapack_complex_double* vt,\n                           lapack_int ldvt, double* superb );\n\nlapack_int LAPACKE_sgesvj( int matrix_order, char joba, char jobu, char jobv,\n                           lapack_int m, lapack_int n, float* a, lapack_int lda,\n                           float* sva, lapack_int mv, float* v, lapack_int ldv,\n                           float* stat );\nlapack_int LAPACKE_dgesvj( int matrix_order, char joba, char jobu, char jobv,\n                           lapack_int m, lapack_int n, double* a,\n                           lapack_int lda, double* sva, lapack_int mv,\n                           double* v, lapack_int ldv, double* stat );\n\nlapack_int LAPACKE_sgesvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int nrhs, float* a,\n                           lapack_int lda, float* af, lapack_int ldaf,\n                           lapack_int* ipiv, char* equed, float* r, float* c,\n                           float* b, lapack_int ldb, float* x, lapack_int ldx,\n                           float* rcond, float* ferr, float* berr,\n                           float* rpivot );\nlapack_int LAPACKE_dgesvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int nrhs, double* a,\n                           lapack_int lda, double* af, lapack_int ldaf,\n                           lapack_int* ipiv, char* equed, double* r, double* c,\n                           double* b, lapack_int ldb, double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr,\n                           double* rpivot );\nlapack_int LAPACKE_cgesvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int nrhs,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* af, lapack_int ldaf,\n                           lapack_int* ipiv, char* equed, float* r, float* c,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx,\n                           float* rcond, float* ferr, float* berr,\n                           float* rpivot );\nlapack_int LAPACKE_zgesvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int nrhs,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* af, lapack_int ldaf,\n                           lapack_int* ipiv, char* equed, double* r, double* c,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr,\n                           double* rpivot );\n\nlapack_int LAPACKE_sgesvxx( int matrix_order, char fact, char trans,\n                            lapack_int n, lapack_int nrhs, float* a,\n                            lapack_int lda, float* af, lapack_int ldaf,\n                            lapack_int* ipiv, char* equed, float* r, float* c,\n                            float* b, lapack_int ldb, float* x, lapack_int ldx,\n                            float* rcond, float* rpvgrw, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_dgesvxx( int matrix_order, char fact, char trans,\n                            lapack_int n, lapack_int nrhs, double* a,\n                            lapack_int lda, double* af, lapack_int ldaf,\n                            lapack_int* ipiv, char* equed, double* r, double* c,\n                            double* b, lapack_int ldb, double* x,\n                            lapack_int ldx, double* rcond, double* rpvgrw,\n                            double* berr, lapack_int n_err_bnds,\n                            double* err_bnds_norm, double* err_bnds_comp,\n                            lapack_int nparams, double* params );\nlapack_int LAPACKE_cgesvxx( int matrix_order, char fact, char trans,\n                            lapack_int n, lapack_int nrhs,\n                            lapack_complex_float* a, lapack_int lda,\n                            lapack_complex_float* af, lapack_int ldaf,\n                            lapack_int* ipiv, char* equed, float* r, float* c,\n                            lapack_complex_float* b, lapack_int ldb,\n                            lapack_complex_float* x, lapack_int ldx,\n                            float* rcond, float* rpvgrw, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_zgesvxx( int matrix_order, char fact, char trans,\n                            lapack_int n, lapack_int nrhs,\n                            lapack_complex_double* a, lapack_int lda,\n                            lapack_complex_double* af, lapack_int ldaf,\n                            lapack_int* ipiv, char* equed, double* r, double* c,\n                            lapack_complex_double* b, lapack_int ldb,\n                            lapack_complex_double* x, lapack_int ldx,\n                            double* rcond, double* rpvgrw, double* berr,\n                            lapack_int n_err_bnds, double* err_bnds_norm,\n                            double* err_bnds_comp, lapack_int nparams,\n                            double* params );\n\nlapack_int LAPACKE_sgetf2( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, lapack_int* ipiv );\nlapack_int LAPACKE_dgetf2( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, lapack_int* ipiv );\nlapack_int LAPACKE_cgetf2( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_int* ipiv );\nlapack_int LAPACKE_zgetf2( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int* ipiv );\n\nlapack_int LAPACKE_sgetrf( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, lapack_int* ipiv );\nlapack_int LAPACKE_dgetrf( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, lapack_int* ipiv );\nlapack_int LAPACKE_cgetrf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_int* ipiv );\nlapack_int LAPACKE_zgetrf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int* ipiv );\n\nlapack_int LAPACKE_sgetri( int matrix_order, lapack_int n, float* a,\n                           lapack_int lda, const lapack_int* ipiv );\nlapack_int LAPACKE_dgetri( int matrix_order, lapack_int n, double* a,\n                           lapack_int lda, const lapack_int* ipiv );\nlapack_int LAPACKE_cgetri( int matrix_order, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           const lapack_int* ipiv );\nlapack_int LAPACKE_zgetri( int matrix_order, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           const lapack_int* ipiv );\n\nlapack_int LAPACKE_sgetrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const float* a, lapack_int lda,\n                           const lapack_int* ipiv, float* b, lapack_int ldb );\nlapack_int LAPACKE_dgetrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const double* a, lapack_int lda,\n                           const lapack_int* ipiv, double* b, lapack_int ldb );\nlapack_int LAPACKE_cgetrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* a,\n                           lapack_int lda, const lapack_int* ipiv,\n                           lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zgetrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* a,\n                           lapack_int lda, const lapack_int* ipiv,\n                           lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_sggbak( int matrix_order, char job, char side, lapack_int n,\n                           lapack_int ilo, lapack_int ihi, const float* lscale,\n                           const float* rscale, lapack_int m, float* v,\n                           lapack_int ldv );\nlapack_int LAPACKE_dggbak( int matrix_order, char job, char side, lapack_int n,\n                           lapack_int ilo, lapack_int ihi, const double* lscale,\n                           const double* rscale, lapack_int m, double* v,\n                           lapack_int ldv );\nlapack_int LAPACKE_cggbak( int matrix_order, char job, char side, lapack_int n,\n                           lapack_int ilo, lapack_int ihi, const float* lscale,\n                           const float* rscale, lapack_int m,\n                           lapack_complex_float* v, lapack_int ldv );\nlapack_int LAPACKE_zggbak( int matrix_order, char job, char side, lapack_int n,\n                           lapack_int ilo, lapack_int ihi, const double* lscale,\n                           const double* rscale, lapack_int m,\n                           lapack_complex_double* v, lapack_int ldv );\n\nlapack_int LAPACKE_sggbal( int matrix_order, char job, lapack_int n, float* a,\n                           lapack_int lda, float* b, lapack_int ldb,\n                           lapack_int* ilo, lapack_int* ihi, float* lscale,\n                           float* rscale );\nlapack_int LAPACKE_dggbal( int matrix_order, char job, lapack_int n, double* a,\n                           lapack_int lda, double* b, lapack_int ldb,\n                           lapack_int* ilo, lapack_int* ihi, double* lscale,\n                           double* rscale );\nlapack_int LAPACKE_cggbal( int matrix_order, char job, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_int* ilo, lapack_int* ihi, float* lscale,\n                           float* rscale );\nlapack_int LAPACKE_zggbal( int matrix_order, char job, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_int* ilo, lapack_int* ihi, double* lscale,\n                           double* rscale );\n\nlapack_int LAPACKE_sgges( int matrix_order, char jobvsl, char jobvsr, char sort,\n                          LAPACK_S_SELECT3 selctg, lapack_int n, float* a,\n                          lapack_int lda, float* b, lapack_int ldb,\n                          lapack_int* sdim, float* alphar, float* alphai,\n                          float* beta, float* vsl, lapack_int ldvsl, float* vsr,\n                          lapack_int ldvsr );\nlapack_int LAPACKE_dgges( int matrix_order, char jobvsl, char jobvsr, char sort,\n                          LAPACK_D_SELECT3 selctg, lapack_int n, double* a,\n                          lapack_int lda, double* b, lapack_int ldb,\n                          lapack_int* sdim, double* alphar, double* alphai,\n                          double* beta, double* vsl, lapack_int ldvsl,\n                          double* vsr, lapack_int ldvsr );\nlapack_int LAPACKE_cgges( int matrix_order, char jobvsl, char jobvsr, char sort,\n                          LAPACK_C_SELECT2 selctg, lapack_int n,\n                          lapack_complex_float* a, lapack_int lda,\n                          lapack_complex_float* b, lapack_int ldb,\n                          lapack_int* sdim, lapack_complex_float* alpha,\n                          lapack_complex_float* beta, lapack_complex_float* vsl,\n                          lapack_int ldvsl, lapack_complex_float* vsr,\n                          lapack_int ldvsr );\nlapack_int LAPACKE_zgges( int matrix_order, char jobvsl, char jobvsr, char sort,\n                          LAPACK_Z_SELECT2 selctg, lapack_int n,\n                          lapack_complex_double* a, lapack_int lda,\n                          lapack_complex_double* b, lapack_int ldb,\n                          lapack_int* sdim, lapack_complex_double* alpha,\n                          lapack_complex_double* beta,\n                          lapack_complex_double* vsl, lapack_int ldvsl,\n                          lapack_complex_double* vsr, lapack_int ldvsr );\n\nlapack_int LAPACKE_sggesx( int matrix_order, char jobvsl, char jobvsr,\n                           char sort, LAPACK_S_SELECT3 selctg, char sense,\n                           lapack_int n, float* a, lapack_int lda, float* b,\n                           lapack_int ldb, lapack_int* sdim, float* alphar,\n                           float* alphai, float* beta, float* vsl,\n                           lapack_int ldvsl, float* vsr, lapack_int ldvsr,\n                           float* rconde, float* rcondv );\nlapack_int LAPACKE_dggesx( int matrix_order, char jobvsl, char jobvsr,\n                           char sort, LAPACK_D_SELECT3 selctg, char sense,\n                           lapack_int n, double* a, lapack_int lda, double* b,\n                           lapack_int ldb, lapack_int* sdim, double* alphar,\n                           double* alphai, double* beta, double* vsl,\n                           lapack_int ldvsl, double* vsr, lapack_int ldvsr,\n                           double* rconde, double* rcondv );\nlapack_int LAPACKE_cggesx( int matrix_order, char jobvsl, char jobvsr,\n                           char sort, LAPACK_C_SELECT2 selctg, char sense,\n                           lapack_int n, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* b,\n                           lapack_int ldb, lapack_int* sdim,\n                           lapack_complex_float* alpha,\n                           lapack_complex_float* beta,\n                           lapack_complex_float* vsl, lapack_int ldvsl,\n                           lapack_complex_float* vsr, lapack_int ldvsr,\n                           float* rconde, float* rcondv );\nlapack_int LAPACKE_zggesx( int matrix_order, char jobvsl, char jobvsr,\n                           char sort, LAPACK_Z_SELECT2 selctg, char sense,\n                           lapack_int n, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* b,\n                           lapack_int ldb, lapack_int* sdim,\n                           lapack_complex_double* alpha,\n                           lapack_complex_double* beta,\n                           lapack_complex_double* vsl, lapack_int ldvsl,\n                           lapack_complex_double* vsr, lapack_int ldvsr,\n                           double* rconde, double* rcondv );\n\nlapack_int LAPACKE_sggev( int matrix_order, char jobvl, char jobvr,\n                          lapack_int n, float* a, lapack_int lda, float* b,\n                          lapack_int ldb, float* alphar, float* alphai,\n                          float* beta, float* vl, lapack_int ldvl, float* vr,\n                          lapack_int ldvr );\nlapack_int LAPACKE_dggev( int matrix_order, char jobvl, char jobvr,\n                          lapack_int n, double* a, lapack_int lda, double* b,\n                          lapack_int ldb, double* alphar, double* alphai,\n                          double* beta, double* vl, lapack_int ldvl, double* vr,\n                          lapack_int ldvr );\nlapack_int LAPACKE_cggev( int matrix_order, char jobvl, char jobvr,\n                          lapack_int n, lapack_complex_float* a, lapack_int lda,\n                          lapack_complex_float* b, lapack_int ldb,\n                          lapack_complex_float* alpha,\n                          lapack_complex_float* beta, lapack_complex_float* vl,\n                          lapack_int ldvl, lapack_complex_float* vr,\n                          lapack_int ldvr );\nlapack_int LAPACKE_zggev( int matrix_order, char jobvl, char jobvr,\n                          lapack_int n, lapack_complex_double* a,\n                          lapack_int lda, lapack_complex_double* b,\n                          lapack_int ldb, lapack_complex_double* alpha,\n                          lapack_complex_double* beta,\n                          lapack_complex_double* vl, lapack_int ldvl,\n                          lapack_complex_double* vr, lapack_int ldvr );\n\nlapack_int LAPACKE_sggevx( int matrix_order, char balanc, char jobvl,\n                           char jobvr, char sense, lapack_int n, float* a,\n                           lapack_int lda, float* b, lapack_int ldb,\n                           float* alphar, float* alphai, float* beta, float* vl,\n                           lapack_int ldvl, float* vr, lapack_int ldvr,\n                           lapack_int* ilo, lapack_int* ihi, float* lscale,\n                           float* rscale, float* abnrm, float* bbnrm,\n                           float* rconde, float* rcondv );\nlapack_int LAPACKE_dggevx( int matrix_order, char balanc, char jobvl,\n                           char jobvr, char sense, lapack_int n, double* a,\n                           lapack_int lda, double* b, lapack_int ldb,\n                           double* alphar, double* alphai, double* beta,\n                           double* vl, lapack_int ldvl, double* vr,\n                           lapack_int ldvr, lapack_int* ilo, lapack_int* ihi,\n                           double* lscale, double* rscale, double* abnrm,\n                           double* bbnrm, double* rconde, double* rcondv );\nlapack_int LAPACKE_cggevx( int matrix_order, char balanc, char jobvl,\n                           char jobvr, char sense, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* alpha,\n                           lapack_complex_float* beta, lapack_complex_float* vl,\n                           lapack_int ldvl, lapack_complex_float* vr,\n                           lapack_int ldvr, lapack_int* ilo, lapack_int* ihi,\n                           float* lscale, float* rscale, float* abnrm,\n                           float* bbnrm, float* rconde, float* rcondv );\nlapack_int LAPACKE_zggevx( int matrix_order, char balanc, char jobvl,\n                           char jobvr, char sense, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* alpha,\n                           lapack_complex_double* beta,\n                           lapack_complex_double* vl, lapack_int ldvl,\n                           lapack_complex_double* vr, lapack_int ldvr,\n                           lapack_int* ilo, lapack_int* ihi, double* lscale,\n                           double* rscale, double* abnrm, double* bbnrm,\n                           double* rconde, double* rcondv );\n\nlapack_int LAPACKE_sggglm( int matrix_order, lapack_int n, lapack_int m,\n                           lapack_int p, float* a, lapack_int lda, float* b,\n                           lapack_int ldb, float* d, float* x, float* y );\nlapack_int LAPACKE_dggglm( int matrix_order, lapack_int n, lapack_int m,\n                           lapack_int p, double* a, lapack_int lda, double* b,\n                           lapack_int ldb, double* d, double* x, double* y );\nlapack_int LAPACKE_cggglm( int matrix_order, lapack_int n, lapack_int m,\n                           lapack_int p, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* b,\n                           lapack_int ldb, lapack_complex_float* d,\n                           lapack_complex_float* x, lapack_complex_float* y );\nlapack_int LAPACKE_zggglm( int matrix_order, lapack_int n, lapack_int m,\n                           lapack_int p, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* b,\n                           lapack_int ldb, lapack_complex_double* d,\n                           lapack_complex_double* x, lapack_complex_double* y );\n\nlapack_int LAPACKE_sgghrd( int matrix_order, char compq, char compz,\n                           lapack_int n, lapack_int ilo, lapack_int ihi,\n                           float* a, lapack_int lda, float* b, lapack_int ldb,\n                           float* q, lapack_int ldq, float* z, lapack_int ldz );\nlapack_int LAPACKE_dgghrd( int matrix_order, char compq, char compz,\n                           lapack_int n, lapack_int ilo, lapack_int ihi,\n                           double* a, lapack_int lda, double* b, lapack_int ldb,\n                           double* q, lapack_int ldq, double* z,\n                           lapack_int ldz );\nlapack_int LAPACKE_cgghrd( int matrix_order, char compq, char compz,\n                           lapack_int n, lapack_int ilo, lapack_int ihi,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* q, lapack_int ldq,\n                           lapack_complex_float* z, lapack_int ldz );\nlapack_int LAPACKE_zgghrd( int matrix_order, char compq, char compz,\n                           lapack_int n, lapack_int ilo, lapack_int ihi,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* q, lapack_int ldq,\n                           lapack_complex_double* z, lapack_int ldz );\n\nlapack_int LAPACKE_sgglse( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int p, float* a, lapack_int lda, float* b,\n                           lapack_int ldb, float* c, float* d, float* x );\nlapack_int LAPACKE_dgglse( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int p, double* a, lapack_int lda, double* b,\n                           lapack_int ldb, double* c, double* d, double* x );\nlapack_int LAPACKE_cgglse( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int p, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* b,\n                           lapack_int ldb, lapack_complex_float* c,\n                           lapack_complex_float* d, lapack_complex_float* x );\nlapack_int LAPACKE_zgglse( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int p, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* b,\n                           lapack_int ldb, lapack_complex_double* c,\n                           lapack_complex_double* d, lapack_complex_double* x );\n\nlapack_int LAPACKE_sggqrf( int matrix_order, lapack_int n, lapack_int m,\n                           lapack_int p, float* a, lapack_int lda, float* taua,\n                           float* b, lapack_int ldb, float* taub );\nlapack_int LAPACKE_dggqrf( int matrix_order, lapack_int n, lapack_int m,\n                           lapack_int p, double* a, lapack_int lda,\n                           double* taua, double* b, lapack_int ldb,\n                           double* taub );\nlapack_int LAPACKE_cggqrf( int matrix_order, lapack_int n, lapack_int m,\n                           lapack_int p, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* taua,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* taub );\nlapack_int LAPACKE_zggqrf( int matrix_order, lapack_int n, lapack_int m,\n                           lapack_int p, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* taua,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* taub );\n\nlapack_int LAPACKE_sggrqf( int matrix_order, lapack_int m, lapack_int p,\n                           lapack_int n, float* a, lapack_int lda, float* taua,\n                           float* b, lapack_int ldb, float* taub );\nlapack_int LAPACKE_dggrqf( int matrix_order, lapack_int m, lapack_int p,\n                           lapack_int n, double* a, lapack_int lda,\n                           double* taua, double* b, lapack_int ldb,\n                           double* taub );\nlapack_int LAPACKE_cggrqf( int matrix_order, lapack_int m, lapack_int p,\n                           lapack_int n, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* taua,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* taub );\nlapack_int LAPACKE_zggrqf( int matrix_order, lapack_int m, lapack_int p,\n                           lapack_int n, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* taua,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* taub );\n\nlapack_int LAPACKE_sggsvd( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int n, lapack_int p,\n                           lapack_int* k, lapack_int* l, float* a,\n                           lapack_int lda, float* b, lapack_int ldb,\n                           float* alpha, float* beta, float* u, lapack_int ldu,\n                           float* v, lapack_int ldv, float* q, lapack_int ldq,\n                           lapack_int* iwork );\nlapack_int LAPACKE_dggsvd( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int n, lapack_int p,\n                           lapack_int* k, lapack_int* l, double* a,\n                           lapack_int lda, double* b, lapack_int ldb,\n                           double* alpha, double* beta, double* u,\n                           lapack_int ldu, double* v, lapack_int ldv, double* q,\n                           lapack_int ldq, lapack_int* iwork );\nlapack_int LAPACKE_cggsvd( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int n, lapack_int p,\n                           lapack_int* k, lapack_int* l,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* b, lapack_int ldb,\n                           float* alpha, float* beta, lapack_complex_float* u,\n                           lapack_int ldu, lapack_complex_float* v,\n                           lapack_int ldv, lapack_complex_float* q,\n                           lapack_int ldq, lapack_int* iwork );\nlapack_int LAPACKE_zggsvd( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int n, lapack_int p,\n                           lapack_int* k, lapack_int* l,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* b, lapack_int ldb,\n                           double* alpha, double* beta,\n                           lapack_complex_double* u, lapack_int ldu,\n                           lapack_complex_double* v, lapack_int ldv,\n                           lapack_complex_double* q, lapack_int ldq,\n                           lapack_int* iwork );\n\nlapack_int LAPACKE_sggsvp( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int p, lapack_int n, float* a,\n                           lapack_int lda, float* b, lapack_int ldb, float tola,\n                           float tolb, lapack_int* k, lapack_int* l, float* u,\n                           lapack_int ldu, float* v, lapack_int ldv, float* q,\n                           lapack_int ldq );\nlapack_int LAPACKE_dggsvp( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int p, lapack_int n, double* a,\n                           lapack_int lda, double* b, lapack_int ldb,\n                           double tola, double tolb, lapack_int* k,\n                           lapack_int* l, double* u, lapack_int ldu, double* v,\n                           lapack_int ldv, double* q, lapack_int ldq );\nlapack_int LAPACKE_cggsvp( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int p, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* b, lapack_int ldb, float tola,\n                           float tolb, lapack_int* k, lapack_int* l,\n                           lapack_complex_float* u, lapack_int ldu,\n                           lapack_complex_float* v, lapack_int ldv,\n                           lapack_complex_float* q, lapack_int ldq );\nlapack_int LAPACKE_zggsvp( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int p, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* b, lapack_int ldb,\n                           double tola, double tolb, lapack_int* k,\n                           lapack_int* l, lapack_complex_double* u,\n                           lapack_int ldu, lapack_complex_double* v,\n                           lapack_int ldv, lapack_complex_double* q,\n                           lapack_int ldq );\n\nlapack_int LAPACKE_sgtcon( char norm, lapack_int n, const float* dl,\n                           const float* d, const float* du, const float* du2,\n                           const lapack_int* ipiv, float anorm, float* rcond );\nlapack_int LAPACKE_dgtcon( char norm, lapack_int n, const double* dl,\n                           const double* d, const double* du, const double* du2,\n                           const lapack_int* ipiv, double anorm,\n                           double* rcond );\nlapack_int LAPACKE_cgtcon( char norm, lapack_int n,\n                           const lapack_complex_float* dl,\n                           const lapack_complex_float* d,\n                           const lapack_complex_float* du,\n                           const lapack_complex_float* du2,\n                           const lapack_int* ipiv, float anorm, float* rcond );\nlapack_int LAPACKE_zgtcon( char norm, lapack_int n,\n                           const lapack_complex_double* dl,\n                           const lapack_complex_double* d,\n                           const lapack_complex_double* du,\n                           const lapack_complex_double* du2,\n                           const lapack_int* ipiv, double anorm,\n                           double* rcond );\n\nlapack_int LAPACKE_sgtrfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const float* dl, const float* d,\n                           const float* du, const float* dlf, const float* df,\n                           const float* duf, const float* du2,\n                           const lapack_int* ipiv, const float* b,\n                           lapack_int ldb, float* x, lapack_int ldx,\n                           float* ferr, float* berr );\nlapack_int LAPACKE_dgtrfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const double* dl, const double* d,\n                           const double* du, const double* dlf,\n                           const double* df, const double* duf,\n                           const double* du2, const lapack_int* ipiv,\n                           const double* b, lapack_int ldb, double* x,\n                           lapack_int ldx, double* ferr, double* berr );\nlapack_int LAPACKE_cgtrfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* dl,\n                           const lapack_complex_float* d,\n                           const lapack_complex_float* du,\n                           const lapack_complex_float* dlf,\n                           const lapack_complex_float* df,\n                           const lapack_complex_float* duf,\n                           const lapack_complex_float* du2,\n                           const lapack_int* ipiv,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zgtrfs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* dl,\n                           const lapack_complex_double* d,\n                           const lapack_complex_double* du,\n                           const lapack_complex_double* dlf,\n                           const lapack_complex_double* df,\n                           const lapack_complex_double* duf,\n                           const lapack_complex_double* du2,\n                           const lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_sgtsv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          float* dl, float* d, float* du, float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_dgtsv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          double* dl, double* d, double* du, double* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_cgtsv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          lapack_complex_float* dl, lapack_complex_float* d,\n                          lapack_complex_float* du, lapack_complex_float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_zgtsv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          lapack_complex_double* dl, lapack_complex_double* d,\n                          lapack_complex_double* du, lapack_complex_double* b,\n                          lapack_int ldb );\n\nlapack_int LAPACKE_sgtsvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int nrhs, const float* dl,\n                           const float* d, const float* du, float* dlf,\n                           float* df, float* duf, float* du2, lapack_int* ipiv,\n                           const float* b, lapack_int ldb, float* x,\n                           lapack_int ldx, float* rcond, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_dgtsvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int nrhs, const double* dl,\n                           const double* d, const double* du, double* dlf,\n                           double* df, double* duf, double* du2,\n                           lapack_int* ipiv, const double* b, lapack_int ldb,\n                           double* x, lapack_int ldx, double* rcond,\n                           double* ferr, double* berr );\nlapack_int LAPACKE_cgtsvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_float* dl,\n                           const lapack_complex_float* d,\n                           const lapack_complex_float* du,\n                           lapack_complex_float* dlf, lapack_complex_float* df,\n                           lapack_complex_float* duf, lapack_complex_float* du2,\n                           lapack_int* ipiv, const lapack_complex_float* b,\n                           lapack_int ldb, lapack_complex_float* x,\n                           lapack_int ldx, float* rcond, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zgtsvx( int matrix_order, char fact, char trans,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_double* dl,\n                           const lapack_complex_double* d,\n                           const lapack_complex_double* du,\n                           lapack_complex_double* dlf,\n                           lapack_complex_double* df,\n                           lapack_complex_double* duf,\n                           lapack_complex_double* du2, lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr );\n\nlapack_int LAPACKE_sgttrf( lapack_int n, float* dl, float* d, float* du,\n                           float* du2, lapack_int* ipiv );\nlapack_int LAPACKE_dgttrf( lapack_int n, double* dl, double* d, double* du,\n                           double* du2, lapack_int* ipiv );\nlapack_int LAPACKE_cgttrf( lapack_int n, lapack_complex_float* dl,\n                           lapack_complex_float* d, lapack_complex_float* du,\n                           lapack_complex_float* du2, lapack_int* ipiv );\nlapack_int LAPACKE_zgttrf( lapack_int n, lapack_complex_double* dl,\n                           lapack_complex_double* d, lapack_complex_double* du,\n                           lapack_complex_double* du2, lapack_int* ipiv );\n\nlapack_int LAPACKE_sgttrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const float* dl, const float* d,\n                           const float* du, const float* du2,\n                           const lapack_int* ipiv, float* b, lapack_int ldb );\nlapack_int LAPACKE_dgttrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const double* dl, const double* d,\n                           const double* du, const double* du2,\n                           const lapack_int* ipiv, double* b, lapack_int ldb );\nlapack_int LAPACKE_cgttrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* dl,\n                           const lapack_complex_float* d,\n                           const lapack_complex_float* du,\n                           const lapack_complex_float* du2,\n                           const lapack_int* ipiv, lapack_complex_float* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_zgttrs( int matrix_order, char trans, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* dl,\n                           const lapack_complex_double* d,\n                           const lapack_complex_double* du,\n                           const lapack_complex_double* du2,\n                           const lapack_int* ipiv, lapack_complex_double* b,\n                           lapack_int ldb );\n\nlapack_int LAPACKE_chbev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_int kd, lapack_complex_float* ab,\n                          lapack_int ldab, float* w, lapack_complex_float* z,\n                          lapack_int ldz );\nlapack_int LAPACKE_zhbev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_int kd, lapack_complex_double* ab,\n                          lapack_int ldab, double* w, lapack_complex_double* z,\n                          lapack_int ldz );\n\nlapack_int LAPACKE_chbevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_int kd, lapack_complex_float* ab,\n                           lapack_int ldab, float* w, lapack_complex_float* z,\n                           lapack_int ldz );\nlapack_int LAPACKE_zhbevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_int kd, lapack_complex_double* ab,\n                           lapack_int ldab, double* w, lapack_complex_double* z,\n                           lapack_int ldz );\n\nlapack_int LAPACKE_chbevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_int kd,\n                           lapack_complex_float* ab, lapack_int ldab,\n                           lapack_complex_float* q, lapack_int ldq, float vl,\n                           float vu, lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, lapack_complex_float* z,\n                           lapack_int ldz, lapack_int* ifail );\nlapack_int LAPACKE_zhbevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_int kd,\n                           lapack_complex_double* ab, lapack_int ldab,\n                           lapack_complex_double* q, lapack_int ldq, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w,\n                           lapack_complex_double* z, lapack_int ldz,\n                           lapack_int* ifail );\n\nlapack_int LAPACKE_chbgst( int matrix_order, char vect, char uplo, lapack_int n,\n                           lapack_int ka, lapack_int kb,\n                           lapack_complex_float* ab, lapack_int ldab,\n                           const lapack_complex_float* bb, lapack_int ldbb,\n                           lapack_complex_float* x, lapack_int ldx );\nlapack_int LAPACKE_zhbgst( int matrix_order, char vect, char uplo, lapack_int n,\n                           lapack_int ka, lapack_int kb,\n                           lapack_complex_double* ab, lapack_int ldab,\n                           const lapack_complex_double* bb, lapack_int ldbb,\n                           lapack_complex_double* x, lapack_int ldx );\n\nlapack_int LAPACKE_chbgv( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_int ka, lapack_int kb,\n                          lapack_complex_float* ab, lapack_int ldab,\n                          lapack_complex_float* bb, lapack_int ldbb, float* w,\n                          lapack_complex_float* z, lapack_int ldz );\nlapack_int LAPACKE_zhbgv( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_int ka, lapack_int kb,\n                          lapack_complex_double* ab, lapack_int ldab,\n                          lapack_complex_double* bb, lapack_int ldbb, double* w,\n                          lapack_complex_double* z, lapack_int ldz );\n\nlapack_int LAPACKE_chbgvd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_int ka, lapack_int kb,\n                           lapack_complex_float* ab, lapack_int ldab,\n                           lapack_complex_float* bb, lapack_int ldbb, float* w,\n                           lapack_complex_float* z, lapack_int ldz );\nlapack_int LAPACKE_zhbgvd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_int ka, lapack_int kb,\n                           lapack_complex_double* ab, lapack_int ldab,\n                           lapack_complex_double* bb, lapack_int ldbb,\n                           double* w, lapack_complex_double* z,\n                           lapack_int ldz );\n\nlapack_int LAPACKE_chbgvx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_int ka, lapack_int kb,\n                           lapack_complex_float* ab, lapack_int ldab,\n                           lapack_complex_float* bb, lapack_int ldbb,\n                           lapack_complex_float* q, lapack_int ldq, float vl,\n                           float vu, lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, lapack_complex_float* z,\n                           lapack_int ldz, lapack_int* ifail );\nlapack_int LAPACKE_zhbgvx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_int ka, lapack_int kb,\n                           lapack_complex_double* ab, lapack_int ldab,\n                           lapack_complex_double* bb, lapack_int ldbb,\n                           lapack_complex_double* q, lapack_int ldq, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w,\n                           lapack_complex_double* z, lapack_int ldz,\n                           lapack_int* ifail );\n\nlapack_int LAPACKE_chbtrd( int matrix_order, char vect, char uplo, lapack_int n,\n                           lapack_int kd, lapack_complex_float* ab,\n                           lapack_int ldab, float* d, float* e,\n                           lapack_complex_float* q, lapack_int ldq );\nlapack_int LAPACKE_zhbtrd( int matrix_order, char vect, char uplo, lapack_int n,\n                           lapack_int kd, lapack_complex_double* ab,\n                           lapack_int ldab, double* d, double* e,\n                           lapack_complex_double* q, lapack_int ldq );\n\nlapack_int LAPACKE_checon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_int* ipiv, float anorm, float* rcond );\nlapack_int LAPACKE_zhecon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_int* ipiv, double anorm,\n                           double* rcond );\n\nlapack_int LAPACKE_cheequb( int matrix_order, char uplo, lapack_int n,\n                            const lapack_complex_float* a, lapack_int lda,\n                            float* s, float* scond, float* amax );\nlapack_int LAPACKE_zheequb( int matrix_order, char uplo, lapack_int n,\n                            const lapack_complex_double* a, lapack_int lda,\n                            double* s, double* scond, double* amax );\n\nlapack_int LAPACKE_cheev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_complex_float* a, lapack_int lda, float* w );\nlapack_int LAPACKE_zheev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_complex_double* a, lapack_int lda, double* w );\n\nlapack_int LAPACKE_cheevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda, float* w );\nlapack_int LAPACKE_zheevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           double* w );\n\nlapack_int LAPACKE_cheevr( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_complex_float* a,\n                           lapack_int lda, float vl, float vu, lapack_int il,\n                           lapack_int iu, float abstol, lapack_int* m, float* w,\n                           lapack_complex_float* z, lapack_int ldz,\n                           lapack_int* isuppz );\nlapack_int LAPACKE_zheevr( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_complex_double* a,\n                           lapack_int lda, double vl, double vu, lapack_int il,\n                           lapack_int iu, double abstol, lapack_int* m,\n                           double* w, lapack_complex_double* z, lapack_int ldz,\n                           lapack_int* isuppz );\n\nlapack_int LAPACKE_cheevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_complex_float* a,\n                           lapack_int lda, float vl, float vu, lapack_int il,\n                           lapack_int iu, float abstol, lapack_int* m, float* w,\n                           lapack_complex_float* z, lapack_int ldz,\n                           lapack_int* ifail );\nlapack_int LAPACKE_zheevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_complex_double* a,\n                           lapack_int lda, double vl, double vu, lapack_int il,\n                           lapack_int iu, double abstol, lapack_int* m,\n                           double* w, lapack_complex_double* z, lapack_int ldz,\n                           lapack_int* ifail );\n\nlapack_int LAPACKE_chegst( int matrix_order, lapack_int itype, char uplo,\n                           lapack_int n, lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_zhegst( int matrix_order, lapack_int itype, char uplo,\n                           lapack_int n, lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* b,\n                           lapack_int ldb );\n\nlapack_int LAPACKE_chegv( int matrix_order, lapack_int itype, char jobz,\n                          char uplo, lapack_int n, lapack_complex_float* a,\n                          lapack_int lda, lapack_complex_float* b,\n                          lapack_int ldb, float* w );\nlapack_int LAPACKE_zhegv( int matrix_order, lapack_int itype, char jobz,\n                          char uplo, lapack_int n, lapack_complex_double* a,\n                          lapack_int lda, lapack_complex_double* b,\n                          lapack_int ldb, double* w );\n\nlapack_int LAPACKE_chegvd( int matrix_order, lapack_int itype, char jobz,\n                           char uplo, lapack_int n, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* b,\n                           lapack_int ldb, float* w );\nlapack_int LAPACKE_zhegvd( int matrix_order, lapack_int itype, char jobz,\n                           char uplo, lapack_int n, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* b,\n                           lapack_int ldb, double* w );\n\nlapack_int LAPACKE_chegvx( int matrix_order, lapack_int itype, char jobz,\n                           char range, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* b, lapack_int ldb, float vl,\n                           float vu, lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, lapack_complex_float* z,\n                           lapack_int ldz, lapack_int* ifail );\nlapack_int LAPACKE_zhegvx( int matrix_order, lapack_int itype, char jobz,\n                           char range, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* b, lapack_int ldb, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w,\n                           lapack_complex_double* z, lapack_int ldz,\n                           lapack_int* ifail );\n\nlapack_int LAPACKE_cherfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* af,\n                           lapack_int ldaf, const lapack_int* ipiv,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zherfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* af,\n                           lapack_int ldaf, const lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_cherfsx( int matrix_order, char uplo, char equed,\n                            lapack_int n, lapack_int nrhs,\n                            const lapack_complex_float* a, lapack_int lda,\n                            const lapack_complex_float* af, lapack_int ldaf,\n                            const lapack_int* ipiv, const float* s,\n                            const lapack_complex_float* b, lapack_int ldb,\n                            lapack_complex_float* x, lapack_int ldx,\n                            float* rcond, float* berr, lapack_int n_err_bnds,\n                            float* err_bnds_norm, float* err_bnds_comp,\n                            lapack_int nparams, float* params );\nlapack_int LAPACKE_zherfsx( int matrix_order, char uplo, char equed,\n                            lapack_int n, lapack_int nrhs,\n                            const lapack_complex_double* a, lapack_int lda,\n                            const lapack_complex_double* af, lapack_int ldaf,\n                            const lapack_int* ipiv, const double* s,\n                            const lapack_complex_double* b, lapack_int ldb,\n                            lapack_complex_double* x, lapack_int ldx,\n                            double* rcond, double* berr, lapack_int n_err_bnds,\n                            double* err_bnds_norm, double* err_bnds_comp,\n                            lapack_int nparams, double* params );\n\nlapack_int LAPACKE_chesv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_float* a,\n                          lapack_int lda, lapack_int* ipiv,\n                          lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zhesv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_double* a,\n                          lapack_int lda, lapack_int* ipiv,\n                          lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_chesvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* af,\n                           lapack_int ldaf, lapack_int* ipiv,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx,\n                           float* rcond, float* ferr, float* berr );\nlapack_int LAPACKE_zhesvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* af,\n                           lapack_int ldaf, lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr );\n\nlapack_int LAPACKE_chesvxx( int matrix_order, char fact, char uplo,\n                            lapack_int n, lapack_int nrhs,\n                            lapack_complex_float* a, lapack_int lda,\n                            lapack_complex_float* af, lapack_int ldaf,\n                            lapack_int* ipiv, char* equed, float* s,\n                            lapack_complex_float* b, lapack_int ldb,\n                            lapack_complex_float* x, lapack_int ldx,\n                            float* rcond, float* rpvgrw, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_zhesvxx( int matrix_order, char fact, char uplo,\n                            lapack_int n, lapack_int nrhs,\n                            lapack_complex_double* a, lapack_int lda,\n                            lapack_complex_double* af, lapack_int ldaf,\n                            lapack_int* ipiv, char* equed, double* s,\n                            lapack_complex_double* b, lapack_int ldb,\n                            lapack_complex_double* x, lapack_int ldx,\n                            double* rcond, double* rpvgrw, double* berr,\n                            lapack_int n_err_bnds, double* err_bnds_norm,\n                            double* err_bnds_comp, lapack_int nparams,\n                            double* params );\n\nlapack_int LAPACKE_chetrd( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda, float* d,\n                           float* e, lapack_complex_float* tau );\nlapack_int LAPACKE_zhetrd( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda, double* d,\n                           double* e, lapack_complex_double* tau );\n\nlapack_int LAPACKE_chetrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_int* ipiv );\nlapack_int LAPACKE_zhetrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int* ipiv );\n\nlapack_int LAPACKE_chetri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           const lapack_int* ipiv );\nlapack_int LAPACKE_zhetri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           const lapack_int* ipiv );\n\nlapack_int LAPACKE_chetrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* a,\n                           lapack_int lda, const lapack_int* ipiv,\n                           lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zhetrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* a,\n                           lapack_int lda, const lapack_int* ipiv,\n                           lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_chfrk( int matrix_order, char transr, char uplo, char trans,\n                          lapack_int n, lapack_int k, float alpha,\n                          const lapack_complex_float* a, lapack_int lda,\n                          float beta, lapack_complex_float* c );\nlapack_int LAPACKE_zhfrk( int matrix_order, char transr, char uplo, char trans,\n                          lapack_int n, lapack_int k, double alpha,\n                          const lapack_complex_double* a, lapack_int lda,\n                          double beta, lapack_complex_double* c );\n\nlapack_int LAPACKE_shgeqz( int matrix_order, char job, char compq, char compz,\n                           lapack_int n, lapack_int ilo, lapack_int ihi,\n                           float* h, lapack_int ldh, float* t, lapack_int ldt,\n                           float* alphar, float* alphai, float* beta, float* q,\n                           lapack_int ldq, float* z, lapack_int ldz );\nlapack_int LAPACKE_dhgeqz( int matrix_order, char job, char compq, char compz,\n                           lapack_int n, lapack_int ilo, lapack_int ihi,\n                           double* h, lapack_int ldh, double* t, lapack_int ldt,\n                           double* alphar, double* alphai, double* beta,\n                           double* q, lapack_int ldq, double* z,\n                           lapack_int ldz );\nlapack_int LAPACKE_chgeqz( int matrix_order, char job, char compq, char compz,\n                           lapack_int n, lapack_int ilo, lapack_int ihi,\n                           lapack_complex_float* h, lapack_int ldh,\n                           lapack_complex_float* t, lapack_int ldt,\n                           lapack_complex_float* alpha,\n                           lapack_complex_float* beta, lapack_complex_float* q,\n                           lapack_int ldq, lapack_complex_float* z,\n                           lapack_int ldz );\nlapack_int LAPACKE_zhgeqz( int matrix_order, char job, char compq, char compz,\n                           lapack_int n, lapack_int ilo, lapack_int ihi,\n                           lapack_complex_double* h, lapack_int ldh,\n                           lapack_complex_double* t, lapack_int ldt,\n                           lapack_complex_double* alpha,\n                           lapack_complex_double* beta,\n                           lapack_complex_double* q, lapack_int ldq,\n                           lapack_complex_double* z, lapack_int ldz );\n\nlapack_int LAPACKE_chpcon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_float* ap,\n                           const lapack_int* ipiv, float anorm, float* rcond );\nlapack_int LAPACKE_zhpcon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_double* ap,\n                           const lapack_int* ipiv, double anorm,\n                           double* rcond );\n\nlapack_int LAPACKE_chpev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_complex_float* ap, float* w,\n                          lapack_complex_float* z, lapack_int ldz );\nlapack_int LAPACKE_zhpev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_complex_double* ap, double* w,\n                          lapack_complex_double* z, lapack_int ldz );\n\nlapack_int LAPACKE_chpevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_complex_float* ap, float* w,\n                           lapack_complex_float* z, lapack_int ldz );\nlapack_int LAPACKE_zhpevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_complex_double* ap, double* w,\n                           lapack_complex_double* z, lapack_int ldz );\n\nlapack_int LAPACKE_chpevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_complex_float* ap, float vl,\n                           float vu, lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, lapack_complex_float* z,\n                           lapack_int ldz, lapack_int* ifail );\nlapack_int LAPACKE_zhpevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_complex_double* ap, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w,\n                           lapack_complex_double* z, lapack_int ldz,\n                           lapack_int* ifail );\n\nlapack_int LAPACKE_chpgst( int matrix_order, lapack_int itype, char uplo,\n                           lapack_int n, lapack_complex_float* ap,\n                           const lapack_complex_float* bp );\nlapack_int LAPACKE_zhpgst( int matrix_order, lapack_int itype, char uplo,\n                           lapack_int n, lapack_complex_double* ap,\n                           const lapack_complex_double* bp );\n\nlapack_int LAPACKE_chpgv( int matrix_order, lapack_int itype, char jobz,\n                          char uplo, lapack_int n, lapack_complex_float* ap,\n                          lapack_complex_float* bp, float* w,\n                          lapack_complex_float* z, lapack_int ldz );\nlapack_int LAPACKE_zhpgv( int matrix_order, lapack_int itype, char jobz,\n                          char uplo, lapack_int n, lapack_complex_double* ap,\n                          lapack_complex_double* bp, double* w,\n                          lapack_complex_double* z, lapack_int ldz );\n\nlapack_int LAPACKE_chpgvd( int matrix_order, lapack_int itype, char jobz,\n                           char uplo, lapack_int n, lapack_complex_float* ap,\n                           lapack_complex_float* bp, float* w,\n                           lapack_complex_float* z, lapack_int ldz );\nlapack_int LAPACKE_zhpgvd( int matrix_order, lapack_int itype, char jobz,\n                           char uplo, lapack_int n, lapack_complex_double* ap,\n                           lapack_complex_double* bp, double* w,\n                           lapack_complex_double* z, lapack_int ldz );\n\nlapack_int LAPACKE_chpgvx( int matrix_order, lapack_int itype, char jobz,\n                           char range, char uplo, lapack_int n,\n                           lapack_complex_float* ap, lapack_complex_float* bp,\n                           float vl, float vu, lapack_int il, lapack_int iu,\n                           float abstol, lapack_int* m, float* w,\n                           lapack_complex_float* z, lapack_int ldz,\n                           lapack_int* ifail );\nlapack_int LAPACKE_zhpgvx( int matrix_order, lapack_int itype, char jobz,\n                           char range, char uplo, lapack_int n,\n                           lapack_complex_double* ap, lapack_complex_double* bp,\n                           double vl, double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w,\n                           lapack_complex_double* z, lapack_int ldz,\n                           lapack_int* ifail );\n\nlapack_int LAPACKE_chprfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* ap,\n                           const lapack_complex_float* afp,\n                           const lapack_int* ipiv,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zhprfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* ap,\n                           const lapack_complex_double* afp,\n                           const lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_chpsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_float* ap,\n                          lapack_int* ipiv, lapack_complex_float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_zhpsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_double* ap,\n                          lapack_int* ipiv, lapack_complex_double* b,\n                          lapack_int ldb );\n\nlapack_int LAPACKE_chpsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* ap,\n                           lapack_complex_float* afp, lapack_int* ipiv,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx,\n                           float* rcond, float* ferr, float* berr );\nlapack_int LAPACKE_zhpsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* ap,\n                           lapack_complex_double* afp, lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr );\n\nlapack_int LAPACKE_chptrd( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* ap, float* d, float* e,\n                           lapack_complex_float* tau );\nlapack_int LAPACKE_zhptrd( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* ap, double* d, double* e,\n                           lapack_complex_double* tau );\n\nlapack_int LAPACKE_chptrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* ap, lapack_int* ipiv );\nlapack_int LAPACKE_zhptrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* ap, lapack_int* ipiv );\n\nlapack_int LAPACKE_chptri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* ap, const lapack_int* ipiv );\nlapack_int LAPACKE_zhptri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* ap, const lapack_int* ipiv );\n\nlapack_int LAPACKE_chptrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* ap,\n                           const lapack_int* ipiv, lapack_complex_float* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_zhptrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* ap,\n                           const lapack_int* ipiv, lapack_complex_double* b,\n                           lapack_int ldb );\n\nlapack_int LAPACKE_shsein( int matrix_order, char job, char eigsrc, char initv,\n                           lapack_logical* select, lapack_int n, const float* h,\n                           lapack_int ldh, float* wr, const float* wi,\n                           float* vl, lapack_int ldvl, float* vr,\n                           lapack_int ldvr, lapack_int mm, lapack_int* m,\n                           lapack_int* ifaill, lapack_int* ifailr );\nlapack_int LAPACKE_dhsein( int matrix_order, char job, char eigsrc, char initv,\n                           lapack_logical* select, lapack_int n,\n                           const double* h, lapack_int ldh, double* wr,\n                           const double* wi, double* vl, lapack_int ldvl,\n                           double* vr, lapack_int ldvr, lapack_int mm,\n                           lapack_int* m, lapack_int* ifaill,\n                           lapack_int* ifailr );\nlapack_int LAPACKE_chsein( int matrix_order, char job, char eigsrc, char initv,\n                           const lapack_logical* select, lapack_int n,\n                           const lapack_complex_float* h, lapack_int ldh,\n                           lapack_complex_float* w, lapack_complex_float* vl,\n                           lapack_int ldvl, lapack_complex_float* vr,\n                           lapack_int ldvr, lapack_int mm, lapack_int* m,\n                           lapack_int* ifaill, lapack_int* ifailr );\nlapack_int LAPACKE_zhsein( int matrix_order, char job, char eigsrc, char initv,\n                           const lapack_logical* select, lapack_int n,\n                           const lapack_complex_double* h, lapack_int ldh,\n                           lapack_complex_double* w, lapack_complex_double* vl,\n                           lapack_int ldvl, lapack_complex_double* vr,\n                           lapack_int ldvr, lapack_int mm, lapack_int* m,\n                           lapack_int* ifaill, lapack_int* ifailr );\n\nlapack_int LAPACKE_shseqr( int matrix_order, char job, char compz, lapack_int n,\n                           lapack_int ilo, lapack_int ihi, float* h,\n                           lapack_int ldh, float* wr, float* wi, float* z,\n                           lapack_int ldz );\nlapack_int LAPACKE_dhseqr( int matrix_order, char job, char compz, lapack_int n,\n                           lapack_int ilo, lapack_int ihi, double* h,\n                           lapack_int ldh, double* wr, double* wi, double* z,\n                           lapack_int ldz );\nlapack_int LAPACKE_chseqr( int matrix_order, char job, char compz, lapack_int n,\n                           lapack_int ilo, lapack_int ihi,\n                           lapack_complex_float* h, lapack_int ldh,\n                           lapack_complex_float* w, lapack_complex_float* z,\n                           lapack_int ldz );\nlapack_int LAPACKE_zhseqr( int matrix_order, char job, char compz, lapack_int n,\n                           lapack_int ilo, lapack_int ihi,\n                           lapack_complex_double* h, lapack_int ldh,\n                           lapack_complex_double* w, lapack_complex_double* z,\n                           lapack_int ldz );\n\nlapack_int LAPACKE_clacgv( lapack_int n, lapack_complex_float* x,\n                           lapack_int incx );\nlapack_int LAPACKE_zlacgv( lapack_int n, lapack_complex_double* x,\n                           lapack_int incx );\n\nlapack_int LAPACKE_slacpy( int matrix_order, char uplo, lapack_int m,\n                           lapack_int n, const float* a, lapack_int lda, float* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_dlacpy( int matrix_order, char uplo, lapack_int m,\n                           lapack_int n, const double* a, lapack_int lda, double* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_clacpy( int matrix_order, char uplo, lapack_int m,\n                           lapack_int n, const lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_zlacpy( int matrix_order, char uplo, lapack_int m,\n                           lapack_int n, const lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* b,\n                           lapack_int ldb );\n\nlapack_int LAPACKE_zlag2c( int matrix_order, lapack_int m, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_float* sa, lapack_int ldsa );\n\nlapack_int LAPACKE_slag2d( int matrix_order, lapack_int m, lapack_int n,\n                           const float* sa, lapack_int ldsa, double* a,\n                           lapack_int lda );\n\nlapack_int LAPACKE_dlag2s( int matrix_order, lapack_int m, lapack_int n,\n                           const double* a, lapack_int lda, float* sa,\n                           lapack_int ldsa );\n\nlapack_int LAPACKE_clag2z( int matrix_order, lapack_int m, lapack_int n,\n                           const lapack_complex_float* sa, lapack_int ldsa,\n                           lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_slagge( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku, const float* d,\n                           float* a, lapack_int lda, lapack_int* iseed );\nlapack_int LAPACKE_dlagge( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku, const double* d,\n                           double* a, lapack_int lda, lapack_int* iseed );\nlapack_int LAPACKE_clagge( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku, const float* d,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_int* iseed );\nlapack_int LAPACKE_zlagge( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int kl, lapack_int ku, const double* d,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int* iseed );\n\nfloat LAPACKE_slamch( char cmach );\ndouble LAPACKE_dlamch( char cmach );\n\nfloat LAPACKE_slange( int matrix_order, char norm, lapack_int m,\n                           lapack_int n, const float* a, lapack_int lda );\ndouble LAPACKE_dlange( int matrix_order, char norm, lapack_int m,\n                           lapack_int n, const double* a, lapack_int lda );\nfloat LAPACKE_clange( int matrix_order, char norm, lapack_int m,\n                           lapack_int n, const lapack_complex_float* a,\n                           lapack_int lda );\ndouble LAPACKE_zlange( int matrix_order, char norm, lapack_int m,\n                           lapack_int n, const lapack_complex_double* a,\n                           lapack_int lda );\n\nfloat LAPACKE_clanhe( int matrix_order, char norm, char uplo, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda );\ndouble LAPACKE_zlanhe( int matrix_order, char norm, char uplo, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda );\n\nfloat LAPACKE_slansy( int matrix_order, char norm, char uplo, lapack_int n,\n                           const float* a, lapack_int lda );\ndouble LAPACKE_dlansy( int matrix_order, char norm, char uplo, lapack_int n,\n                           const double* a, lapack_int lda );\nfloat LAPACKE_clansy( int matrix_order, char norm, char uplo, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda );\ndouble LAPACKE_zlansy( int matrix_order, char norm, char uplo, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda );\n\nfloat LAPACKE_slantr( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int m, lapack_int n, const float* a,\n                           lapack_int lda );\ndouble LAPACKE_dlantr( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int m, lapack_int n, const double* a,\n                           lapack_int lda );\nfloat LAPACKE_clantr( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int m, lapack_int n, const lapack_complex_float* a,\n                           lapack_int lda );\ndouble LAPACKE_zlantr( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int m, lapack_int n, const lapack_complex_double* a,\n                           lapack_int lda );\n\n\nlapack_int LAPACKE_slarfb( int matrix_order, char side, char trans, char direct,\n                           char storev, lapack_int m, lapack_int n,\n                           lapack_int k, const float* v, lapack_int ldv,\n                           const float* t, lapack_int ldt, float* c,\n                           lapack_int ldc );\nlapack_int LAPACKE_dlarfb( int matrix_order, char side, char trans, char direct,\n                           char storev, lapack_int m, lapack_int n,\n                           lapack_int k, const double* v, lapack_int ldv,\n                           const double* t, lapack_int ldt, double* c,\n                           lapack_int ldc );\nlapack_int LAPACKE_clarfb( int matrix_order, char side, char trans, char direct,\n                           char storev, lapack_int m, lapack_int n,\n                           lapack_int k, const lapack_complex_float* v,\n                           lapack_int ldv, const lapack_complex_float* t,\n                           lapack_int ldt, lapack_complex_float* c,\n                           lapack_int ldc );\nlapack_int LAPACKE_zlarfb( int matrix_order, char side, char trans, char direct,\n                           char storev, lapack_int m, lapack_int n,\n                           lapack_int k, const lapack_complex_double* v,\n                           lapack_int ldv, const lapack_complex_double* t,\n                           lapack_int ldt, lapack_complex_double* c,\n                           lapack_int ldc );\n\nlapack_int LAPACKE_slarfg( lapack_int n, float* alpha, float* x,\n                           lapack_int incx, float* tau );\nlapack_int LAPACKE_dlarfg( lapack_int n, double* alpha, double* x,\n                           lapack_int incx, double* tau );\nlapack_int LAPACKE_clarfg( lapack_int n, lapack_complex_float* alpha,\n                           lapack_complex_float* x, lapack_int incx,\n                           lapack_complex_float* tau );\nlapack_int LAPACKE_zlarfg( lapack_int n, lapack_complex_double* alpha,\n                           lapack_complex_double* x, lapack_int incx,\n                           lapack_complex_double* tau );\n\nlapack_int LAPACKE_slarft( int matrix_order, char direct, char storev,\n                           lapack_int n, lapack_int k, const float* v,\n                           lapack_int ldv, const float* tau, float* t,\n                           lapack_int ldt );\nlapack_int LAPACKE_dlarft( int matrix_order, char direct, char storev,\n                           lapack_int n, lapack_int k, const double* v,\n                           lapack_int ldv, const double* tau, double* t,\n                           lapack_int ldt );\nlapack_int LAPACKE_clarft( int matrix_order, char direct, char storev,\n                           lapack_int n, lapack_int k,\n                           const lapack_complex_float* v, lapack_int ldv,\n                           const lapack_complex_float* tau,\n                           lapack_complex_float* t, lapack_int ldt );\nlapack_int LAPACKE_zlarft( int matrix_order, char direct, char storev,\n                           lapack_int n, lapack_int k,\n                           const lapack_complex_double* v, lapack_int ldv,\n                           const lapack_complex_double* tau,\n                           lapack_complex_double* t, lapack_int ldt );\n\nlapack_int LAPACKE_slarfx( int matrix_order, char side, lapack_int m,\n                           lapack_int n, const float* v, float tau, float* c,\n                           lapack_int ldc, float* work );\nlapack_int LAPACKE_dlarfx( int matrix_order, char side, lapack_int m,\n                           lapack_int n, const double* v, double tau, double* c,\n                           lapack_int ldc, double* work );\nlapack_int LAPACKE_clarfx( int matrix_order, char side, lapack_int m,\n                           lapack_int n, const lapack_complex_float* v,\n                           lapack_complex_float tau, lapack_complex_float* c,\n                           lapack_int ldc, lapack_complex_float* work );\nlapack_int LAPACKE_zlarfx( int matrix_order, char side, lapack_int m,\n                           lapack_int n, const lapack_complex_double* v,\n                           lapack_complex_double tau, lapack_complex_double* c,\n                           lapack_int ldc, lapack_complex_double* work );\n\nlapack_int LAPACKE_slarnv( lapack_int idist, lapack_int* iseed, lapack_int n,\n                           float* x );\nlapack_int LAPACKE_dlarnv( lapack_int idist, lapack_int* iseed, lapack_int n,\n                           double* x );\nlapack_int LAPACKE_clarnv( lapack_int idist, lapack_int* iseed, lapack_int n,\n                           lapack_complex_float* x );\nlapack_int LAPACKE_zlarnv( lapack_int idist, lapack_int* iseed, lapack_int n,\n                           lapack_complex_double* x );\n\nlapack_int LAPACKE_slaset( int matrix_order, char uplo, lapack_int m,\n                           lapack_int n, float alpha, float beta, float* a,\n                           lapack_int lda );\nlapack_int LAPACKE_dlaset( int matrix_order, char uplo, lapack_int m,\n                           lapack_int n, double alpha, double beta, double* a,\n                           lapack_int lda );\nlapack_int LAPACKE_claset( int matrix_order, char uplo, lapack_int m,\n                           lapack_int n, lapack_complex_float alpha,\n                           lapack_complex_float beta, lapack_complex_float* a,\n                           lapack_int lda );\nlapack_int LAPACKE_zlaset( int matrix_order, char uplo, lapack_int m,\n                           lapack_int n, lapack_complex_double alpha,\n                           lapack_complex_double beta, lapack_complex_double* a,\n                           lapack_int lda );\n\nlapack_int LAPACKE_slasrt( char id, lapack_int n, float* d );\nlapack_int LAPACKE_dlasrt( char id, lapack_int n, double* d );\n\nlapack_int LAPACKE_slaswp( int matrix_order, lapack_int n, float* a,\n                           lapack_int lda, lapack_int k1, lapack_int k2,\n                           const lapack_int* ipiv, lapack_int incx );\nlapack_int LAPACKE_dlaswp( int matrix_order, lapack_int n, double* a,\n                           lapack_int lda, lapack_int k1, lapack_int k2,\n                           const lapack_int* ipiv, lapack_int incx );\nlapack_int LAPACKE_claswp( int matrix_order, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_int k1, lapack_int k2, const lapack_int* ipiv,\n                           lapack_int incx );\nlapack_int LAPACKE_zlaswp( int matrix_order, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int k1, lapack_int k2, const lapack_int* ipiv,\n                           lapack_int incx );\n\nlapack_int LAPACKE_slatms( int matrix_order, lapack_int m, lapack_int n,\n                           char dist, lapack_int* iseed, char sym, float* d,\n                           lapack_int mode, float cond, float dmax,\n                           lapack_int kl, lapack_int ku, char pack, float* a,\n                           lapack_int lda );\nlapack_int LAPACKE_dlatms( int matrix_order, lapack_int m, lapack_int n,\n                           char dist, lapack_int* iseed, char sym, double* d,\n                           lapack_int mode, double cond, double dmax,\n                           lapack_int kl, lapack_int ku, char pack, double* a,\n                           lapack_int lda );\nlapack_int LAPACKE_clatms( int matrix_order, lapack_int m, lapack_int n,\n                           char dist, lapack_int* iseed, char sym, float* d,\n                           lapack_int mode, float cond, float dmax,\n                           lapack_int kl, lapack_int ku, char pack,\n                           lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_zlatms( int matrix_order, lapack_int m, lapack_int n,\n                           char dist, lapack_int* iseed, char sym, double* d,\n                           lapack_int mode, double cond, double dmax,\n                           lapack_int kl, lapack_int ku, char pack,\n                           lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_slauum( int matrix_order, char uplo, lapack_int n, float* a,\n                           lapack_int lda );\nlapack_int LAPACKE_dlauum( int matrix_order, char uplo, lapack_int n, double* a,\n                           lapack_int lda );\nlapack_int LAPACKE_clauum( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_zlauum( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_sopgtr( int matrix_order, char uplo, lapack_int n,\n                           const float* ap, const float* tau, float* q,\n                           lapack_int ldq );\nlapack_int LAPACKE_dopgtr( int matrix_order, char uplo, lapack_int n,\n                           const double* ap, const double* tau, double* q,\n                           lapack_int ldq );\n\nlapack_int LAPACKE_sopmtr( int matrix_order, char side, char uplo, char trans,\n                           lapack_int m, lapack_int n, const float* ap,\n                           const float* tau, float* c, lapack_int ldc );\nlapack_int LAPACKE_dopmtr( int matrix_order, char side, char uplo, char trans,\n                           lapack_int m, lapack_int n, const double* ap,\n                           const double* tau, double* c, lapack_int ldc );\n\nlapack_int LAPACKE_sorgbr( int matrix_order, char vect, lapack_int m,\n                           lapack_int n, lapack_int k, float* a, lapack_int lda,\n                           const float* tau );\nlapack_int LAPACKE_dorgbr( int matrix_order, char vect, lapack_int m,\n                           lapack_int n, lapack_int k, double* a,\n                           lapack_int lda, const double* tau );\n\nlapack_int LAPACKE_sorghr( int matrix_order, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, float* a, lapack_int lda,\n                           const float* tau );\nlapack_int LAPACKE_dorghr( int matrix_order, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, double* a, lapack_int lda,\n                           const double* tau );\n\nlapack_int LAPACKE_sorglq( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, float* a, lapack_int lda,\n                           const float* tau );\nlapack_int LAPACKE_dorglq( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, double* a, lapack_int lda,\n                           const double* tau );\n\nlapack_int LAPACKE_sorgql( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, float* a, lapack_int lda,\n                           const float* tau );\nlapack_int LAPACKE_dorgql( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, double* a, lapack_int lda,\n                           const double* tau );\n\nlapack_int LAPACKE_sorgqr( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, float* a, lapack_int lda,\n                           const float* tau );\nlapack_int LAPACKE_dorgqr( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, double* a, lapack_int lda,\n                           const double* tau );\n\nlapack_int LAPACKE_sorgrq( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, float* a, lapack_int lda,\n                           const float* tau );\nlapack_int LAPACKE_dorgrq( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, double* a, lapack_int lda,\n                           const double* tau );\n\nlapack_int LAPACKE_sorgtr( int matrix_order, char uplo, lapack_int n, float* a,\n                           lapack_int lda, const float* tau );\nlapack_int LAPACKE_dorgtr( int matrix_order, char uplo, lapack_int n, double* a,\n                           lapack_int lda, const double* tau );\n\nlapack_int LAPACKE_sormbr( int matrix_order, char vect, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const float* a, lapack_int lda, const float* tau,\n                           float* c, lapack_int ldc );\nlapack_int LAPACKE_dormbr( int matrix_order, char vect, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const double* a, lapack_int lda, const double* tau,\n                           double* c, lapack_int ldc );\n\nlapack_int LAPACKE_sormhr( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, const float* a, lapack_int lda,\n                           const float* tau, float* c, lapack_int ldc );\nlapack_int LAPACKE_dormhr( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, const double* a, lapack_int lda,\n                           const double* tau, double* c, lapack_int ldc );\n\nlapack_int LAPACKE_sormlq( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const float* a, lapack_int lda, const float* tau,\n                           float* c, lapack_int ldc );\nlapack_int LAPACKE_dormlq( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const double* a, lapack_int lda, const double* tau,\n                           double* c, lapack_int ldc );\n\nlapack_int LAPACKE_sormql( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const float* a, lapack_int lda, const float* tau,\n                           float* c, lapack_int ldc );\nlapack_int LAPACKE_dormql( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const double* a, lapack_int lda, const double* tau,\n                           double* c, lapack_int ldc );\n\nlapack_int LAPACKE_sormqr( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const float* a, lapack_int lda, const float* tau,\n                           float* c, lapack_int ldc );\nlapack_int LAPACKE_dormqr( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const double* a, lapack_int lda, const double* tau,\n                           double* c, lapack_int ldc );\n\nlapack_int LAPACKE_sormrq( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const float* a, lapack_int lda, const float* tau,\n                           float* c, lapack_int ldc );\nlapack_int LAPACKE_dormrq( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const double* a, lapack_int lda, const double* tau,\n                           double* c, lapack_int ldc );\n\nlapack_int LAPACKE_sormrz( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           lapack_int l, const float* a, lapack_int lda,\n                           const float* tau, float* c, lapack_int ldc );\nlapack_int LAPACKE_dormrz( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           lapack_int l, const double* a, lapack_int lda,\n                           const double* tau, double* c, lapack_int ldc );\n\nlapack_int LAPACKE_sormtr( int matrix_order, char side, char uplo, char trans,\n                           lapack_int m, lapack_int n, const float* a,\n                           lapack_int lda, const float* tau, float* c,\n                           lapack_int ldc );\nlapack_int LAPACKE_dormtr( int matrix_order, char side, char uplo, char trans,\n                           lapack_int m, lapack_int n, const double* a,\n                           lapack_int lda, const double* tau, double* c,\n                           lapack_int ldc );\n\nlapack_int LAPACKE_spbcon( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, const float* ab, lapack_int ldab,\n                           float anorm, float* rcond );\nlapack_int LAPACKE_dpbcon( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, const double* ab, lapack_int ldab,\n                           double anorm, double* rcond );\nlapack_int LAPACKE_cpbcon( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, const lapack_complex_float* ab,\n                           lapack_int ldab, float anorm, float* rcond );\nlapack_int LAPACKE_zpbcon( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, const lapack_complex_double* ab,\n                           lapack_int ldab, double anorm, double* rcond );\n\nlapack_int LAPACKE_spbequ( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, const float* ab, lapack_int ldab,\n                           float* s, float* scond, float* amax );\nlapack_int LAPACKE_dpbequ( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, const double* ab, lapack_int ldab,\n                           double* s, double* scond, double* amax );\nlapack_int LAPACKE_cpbequ( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, const lapack_complex_float* ab,\n                           lapack_int ldab, float* s, float* scond,\n                           float* amax );\nlapack_int LAPACKE_zpbequ( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, const lapack_complex_double* ab,\n                           lapack_int ldab, double* s, double* scond,\n                           double* amax );\n\nlapack_int LAPACKE_spbrfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs, const float* ab,\n                           lapack_int ldab, const float* afb, lapack_int ldafb,\n                           const float* b, lapack_int ldb, float* x,\n                           lapack_int ldx, float* ferr, float* berr );\nlapack_int LAPACKE_dpbrfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs, const double* ab,\n                           lapack_int ldab, const double* afb, lapack_int ldafb,\n                           const double* b, lapack_int ldb, double* x,\n                           lapack_int ldx, double* ferr, double* berr );\nlapack_int LAPACKE_cpbrfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs,\n                           const lapack_complex_float* ab, lapack_int ldab,\n                           const lapack_complex_float* afb, lapack_int ldafb,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zpbrfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs,\n                           const lapack_complex_double* ab, lapack_int ldab,\n                           const lapack_complex_double* afb, lapack_int ldafb,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_spbstf( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kb, float* bb, lapack_int ldbb );\nlapack_int LAPACKE_dpbstf( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kb, double* bb, lapack_int ldbb );\nlapack_int LAPACKE_cpbstf( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kb, lapack_complex_float* bb,\n                           lapack_int ldbb );\nlapack_int LAPACKE_zpbstf( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kb, lapack_complex_double* bb,\n                           lapack_int ldbb );\n\nlapack_int LAPACKE_spbsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int kd, lapack_int nrhs, float* ab,\n                          lapack_int ldab, float* b, lapack_int ldb );\nlapack_int LAPACKE_dpbsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int kd, lapack_int nrhs, double* ab,\n                          lapack_int ldab, double* b, lapack_int ldb );\nlapack_int LAPACKE_cpbsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int kd, lapack_int nrhs,\n                          lapack_complex_float* ab, lapack_int ldab,\n                          lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zpbsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int kd, lapack_int nrhs,\n                          lapack_complex_double* ab, lapack_int ldab,\n                          lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_spbsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs, float* ab,\n                           lapack_int ldab, float* afb, lapack_int ldafb,\n                           char* equed, float* s, float* b, lapack_int ldb,\n                           float* x, lapack_int ldx, float* rcond, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_dpbsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs, double* ab,\n                           lapack_int ldab, double* afb, lapack_int ldafb,\n                           char* equed, double* s, double* b, lapack_int ldb,\n                           double* x, lapack_int ldx, double* rcond,\n                           double* ferr, double* berr );\nlapack_int LAPACKE_cpbsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs,\n                           lapack_complex_float* ab, lapack_int ldab,\n                           lapack_complex_float* afb, lapack_int ldafb,\n                           char* equed, float* s, lapack_complex_float* b,\n                           lapack_int ldb, lapack_complex_float* x,\n                           lapack_int ldx, float* rcond, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zpbsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs,\n                           lapack_complex_double* ab, lapack_int ldab,\n                           lapack_complex_double* afb, lapack_int ldafb,\n                           char* equed, double* s, lapack_complex_double* b,\n                           lapack_int ldb, lapack_complex_double* x,\n                           lapack_int ldx, double* rcond, double* ferr,\n                           double* berr );\n\nlapack_int LAPACKE_spbtrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, float* ab, lapack_int ldab );\nlapack_int LAPACKE_dpbtrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, double* ab, lapack_int ldab );\nlapack_int LAPACKE_cpbtrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, lapack_complex_float* ab,\n                           lapack_int ldab );\nlapack_int LAPACKE_zpbtrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, lapack_complex_double* ab,\n                           lapack_int ldab );\n\nlapack_int LAPACKE_spbtrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs, const float* ab,\n                           lapack_int ldab, float* b, lapack_int ldb );\nlapack_int LAPACKE_dpbtrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs, const double* ab,\n                           lapack_int ldab, double* b, lapack_int ldb );\nlapack_int LAPACKE_cpbtrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs,\n                           const lapack_complex_float* ab, lapack_int ldab,\n                           lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zpbtrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int kd, lapack_int nrhs,\n                           const lapack_complex_double* ab, lapack_int ldab,\n                           lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_spftrf( int matrix_order, char transr, char uplo,\n                           lapack_int n, float* a );\nlapack_int LAPACKE_dpftrf( int matrix_order, char transr, char uplo,\n                           lapack_int n, double* a );\nlapack_int LAPACKE_cpftrf( int matrix_order, char transr, char uplo,\n                           lapack_int n, lapack_complex_float* a );\nlapack_int LAPACKE_zpftrf( int matrix_order, char transr, char uplo,\n                           lapack_int n, lapack_complex_double* a );\n\nlapack_int LAPACKE_spftri( int matrix_order, char transr, char uplo,\n                           lapack_int n, float* a );\nlapack_int LAPACKE_dpftri( int matrix_order, char transr, char uplo,\n                           lapack_int n, double* a );\nlapack_int LAPACKE_cpftri( int matrix_order, char transr, char uplo,\n                           lapack_int n, lapack_complex_float* a );\nlapack_int LAPACKE_zpftri( int matrix_order, char transr, char uplo,\n                           lapack_int n, lapack_complex_double* a );\n\nlapack_int LAPACKE_spftrs( int matrix_order, char transr, char uplo,\n                           lapack_int n, lapack_int nrhs, const float* a,\n                           float* b, lapack_int ldb );\nlapack_int LAPACKE_dpftrs( int matrix_order, char transr, char uplo,\n                           lapack_int n, lapack_int nrhs, const double* a,\n                           double* b, lapack_int ldb );\nlapack_int LAPACKE_cpftrs( int matrix_order, char transr, char uplo,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_float* a,\n                           lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zpftrs( int matrix_order, char transr, char uplo,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_double* a,\n                           lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_spocon( int matrix_order, char uplo, lapack_int n,\n                           const float* a, lapack_int lda, float anorm,\n                           float* rcond );\nlapack_int LAPACKE_dpocon( int matrix_order, char uplo, lapack_int n,\n                           const double* a, lapack_int lda, double anorm,\n                           double* rcond );\nlapack_int LAPACKE_cpocon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda,\n                           float anorm, float* rcond );\nlapack_int LAPACKE_zpocon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           double anorm, double* rcond );\n\nlapack_int LAPACKE_spoequ( int matrix_order, lapack_int n, const float* a,\n                           lapack_int lda, float* s, float* scond,\n                           float* amax );\nlapack_int LAPACKE_dpoequ( int matrix_order, lapack_int n, const double* a,\n                           lapack_int lda, double* s, double* scond,\n                           double* amax );\nlapack_int LAPACKE_cpoequ( int matrix_order, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda,\n                           float* s, float* scond, float* amax );\nlapack_int LAPACKE_zpoequ( int matrix_order, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           double* s, double* scond, double* amax );\n\nlapack_int LAPACKE_spoequb( int matrix_order, lapack_int n, const float* a,\n                            lapack_int lda, float* s, float* scond,\n                            float* amax );\nlapack_int LAPACKE_dpoequb( int matrix_order, lapack_int n, const double* a,\n                            lapack_int lda, double* s, double* scond,\n                            double* amax );\nlapack_int LAPACKE_cpoequb( int matrix_order, lapack_int n,\n                            const lapack_complex_float* a, lapack_int lda,\n                            float* s, float* scond, float* amax );\nlapack_int LAPACKE_zpoequb( int matrix_order, lapack_int n,\n                            const lapack_complex_double* a, lapack_int lda,\n                            double* s, double* scond, double* amax );\n\nlapack_int LAPACKE_sporfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* a, lapack_int lda,\n                           const float* af, lapack_int ldaf, const float* b,\n                           lapack_int ldb, float* x, lapack_int ldx,\n                           float* ferr, float* berr );\nlapack_int LAPACKE_dporfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* a, lapack_int lda,\n                           const double* af, lapack_int ldaf, const double* b,\n                           lapack_int ldb, double* x, lapack_int ldx,\n                           double* ferr, double* berr );\nlapack_int LAPACKE_cporfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* af,\n                           lapack_int ldaf, const lapack_complex_float* b,\n                           lapack_int ldb, lapack_complex_float* x,\n                           lapack_int ldx, float* ferr, float* berr );\nlapack_int LAPACKE_zporfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* af,\n                           lapack_int ldaf, const lapack_complex_double* b,\n                           lapack_int ldb, lapack_complex_double* x,\n                           lapack_int ldx, double* ferr, double* berr );\n\nlapack_int LAPACKE_sporfsx( int matrix_order, char uplo, char equed,\n                            lapack_int n, lapack_int nrhs, const float* a,\n                            lapack_int lda, const float* af, lapack_int ldaf,\n                            const float* s, const float* b, lapack_int ldb,\n                            float* x, lapack_int ldx, float* rcond, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_dporfsx( int matrix_order, char uplo, char equed,\n                            lapack_int n, lapack_int nrhs, const double* a,\n                            lapack_int lda, const double* af, lapack_int ldaf,\n                            const double* s, const double* b, lapack_int ldb,\n                            double* x, lapack_int ldx, double* rcond,\n                            double* berr, lapack_int n_err_bnds,\n                            double* err_bnds_norm, double* err_bnds_comp,\n                            lapack_int nparams, double* params );\nlapack_int LAPACKE_cporfsx( int matrix_order, char uplo, char equed,\n                            lapack_int n, lapack_int nrhs,\n                            const lapack_complex_float* a, lapack_int lda,\n                            const lapack_complex_float* af, lapack_int ldaf,\n                            const float* s, const lapack_complex_float* b,\n                            lapack_int ldb, lapack_complex_float* x,\n                            lapack_int ldx, float* rcond, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_zporfsx( int matrix_order, char uplo, char equed,\n                            lapack_int n, lapack_int nrhs,\n                            const lapack_complex_double* a, lapack_int lda,\n                            const lapack_complex_double* af, lapack_int ldaf,\n                            const double* s, const lapack_complex_double* b,\n                            lapack_int ldb, lapack_complex_double* x,\n                            lapack_int ldx, double* rcond, double* berr,\n                            lapack_int n_err_bnds, double* err_bnds_norm,\n                            double* err_bnds_comp, lapack_int nparams,\n                            double* params );\n\nlapack_int LAPACKE_sposv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, float* a, lapack_int lda, float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_dposv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, double* a, lapack_int lda, double* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_cposv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_float* a,\n                          lapack_int lda, lapack_complex_float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_zposv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_double* a,\n                          lapack_int lda, lapack_complex_double* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_dsposv( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, double* a, lapack_int lda,\n                           double* b, lapack_int ldb, double* x, lapack_int ldx,\n                           lapack_int* iter );\nlapack_int LAPACKE_zcposv( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* b,\n                           lapack_int ldb, lapack_complex_double* x,\n                           lapack_int ldx, lapack_int* iter );\n\nlapack_int LAPACKE_sposvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, float* a, lapack_int lda, float* af,\n                           lapack_int ldaf, char* equed, float* s, float* b,\n                           lapack_int ldb, float* x, lapack_int ldx,\n                           float* rcond, float* ferr, float* berr );\nlapack_int LAPACKE_dposvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, double* a, lapack_int lda,\n                           double* af, lapack_int ldaf, char* equed, double* s,\n                           double* b, lapack_int ldb, double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr );\nlapack_int LAPACKE_cposvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* af,\n                           lapack_int ldaf, char* equed, float* s,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx,\n                           float* rcond, float* ferr, float* berr );\nlapack_int LAPACKE_zposvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* af,\n                           lapack_int ldaf, char* equed, double* s,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr );\n\nlapack_int LAPACKE_sposvxx( int matrix_order, char fact, char uplo,\n                            lapack_int n, lapack_int nrhs, float* a,\n                            lapack_int lda, float* af, lapack_int ldaf,\n                            char* equed, float* s, float* b, lapack_int ldb,\n                            float* x, lapack_int ldx, float* rcond,\n                            float* rpvgrw, float* berr, lapack_int n_err_bnds,\n                            float* err_bnds_norm, float* err_bnds_comp,\n                            lapack_int nparams, float* params );\nlapack_int LAPACKE_dposvxx( int matrix_order, char fact, char uplo,\n                            lapack_int n, lapack_int nrhs, double* a,\n                            lapack_int lda, double* af, lapack_int ldaf,\n                            char* equed, double* s, double* b, lapack_int ldb,\n                            double* x, lapack_int ldx, double* rcond,\n                            double* rpvgrw, double* berr, lapack_int n_err_bnds,\n                            double* err_bnds_norm, double* err_bnds_comp,\n                            lapack_int nparams, double* params );\nlapack_int LAPACKE_cposvxx( int matrix_order, char fact, char uplo,\n                            lapack_int n, lapack_int nrhs,\n                            lapack_complex_float* a, lapack_int lda,\n                            lapack_complex_float* af, lapack_int ldaf,\n                            char* equed, float* s, lapack_complex_float* b,\n                            lapack_int ldb, lapack_complex_float* x,\n                            lapack_int ldx, float* rcond, float* rpvgrw,\n                            float* berr, lapack_int n_err_bnds,\n                            float* err_bnds_norm, float* err_bnds_comp,\n                            lapack_int nparams, float* params );\nlapack_int LAPACKE_zposvxx( int matrix_order, char fact, char uplo,\n                            lapack_int n, lapack_int nrhs,\n                            lapack_complex_double* a, lapack_int lda,\n                            lapack_complex_double* af, lapack_int ldaf,\n                            char* equed, double* s, lapack_complex_double* b,\n                            lapack_int ldb, lapack_complex_double* x,\n                            lapack_int ldx, double* rcond, double* rpvgrw,\n                            double* berr, lapack_int n_err_bnds,\n                            double* err_bnds_norm, double* err_bnds_comp,\n                            lapack_int nparams, double* params );\n\nlapack_int LAPACKE_spotrf( int matrix_order, char uplo, lapack_int n, float* a,\n                           lapack_int lda );\nlapack_int LAPACKE_dpotrf( int matrix_order, char uplo, lapack_int n, double* a,\n                           lapack_int lda );\nlapack_int LAPACKE_cpotrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_zpotrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_spotri( int matrix_order, char uplo, lapack_int n, float* a,\n                           lapack_int lda );\nlapack_int LAPACKE_dpotri( int matrix_order, char uplo, lapack_int n, double* a,\n                           lapack_int lda );\nlapack_int LAPACKE_cpotri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_zpotri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_spotrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* a, lapack_int lda,\n                           float* b, lapack_int ldb );\nlapack_int LAPACKE_dpotrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* a, lapack_int lda,\n                           double* b, lapack_int ldb );\nlapack_int LAPACKE_cpotrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_zpotrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* b,\n                           lapack_int ldb );\n\nlapack_int LAPACKE_sppcon( int matrix_order, char uplo, lapack_int n,\n                           const float* ap, float anorm, float* rcond );\nlapack_int LAPACKE_dppcon( int matrix_order, char uplo, lapack_int n,\n                           const double* ap, double anorm, double* rcond );\nlapack_int LAPACKE_cppcon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_float* ap, float anorm,\n                           float* rcond );\nlapack_int LAPACKE_zppcon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_double* ap, double anorm,\n                           double* rcond );\n\nlapack_int LAPACKE_sppequ( int matrix_order, char uplo, lapack_int n,\n                           const float* ap, float* s, float* scond,\n                           float* amax );\nlapack_int LAPACKE_dppequ( int matrix_order, char uplo, lapack_int n,\n                           const double* ap, double* s, double* scond,\n                           double* amax );\nlapack_int LAPACKE_cppequ( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_float* ap, float* s,\n                           float* scond, float* amax );\nlapack_int LAPACKE_zppequ( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_double* ap, double* s,\n                           double* scond, double* amax );\n\nlapack_int LAPACKE_spprfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* ap, const float* afp,\n                           const float* b, lapack_int ldb, float* x,\n                           lapack_int ldx, float* ferr, float* berr );\nlapack_int LAPACKE_dpprfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* ap, const double* afp,\n                           const double* b, lapack_int ldb, double* x,\n                           lapack_int ldx, double* ferr, double* berr );\nlapack_int LAPACKE_cpprfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* ap,\n                           const lapack_complex_float* afp,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zpprfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* ap,\n                           const lapack_complex_double* afp,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_sppsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, float* ap, float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_dppsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, double* ap, double* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_cppsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_float* ap,\n                          lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zppsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_double* ap,\n                          lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_sppsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, float* ap, float* afp, char* equed,\n                           float* s, float* b, lapack_int ldb, float* x,\n                           lapack_int ldx, float* rcond, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_dppsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, double* ap, double* afp,\n                           char* equed, double* s, double* b, lapack_int ldb,\n                           double* x, lapack_int ldx, double* rcond,\n                           double* ferr, double* berr );\nlapack_int LAPACKE_cppsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, lapack_complex_float* ap,\n                           lapack_complex_float* afp, char* equed, float* s,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx,\n                           float* rcond, float* ferr, float* berr );\nlapack_int LAPACKE_zppsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, lapack_complex_double* ap,\n                           lapack_complex_double* afp, char* equed, double* s,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr );\n\nlapack_int LAPACKE_spptrf( int matrix_order, char uplo, lapack_int n,\n                           float* ap );\nlapack_int LAPACKE_dpptrf( int matrix_order, char uplo, lapack_int n,\n                           double* ap );\nlapack_int LAPACKE_cpptrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* ap );\nlapack_int LAPACKE_zpptrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* ap );\n\nlapack_int LAPACKE_spptri( int matrix_order, char uplo, lapack_int n,\n                           float* ap );\nlapack_int LAPACKE_dpptri( int matrix_order, char uplo, lapack_int n,\n                           double* ap );\nlapack_int LAPACKE_cpptri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* ap );\nlapack_int LAPACKE_zpptri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* ap );\n\nlapack_int LAPACKE_spptrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* ap, float* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_dpptrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* ap, double* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_cpptrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* ap,\n                           lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zpptrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* ap,\n                           lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_spstrf( int matrix_order, char uplo, lapack_int n, float* a,\n                           lapack_int lda, lapack_int* piv, lapack_int* rank,\n                           float tol );\nlapack_int LAPACKE_dpstrf( int matrix_order, char uplo, lapack_int n, double* a,\n                           lapack_int lda, lapack_int* piv, lapack_int* rank,\n                           double tol );\nlapack_int LAPACKE_cpstrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_int* piv, lapack_int* rank, float tol );\nlapack_int LAPACKE_zpstrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int* piv, lapack_int* rank, double tol );\n\nlapack_int LAPACKE_sptcon( lapack_int n, const float* d, const float* e,\n                           float anorm, float* rcond );\nlapack_int LAPACKE_dptcon( lapack_int n, const double* d, const double* e,\n                           double anorm, double* rcond );\nlapack_int LAPACKE_cptcon( lapack_int n, const float* d,\n                           const lapack_complex_float* e, float anorm,\n                           float* rcond );\nlapack_int LAPACKE_zptcon( lapack_int n, const double* d,\n                           const lapack_complex_double* e, double anorm,\n                           double* rcond );\n\nlapack_int LAPACKE_spteqr( int matrix_order, char compz, lapack_int n, float* d,\n                           float* e, float* z, lapack_int ldz );\nlapack_int LAPACKE_dpteqr( int matrix_order, char compz, lapack_int n,\n                           double* d, double* e, double* z, lapack_int ldz );\nlapack_int LAPACKE_cpteqr( int matrix_order, char compz, lapack_int n, float* d,\n                           float* e, lapack_complex_float* z, lapack_int ldz );\nlapack_int LAPACKE_zpteqr( int matrix_order, char compz, lapack_int n,\n                           double* d, double* e, lapack_complex_double* z,\n                           lapack_int ldz );\n\nlapack_int LAPACKE_sptrfs( int matrix_order, lapack_int n, lapack_int nrhs,\n                           const float* d, const float* e, const float* df,\n                           const float* ef, const float* b, lapack_int ldb,\n                           float* x, lapack_int ldx, float* ferr, float* berr );\nlapack_int LAPACKE_dptrfs( int matrix_order, lapack_int n, lapack_int nrhs,\n                           const double* d, const double* e, const double* df,\n                           const double* ef, const double* b, lapack_int ldb,\n                           double* x, lapack_int ldx, double* ferr,\n                           double* berr );\nlapack_int LAPACKE_cptrfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* d,\n                           const lapack_complex_float* e, const float* df,\n                           const lapack_complex_float* ef,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zptrfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* d,\n                           const lapack_complex_double* e, const double* df,\n                           const lapack_complex_double* ef,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_sptsv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          float* d, float* e, float* b, lapack_int ldb );\nlapack_int LAPACKE_dptsv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          double* d, double* e, double* b, lapack_int ldb );\nlapack_int LAPACKE_cptsv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          float* d, lapack_complex_float* e,\n                          lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zptsv( int matrix_order, lapack_int n, lapack_int nrhs,\n                          double* d, lapack_complex_double* e,\n                          lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_sptsvx( int matrix_order, char fact, lapack_int n,\n                           lapack_int nrhs, const float* d, const float* e,\n                           float* df, float* ef, const float* b, lapack_int ldb,\n                           float* x, lapack_int ldx, float* rcond, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_dptsvx( int matrix_order, char fact, lapack_int n,\n                           lapack_int nrhs, const double* d, const double* e,\n                           double* df, double* ef, const double* b,\n                           lapack_int ldb, double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr );\nlapack_int LAPACKE_cptsvx( int matrix_order, char fact, lapack_int n,\n                           lapack_int nrhs, const float* d,\n                           const lapack_complex_float* e, float* df,\n                           lapack_complex_float* ef,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx,\n                           float* rcond, float* ferr, float* berr );\nlapack_int LAPACKE_zptsvx( int matrix_order, char fact, lapack_int n,\n                           lapack_int nrhs, const double* d,\n                           const lapack_complex_double* e, double* df,\n                           lapack_complex_double* ef,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr );\n\nlapack_int LAPACKE_spttrf( lapack_int n, float* d, float* e );\nlapack_int LAPACKE_dpttrf( lapack_int n, double* d, double* e );\nlapack_int LAPACKE_cpttrf( lapack_int n, float* d, lapack_complex_float* e );\nlapack_int LAPACKE_zpttrf( lapack_int n, double* d, lapack_complex_double* e );\n\nlapack_int LAPACKE_spttrs( int matrix_order, lapack_int n, lapack_int nrhs,\n                           const float* d, const float* e, float* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_dpttrs( int matrix_order, lapack_int n, lapack_int nrhs,\n                           const double* d, const double* e, double* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_cpttrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* d,\n                           const lapack_complex_float* e,\n                           lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zpttrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* d,\n                           const lapack_complex_double* e,\n                           lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_ssbev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_int kd, float* ab, lapack_int ldab, float* w,\n                          float* z, lapack_int ldz );\nlapack_int LAPACKE_dsbev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_int kd, double* ab, lapack_int ldab, double* w,\n                          double* z, lapack_int ldz );\n\nlapack_int LAPACKE_ssbevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_int kd, float* ab, lapack_int ldab, float* w,\n                           float* z, lapack_int ldz );\nlapack_int LAPACKE_dsbevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_int kd, double* ab, lapack_int ldab,\n                           double* w, double* z, lapack_int ldz );\n\nlapack_int LAPACKE_ssbevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_int kd, float* ab,\n                           lapack_int ldab, float* q, lapack_int ldq, float vl,\n                           float vu, lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, float* z, lapack_int ldz,\n                           lapack_int* ifail );\nlapack_int LAPACKE_dsbevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_int kd, double* ab,\n                           lapack_int ldab, double* q, lapack_int ldq,\n                           double vl, double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w, double* z,\n                           lapack_int ldz, lapack_int* ifail );\n\nlapack_int LAPACKE_ssbgst( int matrix_order, char vect, char uplo, lapack_int n,\n                           lapack_int ka, lapack_int kb, float* ab,\n                           lapack_int ldab, const float* bb, lapack_int ldbb,\n                           float* x, lapack_int ldx );\nlapack_int LAPACKE_dsbgst( int matrix_order, char vect, char uplo, lapack_int n,\n                           lapack_int ka, lapack_int kb, double* ab,\n                           lapack_int ldab, const double* bb, lapack_int ldbb,\n                           double* x, lapack_int ldx );\n\nlapack_int LAPACKE_ssbgv( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_int ka, lapack_int kb, float* ab,\n                          lapack_int ldab, float* bb, lapack_int ldbb, float* w,\n                          float* z, lapack_int ldz );\nlapack_int LAPACKE_dsbgv( int matrix_order, char jobz, char uplo, lapack_int n,\n                          lapack_int ka, lapack_int kb, double* ab,\n                          lapack_int ldab, double* bb, lapack_int ldbb,\n                          double* w, double* z, lapack_int ldz );\n\nlapack_int LAPACKE_ssbgvd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_int ka, lapack_int kb, float* ab,\n                           lapack_int ldab, float* bb, lapack_int ldbb,\n                           float* w, float* z, lapack_int ldz );\nlapack_int LAPACKE_dsbgvd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           lapack_int ka, lapack_int kb, double* ab,\n                           lapack_int ldab, double* bb, lapack_int ldbb,\n                           double* w, double* z, lapack_int ldz );\n\nlapack_int LAPACKE_ssbgvx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_int ka, lapack_int kb,\n                           float* ab, lapack_int ldab, float* bb,\n                           lapack_int ldbb, float* q, lapack_int ldq, float vl,\n                           float vu, lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, float* z, lapack_int ldz,\n                           lapack_int* ifail );\nlapack_int LAPACKE_dsbgvx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, lapack_int ka, lapack_int kb,\n                           double* ab, lapack_int ldab, double* bb,\n                           lapack_int ldbb, double* q, lapack_int ldq,\n                           double vl, double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w, double* z,\n                           lapack_int ldz, lapack_int* ifail );\n\nlapack_int LAPACKE_ssbtrd( int matrix_order, char vect, char uplo, lapack_int n,\n                           lapack_int kd, float* ab, lapack_int ldab, float* d,\n                           float* e, float* q, lapack_int ldq );\nlapack_int LAPACKE_dsbtrd( int matrix_order, char vect, char uplo, lapack_int n,\n                           lapack_int kd, double* ab, lapack_int ldab,\n                           double* d, double* e, double* q, lapack_int ldq );\n\nlapack_int LAPACKE_ssfrk( int matrix_order, char transr, char uplo, char trans,\n                          lapack_int n, lapack_int k, float alpha,\n                          const float* a, lapack_int lda, float beta,\n                          float* c );\nlapack_int LAPACKE_dsfrk( int matrix_order, char transr, char uplo, char trans,\n                          lapack_int n, lapack_int k, double alpha,\n                          const double* a, lapack_int lda, double beta,\n                          double* c );\n\nlapack_int LAPACKE_sspcon( int matrix_order, char uplo, lapack_int n,\n                           const float* ap, const lapack_int* ipiv, float anorm,\n                           float* rcond );\nlapack_int LAPACKE_dspcon( int matrix_order, char uplo, lapack_int n,\n                           const double* ap, const lapack_int* ipiv,\n                           double anorm, double* rcond );\nlapack_int LAPACKE_cspcon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_float* ap,\n                           const lapack_int* ipiv, float anorm, float* rcond );\nlapack_int LAPACKE_zspcon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_double* ap,\n                           const lapack_int* ipiv, double anorm,\n                           double* rcond );\n\nlapack_int LAPACKE_sspev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          float* ap, float* w, float* z, lapack_int ldz );\nlapack_int LAPACKE_dspev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          double* ap, double* w, double* z, lapack_int ldz );\n\nlapack_int LAPACKE_sspevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           float* ap, float* w, float* z, lapack_int ldz );\nlapack_int LAPACKE_dspevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           double* ap, double* w, double* z, lapack_int ldz );\n\nlapack_int LAPACKE_sspevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, float* ap, float vl, float vu,\n                           lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, float* z, lapack_int ldz,\n                           lapack_int* ifail );\nlapack_int LAPACKE_dspevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, double* ap, double vl, double vu,\n                           lapack_int il, lapack_int iu, double abstol,\n                           lapack_int* m, double* w, double* z, lapack_int ldz,\n                           lapack_int* ifail );\n\nlapack_int LAPACKE_sspgst( int matrix_order, lapack_int itype, char uplo,\n                           lapack_int n, float* ap, const float* bp );\nlapack_int LAPACKE_dspgst( int matrix_order, lapack_int itype, char uplo,\n                           lapack_int n, double* ap, const double* bp );\n\nlapack_int LAPACKE_sspgv( int matrix_order, lapack_int itype, char jobz,\n                          char uplo, lapack_int n, float* ap, float* bp,\n                          float* w, float* z, lapack_int ldz );\nlapack_int LAPACKE_dspgv( int matrix_order, lapack_int itype, char jobz,\n                          char uplo, lapack_int n, double* ap, double* bp,\n                          double* w, double* z, lapack_int ldz );\n\nlapack_int LAPACKE_sspgvd( int matrix_order, lapack_int itype, char jobz,\n                           char uplo, lapack_int n, float* ap, float* bp,\n                           float* w, float* z, lapack_int ldz );\nlapack_int LAPACKE_dspgvd( int matrix_order, lapack_int itype, char jobz,\n                           char uplo, lapack_int n, double* ap, double* bp,\n                           double* w, double* z, lapack_int ldz );\n\nlapack_int LAPACKE_sspgvx( int matrix_order, lapack_int itype, char jobz,\n                           char range, char uplo, lapack_int n, float* ap,\n                           float* bp, float vl, float vu, lapack_int il,\n                           lapack_int iu, float abstol, lapack_int* m, float* w,\n                           float* z, lapack_int ldz, lapack_int* ifail );\nlapack_int LAPACKE_dspgvx( int matrix_order, lapack_int itype, char jobz,\n                           char range, char uplo, lapack_int n, double* ap,\n                           double* bp, double vl, double vu, lapack_int il,\n                           lapack_int iu, double abstol, lapack_int* m,\n                           double* w, double* z, lapack_int ldz,\n                           lapack_int* ifail );\n\nlapack_int LAPACKE_ssprfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* ap, const float* afp,\n                           const lapack_int* ipiv, const float* b,\n                           lapack_int ldb, float* x, lapack_int ldx,\n                           float* ferr, float* berr );\nlapack_int LAPACKE_dsprfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* ap, const double* afp,\n                           const lapack_int* ipiv, const double* b,\n                           lapack_int ldb, double* x, lapack_int ldx,\n                           double* ferr, double* berr );\nlapack_int LAPACKE_csprfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* ap,\n                           const lapack_complex_float* afp,\n                           const lapack_int* ipiv,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zsprfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* ap,\n                           const lapack_complex_double* afp,\n                           const lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_sspsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, float* ap, lapack_int* ipiv,\n                          float* b, lapack_int ldb );\nlapack_int LAPACKE_dspsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, double* ap, lapack_int* ipiv,\n                          double* b, lapack_int ldb );\nlapack_int LAPACKE_cspsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_float* ap,\n                          lapack_int* ipiv, lapack_complex_float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_zspsv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_double* ap,\n                          lapack_int* ipiv, lapack_complex_double* b,\n                          lapack_int ldb );\n\nlapack_int LAPACKE_sspsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* ap, float* afp,\n                           lapack_int* ipiv, const float* b, lapack_int ldb,\n                           float* x, lapack_int ldx, float* rcond, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_dspsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* ap, double* afp,\n                           lapack_int* ipiv, const double* b, lapack_int ldb,\n                           double* x, lapack_int ldx, double* rcond,\n                           double* ferr, double* berr );\nlapack_int LAPACKE_cspsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* ap,\n                           lapack_complex_float* afp, lapack_int* ipiv,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx,\n                           float* rcond, float* ferr, float* berr );\nlapack_int LAPACKE_zspsvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* ap,\n                           lapack_complex_double* afp, lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr );\n\nlapack_int LAPACKE_ssptrd( int matrix_order, char uplo, lapack_int n, float* ap,\n                           float* d, float* e, float* tau );\nlapack_int LAPACKE_dsptrd( int matrix_order, char uplo, lapack_int n,\n                           double* ap, double* d, double* e, double* tau );\n\nlapack_int LAPACKE_ssptrf( int matrix_order, char uplo, lapack_int n, float* ap,\n                           lapack_int* ipiv );\nlapack_int LAPACKE_dsptrf( int matrix_order, char uplo, lapack_int n,\n                           double* ap, lapack_int* ipiv );\nlapack_int LAPACKE_csptrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* ap, lapack_int* ipiv );\nlapack_int LAPACKE_zsptrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* ap, lapack_int* ipiv );\n\nlapack_int LAPACKE_ssptri( int matrix_order, char uplo, lapack_int n, float* ap,\n                           const lapack_int* ipiv );\nlapack_int LAPACKE_dsptri( int matrix_order, char uplo, lapack_int n,\n                           double* ap, const lapack_int* ipiv );\nlapack_int LAPACKE_csptri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* ap, const lapack_int* ipiv );\nlapack_int LAPACKE_zsptri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* ap, const lapack_int* ipiv );\n\nlapack_int LAPACKE_ssptrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* ap,\n                           const lapack_int* ipiv, float* b, lapack_int ldb );\nlapack_int LAPACKE_dsptrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* ap,\n                           const lapack_int* ipiv, double* b, lapack_int ldb );\nlapack_int LAPACKE_csptrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* ap,\n                           const lapack_int* ipiv, lapack_complex_float* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_zsptrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* ap,\n                           const lapack_int* ipiv, lapack_complex_double* b,\n                           lapack_int ldb );\n\nlapack_int LAPACKE_sstebz( char range, char order, lapack_int n, float vl,\n                           float vu, lapack_int il, lapack_int iu, float abstol,\n                           const float* d, const float* e, lapack_int* m,\n                           lapack_int* nsplit, float* w, lapack_int* iblock,\n                           lapack_int* isplit );\nlapack_int LAPACKE_dstebz( char range, char order, lapack_int n, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, const double* d, const double* e,\n                           lapack_int* m, lapack_int* nsplit, double* w,\n                           lapack_int* iblock, lapack_int* isplit );\n\nlapack_int LAPACKE_sstedc( int matrix_order, char compz, lapack_int n, float* d,\n                           float* e, float* z, lapack_int ldz );\nlapack_int LAPACKE_dstedc( int matrix_order, char compz, lapack_int n,\n                           double* d, double* e, double* z, lapack_int ldz );\nlapack_int LAPACKE_cstedc( int matrix_order, char compz, lapack_int n, float* d,\n                           float* e, lapack_complex_float* z, lapack_int ldz );\nlapack_int LAPACKE_zstedc( int matrix_order, char compz, lapack_int n,\n                           double* d, double* e, lapack_complex_double* z,\n                           lapack_int ldz );\n\nlapack_int LAPACKE_sstegr( int matrix_order, char jobz, char range,\n                           lapack_int n, float* d, float* e, float vl, float vu,\n                           lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, float* z, lapack_int ldz,\n                           lapack_int* isuppz );\nlapack_int LAPACKE_dstegr( int matrix_order, char jobz, char range,\n                           lapack_int n, double* d, double* e, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w, double* z,\n                           lapack_int ldz, lapack_int* isuppz );\nlapack_int LAPACKE_cstegr( int matrix_order, char jobz, char range,\n                           lapack_int n, float* d, float* e, float vl, float vu,\n                           lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, lapack_complex_float* z,\n                           lapack_int ldz, lapack_int* isuppz );\nlapack_int LAPACKE_zstegr( int matrix_order, char jobz, char range,\n                           lapack_int n, double* d, double* e, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w,\n                           lapack_complex_double* z, lapack_int ldz,\n                           lapack_int* isuppz );\n\nlapack_int LAPACKE_sstein( int matrix_order, lapack_int n, const float* d,\n                           const float* e, lapack_int m, const float* w,\n                           const lapack_int* iblock, const lapack_int* isplit,\n                           float* z, lapack_int ldz, lapack_int* ifailv );\nlapack_int LAPACKE_dstein( int matrix_order, lapack_int n, const double* d,\n                           const double* e, lapack_int m, const double* w,\n                           const lapack_int* iblock, const lapack_int* isplit,\n                           double* z, lapack_int ldz, lapack_int* ifailv );\nlapack_int LAPACKE_cstein( int matrix_order, lapack_int n, const float* d,\n                           const float* e, lapack_int m, const float* w,\n                           const lapack_int* iblock, const lapack_int* isplit,\n                           lapack_complex_float* z, lapack_int ldz,\n                           lapack_int* ifailv );\nlapack_int LAPACKE_zstein( int matrix_order, lapack_int n, const double* d,\n                           const double* e, lapack_int m, const double* w,\n                           const lapack_int* iblock, const lapack_int* isplit,\n                           lapack_complex_double* z, lapack_int ldz,\n                           lapack_int* ifailv );\n\nlapack_int LAPACKE_sstemr( int matrix_order, char jobz, char range,\n                           lapack_int n, float* d, float* e, float vl, float vu,\n                           lapack_int il, lapack_int iu, lapack_int* m,\n                           float* w, float* z, lapack_int ldz, lapack_int nzc,\n                           lapack_int* isuppz, lapack_logical* tryrac );\nlapack_int LAPACKE_dstemr( int matrix_order, char jobz, char range,\n                           lapack_int n, double* d, double* e, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           lapack_int* m, double* w, double* z, lapack_int ldz,\n                           lapack_int nzc, lapack_int* isuppz,\n                           lapack_logical* tryrac );\nlapack_int LAPACKE_cstemr( int matrix_order, char jobz, char range,\n                           lapack_int n, float* d, float* e, float vl, float vu,\n                           lapack_int il, lapack_int iu, lapack_int* m,\n                           float* w, lapack_complex_float* z, lapack_int ldz,\n                           lapack_int nzc, lapack_int* isuppz,\n                           lapack_logical* tryrac );\nlapack_int LAPACKE_zstemr( int matrix_order, char jobz, char range,\n                           lapack_int n, double* d, double* e, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           lapack_int* m, double* w, lapack_complex_double* z,\n                           lapack_int ldz, lapack_int nzc, lapack_int* isuppz,\n                           lapack_logical* tryrac );\n\nlapack_int LAPACKE_ssteqr( int matrix_order, char compz, lapack_int n, float* d,\n                           float* e, float* z, lapack_int ldz );\nlapack_int LAPACKE_dsteqr( int matrix_order, char compz, lapack_int n,\n                           double* d, double* e, double* z, lapack_int ldz );\nlapack_int LAPACKE_csteqr( int matrix_order, char compz, lapack_int n, float* d,\n                           float* e, lapack_complex_float* z, lapack_int ldz );\nlapack_int LAPACKE_zsteqr( int matrix_order, char compz, lapack_int n,\n                           double* d, double* e, lapack_complex_double* z,\n                           lapack_int ldz );\n\nlapack_int LAPACKE_ssterf( lapack_int n, float* d, float* e );\nlapack_int LAPACKE_dsterf( lapack_int n, double* d, double* e );\n\nlapack_int LAPACKE_sstev( int matrix_order, char jobz, lapack_int n, float* d,\n                          float* e, float* z, lapack_int ldz );\nlapack_int LAPACKE_dstev( int matrix_order, char jobz, lapack_int n, double* d,\n                          double* e, double* z, lapack_int ldz );\n\nlapack_int LAPACKE_sstevd( int matrix_order, char jobz, lapack_int n, float* d,\n                           float* e, float* z, lapack_int ldz );\nlapack_int LAPACKE_dstevd( int matrix_order, char jobz, lapack_int n, double* d,\n                           double* e, double* z, lapack_int ldz );\n\nlapack_int LAPACKE_sstevr( int matrix_order, char jobz, char range,\n                           lapack_int n, float* d, float* e, float vl, float vu,\n                           lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, float* z, lapack_int ldz,\n                           lapack_int* isuppz );\nlapack_int LAPACKE_dstevr( int matrix_order, char jobz, char range,\n                           lapack_int n, double* d, double* e, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w, double* z,\n                           lapack_int ldz, lapack_int* isuppz );\n\nlapack_int LAPACKE_sstevx( int matrix_order, char jobz, char range,\n                           lapack_int n, float* d, float* e, float vl, float vu,\n                           lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, float* z, lapack_int ldz,\n                           lapack_int* ifail );\nlapack_int LAPACKE_dstevx( int matrix_order, char jobz, char range,\n                           lapack_int n, double* d, double* e, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w, double* z,\n                           lapack_int ldz, lapack_int* ifail );\n\nlapack_int LAPACKE_ssycon( int matrix_order, char uplo, lapack_int n,\n                           const float* a, lapack_int lda,\n                           const lapack_int* ipiv, float anorm, float* rcond );\nlapack_int LAPACKE_dsycon( int matrix_order, char uplo, lapack_int n,\n                           const double* a, lapack_int lda,\n                           const lapack_int* ipiv, double anorm,\n                           double* rcond );\nlapack_int LAPACKE_csycon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_int* ipiv, float anorm, float* rcond );\nlapack_int LAPACKE_zsycon( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_int* ipiv, double anorm,\n                           double* rcond );\n\nlapack_int LAPACKE_ssyequb( int matrix_order, char uplo, lapack_int n,\n                            const float* a, lapack_int lda, float* s,\n                            float* scond, float* amax );\nlapack_int LAPACKE_dsyequb( int matrix_order, char uplo, lapack_int n,\n                            const double* a, lapack_int lda, double* s,\n                            double* scond, double* amax );\nlapack_int LAPACKE_csyequb( int matrix_order, char uplo, lapack_int n,\n                            const lapack_complex_float* a, lapack_int lda,\n                            float* s, float* scond, float* amax );\nlapack_int LAPACKE_zsyequb( int matrix_order, char uplo, lapack_int n,\n                            const lapack_complex_double* a, lapack_int lda,\n                            double* s, double* scond, double* amax );\n\nlapack_int LAPACKE_ssyev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          float* a, lapack_int lda, float* w );\nlapack_int LAPACKE_dsyev( int matrix_order, char jobz, char uplo, lapack_int n,\n                          double* a, lapack_int lda, double* w );\n\nlapack_int LAPACKE_ssyevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           float* a, lapack_int lda, float* w );\nlapack_int LAPACKE_dsyevd( int matrix_order, char jobz, char uplo, lapack_int n,\n                           double* a, lapack_int lda, double* w );\n\nlapack_int LAPACKE_ssyevr( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, float* a, lapack_int lda, float vl,\n                           float vu, lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, float* z, lapack_int ldz,\n                           lapack_int* isuppz );\nlapack_int LAPACKE_dsyevr( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, double* a, lapack_int lda, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w, double* z,\n                           lapack_int ldz, lapack_int* isuppz );\n\nlapack_int LAPACKE_ssyevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, float* a, lapack_int lda, float vl,\n                           float vu, lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, float* z, lapack_int ldz,\n                           lapack_int* ifail );\nlapack_int LAPACKE_dsyevx( int matrix_order, char jobz, char range, char uplo,\n                           lapack_int n, double* a, lapack_int lda, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w, double* z,\n                           lapack_int ldz, lapack_int* ifail );\n\nlapack_int LAPACKE_ssygst( int matrix_order, lapack_int itype, char uplo,\n                           lapack_int n, float* a, lapack_int lda,\n                           const float* b, lapack_int ldb );\nlapack_int LAPACKE_dsygst( int matrix_order, lapack_int itype, char uplo,\n                           lapack_int n, double* a, lapack_int lda,\n                           const double* b, lapack_int ldb );\n\nlapack_int LAPACKE_ssygv( int matrix_order, lapack_int itype, char jobz,\n                          char uplo, lapack_int n, float* a, lapack_int lda,\n                          float* b, lapack_int ldb, float* w );\nlapack_int LAPACKE_dsygv( int matrix_order, lapack_int itype, char jobz,\n                          char uplo, lapack_int n, double* a, lapack_int lda,\n                          double* b, lapack_int ldb, double* w );\n\nlapack_int LAPACKE_ssygvd( int matrix_order, lapack_int itype, char jobz,\n                           char uplo, lapack_int n, float* a, lapack_int lda,\n                           float* b, lapack_int ldb, float* w );\nlapack_int LAPACKE_dsygvd( int matrix_order, lapack_int itype, char jobz,\n                           char uplo, lapack_int n, double* a, lapack_int lda,\n                           double* b, lapack_int ldb, double* w );\n\nlapack_int LAPACKE_ssygvx( int matrix_order, lapack_int itype, char jobz,\n                           char range, char uplo, lapack_int n, float* a,\n                           lapack_int lda, float* b, lapack_int ldb, float vl,\n                           float vu, lapack_int il, lapack_int iu, float abstol,\n                           lapack_int* m, float* w, float* z, lapack_int ldz,\n                           lapack_int* ifail );\nlapack_int LAPACKE_dsygvx( int matrix_order, lapack_int itype, char jobz,\n                           char range, char uplo, lapack_int n, double* a,\n                           lapack_int lda, double* b, lapack_int ldb, double vl,\n                           double vu, lapack_int il, lapack_int iu,\n                           double abstol, lapack_int* m, double* w, double* z,\n                           lapack_int ldz, lapack_int* ifail );\n\nlapack_int LAPACKE_ssyrfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* a, lapack_int lda,\n                           const float* af, lapack_int ldaf,\n                           const lapack_int* ipiv, const float* b,\n                           lapack_int ldb, float* x, lapack_int ldx,\n                           float* ferr, float* berr );\nlapack_int LAPACKE_dsyrfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* a, lapack_int lda,\n                           const double* af, lapack_int ldaf,\n                           const lapack_int* ipiv, const double* b,\n                           lapack_int ldb, double* x, lapack_int ldx,\n                           double* ferr, double* berr );\nlapack_int LAPACKE_csyrfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* af,\n                           lapack_int ldaf, const lapack_int* ipiv,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_zsyrfs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* af,\n                           lapack_int ldaf, const lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_ssyrfsx( int matrix_order, char uplo, char equed,\n                            lapack_int n, lapack_int nrhs, const float* a,\n                            lapack_int lda, const float* af, lapack_int ldaf,\n                            const lapack_int* ipiv, const float* s,\n                            const float* b, lapack_int ldb, float* x,\n                            lapack_int ldx, float* rcond, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_dsyrfsx( int matrix_order, char uplo, char equed,\n                            lapack_int n, lapack_int nrhs, const double* a,\n                            lapack_int lda, const double* af, lapack_int ldaf,\n                            const lapack_int* ipiv, const double* s,\n                            const double* b, lapack_int ldb, double* x,\n                            lapack_int ldx, double* rcond, double* berr,\n                            lapack_int n_err_bnds, double* err_bnds_norm,\n                            double* err_bnds_comp, lapack_int nparams,\n                            double* params );\nlapack_int LAPACKE_csyrfsx( int matrix_order, char uplo, char equed,\n                            lapack_int n, lapack_int nrhs,\n                            const lapack_complex_float* a, lapack_int lda,\n                            const lapack_complex_float* af, lapack_int ldaf,\n                            const lapack_int* ipiv, const float* s,\n                            const lapack_complex_float* b, lapack_int ldb,\n                            lapack_complex_float* x, lapack_int ldx,\n                            float* rcond, float* berr, lapack_int n_err_bnds,\n                            float* err_bnds_norm, float* err_bnds_comp,\n                            lapack_int nparams, float* params );\nlapack_int LAPACKE_zsyrfsx( int matrix_order, char uplo, char equed,\n                            lapack_int n, lapack_int nrhs,\n                            const lapack_complex_double* a, lapack_int lda,\n                            const lapack_complex_double* af, lapack_int ldaf,\n                            const lapack_int* ipiv, const double* s,\n                            const lapack_complex_double* b, lapack_int ldb,\n                            lapack_complex_double* x, lapack_int ldx,\n                            double* rcond, double* berr, lapack_int n_err_bnds,\n                            double* err_bnds_norm, double* err_bnds_comp,\n                            lapack_int nparams, double* params );\n\nlapack_int LAPACKE_ssysv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, float* a, lapack_int lda,\n                          lapack_int* ipiv, float* b, lapack_int ldb );\nlapack_int LAPACKE_dsysv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, double* a, lapack_int lda,\n                          lapack_int* ipiv, double* b, lapack_int ldb );\nlapack_int LAPACKE_csysv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_float* a,\n                          lapack_int lda, lapack_int* ipiv,\n                          lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zsysv( int matrix_order, char uplo, lapack_int n,\n                          lapack_int nrhs, lapack_complex_double* a,\n                          lapack_int lda, lapack_int* ipiv,\n                          lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_ssysvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* a, lapack_int lda,\n                           float* af, lapack_int ldaf, lapack_int* ipiv,\n                           const float* b, lapack_int ldb, float* x,\n                           lapack_int ldx, float* rcond, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_dsysvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* a, lapack_int lda,\n                           double* af, lapack_int ldaf, lapack_int* ipiv,\n                           const double* b, lapack_int ldb, double* x,\n                           lapack_int ldx, double* rcond, double* ferr,\n                           double* berr );\nlapack_int LAPACKE_csysvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* af,\n                           lapack_int ldaf, lapack_int* ipiv,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* x, lapack_int ldx,\n                           float* rcond, float* ferr, float* berr );\nlapack_int LAPACKE_zsysvx( int matrix_order, char fact, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* af,\n                           lapack_int ldaf, lapack_int* ipiv,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* x, lapack_int ldx,\n                           double* rcond, double* ferr, double* berr );\n\nlapack_int LAPACKE_ssysvxx( int matrix_order, char fact, char uplo,\n                            lapack_int n, lapack_int nrhs, float* a,\n                            lapack_int lda, float* af, lapack_int ldaf,\n                            lapack_int* ipiv, char* equed, float* s, float* b,\n                            lapack_int ldb, float* x, lapack_int ldx,\n                            float* rcond, float* rpvgrw, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_dsysvxx( int matrix_order, char fact, char uplo,\n                            lapack_int n, lapack_int nrhs, double* a,\n                            lapack_int lda, double* af, lapack_int ldaf,\n                            lapack_int* ipiv, char* equed, double* s, double* b,\n                            lapack_int ldb, double* x, lapack_int ldx,\n                            double* rcond, double* rpvgrw, double* berr,\n                            lapack_int n_err_bnds, double* err_bnds_norm,\n                            double* err_bnds_comp, lapack_int nparams,\n                            double* params );\nlapack_int LAPACKE_csysvxx( int matrix_order, char fact, char uplo,\n                            lapack_int n, lapack_int nrhs,\n                            lapack_complex_float* a, lapack_int lda,\n                            lapack_complex_float* af, lapack_int ldaf,\n                            lapack_int* ipiv, char* equed, float* s,\n                            lapack_complex_float* b, lapack_int ldb,\n                            lapack_complex_float* x, lapack_int ldx,\n                            float* rcond, float* rpvgrw, float* berr,\n                            lapack_int n_err_bnds, float* err_bnds_norm,\n                            float* err_bnds_comp, lapack_int nparams,\n                            float* params );\nlapack_int LAPACKE_zsysvxx( int matrix_order, char fact, char uplo,\n                            lapack_int n, lapack_int nrhs,\n                            lapack_complex_double* a, lapack_int lda,\n                            lapack_complex_double* af, lapack_int ldaf,\n                            lapack_int* ipiv, char* equed, double* s,\n                            lapack_complex_double* b, lapack_int ldb,\n                            lapack_complex_double* x, lapack_int ldx,\n                            double* rcond, double* rpvgrw, double* berr,\n                            lapack_int n_err_bnds, double* err_bnds_norm,\n                            double* err_bnds_comp, lapack_int nparams,\n                            double* params );\n\nlapack_int LAPACKE_ssytrd( int matrix_order, char uplo, lapack_int n, float* a,\n                           lapack_int lda, float* d, float* e, float* tau );\nlapack_int LAPACKE_dsytrd( int matrix_order, char uplo, lapack_int n, double* a,\n                           lapack_int lda, double* d, double* e, double* tau );\n\nlapack_int LAPACKE_ssytrf( int matrix_order, char uplo, lapack_int n, float* a,\n                           lapack_int lda, lapack_int* ipiv );\nlapack_int LAPACKE_dsytrf( int matrix_order, char uplo, lapack_int n, double* a,\n                           lapack_int lda, lapack_int* ipiv );\nlapack_int LAPACKE_csytrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_int* ipiv );\nlapack_int LAPACKE_zsytrf( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_int* ipiv );\n\nlapack_int LAPACKE_ssytri( int matrix_order, char uplo, lapack_int n, float* a,\n                           lapack_int lda, const lapack_int* ipiv );\nlapack_int LAPACKE_dsytri( int matrix_order, char uplo, lapack_int n, double* a,\n                           lapack_int lda, const lapack_int* ipiv );\nlapack_int LAPACKE_csytri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           const lapack_int* ipiv );\nlapack_int LAPACKE_zsytri( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           const lapack_int* ipiv );\n\nlapack_int LAPACKE_ssytrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const float* a, lapack_int lda,\n                           const lapack_int* ipiv, float* b, lapack_int ldb );\nlapack_int LAPACKE_dsytrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const double* a, lapack_int lda,\n                           const lapack_int* ipiv, double* b, lapack_int ldb );\nlapack_int LAPACKE_csytrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_float* a,\n                           lapack_int lda, const lapack_int* ipiv,\n                           lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zsytrs( int matrix_order, char uplo, lapack_int n,\n                           lapack_int nrhs, const lapack_complex_double* a,\n                           lapack_int lda, const lapack_int* ipiv,\n                           lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_stbcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, lapack_int kd, const float* ab,\n                           lapack_int ldab, float* rcond );\nlapack_int LAPACKE_dtbcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, lapack_int kd, const double* ab,\n                           lapack_int ldab, double* rcond );\nlapack_int LAPACKE_ctbcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, lapack_int kd,\n                           const lapack_complex_float* ab, lapack_int ldab,\n                           float* rcond );\nlapack_int LAPACKE_ztbcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, lapack_int kd,\n                           const lapack_complex_double* ab, lapack_int ldab,\n                           double* rcond );\n\nlapack_int LAPACKE_stbrfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int kd, lapack_int nrhs,\n                           const float* ab, lapack_int ldab, const float* b,\n                           lapack_int ldb, const float* x, lapack_int ldx,\n                           float* ferr, float* berr );\nlapack_int LAPACKE_dtbrfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int kd, lapack_int nrhs,\n                           const double* ab, lapack_int ldab, const double* b,\n                           lapack_int ldb, const double* x, lapack_int ldx,\n                           double* ferr, double* berr );\nlapack_int LAPACKE_ctbrfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int kd, lapack_int nrhs,\n                           const lapack_complex_float* ab, lapack_int ldab,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           const lapack_complex_float* x, lapack_int ldx,\n                           float* ferr, float* berr );\nlapack_int LAPACKE_ztbrfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int kd, lapack_int nrhs,\n                           const lapack_complex_double* ab, lapack_int ldab,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           const lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_stbtrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int kd, lapack_int nrhs,\n                           const float* ab, lapack_int ldab, float* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_dtbtrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int kd, lapack_int nrhs,\n                           const double* ab, lapack_int ldab, double* b,\n                           lapack_int ldb );\nlapack_int LAPACKE_ctbtrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int kd, lapack_int nrhs,\n                           const lapack_complex_float* ab, lapack_int ldab,\n                           lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_ztbtrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int kd, lapack_int nrhs,\n                           const lapack_complex_double* ab, lapack_int ldab,\n                           lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_stfsm( int matrix_order, char transr, char side, char uplo,\n                          char trans, char diag, lapack_int m, lapack_int n,\n                          float alpha, const float* a, float* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_dtfsm( int matrix_order, char transr, char side, char uplo,\n                          char trans, char diag, lapack_int m, lapack_int n,\n                          double alpha, const double* a, double* b,\n                          lapack_int ldb );\nlapack_int LAPACKE_ctfsm( int matrix_order, char transr, char side, char uplo,\n                          char trans, char diag, lapack_int m, lapack_int n,\n                          lapack_complex_float alpha,\n                          const lapack_complex_float* a,\n                          lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_ztfsm( int matrix_order, char transr, char side, char uplo,\n                          char trans, char diag, lapack_int m, lapack_int n,\n                          lapack_complex_double alpha,\n                          const lapack_complex_double* a,\n                          lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_stftri( int matrix_order, char transr, char uplo, char diag,\n                           lapack_int n, float* a );\nlapack_int LAPACKE_dtftri( int matrix_order, char transr, char uplo, char diag,\n                           lapack_int n, double* a );\nlapack_int LAPACKE_ctftri( int matrix_order, char transr, char uplo, char diag,\n                           lapack_int n, lapack_complex_float* a );\nlapack_int LAPACKE_ztftri( int matrix_order, char transr, char uplo, char diag,\n                           lapack_int n, lapack_complex_double* a );\n\nlapack_int LAPACKE_stfttp( int matrix_order, char transr, char uplo,\n                           lapack_int n, const float* arf, float* ap );\nlapack_int LAPACKE_dtfttp( int matrix_order, char transr, char uplo,\n                           lapack_int n, const double* arf, double* ap );\nlapack_int LAPACKE_ctfttp( int matrix_order, char transr, char uplo,\n                           lapack_int n, const lapack_complex_float* arf,\n                           lapack_complex_float* ap );\nlapack_int LAPACKE_ztfttp( int matrix_order, char transr, char uplo,\n                           lapack_int n, const lapack_complex_double* arf,\n                           lapack_complex_double* ap );\n\nlapack_int LAPACKE_stfttr( int matrix_order, char transr, char uplo,\n                           lapack_int n, const float* arf, float* a,\n                           lapack_int lda );\nlapack_int LAPACKE_dtfttr( int matrix_order, char transr, char uplo,\n                           lapack_int n, const double* arf, double* a,\n                           lapack_int lda );\nlapack_int LAPACKE_ctfttr( int matrix_order, char transr, char uplo,\n                           lapack_int n, const lapack_complex_float* arf,\n                           lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_ztfttr( int matrix_order, char transr, char uplo,\n                           lapack_int n, const lapack_complex_double* arf,\n                           lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_stgevc( int matrix_order, char side, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const float* s, lapack_int lds, const float* p,\n                           lapack_int ldp, float* vl, lapack_int ldvl,\n                           float* vr, lapack_int ldvr, lapack_int mm,\n                           lapack_int* m );\nlapack_int LAPACKE_dtgevc( int matrix_order, char side, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const double* s, lapack_int lds, const double* p,\n                           lapack_int ldp, double* vl, lapack_int ldvl,\n                           double* vr, lapack_int ldvr, lapack_int mm,\n                           lapack_int* m );\nlapack_int LAPACKE_ctgevc( int matrix_order, char side, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const lapack_complex_float* s, lapack_int lds,\n                           const lapack_complex_float* p, lapack_int ldp,\n                           lapack_complex_float* vl, lapack_int ldvl,\n                           lapack_complex_float* vr, lapack_int ldvr,\n                           lapack_int mm, lapack_int* m );\nlapack_int LAPACKE_ztgevc( int matrix_order, char side, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const lapack_complex_double* s, lapack_int lds,\n                           const lapack_complex_double* p, lapack_int ldp,\n                           lapack_complex_double* vl, lapack_int ldvl,\n                           lapack_complex_double* vr, lapack_int ldvr,\n                           lapack_int mm, lapack_int* m );\n\nlapack_int LAPACKE_stgexc( int matrix_order, lapack_logical wantq,\n                           lapack_logical wantz, lapack_int n, float* a,\n                           lapack_int lda, float* b, lapack_int ldb, float* q,\n                           lapack_int ldq, float* z, lapack_int ldz,\n                           lapack_int* ifst, lapack_int* ilst );\nlapack_int LAPACKE_dtgexc( int matrix_order, lapack_logical wantq,\n                           lapack_logical wantz, lapack_int n, double* a,\n                           lapack_int lda, double* b, lapack_int ldb, double* q,\n                           lapack_int ldq, double* z, lapack_int ldz,\n                           lapack_int* ifst, lapack_int* ilst );\nlapack_int LAPACKE_ctgexc( int matrix_order, lapack_logical wantq,\n                           lapack_logical wantz, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* q, lapack_int ldq,\n                           lapack_complex_float* z, lapack_int ldz,\n                           lapack_int ifst, lapack_int ilst );\nlapack_int LAPACKE_ztgexc( int matrix_order, lapack_logical wantq,\n                           lapack_logical wantz, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* q, lapack_int ldq,\n                           lapack_complex_double* z, lapack_int ldz,\n                           lapack_int ifst, lapack_int ilst );\n\nlapack_int LAPACKE_stgsen( int matrix_order, lapack_int ijob,\n                           lapack_logical wantq, lapack_logical wantz,\n                           const lapack_logical* select, lapack_int n, float* a,\n                           lapack_int lda, float* b, lapack_int ldb,\n                           float* alphar, float* alphai, float* beta, float* q,\n                           lapack_int ldq, float* z, lapack_int ldz,\n                           lapack_int* m, float* pl, float* pr, float* dif );\nlapack_int LAPACKE_dtgsen( int matrix_order, lapack_int ijob,\n                           lapack_logical wantq, lapack_logical wantz,\n                           const lapack_logical* select, lapack_int n,\n                           double* a, lapack_int lda, double* b, lapack_int ldb,\n                           double* alphar, double* alphai, double* beta,\n                           double* q, lapack_int ldq, double* z, lapack_int ldz,\n                           lapack_int* m, double* pl, double* pr, double* dif );\nlapack_int LAPACKE_ctgsen( int matrix_order, lapack_int ijob,\n                           lapack_logical wantq, lapack_logical wantz,\n                           const lapack_logical* select, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* alpha,\n                           lapack_complex_float* beta, lapack_complex_float* q,\n                           lapack_int ldq, lapack_complex_float* z,\n                           lapack_int ldz, lapack_int* m, float* pl, float* pr,\n                           float* dif );\nlapack_int LAPACKE_ztgsen( int matrix_order, lapack_int ijob,\n                           lapack_logical wantq, lapack_logical wantz,\n                           const lapack_logical* select, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* alpha,\n                           lapack_complex_double* beta,\n                           lapack_complex_double* q, lapack_int ldq,\n                           lapack_complex_double* z, lapack_int ldz,\n                           lapack_int* m, double* pl, double* pr, double* dif );\n\nlapack_int LAPACKE_stgsja( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int p, lapack_int n,\n                           lapack_int k, lapack_int l, float* a, lapack_int lda,\n                           float* b, lapack_int ldb, float tola, float tolb,\n                           float* alpha, float* beta, float* u, lapack_int ldu,\n                           float* v, lapack_int ldv, float* q, lapack_int ldq,\n                           lapack_int* ncycle );\nlapack_int LAPACKE_dtgsja( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int p, lapack_int n,\n                           lapack_int k, lapack_int l, double* a,\n                           lapack_int lda, double* b, lapack_int ldb,\n                           double tola, double tolb, double* alpha,\n                           double* beta, double* u, lapack_int ldu, double* v,\n                           lapack_int ldv, double* q, lapack_int ldq,\n                           lapack_int* ncycle );\nlapack_int LAPACKE_ctgsja( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int p, lapack_int n,\n                           lapack_int k, lapack_int l, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* b,\n                           lapack_int ldb, float tola, float tolb, float* alpha,\n                           float* beta, lapack_complex_float* u, lapack_int ldu,\n                           lapack_complex_float* v, lapack_int ldv,\n                           lapack_complex_float* q, lapack_int ldq,\n                           lapack_int* ncycle );\nlapack_int LAPACKE_ztgsja( int matrix_order, char jobu, char jobv, char jobq,\n                           lapack_int m, lapack_int p, lapack_int n,\n                           lapack_int k, lapack_int l, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* b,\n                           lapack_int ldb, double tola, double tolb,\n                           double* alpha, double* beta,\n                           lapack_complex_double* u, lapack_int ldu,\n                           lapack_complex_double* v, lapack_int ldv,\n                           lapack_complex_double* q, lapack_int ldq,\n                           lapack_int* ncycle );\n\nlapack_int LAPACKE_stgsna( int matrix_order, char job, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const float* a, lapack_int lda, const float* b,\n                           lapack_int ldb, const float* vl, lapack_int ldvl,\n                           const float* vr, lapack_int ldvr, float* s,\n                           float* dif, lapack_int mm, lapack_int* m );\nlapack_int LAPACKE_dtgsna( int matrix_order, char job, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const double* a, lapack_int lda, const double* b,\n                           lapack_int ldb, const double* vl, lapack_int ldvl,\n                           const double* vr, lapack_int ldvr, double* s,\n                           double* dif, lapack_int mm, lapack_int* m );\nlapack_int LAPACKE_ctgsna( int matrix_order, char job, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           const lapack_complex_float* vl, lapack_int ldvl,\n                           const lapack_complex_float* vr, lapack_int ldvr,\n                           float* s, float* dif, lapack_int mm, lapack_int* m );\nlapack_int LAPACKE_ztgsna( int matrix_order, char job, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           const lapack_complex_double* vl, lapack_int ldvl,\n                           const lapack_complex_double* vr, lapack_int ldvr,\n                           double* s, double* dif, lapack_int mm,\n                           lapack_int* m );\n\nlapack_int LAPACKE_stgsyl( int matrix_order, char trans, lapack_int ijob,\n                           lapack_int m, lapack_int n, const float* a,\n                           lapack_int lda, const float* b, lapack_int ldb,\n                           float* c, lapack_int ldc, const float* d,\n                           lapack_int ldd, const float* e, lapack_int lde,\n                           float* f, lapack_int ldf, float* scale, float* dif );\nlapack_int LAPACKE_dtgsyl( int matrix_order, char trans, lapack_int ijob,\n                           lapack_int m, lapack_int n, const double* a,\n                           lapack_int lda, const double* b, lapack_int ldb,\n                           double* c, lapack_int ldc, const double* d,\n                           lapack_int ldd, const double* e, lapack_int lde,\n                           double* f, lapack_int ldf, double* scale,\n                           double* dif );\nlapack_int LAPACKE_ctgsyl( int matrix_order, char trans, lapack_int ijob,\n                           lapack_int m, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* c, lapack_int ldc,\n                           const lapack_complex_float* d, lapack_int ldd,\n                           const lapack_complex_float* e, lapack_int lde,\n                           lapack_complex_float* f, lapack_int ldf,\n                           float* scale, float* dif );\nlapack_int LAPACKE_ztgsyl( int matrix_order, char trans, lapack_int ijob,\n                           lapack_int m, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* c, lapack_int ldc,\n                           const lapack_complex_double* d, lapack_int ldd,\n                           const lapack_complex_double* e, lapack_int lde,\n                           lapack_complex_double* f, lapack_int ldf,\n                           double* scale, double* dif );\n\nlapack_int LAPACKE_stpcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, const float* ap, float* rcond );\nlapack_int LAPACKE_dtpcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, const double* ap, double* rcond );\nlapack_int LAPACKE_ctpcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, const lapack_complex_float* ap,\n                           float* rcond );\nlapack_int LAPACKE_ztpcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, const lapack_complex_double* ap,\n                           double* rcond );\n\nlapack_int LAPACKE_stprfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs, const float* ap,\n                           const float* b, lapack_int ldb, const float* x,\n                           lapack_int ldx, float* ferr, float* berr );\nlapack_int LAPACKE_dtprfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs, const double* ap,\n                           const double* b, lapack_int ldb, const double* x,\n                           lapack_int ldx, double* ferr, double* berr );\nlapack_int LAPACKE_ctprfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_float* ap,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           const lapack_complex_float* x, lapack_int ldx,\n                           float* ferr, float* berr );\nlapack_int LAPACKE_ztprfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_double* ap,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           const lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_stptri( int matrix_order, char uplo, char diag, lapack_int n,\n                           float* ap );\nlapack_int LAPACKE_dtptri( int matrix_order, char uplo, char diag, lapack_int n,\n                           double* ap );\nlapack_int LAPACKE_ctptri( int matrix_order, char uplo, char diag, lapack_int n,\n                           lapack_complex_float* ap );\nlapack_int LAPACKE_ztptri( int matrix_order, char uplo, char diag, lapack_int n,\n                           lapack_complex_double* ap );\n\nlapack_int LAPACKE_stptrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs, const float* ap,\n                           float* b, lapack_int ldb );\nlapack_int LAPACKE_dtptrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs, const double* ap,\n                           double* b, lapack_int ldb );\nlapack_int LAPACKE_ctptrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_float* ap,\n                           lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_ztptrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_double* ap,\n                           lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_stpttf( int matrix_order, char transr, char uplo,\n                           lapack_int n, const float* ap, float* arf );\nlapack_int LAPACKE_dtpttf( int matrix_order, char transr, char uplo,\n                           lapack_int n, const double* ap, double* arf );\nlapack_int LAPACKE_ctpttf( int matrix_order, char transr, char uplo,\n                           lapack_int n, const lapack_complex_float* ap,\n                           lapack_complex_float* arf );\nlapack_int LAPACKE_ztpttf( int matrix_order, char transr, char uplo,\n                           lapack_int n, const lapack_complex_double* ap,\n                           lapack_complex_double* arf );\n\nlapack_int LAPACKE_stpttr( int matrix_order, char uplo, lapack_int n,\n                           const float* ap, float* a, lapack_int lda );\nlapack_int LAPACKE_dtpttr( int matrix_order, char uplo, lapack_int n,\n                           const double* ap, double* a, lapack_int lda );\nlapack_int LAPACKE_ctpttr( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_float* ap,\n                           lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_ztpttr( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_double* ap,\n                           lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_strcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, const float* a, lapack_int lda,\n                           float* rcond );\nlapack_int LAPACKE_dtrcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, const double* a, lapack_int lda,\n                           double* rcond );\nlapack_int LAPACKE_ctrcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, const lapack_complex_float* a,\n                           lapack_int lda, float* rcond );\nlapack_int LAPACKE_ztrcon( int matrix_order, char norm, char uplo, char diag,\n                           lapack_int n, const lapack_complex_double* a,\n                           lapack_int lda, double* rcond );\n\nlapack_int LAPACKE_strevc( int matrix_order, char side, char howmny,\n                           lapack_logical* select, lapack_int n, const float* t,\n                           lapack_int ldt, float* vl, lapack_int ldvl,\n                           float* vr, lapack_int ldvr, lapack_int mm,\n                           lapack_int* m );\nlapack_int LAPACKE_dtrevc( int matrix_order, char side, char howmny,\n                           lapack_logical* select, lapack_int n,\n                           const double* t, lapack_int ldt, double* vl,\n                           lapack_int ldvl, double* vr, lapack_int ldvr,\n                           lapack_int mm, lapack_int* m );\nlapack_int LAPACKE_ctrevc( int matrix_order, char side, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           lapack_complex_float* t, lapack_int ldt,\n                           lapack_complex_float* vl, lapack_int ldvl,\n                           lapack_complex_float* vr, lapack_int ldvr,\n                           lapack_int mm, lapack_int* m );\nlapack_int LAPACKE_ztrevc( int matrix_order, char side, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           lapack_complex_double* t, lapack_int ldt,\n                           lapack_complex_double* vl, lapack_int ldvl,\n                           lapack_complex_double* vr, lapack_int ldvr,\n                           lapack_int mm, lapack_int* m );\n\nlapack_int LAPACKE_strexc( int matrix_order, char compq, lapack_int n, float* t,\n                           lapack_int ldt, float* q, lapack_int ldq,\n                           lapack_int* ifst, lapack_int* ilst );\nlapack_int LAPACKE_dtrexc( int matrix_order, char compq, lapack_int n,\n                           double* t, lapack_int ldt, double* q, lapack_int ldq,\n                           lapack_int* ifst, lapack_int* ilst );\nlapack_int LAPACKE_ctrexc( int matrix_order, char compq, lapack_int n,\n                           lapack_complex_float* t, lapack_int ldt,\n                           lapack_complex_float* q, lapack_int ldq,\n                           lapack_int ifst, lapack_int ilst );\nlapack_int LAPACKE_ztrexc( int matrix_order, char compq, lapack_int n,\n                           lapack_complex_double* t, lapack_int ldt,\n                           lapack_complex_double* q, lapack_int ldq,\n                           lapack_int ifst, lapack_int ilst );\n\nlapack_int LAPACKE_strrfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs, const float* a,\n                           lapack_int lda, const float* b, lapack_int ldb,\n                           const float* x, lapack_int ldx, float* ferr,\n                           float* berr );\nlapack_int LAPACKE_dtrrfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs, const double* a,\n                           lapack_int lda, const double* b, lapack_int ldb,\n                           const double* x, lapack_int ldx, double* ferr,\n                           double* berr );\nlapack_int LAPACKE_ctrrfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           const lapack_complex_float* x, lapack_int ldx,\n                           float* ferr, float* berr );\nlapack_int LAPACKE_ztrrfs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           const lapack_complex_double* x, lapack_int ldx,\n                           double* ferr, double* berr );\n\nlapack_int LAPACKE_strsen( int matrix_order, char job, char compq,\n                           const lapack_logical* select, lapack_int n, float* t,\n                           lapack_int ldt, float* q, lapack_int ldq, float* wr,\n                           float* wi, lapack_int* m, float* s, float* sep );\nlapack_int LAPACKE_dtrsen( int matrix_order, char job, char compq,\n                           const lapack_logical* select, lapack_int n,\n                           double* t, lapack_int ldt, double* q, lapack_int ldq,\n                           double* wr, double* wi, lapack_int* m, double* s,\n                           double* sep );\nlapack_int LAPACKE_ctrsen( int matrix_order, char job, char compq,\n                           const lapack_logical* select, lapack_int n,\n                           lapack_complex_float* t, lapack_int ldt,\n                           lapack_complex_float* q, lapack_int ldq,\n                           lapack_complex_float* w, lapack_int* m, float* s,\n                           float* sep );\nlapack_int LAPACKE_ztrsen( int matrix_order, char job, char compq,\n                           const lapack_logical* select, lapack_int n,\n                           lapack_complex_double* t, lapack_int ldt,\n                           lapack_complex_double* q, lapack_int ldq,\n                           lapack_complex_double* w, lapack_int* m, double* s,\n                           double* sep );\n\nlapack_int LAPACKE_strsna( int matrix_order, char job, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const float* t, lapack_int ldt, const float* vl,\n                           lapack_int ldvl, const float* vr, lapack_int ldvr,\n                           float* s, float* sep, lapack_int mm, lapack_int* m );\nlapack_int LAPACKE_dtrsna( int matrix_order, char job, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const double* t, lapack_int ldt, const double* vl,\n                           lapack_int ldvl, const double* vr, lapack_int ldvr,\n                           double* s, double* sep, lapack_int mm,\n                           lapack_int* m );\nlapack_int LAPACKE_ctrsna( int matrix_order, char job, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const lapack_complex_float* t, lapack_int ldt,\n                           const lapack_complex_float* vl, lapack_int ldvl,\n                           const lapack_complex_float* vr, lapack_int ldvr,\n                           float* s, float* sep, lapack_int mm, lapack_int* m );\nlapack_int LAPACKE_ztrsna( int matrix_order, char job, char howmny,\n                           const lapack_logical* select, lapack_int n,\n                           const lapack_complex_double* t, lapack_int ldt,\n                           const lapack_complex_double* vl, lapack_int ldvl,\n                           const lapack_complex_double* vr, lapack_int ldvr,\n                           double* s, double* sep, lapack_int mm,\n                           lapack_int* m );\n\nlapack_int LAPACKE_strsyl( int matrix_order, char trana, char tranb,\n                           lapack_int isgn, lapack_int m, lapack_int n,\n                           const float* a, lapack_int lda, const float* b,\n                           lapack_int ldb, float* c, lapack_int ldc,\n                           float* scale );\nlapack_int LAPACKE_dtrsyl( int matrix_order, char trana, char tranb,\n                           lapack_int isgn, lapack_int m, lapack_int n,\n                           const double* a, lapack_int lda, const double* b,\n                           lapack_int ldb, double* c, lapack_int ldc,\n                           double* scale );\nlapack_int LAPACKE_ctrsyl( int matrix_order, char trana, char tranb,\n                           lapack_int isgn, lapack_int m, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_complex_float* b, lapack_int ldb,\n                           lapack_complex_float* c, lapack_int ldc,\n                           float* scale );\nlapack_int LAPACKE_ztrsyl( int matrix_order, char trana, char tranb,\n                           lapack_int isgn, lapack_int m, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* c, lapack_int ldc,\n                           double* scale );\n\nlapack_int LAPACKE_strtri( int matrix_order, char uplo, char diag, lapack_int n,\n                           float* a, lapack_int lda );\nlapack_int LAPACKE_dtrtri( int matrix_order, char uplo, char diag, lapack_int n,\n                           double* a, lapack_int lda );\nlapack_int LAPACKE_ctrtri( int matrix_order, char uplo, char diag, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_ztrtri( int matrix_order, char uplo, char diag, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_strtrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs, const float* a,\n                           lapack_int lda, float* b, lapack_int ldb );\nlapack_int LAPACKE_dtrtrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs, const double* a,\n                           lapack_int lda, double* b, lapack_int ldb );\nlapack_int LAPACKE_ctrtrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_ztrtrs( int matrix_order, char uplo, char trans, char diag,\n                           lapack_int n, lapack_int nrhs,\n                           const lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_strttf( int matrix_order, char transr, char uplo,\n                           lapack_int n, const float* a, lapack_int lda,\n                           float* arf );\nlapack_int LAPACKE_dtrttf( int matrix_order, char transr, char uplo,\n                           lapack_int n, const double* a, lapack_int lda,\n                           double* arf );\nlapack_int LAPACKE_ctrttf( int matrix_order, char transr, char uplo,\n                           lapack_int n, const lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* arf );\nlapack_int LAPACKE_ztrttf( int matrix_order, char transr, char uplo,\n                           lapack_int n, const lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* arf );\n\nlapack_int LAPACKE_strttp( int matrix_order, char uplo, lapack_int n,\n                           const float* a, lapack_int lda, float* ap );\nlapack_int LAPACKE_dtrttp( int matrix_order, char uplo, lapack_int n,\n                           const double* a, lapack_int lda, double* ap );\nlapack_int LAPACKE_ctrttp( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* ap );\nlapack_int LAPACKE_ztrttp( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* ap );\n\nlapack_int LAPACKE_stzrzf( int matrix_order, lapack_int m, lapack_int n,\n                           float* a, lapack_int lda, float* tau );\nlapack_int LAPACKE_dtzrzf( int matrix_order, lapack_int m, lapack_int n,\n                           double* a, lapack_int lda, double* tau );\nlapack_int LAPACKE_ctzrzf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* tau );\nlapack_int LAPACKE_ztzrzf( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* tau );\n\nlapack_int LAPACKE_cungbr( int matrix_order, char vect, lapack_int m,\n                           lapack_int n, lapack_int k, lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* tau );\nlapack_int LAPACKE_zungbr( int matrix_order, char vect, lapack_int m,\n                           lapack_int n, lapack_int k, lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* tau );\n\nlapack_int LAPACKE_cunghr( int matrix_order, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* tau );\nlapack_int LAPACKE_zunghr( int matrix_order, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* tau );\n\nlapack_int LAPACKE_cunglq( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* tau );\nlapack_int LAPACKE_zunglq( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* tau );\n\nlapack_int LAPACKE_cungql( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* tau );\nlapack_int LAPACKE_zungql( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* tau );\n\nlapack_int LAPACKE_cungqr( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* tau );\nlapack_int LAPACKE_zungqr( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* tau );\n\nlapack_int LAPACKE_cungrq( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* tau );\nlapack_int LAPACKE_zungrq( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* tau );\n\nlapack_int LAPACKE_cungtr( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_float* a, lapack_int lda,\n                           const lapack_complex_float* tau );\nlapack_int LAPACKE_zungtr( int matrix_order, char uplo, lapack_int n,\n                           lapack_complex_double* a, lapack_int lda,\n                           const lapack_complex_double* tau );\n\nlapack_int LAPACKE_cunmbr( int matrix_order, char vect, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_complex_float* tau,\n                           lapack_complex_float* c, lapack_int ldc );\nlapack_int LAPACKE_zunmbr( int matrix_order, char vect, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_complex_double* tau,\n                           lapack_complex_double* c, lapack_int ldc );\n\nlapack_int LAPACKE_cunmhr( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, const lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* tau,\n                           lapack_complex_float* c, lapack_int ldc );\nlapack_int LAPACKE_zunmhr( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int ilo,\n                           lapack_int ihi, const lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* tau,\n                           lapack_complex_double* c, lapack_int ldc );\n\nlapack_int LAPACKE_cunmlq( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_complex_float* tau,\n                           lapack_complex_float* c, lapack_int ldc );\nlapack_int LAPACKE_zunmlq( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_complex_double* tau,\n                           lapack_complex_double* c, lapack_int ldc );\n\nlapack_int LAPACKE_cunmql( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_complex_float* tau,\n                           lapack_complex_float* c, lapack_int ldc );\nlapack_int LAPACKE_zunmql( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_complex_double* tau,\n                           lapack_complex_double* c, lapack_int ldc );\n\nlapack_int LAPACKE_cunmqr( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_complex_float* tau,\n                           lapack_complex_float* c, lapack_int ldc );\nlapack_int LAPACKE_zunmqr( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_complex_double* tau,\n                           lapack_complex_double* c, lapack_int ldc );\n\nlapack_int LAPACKE_cunmrq( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_complex_float* tau,\n                           lapack_complex_float* c, lapack_int ldc );\nlapack_int LAPACKE_zunmrq( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_complex_double* tau,\n                           lapack_complex_double* c, lapack_int ldc );\n\nlapack_int LAPACKE_cunmrz( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           lapack_int l, const lapack_complex_float* a,\n                           lapack_int lda, const lapack_complex_float* tau,\n                           lapack_complex_float* c, lapack_int ldc );\nlapack_int LAPACKE_zunmrz( int matrix_order, char side, char trans,\n                           lapack_int m, lapack_int n, lapack_int k,\n                           lapack_int l, const lapack_complex_double* a,\n                           lapack_int lda, const lapack_complex_double* tau,\n                           lapack_complex_double* c, lapack_int ldc );\n\nlapack_int LAPACKE_cunmtr( int matrix_order, char side, char uplo, char trans,\n                           lapack_int m, lapack_int n,\n                           const lapack_complex_float* a, lapack_int lda,\n                           const lapack_complex_float* tau,\n                           lapack_complex_float* c, lapack_int ldc );\nlapack_int LAPACKE_zunmtr( int matrix_order, char side, char uplo, char trans,\n                           lapack_int m, lapack_int n,\n                           const lapack_complex_double* a, lapack_int lda,\n                           const lapack_complex_double* tau,\n                           lapack_complex_double* c, lapack_int ldc );\n\nlapack_int LAPACKE_cupgtr( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_float* ap,\n                           const lapack_complex_float* tau,\n                           lapack_complex_float* q, lapack_int ldq );\nlapack_int LAPACKE_zupgtr( int matrix_order, char uplo, lapack_int n,\n                           const lapack_complex_double* ap,\n                           const lapack_complex_double* tau,\n                           lapack_complex_double* q, lapack_int ldq );\n\nlapack_int LAPACKE_cupmtr( int matrix_order, char side, char uplo, char trans,\n                           lapack_int m, lapack_int n,\n                           const lapack_complex_float* ap,\n                           const lapack_complex_float* tau,\n                           lapack_complex_float* c, lapack_int ldc );\nlapack_int LAPACKE_zupmtr( int matrix_order, char side, char uplo, char trans,\n                           lapack_int m, lapack_int n,\n                           const lapack_complex_double* ap,\n                           const lapack_complex_double* tau,\n                           lapack_complex_double* c, lapack_int ldc );\n\nlapack_int LAPACKE_sbdsdc_work( int matrix_order, char uplo, char compq,\n                                lapack_int n, float* d, float* e, float* u,\n                                lapack_int ldu, float* vt, lapack_int ldvt,\n                                float* q, lapack_int* iq, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dbdsdc_work( int matrix_order, char uplo, char compq,\n                                lapack_int n, double* d, double* e, double* u,\n                                lapack_int ldu, double* vt, lapack_int ldvt,\n                                double* q, lapack_int* iq, double* work,\n                                lapack_int* iwork );\n\nlapack_int LAPACKE_sbdsqr_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int ncvt, lapack_int nru, lapack_int ncc,\n                                float* d, float* e, float* vt, lapack_int ldvt,\n                                float* u, lapack_int ldu, float* c,\n                                lapack_int ldc, float* work );\nlapack_int LAPACKE_dbdsqr_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int ncvt, lapack_int nru, lapack_int ncc,\n                                double* d, double* e, double* vt,\n                                lapack_int ldvt, double* u, lapack_int ldu,\n                                double* c, lapack_int ldc, double* work );\nlapack_int LAPACKE_cbdsqr_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int ncvt, lapack_int nru, lapack_int ncc,\n                                float* d, float* e, lapack_complex_float* vt,\n                                lapack_int ldvt, lapack_complex_float* u,\n                                lapack_int ldu, lapack_complex_float* c,\n                                lapack_int ldc, float* work );\nlapack_int LAPACKE_zbdsqr_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int ncvt, lapack_int nru, lapack_int ncc,\n                                double* d, double* e, lapack_complex_double* vt,\n                                lapack_int ldvt, lapack_complex_double* u,\n                                lapack_int ldu, lapack_complex_double* c,\n                                lapack_int ldc, double* work );\n\nlapack_int LAPACKE_sdisna_work( char job, lapack_int m, lapack_int n,\n                                const float* d, float* sep );\nlapack_int LAPACKE_ddisna_work( char job, lapack_int m, lapack_int n,\n                                const double* d, double* sep );\n\nlapack_int LAPACKE_sgbbrd_work( int matrix_order, char vect, lapack_int m,\n                                lapack_int n, lapack_int ncc, lapack_int kl,\n                                lapack_int ku, float* ab, lapack_int ldab,\n                                float* d, float* e, float* q, lapack_int ldq,\n                                float* pt, lapack_int ldpt, float* c,\n                                lapack_int ldc, float* work );\nlapack_int LAPACKE_dgbbrd_work( int matrix_order, char vect, lapack_int m,\n                                lapack_int n, lapack_int ncc, lapack_int kl,\n                                lapack_int ku, double* ab, lapack_int ldab,\n                                double* d, double* e, double* q, lapack_int ldq,\n                                double* pt, lapack_int ldpt, double* c,\n                                lapack_int ldc, double* work );\nlapack_int LAPACKE_cgbbrd_work( int matrix_order, char vect, lapack_int m,\n                                lapack_int n, lapack_int ncc, lapack_int kl,\n                                lapack_int ku, lapack_complex_float* ab,\n                                lapack_int ldab, float* d, float* e,\n                                lapack_complex_float* q, lapack_int ldq,\n                                lapack_complex_float* pt, lapack_int ldpt,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zgbbrd_work( int matrix_order, char vect, lapack_int m,\n                                lapack_int n, lapack_int ncc, lapack_int kl,\n                                lapack_int ku, lapack_complex_double* ab,\n                                lapack_int ldab, double* d, double* e,\n                                lapack_complex_double* q, lapack_int ldq,\n                                lapack_complex_double* pt, lapack_int ldpt,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sgbcon_work( int matrix_order, char norm, lapack_int n,\n                                lapack_int kl, lapack_int ku, const float* ab,\n                                lapack_int ldab, const lapack_int* ipiv,\n                                float anorm, float* rcond, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dgbcon_work( int matrix_order, char norm, lapack_int n,\n                                lapack_int kl, lapack_int ku, const double* ab,\n                                lapack_int ldab, const lapack_int* ipiv,\n                                double anorm, double* rcond, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_cgbcon_work( int matrix_order, char norm, lapack_int n,\n                                lapack_int kl, lapack_int ku,\n                                const lapack_complex_float* ab, lapack_int ldab,\n                                const lapack_int* ipiv, float anorm,\n                                float* rcond, lapack_complex_float* work,\n                                float* rwork );\nlapack_int LAPACKE_zgbcon_work( int matrix_order, char norm, lapack_int n,\n                                lapack_int kl, lapack_int ku,\n                                const lapack_complex_double* ab,\n                                lapack_int ldab, const lapack_int* ipiv,\n                                double anorm, double* rcond,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sgbequ_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku, const float* ab,\n                                lapack_int ldab, float* r, float* c,\n                                float* rowcnd, float* colcnd, float* amax );\nlapack_int LAPACKE_dgbequ_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku, const double* ab,\n                                lapack_int ldab, double* r, double* c,\n                                double* rowcnd, double* colcnd, double* amax );\nlapack_int LAPACKE_cgbequ_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku,\n                                const lapack_complex_float* ab, lapack_int ldab,\n                                float* r, float* c, float* rowcnd,\n                                float* colcnd, float* amax );\nlapack_int LAPACKE_zgbequ_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku,\n                                const lapack_complex_double* ab,\n                                lapack_int ldab, double* r, double* c,\n                                double* rowcnd, double* colcnd, double* amax );\n\nlapack_int LAPACKE_sgbequb_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_int kl, lapack_int ku, const float* ab,\n                                 lapack_int ldab, float* r, float* c,\n                                 float* rowcnd, float* colcnd, float* amax );\nlapack_int LAPACKE_dgbequb_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_int kl, lapack_int ku, const double* ab,\n                                 lapack_int ldab, double* r, double* c,\n                                 double* rowcnd, double* colcnd, double* amax );\nlapack_int LAPACKE_cgbequb_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_int kl, lapack_int ku,\n                                 const lapack_complex_float* ab,\n                                 lapack_int ldab, float* r, float* c,\n                                 float* rowcnd, float* colcnd, float* amax );\nlapack_int LAPACKE_zgbequb_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_int kl, lapack_int ku,\n                                 const lapack_complex_double* ab,\n                                 lapack_int ldab, double* r, double* c,\n                                 double* rowcnd, double* colcnd, double* amax );\n\nlapack_int LAPACKE_sgbrfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int kl, lapack_int ku, lapack_int nrhs,\n                                const float* ab, lapack_int ldab,\n                                const float* afb, lapack_int ldafb,\n                                const lapack_int* ipiv, const float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* ferr, float* berr, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dgbrfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int kl, lapack_int ku, lapack_int nrhs,\n                                const double* ab, lapack_int ldab,\n                                const double* afb, lapack_int ldafb,\n                                const lapack_int* ipiv, const double* b,\n                                lapack_int ldb, double* x, lapack_int ldx,\n                                double* ferr, double* berr, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_cgbrfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int kl, lapack_int ku, lapack_int nrhs,\n                                const lapack_complex_float* ab, lapack_int ldab,\n                                const lapack_complex_float* afb,\n                                lapack_int ldafb, const lapack_int* ipiv,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zgbrfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int kl, lapack_int ku, lapack_int nrhs,\n                                const lapack_complex_double* ab,\n                                lapack_int ldab,\n                                const lapack_complex_double* afb,\n                                lapack_int ldafb, const lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sgbrfsx_work( int matrix_order, char trans, char equed,\n                                 lapack_int n, lapack_int kl, lapack_int ku,\n                                 lapack_int nrhs, const float* ab,\n                                 lapack_int ldab, const float* afb,\n                                 lapack_int ldafb, const lapack_int* ipiv,\n                                 const float* r, const float* c, const float* b,\n                                 lapack_int ldb, float* x, lapack_int ldx,\n                                 float* rcond, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, float* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_dgbrfsx_work( int matrix_order, char trans, char equed,\n                                 lapack_int n, lapack_int kl, lapack_int ku,\n                                 lapack_int nrhs, const double* ab,\n                                 lapack_int ldab, const double* afb,\n                                 lapack_int ldafb, const lapack_int* ipiv,\n                                 const double* r, const double* c,\n                                 const double* b, lapack_int ldb, double* x,\n                                 lapack_int ldx, double* rcond, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, double* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_cgbrfsx_work( int matrix_order, char trans, char equed,\n                                 lapack_int n, lapack_int kl, lapack_int ku,\n                                 lapack_int nrhs,\n                                 const lapack_complex_float* ab,\n                                 lapack_int ldab,\n                                 const lapack_complex_float* afb,\n                                 lapack_int ldafb, const lapack_int* ipiv,\n                                 const float* r, const float* c,\n                                 const lapack_complex_float* b, lapack_int ldb,\n                                 lapack_complex_float* x, lapack_int ldx,\n                                 float* rcond, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, lapack_complex_float* work,\n                                 float* rwork );\nlapack_int LAPACKE_zgbrfsx_work( int matrix_order, char trans, char equed,\n                                 lapack_int n, lapack_int kl, lapack_int ku,\n                                 lapack_int nrhs,\n                                 const lapack_complex_double* ab,\n                                 lapack_int ldab,\n                                 const lapack_complex_double* afb,\n                                 lapack_int ldafb, const lapack_int* ipiv,\n                                 const double* r, const double* c,\n                                 const lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* x, lapack_int ldx,\n                                 double* rcond, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, lapack_complex_double* work,\n                                 double* rwork );\n\nlapack_int LAPACKE_sgbsv_work( int matrix_order, lapack_int n, lapack_int kl,\n                               lapack_int ku, lapack_int nrhs, float* ab,\n                               lapack_int ldab, lapack_int* ipiv, float* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_dgbsv_work( int matrix_order, lapack_int n, lapack_int kl,\n                               lapack_int ku, lapack_int nrhs, double* ab,\n                               lapack_int ldab, lapack_int* ipiv, double* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_cgbsv_work( int matrix_order, lapack_int n, lapack_int kl,\n                               lapack_int ku, lapack_int nrhs,\n                               lapack_complex_float* ab, lapack_int ldab,\n                               lapack_int* ipiv, lapack_complex_float* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_zgbsv_work( int matrix_order, lapack_int n, lapack_int kl,\n                               lapack_int ku, lapack_int nrhs,\n                               lapack_complex_double* ab, lapack_int ldab,\n                               lapack_int* ipiv, lapack_complex_double* b,\n                               lapack_int ldb );\n\nlapack_int LAPACKE_sgbsvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int kl, lapack_int ku,\n                                lapack_int nrhs, float* ab, lapack_int ldab,\n                                float* afb, lapack_int ldafb, lapack_int* ipiv,\n                                char* equed, float* r, float* c, float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* rcond, float* ferr, float* berr,\n                                float* work, lapack_int* iwork );\nlapack_int LAPACKE_dgbsvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int kl, lapack_int ku,\n                                lapack_int nrhs, double* ab, lapack_int ldab,\n                                double* afb, lapack_int ldafb, lapack_int* ipiv,\n                                char* equed, double* r, double* c, double* b,\n                                lapack_int ldb, double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_cgbsvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int kl, lapack_int ku,\n                                lapack_int nrhs, lapack_complex_float* ab,\n                                lapack_int ldab, lapack_complex_float* afb,\n                                lapack_int ldafb, lapack_int* ipiv, char* equed,\n                                float* r, float* c, lapack_complex_float* b,\n                                lapack_int ldb, lapack_complex_float* x,\n                                lapack_int ldx, float* rcond, float* ferr,\n                                float* berr, lapack_complex_float* work,\n                                float* rwork );\nlapack_int LAPACKE_zgbsvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int kl, lapack_int ku,\n                                lapack_int nrhs, lapack_complex_double* ab,\n                                lapack_int ldab, lapack_complex_double* afb,\n                                lapack_int ldafb, lapack_int* ipiv, char* equed,\n                                double* r, double* c, lapack_complex_double* b,\n                                lapack_int ldb, lapack_complex_double* x,\n                                lapack_int ldx, double* rcond, double* ferr,\n                                double* berr, lapack_complex_double* work,\n                                double* rwork );\n\nlapack_int LAPACKE_sgbsvxx_work( int matrix_order, char fact, char trans,\n                                 lapack_int n, lapack_int kl, lapack_int ku,\n                                 lapack_int nrhs, float* ab, lapack_int ldab,\n                                 float* afb, lapack_int ldafb, lapack_int* ipiv,\n                                 char* equed, float* r, float* c, float* b,\n                                 lapack_int ldb, float* x, lapack_int ldx,\n                                 float* rcond, float* rpvgrw, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, float* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_dgbsvxx_work( int matrix_order, char fact, char trans,\n                                 lapack_int n, lapack_int kl, lapack_int ku,\n                                 lapack_int nrhs, double* ab, lapack_int ldab,\n                                 double* afb, lapack_int ldafb,\n                                 lapack_int* ipiv, char* equed, double* r,\n                                 double* c, double* b, lapack_int ldb,\n                                 double* x, lapack_int ldx, double* rcond,\n                                 double* rpvgrw, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, double* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_cgbsvxx_work( int matrix_order, char fact, char trans,\n                                 lapack_int n, lapack_int kl, lapack_int ku,\n                                 lapack_int nrhs, lapack_complex_float* ab,\n                                 lapack_int ldab, lapack_complex_float* afb,\n                                 lapack_int ldafb, lapack_int* ipiv,\n                                 char* equed, float* r, float* c,\n                                 lapack_complex_float* b, lapack_int ldb,\n                                 lapack_complex_float* x, lapack_int ldx,\n                                 float* rcond, float* rpvgrw, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, lapack_complex_float* work,\n                                 float* rwork );\nlapack_int LAPACKE_zgbsvxx_work( int matrix_order, char fact, char trans,\n                                 lapack_int n, lapack_int kl, lapack_int ku,\n                                 lapack_int nrhs, lapack_complex_double* ab,\n                                 lapack_int ldab, lapack_complex_double* afb,\n                                 lapack_int ldafb, lapack_int* ipiv,\n                                 char* equed, double* r, double* c,\n                                 lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* x, lapack_int ldx,\n                                 double* rcond, double* rpvgrw, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, lapack_complex_double* work,\n                                 double* rwork );\n\nlapack_int LAPACKE_sgbtrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku, float* ab,\n                                lapack_int ldab, lapack_int* ipiv );\nlapack_int LAPACKE_dgbtrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku, double* ab,\n                                lapack_int ldab, lapack_int* ipiv );\nlapack_int LAPACKE_cgbtrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku,\n                                lapack_complex_float* ab, lapack_int ldab,\n                                lapack_int* ipiv );\nlapack_int LAPACKE_zgbtrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku,\n                                lapack_complex_double* ab, lapack_int ldab,\n                                lapack_int* ipiv );\n\nlapack_int LAPACKE_sgbtrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int kl, lapack_int ku, lapack_int nrhs,\n                                const float* ab, lapack_int ldab,\n                                const lapack_int* ipiv, float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_dgbtrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int kl, lapack_int ku, lapack_int nrhs,\n                                const double* ab, lapack_int ldab,\n                                const lapack_int* ipiv, double* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_cgbtrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int kl, lapack_int ku, lapack_int nrhs,\n                                const lapack_complex_float* ab, lapack_int ldab,\n                                const lapack_int* ipiv, lapack_complex_float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_zgbtrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int kl, lapack_int ku, lapack_int nrhs,\n                                const lapack_complex_double* ab,\n                                lapack_int ldab, const lapack_int* ipiv,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_sgebak_work( int matrix_order, char job, char side,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                const float* scale, lapack_int m, float* v,\n                                lapack_int ldv );\nlapack_int LAPACKE_dgebak_work( int matrix_order, char job, char side,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                const double* scale, lapack_int m, double* v,\n                                lapack_int ldv );\nlapack_int LAPACKE_cgebak_work( int matrix_order, char job, char side,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                const float* scale, lapack_int m,\n                                lapack_complex_float* v, lapack_int ldv );\nlapack_int LAPACKE_zgebak_work( int matrix_order, char job, char side,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                const double* scale, lapack_int m,\n                                lapack_complex_double* v, lapack_int ldv );\n\nlapack_int LAPACKE_sgebal_work( int matrix_order, char job, lapack_int n,\n                                float* a, lapack_int lda, lapack_int* ilo,\n                                lapack_int* ihi, float* scale );\nlapack_int LAPACKE_dgebal_work( int matrix_order, char job, lapack_int n,\n                                double* a, lapack_int lda, lapack_int* ilo,\n                                lapack_int* ihi, double* scale );\nlapack_int LAPACKE_cgebal_work( int matrix_order, char job, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_int* ilo, lapack_int* ihi,\n                                float* scale );\nlapack_int LAPACKE_zgebal_work( int matrix_order, char job, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_int* ilo, lapack_int* ihi,\n                                double* scale );\n\nlapack_int LAPACKE_sgebrd_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, float* d, float* e,\n                                float* tauq, float* taup, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dgebrd_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, double* d, double* e,\n                                double* tauq, double* taup, double* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_cgebrd_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                float* d, float* e, lapack_complex_float* tauq,\n                                lapack_complex_float* taup,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zgebrd_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                double* d, double* e,\n                                lapack_complex_double* tauq,\n                                lapack_complex_double* taup,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sgecon_work( int matrix_order, char norm, lapack_int n,\n                                const float* a, lapack_int lda, float anorm,\n                                float* rcond, float* work, lapack_int* iwork );\nlapack_int LAPACKE_dgecon_work( int matrix_order, char norm, lapack_int n,\n                                const double* a, lapack_int lda, double anorm,\n                                double* rcond, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_cgecon_work( int matrix_order, char norm, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                float anorm, float* rcond,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zgecon_work( int matrix_order, char norm, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                double anorm, double* rcond,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sgeequ_work( int matrix_order, lapack_int m, lapack_int n,\n                                const float* a, lapack_int lda, float* r,\n                                float* c, float* rowcnd, float* colcnd,\n                                float* amax );\nlapack_int LAPACKE_dgeequ_work( int matrix_order, lapack_int m, lapack_int n,\n                                const double* a, lapack_int lda, double* r,\n                                double* c, double* rowcnd, double* colcnd,\n                                double* amax );\nlapack_int LAPACKE_cgeequ_work( int matrix_order, lapack_int m, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                float* r, float* c, float* rowcnd,\n                                float* colcnd, float* amax );\nlapack_int LAPACKE_zgeequ_work( int matrix_order, lapack_int m, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                double* r, double* c, double* rowcnd,\n                                double* colcnd, double* amax );\n\nlapack_int LAPACKE_sgeequb_work( int matrix_order, lapack_int m, lapack_int n,\n                                 const float* a, lapack_int lda, float* r,\n                                 float* c, float* rowcnd, float* colcnd,\n                                 float* amax );\nlapack_int LAPACKE_dgeequb_work( int matrix_order, lapack_int m, lapack_int n,\n                                 const double* a, lapack_int lda, double* r,\n                                 double* c, double* rowcnd, double* colcnd,\n                                 double* amax );\nlapack_int LAPACKE_cgeequb_work( int matrix_order, lapack_int m, lapack_int n,\n                                 const lapack_complex_float* a, lapack_int lda,\n                                 float* r, float* c, float* rowcnd,\n                                 float* colcnd, float* amax );\nlapack_int LAPACKE_zgeequb_work( int matrix_order, lapack_int m, lapack_int n,\n                                 const lapack_complex_double* a, lapack_int lda,\n                                 double* r, double* c, double* rowcnd,\n                                 double* colcnd, double* amax );\n\nlapack_int LAPACKE_sgees_work( int matrix_order, char jobvs, char sort,\n                               LAPACK_S_SELECT2 select, lapack_int n, float* a,\n                               lapack_int lda, lapack_int* sdim, float* wr,\n                               float* wi, float* vs, lapack_int ldvs,\n                               float* work, lapack_int lwork,\n                               lapack_logical* bwork );\nlapack_int LAPACKE_dgees_work( int matrix_order, char jobvs, char sort,\n                               LAPACK_D_SELECT2 select, lapack_int n, double* a,\n                               lapack_int lda, lapack_int* sdim, double* wr,\n                               double* wi, double* vs, lapack_int ldvs,\n                               double* work, lapack_int lwork,\n                               lapack_logical* bwork );\nlapack_int LAPACKE_cgees_work( int matrix_order, char jobvs, char sort,\n                               LAPACK_C_SELECT1 select, lapack_int n,\n                               lapack_complex_float* a, lapack_int lda,\n                               lapack_int* sdim, lapack_complex_float* w,\n                               lapack_complex_float* vs, lapack_int ldvs,\n                               lapack_complex_float* work, lapack_int lwork,\n                               float* rwork, lapack_logical* bwork );\nlapack_int LAPACKE_zgees_work( int matrix_order, char jobvs, char sort,\n                               LAPACK_Z_SELECT1 select, lapack_int n,\n                               lapack_complex_double* a, lapack_int lda,\n                               lapack_int* sdim, lapack_complex_double* w,\n                               lapack_complex_double* vs, lapack_int ldvs,\n                               lapack_complex_double* work, lapack_int lwork,\n                               double* rwork, lapack_logical* bwork );\n\nlapack_int LAPACKE_sgeesx_work( int matrix_order, char jobvs, char sort,\n                                LAPACK_S_SELECT2 select, char sense,\n                                lapack_int n, float* a, lapack_int lda,\n                                lapack_int* sdim, float* wr, float* wi,\n                                float* vs, lapack_int ldvs, float* rconde,\n                                float* rcondv, float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork,\n                                lapack_logical* bwork );\nlapack_int LAPACKE_dgeesx_work( int matrix_order, char jobvs, char sort,\n                                LAPACK_D_SELECT2 select, char sense,\n                                lapack_int n, double* a, lapack_int lda,\n                                lapack_int* sdim, double* wr, double* wi,\n                                double* vs, lapack_int ldvs, double* rconde,\n                                double* rcondv, double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork,\n                                lapack_logical* bwork );\nlapack_int LAPACKE_cgeesx_work( int matrix_order, char jobvs, char sort,\n                                LAPACK_C_SELECT1 select, char sense,\n                                lapack_int n, lapack_complex_float* a,\n                                lapack_int lda, lapack_int* sdim,\n                                lapack_complex_float* w,\n                                lapack_complex_float* vs, lapack_int ldvs,\n                                float* rconde, float* rcondv,\n                                lapack_complex_float* work, lapack_int lwork,\n                                float* rwork, lapack_logical* bwork );\nlapack_int LAPACKE_zgeesx_work( int matrix_order, char jobvs, char sort,\n                                LAPACK_Z_SELECT1 select, char sense,\n                                lapack_int n, lapack_complex_double* a,\n                                lapack_int lda, lapack_int* sdim,\n                                lapack_complex_double* w,\n                                lapack_complex_double* vs, lapack_int ldvs,\n                                double* rconde, double* rcondv,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork, lapack_logical* bwork );\n\nlapack_int LAPACKE_sgeev_work( int matrix_order, char jobvl, char jobvr,\n                               lapack_int n, float* a, lapack_int lda,\n                               float* wr, float* wi, float* vl, lapack_int ldvl,\n                               float* vr, lapack_int ldvr, float* work,\n                               lapack_int lwork );\nlapack_int LAPACKE_dgeev_work( int matrix_order, char jobvl, char jobvr,\n                               lapack_int n, double* a, lapack_int lda,\n                               double* wr, double* wi, double* vl,\n                               lapack_int ldvl, double* vr, lapack_int ldvr,\n                               double* work, lapack_int lwork );\nlapack_int LAPACKE_cgeev_work( int matrix_order, char jobvl, char jobvr,\n                               lapack_int n, lapack_complex_float* a,\n                               lapack_int lda, lapack_complex_float* w,\n                               lapack_complex_float* vl, lapack_int ldvl,\n                               lapack_complex_float* vr, lapack_int ldvr,\n                               lapack_complex_float* work, lapack_int lwork,\n                               float* rwork );\nlapack_int LAPACKE_zgeev_work( int matrix_order, char jobvl, char jobvr,\n                               lapack_int n, lapack_complex_double* a,\n                               lapack_int lda, lapack_complex_double* w,\n                               lapack_complex_double* vl, lapack_int ldvl,\n                               lapack_complex_double* vr, lapack_int ldvr,\n                               lapack_complex_double* work, lapack_int lwork,\n                               double* rwork );\n\nlapack_int LAPACKE_sgeevx_work( int matrix_order, char balanc, char jobvl,\n                                char jobvr, char sense, lapack_int n, float* a,\n                                lapack_int lda, float* wr, float* wi, float* vl,\n                                lapack_int ldvl, float* vr, lapack_int ldvr,\n                                lapack_int* ilo, lapack_int* ihi, float* scale,\n                                float* abnrm, float* rconde, float* rcondv,\n                                float* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dgeevx_work( int matrix_order, char balanc, char jobvl,\n                                char jobvr, char sense, lapack_int n, double* a,\n                                lapack_int lda, double* wr, double* wi,\n                                double* vl, lapack_int ldvl, double* vr,\n                                lapack_int ldvr, lapack_int* ilo,\n                                lapack_int* ihi, double* scale, double* abnrm,\n                                double* rconde, double* rcondv, double* work,\n                                lapack_int lwork, lapack_int* iwork );\nlapack_int LAPACKE_cgeevx_work( int matrix_order, char balanc, char jobvl,\n                                char jobvr, char sense, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* w,\n                                lapack_complex_float* vl, lapack_int ldvl,\n                                lapack_complex_float* vr, lapack_int ldvr,\n                                lapack_int* ilo, lapack_int* ihi, float* scale,\n                                float* abnrm, float* rconde, float* rcondv,\n                                lapack_complex_float* work, lapack_int lwork,\n                                float* rwork );\nlapack_int LAPACKE_zgeevx_work( int matrix_order, char balanc, char jobvl,\n                                char jobvr, char sense, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* w,\n                                lapack_complex_double* vl, lapack_int ldvl,\n                                lapack_complex_double* vr, lapack_int ldvr,\n                                lapack_int* ilo, lapack_int* ihi, double* scale,\n                                double* abnrm, double* rconde, double* rcondv,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork );\n\nlapack_int LAPACKE_sgehrd_work( int matrix_order, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, float* a, lapack_int lda,\n                                float* tau, float* work, lapack_int lwork );\nlapack_int LAPACKE_dgehrd_work( int matrix_order, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, double* a, lapack_int lda,\n                                double* tau, double* work, lapack_int lwork );\nlapack_int LAPACKE_cgehrd_work( int matrix_order, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zgehrd_work( int matrix_order, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sgejsv_work( int matrix_order, char joba, char jobu,\n                                char jobv, char jobr, char jobt, char jobp,\n                                lapack_int m, lapack_int n, float* a,\n                                lapack_int lda, float* sva, float* u,\n                                lapack_int ldu, float* v, lapack_int ldv,\n                                float* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dgejsv_work( int matrix_order, char joba, char jobu,\n                                char jobv, char jobr, char jobt, char jobp,\n                                lapack_int m, lapack_int n, double* a,\n                                lapack_int lda, double* sva, double* u,\n                                lapack_int ldu, double* v, lapack_int ldv,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork );\n\nlapack_int LAPACKE_sgelq2_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, float* tau,\n                                float* work );\nlapack_int LAPACKE_dgelq2_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, double* tau,\n                                double* work );\nlapack_int LAPACKE_cgelq2_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* tau,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zgelq2_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* tau,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_sgelqf_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, float* tau,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dgelqf_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, double* tau,\n                                double* work, lapack_int lwork );\nlapack_int LAPACKE_cgelqf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zgelqf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sgels_work( int matrix_order, char trans, lapack_int m,\n                               lapack_int n, lapack_int nrhs, float* a,\n                               lapack_int lda, float* b, lapack_int ldb,\n                               float* work, lapack_int lwork );\nlapack_int LAPACKE_dgels_work( int matrix_order, char trans, lapack_int m,\n                               lapack_int n, lapack_int nrhs, double* a,\n                               lapack_int lda, double* b, lapack_int ldb,\n                               double* work, lapack_int lwork );\nlapack_int LAPACKE_cgels_work( int matrix_order, char trans, lapack_int m,\n                               lapack_int n, lapack_int nrhs,\n                               lapack_complex_float* a, lapack_int lda,\n                               lapack_complex_float* b, lapack_int ldb,\n                               lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zgels_work( int matrix_order, char trans, lapack_int m,\n                               lapack_int n, lapack_int nrhs,\n                               lapack_complex_double* a, lapack_int lda,\n                               lapack_complex_double* b, lapack_int ldb,\n                               lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sgelsd_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, float* a, lapack_int lda,\n                                float* b, lapack_int ldb, float* s, float rcond,\n                                lapack_int* rank, float* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dgelsd_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, double* a, lapack_int lda,\n                                double* b, lapack_int ldb, double* s,\n                                double rcond, lapack_int* rank, double* work,\n                                lapack_int lwork, lapack_int* iwork );\nlapack_int LAPACKE_cgelsd_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* b,\n                                lapack_int ldb, float* s, float rcond,\n                                lapack_int* rank, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_zgelsd_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* b,\n                                lapack_int ldb, double* s, double rcond,\n                                lapack_int* rank, lapack_complex_double* work,\n                                lapack_int lwork, double* rwork,\n                                lapack_int* iwork );\n\nlapack_int LAPACKE_sgelss_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, float* a, lapack_int lda,\n                                float* b, lapack_int ldb, float* s, float rcond,\n                                lapack_int* rank, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dgelss_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, double* a, lapack_int lda,\n                                double* b, lapack_int ldb, double* s,\n                                double rcond, lapack_int* rank, double* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_cgelss_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* b,\n                                lapack_int ldb, float* s, float rcond,\n                                lapack_int* rank, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork );\nlapack_int LAPACKE_zgelss_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* b,\n                                lapack_int ldb, double* s, double rcond,\n                                lapack_int* rank, lapack_complex_double* work,\n                                lapack_int lwork, double* rwork );\n\nlapack_int LAPACKE_sgelsy_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, float* a, lapack_int lda,\n                                float* b, lapack_int ldb, lapack_int* jpvt,\n                                float rcond, lapack_int* rank, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dgelsy_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, double* a, lapack_int lda,\n                                double* b, lapack_int ldb, lapack_int* jpvt,\n                                double rcond, lapack_int* rank, double* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_cgelsy_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* b,\n                                lapack_int ldb, lapack_int* jpvt, float rcond,\n                                lapack_int* rank, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork );\nlapack_int LAPACKE_zgelsy_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nrhs, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* b,\n                                lapack_int ldb, lapack_int* jpvt, double rcond,\n                                lapack_int* rank, lapack_complex_double* work,\n                                lapack_int lwork, double* rwork );\n\nlapack_int LAPACKE_sgeqlf_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, float* tau,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dgeqlf_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, double* tau,\n                                double* work, lapack_int lwork );\nlapack_int LAPACKE_cgeqlf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zgeqlf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sgeqp3_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, lapack_int* jpvt,\n                                float* tau, float* work, lapack_int lwork );\nlapack_int LAPACKE_dgeqp3_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, lapack_int* jpvt,\n                                double* tau, double* work, lapack_int lwork );\nlapack_int LAPACKE_cgeqp3_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_int* jpvt, lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork,\n                                float* rwork );\nlapack_int LAPACKE_zgeqp3_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_int* jpvt, lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork );\n\nlapack_int LAPACKE_sgeqpf_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, lapack_int* jpvt,\n                                float* tau, float* work );\nlapack_int LAPACKE_dgeqpf_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, lapack_int* jpvt,\n                                double* tau, double* work );\nlapack_int LAPACKE_cgeqpf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_int* jpvt, lapack_complex_float* tau,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zgeqpf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_int* jpvt, lapack_complex_double* tau,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sgeqr2_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, float* tau,\n                                float* work );\nlapack_int LAPACKE_dgeqr2_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, double* tau,\n                                double* work );\nlapack_int LAPACKE_cgeqr2_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* tau,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zgeqr2_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* tau,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_sgeqrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, float* tau,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dgeqrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, double* tau,\n                                double* work, lapack_int lwork );\nlapack_int LAPACKE_cgeqrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zgeqrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sgeqrfp_work( int matrix_order, lapack_int m, lapack_int n,\n                                 float* a, lapack_int lda, float* tau,\n                                 float* work, lapack_int lwork );\nlapack_int LAPACKE_dgeqrfp_work( int matrix_order, lapack_int m, lapack_int n,\n                                 double* a, lapack_int lda, double* tau,\n                                 double* work, lapack_int lwork );\nlapack_int LAPACKE_cgeqrfp_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_complex_float* a, lapack_int lda,\n                                 lapack_complex_float* tau,\n                                 lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zgeqrfp_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_complex_double* a, lapack_int lda,\n                                 lapack_complex_double* tau,\n                                 lapack_complex_double* work,\n                                 lapack_int lwork );\n\nlapack_int LAPACKE_sgerfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const float* a, lapack_int lda,\n                                const float* af, lapack_int ldaf,\n                                const lapack_int* ipiv, const float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* ferr, float* berr, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dgerfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const double* a,\n                                lapack_int lda, const double* af,\n                                lapack_int ldaf, const lapack_int* ipiv,\n                                const double* b, lapack_int ldb, double* x,\n                                lapack_int ldx, double* ferr, double* berr,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_cgerfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* af,\n                                lapack_int ldaf, const lapack_int* ipiv,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zgerfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_double* a,\n                                lapack_int lda, const lapack_complex_double* af,\n                                lapack_int ldaf, const lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sgerfsx_work( int matrix_order, char trans, char equed,\n                                 lapack_int n, lapack_int nrhs, const float* a,\n                                 lapack_int lda, const float* af,\n                                 lapack_int ldaf, const lapack_int* ipiv,\n                                 const float* r, const float* c, const float* b,\n                                 lapack_int ldb, float* x, lapack_int ldx,\n                                 float* rcond, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, float* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_dgerfsx_work( int matrix_order, char trans, char equed,\n                                 lapack_int n, lapack_int nrhs, const double* a,\n                                 lapack_int lda, const double* af,\n                                 lapack_int ldaf, const lapack_int* ipiv,\n                                 const double* r, const double* c,\n                                 const double* b, lapack_int ldb, double* x,\n                                 lapack_int ldx, double* rcond, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, double* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_cgerfsx_work( int matrix_order, char trans, char equed,\n                                 lapack_int n, lapack_int nrhs,\n                                 const lapack_complex_float* a, lapack_int lda,\n                                 const lapack_complex_float* af,\n                                 lapack_int ldaf, const lapack_int* ipiv,\n                                 const float* r, const float* c,\n                                 const lapack_complex_float* b, lapack_int ldb,\n                                 lapack_complex_float* x, lapack_int ldx,\n                                 float* rcond, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, lapack_complex_float* work,\n                                 float* rwork );\nlapack_int LAPACKE_zgerfsx_work( int matrix_order, char trans, char equed,\n                                 lapack_int n, lapack_int nrhs,\n                                 const lapack_complex_double* a, lapack_int lda,\n                                 const lapack_complex_double* af,\n                                 lapack_int ldaf, const lapack_int* ipiv,\n                                 const double* r, const double* c,\n                                 const lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* x, lapack_int ldx,\n                                 double* rcond, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, lapack_complex_double* work,\n                                 double* rwork );\n\nlapack_int LAPACKE_sgerqf_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, float* tau,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dgerqf_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, double* tau,\n                                double* work, lapack_int lwork );\nlapack_int LAPACKE_cgerqf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zgerqf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sgesdd_work( int matrix_order, char jobz, lapack_int m,\n                                lapack_int n, float* a, lapack_int lda,\n                                float* s, float* u, lapack_int ldu, float* vt,\n                                lapack_int ldvt, float* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dgesdd_work( int matrix_order, char jobz, lapack_int m,\n                                lapack_int n, double* a, lapack_int lda,\n                                double* s, double* u, lapack_int ldu,\n                                double* vt, lapack_int ldvt, double* work,\n                                lapack_int lwork, lapack_int* iwork );\nlapack_int LAPACKE_cgesdd_work( int matrix_order, char jobz, lapack_int m,\n                                lapack_int n, lapack_complex_float* a,\n                                lapack_int lda, float* s,\n                                lapack_complex_float* u, lapack_int ldu,\n                                lapack_complex_float* vt, lapack_int ldvt,\n                                lapack_complex_float* work, lapack_int lwork,\n                                float* rwork, lapack_int* iwork );\nlapack_int LAPACKE_zgesdd_work( int matrix_order, char jobz, lapack_int m,\n                                lapack_int n, lapack_complex_double* a,\n                                lapack_int lda, double* s,\n                                lapack_complex_double* u, lapack_int ldu,\n                                lapack_complex_double* vt, lapack_int ldvt,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork, lapack_int* iwork );\n\nlapack_int LAPACKE_sgesv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               float* a, lapack_int lda, lapack_int* ipiv,\n                               float* b, lapack_int ldb );\nlapack_int LAPACKE_dgesv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               double* a, lapack_int lda, lapack_int* ipiv,\n                               double* b, lapack_int ldb );\nlapack_int LAPACKE_cgesv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               lapack_complex_float* a, lapack_int lda,\n                               lapack_int* ipiv, lapack_complex_float* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_zgesv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               lapack_complex_double* a, lapack_int lda,\n                               lapack_int* ipiv, lapack_complex_double* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_dsgesv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                                double* a, lapack_int lda, lapack_int* ipiv,\n                                double* b, lapack_int ldb, double* x,\n                                lapack_int ldx, double* work, float* swork,\n                                lapack_int* iter );\nlapack_int LAPACKE_zcgesv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_int* ipiv, lapack_complex_double* b,\n                                lapack_int ldb, lapack_complex_double* x,\n                                lapack_int ldx, lapack_complex_double* work,\n                                lapack_complex_float* swork, double* rwork,\n                                lapack_int* iter );\n\nlapack_int LAPACKE_sgesvd_work( int matrix_order, char jobu, char jobvt,\n                                lapack_int m, lapack_int n, float* a,\n                                lapack_int lda, float* s, float* u,\n                                lapack_int ldu, float* vt, lapack_int ldvt,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dgesvd_work( int matrix_order, char jobu, char jobvt,\n                                lapack_int m, lapack_int n, double* a,\n                                lapack_int lda, double* s, double* u,\n                                lapack_int ldu, double* vt, lapack_int ldvt,\n                                double* work, lapack_int lwork );\nlapack_int LAPACKE_cgesvd_work( int matrix_order, char jobu, char jobvt,\n                                lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                float* s, lapack_complex_float* u,\n                                lapack_int ldu, lapack_complex_float* vt,\n                                lapack_int ldvt, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork );\nlapack_int LAPACKE_zgesvd_work( int matrix_order, char jobu, char jobvt,\n                                lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                double* s, lapack_complex_double* u,\n                                lapack_int ldu, lapack_complex_double* vt,\n                                lapack_int ldvt, lapack_complex_double* work,\n                                lapack_int lwork, double* rwork );\n\nlapack_int LAPACKE_sgesvj_work( int matrix_order, char joba, char jobu,\n                                char jobv, lapack_int m, lapack_int n, float* a,\n                                lapack_int lda, float* sva, lapack_int mv,\n                                float* v, lapack_int ldv, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dgesvj_work( int matrix_order, char joba, char jobu,\n                                char jobv, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, double* sva,\n                                lapack_int mv, double* v, lapack_int ldv,\n                                double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sgesvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int nrhs, float* a,\n                                lapack_int lda, float* af, lapack_int ldaf,\n                                lapack_int* ipiv, char* equed, float* r,\n                                float* c, float* b, lapack_int ldb, float* x,\n                                lapack_int ldx, float* rcond, float* ferr,\n                                float* berr, float* work, lapack_int* iwork );\nlapack_int LAPACKE_dgesvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int nrhs, double* a,\n                                lapack_int lda, double* af, lapack_int ldaf,\n                                lapack_int* ipiv, char* equed, double* r,\n                                double* c, double* b, lapack_int ldb, double* x,\n                                lapack_int ldx, double* rcond, double* ferr,\n                                double* berr, double* work, lapack_int* iwork );\nlapack_int LAPACKE_cgesvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int nrhs,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* af, lapack_int ldaf,\n                                lapack_int* ipiv, char* equed, float* r,\n                                float* c, lapack_complex_float* b,\n                                lapack_int ldb, lapack_complex_float* x,\n                                lapack_int ldx, float* rcond, float* ferr,\n                                float* berr, lapack_complex_float* work,\n                                float* rwork );\nlapack_int LAPACKE_zgesvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int nrhs,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* af, lapack_int ldaf,\n                                lapack_int* ipiv, char* equed, double* r,\n                                double* c, lapack_complex_double* b,\n                                lapack_int ldb, lapack_complex_double* x,\n                                lapack_int ldx, double* rcond, double* ferr,\n                                double* berr, lapack_complex_double* work,\n                                double* rwork );\n\nlapack_int LAPACKE_sgesvxx_work( int matrix_order, char fact, char trans,\n                                 lapack_int n, lapack_int nrhs, float* a,\n                                 lapack_int lda, float* af, lapack_int ldaf,\n                                 lapack_int* ipiv, char* equed, float* r,\n                                 float* c, float* b, lapack_int ldb, float* x,\n                                 lapack_int ldx, float* rcond, float* rpvgrw,\n                                 float* berr, lapack_int n_err_bnds,\n                                 float* err_bnds_norm, float* err_bnds_comp,\n                                 lapack_int nparams, float* params, float* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_dgesvxx_work( int matrix_order, char fact, char trans,\n                                 lapack_int n, lapack_int nrhs, double* a,\n                                 lapack_int lda, double* af, lapack_int ldaf,\n                                 lapack_int* ipiv, char* equed, double* r,\n                                 double* c, double* b, lapack_int ldb,\n                                 double* x, lapack_int ldx, double* rcond,\n                                 double* rpvgrw, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, double* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_cgesvxx_work( int matrix_order, char fact, char trans,\n                                 lapack_int n, lapack_int nrhs,\n                                 lapack_complex_float* a, lapack_int lda,\n                                 lapack_complex_float* af, lapack_int ldaf,\n                                 lapack_int* ipiv, char* equed, float* r,\n                                 float* c, lapack_complex_float* b,\n                                 lapack_int ldb, lapack_complex_float* x,\n                                 lapack_int ldx, float* rcond, float* rpvgrw,\n                                 float* berr, lapack_int n_err_bnds,\n                                 float* err_bnds_norm, float* err_bnds_comp,\n                                 lapack_int nparams, float* params,\n                                 lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zgesvxx_work( int matrix_order, char fact, char trans,\n                                 lapack_int n, lapack_int nrhs,\n                                 lapack_complex_double* a, lapack_int lda,\n                                 lapack_complex_double* af, lapack_int ldaf,\n                                 lapack_int* ipiv, char* equed, double* r,\n                                 double* c, lapack_complex_double* b,\n                                 lapack_int ldb, lapack_complex_double* x,\n                                 lapack_int ldx, double* rcond, double* rpvgrw,\n                                 double* berr, lapack_int n_err_bnds,\n                                 double* err_bnds_norm, double* err_bnds_comp,\n                                 lapack_int nparams, double* params,\n                                 lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sgetf2_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, lapack_int* ipiv );\nlapack_int LAPACKE_dgetf2_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, lapack_int* ipiv );\nlapack_int LAPACKE_cgetf2_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_int* ipiv );\nlapack_int LAPACKE_zgetf2_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_int* ipiv );\n\nlapack_int LAPACKE_sgetrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, lapack_int* ipiv );\nlapack_int LAPACKE_dgetrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, lapack_int* ipiv );\nlapack_int LAPACKE_cgetrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_int* ipiv );\nlapack_int LAPACKE_zgetrf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_int* ipiv );\n\nlapack_int LAPACKE_sgetri_work( int matrix_order, lapack_int n, float* a,\n                                lapack_int lda, const lapack_int* ipiv,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dgetri_work( int matrix_order, lapack_int n, double* a,\n                                lapack_int lda, const lapack_int* ipiv,\n                                double* work, lapack_int lwork );\nlapack_int LAPACKE_cgetri_work( int matrix_order, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                const lapack_int* ipiv,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zgetri_work( int matrix_order, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                const lapack_int* ipiv,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sgetrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const float* a, lapack_int lda,\n                                const lapack_int* ipiv, float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_dgetrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const double* a,\n                                lapack_int lda, const lapack_int* ipiv,\n                                double* b, lapack_int ldb );\nlapack_int LAPACKE_cgetrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* a,\n                                lapack_int lda, const lapack_int* ipiv,\n                                lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zgetrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_double* a,\n                                lapack_int lda, const lapack_int* ipiv,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_sggbak_work( int matrix_order, char job, char side,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                const float* lscale, const float* rscale,\n                                lapack_int m, float* v, lapack_int ldv );\nlapack_int LAPACKE_dggbak_work( int matrix_order, char job, char side,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                const double* lscale, const double* rscale,\n                                lapack_int m, double* v, lapack_int ldv );\nlapack_int LAPACKE_cggbak_work( int matrix_order, char job, char side,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                const float* lscale, const float* rscale,\n                                lapack_int m, lapack_complex_float* v,\n                                lapack_int ldv );\nlapack_int LAPACKE_zggbak_work( int matrix_order, char job, char side,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                const double* lscale, const double* rscale,\n                                lapack_int m, lapack_complex_double* v,\n                                lapack_int ldv );\n\nlapack_int LAPACKE_sggbal_work( int matrix_order, char job, lapack_int n,\n                                float* a, lapack_int lda, float* b,\n                                lapack_int ldb, lapack_int* ilo,\n                                lapack_int* ihi, float* lscale, float* rscale,\n                                float* work );\nlapack_int LAPACKE_dggbal_work( int matrix_order, char job, lapack_int n,\n                                double* a, lapack_int lda, double* b,\n                                lapack_int ldb, lapack_int* ilo,\n                                lapack_int* ihi, double* lscale, double* rscale,\n                                double* work );\nlapack_int LAPACKE_cggbal_work( int matrix_order, char job, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* b, lapack_int ldb,\n                                lapack_int* ilo, lapack_int* ihi, float* lscale,\n                                float* rscale, float* work );\nlapack_int LAPACKE_zggbal_work( int matrix_order, char job, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb,\n                                lapack_int* ilo, lapack_int* ihi,\n                                double* lscale, double* rscale, double* work );\n\nlapack_int LAPACKE_sgges_work( int matrix_order, char jobvsl, char jobvsr,\n                               char sort, LAPACK_S_SELECT3 selctg, lapack_int n,\n                               float* a, lapack_int lda, float* b,\n                               lapack_int ldb, lapack_int* sdim, float* alphar,\n                               float* alphai, float* beta, float* vsl,\n                               lapack_int ldvsl, float* vsr, lapack_int ldvsr,\n                               float* work, lapack_int lwork,\n                               lapack_logical* bwork );\nlapack_int LAPACKE_dgges_work( int matrix_order, char jobvsl, char jobvsr,\n                               char sort, LAPACK_D_SELECT3 selctg, lapack_int n,\n                               double* a, lapack_int lda, double* b,\n                               lapack_int ldb, lapack_int* sdim, double* alphar,\n                               double* alphai, double* beta, double* vsl,\n                               lapack_int ldvsl, double* vsr, lapack_int ldvsr,\n                               double* work, lapack_int lwork,\n                               lapack_logical* bwork );\nlapack_int LAPACKE_cgges_work( int matrix_order, char jobvsl, char jobvsr,\n                               char sort, LAPACK_C_SELECT2 selctg, lapack_int n,\n                               lapack_complex_float* a, lapack_int lda,\n                               lapack_complex_float* b, lapack_int ldb,\n                               lapack_int* sdim, lapack_complex_float* alpha,\n                               lapack_complex_float* beta,\n                               lapack_complex_float* vsl, lapack_int ldvsl,\n                               lapack_complex_float* vsr, lapack_int ldvsr,\n                               lapack_complex_float* work, lapack_int lwork,\n                               float* rwork, lapack_logical* bwork );\nlapack_int LAPACKE_zgges_work( int matrix_order, char jobvsl, char jobvsr,\n                               char sort, LAPACK_Z_SELECT2 selctg, lapack_int n,\n                               lapack_complex_double* a, lapack_int lda,\n                               lapack_complex_double* b, lapack_int ldb,\n                               lapack_int* sdim, lapack_complex_double* alpha,\n                               lapack_complex_double* beta,\n                               lapack_complex_double* vsl, lapack_int ldvsl,\n                               lapack_complex_double* vsr, lapack_int ldvsr,\n                               lapack_complex_double* work, lapack_int lwork,\n                               double* rwork, lapack_logical* bwork );\n\nlapack_int LAPACKE_sggesx_work( int matrix_order, char jobvsl, char jobvsr,\n                                char sort, LAPACK_S_SELECT3 selctg, char sense,\n                                lapack_int n, float* a, lapack_int lda,\n                                float* b, lapack_int ldb, lapack_int* sdim,\n                                float* alphar, float* alphai, float* beta,\n                                float* vsl, lapack_int ldvsl, float* vsr,\n                                lapack_int ldvsr, float* rconde, float* rcondv,\n                                float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork,\n                                lapack_logical* bwork );\nlapack_int LAPACKE_dggesx_work( int matrix_order, char jobvsl, char jobvsr,\n                                char sort, LAPACK_D_SELECT3 selctg, char sense,\n                                lapack_int n, double* a, lapack_int lda,\n                                double* b, lapack_int ldb, lapack_int* sdim,\n                                double* alphar, double* alphai, double* beta,\n                                double* vsl, lapack_int ldvsl, double* vsr,\n                                lapack_int ldvsr, double* rconde,\n                                double* rcondv, double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork,\n                                lapack_logical* bwork );\nlapack_int LAPACKE_cggesx_work( int matrix_order, char jobvsl, char jobvsr,\n                                char sort, LAPACK_C_SELECT2 selctg, char sense,\n                                lapack_int n, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* b,\n                                lapack_int ldb, lapack_int* sdim,\n                                lapack_complex_float* alpha,\n                                lapack_complex_float* beta,\n                                lapack_complex_float* vsl, lapack_int ldvsl,\n                                lapack_complex_float* vsr, lapack_int ldvsr,\n                                float* rconde, float* rcondv,\n                                lapack_complex_float* work, lapack_int lwork,\n                                float* rwork, lapack_int* iwork,\n                                lapack_int liwork, lapack_logical* bwork );\nlapack_int LAPACKE_zggesx_work( int matrix_order, char jobvsl, char jobvsr,\n                                char sort, LAPACK_Z_SELECT2 selctg, char sense,\n                                lapack_int n, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* b,\n                                lapack_int ldb, lapack_int* sdim,\n                                lapack_complex_double* alpha,\n                                lapack_complex_double* beta,\n                                lapack_complex_double* vsl, lapack_int ldvsl,\n                                lapack_complex_double* vsr, lapack_int ldvsr,\n                                double* rconde, double* rcondv,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork, lapack_int* iwork,\n                                lapack_int liwork, lapack_logical* bwork );\n\nlapack_int LAPACKE_sggev_work( int matrix_order, char jobvl, char jobvr,\n                               lapack_int n, float* a, lapack_int lda, float* b,\n                               lapack_int ldb, float* alphar, float* alphai,\n                               float* beta, float* vl, lapack_int ldvl,\n                               float* vr, lapack_int ldvr, float* work,\n                               lapack_int lwork );\nlapack_int LAPACKE_dggev_work( int matrix_order, char jobvl, char jobvr,\n                               lapack_int n, double* a, lapack_int lda,\n                               double* b, lapack_int ldb, double* alphar,\n                               double* alphai, double* beta, double* vl,\n                               lapack_int ldvl, double* vr, lapack_int ldvr,\n                               double* work, lapack_int lwork );\nlapack_int LAPACKE_cggev_work( int matrix_order, char jobvl, char jobvr,\n                               lapack_int n, lapack_complex_float* a,\n                               lapack_int lda, lapack_complex_float* b,\n                               lapack_int ldb, lapack_complex_float* alpha,\n                               lapack_complex_float* beta,\n                               lapack_complex_float* vl, lapack_int ldvl,\n                               lapack_complex_float* vr, lapack_int ldvr,\n                               lapack_complex_float* work, lapack_int lwork,\n                               float* rwork );\nlapack_int LAPACKE_zggev_work( int matrix_order, char jobvl, char jobvr,\n                               lapack_int n, lapack_complex_double* a,\n                               lapack_int lda, lapack_complex_double* b,\n                               lapack_int ldb, lapack_complex_double* alpha,\n                               lapack_complex_double* beta,\n                               lapack_complex_double* vl, lapack_int ldvl,\n                               lapack_complex_double* vr, lapack_int ldvr,\n                               lapack_complex_double* work, lapack_int lwork,\n                               double* rwork );\n\nlapack_int LAPACKE_sggevx_work( int matrix_order, char balanc, char jobvl,\n                                char jobvr, char sense, lapack_int n, float* a,\n                                lapack_int lda, float* b, lapack_int ldb,\n                                float* alphar, float* alphai, float* beta,\n                                float* vl, lapack_int ldvl, float* vr,\n                                lapack_int ldvr, lapack_int* ilo,\n                                lapack_int* ihi, float* lscale, float* rscale,\n                                float* abnrm, float* bbnrm, float* rconde,\n                                float* rcondv, float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_logical* bwork );\nlapack_int LAPACKE_dggevx_work( int matrix_order, char balanc, char jobvl,\n                                char jobvr, char sense, lapack_int n, double* a,\n                                lapack_int lda, double* b, lapack_int ldb,\n                                double* alphar, double* alphai, double* beta,\n                                double* vl, lapack_int ldvl, double* vr,\n                                lapack_int ldvr, lapack_int* ilo,\n                                lapack_int* ihi, double* lscale, double* rscale,\n                                double* abnrm, double* bbnrm, double* rconde,\n                                double* rcondv, double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_logical* bwork );\nlapack_int LAPACKE_cggevx_work( int matrix_order, char balanc, char jobvl,\n                                char jobvr, char sense, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* alpha,\n                                lapack_complex_float* beta,\n                                lapack_complex_float* vl, lapack_int ldvl,\n                                lapack_complex_float* vr, lapack_int ldvr,\n                                lapack_int* ilo, lapack_int* ihi, float* lscale,\n                                float* rscale, float* abnrm, float* bbnrm,\n                                float* rconde, float* rcondv,\n                                lapack_complex_float* work, lapack_int lwork,\n                                float* rwork, lapack_int* iwork,\n                                lapack_logical* bwork );\nlapack_int LAPACKE_zggevx_work( int matrix_order, char balanc, char jobvl,\n                                char jobvr, char sense, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* alpha,\n                                lapack_complex_double* beta,\n                                lapack_complex_double* vl, lapack_int ldvl,\n                                lapack_complex_double* vr, lapack_int ldvr,\n                                lapack_int* ilo, lapack_int* ihi,\n                                double* lscale, double* rscale, double* abnrm,\n                                double* bbnrm, double* rconde, double* rcondv,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork, lapack_int* iwork,\n                                lapack_logical* bwork );\n\nlapack_int LAPACKE_sggglm_work( int matrix_order, lapack_int n, lapack_int m,\n                                lapack_int p, float* a, lapack_int lda,\n                                float* b, lapack_int ldb, float* d, float* x,\n                                float* y, float* work, lapack_int lwork );\nlapack_int LAPACKE_dggglm_work( int matrix_order, lapack_int n, lapack_int m,\n                                lapack_int p, double* a, lapack_int lda,\n                                double* b, lapack_int ldb, double* d, double* x,\n                                double* y, double* work, lapack_int lwork );\nlapack_int LAPACKE_cggglm_work( int matrix_order, lapack_int n, lapack_int m,\n                                lapack_int p, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* b,\n                                lapack_int ldb, lapack_complex_float* d,\n                                lapack_complex_float* x,\n                                lapack_complex_float* y,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zggglm_work( int matrix_order, lapack_int n, lapack_int m,\n                                lapack_int p, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* b,\n                                lapack_int ldb, lapack_complex_double* d,\n                                lapack_complex_double* x,\n                                lapack_complex_double* y,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sgghrd_work( int matrix_order, char compq, char compz,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                float* a, lapack_int lda, float* b,\n                                lapack_int ldb, float* q, lapack_int ldq,\n                                float* z, lapack_int ldz );\nlapack_int LAPACKE_dgghrd_work( int matrix_order, char compq, char compz,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                double* a, lapack_int lda, double* b,\n                                lapack_int ldb, double* q, lapack_int ldq,\n                                double* z, lapack_int ldz );\nlapack_int LAPACKE_cgghrd_work( int matrix_order, char compq, char compz,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* q, lapack_int ldq,\n                                lapack_complex_float* z, lapack_int ldz );\nlapack_int LAPACKE_zgghrd_work( int matrix_order, char compq, char compz,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* q, lapack_int ldq,\n                                lapack_complex_double* z, lapack_int ldz );\n\nlapack_int LAPACKE_sgglse_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int p, float* a, lapack_int lda,\n                                float* b, lapack_int ldb, float* c, float* d,\n                                float* x, float* work, lapack_int lwork );\nlapack_int LAPACKE_dgglse_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int p, double* a, lapack_int lda,\n                                double* b, lapack_int ldb, double* c, double* d,\n                                double* x, double* work, lapack_int lwork );\nlapack_int LAPACKE_cgglse_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int p, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* b,\n                                lapack_int ldb, lapack_complex_float* c,\n                                lapack_complex_float* d,\n                                lapack_complex_float* x,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zgglse_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int p, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* b,\n                                lapack_int ldb, lapack_complex_double* c,\n                                lapack_complex_double* d,\n                                lapack_complex_double* x,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sggqrf_work( int matrix_order, lapack_int n, lapack_int m,\n                                lapack_int p, float* a, lapack_int lda,\n                                float* taua, float* b, lapack_int ldb,\n                                float* taub, float* work, lapack_int lwork );\nlapack_int LAPACKE_dggqrf_work( int matrix_order, lapack_int n, lapack_int m,\n                                lapack_int p, double* a, lapack_int lda,\n                                double* taua, double* b, lapack_int ldb,\n                                double* taub, double* work, lapack_int lwork );\nlapack_int LAPACKE_cggqrf_work( int matrix_order, lapack_int n, lapack_int m,\n                                lapack_int p, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* taua,\n                                lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* taub,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zggqrf_work( int matrix_order, lapack_int n, lapack_int m,\n                                lapack_int p, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* taua,\n                                lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* taub,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sggrqf_work( int matrix_order, lapack_int m, lapack_int p,\n                                lapack_int n, float* a, lapack_int lda,\n                                float* taua, float* b, lapack_int ldb,\n                                float* taub, float* work, lapack_int lwork );\nlapack_int LAPACKE_dggrqf_work( int matrix_order, lapack_int m, lapack_int p,\n                                lapack_int n, double* a, lapack_int lda,\n                                double* taua, double* b, lapack_int ldb,\n                                double* taub, double* work, lapack_int lwork );\nlapack_int LAPACKE_cggrqf_work( int matrix_order, lapack_int m, lapack_int p,\n                                lapack_int n, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* taua,\n                                lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* taub,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zggrqf_work( int matrix_order, lapack_int m, lapack_int p,\n                                lapack_int n, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* taua,\n                                lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* taub,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sggsvd_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int n,\n                                lapack_int p, lapack_int* k, lapack_int* l,\n                                float* a, lapack_int lda, float* b,\n                                lapack_int ldb, float* alpha, float* beta,\n                                float* u, lapack_int ldu, float* v,\n                                lapack_int ldv, float* q, lapack_int ldq,\n                                float* work, lapack_int* iwork );\nlapack_int LAPACKE_dggsvd_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int n,\n                                lapack_int p, lapack_int* k, lapack_int* l,\n                                double* a, lapack_int lda, double* b,\n                                lapack_int ldb, double* alpha, double* beta,\n                                double* u, lapack_int ldu, double* v,\n                                lapack_int ldv, double* q, lapack_int ldq,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_cggsvd_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int n,\n                                lapack_int p, lapack_int* k, lapack_int* l,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* b, lapack_int ldb,\n                                float* alpha, float* beta,\n                                lapack_complex_float* u, lapack_int ldu,\n                                lapack_complex_float* v, lapack_int ldv,\n                                lapack_complex_float* q, lapack_int ldq,\n                                lapack_complex_float* work, float* rwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_zggsvd_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int n,\n                                lapack_int p, lapack_int* k, lapack_int* l,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb,\n                                double* alpha, double* beta,\n                                lapack_complex_double* u, lapack_int ldu,\n                                lapack_complex_double* v, lapack_int ldv,\n                                lapack_complex_double* q, lapack_int ldq,\n                                lapack_complex_double* work, double* rwork,\n                                lapack_int* iwork );\n\nlapack_int LAPACKE_sggsvp_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int p,\n                                lapack_int n, float* a, lapack_int lda,\n                                float* b, lapack_int ldb, float tola,\n                                float tolb, lapack_int* k, lapack_int* l,\n                                float* u, lapack_int ldu, float* v,\n                                lapack_int ldv, float* q, lapack_int ldq,\n                                lapack_int* iwork, float* tau, float* work );\nlapack_int LAPACKE_dggsvp_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int p,\n                                lapack_int n, double* a, lapack_int lda,\n                                double* b, lapack_int ldb, double tola,\n                                double tolb, lapack_int* k, lapack_int* l,\n                                double* u, lapack_int ldu, double* v,\n                                lapack_int ldv, double* q, lapack_int ldq,\n                                lapack_int* iwork, double* tau, double* work );\nlapack_int LAPACKE_cggsvp_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int p,\n                                lapack_int n, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* b,\n                                lapack_int ldb, float tola, float tolb,\n                                lapack_int* k, lapack_int* l,\n                                lapack_complex_float* u, lapack_int ldu,\n                                lapack_complex_float* v, lapack_int ldv,\n                                lapack_complex_float* q, lapack_int ldq,\n                                lapack_int* iwork, float* rwork,\n                                lapack_complex_float* tau,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zggsvp_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int p,\n                                lapack_int n, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* b,\n                                lapack_int ldb, double tola, double tolb,\n                                lapack_int* k, lapack_int* l,\n                                lapack_complex_double* u, lapack_int ldu,\n                                lapack_complex_double* v, lapack_int ldv,\n                                lapack_complex_double* q, lapack_int ldq,\n                                lapack_int* iwork, double* rwork,\n                                lapack_complex_double* tau,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_sgtcon_work( char norm, lapack_int n, const float* dl,\n                                const float* d, const float* du,\n                                const float* du2, const lapack_int* ipiv,\n                                float anorm, float* rcond, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dgtcon_work( char norm, lapack_int n, const double* dl,\n                                const double* d, const double* du,\n                                const double* du2, const lapack_int* ipiv,\n                                double anorm, double* rcond, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_cgtcon_work( char norm, lapack_int n,\n                                const lapack_complex_float* dl,\n                                const lapack_complex_float* d,\n                                const lapack_complex_float* du,\n                                const lapack_complex_float* du2,\n                                const lapack_int* ipiv, float anorm,\n                                float* rcond, lapack_complex_float* work );\nlapack_int LAPACKE_zgtcon_work( char norm, lapack_int n,\n                                const lapack_complex_double* dl,\n                                const lapack_complex_double* d,\n                                const lapack_complex_double* du,\n                                const lapack_complex_double* du2,\n                                const lapack_int* ipiv, double anorm,\n                                double* rcond, lapack_complex_double* work );\n\nlapack_int LAPACKE_sgtrfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const float* dl,\n                                const float* d, const float* du,\n                                const float* dlf, const float* df,\n                                const float* duf, const float* du2,\n                                const lapack_int* ipiv, const float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* ferr, float* berr, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dgtrfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const double* dl,\n                                const double* d, const double* du,\n                                const double* dlf, const double* df,\n                                const double* duf, const double* du2,\n                                const lapack_int* ipiv, const double* b,\n                                lapack_int ldb, double* x, lapack_int ldx,\n                                double* ferr, double* berr, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_cgtrfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* dl,\n                                const lapack_complex_float* d,\n                                const lapack_complex_float* du,\n                                const lapack_complex_float* dlf,\n                                const lapack_complex_float* df,\n                                const lapack_complex_float* duf,\n                                const lapack_complex_float* du2,\n                                const lapack_int* ipiv,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zgtrfs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs,\n                                const lapack_complex_double* dl,\n                                const lapack_complex_double* d,\n                                const lapack_complex_double* du,\n                                const lapack_complex_double* dlf,\n                                const lapack_complex_double* df,\n                                const lapack_complex_double* duf,\n                                const lapack_complex_double* du2,\n                                const lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sgtsv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               float* dl, float* d, float* du, float* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_dgtsv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               double* dl, double* d, double* du, double* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_cgtsv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               lapack_complex_float* dl,\n                               lapack_complex_float* d,\n                               lapack_complex_float* du,\n                               lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zgtsv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               lapack_complex_double* dl,\n                               lapack_complex_double* d,\n                               lapack_complex_double* du,\n                               lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_sgtsvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int nrhs, const float* dl,\n                                const float* d, const float* du, float* dlf,\n                                float* df, float* duf, float* du2,\n                                lapack_int* ipiv, const float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* rcond, float* ferr, float* berr,\n                                float* work, lapack_int* iwork );\nlapack_int LAPACKE_dgtsvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int nrhs, const double* dl,\n                                const double* d, const double* du, double* dlf,\n                                double* df, double* duf, double* du2,\n                                lapack_int* ipiv, const double* b,\n                                lapack_int ldb, double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_cgtsvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_float* dl,\n                                const lapack_complex_float* d,\n                                const lapack_complex_float* du,\n                                lapack_complex_float* dlf,\n                                lapack_complex_float* df,\n                                lapack_complex_float* duf,\n                                lapack_complex_float* du2, lapack_int* ipiv,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* rcond, float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zgtsvx_work( int matrix_order, char fact, char trans,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_double* dl,\n                                const lapack_complex_double* d,\n                                const lapack_complex_double* du,\n                                lapack_complex_double* dlf,\n                                lapack_complex_double* df,\n                                lapack_complex_double* duf,\n                                lapack_complex_double* du2, lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sgttrf_work( lapack_int n, float* dl, float* d, float* du,\n                                float* du2, lapack_int* ipiv );\nlapack_int LAPACKE_dgttrf_work( lapack_int n, double* dl, double* d, double* du,\n                                double* du2, lapack_int* ipiv );\nlapack_int LAPACKE_cgttrf_work( lapack_int n, lapack_complex_float* dl,\n                                lapack_complex_float* d,\n                                lapack_complex_float* du,\n                                lapack_complex_float* du2, lapack_int* ipiv );\nlapack_int LAPACKE_zgttrf_work( lapack_int n, lapack_complex_double* dl,\n                                lapack_complex_double* d,\n                                lapack_complex_double* du,\n                                lapack_complex_double* du2, lapack_int* ipiv );\n\nlapack_int LAPACKE_sgttrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const float* dl,\n                                const float* d, const float* du,\n                                const float* du2, const lapack_int* ipiv,\n                                float* b, lapack_int ldb );\nlapack_int LAPACKE_dgttrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const double* dl,\n                                const double* d, const double* du,\n                                const double* du2, const lapack_int* ipiv,\n                                double* b, lapack_int ldb );\nlapack_int LAPACKE_cgttrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* dl,\n                                const lapack_complex_float* d,\n                                const lapack_complex_float* du,\n                                const lapack_complex_float* du2,\n                                const lapack_int* ipiv, lapack_complex_float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_zgttrs_work( int matrix_order, char trans, lapack_int n,\n                                lapack_int nrhs,\n                                const lapack_complex_double* dl,\n                                const lapack_complex_double* d,\n                                const lapack_complex_double* du,\n                                const lapack_complex_double* du2,\n                                const lapack_int* ipiv,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_chbev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_int kd,\n                               lapack_complex_float* ab, lapack_int ldab,\n                               float* w, lapack_complex_float* z,\n                               lapack_int ldz, lapack_complex_float* work,\n                               float* rwork );\nlapack_int LAPACKE_zhbev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_int kd,\n                               lapack_complex_double* ab, lapack_int ldab,\n                               double* w, lapack_complex_double* z,\n                               lapack_int ldz, lapack_complex_double* work,\n                               double* rwork );\n\nlapack_int LAPACKE_chbevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_int kd,\n                                lapack_complex_float* ab, lapack_int ldab,\n                                float* w, lapack_complex_float* z,\n                                lapack_int ldz, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork,\n                                lapack_int lrwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_zhbevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_int kd,\n                                lapack_complex_double* ab, lapack_int ldab,\n                                double* w, lapack_complex_double* z,\n                                lapack_int ldz, lapack_complex_double* work,\n                                lapack_int lwork, double* rwork,\n                                lapack_int lrwork, lapack_int* iwork,\n                                lapack_int liwork );\n\nlapack_int LAPACKE_chbevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, lapack_int kd,\n                                lapack_complex_float* ab, lapack_int ldab,\n                                lapack_complex_float* q, lapack_int ldq,\n                                float vl, float vu, lapack_int il,\n                                lapack_int iu, float abstol, lapack_int* m,\n                                float* w, lapack_complex_float* z,\n                                lapack_int ldz, lapack_complex_float* work,\n                                float* rwork, lapack_int* iwork,\n                                lapack_int* ifail );\nlapack_int LAPACKE_zhbevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, lapack_int kd,\n                                lapack_complex_double* ab, lapack_int ldab,\n                                lapack_complex_double* q, lapack_int ldq,\n                                double vl, double vu, lapack_int il,\n                                lapack_int iu, double abstol, lapack_int* m,\n                                double* w, lapack_complex_double* z,\n                                lapack_int ldz, lapack_complex_double* work,\n                                double* rwork, lapack_int* iwork,\n                                lapack_int* ifail );\n\nlapack_int LAPACKE_chbgst_work( int matrix_order, char vect, char uplo,\n                                lapack_int n, lapack_int ka, lapack_int kb,\n                                lapack_complex_float* ab, lapack_int ldab,\n                                const lapack_complex_float* bb, lapack_int ldbb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zhbgst_work( int matrix_order, char vect, char uplo,\n                                lapack_int n, lapack_int ka, lapack_int kb,\n                                lapack_complex_double* ab, lapack_int ldab,\n                                const lapack_complex_double* bb,\n                                lapack_int ldbb, lapack_complex_double* x,\n                                lapack_int ldx, lapack_complex_double* work,\n                                double* rwork );\n\nlapack_int LAPACKE_chbgv_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_int ka, lapack_int kb,\n                               lapack_complex_float* ab, lapack_int ldab,\n                               lapack_complex_float* bb, lapack_int ldbb,\n                               float* w, lapack_complex_float* z,\n                               lapack_int ldz, lapack_complex_float* work,\n                               float* rwork );\nlapack_int LAPACKE_zhbgv_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_int ka, lapack_int kb,\n                               lapack_complex_double* ab, lapack_int ldab,\n                               lapack_complex_double* bb, lapack_int ldbb,\n                               double* w, lapack_complex_double* z,\n                               lapack_int ldz, lapack_complex_double* work,\n                               double* rwork );\n\nlapack_int LAPACKE_chbgvd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_int ka, lapack_int kb,\n                                lapack_complex_float* ab, lapack_int ldab,\n                                lapack_complex_float* bb, lapack_int ldbb,\n                                float* w, lapack_complex_float* z,\n                                lapack_int ldz, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork,\n                                lapack_int lrwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_zhbgvd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_int ka, lapack_int kb,\n                                lapack_complex_double* ab, lapack_int ldab,\n                                lapack_complex_double* bb, lapack_int ldbb,\n                                double* w, lapack_complex_double* z,\n                                lapack_int ldz, lapack_complex_double* work,\n                                lapack_int lwork, double* rwork,\n                                lapack_int lrwork, lapack_int* iwork,\n                                lapack_int liwork );\n\nlapack_int LAPACKE_chbgvx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, lapack_int ka,\n                                lapack_int kb, lapack_complex_float* ab,\n                                lapack_int ldab, lapack_complex_float* bb,\n                                lapack_int ldbb, lapack_complex_float* q,\n                                lapack_int ldq, float vl, float vu,\n                                lapack_int il, lapack_int iu, float abstol,\n                                lapack_int* m, float* w,\n                                lapack_complex_float* z, lapack_int ldz,\n                                lapack_complex_float* work, float* rwork,\n                                lapack_int* iwork, lapack_int* ifail );\nlapack_int LAPACKE_zhbgvx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, lapack_int ka,\n                                lapack_int kb, lapack_complex_double* ab,\n                                lapack_int ldab, lapack_complex_double* bb,\n                                lapack_int ldbb, lapack_complex_double* q,\n                                lapack_int ldq, double vl, double vu,\n                                lapack_int il, lapack_int iu, double abstol,\n                                lapack_int* m, double* w,\n                                lapack_complex_double* z, lapack_int ldz,\n                                lapack_complex_double* work, double* rwork,\n                                lapack_int* iwork, lapack_int* ifail );\n\nlapack_int LAPACKE_chbtrd_work( int matrix_order, char vect, char uplo,\n                                lapack_int n, lapack_int kd,\n                                lapack_complex_float* ab, lapack_int ldab,\n                                float* d, float* e, lapack_complex_float* q,\n                                lapack_int ldq, lapack_complex_float* work );\nlapack_int LAPACKE_zhbtrd_work( int matrix_order, char vect, char uplo,\n                                lapack_int n, lapack_int kd,\n                                lapack_complex_double* ab, lapack_int ldab,\n                                double* d, double* e, lapack_complex_double* q,\n                                lapack_int ldq, lapack_complex_double* work );\n\nlapack_int LAPACKE_checon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                const lapack_int* ipiv, float anorm,\n                                float* rcond, lapack_complex_float* work );\nlapack_int LAPACKE_zhecon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                const lapack_int* ipiv, double anorm,\n                                double* rcond, lapack_complex_double* work );\n\nlapack_int LAPACKE_cheequb_work( int matrix_order, char uplo, lapack_int n,\n                                 const lapack_complex_float* a, lapack_int lda,\n                                 float* s, float* scond, float* amax,\n                                 lapack_complex_float* work );\nlapack_int LAPACKE_zheequb_work( int matrix_order, char uplo, lapack_int n,\n                                 const lapack_complex_double* a, lapack_int lda,\n                                 double* s, double* scond, double* amax,\n                                 lapack_complex_double* work );\n\nlapack_int LAPACKE_cheev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_complex_float* a,\n                               lapack_int lda, float* w,\n                               lapack_complex_float* work, lapack_int lwork,\n                               float* rwork );\nlapack_int LAPACKE_zheev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_complex_double* a,\n                               lapack_int lda, double* w,\n                               lapack_complex_double* work, lapack_int lwork,\n                               double* rwork );\n\nlapack_int LAPACKE_cheevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_complex_float* a,\n                                lapack_int lda, float* w,\n                                lapack_complex_float* work, lapack_int lwork,\n                                float* rwork, lapack_int lrwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_zheevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_complex_double* a,\n                                lapack_int lda, double* w,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork, lapack_int lrwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_cheevr_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                float vl, float vu, lapack_int il,\n                                lapack_int iu, float abstol, lapack_int* m,\n                                float* w, lapack_complex_float* z,\n                                lapack_int ldz, lapack_int* isuppz,\n                                lapack_complex_float* work, lapack_int lwork,\n                                float* rwork, lapack_int lrwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_zheevr_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                double vl, double vu, lapack_int il,\n                                lapack_int iu, double abstol, lapack_int* m,\n                                double* w, lapack_complex_double* z,\n                                lapack_int ldz, lapack_int* isuppz,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork, lapack_int lrwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_cheevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                float vl, float vu, lapack_int il,\n                                lapack_int iu, float abstol, lapack_int* m,\n                                float* w, lapack_complex_float* z,\n                                lapack_int ldz, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork,\n                                lapack_int* iwork, lapack_int* ifail );\nlapack_int LAPACKE_zheevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                double vl, double vu, lapack_int il,\n                                lapack_int iu, double abstol, lapack_int* m,\n                                double* w, lapack_complex_double* z,\n                                lapack_int ldz, lapack_complex_double* work,\n                                lapack_int lwork, double* rwork,\n                                lapack_int* iwork, lapack_int* ifail );\n\nlapack_int LAPACKE_chegst_work( int matrix_order, lapack_int itype, char uplo,\n                                lapack_int n, lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_zhegst_work( int matrix_order, lapack_int itype, char uplo,\n                                lapack_int n, lapack_complex_double* a,\n                                lapack_int lda, const lapack_complex_double* b,\n                                lapack_int ldb );\n\nlapack_int LAPACKE_chegv_work( int matrix_order, lapack_int itype, char jobz,\n                               char uplo, lapack_int n, lapack_complex_float* a,\n                               lapack_int lda, lapack_complex_float* b,\n                               lapack_int ldb, float* w,\n                               lapack_complex_float* work, lapack_int lwork,\n                               float* rwork );\nlapack_int LAPACKE_zhegv_work( int matrix_order, lapack_int itype, char jobz,\n                               char uplo, lapack_int n,\n                               lapack_complex_double* a, lapack_int lda,\n                               lapack_complex_double* b, lapack_int ldb,\n                               double* w, lapack_complex_double* work,\n                               lapack_int lwork, double* rwork );\n\nlapack_int LAPACKE_chegvd_work( int matrix_order, lapack_int itype, char jobz,\n                                char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* b, lapack_int ldb,\n                                float* w, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork,\n                                lapack_int lrwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_zhegvd_work( int matrix_order, lapack_int itype, char jobz,\n                                char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb,\n                                double* w, lapack_complex_double* work,\n                                lapack_int lwork, double* rwork,\n                                lapack_int lrwork, lapack_int* iwork,\n                                lapack_int liwork );\n\nlapack_int LAPACKE_chegvx_work( int matrix_order, lapack_int itype, char jobz,\n                                char range, char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* b, lapack_int ldb,\n                                float vl, float vu, lapack_int il,\n                                lapack_int iu, float abstol, lapack_int* m,\n                                float* w, lapack_complex_float* z,\n                                lapack_int ldz, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork,\n                                lapack_int* iwork, lapack_int* ifail );\nlapack_int LAPACKE_zhegvx_work( int matrix_order, lapack_int itype, char jobz,\n                                char range, char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb,\n                                double vl, double vu, lapack_int il,\n                                lapack_int iu, double abstol, lapack_int* m,\n                                double* w, lapack_complex_double* z,\n                                lapack_int ldz, lapack_complex_double* work,\n                                lapack_int lwork, double* rwork,\n                                lapack_int* iwork, lapack_int* ifail );\n\nlapack_int LAPACKE_cherfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* af,\n                                lapack_int ldaf, const lapack_int* ipiv,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zherfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_double* a,\n                                lapack_int lda, const lapack_complex_double* af,\n                                lapack_int ldaf, const lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_cherfsx_work( int matrix_order, char uplo, char equed,\n                                 lapack_int n, lapack_int nrhs,\n                                 const lapack_complex_float* a, lapack_int lda,\n                                 const lapack_complex_float* af,\n                                 lapack_int ldaf, const lapack_int* ipiv,\n                                 const float* s, const lapack_complex_float* b,\n                                 lapack_int ldb, lapack_complex_float* x,\n                                 lapack_int ldx, float* rcond, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, lapack_complex_float* work,\n                                 float* rwork );\nlapack_int LAPACKE_zherfsx_work( int matrix_order, char uplo, char equed,\n                                 lapack_int n, lapack_int nrhs,\n                                 const lapack_complex_double* a, lapack_int lda,\n                                 const lapack_complex_double* af,\n                                 lapack_int ldaf, const lapack_int* ipiv,\n                                 const double* s,\n                                 const lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* x, lapack_int ldx,\n                                 double* rcond, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, lapack_complex_double* work,\n                                 double* rwork );\n\nlapack_int LAPACKE_chesv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_float* a,\n                               lapack_int lda, lapack_int* ipiv,\n                               lapack_complex_float* b, lapack_int ldb,\n                               lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zhesv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_double* a,\n                               lapack_int lda, lapack_int* ipiv,\n                               lapack_complex_double* b, lapack_int ldb,\n                               lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_chesvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* af, lapack_int ldaf,\n                                lapack_int* ipiv, const lapack_complex_float* b,\n                                lapack_int ldb, lapack_complex_float* x,\n                                lapack_int ldx, float* rcond, float* ferr,\n                                float* berr, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork );\nlapack_int LAPACKE_zhesvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* af, lapack_int ldaf,\n                                lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork );\n\nlapack_int LAPACKE_chesvxx_work( int matrix_order, char fact, char uplo,\n                                 lapack_int n, lapack_int nrhs,\n                                 lapack_complex_float* a, lapack_int lda,\n                                 lapack_complex_float* af, lapack_int ldaf,\n                                 lapack_int* ipiv, char* equed, float* s,\n                                 lapack_complex_float* b, lapack_int ldb,\n                                 lapack_complex_float* x, lapack_int ldx,\n                                 float* rcond, float* rpvgrw, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, lapack_complex_float* work,\n                                 float* rwork );\nlapack_int LAPACKE_zhesvxx_work( int matrix_order, char fact, char uplo,\n                                 lapack_int n, lapack_int nrhs,\n                                 lapack_complex_double* a, lapack_int lda,\n                                 lapack_complex_double* af, lapack_int ldaf,\n                                 lapack_int* ipiv, char* equed, double* s,\n                                 lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* x, lapack_int ldx,\n                                 double* rcond, double* rpvgrw, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, lapack_complex_double* work,\n                                 double* rwork );\n\nlapack_int LAPACKE_chetrd_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                float* d, float* e, lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zhetrd_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                double* d, double* e,\n                                lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_chetrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_int* ipiv, lapack_complex_float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_zhetrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_int* ipiv, lapack_complex_double* work,\n                                lapack_int lwork );\n\nlapack_int LAPACKE_chetri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                const lapack_int* ipiv,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zhetri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                const lapack_int* ipiv,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_chetrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* a,\n                                lapack_int lda, const lapack_int* ipiv,\n                                lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zhetrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_double* a,\n                                lapack_int lda, const lapack_int* ipiv,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_chfrk_work( int matrix_order, char transr, char uplo,\n                               char trans, lapack_int n, lapack_int k,\n                               float alpha, const lapack_complex_float* a,\n                               lapack_int lda, float beta,\n                               lapack_complex_float* c );\nlapack_int LAPACKE_zhfrk_work( int matrix_order, char transr, char uplo,\n                               char trans, lapack_int n, lapack_int k,\n                               double alpha, const lapack_complex_double* a,\n                               lapack_int lda, double beta,\n                               lapack_complex_double* c );\n\nlapack_int LAPACKE_shgeqz_work( int matrix_order, char job, char compq,\n                                char compz, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, float* h, lapack_int ldh,\n                                float* t, lapack_int ldt, float* alphar,\n                                float* alphai, float* beta, float* q,\n                                lapack_int ldq, float* z, lapack_int ldz,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dhgeqz_work( int matrix_order, char job, char compq,\n                                char compz, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, double* h, lapack_int ldh,\n                                double* t, lapack_int ldt, double* alphar,\n                                double* alphai, double* beta, double* q,\n                                lapack_int ldq, double* z, lapack_int ldz,\n                                double* work, lapack_int lwork );\nlapack_int LAPACKE_chgeqz_work( int matrix_order, char job, char compq,\n                                char compz, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, lapack_complex_float* h,\n                                lapack_int ldh, lapack_complex_float* t,\n                                lapack_int ldt, lapack_complex_float* alpha,\n                                lapack_complex_float* beta,\n                                lapack_complex_float* q, lapack_int ldq,\n                                lapack_complex_float* z, lapack_int ldz,\n                                lapack_complex_float* work, lapack_int lwork,\n                                float* rwork );\nlapack_int LAPACKE_zhgeqz_work( int matrix_order, char job, char compq,\n                                char compz, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, lapack_complex_double* h,\n                                lapack_int ldh, lapack_complex_double* t,\n                                lapack_int ldt, lapack_complex_double* alpha,\n                                lapack_complex_double* beta,\n                                lapack_complex_double* q, lapack_int ldq,\n                                lapack_complex_double* z, lapack_int ldz,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork );\n\nlapack_int LAPACKE_chpcon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_float* ap,\n                                const lapack_int* ipiv, float anorm,\n                                float* rcond, lapack_complex_float* work );\nlapack_int LAPACKE_zhpcon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_double* ap,\n                                const lapack_int* ipiv, double anorm,\n                                double* rcond, lapack_complex_double* work );\n\nlapack_int LAPACKE_chpev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_complex_float* ap, float* w,\n                               lapack_complex_float* z, lapack_int ldz,\n                               lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zhpev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_complex_double* ap,\n                               double* w, lapack_complex_double* z,\n                               lapack_int ldz, lapack_complex_double* work,\n                               double* rwork );\n\nlapack_int LAPACKE_chpevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_complex_float* ap,\n                                float* w, lapack_complex_float* z,\n                                lapack_int ldz, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork,\n                                lapack_int lrwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_zhpevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_complex_double* ap,\n                                double* w, lapack_complex_double* z,\n                                lapack_int ldz, lapack_complex_double* work,\n                                lapack_int lwork, double* rwork,\n                                lapack_int lrwork, lapack_int* iwork,\n                                lapack_int liwork );\n\nlapack_int LAPACKE_chpevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n,\n                                lapack_complex_float* ap, float vl, float vu,\n                                lapack_int il, lapack_int iu, float abstol,\n                                lapack_int* m, float* w,\n                                lapack_complex_float* z, lapack_int ldz,\n                                lapack_complex_float* work, float* rwork,\n                                lapack_int* iwork, lapack_int* ifail );\nlapack_int LAPACKE_zhpevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n,\n                                lapack_complex_double* ap, double vl, double vu,\n                                lapack_int il, lapack_int iu, double abstol,\n                                lapack_int* m, double* w,\n                                lapack_complex_double* z, lapack_int ldz,\n                                lapack_complex_double* work, double* rwork,\n                                lapack_int* iwork, lapack_int* ifail );\n\nlapack_int LAPACKE_chpgst_work( int matrix_order, lapack_int itype, char uplo,\n                                lapack_int n, lapack_complex_float* ap,\n                                const lapack_complex_float* bp );\nlapack_int LAPACKE_zhpgst_work( int matrix_order, lapack_int itype, char uplo,\n                                lapack_int n, lapack_complex_double* ap,\n                                const lapack_complex_double* bp );\n\nlapack_int LAPACKE_chpgv_work( int matrix_order, lapack_int itype, char jobz,\n                               char uplo, lapack_int n,\n                               lapack_complex_float* ap,\n                               lapack_complex_float* bp, float* w,\n                               lapack_complex_float* z, lapack_int ldz,\n                               lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zhpgv_work( int matrix_order, lapack_int itype, char jobz,\n                               char uplo, lapack_int n,\n                               lapack_complex_double* ap,\n                               lapack_complex_double* bp, double* w,\n                               lapack_complex_double* z, lapack_int ldz,\n                               lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_chpgvd_work( int matrix_order, lapack_int itype, char jobz,\n                                char uplo, lapack_int n,\n                                lapack_complex_float* ap,\n                                lapack_complex_float* bp, float* w,\n                                lapack_complex_float* z, lapack_int ldz,\n                                lapack_complex_float* work, lapack_int lwork,\n                                float* rwork, lapack_int lrwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_zhpgvd_work( int matrix_order, lapack_int itype, char jobz,\n                                char uplo, lapack_int n,\n                                lapack_complex_double* ap,\n                                lapack_complex_double* bp, double* w,\n                                lapack_complex_double* z, lapack_int ldz,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork, lapack_int lrwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_chpgvx_work( int matrix_order, lapack_int itype, char jobz,\n                                char range, char uplo, lapack_int n,\n                                lapack_complex_float* ap,\n                                lapack_complex_float* bp, float vl, float vu,\n                                lapack_int il, lapack_int iu, float abstol,\n                                lapack_int* m, float* w,\n                                lapack_complex_float* z, lapack_int ldz,\n                                lapack_complex_float* work, float* rwork,\n                                lapack_int* iwork, lapack_int* ifail );\nlapack_int LAPACKE_zhpgvx_work( int matrix_order, lapack_int itype, char jobz,\n                                char range, char uplo, lapack_int n,\n                                lapack_complex_double* ap,\n                                lapack_complex_double* bp, double vl, double vu,\n                                lapack_int il, lapack_int iu, double abstol,\n                                lapack_int* m, double* w,\n                                lapack_complex_double* z, lapack_int ldz,\n                                lapack_complex_double* work, double* rwork,\n                                lapack_int* iwork, lapack_int* ifail );\n\nlapack_int LAPACKE_chprfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* ap,\n                                const lapack_complex_float* afp,\n                                const lapack_int* ipiv,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zhprfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs,\n                                const lapack_complex_double* ap,\n                                const lapack_complex_double* afp,\n                                const lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_chpsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_float* ap,\n                               lapack_int* ipiv, lapack_complex_float* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_zhpsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_double* ap,\n                               lapack_int* ipiv, lapack_complex_double* b,\n                               lapack_int ldb );\n\nlapack_int LAPACKE_chpsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_float* ap,\n                                lapack_complex_float* afp, lapack_int* ipiv,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* rcond, float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zhpsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_double* ap,\n                                lapack_complex_double* afp, lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_chptrd_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* ap, float* d, float* e,\n                                lapack_complex_float* tau );\nlapack_int LAPACKE_zhptrd_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* ap, double* d, double* e,\n                                lapack_complex_double* tau );\n\nlapack_int LAPACKE_chptrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* ap, lapack_int* ipiv );\nlapack_int LAPACKE_zhptrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* ap, lapack_int* ipiv );\n\nlapack_int LAPACKE_chptri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* ap,\n                                const lapack_int* ipiv,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zhptri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* ap,\n                                const lapack_int* ipiv,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_chptrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* ap,\n                                const lapack_int* ipiv, lapack_complex_float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_zhptrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs,\n                                const lapack_complex_double* ap,\n                                const lapack_int* ipiv,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_shsein_work( int matrix_order, char job, char eigsrc,\n                                char initv, lapack_logical* select,\n                                lapack_int n, const float* h, lapack_int ldh,\n                                float* wr, const float* wi, float* vl,\n                                lapack_int ldvl, float* vr, lapack_int ldvr,\n                                lapack_int mm, lapack_int* m, float* work,\n                                lapack_int* ifaill, lapack_int* ifailr );\nlapack_int LAPACKE_dhsein_work( int matrix_order, char job, char eigsrc,\n                                char initv, lapack_logical* select,\n                                lapack_int n, const double* h, lapack_int ldh,\n                                double* wr, const double* wi, double* vl,\n                                lapack_int ldvl, double* vr, lapack_int ldvr,\n                                lapack_int mm, lapack_int* m, double* work,\n                                lapack_int* ifaill, lapack_int* ifailr );\nlapack_int LAPACKE_chsein_work( int matrix_order, char job, char eigsrc,\n                                char initv, const lapack_logical* select,\n                                lapack_int n, const lapack_complex_float* h,\n                                lapack_int ldh, lapack_complex_float* w,\n                                lapack_complex_float* vl, lapack_int ldvl,\n                                lapack_complex_float* vr, lapack_int ldvr,\n                                lapack_int mm, lapack_int* m,\n                                lapack_complex_float* work, float* rwork,\n                                lapack_int* ifaill, lapack_int* ifailr );\nlapack_int LAPACKE_zhsein_work( int matrix_order, char job, char eigsrc,\n                                char initv, const lapack_logical* select,\n                                lapack_int n, const lapack_complex_double* h,\n                                lapack_int ldh, lapack_complex_double* w,\n                                lapack_complex_double* vl, lapack_int ldvl,\n                                lapack_complex_double* vr, lapack_int ldvr,\n                                lapack_int mm, lapack_int* m,\n                                lapack_complex_double* work, double* rwork,\n                                lapack_int* ifaill, lapack_int* ifailr );\n\nlapack_int LAPACKE_shseqr_work( int matrix_order, char job, char compz,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                float* h, lapack_int ldh, float* wr, float* wi,\n                                float* z, lapack_int ldz, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dhseqr_work( int matrix_order, char job, char compz,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                double* h, lapack_int ldh, double* wr,\n                                double* wi, double* z, lapack_int ldz,\n                                double* work, lapack_int lwork );\nlapack_int LAPACKE_chseqr_work( int matrix_order, char job, char compz,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                lapack_complex_float* h, lapack_int ldh,\n                                lapack_complex_float* w,\n                                lapack_complex_float* z, lapack_int ldz,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zhseqr_work( int matrix_order, char job, char compz,\n                                lapack_int n, lapack_int ilo, lapack_int ihi,\n                                lapack_complex_double* h, lapack_int ldh,\n                                lapack_complex_double* w,\n                                lapack_complex_double* z, lapack_int ldz,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_clacgv_work( lapack_int n, lapack_complex_float* x,\n                                lapack_int incx );\nlapack_int LAPACKE_zlacgv_work( lapack_int n, lapack_complex_double* x,\n                                lapack_int incx );\n\nlapack_int LAPACKE_slacpy_work( int matrix_order, char uplo, lapack_int m,\n                                lapack_int n, const float* a, lapack_int lda,\n                                float* b, lapack_int ldb );\nlapack_int LAPACKE_dlacpy_work( int matrix_order, char uplo, lapack_int m,\n                                lapack_int n, const double* a, lapack_int lda,\n                                double* b, lapack_int ldb );\nlapack_int LAPACKE_clacpy_work( int matrix_order, char uplo, lapack_int m,\n                                lapack_int n, const lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_zlacpy_work( int matrix_order, char uplo, lapack_int m,\n                                lapack_int n, const lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* b,\n                                lapack_int ldb );\n\nlapack_int LAPACKE_zlag2c_work( int matrix_order, lapack_int m, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_float* sa, lapack_int ldsa );\n\nlapack_int LAPACKE_slag2d_work( int matrix_order, lapack_int m, lapack_int n,\n                                const float* sa, lapack_int ldsa, double* a,\n                                lapack_int lda );\n\nlapack_int LAPACKE_dlag2s_work( int matrix_order, lapack_int m, lapack_int n,\n                                const double* a, lapack_int lda, float* sa,\n                                lapack_int ldsa );\n\nlapack_int LAPACKE_clag2z_work( int matrix_order, lapack_int m, lapack_int n,\n                                const lapack_complex_float* sa, lapack_int ldsa,\n                                lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_slagge_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku, const float* d,\n                                float* a, lapack_int lda, lapack_int* iseed,\n                                float* work );\nlapack_int LAPACKE_dlagge_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku, const double* d,\n                                double* a, lapack_int lda, lapack_int* iseed,\n                                double* work );\nlapack_int LAPACKE_clagge_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku, const float* d,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_int* iseed, lapack_complex_float* work );\nlapack_int LAPACKE_zlagge_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int kl, lapack_int ku, const double* d,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_int* iseed,\n                                lapack_complex_double* work );\n                                \nlapack_int LAPACKE_claghe_work( int matrix_order, lapack_int n, lapack_int k,\n                                const float* d, lapack_complex_float* a,\n                                lapack_int lda, lapack_int* iseed,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zlaghe_work( int matrix_order, lapack_int n, lapack_int k,\n                                const double* d, lapack_complex_double* a,\n                                lapack_int lda, lapack_int* iseed,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_slagsy_work( int matrix_order, lapack_int n, lapack_int k,\n                                const float* d, float* a, lapack_int lda,\n                                lapack_int* iseed, float* work );\nlapack_int LAPACKE_dlagsy_work( int matrix_order, lapack_int n, lapack_int k,\n                                const double* d, double* a, lapack_int lda,\n                                lapack_int* iseed, double* work );\nlapack_int LAPACKE_clagsy_work( int matrix_order, lapack_int n, lapack_int k,\n                                const float* d, lapack_complex_float* a,\n                                lapack_int lda, lapack_int* iseed,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zlagsy_work( int matrix_order, lapack_int n, lapack_int k,\n                                const double* d, lapack_complex_double* a,\n                                lapack_int lda, lapack_int* iseed,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_slapmr_work( int matrix_order, lapack_logical forwrd,\n                                lapack_int m, lapack_int n, float* x,\n                                lapack_int ldx, lapack_int* k );\nlapack_int LAPACKE_dlapmr_work( int matrix_order, lapack_logical forwrd,\n                                lapack_int m, lapack_int n, double* x,\n                                lapack_int ldx, lapack_int* k );\nlapack_int LAPACKE_clapmr_work( int matrix_order, lapack_logical forwrd,\n                                lapack_int m, lapack_int n,\n                                lapack_complex_float* x, lapack_int ldx,\n                                lapack_int* k );\nlapack_int LAPACKE_zlapmr_work( int matrix_order, lapack_logical forwrd,\n                                lapack_int m, lapack_int n,\n                                lapack_complex_double* x, lapack_int ldx,\n                                lapack_int* k );\n\nlapack_int LAPACKE_slartgp_work( float f, float g, float* cs, float* sn,\n                                 float* r );\nlapack_int LAPACKE_dlartgp_work( double f, double g, double* cs, double* sn,\n                                 double* r );\n\nlapack_int LAPACKE_slartgs_work( float x, float y, float sigma, float* cs,\n                                 float* sn );\nlapack_int LAPACKE_dlartgs_work( double x, double y, double sigma, double* cs,\n                                 double* sn );\n                                \nfloat LAPACKE_slapy2_work( float x, float y );\ndouble LAPACKE_dlapy2_work( double x, double y );\n\nfloat LAPACKE_slapy3_work( float x, float y, float z );\ndouble LAPACKE_dlapy3_work( double x, double y, double z );\n\nfloat LAPACKE_slamch_work( char cmach );\ndouble LAPACKE_dlamch_work( char cmach );\n\nfloat LAPACKE_slange_work( int matrix_order, char norm, lapack_int m,\n                                lapack_int n, const float* a, lapack_int lda,\n                                float* work );\ndouble LAPACKE_dlange_work( int matrix_order, char norm, lapack_int m,\n                                lapack_int n, const double* a, lapack_int lda,\n                                double* work );\nfloat LAPACKE_clange_work( int matrix_order, char norm, lapack_int m,\n                                lapack_int n, const lapack_complex_float* a,\n                                lapack_int lda, float* work );\ndouble LAPACKE_zlange_work( int matrix_order, char norm, lapack_int m,\n                                lapack_int n, const lapack_complex_double* a,\n                                lapack_int lda, double* work );\n\nfloat LAPACKE_clanhe_work( int matrix_order, char norm, char uplo,\n                                lapack_int n, const lapack_complex_float* a,\n                                lapack_int lda, float* work );\ndouble LAPACKE_zlanhe_work( int matrix_order, char norm, char uplo,\n                                lapack_int n, const lapack_complex_double* a,\n                                lapack_int lda, double* work );\n\nfloat LAPACKE_slansy_work( int matrix_order, char norm, char uplo,\n                                lapack_int n, const float* a, lapack_int lda,\n                                float* work );\ndouble LAPACKE_dlansy_work( int matrix_order, char norm, char uplo,\n                                lapack_int n, const double* a, lapack_int lda,\n                                double* work );\nfloat LAPACKE_clansy_work( int matrix_order, char norm, char uplo,\n                                lapack_int n, const lapack_complex_float* a,\n                                lapack_int lda, float* work );\ndouble LAPACKE_zlansy_work( int matrix_order, char norm, char uplo,\n                                lapack_int n, const lapack_complex_double* a,\n                                lapack_int lda, double* work );\n\nfloat LAPACKE_slantr_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int m, lapack_int n, const float* a,\n                                lapack_int lda, float* work );\ndouble LAPACKE_dlantr_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int m, lapack_int n,\n                                const double* a, lapack_int lda, double* work );\nfloat LAPACKE_clantr_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int m, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                float* work );\ndouble LAPACKE_zlantr_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int m, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                double* work );\n\nlapack_int LAPACKE_slarfb_work( int matrix_order, char side, char trans,\n                                char direct, char storev, lapack_int m,\n                                lapack_int n, lapack_int k, const float* v,\n                                lapack_int ldv, const float* t, lapack_int ldt,\n                                float* c, lapack_int ldc, float* work,\n                                lapack_int ldwork );\nlapack_int LAPACKE_dlarfb_work( int matrix_order, char side, char trans,\n                                char direct, char storev, lapack_int m,\n                                lapack_int n, lapack_int k, const double* v,\n                                lapack_int ldv, const double* t, lapack_int ldt,\n                                double* c, lapack_int ldc, double* work,\n                                lapack_int ldwork );\nlapack_int LAPACKE_clarfb_work( int matrix_order, char side, char trans,\n                                char direct, char storev, lapack_int m,\n                                lapack_int n, lapack_int k,\n                                const lapack_complex_float* v, lapack_int ldv,\n                                const lapack_complex_float* t, lapack_int ldt,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work, lapack_int ldwork );\nlapack_int LAPACKE_zlarfb_work( int matrix_order, char side, char trans,\n                                char direct, char storev, lapack_int m,\n                                lapack_int n, lapack_int k,\n                                const lapack_complex_double* v, lapack_int ldv,\n                                const lapack_complex_double* t, lapack_int ldt,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work,\n                                lapack_int ldwork );\n\nlapack_int LAPACKE_slarfg_work( lapack_int n, float* alpha, float* x,\n                                lapack_int incx, float* tau );\nlapack_int LAPACKE_dlarfg_work( lapack_int n, double* alpha, double* x,\n                                lapack_int incx, double* tau );\nlapack_int LAPACKE_clarfg_work( lapack_int n, lapack_complex_float* alpha,\n                                lapack_complex_float* x, lapack_int incx,\n                                lapack_complex_float* tau );\nlapack_int LAPACKE_zlarfg_work( lapack_int n, lapack_complex_double* alpha,\n                                lapack_complex_double* x, lapack_int incx,\n                                lapack_complex_double* tau );\n\nlapack_int LAPACKE_slarft_work( int matrix_order, char direct, char storev,\n                                lapack_int n, lapack_int k, const float* v,\n                                lapack_int ldv, const float* tau, float* t,\n                                lapack_int ldt );\nlapack_int LAPACKE_dlarft_work( int matrix_order, char direct, char storev,\n                                lapack_int n, lapack_int k, const double* v,\n                                lapack_int ldv, const double* tau, double* t,\n                                lapack_int ldt );\nlapack_int LAPACKE_clarft_work( int matrix_order, char direct, char storev,\n                                lapack_int n, lapack_int k,\n                                const lapack_complex_float* v, lapack_int ldv,\n                                const lapack_complex_float* tau,\n                                lapack_complex_float* t, lapack_int ldt );\nlapack_int LAPACKE_zlarft_work( int matrix_order, char direct, char storev,\n                                lapack_int n, lapack_int k,\n                                const lapack_complex_double* v, lapack_int ldv,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* t, lapack_int ldt );\n\nlapack_int LAPACKE_slarfx_work( int matrix_order, char side, lapack_int m,\n                                lapack_int n, const float* v, float tau,\n                                float* c, lapack_int ldc, float* work );\nlapack_int LAPACKE_dlarfx_work( int matrix_order, char side, lapack_int m,\n                                lapack_int n, const double* v, double tau,\n                                double* c, lapack_int ldc, double* work );\nlapack_int LAPACKE_clarfx_work( int matrix_order, char side, lapack_int m,\n                                lapack_int n, const lapack_complex_float* v,\n                                lapack_complex_float tau,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zlarfx_work( int matrix_order, char side, lapack_int m,\n                                lapack_int n, const lapack_complex_double* v,\n                                lapack_complex_double tau,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_slarnv_work( lapack_int idist, lapack_int* iseed,\n                                lapack_int n, float* x );\nlapack_int LAPACKE_dlarnv_work( lapack_int idist, lapack_int* iseed,\n                                lapack_int n, double* x );\nlapack_int LAPACKE_clarnv_work( lapack_int idist, lapack_int* iseed,\n                                lapack_int n, lapack_complex_float* x );\nlapack_int LAPACKE_zlarnv_work( lapack_int idist, lapack_int* iseed,\n                                lapack_int n, lapack_complex_double* x );\n\nlapack_int LAPACKE_slaset_work( int matrix_order, char uplo, lapack_int m,\n                                lapack_int n, float alpha, float beta, float* a,\n                                lapack_int lda );\nlapack_int LAPACKE_dlaset_work( int matrix_order, char uplo, lapack_int m,\n                                lapack_int n, double alpha, double beta,\n                                double* a, lapack_int lda );\nlapack_int LAPACKE_claset_work( int matrix_order, char uplo, lapack_int m,\n                                lapack_int n, lapack_complex_float alpha,\n                                lapack_complex_float beta,\n                                lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_zlaset_work( int matrix_order, char uplo, lapack_int m,\n                                lapack_int n, lapack_complex_double alpha,\n                                lapack_complex_double beta,\n                                lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_slasrt_work( char id, lapack_int n, float* d );\nlapack_int LAPACKE_dlasrt_work( char id, lapack_int n, double* d );\n\nlapack_int LAPACKE_slaswp_work( int matrix_order, lapack_int n, float* a,\n                                lapack_int lda, lapack_int k1, lapack_int k2,\n                                const lapack_int* ipiv, lapack_int incx );\nlapack_int LAPACKE_dlaswp_work( int matrix_order, lapack_int n, double* a,\n                                lapack_int lda, lapack_int k1, lapack_int k2,\n                                const lapack_int* ipiv, lapack_int incx );\nlapack_int LAPACKE_claswp_work( int matrix_order, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_int k1, lapack_int k2,\n                                const lapack_int* ipiv, lapack_int incx );\nlapack_int LAPACKE_zlaswp_work( int matrix_order, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_int k1, lapack_int k2,\n                                const lapack_int* ipiv, lapack_int incx );\n\nlapack_int LAPACKE_slatms_work( int matrix_order, lapack_int m, lapack_int n,\n                                char dist, lapack_int* iseed, char sym,\n                                float* d, lapack_int mode, float cond,\n                                float dmax, lapack_int kl, lapack_int ku,\n                                char pack, float* a, lapack_int lda,\n                                float* work );\nlapack_int LAPACKE_dlatms_work( int matrix_order, lapack_int m, lapack_int n,\n                                char dist, lapack_int* iseed, char sym,\n                                double* d, lapack_int mode, double cond,\n                                double dmax, lapack_int kl, lapack_int ku,\n                                char pack, double* a, lapack_int lda,\n                                double* work );\nlapack_int LAPACKE_clatms_work( int matrix_order, lapack_int m, lapack_int n,\n                                char dist, lapack_int* iseed, char sym,\n                                float* d, lapack_int mode, float cond,\n                                float dmax, lapack_int kl, lapack_int ku,\n                                char pack, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* work );\nlapack_int LAPACKE_zlatms_work( int matrix_order, lapack_int m, lapack_int n,\n                                char dist, lapack_int* iseed, char sym,\n                                double* d, lapack_int mode, double cond,\n                                double dmax, lapack_int kl, lapack_int ku,\n                                char pack, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* work );\n\nlapack_int LAPACKE_slauum_work( int matrix_order, char uplo, lapack_int n,\n                                float* a, lapack_int lda );\nlapack_int LAPACKE_dlauum_work( int matrix_order, char uplo, lapack_int n,\n                                double* a, lapack_int lda );\nlapack_int LAPACKE_clauum_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_zlauum_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_sopgtr_work( int matrix_order, char uplo, lapack_int n,\n                                const float* ap, const float* tau, float* q,\n                                lapack_int ldq, float* work );\nlapack_int LAPACKE_dopgtr_work( int matrix_order, char uplo, lapack_int n,\n                                const double* ap, const double* tau, double* q,\n                                lapack_int ldq, double* work );\n\nlapack_int LAPACKE_sopmtr_work( int matrix_order, char side, char uplo,\n                                char trans, lapack_int m, lapack_int n,\n                                const float* ap, const float* tau, float* c,\n                                lapack_int ldc, float* work );\nlapack_int LAPACKE_dopmtr_work( int matrix_order, char side, char uplo,\n                                char trans, lapack_int m, lapack_int n,\n                                const double* ap, const double* tau, double* c,\n                                lapack_int ldc, double* work );\n\nlapack_int LAPACKE_sorgbr_work( int matrix_order, char vect, lapack_int m,\n                                lapack_int n, lapack_int k, float* a,\n                                lapack_int lda, const float* tau, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dorgbr_work( int matrix_order, char vect, lapack_int m,\n                                lapack_int n, lapack_int k, double* a,\n                                lapack_int lda, const double* tau, double* work,\n                                lapack_int lwork );\n\nlapack_int LAPACKE_sorghr_work( int matrix_order, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, float* a, lapack_int lda,\n                                const float* tau, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dorghr_work( int matrix_order, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, double* a, lapack_int lda,\n                                const double* tau, double* work,\n                                lapack_int lwork );\n\nlapack_int LAPACKE_sorglq_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, float* a, lapack_int lda,\n                                const float* tau, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dorglq_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, double* a, lapack_int lda,\n                                const double* tau, double* work,\n                                lapack_int lwork );\n\nlapack_int LAPACKE_sorgql_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, float* a, lapack_int lda,\n                                const float* tau, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dorgql_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, double* a, lapack_int lda,\n                                const double* tau, double* work,\n                                lapack_int lwork );\n\nlapack_int LAPACKE_sorgqr_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, float* a, lapack_int lda,\n                                const float* tau, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dorgqr_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, double* a, lapack_int lda,\n                                const double* tau, double* work,\n                                lapack_int lwork );\n\nlapack_int LAPACKE_sorgrq_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, float* a, lapack_int lda,\n                                const float* tau, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dorgrq_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, double* a, lapack_int lda,\n                                const double* tau, double* work,\n                                lapack_int lwork );\n\nlapack_int LAPACKE_sorgtr_work( int matrix_order, char uplo, lapack_int n,\n                                float* a, lapack_int lda, const float* tau,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dorgtr_work( int matrix_order, char uplo, lapack_int n,\n                                double* a, lapack_int lda, const double* tau,\n                                double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sormbr_work( int matrix_order, char vect, char side,\n                                char trans, lapack_int m, lapack_int n,\n                                lapack_int k, const float* a, lapack_int lda,\n                                const float* tau, float* c, lapack_int ldc,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dormbr_work( int matrix_order, char vect, char side,\n                                char trans, lapack_int m, lapack_int n,\n                                lapack_int k, const double* a, lapack_int lda,\n                                const double* tau, double* c, lapack_int ldc,\n                                double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sormhr_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, const float* a, lapack_int lda,\n                                const float* tau, float* c, lapack_int ldc,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dormhr_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, const double* a, lapack_int lda,\n                                const double* tau, double* c, lapack_int ldc,\n                                double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sormlq_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const float* a, lapack_int lda,\n                                const float* tau, float* c, lapack_int ldc,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dormlq_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const double* a, lapack_int lda,\n                                const double* tau, double* c, lapack_int ldc,\n                                double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sormql_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const float* a, lapack_int lda,\n                                const float* tau, float* c, lapack_int ldc,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dormql_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const double* a, lapack_int lda,\n                                const double* tau, double* c, lapack_int ldc,\n                                double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sormqr_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const float* a, lapack_int lda,\n                                const float* tau, float* c, lapack_int ldc,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dormqr_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const double* a, lapack_int lda,\n                                const double* tau, double* c, lapack_int ldc,\n                                double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sormrq_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const float* a, lapack_int lda,\n                                const float* tau, float* c, lapack_int ldc,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dormrq_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const double* a, lapack_int lda,\n                                const double* tau, double* c, lapack_int ldc,\n                                double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sormrz_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                lapack_int l, const float* a, lapack_int lda,\n                                const float* tau, float* c, lapack_int ldc,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dormrz_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                lapack_int l, const double* a, lapack_int lda,\n                                const double* tau, double* c, lapack_int ldc,\n                                double* work, lapack_int lwork );\n\nlapack_int LAPACKE_sormtr_work( int matrix_order, char side, char uplo,\n                                char trans, lapack_int m, lapack_int n,\n                                const float* a, lapack_int lda,\n                                const float* tau, float* c, lapack_int ldc,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dormtr_work( int matrix_order, char side, char uplo,\n                                char trans, lapack_int m, lapack_int n,\n                                const double* a, lapack_int lda,\n                                const double* tau, double* c, lapack_int ldc,\n                                double* work, lapack_int lwork );\n\nlapack_int LAPACKE_spbcon_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, const float* ab, lapack_int ldab,\n                                float anorm, float* rcond, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dpbcon_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, const double* ab,\n                                lapack_int ldab, double anorm, double* rcond,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_cpbcon_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, const lapack_complex_float* ab,\n                                lapack_int ldab, float anorm, float* rcond,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zpbcon_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, const lapack_complex_double* ab,\n                                lapack_int ldab, double anorm, double* rcond,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_spbequ_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, const float* ab, lapack_int ldab,\n                                float* s, float* scond, float* amax );\nlapack_int LAPACKE_dpbequ_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, const double* ab,\n                                lapack_int ldab, double* s, double* scond,\n                                double* amax );\nlapack_int LAPACKE_cpbequ_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, const lapack_complex_float* ab,\n                                lapack_int ldab, float* s, float* scond,\n                                float* amax );\nlapack_int LAPACKE_zpbequ_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, const lapack_complex_double* ab,\n                                lapack_int ldab, double* s, double* scond,\n                                double* amax );\n\nlapack_int LAPACKE_spbrfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, lapack_int nrhs, const float* ab,\n                                lapack_int ldab, const float* afb,\n                                lapack_int ldafb, const float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* ferr, float* berr, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dpbrfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, lapack_int nrhs,\n                                const double* ab, lapack_int ldab,\n                                const double* afb, lapack_int ldafb,\n                                const double* b, lapack_int ldb, double* x,\n                                lapack_int ldx, double* ferr, double* berr,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_cpbrfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, lapack_int nrhs,\n                                const lapack_complex_float* ab, lapack_int ldab,\n                                const lapack_complex_float* afb,\n                                lapack_int ldafb, const lapack_complex_float* b,\n                                lapack_int ldb, lapack_complex_float* x,\n                                lapack_int ldx, float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zpbrfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, lapack_int nrhs,\n                                const lapack_complex_double* ab,\n                                lapack_int ldab,\n                                const lapack_complex_double* afb,\n                                lapack_int ldafb,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_spbstf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kb, float* bb, lapack_int ldbb );\nlapack_int LAPACKE_dpbstf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kb, double* bb, lapack_int ldbb );\nlapack_int LAPACKE_cpbstf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kb, lapack_complex_float* bb,\n                                lapack_int ldbb );\nlapack_int LAPACKE_zpbstf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kb, lapack_complex_double* bb,\n                                lapack_int ldbb );\n\nlapack_int LAPACKE_spbsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int kd, lapack_int nrhs, float* ab,\n                               lapack_int ldab, float* b, lapack_int ldb );\nlapack_int LAPACKE_dpbsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int kd, lapack_int nrhs, double* ab,\n                               lapack_int ldab, double* b, lapack_int ldb );\nlapack_int LAPACKE_cpbsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int kd, lapack_int nrhs,\n                               lapack_complex_float* ab, lapack_int ldab,\n                               lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zpbsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int kd, lapack_int nrhs,\n                               lapack_complex_double* ab, lapack_int ldab,\n                               lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_spbsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int kd, lapack_int nrhs,\n                                float* ab, lapack_int ldab, float* afb,\n                                lapack_int ldafb, char* equed, float* s,\n                                float* b, lapack_int ldb, float* x,\n                                lapack_int ldx, float* rcond, float* ferr,\n                                float* berr, float* work, lapack_int* iwork );\nlapack_int LAPACKE_dpbsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int kd, lapack_int nrhs,\n                                double* ab, lapack_int ldab, double* afb,\n                                lapack_int ldafb, char* equed, double* s,\n                                double* b, lapack_int ldb, double* x,\n                                lapack_int ldx, double* rcond, double* ferr,\n                                double* berr, double* work, lapack_int* iwork );\nlapack_int LAPACKE_cpbsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int kd, lapack_int nrhs,\n                                lapack_complex_float* ab, lapack_int ldab,\n                                lapack_complex_float* afb, lapack_int ldafb,\n                                char* equed, float* s, lapack_complex_float* b,\n                                lapack_int ldb, lapack_complex_float* x,\n                                lapack_int ldx, float* rcond, float* ferr,\n                                float* berr, lapack_complex_float* work,\n                                float* rwork );\nlapack_int LAPACKE_zpbsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int kd, lapack_int nrhs,\n                                lapack_complex_double* ab, lapack_int ldab,\n                                lapack_complex_double* afb, lapack_int ldafb,\n                                char* equed, double* s,\n                                lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_spbtrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, float* ab, lapack_int ldab );\nlapack_int LAPACKE_dpbtrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, double* ab, lapack_int ldab );\nlapack_int LAPACKE_cpbtrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, lapack_complex_float* ab,\n                                lapack_int ldab );\nlapack_int LAPACKE_zpbtrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, lapack_complex_double* ab,\n                                lapack_int ldab );\n\nlapack_int LAPACKE_spbtrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, lapack_int nrhs, const float* ab,\n                                lapack_int ldab, float* b, lapack_int ldb );\nlapack_int LAPACKE_dpbtrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, lapack_int nrhs,\n                                const double* ab, lapack_int ldab, double* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_cpbtrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, lapack_int nrhs,\n                                const lapack_complex_float* ab, lapack_int ldab,\n                                lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zpbtrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int kd, lapack_int nrhs,\n                                const lapack_complex_double* ab,\n                                lapack_int ldab, lapack_complex_double* b,\n                                lapack_int ldb );\n\nlapack_int LAPACKE_spftrf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, float* a );\nlapack_int LAPACKE_dpftrf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, double* a );\nlapack_int LAPACKE_cpftrf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, lapack_complex_float* a );\nlapack_int LAPACKE_zpftrf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, lapack_complex_double* a );\n\nlapack_int LAPACKE_spftri_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, float* a );\nlapack_int LAPACKE_dpftri_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, double* a );\nlapack_int LAPACKE_cpftri_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, lapack_complex_float* a );\nlapack_int LAPACKE_zpftri_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, lapack_complex_double* a );\n\nlapack_int LAPACKE_spftrs_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, lapack_int nrhs, const float* a,\n                                float* b, lapack_int ldb );\nlapack_int LAPACKE_dpftrs_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, lapack_int nrhs, const double* a,\n                                double* b, lapack_int ldb );\nlapack_int LAPACKE_cpftrs_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_float* a,\n                                lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zpftrs_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_double* a,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_spocon_work( int matrix_order, char uplo, lapack_int n,\n                                const float* a, lapack_int lda, float anorm,\n                                float* rcond, float* work, lapack_int* iwork );\nlapack_int LAPACKE_dpocon_work( int matrix_order, char uplo, lapack_int n,\n                                const double* a, lapack_int lda, double anorm,\n                                double* rcond, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_cpocon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                float anorm, float* rcond,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zpocon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                double anorm, double* rcond,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_spoequ_work( int matrix_order, lapack_int n, const float* a,\n                                lapack_int lda, float* s, float* scond,\n                                float* amax );\nlapack_int LAPACKE_dpoequ_work( int matrix_order, lapack_int n, const double* a,\n                                lapack_int lda, double* s, double* scond,\n                                double* amax );\nlapack_int LAPACKE_cpoequ_work( int matrix_order, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                float* s, float* scond, float* amax );\nlapack_int LAPACKE_zpoequ_work( int matrix_order, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                double* s, double* scond, double* amax );\n\nlapack_int LAPACKE_spoequb_work( int matrix_order, lapack_int n, const float* a,\n                                 lapack_int lda, float* s, float* scond,\n                                 float* amax );\nlapack_int LAPACKE_dpoequb_work( int matrix_order, lapack_int n,\n                                 const double* a, lapack_int lda, double* s,\n                                 double* scond, double* amax );\nlapack_int LAPACKE_cpoequb_work( int matrix_order, lapack_int n,\n                                 const lapack_complex_float* a, lapack_int lda,\n                                 float* s, float* scond, float* amax );\nlapack_int LAPACKE_zpoequb_work( int matrix_order, lapack_int n,\n                                 const lapack_complex_double* a, lapack_int lda,\n                                 double* s, double* scond, double* amax );\n\nlapack_int LAPACKE_sporfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const float* a, lapack_int lda,\n                                const float* af, lapack_int ldaf,\n                                const float* b, lapack_int ldb, float* x,\n                                lapack_int ldx, float* ferr, float* berr,\n                                float* work, lapack_int* iwork );\nlapack_int LAPACKE_dporfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const double* a,\n                                lapack_int lda, const double* af,\n                                lapack_int ldaf, const double* b,\n                                lapack_int ldb, double* x, lapack_int ldx,\n                                double* ferr, double* berr, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_cporfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* af,\n                                lapack_int ldaf, const lapack_complex_float* b,\n                                lapack_int ldb, lapack_complex_float* x,\n                                lapack_int ldx, float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zporfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_double* a,\n                                lapack_int lda, const lapack_complex_double* af,\n                                lapack_int ldaf, const lapack_complex_double* b,\n                                lapack_int ldb, lapack_complex_double* x,\n                                lapack_int ldx, double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sporfsx_work( int matrix_order, char uplo, char equed,\n                                 lapack_int n, lapack_int nrhs, const float* a,\n                                 lapack_int lda, const float* af,\n                                 lapack_int ldaf, const float* s,\n                                 const float* b, lapack_int ldb, float* x,\n                                 lapack_int ldx, float* rcond, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, float* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_dporfsx_work( int matrix_order, char uplo, char equed,\n                                 lapack_int n, lapack_int nrhs, const double* a,\n                                 lapack_int lda, const double* af,\n                                 lapack_int ldaf, const double* s,\n                                 const double* b, lapack_int ldb, double* x,\n                                 lapack_int ldx, double* rcond, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, double* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_cporfsx_work( int matrix_order, char uplo, char equed,\n                                 lapack_int n, lapack_int nrhs,\n                                 const lapack_complex_float* a, lapack_int lda,\n                                 const lapack_complex_float* af,\n                                 lapack_int ldaf, const float* s,\n                                 const lapack_complex_float* b, lapack_int ldb,\n                                 lapack_complex_float* x, lapack_int ldx,\n                                 float* rcond, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, lapack_complex_float* work,\n                                 float* rwork );\nlapack_int LAPACKE_zporfsx_work( int matrix_order, char uplo, char equed,\n                                 lapack_int n, lapack_int nrhs,\n                                 const lapack_complex_double* a, lapack_int lda,\n                                 const lapack_complex_double* af,\n                                 lapack_int ldaf, const double* s,\n                                 const lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* x, lapack_int ldx,\n                                 double* rcond, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, lapack_complex_double* work,\n                                 double* rwork );\n\nlapack_int LAPACKE_sposv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, float* a, lapack_int lda,\n                               float* b, lapack_int ldb );\nlapack_int LAPACKE_dposv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, double* a, lapack_int lda,\n                               double* b, lapack_int ldb );\nlapack_int LAPACKE_cposv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_float* a,\n                               lapack_int lda, lapack_complex_float* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_zposv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_double* a,\n                               lapack_int lda, lapack_complex_double* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_dsposv_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, double* a, lapack_int lda,\n                                double* b, lapack_int ldb, double* x,\n                                lapack_int ldx, double* work, float* swork,\n                                lapack_int* iter );\nlapack_int LAPACKE_zcposv_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* b,\n                                lapack_int ldb, lapack_complex_double* x,\n                                lapack_int ldx, lapack_complex_double* work,\n                                lapack_complex_float* swork, double* rwork,\n                                lapack_int* iter );\n\nlapack_int LAPACKE_sposvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs, float* a,\n                                lapack_int lda, float* af, lapack_int ldaf,\n                                char* equed, float* s, float* b, lapack_int ldb,\n                                float* x, lapack_int ldx, float* rcond,\n                                float* ferr, float* berr, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dposvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs, double* a,\n                                lapack_int lda, double* af, lapack_int ldaf,\n                                char* equed, double* s, double* b,\n                                lapack_int ldb, double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_cposvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* af, lapack_int ldaf,\n                                char* equed, float* s, lapack_complex_float* b,\n                                lapack_int ldb, lapack_complex_float* x,\n                                lapack_int ldx, float* rcond, float* ferr,\n                                float* berr, lapack_complex_float* work,\n                                float* rwork );\nlapack_int LAPACKE_zposvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* af, lapack_int ldaf,\n                                char* equed, double* s,\n                                lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sposvxx_work( int matrix_order, char fact, char uplo,\n                                 lapack_int n, lapack_int nrhs, float* a,\n                                 lapack_int lda, float* af, lapack_int ldaf,\n                                 char* equed, float* s, float* b,\n                                 lapack_int ldb, float* x, lapack_int ldx,\n                                 float* rcond, float* rpvgrw, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, float* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_dposvxx_work( int matrix_order, char fact, char uplo,\n                                 lapack_int n, lapack_int nrhs, double* a,\n                                 lapack_int lda, double* af, lapack_int ldaf,\n                                 char* equed, double* s, double* b,\n                                 lapack_int ldb, double* x, lapack_int ldx,\n                                 double* rcond, double* rpvgrw, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, double* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_cposvxx_work( int matrix_order, char fact, char uplo,\n                                 lapack_int n, lapack_int nrhs,\n                                 lapack_complex_float* a, lapack_int lda,\n                                 lapack_complex_float* af, lapack_int ldaf,\n                                 char* equed, float* s, lapack_complex_float* b,\n                                 lapack_int ldb, lapack_complex_float* x,\n                                 lapack_int ldx, float* rcond, float* rpvgrw,\n                                 float* berr, lapack_int n_err_bnds,\n                                 float* err_bnds_norm, float* err_bnds_comp,\n                                 lapack_int nparams, float* params,\n                                 lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zposvxx_work( int matrix_order, char fact, char uplo,\n                                 lapack_int n, lapack_int nrhs,\n                                 lapack_complex_double* a, lapack_int lda,\n                                 lapack_complex_double* af, lapack_int ldaf,\n                                 char* equed, double* s,\n                                 lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* x, lapack_int ldx,\n                                 double* rcond, double* rpvgrw, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, lapack_complex_double* work,\n                                 double* rwork );\n\nlapack_int LAPACKE_spotrf_work( int matrix_order, char uplo, lapack_int n,\n                                float* a, lapack_int lda );\nlapack_int LAPACKE_dpotrf_work( int matrix_order, char uplo, lapack_int n,\n                                double* a, lapack_int lda );\nlapack_int LAPACKE_cpotrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_zpotrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_spotri_work( int matrix_order, char uplo, lapack_int n,\n                                float* a, lapack_int lda );\nlapack_int LAPACKE_dpotri_work( int matrix_order, char uplo, lapack_int n,\n                                double* a, lapack_int lda );\nlapack_int LAPACKE_cpotri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_zpotri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_spotrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const float* a, lapack_int lda,\n                                float* b, lapack_int ldb );\nlapack_int LAPACKE_dpotrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const double* a,\n                                lapack_int lda, double* b, lapack_int ldb );\nlapack_int LAPACKE_cpotrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_zpotrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* b,\n                                lapack_int ldb );\n\nlapack_int LAPACKE_sppcon_work( int matrix_order, char uplo, lapack_int n,\n                                const float* ap, float anorm, float* rcond,\n                                float* work, lapack_int* iwork );\nlapack_int LAPACKE_dppcon_work( int matrix_order, char uplo, lapack_int n,\n                                const double* ap, double anorm, double* rcond,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_cppcon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_float* ap, float anorm,\n                                float* rcond, lapack_complex_float* work,\n                                float* rwork );\nlapack_int LAPACKE_zppcon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_double* ap, double anorm,\n                                double* rcond, lapack_complex_double* work,\n                                double* rwork );\n\nlapack_int LAPACKE_sppequ_work( int matrix_order, char uplo, lapack_int n,\n                                const float* ap, float* s, float* scond,\n                                float* amax );\nlapack_int LAPACKE_dppequ_work( int matrix_order, char uplo, lapack_int n,\n                                const double* ap, double* s, double* scond,\n                                double* amax );\nlapack_int LAPACKE_cppequ_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_float* ap, float* s,\n                                float* scond, float* amax );\nlapack_int LAPACKE_zppequ_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_double* ap, double* s,\n                                double* scond, double* amax );\n\nlapack_int LAPACKE_spprfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const float* ap,\n                                const float* afp, const float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* ferr, float* berr, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dpprfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const double* ap,\n                                const double* afp, const double* b,\n                                lapack_int ldb, double* x, lapack_int ldx,\n                                double* ferr, double* berr, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_cpprfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* ap,\n                                const lapack_complex_float* afp,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zpprfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs,\n                                const lapack_complex_double* ap,\n                                const lapack_complex_double* afp,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sppsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, float* ap, float* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_dppsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, double* ap, double* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_cppsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_float* ap,\n                               lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zppsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_double* ap,\n                               lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_sppsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs, float* ap,\n                                float* afp, char* equed, float* s, float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* rcond, float* ferr, float* berr,\n                                float* work, lapack_int* iwork );\nlapack_int LAPACKE_dppsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs, double* ap,\n                                double* afp, char* equed, double* s, double* b,\n                                lapack_int ldb, double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_cppsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                lapack_complex_float* ap,\n                                lapack_complex_float* afp, char* equed,\n                                float* s, lapack_complex_float* b,\n                                lapack_int ldb, lapack_complex_float* x,\n                                lapack_int ldx, float* rcond, float* ferr,\n                                float* berr, lapack_complex_float* work,\n                                float* rwork );\nlapack_int LAPACKE_zppsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                lapack_complex_double* ap,\n                                lapack_complex_double* afp, char* equed,\n                                double* s, lapack_complex_double* b,\n                                lapack_int ldb, lapack_complex_double* x,\n                                lapack_int ldx, double* rcond, double* ferr,\n                                double* berr, lapack_complex_double* work,\n                                double* rwork );\n\nlapack_int LAPACKE_spptrf_work( int matrix_order, char uplo, lapack_int n,\n                                float* ap );\nlapack_int LAPACKE_dpptrf_work( int matrix_order, char uplo, lapack_int n,\n                                double* ap );\nlapack_int LAPACKE_cpptrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* ap );\nlapack_int LAPACKE_zpptrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* ap );\n\nlapack_int LAPACKE_spptri_work( int matrix_order, char uplo, lapack_int n,\n                                float* ap );\nlapack_int LAPACKE_dpptri_work( int matrix_order, char uplo, lapack_int n,\n                                double* ap );\nlapack_int LAPACKE_cpptri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* ap );\nlapack_int LAPACKE_zpptri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* ap );\n\nlapack_int LAPACKE_spptrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const float* ap, float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_dpptrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const double* ap, double* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_cpptrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* ap,\n                                lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zpptrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs,\n                                const lapack_complex_double* ap,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_spstrf_work( int matrix_order, char uplo, lapack_int n,\n                                float* a, lapack_int lda, lapack_int* piv,\n                                lapack_int* rank, float tol, float* work );\nlapack_int LAPACKE_dpstrf_work( int matrix_order, char uplo, lapack_int n,\n                                double* a, lapack_int lda, lapack_int* piv,\n                                lapack_int* rank, double tol, double* work );\nlapack_int LAPACKE_cpstrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_int* piv, lapack_int* rank, float tol,\n                                float* work );\nlapack_int LAPACKE_zpstrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_int* piv, lapack_int* rank, double tol,\n                                double* work );\n\nlapack_int LAPACKE_sptcon_work( lapack_int n, const float* d, const float* e,\n                                float anorm, float* rcond, float* work );\nlapack_int LAPACKE_dptcon_work( lapack_int n, const double* d, const double* e,\n                                double anorm, double* rcond, double* work );\nlapack_int LAPACKE_cptcon_work( lapack_int n, const float* d,\n                                const lapack_complex_float* e, float anorm,\n                                float* rcond, float* work );\nlapack_int LAPACKE_zptcon_work( lapack_int n, const double* d,\n                                const lapack_complex_double* e, double anorm,\n                                double* rcond, double* work );\n\nlapack_int LAPACKE_spteqr_work( int matrix_order, char compz, lapack_int n,\n                                float* d, float* e, float* z, lapack_int ldz,\n                                float* work );\nlapack_int LAPACKE_dpteqr_work( int matrix_order, char compz, lapack_int n,\n                                double* d, double* e, double* z, lapack_int ldz,\n                                double* work );\nlapack_int LAPACKE_cpteqr_work( int matrix_order, char compz, lapack_int n,\n                                float* d, float* e, lapack_complex_float* z,\n                                lapack_int ldz, float* work );\nlapack_int LAPACKE_zpteqr_work( int matrix_order, char compz, lapack_int n,\n                                double* d, double* e, lapack_complex_double* z,\n                                lapack_int ldz, double* work );\n\nlapack_int LAPACKE_sptrfs_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                                const float* d, const float* e, const float* df,\n                                const float* ef, const float* b, lapack_int ldb,\n                                float* x, lapack_int ldx, float* ferr,\n                                float* berr, float* work );\nlapack_int LAPACKE_dptrfs_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                                const double* d, const double* e,\n                                const double* df, const double* ef,\n                                const double* b, lapack_int ldb, double* x,\n                                lapack_int ldx, double* ferr, double* berr,\n                                double* work );\nlapack_int LAPACKE_cptrfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const float* d,\n                                const lapack_complex_float* e, const float* df,\n                                const lapack_complex_float* ef,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zptrfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const double* d,\n                                const lapack_complex_double* e,\n                                const double* df,\n                                const lapack_complex_double* ef,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sptsv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               float* d, float* e, float* b, lapack_int ldb );\nlapack_int LAPACKE_dptsv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               double* d, double* e, double* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_cptsv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               float* d, lapack_complex_float* e,\n                               lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zptsv_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                               double* d, lapack_complex_double* e,\n                               lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_sptsvx_work( int matrix_order, char fact, lapack_int n,\n                                lapack_int nrhs, const float* d, const float* e,\n                                float* df, float* ef, const float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* rcond, float* ferr, float* berr,\n                                float* work );\nlapack_int LAPACKE_dptsvx_work( int matrix_order, char fact, lapack_int n,\n                                lapack_int nrhs, const double* d,\n                                const double* e, double* df, double* ef,\n                                const double* b, lapack_int ldb, double* x,\n                                lapack_int ldx, double* rcond, double* ferr,\n                                double* berr, double* work );\nlapack_int LAPACKE_cptsvx_work( int matrix_order, char fact, lapack_int n,\n                                lapack_int nrhs, const float* d,\n                                const lapack_complex_float* e, float* df,\n                                lapack_complex_float* ef,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* rcond, float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zptsvx_work( int matrix_order, char fact, lapack_int n,\n                                lapack_int nrhs, const double* d,\n                                const lapack_complex_double* e, double* df,\n                                lapack_complex_double* ef,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_spttrf_work( lapack_int n, float* d, float* e );\nlapack_int LAPACKE_dpttrf_work( lapack_int n, double* d, double* e );\nlapack_int LAPACKE_cpttrf_work( lapack_int n, float* d,\n                                lapack_complex_float* e );\nlapack_int LAPACKE_zpttrf_work( lapack_int n, double* d,\n                                lapack_complex_double* e );\n\nlapack_int LAPACKE_spttrs_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                                const float* d, const float* e, float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_dpttrs_work( int matrix_order, lapack_int n, lapack_int nrhs,\n                                const double* d, const double* e, double* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_cpttrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const float* d,\n                                const lapack_complex_float* e,\n                                lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zpttrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const double* d,\n                                const lapack_complex_double* e,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_ssbev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_int kd, float* ab,\n                               lapack_int ldab, float* w, float* z,\n                               lapack_int ldz, float* work );\nlapack_int LAPACKE_dsbev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_int kd, double* ab,\n                               lapack_int ldab, double* w, double* z,\n                               lapack_int ldz, double* work );\n\nlapack_int LAPACKE_ssbevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_int kd, float* ab,\n                                lapack_int ldab, float* w, float* z,\n                                lapack_int ldz, float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_dsbevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_int kd, double* ab,\n                                lapack_int ldab, double* w, double* z,\n                                lapack_int ldz, double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_ssbevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, lapack_int kd,\n                                float* ab, lapack_int ldab, float* q,\n                                lapack_int ldq, float vl, float vu,\n                                lapack_int il, lapack_int iu, float abstol,\n                                lapack_int* m, float* w, float* z,\n                                lapack_int ldz, float* work, lapack_int* iwork,\n                                lapack_int* ifail );\nlapack_int LAPACKE_dsbevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, lapack_int kd,\n                                double* ab, lapack_int ldab, double* q,\n                                lapack_int ldq, double vl, double vu,\n                                lapack_int il, lapack_int iu, double abstol,\n                                lapack_int* m, double* w, double* z,\n                                lapack_int ldz, double* work, lapack_int* iwork,\n                                lapack_int* ifail );\n\nlapack_int LAPACKE_ssbgst_work( int matrix_order, char vect, char uplo,\n                                lapack_int n, lapack_int ka, lapack_int kb,\n                                float* ab, lapack_int ldab, const float* bb,\n                                lapack_int ldbb, float* x, lapack_int ldx,\n                                float* work );\nlapack_int LAPACKE_dsbgst_work( int matrix_order, char vect, char uplo,\n                                lapack_int n, lapack_int ka, lapack_int kb,\n                                double* ab, lapack_int ldab, const double* bb,\n                                lapack_int ldbb, double* x, lapack_int ldx,\n                                double* work );\n\nlapack_int LAPACKE_ssbgv_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_int ka, lapack_int kb,\n                               float* ab, lapack_int ldab, float* bb,\n                               lapack_int ldbb, float* w, float* z,\n                               lapack_int ldz, float* work );\nlapack_int LAPACKE_dsbgv_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, lapack_int ka, lapack_int kb,\n                               double* ab, lapack_int ldab, double* bb,\n                               lapack_int ldbb, double* w, double* z,\n                               lapack_int ldz, double* work );\n\nlapack_int LAPACKE_ssbgvd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_int ka, lapack_int kb,\n                                float* ab, lapack_int ldab, float* bb,\n                                lapack_int ldbb, float* w, float* z,\n                                lapack_int ldz, float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_dsbgvd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, lapack_int ka, lapack_int kb,\n                                double* ab, lapack_int ldab, double* bb,\n                                lapack_int ldbb, double* w, double* z,\n                                lapack_int ldz, double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_ssbgvx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, lapack_int ka,\n                                lapack_int kb, float* ab, lapack_int ldab,\n                                float* bb, lapack_int ldbb, float* q,\n                                lapack_int ldq, float vl, float vu,\n                                lapack_int il, lapack_int iu, float abstol,\n                                lapack_int* m, float* w, float* z,\n                                lapack_int ldz, float* work, lapack_int* iwork,\n                                lapack_int* ifail );\nlapack_int LAPACKE_dsbgvx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, lapack_int ka,\n                                lapack_int kb, double* ab, lapack_int ldab,\n                                double* bb, lapack_int ldbb, double* q,\n                                lapack_int ldq, double vl, double vu,\n                                lapack_int il, lapack_int iu, double abstol,\n                                lapack_int* m, double* w, double* z,\n                                lapack_int ldz, double* work, lapack_int* iwork,\n                                lapack_int* ifail );\n\nlapack_int LAPACKE_ssbtrd_work( int matrix_order, char vect, char uplo,\n                                lapack_int n, lapack_int kd, float* ab,\n                                lapack_int ldab, float* d, float* e, float* q,\n                                lapack_int ldq, float* work );\nlapack_int LAPACKE_dsbtrd_work( int matrix_order, char vect, char uplo,\n                                lapack_int n, lapack_int kd, double* ab,\n                                lapack_int ldab, double* d, double* e,\n                                double* q, lapack_int ldq, double* work );\n\nlapack_int LAPACKE_ssfrk_work( int matrix_order, char transr, char uplo,\n                               char trans, lapack_int n, lapack_int k,\n                               float alpha, const float* a, lapack_int lda,\n                               float beta, float* c );\nlapack_int LAPACKE_dsfrk_work( int matrix_order, char transr, char uplo,\n                               char trans, lapack_int n, lapack_int k,\n                               double alpha, const double* a, lapack_int lda,\n                               double beta, double* c );\n\nlapack_int LAPACKE_sspcon_work( int matrix_order, char uplo, lapack_int n,\n                                const float* ap, const lapack_int* ipiv,\n                                float anorm, float* rcond, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dspcon_work( int matrix_order, char uplo, lapack_int n,\n                                const double* ap, const lapack_int* ipiv,\n                                double anorm, double* rcond, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_cspcon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_float* ap,\n                                const lapack_int* ipiv, float anorm,\n                                float* rcond, lapack_complex_float* work );\nlapack_int LAPACKE_zspcon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_double* ap,\n                                const lapack_int* ipiv, double anorm,\n                                double* rcond, lapack_complex_double* work );\n\nlapack_int LAPACKE_sspev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, float* ap, float* w, float* z,\n                               lapack_int ldz, float* work );\nlapack_int LAPACKE_dspev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, double* ap, double* w, double* z,\n                               lapack_int ldz, double* work );\n\nlapack_int LAPACKE_sspevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, float* ap, float* w, float* z,\n                                lapack_int ldz, float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_dspevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, double* ap, double* w, double* z,\n                                lapack_int ldz, double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_sspevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, float* ap, float vl,\n                                float vu, lapack_int il, lapack_int iu,\n                                float abstol, lapack_int* m, float* w, float* z,\n                                lapack_int ldz, float* work, lapack_int* iwork,\n                                lapack_int* ifail );\nlapack_int LAPACKE_dspevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, double* ap, double vl,\n                                double vu, lapack_int il, lapack_int iu,\n                                double abstol, lapack_int* m, double* w,\n                                double* z, lapack_int ldz, double* work,\n                                lapack_int* iwork, lapack_int* ifail );\n\nlapack_int LAPACKE_sspgst_work( int matrix_order, lapack_int itype, char uplo,\n                                lapack_int n, float* ap, const float* bp );\nlapack_int LAPACKE_dspgst_work( int matrix_order, lapack_int itype, char uplo,\n                                lapack_int n, double* ap, const double* bp );\n\nlapack_int LAPACKE_sspgv_work( int matrix_order, lapack_int itype, char jobz,\n                               char uplo, lapack_int n, float* ap, float* bp,\n                               float* w, float* z, lapack_int ldz,\n                               float* work );\nlapack_int LAPACKE_dspgv_work( int matrix_order, lapack_int itype, char jobz,\n                               char uplo, lapack_int n, double* ap, double* bp,\n                               double* w, double* z, lapack_int ldz,\n                               double* work );\n\nlapack_int LAPACKE_sspgvd_work( int matrix_order, lapack_int itype, char jobz,\n                                char uplo, lapack_int n, float* ap, float* bp,\n                                float* w, float* z, lapack_int ldz, float* work,\n                                lapack_int lwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_dspgvd_work( int matrix_order, lapack_int itype, char jobz,\n                                char uplo, lapack_int n, double* ap, double* bp,\n                                double* w, double* z, lapack_int ldz,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_sspgvx_work( int matrix_order, lapack_int itype, char jobz,\n                                char range, char uplo, lapack_int n, float* ap,\n                                float* bp, float vl, float vu, lapack_int il,\n                                lapack_int iu, float abstol, lapack_int* m,\n                                float* w, float* z, lapack_int ldz, float* work,\n                                lapack_int* iwork, lapack_int* ifail );\nlapack_int LAPACKE_dspgvx_work( int matrix_order, lapack_int itype, char jobz,\n                                char range, char uplo, lapack_int n, double* ap,\n                                double* bp, double vl, double vu, lapack_int il,\n                                lapack_int iu, double abstol, lapack_int* m,\n                                double* w, double* z, lapack_int ldz,\n                                double* work, lapack_int* iwork,\n                                lapack_int* ifail );\n\nlapack_int LAPACKE_ssprfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const float* ap,\n                                const float* afp, const lapack_int* ipiv,\n                                const float* b, lapack_int ldb, float* x,\n                                lapack_int ldx, float* ferr, float* berr,\n                                float* work, lapack_int* iwork );\nlapack_int LAPACKE_dsprfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const double* ap,\n                                const double* afp, const lapack_int* ipiv,\n                                const double* b, lapack_int ldb, double* x,\n                                lapack_int ldx, double* ferr, double* berr,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_csprfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* ap,\n                                const lapack_complex_float* afp,\n                                const lapack_int* ipiv,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zsprfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs,\n                                const lapack_complex_double* ap,\n                                const lapack_complex_double* afp,\n                                const lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_sspsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, float* ap, lapack_int* ipiv,\n                               float* b, lapack_int ldb );\nlapack_int LAPACKE_dspsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, double* ap, lapack_int* ipiv,\n                               double* b, lapack_int ldb );\nlapack_int LAPACKE_cspsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_float* ap,\n                               lapack_int* ipiv, lapack_complex_float* b,\n                               lapack_int ldb );\nlapack_int LAPACKE_zspsv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_double* ap,\n                               lapack_int* ipiv, lapack_complex_double* b,\n                               lapack_int ldb );\n\nlapack_int LAPACKE_sspsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs, const float* ap,\n                                float* afp, lapack_int* ipiv, const float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* rcond, float* ferr, float* berr,\n                                float* work, lapack_int* iwork );\nlapack_int LAPACKE_dspsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs, const double* ap,\n                                double* afp, lapack_int* ipiv, const double* b,\n                                lapack_int ldb, double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_cspsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_float* ap,\n                                lapack_complex_float* afp, lapack_int* ipiv,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* rcond, float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zspsvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_double* ap,\n                                lapack_complex_double* afp, lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_ssptrd_work( int matrix_order, char uplo, lapack_int n,\n                                float* ap, float* d, float* e, float* tau );\nlapack_int LAPACKE_dsptrd_work( int matrix_order, char uplo, lapack_int n,\n                                double* ap, double* d, double* e, double* tau );\n\nlapack_int LAPACKE_ssptrf_work( int matrix_order, char uplo, lapack_int n,\n                                float* ap, lapack_int* ipiv );\nlapack_int LAPACKE_dsptrf_work( int matrix_order, char uplo, lapack_int n,\n                                double* ap, lapack_int* ipiv );\nlapack_int LAPACKE_csptrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* ap, lapack_int* ipiv );\nlapack_int LAPACKE_zsptrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* ap, lapack_int* ipiv );\n\nlapack_int LAPACKE_ssptri_work( int matrix_order, char uplo, lapack_int n,\n                                float* ap, const lapack_int* ipiv,\n                                float* work );\nlapack_int LAPACKE_dsptri_work( int matrix_order, char uplo, lapack_int n,\n                                double* ap, const lapack_int* ipiv,\n                                double* work );\nlapack_int LAPACKE_csptri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* ap,\n                                const lapack_int* ipiv,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zsptri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* ap,\n                                const lapack_int* ipiv,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_ssptrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const float* ap,\n                                const lapack_int* ipiv, float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_dsptrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const double* ap,\n                                const lapack_int* ipiv, double* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_csptrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* ap,\n                                const lapack_int* ipiv, lapack_complex_float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_zsptrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs,\n                                const lapack_complex_double* ap,\n                                const lapack_int* ipiv,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_sstebz_work( char range, char order, lapack_int n, float vl,\n                                float vu, lapack_int il, lapack_int iu,\n                                float abstol, const float* d, const float* e,\n                                lapack_int* m, lapack_int* nsplit, float* w,\n                                lapack_int* iblock, lapack_int* isplit,\n                                float* work, lapack_int* iwork );\nlapack_int LAPACKE_dstebz_work( char range, char order, lapack_int n, double vl,\n                                double vu, lapack_int il, lapack_int iu,\n                                double abstol, const double* d, const double* e,\n                                lapack_int* m, lapack_int* nsplit, double* w,\n                                lapack_int* iblock, lapack_int* isplit,\n                                double* work, lapack_int* iwork );\n\nlapack_int LAPACKE_sstedc_work( int matrix_order, char compz, lapack_int n,\n                                float* d, float* e, float* z, lapack_int ldz,\n                                float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_dstedc_work( int matrix_order, char compz, lapack_int n,\n                                double* d, double* e, double* z, lapack_int ldz,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_cstedc_work( int matrix_order, char compz, lapack_int n,\n                                float* d, float* e, lapack_complex_float* z,\n                                lapack_int ldz, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork,\n                                lapack_int lrwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_zstedc_work( int matrix_order, char compz, lapack_int n,\n                                double* d, double* e, lapack_complex_double* z,\n                                lapack_int ldz, lapack_complex_double* work,\n                                lapack_int lwork, double* rwork,\n                                lapack_int lrwork, lapack_int* iwork,\n                                lapack_int liwork );\n\nlapack_int LAPACKE_sstegr_work( int matrix_order, char jobz, char range,\n                                lapack_int n, float* d, float* e, float vl,\n                                float vu, lapack_int il, lapack_int iu,\n                                float abstol, lapack_int* m, float* w, float* z,\n                                lapack_int ldz, lapack_int* isuppz, float* work,\n                                lapack_int lwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_dstegr_work( int matrix_order, char jobz, char range,\n                                lapack_int n, double* d, double* e, double vl,\n                                double vu, lapack_int il, lapack_int iu,\n                                double abstol, lapack_int* m, double* w,\n                                double* z, lapack_int ldz, lapack_int* isuppz,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_cstegr_work( int matrix_order, char jobz, char range,\n                                lapack_int n, float* d, float* e, float vl,\n                                float vu, lapack_int il, lapack_int iu,\n                                float abstol, lapack_int* m, float* w,\n                                lapack_complex_float* z, lapack_int ldz,\n                                lapack_int* isuppz, float* work,\n                                lapack_int lwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_zstegr_work( int matrix_order, char jobz, char range,\n                                lapack_int n, double* d, double* e, double vl,\n                                double vu, lapack_int il, lapack_int iu,\n                                double abstol, lapack_int* m, double* w,\n                                lapack_complex_double* z, lapack_int ldz,\n                                lapack_int* isuppz, double* work,\n                                lapack_int lwork, lapack_int* iwork,\n                                lapack_int liwork );\n\nlapack_int LAPACKE_sstein_work( int matrix_order, lapack_int n, const float* d,\n                                const float* e, lapack_int m, const float* w,\n                                const lapack_int* iblock,\n                                const lapack_int* isplit, float* z,\n                                lapack_int ldz, float* work, lapack_int* iwork,\n                                lapack_int* ifailv );\nlapack_int LAPACKE_dstein_work( int matrix_order, lapack_int n, const double* d,\n                                const double* e, lapack_int m, const double* w,\n                                const lapack_int* iblock,\n                                const lapack_int* isplit, double* z,\n                                lapack_int ldz, double* work, lapack_int* iwork,\n                                lapack_int* ifailv );\nlapack_int LAPACKE_cstein_work( int matrix_order, lapack_int n, const float* d,\n                                const float* e, lapack_int m, const float* w,\n                                const lapack_int* iblock,\n                                const lapack_int* isplit,\n                                lapack_complex_float* z, lapack_int ldz,\n                                float* work, lapack_int* iwork,\n                                lapack_int* ifailv );\nlapack_int LAPACKE_zstein_work( int matrix_order, lapack_int n, const double* d,\n                                const double* e, lapack_int m, const double* w,\n                                const lapack_int* iblock,\n                                const lapack_int* isplit,\n                                lapack_complex_double* z, lapack_int ldz,\n                                double* work, lapack_int* iwork,\n                                lapack_int* ifailv );\n\nlapack_int LAPACKE_sstemr_work( int matrix_order, char jobz, char range,\n                                lapack_int n, float* d, float* e, float vl,\n                                float vu, lapack_int il, lapack_int iu,\n                                lapack_int* m, float* w, float* z,\n                                lapack_int ldz, lapack_int nzc,\n                                lapack_int* isuppz, lapack_logical* tryrac,\n                                float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_dstemr_work( int matrix_order, char jobz, char range,\n                                lapack_int n, double* d, double* e, double vl,\n                                double vu, lapack_int il, lapack_int iu,\n                                lapack_int* m, double* w, double* z,\n                                lapack_int ldz, lapack_int nzc,\n                                lapack_int* isuppz, lapack_logical* tryrac,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_cstemr_work( int matrix_order, char jobz, char range,\n                                lapack_int n, float* d, float* e, float vl,\n                                float vu, lapack_int il, lapack_int iu,\n                                lapack_int* m, float* w,\n                                lapack_complex_float* z, lapack_int ldz,\n                                lapack_int nzc, lapack_int* isuppz,\n                                lapack_logical* tryrac, float* work,\n                                lapack_int lwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_zstemr_work( int matrix_order, char jobz, char range,\n                                lapack_int n, double* d, double* e, double vl,\n                                double vu, lapack_int il, lapack_int iu,\n                                lapack_int* m, double* w,\n                                lapack_complex_double* z, lapack_int ldz,\n                                lapack_int nzc, lapack_int* isuppz,\n                                lapack_logical* tryrac, double* work,\n                                lapack_int lwork, lapack_int* iwork,\n                                lapack_int liwork );\n\nlapack_int LAPACKE_ssteqr_work( int matrix_order, char compz, lapack_int n,\n                                float* d, float* e, float* z, lapack_int ldz,\n                                float* work );\nlapack_int LAPACKE_dsteqr_work( int matrix_order, char compz, lapack_int n,\n                                double* d, double* e, double* z, lapack_int ldz,\n                                double* work );\nlapack_int LAPACKE_csteqr_work( int matrix_order, char compz, lapack_int n,\n                                float* d, float* e, lapack_complex_float* z,\n                                lapack_int ldz, float* work );\nlapack_int LAPACKE_zsteqr_work( int matrix_order, char compz, lapack_int n,\n                                double* d, double* e, lapack_complex_double* z,\n                                lapack_int ldz, double* work );\n\nlapack_int LAPACKE_ssterf_work( lapack_int n, float* d, float* e );\nlapack_int LAPACKE_dsterf_work( lapack_int n, double* d, double* e );\n\nlapack_int LAPACKE_sstev_work( int matrix_order, char jobz, lapack_int n,\n                               float* d, float* e, float* z, lapack_int ldz,\n                               float* work );\nlapack_int LAPACKE_dstev_work( int matrix_order, char jobz, lapack_int n,\n                               double* d, double* e, double* z, lapack_int ldz,\n                               double* work );\n\nlapack_int LAPACKE_sstevd_work( int matrix_order, char jobz, lapack_int n,\n                                float* d, float* e, float* z, lapack_int ldz,\n                                float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_dstevd_work( int matrix_order, char jobz, lapack_int n,\n                                double* d, double* e, double* z, lapack_int ldz,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_sstevr_work( int matrix_order, char jobz, char range,\n                                lapack_int n, float* d, float* e, float vl,\n                                float vu, lapack_int il, lapack_int iu,\n                                float abstol, lapack_int* m, float* w, float* z,\n                                lapack_int ldz, lapack_int* isuppz, float* work,\n                                lapack_int lwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_dstevr_work( int matrix_order, char jobz, char range,\n                                lapack_int n, double* d, double* e, double vl,\n                                double vu, lapack_int il, lapack_int iu,\n                                double abstol, lapack_int* m, double* w,\n                                double* z, lapack_int ldz, lapack_int* isuppz,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_sstevx_work( int matrix_order, char jobz, char range,\n                                lapack_int n, float* d, float* e, float vl,\n                                float vu, lapack_int il, lapack_int iu,\n                                float abstol, lapack_int* m, float* w, float* z,\n                                lapack_int ldz, float* work, lapack_int* iwork,\n                                lapack_int* ifail );\nlapack_int LAPACKE_dstevx_work( int matrix_order, char jobz, char range,\n                                lapack_int n, double* d, double* e, double vl,\n                                double vu, lapack_int il, lapack_int iu,\n                                double abstol, lapack_int* m, double* w,\n                                double* z, lapack_int ldz, double* work,\n                                lapack_int* iwork, lapack_int* ifail );\n\nlapack_int LAPACKE_ssycon_work( int matrix_order, char uplo, lapack_int n,\n                                const float* a, lapack_int lda,\n                                const lapack_int* ipiv, float anorm,\n                                float* rcond, float* work, lapack_int* iwork );\nlapack_int LAPACKE_dsycon_work( int matrix_order, char uplo, lapack_int n,\n                                const double* a, lapack_int lda,\n                                const lapack_int* ipiv, double anorm,\n                                double* rcond, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_csycon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                const lapack_int* ipiv, float anorm,\n                                float* rcond, lapack_complex_float* work );\nlapack_int LAPACKE_zsycon_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                const lapack_int* ipiv, double anorm,\n                                double* rcond, lapack_complex_double* work );\n\nlapack_int LAPACKE_ssyequb_work( int matrix_order, char uplo, lapack_int n,\n                                 const float* a, lapack_int lda, float* s,\n                                 float* scond, float* amax, float* work );\nlapack_int LAPACKE_dsyequb_work( int matrix_order, char uplo, lapack_int n,\n                                 const double* a, lapack_int lda, double* s,\n                                 double* scond, double* amax, double* work );\nlapack_int LAPACKE_csyequb_work( int matrix_order, char uplo, lapack_int n,\n                                 const lapack_complex_float* a, lapack_int lda,\n                                 float* s, float* scond, float* amax,\n                                 lapack_complex_float* work );\nlapack_int LAPACKE_zsyequb_work( int matrix_order, char uplo, lapack_int n,\n                                 const lapack_complex_double* a, lapack_int lda,\n                                 double* s, double* scond, double* amax,\n                                 lapack_complex_double* work );\n\nlapack_int LAPACKE_ssyev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, float* a, lapack_int lda, float* w,\n                               float* work, lapack_int lwork );\nlapack_int LAPACKE_dsyev_work( int matrix_order, char jobz, char uplo,\n                               lapack_int n, double* a, lapack_int lda,\n                               double* w, double* work, lapack_int lwork );\n\nlapack_int LAPACKE_ssyevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, float* a, lapack_int lda,\n                                float* w, float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_dsyevd_work( int matrix_order, char jobz, char uplo,\n                                lapack_int n, double* a, lapack_int lda,\n                                double* w, double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_ssyevr_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, float* a,\n                                lapack_int lda, float vl, float vu,\n                                lapack_int il, lapack_int iu, float abstol,\n                                lapack_int* m, float* w, float* z,\n                                lapack_int ldz, lapack_int* isuppz, float* work,\n                                lapack_int lwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_dsyevr_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, double* a,\n                                lapack_int lda, double vl, double vu,\n                                lapack_int il, lapack_int iu, double abstol,\n                                lapack_int* m, double* w, double* z,\n                                lapack_int ldz, lapack_int* isuppz,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_ssyevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, float* a,\n                                lapack_int lda, float vl, float vu,\n                                lapack_int il, lapack_int iu, float abstol,\n                                lapack_int* m, float* w, float* z,\n                                lapack_int ldz, float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int* ifail );\nlapack_int LAPACKE_dsyevx_work( int matrix_order, char jobz, char range,\n                                char uplo, lapack_int n, double* a,\n                                lapack_int lda, double vl, double vu,\n                                lapack_int il, lapack_int iu, double abstol,\n                                lapack_int* m, double* w, double* z,\n                                lapack_int ldz, double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int* ifail );\n\nlapack_int LAPACKE_ssygst_work( int matrix_order, lapack_int itype, char uplo,\n                                lapack_int n, float* a, lapack_int lda,\n                                const float* b, lapack_int ldb );\nlapack_int LAPACKE_dsygst_work( int matrix_order, lapack_int itype, char uplo,\n                                lapack_int n, double* a, lapack_int lda,\n                                const double* b, lapack_int ldb );\n\nlapack_int LAPACKE_ssygv_work( int matrix_order, lapack_int itype, char jobz,\n                               char uplo, lapack_int n, float* a,\n                               lapack_int lda, float* b, lapack_int ldb,\n                               float* w, float* work, lapack_int lwork );\nlapack_int LAPACKE_dsygv_work( int matrix_order, lapack_int itype, char jobz,\n                               char uplo, lapack_int n, double* a,\n                               lapack_int lda, double* b, lapack_int ldb,\n                               double* w, double* work, lapack_int lwork );\n\nlapack_int LAPACKE_ssygvd_work( int matrix_order, lapack_int itype, char jobz,\n                                char uplo, lapack_int n, float* a,\n                                lapack_int lda, float* b, lapack_int ldb,\n                                float* w, float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_dsygvd_work( int matrix_order, lapack_int itype, char jobz,\n                                char uplo, lapack_int n, double* a,\n                                lapack_int lda, double* b, lapack_int ldb,\n                                double* w, double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\n\nlapack_int LAPACKE_ssygvx_work( int matrix_order, lapack_int itype, char jobz,\n                                char range, char uplo, lapack_int n, float* a,\n                                lapack_int lda, float* b, lapack_int ldb,\n                                float vl, float vu, lapack_int il,\n                                lapack_int iu, float abstol, lapack_int* m,\n                                float* w, float* z, lapack_int ldz, float* work,\n                                lapack_int lwork, lapack_int* iwork,\n                                lapack_int* ifail );\nlapack_int LAPACKE_dsygvx_work( int matrix_order, lapack_int itype, char jobz,\n                                char range, char uplo, lapack_int n, double* a,\n                                lapack_int lda, double* b, lapack_int ldb,\n                                double vl, double vu, lapack_int il,\n                                lapack_int iu, double abstol, lapack_int* m,\n                                double* w, double* z, lapack_int ldz,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int* ifail );\n\nlapack_int LAPACKE_ssyrfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const float* a, lapack_int lda,\n                                const float* af, lapack_int ldaf,\n                                const lapack_int* ipiv, const float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* ferr, float* berr, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dsyrfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const double* a,\n                                lapack_int lda, const double* af,\n                                lapack_int ldaf, const lapack_int* ipiv,\n                                const double* b, lapack_int ldb, double* x,\n                                lapack_int ldx, double* ferr, double* berr,\n                                double* work, lapack_int* iwork );\nlapack_int LAPACKE_csyrfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* af,\n                                lapack_int ldaf, const lapack_int* ipiv,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* x, lapack_int ldx,\n                                float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_zsyrfs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_double* a,\n                                lapack_int lda, const lapack_complex_double* af,\n                                lapack_int ldaf, const lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_ssyrfsx_work( int matrix_order, char uplo, char equed,\n                                 lapack_int n, lapack_int nrhs, const float* a,\n                                 lapack_int lda, const float* af,\n                                 lapack_int ldaf, const lapack_int* ipiv,\n                                 const float* s, const float* b, lapack_int ldb,\n                                 float* x, lapack_int ldx, float* rcond,\n                                 float* berr, lapack_int n_err_bnds,\n                                 float* err_bnds_norm, float* err_bnds_comp,\n                                 lapack_int nparams, float* params, float* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_dsyrfsx_work( int matrix_order, char uplo, char equed,\n                                 lapack_int n, lapack_int nrhs, const double* a,\n                                 lapack_int lda, const double* af,\n                                 lapack_int ldaf, const lapack_int* ipiv,\n                                 const double* s, const double* b,\n                                 lapack_int ldb, double* x, lapack_int ldx,\n                                 double* rcond, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, double* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_csyrfsx_work( int matrix_order, char uplo, char equed,\n                                 lapack_int n, lapack_int nrhs,\n                                 const lapack_complex_float* a, lapack_int lda,\n                                 const lapack_complex_float* af,\n                                 lapack_int ldaf, const lapack_int* ipiv,\n                                 const float* s, const lapack_complex_float* b,\n                                 lapack_int ldb, lapack_complex_float* x,\n                                 lapack_int ldx, float* rcond, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, lapack_complex_float* work,\n                                 float* rwork );\nlapack_int LAPACKE_zsyrfsx_work( int matrix_order, char uplo, char equed,\n                                 lapack_int n, lapack_int nrhs,\n                                 const lapack_complex_double* a, lapack_int lda,\n                                 const lapack_complex_double* af,\n                                 lapack_int ldaf, const lapack_int* ipiv,\n                                 const double* s,\n                                 const lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* x, lapack_int ldx,\n                                 double* rcond, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, lapack_complex_double* work,\n                                 double* rwork );\n\nlapack_int LAPACKE_ssysv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, float* a, lapack_int lda,\n                               lapack_int* ipiv, float* b, lapack_int ldb,\n                               float* work, lapack_int lwork );\nlapack_int LAPACKE_dsysv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, double* a, lapack_int lda,\n                               lapack_int* ipiv, double* b, lapack_int ldb,\n                               double* work, lapack_int lwork );\nlapack_int LAPACKE_csysv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_float* a,\n                               lapack_int lda, lapack_int* ipiv,\n                               lapack_complex_float* b, lapack_int ldb,\n                               lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zsysv_work( int matrix_order, char uplo, lapack_int n,\n                               lapack_int nrhs, lapack_complex_double* a,\n                               lapack_int lda, lapack_int* ipiv,\n                               lapack_complex_double* b, lapack_int ldb,\n                               lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_ssysvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs, const float* a,\n                                lapack_int lda, float* af, lapack_int ldaf,\n                                lapack_int* ipiv, const float* b,\n                                lapack_int ldb, float* x, lapack_int ldx,\n                                float* rcond, float* ferr, float* berr,\n                                float* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dsysvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs, const double* a,\n                                lapack_int lda, double* af, lapack_int ldaf,\n                                lapack_int* ipiv, const double* b,\n                                lapack_int ldb, double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_csysvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* af, lapack_int ldaf,\n                                lapack_int* ipiv, const lapack_complex_float* b,\n                                lapack_int ldb, lapack_complex_float* x,\n                                lapack_int ldx, float* rcond, float* ferr,\n                                float* berr, lapack_complex_float* work,\n                                lapack_int lwork, float* rwork );\nlapack_int LAPACKE_zsysvx_work( int matrix_order, char fact, char uplo,\n                                lapack_int n, lapack_int nrhs,\n                                const lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* af, lapack_int ldaf,\n                                lapack_int* ipiv,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* x, lapack_int ldx,\n                                double* rcond, double* ferr, double* berr,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork );\n\nlapack_int LAPACKE_ssysvxx_work( int matrix_order, char fact, char uplo,\n                                 lapack_int n, lapack_int nrhs, float* a,\n                                 lapack_int lda, float* af, lapack_int ldaf,\n                                 lapack_int* ipiv, char* equed, float* s,\n                                 float* b, lapack_int ldb, float* x,\n                                 lapack_int ldx, float* rcond, float* rpvgrw,\n                                 float* berr, lapack_int n_err_bnds,\n                                 float* err_bnds_norm, float* err_bnds_comp,\n                                 lapack_int nparams, float* params, float* work,\n                                 lapack_int* iwork );\nlapack_int LAPACKE_dsysvxx_work( int matrix_order, char fact, char uplo,\n                                 lapack_int n, lapack_int nrhs, double* a,\n                                 lapack_int lda, double* af, lapack_int ldaf,\n                                 lapack_int* ipiv, char* equed, double* s,\n                                 double* b, lapack_int ldb, double* x,\n                                 lapack_int ldx, double* rcond, double* rpvgrw,\n                                 double* berr, lapack_int n_err_bnds,\n                                 double* err_bnds_norm, double* err_bnds_comp,\n                                 lapack_int nparams, double* params,\n                                 double* work, lapack_int* iwork );\nlapack_int LAPACKE_csysvxx_work( int matrix_order, char fact, char uplo,\n                                 lapack_int n, lapack_int nrhs,\n                                 lapack_complex_float* a, lapack_int lda,\n                                 lapack_complex_float* af, lapack_int ldaf,\n                                 lapack_int* ipiv, char* equed, float* s,\n                                 lapack_complex_float* b, lapack_int ldb,\n                                 lapack_complex_float* x, lapack_int ldx,\n                                 float* rcond, float* rpvgrw, float* berr,\n                                 lapack_int n_err_bnds, float* err_bnds_norm,\n                                 float* err_bnds_comp, lapack_int nparams,\n                                 float* params, lapack_complex_float* work,\n                                 float* rwork );\nlapack_int LAPACKE_zsysvxx_work( int matrix_order, char fact, char uplo,\n                                 lapack_int n, lapack_int nrhs,\n                                 lapack_complex_double* a, lapack_int lda,\n                                 lapack_complex_double* af, lapack_int ldaf,\n                                 lapack_int* ipiv, char* equed, double* s,\n                                 lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* x, lapack_int ldx,\n                                 double* rcond, double* rpvgrw, double* berr,\n                                 lapack_int n_err_bnds, double* err_bnds_norm,\n                                 double* err_bnds_comp, lapack_int nparams,\n                                 double* params, lapack_complex_double* work,\n                                 double* rwork );\n\nlapack_int LAPACKE_ssytrd_work( int matrix_order, char uplo, lapack_int n,\n                                float* a, lapack_int lda, float* d, float* e,\n                                float* tau, float* work, lapack_int lwork );\nlapack_int LAPACKE_dsytrd_work( int matrix_order, char uplo, lapack_int n,\n                                double* a, lapack_int lda, double* d, double* e,\n                                double* tau, double* work, lapack_int lwork );\n\nlapack_int LAPACKE_ssytrf_work( int matrix_order, char uplo, lapack_int n,\n                                float* a, lapack_int lda, lapack_int* ipiv,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dsytrf_work( int matrix_order, char uplo, lapack_int n,\n                                double* a, lapack_int lda, lapack_int* ipiv,\n                                double* work, lapack_int lwork );\nlapack_int LAPACKE_csytrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_int* ipiv, lapack_complex_float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_zsytrf_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_int* ipiv, lapack_complex_double* work,\n                                lapack_int lwork );\n\nlapack_int LAPACKE_ssytri_work( int matrix_order, char uplo, lapack_int n,\n                                float* a, lapack_int lda,\n                                const lapack_int* ipiv, float* work );\nlapack_int LAPACKE_dsytri_work( int matrix_order, char uplo, lapack_int n,\n                                double* a, lapack_int lda,\n                                const lapack_int* ipiv, double* work );\nlapack_int LAPACKE_csytri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                const lapack_int* ipiv,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zsytri_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                const lapack_int* ipiv,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_ssytrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const float* a, lapack_int lda,\n                                const lapack_int* ipiv, float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_dsytrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const double* a,\n                                lapack_int lda, const lapack_int* ipiv,\n                                double* b, lapack_int ldb );\nlapack_int LAPACKE_csytrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_float* a,\n                                lapack_int lda, const lapack_int* ipiv,\n                                lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_zsytrs_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_int nrhs, const lapack_complex_double* a,\n                                lapack_int lda, const lapack_int* ipiv,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_stbcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n, lapack_int kd,\n                                const float* ab, lapack_int ldab, float* rcond,\n                                float* work, lapack_int* iwork );\nlapack_int LAPACKE_dtbcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n, lapack_int kd,\n                                const double* ab, lapack_int ldab,\n                                double* rcond, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_ctbcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n, lapack_int kd,\n                                const lapack_complex_float* ab, lapack_int ldab,\n                                float* rcond, lapack_complex_float* work,\n                                float* rwork );\nlapack_int LAPACKE_ztbcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n, lapack_int kd,\n                                const lapack_complex_double* ab,\n                                lapack_int ldab, double* rcond,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_stbrfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int kd,\n                                lapack_int nrhs, const float* ab,\n                                lapack_int ldab, const float* b, lapack_int ldb,\n                                const float* x, lapack_int ldx, float* ferr,\n                                float* berr, float* work, lapack_int* iwork );\nlapack_int LAPACKE_dtbrfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int kd,\n                                lapack_int nrhs, const double* ab,\n                                lapack_int ldab, const double* b,\n                                lapack_int ldb, const double* x, lapack_int ldx,\n                                double* ferr, double* berr, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_ctbrfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int kd,\n                                lapack_int nrhs, const lapack_complex_float* ab,\n                                lapack_int ldab, const lapack_complex_float* b,\n                                lapack_int ldb, const lapack_complex_float* x,\n                                lapack_int ldx, float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_ztbrfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int kd,\n                                lapack_int nrhs,\n                                const lapack_complex_double* ab,\n                                lapack_int ldab, const lapack_complex_double* b,\n                                lapack_int ldb, const lapack_complex_double* x,\n                                lapack_int ldx, double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_stbtrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int kd,\n                                lapack_int nrhs, const float* ab,\n                                lapack_int ldab, float* b, lapack_int ldb );\nlapack_int LAPACKE_dtbtrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int kd,\n                                lapack_int nrhs, const double* ab,\n                                lapack_int ldab, double* b, lapack_int ldb );\nlapack_int LAPACKE_ctbtrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int kd,\n                                lapack_int nrhs, const lapack_complex_float* ab,\n                                lapack_int ldab, lapack_complex_float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_ztbtrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int kd,\n                                lapack_int nrhs,\n                                const lapack_complex_double* ab,\n                                lapack_int ldab, lapack_complex_double* b,\n                                lapack_int ldb );\n\nlapack_int LAPACKE_stfsm_work( int matrix_order, char transr, char side,\n                               char uplo, char trans, char diag, lapack_int m,\n                               lapack_int n, float alpha, const float* a,\n                               float* b, lapack_int ldb );\nlapack_int LAPACKE_dtfsm_work( int matrix_order, char transr, char side,\n                               char uplo, char trans, char diag, lapack_int m,\n                               lapack_int n, double alpha, const double* a,\n                               double* b, lapack_int ldb );\nlapack_int LAPACKE_ctfsm_work( int matrix_order, char transr, char side,\n                               char uplo, char trans, char diag, lapack_int m,\n                               lapack_int n, lapack_complex_float alpha,\n                               const lapack_complex_float* a,\n                               lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_ztfsm_work( int matrix_order, char transr, char side,\n                               char uplo, char trans, char diag, lapack_int m,\n                               lapack_int n, lapack_complex_double alpha,\n                               const lapack_complex_double* a,\n                               lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_stftri_work( int matrix_order, char transr, char uplo,\n                                char diag, lapack_int n, float* a );\nlapack_int LAPACKE_dtftri_work( int matrix_order, char transr, char uplo,\n                                char diag, lapack_int n, double* a );\nlapack_int LAPACKE_ctftri_work( int matrix_order, char transr, char uplo,\n                                char diag, lapack_int n,\n                                lapack_complex_float* a );\nlapack_int LAPACKE_ztftri_work( int matrix_order, char transr, char uplo,\n                                char diag, lapack_int n,\n                                lapack_complex_double* a );\n\nlapack_int LAPACKE_stfttp_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const float* arf, float* ap );\nlapack_int LAPACKE_dtfttp_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const double* arf, double* ap );\nlapack_int LAPACKE_ctfttp_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const lapack_complex_float* arf,\n                                lapack_complex_float* ap );\nlapack_int LAPACKE_ztfttp_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const lapack_complex_double* arf,\n                                lapack_complex_double* ap );\n\nlapack_int LAPACKE_stfttr_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const float* arf, float* a,\n                                lapack_int lda );\nlapack_int LAPACKE_dtfttr_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const double* arf, double* a,\n                                lapack_int lda );\nlapack_int LAPACKE_ctfttr_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const lapack_complex_float* arf,\n                                lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_ztfttr_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const lapack_complex_double* arf,\n                                lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_stgevc_work( int matrix_order, char side, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const float* s, lapack_int lds, const float* p,\n                                lapack_int ldp, float* vl, lapack_int ldvl,\n                                float* vr, lapack_int ldvr, lapack_int mm,\n                                lapack_int* m, float* work );\nlapack_int LAPACKE_dtgevc_work( int matrix_order, char side, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const double* s, lapack_int lds,\n                                const double* p, lapack_int ldp, double* vl,\n                                lapack_int ldvl, double* vr, lapack_int ldvr,\n                                lapack_int mm, lapack_int* m, double* work );\nlapack_int LAPACKE_ctgevc_work( int matrix_order, char side, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const lapack_complex_float* s, lapack_int lds,\n                                const lapack_complex_float* p, lapack_int ldp,\n                                lapack_complex_float* vl, lapack_int ldvl,\n                                lapack_complex_float* vr, lapack_int ldvr,\n                                lapack_int mm, lapack_int* m,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_ztgevc_work( int matrix_order, char side, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const lapack_complex_double* s, lapack_int lds,\n                                const lapack_complex_double* p, lapack_int ldp,\n                                lapack_complex_double* vl, lapack_int ldvl,\n                                lapack_complex_double* vr, lapack_int ldvr,\n                                lapack_int mm, lapack_int* m,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_stgexc_work( int matrix_order, lapack_logical wantq,\n                                lapack_logical wantz, lapack_int n, float* a,\n                                lapack_int lda, float* b, lapack_int ldb,\n                                float* q, lapack_int ldq, float* z,\n                                lapack_int ldz, lapack_int* ifst,\n                                lapack_int* ilst, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dtgexc_work( int matrix_order, lapack_logical wantq,\n                                lapack_logical wantz, lapack_int n, double* a,\n                                lapack_int lda, double* b, lapack_int ldb,\n                                double* q, lapack_int ldq, double* z,\n                                lapack_int ldz, lapack_int* ifst,\n                                lapack_int* ilst, double* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_ctgexc_work( int matrix_order, lapack_logical wantq,\n                                lapack_logical wantz, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* q, lapack_int ldq,\n                                lapack_complex_float* z, lapack_int ldz,\n                                lapack_int ifst, lapack_int ilst );\nlapack_int LAPACKE_ztgexc_work( int matrix_order, lapack_logical wantq,\n                                lapack_logical wantz, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* q, lapack_int ldq,\n                                lapack_complex_double* z, lapack_int ldz,\n                                lapack_int ifst, lapack_int ilst );\n\nlapack_int LAPACKE_stgsen_work( int matrix_order, lapack_int ijob,\n                                lapack_logical wantq, lapack_logical wantz,\n                                const lapack_logical* select, lapack_int n,\n                                float* a, lapack_int lda, float* b,\n                                lapack_int ldb, float* alphar, float* alphai,\n                                float* beta, float* q, lapack_int ldq, float* z,\n                                lapack_int ldz, lapack_int* m, float* pl,\n                                float* pr, float* dif, float* work,\n                                lapack_int lwork, lapack_int* iwork,\n                                lapack_int liwork );\nlapack_int LAPACKE_dtgsen_work( int matrix_order, lapack_int ijob,\n                                lapack_logical wantq, lapack_logical wantz,\n                                const lapack_logical* select, lapack_int n,\n                                double* a, lapack_int lda, double* b,\n                                lapack_int ldb, double* alphar, double* alphai,\n                                double* beta, double* q, lapack_int ldq,\n                                double* z, lapack_int ldz, lapack_int* m,\n                                double* pl, double* pr, double* dif,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_ctgsen_work( int matrix_order, lapack_int ijob,\n                                lapack_logical wantq, lapack_logical wantz,\n                                const lapack_logical* select, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* alpha,\n                                lapack_complex_float* beta,\n                                lapack_complex_float* q, lapack_int ldq,\n                                lapack_complex_float* z, lapack_int ldz,\n                                lapack_int* m, float* pl, float* pr, float* dif,\n                                lapack_complex_float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_ztgsen_work( int matrix_order, lapack_int ijob,\n                                lapack_logical wantq, lapack_logical wantz,\n                                const lapack_logical* select, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* alpha,\n                                lapack_complex_double* beta,\n                                lapack_complex_double* q, lapack_int ldq,\n                                lapack_complex_double* z, lapack_int ldz,\n                                lapack_int* m, double* pl, double* pr,\n                                double* dif, lapack_complex_double* work,\n                                lapack_int lwork, lapack_int* iwork,\n                                lapack_int liwork );\n\nlapack_int LAPACKE_stgsja_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int p,\n                                lapack_int n, lapack_int k, lapack_int l,\n                                float* a, lapack_int lda, float* b,\n                                lapack_int ldb, float tola, float tolb,\n                                float* alpha, float* beta, float* u,\n                                lapack_int ldu, float* v, lapack_int ldv,\n                                float* q, lapack_int ldq, float* work,\n                                lapack_int* ncycle );\nlapack_int LAPACKE_dtgsja_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int p,\n                                lapack_int n, lapack_int k, lapack_int l,\n                                double* a, lapack_int lda, double* b,\n                                lapack_int ldb, double tola, double tolb,\n                                double* alpha, double* beta, double* u,\n                                lapack_int ldu, double* v, lapack_int ldv,\n                                double* q, lapack_int ldq, double* work,\n                                lapack_int* ncycle );\nlapack_int LAPACKE_ctgsja_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int p,\n                                lapack_int n, lapack_int k, lapack_int l,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* b, lapack_int ldb,\n                                float tola, float tolb, float* alpha,\n                                float* beta, lapack_complex_float* u,\n                                lapack_int ldu, lapack_complex_float* v,\n                                lapack_int ldv, lapack_complex_float* q,\n                                lapack_int ldq, lapack_complex_float* work,\n                                lapack_int* ncycle );\nlapack_int LAPACKE_ztgsja_work( int matrix_order, char jobu, char jobv,\n                                char jobq, lapack_int m, lapack_int p,\n                                lapack_int n, lapack_int k, lapack_int l,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb,\n                                double tola, double tolb, double* alpha,\n                                double* beta, lapack_complex_double* u,\n                                lapack_int ldu, lapack_complex_double* v,\n                                lapack_int ldv, lapack_complex_double* q,\n                                lapack_int ldq, lapack_complex_double* work,\n                                lapack_int* ncycle );\n\nlapack_int LAPACKE_stgsna_work( int matrix_order, char job, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const float* a, lapack_int lda, const float* b,\n                                lapack_int ldb, const float* vl,\n                                lapack_int ldvl, const float* vr,\n                                lapack_int ldvr, float* s, float* dif,\n                                lapack_int mm, lapack_int* m, float* work,\n                                lapack_int lwork, lapack_int* iwork );\nlapack_int LAPACKE_dtgsna_work( int matrix_order, char job, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const double* a, lapack_int lda,\n                                const double* b, lapack_int ldb,\n                                const double* vl, lapack_int ldvl,\n                                const double* vr, lapack_int ldvr, double* s,\n                                double* dif, lapack_int mm, lapack_int* m,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_ctgsna_work( int matrix_order, char job, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                const lapack_complex_float* vl, lapack_int ldvl,\n                                const lapack_complex_float* vr, lapack_int ldvr,\n                                float* s, float* dif, lapack_int mm,\n                                lapack_int* m, lapack_complex_float* work,\n                                lapack_int lwork, lapack_int* iwork );\nlapack_int LAPACKE_ztgsna_work( int matrix_order, char job, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                const lapack_complex_double* vl,\n                                lapack_int ldvl,\n                                const lapack_complex_double* vr,\n                                lapack_int ldvr, double* s, double* dif,\n                                lapack_int mm, lapack_int* m,\n                                lapack_complex_double* work, lapack_int lwork,\n                                lapack_int* iwork );\n\nlapack_int LAPACKE_stgsyl_work( int matrix_order, char trans, lapack_int ijob,\n                                lapack_int m, lapack_int n, const float* a,\n                                lapack_int lda, const float* b, lapack_int ldb,\n                                float* c, lapack_int ldc, const float* d,\n                                lapack_int ldd, const float* e, lapack_int lde,\n                                float* f, lapack_int ldf, float* scale,\n                                float* dif, float* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dtgsyl_work( int matrix_order, char trans, lapack_int ijob,\n                                lapack_int m, lapack_int n, const double* a,\n                                lapack_int lda, const double* b, lapack_int ldb,\n                                double* c, lapack_int ldc, const double* d,\n                                lapack_int ldd, const double* e, lapack_int lde,\n                                double* f, lapack_int ldf, double* scale,\n                                double* dif, double* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_ctgsyl_work( int matrix_order, char trans, lapack_int ijob,\n                                lapack_int m, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* c, lapack_int ldc,\n                                const lapack_complex_float* d, lapack_int ldd,\n                                const lapack_complex_float* e, lapack_int lde,\n                                lapack_complex_float* f, lapack_int ldf,\n                                float* scale, float* dif,\n                                lapack_complex_float* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_ztgsyl_work( int matrix_order, char trans, lapack_int ijob,\n                                lapack_int m, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* c, lapack_int ldc,\n                                const lapack_complex_double* d, lapack_int ldd,\n                                const lapack_complex_double* e, lapack_int lde,\n                                lapack_complex_double* f, lapack_int ldf,\n                                double* scale, double* dif,\n                                lapack_complex_double* work, lapack_int lwork,\n                                lapack_int* iwork );\n\nlapack_int LAPACKE_stpcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n, const float* ap,\n                                float* rcond, float* work, lapack_int* iwork );\nlapack_int LAPACKE_dtpcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n, const double* ap,\n                                double* rcond, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_ctpcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n,\n                                const lapack_complex_float* ap, float* rcond,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_ztpcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n,\n                                const lapack_complex_double* ap, double* rcond,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_stprfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const float* ap, const float* b, lapack_int ldb,\n                                const float* x, lapack_int ldx, float* ferr,\n                                float* berr, float* work, lapack_int* iwork );\nlapack_int LAPACKE_dtprfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const double* ap, const double* b,\n                                lapack_int ldb, const double* x, lapack_int ldx,\n                                double* ferr, double* berr, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_ctprfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const lapack_complex_float* ap,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                const lapack_complex_float* x, lapack_int ldx,\n                                float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_ztprfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const lapack_complex_double* ap,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                const lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_stptri_work( int matrix_order, char uplo, char diag,\n                                lapack_int n, float* ap );\nlapack_int LAPACKE_dtptri_work( int matrix_order, char uplo, char diag,\n                                lapack_int n, double* ap );\nlapack_int LAPACKE_ctptri_work( int matrix_order, char uplo, char diag,\n                                lapack_int n, lapack_complex_float* ap );\nlapack_int LAPACKE_ztptri_work( int matrix_order, char uplo, char diag,\n                                lapack_int n, lapack_complex_double* ap );\n\nlapack_int LAPACKE_stptrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const float* ap, float* b, lapack_int ldb );\nlapack_int LAPACKE_dtptrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const double* ap, double* b, lapack_int ldb );\nlapack_int LAPACKE_ctptrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const lapack_complex_float* ap,\n                                lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_ztptrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const lapack_complex_double* ap,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_stpttf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const float* ap, float* arf );\nlapack_int LAPACKE_dtpttf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const double* ap, double* arf );\nlapack_int LAPACKE_ctpttf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const lapack_complex_float* ap,\n                                lapack_complex_float* arf );\nlapack_int LAPACKE_ztpttf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const lapack_complex_double* ap,\n                                lapack_complex_double* arf );\n\nlapack_int LAPACKE_stpttr_work( int matrix_order, char uplo, lapack_int n,\n                                const float* ap, float* a, lapack_int lda );\nlapack_int LAPACKE_dtpttr_work( int matrix_order, char uplo, lapack_int n,\n                                const double* ap, double* a, lapack_int lda );\nlapack_int LAPACKE_ctpttr_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_float* ap,\n                                lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_ztpttr_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_double* ap,\n                                lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_strcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n, const float* a,\n                                lapack_int lda, float* rcond, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dtrcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n, const double* a,\n                                lapack_int lda, double* rcond, double* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_ctrcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                float* rcond, lapack_complex_float* work,\n                                float* rwork );\nlapack_int LAPACKE_ztrcon_work( int matrix_order, char norm, char uplo,\n                                char diag, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                double* rcond, lapack_complex_double* work,\n                                double* rwork );\n\nlapack_int LAPACKE_strevc_work( int matrix_order, char side, char howmny,\n                                lapack_logical* select, lapack_int n,\n                                const float* t, lapack_int ldt, float* vl,\n                                lapack_int ldvl, float* vr, lapack_int ldvr,\n                                lapack_int mm, lapack_int* m, float* work );\nlapack_int LAPACKE_dtrevc_work( int matrix_order, char side, char howmny,\n                                lapack_logical* select, lapack_int n,\n                                const double* t, lapack_int ldt, double* vl,\n                                lapack_int ldvl, double* vr, lapack_int ldvr,\n                                lapack_int mm, lapack_int* m, double* work );\nlapack_int LAPACKE_ctrevc_work( int matrix_order, char side, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                lapack_complex_float* t, lapack_int ldt,\n                                lapack_complex_float* vl, lapack_int ldvl,\n                                lapack_complex_float* vr, lapack_int ldvr,\n                                lapack_int mm, lapack_int* m,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_ztrevc_work( int matrix_order, char side, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                lapack_complex_double* t, lapack_int ldt,\n                                lapack_complex_double* vl, lapack_int ldvl,\n                                lapack_complex_double* vr, lapack_int ldvr,\n                                lapack_int mm, lapack_int* m,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_strexc_work( int matrix_order, char compq, lapack_int n,\n                                float* t, lapack_int ldt, float* q,\n                                lapack_int ldq, lapack_int* ifst,\n                                lapack_int* ilst, float* work );\nlapack_int LAPACKE_dtrexc_work( int matrix_order, char compq, lapack_int n,\n                                double* t, lapack_int ldt, double* q,\n                                lapack_int ldq, lapack_int* ifst,\n                                lapack_int* ilst, double* work );\nlapack_int LAPACKE_ctrexc_work( int matrix_order, char compq, lapack_int n,\n                                lapack_complex_float* t, lapack_int ldt,\n                                lapack_complex_float* q, lapack_int ldq,\n                                lapack_int ifst, lapack_int ilst );\nlapack_int LAPACKE_ztrexc_work( int matrix_order, char compq, lapack_int n,\n                                lapack_complex_double* t, lapack_int ldt,\n                                lapack_complex_double* q, lapack_int ldq,\n                                lapack_int ifst, lapack_int ilst );\n\nlapack_int LAPACKE_strrfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const float* a, lapack_int lda, const float* b,\n                                lapack_int ldb, const float* x, lapack_int ldx,\n                                float* ferr, float* berr, float* work,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dtrrfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const double* a, lapack_int lda,\n                                const double* b, lapack_int ldb,\n                                const double* x, lapack_int ldx, double* ferr,\n                                double* berr, double* work, lapack_int* iwork );\nlapack_int LAPACKE_ctrrfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const lapack_complex_float* a, lapack_int lda,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                const lapack_complex_float* x, lapack_int ldx,\n                                float* ferr, float* berr,\n                                lapack_complex_float* work, float* rwork );\nlapack_int LAPACKE_ztrrfs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const lapack_complex_double* a, lapack_int lda,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                const lapack_complex_double* x, lapack_int ldx,\n                                double* ferr, double* berr,\n                                lapack_complex_double* work, double* rwork );\n\nlapack_int LAPACKE_strsen_work( int matrix_order, char job, char compq,\n                                const lapack_logical* select, lapack_int n,\n                                float* t, lapack_int ldt, float* q,\n                                lapack_int ldq, float* wr, float* wi,\n                                lapack_int* m, float* s, float* sep,\n                                float* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_dtrsen_work( int matrix_order, char job, char compq,\n                                const lapack_logical* select, lapack_int n,\n                                double* t, lapack_int ldt, double* q,\n                                lapack_int ldq, double* wr, double* wi,\n                                lapack_int* m, double* s, double* sep,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork, lapack_int liwork );\nlapack_int LAPACKE_ctrsen_work( int matrix_order, char job, char compq,\n                                const lapack_logical* select, lapack_int n,\n                                lapack_complex_float* t, lapack_int ldt,\n                                lapack_complex_float* q, lapack_int ldq,\n                                lapack_complex_float* w, lapack_int* m,\n                                float* s, float* sep,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_ztrsen_work( int matrix_order, char job, char compq,\n                                const lapack_logical* select, lapack_int n,\n                                lapack_complex_double* t, lapack_int ldt,\n                                lapack_complex_double* q, lapack_int ldq,\n                                lapack_complex_double* w, lapack_int* m,\n                                double* s, double* sep,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_strsna_work( int matrix_order, char job, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const float* t, lapack_int ldt, const float* vl,\n                                lapack_int ldvl, const float* vr,\n                                lapack_int ldvr, float* s, float* sep,\n                                lapack_int mm, lapack_int* m, float* work,\n                                lapack_int ldwork, lapack_int* iwork );\nlapack_int LAPACKE_dtrsna_work( int matrix_order, char job, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const double* t, lapack_int ldt,\n                                const double* vl, lapack_int ldvl,\n                                const double* vr, lapack_int ldvr, double* s,\n                                double* sep, lapack_int mm, lapack_int* m,\n                                double* work, lapack_int ldwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_ctrsna_work( int matrix_order, char job, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const lapack_complex_float* t, lapack_int ldt,\n                                const lapack_complex_float* vl, lapack_int ldvl,\n                                const lapack_complex_float* vr, lapack_int ldvr,\n                                float* s, float* sep, lapack_int mm,\n                                lapack_int* m, lapack_complex_float* work,\n                                lapack_int ldwork, float* rwork );\nlapack_int LAPACKE_ztrsna_work( int matrix_order, char job, char howmny,\n                                const lapack_logical* select, lapack_int n,\n                                const lapack_complex_double* t, lapack_int ldt,\n                                const lapack_complex_double* vl,\n                                lapack_int ldvl,\n                                const lapack_complex_double* vr,\n                                lapack_int ldvr, double* s, double* sep,\n                                lapack_int mm, lapack_int* m,\n                                lapack_complex_double* work, lapack_int ldwork,\n                                double* rwork );\n\nlapack_int LAPACKE_strsyl_work( int matrix_order, char trana, char tranb,\n                                lapack_int isgn, lapack_int m, lapack_int n,\n                                const float* a, lapack_int lda, const float* b,\n                                lapack_int ldb, float* c, lapack_int ldc,\n                                float* scale );\nlapack_int LAPACKE_dtrsyl_work( int matrix_order, char trana, char tranb,\n                                lapack_int isgn, lapack_int m, lapack_int n,\n                                const double* a, lapack_int lda,\n                                const double* b, lapack_int ldb, double* c,\n                                lapack_int ldc, double* scale );\nlapack_int LAPACKE_ctrsyl_work( int matrix_order, char trana, char tranb,\n                                lapack_int isgn, lapack_int m, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                const lapack_complex_float* b, lapack_int ldb,\n                                lapack_complex_float* c, lapack_int ldc,\n                                float* scale );\nlapack_int LAPACKE_ztrsyl_work( int matrix_order, char trana, char tranb,\n                                lapack_int isgn, lapack_int m, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                const lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* c, lapack_int ldc,\n                                double* scale );\n\nlapack_int LAPACKE_strtri_work( int matrix_order, char uplo, char diag,\n                                lapack_int n, float* a, lapack_int lda );\nlapack_int LAPACKE_dtrtri_work( int matrix_order, char uplo, char diag,\n                                lapack_int n, double* a, lapack_int lda );\nlapack_int LAPACKE_ctrtri_work( int matrix_order, char uplo, char diag,\n                                lapack_int n, lapack_complex_float* a,\n                                lapack_int lda );\nlapack_int LAPACKE_ztrtri_work( int matrix_order, char uplo, char diag,\n                                lapack_int n, lapack_complex_double* a,\n                                lapack_int lda );\n\nlapack_int LAPACKE_strtrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const float* a, lapack_int lda, float* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_dtrtrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const double* a, lapack_int lda, double* b,\n                                lapack_int ldb );\nlapack_int LAPACKE_ctrtrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_ztrtrs_work( int matrix_order, char uplo, char trans,\n                                char diag, lapack_int n, lapack_int nrhs,\n                                const lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_strttf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const float* a, lapack_int lda,\n                                float* arf );\nlapack_int LAPACKE_dtrttf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const double* a, lapack_int lda,\n                                double* arf );\nlapack_int LAPACKE_ctrttf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* arf );\nlapack_int LAPACKE_ztrttf_work( int matrix_order, char transr, char uplo,\n                                lapack_int n, const lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* arf );\n\nlapack_int LAPACKE_strttp_work( int matrix_order, char uplo, lapack_int n,\n                                const float* a, lapack_int lda, float* ap );\nlapack_int LAPACKE_dtrttp_work( int matrix_order, char uplo, lapack_int n,\n                                const double* a, lapack_int lda, double* ap );\nlapack_int LAPACKE_ctrttp_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* ap );\nlapack_int LAPACKE_ztrttp_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* ap );\n\nlapack_int LAPACKE_stzrzf_work( int matrix_order, lapack_int m, lapack_int n,\n                                float* a, lapack_int lda, float* tau,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_dtzrzf_work( int matrix_order, lapack_int m, lapack_int n,\n                                double* a, lapack_int lda, double* tau,\n                                double* work, lapack_int lwork );\nlapack_int LAPACKE_ctzrzf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_ztzrzf_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cungbr_work( int matrix_order, char vect, lapack_int m,\n                                lapack_int n, lapack_int k,\n                                lapack_complex_float* a, lapack_int lda,\n                                const lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zungbr_work( int matrix_order, char vect, lapack_int m,\n                                lapack_int n, lapack_int k,\n                                lapack_complex_double* a, lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cunghr_work( int matrix_order, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zunghr_work( int matrix_order, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, lapack_complex_double* a,\n                                lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cunglq_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zunglq_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, lapack_complex_double* a,\n                                lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cungql_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zungql_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, lapack_complex_double* a,\n                                lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cungqr_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zungqr_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, lapack_complex_double* a,\n                                lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cungrq_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zungrq_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int k, lapack_complex_double* a,\n                                lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cungtr_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_float* a, lapack_int lda,\n                                const lapack_complex_float* tau,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zungtr_work( int matrix_order, char uplo, lapack_int n,\n                                lapack_complex_double* a, lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cunmbr_work( int matrix_order, char vect, char side,\n                                char trans, lapack_int m, lapack_int n,\n                                lapack_int k, const lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* tau,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zunmbr_work( int matrix_order, char vect, char side,\n                                char trans, lapack_int m, lapack_int n,\n                                lapack_int k, const lapack_complex_double* a,\n                                lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cunmhr_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, const lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* tau,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zunmhr_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int ilo,\n                                lapack_int ihi, const lapack_complex_double* a,\n                                lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cunmlq_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const lapack_complex_float* a, lapack_int lda,\n                                const lapack_complex_float* tau,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zunmlq_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const lapack_complex_double* a, lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cunmql_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const lapack_complex_float* a, lapack_int lda,\n                                const lapack_complex_float* tau,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zunmql_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const lapack_complex_double* a, lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cunmqr_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const lapack_complex_float* a, lapack_int lda,\n                                const lapack_complex_float* tau,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zunmqr_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const lapack_complex_double* a, lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cunmrq_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const lapack_complex_float* a, lapack_int lda,\n                                const lapack_complex_float* tau,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zunmrq_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                const lapack_complex_double* a, lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cunmrz_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                lapack_int l, const lapack_complex_float* a,\n                                lapack_int lda, const lapack_complex_float* tau,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zunmrz_work( int matrix_order, char side, char trans,\n                                lapack_int m, lapack_int n, lapack_int k,\n                                lapack_int l, const lapack_complex_double* a,\n                                lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cunmtr_work( int matrix_order, char side, char uplo,\n                                char trans, lapack_int m, lapack_int n,\n                                const lapack_complex_float* a, lapack_int lda,\n                                const lapack_complex_float* tau,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_zunmtr_work( int matrix_order, char side, char uplo,\n                                char trans, lapack_int m, lapack_int n,\n                                const lapack_complex_double* a, lapack_int lda,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work, lapack_int lwork );\n\nlapack_int LAPACKE_cupgtr_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_float* ap,\n                                const lapack_complex_float* tau,\n                                lapack_complex_float* q, lapack_int ldq,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zupgtr_work( int matrix_order, char uplo, lapack_int n,\n                                const lapack_complex_double* ap,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* q, lapack_int ldq,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_cupmtr_work( int matrix_order, char side, char uplo,\n                                char trans, lapack_int m, lapack_int n,\n                                const lapack_complex_float* ap,\n                                const lapack_complex_float* tau,\n                                lapack_complex_float* c, lapack_int ldc,\n                                lapack_complex_float* work );\nlapack_int LAPACKE_zupmtr_work( int matrix_order, char side, char uplo,\n                                char trans, lapack_int m, lapack_int n,\n                                const lapack_complex_double* ap,\n                                const lapack_complex_double* tau,\n                                lapack_complex_double* c, lapack_int ldc,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_claghe( int matrix_order, lapack_int n, lapack_int k,\n                           const float* d, lapack_complex_float* a,\n                           lapack_int lda, lapack_int* iseed );\nlapack_int LAPACKE_zlaghe( int matrix_order, lapack_int n, lapack_int k,\n                           const double* d, lapack_complex_double* a,\n                           lapack_int lda, lapack_int* iseed );\n\nlapack_int LAPACKE_slagsy( int matrix_order, lapack_int n, lapack_int k,\n                           const float* d, float* a, lapack_int lda,\n                           lapack_int* iseed );\nlapack_int LAPACKE_dlagsy( int matrix_order, lapack_int n, lapack_int k,\n                           const double* d, double* a, lapack_int lda,\n                           lapack_int* iseed );\nlapack_int LAPACKE_clagsy( int matrix_order, lapack_int n, lapack_int k,\n                           const float* d, lapack_complex_float* a,\n                           lapack_int lda, lapack_int* iseed );\nlapack_int LAPACKE_zlagsy( int matrix_order, lapack_int n, lapack_int k,\n                           const double* d, lapack_complex_double* a,\n                           lapack_int lda, lapack_int* iseed );\n\nlapack_int LAPACKE_slapmr( int matrix_order, lapack_logical forwrd,\n                           lapack_int m, lapack_int n, float* x, lapack_int ldx,\n                           lapack_int* k );\nlapack_int LAPACKE_dlapmr( int matrix_order, lapack_logical forwrd,\n                           lapack_int m, lapack_int n, double* x,\n                           lapack_int ldx, lapack_int* k );\nlapack_int LAPACKE_clapmr( int matrix_order, lapack_logical forwrd,\n                           lapack_int m, lapack_int n, lapack_complex_float* x,\n                           lapack_int ldx, lapack_int* k );\nlapack_int LAPACKE_zlapmr( int matrix_order, lapack_logical forwrd,\n                           lapack_int m, lapack_int n, lapack_complex_double* x,\n                           lapack_int ldx, lapack_int* k );\n\n\nfloat LAPACKE_slapy2( float x, float y );\ndouble LAPACKE_dlapy2( double x, double y );\n\nfloat LAPACKE_slapy3( float x, float y, float z );\ndouble LAPACKE_dlapy3( double x, double y, double z );\n\nlapack_int LAPACKE_slartgp( float f, float g, float* cs, float* sn, float* r );\nlapack_int LAPACKE_dlartgp( double f, double g, double* cs, double* sn,\n                            double* r );\n\nlapack_int LAPACKE_slartgs( float x, float y, float sigma, float* cs,\n                            float* sn );\nlapack_int LAPACKE_dlartgs( double x, double y, double sigma, double* cs,\n                            double* sn );\n\n\n//LAPACK 3.3.0\nlapack_int LAPACKE_cbbcsd( int matrix_order, char jobu1, char jobu2,\n                           char jobv1t, char jobv2t, char trans, lapack_int m,\n                           lapack_int p, lapack_int q, float* theta, float* phi,\n                           lapack_complex_float* u1, lapack_int ldu1,\n                           lapack_complex_float* u2, lapack_int ldu2,\n                           lapack_complex_float* v1t, lapack_int ldv1t,\n                           lapack_complex_float* v2t, lapack_int ldv2t,\n                           float* b11d, float* b11e, float* b12d, float* b12e,\n                           float* b21d, float* b21e, float* b22d, float* b22e );\nlapack_int LAPACKE_cbbcsd_work( int matrix_order, char jobu1, char jobu2,\n                                char jobv1t, char jobv2t, char trans,\n                                lapack_int m, lapack_int p, lapack_int q,\n                                float* theta, float* phi,\n                                lapack_complex_float* u1, lapack_int ldu1,\n                                lapack_complex_float* u2, lapack_int ldu2,\n                                lapack_complex_float* v1t, lapack_int ldv1t,\n                                lapack_complex_float* v2t, lapack_int ldv2t,\n                                float* b11d, float* b11e, float* b12d,\n                                float* b12e, float* b21d, float* b21e,\n                                float* b22d, float* b22e, float* rwork,\n                                lapack_int lrwork );\nlapack_int LAPACKE_cheswapr( int matrix_order, char uplo, lapack_int n,\n                             lapack_complex_float* a, lapack_int i1,\n                             lapack_int i2 );\nlapack_int LAPACKE_cheswapr_work( int matrix_order, char uplo, lapack_int n,\n                                  lapack_complex_float* a, lapack_int i1,\n                                  lapack_int i2 );\nlapack_int LAPACKE_chetri2( int matrix_order, char uplo, lapack_int n,\n                            lapack_complex_float* a, lapack_int lda,\n                            const lapack_int* ipiv );\nlapack_int LAPACKE_chetri2_work( int matrix_order, char uplo, lapack_int n,\n                                 lapack_complex_float* a, lapack_int lda,\n                                 const lapack_int* ipiv,\n                                 lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_chetri2x( int matrix_order, char uplo, lapack_int n,\n                             lapack_complex_float* a, lapack_int lda,\n                             const lapack_int* ipiv, lapack_int nb );\nlapack_int LAPACKE_chetri2x_work( int matrix_order, char uplo, lapack_int n,\n                                  lapack_complex_float* a, lapack_int lda,\n                                  const lapack_int* ipiv,\n                                  lapack_complex_float* work, lapack_int nb );\nlapack_int LAPACKE_chetrs2( int matrix_order, char uplo, lapack_int n,\n                            lapack_int nrhs, const lapack_complex_float* a,\n                            lapack_int lda, const lapack_int* ipiv,\n                            lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_chetrs2_work( int matrix_order, char uplo, lapack_int n,\n                                 lapack_int nrhs, const lapack_complex_float* a,\n                                 lapack_int lda, const lapack_int* ipiv,\n                                 lapack_complex_float* b, lapack_int ldb,\n                                 lapack_complex_float* work );\nlapack_int LAPACKE_csyconv( int matrix_order, char uplo, char way, lapack_int n,\n                            lapack_complex_float* a, lapack_int lda,\n                            const lapack_int* ipiv );\nlapack_int LAPACKE_csyconv_work( int matrix_order, char uplo, char way,\n                                 lapack_int n, lapack_complex_float* a,\n                                 lapack_int lda, const lapack_int* ipiv,\n                                 lapack_complex_float* work );\nlapack_int LAPACKE_csyswapr( int matrix_order, char uplo, lapack_int n,\n                             lapack_complex_float* a, lapack_int i1,\n                             lapack_int i2 );\nlapack_int LAPACKE_csyswapr_work( int matrix_order, char uplo, lapack_int n,\n                                  lapack_complex_float* a, lapack_int i1,\n                                  lapack_int i2 );\nlapack_int LAPACKE_csytri2( int matrix_order, char uplo, lapack_int n,\n                            lapack_complex_float* a, lapack_int lda,\n                            const lapack_int* ipiv );\nlapack_int LAPACKE_csytri2_work( int matrix_order, char uplo, lapack_int n,\n                                 lapack_complex_float* a, lapack_int lda,\n                                 const lapack_int* ipiv,\n                                 lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_csytri2x( int matrix_order, char uplo, lapack_int n,\n                             lapack_complex_float* a, lapack_int lda,\n                             const lapack_int* ipiv, lapack_int nb );\nlapack_int LAPACKE_csytri2x_work( int matrix_order, char uplo, lapack_int n,\n                                  lapack_complex_float* a, lapack_int lda,\n                                  const lapack_int* ipiv,\n                                  lapack_complex_float* work, lapack_int nb );\nlapack_int LAPACKE_csytrs2( int matrix_order, char uplo, lapack_int n,\n                            lapack_int nrhs, const lapack_complex_float* a,\n                            lapack_int lda, const lapack_int* ipiv,\n                            lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_csytrs2_work( int matrix_order, char uplo, lapack_int n,\n                                 lapack_int nrhs, const lapack_complex_float* a,\n                                 lapack_int lda, const lapack_int* ipiv,\n                                 lapack_complex_float* b, lapack_int ldb,\n                                 lapack_complex_float* work );\nlapack_int LAPACKE_cunbdb( int matrix_order, char trans, char signs,\n                           lapack_int m, lapack_int p, lapack_int q,\n                           lapack_complex_float* x11, lapack_int ldx11,\n                           lapack_complex_float* x12, lapack_int ldx12,\n                           lapack_complex_float* x21, lapack_int ldx21,\n                           lapack_complex_float* x22, lapack_int ldx22,\n                           float* theta, float* phi,\n                           lapack_complex_float* taup1,\n                           lapack_complex_float* taup2,\n                           lapack_complex_float* tauq1,\n                           lapack_complex_float* tauq2 );\nlapack_int LAPACKE_cunbdb_work( int matrix_order, char trans, char signs,\n                                lapack_int m, lapack_int p, lapack_int q,\n                                lapack_complex_float* x11, lapack_int ldx11,\n                                lapack_complex_float* x12, lapack_int ldx12,\n                                lapack_complex_float* x21, lapack_int ldx21,\n                                lapack_complex_float* x22, lapack_int ldx22,\n                                float* theta, float* phi,\n                                lapack_complex_float* taup1,\n                                lapack_complex_float* taup2,\n                                lapack_complex_float* tauq1,\n                                lapack_complex_float* tauq2,\n                                lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_cuncsd( int matrix_order, char jobu1, char jobu2,\n                           char jobv1t, char jobv2t, char trans, char signs,\n                           lapack_int m, lapack_int p, lapack_int q,\n                           lapack_complex_float* x11, lapack_int ldx11,\n                           lapack_complex_float* x12, lapack_int ldx12,\n                           lapack_complex_float* x21, lapack_int ldx21,\n                           lapack_complex_float* x22, lapack_int ldx22,\n                           float* theta, lapack_complex_float* u1,\n                           lapack_int ldu1, lapack_complex_float* u2,\n                           lapack_int ldu2, lapack_complex_float* v1t,\n                           lapack_int ldv1t, lapack_complex_float* v2t,\n                           lapack_int ldv2t );\nlapack_int LAPACKE_cuncsd_work( int matrix_order, char jobu1, char jobu2,\n                                char jobv1t, char jobv2t, char trans,\n                                char signs, lapack_int m, lapack_int p,\n                                lapack_int q, lapack_complex_float* x11,\n                                lapack_int ldx11, lapack_complex_float* x12,\n                                lapack_int ldx12, lapack_complex_float* x21,\n                                lapack_int ldx21, lapack_complex_float* x22,\n                                lapack_int ldx22, float* theta,\n                                lapack_complex_float* u1, lapack_int ldu1,\n                                lapack_complex_float* u2, lapack_int ldu2,\n                                lapack_complex_float* v1t, lapack_int ldv1t,\n                                lapack_complex_float* v2t, lapack_int ldv2t,\n                                lapack_complex_float* work, lapack_int lwork,\n                                float* rwork, lapack_int lrwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dbbcsd( int matrix_order, char jobu1, char jobu2,\n                           char jobv1t, char jobv2t, char trans, lapack_int m,\n                           lapack_int p, lapack_int q, double* theta,\n                           double* phi, double* u1, lapack_int ldu1, double* u2,\n                           lapack_int ldu2, double* v1t, lapack_int ldv1t,\n                           double* v2t, lapack_int ldv2t, double* b11d,\n                           double* b11e, double* b12d, double* b12e,\n                           double* b21d, double* b21e, double* b22d,\n                           double* b22e );\nlapack_int LAPACKE_dbbcsd_work( int matrix_order, char jobu1, char jobu2,\n                                char jobv1t, char jobv2t, char trans,\n                                lapack_int m, lapack_int p, lapack_int q,\n                                double* theta, double* phi, double* u1,\n                                lapack_int ldu1, double* u2, lapack_int ldu2,\n                                double* v1t, lapack_int ldv1t, double* v2t,\n                                lapack_int ldv2t, double* b11d, double* b11e,\n                                double* b12d, double* b12e, double* b21d,\n                                double* b21e, double* b22d, double* b22e,\n                                double* work, lapack_int lwork );\nlapack_int LAPACKE_dorbdb( int matrix_order, char trans, char signs,\n                           lapack_int m, lapack_int p, lapack_int q,\n                           double* x11, lapack_int ldx11, double* x12,\n                           lapack_int ldx12, double* x21, lapack_int ldx21,\n                           double* x22, lapack_int ldx22, double* theta,\n                           double* phi, double* taup1, double* taup2,\n                           double* tauq1, double* tauq2 );\nlapack_int LAPACKE_dorbdb_work( int matrix_order, char trans, char signs,\n                                lapack_int m, lapack_int p, lapack_int q,\n                                double* x11, lapack_int ldx11, double* x12,\n                                lapack_int ldx12, double* x21, lapack_int ldx21,\n                                double* x22, lapack_int ldx22, double* theta,\n                                double* phi, double* taup1, double* taup2,\n                                double* tauq1, double* tauq2, double* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_dorcsd( int matrix_order, char jobu1, char jobu2,\n                           char jobv1t, char jobv2t, char trans, char signs,\n                           lapack_int m, lapack_int p, lapack_int q,\n                           double* x11, lapack_int ldx11, double* x12,\n                           lapack_int ldx12, double* x21, lapack_int ldx21,\n                           double* x22, lapack_int ldx22, double* theta,\n                           double* u1, lapack_int ldu1, double* u2,\n                           lapack_int ldu2, double* v1t, lapack_int ldv1t,\n                           double* v2t, lapack_int ldv2t );\nlapack_int LAPACKE_dorcsd_work( int matrix_order, char jobu1, char jobu2,\n                                char jobv1t, char jobv2t, char trans,\n                                char signs, lapack_int m, lapack_int p,\n                                lapack_int q, double* x11, lapack_int ldx11,\n                                double* x12, lapack_int ldx12, double* x21,\n                                lapack_int ldx21, double* x22, lapack_int ldx22,\n                                double* theta, double* u1, lapack_int ldu1,\n                                double* u2, lapack_int ldu2, double* v1t,\n                                lapack_int ldv1t, double* v2t, lapack_int ldv2t,\n                                double* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_dsyconv( int matrix_order, char uplo, char way, lapack_int n,\n                            double* a, lapack_int lda, const lapack_int* ipiv );\nlapack_int LAPACKE_dsyconv_work( int matrix_order, char uplo, char way,\n                                 lapack_int n, double* a, lapack_int lda,\n                                 const lapack_int* ipiv, double* work );\nlapack_int LAPACKE_dsyswapr( int matrix_order, char uplo, lapack_int n,\n                             double* a, lapack_int i1, lapack_int i2 );\nlapack_int LAPACKE_dsyswapr_work( int matrix_order, char uplo, lapack_int n,\n                                  double* a, lapack_int i1, lapack_int i2 );\nlapack_int LAPACKE_dsytri2( int matrix_order, char uplo, lapack_int n,\n                            double* a, lapack_int lda, const lapack_int* ipiv );\nlapack_int LAPACKE_dsytri2_work( int matrix_order, char uplo, lapack_int n,\n                                 double* a, lapack_int lda,\n                                 const lapack_int* ipiv,\n                                 lapack_complex_double* work, lapack_int lwork );\nlapack_int LAPACKE_dsytri2x( int matrix_order, char uplo, lapack_int n,\n                             double* a, lapack_int lda, const lapack_int* ipiv,\n                             lapack_int nb );\nlapack_int LAPACKE_dsytri2x_work( int matrix_order, char uplo, lapack_int n,\n                                  double* a, lapack_int lda,\n                                  const lapack_int* ipiv, double* work,\n                                  lapack_int nb );\nlapack_int LAPACKE_dsytrs2( int matrix_order, char uplo, lapack_int n,\n                            lapack_int nrhs, const double* a, lapack_int lda,\n                            const lapack_int* ipiv, double* b, lapack_int ldb );\nlapack_int LAPACKE_dsytrs2_work( int matrix_order, char uplo, lapack_int n,\n                                 lapack_int nrhs, const double* a,\n                                 lapack_int lda, const lapack_int* ipiv,\n                                 double* b, lapack_int ldb, double* work );\nlapack_int LAPACKE_sbbcsd( int matrix_order, char jobu1, char jobu2,\n                           char jobv1t, char jobv2t, char trans, lapack_int m,\n                           lapack_int p, lapack_int q, float* theta, float* phi,\n                           float* u1, lapack_int ldu1, float* u2,\n                           lapack_int ldu2, float* v1t, lapack_int ldv1t,\n                           float* v2t, lapack_int ldv2t, float* b11d,\n                           float* b11e, float* b12d, float* b12e, float* b21d,\n                           float* b21e, float* b22d, float* b22e );\nlapack_int LAPACKE_sbbcsd_work( int matrix_order, char jobu1, char jobu2,\n                                char jobv1t, char jobv2t, char trans,\n                                lapack_int m, lapack_int p, lapack_int q,\n                                float* theta, float* phi, float* u1,\n                                lapack_int ldu1, float* u2, lapack_int ldu2,\n                                float* v1t, lapack_int ldv1t, float* v2t,\n                                lapack_int ldv2t, float* b11d, float* b11e,\n                                float* b12d, float* b12e, float* b21d,\n                                float* b21e, float* b22d, float* b22e,\n                                float* work, lapack_int lwork );\nlapack_int LAPACKE_sorbdb( int matrix_order, char trans, char signs,\n                           lapack_int m, lapack_int p, lapack_int q, float* x11,\n                           lapack_int ldx11, float* x12, lapack_int ldx12,\n                           float* x21, lapack_int ldx21, float* x22,\n                           lapack_int ldx22, float* theta, float* phi,\n                           float* taup1, float* taup2, float* tauq1,\n                           float* tauq2 );\nlapack_int LAPACKE_sorbdb_work( int matrix_order, char trans, char signs,\n                                lapack_int m, lapack_int p, lapack_int q,\n                                float* x11, lapack_int ldx11, float* x12,\n                                lapack_int ldx12, float* x21, lapack_int ldx21,\n                                float* x22, lapack_int ldx22, float* theta,\n                                float* phi, float* taup1, float* taup2,\n                                float* tauq1, float* tauq2, float* work,\n                                lapack_int lwork );\nlapack_int LAPACKE_sorcsd( int matrix_order, char jobu1, char jobu2,\n                           char jobv1t, char jobv2t, char trans, char signs,\n                           lapack_int m, lapack_int p, lapack_int q, float* x11,\n                           lapack_int ldx11, float* x12, lapack_int ldx12,\n                           float* x21, lapack_int ldx21, float* x22,\n                           lapack_int ldx22, float* theta, float* u1,\n                           lapack_int ldu1, float* u2, lapack_int ldu2,\n                           float* v1t, lapack_int ldv1t, float* v2t,\n                           lapack_int ldv2t );\nlapack_int LAPACKE_sorcsd_work( int matrix_order, char jobu1, char jobu2,\n                                char jobv1t, char jobv2t, char trans,\n                                char signs, lapack_int m, lapack_int p,\n                                lapack_int q, float* x11, lapack_int ldx11,\n                                float* x12, lapack_int ldx12, float* x21,\n                                lapack_int ldx21, float* x22, lapack_int ldx22,\n                                float* theta, float* u1, lapack_int ldu1,\n                                float* u2, lapack_int ldu2, float* v1t,\n                                lapack_int ldv1t, float* v2t, lapack_int ldv2t,\n                                float* work, lapack_int lwork,\n                                lapack_int* iwork );\nlapack_int LAPACKE_ssyconv( int matrix_order, char uplo, char way, lapack_int n,\n                            float* a, lapack_int lda, const lapack_int* ipiv );\nlapack_int LAPACKE_ssyconv_work( int matrix_order, char uplo, char way,\n                                 lapack_int n, float* a, lapack_int lda,\n                                 const lapack_int* ipiv, float* work );\nlapack_int LAPACKE_ssyswapr( int matrix_order, char uplo, lapack_int n,\n                             float* a, lapack_int i1, lapack_int i2 );\nlapack_int LAPACKE_ssyswapr_work( int matrix_order, char uplo, lapack_int n,\n                                  float* a, lapack_int i1, lapack_int i2 );\nlapack_int LAPACKE_ssytri2( int matrix_order, char uplo, lapack_int n, float* a,\n                            lapack_int lda, const lapack_int* ipiv );\nlapack_int LAPACKE_ssytri2_work( int matrix_order, char uplo, lapack_int n,\n                                 float* a, lapack_int lda,\n                                 const lapack_int* ipiv,\n                                 lapack_complex_float* work, lapack_int lwork );\nlapack_int LAPACKE_ssytri2x( int matrix_order, char uplo, lapack_int n,\n                             float* a, lapack_int lda, const lapack_int* ipiv,\n                             lapack_int nb );\nlapack_int LAPACKE_ssytri2x_work( int matrix_order, char uplo, lapack_int n,\n                                  float* a, lapack_int lda,\n                                  const lapack_int* ipiv, float* work,\n                                  lapack_int nb );\nlapack_int LAPACKE_ssytrs2( int matrix_order, char uplo, lapack_int n,\n                            lapack_int nrhs, const float* a, lapack_int lda,\n                            const lapack_int* ipiv, float* b, lapack_int ldb );\nlapack_int LAPACKE_ssytrs2_work( int matrix_order, char uplo, lapack_int n,\n                                 lapack_int nrhs, const float* a,\n                                 lapack_int lda, const lapack_int* ipiv,\n                                 float* b, lapack_int ldb, float* work );\nlapack_int LAPACKE_zbbcsd( int matrix_order, char jobu1, char jobu2,\n                           char jobv1t, char jobv2t, char trans, lapack_int m,\n                           lapack_int p, lapack_int q, double* theta,\n                           double* phi, lapack_complex_double* u1,\n                           lapack_int ldu1, lapack_complex_double* u2,\n                           lapack_int ldu2, lapack_complex_double* v1t,\n                           lapack_int ldv1t, lapack_complex_double* v2t,\n                           lapack_int ldv2t, double* b11d, double* b11e,\n                           double* b12d, double* b12e, double* b21d,\n                           double* b21e, double* b22d, double* b22e );\nlapack_int LAPACKE_zbbcsd_work( int matrix_order, char jobu1, char jobu2,\n                                char jobv1t, char jobv2t, char trans,\n                                lapack_int m, lapack_int p, lapack_int q,\n                                double* theta, double* phi,\n                                lapack_complex_double* u1, lapack_int ldu1,\n                                lapack_complex_double* u2, lapack_int ldu2,\n                                lapack_complex_double* v1t, lapack_int ldv1t,\n                                lapack_complex_double* v2t, lapack_int ldv2t,\n                                double* b11d, double* b11e, double* b12d,\n                                double* b12e, double* b21d, double* b21e,\n                                double* b22d, double* b22e, double* rwork,\n                                lapack_int lrwork );\nlapack_int LAPACKE_zheswapr( int matrix_order, char uplo, lapack_int n,\n                             lapack_complex_double* a, lapack_int i1,\n                             lapack_int i2 );\nlapack_int LAPACKE_zheswapr_work( int matrix_order, char uplo, lapack_int n,\n                                  lapack_complex_double* a, lapack_int i1,\n                                  lapack_int i2 );\nlapack_int LAPACKE_zhetri2( int matrix_order, char uplo, lapack_int n,\n                            lapack_complex_double* a, lapack_int lda,\n                            const lapack_int* ipiv );\nlapack_int LAPACKE_zhetri2_work( int matrix_order, char uplo, lapack_int n,\n                                 lapack_complex_double* a, lapack_int lda,\n                                 const lapack_int* ipiv,\n                                 lapack_complex_double* work, lapack_int lwork );\nlapack_int LAPACKE_zhetri2x( int matrix_order, char uplo, lapack_int n,\n                             lapack_complex_double* a, lapack_int lda,\n                             const lapack_int* ipiv, lapack_int nb );\nlapack_int LAPACKE_zhetri2x_work( int matrix_order, char uplo, lapack_int n,\n                                  lapack_complex_double* a, lapack_int lda,\n                                  const lapack_int* ipiv,\n                                  lapack_complex_double* work, lapack_int nb );\nlapack_int LAPACKE_zhetrs2( int matrix_order, char uplo, lapack_int n,\n                            lapack_int nrhs, const lapack_complex_double* a,\n                            lapack_int lda, const lapack_int* ipiv,\n                            lapack_complex_double* b, lapack_int ldb );\nlapack_int LAPACKE_zhetrs2_work( int matrix_order, char uplo, lapack_int n,\n                                 lapack_int nrhs, const lapack_complex_double* a,\n                                 lapack_int lda, const lapack_int* ipiv,\n                                 lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* work );\nlapack_int LAPACKE_zsyconv( int matrix_order, char uplo, char way, lapack_int n,\n                            lapack_complex_double* a, lapack_int lda,\n                            const lapack_int* ipiv );\nlapack_int LAPACKE_zsyconv_work( int matrix_order, char uplo, char way,\n                                 lapack_int n, lapack_complex_double* a,\n                                 lapack_int lda, const lapack_int* ipiv,\n                                 lapack_complex_double* work );\nlapack_int LAPACKE_zsyswapr( int matrix_order, char uplo, lapack_int n,\n                             lapack_complex_double* a, lapack_int i1,\n                             lapack_int i2 );\nlapack_int LAPACKE_zsyswapr_work( int matrix_order, char uplo, lapack_int n,\n                                  lapack_complex_double* a, lapack_int i1,\n                                  lapack_int i2 );\nlapack_int LAPACKE_zsytri2( int matrix_order, char uplo, lapack_int n,\n                            lapack_complex_double* a, lapack_int lda,\n                            const lapack_int* ipiv );\nlapack_int LAPACKE_zsytri2_work( int matrix_order, char uplo, lapack_int n,\n                                 lapack_complex_double* a, lapack_int lda,\n                                 const lapack_int* ipiv,\n                                 lapack_complex_double* work, lapack_int lwork );\nlapack_int LAPACKE_zsytri2x( int matrix_order, char uplo, lapack_int n,\n                             lapack_complex_double* a, lapack_int lda,\n                             const lapack_int* ipiv, lapack_int nb );\nlapack_int LAPACKE_zsytri2x_work( int matrix_order, char uplo, lapack_int n,\n                                  lapack_complex_double* a, lapack_int lda,\n                                  const lapack_int* ipiv,\n                                  lapack_complex_double* work, lapack_int nb );\nlapack_int LAPACKE_zsytrs2( int matrix_order, char uplo, lapack_int n,\n                            lapack_int nrhs, const lapack_complex_double* a,\n                            lapack_int lda, const lapack_int* ipiv,\n                            lapack_complex_double* b, lapack_int ldb );\nlapack_int LAPACKE_zsytrs2_work( int matrix_order, char uplo, lapack_int n,\n                                 lapack_int nrhs, const lapack_complex_double* a,\n                                 lapack_int lda, const lapack_int* ipiv,\n                                 lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* work );\nlapack_int LAPACKE_zunbdb( int matrix_order, char trans, char signs,\n                           lapack_int m, lapack_int p, lapack_int q,\n                           lapack_complex_double* x11, lapack_int ldx11,\n                           lapack_complex_double* x12, lapack_int ldx12,\n                           lapack_complex_double* x21, lapack_int ldx21,\n                           lapack_complex_double* x22, lapack_int ldx22,\n                           double* theta, double* phi,\n                           lapack_complex_double* taup1,\n                           lapack_complex_double* taup2,\n                           lapack_complex_double* tauq1,\n                           lapack_complex_double* tauq2 );\nlapack_int LAPACKE_zunbdb_work( int matrix_order, char trans, char signs,\n                                lapack_int m, lapack_int p, lapack_int q,\n                                lapack_complex_double* x11, lapack_int ldx11,\n                                lapack_complex_double* x12, lapack_int ldx12,\n                                lapack_complex_double* x21, lapack_int ldx21,\n                                lapack_complex_double* x22, lapack_int ldx22,\n                                double* theta, double* phi,\n                                lapack_complex_double* taup1,\n                                lapack_complex_double* taup2,\n                                lapack_complex_double* tauq1,\n                                lapack_complex_double* tauq2,\n                                lapack_complex_double* work, lapack_int lwork );\nlapack_int LAPACKE_zuncsd( int matrix_order, char jobu1, char jobu2,\n                           char jobv1t, char jobv2t, char trans, char signs,\n                           lapack_int m, lapack_int p, lapack_int q,\n                           lapack_complex_double* x11, lapack_int ldx11,\n                           lapack_complex_double* x12, lapack_int ldx12,\n                           lapack_complex_double* x21, lapack_int ldx21,\n                           lapack_complex_double* x22, lapack_int ldx22,\n                           double* theta, lapack_complex_double* u1,\n                           lapack_int ldu1, lapack_complex_double* u2,\n                           lapack_int ldu2, lapack_complex_double* v1t,\n                           lapack_int ldv1t, lapack_complex_double* v2t,\n                           lapack_int ldv2t );\nlapack_int LAPACKE_zuncsd_work( int matrix_order, char jobu1, char jobu2,\n                                char jobv1t, char jobv2t, char trans,\n                                char signs, lapack_int m, lapack_int p,\n                                lapack_int q, lapack_complex_double* x11,\n                                lapack_int ldx11, lapack_complex_double* x12,\n                                lapack_int ldx12, lapack_complex_double* x21,\n                                lapack_int ldx21, lapack_complex_double* x22,\n                                lapack_int ldx22, double* theta,\n                                lapack_complex_double* u1, lapack_int ldu1,\n                                lapack_complex_double* u2, lapack_int ldu2,\n                                lapack_complex_double* v1t, lapack_int ldv1t,\n                                lapack_complex_double* v2t, lapack_int ldv2t,\n                                lapack_complex_double* work, lapack_int lwork,\n                                double* rwork, lapack_int lrwork,\n                                lapack_int* iwork );\n//LAPACK 3.4.0\nlapack_int LAPACKE_sgemqrt( int matrix_order, char side, char trans,\n                            lapack_int m, lapack_int n, lapack_int k,\n                            lapack_int nb, const float* v, lapack_int ldv,\n                            const float* t, lapack_int ldt, float* c,\n                            lapack_int ldc );\nlapack_int LAPACKE_dgemqrt( int matrix_order, char side, char trans,\n                            lapack_int m, lapack_int n, lapack_int k,\n                            lapack_int nb, const double* v, lapack_int ldv,\n                            const double* t, lapack_int ldt, double* c,\n                            lapack_int ldc );\nlapack_int LAPACKE_cgemqrt( int matrix_order, char side, char trans,\n                            lapack_int m, lapack_int n, lapack_int k,\n                            lapack_int nb, const lapack_complex_float* v,\n                            lapack_int ldv, const lapack_complex_float* t,\n                            lapack_int ldt, lapack_complex_float* c,\n                            lapack_int ldc );\nlapack_int LAPACKE_zgemqrt( int matrix_order, char side, char trans,\n                            lapack_int m, lapack_int n, lapack_int k,\n                            lapack_int nb, const lapack_complex_double* v,\n                            lapack_int ldv, const lapack_complex_double* t,\n                            lapack_int ldt, lapack_complex_double* c,\n                            lapack_int ldc );\n\nlapack_int LAPACKE_sgeqrt( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nb, float* a, lapack_int lda, float* t,\n                           lapack_int ldt );\nlapack_int LAPACKE_dgeqrt( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nb, double* a, lapack_int lda, double* t,\n                           lapack_int ldt );\nlapack_int LAPACKE_cgeqrt( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nb, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* t,\n                           lapack_int ldt );\nlapack_int LAPACKE_zgeqrt( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int nb, lapack_complex_double* a,\n                           lapack_int lda, lapack_complex_double* t,\n                           lapack_int ldt );\n\nlapack_int LAPACKE_sgeqrt2( int matrix_order, lapack_int m, lapack_int n,\n                            float* a, lapack_int lda, float* t,\n                            lapack_int ldt );\nlapack_int LAPACKE_dgeqrt2( int matrix_order, lapack_int m, lapack_int n,\n                            double* a, lapack_int lda, double* t,\n                            lapack_int ldt );\nlapack_int LAPACKE_cgeqrt2( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_complex_float* a, lapack_int lda,\n                            lapack_complex_float* t, lapack_int ldt );\nlapack_int LAPACKE_zgeqrt2( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_complex_double* a, lapack_int lda,\n                            lapack_complex_double* t, lapack_int ldt );\n\nlapack_int LAPACKE_sgeqrt3( int matrix_order, lapack_int m, lapack_int n,\n                            float* a, lapack_int lda, float* t,\n                            lapack_int ldt );\nlapack_int LAPACKE_dgeqrt3( int matrix_order, lapack_int m, lapack_int n,\n                            double* a, lapack_int lda, double* t,\n                            lapack_int ldt );\nlapack_int LAPACKE_cgeqrt3( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_complex_float* a, lapack_int lda,\n                            lapack_complex_float* t, lapack_int ldt );\nlapack_int LAPACKE_zgeqrt3( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_complex_double* a, lapack_int lda,\n                            lapack_complex_double* t, lapack_int ldt );\n\nlapack_int LAPACKE_stpmqrt( int matrix_order, char side, char trans,\n                            lapack_int m, lapack_int n, lapack_int k,\n                            lapack_int l, lapack_int nb, const float* v,\n                            lapack_int ldv, const float* t, lapack_int ldt,\n                            float* a, lapack_int lda, float* b,\n                            lapack_int ldb );\nlapack_int LAPACKE_dtpmqrt( int matrix_order, char side, char trans,\n                            lapack_int m, lapack_int n, lapack_int k,\n                            lapack_int l, lapack_int nb, const double* v,\n                            lapack_int ldv, const double* t, lapack_int ldt,\n                            double* a, lapack_int lda, double* b,\n                            lapack_int ldb );\nlapack_int LAPACKE_ctpmqrt( int matrix_order, char side, char trans,\n                            lapack_int m, lapack_int n, lapack_int k,\n                            lapack_int l, lapack_int nb,\n                            const lapack_complex_float* v, lapack_int ldv,\n                            const lapack_complex_float* t, lapack_int ldt,\n                            lapack_complex_float* a, lapack_int lda,\n                            lapack_complex_float* b, lapack_int ldb );\nlapack_int LAPACKE_ztpmqrt( int matrix_order, char side, char trans,\n                            lapack_int m, lapack_int n, lapack_int k,\n                            lapack_int l, lapack_int nb,\n                            const lapack_complex_double* v, lapack_int ldv,\n                            const lapack_complex_double* t, lapack_int ldt,\n                            lapack_complex_double* a, lapack_int lda,\n                            lapack_complex_double* b, lapack_int ldb );\n\nlapack_int LAPACKE_dtpqrt( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int l, lapack_int nb, double* a,\n                           lapack_int lda, double* b, lapack_int ldb, double* t,\n                           lapack_int ldt );\nlapack_int LAPACKE_ctpqrt( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int l, lapack_int nb, lapack_complex_float* a,\n                           lapack_int lda, lapack_complex_float* t,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_int ldt );\nlapack_int LAPACKE_ztpqrt( int matrix_order, lapack_int m, lapack_int n,\n                           lapack_int l, lapack_int nb,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_complex_double* t, lapack_int ldt );\n\nlapack_int LAPACKE_stpqrt2( int matrix_order, lapack_int m, lapack_int n,\n                            float* a, lapack_int lda, float* b, lapack_int ldb,\n                            float* t, lapack_int ldt );\nlapack_int LAPACKE_dtpqrt2( int matrix_order, lapack_int m, lapack_int n,\n                            double* a, lapack_int lda, double* b,\n                            lapack_int ldb, double* t, lapack_int ldt );\nlapack_int LAPACKE_ctpqrt2( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_complex_float* a, lapack_int lda,\n                            lapack_complex_float* b, lapack_int ldb,\n                            lapack_complex_float* t, lapack_int ldt );\nlapack_int LAPACKE_ztpqrt2( int matrix_order, lapack_int m, lapack_int n,\n                            lapack_complex_double* a, lapack_int lda,\n                            lapack_complex_double* b, lapack_int ldb,\n                            lapack_complex_double* t, lapack_int ldt );\n\nlapack_int LAPACKE_stprfb( int matrix_order, char side, char trans, char direct,\n                           char storev, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_int l, const float* v,\n                           lapack_int ldv, const float* t, lapack_int ldt,\n                           float* a, lapack_int lda, float* b, lapack_int ldb,\n                           lapack_int myldwork );\nlapack_int LAPACKE_dtprfb( int matrix_order, char side, char trans, char direct,\n                           char storev, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_int l, const double* v,\n                           lapack_int ldv, const double* t, lapack_int ldt,\n                           double* a, lapack_int lda, double* b, lapack_int ldb,\n                           lapack_int myldwork );\nlapack_int LAPACKE_ctprfb( int matrix_order, char side, char trans, char direct,\n                           char storev, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_int l,\n                           const lapack_complex_float* v, lapack_int ldv,\n                           const lapack_complex_float* t, lapack_int ldt,\n                           lapack_complex_float* a, lapack_int lda,\n                           lapack_complex_float* b, lapack_int ldb,\n                           lapack_int myldwork );\nlapack_int LAPACKE_ztprfb( int matrix_order, char side, char trans, char direct,\n                           char storev, lapack_int m, lapack_int n,\n                           lapack_int k, lapack_int l,\n                           const lapack_complex_double* v, lapack_int ldv,\n                           const lapack_complex_double* t, lapack_int ldt,\n                           lapack_complex_double* a, lapack_int lda,\n                           lapack_complex_double* b, lapack_int ldb,\n                           lapack_int myldwork );\n\nlapack_int LAPACKE_sgemqrt_work( int matrix_order, char side, char trans,\n                                 lapack_int m, lapack_int n, lapack_int k,\n                                 lapack_int nb, const float* v, lapack_int ldv,\n                                 const float* t, lapack_int ldt, float* c,\n                                 lapack_int ldc, float* work );\nlapack_int LAPACKE_dgemqrt_work( int matrix_order, char side, char trans,\n                                 lapack_int m, lapack_int n, lapack_int k,\n                                 lapack_int nb, const double* v, lapack_int ldv,\n                                 const double* t, lapack_int ldt, double* c,\n                                 lapack_int ldc, double* work );\nlapack_int LAPACKE_cgemqrt_work( int matrix_order, char side, char trans,\n                                 lapack_int m, lapack_int n, lapack_int k,\n                                 lapack_int nb, const lapack_complex_float* v,\n                                 lapack_int ldv, const lapack_complex_float* t,\n                                 lapack_int ldt, lapack_complex_float* c,\n                                 lapack_int ldc, lapack_complex_float* work );\nlapack_int LAPACKE_zgemqrt_work( int matrix_order, char side, char trans,\n                                 lapack_int m, lapack_int n, lapack_int k,\n                                 lapack_int nb, const lapack_complex_double* v,\n                                 lapack_int ldv, const lapack_complex_double* t,\n                                 lapack_int ldt, lapack_complex_double* c,\n                                 lapack_int ldc, lapack_complex_double* work );\n\nlapack_int LAPACKE_sgeqrt_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nb, float* a, lapack_int lda,\n                                float* t, lapack_int ldt, float* work );\nlapack_int LAPACKE_dgeqrt_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nb, double* a, lapack_int lda,\n                                double* t, lapack_int ldt, double* work );\nlapack_int LAPACKE_cgeqrt_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nb, lapack_complex_float* a,\n                                lapack_int lda, lapack_complex_float* t,\n                                lapack_int ldt, lapack_complex_float* work );\nlapack_int LAPACKE_zgeqrt_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int nb, lapack_complex_double* a,\n                                lapack_int lda, lapack_complex_double* t,\n                                lapack_int ldt, lapack_complex_double* work );\n\nlapack_int LAPACKE_sgeqrt2_work( int matrix_order, lapack_int m, lapack_int n,\n                                 float* a, lapack_int lda, float* t,\n                                 lapack_int ldt );\nlapack_int LAPACKE_dgeqrt2_work( int matrix_order, lapack_int m, lapack_int n,\n                                 double* a, lapack_int lda, double* t,\n                                 lapack_int ldt );\nlapack_int LAPACKE_cgeqrt2_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_complex_float* a, lapack_int lda,\n                                 lapack_complex_float* t, lapack_int ldt );\nlapack_int LAPACKE_zgeqrt2_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_complex_double* a, lapack_int lda,\n                                 lapack_complex_double* t, lapack_int ldt );\n\nlapack_int LAPACKE_sgeqrt3_work( int matrix_order, lapack_int m, lapack_int n,\n                                 float* a, lapack_int lda, float* t,\n                                 lapack_int ldt );\nlapack_int LAPACKE_dgeqrt3_work( int matrix_order, lapack_int m, lapack_int n,\n                                 double* a, lapack_int lda, double* t,\n                                 lapack_int ldt );\nlapack_int LAPACKE_cgeqrt3_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_complex_float* a, lapack_int lda,\n                                 lapack_complex_float* t, lapack_int ldt );\nlapack_int LAPACKE_zgeqrt3_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_complex_double* a, lapack_int lda,\n                                 lapack_complex_double* t, lapack_int ldt );\n\nlapack_int LAPACKE_stpmqrt_work( int matrix_order, char side, char trans,\n                                 lapack_int m, lapack_int n, lapack_int k,\n                                 lapack_int l, lapack_int nb, const float* v,\n                                 lapack_int ldv, const float* t, lapack_int ldt,\n                                 float* a, lapack_int lda, float* b,\n                                 lapack_int ldb, float* work );\nlapack_int LAPACKE_dtpmqrt_work( int matrix_order, char side, char trans,\n                                 lapack_int m, lapack_int n, lapack_int k,\n                                 lapack_int l, lapack_int nb, const double* v,\n                                 lapack_int ldv, const double* t,\n                                 lapack_int ldt, double* a, lapack_int lda,\n                                 double* b, lapack_int ldb, double* work );\nlapack_int LAPACKE_ctpmqrt_work( int matrix_order, char side, char trans,\n                                 lapack_int m, lapack_int n, lapack_int k,\n                                 lapack_int l, lapack_int nb,\n                                 const lapack_complex_float* v, lapack_int ldv,\n                                 const lapack_complex_float* t, lapack_int ldt,\n                                 lapack_complex_float* a, lapack_int lda,\n                                 lapack_complex_float* b, lapack_int ldb,\n                                 lapack_complex_float* work );\nlapack_int LAPACKE_ztpmqrt_work( int matrix_order, char side, char trans,\n                                 lapack_int m, lapack_int n, lapack_int k,\n                                 lapack_int l, lapack_int nb,\n                                 const lapack_complex_double* v, lapack_int ldv,\n                                 const lapack_complex_double* t, lapack_int ldt,\n                                 lapack_complex_double* a, lapack_int lda,\n                                 lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* work );\n\nlapack_int LAPACKE_dtpqrt_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int l, lapack_int nb, double* a,\n                                lapack_int lda, double* b, lapack_int ldb,\n                                double* t, lapack_int ldt, double* work );\nlapack_int LAPACKE_ctpqrt_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int l, lapack_int nb,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* t,\n                                lapack_complex_float* b, lapack_int ldb,\n                                lapack_int ldt, lapack_complex_float* work );\nlapack_int LAPACKE_ztpqrt_work( int matrix_order, lapack_int m, lapack_int n,\n                                lapack_int l, lapack_int nb,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb,\n                                lapack_complex_double* t, lapack_int ldt,\n                                lapack_complex_double* work );\n\nlapack_int LAPACKE_stpqrt2_work( int matrix_order, lapack_int m, lapack_int n,\n                                 float* a, lapack_int lda, float* b,\n                                 lapack_int ldb, float* t, lapack_int ldt );\nlapack_int LAPACKE_dtpqrt2_work( int matrix_order, lapack_int m, lapack_int n,\n                                 double* a, lapack_int lda, double* b,\n                                 lapack_int ldb, double* t, lapack_int ldt );\nlapack_int LAPACKE_ctpqrt2_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_complex_float* a, lapack_int lda,\n                                 lapack_complex_float* b, lapack_int ldb,\n                                 lapack_complex_float* t, lapack_int ldt );\nlapack_int LAPACKE_ztpqrt2_work( int matrix_order, lapack_int m, lapack_int n,\n                                 lapack_complex_double* a, lapack_int lda,\n                                 lapack_complex_double* b, lapack_int ldb,\n                                 lapack_complex_double* t, lapack_int ldt );\n\nlapack_int LAPACKE_stprfb_work( int matrix_order, char side, char trans,\n                                char direct, char storev, lapack_int m,\n                                lapack_int n, lapack_int k, lapack_int l,\n                                const float* v, lapack_int ldv, const float* t,\n                                lapack_int ldt, float* a, lapack_int lda,\n                                float* b, lapack_int ldb, const float* mywork,\n                                lapack_int myldwork );\nlapack_int LAPACKE_dtprfb_work( int matrix_order, char side, char trans,\n                                char direct, char storev, lapack_int m,\n                                lapack_int n, lapack_int k, lapack_int l,\n                                const double* v, lapack_int ldv,\n                                const double* t, lapack_int ldt, double* a,\n                                lapack_int lda, double* b, lapack_int ldb,\n                                const double* mywork, lapack_int myldwork );\nlapack_int LAPACKE_ctprfb_work( int matrix_order, char side, char trans,\n                                char direct, char storev, lapack_int m,\n                                lapack_int n, lapack_int k, lapack_int l,\n                                const lapack_complex_float* v, lapack_int ldv,\n                                const lapack_complex_float* t, lapack_int ldt,\n                                lapack_complex_float* a, lapack_int lda,\n                                lapack_complex_float* b, lapack_int ldb,\n                                const float* mywork, lapack_int myldwork );\nlapack_int LAPACKE_ztprfb_work( int matrix_order, char side, char trans,\n                                char direct, char storev, lapack_int m,\n                                lapack_int n, lapack_int k, lapack_int l,\n                                const lapack_complex_double* v, lapack_int ldv,\n                                const lapack_complex_double* t, lapack_int ldt,\n                                lapack_complex_double* a, lapack_int lda,\n                                lapack_complex_double* b, lapack_int ldb,\n                                const double* mywork, lapack_int myldwork );\n//LAPACK 3.X.X\nlapack_int LAPACKE_csyr( int matrix_order, char uplo, lapack_int n,\n                             lapack_complex_float alpha,\n                             const lapack_complex_float* x, lapack_int incx,\n                             lapack_complex_float* a, lapack_int lda );\nlapack_int LAPACKE_zsyr( int matrix_order, char uplo, lapack_int n,\n                             lapack_complex_double alpha,\n                             const lapack_complex_double* x, lapack_int incx,\n                             lapack_complex_double* a, lapack_int lda );\n\nlapack_int LAPACKE_csyr_work( int matrix_order, char uplo, lapack_int n,\n                                  lapack_complex_float alpha,\n                                  const lapack_complex_float* x,\n                                  lapack_int incx, lapack_complex_float* a,\n                                  lapack_int lda );\nlapack_int LAPACKE_zsyr_work( int matrix_order, char uplo, lapack_int n,\n                                  lapack_complex_double alpha,\n                                  const lapack_complex_double* x,\n                                  lapack_int incx, lapack_complex_double* a,\n                                  lapack_int lda );\n\n\n\n#define LAPACK_sgetrf LAPACK_GLOBAL(sgetrf,SGETRF)\n#define LAPACK_dgetrf LAPACK_GLOBAL(dgetrf,DGETRF)\n#define LAPACK_cgetrf LAPACK_GLOBAL(cgetrf,CGETRF)\n#define LAPACK_zgetrf LAPACK_GLOBAL(zgetrf,ZGETRF)\n#define LAPACK_sgbtrf LAPACK_GLOBAL(sgbtrf,SGBTRF)\n#define LAPACK_dgbtrf LAPACK_GLOBAL(dgbtrf,DGBTRF)\n#define LAPACK_cgbtrf LAPACK_GLOBAL(cgbtrf,CGBTRF)\n#define LAPACK_zgbtrf LAPACK_GLOBAL(zgbtrf,ZGBTRF)\n#define LAPACK_sgttrf LAPACK_GLOBAL(sgttrf,SGTTRF)\n#define LAPACK_dgttrf LAPACK_GLOBAL(dgttrf,DGTTRF)\n#define LAPACK_cgttrf LAPACK_GLOBAL(cgttrf,CGTTRF)\n#define LAPACK_zgttrf LAPACK_GLOBAL(zgttrf,ZGTTRF)\n#define LAPACK_spotrf LAPACK_GLOBAL(spotrf,SPOTRF)\n#define LAPACK_dpotrf LAPACK_GLOBAL(dpotrf,DPOTRF)\n#define LAPACK_cpotrf LAPACK_GLOBAL(cpotrf,CPOTRF)\n#define LAPACK_zpotrf LAPACK_GLOBAL(zpotrf,ZPOTRF)\n#define LAPACK_dpstrf LAPACK_GLOBAL(dpstrf,DPSTRF)\n#define LAPACK_spstrf LAPACK_GLOBAL(spstrf,SPSTRF)\n#define LAPACK_zpstrf LAPACK_GLOBAL(zpstrf,ZPSTRF)\n#define LAPACK_cpstrf LAPACK_GLOBAL(cpstrf,CPSTRF)\n#define LAPACK_dpftrf LAPACK_GLOBAL(dpftrf,DPFTRF)\n#define LAPACK_spftrf LAPACK_GLOBAL(spftrf,SPFTRF)\n#define LAPACK_zpftrf LAPACK_GLOBAL(zpftrf,ZPFTRF)\n#define LAPACK_cpftrf LAPACK_GLOBAL(cpftrf,CPFTRF)\n#define LAPACK_spptrf LAPACK_GLOBAL(spptrf,SPPTRF)\n#define LAPACK_dpptrf LAPACK_GLOBAL(dpptrf,DPPTRF)\n#define LAPACK_cpptrf LAPACK_GLOBAL(cpptrf,CPPTRF)\n#define LAPACK_zpptrf LAPACK_GLOBAL(zpptrf,ZPPTRF)\n#define LAPACK_spbtrf LAPACK_GLOBAL(spbtrf,SPBTRF)\n#define LAPACK_dpbtrf LAPACK_GLOBAL(dpbtrf,DPBTRF)\n#define LAPACK_cpbtrf LAPACK_GLOBAL(cpbtrf,CPBTRF)\n#define LAPACK_zpbtrf LAPACK_GLOBAL(zpbtrf,ZPBTRF)\n#define LAPACK_spttrf LAPACK_GLOBAL(spttrf,SPTTRF)\n#define LAPACK_dpttrf LAPACK_GLOBAL(dpttrf,DPTTRF)\n#define LAPACK_cpttrf LAPACK_GLOBAL(cpttrf,CPTTRF)\n#define LAPACK_zpttrf LAPACK_GLOBAL(zpttrf,ZPTTRF)\n#define LAPACK_ssytrf LAPACK_GLOBAL(ssytrf,SSYTRF)\n#define LAPACK_dsytrf LAPACK_GLOBAL(dsytrf,DSYTRF)\n#define LAPACK_csytrf LAPACK_GLOBAL(csytrf,CSYTRF)\n#define LAPACK_zsytrf LAPACK_GLOBAL(zsytrf,ZSYTRF)\n#define LAPACK_chetrf LAPACK_GLOBAL(chetrf,CHETRF)\n#define LAPACK_zhetrf LAPACK_GLOBAL(zhetrf,ZHETRF)\n#define LAPACK_ssptrf LAPACK_GLOBAL(ssptrf,SSPTRF)\n#define LAPACK_dsptrf LAPACK_GLOBAL(dsptrf,DSPTRF)\n#define LAPACK_csptrf LAPACK_GLOBAL(csptrf,CSPTRF)\n#define LAPACK_zsptrf LAPACK_GLOBAL(zsptrf,ZSPTRF)\n#define LAPACK_chptrf LAPACK_GLOBAL(chptrf,CHPTRF)\n#define LAPACK_zhptrf LAPACK_GLOBAL(zhptrf,ZHPTRF)\n#define LAPACK_sgetrs LAPACK_GLOBAL(sgetrs,SGETRS)\n#define LAPACK_dgetrs LAPACK_GLOBAL(dgetrs,DGETRS)\n#define LAPACK_cgetrs LAPACK_GLOBAL(cgetrs,CGETRS)\n#define LAPACK_zgetrs LAPACK_GLOBAL(zgetrs,ZGETRS)\n#define LAPACK_sgbtrs LAPACK_GLOBAL(sgbtrs,SGBTRS)\n#define LAPACK_dgbtrs LAPACK_GLOBAL(dgbtrs,DGBTRS)\n#define LAPACK_cgbtrs LAPACK_GLOBAL(cgbtrs,CGBTRS)\n#define LAPACK_zgbtrs LAPACK_GLOBAL(zgbtrs,ZGBTRS)\n#define LAPACK_sgttrs LAPACK_GLOBAL(sgttrs,SGTTRS)\n#define LAPACK_dgttrs LAPACK_GLOBAL(dgttrs,DGTTRS)\n#define LAPACK_cgttrs LAPACK_GLOBAL(cgttrs,CGTTRS)\n#define LAPACK_zgttrs LAPACK_GLOBAL(zgttrs,ZGTTRS)\n#define LAPACK_spotrs LAPACK_GLOBAL(spotrs,SPOTRS)\n#define LAPACK_dpotrs LAPACK_GLOBAL(dpotrs,DPOTRS)\n#define LAPACK_cpotrs LAPACK_GLOBAL(cpotrs,CPOTRS)\n#define LAPACK_zpotrs LAPACK_GLOBAL(zpotrs,ZPOTRS)\n#define LAPACK_dpftrs LAPACK_GLOBAL(dpftrs,DPFTRS)\n#define LAPACK_spftrs LAPACK_GLOBAL(spftrs,SPFTRS)\n#define LAPACK_zpftrs LAPACK_GLOBAL(zpftrs,ZPFTRS)\n#define LAPACK_cpftrs LAPACK_GLOBAL(cpftrs,CPFTRS)\n#define LAPACK_spptrs LAPACK_GLOBAL(spptrs,SPPTRS)\n#define LAPACK_dpptrs LAPACK_GLOBAL(dpptrs,DPPTRS)\n#define LAPACK_cpptrs LAPACK_GLOBAL(cpptrs,CPPTRS)\n#define LAPACK_zpptrs LAPACK_GLOBAL(zpptrs,ZPPTRS)\n#define LAPACK_spbtrs LAPACK_GLOBAL(spbtrs,SPBTRS)\n#define LAPACK_dpbtrs LAPACK_GLOBAL(dpbtrs,DPBTRS)\n#define LAPACK_cpbtrs LAPACK_GLOBAL(cpbtrs,CPBTRS)\n#define LAPACK_zpbtrs LAPACK_GLOBAL(zpbtrs,ZPBTRS)\n#define LAPACK_spttrs LAPACK_GLOBAL(spttrs,SPTTRS)\n#define LAPACK_dpttrs LAPACK_GLOBAL(dpttrs,DPTTRS)\n#define LAPACK_cpttrs LAPACK_GLOBAL(cpttrs,CPTTRS)\n#define LAPACK_zpttrs LAPACK_GLOBAL(zpttrs,ZPTTRS)\n#define LAPACK_ssytrs LAPACK_GLOBAL(ssytrs,SSYTRS)\n#define LAPACK_dsytrs LAPACK_GLOBAL(dsytrs,DSYTRS)\n#define LAPACK_csytrs LAPACK_GLOBAL(csytrs,CSYTRS)\n#define LAPACK_zsytrs LAPACK_GLOBAL(zsytrs,ZSYTRS)\n#define LAPACK_chetrs LAPACK_GLOBAL(chetrs,CHETRS)\n#define LAPACK_zhetrs LAPACK_GLOBAL(zhetrs,ZHETRS)\n#define LAPACK_ssptrs LAPACK_GLOBAL(ssptrs,SSPTRS)\n#define LAPACK_dsptrs LAPACK_GLOBAL(dsptrs,DSPTRS)\n#define LAPACK_csptrs LAPACK_GLOBAL(csptrs,CSPTRS)\n#define LAPACK_zsptrs LAPACK_GLOBAL(zsptrs,ZSPTRS)\n#define LAPACK_chptrs LAPACK_GLOBAL(chptrs,CHPTRS)\n#define LAPACK_zhptrs LAPACK_GLOBAL(zhptrs,ZHPTRS)\n#define LAPACK_strtrs LAPACK_GLOBAL(strtrs,STRTRS)\n#define LAPACK_dtrtrs LAPACK_GLOBAL(dtrtrs,DTRTRS)\n#define LAPACK_ctrtrs LAPACK_GLOBAL(ctrtrs,CTRTRS)\n#define LAPACK_ztrtrs LAPACK_GLOBAL(ztrtrs,ZTRTRS)\n#define LAPACK_stptrs LAPACK_GLOBAL(stptrs,STPTRS)\n#define LAPACK_dtptrs LAPACK_GLOBAL(dtptrs,DTPTRS)\n#define LAPACK_ctptrs LAPACK_GLOBAL(ctptrs,CTPTRS)\n#define LAPACK_ztptrs LAPACK_GLOBAL(ztptrs,ZTPTRS)\n#define LAPACK_stbtrs LAPACK_GLOBAL(stbtrs,STBTRS)\n#define LAPACK_dtbtrs LAPACK_GLOBAL(dtbtrs,DTBTRS)\n#define LAPACK_ctbtrs LAPACK_GLOBAL(ctbtrs,CTBTRS)\n#define LAPACK_ztbtrs LAPACK_GLOBAL(ztbtrs,ZTBTRS)\n#define LAPACK_sgecon LAPACK_GLOBAL(sgecon,SGECON)\n#define LAPACK_dgecon LAPACK_GLOBAL(dgecon,DGECON)\n#define LAPACK_cgecon LAPACK_GLOBAL(cgecon,CGECON)\n#define LAPACK_zgecon LAPACK_GLOBAL(zgecon,ZGECON)\n#define LAPACK_sgbcon LAPACK_GLOBAL(sgbcon,SGBCON)\n#define LAPACK_dgbcon LAPACK_GLOBAL(dgbcon,DGBCON)\n#define LAPACK_cgbcon LAPACK_GLOBAL(cgbcon,CGBCON)\n#define LAPACK_zgbcon LAPACK_GLOBAL(zgbcon,ZGBCON)\n#define LAPACK_sgtcon LAPACK_GLOBAL(sgtcon,SGTCON)\n#define LAPACK_dgtcon LAPACK_GLOBAL(dgtcon,DGTCON)\n#define LAPACK_cgtcon LAPACK_GLOBAL(cgtcon,CGTCON)\n#define LAPACK_zgtcon LAPACK_GLOBAL(zgtcon,ZGTCON)\n#define LAPACK_spocon LAPACK_GLOBAL(spocon,SPOCON)\n#define LAPACK_dpocon LAPACK_GLOBAL(dpocon,DPOCON)\n#define LAPACK_cpocon LAPACK_GLOBAL(cpocon,CPOCON)\n#define LAPACK_zpocon LAPACK_GLOBAL(zpocon,ZPOCON)\n#define LAPACK_sppcon LAPACK_GLOBAL(sppcon,SPPCON)\n#define LAPACK_dppcon LAPACK_GLOBAL(dppcon,DPPCON)\n#define LAPACK_cppcon LAPACK_GLOBAL(cppcon,CPPCON)\n#define LAPACK_zppcon LAPACK_GLOBAL(zppcon,ZPPCON)\n#define LAPACK_spbcon LAPACK_GLOBAL(spbcon,SPBCON)\n#define LAPACK_dpbcon LAPACK_GLOBAL(dpbcon,DPBCON)\n#define LAPACK_cpbcon LAPACK_GLOBAL(cpbcon,CPBCON)\n#define LAPACK_zpbcon LAPACK_GLOBAL(zpbcon,ZPBCON)\n#define LAPACK_sptcon LAPACK_GLOBAL(sptcon,SPTCON)\n#define LAPACK_dptcon LAPACK_GLOBAL(dptcon,DPTCON)\n#define LAPACK_cptcon LAPACK_GLOBAL(cptcon,CPTCON)\n#define LAPACK_zptcon LAPACK_GLOBAL(zptcon,ZPTCON)\n#define LAPACK_ssycon LAPACK_GLOBAL(ssycon,SSYCON)\n#define LAPACK_dsycon LAPACK_GLOBAL(dsycon,DSYCON)\n#define LAPACK_csycon LAPACK_GLOBAL(csycon,CSYCON)\n#define LAPACK_zsycon LAPACK_GLOBAL(zsycon,ZSYCON)\n#define LAPACK_checon LAPACK_GLOBAL(checon,CHECON)\n#define LAPACK_zhecon LAPACK_GLOBAL(zhecon,ZHECON)\n#define LAPACK_sspcon LAPACK_GLOBAL(sspcon,SSPCON)\n#define LAPACK_dspcon LAPACK_GLOBAL(dspcon,DSPCON)\n#define LAPACK_cspcon LAPACK_GLOBAL(cspcon,CSPCON)\n#define LAPACK_zspcon LAPACK_GLOBAL(zspcon,ZSPCON)\n#define LAPACK_chpcon LAPACK_GLOBAL(chpcon,CHPCON)\n#define LAPACK_zhpcon LAPACK_GLOBAL(zhpcon,ZHPCON)\n#define LAPACK_strcon LAPACK_GLOBAL(strcon,STRCON)\n#define LAPACK_dtrcon LAPACK_GLOBAL(dtrcon,DTRCON)\n#define LAPACK_ctrcon LAPACK_GLOBAL(ctrcon,CTRCON)\n#define LAPACK_ztrcon LAPACK_GLOBAL(ztrcon,ZTRCON)\n#define LAPACK_stpcon LAPACK_GLOBAL(stpcon,STPCON)\n#define LAPACK_dtpcon LAPACK_GLOBAL(dtpcon,DTPCON)\n#define LAPACK_ctpcon LAPACK_GLOBAL(ctpcon,CTPCON)\n#define LAPACK_ztpcon LAPACK_GLOBAL(ztpcon,ZTPCON)\n#define LAPACK_stbcon LAPACK_GLOBAL(stbcon,STBCON)\n#define LAPACK_dtbcon LAPACK_GLOBAL(dtbcon,DTBCON)\n#define LAPACK_ctbcon LAPACK_GLOBAL(ctbcon,CTBCON)\n#define LAPACK_ztbcon LAPACK_GLOBAL(ztbcon,ZTBCON)\n#define LAPACK_sgerfs LAPACK_GLOBAL(sgerfs,SGERFS)\n#define LAPACK_dgerfs LAPACK_GLOBAL(dgerfs,DGERFS)\n#define LAPACK_cgerfs LAPACK_GLOBAL(cgerfs,CGERFS)\n#define LAPACK_zgerfs LAPACK_GLOBAL(zgerfs,ZGERFS)\n#define LAPACK_dgerfsx LAPACK_GLOBAL(dgerfsx,DGERFSX)\n#define LAPACK_sgerfsx LAPACK_GLOBAL(sgerfsx,SGERFSX)\n#define LAPACK_zgerfsx LAPACK_GLOBAL(zgerfsx,ZGERFSX)\n#define LAPACK_cgerfsx LAPACK_GLOBAL(cgerfsx,CGERFSX)\n#define LAPACK_sgbrfs LAPACK_GLOBAL(sgbrfs,SGBRFS)\n#define LAPACK_dgbrfs LAPACK_GLOBAL(dgbrfs,DGBRFS)\n#define LAPACK_cgbrfs LAPACK_GLOBAL(cgbrfs,CGBRFS)\n#define LAPACK_zgbrfs LAPACK_GLOBAL(zgbrfs,ZGBRFS)\n#define LAPACK_dgbrfsx LAPACK_GLOBAL(dgbrfsx,DGBRFSX)\n#define LAPACK_sgbrfsx LAPACK_GLOBAL(sgbrfsx,SGBRFSX)\n#define LAPACK_zgbrfsx LAPACK_GLOBAL(zgbrfsx,ZGBRFSX)\n#define LAPACK_cgbrfsx LAPACK_GLOBAL(cgbrfsx,CGBRFSX)\n#define LAPACK_sgtrfs LAPACK_GLOBAL(sgtrfs,SGTRFS)\n#define LAPACK_dgtrfs LAPACK_GLOBAL(dgtrfs,DGTRFS)\n#define LAPACK_cgtrfs LAPACK_GLOBAL(cgtrfs,CGTRFS)\n#define LAPACK_zgtrfs LAPACK_GLOBAL(zgtrfs,ZGTRFS)\n#define LAPACK_sporfs LAPACK_GLOBAL(sporfs,SPORFS)\n#define LAPACK_dporfs LAPACK_GLOBAL(dporfs,DPORFS)\n#define LAPACK_cporfs LAPACK_GLOBAL(cporfs,CPORFS)\n#define LAPACK_zporfs LAPACK_GLOBAL(zporfs,ZPORFS)\n#define LAPACK_dporfsx LAPACK_GLOBAL(dporfsx,DPORFSX)\n#define LAPACK_sporfsx LAPACK_GLOBAL(sporfsx,SPORFSX)\n#define LAPACK_zporfsx LAPACK_GLOBAL(zporfsx,ZPORFSX)\n#define LAPACK_cporfsx LAPACK_GLOBAL(cporfsx,CPORFSX)\n#define LAPACK_spprfs LAPACK_GLOBAL(spprfs,SPPRFS)\n#define LAPACK_dpprfs LAPACK_GLOBAL(dpprfs,DPPRFS)\n#define LAPACK_cpprfs LAPACK_GLOBAL(cpprfs,CPPRFS)\n#define LAPACK_zpprfs LAPACK_GLOBAL(zpprfs,ZPPRFS)\n#define LAPACK_spbrfs LAPACK_GLOBAL(spbrfs,SPBRFS)\n#define LAPACK_dpbrfs LAPACK_GLOBAL(dpbrfs,DPBRFS)\n#define LAPACK_cpbrfs LAPACK_GLOBAL(cpbrfs,CPBRFS)\n#define LAPACK_zpbrfs LAPACK_GLOBAL(zpbrfs,ZPBRFS)\n#define LAPACK_sptrfs LAPACK_GLOBAL(sptrfs,SPTRFS)\n#define LAPACK_dptrfs LAPACK_GLOBAL(dptrfs,DPTRFS)\n#define LAPACK_cptrfs LAPACK_GLOBAL(cptrfs,CPTRFS)\n#define LAPACK_zptrfs LAPACK_GLOBAL(zptrfs,ZPTRFS)\n#define LAPACK_ssyrfs LAPACK_GLOBAL(ssyrfs,SSYRFS)\n#define LAPACK_dsyrfs LAPACK_GLOBAL(dsyrfs,DSYRFS)\n#define LAPACK_csyrfs LAPACK_GLOBAL(csyrfs,CSYRFS)\n#define LAPACK_zsyrfs LAPACK_GLOBAL(zsyrfs,ZSYRFS)\n#define LAPACK_dsyrfsx LAPACK_GLOBAL(dsyrfsx,DSYRFSX)\n#define LAPACK_ssyrfsx LAPACK_GLOBAL(ssyrfsx,SSYRFSX)\n#define LAPACK_zsyrfsx LAPACK_GLOBAL(zsyrfsx,ZSYRFSX)\n#define LAPACK_csyrfsx LAPACK_GLOBAL(csyrfsx,CSYRFSX)\n#define LAPACK_cherfs LAPACK_GLOBAL(cherfs,CHERFS)\n#define LAPACK_zherfs LAPACK_GLOBAL(zherfs,ZHERFS)\n#define LAPACK_zherfsx LAPACK_GLOBAL(zherfsx,ZHERFSX)\n#define LAPACK_cherfsx LAPACK_GLOBAL(cherfsx,CHERFSX)\n#define LAPACK_ssprfs LAPACK_GLOBAL(ssprfs,SSPRFS)\n#define LAPACK_dsprfs LAPACK_GLOBAL(dsprfs,DSPRFS)\n#define LAPACK_csprfs LAPACK_GLOBAL(csprfs,CSPRFS)\n#define LAPACK_zsprfs LAPACK_GLOBAL(zsprfs,ZSPRFS)\n#define LAPACK_chprfs LAPACK_GLOBAL(chprfs,CHPRFS)\n#define LAPACK_zhprfs LAPACK_GLOBAL(zhprfs,ZHPRFS)\n#define LAPACK_strrfs LAPACK_GLOBAL(strrfs,STRRFS)\n#define LAPACK_dtrrfs LAPACK_GLOBAL(dtrrfs,DTRRFS)\n#define LAPACK_ctrrfs LAPACK_GLOBAL(ctrrfs,CTRRFS)\n#define LAPACK_ztrrfs LAPACK_GLOBAL(ztrrfs,ZTRRFS)\n#define LAPACK_stprfs LAPACK_GLOBAL(stprfs,STPRFS)\n#define LAPACK_dtprfs LAPACK_GLOBAL(dtprfs,DTPRFS)\n#define LAPACK_ctprfs LAPACK_GLOBAL(ctprfs,CTPRFS)\n#define LAPACK_ztprfs LAPACK_GLOBAL(ztprfs,ZTPRFS)\n#define LAPACK_stbrfs LAPACK_GLOBAL(stbrfs,STBRFS)\n#define LAPACK_dtbrfs LAPACK_GLOBAL(dtbrfs,DTBRFS)\n#define LAPACK_ctbrfs LAPACK_GLOBAL(ctbrfs,CTBRFS)\n#define LAPACK_ztbrfs LAPACK_GLOBAL(ztbrfs,ZTBRFS)\n#define LAPACK_sgetri LAPACK_GLOBAL(sgetri,SGETRI)\n#define LAPACK_dgetri LAPACK_GLOBAL(dgetri,DGETRI)\n#define LAPACK_cgetri LAPACK_GLOBAL(cgetri,CGETRI)\n#define LAPACK_zgetri LAPACK_GLOBAL(zgetri,ZGETRI)\n#define LAPACK_spotri LAPACK_GLOBAL(spotri,SPOTRI)\n#define LAPACK_dpotri LAPACK_GLOBAL(dpotri,DPOTRI)\n#define LAPACK_cpotri LAPACK_GLOBAL(cpotri,CPOTRI)\n#define LAPACK_zpotri LAPACK_GLOBAL(zpotri,ZPOTRI)\n#define LAPACK_dpftri LAPACK_GLOBAL(dpftri,DPFTRI)\n#define LAPACK_spftri LAPACK_GLOBAL(spftri,SPFTRI)\n#define LAPACK_zpftri LAPACK_GLOBAL(zpftri,ZPFTRI)\n#define LAPACK_cpftri LAPACK_GLOBAL(cpftri,CPFTRI)\n#define LAPACK_spptri LAPACK_GLOBAL(spptri,SPPTRI)\n#define LAPACK_dpptri LAPACK_GLOBAL(dpptri,DPPTRI)\n#define LAPACK_cpptri LAPACK_GLOBAL(cpptri,CPPTRI)\n#define LAPACK_zpptri LAPACK_GLOBAL(zpptri,ZPPTRI)\n#define LAPACK_ssytri LAPACK_GLOBAL(ssytri,SSYTRI)\n#define LAPACK_dsytri LAPACK_GLOBAL(dsytri,DSYTRI)\n#define LAPACK_csytri LAPACK_GLOBAL(csytri,CSYTRI)\n#define LAPACK_zsytri LAPACK_GLOBAL(zsytri,ZSYTRI)\n#define LAPACK_chetri LAPACK_GLOBAL(chetri,CHETRI)\n#define LAPACK_zhetri LAPACK_GLOBAL(zhetri,ZHETRI)\n#define LAPACK_ssptri LAPACK_GLOBAL(ssptri,SSPTRI)\n#define LAPACK_dsptri LAPACK_GLOBAL(dsptri,DSPTRI)\n#define LAPACK_csptri LAPACK_GLOBAL(csptri,CSPTRI)\n#define LAPACK_zsptri LAPACK_GLOBAL(zsptri,ZSPTRI)\n#define LAPACK_chptri LAPACK_GLOBAL(chptri,CHPTRI)\n#define LAPACK_zhptri LAPACK_GLOBAL(zhptri,ZHPTRI)\n#define LAPACK_strtri LAPACK_GLOBAL(strtri,STRTRI)\n#define LAPACK_dtrtri LAPACK_GLOBAL(dtrtri,DTRTRI)\n#define LAPACK_ctrtri LAPACK_GLOBAL(ctrtri,CTRTRI)\n#define LAPACK_ztrtri LAPACK_GLOBAL(ztrtri,ZTRTRI)\n#define LAPACK_dtftri LAPACK_GLOBAL(dtftri,DTFTRI)\n#define LAPACK_stftri LAPACK_GLOBAL(stftri,STFTRI)\n#define LAPACK_ztftri LAPACK_GLOBAL(ztftri,ZTFTRI)\n#define LAPACK_ctftri LAPACK_GLOBAL(ctftri,CTFTRI)\n#define LAPACK_stptri LAPACK_GLOBAL(stptri,STPTRI)\n#define LAPACK_dtptri LAPACK_GLOBAL(dtptri,DTPTRI)\n#define LAPACK_ctptri LAPACK_GLOBAL(ctptri,CTPTRI)\n#define LAPACK_ztptri LAPACK_GLOBAL(ztptri,ZTPTRI)\n#define LAPACK_sgeequ LAPACK_GLOBAL(sgeequ,SGEEQU)\n#define LAPACK_dgeequ LAPACK_GLOBAL(dgeequ,DGEEQU)\n#define LAPACK_cgeequ LAPACK_GLOBAL(cgeequ,CGEEQU)\n#define LAPACK_zgeequ LAPACK_GLOBAL(zgeequ,ZGEEQU)\n#define LAPACK_dgeequb LAPACK_GLOBAL(dgeequb,DGEEQUB)\n#define LAPACK_sgeequb LAPACK_GLOBAL(sgeequb,SGEEQUB)\n#define LAPACK_zgeequb LAPACK_GLOBAL(zgeequb,ZGEEQUB)\n#define LAPACK_cgeequb LAPACK_GLOBAL(cgeequb,CGEEQUB)\n#define LAPACK_sgbequ LAPACK_GLOBAL(sgbequ,SGBEQU)\n#define LAPACK_dgbequ LAPACK_GLOBAL(dgbequ,DGBEQU)\n#define LAPACK_cgbequ LAPACK_GLOBAL(cgbequ,CGBEQU)\n#define LAPACK_zgbequ LAPACK_GLOBAL(zgbequ,ZGBEQU)\n#define LAPACK_dgbequb LAPACK_GLOBAL(dgbequb,DGBEQUB)\n#define LAPACK_sgbequb LAPACK_GLOBAL(sgbequb,SGBEQUB)\n#define LAPACK_zgbequb LAPACK_GLOBAL(zgbequb,ZGBEQUB)\n#define LAPACK_cgbequb LAPACK_GLOBAL(cgbequb,CGBEQUB)\n#define LAPACK_spoequ LAPACK_GLOBAL(spoequ,SPOEQU)\n#define LAPACK_dpoequ LAPACK_GLOBAL(dpoequ,DPOEQU)\n#define LAPACK_cpoequ LAPACK_GLOBAL(cpoequ,CPOEQU)\n#define LAPACK_zpoequ LAPACK_GLOBAL(zpoequ,ZPOEQU)\n#define LAPACK_dpoequb LAPACK_GLOBAL(dpoequb,DPOEQUB)\n#define LAPACK_spoequb LAPACK_GLOBAL(spoequb,SPOEQUB)\n#define LAPACK_zpoequb LAPACK_GLOBAL(zpoequb,ZPOEQUB)\n#define LAPACK_cpoequb LAPACK_GLOBAL(cpoequb,CPOEQUB)\n#define LAPACK_sppequ LAPACK_GLOBAL(sppequ,SPPEQU)\n#define LAPACK_dppequ LAPACK_GLOBAL(dppequ,DPPEQU)\n#define LAPACK_cppequ LAPACK_GLOBAL(cppequ,CPPEQU)\n#define LAPACK_zppequ LAPACK_GLOBAL(zppequ,ZPPEQU)\n#define LAPACK_spbequ LAPACK_GLOBAL(spbequ,SPBEQU)\n#define LAPACK_dpbequ LAPACK_GLOBAL(dpbequ,DPBEQU)\n#define LAPACK_cpbequ LAPACK_GLOBAL(cpbequ,CPBEQU)\n#define LAPACK_zpbequ LAPACK_GLOBAL(zpbequ,ZPBEQU)\n#define LAPACK_dsyequb LAPACK_GLOBAL(dsyequb,DSYEQUB)\n#define LAPACK_ssyequb LAPACK_GLOBAL(ssyequb,SSYEQUB)\n#define LAPACK_zsyequb LAPACK_GLOBAL(zsyequb,ZSYEQUB)\n#define LAPACK_csyequb LAPACK_GLOBAL(csyequb,CSYEQUB)\n#define LAPACK_zheequb LAPACK_GLOBAL(zheequb,ZHEEQUB)\n#define LAPACK_cheequb LAPACK_GLOBAL(cheequb,CHEEQUB)\n#define LAPACK_sgesv LAPACK_GLOBAL(sgesv,SGESV)\n#define LAPACK_dgesv LAPACK_GLOBAL(dgesv,DGESV)\n#define LAPACK_cgesv LAPACK_GLOBAL(cgesv,CGESV)\n#define LAPACK_zgesv LAPACK_GLOBAL(zgesv,ZGESV)\n#define LAPACK_dsgesv LAPACK_GLOBAL(dsgesv,DSGESV)\n#define LAPACK_zcgesv LAPACK_GLOBAL(zcgesv,ZCGESV)\n#define LAPACK_sgesvx LAPACK_GLOBAL(sgesvx,SGESVX)\n#define LAPACK_dgesvx LAPACK_GLOBAL(dgesvx,DGESVX)\n#define LAPACK_cgesvx LAPACK_GLOBAL(cgesvx,CGESVX)\n#define LAPACK_zgesvx LAPACK_GLOBAL(zgesvx,ZGESVX)\n#define LAPACK_dgesvxx LAPACK_GLOBAL(dgesvxx,DGESVXX)\n#define LAPACK_sgesvxx LAPACK_GLOBAL(sgesvxx,SGESVXX)\n#define LAPACK_zgesvxx LAPACK_GLOBAL(zgesvxx,ZGESVXX)\n#define LAPACK_cgesvxx LAPACK_GLOBAL(cgesvxx,CGESVXX)\n#define LAPACK_sgbsv LAPACK_GLOBAL(sgbsv,SGBSV)\n#define LAPACK_dgbsv LAPACK_GLOBAL(dgbsv,DGBSV)\n#define LAPACK_cgbsv LAPACK_GLOBAL(cgbsv,CGBSV)\n#define LAPACK_zgbsv LAPACK_GLOBAL(zgbsv,ZGBSV)\n#define LAPACK_sgbsvx LAPACK_GLOBAL(sgbsvx,SGBSVX)\n#define LAPACK_dgbsvx LAPACK_GLOBAL(dgbsvx,DGBSVX)\n#define LAPACK_cgbsvx LAPACK_GLOBAL(cgbsvx,CGBSVX)\n#define LAPACK_zgbsvx LAPACK_GLOBAL(zgbsvx,ZGBSVX)\n#define LAPACK_dgbsvxx LAPACK_GLOBAL(dgbsvxx,DGBSVXX)\n#define LAPACK_sgbsvxx LAPACK_GLOBAL(sgbsvxx,SGBSVXX)\n#define LAPACK_zgbsvxx LAPACK_GLOBAL(zgbsvxx,ZGBSVXX)\n#define LAPACK_cgbsvxx LAPACK_GLOBAL(cgbsvxx,CGBSVXX)\n#define LAPACK_sgtsv LAPACK_GLOBAL(sgtsv,SGTSV)\n#define LAPACK_dgtsv LAPACK_GLOBAL(dgtsv,DGTSV)\n#define LAPACK_cgtsv LAPACK_GLOBAL(cgtsv,CGTSV)\n#define LAPACK_zgtsv LAPACK_GLOBAL(zgtsv,ZGTSV)\n#define LAPACK_sgtsvx LAPACK_GLOBAL(sgtsvx,SGTSVX)\n#define LAPACK_dgtsvx LAPACK_GLOBAL(dgtsvx,DGTSVX)\n#define LAPACK_cgtsvx LAPACK_GLOBAL(cgtsvx,CGTSVX)\n#define LAPACK_zgtsvx LAPACK_GLOBAL(zgtsvx,ZGTSVX)\n#define LAPACK_sposv LAPACK_GLOBAL(sposv,SPOSV)\n#define LAPACK_dposv LAPACK_GLOBAL(dposv,DPOSV)\n#define LAPACK_cposv LAPACK_GLOBAL(cposv,CPOSV)\n#define LAPACK_zposv LAPACK_GLOBAL(zposv,ZPOSV)\n#define LAPACK_dsposv LAPACK_GLOBAL(dsposv,DSPOSV)\n#define LAPACK_zcposv LAPACK_GLOBAL(zcposv,ZCPOSV)\n#define LAPACK_sposvx LAPACK_GLOBAL(sposvx,SPOSVX)\n#define LAPACK_dposvx LAPACK_GLOBAL(dposvx,DPOSVX)\n#define LAPACK_cposvx LAPACK_GLOBAL(cposvx,CPOSVX)\n#define LAPACK_zposvx LAPACK_GLOBAL(zposvx,ZPOSVX)\n#define LAPACK_dposvxx LAPACK_GLOBAL(dposvxx,DPOSVXX)\n#define LAPACK_sposvxx LAPACK_GLOBAL(sposvxx,SPOSVXX)\n#define LAPACK_zposvxx LAPACK_GLOBAL(zposvxx,ZPOSVXX)\n#define LAPACK_cposvxx LAPACK_GLOBAL(cposvxx,CPOSVXX)\n#define LAPACK_sppsv LAPACK_GLOBAL(sppsv,SPPSV)\n#define LAPACK_dppsv LAPACK_GLOBAL(dppsv,DPPSV)\n#define LAPACK_cppsv LAPACK_GLOBAL(cppsv,CPPSV)\n#define LAPACK_zppsv LAPACK_GLOBAL(zppsv,ZPPSV)\n#define LAPACK_sppsvx LAPACK_GLOBAL(sppsvx,SPPSVX)\n#define LAPACK_dppsvx LAPACK_GLOBAL(dppsvx,DPPSVX)\n#define LAPACK_cppsvx LAPACK_GLOBAL(cppsvx,CPPSVX)\n#define LAPACK_zppsvx LAPACK_GLOBAL(zppsvx,ZPPSVX)\n#define LAPACK_spbsv LAPACK_GLOBAL(spbsv,SPBSV)\n#define LAPACK_dpbsv LAPACK_GLOBAL(dpbsv,DPBSV)\n#define LAPACK_cpbsv LAPACK_GLOBAL(cpbsv,CPBSV)\n#define LAPACK_zpbsv LAPACK_GLOBAL(zpbsv,ZPBSV)\n#define LAPACK_spbsvx LAPACK_GLOBAL(spbsvx,SPBSVX)\n#define LAPACK_dpbsvx LAPACK_GLOBAL(dpbsvx,DPBSVX)\n#define LAPACK_cpbsvx LAPACK_GLOBAL(cpbsvx,CPBSVX)\n#define LAPACK_zpbsvx LAPACK_GLOBAL(zpbsvx,ZPBSVX)\n#define LAPACK_sptsv LAPACK_GLOBAL(sptsv,SPTSV)\n#define LAPACK_dptsv LAPACK_GLOBAL(dptsv,DPTSV)\n#define LAPACK_cptsv LAPACK_GLOBAL(cptsv,CPTSV)\n#define LAPACK_zptsv LAPACK_GLOBAL(zptsv,ZPTSV)\n#define LAPACK_sptsvx LAPACK_GLOBAL(sptsvx,SPTSVX)\n#define LAPACK_dptsvx LAPACK_GLOBAL(dptsvx,DPTSVX)\n#define LAPACK_cptsvx LAPACK_GLOBAL(cptsvx,CPTSVX)\n#define LAPACK_zptsvx LAPACK_GLOBAL(zptsvx,ZPTSVX)\n#define LAPACK_ssysv LAPACK_GLOBAL(ssysv,SSYSV)\n#define LAPACK_dsysv LAPACK_GLOBAL(dsysv,DSYSV)\n#define LAPACK_csysv LAPACK_GLOBAL(csysv,CSYSV)\n#define LAPACK_zsysv LAPACK_GLOBAL(zsysv,ZSYSV)\n#define LAPACK_ssysvx LAPACK_GLOBAL(ssysvx,SSYSVX)\n#define LAPACK_dsysvx LAPACK_GLOBAL(dsysvx,DSYSVX)\n#define LAPACK_csysvx LAPACK_GLOBAL(csysvx,CSYSVX)\n#define LAPACK_zsysvx LAPACK_GLOBAL(zsysvx,ZSYSVX)\n#define LAPACK_dsysvxx LAPACK_GLOBAL(dsysvxx,DSYSVXX)\n#define LAPACK_ssysvxx LAPACK_GLOBAL(ssysvxx,SSYSVXX)\n#define LAPACK_zsysvxx LAPACK_GLOBAL(zsysvxx,ZSYSVXX)\n#define LAPACK_csysvxx LAPACK_GLOBAL(csysvxx,CSYSVXX)\n#define LAPACK_chesv LAPACK_GLOBAL(chesv,CHESV)\n#define LAPACK_zhesv LAPACK_GLOBAL(zhesv,ZHESV)\n#define LAPACK_chesvx LAPACK_GLOBAL(chesvx,CHESVX)\n#define LAPACK_zhesvx LAPACK_GLOBAL(zhesvx,ZHESVX)\n#define LAPACK_zhesvxx LAPACK_GLOBAL(zhesvxx,ZHESVXX)\n#define LAPACK_chesvxx LAPACK_GLOBAL(chesvxx,CHESVXX)\n#define LAPACK_sspsv LAPACK_GLOBAL(sspsv,SSPSV)\n#define LAPACK_dspsv LAPACK_GLOBAL(dspsv,DSPSV)\n#define LAPACK_cspsv LAPACK_GLOBAL(cspsv,CSPSV)\n#define LAPACK_zspsv LAPACK_GLOBAL(zspsv,ZSPSV)\n#define LAPACK_sspsvx LAPACK_GLOBAL(sspsvx,SSPSVX)\n#define LAPACK_dspsvx LAPACK_GLOBAL(dspsvx,DSPSVX)\n#define LAPACK_cspsvx LAPACK_GLOBAL(cspsvx,CSPSVX)\n#define LAPACK_zspsvx LAPACK_GLOBAL(zspsvx,ZSPSVX)\n#define LAPACK_chpsv LAPACK_GLOBAL(chpsv,CHPSV)\n#define LAPACK_zhpsv LAPACK_GLOBAL(zhpsv,ZHPSV)\n#define LAPACK_chpsvx LAPACK_GLOBAL(chpsvx,CHPSVX)\n#define LAPACK_zhpsvx LAPACK_GLOBAL(zhpsvx,ZHPSVX)\n#define LAPACK_sgeqrf LAPACK_GLOBAL(sgeqrf,SGEQRF)\n#define LAPACK_dgeqrf LAPACK_GLOBAL(dgeqrf,DGEQRF)\n#define LAPACK_cgeqrf LAPACK_GLOBAL(cgeqrf,CGEQRF)\n#define LAPACK_zgeqrf LAPACK_GLOBAL(zgeqrf,ZGEQRF)\n#define LAPACK_sgeqpf LAPACK_GLOBAL(sgeqpf,SGEQPF)\n#define LAPACK_dgeqpf LAPACK_GLOBAL(dgeqpf,DGEQPF)\n#define LAPACK_cgeqpf LAPACK_GLOBAL(cgeqpf,CGEQPF)\n#define LAPACK_zgeqpf LAPACK_GLOBAL(zgeqpf,ZGEQPF)\n#define LAPACK_sgeqp3 LAPACK_GLOBAL(sgeqp3,SGEQP3)\n#define LAPACK_dgeqp3 LAPACK_GLOBAL(dgeqp3,DGEQP3)\n#define LAPACK_cgeqp3 LAPACK_GLOBAL(cgeqp3,CGEQP3)\n#define LAPACK_zgeqp3 LAPACK_GLOBAL(zgeqp3,ZGEQP3)\n#define LAPACK_sorgqr LAPACK_GLOBAL(sorgqr,SORGQR)\n#define LAPACK_dorgqr LAPACK_GLOBAL(dorgqr,DORGQR)\n#define LAPACK_sormqr LAPACK_GLOBAL(sormqr,SORMQR)\n#define LAPACK_dormqr LAPACK_GLOBAL(dormqr,DORMQR)\n#define LAPACK_cungqr LAPACK_GLOBAL(cungqr,CUNGQR)\n#define LAPACK_zungqr LAPACK_GLOBAL(zungqr,ZUNGQR)\n#define LAPACK_cunmqr LAPACK_GLOBAL(cunmqr,CUNMQR)\n#define LAPACK_zunmqr LAPACK_GLOBAL(zunmqr,ZUNMQR)\n#define LAPACK_sgelqf LAPACK_GLOBAL(sgelqf,SGELQF)\n#define LAPACK_dgelqf LAPACK_GLOBAL(dgelqf,DGELQF)\n#define LAPACK_cgelqf LAPACK_GLOBAL(cgelqf,CGELQF)\n#define LAPACK_zgelqf LAPACK_GLOBAL(zgelqf,ZGELQF)\n#define LAPACK_sorglq LAPACK_GLOBAL(sorglq,SORGLQ)\n#define LAPACK_dorglq LAPACK_GLOBAL(dorglq,DORGLQ)\n#define LAPACK_sormlq LAPACK_GLOBAL(sormlq,SORMLQ)\n#define LAPACK_dormlq LAPACK_GLOBAL(dormlq,DORMLQ)\n#define LAPACK_cunglq LAPACK_GLOBAL(cunglq,CUNGLQ)\n#define LAPACK_zunglq LAPACK_GLOBAL(zunglq,ZUNGLQ)\n#define LAPACK_cunmlq LAPACK_GLOBAL(cunmlq,CUNMLQ)\n#define LAPACK_zunmlq LAPACK_GLOBAL(zunmlq,ZUNMLQ)\n#define LAPACK_sgeqlf LAPACK_GLOBAL(sgeqlf,SGEQLF)\n#define LAPACK_dgeqlf LAPACK_GLOBAL(dgeqlf,DGEQLF)\n#define LAPACK_cgeqlf LAPACK_GLOBAL(cgeqlf,CGEQLF)\n#define LAPACK_zgeqlf LAPACK_GLOBAL(zgeqlf,ZGEQLF)\n#define LAPACK_sorgql LAPACK_GLOBAL(sorgql,SORGQL)\n#define LAPACK_dorgql LAPACK_GLOBAL(dorgql,DORGQL)\n#define LAPACK_cungql LAPACK_GLOBAL(cungql,CUNGQL)\n#define LAPACK_zungql LAPACK_GLOBAL(zungql,ZUNGQL)\n#define LAPACK_sormql LAPACK_GLOBAL(sormql,SORMQL)\n#define LAPACK_dormql LAPACK_GLOBAL(dormql,DORMQL)\n#define LAPACK_cunmql LAPACK_GLOBAL(cunmql,CUNMQL)\n#define LAPACK_zunmql LAPACK_GLOBAL(zunmql,ZUNMQL)\n#define LAPACK_sgerqf LAPACK_GLOBAL(sgerqf,SGERQF)\n#define LAPACK_dgerqf LAPACK_GLOBAL(dgerqf,DGERQF)\n#define LAPACK_cgerqf LAPACK_GLOBAL(cgerqf,CGERQF)\n#define LAPACK_zgerqf LAPACK_GLOBAL(zgerqf,ZGERQF)\n#define LAPACK_sorgrq LAPACK_GLOBAL(sorgrq,SORGRQ)\n#define LAPACK_dorgrq LAPACK_GLOBAL(dorgrq,DORGRQ)\n#define LAPACK_cungrq LAPACK_GLOBAL(cungrq,CUNGRQ)\n#define LAPACK_zungrq LAPACK_GLOBAL(zungrq,ZUNGRQ)\n#define LAPACK_sormrq LAPACK_GLOBAL(sormrq,SORMRQ)\n#define LAPACK_dormrq LAPACK_GLOBAL(dormrq,DORMRQ)\n#define LAPACK_cunmrq LAPACK_GLOBAL(cunmrq,CUNMRQ)\n#define LAPACK_zunmrq LAPACK_GLOBAL(zunmrq,ZUNMRQ)\n#define LAPACK_stzrzf LAPACK_GLOBAL(stzrzf,STZRZF)\n#define LAPACK_dtzrzf LAPACK_GLOBAL(dtzrzf,DTZRZF)\n#define LAPACK_ctzrzf LAPACK_GLOBAL(ctzrzf,CTZRZF)\n#define LAPACK_ztzrzf LAPACK_GLOBAL(ztzrzf,ZTZRZF)\n#define LAPACK_sormrz LAPACK_GLOBAL(sormrz,SORMRZ)\n#define LAPACK_dormrz LAPACK_GLOBAL(dormrz,DORMRZ)\n#define LAPACK_cunmrz LAPACK_GLOBAL(cunmrz,CUNMRZ)\n#define LAPACK_zunmrz LAPACK_GLOBAL(zunmrz,ZUNMRZ)\n#define LAPACK_sggqrf LAPACK_GLOBAL(sggqrf,SGGQRF)\n#define LAPACK_dggqrf LAPACK_GLOBAL(dggqrf,DGGQRF)\n#define LAPACK_cggqrf LAPACK_GLOBAL(cggqrf,CGGQRF)\n#define LAPACK_zggqrf LAPACK_GLOBAL(zggqrf,ZGGQRF)\n#define LAPACK_sggrqf LAPACK_GLOBAL(sggrqf,SGGRQF)\n#define LAPACK_dggrqf LAPACK_GLOBAL(dggrqf,DGGRQF)\n#define LAPACK_cggrqf LAPACK_GLOBAL(cggrqf,CGGRQF)\n#define LAPACK_zggrqf LAPACK_GLOBAL(zggrqf,ZGGRQF)\n#define LAPACK_sgebrd LAPACK_GLOBAL(sgebrd,SGEBRD)\n#define LAPACK_dgebrd LAPACK_GLOBAL(dgebrd,DGEBRD)\n#define LAPACK_cgebrd LAPACK_GLOBAL(cgebrd,CGEBRD)\n#define LAPACK_zgebrd LAPACK_GLOBAL(zgebrd,ZGEBRD)\n#define LAPACK_sgbbrd LAPACK_GLOBAL(sgbbrd,SGBBRD)\n#define LAPACK_dgbbrd LAPACK_GLOBAL(dgbbrd,DGBBRD)\n#define LAPACK_cgbbrd LAPACK_GLOBAL(cgbbrd,CGBBRD)\n#define LAPACK_zgbbrd LAPACK_GLOBAL(zgbbrd,ZGBBRD)\n#define LAPACK_sorgbr LAPACK_GLOBAL(sorgbr,SORGBR)\n#define LAPACK_dorgbr LAPACK_GLOBAL(dorgbr,DORGBR)\n#define LAPACK_sormbr LAPACK_GLOBAL(sormbr,SORMBR)\n#define LAPACK_dormbr LAPACK_GLOBAL(dormbr,DORMBR)\n#define LAPACK_cungbr LAPACK_GLOBAL(cungbr,CUNGBR)\n#define LAPACK_zungbr LAPACK_GLOBAL(zungbr,ZUNGBR)\n#define LAPACK_cunmbr LAPACK_GLOBAL(cunmbr,CUNMBR)\n#define LAPACK_zunmbr LAPACK_GLOBAL(zunmbr,ZUNMBR)\n#define LAPACK_sbdsqr LAPACK_GLOBAL(sbdsqr,SBDSQR)\n#define LAPACK_dbdsqr LAPACK_GLOBAL(dbdsqr,DBDSQR)\n#define LAPACK_cbdsqr LAPACK_GLOBAL(cbdsqr,CBDSQR)\n#define LAPACK_zbdsqr LAPACK_GLOBAL(zbdsqr,ZBDSQR)\n#define LAPACK_sbdsdc LAPACK_GLOBAL(sbdsdc,SBDSDC)\n#define LAPACK_dbdsdc LAPACK_GLOBAL(dbdsdc,DBDSDC)\n#define LAPACK_ssytrd LAPACK_GLOBAL(ssytrd,SSYTRD)\n#define LAPACK_dsytrd LAPACK_GLOBAL(dsytrd,DSYTRD)\n#define LAPACK_sorgtr LAPACK_GLOBAL(sorgtr,SORGTR)\n#define LAPACK_dorgtr LAPACK_GLOBAL(dorgtr,DORGTR)\n#define LAPACK_sormtr LAPACK_GLOBAL(sormtr,SORMTR)\n#define LAPACK_dormtr LAPACK_GLOBAL(dormtr,DORMTR)\n#define LAPACK_chetrd LAPACK_GLOBAL(chetrd,CHETRD)\n#define LAPACK_zhetrd LAPACK_GLOBAL(zhetrd,ZHETRD)\n#define LAPACK_cungtr LAPACK_GLOBAL(cungtr,CUNGTR)\n#define LAPACK_zungtr LAPACK_GLOBAL(zungtr,ZUNGTR)\n#define LAPACK_cunmtr LAPACK_GLOBAL(cunmtr,CUNMTR)\n#define LAPACK_zunmtr LAPACK_GLOBAL(zunmtr,ZUNMTR)\n#define LAPACK_ssptrd LAPACK_GLOBAL(ssptrd,SSPTRD)\n#define LAPACK_dsptrd LAPACK_GLOBAL(dsptrd,DSPTRD)\n#define LAPACK_sopgtr LAPACK_GLOBAL(sopgtr,SOPGTR)\n#define LAPACK_dopgtr LAPACK_GLOBAL(dopgtr,DOPGTR)\n#define LAPACK_sopmtr LAPACK_GLOBAL(sopmtr,SOPMTR)\n#define LAPACK_dopmtr LAPACK_GLOBAL(dopmtr,DOPMTR)\n#define LAPACK_chptrd LAPACK_GLOBAL(chptrd,CHPTRD)\n#define LAPACK_zhptrd LAPACK_GLOBAL(zhptrd,ZHPTRD)\n#define LAPACK_cupgtr LAPACK_GLOBAL(cupgtr,CUPGTR)\n#define LAPACK_zupgtr LAPACK_GLOBAL(zupgtr,ZUPGTR)\n#define LAPACK_cupmtr LAPACK_GLOBAL(cupmtr,CUPMTR)\n#define LAPACK_zupmtr LAPACK_GLOBAL(zupmtr,ZUPMTR)\n#define LAPACK_ssbtrd LAPACK_GLOBAL(ssbtrd,SSBTRD)\n#define LAPACK_dsbtrd LAPACK_GLOBAL(dsbtrd,DSBTRD)\n#define LAPACK_chbtrd LAPACK_GLOBAL(chbtrd,CHBTRD)\n#define LAPACK_zhbtrd LAPACK_GLOBAL(zhbtrd,ZHBTRD)\n#define LAPACK_ssterf LAPACK_GLOBAL(ssterf,SSTERF)\n#define LAPACK_dsterf LAPACK_GLOBAL(dsterf,DSTERF)\n#define LAPACK_ssteqr LAPACK_GLOBAL(ssteqr,SSTEQR)\n#define LAPACK_dsteqr LAPACK_GLOBAL(dsteqr,DSTEQR)\n#define LAPACK_csteqr LAPACK_GLOBAL(csteqr,CSTEQR)\n#define LAPACK_zsteqr LAPACK_GLOBAL(zsteqr,ZSTEQR)\n#define LAPACK_sstemr LAPACK_GLOBAL(sstemr,SSTEMR)\n#define LAPACK_dstemr LAPACK_GLOBAL(dstemr,DSTEMR)\n#define LAPACK_cstemr LAPACK_GLOBAL(cstemr,CSTEMR)\n#define LAPACK_zstemr LAPACK_GLOBAL(zstemr,ZSTEMR)\n#define LAPACK_sstedc LAPACK_GLOBAL(sstedc,SSTEDC)\n#define LAPACK_dstedc LAPACK_GLOBAL(dstedc,DSTEDC)\n#define LAPACK_cstedc LAPACK_GLOBAL(cstedc,CSTEDC)\n#define LAPACK_zstedc LAPACK_GLOBAL(zstedc,ZSTEDC)\n#define LAPACK_sstegr LAPACK_GLOBAL(sstegr,SSTEGR)\n#define LAPACK_dstegr LAPACK_GLOBAL(dstegr,DSTEGR)\n#define LAPACK_cstegr LAPACK_GLOBAL(cstegr,CSTEGR)\n#define LAPACK_zstegr LAPACK_GLOBAL(zstegr,ZSTEGR)\n#define LAPACK_spteqr LAPACK_GLOBAL(spteqr,SPTEQR)\n#define LAPACK_dpteqr LAPACK_GLOBAL(dpteqr,DPTEQR)\n#define LAPACK_cpteqr LAPACK_GLOBAL(cpteqr,CPTEQR)\n#define LAPACK_zpteqr LAPACK_GLOBAL(zpteqr,ZPTEQR)\n#define LAPACK_sstebz LAPACK_GLOBAL(sstebz,SSTEBZ)\n#define LAPACK_dstebz LAPACK_GLOBAL(dstebz,DSTEBZ)\n#define LAPACK_sstein LAPACK_GLOBAL(sstein,SSTEIN)\n#define LAPACK_dstein LAPACK_GLOBAL(dstein,DSTEIN)\n#define LAPACK_cstein LAPACK_GLOBAL(cstein,CSTEIN)\n#define LAPACK_zstein LAPACK_GLOBAL(zstein,ZSTEIN)\n#define LAPACK_sdisna LAPACK_GLOBAL(sdisna,SDISNA)\n#define LAPACK_ddisna LAPACK_GLOBAL(ddisna,DDISNA)\n#define LAPACK_ssygst LAPACK_GLOBAL(ssygst,SSYGST)\n#define LAPACK_dsygst LAPACK_GLOBAL(dsygst,DSYGST)\n#define LAPACK_chegst LAPACK_GLOBAL(chegst,CHEGST)\n#define LAPACK_zhegst LAPACK_GLOBAL(zhegst,ZHEGST)\n#define LAPACK_sspgst LAPACK_GLOBAL(sspgst,SSPGST)\n#define LAPACK_dspgst LAPACK_GLOBAL(dspgst,DSPGST)\n#define LAPACK_chpgst LAPACK_GLOBAL(chpgst,CHPGST)\n#define LAPACK_zhpgst LAPACK_GLOBAL(zhpgst,ZHPGST)\n#define LAPACK_ssbgst LAPACK_GLOBAL(ssbgst,SSBGST)\n#define LAPACK_dsbgst LAPACK_GLOBAL(dsbgst,DSBGST)\n#define LAPACK_chbgst LAPACK_GLOBAL(chbgst,CHBGST)\n#define LAPACK_zhbgst LAPACK_GLOBAL(zhbgst,ZHBGST)\n#define LAPACK_spbstf LAPACK_GLOBAL(spbstf,SPBSTF)\n#define LAPACK_dpbstf LAPACK_GLOBAL(dpbstf,DPBSTF)\n#define LAPACK_cpbstf LAPACK_GLOBAL(cpbstf,CPBSTF)\n#define LAPACK_zpbstf LAPACK_GLOBAL(zpbstf,ZPBSTF)\n#define LAPACK_sgehrd LAPACK_GLOBAL(sgehrd,SGEHRD)\n#define LAPACK_dgehrd LAPACK_GLOBAL(dgehrd,DGEHRD)\n#define LAPACK_cgehrd LAPACK_GLOBAL(cgehrd,CGEHRD)\n#define LAPACK_zgehrd LAPACK_GLOBAL(zgehrd,ZGEHRD)\n#define LAPACK_sorghr LAPACK_GLOBAL(sorghr,SORGHR)\n#define LAPACK_dorghr LAPACK_GLOBAL(dorghr,DORGHR)\n#define LAPACK_sormhr LAPACK_GLOBAL(sormhr,SORMHR)\n#define LAPACK_dormhr LAPACK_GLOBAL(dormhr,DORMHR)\n#define LAPACK_cunghr LAPACK_GLOBAL(cunghr,CUNGHR)\n#define LAPACK_zunghr LAPACK_GLOBAL(zunghr,ZUNGHR)\n#define LAPACK_cunmhr LAPACK_GLOBAL(cunmhr,CUNMHR)\n#define LAPACK_zunmhr LAPACK_GLOBAL(zunmhr,ZUNMHR)\n#define LAPACK_sgebal LAPACK_GLOBAL(sgebal,SGEBAL)\n#define LAPACK_dgebal LAPACK_GLOBAL(dgebal,DGEBAL)\n#define LAPACK_cgebal LAPACK_GLOBAL(cgebal,CGEBAL)\n#define LAPACK_zgebal LAPACK_GLOBAL(zgebal,ZGEBAL)\n#define LAPACK_sgebak LAPACK_GLOBAL(sgebak,SGEBAK)\n#define LAPACK_dgebak LAPACK_GLOBAL(dgebak,DGEBAK)\n#define LAPACK_cgebak LAPACK_GLOBAL(cgebak,CGEBAK)\n#define LAPACK_zgebak LAPACK_GLOBAL(zgebak,ZGEBAK)\n#define LAPACK_shseqr LAPACK_GLOBAL(shseqr,SHSEQR)\n#define LAPACK_dhseqr LAPACK_GLOBAL(dhseqr,DHSEQR)\n#define LAPACK_chseqr LAPACK_GLOBAL(chseqr,CHSEQR)\n#define LAPACK_zhseqr LAPACK_GLOBAL(zhseqr,ZHSEQR)\n#define LAPACK_shsein LAPACK_GLOBAL(shsein,SHSEIN)\n#define LAPACK_dhsein LAPACK_GLOBAL(dhsein,DHSEIN)\n#define LAPACK_chsein LAPACK_GLOBAL(chsein,CHSEIN)\n#define LAPACK_zhsein LAPACK_GLOBAL(zhsein,ZHSEIN)\n#define LAPACK_strevc LAPACK_GLOBAL(strevc,STREVC)\n#define LAPACK_dtrevc LAPACK_GLOBAL(dtrevc,DTREVC)\n#define LAPACK_ctrevc LAPACK_GLOBAL(ctrevc,CTREVC)\n#define LAPACK_ztrevc LAPACK_GLOBAL(ztrevc,ZTREVC)\n#define LAPACK_strsna LAPACK_GLOBAL(strsna,STRSNA)\n#define LAPACK_dtrsna LAPACK_GLOBAL(dtrsna,DTRSNA)\n#define LAPACK_ctrsna LAPACK_GLOBAL(ctrsna,CTRSNA)\n#define LAPACK_ztrsna LAPACK_GLOBAL(ztrsna,ZTRSNA)\n#define LAPACK_strexc LAPACK_GLOBAL(strexc,STREXC)\n#define LAPACK_dtrexc LAPACK_GLOBAL(dtrexc,DTREXC)\n#define LAPACK_ctrexc LAPACK_GLOBAL(ctrexc,CTREXC)\n#define LAPACK_ztrexc LAPACK_GLOBAL(ztrexc,ZTREXC)\n#define LAPACK_strsen LAPACK_GLOBAL(strsen,STRSEN)\n#define LAPACK_dtrsen LAPACK_GLOBAL(dtrsen,DTRSEN)\n#define LAPACK_ctrsen LAPACK_GLOBAL(ctrsen,CTRSEN)\n#define LAPACK_ztrsen LAPACK_GLOBAL(ztrsen,ZTRSEN)\n#define LAPACK_strsyl LAPACK_GLOBAL(strsyl,STRSYL)\n#define LAPACK_dtrsyl LAPACK_GLOBAL(dtrsyl,DTRSYL)\n#define LAPACK_ctrsyl LAPACK_GLOBAL(ctrsyl,CTRSYL)\n#define LAPACK_ztrsyl LAPACK_GLOBAL(ztrsyl,ZTRSYL)\n#define LAPACK_sgghrd LAPACK_GLOBAL(sgghrd,SGGHRD)\n#define LAPACK_dgghrd LAPACK_GLOBAL(dgghrd,DGGHRD)\n#define LAPACK_cgghrd LAPACK_GLOBAL(cgghrd,CGGHRD)\n#define LAPACK_zgghrd LAPACK_GLOBAL(zgghrd,ZGGHRD)\n#define LAPACK_sggbal LAPACK_GLOBAL(sggbal,SGGBAL)\n#define LAPACK_dggbal LAPACK_GLOBAL(dggbal,DGGBAL)\n#define LAPACK_cggbal LAPACK_GLOBAL(cggbal,CGGBAL)\n#define LAPACK_zggbal LAPACK_GLOBAL(zggbal,ZGGBAL)\n#define LAPACK_sggbak LAPACK_GLOBAL(sggbak,SGGBAK)\n#define LAPACK_dggbak LAPACK_GLOBAL(dggbak,DGGBAK)\n#define LAPACK_cggbak LAPACK_GLOBAL(cggbak,CGGBAK)\n#define LAPACK_zggbak LAPACK_GLOBAL(zggbak,ZGGBAK)\n#define LAPACK_shgeqz LAPACK_GLOBAL(shgeqz,SHGEQZ)\n#define LAPACK_dhgeqz LAPACK_GLOBAL(dhgeqz,DHGEQZ)\n#define LAPACK_chgeqz LAPACK_GLOBAL(chgeqz,CHGEQZ)\n#define LAPACK_zhgeqz LAPACK_GLOBAL(zhgeqz,ZHGEQZ)\n#define LAPACK_stgevc LAPACK_GLOBAL(stgevc,STGEVC)\n#define LAPACK_dtgevc LAPACK_GLOBAL(dtgevc,DTGEVC)\n#define LAPACK_ctgevc LAPACK_GLOBAL(ctgevc,CTGEVC)\n#define LAPACK_ztgevc LAPACK_GLOBAL(ztgevc,ZTGEVC)\n#define LAPACK_stgexc LAPACK_GLOBAL(stgexc,STGEXC)\n#define LAPACK_dtgexc LAPACK_GLOBAL(dtgexc,DTGEXC)\n#define LAPACK_ctgexc LAPACK_GLOBAL(ctgexc,CTGEXC)\n#define LAPACK_ztgexc LAPACK_GLOBAL(ztgexc,ZTGEXC)\n#define LAPACK_stgsen LAPACK_GLOBAL(stgsen,STGSEN)\n#define LAPACK_dtgsen LAPACK_GLOBAL(dtgsen,DTGSEN)\n#define LAPACK_ctgsen LAPACK_GLOBAL(ctgsen,CTGSEN)\n#define LAPACK_ztgsen LAPACK_GLOBAL(ztgsen,ZTGSEN)\n#define LAPACK_stgsyl LAPACK_GLOBAL(stgsyl,STGSYL)\n#define LAPACK_dtgsyl LAPACK_GLOBAL(dtgsyl,DTGSYL)\n#define LAPACK_ctgsyl LAPACK_GLOBAL(ctgsyl,CTGSYL)\n#define LAPACK_ztgsyl LAPACK_GLOBAL(ztgsyl,ZTGSYL)\n#define LAPACK_stgsna LAPACK_GLOBAL(stgsna,STGSNA)\n#define LAPACK_dtgsna LAPACK_GLOBAL(dtgsna,DTGSNA)\n#define LAPACK_ctgsna LAPACK_GLOBAL(ctgsna,CTGSNA)\n#define LAPACK_ztgsna LAPACK_GLOBAL(ztgsna,ZTGSNA)\n#define LAPACK_sggsvp LAPACK_GLOBAL(sggsvp,SGGSVP)\n#define LAPACK_dggsvp LAPACK_GLOBAL(dggsvp,DGGSVP)\n#define LAPACK_cggsvp LAPACK_GLOBAL(cggsvp,CGGSVP)\n#define LAPACK_zggsvp LAPACK_GLOBAL(zggsvp,ZGGSVP)\n#define LAPACK_stgsja LAPACK_GLOBAL(stgsja,STGSJA)\n#define LAPACK_dtgsja LAPACK_GLOBAL(dtgsja,DTGSJA)\n#define LAPACK_ctgsja LAPACK_GLOBAL(ctgsja,CTGSJA)\n#define LAPACK_ztgsja LAPACK_GLOBAL(ztgsja,ZTGSJA)\n#define LAPACK_sgels LAPACK_GLOBAL(sgels,SGELS)\n#define LAPACK_dgels LAPACK_GLOBAL(dgels,DGELS)\n#define LAPACK_cgels LAPACK_GLOBAL(cgels,CGELS)\n#define LAPACK_zgels LAPACK_GLOBAL(zgels,ZGELS)\n#define LAPACK_sgelsy LAPACK_GLOBAL(sgelsy,SGELSY)\n#define LAPACK_dgelsy LAPACK_GLOBAL(dgelsy,DGELSY)\n#define LAPACK_cgelsy LAPACK_GLOBAL(cgelsy,CGELSY)\n#define LAPACK_zgelsy LAPACK_GLOBAL(zgelsy,ZGELSY)\n#define LAPACK_sgelss LAPACK_GLOBAL(sgelss,SGELSS)\n#define LAPACK_dgelss LAPACK_GLOBAL(dgelss,DGELSS)\n#define LAPACK_cgelss LAPACK_GLOBAL(cgelss,CGELSS)\n#define LAPACK_zgelss LAPACK_GLOBAL(zgelss,ZGELSS)\n#define LAPACK_sgelsd LAPACK_GLOBAL(sgelsd,SGELSD)\n#define LAPACK_dgelsd LAPACK_GLOBAL(dgelsd,DGELSD)\n#define LAPACK_cgelsd LAPACK_GLOBAL(cgelsd,CGELSD)\n#define LAPACK_zgelsd LAPACK_GLOBAL(zgelsd,ZGELSD)\n#define LAPACK_sgglse LAPACK_GLOBAL(sgglse,SGGLSE)\n#define LAPACK_dgglse LAPACK_GLOBAL(dgglse,DGGLSE)\n#define LAPACK_cgglse LAPACK_GLOBAL(cgglse,CGGLSE)\n#define LAPACK_zgglse LAPACK_GLOBAL(zgglse,ZGGLSE)\n#define LAPACK_sggglm LAPACK_GLOBAL(sggglm,SGGGLM)\n#define LAPACK_dggglm LAPACK_GLOBAL(dggglm,DGGGLM)\n#define LAPACK_cggglm LAPACK_GLOBAL(cggglm,CGGGLM)\n#define LAPACK_zggglm LAPACK_GLOBAL(zggglm,ZGGGLM)\n#define LAPACK_ssyev LAPACK_GLOBAL(ssyev,SSYEV)\n#define LAPACK_dsyev LAPACK_GLOBAL(dsyev,DSYEV)\n#define LAPACK_cheev LAPACK_GLOBAL(cheev,CHEEV)\n#define LAPACK_zheev LAPACK_GLOBAL(zheev,ZHEEV)\n#define LAPACK_ssyevd LAPACK_GLOBAL(ssyevd,SSYEVD)\n#define LAPACK_dsyevd LAPACK_GLOBAL(dsyevd,DSYEVD)\n#define LAPACK_cheevd LAPACK_GLOBAL(cheevd,CHEEVD)\n#define LAPACK_zheevd LAPACK_GLOBAL(zheevd,ZHEEVD)\n#define LAPACK_ssyevx LAPACK_GLOBAL(ssyevx,SSYEVX)\n#define LAPACK_dsyevx LAPACK_GLOBAL(dsyevx,DSYEVX)\n#define LAPACK_cheevx LAPACK_GLOBAL(cheevx,CHEEVX)\n#define LAPACK_zheevx LAPACK_GLOBAL(zheevx,ZHEEVX)\n#define LAPACK_ssyevr LAPACK_GLOBAL(ssyevr,SSYEVR)\n#define LAPACK_dsyevr LAPACK_GLOBAL(dsyevr,DSYEVR)\n#define LAPACK_cheevr LAPACK_GLOBAL(cheevr,CHEEVR)\n#define LAPACK_zheevr LAPACK_GLOBAL(zheevr,ZHEEVR)\n#define LAPACK_sspev LAPACK_GLOBAL(sspev,SSPEV)\n#define LAPACK_dspev LAPACK_GLOBAL(dspev,DSPEV)\n#define LAPACK_chpev LAPACK_GLOBAL(chpev,CHPEV)\n#define LAPACK_zhpev LAPACK_GLOBAL(zhpev,ZHPEV)\n#define LAPACK_sspevd LAPACK_GLOBAL(sspevd,SSPEVD)\n#define LAPACK_dspevd LAPACK_GLOBAL(dspevd,DSPEVD)\n#define LAPACK_chpevd LAPACK_GLOBAL(chpevd,CHPEVD)\n#define LAPACK_zhpevd LAPACK_GLOBAL(zhpevd,ZHPEVD)\n#define LAPACK_sspevx LAPACK_GLOBAL(sspevx,SSPEVX)\n#define LAPACK_dspevx LAPACK_GLOBAL(dspevx,DSPEVX)\n#define LAPACK_chpevx LAPACK_GLOBAL(chpevx,CHPEVX)\n#define LAPACK_zhpevx LAPACK_GLOBAL(zhpevx,ZHPEVX)\n#define LAPACK_ssbev LAPACK_GLOBAL(ssbev,SSBEV)\n#define LAPACK_dsbev LAPACK_GLOBAL(dsbev,DSBEV)\n#define LAPACK_chbev LAPACK_GLOBAL(chbev,CHBEV)\n#define LAPACK_zhbev LAPACK_GLOBAL(zhbev,ZHBEV)\n#define LAPACK_ssbevd LAPACK_GLOBAL(ssbevd,SSBEVD)\n#define LAPACK_dsbevd LAPACK_GLOBAL(dsbevd,DSBEVD)\n#define LAPACK_chbevd LAPACK_GLOBAL(chbevd,CHBEVD)\n#define LAPACK_zhbevd LAPACK_GLOBAL(zhbevd,ZHBEVD)\n#define LAPACK_ssbevx LAPACK_GLOBAL(ssbevx,SSBEVX)\n#define LAPACK_dsbevx LAPACK_GLOBAL(dsbevx,DSBEVX)\n#define LAPACK_chbevx LAPACK_GLOBAL(chbevx,CHBEVX)\n#define LAPACK_zhbevx LAPACK_GLOBAL(zhbevx,ZHBEVX)\n#define LAPACK_sstev LAPACK_GLOBAL(sstev,SSTEV)\n#define LAPACK_dstev LAPACK_GLOBAL(dstev,DSTEV)\n#define LAPACK_sstevd LAPACK_GLOBAL(sstevd,SSTEVD)\n#define LAPACK_dstevd LAPACK_GLOBAL(dstevd,DSTEVD)\n#define LAPACK_sstevx LAPACK_GLOBAL(sstevx,SSTEVX)\n#define LAPACK_dstevx LAPACK_GLOBAL(dstevx,DSTEVX)\n#define LAPACK_sstevr LAPACK_GLOBAL(sstevr,SSTEVR)\n#define LAPACK_dstevr LAPACK_GLOBAL(dstevr,DSTEVR)\n#define LAPACK_sgees LAPACK_GLOBAL(sgees,SGEES)\n#define LAPACK_dgees LAPACK_GLOBAL(dgees,DGEES)\n#define LAPACK_cgees LAPACK_GLOBAL(cgees,CGEES)\n#define LAPACK_zgees LAPACK_GLOBAL(zgees,ZGEES)\n#define LAPACK_sgeesx LAPACK_GLOBAL(sgeesx,SGEESX)\n#define LAPACK_dgeesx LAPACK_GLOBAL(dgeesx,DGEESX)\n#define LAPACK_cgeesx LAPACK_GLOBAL(cgeesx,CGEESX)\n#define LAPACK_zgeesx LAPACK_GLOBAL(zgeesx,ZGEESX)\n#define LAPACK_sgeev LAPACK_GLOBAL(sgeev,SGEEV)\n#define LAPACK_dgeev LAPACK_GLOBAL(dgeev,DGEEV)\n#define LAPACK_cgeev LAPACK_GLOBAL(cgeev,CGEEV)\n#define LAPACK_zgeev LAPACK_GLOBAL(zgeev,ZGEEV)\n#define LAPACK_sgeevx LAPACK_GLOBAL(sgeevx,SGEEVX)\n#define LAPACK_dgeevx LAPACK_GLOBAL(dgeevx,DGEEVX)\n#define LAPACK_cgeevx LAPACK_GLOBAL(cgeevx,CGEEVX)\n#define LAPACK_zgeevx LAPACK_GLOBAL(zgeevx,ZGEEVX)\n#define LAPACK_sgesvd LAPACK_GLOBAL(sgesvd,SGESVD)\n#define LAPACK_dgesvd LAPACK_GLOBAL(dgesvd,DGESVD)\n#define LAPACK_cgesvd LAPACK_GLOBAL(cgesvd,CGESVD)\n#define LAPACK_zgesvd LAPACK_GLOBAL(zgesvd,ZGESVD)\n#define LAPACK_sgesdd LAPACK_GLOBAL(sgesdd,SGESDD)\n#define LAPACK_dgesdd LAPACK_GLOBAL(dgesdd,DGESDD)\n#define LAPACK_cgesdd LAPACK_GLOBAL(cgesdd,CGESDD)\n#define LAPACK_zgesdd LAPACK_GLOBAL(zgesdd,ZGESDD)\n#define LAPACK_dgejsv LAPACK_GLOBAL(dgejsv,DGEJSV)\n#define LAPACK_sgejsv LAPACK_GLOBAL(sgejsv,SGEJSV)\n#define LAPACK_dgesvj LAPACK_GLOBAL(dgesvj,DGESVJ)\n#define LAPACK_sgesvj LAPACK_GLOBAL(sgesvj,SGESVJ)\n#define LAPACK_sggsvd LAPACK_GLOBAL(sggsvd,SGGSVD)\n#define LAPACK_dggsvd LAPACK_GLOBAL(dggsvd,DGGSVD)\n#define LAPACK_cggsvd LAPACK_GLOBAL(cggsvd,CGGSVD)\n#define LAPACK_zggsvd LAPACK_GLOBAL(zggsvd,ZGGSVD)\n#define LAPACK_ssygv LAPACK_GLOBAL(ssygv,SSYGV)\n#define LAPACK_dsygv LAPACK_GLOBAL(dsygv,DSYGV)\n#define LAPACK_chegv LAPACK_GLOBAL(chegv,CHEGV)\n#define LAPACK_zhegv LAPACK_GLOBAL(zhegv,ZHEGV)\n#define LAPACK_ssygvd LAPACK_GLOBAL(ssygvd,SSYGVD)\n#define LAPACK_dsygvd LAPACK_GLOBAL(dsygvd,DSYGVD)\n#define LAPACK_chegvd LAPACK_GLOBAL(chegvd,CHEGVD)\n#define LAPACK_zhegvd LAPACK_GLOBAL(zhegvd,ZHEGVD)\n#define LAPACK_ssygvx LAPACK_GLOBAL(ssygvx,SSYGVX)\n#define LAPACK_dsygvx LAPACK_GLOBAL(dsygvx,DSYGVX)\n#define LAPACK_chegvx LAPACK_GLOBAL(chegvx,CHEGVX)\n#define LAPACK_zhegvx LAPACK_GLOBAL(zhegvx,ZHEGVX)\n#define LAPACK_sspgv LAPACK_GLOBAL(sspgv,SSPGV)\n#define LAPACK_dspgv LAPACK_GLOBAL(dspgv,DSPGV)\n#define LAPACK_chpgv LAPACK_GLOBAL(chpgv,CHPGV)\n#define LAPACK_zhpgv LAPACK_GLOBAL(zhpgv,ZHPGV)\n#define LAPACK_sspgvd LAPACK_GLOBAL(sspgvd,SSPGVD)\n#define LAPACK_dspgvd LAPACK_GLOBAL(dspgvd,DSPGVD)\n#define LAPACK_chpgvd LAPACK_GLOBAL(chpgvd,CHPGVD)\n#define LAPACK_zhpgvd LAPACK_GLOBAL(zhpgvd,ZHPGVD)\n#define LAPACK_sspgvx LAPACK_GLOBAL(sspgvx,SSPGVX)\n#define LAPACK_dspgvx LAPACK_GLOBAL(dspgvx,DSPGVX)\n#define LAPACK_chpgvx LAPACK_GLOBAL(chpgvx,CHPGVX)\n#define LAPACK_zhpgvx LAPACK_GLOBAL(zhpgvx,ZHPGVX)\n#define LAPACK_ssbgv LAPACK_GLOBAL(ssbgv,SSBGV)\n#define LAPACK_dsbgv LAPACK_GLOBAL(dsbgv,DSBGV)\n#define LAPACK_chbgv LAPACK_GLOBAL(chbgv,CHBGV)\n#define LAPACK_zhbgv LAPACK_GLOBAL(zhbgv,ZHBGV)\n#define LAPACK_ssbgvd LAPACK_GLOBAL(ssbgvd,SSBGVD)\n#define LAPACK_dsbgvd LAPACK_GLOBAL(dsbgvd,DSBGVD)\n#define LAPACK_chbgvd LAPACK_GLOBAL(chbgvd,CHBGVD)\n#define LAPACK_zhbgvd LAPACK_GLOBAL(zhbgvd,ZHBGVD)\n#define LAPACK_ssbgvx LAPACK_GLOBAL(ssbgvx,SSBGVX)\n#define LAPACK_dsbgvx LAPACK_GLOBAL(dsbgvx,DSBGVX)\n#define LAPACK_chbgvx LAPACK_GLOBAL(chbgvx,CHBGVX)\n#define LAPACK_zhbgvx LAPACK_GLOBAL(zhbgvx,ZHBGVX)\n#define LAPACK_sgges LAPACK_GLOBAL(sgges,SGGES)\n#define LAPACK_dgges LAPACK_GLOBAL(dgges,DGGES)\n#define LAPACK_cgges LAPACK_GLOBAL(cgges,CGGES)\n#define LAPACK_zgges LAPACK_GLOBAL(zgges,ZGGES)\n#define LAPACK_sggesx LAPACK_GLOBAL(sggesx,SGGESX)\n#define LAPACK_dggesx LAPACK_GLOBAL(dggesx,DGGESX)\n#define LAPACK_cggesx LAPACK_GLOBAL(cggesx,CGGESX)\n#define LAPACK_zggesx LAPACK_GLOBAL(zggesx,ZGGESX)\n#define LAPACK_sggev LAPACK_GLOBAL(sggev,SGGEV)\n#define LAPACK_dggev LAPACK_GLOBAL(dggev,DGGEV)\n#define LAPACK_cggev LAPACK_GLOBAL(cggev,CGGEV)\n#define LAPACK_zggev LAPACK_GLOBAL(zggev,ZGGEV)\n#define LAPACK_sggevx LAPACK_GLOBAL(sggevx,SGGEVX)\n#define LAPACK_dggevx LAPACK_GLOBAL(dggevx,DGGEVX)\n#define LAPACK_cggevx LAPACK_GLOBAL(cggevx,CGGEVX)\n#define LAPACK_zggevx LAPACK_GLOBAL(zggevx,ZGGEVX)\n#define LAPACK_dsfrk LAPACK_GLOBAL(dsfrk,DSFRK)\n#define LAPACK_ssfrk LAPACK_GLOBAL(ssfrk,SSFRK)\n#define LAPACK_zhfrk LAPACK_GLOBAL(zhfrk,ZHFRK)\n#define LAPACK_chfrk LAPACK_GLOBAL(chfrk,CHFRK)\n#define LAPACK_dtfsm LAPACK_GLOBAL(dtfsm,DTFSM)\n#define LAPACK_stfsm LAPACK_GLOBAL(stfsm,STFSM)\n#define LAPACK_ztfsm LAPACK_GLOBAL(ztfsm,ZTFSM)\n#define LAPACK_ctfsm LAPACK_GLOBAL(ctfsm,CTFSM)\n#define LAPACK_dtfttp LAPACK_GLOBAL(dtfttp,DTFTTP)\n#define LAPACK_stfttp LAPACK_GLOBAL(stfttp,STFTTP)\n#define LAPACK_ztfttp LAPACK_GLOBAL(ztfttp,ZTFTTP)\n#define LAPACK_ctfttp LAPACK_GLOBAL(ctfttp,CTFTTP)\n#define LAPACK_dtfttr LAPACK_GLOBAL(dtfttr,DTFTTR)\n#define LAPACK_stfttr LAPACK_GLOBAL(stfttr,STFTTR)\n#define LAPACK_ztfttr LAPACK_GLOBAL(ztfttr,ZTFTTR)\n#define LAPACK_ctfttr LAPACK_GLOBAL(ctfttr,CTFTTR)\n#define LAPACK_dtpttf LAPACK_GLOBAL(dtpttf,DTPTTF)\n#define LAPACK_stpttf LAPACK_GLOBAL(stpttf,STPTTF)\n#define LAPACK_ztpttf LAPACK_GLOBAL(ztpttf,ZTPTTF)\n#define LAPACK_ctpttf LAPACK_GLOBAL(ctpttf,CTPTTF)\n#define LAPACK_dtpttr LAPACK_GLOBAL(dtpttr,DTPTTR)\n#define LAPACK_stpttr LAPACK_GLOBAL(stpttr,STPTTR)\n#define LAPACK_ztpttr LAPACK_GLOBAL(ztpttr,ZTPTTR)\n#define LAPACK_ctpttr LAPACK_GLOBAL(ctpttr,CTPTTR)\n#define LAPACK_dtrttf LAPACK_GLOBAL(dtrttf,DTRTTF)\n#define LAPACK_strttf LAPACK_GLOBAL(strttf,STRTTF)\n#define LAPACK_ztrttf LAPACK_GLOBAL(ztrttf,ZTRTTF)\n#define LAPACK_ctrttf LAPACK_GLOBAL(ctrttf,CTRTTF)\n#define LAPACK_dtrttp LAPACK_GLOBAL(dtrttp,DTRTTP)\n#define LAPACK_strttp LAPACK_GLOBAL(strttp,STRTTP)\n#define LAPACK_ztrttp LAPACK_GLOBAL(ztrttp,ZTRTTP)\n#define LAPACK_ctrttp LAPACK_GLOBAL(ctrttp,CTRTTP)\n#define LAPACK_sgeqrfp LAPACK_GLOBAL(sgeqrfp,SGEQRFP)\n#define LAPACK_dgeqrfp LAPACK_GLOBAL(dgeqrfp,DGEQRFP)\n#define LAPACK_cgeqrfp LAPACK_GLOBAL(cgeqrfp,CGEQRFP)\n#define LAPACK_zgeqrfp LAPACK_GLOBAL(zgeqrfp,ZGEQRFP)\n#define LAPACK_clacgv LAPACK_GLOBAL(clacgv,CLACGV)\n#define LAPACK_zlacgv LAPACK_GLOBAL(zlacgv,ZLACGV)\n#define LAPACK_slarnv LAPACK_GLOBAL(slarnv,SLARNV)\n#define LAPACK_dlarnv LAPACK_GLOBAL(dlarnv,DLARNV)\n#define LAPACK_clarnv LAPACK_GLOBAL(clarnv,CLARNV)\n#define LAPACK_zlarnv LAPACK_GLOBAL(zlarnv,ZLARNV)\n#define LAPACK_sgeqr2 LAPACK_GLOBAL(sgeqr2,SGEQR2)\n#define LAPACK_dgeqr2 LAPACK_GLOBAL(dgeqr2,DGEQR2)\n#define LAPACK_cgeqr2 LAPACK_GLOBAL(cgeqr2,CGEQR2)\n#define LAPACK_zgeqr2 LAPACK_GLOBAL(zgeqr2,ZGEQR2)\n#define LAPACK_slacpy LAPACK_GLOBAL(slacpy,SLACPY)\n#define LAPACK_dlacpy LAPACK_GLOBAL(dlacpy,DLACPY)\n#define LAPACK_clacpy LAPACK_GLOBAL(clacpy,CLACPY)\n#define LAPACK_zlacpy LAPACK_GLOBAL(zlacpy,ZLACPY)\n#define LAPACK_sgetf2 LAPACK_GLOBAL(sgetf2,SGETF2)\n#define LAPACK_dgetf2 LAPACK_GLOBAL(dgetf2,DGETF2)\n#define LAPACK_cgetf2 LAPACK_GLOBAL(cgetf2,CGETF2)\n#define LAPACK_zgetf2 LAPACK_GLOBAL(zgetf2,ZGETF2)\n#define LAPACK_slaswp LAPACK_GLOBAL(slaswp,SLASWP)\n#define LAPACK_dlaswp LAPACK_GLOBAL(dlaswp,DLASWP)\n#define LAPACK_claswp LAPACK_GLOBAL(claswp,CLASWP)\n#define LAPACK_zlaswp LAPACK_GLOBAL(zlaswp,ZLASWP)\n#define LAPACK_slange LAPACK_GLOBAL(slange,SLANGE)\n#define LAPACK_dlange LAPACK_GLOBAL(dlange,DLANGE)\n#define LAPACK_clange LAPACK_GLOBAL(clange,CLANGE)\n#define LAPACK_zlange LAPACK_GLOBAL(zlange,ZLANGE)\n#define LAPACK_clanhe LAPACK_GLOBAL(clanhe,CLANHE)\n#define LAPACK_zlanhe LAPACK_GLOBAL(zlanhe,ZLANHE)\n#define LAPACK_slansy LAPACK_GLOBAL(slansy,SLANSY)\n#define LAPACK_dlansy LAPACK_GLOBAL(dlansy,DLANSY)\n#define LAPACK_clansy LAPACK_GLOBAL(clansy,CLANSY)\n#define LAPACK_zlansy LAPACK_GLOBAL(zlansy,ZLANSY)\n#define LAPACK_slantr LAPACK_GLOBAL(slantr,SLANTR)\n#define LAPACK_dlantr LAPACK_GLOBAL(dlantr,DLANTR)\n#define LAPACK_clantr LAPACK_GLOBAL(clantr,CLANTR)\n#define LAPACK_zlantr LAPACK_GLOBAL(zlantr,ZLANTR)\n#define LAPACK_slamch LAPACK_GLOBAL(slamch,SLAMCH)\n#define LAPACK_dlamch LAPACK_GLOBAL(dlamch,DLAMCH)\n#define LAPACK_sgelq2 LAPACK_GLOBAL(sgelq2,SGELQ2)\n#define LAPACK_dgelq2 LAPACK_GLOBAL(dgelq2,DGELQ2)\n#define LAPACK_cgelq2 LAPACK_GLOBAL(cgelq2,CGELQ2)\n#define LAPACK_zgelq2 LAPACK_GLOBAL(zgelq2,ZGELQ2)\n#define LAPACK_slarfb LAPACK_GLOBAL(slarfb,SLARFB)\n#define LAPACK_dlarfb LAPACK_GLOBAL(dlarfb,DLARFB)\n#define LAPACK_clarfb LAPACK_GLOBAL(clarfb,CLARFB)\n#define LAPACK_zlarfb LAPACK_GLOBAL(zlarfb,ZLARFB)\n#define LAPACK_slarfg LAPACK_GLOBAL(slarfg,SLARFG)\n#define LAPACK_dlarfg LAPACK_GLOBAL(dlarfg,DLARFG)\n#define LAPACK_clarfg LAPACK_GLOBAL(clarfg,CLARFG)\n#define LAPACK_zlarfg LAPACK_GLOBAL(zlarfg,ZLARFG)\n#define LAPACK_slarft LAPACK_GLOBAL(slarft,SLARFT)\n#define LAPACK_dlarft LAPACK_GLOBAL(dlarft,DLARFT)\n#define LAPACK_clarft LAPACK_GLOBAL(clarft,CLARFT)\n#define LAPACK_zlarft LAPACK_GLOBAL(zlarft,ZLARFT)\n#define LAPACK_slarfx LAPACK_GLOBAL(slarfx,SLARFX)\n#define LAPACK_dlarfx LAPACK_GLOBAL(dlarfx,DLARFX)\n#define LAPACK_clarfx LAPACK_GLOBAL(clarfx,CLARFX)\n#define LAPACK_zlarfx LAPACK_GLOBAL(zlarfx,ZLARFX)\n#define LAPACK_slatms LAPACK_GLOBAL(slatms,SLATMS)\n#define LAPACK_dlatms LAPACK_GLOBAL(dlatms,DLATMS)\n#define LAPACK_clatms LAPACK_GLOBAL(clatms,CLATMS)\n#define LAPACK_zlatms LAPACK_GLOBAL(zlatms,ZLATMS)\n#define LAPACK_slag2d LAPACK_GLOBAL(slag2d,SLAG2D)\n#define LAPACK_dlag2s LAPACK_GLOBAL(dlag2s,DLAG2S)\n#define LAPACK_clag2z LAPACK_GLOBAL(clag2z,CLAG2Z)\n#define LAPACK_zlag2c LAPACK_GLOBAL(zlag2c,ZLAG2C)\n#define LAPACK_slauum LAPACK_GLOBAL(slauum,SLAUUM)\n#define LAPACK_dlauum LAPACK_GLOBAL(dlauum,DLAUUM)\n#define LAPACK_clauum LAPACK_GLOBAL(clauum,CLAUUM)\n#define LAPACK_zlauum LAPACK_GLOBAL(zlauum,ZLAUUM)\n#define LAPACK_slagge LAPACK_GLOBAL(slagge,SLAGGE)\n#define LAPACK_dlagge LAPACK_GLOBAL(dlagge,DLAGGE)\n#define LAPACK_clagge LAPACK_GLOBAL(clagge,CLAGGE)\n#define LAPACK_zlagge LAPACK_GLOBAL(zlagge,ZLAGGE)\n#define LAPACK_slaset LAPACK_GLOBAL(slaset,SLASET)\n#define LAPACK_dlaset LAPACK_GLOBAL(dlaset,DLASET)\n#define LAPACK_claset LAPACK_GLOBAL(claset,CLASET)\n#define LAPACK_zlaset LAPACK_GLOBAL(zlaset,ZLASET)\n#define LAPACK_slasrt LAPACK_GLOBAL(slasrt,SLASRT)\n#define LAPACK_dlasrt LAPACK_GLOBAL(dlasrt,DLASRT)\n#define LAPACK_slagsy LAPACK_GLOBAL(slagsy,SLAGSY)\n#define LAPACK_dlagsy LAPACK_GLOBAL(dlagsy,DLAGSY)\n#define LAPACK_clagsy LAPACK_GLOBAL(clagsy,CLAGSY)\n#define LAPACK_zlagsy LAPACK_GLOBAL(zlagsy,ZLAGSY)\n#define LAPACK_claghe LAPACK_GLOBAL(claghe,CLAGHE)\n#define LAPACK_zlaghe LAPACK_GLOBAL(zlaghe,ZLAGHE)\n#define LAPACK_slapmr LAPACK_GLOBAL(slapmr,SLAPMR)\n#define LAPACK_dlapmr LAPACK_GLOBAL(dlapmr,DLAPMR)\n#define LAPACK_clapmr LAPACK_GLOBAL(clapmr,CLAPMR)\n#define LAPACK_zlapmr LAPACK_GLOBAL(zlapmr,ZLAPMR)\n#define LAPACK_slapy2 LAPACK_GLOBAL(slapy2,SLAPY2)\n#define LAPACK_dlapy2 LAPACK_GLOBAL(dlapy2,DLAPY2)\n#define LAPACK_slapy3 LAPACK_GLOBAL(slapy3,SLAPY3)\n#define LAPACK_dlapy3 LAPACK_GLOBAL(dlapy3,DLAPY3)\n#define LAPACK_slartgp LAPACK_GLOBAL(slartgp,SLARTGP)\n#define LAPACK_dlartgp LAPACK_GLOBAL(dlartgp,DLARTGP)\n#define LAPACK_slartgs LAPACK_GLOBAL(slartgs,SLARTGS)\n#define LAPACK_dlartgs LAPACK_GLOBAL(dlartgs,DLARTGS)\n// LAPACK 3.3.0\n#define LAPACK_cbbcsd LAPACK_GLOBAL(cbbcsd,CBBCSD)\n#define LAPACK_cheswapr LAPACK_GLOBAL(cheswapr,CHESWAPR)\n#define LAPACK_chetri2 LAPACK_GLOBAL(chetri2,CHETRI2)\n#define LAPACK_chetri2x LAPACK_GLOBAL(chetri2x,CHETRI2X)\n#define LAPACK_chetrs2 LAPACK_GLOBAL(chetrs2,CHETRS2)\n#define LAPACK_csyconv LAPACK_GLOBAL(csyconv,CSYCONV)\n#define LAPACK_csyswapr LAPACK_GLOBAL(csyswapr,CSYSWAPR)\n#define LAPACK_csytri2 LAPACK_GLOBAL(csytri2,CSYTRI2)\n#define LAPACK_csytri2x LAPACK_GLOBAL(csytri2x,CSYTRI2X)\n#define LAPACK_csytrs2 LAPACK_GLOBAL(csytrs2,CSYTRS2)\n#define LAPACK_cunbdb LAPACK_GLOBAL(cunbdb,CUNBDB)\n#define LAPACK_cuncsd LAPACK_GLOBAL(cuncsd,CUNCSD)\n#define LAPACK_dbbcsd LAPACK_GLOBAL(dbbcsd,DBBCSD)\n#define LAPACK_dorbdb LAPACK_GLOBAL(dorbdb,DORBDB)\n#define LAPACK_dorcsd LAPACK_GLOBAL(dorcsd,DORCSD)\n#define LAPACK_dsyconv LAPACK_GLOBAL(dsyconv,DSYCONV)\n#define LAPACK_dsyswapr LAPACK_GLOBAL(dsyswapr,DSYSWAPR)\n#define LAPACK_dsytri2 LAPACK_GLOBAL(dsytri2,DSYTRI2)\n#define LAPACK_dsytri2x LAPACK_GLOBAL(dsytri2x,DSYTRI2X)\n#define LAPACK_dsytrs2 LAPACK_GLOBAL(dsytrs2,DSYTRS2)\n#define LAPACK_sbbcsd LAPACK_GLOBAL(sbbcsd,SBBCSD)\n#define LAPACK_sorbdb LAPACK_GLOBAL(sorbdb,SORBDB)\n#define LAPACK_sorcsd LAPACK_GLOBAL(sorcsd,SORCSD)\n#define LAPACK_ssyconv LAPACK_GLOBAL(ssyconv,SSYCONV)\n#define LAPACK_ssyswapr LAPACK_GLOBAL(ssyswapr,SSYSWAPR)\n#define LAPACK_ssytri2 LAPACK_GLOBAL(ssytri2,SSYTRI2)\n#define LAPACK_ssytri2x LAPACK_GLOBAL(ssytri2x,SSYTRI2X)\n#define LAPACK_ssytrs2 LAPACK_GLOBAL(ssytrs2,SSYTRS2)\n#define LAPACK_zbbcsd LAPACK_GLOBAL(zbbcsd,ZBBCSD)\n#define LAPACK_zheswapr LAPACK_GLOBAL(zheswapr,ZHESWAPR)\n#define LAPACK_zhetri2 LAPACK_GLOBAL(zhetri2,ZHETRI2)\n#define LAPACK_zhetri2x LAPACK_GLOBAL(zhetri2x,ZHETRI2X)\n#define LAPACK_zhetrs2 LAPACK_GLOBAL(zhetrs2,ZHETRS2)\n#define LAPACK_zsyconv LAPACK_GLOBAL(zsyconv,ZSYCONV)\n#define LAPACK_zsyswapr LAPACK_GLOBAL(zsyswapr,ZSYSWAPR)\n#define LAPACK_zsytri2 LAPACK_GLOBAL(zsytri2,ZSYTRI2)\n#define LAPACK_zsytri2x LAPACK_GLOBAL(zsytri2x,ZSYTRI2X)\n#define LAPACK_zsytrs2 LAPACK_GLOBAL(zsytrs2,ZSYTRS2)\n#define LAPACK_zunbdb LAPACK_GLOBAL(zunbdb,ZUNBDB)\n#define LAPACK_zuncsd LAPACK_GLOBAL(zuncsd,ZUNCSD)\n// LAPACK 3.4.0\n#define LAPACK_sgemqrt LAPACK_GLOBAL(sgemqrt,SGEMQRT)\n#define LAPACK_dgemqrt LAPACK_GLOBAL(dgemqrt,DGEMQRT)\n#define LAPACK_cgemqrt LAPACK_GLOBAL(cgemqrt,CGEMQRT)\n#define LAPACK_zgemqrt LAPACK_GLOBAL(zgemqrt,ZGEMQRT)\n#define LAPACK_sgeqrt LAPACK_GLOBAL(sgeqrt,SGEQRT)\n#define LAPACK_dgeqrt LAPACK_GLOBAL(dgeqrt,DGEQRT)\n#define LAPACK_cgeqrt LAPACK_GLOBAL(cgeqrt,CGEQRT)\n#define LAPACK_zgeqrt LAPACK_GLOBAL(zgeqrt,ZGEQRT)\n#define LAPACK_sgeqrt2 LAPACK_GLOBAL(sgeqrt2,SGEQRT2)\n#define LAPACK_dgeqrt2 LAPACK_GLOBAL(dgeqrt2,DGEQRT2)\n#define LAPACK_cgeqrt2 LAPACK_GLOBAL(cgeqrt2,CGEQRT2)\n#define LAPACK_zgeqrt2 LAPACK_GLOBAL(zgeqrt2,ZGEQRT2)\n#define LAPACK_sgeqrt3 LAPACK_GLOBAL(sgeqrt3,SGEQRT3)\n#define LAPACK_dgeqrt3 LAPACK_GLOBAL(dgeqrt3,DGEQRT3)\n#define LAPACK_cgeqrt3 LAPACK_GLOBAL(cgeqrt3,CGEQRT3)\n#define LAPACK_zgeqrt3 LAPACK_GLOBAL(zgeqrt3,ZGEQRT3)\n#define LAPACK_stpmqrt LAPACK_GLOBAL(stpmqrt,STPMQRT)\n#define LAPACK_dtpmqrt LAPACK_GLOBAL(dtpmqrt,DTPMQRT)\n#define LAPACK_ctpmqrt LAPACK_GLOBAL(ctpmqrt,CTPMQRT)\n#define LAPACK_ztpmqrt LAPACK_GLOBAL(ztpmqrt,ZTPMQRT)\n#define LAPACK_dtpqrt LAPACK_GLOBAL(dtpqrt,DTPQRT)\n#define LAPACK_ctpqrt LAPACK_GLOBAL(ctpqrt,CTPQRT)\n#define LAPACK_ztpqrt LAPACK_GLOBAL(ztpqrt,ZTPQRT)\n#define LAPACK_stpqrt2 LAPACK_GLOBAL(stpqrt2,STPQRT2)\n#define LAPACK_dtpqrt2 LAPACK_GLOBAL(dtpqrt2,DTPQRT2)\n#define LAPACK_ctpqrt2 LAPACK_GLOBAL(ctpqrt2,CTPQRT2)\n#define LAPACK_ztpqrt2 LAPACK_GLOBAL(ztpqrt2,ZTPQRT2)\n#define LAPACK_stprfb LAPACK_GLOBAL(stprfb,STPRFB)\n#define LAPACK_dtprfb LAPACK_GLOBAL(dtprfb,DTPRFB)\n#define LAPACK_ctprfb LAPACK_GLOBAL(ctprfb,CTPRFB)\n#define LAPACK_ztprfb LAPACK_GLOBAL(ztprfb,ZTPRFB)\n// LAPACK 3.X.X\n#define LAPACK_csyr LAPACK_GLOBAL(csyr,CSYR)\n#define LAPACK_zsyr LAPACK_GLOBAL(zsyr,ZSYR)\n\n\nvoid LAPACK_sgetrf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_dgetrf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_cgetrf( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_zgetrf( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_sgbtrf( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, float* ab, lapack_int* ldab,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_dgbtrf( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, double* ab, lapack_int* ldab,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_cgbtrf( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, lapack_complex_float* ab, lapack_int* ldab,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_zgbtrf( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, lapack_complex_double* ab, lapack_int* ldab,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_sgttrf( lapack_int* n, float* dl, float* d, float* du, float* du2,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_dgttrf( lapack_int* n, double* dl, double* d, double* du,\n                    double* du2, lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_cgttrf( lapack_int* n, lapack_complex_float* dl,\n                    lapack_complex_float* d, lapack_complex_float* du,\n                    lapack_complex_float* du2, lapack_int* ipiv,\n                    lapack_int *info );\nvoid LAPACK_zgttrf( lapack_int* n, lapack_complex_double* dl,\n                    lapack_complex_double* d, lapack_complex_double* du,\n                    lapack_complex_double* du2, lapack_int* ipiv,\n                    lapack_int *info );\nvoid LAPACK_spotrf( char* uplo, lapack_int* n, float* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_dpotrf( char* uplo, lapack_int* n, double* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_cpotrf( char* uplo, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_zpotrf( char* uplo, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_dpstrf( char* uplo, lapack_int* n, double* a, lapack_int* lda,\n                    lapack_int* piv, lapack_int* rank, double* tol,\n                    double* work, lapack_int *info );\nvoid LAPACK_spstrf( char* uplo, lapack_int* n, float* a, lapack_int* lda,\n                    lapack_int* piv, lapack_int* rank, float* tol, float* work,\n                    lapack_int *info );\nvoid LAPACK_zpstrf( char* uplo, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int* piv, lapack_int* rank,\n                    double* tol, double* work, lapack_int *info );\nvoid LAPACK_cpstrf( char* uplo, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int* piv, lapack_int* rank,\n                    float* tol, float* work, lapack_int *info );\nvoid LAPACK_dpftrf( char* transr, char* uplo, lapack_int* n, double* a,\n                    lapack_int *info );\nvoid LAPACK_spftrf( char* transr, char* uplo, lapack_int* n, float* a,\n                    lapack_int *info );\nvoid LAPACK_zpftrf( char* transr, char* uplo, lapack_int* n,\n                    lapack_complex_double* a, lapack_int *info );\nvoid LAPACK_cpftrf( char* transr, char* uplo, lapack_int* n,\n                    lapack_complex_float* a, lapack_int *info );\nvoid LAPACK_spptrf( char* uplo, lapack_int* n, float* ap, lapack_int *info );\nvoid LAPACK_dpptrf( char* uplo, lapack_int* n, double* ap, lapack_int *info );\nvoid LAPACK_cpptrf( char* uplo, lapack_int* n, lapack_complex_float* ap,\n                    lapack_int *info );\nvoid LAPACK_zpptrf( char* uplo, lapack_int* n, lapack_complex_double* ap,\n                    lapack_int *info );\nvoid LAPACK_spbtrf( char* uplo, lapack_int* n, lapack_int* kd, float* ab,\n                    lapack_int* ldab, lapack_int *info );\nvoid LAPACK_dpbtrf( char* uplo, lapack_int* n, lapack_int* kd, double* ab,\n                    lapack_int* ldab, lapack_int *info );\nvoid LAPACK_cpbtrf( char* uplo, lapack_int* n, lapack_int* kd,\n                    lapack_complex_float* ab, lapack_int* ldab,\n                    lapack_int *info );\nvoid LAPACK_zpbtrf( char* uplo, lapack_int* n, lapack_int* kd,\n                    lapack_complex_double* ab, lapack_int* ldab,\n                    lapack_int *info );\nvoid LAPACK_spttrf( lapack_int* n, float* d, float* e, lapack_int *info );\nvoid LAPACK_dpttrf( lapack_int* n, double* d, double* e, lapack_int *info );\nvoid LAPACK_cpttrf( lapack_int* n, float* d, lapack_complex_float* e,\n                    lapack_int *info );\nvoid LAPACK_zpttrf( lapack_int* n, double* d, lapack_complex_double* e,\n                    lapack_int *info );\nvoid LAPACK_ssytrf( char* uplo, lapack_int* n, float* a, lapack_int* lda,\n                    lapack_int* ipiv, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dsytrf( char* uplo, lapack_int* n, double* a, lapack_int* lda,\n                    lapack_int* ipiv, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_csytrf( char* uplo, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int* ipiv,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zsytrf( char* uplo, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int* ipiv,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_chetrf( char* uplo, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int* ipiv,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zhetrf( char* uplo, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int* ipiv,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_ssptrf( char* uplo, lapack_int* n, float* ap, lapack_int* ipiv,\n                    lapack_int *info );\nvoid LAPACK_dsptrf( char* uplo, lapack_int* n, double* ap, lapack_int* ipiv,\n                    lapack_int *info );\nvoid LAPACK_csptrf( char* uplo, lapack_int* n, lapack_complex_float* ap,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_zsptrf( char* uplo, lapack_int* n, lapack_complex_double* ap,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_chptrf( char* uplo, lapack_int* n, lapack_complex_float* ap,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_zhptrf( char* uplo, lapack_int* n, lapack_complex_double* ap,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_sgetrs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const float* a, lapack_int* lda, const lapack_int* ipiv,\n                    float* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_dgetrs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const double* a, lapack_int* lda, const lapack_int* ipiv,\n                    double* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_cgetrs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    const lapack_int* ipiv, lapack_complex_float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zgetrs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    const lapack_int* ipiv, lapack_complex_double* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_sgbtrs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    lapack_int* nrhs, const float* ab, lapack_int* ldab,\n                    const lapack_int* ipiv, float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_dgbtrs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    lapack_int* nrhs, const double* ab, lapack_int* ldab,\n                    const lapack_int* ipiv, double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_cgbtrs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    lapack_int* nrhs, const lapack_complex_float* ab,\n                    lapack_int* ldab, const lapack_int* ipiv,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_zgbtrs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    lapack_int* nrhs, const lapack_complex_double* ab,\n                    lapack_int* ldab, const lapack_int* ipiv,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_sgttrs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const float* dl, const float* d, const float* du,\n                    const float* du2, const lapack_int* ipiv, float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_dgttrs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const double* dl, const double* d, const double* du,\n                    const double* du2, const lapack_int* ipiv, double* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_cgttrs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* dl,\n                    const lapack_complex_float* d,\n                    const lapack_complex_float* du,\n                    const lapack_complex_float* du2, const lapack_int* ipiv,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_zgttrs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* dl,\n                    const lapack_complex_double* d,\n                    const lapack_complex_double* du,\n                    const lapack_complex_double* du2, const lapack_int* ipiv,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_spotrs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* a,\n                    lapack_int* lda, float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_dpotrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* a, lapack_int* lda, double* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_cpotrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_zpotrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_dpftrs( char* transr, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* a, double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_spftrs( char* transr, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const float* a, float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_zpftrs( char* transr, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* a, lapack_complex_double* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_cpftrs( char* transr, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* a, lapack_complex_float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_spptrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const float* ap, float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_dpptrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* ap, double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_cpptrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* ap, lapack_complex_float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zpptrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* ap, lapack_complex_double* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_spbtrs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                    const float* ab, lapack_int* ldab, float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_dpbtrs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                    const double* ab, lapack_int* ldab, double* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_cpbtrs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                    const lapack_complex_float* ab, lapack_int* ldab,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_zpbtrs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                    const lapack_complex_double* ab, lapack_int* ldab,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_spttrs( lapack_int* n, lapack_int* nrhs, const float* d,\n                    const float* e, float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_dpttrs( lapack_int* n, lapack_int* nrhs, const double* d,\n                    const double* e, double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_cpttrs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* d,\n                    const lapack_complex_float* e, lapack_complex_float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zpttrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* d, const lapack_complex_double* e,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_ssytrs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* a,\n                    lapack_int* lda, const lapack_int* ipiv, float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_dsytrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* a, lapack_int* lda, const lapack_int* ipiv,\n                    double* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_csytrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    const lapack_int* ipiv, lapack_complex_float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zsytrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    const lapack_int* ipiv, lapack_complex_double* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_chetrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    const lapack_int* ipiv, lapack_complex_float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zhetrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    const lapack_int* ipiv, lapack_complex_double* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_ssptrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const float* ap, const lapack_int* ipiv, float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_dsptrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* ap, const lapack_int* ipiv, double* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_csptrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* ap, const lapack_int* ipiv,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_zsptrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* ap, const lapack_int* ipiv,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_chptrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* ap, const lapack_int* ipiv,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_zhptrs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* ap, const lapack_int* ipiv,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_strtrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const float* a, lapack_int* lda, float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_dtrtrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const double* a, lapack_int* lda,\n                    double* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_ctrtrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const lapack_complex_float* a,\n                    lapack_int* lda, lapack_complex_float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_ztrtrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const lapack_complex_double* a,\n                    lapack_int* lda, lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_stptrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const float* ap, float* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_dtptrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const double* ap, double* b,\n                    lapack_int* ldb, lapack_int *info );\nvoid LAPACK_ctptrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const lapack_complex_float* ap,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_ztptrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const lapack_complex_double* ap,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_stbtrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* kd, lapack_int* nrhs, const float* ab,\n                    lapack_int* ldab, float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_dtbtrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* kd, lapack_int* nrhs, const double* ab,\n                    lapack_int* ldab, double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_ctbtrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* kd, lapack_int* nrhs,\n                    const lapack_complex_float* ab, lapack_int* ldab,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_ztbtrs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* kd, lapack_int* nrhs,\n                    const lapack_complex_double* ab, lapack_int* ldab,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_sgecon( char* norm, lapack_int* n, const float* a, lapack_int* lda,\n                    float* anorm, float* rcond, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dgecon( char* norm, lapack_int* n, const double* a, lapack_int* lda,\n                    double* anorm, double* rcond, double* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cgecon( char* norm, lapack_int* n, const lapack_complex_float* a,\n                    lapack_int* lda, float* anorm, float* rcond,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zgecon( char* norm, lapack_int* n, const lapack_complex_double* a,\n                    lapack_int* lda, double* anorm, double* rcond,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_sgbcon( char* norm, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    const float* ab, lapack_int* ldab, const lapack_int* ipiv,\n                    float* anorm, float* rcond, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dgbcon( char* norm, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    const double* ab, lapack_int* ldab, const lapack_int* ipiv,\n                    double* anorm, double* rcond, double* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cgbcon( char* norm, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    const lapack_complex_float* ab, lapack_int* ldab,\n                    const lapack_int* ipiv, float* anorm, float* rcond,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zgbcon( char* norm, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    const lapack_complex_double* ab, lapack_int* ldab,\n                    const lapack_int* ipiv, double* anorm, double* rcond,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_sgtcon( char* norm, lapack_int* n, const float* dl, const float* d,\n                    const float* du, const float* du2, const lapack_int* ipiv,\n                    float* anorm, float* rcond, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dgtcon( char* norm, lapack_int* n, const double* dl,\n                    const double* d, const double* du, const double* du2,\n                    const lapack_int* ipiv, double* anorm, double* rcond,\n                    double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cgtcon( char* norm, lapack_int* n, const lapack_complex_float* dl,\n                    const lapack_complex_float* d,\n                    const lapack_complex_float* du,\n                    const lapack_complex_float* du2, const lapack_int* ipiv,\n                    float* anorm, float* rcond, lapack_complex_float* work,\n                    lapack_int *info );\nvoid LAPACK_zgtcon( char* norm, lapack_int* n, const lapack_complex_double* dl,\n                    const lapack_complex_double* d,\n                    const lapack_complex_double* du,\n                    const lapack_complex_double* du2, const lapack_int* ipiv,\n                    double* anorm, double* rcond, lapack_complex_double* work,\n                    lapack_int *info );\nvoid LAPACK_spocon( char* uplo, lapack_int* n, const float* a, lapack_int* lda,\n                    float* anorm, float* rcond, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dpocon( char* uplo, lapack_int* n, const double* a, lapack_int* lda,\n                    double* anorm, double* rcond, double* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cpocon( char* uplo, lapack_int* n, const lapack_complex_float* a,\n                    lapack_int* lda, float* anorm, float* rcond,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zpocon( char* uplo, lapack_int* n, const lapack_complex_double* a,\n                    lapack_int* lda, double* anorm, double* rcond,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_sppcon( char* uplo, lapack_int* n, const float* ap, float* anorm,\n                    float* rcond, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dppcon( char* uplo, lapack_int* n, const double* ap, double* anorm,\n                    double* rcond, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_cppcon( char* uplo, lapack_int* n, const lapack_complex_float* ap,\n                    float* anorm, float* rcond, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_zppcon( char* uplo, lapack_int* n, const lapack_complex_double* ap,\n                    double* anorm, double* rcond, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_spbcon( char* uplo, lapack_int* n, lapack_int* kd, const float* ab,\n                    lapack_int* ldab, float* anorm, float* rcond, float* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dpbcon( char* uplo, lapack_int* n, lapack_int* kd, const double* ab,\n                    lapack_int* ldab, double* anorm, double* rcond,\n                    double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cpbcon( char* uplo, lapack_int* n, lapack_int* kd,\n                    const lapack_complex_float* ab, lapack_int* ldab,\n                    float* anorm, float* rcond, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_zpbcon( char* uplo, lapack_int* n, lapack_int* kd,\n                    const lapack_complex_double* ab, lapack_int* ldab,\n                    double* anorm, double* rcond, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_sptcon( lapack_int* n, const float* d, const float* e, float* anorm,\n                    float* rcond, float* work, lapack_int *info );\nvoid LAPACK_dptcon( lapack_int* n, const double* d, const double* e,\n                    double* anorm, double* rcond, double* work,\n                    lapack_int *info );\nvoid LAPACK_cptcon( lapack_int* n, const float* d,\n                    const lapack_complex_float* e, float* anorm, float* rcond,\n                    float* work, lapack_int *info );\nvoid LAPACK_zptcon( lapack_int* n, const double* d,\n                    const lapack_complex_double* e, double* anorm,\n                    double* rcond, double* work, lapack_int *info );\nvoid LAPACK_ssycon( char* uplo, lapack_int* n, const float* a, lapack_int* lda,\n                    const lapack_int* ipiv, float* anorm, float* rcond,\n                    float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dsycon( char* uplo, lapack_int* n, const double* a, lapack_int* lda,\n                    const lapack_int* ipiv, double* anorm, double* rcond,\n                    double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_csycon( char* uplo, lapack_int* n, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_int* ipiv, float* anorm,\n                    float* rcond, lapack_complex_float* work,\n                    lapack_int *info );\nvoid LAPACK_zsycon( char* uplo, lapack_int* n, const lapack_complex_double* a,\n                    lapack_int* lda, const lapack_int* ipiv, double* anorm,\n                    double* rcond, lapack_complex_double* work,\n                    lapack_int *info );\nvoid LAPACK_checon( char* uplo, lapack_int* n, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_int* ipiv, float* anorm,\n                    float* rcond, lapack_complex_float* work,\n                    lapack_int *info );\nvoid LAPACK_zhecon( char* uplo, lapack_int* n, const lapack_complex_double* a,\n                    lapack_int* lda, const lapack_int* ipiv, double* anorm,\n                    double* rcond, lapack_complex_double* work,\n                    lapack_int *info );\nvoid LAPACK_sspcon( char* uplo, lapack_int* n, const float* ap,\n                    const lapack_int* ipiv, float* anorm, float* rcond,\n                    float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dspcon( char* uplo, lapack_int* n, const double* ap,\n                    const lapack_int* ipiv, double* anorm, double* rcond,\n                    double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cspcon( char* uplo, lapack_int* n, const lapack_complex_float* ap,\n                    const lapack_int* ipiv, float* anorm, float* rcond,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zspcon( char* uplo, lapack_int* n, const lapack_complex_double* ap,\n                    const lapack_int* ipiv, double* anorm, double* rcond,\n                    lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_chpcon( char* uplo, lapack_int* n, const lapack_complex_float* ap,\n                    const lapack_int* ipiv, float* anorm, float* rcond,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zhpcon( char* uplo, lapack_int* n, const lapack_complex_double* ap,\n                    const lapack_int* ipiv, double* anorm, double* rcond,\n                    lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_strcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    const float* a, lapack_int* lda, float* rcond, float* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dtrcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    const double* a, lapack_int* lda, double* rcond,\n                    double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_ctrcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    float* rcond, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_ztrcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    double* rcond, lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_stpcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    const float* ap, float* rcond, float* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dtpcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    const double* ap, double* rcond, double* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_ctpcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    const lapack_complex_float* ap, float* rcond,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_ztpcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    const lapack_complex_double* ap, double* rcond,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_stbcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    lapack_int* kd, const float* ab, lapack_int* ldab,\n                    float* rcond, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dtbcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    lapack_int* kd, const double* ab, lapack_int* ldab,\n                    double* rcond, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_ctbcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    lapack_int* kd, const lapack_complex_float* ab,\n                    lapack_int* ldab, float* rcond, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_ztbcon( char* norm, char* uplo, char* diag, lapack_int* n,\n                    lapack_int* kd, const lapack_complex_double* ab,\n                    lapack_int* ldab, double* rcond,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_sgerfs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const float* a, lapack_int* lda, const float* af,\n                    lapack_int* ldaf, const lapack_int* ipiv, const float* b,\n                    lapack_int* ldb, float* x, lapack_int* ldx, float* ferr,\n                    float* berr, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dgerfs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const double* a, lapack_int* lda, const double* af,\n                    lapack_int* ldaf, const lapack_int* ipiv, const double* b,\n                    lapack_int* ldb, double* x, lapack_int* ldx, double* ferr,\n                    double* berr, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_cgerfs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* af, lapack_int* ldaf,\n                    const lapack_int* ipiv, const lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx,\n                    float* ferr, float* berr, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_zgerfs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* af, lapack_int* ldaf,\n                    const lapack_int* ipiv, const lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx,\n                    double* ferr, double* berr, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_dgerfsx( char* trans, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const double* a, lapack_int* lda, const double* af,\n                     lapack_int* ldaf, const lapack_int* ipiv, const double* r,\n                     const double* c, const double* b, lapack_int* ldb,\n                     double* x, lapack_int* ldx, double* rcond, double* berr,\n                     lapack_int* n_err_bnds, double* err_bnds_norm,\n                     double* err_bnds_comp, lapack_int* nparams, double* params,\n                     double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_sgerfsx( char* trans, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const float* a, lapack_int* lda, const float* af,\n                     lapack_int* ldaf, const lapack_int* ipiv, const float* r,\n                     const float* c, const float* b, lapack_int* ldb, float* x,\n                     lapack_int* ldx, float* rcond, float* berr,\n                     lapack_int* n_err_bnds, float* err_bnds_norm,\n                     float* err_bnds_comp, lapack_int* nparams, float* params,\n                     float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_zgerfsx( char* trans, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const lapack_complex_double* a, lapack_int* lda,\n                     const lapack_complex_double* af, lapack_int* ldaf,\n                     const lapack_int* ipiv, const double* r, const double* c,\n                     const lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                     double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params,\n                     lapack_complex_double* work, double* rwork,\n                     lapack_int *info );\nvoid LAPACK_cgerfsx( char* trans, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const lapack_complex_float* a, lapack_int* lda,\n                     const lapack_complex_float* af, lapack_int* ldaf,\n                     const lapack_int* ipiv, const float* r, const float* c,\n                     const lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                     float* berr, lapack_int* n_err_bnds, float* err_bnds_norm,\n                     float* err_bnds_comp, lapack_int* nparams, float* params,\n                     lapack_complex_float* work, float* rwork,\n                     lapack_int *info );\nvoid LAPACK_sgbrfs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    lapack_int* nrhs, const float* ab, lapack_int* ldab,\n                    const float* afb, lapack_int* ldafb, const lapack_int* ipiv,\n                    const float* b, lapack_int* ldb, float* x, lapack_int* ldx,\n                    float* ferr, float* berr, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dgbrfs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    lapack_int* nrhs, const double* ab, lapack_int* ldab,\n                    const double* afb, lapack_int* ldafb,\n                    const lapack_int* ipiv, const double* b, lapack_int* ldb,\n                    double* x, lapack_int* ldx, double* ferr, double* berr,\n                    double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cgbrfs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    lapack_int* nrhs, const lapack_complex_float* ab,\n                    lapack_int* ldab, const lapack_complex_float* afb,\n                    lapack_int* ldafb, const lapack_int* ipiv,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* ferr,\n                    float* berr, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zgbrfs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku,\n                    lapack_int* nrhs, const lapack_complex_double* ab,\n                    lapack_int* ldab, const lapack_complex_double* afb,\n                    lapack_int* ldafb, const lapack_int* ipiv,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* ferr,\n                    double* berr, lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_dgbrfsx( char* trans, char* equed, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, lapack_int* nrhs, const double* ab,\n                     lapack_int* ldab, const double* afb, lapack_int* ldafb,\n                     const lapack_int* ipiv, const double* r, const double* c,\n                     const double* b, lapack_int* ldb, double* x,\n                     lapack_int* ldx, double* rcond, double* berr,\n                     lapack_int* n_err_bnds, double* err_bnds_norm,\n                     double* err_bnds_comp, lapack_int* nparams, double* params,\n                     double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_sgbrfsx( char* trans, char* equed, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, lapack_int* nrhs, const float* ab,\n                     lapack_int* ldab, const float* afb, lapack_int* ldafb,\n                     const lapack_int* ipiv, const float* r, const float* c,\n                     const float* b, lapack_int* ldb, float* x, lapack_int* ldx,\n                     float* rcond, float* berr, lapack_int* n_err_bnds,\n                     float* err_bnds_norm, float* err_bnds_comp,\n                     lapack_int* nparams, float* params, float* work,\n                     lapack_int* iwork, lapack_int *info );\nvoid LAPACK_zgbrfsx( char* trans, char* equed, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, lapack_int* nrhs,\n                     const lapack_complex_double* ab, lapack_int* ldab,\n                     const lapack_complex_double* afb, lapack_int* ldafb,\n                     const lapack_int* ipiv, const double* r, const double* c,\n                     const lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                     double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params,\n                     lapack_complex_double* work, double* rwork,\n                     lapack_int *info );\nvoid LAPACK_cgbrfsx( char* trans, char* equed, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, lapack_int* nrhs,\n                     const lapack_complex_float* ab, lapack_int* ldab,\n                     const lapack_complex_float* afb, lapack_int* ldafb,\n                     const lapack_int* ipiv, const float* r, const float* c,\n                     const lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                     float* berr, lapack_int* n_err_bnds, float* err_bnds_norm,\n                     float* err_bnds_comp, lapack_int* nparams, float* params,\n                     lapack_complex_float* work, float* rwork,\n                     lapack_int *info );\nvoid LAPACK_sgtrfs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const float* dl, const float* d, const float* du,\n                    const float* dlf, const float* df, const float* duf,\n                    const float* du2, const lapack_int* ipiv, const float* b,\n                    lapack_int* ldb, float* x, lapack_int* ldx, float* ferr,\n                    float* berr, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dgtrfs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const double* dl, const double* d, const double* du,\n                    const double* dlf, const double* df, const double* duf,\n                    const double* du2, const lapack_int* ipiv, const double* b,\n                    lapack_int* ldb, double* x, lapack_int* ldx, double* ferr,\n                    double* berr, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_cgtrfs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* dl,\n                    const lapack_complex_float* d,\n                    const lapack_complex_float* du,\n                    const lapack_complex_float* dlf,\n                    const lapack_complex_float* df,\n                    const lapack_complex_float* duf,\n                    const lapack_complex_float* du2, const lapack_int* ipiv,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* ferr,\n                    float* berr, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zgtrfs( char* trans, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* dl,\n                    const lapack_complex_double* d,\n                    const lapack_complex_double* du,\n                    const lapack_complex_double* dlf,\n                    const lapack_complex_double* df,\n                    const lapack_complex_double* duf,\n                    const lapack_complex_double* du2, const lapack_int* ipiv,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* ferr,\n                    double* berr, lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_sporfs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* a,\n                    lapack_int* lda, const float* af, lapack_int* ldaf,\n                    const float* b, lapack_int* ldb, float* x, lapack_int* ldx,\n                    float* ferr, float* berr, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dporfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* a, lapack_int* lda, const double* af,\n                    lapack_int* ldaf, const double* b, lapack_int* ldb,\n                    double* x, lapack_int* ldx, double* ferr, double* berr,\n                    double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cporfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* af, lapack_int* ldaf,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* ferr,\n                    float* berr, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zporfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* af, lapack_int* ldaf,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* ferr,\n                    double* berr, lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_dporfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const double* a, lapack_int* lda, const double* af,\n                     lapack_int* ldaf, const double* s, const double* b,\n                     lapack_int* ldb, double* x, lapack_int* ldx, double* rcond,\n                     double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params, double* work,\n                     lapack_int* iwork, lapack_int *info );\nvoid LAPACK_sporfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const float* a, lapack_int* lda, const float* af,\n                     lapack_int* ldaf, const float* s, const float* b,\n                     lapack_int* ldb, float* x, lapack_int* ldx, float* rcond,\n                     float* berr, lapack_int* n_err_bnds, float* err_bnds_norm,\n                     float* err_bnds_comp, lapack_int* nparams, float* params,\n                     float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_zporfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const lapack_complex_double* a, lapack_int* lda,\n                     const lapack_complex_double* af, lapack_int* ldaf,\n                     const double* s, const lapack_complex_double* b,\n                     lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx,\n                     double* rcond, double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params,\n                     lapack_complex_double* work, double* rwork,\n                     lapack_int *info );\nvoid LAPACK_cporfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const lapack_complex_float* a, lapack_int* lda,\n                     const lapack_complex_float* af, lapack_int* ldaf,\n                     const float* s, const lapack_complex_float* b,\n                     lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx,\n                     float* rcond, float* berr, lapack_int* n_err_bnds,\n                     float* err_bnds_norm, float* err_bnds_comp,\n                     lapack_int* nparams, float* params,\n                     lapack_complex_float* work, float* rwork,\n                     lapack_int *info );\nvoid LAPACK_spprfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const float* ap, const float* afp, const float* b,\n                    lapack_int* ldb, float* x, lapack_int* ldx, float* ferr,\n                    float* berr, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dpprfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* ap, const double* afp, const double* b,\n                    lapack_int* ldb, double* x, lapack_int* ldx, double* ferr,\n                    double* berr, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_cpprfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* ap,\n                    const lapack_complex_float* afp,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* ferr,\n                    float* berr, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zpprfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* ap,\n                    const lapack_complex_double* afp,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* ferr,\n                    double* berr, lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_spbrfs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                    const float* ab, lapack_int* ldab, const float* afb,\n                    lapack_int* ldafb, const float* b, lapack_int* ldb,\n                    float* x, lapack_int* ldx, float* ferr, float* berr,\n                    float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dpbrfs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                    const double* ab, lapack_int* ldab, const double* afb,\n                    lapack_int* ldafb, const double* b, lapack_int* ldb,\n                    double* x, lapack_int* ldx, double* ferr, double* berr,\n                    double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cpbrfs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                    const lapack_complex_float* ab, lapack_int* ldab,\n                    const lapack_complex_float* afb, lapack_int* ldafb,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* ferr,\n                    float* berr, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zpbrfs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                    const lapack_complex_double* ab, lapack_int* ldab,\n                    const lapack_complex_double* afb, lapack_int* ldafb,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* ferr,\n                    double* berr, lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_sptrfs( lapack_int* n, lapack_int* nrhs, const float* d,\n                    const float* e, const float* df, const float* ef,\n                    const float* b, lapack_int* ldb, float* x, lapack_int* ldx,\n                    float* ferr, float* berr, float* work, lapack_int *info );\nvoid LAPACK_dptrfs( lapack_int* n, lapack_int* nrhs, const double* d,\n                    const double* e, const double* df, const double* ef,\n                    const double* b, lapack_int* ldb, double* x,\n                    lapack_int* ldx, double* ferr, double* berr, double* work,\n                    lapack_int *info );\nvoid LAPACK_cptrfs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* d,\n                    const lapack_complex_float* e, const float* df,\n                    const lapack_complex_float* ef,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* ferr,\n                    float* berr, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zptrfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* d, const lapack_complex_double* e,\n                    const double* df, const lapack_complex_double* ef,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* ferr,\n                    double* berr, lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_ssyrfs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* a,\n                    lapack_int* lda, const float* af, lapack_int* ldaf,\n                    const lapack_int* ipiv, const float* b, lapack_int* ldb,\n                    float* x, lapack_int* ldx, float* ferr, float* berr,\n                    float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dsyrfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* a, lapack_int* lda, const double* af,\n                    lapack_int* ldaf, const lapack_int* ipiv, const double* b,\n                    lapack_int* ldb, double* x, lapack_int* ldx, double* ferr,\n                    double* berr, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_csyrfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* af, lapack_int* ldaf,\n                    const lapack_int* ipiv, const lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx,\n                    float* ferr, float* berr, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_zsyrfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* af, lapack_int* ldaf,\n                    const lapack_int* ipiv, const lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx,\n                    double* ferr, double* berr, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_dsyrfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const double* a, lapack_int* lda, const double* af,\n                     lapack_int* ldaf, const lapack_int* ipiv, const double* s,\n                     const double* b, lapack_int* ldb, double* x,\n                     lapack_int* ldx, double* rcond, double* berr,\n                     lapack_int* n_err_bnds, double* err_bnds_norm,\n                     double* err_bnds_comp, lapack_int* nparams, double* params,\n                     double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_ssyrfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const float* a, lapack_int* lda, const float* af,\n                     lapack_int* ldaf, const lapack_int* ipiv, const float* s,\n                     const float* b, lapack_int* ldb, float* x, lapack_int* ldx,\n                     float* rcond, float* berr, lapack_int* n_err_bnds,\n                     float* err_bnds_norm, float* err_bnds_comp,\n                     lapack_int* nparams, float* params, float* work,\n                     lapack_int* iwork, lapack_int *info );\nvoid LAPACK_zsyrfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const lapack_complex_double* a, lapack_int* lda,\n                     const lapack_complex_double* af, lapack_int* ldaf,\n                     const lapack_int* ipiv, const double* s,\n                     const lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                     double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params,\n                     lapack_complex_double* work, double* rwork,\n                     lapack_int *info );\nvoid LAPACK_csyrfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const lapack_complex_float* a, lapack_int* lda,\n                     const lapack_complex_float* af, lapack_int* ldaf,\n                     const lapack_int* ipiv, const float* s,\n                     const lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                     float* berr, lapack_int* n_err_bnds, float* err_bnds_norm,\n                     float* err_bnds_comp, lapack_int* nparams, float* params,\n                     lapack_complex_float* work, float* rwork,\n                     lapack_int *info );\nvoid LAPACK_cherfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* af, lapack_int* ldaf,\n                    const lapack_int* ipiv, const lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx,\n                    float* ferr, float* berr, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_zherfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* af, lapack_int* ldaf,\n                    const lapack_int* ipiv, const lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx,\n                    double* ferr, double* berr, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_zherfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const lapack_complex_double* a, lapack_int* lda,\n                     const lapack_complex_double* af, lapack_int* ldaf,\n                     const lapack_int* ipiv, const double* s,\n                     const lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                     double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params,\n                     lapack_complex_double* work, double* rwork,\n                     lapack_int *info );\nvoid LAPACK_cherfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs,\n                     const lapack_complex_float* a, lapack_int* lda,\n                     const lapack_complex_float* af, lapack_int* ldaf,\n                     const lapack_int* ipiv, const float* s,\n                     const lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                     float* berr, lapack_int* n_err_bnds, float* err_bnds_norm,\n                     float* err_bnds_comp, lapack_int* nparams, float* params,\n                     lapack_complex_float* work, float* rwork,\n                     lapack_int *info );\nvoid LAPACK_ssprfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const float* ap, const float* afp, const lapack_int* ipiv,\n                    const float* b, lapack_int* ldb, float* x, lapack_int* ldx,\n                    float* ferr, float* berr, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dsprfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* ap, const double* afp, const lapack_int* ipiv,\n                    const double* b, lapack_int* ldb, double* x,\n                    lapack_int* ldx, double* ferr, double* berr, double* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_csprfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* ap,\n                    const lapack_complex_float* afp, const lapack_int* ipiv,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* ferr,\n                    float* berr, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zsprfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* ap,\n                    const lapack_complex_double* afp, const lapack_int* ipiv,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* ferr,\n                    double* berr, lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_chprfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* ap,\n                    const lapack_complex_float* afp, const lapack_int* ipiv,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* ferr,\n                    float* berr, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zhprfs( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* ap,\n                    const lapack_complex_double* afp, const lapack_int* ipiv,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* ferr,\n                    double* berr, lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_strrfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const float* a, lapack_int* lda,\n                    const float* b, lapack_int* ldb, const float* x,\n                    lapack_int* ldx, float* ferr, float* berr, float* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dtrrfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const double* a, lapack_int* lda,\n                    const double* b, lapack_int* ldb, const double* x,\n                    lapack_int* ldx, double* ferr, double* berr, double* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_ctrrfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_complex_float* b,\n                    lapack_int* ldb, const lapack_complex_float* x,\n                    lapack_int* ldx, float* ferr, float* berr,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_ztrrfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const lapack_complex_double* a,\n                    lapack_int* lda, const lapack_complex_double* b,\n                    lapack_int* ldb, const lapack_complex_double* x,\n                    lapack_int* ldx, double* ferr, double* berr,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_stprfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const float* ap, const float* b,\n                    lapack_int* ldb, const float* x, lapack_int* ldx,\n                    float* ferr, float* berr, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dtprfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const double* ap, const double* b,\n                    lapack_int* ldb, const double* x, lapack_int* ldx,\n                    double* ferr, double* berr, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_ctprfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const lapack_complex_float* ap,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    const lapack_complex_float* x, lapack_int* ldx, float* ferr,\n                    float* berr, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_ztprfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* nrhs, const lapack_complex_double* ap,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    const lapack_complex_double* x, lapack_int* ldx,\n                    double* ferr, double* berr, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_stbrfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* kd, lapack_int* nrhs, const float* ab,\n                    lapack_int* ldab, const float* b, lapack_int* ldb,\n                    const float* x, lapack_int* ldx, float* ferr, float* berr,\n                    float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dtbrfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* kd, lapack_int* nrhs, const double* ab,\n                    lapack_int* ldab, const double* b, lapack_int* ldb,\n                    const double* x, lapack_int* ldx, double* ferr,\n                    double* berr, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_ctbrfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* kd, lapack_int* nrhs,\n                    const lapack_complex_float* ab, lapack_int* ldab,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    const lapack_complex_float* x, lapack_int* ldx, float* ferr,\n                    float* berr, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_ztbrfs( char* uplo, char* trans, char* diag, lapack_int* n,\n                    lapack_int* kd, lapack_int* nrhs,\n                    const lapack_complex_double* ab, lapack_int* ldab,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    const lapack_complex_double* x, lapack_int* ldx,\n                    double* ferr, double* berr, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_sgetri( lapack_int* n, float* a, lapack_int* lda,\n                    const lapack_int* ipiv, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dgetri( lapack_int* n, double* a, lapack_int* lda,\n                    const lapack_int* ipiv, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cgetri( lapack_int* n, lapack_complex_float* a, lapack_int* lda,\n                    const lapack_int* ipiv, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zgetri( lapack_int* n, lapack_complex_double* a, lapack_int* lda,\n                    const lapack_int* ipiv, lapack_complex_double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_spotri( char* uplo, lapack_int* n, float* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_dpotri( char* uplo, lapack_int* n, double* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_cpotri( char* uplo, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_zpotri( char* uplo, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_dpftri( char* transr, char* uplo, lapack_int* n, double* a,\n                    lapack_int *info );\nvoid LAPACK_spftri( char* transr, char* uplo, lapack_int* n, float* a,\n                    lapack_int *info );\nvoid LAPACK_zpftri( char* transr, char* uplo, lapack_int* n,\n                    lapack_complex_double* a, lapack_int *info );\nvoid LAPACK_cpftri( char* transr, char* uplo, lapack_int* n,\n                    lapack_complex_float* a, lapack_int *info );\nvoid LAPACK_spptri( char* uplo, lapack_int* n, float* ap, lapack_int *info );\nvoid LAPACK_dpptri( char* uplo, lapack_int* n, double* ap, lapack_int *info );\nvoid LAPACK_cpptri( char* uplo, lapack_int* n, lapack_complex_float* ap,\n                    lapack_int *info );\nvoid LAPACK_zpptri( char* uplo, lapack_int* n, lapack_complex_double* ap,\n                    lapack_int *info );\nvoid LAPACK_ssytri( char* uplo, lapack_int* n, float* a, lapack_int* lda,\n                    const lapack_int* ipiv, float* work, lapack_int *info );\nvoid LAPACK_dsytri( char* uplo, lapack_int* n, double* a, lapack_int* lda,\n                    const lapack_int* ipiv, double* work, lapack_int *info );\nvoid LAPACK_csytri( char* uplo, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, const lapack_int* ipiv,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zsytri( char* uplo, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, const lapack_int* ipiv,\n                    lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_chetri( char* uplo, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, const lapack_int* ipiv,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zhetri( char* uplo, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, const lapack_int* ipiv,\n                    lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_ssptri( char* uplo, lapack_int* n, float* ap,\n                    const lapack_int* ipiv, float* work, lapack_int *info );\nvoid LAPACK_dsptri( char* uplo, lapack_int* n, double* ap,\n                    const lapack_int* ipiv, double* work, lapack_int *info );\nvoid LAPACK_csptri( char* uplo, lapack_int* n, lapack_complex_float* ap,\n                    const lapack_int* ipiv, lapack_complex_float* work,\n                    lapack_int *info );\nvoid LAPACK_zsptri( char* uplo, lapack_int* n, lapack_complex_double* ap,\n                    const lapack_int* ipiv, lapack_complex_double* work,\n                    lapack_int *info );\nvoid LAPACK_chptri( char* uplo, lapack_int* n, lapack_complex_float* ap,\n                    const lapack_int* ipiv, lapack_complex_float* work,\n                    lapack_int *info );\nvoid LAPACK_zhptri( char* uplo, lapack_int* n, lapack_complex_double* ap,\n                    const lapack_int* ipiv, lapack_complex_double* work,\n                    lapack_int *info );\nvoid LAPACK_strtri( char* uplo, char* diag, lapack_int* n, float* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_dtrtri( char* uplo, char* diag, lapack_int* n, double* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_ctrtri( char* uplo, char* diag, lapack_int* n,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_ztrtri( char* uplo, char* diag, lapack_int* n,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_dtftri( char* transr, char* uplo, char* diag, lapack_int* n,\n                    double* a, lapack_int *info );\nvoid LAPACK_stftri( char* transr, char* uplo, char* diag, lapack_int* n,\n                    float* a, lapack_int *info );\nvoid LAPACK_ztftri( char* transr, char* uplo, char* diag, lapack_int* n,\n                    lapack_complex_double* a, lapack_int *info );\nvoid LAPACK_ctftri( char* transr, char* uplo, char* diag, lapack_int* n,\n                    lapack_complex_float* a, lapack_int *info );\nvoid LAPACK_stptri( char* uplo, char* diag, lapack_int* n, float* ap,\n                    lapack_int *info );\nvoid LAPACK_dtptri( char* uplo, char* diag, lapack_int* n, double* ap,\n                    lapack_int *info );\nvoid LAPACK_ctptri( char* uplo, char* diag, lapack_int* n,\n                    lapack_complex_float* ap, lapack_int *info );\nvoid LAPACK_ztptri( char* uplo, char* diag, lapack_int* n,\n                    lapack_complex_double* ap, lapack_int *info );\nvoid LAPACK_sgeequ( lapack_int* m, lapack_int* n, const float* a,\n                    lapack_int* lda, float* r, float* c, float* rowcnd,\n                    float* colcnd, float* amax, lapack_int *info );\nvoid LAPACK_dgeequ( lapack_int* m, lapack_int* n, const double* a,\n                    lapack_int* lda, double* r, double* c, double* rowcnd,\n                    double* colcnd, double* amax, lapack_int *info );\nvoid LAPACK_cgeequ( lapack_int* m, lapack_int* n, const lapack_complex_float* a,\n                    lapack_int* lda, float* r, float* c, float* rowcnd,\n                    float* colcnd, float* amax, lapack_int *info );\nvoid LAPACK_zgeequ( lapack_int* m, lapack_int* n,\n                    const lapack_complex_double* a, lapack_int* lda, double* r,\n                    double* c, double* rowcnd, double* colcnd, double* amax,\n                    lapack_int *info );\nvoid LAPACK_dgeequb( lapack_int* m, lapack_int* n, const double* a,\n                     lapack_int* lda, double* r, double* c, double* rowcnd,\n                     double* colcnd, double* amax, lapack_int *info );\nvoid LAPACK_sgeequb( lapack_int* m, lapack_int* n, const float* a,\n                     lapack_int* lda, float* r, float* c, float* rowcnd,\n                     float* colcnd, float* amax, lapack_int *info );\nvoid LAPACK_zgeequb( lapack_int* m, lapack_int* n,\n                     const lapack_complex_double* a, lapack_int* lda, double* r,\n                     double* c, double* rowcnd, double* colcnd, double* amax,\n                     lapack_int *info );\nvoid LAPACK_cgeequb( lapack_int* m, lapack_int* n,\n                     const lapack_complex_float* a, lapack_int* lda, float* r,\n                     float* c, float* rowcnd, float* colcnd, float* amax,\n                     lapack_int *info );\nvoid LAPACK_sgbequ( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, const float* ab, lapack_int* ldab, float* r,\n                    float* c, float* rowcnd, float* colcnd, float* amax,\n                    lapack_int *info );\nvoid LAPACK_dgbequ( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, const double* ab, lapack_int* ldab,\n                    double* r, double* c, double* rowcnd, double* colcnd,\n                    double* amax, lapack_int *info );\nvoid LAPACK_cgbequ( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, const lapack_complex_float* ab,\n                    lapack_int* ldab, float* r, float* c, float* rowcnd,\n                    float* colcnd, float* amax, lapack_int *info );\nvoid LAPACK_zgbequ( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, const lapack_complex_double* ab,\n                    lapack_int* ldab, double* r, double* c, double* rowcnd,\n                    double* colcnd, double* amax, lapack_int *info );\nvoid LAPACK_dgbequb( lapack_int* m, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, const double* ab, lapack_int* ldab,\n                     double* r, double* c, double* rowcnd, double* colcnd,\n                     double* amax, lapack_int *info );\nvoid LAPACK_sgbequb( lapack_int* m, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, const float* ab, lapack_int* ldab,\n                     float* r, float* c, float* rowcnd, float* colcnd,\n                     float* amax, lapack_int *info );\nvoid LAPACK_zgbequb( lapack_int* m, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, const lapack_complex_double* ab,\n                     lapack_int* ldab, double* r, double* c, double* rowcnd,\n                     double* colcnd, double* amax, lapack_int *info );\nvoid LAPACK_cgbequb( lapack_int* m, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, const lapack_complex_float* ab,\n                     lapack_int* ldab, float* r, float* c, float* rowcnd,\n                     float* colcnd, float* amax, lapack_int *info );\nvoid LAPACK_spoequ( lapack_int* n, const float* a, lapack_int* lda, float* s,\n                    float* scond, float* amax, lapack_int *info );\nvoid LAPACK_dpoequ( lapack_int* n, const double* a, lapack_int* lda, double* s,\n                    double* scond, double* amax, lapack_int *info );\nvoid LAPACK_cpoequ( lapack_int* n, const lapack_complex_float* a,\n                    lapack_int* lda, float* s, float* scond, float* amax,\n                    lapack_int *info );\nvoid LAPACK_zpoequ( lapack_int* n, const lapack_complex_double* a,\n                    lapack_int* lda, double* s, double* scond, double* amax,\n                    lapack_int *info );\nvoid LAPACK_dpoequb( lapack_int* n, const double* a, lapack_int* lda, double* s,\n                     double* scond, double* amax, lapack_int *info );\nvoid LAPACK_spoequb( lapack_int* n, const float* a, lapack_int* lda, float* s,\n                     float* scond, float* amax, lapack_int *info );\nvoid LAPACK_zpoequb( lapack_int* n, const lapack_complex_double* a,\n                     lapack_int* lda, double* s, double* scond, double* amax,\n                     lapack_int *info );\nvoid LAPACK_cpoequb( lapack_int* n, const lapack_complex_float* a,\n                     lapack_int* lda, float* s, float* scond, float* amax,\n                     lapack_int *info );\nvoid LAPACK_sppequ( char* uplo, lapack_int* n, const float* ap, float* s,\n                    float* scond, float* amax, lapack_int *info );\nvoid LAPACK_dppequ( char* uplo, lapack_int* n, const double* ap, double* s,\n                    double* scond, double* amax, lapack_int *info );\nvoid LAPACK_cppequ( char* uplo, lapack_int* n, const lapack_complex_float* ap,\n                    float* s, float* scond, float* amax, lapack_int *info );\nvoid LAPACK_zppequ( char* uplo, lapack_int* n, const lapack_complex_double* ap,\n                    double* s, double* scond, double* amax, lapack_int *info );\nvoid LAPACK_spbequ( char* uplo, lapack_int* n, lapack_int* kd, const float* ab,\n                    lapack_int* ldab, float* s, float* scond, float* amax,\n                    lapack_int *info );\nvoid LAPACK_dpbequ( char* uplo, lapack_int* n, lapack_int* kd, const double* ab,\n                    lapack_int* ldab, double* s, double* scond, double* amax,\n                    lapack_int *info );\nvoid LAPACK_cpbequ( char* uplo, lapack_int* n, lapack_int* kd,\n                    const lapack_complex_float* ab, lapack_int* ldab, float* s,\n                    float* scond, float* amax, lapack_int *info );\nvoid LAPACK_zpbequ( char* uplo, lapack_int* n, lapack_int* kd,\n                    const lapack_complex_double* ab, lapack_int* ldab,\n                    double* s, double* scond, double* amax, lapack_int *info );\nvoid LAPACK_dsyequb( char* uplo, lapack_int* n, const double* a,\n                     lapack_int* lda, double* s, double* scond, double* amax,\n                     double* work, lapack_int *info );\nvoid LAPACK_ssyequb( char* uplo, lapack_int* n, const float* a, lapack_int* lda,\n                     float* s, float* scond, float* amax, float* work,\n                     lapack_int *info );\nvoid LAPACK_zsyequb( char* uplo, lapack_int* n, const lapack_complex_double* a,\n                     lapack_int* lda, double* s, double* scond, double* amax,\n                     lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_csyequb( char* uplo, lapack_int* n, const lapack_complex_float* a,\n                     lapack_int* lda, float* s, float* scond, float* amax,\n                     lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zheequb( char* uplo, lapack_int* n, const lapack_complex_double* a,\n                     lapack_int* lda, double* s, double* scond, double* amax,\n                     lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_cheequb( char* uplo, lapack_int* n, const lapack_complex_float* a,\n                     lapack_int* lda, float* s, float* scond, float* amax,\n                     lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_sgesv( lapack_int* n, lapack_int* nrhs, float* a, lapack_int* lda,\n                   lapack_int* ipiv, float* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_dgesv( lapack_int* n, lapack_int* nrhs, double* a, lapack_int* lda,\n                   lapack_int* ipiv, double* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_cgesv( lapack_int* n, lapack_int* nrhs, lapack_complex_float* a,\n                   lapack_int* lda, lapack_int* ipiv, lapack_complex_float* b,\n                   lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zgesv( lapack_int* n, lapack_int* nrhs, lapack_complex_double* a,\n                   lapack_int* lda, lapack_int* ipiv, lapack_complex_double* b,\n                   lapack_int* ldb, lapack_int *info );\nvoid LAPACK_dsgesv( lapack_int* n, lapack_int* nrhs, double* a, lapack_int* lda,\n                    lapack_int* ipiv, double* b, lapack_int* ldb, double* x,\n                    lapack_int* ldx, double* work, float* swork,\n                    lapack_int* iter, lapack_int *info );\nvoid LAPACK_zcgesv( lapack_int* n, lapack_int* nrhs, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int* ipiv, lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx,\n                    lapack_complex_double* work, lapack_complex_float* swork,\n                    double* rwork, lapack_int* iter, lapack_int *info );\nvoid LAPACK_sgesvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                    float* a, lapack_int* lda, float* af, lapack_int* ldaf,\n                    lapack_int* ipiv, char* equed, float* r, float* c, float* b,\n                    lapack_int* ldb, float* x, lapack_int* ldx, float* rcond,\n                    float* ferr, float* berr, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dgesvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                    double* a, lapack_int* lda, double* af, lapack_int* ldaf,\n                    lapack_int* ipiv, char* equed, double* r, double* c,\n                    double* b, lapack_int* ldb, double* x, lapack_int* ldx,\n                    double* rcond, double* ferr, double* berr, double* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cgesvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* af, lapack_int* ldaf,\n                    lapack_int* ipiv, char* equed, float* r, float* c,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                    float* ferr, float* berr, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_zgesvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* af, lapack_int* ldaf,\n                    lapack_int* ipiv, char* equed, double* r, double* c,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                    double* ferr, double* berr, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_dgesvxx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                     double* a, lapack_int* lda, double* af, lapack_int* ldaf,\n                     lapack_int* ipiv, char* equed, double* r, double* c,\n                     double* b, lapack_int* ldb, double* x, lapack_int* ldx,\n                     double* rcond, double* rpvgrw, double* berr,\n                     lapack_int* n_err_bnds, double* err_bnds_norm,\n                     double* err_bnds_comp, lapack_int* nparams, double* params,\n                     double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_sgesvxx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                     float* a, lapack_int* lda, float* af, lapack_int* ldaf,\n                     lapack_int* ipiv, char* equed, float* r, float* c,\n                     float* b, lapack_int* ldb, float* x, lapack_int* ldx,\n                     float* rcond, float* rpvgrw, float* berr,\n                     lapack_int* n_err_bnds, float* err_bnds_norm,\n                     float* err_bnds_comp, lapack_int* nparams, float* params,\n                     float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_zgesvxx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                     lapack_complex_double* a, lapack_int* lda,\n                     lapack_complex_double* af, lapack_int* ldaf,\n                     lapack_int* ipiv, char* equed, double* r, double* c,\n                     lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                     double* rpvgrw, double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params,\n                     lapack_complex_double* work, double* rwork,\n                     lapack_int *info );\nvoid LAPACK_cgesvxx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                     lapack_complex_float* a, lapack_int* lda,\n                     lapack_complex_float* af, lapack_int* ldaf,\n                     lapack_int* ipiv, char* equed, float* r, float* c,\n                     lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                     float* rpvgrw, float* berr, lapack_int* n_err_bnds,\n                     float* err_bnds_norm, float* err_bnds_comp,\n                     lapack_int* nparams, float* params,\n                     lapack_complex_float* work, float* rwork,\n                     lapack_int *info );\nvoid LAPACK_sgbsv( lapack_int* n, lapack_int* kl, lapack_int* ku,\n                   lapack_int* nrhs, float* ab, lapack_int* ldab,\n                   lapack_int* ipiv, float* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_dgbsv( lapack_int* n, lapack_int* kl, lapack_int* ku,\n                   lapack_int* nrhs, double* ab, lapack_int* ldab,\n                   lapack_int* ipiv, double* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_cgbsv( lapack_int* n, lapack_int* kl, lapack_int* ku,\n                   lapack_int* nrhs, lapack_complex_float* ab, lapack_int* ldab,\n                   lapack_int* ipiv, lapack_complex_float* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_zgbsv( lapack_int* n, lapack_int* kl, lapack_int* ku,\n                   lapack_int* nrhs, lapack_complex_double* ab,\n                   lapack_int* ldab, lapack_int* ipiv, lapack_complex_double* b,\n                   lapack_int* ldb, lapack_int *info );\nvoid LAPACK_sgbsvx( char* fact, char* trans, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, lapack_int* nrhs, float* ab,\n                    lapack_int* ldab, float* afb, lapack_int* ldafb,\n                    lapack_int* ipiv, char* equed, float* r, float* c, float* b,\n                    lapack_int* ldb, float* x, lapack_int* ldx, float* rcond,\n                    float* ferr, float* berr, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dgbsvx( char* fact, char* trans, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, lapack_int* nrhs, double* ab,\n                    lapack_int* ldab, double* afb, lapack_int* ldafb,\n                    lapack_int* ipiv, char* equed, double* r, double* c,\n                    double* b, lapack_int* ldb, double* x, lapack_int* ldx,\n                    double* rcond, double* ferr, double* berr, double* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cgbsvx( char* fact, char* trans, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, lapack_int* nrhs, lapack_complex_float* ab,\n                    lapack_int* ldab, lapack_complex_float* afb,\n                    lapack_int* ldafb, lapack_int* ipiv, char* equed, float* r,\n                    float* c, lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                    float* ferr, float* berr, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_zgbsvx( char* fact, char* trans, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, lapack_int* nrhs, lapack_complex_double* ab,\n                    lapack_int* ldab, lapack_complex_double* afb,\n                    lapack_int* ldafb, lapack_int* ipiv, char* equed, double* r,\n                    double* c, lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                    double* ferr, double* berr, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_dgbsvxx( char* fact, char* trans, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, lapack_int* nrhs, double* ab,\n                     lapack_int* ldab, double* afb, lapack_int* ldafb,\n                     lapack_int* ipiv, char* equed, double* r, double* c,\n                     double* b, lapack_int* ldb, double* x, lapack_int* ldx,\n                     double* rcond, double* rpvgrw, double* berr,\n                     lapack_int* n_err_bnds, double* err_bnds_norm,\n                     double* err_bnds_comp, lapack_int* nparams, double* params,\n                     double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_sgbsvxx( char* fact, char* trans, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, lapack_int* nrhs, float* ab,\n                     lapack_int* ldab, float* afb, lapack_int* ldafb,\n                     lapack_int* ipiv, char* equed, float* r, float* c,\n                     float* b, lapack_int* ldb, float* x, lapack_int* ldx,\n                     float* rcond, float* rpvgrw, float* berr,\n                     lapack_int* n_err_bnds, float* err_bnds_norm,\n                     float* err_bnds_comp, lapack_int* nparams, float* params,\n                     float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_zgbsvxx( char* fact, char* trans, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, lapack_int* nrhs,\n                     lapack_complex_double* ab, lapack_int* ldab,\n                     lapack_complex_double* afb, lapack_int* ldafb,\n                     lapack_int* ipiv, char* equed, double* r, double* c,\n                     lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                     double* rpvgrw, double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params,\n                     lapack_complex_double* work, double* rwork,\n                     lapack_int *info );\nvoid LAPACK_cgbsvxx( char* fact, char* trans, lapack_int* n, lapack_int* kl,\n                     lapack_int* ku, lapack_int* nrhs, lapack_complex_float* ab,\n                     lapack_int* ldab, lapack_complex_float* afb,\n                     lapack_int* ldafb, lapack_int* ipiv, char* equed, float* r,\n                     float* c, lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                     float* rpvgrw, float* berr, lapack_int* n_err_bnds,\n                     float* err_bnds_norm, float* err_bnds_comp,\n                     lapack_int* nparams, float* params,\n                     lapack_complex_float* work, float* rwork,\n                     lapack_int *info );\nvoid LAPACK_sgtsv( lapack_int* n, lapack_int* nrhs, float* dl, float* d,\n                   float* du, float* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_dgtsv( lapack_int* n, lapack_int* nrhs, double* dl, double* d,\n                   double* du, double* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_cgtsv( lapack_int* n, lapack_int* nrhs, lapack_complex_float* dl,\n                   lapack_complex_float* d, lapack_complex_float* du,\n                   lapack_complex_float* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zgtsv( lapack_int* n, lapack_int* nrhs, lapack_complex_double* dl,\n                   lapack_complex_double* d, lapack_complex_double* du,\n                   lapack_complex_double* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_sgtsvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                    const float* dl, const float* d, const float* du,\n                    float* dlf, float* df, float* duf, float* du2,\n                    lapack_int* ipiv, const float* b, lapack_int* ldb, float* x,\n                    lapack_int* ldx, float* rcond, float* ferr, float* berr,\n                    float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dgtsvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                    const double* dl, const double* d, const double* du,\n                    double* dlf, double* df, double* duf, double* du2,\n                    lapack_int* ipiv, const double* b, lapack_int* ldb,\n                    double* x, lapack_int* ldx, double* rcond, double* ferr,\n                    double* berr, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_cgtsvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* dl,\n                    const lapack_complex_float* d,\n                    const lapack_complex_float* du, lapack_complex_float* dlf,\n                    lapack_complex_float* df, lapack_complex_float* duf,\n                    lapack_complex_float* du2, lapack_int* ipiv,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                    float* ferr, float* berr, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_zgtsvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* dl,\n                    const lapack_complex_double* d,\n                    const lapack_complex_double* du, lapack_complex_double* dlf,\n                    lapack_complex_double* df, lapack_complex_double* duf,\n                    lapack_complex_double* du2, lapack_int* ipiv,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                    double* ferr, double* berr, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_sposv( char* uplo, lapack_int* n, lapack_int* nrhs, float* a,\n                   lapack_int* lda, float* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_dposv( char* uplo, lapack_int* n, lapack_int* nrhs, double* a,\n                   lapack_int* lda, double* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_cposv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_float* a, lapack_int* lda,\n                   lapack_complex_float* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zposv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_double* a, lapack_int* lda,\n                   lapack_complex_double* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_dsposv( char* uplo, lapack_int* n, lapack_int* nrhs, double* a,\n                    lapack_int* lda, double* b, lapack_int* ldb, double* x,\n                    lapack_int* ldx, double* work, float* swork,\n                    lapack_int* iter, lapack_int *info );\nvoid LAPACK_zcposv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx,\n                    lapack_complex_double* work, lapack_complex_float* swork,\n                    double* rwork, lapack_int* iter, lapack_int *info );\nvoid LAPACK_sposvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    float* a, lapack_int* lda, float* af, lapack_int* ldaf,\n                    char* equed, float* s, float* b, lapack_int* ldb, float* x,\n                    lapack_int* ldx, float* rcond, float* ferr, float* berr,\n                    float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dposvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    double* a, lapack_int* lda, double* af, lapack_int* ldaf,\n                    char* equed, double* s, double* b, lapack_int* ldb,\n                    double* x, lapack_int* ldx, double* rcond, double* ferr,\n                    double* berr, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_cposvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* af, lapack_int* ldaf, char* equed,\n                    float* s, lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                    float* ferr, float* berr, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_zposvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* af, lapack_int* ldaf, char* equed,\n                    double* s, lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                    double* ferr, double* berr, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_dposvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                     double* a, lapack_int* lda, double* af, lapack_int* ldaf,\n                     char* equed, double* s, double* b, lapack_int* ldb,\n                     double* x, lapack_int* ldx, double* rcond, double* rpvgrw,\n                     double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params, double* work,\n                     lapack_int* iwork, lapack_int *info );\nvoid LAPACK_sposvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                     float* a, lapack_int* lda, float* af, lapack_int* ldaf,\n                     char* equed, float* s, float* b, lapack_int* ldb, float* x,\n                     lapack_int* ldx, float* rcond, float* rpvgrw, float* berr,\n                     lapack_int* n_err_bnds, float* err_bnds_norm,\n                     float* err_bnds_comp, lapack_int* nparams, float* params,\n                     float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_zposvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                     lapack_complex_double* a, lapack_int* lda,\n                     lapack_complex_double* af, lapack_int* ldaf, char* equed,\n                     double* s, lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                     double* rpvgrw, double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params,\n                     lapack_complex_double* work, double* rwork,\n                     lapack_int *info );\nvoid LAPACK_cposvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                     lapack_complex_float* a, lapack_int* lda,\n                     lapack_complex_float* af, lapack_int* ldaf, char* equed,\n                     float* s, lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                     float* rpvgrw, float* berr, lapack_int* n_err_bnds,\n                     float* err_bnds_norm, float* err_bnds_comp,\n                     lapack_int* nparams, float* params,\n                     lapack_complex_float* work, float* rwork,\n                     lapack_int *info );\nvoid LAPACK_sppsv( char* uplo, lapack_int* n, lapack_int* nrhs, float* ap,\n                   float* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_dppsv( char* uplo, lapack_int* n, lapack_int* nrhs, double* ap,\n                   double* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_cppsv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_float* ap, lapack_complex_float* b,\n                   lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zppsv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_double* ap, lapack_complex_double* b,\n                   lapack_int* ldb, lapack_int *info );\nvoid LAPACK_sppsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    float* ap, float* afp, char* equed, float* s, float* b,\n                    lapack_int* ldb, float* x, lapack_int* ldx, float* rcond,\n                    float* ferr, float* berr, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dppsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    double* ap, double* afp, char* equed, double* s, double* b,\n                    lapack_int* ldb, double* x, lapack_int* ldx, double* rcond,\n                    double* ferr, double* berr, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_cppsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_float* ap, lapack_complex_float* afp,\n                    char* equed, float* s, lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx,\n                    float* rcond, float* ferr, float* berr,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zppsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_double* ap, lapack_complex_double* afp,\n                    char* equed, double* s, lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx,\n                    double* rcond, double* ferr, double* berr,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_spbsv( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                   float* ab, lapack_int* ldab, float* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_dpbsv( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                   double* ab, lapack_int* ldab, double* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_cpbsv( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                   lapack_complex_float* ab, lapack_int* ldab,\n                   lapack_complex_float* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zpbsv( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs,\n                   lapack_complex_double* ab, lapack_int* ldab,\n                   lapack_complex_double* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_spbsvx( char* fact, char* uplo, lapack_int* n, lapack_int* kd,\n                    lapack_int* nrhs, float* ab, lapack_int* ldab, float* afb,\n                    lapack_int* ldafb, char* equed, float* s, float* b,\n                    lapack_int* ldb, float* x, lapack_int* ldx, float* rcond,\n                    float* ferr, float* berr, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dpbsvx( char* fact, char* uplo, lapack_int* n, lapack_int* kd,\n                    lapack_int* nrhs, double* ab, lapack_int* ldab, double* afb,\n                    lapack_int* ldafb, char* equed, double* s, double* b,\n                    lapack_int* ldb, double* x, lapack_int* ldx, double* rcond,\n                    double* ferr, double* berr, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_cpbsvx( char* fact, char* uplo, lapack_int* n, lapack_int* kd,\n                    lapack_int* nrhs, lapack_complex_float* ab,\n                    lapack_int* ldab, lapack_complex_float* afb,\n                    lapack_int* ldafb, char* equed, float* s,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                    float* ferr, float* berr, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_zpbsvx( char* fact, char* uplo, lapack_int* n, lapack_int* kd,\n                    lapack_int* nrhs, lapack_complex_double* ab,\n                    lapack_int* ldab, lapack_complex_double* afb,\n                    lapack_int* ldafb, char* equed, double* s,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                    double* ferr, double* berr, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_sptsv( lapack_int* n, lapack_int* nrhs, float* d, float* e,\n                   float* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_dptsv( lapack_int* n, lapack_int* nrhs, double* d, double* e,\n                   double* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_cptsv( lapack_int* n, lapack_int* nrhs, float* d,\n                   lapack_complex_float* e, lapack_complex_float* b,\n                   lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zptsv( lapack_int* n, lapack_int* nrhs, double* d,\n                   lapack_complex_double* e, lapack_complex_double* b,\n                   lapack_int* ldb, lapack_int *info );\nvoid LAPACK_sptsvx( char* fact, lapack_int* n, lapack_int* nrhs, const float* d,\n                    const float* e, float* df, float* ef, const float* b,\n                    lapack_int* ldb, float* x, lapack_int* ldx, float* rcond,\n                    float* ferr, float* berr, float* work, lapack_int *info );\nvoid LAPACK_dptsvx( char* fact, lapack_int* n, lapack_int* nrhs,\n                    const double* d, const double* e, double* df, double* ef,\n                    const double* b, lapack_int* ldb, double* x,\n                    lapack_int* ldx, double* rcond, double* ferr, double* berr,\n                    double* work, lapack_int *info );\nvoid LAPACK_cptsvx( char* fact, lapack_int* n, lapack_int* nrhs, const float* d,\n                    const lapack_complex_float* e, float* df,\n                    lapack_complex_float* ef, const lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx,\n                    float* rcond, float* ferr, float* berr,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zptsvx( char* fact, lapack_int* n, lapack_int* nrhs,\n                    const double* d, const lapack_complex_double* e, double* df,\n                    lapack_complex_double* ef, const lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx,\n                    double* rcond, double* ferr, double* berr,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_ssysv( char* uplo, lapack_int* n, lapack_int* nrhs, float* a,\n                   lapack_int* lda, lapack_int* ipiv, float* b, lapack_int* ldb,\n                   float* work, lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dsysv( char* uplo, lapack_int* n, lapack_int* nrhs, double* a,\n                   lapack_int* lda, lapack_int* ipiv, double* b,\n                   lapack_int* ldb, double* work, lapack_int* lwork,\n                   lapack_int *info );\nvoid LAPACK_csysv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_float* a, lapack_int* lda, lapack_int* ipiv,\n                   lapack_complex_float* b, lapack_int* ldb,\n                   lapack_complex_float* work, lapack_int* lwork,\n                   lapack_int *info );\nvoid LAPACK_zsysv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_double* a, lapack_int* lda, lapack_int* ipiv,\n                   lapack_complex_double* b, lapack_int* ldb,\n                   lapack_complex_double* work, lapack_int* lwork,\n                   lapack_int *info );\nvoid LAPACK_ssysvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const float* a, lapack_int* lda, float* af,\n                    lapack_int* ldaf, lapack_int* ipiv, const float* b,\n                    lapack_int* ldb, float* x, lapack_int* ldx, float* rcond,\n                    float* ferr, float* berr, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dsysvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* a, lapack_int* lda, double* af,\n                    lapack_int* ldaf, lapack_int* ipiv, const double* b,\n                    lapack_int* ldb, double* x, lapack_int* ldx, double* rcond,\n                    double* ferr, double* berr, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_csysvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* af, lapack_int* ldaf,\n                    lapack_int* ipiv, const lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx,\n                    float* rcond, float* ferr, float* berr,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zsysvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* af, lapack_int* ldaf,\n                    lapack_int* ipiv, const lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx,\n                    double* rcond, double* ferr, double* berr,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_dsysvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                     double* a, lapack_int* lda, double* af, lapack_int* ldaf,\n                     lapack_int* ipiv, char* equed, double* s, double* b,\n                     lapack_int* ldb, double* x, lapack_int* ldx, double* rcond,\n                     double* rpvgrw, double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params, double* work,\n                     lapack_int* iwork, lapack_int *info );\nvoid LAPACK_ssysvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                     float* a, lapack_int* lda, float* af, lapack_int* ldaf,\n                     lapack_int* ipiv, char* equed, float* s, float* b,\n                     lapack_int* ldb, float* x, lapack_int* ldx, float* rcond,\n                     float* rpvgrw, float* berr, lapack_int* n_err_bnds,\n                     float* err_bnds_norm, float* err_bnds_comp,\n                     lapack_int* nparams, float* params, float* work,\n                     lapack_int* iwork, lapack_int *info );\nvoid LAPACK_zsysvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                     lapack_complex_double* a, lapack_int* lda,\n                     lapack_complex_double* af, lapack_int* ldaf,\n                     lapack_int* ipiv, char* equed, double* s,\n                     lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                     double* rpvgrw, double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params,\n                     lapack_complex_double* work, double* rwork,\n                     lapack_int *info );\nvoid LAPACK_csysvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                     lapack_complex_float* a, lapack_int* lda,\n                     lapack_complex_float* af, lapack_int* ldaf,\n                     lapack_int* ipiv, char* equed, float* s,\n                     lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                     float* rpvgrw, float* berr, lapack_int* n_err_bnds,\n                     float* err_bnds_norm, float* err_bnds_comp,\n                     lapack_int* nparams, float* params,\n                     lapack_complex_float* work, float* rwork,\n                     lapack_int *info );\nvoid LAPACK_chesv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_float* a, lapack_int* lda, lapack_int* ipiv,\n                   lapack_complex_float* b, lapack_int* ldb,\n                   lapack_complex_float* work, lapack_int* lwork,\n                   lapack_int *info );\nvoid LAPACK_zhesv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_double* a, lapack_int* lda, lapack_int* ipiv,\n                   lapack_complex_double* b, lapack_int* ldb,\n                   lapack_complex_double* work, lapack_int* lwork,\n                   lapack_int *info );\nvoid LAPACK_chesvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* af, lapack_int* ldaf,\n                    lapack_int* ipiv, const lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx,\n                    float* rcond, float* ferr, float* berr,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zhesvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* af, lapack_int* ldaf,\n                    lapack_int* ipiv, const lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx,\n                    double* rcond, double* ferr, double* berr,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_zhesvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                     lapack_complex_double* a, lapack_int* lda,\n                     lapack_complex_double* af, lapack_int* ldaf,\n                     lapack_int* ipiv, char* equed, double* s,\n                     lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* x, lapack_int* ldx, double* rcond,\n                     double* rpvgrw, double* berr, lapack_int* n_err_bnds,\n                     double* err_bnds_norm, double* err_bnds_comp,\n                     lapack_int* nparams, double* params,\n                     lapack_complex_double* work, double* rwork,\n                     lapack_int *info );\nvoid LAPACK_chesvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                     lapack_complex_float* a, lapack_int* lda,\n                     lapack_complex_float* af, lapack_int* ldaf,\n                     lapack_int* ipiv, char* equed, float* s,\n                     lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* x, lapack_int* ldx, float* rcond,\n                     float* rpvgrw, float* berr, lapack_int* n_err_bnds,\n                     float* err_bnds_norm, float* err_bnds_comp,\n                     lapack_int* nparams, float* params,\n                     lapack_complex_float* work, float* rwork,\n                     lapack_int *info );\nvoid LAPACK_sspsv( char* uplo, lapack_int* n, lapack_int* nrhs, float* ap,\n                   lapack_int* ipiv, float* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_dspsv( char* uplo, lapack_int* n, lapack_int* nrhs, double* ap,\n                   lapack_int* ipiv, double* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_cspsv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_float* ap, lapack_int* ipiv,\n                   lapack_complex_float* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zspsv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_double* ap, lapack_int* ipiv,\n                   lapack_complex_double* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_sspsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const float* ap, float* afp, lapack_int* ipiv,\n                    const float* b, lapack_int* ldb, float* x, lapack_int* ldx,\n                    float* rcond, float* ferr, float* berr, float* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dspsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const double* ap, double* afp, lapack_int* ipiv,\n                    const double* b, lapack_int* ldb, double* x,\n                    lapack_int* ldx, double* rcond, double* ferr, double* berr,\n                    double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cspsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* ap, lapack_complex_float* afp,\n                    lapack_int* ipiv, const lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx,\n                    float* rcond, float* ferr, float* berr,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zspsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* ap, lapack_complex_double* afp,\n                    lapack_int* ipiv, const lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx,\n                    double* rcond, double* ferr, double* berr,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_chpsv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_float* ap, lapack_int* ipiv,\n                   lapack_complex_float* b, lapack_int* ldb, lapack_int *info );\nvoid LAPACK_zhpsv( char* uplo, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_double* ap, lapack_int* ipiv,\n                   lapack_complex_double* b, lapack_int* ldb,\n                   lapack_int *info );\nvoid LAPACK_chpsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_float* ap, lapack_complex_float* afp,\n                    lapack_int* ipiv, const lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx,\n                    float* rcond, float* ferr, float* berr,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zhpsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs,\n                    const lapack_complex_double* ap, lapack_complex_double* afp,\n                    lapack_int* ipiv, const lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx,\n                    double* rcond, double* ferr, double* berr,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_sgeqrf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    float* tau, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dgeqrf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    double* tau, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cgeqrf( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_complex_float* tau,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zgeqrf( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sgeqpf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    lapack_int* jpvt, float* tau, float* work,\n                    lapack_int *info );\nvoid LAPACK_dgeqpf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    lapack_int* jpvt, double* tau, double* work,\n                    lapack_int *info );\nvoid LAPACK_cgeqpf( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int* jpvt,\n                    lapack_complex_float* tau, lapack_complex_float* work,\n                    float* rwork, lapack_int *info );\nvoid LAPACK_zgeqpf( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int* jpvt,\n                    lapack_complex_double* tau, lapack_complex_double* work,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_sgeqp3( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    lapack_int* jpvt, float* tau, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dgeqp3( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    lapack_int* jpvt, double* tau, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cgeqp3( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int* jpvt,\n                    lapack_complex_float* tau, lapack_complex_float* work,\n                    lapack_int* lwork, float* rwork, lapack_int *info );\nvoid LAPACK_zgeqp3( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int* jpvt,\n                    lapack_complex_double* tau, lapack_complex_double* work,\n                    lapack_int* lwork, double* rwork, lapack_int *info );\nvoid LAPACK_sorgqr( lapack_int* m, lapack_int* n, lapack_int* k, float* a,\n                    lapack_int* lda, const float* tau, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dorgqr( lapack_int* m, lapack_int* n, lapack_int* k, double* a,\n                    lapack_int* lda, const double* tau, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sormqr( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const float* a, lapack_int* lda,\n                    const float* tau, float* c, lapack_int* ldc, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dormqr( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const double* a, lapack_int* lda,\n                    const double* tau, double* c, lapack_int* ldc, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cungqr( lapack_int* m, lapack_int* n, lapack_int* k,\n                    lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* tau, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zungqr( lapack_int* m, lapack_int* n, lapack_int* k,\n                    lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cunmqr( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_complex_float* tau,\n                    lapack_complex_float* c, lapack_int* ldc,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zunmqr( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const lapack_complex_double* a,\n                    lapack_int* lda, const lapack_complex_double* tau,\n                    lapack_complex_double* c, lapack_int* ldc,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sgelqf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    float* tau, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dgelqf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    double* tau, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cgelqf( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_complex_float* tau,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zgelqf( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sorglq( lapack_int* m, lapack_int* n, lapack_int* k, float* a,\n                    lapack_int* lda, const float* tau, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dorglq( lapack_int* m, lapack_int* n, lapack_int* k, double* a,\n                    lapack_int* lda, const double* tau, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sormlq( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const float* a, lapack_int* lda,\n                    const float* tau, float* c, lapack_int* ldc, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dormlq( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const double* a, lapack_int* lda,\n                    const double* tau, double* c, lapack_int* ldc, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cunglq( lapack_int* m, lapack_int* n, lapack_int* k,\n                    lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* tau, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zunglq( lapack_int* m, lapack_int* n, lapack_int* k,\n                    lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cunmlq( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_complex_float* tau,\n                    lapack_complex_float* c, lapack_int* ldc,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zunmlq( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const lapack_complex_double* a,\n                    lapack_int* lda, const lapack_complex_double* tau,\n                    lapack_complex_double* c, lapack_int* ldc,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sgeqlf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    float* tau, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dgeqlf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    double* tau, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cgeqlf( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_complex_float* tau,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zgeqlf( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sorgql( lapack_int* m, lapack_int* n, lapack_int* k, float* a,\n                    lapack_int* lda, const float* tau, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dorgql( lapack_int* m, lapack_int* n, lapack_int* k, double* a,\n                    lapack_int* lda, const double* tau, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cungql( lapack_int* m, lapack_int* n, lapack_int* k,\n                    lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* tau, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zungql( lapack_int* m, lapack_int* n, lapack_int* k,\n                    lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sormql( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const float* a, lapack_int* lda,\n                    const float* tau, float* c, lapack_int* ldc, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dormql( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const double* a, lapack_int* lda,\n                    const double* tau, double* c, lapack_int* ldc, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cunmql( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_complex_float* tau,\n                    lapack_complex_float* c, lapack_int* ldc,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zunmql( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const lapack_complex_double* a,\n                    lapack_int* lda, const lapack_complex_double* tau,\n                    lapack_complex_double* c, lapack_int* ldc,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sgerqf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    float* tau, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dgerqf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    double* tau, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cgerqf( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_complex_float* tau,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zgerqf( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sorgrq( lapack_int* m, lapack_int* n, lapack_int* k, float* a,\n                    lapack_int* lda, const float* tau, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dorgrq( lapack_int* m, lapack_int* n, lapack_int* k, double* a,\n                    lapack_int* lda, const double* tau, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cungrq( lapack_int* m, lapack_int* n, lapack_int* k,\n                    lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* tau, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zungrq( lapack_int* m, lapack_int* n, lapack_int* k,\n                    lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sormrq( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const float* a, lapack_int* lda,\n                    const float* tau, float* c, lapack_int* ldc, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dormrq( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const double* a, lapack_int* lda,\n                    const double* tau, double* c, lapack_int* ldc, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cunmrq( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_complex_float* tau,\n                    lapack_complex_float* c, lapack_int* ldc,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zunmrq( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, const lapack_complex_double* a,\n                    lapack_int* lda, const lapack_complex_double* tau,\n                    lapack_complex_double* c, lapack_int* ldc,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_stzrzf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    float* tau, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dtzrzf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    double* tau, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_ctzrzf( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_complex_float* tau,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_ztzrzf( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sormrz( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, lapack_int* l, const float* a,\n                    lapack_int* lda, const float* tau, float* c,\n                    lapack_int* ldc, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dormrz( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, lapack_int* l, const double* a,\n                    lapack_int* lda, const double* tau, double* c,\n                    lapack_int* ldc, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cunmrz( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, lapack_int* l, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_complex_float* tau,\n                    lapack_complex_float* c, lapack_int* ldc,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zunmrz( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* k, lapack_int* l,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* tau, lapack_complex_double* c,\n                    lapack_int* ldc, lapack_complex_double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sggqrf( lapack_int* n, lapack_int* m, lapack_int* p, float* a,\n                    lapack_int* lda, float* taua, float* b, lapack_int* ldb,\n                    float* taub, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dggqrf( lapack_int* n, lapack_int* m, lapack_int* p, double* a,\n                    lapack_int* lda, double* taua, double* b, lapack_int* ldb,\n                    double* taub, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cggqrf( lapack_int* n, lapack_int* m, lapack_int* p,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* taua, lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* taub,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zggqrf( lapack_int* n, lapack_int* m, lapack_int* p,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* taua, lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* taub,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sggrqf( lapack_int* m, lapack_int* p, lapack_int* n, float* a,\n                    lapack_int* lda, float* taua, float* b, lapack_int* ldb,\n                    float* taub, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dggrqf( lapack_int* m, lapack_int* p, lapack_int* n, double* a,\n                    lapack_int* lda, double* taua, double* b, lapack_int* ldb,\n                    double* taub, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cggrqf( lapack_int* m, lapack_int* p, lapack_int* n,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* taua, lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* taub,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zggrqf( lapack_int* m, lapack_int* p, lapack_int* n,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* taua, lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* taub,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sgebrd( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    float* d, float* e, float* tauq, float* taup, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dgebrd( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    double* d, double* e, double* tauq, double* taup,\n                    double* work, lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cgebrd( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, float* d, float* e,\n                    lapack_complex_float* tauq, lapack_complex_float* taup,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zgebrd( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, double* d, double* e,\n                    lapack_complex_double* tauq, lapack_complex_double* taup,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sgbbrd( char* vect, lapack_int* m, lapack_int* n, lapack_int* ncc,\n                    lapack_int* kl, lapack_int* ku, float* ab, lapack_int* ldab,\n                    float* d, float* e, float* q, lapack_int* ldq, float* pt,\n                    lapack_int* ldpt, float* c, lapack_int* ldc, float* work,\n                    lapack_int *info );\nvoid LAPACK_dgbbrd( char* vect, lapack_int* m, lapack_int* n, lapack_int* ncc,\n                    lapack_int* kl, lapack_int* ku, double* ab,\n                    lapack_int* ldab, double* d, double* e, double* q,\n                    lapack_int* ldq, double* pt, lapack_int* ldpt, double* c,\n                    lapack_int* ldc, double* work, lapack_int *info );\nvoid LAPACK_cgbbrd( char* vect, lapack_int* m, lapack_int* n, lapack_int* ncc,\n                    lapack_int* kl, lapack_int* ku, lapack_complex_float* ab,\n                    lapack_int* ldab, float* d, float* e,\n                    lapack_complex_float* q, lapack_int* ldq,\n                    lapack_complex_float* pt, lapack_int* ldpt,\n                    lapack_complex_float* c, lapack_int* ldc,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zgbbrd( char* vect, lapack_int* m, lapack_int* n, lapack_int* ncc,\n                    lapack_int* kl, lapack_int* ku, lapack_complex_double* ab,\n                    lapack_int* ldab, double* d, double* e,\n                    lapack_complex_double* q, lapack_int* ldq,\n                    lapack_complex_double* pt, lapack_int* ldpt,\n                    lapack_complex_double* c, lapack_int* ldc,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_sorgbr( char* vect, lapack_int* m, lapack_int* n, lapack_int* k,\n                    float* a, lapack_int* lda, const float* tau, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dorgbr( char* vect, lapack_int* m, lapack_int* n, lapack_int* k,\n                    double* a, lapack_int* lda, const double* tau, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sormbr( char* vect, char* side, char* trans, lapack_int* m,\n                    lapack_int* n, lapack_int* k, const float* a,\n                    lapack_int* lda, const float* tau, float* c,\n                    lapack_int* ldc, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dormbr( char* vect, char* side, char* trans, lapack_int* m,\n                    lapack_int* n, lapack_int* k, const double* a,\n                    lapack_int* lda, const double* tau, double* c,\n                    lapack_int* ldc, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cungbr( char* vect, lapack_int* m, lapack_int* n, lapack_int* k,\n                    lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* tau, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zungbr( char* vect, lapack_int* m, lapack_int* n, lapack_int* k,\n                    lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cunmbr( char* vect, char* side, char* trans, lapack_int* m,\n                    lapack_int* n, lapack_int* k, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_complex_float* tau,\n                    lapack_complex_float* c, lapack_int* ldc,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zunmbr( char* vect, char* side, char* trans, lapack_int* m,\n                    lapack_int* n, lapack_int* k,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* tau, lapack_complex_double* c,\n                    lapack_int* ldc, lapack_complex_double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sbdsqr( char* uplo, lapack_int* n, lapack_int* ncvt,\n                    lapack_int* nru, lapack_int* ncc, float* d, float* e,\n                    float* vt, lapack_int* ldvt, float* u, lapack_int* ldu,\n                    float* c, lapack_int* ldc, float* work, lapack_int *info );\nvoid LAPACK_dbdsqr( char* uplo, lapack_int* n, lapack_int* ncvt,\n                    lapack_int* nru, lapack_int* ncc, double* d, double* e,\n                    double* vt, lapack_int* ldvt, double* u, lapack_int* ldu,\n                    double* c, lapack_int* ldc, double* work,\n                    lapack_int *info );\nvoid LAPACK_cbdsqr( char* uplo, lapack_int* n, lapack_int* ncvt,\n                    lapack_int* nru, lapack_int* ncc, float* d, float* e,\n                    lapack_complex_float* vt, lapack_int* ldvt,\n                    lapack_complex_float* u, lapack_int* ldu,\n                    lapack_complex_float* c, lapack_int* ldc, float* work,\n                    lapack_int *info );\nvoid LAPACK_zbdsqr( char* uplo, lapack_int* n, lapack_int* ncvt,\n                    lapack_int* nru, lapack_int* ncc, double* d, double* e,\n                    lapack_complex_double* vt, lapack_int* ldvt,\n                    lapack_complex_double* u, lapack_int* ldu,\n                    lapack_complex_double* c, lapack_int* ldc, double* work,\n                    lapack_int *info );\nvoid LAPACK_sbdsdc( char* uplo, char* compq, lapack_int* n, float* d, float* e,\n                    float* u, lapack_int* ldu, float* vt, lapack_int* ldvt,\n                    float* q, lapack_int* iq, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dbdsdc( char* uplo, char* compq, lapack_int* n, double* d,\n                    double* e, double* u, lapack_int* ldu, double* vt,\n                    lapack_int* ldvt, double* q, lapack_int* iq, double* work,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_ssytrd( char* uplo, lapack_int* n, float* a, lapack_int* lda,\n                    float* d, float* e, float* tau, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dsytrd( char* uplo, lapack_int* n, double* a, lapack_int* lda,\n                    double* d, double* e, double* tau, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sorgtr( char* uplo, lapack_int* n, float* a, lapack_int* lda,\n                    const float* tau, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dorgtr( char* uplo, lapack_int* n, double* a, lapack_int* lda,\n                    const double* tau, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_sormtr( char* side, char* uplo, char* trans, lapack_int* m,\n                    lapack_int* n, const float* a, lapack_int* lda,\n                    const float* tau, float* c, lapack_int* ldc, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dormtr( char* side, char* uplo, char* trans, lapack_int* m,\n                    lapack_int* n, const double* a, lapack_int* lda,\n                    const double* tau, double* c, lapack_int* ldc, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_chetrd( char* uplo, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, float* d, float* e,\n                    lapack_complex_float* tau, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zhetrd( char* uplo, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, double* d, double* e,\n                    lapack_complex_double* tau, lapack_complex_double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cungtr( char* uplo, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, const lapack_complex_float* tau,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zungtr( char* uplo, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, const lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cunmtr( char* side, char* uplo, char* trans, lapack_int* m,\n                    lapack_int* n, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_complex_float* tau,\n                    lapack_complex_float* c, lapack_int* ldc,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_zunmtr( char* side, char* uplo, char* trans, lapack_int* m,\n                    lapack_int* n, const lapack_complex_double* a,\n                    lapack_int* lda, const lapack_complex_double* tau,\n                    lapack_complex_double* c, lapack_int* ldc,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_ssptrd( char* uplo, lapack_int* n, float* ap, float* d, float* e,\n                    float* tau, lapack_int *info );\nvoid LAPACK_dsptrd( char* uplo, lapack_int* n, double* ap, double* d, double* e,\n                    double* tau, lapack_int *info );\nvoid LAPACK_sopgtr( char* uplo, lapack_int* n, const float* ap,\n                    const float* tau, float* q, lapack_int* ldq, float* work,\n                    lapack_int *info );\nvoid LAPACK_dopgtr( char* uplo, lapack_int* n, const double* ap,\n                    const double* tau, double* q, lapack_int* ldq, double* work,\n                    lapack_int *info );\nvoid LAPACK_sopmtr( char* side, char* uplo, char* trans, lapack_int* m,\n                    lapack_int* n, const float* ap, const float* tau, float* c,\n                    lapack_int* ldc, float* work, lapack_int *info );\nvoid LAPACK_dopmtr( char* side, char* uplo, char* trans, lapack_int* m,\n                    lapack_int* n, const double* ap, const double* tau,\n                    double* c, lapack_int* ldc, double* work,\n                    lapack_int *info );\nvoid LAPACK_chptrd( char* uplo, lapack_int* n, lapack_complex_float* ap,\n                    float* d, float* e, lapack_complex_float* tau,\n                    lapack_int *info );\nvoid LAPACK_zhptrd( char* uplo, lapack_int* n, lapack_complex_double* ap,\n                    double* d, double* e, lapack_complex_double* tau,\n                    lapack_int *info );\nvoid LAPACK_cupgtr( char* uplo, lapack_int* n, const lapack_complex_float* ap,\n                    const lapack_complex_float* tau, lapack_complex_float* q,\n                    lapack_int* ldq, lapack_complex_float* work,\n                    lapack_int *info );\nvoid LAPACK_zupgtr( char* uplo, lapack_int* n, const lapack_complex_double* ap,\n                    const lapack_complex_double* tau, lapack_complex_double* q,\n                    lapack_int* ldq, lapack_complex_double* work,\n                    lapack_int *info );\nvoid LAPACK_cupmtr( char* side, char* uplo, char* trans, lapack_int* m,\n                    lapack_int* n, const lapack_complex_float* ap,\n                    const lapack_complex_float* tau, lapack_complex_float* c,\n                    lapack_int* ldc, lapack_complex_float* work,\n                    lapack_int *info );\nvoid LAPACK_zupmtr( char* side, char* uplo, char* trans, lapack_int* m,\n                    lapack_int* n, const lapack_complex_double* ap,\n                    const lapack_complex_double* tau, lapack_complex_double* c,\n                    lapack_int* ldc, lapack_complex_double* work,\n                    lapack_int *info );\nvoid LAPACK_ssbtrd( char* vect, char* uplo, lapack_int* n, lapack_int* kd,\n                    float* ab, lapack_int* ldab, float* d, float* e, float* q,\n                    lapack_int* ldq, float* work, lapack_int *info );\nvoid LAPACK_dsbtrd( char* vect, char* uplo, lapack_int* n, lapack_int* kd,\n                    double* ab, lapack_int* ldab, double* d, double* e,\n                    double* q, lapack_int* ldq, double* work,\n                    lapack_int *info );\nvoid LAPACK_chbtrd( char* vect, char* uplo, lapack_int* n, lapack_int* kd,\n                    lapack_complex_float* ab, lapack_int* ldab, float* d,\n                    float* e, lapack_complex_float* q, lapack_int* ldq,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zhbtrd( char* vect, char* uplo, lapack_int* n, lapack_int* kd,\n                    lapack_complex_double* ab, lapack_int* ldab, double* d,\n                    double* e, lapack_complex_double* q, lapack_int* ldq,\n                    lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_ssterf( lapack_int* n, float* d, float* e, lapack_int *info );\nvoid LAPACK_dsterf( lapack_int* n, double* d, double* e, lapack_int *info );\nvoid LAPACK_ssteqr( char* compz, lapack_int* n, float* d, float* e, float* z,\n                    lapack_int* ldz, float* work, lapack_int *info );\nvoid LAPACK_dsteqr( char* compz, lapack_int* n, double* d, double* e, double* z,\n                    lapack_int* ldz, double* work, lapack_int *info );\nvoid LAPACK_csteqr( char* compz, lapack_int* n, float* d, float* e,\n                    lapack_complex_float* z, lapack_int* ldz, float* work,\n                    lapack_int *info );\nvoid LAPACK_zsteqr( char* compz, lapack_int* n, double* d, double* e,\n                    lapack_complex_double* z, lapack_int* ldz, double* work,\n                    lapack_int *info );\nvoid LAPACK_sstemr( char* jobz, char* range, lapack_int* n, float* d, float* e,\n                    float* vl, float* vu, lapack_int* il, lapack_int* iu,\n                    lapack_int* m, float* w, float* z, lapack_int* ldz,\n                    lapack_int* nzc, lapack_int* isuppz, lapack_logical* tryrac,\n                    float* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dstemr( char* jobz, char* range, lapack_int* n, double* d,\n                    double* e, double* vl, double* vu, lapack_int* il,\n                    lapack_int* iu, lapack_int* m, double* w, double* z,\n                    lapack_int* ldz, lapack_int* nzc, lapack_int* isuppz,\n                    lapack_logical* tryrac, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_cstemr( char* jobz, char* range, lapack_int* n, float* d, float* e,\n                    float* vl, float* vu, lapack_int* il, lapack_int* iu,\n                    lapack_int* m, float* w, lapack_complex_float* z,\n                    lapack_int* ldz, lapack_int* nzc, lapack_int* isuppz,\n                    lapack_logical* tryrac, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_zstemr( char* jobz, char* range, lapack_int* n, double* d,\n                    double* e, double* vl, double* vu, lapack_int* il,\n                    lapack_int* iu, lapack_int* m, double* w,\n                    lapack_complex_double* z, lapack_int* ldz, lapack_int* nzc,\n                    lapack_int* isuppz, lapack_logical* tryrac, double* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_int *info );\nvoid LAPACK_sstedc( char* compz, lapack_int* n, float* d, float* e, float* z,\n                    lapack_int* ldz, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dstedc( char* compz, lapack_int* n, double* d, double* e, double* z,\n                    lapack_int* ldz, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_cstedc( char* compz, lapack_int* n, float* d, float* e,\n                    lapack_complex_float* z, lapack_int* ldz,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_int *info );\nvoid LAPACK_zstedc( char* compz, lapack_int* n, double* d, double* e,\n                    lapack_complex_double* z, lapack_int* ldz,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int* lrwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_sstegr( char* jobz, char* range, lapack_int* n, float* d, float* e,\n                    float* vl, float* vu, lapack_int* il, lapack_int* iu,\n                    float* abstol, lapack_int* m, float* w, float* z,\n                    lapack_int* ldz, lapack_int* isuppz, float* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_int *info );\nvoid LAPACK_dstegr( char* jobz, char* range, lapack_int* n, double* d,\n                    double* e, double* vl, double* vu, lapack_int* il,\n                    lapack_int* iu, double* abstol, lapack_int* m, double* w,\n                    double* z, lapack_int* ldz, lapack_int* isuppz,\n                    double* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_cstegr( char* jobz, char* range, lapack_int* n, float* d, float* e,\n                    float* vl, float* vu, lapack_int* il, lapack_int* iu,\n                    float* abstol, lapack_int* m, float* w,\n                    lapack_complex_float* z, lapack_int* ldz,\n                    lapack_int* isuppz, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_zstegr( char* jobz, char* range, lapack_int* n, double* d,\n                    double* e, double* vl, double* vu, lapack_int* il,\n                    lapack_int* iu, double* abstol, lapack_int* m, double* w,\n                    lapack_complex_double* z, lapack_int* ldz,\n                    lapack_int* isuppz, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_spteqr( char* compz, lapack_int* n, float* d, float* e, float* z,\n                    lapack_int* ldz, float* work, lapack_int *info );\nvoid LAPACK_dpteqr( char* compz, lapack_int* n, double* d, double* e, double* z,\n                    lapack_int* ldz, double* work, lapack_int *info );\nvoid LAPACK_cpteqr( char* compz, lapack_int* n, float* d, float* e,\n                    lapack_complex_float* z, lapack_int* ldz, float* work,\n                    lapack_int *info );\nvoid LAPACK_zpteqr( char* compz, lapack_int* n, double* d, double* e,\n                    lapack_complex_double* z, lapack_int* ldz, double* work,\n                    lapack_int *info );\nvoid LAPACK_sstebz( char* range, char* order, lapack_int* n, float* vl,\n                    float* vu, lapack_int* il, lapack_int* iu, float* abstol,\n                    const float* d, const float* e, lapack_int* m,\n                    lapack_int* nsplit, float* w, lapack_int* iblock,\n                    lapack_int* isplit, float* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dstebz( char* range, char* order, lapack_int* n, double* vl,\n                    double* vu, lapack_int* il, lapack_int* iu, double* abstol,\n                    const double* d, const double* e, lapack_int* m,\n                    lapack_int* nsplit, double* w, lapack_int* iblock,\n                    lapack_int* isplit, double* work, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_sstein( lapack_int* n, const float* d, const float* e,\n                    lapack_int* m, const float* w, const lapack_int* iblock,\n                    const lapack_int* isplit, float* z, lapack_int* ldz,\n                    float* work, lapack_int* iwork, lapack_int* ifailv,\n                    lapack_int *info );\nvoid LAPACK_dstein( lapack_int* n, const double* d, const double* e,\n                    lapack_int* m, const double* w, const lapack_int* iblock,\n                    const lapack_int* isplit, double* z, lapack_int* ldz,\n                    double* work, lapack_int* iwork, lapack_int* ifailv,\n                    lapack_int *info );\nvoid LAPACK_cstein( lapack_int* n, const float* d, const float* e,\n                    lapack_int* m, const float* w, const lapack_int* iblock,\n                    const lapack_int* isplit, lapack_complex_float* z,\n                    lapack_int* ldz, float* work, lapack_int* iwork,\n                    lapack_int* ifailv, lapack_int *info );\nvoid LAPACK_zstein( lapack_int* n, const double* d, const double* e,\n                    lapack_int* m, const double* w, const lapack_int* iblock,\n                    const lapack_int* isplit, lapack_complex_double* z,\n                    lapack_int* ldz, double* work, lapack_int* iwork,\n                    lapack_int* ifailv, lapack_int *info );\nvoid LAPACK_sdisna( char* job, lapack_int* m, lapack_int* n, const float* d,\n                    float* sep, lapack_int *info );\nvoid LAPACK_ddisna( char* job, lapack_int* m, lapack_int* n, const double* d,\n                    double* sep, lapack_int *info );\nvoid LAPACK_ssygst( lapack_int* itype, char* uplo, lapack_int* n, float* a,\n                    lapack_int* lda, const float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_dsygst( lapack_int* itype, char* uplo, lapack_int* n, double* a,\n                    lapack_int* lda, const double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_chegst( lapack_int* itype, char* uplo, lapack_int* n,\n                    lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_zhegst( lapack_int* itype, char* uplo, lapack_int* n,\n                    lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int *info );\nvoid LAPACK_sspgst( lapack_int* itype, char* uplo, lapack_int* n, float* ap,\n                    const float* bp, lapack_int *info );\nvoid LAPACK_dspgst( lapack_int* itype, char* uplo, lapack_int* n, double* ap,\n                    const double* bp, lapack_int *info );\nvoid LAPACK_chpgst( lapack_int* itype, char* uplo, lapack_int* n,\n                    lapack_complex_float* ap, const lapack_complex_float* bp,\n                    lapack_int *info );\nvoid LAPACK_zhpgst( lapack_int* itype, char* uplo, lapack_int* n,\n                    lapack_complex_double* ap, const lapack_complex_double* bp,\n                    lapack_int *info );\nvoid LAPACK_ssbgst( char* vect, char* uplo, lapack_int* n, lapack_int* ka,\n                    lapack_int* kb, float* ab, lapack_int* ldab,\n                    const float* bb, lapack_int* ldbb, float* x,\n                    lapack_int* ldx, float* work, lapack_int *info );\nvoid LAPACK_dsbgst( char* vect, char* uplo, lapack_int* n, lapack_int* ka,\n                    lapack_int* kb, double* ab, lapack_int* ldab,\n                    const double* bb, lapack_int* ldbb, double* x,\n                    lapack_int* ldx, double* work, lapack_int *info );\nvoid LAPACK_chbgst( char* vect, char* uplo, lapack_int* n, lapack_int* ka,\n                    lapack_int* kb, lapack_complex_float* ab, lapack_int* ldab,\n                    const lapack_complex_float* bb, lapack_int* ldbb,\n                    lapack_complex_float* x, lapack_int* ldx,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zhbgst( char* vect, char* uplo, lapack_int* n, lapack_int* ka,\n                    lapack_int* kb, lapack_complex_double* ab, lapack_int* ldab,\n                    const lapack_complex_double* bb, lapack_int* ldbb,\n                    lapack_complex_double* x, lapack_int* ldx,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_spbstf( char* uplo, lapack_int* n, lapack_int* kb, float* bb,\n                    lapack_int* ldbb, lapack_int *info );\nvoid LAPACK_dpbstf( char* uplo, lapack_int* n, lapack_int* kb, double* bb,\n                    lapack_int* ldbb, lapack_int *info );\nvoid LAPACK_cpbstf( char* uplo, lapack_int* n, lapack_int* kb,\n                    lapack_complex_float* bb, lapack_int* ldbb,\n                    lapack_int *info );\nvoid LAPACK_zpbstf( char* uplo, lapack_int* n, lapack_int* kb,\n                    lapack_complex_double* bb, lapack_int* ldbb,\n                    lapack_int *info );\nvoid LAPACK_sgehrd( lapack_int* n, lapack_int* ilo, lapack_int* ihi, float* a,\n                    lapack_int* lda, float* tau, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dgehrd( lapack_int* n, lapack_int* ilo, lapack_int* ihi, double* a,\n                    lapack_int* lda, double* tau, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cgehrd( lapack_int* n, lapack_int* ilo, lapack_int* ihi,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* tau, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zgehrd( lapack_int* n, lapack_int* ilo, lapack_int* ihi,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* tau, lapack_complex_double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sorghr( lapack_int* n, lapack_int* ilo, lapack_int* ihi, float* a,\n                    lapack_int* lda, const float* tau, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dorghr( lapack_int* n, lapack_int* ilo, lapack_int* ihi, double* a,\n                    lapack_int* lda, const double* tau, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sormhr( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* ilo, lapack_int* ihi, const float* a,\n                    lapack_int* lda, const float* tau, float* c,\n                    lapack_int* ldc, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dormhr( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* ilo, lapack_int* ihi, const double* a,\n                    lapack_int* lda, const double* tau, double* c,\n                    lapack_int* ldc, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cunghr( lapack_int* n, lapack_int* ilo, lapack_int* ihi,\n                    lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* tau, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zunghr( lapack_int* n, lapack_int* ilo, lapack_int* ihi,\n                    lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cunmhr( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* ilo, lapack_int* ihi,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* tau, lapack_complex_float* c,\n                    lapack_int* ldc, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zunmhr( char* side, char* trans, lapack_int* m, lapack_int* n,\n                    lapack_int* ilo, lapack_int* ihi,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* tau, lapack_complex_double* c,\n                    lapack_int* ldc, lapack_complex_double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sgebal( char* job, lapack_int* n, float* a, lapack_int* lda,\n                    lapack_int* ilo, lapack_int* ihi, float* scale,\n                    lapack_int *info );\nvoid LAPACK_dgebal( char* job, lapack_int* n, double* a, lapack_int* lda,\n                    lapack_int* ilo, lapack_int* ihi, double* scale,\n                    lapack_int *info );\nvoid LAPACK_cgebal( char* job, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int* ilo, lapack_int* ihi,\n                    float* scale, lapack_int *info );\nvoid LAPACK_zgebal( char* job, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int* ilo, lapack_int* ihi,\n                    double* scale, lapack_int *info );\nvoid LAPACK_sgebak( char* job, char* side, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, const float* scale, lapack_int* m,\n                    float* v, lapack_int* ldv, lapack_int *info );\nvoid LAPACK_dgebak( char* job, char* side, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, const double* scale, lapack_int* m,\n                    double* v, lapack_int* ldv, lapack_int *info );\nvoid LAPACK_cgebak( char* job, char* side, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, const float* scale, lapack_int* m,\n                    lapack_complex_float* v, lapack_int* ldv,\n                    lapack_int *info );\nvoid LAPACK_zgebak( char* job, char* side, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, const double* scale, lapack_int* m,\n                    lapack_complex_double* v, lapack_int* ldv,\n                    lapack_int *info );\nvoid LAPACK_shseqr( char* job, char* compz, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, float* h, lapack_int* ldh, float* wr,\n                    float* wi, float* z, lapack_int* ldz, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dhseqr( char* job, char* compz, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, double* h, lapack_int* ldh, double* wr,\n                    double* wi, double* z, lapack_int* ldz, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_chseqr( char* job, char* compz, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, lapack_complex_float* h, lapack_int* ldh,\n                    lapack_complex_float* w, lapack_complex_float* z,\n                    lapack_int* ldz, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zhseqr( char* job, char* compz, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, lapack_complex_double* h, lapack_int* ldh,\n                    lapack_complex_double* w, lapack_complex_double* z,\n                    lapack_int* ldz, lapack_complex_double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_shsein( char* job, char* eigsrc, char* initv,\n                    lapack_logical* select, lapack_int* n, const float* h,\n                    lapack_int* ldh, float* wr, const float* wi, float* vl,\n                    lapack_int* ldvl, float* vr, lapack_int* ldvr,\n                    lapack_int* mm, lapack_int* m, float* work,\n                    lapack_int* ifaill, lapack_int* ifailr, lapack_int *info );\nvoid LAPACK_dhsein( char* job, char* eigsrc, char* initv,\n                    lapack_logical* select, lapack_int* n, const double* h,\n                    lapack_int* ldh, double* wr, const double* wi, double* vl,\n                    lapack_int* ldvl, double* vr, lapack_int* ldvr,\n                    lapack_int* mm, lapack_int* m, double* work,\n                    lapack_int* ifaill, lapack_int* ifailr, lapack_int *info );\nvoid LAPACK_chsein( char* job, char* eigsrc, char* initv,\n                    const lapack_logical* select, lapack_int* n,\n                    const lapack_complex_float* h, lapack_int* ldh,\n                    lapack_complex_float* w, lapack_complex_float* vl,\n                    lapack_int* ldvl, lapack_complex_float* vr,\n                    lapack_int* ldvr, lapack_int* mm, lapack_int* m,\n                    lapack_complex_float* work, float* rwork,\n                    lapack_int* ifaill, lapack_int* ifailr, lapack_int *info );\nvoid LAPACK_zhsein( char* job, char* eigsrc, char* initv,\n                    const lapack_logical* select, lapack_int* n,\n                    const lapack_complex_double* h, lapack_int* ldh,\n                    lapack_complex_double* w, lapack_complex_double* vl,\n                    lapack_int* ldvl, lapack_complex_double* vr,\n                    lapack_int* ldvr, lapack_int* mm, lapack_int* m,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int* ifaill, lapack_int* ifailr, lapack_int *info );\nvoid LAPACK_strevc( char* side, char* howmny, lapack_logical* select,\n                    lapack_int* n, const float* t, lapack_int* ldt, float* vl,\n                    lapack_int* ldvl, float* vr, lapack_int* ldvr,\n                    lapack_int* mm, lapack_int* m, float* work,\n                    lapack_int *info );\nvoid LAPACK_dtrevc( char* side, char* howmny, lapack_logical* select,\n                    lapack_int* n, const double* t, lapack_int* ldt, double* vl,\n                    lapack_int* ldvl, double* vr, lapack_int* ldvr,\n                    lapack_int* mm, lapack_int* m, double* work,\n                    lapack_int *info );\nvoid LAPACK_ctrevc( char* side, char* howmny, const lapack_logical* select,\n                    lapack_int* n, lapack_complex_float* t, lapack_int* ldt,\n                    lapack_complex_float* vl, lapack_int* ldvl,\n                    lapack_complex_float* vr, lapack_int* ldvr, lapack_int* mm,\n                    lapack_int* m, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_ztrevc( char* side, char* howmny, const lapack_logical* select,\n                    lapack_int* n, lapack_complex_double* t, lapack_int* ldt,\n                    lapack_complex_double* vl, lapack_int* ldvl,\n                    lapack_complex_double* vr, lapack_int* ldvr, lapack_int* mm,\n                    lapack_int* m, lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_strsna( char* job, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const float* t, lapack_int* ldt,\n                    const float* vl, lapack_int* ldvl, const float* vr,\n                    lapack_int* ldvr, float* s, float* sep, lapack_int* mm,\n                    lapack_int* m, float* work, lapack_int* ldwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dtrsna( char* job, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const double* t, lapack_int* ldt,\n                    const double* vl, lapack_int* ldvl, const double* vr,\n                    lapack_int* ldvr, double* s, double* sep, lapack_int* mm,\n                    lapack_int* m, double* work, lapack_int* ldwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_ctrsna( char* job, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const lapack_complex_float* t,\n                    lapack_int* ldt, const lapack_complex_float* vl,\n                    lapack_int* ldvl, const lapack_complex_float* vr,\n                    lapack_int* ldvr, float* s, float* sep, lapack_int* mm,\n                    lapack_int* m, lapack_complex_float* work,\n                    lapack_int* ldwork, float* rwork, lapack_int *info );\nvoid LAPACK_ztrsna( char* job, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const lapack_complex_double* t,\n                    lapack_int* ldt, const lapack_complex_double* vl,\n                    lapack_int* ldvl, const lapack_complex_double* vr,\n                    lapack_int* ldvr, double* s, double* sep, lapack_int* mm,\n                    lapack_int* m, lapack_complex_double* work,\n                    lapack_int* ldwork, double* rwork, lapack_int *info );\nvoid LAPACK_strexc( char* compq, lapack_int* n, float* t, lapack_int* ldt,\n                    float* q, lapack_int* ldq, lapack_int* ifst,\n                    lapack_int* ilst, float* work, lapack_int *info );\nvoid LAPACK_dtrexc( char* compq, lapack_int* n, double* t, lapack_int* ldt,\n                    double* q, lapack_int* ldq, lapack_int* ifst,\n                    lapack_int* ilst, double* work, lapack_int *info );\nvoid LAPACK_ctrexc( char* compq, lapack_int* n, lapack_complex_float* t,\n                    lapack_int* ldt, lapack_complex_float* q, lapack_int* ldq,\n                    lapack_int* ifst, lapack_int* ilst, lapack_int *info );\nvoid LAPACK_ztrexc( char* compq, lapack_int* n, lapack_complex_double* t,\n                    lapack_int* ldt, lapack_complex_double* q, lapack_int* ldq,\n                    lapack_int* ifst, lapack_int* ilst, lapack_int *info );\nvoid LAPACK_strsen( char* job, char* compq, const lapack_logical* select,\n                    lapack_int* n, float* t, lapack_int* ldt, float* q,\n                    lapack_int* ldq, float* wr, float* wi, lapack_int* m,\n                    float* s, float* sep, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dtrsen( char* job, char* compq, const lapack_logical* select,\n                    lapack_int* n, double* t, lapack_int* ldt, double* q,\n                    lapack_int* ldq, double* wr, double* wi, lapack_int* m,\n                    double* s, double* sep, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_ctrsen( char* job, char* compq, const lapack_logical* select,\n                    lapack_int* n, lapack_complex_float* t, lapack_int* ldt,\n                    lapack_complex_float* q, lapack_int* ldq,\n                    lapack_complex_float* w, lapack_int* m, float* s,\n                    float* sep, lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_ztrsen( char* job, char* compq, const lapack_logical* select,\n                    lapack_int* n, lapack_complex_double* t, lapack_int* ldt,\n                    lapack_complex_double* q, lapack_int* ldq,\n                    lapack_complex_double* w, lapack_int* m, double* s,\n                    double* sep, lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_strsyl( char* trana, char* tranb, lapack_int* isgn, lapack_int* m,\n                    lapack_int* n, const float* a, lapack_int* lda,\n                    const float* b, lapack_int* ldb, float* c, lapack_int* ldc,\n                    float* scale, lapack_int *info );\nvoid LAPACK_dtrsyl( char* trana, char* tranb, lapack_int* isgn, lapack_int* m,\n                    lapack_int* n, const double* a, lapack_int* lda,\n                    const double* b, lapack_int* ldb, double* c,\n                    lapack_int* ldc, double* scale, lapack_int *info );\nvoid LAPACK_ctrsyl( char* trana, char* tranb, lapack_int* isgn, lapack_int* m,\n                    lapack_int* n, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_complex_float* b,\n                    lapack_int* ldb, lapack_complex_float* c, lapack_int* ldc,\n                    float* scale, lapack_int *info );\nvoid LAPACK_ztrsyl( char* trana, char* tranb, lapack_int* isgn, lapack_int* m,\n                    lapack_int* n, const lapack_complex_double* a,\n                    lapack_int* lda, const lapack_complex_double* b,\n                    lapack_int* ldb, lapack_complex_double* c, lapack_int* ldc,\n                    double* scale, lapack_int *info );\nvoid LAPACK_sgghrd( char* compq, char* compz, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, float* a, lapack_int* lda, float* b,\n                    lapack_int* ldb, float* q, lapack_int* ldq, float* z,\n                    lapack_int* ldz, lapack_int *info );\nvoid LAPACK_dgghrd( char* compq, char* compz, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, double* a, lapack_int* lda, double* b,\n                    lapack_int* ldb, double* q, lapack_int* ldq, double* z,\n                    lapack_int* ldz, lapack_int *info );\nvoid LAPACK_cgghrd( char* compq, char* compz, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* q, lapack_int* ldq,\n                    lapack_complex_float* z, lapack_int* ldz,\n                    lapack_int *info );\nvoid LAPACK_zgghrd( char* compq, char* compz, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* q, lapack_int* ldq,\n                    lapack_complex_double* z, lapack_int* ldz,\n                    lapack_int *info );\nvoid LAPACK_sggbal( char* job, lapack_int* n, float* a, lapack_int* lda,\n                    float* b, lapack_int* ldb, lapack_int* ilo, lapack_int* ihi,\n                    float* lscale, float* rscale, float* work,\n                    lapack_int *info );\nvoid LAPACK_dggbal( char* job, lapack_int* n, double* a, lapack_int* lda,\n                    double* b, lapack_int* ldb, lapack_int* ilo,\n                    lapack_int* ihi, double* lscale, double* rscale,\n                    double* work, lapack_int *info );\nvoid LAPACK_cggbal( char* job, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_complex_float* b, lapack_int* ldb,\n                    lapack_int* ilo, lapack_int* ihi, float* lscale,\n                    float* rscale, float* work, lapack_int *info );\nvoid LAPACK_zggbal( char* job, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_complex_double* b, lapack_int* ldb,\n                    lapack_int* ilo, lapack_int* ihi, double* lscale,\n                    double* rscale, double* work, lapack_int *info );\nvoid LAPACK_sggbak( char* job, char* side, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, const float* lscale, const float* rscale,\n                    lapack_int* m, float* v, lapack_int* ldv,\n                    lapack_int *info );\nvoid LAPACK_dggbak( char* job, char* side, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, const double* lscale, const double* rscale,\n                    lapack_int* m, double* v, lapack_int* ldv,\n                    lapack_int *info );\nvoid LAPACK_cggbak( char* job, char* side, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, const float* lscale, const float* rscale,\n                    lapack_int* m, lapack_complex_float* v, lapack_int* ldv,\n                    lapack_int *info );\nvoid LAPACK_zggbak( char* job, char* side, lapack_int* n, lapack_int* ilo,\n                    lapack_int* ihi, const double* lscale, const double* rscale,\n                    lapack_int* m, lapack_complex_double* v, lapack_int* ldv,\n                    lapack_int *info );\nvoid LAPACK_shgeqz( char* job, char* compq, char* compz, lapack_int* n,\n                    lapack_int* ilo, lapack_int* ihi, float* h, lapack_int* ldh,\n                    float* t, lapack_int* ldt, float* alphar, float* alphai,\n                    float* beta, float* q, lapack_int* ldq, float* z,\n                    lapack_int* ldz, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dhgeqz( char* job, char* compq, char* compz, lapack_int* n,\n                    lapack_int* ilo, lapack_int* ihi, double* h,\n                    lapack_int* ldh, double* t, lapack_int* ldt, double* alphar,\n                    double* alphai, double* beta, double* q, lapack_int* ldq,\n                    double* z, lapack_int* ldz, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_chgeqz( char* job, char* compq, char* compz, lapack_int* n,\n                    lapack_int* ilo, lapack_int* ihi, lapack_complex_float* h,\n                    lapack_int* ldh, lapack_complex_float* t, lapack_int* ldt,\n                    lapack_complex_float* alpha, lapack_complex_float* beta,\n                    lapack_complex_float* q, lapack_int* ldq,\n                    lapack_complex_float* z, lapack_int* ldz,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zhgeqz( char* job, char* compq, char* compz, lapack_int* n,\n                    lapack_int* ilo, lapack_int* ihi, lapack_complex_double* h,\n                    lapack_int* ldh, lapack_complex_double* t, lapack_int* ldt,\n                    lapack_complex_double* alpha, lapack_complex_double* beta,\n                    lapack_complex_double* q, lapack_int* ldq,\n                    lapack_complex_double* z, lapack_int* ldz,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_stgevc( char* side, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const float* s, lapack_int* lds,\n                    const float* p, lapack_int* ldp, float* vl,\n                    lapack_int* ldvl, float* vr, lapack_int* ldvr,\n                    lapack_int* mm, lapack_int* m, float* work,\n                    lapack_int *info );\nvoid LAPACK_dtgevc( char* side, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const double* s, lapack_int* lds,\n                    const double* p, lapack_int* ldp, double* vl,\n                    lapack_int* ldvl, double* vr, lapack_int* ldvr,\n                    lapack_int* mm, lapack_int* m, double* work,\n                    lapack_int *info );\nvoid LAPACK_ctgevc( char* side, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const lapack_complex_float* s,\n                    lapack_int* lds, const lapack_complex_float* p,\n                    lapack_int* ldp, lapack_complex_float* vl, lapack_int* ldvl,\n                    lapack_complex_float* vr, lapack_int* ldvr, lapack_int* mm,\n                    lapack_int* m, lapack_complex_float* work, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_ztgevc( char* side, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const lapack_complex_double* s,\n                    lapack_int* lds, const lapack_complex_double* p,\n                    lapack_int* ldp, lapack_complex_double* vl,\n                    lapack_int* ldvl, lapack_complex_double* vr,\n                    lapack_int* ldvr, lapack_int* mm, lapack_int* m,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int *info );\nvoid LAPACK_stgexc( lapack_logical* wantq, lapack_logical* wantz, lapack_int* n,\n                    float* a, lapack_int* lda, float* b, lapack_int* ldb,\n                    float* q, lapack_int* ldq, float* z, lapack_int* ldz,\n                    lapack_int* ifst, lapack_int* ilst, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dtgexc( lapack_logical* wantq, lapack_logical* wantz, lapack_int* n,\n                    double* a, lapack_int* lda, double* b, lapack_int* ldb,\n                    double* q, lapack_int* ldq, double* z, lapack_int* ldz,\n                    lapack_int* ifst, lapack_int* ilst, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_ctgexc( lapack_logical* wantq, lapack_logical* wantz, lapack_int* n,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* q, lapack_int* ldq,\n                    lapack_complex_float* z, lapack_int* ldz, lapack_int* ifst,\n                    lapack_int* ilst, lapack_int *info );\nvoid LAPACK_ztgexc( lapack_logical* wantq, lapack_logical* wantz, lapack_int* n,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* q, lapack_int* ldq,\n                    lapack_complex_double* z, lapack_int* ldz, lapack_int* ifst,\n                    lapack_int* ilst, lapack_int *info );\nvoid LAPACK_stgsen( lapack_int* ijob, lapack_logical* wantq,\n                    lapack_logical* wantz, const lapack_logical* select,\n                    lapack_int* n, float* a, lapack_int* lda, float* b,\n                    lapack_int* ldb, float* alphar, float* alphai, float* beta,\n                    float* q, lapack_int* ldq, float* z, lapack_int* ldz,\n                    lapack_int* m, float* pl, float* pr, float* dif,\n                    float* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dtgsen( lapack_int* ijob, lapack_logical* wantq,\n                    lapack_logical* wantz, const lapack_logical* select,\n                    lapack_int* n, double* a, lapack_int* lda, double* b,\n                    lapack_int* ldb, double* alphar, double* alphai,\n                    double* beta, double* q, lapack_int* ldq, double* z,\n                    lapack_int* ldz, lapack_int* m, double* pl, double* pr,\n                    double* dif, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_ctgsen( lapack_int* ijob, lapack_logical* wantq,\n                    lapack_logical* wantz, const lapack_logical* select,\n                    lapack_int* n, lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* alpha, lapack_complex_float* beta,\n                    lapack_complex_float* q, lapack_int* ldq,\n                    lapack_complex_float* z, lapack_int* ldz, lapack_int* m,\n                    float* pl, float* pr, float* dif,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_ztgsen( lapack_int* ijob, lapack_logical* wantq,\n                    lapack_logical* wantz, const lapack_logical* select,\n                    lapack_int* n, lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* alpha, lapack_complex_double* beta,\n                    lapack_complex_double* q, lapack_int* ldq,\n                    lapack_complex_double* z, lapack_int* ldz, lapack_int* m,\n                    double* pl, double* pr, double* dif,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_stgsyl( char* trans, lapack_int* ijob, lapack_int* m, lapack_int* n,\n                    const float* a, lapack_int* lda, const float* b,\n                    lapack_int* ldb, float* c, lapack_int* ldc, const float* d,\n                    lapack_int* ldd, const float* e, lapack_int* lde, float* f,\n                    lapack_int* ldf, float* scale, float* dif, float* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dtgsyl( char* trans, lapack_int* ijob, lapack_int* m, lapack_int* n,\n                    const double* a, lapack_int* lda, const double* b,\n                    lapack_int* ldb, double* c, lapack_int* ldc,\n                    const double* d, lapack_int* ldd, const double* e,\n                    lapack_int* lde, double* f, lapack_int* ldf, double* scale,\n                    double* dif, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_ctgsyl( char* trans, lapack_int* ijob, lapack_int* m, lapack_int* n,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    const lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* c, lapack_int* ldc,\n                    const lapack_complex_float* d, lapack_int* ldd,\n                    const lapack_complex_float* e, lapack_int* lde,\n                    lapack_complex_float* f, lapack_int* ldf, float* scale,\n                    float* dif, lapack_complex_float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_ztgsyl( char* trans, lapack_int* ijob, lapack_int* m, lapack_int* n,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    const lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* c, lapack_int* ldc,\n                    const lapack_complex_double* d, lapack_int* ldd,\n                    const lapack_complex_double* e, lapack_int* lde,\n                    lapack_complex_double* f, lapack_int* ldf, double* scale,\n                    double* dif, lapack_complex_double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_stgsna( char* job, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const float* a, lapack_int* lda,\n                    const float* b, lapack_int* ldb, const float* vl,\n                    lapack_int* ldvl, const float* vr, lapack_int* ldvr,\n                    float* s, float* dif, lapack_int* mm, lapack_int* m,\n                    float* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dtgsna( char* job, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const double* a, lapack_int* lda,\n                    const double* b, lapack_int* ldb, const double* vl,\n                    lapack_int* ldvl, const double* vr, lapack_int* ldvr,\n                    double* s, double* dif, lapack_int* mm, lapack_int* m,\n                    double* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_ctgsna( char* job, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const lapack_complex_float* a,\n                    lapack_int* lda, const lapack_complex_float* b,\n                    lapack_int* ldb, const lapack_complex_float* vl,\n                    lapack_int* ldvl, const lapack_complex_float* vr,\n                    lapack_int* ldvr, float* s, float* dif, lapack_int* mm,\n                    lapack_int* m, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_ztgsna( char* job, char* howmny, const lapack_logical* select,\n                    lapack_int* n, const lapack_complex_double* a,\n                    lapack_int* lda, const lapack_complex_double* b,\n                    lapack_int* ldb, const lapack_complex_double* vl,\n                    lapack_int* ldvl, const lapack_complex_double* vr,\n                    lapack_int* ldvr, double* s, double* dif, lapack_int* mm,\n                    lapack_int* m, lapack_complex_double* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_sggsvp( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* p, lapack_int* n, float* a, lapack_int* lda,\n                    float* b, lapack_int* ldb, float* tola, float* tolb,\n                    lapack_int* k, lapack_int* l, float* u, lapack_int* ldu,\n                    float* v, lapack_int* ldv, float* q, lapack_int* ldq,\n                    lapack_int* iwork, float* tau, float* work,\n                    lapack_int *info );\nvoid LAPACK_dggsvp( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* p, lapack_int* n, double* a, lapack_int* lda,\n                    double* b, lapack_int* ldb, double* tola, double* tolb,\n                    lapack_int* k, lapack_int* l, double* u, lapack_int* ldu,\n                    double* v, lapack_int* ldv, double* q, lapack_int* ldq,\n                    lapack_int* iwork, double* tau, double* work,\n                    lapack_int *info );\nvoid LAPACK_cggsvp( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* p, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_complex_float* b, lapack_int* ldb,\n                    float* tola, float* tolb, lapack_int* k, lapack_int* l,\n                    lapack_complex_float* u, lapack_int* ldu,\n                    lapack_complex_float* v, lapack_int* ldv,\n                    lapack_complex_float* q, lapack_int* ldq, lapack_int* iwork,\n                    float* rwork, lapack_complex_float* tau,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zggsvp( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* p, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_complex_double* b, lapack_int* ldb,\n                    double* tola, double* tolb, lapack_int* k, lapack_int* l,\n                    lapack_complex_double* u, lapack_int* ldu,\n                    lapack_complex_double* v, lapack_int* ldv,\n                    lapack_complex_double* q, lapack_int* ldq,\n                    lapack_int* iwork, double* rwork,\n                    lapack_complex_double* tau, lapack_complex_double* work,\n                    lapack_int *info );\nvoid LAPACK_stgsja( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* p, lapack_int* n, lapack_int* k, lapack_int* l,\n                    float* a, lapack_int* lda, float* b, lapack_int* ldb,\n                    float* tola, float* tolb, float* alpha, float* beta,\n                    float* u, lapack_int* ldu, float* v, lapack_int* ldv,\n                    float* q, lapack_int* ldq, float* work, lapack_int* ncycle,\n                    lapack_int *info );\nvoid LAPACK_dtgsja( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* p, lapack_int* n, lapack_int* k, lapack_int* l,\n                    double* a, lapack_int* lda, double* b, lapack_int* ldb,\n                    double* tola, double* tolb, double* alpha, double* beta,\n                    double* u, lapack_int* ldu, double* v, lapack_int* ldv,\n                    double* q, lapack_int* ldq, double* work,\n                    lapack_int* ncycle, lapack_int *info );\nvoid LAPACK_ctgsja( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* p, lapack_int* n, lapack_int* k, lapack_int* l,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb, float* tola,\n                    float* tolb, float* alpha, float* beta,\n                    lapack_complex_float* u, lapack_int* ldu,\n                    lapack_complex_float* v, lapack_int* ldv,\n                    lapack_complex_float* q, lapack_int* ldq,\n                    lapack_complex_float* work, lapack_int* ncycle,\n                    lapack_int *info );\nvoid LAPACK_ztgsja( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* p, lapack_int* n, lapack_int* k, lapack_int* l,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb, double* tola,\n                    double* tolb, double* alpha, double* beta,\n                    lapack_complex_double* u, lapack_int* ldu,\n                    lapack_complex_double* v, lapack_int* ldv,\n                    lapack_complex_double* q, lapack_int* ldq,\n                    lapack_complex_double* work, lapack_int* ncycle,\n                    lapack_int *info );\nvoid LAPACK_sgels( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs,\n                   float* a, lapack_int* lda, float* b, lapack_int* ldb,\n                   float* work, lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dgels( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs,\n                   double* a, lapack_int* lda, double* b, lapack_int* ldb,\n                   double* work, lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cgels( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_float* a, lapack_int* lda,\n                   lapack_complex_float* b, lapack_int* ldb,\n                   lapack_complex_float* work, lapack_int* lwork,\n                   lapack_int *info );\nvoid LAPACK_zgels( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs,\n                   lapack_complex_double* a, lapack_int* lda,\n                   lapack_complex_double* b, lapack_int* ldb,\n                   lapack_complex_double* work, lapack_int* lwork,\n                   lapack_int *info );\nvoid LAPACK_sgelsy( lapack_int* m, lapack_int* n, lapack_int* nrhs, float* a,\n                    lapack_int* lda, float* b, lapack_int* ldb,\n                    lapack_int* jpvt, float* rcond, lapack_int* rank,\n                    float* work, lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dgelsy( lapack_int* m, lapack_int* n, lapack_int* nrhs, double* a,\n                    lapack_int* lda, double* b, lapack_int* ldb,\n                    lapack_int* jpvt, double* rcond, lapack_int* rank,\n                    double* work, lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cgelsy( lapack_int* m, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb, lapack_int* jpvt,\n                    float* rcond, lapack_int* rank, lapack_complex_float* work,\n                    lapack_int* lwork, float* rwork, lapack_int *info );\nvoid LAPACK_zgelsy( lapack_int* m, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb, lapack_int* jpvt,\n                    double* rcond, lapack_int* rank,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_sgelss( lapack_int* m, lapack_int* n, lapack_int* nrhs, float* a,\n                    lapack_int* lda, float* b, lapack_int* ldb, float* s,\n                    float* rcond, lapack_int* rank, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dgelss( lapack_int* m, lapack_int* n, lapack_int* nrhs, double* a,\n                    lapack_int* lda, double* b, lapack_int* ldb, double* s,\n                    double* rcond, lapack_int* rank, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cgelss( lapack_int* m, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb, float* s,\n                    float* rcond, lapack_int* rank, lapack_complex_float* work,\n                    lapack_int* lwork, float* rwork, lapack_int *info );\nvoid LAPACK_zgelss( lapack_int* m, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb, double* s,\n                    double* rcond, lapack_int* rank,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_sgelsd( lapack_int* m, lapack_int* n, lapack_int* nrhs, float* a,\n                    lapack_int* lda, float* b, lapack_int* ldb, float* s,\n                    float* rcond, lapack_int* rank, float* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dgelsd( lapack_int* m, lapack_int* n, lapack_int* nrhs, double* a,\n                    lapack_int* lda, double* b, lapack_int* ldb, double* s,\n                    double* rcond, lapack_int* rank, double* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cgelsd( lapack_int* m, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb, float* s,\n                    float* rcond, lapack_int* rank, lapack_complex_float* work,\n                    lapack_int* lwork, float* rwork, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_zgelsd( lapack_int* m, lapack_int* n, lapack_int* nrhs,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb, double* s,\n                    double* rcond, lapack_int* rank,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_sgglse( lapack_int* m, lapack_int* n, lapack_int* p, float* a,\n                    lapack_int* lda, float* b, lapack_int* ldb, float* c,\n                    float* d, float* x, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dgglse( lapack_int* m, lapack_int* n, lapack_int* p, double* a,\n                    lapack_int* lda, double* b, lapack_int* ldb, double* c,\n                    double* d, double* x, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cgglse( lapack_int* m, lapack_int* n, lapack_int* p,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* c, lapack_complex_float* d,\n                    lapack_complex_float* x, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zgglse( lapack_int* m, lapack_int* n, lapack_int* p,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* c, lapack_complex_double* d,\n                    lapack_complex_double* x, lapack_complex_double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sggglm( lapack_int* n, lapack_int* m, lapack_int* p, float* a,\n                    lapack_int* lda, float* b, lapack_int* ldb, float* d,\n                    float* x, float* y, float* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_dggglm( lapack_int* n, lapack_int* m, lapack_int* p, double* a,\n                    lapack_int* lda, double* b, lapack_int* ldb, double* d,\n                    double* x, double* y, double* work, lapack_int* lwork,\n                    lapack_int *info );\nvoid LAPACK_cggglm( lapack_int* n, lapack_int* m, lapack_int* p,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* d, lapack_complex_float* x,\n                    lapack_complex_float* y, lapack_complex_float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_zggglm( lapack_int* n, lapack_int* m, lapack_int* p,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* d, lapack_complex_double* x,\n                    lapack_complex_double* y, lapack_complex_double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_ssyev( char* jobz, char* uplo, lapack_int* n, float* a,\n                   lapack_int* lda, float* w, float* work, lapack_int* lwork,\n                   lapack_int *info );\nvoid LAPACK_dsyev( char* jobz, char* uplo, lapack_int* n, double* a,\n                   lapack_int* lda, double* w, double* work, lapack_int* lwork,\n                   lapack_int *info );\nvoid LAPACK_cheev( char* jobz, char* uplo, lapack_int* n,\n                   lapack_complex_float* a, lapack_int* lda, float* w,\n                   lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                   lapack_int *info );\nvoid LAPACK_zheev( char* jobz, char* uplo, lapack_int* n,\n                   lapack_complex_double* a, lapack_int* lda, double* w,\n                   lapack_complex_double* work, lapack_int* lwork,\n                   double* rwork, lapack_int *info );\nvoid LAPACK_ssyevd( char* jobz, char* uplo, lapack_int* n, float* a,\n                    lapack_int* lda, float* w, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dsyevd( char* jobz, char* uplo, lapack_int* n, double* a,\n                    lapack_int* lda, double* w, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_cheevd( char* jobz, char* uplo, lapack_int* n,\n                    lapack_complex_float* a, lapack_int* lda, float* w,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_int *info );\nvoid LAPACK_zheevd( char* jobz, char* uplo, lapack_int* n,\n                    lapack_complex_double* a, lapack_int* lda, double* w,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int* lrwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_ssyevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    float* a, lapack_int* lda, float* vl, float* vu,\n                    lapack_int* il, lapack_int* iu, float* abstol,\n                    lapack_int* m, float* w, float* z, lapack_int* ldz,\n                    float* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_dsyevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    double* a, lapack_int* lda, double* vl, double* vu,\n                    lapack_int* il, lapack_int* iu, double* abstol,\n                    lapack_int* m, double* w, double* z, lapack_int* ldz,\n                    double* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_cheevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_complex_float* a, lapack_int* lda, float* vl,\n                    float* vu, lapack_int* il, lapack_int* iu, float* abstol,\n                    lapack_int* m, float* w, lapack_complex_float* z,\n                    lapack_int* ldz, lapack_complex_float* work,\n                    lapack_int* lwork, float* rwork, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_zheevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_complex_double* a, lapack_int* lda, double* vl,\n                    double* vu, lapack_int* il, lapack_int* iu, double* abstol,\n                    lapack_int* m, double* w, lapack_complex_double* z,\n                    lapack_int* ldz, lapack_complex_double* work,\n                    lapack_int* lwork, double* rwork, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_ssyevr( char* jobz, char* range, char* uplo, lapack_int* n,\n                    float* a, lapack_int* lda, float* vl, float* vu,\n                    lapack_int* il, lapack_int* iu, float* abstol,\n                    lapack_int* m, float* w, float* z, lapack_int* ldz,\n                    lapack_int* isuppz, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dsyevr( char* jobz, char* range, char* uplo, lapack_int* n,\n                    double* a, lapack_int* lda, double* vl, double* vu,\n                    lapack_int* il, lapack_int* iu, double* abstol,\n                    lapack_int* m, double* w, double* z, lapack_int* ldz,\n                    lapack_int* isuppz, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_cheevr( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_complex_float* a, lapack_int* lda, float* vl,\n                    float* vu, lapack_int* il, lapack_int* iu, float* abstol,\n                    lapack_int* m, float* w, lapack_complex_float* z,\n                    lapack_int* ldz, lapack_int* isuppz,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_int *info );\nvoid LAPACK_zheevr( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_complex_double* a, lapack_int* lda, double* vl,\n                    double* vu, lapack_int* il, lapack_int* iu, double* abstol,\n                    lapack_int* m, double* w, lapack_complex_double* z,\n                    lapack_int* ldz, lapack_int* isuppz,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int* lrwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_sspev( char* jobz, char* uplo, lapack_int* n, float* ap, float* w,\n                   float* z, lapack_int* ldz, float* work, lapack_int *info );\nvoid LAPACK_dspev( char* jobz, char* uplo, lapack_int* n, double* ap, double* w,\n                   double* z, lapack_int* ldz, double* work, lapack_int *info );\nvoid LAPACK_chpev( char* jobz, char* uplo, lapack_int* n,\n                   lapack_complex_float* ap, float* w, lapack_complex_float* z,\n                   lapack_int* ldz, lapack_complex_float* work, float* rwork,\n                   lapack_int *info );\nvoid LAPACK_zhpev( char* jobz, char* uplo, lapack_int* n,\n                   lapack_complex_double* ap, double* w,\n                   lapack_complex_double* z, lapack_int* ldz,\n                   lapack_complex_double* work, double* rwork,\n                   lapack_int *info );\nvoid LAPACK_sspevd( char* jobz, char* uplo, lapack_int* n, float* ap, float* w,\n                    float* z, lapack_int* ldz, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dspevd( char* jobz, char* uplo, lapack_int* n, double* ap,\n                    double* w, double* z, lapack_int* ldz, double* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_int *info );\nvoid LAPACK_chpevd( char* jobz, char* uplo, lapack_int* n,\n                    lapack_complex_float* ap, float* w, lapack_complex_float* z,\n                    lapack_int* ldz, lapack_complex_float* work,\n                    lapack_int* lwork, float* rwork, lapack_int* lrwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_zhpevd( char* jobz, char* uplo, lapack_int* n,\n                    lapack_complex_double* ap, double* w,\n                    lapack_complex_double* z, lapack_int* ldz,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int* lrwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_sspevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    float* ap, float* vl, float* vu, lapack_int* il,\n                    lapack_int* iu, float* abstol, lapack_int* m, float* w,\n                    float* z, lapack_int* ldz, float* work, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_dspevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    double* ap, double* vl, double* vu, lapack_int* il,\n                    lapack_int* iu, double* abstol, lapack_int* m, double* w,\n                    double* z, lapack_int* ldz, double* work, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_chpevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_complex_float* ap, float* vl, float* vu,\n                    lapack_int* il, lapack_int* iu, float* abstol,\n                    lapack_int* m, float* w, lapack_complex_float* z,\n                    lapack_int* ldz, lapack_complex_float* work, float* rwork,\n                    lapack_int* iwork, lapack_int* ifail, lapack_int *info );\nvoid LAPACK_zhpevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_complex_double* ap, double* vl, double* vu,\n                    lapack_int* il, lapack_int* iu, double* abstol,\n                    lapack_int* m, double* w, lapack_complex_double* z,\n                    lapack_int* ldz, lapack_complex_double* work, double* rwork,\n                    lapack_int* iwork, lapack_int* ifail, lapack_int *info );\nvoid LAPACK_ssbev( char* jobz, char* uplo, lapack_int* n, lapack_int* kd,\n                   float* ab, lapack_int* ldab, float* w, float* z,\n                   lapack_int* ldz, float* work, lapack_int *info );\nvoid LAPACK_dsbev( char* jobz, char* uplo, lapack_int* n, lapack_int* kd,\n                   double* ab, lapack_int* ldab, double* w, double* z,\n                   lapack_int* ldz, double* work, lapack_int *info );\nvoid LAPACK_chbev( char* jobz, char* uplo, lapack_int* n, lapack_int* kd,\n                   lapack_complex_float* ab, lapack_int* ldab, float* w,\n                   lapack_complex_float* z, lapack_int* ldz,\n                   lapack_complex_float* work, float* rwork, lapack_int *info );\nvoid LAPACK_zhbev( char* jobz, char* uplo, lapack_int* n, lapack_int* kd,\n                   lapack_complex_double* ab, lapack_int* ldab, double* w,\n                   lapack_complex_double* z, lapack_int* ldz,\n                   lapack_complex_double* work, double* rwork,\n                   lapack_int *info );\nvoid LAPACK_ssbevd( char* jobz, char* uplo, lapack_int* n, lapack_int* kd,\n                    float* ab, lapack_int* ldab, float* w, float* z,\n                    lapack_int* ldz, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dsbevd( char* jobz, char* uplo, lapack_int* n, lapack_int* kd,\n                    double* ab, lapack_int* ldab, double* w, double* z,\n                    lapack_int* ldz, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_chbevd( char* jobz, char* uplo, lapack_int* n, lapack_int* kd,\n                    lapack_complex_float* ab, lapack_int* ldab, float* w,\n                    lapack_complex_float* z, lapack_int* ldz,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_int *info );\nvoid LAPACK_zhbevd( char* jobz, char* uplo, lapack_int* n, lapack_int* kd,\n                    lapack_complex_double* ab, lapack_int* ldab, double* w,\n                    lapack_complex_double* z, lapack_int* ldz,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int* lrwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_ssbevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_int* kd, float* ab, lapack_int* ldab, float* q,\n                    lapack_int* ldq, float* vl, float* vu, lapack_int* il,\n                    lapack_int* iu, float* abstol, lapack_int* m, float* w,\n                    float* z, lapack_int* ldz, float* work, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_dsbevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_int* kd, double* ab, lapack_int* ldab, double* q,\n                    lapack_int* ldq, double* vl, double* vu, lapack_int* il,\n                    lapack_int* iu, double* abstol, lapack_int* m, double* w,\n                    double* z, lapack_int* ldz, double* work, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_chbevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_int* kd, lapack_complex_float* ab, lapack_int* ldab,\n                    lapack_complex_float* q, lapack_int* ldq, float* vl,\n                    float* vu, lapack_int* il, lapack_int* iu, float* abstol,\n                    lapack_int* m, float* w, lapack_complex_float* z,\n                    lapack_int* ldz, lapack_complex_float* work, float* rwork,\n                    lapack_int* iwork, lapack_int* ifail, lapack_int *info );\nvoid LAPACK_zhbevx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_int* kd, lapack_complex_double* ab, lapack_int* ldab,\n                    lapack_complex_double* q, lapack_int* ldq, double* vl,\n                    double* vu, lapack_int* il, lapack_int* iu, double* abstol,\n                    lapack_int* m, double* w, lapack_complex_double* z,\n                    lapack_int* ldz, lapack_complex_double* work, double* rwork,\n                    lapack_int* iwork, lapack_int* ifail, lapack_int *info );\nvoid LAPACK_sstev( char* jobz, lapack_int* n, float* d, float* e, float* z,\n                   lapack_int* ldz, float* work, lapack_int *info );\nvoid LAPACK_dstev( char* jobz, lapack_int* n, double* d, double* e, double* z,\n                   lapack_int* ldz, double* work, lapack_int *info );\nvoid LAPACK_sstevd( char* jobz, lapack_int* n, float* d, float* e, float* z,\n                    lapack_int* ldz, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dstevd( char* jobz, lapack_int* n, double* d, double* e, double* z,\n                    lapack_int* ldz, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_sstevx( char* jobz, char* range, lapack_int* n, float* d, float* e,\n                    float* vl, float* vu, lapack_int* il, lapack_int* iu,\n                    float* abstol, lapack_int* m, float* w, float* z,\n                    lapack_int* ldz, float* work, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_dstevx( char* jobz, char* range, lapack_int* n, double* d,\n                    double* e, double* vl, double* vu, lapack_int* il,\n                    lapack_int* iu, double* abstol, lapack_int* m, double* w,\n                    double* z, lapack_int* ldz, double* work, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_sstevr( char* jobz, char* range, lapack_int* n, float* d, float* e,\n                    float* vl, float* vu, lapack_int* il, lapack_int* iu,\n                    float* abstol, lapack_int* m, float* w, float* z,\n                    lapack_int* ldz, lapack_int* isuppz, float* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_int *info );\nvoid LAPACK_dstevr( char* jobz, char* range, lapack_int* n, double* d,\n                    double* e, double* vl, double* vu, lapack_int* il,\n                    lapack_int* iu, double* abstol, lapack_int* m, double* w,\n                    double* z, lapack_int* ldz, lapack_int* isuppz,\n                    double* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_sgees( char* jobvs, char* sort, LAPACK_S_SELECT2 select,\n                   lapack_int* n, float* a, lapack_int* lda, lapack_int* sdim,\n                   float* wr, float* wi, float* vs, lapack_int* ldvs,\n                   float* work, lapack_int* lwork, lapack_logical* bwork,\n                   lapack_int *info );\nvoid LAPACK_dgees( char* jobvs, char* sort, LAPACK_D_SELECT2 select,\n                   lapack_int* n, double* a, lapack_int* lda, lapack_int* sdim,\n                   double* wr, double* wi, double* vs, lapack_int* ldvs,\n                   double* work, lapack_int* lwork, lapack_logical* bwork,\n                   lapack_int *info );\nvoid LAPACK_cgees( char* jobvs, char* sort, LAPACK_C_SELECT1 select,\n                   lapack_int* n, lapack_complex_float* a, lapack_int* lda,\n                   lapack_int* sdim, lapack_complex_float* w,\n                   lapack_complex_float* vs, lapack_int* ldvs,\n                   lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                   lapack_logical* bwork, lapack_int *info );\nvoid LAPACK_zgees( char* jobvs, char* sort, LAPACK_Z_SELECT1 select,\n                   lapack_int* n, lapack_complex_double* a, lapack_int* lda,\n                   lapack_int* sdim, lapack_complex_double* w,\n                   lapack_complex_double* vs, lapack_int* ldvs,\n                   lapack_complex_double* work, lapack_int* lwork,\n                   double* rwork, lapack_logical* bwork, lapack_int *info );\nvoid LAPACK_sgeesx( char* jobvs, char* sort, LAPACK_S_SELECT2 select,\n                    char* sense, lapack_int* n, float* a, lapack_int* lda,\n                    lapack_int* sdim, float* wr, float* wi, float* vs,\n                    lapack_int* ldvs, float* rconde, float* rcondv, float* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_logical* bwork, lapack_int *info );\nvoid LAPACK_dgeesx( char* jobvs, char* sort, LAPACK_D_SELECT2 select,\n                    char* sense, lapack_int* n, double* a, lapack_int* lda,\n                    lapack_int* sdim, double* wr, double* wi, double* vs,\n                    lapack_int* ldvs, double* rconde, double* rcondv,\n                    double* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_logical* bwork,\n                    lapack_int *info );\nvoid LAPACK_cgeesx( char* jobvs, char* sort, LAPACK_C_SELECT1 select,\n                    char* sense, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int* sdim, lapack_complex_float* w,\n                    lapack_complex_float* vs, lapack_int* ldvs, float* rconde,\n                    float* rcondv, lapack_complex_float* work,\n                    lapack_int* lwork, float* rwork, lapack_logical* bwork,\n                    lapack_int *info );\nvoid LAPACK_zgeesx( char* jobvs, char* sort, LAPACK_Z_SELECT1 select,\n                    char* sense, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int* sdim, lapack_complex_double* w,\n                    lapack_complex_double* vs, lapack_int* ldvs, double* rconde,\n                    double* rcondv, lapack_complex_double* work,\n                    lapack_int* lwork, double* rwork, lapack_logical* bwork,\n                    lapack_int *info );\nvoid LAPACK_sgeev( char* jobvl, char* jobvr, lapack_int* n, float* a,\n                   lapack_int* lda, float* wr, float* wi, float* vl,\n                   lapack_int* ldvl, float* vr, lapack_int* ldvr, float* work,\n                   lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dgeev( char* jobvl, char* jobvr, lapack_int* n, double* a,\n                   lapack_int* lda, double* wr, double* wi, double* vl,\n                   lapack_int* ldvl, double* vr, lapack_int* ldvr, double* work,\n                   lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cgeev( char* jobvl, char* jobvr, lapack_int* n,\n                   lapack_complex_float* a, lapack_int* lda,\n                   lapack_complex_float* w, lapack_complex_float* vl,\n                   lapack_int* ldvl, lapack_complex_float* vr, lapack_int* ldvr,\n                   lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                   lapack_int *info );\nvoid LAPACK_zgeev( char* jobvl, char* jobvr, lapack_int* n,\n                   lapack_complex_double* a, lapack_int* lda,\n                   lapack_complex_double* w, lapack_complex_double* vl,\n                   lapack_int* ldvl, lapack_complex_double* vr,\n                   lapack_int* ldvr, lapack_complex_double* work,\n                   lapack_int* lwork, double* rwork, lapack_int *info );\nvoid LAPACK_sgeevx( char* balanc, char* jobvl, char* jobvr, char* sense,\n                    lapack_int* n, float* a, lapack_int* lda, float* wr,\n                    float* wi, float* vl, lapack_int* ldvl, float* vr,\n                    lapack_int* ldvr, lapack_int* ilo, lapack_int* ihi,\n                    float* scale, float* abnrm, float* rconde, float* rcondv,\n                    float* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_dgeevx( char* balanc, char* jobvl, char* jobvr, char* sense,\n                    lapack_int* n, double* a, lapack_int* lda, double* wr,\n                    double* wi, double* vl, lapack_int* ldvl, double* vr,\n                    lapack_int* ldvr, lapack_int* ilo, lapack_int* ihi,\n                    double* scale, double* abnrm, double* rconde,\n                    double* rcondv, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cgeevx( char* balanc, char* jobvl, char* jobvr, char* sense,\n                    lapack_int* n, lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* w, lapack_complex_float* vl,\n                    lapack_int* ldvl, lapack_complex_float* vr,\n                    lapack_int* ldvr, lapack_int* ilo, lapack_int* ihi,\n                    float* scale, float* abnrm, float* rconde, float* rcondv,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zgeevx( char* balanc, char* jobvl, char* jobvr, char* sense,\n                    lapack_int* n, lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* w, lapack_complex_double* vl,\n                    lapack_int* ldvl, lapack_complex_double* vr,\n                    lapack_int* ldvr, lapack_int* ilo, lapack_int* ihi,\n                    double* scale, double* abnrm, double* rconde,\n                    double* rcondv, lapack_complex_double* work,\n                    lapack_int* lwork, double* rwork, lapack_int *info );\nvoid LAPACK_sgesvd( char* jobu, char* jobvt, lapack_int* m, lapack_int* n,\n                    float* a, lapack_int* lda, float* s, float* u,\n                    lapack_int* ldu, float* vt, lapack_int* ldvt, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dgesvd( char* jobu, char* jobvt, lapack_int* m, lapack_int* n,\n                    double* a, lapack_int* lda, double* s, double* u,\n                    lapack_int* ldu, double* vt, lapack_int* ldvt, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cgesvd( char* jobu, char* jobvt, lapack_int* m, lapack_int* n,\n                    lapack_complex_float* a, lapack_int* lda, float* s,\n                    lapack_complex_float* u, lapack_int* ldu,\n                    lapack_complex_float* vt, lapack_int* ldvt,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int *info );\nvoid LAPACK_zgesvd( char* jobu, char* jobvt, lapack_int* m, lapack_int* n,\n                    lapack_complex_double* a, lapack_int* lda, double* s,\n                    lapack_complex_double* u, lapack_int* ldu,\n                    lapack_complex_double* vt, lapack_int* ldvt,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int *info );\nvoid LAPACK_sgesdd( char* jobz, lapack_int* m, lapack_int* n, float* a,\n                    lapack_int* lda, float* s, float* u, lapack_int* ldu,\n                    float* vt, lapack_int* ldvt, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dgesdd( char* jobz, lapack_int* m, lapack_int* n, double* a,\n                    lapack_int* lda, double* s, double* u, lapack_int* ldu,\n                    double* vt, lapack_int* ldvt, double* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cgesdd( char* jobz, lapack_int* m, lapack_int* n,\n                    lapack_complex_float* a, lapack_int* lda, float* s,\n                    lapack_complex_float* u, lapack_int* ldu,\n                    lapack_complex_float* vt, lapack_int* ldvt,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_zgesdd( char* jobz, lapack_int* m, lapack_int* n,\n                    lapack_complex_double* a, lapack_int* lda, double* s,\n                    lapack_complex_double* u, lapack_int* ldu,\n                    lapack_complex_double* vt, lapack_int* ldvt,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dgejsv( char* joba, char* jobu, char* jobv, char* jobr, char* jobt,\n                    char* jobp, lapack_int* m, lapack_int* n, double* a,\n                    lapack_int* lda, double* sva, double* u, lapack_int* ldu,\n                    double* v, lapack_int* ldv, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_sgejsv( char* joba, char* jobu, char* jobv, char* jobr, char* jobt,\n                    char* jobp, lapack_int* m, lapack_int* n, float* a,\n                    lapack_int* lda, float* sva, float* u, lapack_int* ldu,\n                    float* v, lapack_int* ldv, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dgesvj( char* joba, char* jobu, char* jobv, lapack_int* m,\n                    lapack_int* n, double* a, lapack_int* lda, double* sva,\n                    lapack_int* mv, double* v, lapack_int* ldv, double* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sgesvj( char* joba, char* jobu, char* jobv, lapack_int* m,\n                    lapack_int* n, float* a, lapack_int* lda, float* sva,\n                    lapack_int* mv, float* v, lapack_int* ldv, float* work,\n                    lapack_int* lwork, lapack_int *info );\nvoid LAPACK_sggsvd( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l,\n                    float* a, lapack_int* lda, float* b, lapack_int* ldb,\n                    float* alpha, float* beta, float* u, lapack_int* ldu,\n                    float* v, lapack_int* ldv, float* q, lapack_int* ldq,\n                    float* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_dggsvd( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l,\n                    double* a, lapack_int* lda, double* b, lapack_int* ldb,\n                    double* alpha, double* beta, double* u, lapack_int* ldu,\n                    double* v, lapack_int* ldv, double* q, lapack_int* ldq,\n                    double* work, lapack_int* iwork, lapack_int *info );\nvoid LAPACK_cggsvd( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb, float* alpha,\n                    float* beta, lapack_complex_float* u, lapack_int* ldu,\n                    lapack_complex_float* v, lapack_int* ldv,\n                    lapack_complex_float* q, lapack_int* ldq,\n                    lapack_complex_float* work, float* rwork, lapack_int* iwork,\n                    lapack_int *info );\nvoid LAPACK_zggsvd( char* jobu, char* jobv, char* jobq, lapack_int* m,\n                    lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb, double* alpha,\n                    double* beta, lapack_complex_double* u, lapack_int* ldu,\n                    lapack_complex_double* v, lapack_int* ldv,\n                    lapack_complex_double* q, lapack_int* ldq,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int* iwork, lapack_int *info );\nvoid LAPACK_ssygv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                   float* a, lapack_int* lda, float* b, lapack_int* ldb,\n                   float* w, float* work, lapack_int* lwork, lapack_int *info );\nvoid LAPACK_dsygv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                   double* a, lapack_int* lda, double* b, lapack_int* ldb,\n                   double* w, double* work, lapack_int* lwork,\n                   lapack_int *info );\nvoid LAPACK_chegv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                   lapack_complex_float* a, lapack_int* lda,\n                   lapack_complex_float* b, lapack_int* ldb, float* w,\n                   lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                   lapack_int *info );\nvoid LAPACK_zhegv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                   lapack_complex_double* a, lapack_int* lda,\n                   lapack_complex_double* b, lapack_int* ldb, double* w,\n                   lapack_complex_double* work, lapack_int* lwork,\n                   double* rwork, lapack_int *info );\nvoid LAPACK_ssygvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                    float* a, lapack_int* lda, float* b, lapack_int* ldb,\n                    float* w, float* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dsygvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                    double* a, lapack_int* lda, double* b, lapack_int* ldb,\n                    double* w, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_chegvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb, float* w,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_int *info );\nvoid LAPACK_zhegvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb, double* w,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int* lrwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_ssygvx( lapack_int* itype, char* jobz, char* range, char* uplo,\n                    lapack_int* n, float* a, lapack_int* lda, float* b,\n                    lapack_int* ldb, float* vl, float* vu, lapack_int* il,\n                    lapack_int* iu, float* abstol, lapack_int* m, float* w,\n                    float* z, lapack_int* ldz, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* ifail, lapack_int *info );\nvoid LAPACK_dsygvx( lapack_int* itype, char* jobz, char* range, char* uplo,\n                    lapack_int* n, double* a, lapack_int* lda, double* b,\n                    lapack_int* ldb, double* vl, double* vu, lapack_int* il,\n                    lapack_int* iu, double* abstol, lapack_int* m, double* w,\n                    double* z, lapack_int* ldz, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* ifail, lapack_int *info );\nvoid LAPACK_chegvx( lapack_int* itype, char* jobz, char* range, char* uplo,\n                    lapack_int* n, lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb, float* vl,\n                    float* vu, lapack_int* il, lapack_int* iu, float* abstol,\n                    lapack_int* m, float* w, lapack_complex_float* z,\n                    lapack_int* ldz, lapack_complex_float* work,\n                    lapack_int* lwork, float* rwork, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_zhegvx( lapack_int* itype, char* jobz, char* range, char* uplo,\n                    lapack_int* n, lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb, double* vl,\n                    double* vu, lapack_int* il, lapack_int* iu, double* abstol,\n                    lapack_int* m, double* w, lapack_complex_double* z,\n                    lapack_int* ldz, lapack_complex_double* work,\n                    lapack_int* lwork, double* rwork, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_sspgv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                   float* ap, float* bp, float* w, float* z, lapack_int* ldz,\n                   float* work, lapack_int *info );\nvoid LAPACK_dspgv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                   double* ap, double* bp, double* w, double* z,\n                   lapack_int* ldz, double* work, lapack_int *info );\nvoid LAPACK_chpgv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                   lapack_complex_float* ap, lapack_complex_float* bp, float* w,\n                   lapack_complex_float* z, lapack_int* ldz,\n                   lapack_complex_float* work, float* rwork, lapack_int *info );\nvoid LAPACK_zhpgv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                   lapack_complex_double* ap, lapack_complex_double* bp,\n                   double* w, lapack_complex_double* z, lapack_int* ldz,\n                   lapack_complex_double* work, double* rwork,\n                   lapack_int *info );\nvoid LAPACK_sspgvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                    float* ap, float* bp, float* w, float* z, lapack_int* ldz,\n                    float* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dspgvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                    double* ap, double* bp, double* w, double* z,\n                    lapack_int* ldz, double* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_int* liwork, lapack_int *info );\nvoid LAPACK_chpgvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                    lapack_complex_float* ap, lapack_complex_float* bp,\n                    float* w, lapack_complex_float* z, lapack_int* ldz,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_int *info );\nvoid LAPACK_zhpgvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n,\n                    lapack_complex_double* ap, lapack_complex_double* bp,\n                    double* w, lapack_complex_double* z, lapack_int* ldz,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int* lrwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_sspgvx( lapack_int* itype, char* jobz, char* range, char* uplo,\n                    lapack_int* n, float* ap, float* bp, float* vl, float* vu,\n                    lapack_int* il, lapack_int* iu, float* abstol,\n                    lapack_int* m, float* w, float* z, lapack_int* ldz,\n                    float* work, lapack_int* iwork, lapack_int* ifail,\n                    lapack_int *info );\nvoid LAPACK_dspgvx( lapack_int* itype, char* jobz, char* range, char* uplo,\n                    lapack_int* n, double* ap, double* bp, double* vl,\n                    double* vu, lapack_int* il, lapack_int* iu, double* abstol,\n                    lapack_int* m, double* w, double* z, lapack_int* ldz,\n                    double* work, lapack_int* iwork, lapack_int* ifail,\n                    lapack_int *info );\nvoid LAPACK_chpgvx( lapack_int* itype, char* jobz, char* range, char* uplo,\n                    lapack_int* n, lapack_complex_float* ap,\n                    lapack_complex_float* bp, float* vl, float* vu,\n                    lapack_int* il, lapack_int* iu, float* abstol,\n                    lapack_int* m, float* w, lapack_complex_float* z,\n                    lapack_int* ldz, lapack_complex_float* work, float* rwork,\n                    lapack_int* iwork, lapack_int* ifail, lapack_int *info );\nvoid LAPACK_zhpgvx( lapack_int* itype, char* jobz, char* range, char* uplo,\n                    lapack_int* n, lapack_complex_double* ap,\n                    lapack_complex_double* bp, double* vl, double* vu,\n                    lapack_int* il, lapack_int* iu, double* abstol,\n                    lapack_int* m, double* w, lapack_complex_double* z,\n                    lapack_int* ldz, lapack_complex_double* work, double* rwork,\n                    lapack_int* iwork, lapack_int* ifail, lapack_int *info );\nvoid LAPACK_ssbgv( char* jobz, char* uplo, lapack_int* n, lapack_int* ka,\n                   lapack_int* kb, float* ab, lapack_int* ldab, float* bb,\n                   lapack_int* ldbb, float* w, float* z, lapack_int* ldz,\n                   float* work, lapack_int *info );\nvoid LAPACK_dsbgv( char* jobz, char* uplo, lapack_int* n, lapack_int* ka,\n                   lapack_int* kb, double* ab, lapack_int* ldab, double* bb,\n                   lapack_int* ldbb, double* w, double* z, lapack_int* ldz,\n                   double* work, lapack_int *info );\nvoid LAPACK_chbgv( char* jobz, char* uplo, lapack_int* n, lapack_int* ka,\n                   lapack_int* kb, lapack_complex_float* ab, lapack_int* ldab,\n                   lapack_complex_float* bb, lapack_int* ldbb, float* w,\n                   lapack_complex_float* z, lapack_int* ldz,\n                   lapack_complex_float* work, float* rwork, lapack_int *info );\nvoid LAPACK_zhbgv( char* jobz, char* uplo, lapack_int* n, lapack_int* ka,\n                   lapack_int* kb, lapack_complex_double* ab, lapack_int* ldab,\n                   lapack_complex_double* bb, lapack_int* ldbb, double* w,\n                   lapack_complex_double* z, lapack_int* ldz,\n                   lapack_complex_double* work, double* rwork,\n                   lapack_int *info );\nvoid LAPACK_ssbgvd( char* jobz, char* uplo, lapack_int* n, lapack_int* ka,\n                    lapack_int* kb, float* ab, lapack_int* ldab, float* bb,\n                    lapack_int* ldbb, float* w, float* z, lapack_int* ldz,\n                    float* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_dsbgvd( char* jobz, char* uplo, lapack_int* n, lapack_int* ka,\n                    lapack_int* kb, double* ab, lapack_int* ldab, double* bb,\n                    lapack_int* ldbb, double* w, double* z, lapack_int* ldz,\n                    double* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_chbgvd( char* jobz, char* uplo, lapack_int* n, lapack_int* ka,\n                    lapack_int* kb, lapack_complex_float* ab, lapack_int* ldab,\n                    lapack_complex_float* bb, lapack_int* ldbb, float* w,\n                    lapack_complex_float* z, lapack_int* ldz,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork,\n                    lapack_int *info );\nvoid LAPACK_zhbgvd( char* jobz, char* uplo, lapack_int* n, lapack_int* ka,\n                    lapack_int* kb, lapack_complex_double* ab, lapack_int* ldab,\n                    lapack_complex_double* bb, lapack_int* ldbb, double* w,\n                    lapack_complex_double* z, lapack_int* ldz,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int* lrwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_int *info );\nvoid LAPACK_ssbgvx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_int* ka, lapack_int* kb, float* ab, lapack_int* ldab,\n                    float* bb, lapack_int* ldbb, float* q, lapack_int* ldq,\n                    float* vl, float* vu, lapack_int* il, lapack_int* iu,\n                    float* abstol, lapack_int* m, float* w, float* z,\n                    lapack_int* ldz, float* work, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_dsbgvx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_int* ka, lapack_int* kb, double* ab,\n                    lapack_int* ldab, double* bb, lapack_int* ldbb, double* q,\n                    lapack_int* ldq, double* vl, double* vu, lapack_int* il,\n                    lapack_int* iu, double* abstol, lapack_int* m, double* w,\n                    double* z, lapack_int* ldz, double* work, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_chbgvx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_int* ka, lapack_int* kb, lapack_complex_float* ab,\n                    lapack_int* ldab, lapack_complex_float* bb,\n                    lapack_int* ldbb, lapack_complex_float* q, lapack_int* ldq,\n                    float* vl, float* vu, lapack_int* il, lapack_int* iu,\n                    float* abstol, lapack_int* m, float* w,\n                    lapack_complex_float* z, lapack_int* ldz,\n                    lapack_complex_float* work, float* rwork, lapack_int* iwork,\n                    lapack_int* ifail, lapack_int *info );\nvoid LAPACK_zhbgvx( char* jobz, char* range, char* uplo, lapack_int* n,\n                    lapack_int* ka, lapack_int* kb, lapack_complex_double* ab,\n                    lapack_int* ldab, lapack_complex_double* bb,\n                    lapack_int* ldbb, lapack_complex_double* q, lapack_int* ldq,\n                    double* vl, double* vu, lapack_int* il, lapack_int* iu,\n                    double* abstol, lapack_int* m, double* w,\n                    lapack_complex_double* z, lapack_int* ldz,\n                    lapack_complex_double* work, double* rwork,\n                    lapack_int* iwork, lapack_int* ifail, lapack_int *info );\nvoid LAPACK_sgges( char* jobvsl, char* jobvsr, char* sort,\n                   LAPACK_S_SELECT3 selctg, lapack_int* n, float* a,\n                   lapack_int* lda, float* b, lapack_int* ldb, lapack_int* sdim,\n                   float* alphar, float* alphai, float* beta, float* vsl,\n                   lapack_int* ldvsl, float* vsr, lapack_int* ldvsr,\n                   float* work, lapack_int* lwork, lapack_logical* bwork,\n                   lapack_int *info );\nvoid LAPACK_dgges( char* jobvsl, char* jobvsr, char* sort,\n                   LAPACK_D_SELECT3 selctg, lapack_int* n, double* a,\n                   lapack_int* lda, double* b, lapack_int* ldb,\n                   lapack_int* sdim, double* alphar, double* alphai,\n                   double* beta, double* vsl, lapack_int* ldvsl, double* vsr,\n                   lapack_int* ldvsr, double* work, lapack_int* lwork,\n                   lapack_logical* bwork, lapack_int *info );\nvoid LAPACK_cgges( char* jobvsl, char* jobvsr, char* sort,\n                   LAPACK_C_SELECT2 selctg, lapack_int* n,\n                   lapack_complex_float* a, lapack_int* lda,\n                   lapack_complex_float* b, lapack_int* ldb, lapack_int* sdim,\n                   lapack_complex_float* alpha, lapack_complex_float* beta,\n                   lapack_complex_float* vsl, lapack_int* ldvsl,\n                   lapack_complex_float* vsr, lapack_int* ldvsr,\n                   lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                   lapack_logical* bwork, lapack_int *info );\nvoid LAPACK_zgges( char* jobvsl, char* jobvsr, char* sort,\n                   LAPACK_Z_SELECT2 selctg, lapack_int* n,\n                   lapack_complex_double* a, lapack_int* lda,\n                   lapack_complex_double* b, lapack_int* ldb, lapack_int* sdim,\n                   lapack_complex_double* alpha, lapack_complex_double* beta,\n                   lapack_complex_double* vsl, lapack_int* ldvsl,\n                   lapack_complex_double* vsr, lapack_int* ldvsr,\n                   lapack_complex_double* work, lapack_int* lwork,\n                   double* rwork, lapack_logical* bwork, lapack_int *info );\nvoid LAPACK_sggesx( char* jobvsl, char* jobvsr, char* sort,\n                    LAPACK_S_SELECT3 selctg, char* sense, lapack_int* n,\n                    float* a, lapack_int* lda, float* b, lapack_int* ldb,\n                    lapack_int* sdim, float* alphar, float* alphai, float* beta,\n                    float* vsl, lapack_int* ldvsl, float* vsr,\n                    lapack_int* ldvsr, float* rconde, float* rcondv,\n                    float* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_logical* bwork,\n                    lapack_int *info );\nvoid LAPACK_dggesx( char* jobvsl, char* jobvsr, char* sort,\n                    LAPACK_D_SELECT3 selctg, char* sense, lapack_int* n,\n                    double* a, lapack_int* lda, double* b, lapack_int* ldb,\n                    lapack_int* sdim, double* alphar, double* alphai,\n                    double* beta, double* vsl, lapack_int* ldvsl, double* vsr,\n                    lapack_int* ldvsr, double* rconde, double* rcondv,\n                    double* work, lapack_int* lwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_logical* bwork,\n                    lapack_int *info );\nvoid LAPACK_cggesx( char* jobvsl, char* jobvsr, char* sort,\n                    LAPACK_C_SELECT2 selctg, char* sense, lapack_int* n,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb, lapack_int* sdim,\n                    lapack_complex_float* alpha, lapack_complex_float* beta,\n                    lapack_complex_float* vsl, lapack_int* ldvsl,\n                    lapack_complex_float* vsr, lapack_int* ldvsr, float* rconde,\n                    float* rcondv, lapack_complex_float* work,\n                    lapack_int* lwork, float* rwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_logical* bwork,\n                    lapack_int *info );\nvoid LAPACK_zggesx( char* jobvsl, char* jobvsr, char* sort,\n                    LAPACK_Z_SELECT2 selctg, char* sense, lapack_int* n,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb, lapack_int* sdim,\n                    lapack_complex_double* alpha, lapack_complex_double* beta,\n                    lapack_complex_double* vsl, lapack_int* ldvsl,\n                    lapack_complex_double* vsr, lapack_int* ldvsr,\n                    double* rconde, double* rcondv, lapack_complex_double* work,\n                    lapack_int* lwork, double* rwork, lapack_int* iwork,\n                    lapack_int* liwork, lapack_logical* bwork,\n                    lapack_int *info );\nvoid LAPACK_sggev( char* jobvl, char* jobvr, lapack_int* n, float* a,\n                   lapack_int* lda, float* b, lapack_int* ldb, float* alphar,\n                   float* alphai, float* beta, float* vl, lapack_int* ldvl,\n                   float* vr, lapack_int* ldvr, float* work, lapack_int* lwork,\n                   lapack_int *info );\nvoid LAPACK_dggev( char* jobvl, char* jobvr, lapack_int* n, double* a,\n                   lapack_int* lda, double* b, lapack_int* ldb, double* alphar,\n                   double* alphai, double* beta, double* vl, lapack_int* ldvl,\n                   double* vr, lapack_int* ldvr, double* work,\n                   lapack_int* lwork, lapack_int *info );\nvoid LAPACK_cggev( char* jobvl, char* jobvr, lapack_int* n,\n                   lapack_complex_float* a, lapack_int* lda,\n                   lapack_complex_float* b, lapack_int* ldb,\n                   lapack_complex_float* alpha, lapack_complex_float* beta,\n                   lapack_complex_float* vl, lapack_int* ldvl,\n                   lapack_complex_float* vr, lapack_int* ldvr,\n                   lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                   lapack_int *info );\nvoid LAPACK_zggev( char* jobvl, char* jobvr, lapack_int* n,\n                   lapack_complex_double* a, lapack_int* lda,\n                   lapack_complex_double* b, lapack_int* ldb,\n                   lapack_complex_double* alpha, lapack_complex_double* beta,\n                   lapack_complex_double* vl, lapack_int* ldvl,\n                   lapack_complex_double* vr, lapack_int* ldvr,\n                   lapack_complex_double* work, lapack_int* lwork,\n                   double* rwork, lapack_int *info );\nvoid LAPACK_sggevx( char* balanc, char* jobvl, char* jobvr, char* sense,\n                    lapack_int* n, float* a, lapack_int* lda, float* b,\n                    lapack_int* ldb, float* alphar, float* alphai, float* beta,\n                    float* vl, lapack_int* ldvl, float* vr, lapack_int* ldvr,\n                    lapack_int* ilo, lapack_int* ihi, float* lscale,\n                    float* rscale, float* abnrm, float* bbnrm, float* rconde,\n                    float* rcondv, float* work, lapack_int* lwork,\n                    lapack_int* iwork, lapack_logical* bwork,\n                    lapack_int *info );\nvoid LAPACK_dggevx( char* balanc, char* jobvl, char* jobvr, char* sense,\n                    lapack_int* n, double* a, lapack_int* lda, double* b,\n                    lapack_int* ldb, double* alphar, double* alphai,\n                    double* beta, double* vl, lapack_int* ldvl, double* vr,\n                    lapack_int* ldvr, lapack_int* ilo, lapack_int* ihi,\n                    double* lscale, double* rscale, double* abnrm,\n                    double* bbnrm, double* rconde, double* rcondv, double* work,\n                    lapack_int* lwork, lapack_int* iwork, lapack_logical* bwork,\n                    lapack_int *info );\nvoid LAPACK_cggevx( char* balanc, char* jobvl, char* jobvr, char* sense,\n                    lapack_int* n, lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    lapack_complex_float* alpha, lapack_complex_float* beta,\n                    lapack_complex_float* vl, lapack_int* ldvl,\n                    lapack_complex_float* vr, lapack_int* ldvr, lapack_int* ilo,\n                    lapack_int* ihi, float* lscale, float* rscale, float* abnrm,\n                    float* bbnrm, float* rconde, float* rcondv,\n                    lapack_complex_float* work, lapack_int* lwork, float* rwork,\n                    lapack_int* iwork, lapack_logical* bwork,\n                    lapack_int *info );\nvoid LAPACK_zggevx( char* balanc, char* jobvl, char* jobvr, char* sense,\n                    lapack_int* n, lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* alpha, lapack_complex_double* beta,\n                    lapack_complex_double* vl, lapack_int* ldvl,\n                    lapack_complex_double* vr, lapack_int* ldvr,\n                    lapack_int* ilo, lapack_int* ihi, double* lscale,\n                    double* rscale, double* abnrm, double* bbnrm,\n                    double* rconde, double* rcondv, lapack_complex_double* work,\n                    lapack_int* lwork, double* rwork, lapack_int* iwork,\n                    lapack_logical* bwork, lapack_int *info );\nvoid LAPACK_dsfrk( char* transr, char* uplo, char* trans, lapack_int* n,\n                   lapack_int* k, double* alpha, const double* a,\n                   lapack_int* lda, double* beta, double* c );\nvoid LAPACK_ssfrk( char* transr, char* uplo, char* trans, lapack_int* n,\n                   lapack_int* k, float* alpha, const float* a, lapack_int* lda,\n                   float* beta, float* c );\nvoid LAPACK_zhfrk( char* transr, char* uplo, char* trans, lapack_int* n,\n                   lapack_int* k, double* alpha, const lapack_complex_double* a,\n                   lapack_int* lda, double* beta, lapack_complex_double* c );\nvoid LAPACK_chfrk( char* transr, char* uplo, char* trans, lapack_int* n,\n                   lapack_int* k, float* alpha, const lapack_complex_float* a,\n                   lapack_int* lda, float* beta, lapack_complex_float* c );\nvoid LAPACK_dtfsm( char* transr, char* side, char* uplo, char* trans,\n                   char* diag, lapack_int* m, lapack_int* n, double* alpha,\n                   const double* a, double* b, lapack_int* ldb );\nvoid LAPACK_stfsm( char* transr, char* side, char* uplo, char* trans,\n                   char* diag, lapack_int* m, lapack_int* n, float* alpha,\n                   const float* a, float* b, lapack_int* ldb );\nvoid LAPACK_ztfsm( char* transr, char* side, char* uplo, char* trans,\n                   char* diag, lapack_int* m, lapack_int* n,\n                   lapack_complex_double* alpha, const lapack_complex_double* a,\n                   lapack_complex_double* b, lapack_int* ldb );\nvoid LAPACK_ctfsm( char* transr, char* side, char* uplo, char* trans,\n                   char* diag, lapack_int* m, lapack_int* n,\n                   lapack_complex_float* alpha, const lapack_complex_float* a,\n                   lapack_complex_float* b, lapack_int* ldb );\nvoid LAPACK_dtfttp( char* transr, char* uplo, lapack_int* n, const double* arf,\n                    double* ap, lapack_int *info );\nvoid LAPACK_stfttp( char* transr, char* uplo, lapack_int* n, const float* arf,\n                    float* ap, lapack_int *info );\nvoid LAPACK_ztfttp( char* transr, char* uplo, lapack_int* n,\n                    const lapack_complex_double* arf, lapack_complex_double* ap,\n                    lapack_int *info );\nvoid LAPACK_ctfttp( char* transr, char* uplo, lapack_int* n,\n                    const lapack_complex_float* arf, lapack_complex_float* ap,\n                    lapack_int *info );\nvoid LAPACK_dtfttr( char* transr, char* uplo, lapack_int* n, const double* arf,\n                    double* a, lapack_int* lda, lapack_int *info );\nvoid LAPACK_stfttr( char* transr, char* uplo, lapack_int* n, const float* arf,\n                    float* a, lapack_int* lda, lapack_int *info );\nvoid LAPACK_ztfttr( char* transr, char* uplo, lapack_int* n,\n                    const lapack_complex_double* arf, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_ctfttr( char* transr, char* uplo, lapack_int* n,\n                    const lapack_complex_float* arf, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_dtpttf( char* transr, char* uplo, lapack_int* n, const double* ap,\n                    double* arf, lapack_int *info );\nvoid LAPACK_stpttf( char* transr, char* uplo, lapack_int* n, const float* ap,\n                    float* arf, lapack_int *info );\nvoid LAPACK_ztpttf( char* transr, char* uplo, lapack_int* n,\n                    const lapack_complex_double* ap, lapack_complex_double* arf,\n                    lapack_int *info );\nvoid LAPACK_ctpttf( char* transr, char* uplo, lapack_int* n,\n                    const lapack_complex_float* ap, lapack_complex_float* arf,\n                    lapack_int *info );\nvoid LAPACK_dtpttr( char* uplo, lapack_int* n, const double* ap, double* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_stpttr( char* uplo, lapack_int* n, const float* ap, float* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_ztpttr( char* uplo, lapack_int* n, const lapack_complex_double* ap,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_ctpttr( char* uplo, lapack_int* n, const lapack_complex_float* ap,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_dtrttf( char* transr, char* uplo, lapack_int* n, const double* a,\n                    lapack_int* lda, double* arf, lapack_int *info );\nvoid LAPACK_strttf( char* transr, char* uplo, lapack_int* n, const float* a,\n                    lapack_int* lda, float* arf, lapack_int *info );\nvoid LAPACK_ztrttf( char* transr, char* uplo, lapack_int* n,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* arf, lapack_int *info );\nvoid LAPACK_ctrttf( char* transr, char* uplo, lapack_int* n,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* arf, lapack_int *info );\nvoid LAPACK_dtrttp( char* uplo, lapack_int* n, const double* a, lapack_int* lda,\n                    double* ap, lapack_int *info );\nvoid LAPACK_strttp( char* uplo, lapack_int* n, const float* a, lapack_int* lda,\n                    float* ap, lapack_int *info );\nvoid LAPACK_ztrttp( char* uplo, lapack_int* n, const lapack_complex_double* a,\n                    lapack_int* lda, lapack_complex_double* ap,\n                    lapack_int *info );\nvoid LAPACK_ctrttp( char* uplo, lapack_int* n, const lapack_complex_float* a,\n                    lapack_int* lda, lapack_complex_float* ap,\n                    lapack_int *info );\nvoid LAPACK_sgeqrfp( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                     float* tau, float* work, lapack_int* lwork,\n                     lapack_int *info );\nvoid LAPACK_dgeqrfp( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                     double* tau, double* work, lapack_int* lwork,\n                     lapack_int *info );\nvoid LAPACK_cgeqrfp( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                     lapack_int* lda, lapack_complex_float* tau,\n                     lapack_complex_float* work, lapack_int* lwork,\n                     lapack_int *info );\nvoid LAPACK_zgeqrfp( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                     lapack_int* lda, lapack_complex_double* tau,\n                     lapack_complex_double* work, lapack_int* lwork,\n                     lapack_int *info );\nvoid LAPACK_clacgv( lapack_int* n, lapack_complex_float* x, lapack_int* incx );\nvoid LAPACK_zlacgv( lapack_int* n, lapack_complex_double* x, lapack_int* incx );\nvoid LAPACK_slarnv( lapack_int* idist, lapack_int* iseed, lapack_int* n,\n                    float* x );\nvoid LAPACK_dlarnv( lapack_int* idist, lapack_int* iseed, lapack_int* n,\n                    double* x );\nvoid LAPACK_clarnv( lapack_int* idist, lapack_int* iseed, lapack_int* n,\n                    lapack_complex_float* x );\nvoid LAPACK_zlarnv( lapack_int* idist, lapack_int* iseed, lapack_int* n,\n                    lapack_complex_double* x );\nvoid LAPACK_sgeqr2( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    float* tau, float* work, lapack_int *info );\nvoid LAPACK_dgeqr2( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    double* tau, double* work, lapack_int *info );\nvoid LAPACK_cgeqr2( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_complex_float* tau,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zgeqr2( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_slacpy( char* uplo, lapack_int* m, lapack_int* n, const float* a,\n                    lapack_int* lda, float* b, lapack_int* ldb );\nvoid LAPACK_dlacpy( char* uplo, lapack_int* m, lapack_int* n, const double* a,\n                    lapack_int* lda, double* b, lapack_int* ldb );\nvoid LAPACK_clacpy( char* uplo, lapack_int* m, lapack_int* n,\n                    const lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb );\nvoid LAPACK_zlacpy( char* uplo, lapack_int* m, lapack_int* n,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb );\nvoid LAPACK_sgetf2( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_dgetf2( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_cgetf2( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_zgetf2( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int* ipiv, lapack_int *info );\nvoid LAPACK_slaswp( lapack_int* n, float* a, lapack_int* lda, lapack_int* k1,\n                    lapack_int* k2, const lapack_int* ipiv, lapack_int* incx );\nvoid LAPACK_dlaswp( lapack_int* n, double* a, lapack_int* lda, lapack_int* k1,\n                    lapack_int* k2, const lapack_int* ipiv, lapack_int* incx );\nvoid LAPACK_claswp( lapack_int* n, lapack_complex_float* a, lapack_int* lda,\n                    lapack_int* k1, lapack_int* k2, const lapack_int* ipiv,\n                    lapack_int* incx );\nvoid LAPACK_zlaswp( lapack_int* n, lapack_complex_double* a, lapack_int* lda,\n                    lapack_int* k1, lapack_int* k2, const lapack_int* ipiv,\n                    lapack_int* incx );\nfloat LAPACK_slange( char* norm, lapack_int* m, lapack_int* n, const float* a,\n                    lapack_int* lda, float* work );\ndouble LAPACK_dlange( char* norm, lapack_int* m, lapack_int* n, const double* a,\n                    lapack_int* lda, double* work );\nfloat LAPACK_clange( char* norm, lapack_int* m, lapack_int* n,\n                    const lapack_complex_float* a, lapack_int* lda, float* work );\ndouble LAPACK_zlange( char* norm, lapack_int* m, lapack_int* n,\n                    const lapack_complex_double* a, lapack_int* lda, double* work );\nfloat LAPACK_clanhe( char* norm, char* uplo, lapack_int* n,\n                    const lapack_complex_float* a, lapack_int* lda, float* work );\ndouble LAPACK_zlanhe( char* norm, char* uplo, lapack_int* n,\n                    const lapack_complex_double* a, lapack_int* lda, double* work );\nfloat LAPACK_slansy( char* norm, char* uplo, lapack_int* n, const float* a,\n                    lapack_int* lda, float* work );\ndouble LAPACK_dlansy( char* norm, char* uplo, lapack_int* n, const double* a,\n                    lapack_int* lda, double* work );\nfloat LAPACK_clansy( char* norm, char* uplo, lapack_int* n,\n                    const lapack_complex_float* a, lapack_int* lda, float* work );\ndouble LAPACK_zlansy( char* norm, char* uplo, lapack_int* n,\n                    const lapack_complex_double* a, lapack_int* lda, double* work );\nfloat LAPACK_slantr( char* norm, char* uplo, char* diag, lapack_int* m,\n                    lapack_int* n, const float* a, lapack_int* lda, float* work );\ndouble LAPACK_dlantr( char* norm, char* uplo, char* diag, lapack_int* m,\n                    lapack_int* n, const double* a, lapack_int* lda, double* work );\nfloat LAPACK_clantr( char* norm, char* uplo, char* diag, lapack_int* m,\n                    lapack_int* n, const lapack_complex_float* a, lapack_int* lda,\n                    float* work );\ndouble LAPACK_zlantr( char* norm, char* uplo, char* diag, lapack_int* m,\n                    lapack_int* n, const lapack_complex_double* a, lapack_int* lda,\n                    double* work );\nfloat LAPACK_slamch( char* cmach );\ndouble LAPACK_dlamch( char* cmach );\nvoid LAPACK_sgelq2( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                    float* tau, float* work, lapack_int *info );\nvoid LAPACK_dgelq2( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                    double* tau, double* work, lapack_int *info );\nvoid LAPACK_cgelq2( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_complex_float* tau,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zgelq2( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_complex_double* tau,\n                    lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_slarfb( char* side, char* trans, char* direct, char* storev,\n                    lapack_int* m, lapack_int* n, lapack_int* k, const float* v,\n                    lapack_int* ldv, const float* t, lapack_int* ldt, float* c,\n                    lapack_int* ldc, float* work, lapack_int* ldwork );\nvoid LAPACK_dlarfb( char* side, char* trans, char* direct, char* storev,\n                    lapack_int* m, lapack_int* n, lapack_int* k,\n                    const double* v, lapack_int* ldv, const double* t,\n                    lapack_int* ldt, double* c, lapack_int* ldc, double* work,\n                    lapack_int* ldwork );\nvoid LAPACK_clarfb( char* side, char* trans, char* direct, char* storev,\n                    lapack_int* m, lapack_int* n, lapack_int* k,\n                    const lapack_complex_float* v, lapack_int* ldv,\n                    const lapack_complex_float* t, lapack_int* ldt,\n                    lapack_complex_float* c, lapack_int* ldc,\n                    lapack_complex_float* work, lapack_int* ldwork );\nvoid LAPACK_zlarfb( char* side, char* trans, char* direct, char* storev,\n                    lapack_int* m, lapack_int* n, lapack_int* k,\n                    const lapack_complex_double* v, lapack_int* ldv,\n                    const lapack_complex_double* t, lapack_int* ldt,\n                    lapack_complex_double* c, lapack_int* ldc,\n                    lapack_complex_double* work, lapack_int* ldwork );\nvoid LAPACK_slarfg( lapack_int* n, float* alpha, float* x, lapack_int* incx,\n                    float* tau );\nvoid LAPACK_dlarfg( lapack_int* n, double* alpha, double* x, lapack_int* incx,\n                    double* tau );\nvoid LAPACK_clarfg( lapack_int* n, lapack_complex_float* alpha,\n                    lapack_complex_float* x, lapack_int* incx,\n                    lapack_complex_float* tau );\nvoid LAPACK_zlarfg( lapack_int* n, lapack_complex_double* alpha,\n                    lapack_complex_double* x, lapack_int* incx,\n                    lapack_complex_double* tau );\nvoid LAPACK_slarft( char* direct, char* storev, lapack_int* n, lapack_int* k,\n                    const float* v, lapack_int* ldv, const float* tau, float* t,\n                    lapack_int* ldt );\nvoid LAPACK_dlarft( char* direct, char* storev, lapack_int* n, lapack_int* k,\n                    const double* v, lapack_int* ldv, const double* tau,\n                    double* t, lapack_int* ldt );\nvoid LAPACK_clarft( char* direct, char* storev, lapack_int* n, lapack_int* k,\n                    const lapack_complex_float* v, lapack_int* ldv,\n                    const lapack_complex_float* tau, lapack_complex_float* t,\n                    lapack_int* ldt );\nvoid LAPACK_zlarft( char* direct, char* storev, lapack_int* n, lapack_int* k,\n                    const lapack_complex_double* v, lapack_int* ldv,\n                    const lapack_complex_double* tau, lapack_complex_double* t,\n                    lapack_int* ldt );\nvoid LAPACK_slarfx( char* side, lapack_int* m, lapack_int* n, const float* v,\n                    float* tau, float* c, lapack_int* ldc, float* work );\nvoid LAPACK_dlarfx( char* side, lapack_int* m, lapack_int* n, const double* v,\n                    double* tau, double* c, lapack_int* ldc, double* work );\nvoid LAPACK_clarfx( char* side, lapack_int* m, lapack_int* n,\n                    const lapack_complex_float* v, lapack_complex_float* tau,\n                    lapack_complex_float* c, lapack_int* ldc,\n                    lapack_complex_float* work );\nvoid LAPACK_zlarfx( char* side, lapack_int* m, lapack_int* n,\n                    const lapack_complex_double* v, lapack_complex_double* tau,\n                    lapack_complex_double* c, lapack_int* ldc,\n                    lapack_complex_double* work );\nvoid LAPACK_slatms( lapack_int* m, lapack_int* n, char* dist, lapack_int* iseed,\n                    char* sym, float* d, lapack_int* mode, float* cond,\n                    float* dmax, lapack_int* kl, lapack_int* ku, char* pack,\n                    float* a, lapack_int* lda, float* work, lapack_int *info );\nvoid LAPACK_dlatms( lapack_int* m, lapack_int* n, char* dist, lapack_int* iseed,\n                    char* sym, double* d, lapack_int* mode, double* cond,\n                    double* dmax, lapack_int* kl, lapack_int* ku, char* pack,\n                    double* a, lapack_int* lda, double* work,\n                    lapack_int *info );\nvoid LAPACK_clatms( lapack_int* m, lapack_int* n, char* dist, lapack_int* iseed,\n                    char* sym, float* d, lapack_int* mode, float* cond,\n                    float* dmax, lapack_int* kl, lapack_int* ku, char* pack,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zlatms( lapack_int* m, lapack_int* n, char* dist, lapack_int* iseed,\n                    char* sym, double* d, lapack_int* mode, double* cond,\n                    double* dmax, lapack_int* kl, lapack_int* ku, char* pack,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_slag2d( lapack_int* m, lapack_int* n, const float* sa,\n                    lapack_int* ldsa, double* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_dlag2s( lapack_int* m, lapack_int* n, const double* a,\n                    lapack_int* lda, float* sa, lapack_int* ldsa,\n                    lapack_int *info );\nvoid LAPACK_clag2z( lapack_int* m, lapack_int* n,\n                    const lapack_complex_float* sa, lapack_int* ldsa,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_zlag2c( lapack_int* m, lapack_int* n,\n                    const lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_float* sa, lapack_int* ldsa,\n                    lapack_int *info );\nvoid LAPACK_slauum( char* uplo, lapack_int* n, float* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_dlauum( char* uplo, lapack_int* n, double* a, lapack_int* lda,\n                    lapack_int *info );\nvoid LAPACK_clauum( char* uplo, lapack_int* n, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_zlauum( char* uplo, lapack_int* n, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int *info );\nvoid LAPACK_slagge( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, const float* d, float* a, lapack_int* lda,\n                    lapack_int* iseed, float* work, lapack_int *info );\nvoid LAPACK_dlagge( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, const double* d, double* a, lapack_int* lda,\n                    lapack_int* iseed, double* work, lapack_int *info );\nvoid LAPACK_clagge( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, const float* d, lapack_complex_float* a,\n                    lapack_int* lda, lapack_int* iseed,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zlagge( lapack_int* m, lapack_int* n, lapack_int* kl,\n                    lapack_int* ku, const double* d, lapack_complex_double* a,\n                    lapack_int* lda, lapack_int* iseed,\n                    lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_slaset( char* uplo, lapack_int* m, lapack_int* n, float* alpha,\n                    float* beta, float* a, lapack_int* lda );\nvoid LAPACK_dlaset( char* uplo, lapack_int* m, lapack_int* n, double* alpha,\n                    double* beta, double* a, lapack_int* lda );\nvoid LAPACK_claset( char* uplo, lapack_int* m, lapack_int* n,\n                    lapack_complex_float* alpha, lapack_complex_float* beta,\n                    lapack_complex_float* a, lapack_int* lda );\nvoid LAPACK_zlaset( char* uplo, lapack_int* m, lapack_int* n,\n                    lapack_complex_double* alpha, lapack_complex_double* beta,\n                    lapack_complex_double* a, lapack_int* lda );\nvoid LAPACK_slasrt( char* id, lapack_int* n, float* d, lapack_int *info );\nvoid LAPACK_dlasrt( char* id, lapack_int* n, double* d, lapack_int *info );\nvoid LAPACK_claghe( lapack_int* n, lapack_int* k, const float* d,\n                    lapack_complex_float* a, lapack_int* lda, lapack_int* iseed,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zlaghe( lapack_int* n, lapack_int* k, const double* d,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_int* iseed, lapack_complex_double* work,\n                    lapack_int *info );\nvoid LAPACK_slagsy( lapack_int* n, lapack_int* k, const float* d, float* a,\n                    lapack_int* lda, lapack_int* iseed, float* work,\n                    lapack_int *info );\nvoid LAPACK_dlagsy( lapack_int* n, lapack_int* k, const double* d, double* a,\n                    lapack_int* lda, lapack_int* iseed, double* work,\n                    lapack_int *info );\nvoid LAPACK_clagsy( lapack_int* n, lapack_int* k, const float* d,\n                    lapack_complex_float* a, lapack_int* lda, lapack_int* iseed,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zlagsy( lapack_int* n, lapack_int* k, const double* d,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_int* iseed, lapack_complex_double* work,\n                    lapack_int *info );\nvoid LAPACK_slapmr( lapack_logical* forwrd, lapack_int* m, lapack_int* n,\n                    float* x, lapack_int* ldx, lapack_int* k );\nvoid LAPACK_dlapmr( lapack_logical* forwrd, lapack_int* m, lapack_int* n,\n                    double* x, lapack_int* ldx, lapack_int* k );\nvoid LAPACK_clapmr( lapack_logical* forwrd, lapack_int* m, lapack_int* n,\n                    lapack_complex_float* x, lapack_int* ldx, lapack_int* k );\nvoid LAPACK_zlapmr( lapack_logical* forwrd, lapack_int* m, lapack_int* n,\n                    lapack_complex_double* x, lapack_int* ldx, lapack_int* k );\nfloat LAPACK_slapy2( float* x, float* y );\ndouble LAPACK_dlapy2( double* x, double* y );\nfloat LAPACK_slapy3( float* x, float* y, float* z );\ndouble LAPACK_dlapy3( double* x, double* y, double* z );\nvoid LAPACK_slartgp( float* f, float* g, float* cs, float* sn, float* r );\nvoid LAPACK_dlartgp( double* f, double* g, double* cs, double* sn, double* r );\nvoid LAPACK_slartgs( float* x, float* y, float* sigma, float* cs, float* sn );\nvoid LAPACK_dlartgs( double* x, double* y, double* sigma, double* cs,\n                     double* sn );\n// LAPACK 3.3.0\nvoid LAPACK_cbbcsd( char* jobu1, char* jobu2,\n                    char* jobv1t, char* jobv2t, char* trans,\n                    lapack_int* m, lapack_int* p, lapack_int* q,\n                    float* theta, float* phi,\n                    lapack_complex_float* u1, lapack_int* ldu1,\n                    lapack_complex_float* u2, lapack_int* ldu2,\n                    lapack_complex_float* v1t, lapack_int* ldv1t,\n                    lapack_complex_float* v2t, lapack_int* ldv2t,\n                    float* b11d, float* b11e, float* b12d,\n                    float* b12e, float* b21d, float* b21e,\n                    float* b22d, float* b22e, float* rwork,\n                    lapack_int* lrwork , lapack_int *info );\nvoid LAPACK_cheswapr( char* uplo, lapack_int* n,\n                      lapack_complex_float* a, lapack_int* i1,\n                      lapack_int* i2 );\nvoid LAPACK_chetri2( char* uplo, lapack_int* n,\n                     lapack_complex_float* a, lapack_int* lda,\n                     const lapack_int* ipiv,\n                     lapack_complex_float* work, lapack_int* lwork , lapack_int *info );\nvoid LAPACK_chetri2x( char* uplo, lapack_int* n,\n                      lapack_complex_float* a, lapack_int* lda,\n                      const lapack_int* ipiv,\n                      lapack_complex_float* work, lapack_int* nb , lapack_int *info );\nvoid LAPACK_chetrs2( char* uplo, lapack_int* n,\n                     lapack_int* nrhs, const lapack_complex_float* a,\n                     lapack_int* lda, const lapack_int* ipiv,\n                     lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* work , lapack_int *info );\nvoid LAPACK_csyconv( char* uplo, char* way,\n                     lapack_int* n, lapack_complex_float* a,\n                     lapack_int* lda, const lapack_int* ipiv,\n                     lapack_complex_float* work , lapack_int *info );\nvoid LAPACK_csyswapr( char* uplo, lapack_int* n,\n                      lapack_complex_float* a, lapack_int* i1,\n                      lapack_int* i2 );\nvoid LAPACK_csytri2( char* uplo, lapack_int* n,\n                     lapack_complex_float* a, lapack_int* lda,\n                     const lapack_int* ipiv,\n                     lapack_complex_float* work, lapack_int* lwork , lapack_int *info );\nvoid LAPACK_csytri2x( char* uplo, lapack_int* n,\n                      lapack_complex_float* a, lapack_int* lda,\n                      const lapack_int* ipiv,\n                      lapack_complex_float* work, lapack_int* nb , lapack_int *info );\nvoid LAPACK_csytrs2( char* uplo, lapack_int* n,\n                     lapack_int* nrhs, const lapack_complex_float* a,\n                     lapack_int* lda, const lapack_int* ipiv,\n                     lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* work , lapack_int *info );\nvoid LAPACK_cunbdb( char* trans, char* signs,\n                    lapack_int* m, lapack_int* p, lapack_int* q,\n                    lapack_complex_float* x11, lapack_int* ldx11,\n                    lapack_complex_float* x12, lapack_int* ldx12,\n                    lapack_complex_float* x21, lapack_int* ldx21,\n                    lapack_complex_float* x22, lapack_int* ldx22,\n                    float* theta, float* phi,\n                    lapack_complex_float* taup1,\n                    lapack_complex_float* taup2,\n                    lapack_complex_float* tauq1,\n                    lapack_complex_float* tauq2,\n                    lapack_complex_float* work, lapack_int* lwork , lapack_int *info );\nvoid LAPACK_cuncsd( char* jobu1, char* jobu2,\n                    char* jobv1t, char* jobv2t, char* trans,\n                    char* signs, lapack_int* m, lapack_int* p,\n                    lapack_int* q, lapack_complex_float* x11,\n                    lapack_int* ldx11, lapack_complex_float* x12,\n                    lapack_int* ldx12, lapack_complex_float* x21,\n                    lapack_int* ldx21, lapack_complex_float* x22,\n                    lapack_int* ldx22, float* theta,\n                    lapack_complex_float* u1, lapack_int* ldu1,\n                    lapack_complex_float* u2, lapack_int* ldu2,\n                    lapack_complex_float* v1t, lapack_int* ldv1t,\n                    lapack_complex_float* v2t, lapack_int* ldv2t,\n                    lapack_complex_float* work, lapack_int* lwork,\n                    float* rwork, lapack_int* lrwork,\n                    lapack_int* iwork , lapack_int *info );\nvoid LAPACK_dbbcsd( char* jobu1, char* jobu2,\n                    char* jobv1t, char* jobv2t, char* trans,\n                    lapack_int* m, lapack_int* p, lapack_int* q,\n                    double* theta, double* phi, double* u1,\n                    lapack_int* ldu1, double* u2, lapack_int* ldu2,\n                    double* v1t, lapack_int* ldv1t, double* v2t,\n                    lapack_int* ldv2t, double* b11d, double* b11e,\n                    double* b12d, double* b12e, double* b21d,\n                    double* b21e, double* b22d, double* b22e,\n                    double* work, lapack_int* lwork , lapack_int *info );\nvoid LAPACK_dorbdb( char* trans, char* signs,\n                    lapack_int* m, lapack_int* p, lapack_int* q,\n                    double* x11, lapack_int* ldx11, double* x12,\n                    lapack_int* ldx12, double* x21, lapack_int* ldx21,\n                    double* x22, lapack_int* ldx22, double* theta,\n                    double* phi, double* taup1, double* taup2,\n                    double* tauq1, double* tauq2, double* work,\n                    lapack_int* lwork , lapack_int *info );\nvoid LAPACK_dorcsd( char* jobu1, char* jobu2,\n                    char* jobv1t, char* jobv2t, char* trans,\n                    char* signs, lapack_int* m, lapack_int* p,\n                    lapack_int* q, double* x11, lapack_int* ldx11,\n                    double* x12, lapack_int* ldx12, double* x21,\n                    lapack_int* ldx21, double* x22, lapack_int* ldx22,\n                    double* theta, double* u1, lapack_int* ldu1,\n                    double* u2, lapack_int* ldu2, double* v1t,\n                    lapack_int* ldv1t, double* v2t, lapack_int* ldv2t,\n                    double* work, lapack_int* lwork,\n                    lapack_int* iwork , lapack_int *info );\nvoid LAPACK_dsyconv( char* uplo, char* way,\n                     lapack_int* n, double* a, lapack_int* lda,\n                     const lapack_int* ipiv, double* work , lapack_int *info );\nvoid LAPACK_dsyswapr( char* uplo, lapack_int* n,\n                      double* a, lapack_int* i1, lapack_int* i2 );\nvoid LAPACK_dsytri2( char* uplo, lapack_int* n,\n                     double* a, lapack_int* lda,\n                     const lapack_int* ipiv,\n                     lapack_complex_double* work, lapack_int* lwork , lapack_int *info );\nvoid LAPACK_dsytri2x( char* uplo, lapack_int* n,\n                      double* a, lapack_int* lda,\n                      const lapack_int* ipiv, double* work,\n                      lapack_int* nb , lapack_int *info );\nvoid LAPACK_dsytrs2( char* uplo, lapack_int* n,\n                     lapack_int* nrhs, const double* a,\n                     lapack_int* lda, const lapack_int* ipiv,\n                     double* b, lapack_int* ldb, double* work , lapack_int *info );\nvoid LAPACK_sbbcsd( char* jobu1, char* jobu2,\n                    char* jobv1t, char* jobv2t, char* trans,\n                    lapack_int* m, lapack_int* p, lapack_int* q,\n                    float* theta, float* phi, float* u1,\n                    lapack_int* ldu1, float* u2, lapack_int* ldu2,\n                    float* v1t, lapack_int* ldv1t, float* v2t,\n                    lapack_int* ldv2t, float* b11d, float* b11e,\n                    float* b12d, float* b12e, float* b21d,\n                    float* b21e, float* b22d, float* b22e,\n                    float* work, lapack_int* lwork , lapack_int *info );\nvoid LAPACK_sorbdb( char* trans, char* signs,\n                    lapack_int* m, lapack_int* p, lapack_int* q,\n                    float* x11, lapack_int* ldx11, float* x12,\n                    lapack_int* ldx12, float* x21, lapack_int* ldx21,\n                    float* x22, lapack_int* ldx22, float* theta,\n                    float* phi, float* taup1, float* taup2,\n                    float* tauq1, float* tauq2, float* work,\n                    lapack_int* lwork , lapack_int *info );\nvoid LAPACK_sorcsd( char* jobu1, char* jobu2,\n                    char* jobv1t, char* jobv2t, char* trans,\n                    char* signs, lapack_int* m, lapack_int* p,\n                    lapack_int* q, float* x11, lapack_int* ldx11,\n                    float* x12, lapack_int* ldx12, float* x21,\n                    lapack_int* ldx21, float* x22, lapack_int* ldx22,\n                    float* theta, float* u1, lapack_int* ldu1,\n                    float* u2, lapack_int* ldu2, float* v1t,\n                    lapack_int* ldv1t, float* v2t, lapack_int* ldv2t,\n                    float* work, lapack_int* lwork,\n                    lapack_int* iwork , lapack_int *info );\nvoid LAPACK_ssyconv( char* uplo, char* way,\n                     lapack_int* n, float* a, lapack_int* lda,\n                     const lapack_int* ipiv, float* work , lapack_int *info );\nvoid LAPACK_ssyswapr( char* uplo, lapack_int* n,\n                      float* a, lapack_int* i1, lapack_int* i2 );\nvoid LAPACK_ssytri2( char* uplo, lapack_int* n,\n                     float* a, lapack_int* lda,\n                     const lapack_int* ipiv,\n                     lapack_complex_float* work, lapack_int* lwork , lapack_int *info );\nvoid LAPACK_ssytri2x( char* uplo, lapack_int* n,\n                      float* a, lapack_int* lda,\n                      const lapack_int* ipiv, float* work,\n                      lapack_int* nb , lapack_int *info );\nvoid LAPACK_ssytrs2( char* uplo, lapack_int* n,\n                     lapack_int* nrhs, const float* a,\n                     lapack_int* lda, const lapack_int* ipiv,\n                     float* b, lapack_int* ldb, float* work , lapack_int *info );\nvoid LAPACK_zbbcsd( char* jobu1, char* jobu2,\n                    char* jobv1t, char* jobv2t, char* trans,\n                    lapack_int* m, lapack_int* p, lapack_int* q,\n                    double* theta, double* phi,\n                    lapack_complex_double* u1, lapack_int* ldu1,\n                    lapack_complex_double* u2, lapack_int* ldu2,\n                    lapack_complex_double* v1t, lapack_int* ldv1t,\n                    lapack_complex_double* v2t, lapack_int* ldv2t,\n                    double* b11d, double* b11e, double* b12d,\n                    double* b12e, double* b21d, double* b21e,\n                    double* b22d, double* b22e, double* rwork,\n                    lapack_int* lrwork , lapack_int *info );\nvoid LAPACK_zheswapr( char* uplo, lapack_int* n,\n                      lapack_complex_double* a, lapack_int* i1,\n                      lapack_int* i2 );\nvoid LAPACK_zhetri2( char* uplo, lapack_int* n,\n                     lapack_complex_double* a, lapack_int* lda,\n                     const lapack_int* ipiv,\n                     lapack_complex_double* work, lapack_int* lwork , lapack_int *info );\nvoid LAPACK_zhetri2x( char* uplo, lapack_int* n,\n                      lapack_complex_double* a, lapack_int* lda,\n                      const lapack_int* ipiv,\n                      lapack_complex_double* work, lapack_int* nb , lapack_int *info );\nvoid LAPACK_zhetrs2( char* uplo, lapack_int* n,\n                     lapack_int* nrhs,\n                     const lapack_complex_double* a, lapack_int* lda,\n                     const lapack_int* ipiv,\n                     lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* work , lapack_int *info );\nvoid LAPACK_zsyconv( char* uplo, char* way,\n                     lapack_int* n, lapack_complex_double* a,\n                     lapack_int* lda, const lapack_int* ipiv,\n                     lapack_complex_double* work , lapack_int *info );\nvoid LAPACK_zsyswapr( char* uplo, lapack_int* n,\n                      lapack_complex_double* a, lapack_int* i1,\n                      lapack_int* i2 );\nvoid LAPACK_zsytri2( char* uplo, lapack_int* n,\n                     lapack_complex_double* a, lapack_int* lda,\n                     const lapack_int* ipiv,\n                     lapack_complex_double* work, lapack_int* lwork , lapack_int *info );\nvoid LAPACK_zsytri2x( char* uplo, lapack_int* n,\n                      lapack_complex_double* a, lapack_int* lda,\n                      const lapack_int* ipiv,\n                      lapack_complex_double* work, lapack_int* nb , lapack_int *info );\nvoid LAPACK_zsytrs2( char* uplo, lapack_int* n,\n                     lapack_int* nrhs,\n                     const lapack_complex_double* a, lapack_int* lda,\n                     const lapack_int* ipiv,\n                     lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* work , lapack_int *info );\nvoid LAPACK_zunbdb( char* trans, char* signs,\n                    lapack_int* m, lapack_int* p, lapack_int* q,\n                    lapack_complex_double* x11, lapack_int* ldx11,\n                    lapack_complex_double* x12, lapack_int* ldx12,\n                    lapack_complex_double* x21, lapack_int* ldx21,\n                    lapack_complex_double* x22, lapack_int* ldx22,\n                    double* theta, double* phi,\n                    lapack_complex_double* taup1,\n                    lapack_complex_double* taup2,\n                    lapack_complex_double* tauq1,\n                    lapack_complex_double* tauq2,\n                    lapack_complex_double* work, lapack_int* lwork , lapack_int *info );\nvoid LAPACK_zuncsd( char* jobu1, char* jobu2,\n                    char* jobv1t, char* jobv2t, char* trans,\n                    char* signs, lapack_int* m, lapack_int* p,\n                    lapack_int* q, lapack_complex_double* x11,\n                    lapack_int* ldx11, lapack_complex_double* x12,\n                    lapack_int* ldx12, lapack_complex_double* x21,\n                    lapack_int* ldx21, lapack_complex_double* x22,\n                    lapack_int* ldx22, double* theta,\n                    lapack_complex_double* u1, lapack_int* ldu1,\n                    lapack_complex_double* u2, lapack_int* ldu2,\n                    lapack_complex_double* v1t, lapack_int* ldv1t,\n                    lapack_complex_double* v2t, lapack_int* ldv2t,\n                    lapack_complex_double* work, lapack_int* lwork,\n                    double* rwork, lapack_int* lrwork,\n                    lapack_int* iwork , lapack_int *info );\n// LAPACK 3.4.0\nvoid LAPACK_sgemqrt( char* side, char* trans, lapack_int* m, lapack_int* n,\n                     lapack_int* k, lapack_int* nb, const float* v,\n                     lapack_int* ldv, const float* t, lapack_int* ldt, float* c,\n                     lapack_int* ldc, float* work, lapack_int *info );\nvoid LAPACK_dgemqrt( char* side, char* trans, lapack_int* m, lapack_int* n,\n                     lapack_int* k, lapack_int* nb, const double* v,\n                     lapack_int* ldv, const double* t, lapack_int* ldt,\n                     double* c, lapack_int* ldc, double* work,\n                     lapack_int *info );\nvoid LAPACK_cgemqrt( char* side, char* trans, lapack_int* m, lapack_int* n,\n                     lapack_int* k, lapack_int* nb,\n                     const lapack_complex_float* v, lapack_int* ldv,\n                     const lapack_complex_float* t, lapack_int* ldt,\n                     lapack_complex_float* c, lapack_int* ldc,\n                     lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zgemqrt( char* side, char* trans, lapack_int* m, lapack_int* n,\n                     lapack_int* k, lapack_int* nb,\n                     const lapack_complex_double* v, lapack_int* ldv,\n                     const lapack_complex_double* t, lapack_int* ldt,\n                     lapack_complex_double* c, lapack_int* ldc,\n                     lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_sgeqrt( lapack_int* m, lapack_int* n, lapack_int* nb, float* a,\n                    lapack_int* lda, float* t, lapack_int* ldt, float* work,\n                    lapack_int *info );\nvoid LAPACK_dgeqrt( lapack_int* m, lapack_int* n, lapack_int* nb, double* a,\n                    lapack_int* lda, double* t, lapack_int* ldt, double* work,\n                    lapack_int *info );\nvoid LAPACK_cgeqrt( lapack_int* m, lapack_int* n, lapack_int* nb,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* t, lapack_int* ldt,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_zgeqrt( lapack_int* m, lapack_int* n, lapack_int* nb,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* t, lapack_int* ldt,\n                    lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_sgeqrt2( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                     float* t, lapack_int* ldt, lapack_int *info );\nvoid LAPACK_dgeqrt2( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                     double* t, lapack_int* ldt, lapack_int *info );\nvoid LAPACK_cgeqrt2( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                     lapack_int* lda, lapack_complex_float* t, lapack_int* ldt,\n                     lapack_int *info );\nvoid LAPACK_zgeqrt2( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                     lapack_int* lda, lapack_complex_double* t, lapack_int* ldt,\n                     lapack_int *info );\nvoid LAPACK_sgeqrt3( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                     float* t, lapack_int* ldt, lapack_int *info );\nvoid LAPACK_dgeqrt3( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                     double* t, lapack_int* ldt, lapack_int *info );\nvoid LAPACK_cgeqrt3( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                     lapack_int* lda, lapack_complex_float* t, lapack_int* ldt,\n                     lapack_int *info );\nvoid LAPACK_zgeqrt3( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                     lapack_int* lda, lapack_complex_double* t, lapack_int* ldt,\n                     lapack_int *info );\nvoid LAPACK_stpmqrt( char* side, char* trans, lapack_int* m, lapack_int* n,\n                     lapack_int* k, lapack_int* l, lapack_int* nb,\n                     const float* v, lapack_int* ldv, const float* t,\n                     lapack_int* ldt, float* a, lapack_int* lda, float* b,\n                     lapack_int* ldb, float* work, lapack_int *info );\nvoid LAPACK_dtpmqrt( char* side, char* trans, lapack_int* m, lapack_int* n,\n                     lapack_int* k, lapack_int* l, lapack_int* nb,\n                     const double* v, lapack_int* ldv, const double* t,\n                     lapack_int* ldt, double* a, lapack_int* lda, double* b,\n                     lapack_int* ldb, double* work, lapack_int *info );\nvoid LAPACK_ctpmqrt( char* side, char* trans, lapack_int* m, lapack_int* n,\n                     lapack_int* k, lapack_int* l, lapack_int* nb,\n                     const lapack_complex_float* v, lapack_int* ldv,\n                     const lapack_complex_float* t, lapack_int* ldt,\n                     lapack_complex_float* a, lapack_int* lda,\n                     lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_ztpmqrt( char* side, char* trans, lapack_int* m, lapack_int* n,\n                     lapack_int* k, lapack_int* l, lapack_int* nb,\n                     const lapack_complex_double* v, lapack_int* ldv,\n                     const lapack_complex_double* t, lapack_int* ldt,\n                     lapack_complex_double* a, lapack_int* lda,\n                     lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_dtpqrt( lapack_int* m, lapack_int* n, lapack_int* l, lapack_int* nb,\n                    double* a, lapack_int* lda, double* b, lapack_int* ldb,\n                    double* t, lapack_int* ldt, double* work,\n                    lapack_int *info );\nvoid LAPACK_ctpqrt( lapack_int* m, lapack_int* n, lapack_int* l, lapack_int* nb,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* t, lapack_complex_float* b,\n                    lapack_int* ldb, lapack_int* ldt,\n                    lapack_complex_float* work, lapack_int *info );\nvoid LAPACK_ztpqrt( lapack_int* m, lapack_int* n, lapack_int* l, lapack_int* nb,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    lapack_complex_double* t, lapack_int* ldt,\n                    lapack_complex_double* work, lapack_int *info );\nvoid LAPACK_stpqrt2( lapack_int* m, lapack_int* n, float* a, lapack_int* lda,\n                     float* b, lapack_int* ldb, float* t, lapack_int* ldt,\n                     lapack_int *info );\nvoid LAPACK_dtpqrt2( lapack_int* m, lapack_int* n, double* a, lapack_int* lda,\n                     double* b, lapack_int* ldb, double* t, lapack_int* ldt,\n                     lapack_int *info );\nvoid LAPACK_ctpqrt2( lapack_int* m, lapack_int* n, lapack_complex_float* a,\n                     lapack_int* lda, lapack_complex_float* b, lapack_int* ldb,\n                     lapack_complex_float* t, lapack_int* ldt,\n                     lapack_int *info );\nvoid LAPACK_ztpqrt2( lapack_int* m, lapack_int* n, lapack_complex_double* a,\n                     lapack_int* lda, lapack_complex_double* b, lapack_int* ldb,\n                     lapack_complex_double* t, lapack_int* ldt,\n                     lapack_int *info );\nvoid LAPACK_stprfb( char* side, char* trans, char* direct, char* storev,\n                    lapack_int* m, lapack_int* n, lapack_int* k, lapack_int* l,\n                    const float* v, lapack_int* ldv, const float* t,\n                    lapack_int* ldt, float* a, lapack_int* lda, float* b,\n                    lapack_int* ldb, const float* mywork,\n                    lapack_int* myldwork );\nvoid LAPACK_dtprfb( char* side, char* trans, char* direct, char* storev,\n                    lapack_int* m, lapack_int* n, lapack_int* k, lapack_int* l,\n                    const double* v, lapack_int* ldv, const double* t,\n                    lapack_int* ldt, double* a, lapack_int* lda, double* b,\n                    lapack_int* ldb, const double* mywork,\n                    lapack_int* myldwork );\nvoid LAPACK_ctprfb( char* side, char* trans, char* direct, char* storev,\n                    lapack_int* m, lapack_int* n, lapack_int* k, lapack_int* l,\n                    const lapack_complex_float* v, lapack_int* ldv,\n                    const lapack_complex_float* t, lapack_int* ldt,\n                    lapack_complex_float* a, lapack_int* lda,\n                    lapack_complex_float* b, lapack_int* ldb,\n                    const float* mywork, lapack_int* myldwork );\nvoid LAPACK_ztprfb( char* side, char* trans, char* direct, char* storev,\n                    lapack_int* m, lapack_int* n, lapack_int* k, lapack_int* l,\n                    const lapack_complex_double* v, lapack_int* ldv,\n                    const lapack_complex_double* t, lapack_int* ldt,\n                    lapack_complex_double* a, lapack_int* lda,\n                    lapack_complex_double* b, lapack_int* ldb,\n                    const double* mywork, lapack_int* myldwork );\n// LAPACK 3.X.X\nvoid LAPACK_csyr( char* uplo, lapack_int* n, lapack_complex_float* alpha,\n                      const lapack_complex_float* x, lapack_int* incx,\n                      lapack_complex_float* a, lapack_int* lda );\nvoid LAPACK_zsyr( char* uplo, lapack_int* n, lapack_complex_double* alpha,\n                      const lapack_complex_double* x, lapack_int* incx,\n                      lapack_complex_double* a, lapack_int* lda );\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* _LAPACKE_H_ */\n\n#endif /* _MKL_LAPACKE_H_ */\n"
  },
  {
    "path": "include/externals/Eigen/src/misc/lapacke_mangling.h",
    "content": "#ifndef LAPACK_HEADER_INCLUDED\n#define LAPACK_HEADER_INCLUDED\n\n#ifndef LAPACK_GLOBAL\n#if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_)\n#define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_\n#elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER)\n#define LAPACK_GLOBAL(lcname,UCNAME)  UCNAME\n#elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE)\n#define LAPACK_GLOBAL(lcname,UCNAME)  lcname\n#else\n#define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_\n#endif\n#endif\n\n#endif\n\n"
  },
  {
    "path": "include/externals/Eigen/src/plugins/ArrayCwiseBinaryOps.h",
    "content": "\n/** \\returns an expression of the coefficient wise product of \\c *this and \\a other\n  *\n  * \\sa MatrixBase::cwiseProduct\n  */\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)\noperator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const\n{\n  return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)(derived(), other.derived());\n}\n\n/** \\returns an expression of the coefficient wise quotient of \\c *this and \\a other\n  *\n  * \\sa MatrixBase::cwiseQuotient\n  */\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar,typename OtherDerived::Scalar>, const Derived, const OtherDerived>\noperator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const\n{\n  return CwiseBinaryOp<internal::scalar_quotient_op<Scalar,typename OtherDerived::Scalar>, const Derived, const OtherDerived>(derived(), other.derived());\n}\n\n/** \\returns an expression of the coefficient-wise min of \\c *this and \\a other\n  *\n  * Example: \\include Cwise_min.cpp\n  * Output: \\verbinclude Cwise_min.out\n  *\n  * \\sa max()\n  */\nEIGEN_MAKE_CWISE_BINARY_OP(min,min)\n\n/** \\returns an expression of the coefficient-wise min of \\c *this and scalar \\a other\n  *\n  * \\sa max()\n  */\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived,\n                                        const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >\n#ifdef EIGEN_PARSED_BY_DOXYGEN\nmin\n#else\n(min)\n#endif\n(const Scalar &other) const\n{\n  return (min)(Derived::PlainObject::Constant(rows(), cols(), other));\n}\n\n/** \\returns an expression of the coefficient-wise max of \\c *this and \\a other\n  *\n  * Example: \\include Cwise_max.cpp\n  * Output: \\verbinclude Cwise_max.out\n  *\n  * \\sa min()\n  */\nEIGEN_MAKE_CWISE_BINARY_OP(max,max)\n\n/** \\returns an expression of the coefficient-wise max of \\c *this and scalar \\a other\n  *\n  * \\sa min()\n  */\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived,\n                                        const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >\n#ifdef EIGEN_PARSED_BY_DOXYGEN\nmax\n#else\n(max)\n#endif\n(const Scalar &other) const\n{\n  return (max)(Derived::PlainObject::Constant(rows(), cols(), other));\n}\n\n/** \\returns an expression of the coefficient-wise power of \\c *this to the given array of \\a exponents.\n  *\n  * This function computes the coefficient-wise power.\n  *\n  * Example: \\include Cwise_array_power_array.cpp\n  * Output: \\verbinclude Cwise_array_power_array.out\n  */\nEIGEN_MAKE_CWISE_BINARY_OP(pow,pow)\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\nEIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(pow,pow)\n#else\n/** \\returns an expression of the coefficients of \\c *this rasied to the constant power \\a exponent\n  *\n  * \\tparam T is the scalar type of \\a exponent. It must be compatible with the scalar type of the given expression.\n  *\n  * This function computes the coefficient-wise power. The function MatrixBase::pow() in the\n  * unsupported module MatrixFunctions computes the matrix power.\n  *\n  * Example: \\include Cwise_pow.cpp\n  * Output: \\verbinclude Cwise_pow.out\n  *\n  * \\sa ArrayBase::pow(ArrayBase), square(), cube(), exp(), log()\n  */\ntemplate<typename T>\nconst CwiseBinaryOp<internal::scalar_pow_op<Scalar,T>,Derived,Constant<T> > pow(const T& exponent) const;\n#endif\n\n\n// TODO code generating macros could be moved to Macros.h and could include generation of documentation\n#define EIGEN_MAKE_CWISE_COMP_OP(OP, COMPARATOR) \\\ntemplate<typename OtherDerived> \\\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, typename OtherDerived::Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived> \\\nOP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \\\n{ \\\n  return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, typename OtherDerived::Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived>(derived(), other.derived()); \\\n}\\\ntypedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar,Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Cmp ## COMPARATOR ## ReturnType; \\\ntypedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar,Scalar, internal::cmp_ ## COMPARATOR>, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject>, const Derived > RCmp ## COMPARATOR ## ReturnType; \\\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Cmp ## COMPARATOR ## ReturnType \\\nOP(const Scalar& s) const { \\\n  return this->OP(Derived::PlainObject::Constant(rows(), cols(), s)); \\\n} \\\nEIGEN_DEVICE_FUNC friend EIGEN_STRONG_INLINE const RCmp ## COMPARATOR ## ReturnType \\\nOP(const Scalar& s, const Derived& d) { \\\n  return Derived::PlainObject::Constant(d.rows(), d.cols(), s).OP(d); \\\n}\n\n#define EIGEN_MAKE_CWISE_COMP_R_OP(OP, R_OP, RCOMPARATOR) \\\ntemplate<typename OtherDerived> \\\nEIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<typename OtherDerived::Scalar, Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived> \\\nOP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \\\n{ \\\n  return CwiseBinaryOp<internal::scalar_cmp_op<typename OtherDerived::Scalar, Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived>(other.derived(), derived()); \\\n} \\\nEIGEN_DEVICE_FUNC \\\ninline const RCmp ## RCOMPARATOR ## ReturnType \\\nOP(const Scalar& s) const { \\\n  return Derived::PlainObject::Constant(rows(), cols(), s).R_OP(*this); \\\n} \\\nfriend inline const Cmp ## RCOMPARATOR ## ReturnType \\\nOP(const Scalar& s, const Derived& d) { \\\n  return d.R_OP(Derived::PlainObject::Constant(d.rows(), d.cols(), s)); \\\n}\n\n\n\n/** \\returns an expression of the coefficient-wise \\< operator of *this and \\a other\n  *\n  * Example: \\include Cwise_less.cpp\n  * Output: \\verbinclude Cwise_less.out\n  *\n  * \\sa all(), any(), operator>(), operator<=()\n  */\nEIGEN_MAKE_CWISE_COMP_OP(operator<, LT)\n\n/** \\returns an expression of the coefficient-wise \\<= operator of *this and \\a other\n  *\n  * Example: \\include Cwise_less_equal.cpp\n  * Output: \\verbinclude Cwise_less_equal.out\n  *\n  * \\sa all(), any(), operator>=(), operator<()\n  */\nEIGEN_MAKE_CWISE_COMP_OP(operator<=, LE)\n\n/** \\returns an expression of the coefficient-wise \\> operator of *this and \\a other\n  *\n  * Example: \\include Cwise_greater.cpp\n  * Output: \\verbinclude Cwise_greater.out\n  *\n  * \\sa all(), any(), operator>=(), operator<()\n  */\nEIGEN_MAKE_CWISE_COMP_R_OP(operator>, operator<, LT)\n\n/** \\returns an expression of the coefficient-wise \\>= operator of *this and \\a other\n  *\n  * Example: \\include Cwise_greater_equal.cpp\n  * Output: \\verbinclude Cwise_greater_equal.out\n  *\n  * \\sa all(), any(), operator>(), operator<=()\n  */\nEIGEN_MAKE_CWISE_COMP_R_OP(operator>=, operator<=, LE)\n\n/** \\returns an expression of the coefficient-wise == operator of *this and \\a other\n  *\n  * \\warning this performs an exact comparison, which is generally a bad idea with floating-point types.\n  * In order to check for equality between two vectors or matrices with floating-point coefficients, it is\n  * generally a far better idea to use a fuzzy comparison as provided by isApprox() and\n  * isMuchSmallerThan().\n  *\n  * Example: \\include Cwise_equal_equal.cpp\n  * Output: \\verbinclude Cwise_equal_equal.out\n  *\n  * \\sa all(), any(), isApprox(), isMuchSmallerThan()\n  */\nEIGEN_MAKE_CWISE_COMP_OP(operator==, EQ)\n\n/** \\returns an expression of the coefficient-wise != operator of *this and \\a other\n  *\n  * \\warning this performs an exact comparison, which is generally a bad idea with floating-point types.\n  * In order to check for equality between two vectors or matrices with floating-point coefficients, it is\n  * generally a far better idea to use a fuzzy comparison as provided by isApprox() and\n  * isMuchSmallerThan().\n  *\n  * Example: \\include Cwise_not_equal.cpp\n  * Output: \\verbinclude Cwise_not_equal.out\n  *\n  * \\sa all(), any(), isApprox(), isMuchSmallerThan()\n  */\nEIGEN_MAKE_CWISE_COMP_OP(operator!=, NEQ)\n\n\n#undef EIGEN_MAKE_CWISE_COMP_OP\n#undef EIGEN_MAKE_CWISE_COMP_R_OP\n\n// scalar addition\n#ifndef EIGEN_PARSED_BY_DOXYGEN\nEIGEN_MAKE_SCALAR_BINARY_OP(operator+,sum)\n#else\n/** \\returns an expression of \\c *this with each coeff incremented by the constant \\a scalar\n  *\n  * \\tparam T is the scalar type of \\a scalar. It must be compatible with the scalar type of the given expression.\n  *\n  * Example: \\include Cwise_plus.cpp\n  * Output: \\verbinclude Cwise_plus.out\n  *\n  * \\sa operator+=(), operator-()\n  */\ntemplate<typename T>\nconst CwiseBinaryOp<internal::scalar_sum_op<Scalar,T>,Derived,Constant<T> > operator+(const T& scalar) const;\n/** \\returns an expression of \\a expr with each coeff incremented by the constant \\a scalar\n  *\n  * \\tparam T is the scalar type of \\a scalar. It must be compatible with the scalar type of the given expression.\n  */\ntemplate<typename T> friend\nconst CwiseBinaryOp<internal::scalar_sum_op<T,Scalar>,Constant<T>,Derived> operator+(const T& scalar, const StorageBaseType& expr);\n#endif\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\nEIGEN_MAKE_SCALAR_BINARY_OP(operator-,difference)\n#else\n/** \\returns an expression of \\c *this with each coeff decremented by the constant \\a scalar\n  *\n  * \\tparam T is the scalar type of \\a scalar. It must be compatible with the scalar type of the given expression.\n  *\n  * Example: \\include Cwise_minus.cpp\n  * Output: \\verbinclude Cwise_minus.out\n  *\n  * \\sa operator+=(), operator-()\n  */\ntemplate<typename T>\nconst CwiseBinaryOp<internal::scalar_difference_op<Scalar,T>,Derived,Constant<T> > operator-(const T& scalar) const;\n/** \\returns an expression of the constant matrix of value \\a scalar decremented by the coefficients of \\a expr\n  *\n  * \\tparam T is the scalar type of \\a scalar. It must be compatible with the scalar type of the given expression.\n  */\ntemplate<typename T> friend\nconst CwiseBinaryOp<internal::scalar_difference_op<T,Scalar>,Constant<T>,Derived> operator-(const T& scalar, const StorageBaseType& expr);\n#endif\n\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n  EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(operator/,quotient)\n#else\n  /**\n    * \\brief Component-wise division of the scalar \\a s by array elements of \\a a.\n    *\n    * \\tparam Scalar is the scalar type of \\a x. It must be compatible with the scalar type of the given array expression (\\c Derived::Scalar).\n    */\n  template<typename T> friend\n  inline const CwiseBinaryOp<internal::scalar_quotient_op<T,Scalar>,Constant<T>,Derived>\n  operator/(const T& s,const StorageBaseType& a);\n#endif\n\n/** \\returns an expression of the coefficient-wise ^ operator of *this and \\a other\n *\n * \\warning this operator is for expression of bool only.\n *\n * Example: \\include Cwise_boolean_xor.cpp\n * Output: \\verbinclude Cwise_boolean_xor.out\n *\n * \\sa operator&&(), select()\n */\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\ninline const CwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived>\noperator^(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const\n{\n  EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),\n                      THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);\n  return CwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived>(derived(),other.derived());\n}\n\n// NOTE disabled until we agree on argument order\n#if 0\n/** \\cpp11 \\returns an expression of the coefficient-wise polygamma function.\n  *\n  * \\specialfunctions_module\n  *\n  * It returns the \\a n -th derivative of the digamma(psi) evaluated at \\c *this.\n  *\n  * \\warning Be careful with the order of the parameters: x.polygamma(n) is equivalent to polygamma(n,x)\n  *\n  * \\sa Eigen::polygamma()\n  */\ntemplate<typename DerivedN>\ninline const CwiseBinaryOp<internal::scalar_polygamma_op<Scalar>, const DerivedN, const Derived>\npolygamma(const EIGEN_CURRENT_STORAGE_BASE_CLASS<DerivedN> &n) const\n{\n  return CwiseBinaryOp<internal::scalar_polygamma_op<Scalar>, const DerivedN, const Derived>(n.derived(), this->derived());\n}\n#endif\n\n/** \\returns an expression of the coefficient-wise zeta function.\n  *\n  * \\specialfunctions_module\n  *\n  * It returns the Riemann zeta function of two arguments \\c *this and \\a q:\n  *\n  * \\param *this is the exposent, it must be > 1\n  * \\param q is the shift, it must be > 0\n  *\n  * \\note This function supports only float and double scalar types. To support other scalar types, the user has\n  * to provide implementations of zeta(T,T) for any scalar type T to be supported.\n  *\n  * This method is an alias for zeta(*this,q);\n  *\n  * \\sa Eigen::zeta()\n  */\ntemplate<typename DerivedQ>\ninline const CwiseBinaryOp<internal::scalar_zeta_op<Scalar>, const Derived, const DerivedQ>\nzeta(const EIGEN_CURRENT_STORAGE_BASE_CLASS<DerivedQ> &q) const\n{\n  return CwiseBinaryOp<internal::scalar_zeta_op<Scalar>, const Derived, const DerivedQ>(this->derived(), q.derived());\n}\n"
  },
  {
    "path": "include/externals/Eigen/src/plugins/ArrayCwiseUnaryOps.h",
    "content": "\n\ntypedef CwiseUnaryOp<internal::scalar_abs_op<Scalar>, const Derived> AbsReturnType;\ntypedef CwiseUnaryOp<internal::scalar_arg_op<Scalar>, const Derived> ArgReturnType;\ntypedef CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const Derived> Abs2ReturnType;\ntypedef CwiseUnaryOp<internal::scalar_sqrt_op<Scalar>, const Derived> SqrtReturnType;\ntypedef CwiseUnaryOp<internal::scalar_rsqrt_op<Scalar>, const Derived> RsqrtReturnType;\ntypedef CwiseUnaryOp<internal::scalar_sign_op<Scalar>, const Derived> SignReturnType;\ntypedef CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const Derived> InverseReturnType;\ntypedef CwiseUnaryOp<internal::scalar_boolean_not_op<Scalar>, const Derived> BooleanNotReturnType;\n\ntypedef CwiseUnaryOp<internal::scalar_exp_op<Scalar>, const Derived> ExpReturnType;\ntypedef CwiseUnaryOp<internal::scalar_log_op<Scalar>, const Derived> LogReturnType;\ntypedef CwiseUnaryOp<internal::scalar_log1p_op<Scalar>, const Derived> Log1pReturnType;\ntypedef CwiseUnaryOp<internal::scalar_log10_op<Scalar>, const Derived> Log10ReturnType;\ntypedef CwiseUnaryOp<internal::scalar_cos_op<Scalar>, const Derived> CosReturnType;\ntypedef CwiseUnaryOp<internal::scalar_sin_op<Scalar>, const Derived> SinReturnType;\ntypedef CwiseUnaryOp<internal::scalar_tan_op<Scalar>, const Derived> TanReturnType;\ntypedef CwiseUnaryOp<internal::scalar_acos_op<Scalar>, const Derived> AcosReturnType;\ntypedef CwiseUnaryOp<internal::scalar_asin_op<Scalar>, const Derived> AsinReturnType;\ntypedef CwiseUnaryOp<internal::scalar_atan_op<Scalar>, const Derived> AtanReturnType;\ntypedef CwiseUnaryOp<internal::scalar_tanh_op<Scalar>, const Derived> TanhReturnType;\ntypedef CwiseUnaryOp<internal::scalar_sinh_op<Scalar>, const Derived> SinhReturnType;\ntypedef CwiseUnaryOp<internal::scalar_cosh_op<Scalar>, const Derived> CoshReturnType;\ntypedef CwiseUnaryOp<internal::scalar_square_op<Scalar>, const Derived> SquareReturnType;\ntypedef CwiseUnaryOp<internal::scalar_cube_op<Scalar>, const Derived> CubeReturnType;\ntypedef CwiseUnaryOp<internal::scalar_round_op<Scalar>, const Derived> RoundReturnType;\ntypedef CwiseUnaryOp<internal::scalar_floor_op<Scalar>, const Derived> FloorReturnType;\ntypedef CwiseUnaryOp<internal::scalar_ceil_op<Scalar>, const Derived> CeilReturnType;\ntypedef CwiseUnaryOp<internal::scalar_isnan_op<Scalar>, const Derived> IsNaNReturnType;\ntypedef CwiseUnaryOp<internal::scalar_isinf_op<Scalar>, const Derived> IsInfReturnType;\ntypedef CwiseUnaryOp<internal::scalar_isfinite_op<Scalar>, const Derived> IsFiniteReturnType;\n\n/** \\returns an expression of the coefficient-wise absolute value of \\c *this\n  *\n  * Example: \\include Cwise_abs.cpp\n  * Output: \\verbinclude Cwise_abs.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_abs\">Math functions</a>, abs2()\n  */\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const AbsReturnType\nabs() const\n{\n  return AbsReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise phase angle of \\c *this\n  *\n  * Example: \\include Cwise_arg.cpp\n  * Output: \\verbinclude Cwise_arg.out\n  *\n  * \\sa abs()\n  */\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const ArgReturnType\narg() const\n{\n  return ArgReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise squared absolute value of \\c *this\n  *\n  * Example: \\include Cwise_abs2.cpp\n  * Output: \\verbinclude Cwise_abs2.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_abs2\">Math functions</a>, abs(), square()\n  */\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const Abs2ReturnType\nabs2() const\n{\n  return Abs2ReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise exponential of *this.\n  *\n  * This function computes the coefficient-wise exponential. The function MatrixBase::exp() in the\n  * unsupported module MatrixFunctions computes the matrix exponential.\n  *\n  * Example: \\include Cwise_exp.cpp\n  * Output: \\verbinclude Cwise_exp.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_exp\">Math functions</a>, pow(), log(), sin(), cos()\n  */\nEIGEN_DEVICE_FUNC\ninline const ExpReturnType\nexp() const\n{\n  return ExpReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise logarithm of *this.\n  *\n  * This function computes the coefficient-wise logarithm. The function MatrixBase::log() in the\n  * unsupported module MatrixFunctions computes the matrix logarithm.\n  *\n  * Example: \\include Cwise_log.cpp\n  * Output: \\verbinclude Cwise_log.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_log\">Math functions</a>, exp()\n  */\nEIGEN_DEVICE_FUNC\ninline const LogReturnType\nlog() const\n{\n  return LogReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise logarithm of 1 plus \\c *this.\n  *\n  * In exact arithmetic, \\c x.log() is equivalent to \\c (x+1).log(),\n  * however, with finite precision, this function is much more accurate when \\c x is close to zero.\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_log1p\">Math functions</a>, log()\n  */\nEIGEN_DEVICE_FUNC\ninline const Log1pReturnType\nlog1p() const\n{\n  return Log1pReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise base-10 logarithm of *this.\n  *\n  * This function computes the coefficient-wise base-10 logarithm.\n  *\n  * Example: \\include Cwise_log10.cpp\n  * Output: \\verbinclude Cwise_log10.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_log10\">Math functions</a>, log()\n  */\nEIGEN_DEVICE_FUNC\ninline const Log10ReturnType\nlog10() const\n{\n  return Log10ReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise square root of *this.\n  *\n  * This function computes the coefficient-wise square root. The function MatrixBase::sqrt() in the\n  * unsupported module MatrixFunctions computes the matrix square root.\n  *\n  * Example: \\include Cwise_sqrt.cpp\n  * Output: \\verbinclude Cwise_sqrt.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_sqrt\">Math functions</a>, pow(), square()\n  */\nEIGEN_DEVICE_FUNC\ninline const SqrtReturnType\nsqrt() const\n{\n  return SqrtReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise inverse square root of *this.\n  *\n  * This function computes the coefficient-wise inverse square root.\n  *\n  * Example: \\include Cwise_sqrt.cpp\n  * Output: \\verbinclude Cwise_sqrt.out\n  *\n  * \\sa pow(), square()\n  */\nEIGEN_DEVICE_FUNC\ninline const RsqrtReturnType\nrsqrt() const\n{\n  return RsqrtReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise signum of *this.\n  *\n  * This function computes the coefficient-wise signum.\n  *\n  * Example: \\include Cwise_sign.cpp\n  * Output: \\verbinclude Cwise_sign.out\n  *\n  * \\sa pow(), square()\n  */\nEIGEN_DEVICE_FUNC\ninline const SignReturnType\nsign() const\n{\n  return SignReturnType(derived());\n}\n\n\n/** \\returns an expression of the coefficient-wise cosine of *this.\n  *\n  * This function computes the coefficient-wise cosine. The function MatrixBase::cos() in the\n  * unsupported module MatrixFunctions computes the matrix cosine.\n  *\n  * Example: \\include Cwise_cos.cpp\n  * Output: \\verbinclude Cwise_cos.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_cos\">Math functions</a>, sin(), acos()\n  */\nEIGEN_DEVICE_FUNC\ninline const CosReturnType\ncos() const\n{\n  return CosReturnType(derived());\n}\n\n\n/** \\returns an expression of the coefficient-wise sine of *this.\n  *\n  * This function computes the coefficient-wise sine. The function MatrixBase::sin() in the\n  * unsupported module MatrixFunctions computes the matrix sine.\n  *\n  * Example: \\include Cwise_sin.cpp\n  * Output: \\verbinclude Cwise_sin.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_sin\">Math functions</a>, cos(), asin()\n  */\nEIGEN_DEVICE_FUNC\ninline const SinReturnType\nsin() const\n{\n  return SinReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise tan of *this.\n  *\n  * Example: \\include Cwise_tan.cpp\n  * Output: \\verbinclude Cwise_tan.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_tan\">Math functions</a>, cos(), sin()\n  */\nEIGEN_DEVICE_FUNC\ninline const TanReturnType\ntan() const\n{\n  return TanReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise arc tan of *this.\n  *\n  * Example: \\include Cwise_atan.cpp\n  * Output: \\verbinclude Cwise_atan.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_atan\">Math functions</a>, tan(), asin(), acos()\n  */\nEIGEN_DEVICE_FUNC\ninline const AtanReturnType\natan() const\n{\n  return AtanReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise arc cosine of *this.\n  *\n  * Example: \\include Cwise_acos.cpp\n  * Output: \\verbinclude Cwise_acos.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_acos\">Math functions</a>, cos(), asin()\n  */\nEIGEN_DEVICE_FUNC\ninline const AcosReturnType\nacos() const\n{\n  return AcosReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise arc sine of *this.\n  *\n  * Example: \\include Cwise_asin.cpp\n  * Output: \\verbinclude Cwise_asin.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_asin\">Math functions</a>, sin(), acos()\n  */\nEIGEN_DEVICE_FUNC\ninline const AsinReturnType\nasin() const\n{\n  return AsinReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise hyperbolic tan of *this.\n  *\n  * Example: \\include Cwise_tanh.cpp\n  * Output: \\verbinclude Cwise_tanh.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_tanh\">Math functions</a>, tan(), sinh(), cosh()\n  */\nEIGEN_DEVICE_FUNC\ninline const TanhReturnType\ntanh() const\n{\n  return TanhReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise hyperbolic sin of *this.\n  *\n  * Example: \\include Cwise_sinh.cpp\n  * Output: \\verbinclude Cwise_sinh.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_sinh\">Math functions</a>, sin(), tanh(), cosh()\n  */\nEIGEN_DEVICE_FUNC\ninline const SinhReturnType\nsinh() const\n{\n  return SinhReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise hyperbolic cos of *this.\n  *\n  * Example: \\include Cwise_cosh.cpp\n  * Output: \\verbinclude Cwise_cosh.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_cosh\">Math functions</a>, tan(), sinh(), cosh()\n  */\nEIGEN_DEVICE_FUNC\ninline const CoshReturnType\ncosh() const\n{\n  return CoshReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise inverse of *this.\n  *\n  * Example: \\include Cwise_inverse.cpp\n  * Output: \\verbinclude Cwise_inverse.out\n  *\n  * \\sa operator/(), operator*()\n  */\nEIGEN_DEVICE_FUNC\ninline const InverseReturnType\ninverse() const\n{\n  return InverseReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise square of *this.\n  *\n  * Example: \\include Cwise_square.cpp\n  * Output: \\verbinclude Cwise_square.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_squareE\">Math functions</a>, abs2(), cube(), pow()\n  */\nEIGEN_DEVICE_FUNC\ninline const SquareReturnType\nsquare() const\n{\n  return SquareReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise cube of *this.\n  *\n  * Example: \\include Cwise_cube.cpp\n  * Output: \\verbinclude Cwise_cube.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_cube\">Math functions</a>, square(), pow()\n  */\nEIGEN_DEVICE_FUNC\ninline const CubeReturnType\ncube() const\n{\n  return CubeReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise round of *this.\n  *\n  * Example: \\include Cwise_round.cpp\n  * Output: \\verbinclude Cwise_round.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_round\">Math functions</a>, ceil(), floor()\n  */\nEIGEN_DEVICE_FUNC\ninline const RoundReturnType\nround() const\n{\n  return RoundReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise floor of *this.\n  *\n  * Example: \\include Cwise_floor.cpp\n  * Output: \\verbinclude Cwise_floor.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_floor\">Math functions</a>, ceil(), round()\n  */\nEIGEN_DEVICE_FUNC\ninline const FloorReturnType\nfloor() const\n{\n  return FloorReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise ceil of *this.\n  *\n  * Example: \\include Cwise_ceil.cpp\n  * Output: \\verbinclude Cwise_ceil.out\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_ceil\">Math functions</a>, floor(), round()\n  */\nEIGEN_DEVICE_FUNC\ninline const CeilReturnType\nceil() const\n{\n  return CeilReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise isnan of *this.\n  *\n  * Example: \\include Cwise_isNaN.cpp\n  * Output: \\verbinclude Cwise_isNaN.out\n  *\n  * \\sa isfinite(), isinf()\n  */\nEIGEN_DEVICE_FUNC\ninline const IsNaNReturnType\nisNaN() const\n{\n  return IsNaNReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise isinf of *this.\n  *\n  * Example: \\include Cwise_isInf.cpp\n  * Output: \\verbinclude Cwise_isInf.out\n  *\n  * \\sa isnan(), isfinite()\n  */\nEIGEN_DEVICE_FUNC\ninline const IsInfReturnType\nisInf() const\n{\n  return IsInfReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise isfinite of *this.\n  *\n  * Example: \\include Cwise_isFinite.cpp\n  * Output: \\verbinclude Cwise_isFinite.out\n  *\n  * \\sa isnan(), isinf()\n  */\nEIGEN_DEVICE_FUNC\ninline const IsFiniteReturnType\nisFinite() const\n{\n  return IsFiniteReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise ! operator of *this\n  *\n  * \\warning this operator is for expression of bool only.\n  *\n  * Example: \\include Cwise_boolean_not.cpp\n  * Output: \\verbinclude Cwise_boolean_not.out\n  *\n  * \\sa operator!=()\n  */\nEIGEN_DEVICE_FUNC\ninline const BooleanNotReturnType\noperator!() const\n{\n  EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value),\n                      THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);\n  return BooleanNotReturnType(derived());\n}\n\n\n// --- SpecialFunctions module ---\n\ntypedef CwiseUnaryOp<internal::scalar_lgamma_op<Scalar>, const Derived> LgammaReturnType;\ntypedef CwiseUnaryOp<internal::scalar_digamma_op<Scalar>, const Derived> DigammaReturnType;\ntypedef CwiseUnaryOp<internal::scalar_erf_op<Scalar>, const Derived> ErfReturnType;\ntypedef CwiseUnaryOp<internal::scalar_erfc_op<Scalar>, const Derived> ErfcReturnType;\n\n/** \\cpp11 \\returns an expression of the coefficient-wise ln(|gamma(*this)|).\n  *\n  * \\specialfunctions_module\n  *\n  * Example: \\include Cwise_lgamma.cpp\n  * Output: \\verbinclude Cwise_lgamma.out\n  *\n  * \\note This function supports only float and double scalar types in c++11 mode. To support other scalar types,\n  * or float/double in non c++11 mode, the user has to provide implementations of lgamma(T) for any scalar\n  * type T to be supported.\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_lgamma\">Math functions</a>, digamma()\n  */\nEIGEN_DEVICE_FUNC\ninline const LgammaReturnType\nlgamma() const\n{\n  return LgammaReturnType(derived());\n}\n\n/** \\returns an expression of the coefficient-wise digamma (psi, derivative of lgamma).\n  *\n  * \\specialfunctions_module\n  *\n  * \\note This function supports only float and double scalar types. To support other scalar types,\n  * the user has to provide implementations of digamma(T) for any scalar\n  * type T to be supported.\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_digamma\">Math functions</a>, Eigen::digamma(), Eigen::polygamma(), lgamma()\n  */\nEIGEN_DEVICE_FUNC\ninline const DigammaReturnType\ndigamma() const\n{\n  return DigammaReturnType(derived());\n}\n\n/** \\cpp11 \\returns an expression of the coefficient-wise Gauss error\n  * function of *this.\n  *\n  * \\specialfunctions_module\n  *\n  * Example: \\include Cwise_erf.cpp\n  * Output: \\verbinclude Cwise_erf.out\n  *\n  * \\note This function supports only float and double scalar types in c++11 mode. To support other scalar types,\n  * or float/double in non c++11 mode, the user has to provide implementations of erf(T) for any scalar\n  * type T to be supported.\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_erf\">Math functions</a>, erfc()\n  */\nEIGEN_DEVICE_FUNC\ninline const ErfReturnType\nerf() const\n{\n  return ErfReturnType(derived());\n}\n\n/** \\cpp11 \\returns an expression of the coefficient-wise Complementary error\n  * function of *this.\n  *\n  * \\specialfunctions_module\n  *\n  * Example: \\include Cwise_erfc.cpp\n  * Output: \\verbinclude Cwise_erfc.out\n  *\n  * \\note This function supports only float and double scalar types in c++11 mode. To support other scalar types,\n  * or float/double in non c++11 mode, the user has to provide implementations of erfc(T) for any scalar\n  * type T to be supported.\n  *\n  * \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_erfc\">Math functions</a>, erf()\n  */\nEIGEN_DEVICE_FUNC\ninline const ErfcReturnType\nerfc() const\n{\n  return ErfcReturnType(derived());\n}\n"
  },
  {
    "path": "include/externals/Eigen/src/plugins/BlockMethods.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n\n/// \\internal expression type of a column */\ntypedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr;\ntypedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr;\n/// \\internal expression type of a row */\ntypedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr;\ntypedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr;\n/// \\internal expression type of a block of whole columns */\ntypedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr;\ntypedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr;\n/// \\internal expression type of a block of whole rows */\ntypedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr;\ntypedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr;\n/// \\internal expression type of a block of whole columns */\ntemplate<int N> struct NColsBlockXpr { typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };\ntemplate<int N> struct ConstNColsBlockXpr { typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };\n/// \\internal expression type of a block of whole rows */\ntemplate<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };\ntemplate<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };\n/// \\internal expression of a block */\ntypedef Block<Derived> BlockXpr;\ntypedef const Block<const Derived> ConstBlockXpr;\n/// \\internal expression of a block of fixed sizes */\ntemplate<int Rows, int Cols> struct FixedBlockXpr { typedef Block<Derived,Rows,Cols> Type; };\ntemplate<int Rows, int Cols> struct ConstFixedBlockXpr { typedef Block<const Derived,Rows,Cols> Type; };\n\ntypedef VectorBlock<Derived> SegmentReturnType;\ntypedef const VectorBlock<const Derived> ConstSegmentReturnType;\ntemplate<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; };\ntemplate<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; };\n\n#endif // not EIGEN_PARSED_BY_DOXYGEN\n\n/// \\returns a dynamic-size expression of a block in *this.\n///\n/// \\param startRow the first row in the block\n/// \\param startCol the first column in the block\n/// \\param blockRows the number of rows in the block\n/// \\param blockCols the number of columns in the block\n///\n/// Example: \\include MatrixBase_block_int_int_int_int.cpp\n/// Output: \\verbinclude MatrixBase_block_int_int_int_int.out\n///\n/// \\note Even though the returned expression has dynamic size, in the case\n/// when it is applied to a fixed-size matrix, it inherits a fixed maximal size,\n/// which means that evaluating it does not cause a dynamic memory allocation.\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block, block(Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline BlockXpr block(Index startRow, Index startCol, Index blockRows, Index blockCols)\n{\n  return BlockXpr(derived(), startRow, startCol, blockRows, blockCols);\n}\n\n/// This is the const version of block(Index,Index,Index,Index). */\nEIGEN_DEVICE_FUNC\ninline const ConstBlockXpr block(Index startRow, Index startCol, Index blockRows, Index blockCols) const\n{\n  return ConstBlockXpr(derived(), startRow, startCol, blockRows, blockCols);\n}\n\n\n\n\n/// \\returns a dynamic-size expression of a top-right corner of *this.\n///\n/// \\param cRows the number of rows in the corner\n/// \\param cCols the number of columns in the corner\n///\n/// Example: \\include MatrixBase_topRightCorner_int_int.cpp\n/// Output: \\verbinclude MatrixBase_topRightCorner_int_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline BlockXpr topRightCorner(Index cRows, Index cCols)\n{\n  return BlockXpr(derived(), 0, cols() - cCols, cRows, cCols);\n}\n\n/// This is the const version of topRightCorner(Index, Index).\nEIGEN_DEVICE_FUNC\ninline const ConstBlockXpr topRightCorner(Index cRows, Index cCols) const\n{\n  return ConstBlockXpr(derived(), 0, cols() - cCols, cRows, cCols);\n}\n\n/// \\returns an expression of a fixed-size top-right corner of *this.\n///\n/// \\tparam CRows the number of rows in the corner\n/// \\tparam CCols the number of columns in the corner\n///\n/// Example: \\include MatrixBase_template_int_int_topRightCorner.cpp\n/// Output: \\verbinclude MatrixBase_template_int_int_topRightCorner.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block, block<int,int>(Index,Index)\n///\ntemplate<int CRows, int CCols>\nEIGEN_DEVICE_FUNC\ninline typename FixedBlockXpr<CRows,CCols>::Type topRightCorner()\n{\n  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);\n}\n\n/// This is the const version of topRightCorner<int, int>().\ntemplate<int CRows, int CCols>\nEIGEN_DEVICE_FUNC\ninline const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner() const\n{\n  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);\n}\n\n/// \\returns an expression of a top-right corner of *this.\n///\n/// \\tparam CRows number of rows in corner as specified at compile-time\n/// \\tparam CCols number of columns in corner as specified at compile-time\n/// \\param  cRows number of rows in corner as specified at run-time\n/// \\param  cCols number of columns in corner as specified at run-time\n///\n/// This function is mainly useful for corners where the number of rows is specified at compile-time\n/// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time\n/// information should not contradict. In other words, \\a cRows should equal \\a CRows unless\n/// \\a CRows is \\a Dynamic, and the same for the number of columns.\n///\n/// Example: \\include MatrixBase_template_int_int_topRightCorner_int_int.cpp\n/// Output: \\verbinclude MatrixBase_template_int_int_topRightCorner_int_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block\n///\ntemplate<int CRows, int CCols>\ninline typename FixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols)\n{\n  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);\n}\n\n/// This is the const version of topRightCorner<int, int>(Index, Index).\ntemplate<int CRows, int CCols>\ninline const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols) const\n{\n  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);\n}\n\n\n\n/// \\returns a dynamic-size expression of a top-left corner of *this.\n///\n/// \\param cRows the number of rows in the corner\n/// \\param cCols the number of columns in the corner\n///\n/// Example: \\include MatrixBase_topLeftCorner_int_int.cpp\n/// Output: \\verbinclude MatrixBase_topLeftCorner_int_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline BlockXpr topLeftCorner(Index cRows, Index cCols)\n{\n  return BlockXpr(derived(), 0, 0, cRows, cCols);\n}\n\n/// This is the const version of topLeftCorner(Index, Index).\nEIGEN_DEVICE_FUNC\ninline const ConstBlockXpr topLeftCorner(Index cRows, Index cCols) const\n{\n  return ConstBlockXpr(derived(), 0, 0, cRows, cCols);\n}\n\n/// \\returns an expression of a fixed-size top-left corner of *this.\n///\n/// The template parameters CRows and CCols are the number of rows and columns in the corner.\n///\n/// Example: \\include MatrixBase_template_int_int_topLeftCorner.cpp\n/// Output: \\verbinclude MatrixBase_template_int_int_topLeftCorner.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\ntemplate<int CRows, int CCols>\nEIGEN_DEVICE_FUNC\ninline typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner()\n{\n  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);\n}\n\n/// This is the const version of topLeftCorner<int, int>().\ntemplate<int CRows, int CCols>\nEIGEN_DEVICE_FUNC\ninline const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner() const\n{\n  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);\n}\n\n/// \\returns an expression of a top-left corner of *this.\n///\n/// \\tparam CRows number of rows in corner as specified at compile-time\n/// \\tparam CCols number of columns in corner as specified at compile-time\n/// \\param  cRows number of rows in corner as specified at run-time\n/// \\param  cCols number of columns in corner as specified at run-time\n///\n/// This function is mainly useful for corners where the number of rows is specified at compile-time\n/// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time\n/// information should not contradict. In other words, \\a cRows should equal \\a CRows unless\n/// \\a CRows is \\a Dynamic, and the same for the number of columns.\n///\n/// Example: \\include MatrixBase_template_int_int_topLeftCorner_int_int.cpp\n/// Output: \\verbinclude MatrixBase_template_int_int_topLeftCorner_int_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block\n///\ntemplate<int CRows, int CCols>\ninline typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols)\n{\n  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);\n}\n\n/// This is the const version of topLeftCorner<int, int>(Index, Index).\ntemplate<int CRows, int CCols>\ninline const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols) const\n{\n  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);\n}\n\n\n\n/// \\returns a dynamic-size expression of a bottom-right corner of *this.\n///\n/// \\param cRows the number of rows in the corner\n/// \\param cCols the number of columns in the corner\n///\n/// Example: \\include MatrixBase_bottomRightCorner_int_int.cpp\n/// Output: \\verbinclude MatrixBase_bottomRightCorner_int_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline BlockXpr bottomRightCorner(Index cRows, Index cCols)\n{\n  return BlockXpr(derived(), rows() - cRows, cols() - cCols, cRows, cCols);\n}\n\n/// This is the const version of bottomRightCorner(Index, Index).\nEIGEN_DEVICE_FUNC\ninline const ConstBlockXpr bottomRightCorner(Index cRows, Index cCols) const\n{\n  return ConstBlockXpr(derived(), rows() - cRows, cols() - cCols, cRows, cCols);\n}\n\n/// \\returns an expression of a fixed-size bottom-right corner of *this.\n///\n/// The template parameters CRows and CCols are the number of rows and columns in the corner.\n///\n/// Example: \\include MatrixBase_template_int_int_bottomRightCorner.cpp\n/// Output: \\verbinclude MatrixBase_template_int_int_bottomRightCorner.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\ntemplate<int CRows, int CCols>\nEIGEN_DEVICE_FUNC\ninline typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner()\n{\n  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);\n}\n\n/// This is the const version of bottomRightCorner<int, int>().\ntemplate<int CRows, int CCols>\nEIGEN_DEVICE_FUNC\ninline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner() const\n{\n  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);\n}\n\n/// \\returns an expression of a bottom-right corner of *this.\n///\n/// \\tparam CRows number of rows in corner as specified at compile-time\n/// \\tparam CCols number of columns in corner as specified at compile-time\n/// \\param  cRows number of rows in corner as specified at run-time\n/// \\param  cCols number of columns in corner as specified at run-time\n///\n/// This function is mainly useful for corners where the number of rows is specified at compile-time\n/// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time\n/// information should not contradict. In other words, \\a cRows should equal \\a CRows unless\n/// \\a CRows is \\a Dynamic, and the same for the number of columns.\n///\n/// Example: \\include MatrixBase_template_int_int_bottomRightCorner_int_int.cpp\n/// Output: \\verbinclude MatrixBase_template_int_int_bottomRightCorner_int_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block\n///\ntemplate<int CRows, int CCols>\ninline typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols)\n{\n  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);\n}\n\n/// This is the const version of bottomRightCorner<int, int>(Index, Index).\ntemplate<int CRows, int CCols>\ninline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols) const\n{\n  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);\n}\n\n\n\n/// \\returns a dynamic-size expression of a bottom-left corner of *this.\n///\n/// \\param cRows the number of rows in the corner\n/// \\param cCols the number of columns in the corner\n///\n/// Example: \\include MatrixBase_bottomLeftCorner_int_int.cpp\n/// Output: \\verbinclude MatrixBase_bottomLeftCorner_int_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline BlockXpr bottomLeftCorner(Index cRows, Index cCols)\n{\n  return BlockXpr(derived(), rows() - cRows, 0, cRows, cCols);\n}\n\n/// This is the const version of bottomLeftCorner(Index, Index).\nEIGEN_DEVICE_FUNC\ninline const ConstBlockXpr bottomLeftCorner(Index cRows, Index cCols) const\n{\n  return ConstBlockXpr(derived(), rows() - cRows, 0, cRows, cCols);\n}\n\n/// \\returns an expression of a fixed-size bottom-left corner of *this.\n///\n/// The template parameters CRows and CCols are the number of rows and columns in the corner.\n///\n/// Example: \\include MatrixBase_template_int_int_bottomLeftCorner.cpp\n/// Output: \\verbinclude MatrixBase_template_int_int_bottomLeftCorner.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\ntemplate<int CRows, int CCols>\nEIGEN_DEVICE_FUNC\ninline typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner()\n{\n  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);\n}\n\n/// This is the const version of bottomLeftCorner<int, int>().\ntemplate<int CRows, int CCols>\nEIGEN_DEVICE_FUNC\ninline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner() const\n{\n  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);\n}\n\n/// \\returns an expression of a bottom-left corner of *this.\n///\n/// \\tparam CRows number of rows in corner as specified at compile-time\n/// \\tparam CCols number of columns in corner as specified at compile-time\n/// \\param  cRows number of rows in corner as specified at run-time\n/// \\param  cCols number of columns in corner as specified at run-time\n///\n/// This function is mainly useful for corners where the number of rows is specified at compile-time\n/// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time\n/// information should not contradict. In other words, \\a cRows should equal \\a CRows unless\n/// \\a CRows is \\a Dynamic, and the same for the number of columns.\n///\n/// Example: \\include MatrixBase_template_int_int_bottomLeftCorner_int_int.cpp\n/// Output: \\verbinclude MatrixBase_template_int_int_bottomLeftCorner_int_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block\n///\ntemplate<int CRows, int CCols>\ninline typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols)\n{\n  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);\n}\n\n/// This is the const version of bottomLeftCorner<int, int>(Index, Index).\ntemplate<int CRows, int CCols>\ninline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols) const\n{\n  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);\n}\n\n\n\n/// \\returns a block consisting of the top rows of *this.\n///\n/// \\param n the number of rows in the block\n///\n/// Example: \\include MatrixBase_topRows_int.cpp\n/// Output: \\verbinclude MatrixBase_topRows_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline RowsBlockXpr topRows(Index n)\n{\n  return RowsBlockXpr(derived(), 0, 0, n, cols());\n}\n\n/// This is the const version of topRows(Index).\nEIGEN_DEVICE_FUNC\ninline ConstRowsBlockXpr topRows(Index n) const\n{\n  return ConstRowsBlockXpr(derived(), 0, 0, n, cols());\n}\n\n/// \\returns a block consisting of the top rows of *this.\n///\n/// \\tparam N the number of rows in the block as specified at compile-time\n/// \\param n the number of rows in the block as specified at run-time\n///\n/// The compile-time and run-time information should not contradict. In other words,\n/// \\a n should equal \\a N unless \\a N is \\a Dynamic.\n///\n/// Example: \\include MatrixBase_template_int_topRows.cpp\n/// Output: \\verbinclude MatrixBase_template_int_topRows.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename NRowsBlockXpr<N>::Type topRows(Index n = N)\n{\n  return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());\n}\n\n/// This is the const version of topRows<int>().\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const\n{\n  return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());\n}\n\n\n\n/// \\returns a block consisting of the bottom rows of *this.\n///\n/// \\param n the number of rows in the block\n///\n/// Example: \\include MatrixBase_bottomRows_int.cpp\n/// Output: \\verbinclude MatrixBase_bottomRows_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline RowsBlockXpr bottomRows(Index n)\n{\n  return RowsBlockXpr(derived(), rows() - n, 0, n, cols());\n}\n\n/// This is the const version of bottomRows(Index).\nEIGEN_DEVICE_FUNC\ninline ConstRowsBlockXpr bottomRows(Index n) const\n{\n  return ConstRowsBlockXpr(derived(), rows() - n, 0, n, cols());\n}\n\n/// \\returns a block consisting of the bottom rows of *this.\n///\n/// \\tparam N the number of rows in the block as specified at compile-time\n/// \\param n the number of rows in the block as specified at run-time\n///\n/// The compile-time and run-time information should not contradict. In other words,\n/// \\a n should equal \\a N unless \\a N is \\a Dynamic.\n///\n/// Example: \\include MatrixBase_template_int_bottomRows.cpp\n/// Output: \\verbinclude MatrixBase_template_int_bottomRows.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename NRowsBlockXpr<N>::Type bottomRows(Index n = N)\n{\n  return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());\n}\n\n/// This is the const version of bottomRows<int>().\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const\n{\n  return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());\n}\n\n\n\n/// \\returns a block consisting of a range of rows of *this.\n///\n/// \\param startRow the index of the first row in the block\n/// \\param n the number of rows in the block\n///\n/// Example: \\include DenseBase_middleRows_int.cpp\n/// Output: \\verbinclude DenseBase_middleRows_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline RowsBlockXpr middleRows(Index startRow, Index n)\n{\n  return RowsBlockXpr(derived(), startRow, 0, n, cols());\n}\n\n/// This is the const version of middleRows(Index,Index).\nEIGEN_DEVICE_FUNC\ninline ConstRowsBlockXpr middleRows(Index startRow, Index n) const\n{\n  return ConstRowsBlockXpr(derived(), startRow, 0, n, cols());\n}\n\n/// \\returns a block consisting of a range of rows of *this.\n///\n/// \\tparam N the number of rows in the block as specified at compile-time\n/// \\param startRow the index of the first row in the block\n/// \\param n the number of rows in the block as specified at run-time\n///\n/// The compile-time and run-time information should not contradict. In other words,\n/// \\a n should equal \\a N unless \\a N is \\a Dynamic.\n///\n/// Example: \\include DenseBase_template_int_middleRows.cpp\n/// Output: \\verbinclude DenseBase_template_int_middleRows.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N)\n{\n  return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());\n}\n\n/// This is the const version of middleRows<int>().\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const\n{\n  return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());\n}\n\n\n\n/// \\returns a block consisting of the left columns of *this.\n///\n/// \\param n the number of columns in the block\n///\n/// Example: \\include MatrixBase_leftCols_int.cpp\n/// Output: \\verbinclude MatrixBase_leftCols_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline ColsBlockXpr leftCols(Index n)\n{\n  return ColsBlockXpr(derived(), 0, 0, rows(), n);\n}\n\n/// This is the const version of leftCols(Index).\nEIGEN_DEVICE_FUNC\ninline ConstColsBlockXpr leftCols(Index n) const\n{\n  return ConstColsBlockXpr(derived(), 0, 0, rows(), n);\n}\n\n/// \\returns a block consisting of the left columns of *this.\n///\n/// \\tparam N the number of columns in the block as specified at compile-time\n/// \\param n the number of columns in the block as specified at run-time\n///\n/// The compile-time and run-time information should not contradict. In other words,\n/// \\a n should equal \\a N unless \\a N is \\a Dynamic.\n///\n/// Example: \\include MatrixBase_template_int_leftCols.cpp\n/// Output: \\verbinclude MatrixBase_template_int_leftCols.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename NColsBlockXpr<N>::Type leftCols(Index n = N)\n{\n  return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);\n}\n\n/// This is the const version of leftCols<int>().\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const\n{\n  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);\n}\n\n\n\n/// \\returns a block consisting of the right columns of *this.\n///\n/// \\param n the number of columns in the block\n///\n/// Example: \\include MatrixBase_rightCols_int.cpp\n/// Output: \\verbinclude MatrixBase_rightCols_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline ColsBlockXpr rightCols(Index n)\n{\n  return ColsBlockXpr(derived(), 0, cols() - n, rows(), n);\n}\n\n/// This is the const version of rightCols(Index).\nEIGEN_DEVICE_FUNC\ninline ConstColsBlockXpr rightCols(Index n) const\n{\n  return ConstColsBlockXpr(derived(), 0, cols() - n, rows(), n);\n}\n\n/// \\returns a block consisting of the right columns of *this.\n///\n/// \\tparam N the number of columns in the block as specified at compile-time\n/// \\param n the number of columns in the block as specified at run-time\n///\n/// The compile-time and run-time information should not contradict. In other words,\n/// \\a n should equal \\a N unless \\a N is \\a Dynamic.\n///\n/// Example: \\include MatrixBase_template_int_rightCols.cpp\n/// Output: \\verbinclude MatrixBase_template_int_rightCols.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename NColsBlockXpr<N>::Type rightCols(Index n = N)\n{\n  return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);\n}\n\n/// This is the const version of rightCols<int>().\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const\n{\n  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);\n}\n\n\n\n/// \\returns a block consisting of a range of columns of *this.\n///\n/// \\param startCol the index of the first column in the block\n/// \\param numCols the number of columns in the block\n///\n/// Example: \\include DenseBase_middleCols_int.cpp\n/// Output: \\verbinclude DenseBase_middleCols_int.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline ColsBlockXpr middleCols(Index startCol, Index numCols)\n{\n  return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);\n}\n\n/// This is the const version of middleCols(Index,Index).\nEIGEN_DEVICE_FUNC\ninline ConstColsBlockXpr middleCols(Index startCol, Index numCols) const\n{\n  return ConstColsBlockXpr(derived(), 0, startCol, rows(), numCols);\n}\n\n/// \\returns a block consisting of a range of columns of *this.\n///\n/// \\tparam N the number of columns in the block as specified at compile-time\n/// \\param startCol the index of the first column in the block\n/// \\param n the number of columns in the block as specified at run-time\n///\n/// The compile-time and run-time information should not contradict. In other words,\n/// \\a n should equal \\a N unless \\a N is \\a Dynamic.\n///\n/// Example: \\include DenseBase_template_int_middleCols.cpp\n/// Output: \\verbinclude DenseBase_template_int_middleCols.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N)\n{\n  return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);\n}\n\n/// This is the const version of middleCols<int>().\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const\n{\n  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);\n}\n\n\n\n/// \\returns a fixed-size expression of a block in *this.\n///\n/// The template parameters \\a NRows and \\a NCols are the number of\n/// rows and columns in the block.\n///\n/// \\param startRow the first row in the block\n/// \\param startCol the first column in the block\n///\n/// Example: \\include MatrixBase_block_int_int.cpp\n/// Output: \\verbinclude MatrixBase_block_int_int.out\n///\n/// \\note since block is a templated member, the keyword template has to be used\n/// if the matrix type is also a template parameter: \\code m.template block<3,3>(1,1); \\endcode\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\ntemplate<int NRows, int NCols>\nEIGEN_DEVICE_FUNC\ninline typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol)\n{\n  return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);\n}\n\n/// This is the const version of block<>(Index, Index). */\ntemplate<int NRows, int NCols>\nEIGEN_DEVICE_FUNC\ninline const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol) const\n{\n  return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);\n}\n\n/// \\returns an expression of a block in *this.\n///\n/// \\tparam NRows number of rows in block as specified at compile-time\n/// \\tparam NCols number of columns in block as specified at compile-time\n/// \\param  startRow  the first row in the block\n/// \\param  startCol  the first column in the block\n/// \\param  blockRows number of rows in block as specified at run-time\n/// \\param  blockCols number of columns in block as specified at run-time\n///\n/// This function is mainly useful for blocks where the number of rows is specified at compile-time\n/// and the number of columns is specified at run-time, or vice versa. The compile-time and run-time\n/// information should not contradict. In other words, \\a blockRows should equal \\a NRows unless\n/// \\a NRows is \\a Dynamic, and the same for the number of columns.\n///\n/// Example: \\include MatrixBase_template_int_int_block_int_int_int_int.cpp\n/// Output: \\verbinclude MatrixBase_template_int_int_block_int_int_int_int.cpp\n///\nEIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL\n///\n/// \\sa class Block, block(Index,Index,Index,Index)\n///\ntemplate<int NRows, int NCols>\ninline typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol,\n                                                  Index blockRows, Index blockCols)\n{\n  return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);\n}\n\n/// This is the const version of block<>(Index, Index, Index, Index).\ntemplate<int NRows, int NCols>\ninline const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol,\n                                                              Index blockRows, Index blockCols) const\n{\n  return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);\n}\n\n/// \\returns an expression of the \\a i-th column of *this. Note that the numbering starts at 0.\n///\n/// Example: \\include MatrixBase_col.cpp\n/// Output: \\verbinclude MatrixBase_col.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)\n/**\n  * \\sa row(), class Block */\nEIGEN_DEVICE_FUNC\ninline ColXpr col(Index i)\n{\n  return ColXpr(derived(), i);\n}\n\n/// This is the const version of col().\nEIGEN_DEVICE_FUNC\ninline ConstColXpr col(Index i) const\n{\n  return ConstColXpr(derived(), i);\n}\n\n/// \\returns an expression of the \\a i-th row of *this. Note that the numbering starts at 0.\n///\n/// Example: \\include MatrixBase_row.cpp\n/// Output: \\verbinclude MatrixBase_row.out\n///\nEIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)\n/**\n  * \\sa col(), class Block */\nEIGEN_DEVICE_FUNC\ninline RowXpr row(Index i)\n{\n  return RowXpr(derived(), i);\n}\n\n/// This is the const version of row(). */\nEIGEN_DEVICE_FUNC\ninline ConstRowXpr row(Index i) const\n{\n  return ConstRowXpr(derived(), i);\n}\n\n/// \\returns a dynamic-size expression of a segment (i.e. a vector block) in *this.\n///\n/// \\only_for_vectors\n///\n/// \\param start the first coefficient in the segment\n/// \\param n the number of coefficients in the segment\n///\n/// Example: \\include MatrixBase_segment_int_int.cpp\n/// Output: \\verbinclude MatrixBase_segment_int_int.out\n///\n/// \\note Even though the returned expression has dynamic size, in the case\n/// when it is applied to a fixed-size vector, it inherits a fixed maximal size,\n/// which means that evaluating it does not cause a dynamic memory allocation.\n///\n/// \\sa class Block, segment(Index)\n///\nEIGEN_DEVICE_FUNC\ninline SegmentReturnType segment(Index start, Index n)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return SegmentReturnType(derived(), start, n);\n}\n\n\n/// This is the const version of segment(Index,Index).\nEIGEN_DEVICE_FUNC\ninline ConstSegmentReturnType segment(Index start, Index n) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return ConstSegmentReturnType(derived(), start, n);\n}\n\n/// \\returns a dynamic-size expression of the first coefficients of *this.\n///\n/// \\only_for_vectors\n///\n/// \\param n the number of coefficients in the segment\n///\n/// Example: \\include MatrixBase_start_int.cpp\n/// Output: \\verbinclude MatrixBase_start_int.out\n///\n/// \\note Even though the returned expression has dynamic size, in the case\n/// when it is applied to a fixed-size vector, it inherits a fixed maximal size,\n/// which means that evaluating it does not cause a dynamic memory allocation.\n///\n/// \\sa class Block, block(Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline SegmentReturnType head(Index n)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return SegmentReturnType(derived(), 0, n);\n}\n\n/// This is the const version of head(Index).\nEIGEN_DEVICE_FUNC\ninline ConstSegmentReturnType head(Index n) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return ConstSegmentReturnType(derived(), 0, n);\n}\n\n/// \\returns a dynamic-size expression of the last coefficients of *this.\n///\n/// \\only_for_vectors\n///\n/// \\param n the number of coefficients in the segment\n///\n/// Example: \\include MatrixBase_end_int.cpp\n/// Output: \\verbinclude MatrixBase_end_int.out\n///\n/// \\note Even though the returned expression has dynamic size, in the case\n/// when it is applied to a fixed-size vector, it inherits a fixed maximal size,\n/// which means that evaluating it does not cause a dynamic memory allocation.\n///\n/// \\sa class Block, block(Index,Index)\n///\nEIGEN_DEVICE_FUNC\ninline SegmentReturnType tail(Index n)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return SegmentReturnType(derived(), this->size() - n, n);\n}\n\n/// This is the const version of tail(Index).\nEIGEN_DEVICE_FUNC\ninline ConstSegmentReturnType tail(Index n) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return ConstSegmentReturnType(derived(), this->size() - n, n);\n}\n\n/// \\returns a fixed-size expression of a segment (i.e. a vector block) in \\c *this\n///\n/// \\only_for_vectors\n///\n/// \\tparam N the number of coefficients in the segment as specified at compile-time\n/// \\param start the index of the first element in the segment\n/// \\param n the number of coefficients in the segment as specified at compile-time\n///\n/// The compile-time and run-time information should not contradict. In other words,\n/// \\a n should equal \\a N unless \\a N is \\a Dynamic.\n///\n/// Example: \\include MatrixBase_template_int_segment.cpp\n/// Output: \\verbinclude MatrixBase_template_int_segment.out\n///\n/// \\sa class Block\n///\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return typename FixedSegmentReturnType<N>::Type(derived(), start, n);\n}\n\n/// This is the const version of segment<int>(Index).\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n);\n}\n\n/// \\returns a fixed-size expression of the first coefficients of *this.\n///\n/// \\only_for_vectors\n///\n/// \\tparam N the number of coefficients in the segment as specified at compile-time\n/// \\param  n the number of coefficients in the segment as specified at run-time\n///\n/// The compile-time and run-time information should not contradict. In other words,\n/// \\a n should equal \\a N unless \\a N is \\a Dynamic.\n///\n/// Example: \\include MatrixBase_template_int_start.cpp\n/// Output: \\verbinclude MatrixBase_template_int_start.out\n///\n/// \\sa class Block\n///\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename FixedSegmentReturnType<N>::Type head(Index n = N)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);\n}\n\n/// This is the const version of head<int>().\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);\n}\n\n/// \\returns a fixed-size expression of the last coefficients of *this.\n///\n/// \\only_for_vectors\n///\n/// \\tparam N the number of coefficients in the segment as specified at compile-time\n/// \\param  n the number of coefficients in the segment as specified at run-time\n///\n/// The compile-time and run-time information should not contradict. In other words,\n/// \\a n should equal \\a N unless \\a N is \\a Dynamic.\n///\n/// Example: \\include MatrixBase_template_int_end.cpp\n/// Output: \\verbinclude MatrixBase_template_int_end.out\n///\n/// \\sa class Block\n///\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename FixedSegmentReturnType<N>::Type tail(Index n = N)\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);\n}\n\n/// This is the const version of tail<int>.\ntemplate<int N>\nEIGEN_DEVICE_FUNC\ninline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const\n{\n  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)\n  return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);\n}\n"
  },
  {
    "path": "include/externals/Eigen/src/plugins/CommonCwiseBinaryOps.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2016 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n// This file is a base class plugin containing common coefficient wise functions.\n\n/** \\returns an expression of the difference of \\c *this and \\a other\n  *\n  * \\note If you want to substract a given scalar from all coefficients, see Cwise::operator-().\n  *\n  * \\sa class CwiseBinaryOp, operator-=()\n  */\nEIGEN_MAKE_CWISE_BINARY_OP(operator-,difference)\n\n/** \\returns an expression of the sum of \\c *this and \\a other\n  *\n  * \\note If you want to add a given scalar to all coefficients, see Cwise::operator+().\n  *\n  * \\sa class CwiseBinaryOp, operator+=()\n  */\nEIGEN_MAKE_CWISE_BINARY_OP(operator+,sum)\n\n/** \\returns an expression of a custom coefficient-wise operator \\a func of *this and \\a other\n  *\n  * The template parameter \\a CustomBinaryOp is the type of the functor\n  * of the custom operator (see class CwiseBinaryOp for an example)\n  *\n  * Here is an example illustrating the use of custom functors:\n  * \\include class_CwiseBinaryOp.cpp\n  * Output: \\verbinclude class_CwiseBinaryOp.out\n  *\n  * \\sa class CwiseBinaryOp, operator+(), operator-(), cwiseProduct()\n  */\ntemplate<typename CustomBinaryOp, typename OtherDerived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const CwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>\nbinaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const\n{\n  return CwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>(derived(), other.derived(), func);\n}\n\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\nEIGEN_MAKE_SCALAR_BINARY_OP(operator*,product)\n#else\n/** \\returns an expression of \\c *this scaled by the scalar factor \\a scalar\n  *\n  * \\tparam T is the scalar type of \\a scalar. It must be compatible with the scalar type of the given expression.\n  */\ntemplate<typename T>\nconst CwiseBinaryOp<internal::scalar_product_op<Scalar,T>,Derived,Constant<T> > operator*(const T& scalar) const;\n/** \\returns an expression of \\a expr scaled by the scalar factor \\a scalar\n  *\n  * \\tparam T is the scalar type of \\a scalar. It must be compatible with the scalar type of the given expression.\n  */\ntemplate<typename T> friend\nconst CwiseBinaryOp<internal::scalar_product_op<T,Scalar>,Constant<T>,Derived> operator*(const T& scalar, const StorageBaseType& expr);\n#endif\n\n\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\nEIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(operator/,quotient)\n#else\n/** \\returns an expression of \\c *this divided by the scalar value \\a scalar\n  *\n  * \\tparam T is the scalar type of \\a scalar. It must be compatible with the scalar type of the given expression.\n  */\ntemplate<typename T>\nconst CwiseBinaryOp<internal::scalar_quotient_op<Scalar,T>,Derived,Constant<T> > operator/(const T& scalar) const;\n#endif\n\n/** \\returns an expression of the coefficient-wise boolean \\b and operator of \\c *this and \\a other\n  *\n  * \\warning this operator is for expression of bool only.\n  *\n  * Example: \\include Cwise_boolean_and.cpp\n  * Output: \\verbinclude Cwise_boolean_and.out\n  *\n  * \\sa operator||(), select()\n  */\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\ninline const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>\noperator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const\n{\n  EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),\n                      THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);\n  return CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>(derived(),other.derived());\n}\n\n/** \\returns an expression of the coefficient-wise boolean \\b or operator of \\c *this and \\a other\n  *\n  * \\warning this operator is for expression of bool only.\n  *\n  * Example: \\include Cwise_boolean_or.cpp\n  * Output: \\verbinclude Cwise_boolean_or.out\n  *\n  * \\sa operator&&(), select()\n  */\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\ninline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>\noperator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const\n{\n  EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),\n                      THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);\n  return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived());\n}\n"
  },
  {
    "path": "include/externals/Eigen/src/plugins/CommonCwiseUnaryOps.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n// This file is a base class plugin containing common coefficient wise functions.\n\n#ifndef EIGEN_PARSED_BY_DOXYGEN\n\n/** \\internal the return type of conjugate() */\ntypedef typename internal::conditional<NumTraits<Scalar>::IsComplex,\n                    const CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Derived>,\n                    const Derived&\n                  >::type ConjugateReturnType;\n/** \\internal the return type of real() const */\ntypedef typename internal::conditional<NumTraits<Scalar>::IsComplex,\n                    const CwiseUnaryOp<internal::scalar_real_op<Scalar>, const Derived>,\n                    const Derived&\n                  >::type RealReturnType;\n/** \\internal the return type of real() */\ntypedef typename internal::conditional<NumTraits<Scalar>::IsComplex,\n                    CwiseUnaryView<internal::scalar_real_ref_op<Scalar>, Derived>,\n                    Derived&\n                  >::type NonConstRealReturnType;\n/** \\internal the return type of imag() const */\ntypedef CwiseUnaryOp<internal::scalar_imag_op<Scalar>, const Derived> ImagReturnType;\n/** \\internal the return type of imag() */\ntypedef CwiseUnaryView<internal::scalar_imag_ref_op<Scalar>, Derived> NonConstImagReturnType;\n\ntypedef CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> NegativeReturnType;\n\n#endif // not EIGEN_PARSED_BY_DOXYGEN\n\n/// \\returns an expression of the opposite of \\c *this\n///\nEIGEN_DOC_UNARY_ADDONS(operator-,opposite)\n///\nEIGEN_DEVICE_FUNC\ninline const NegativeReturnType\noperator-() const { return NegativeReturnType(derived()); }\n\n\ntemplate<class NewType> struct CastXpr { typedef typename internal::cast_return_type<Derived,const CwiseUnaryOp<internal::scalar_cast_op<Scalar, NewType>, const Derived> >::type Type; };\n\n/// \\returns an expression of \\c *this with the \\a Scalar type casted to\n/// \\a NewScalar.\n///\n/// The template parameter \\a NewScalar is the type we are casting the scalars to.\n///\nEIGEN_DOC_UNARY_ADDONS(cast,conversion function)\n///\n/// \\sa class CwiseUnaryOp\n///\ntemplate<typename NewType>\nEIGEN_DEVICE_FUNC\ntypename CastXpr<NewType>::Type\ncast() const\n{\n  return typename CastXpr<NewType>::Type(derived());\n}\n\n/// \\returns an expression of the complex conjugate of \\c *this.\n///\nEIGEN_DOC_UNARY_ADDONS(conjugate,complex conjugate)\n///\n/// \\sa <a href=\"group__CoeffwiseMathFunctions.html#cwisetable_conj\">Math functions</a>, MatrixBase::adjoint()\nEIGEN_DEVICE_FUNC\ninline ConjugateReturnType\nconjugate() const\n{\n  return ConjugateReturnType(derived());\n}\n\n/// \\returns a read-only expression of the real part of \\c *this.\n///\nEIGEN_DOC_UNARY_ADDONS(real,real part function)\n///\n/// \\sa imag()\nEIGEN_DEVICE_FUNC\ninline RealReturnType\nreal() const { return RealReturnType(derived()); }\n\n/// \\returns an read-only expression of the imaginary part of \\c *this.\n///\nEIGEN_DOC_UNARY_ADDONS(imag,imaginary part function)\n///\n/// \\sa real()\nEIGEN_DEVICE_FUNC\ninline const ImagReturnType\nimag() const { return ImagReturnType(derived()); }\n\n/// \\brief Apply a unary operator coefficient-wise\n/// \\param[in]  func  Functor implementing the unary operator\n/// \\tparam  CustomUnaryOp Type of \\a func\n/// \\returns An expression of a custom coefficient-wise unary operator \\a func of *this\n///\n/// The function \\c ptr_fun() from the C++ standard library can be used to make functors out of normal functions.\n///\n/// Example:\n/// \\include class_CwiseUnaryOp_ptrfun.cpp\n/// Output: \\verbinclude class_CwiseUnaryOp_ptrfun.out\n///\n/// Genuine functors allow for more possibilities, for instance it may contain a state.\n///\n/// Example:\n/// \\include class_CwiseUnaryOp.cpp\n/// Output: \\verbinclude class_CwiseUnaryOp.out\n///\nEIGEN_DOC_UNARY_ADDONS(unaryExpr,unary function)\n///\n/// \\sa unaryViewExpr, binaryExpr, class CwiseUnaryOp\n///\ntemplate<typename CustomUnaryOp>\nEIGEN_DEVICE_FUNC\ninline const CwiseUnaryOp<CustomUnaryOp, const Derived>\nunaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const\n{\n  return CwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);\n}\n\n/// \\returns an expression of a custom coefficient-wise unary operator \\a func of *this\n///\n/// The template parameter \\a CustomUnaryOp is the type of the functor\n/// of the custom unary operator.\n///\n/// Example:\n/// \\include class_CwiseUnaryOp.cpp\n/// Output: \\verbinclude class_CwiseUnaryOp.out\n///\nEIGEN_DOC_UNARY_ADDONS(unaryViewExpr,unary function)\n///\n/// \\sa unaryExpr, binaryExpr class CwiseUnaryOp\n///\ntemplate<typename CustomViewOp>\nEIGEN_DEVICE_FUNC\ninline const CwiseUnaryView<CustomViewOp, const Derived>\nunaryViewExpr(const CustomViewOp& func = CustomViewOp()) const\n{\n  return CwiseUnaryView<CustomViewOp, const Derived>(derived(), func);\n}\n\n/// \\returns a non const expression of the real part of \\c *this.\n///\nEIGEN_DOC_UNARY_ADDONS(real,real part function)\n///\n/// \\sa imag()\nEIGEN_DEVICE_FUNC\ninline NonConstRealReturnType\nreal() { return NonConstRealReturnType(derived()); }\n\n/// \\returns a non const expression of the imaginary part of \\c *this.\n///\nEIGEN_DOC_UNARY_ADDONS(imag,imaginary part function)\n///\n/// \\sa real()\nEIGEN_DEVICE_FUNC\ninline NonConstImagReturnType\nimag() { return NonConstImagReturnType(derived()); }\n"
  },
  {
    "path": "include/externals/Eigen/src/plugins/MatrixCwiseBinaryOps.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n// This file is a base class plugin containing matrix specifics coefficient wise functions.\n\n/** \\returns an expression of the Schur product (coefficient wise product) of *this and \\a other\n  *\n  * Example: \\include MatrixBase_cwiseProduct.cpp\n  * Output: \\verbinclude MatrixBase_cwiseProduct.out\n  *\n  * \\sa class CwiseBinaryOp, cwiseAbs2\n  */\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)\ncwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const\n{\n  return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)(derived(), other.derived());\n}\n\n/** \\returns an expression of the coefficient-wise == operator of *this and \\a other\n  *\n  * \\warning this performs an exact comparison, which is generally a bad idea with floating-point types.\n  * In order to check for equality between two vectors or matrices with floating-point coefficients, it is\n  * generally a far better idea to use a fuzzy comparison as provided by isApprox() and\n  * isMuchSmallerThan().\n  *\n  * Example: \\include MatrixBase_cwiseEqual.cpp\n  * Output: \\verbinclude MatrixBase_cwiseEqual.out\n  *\n  * \\sa cwiseNotEqual(), isApprox(), isMuchSmallerThan()\n  */\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\ninline const CwiseBinaryOp<std::equal_to<Scalar>, const Derived, const OtherDerived>\ncwiseEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const\n{\n  return CwiseBinaryOp<std::equal_to<Scalar>, const Derived, const OtherDerived>(derived(), other.derived());\n}\n\n/** \\returns an expression of the coefficient-wise != operator of *this and \\a other\n  *\n  * \\warning this performs an exact comparison, which is generally a bad idea with floating-point types.\n  * In order to check for equality between two vectors or matrices with floating-point coefficients, it is\n  * generally a far better idea to use a fuzzy comparison as provided by isApprox() and\n  * isMuchSmallerThan().\n  *\n  * Example: \\include MatrixBase_cwiseNotEqual.cpp\n  * Output: \\verbinclude MatrixBase_cwiseNotEqual.out\n  *\n  * \\sa cwiseEqual(), isApprox(), isMuchSmallerThan()\n  */\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\ninline const CwiseBinaryOp<std::not_equal_to<Scalar>, const Derived, const OtherDerived>\ncwiseNotEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const\n{\n  return CwiseBinaryOp<std::not_equal_to<Scalar>, const Derived, const OtherDerived>(derived(), other.derived());\n}\n\n/** \\returns an expression of the coefficient-wise min of *this and \\a other\n  *\n  * Example: \\include MatrixBase_cwiseMin.cpp\n  * Output: \\verbinclude MatrixBase_cwiseMin.out\n  *\n  * \\sa class CwiseBinaryOp, max()\n  */\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived, const OtherDerived>\ncwiseMin(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const\n{\n  return CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived, const OtherDerived>(derived(), other.derived());\n}\n\n/** \\returns an expression of the coefficient-wise min of *this and scalar \\a other\n  *\n  * \\sa class CwiseBinaryOp, min()\n  */\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived, const ConstantReturnType>\ncwiseMin(const Scalar &other) const\n{\n  return cwiseMin(Derived::Constant(rows(), cols(), other));\n}\n\n/** \\returns an expression of the coefficient-wise max of *this and \\a other\n  *\n  * Example: \\include MatrixBase_cwiseMax.cpp\n  * Output: \\verbinclude MatrixBase_cwiseMax.out\n  *\n  * \\sa class CwiseBinaryOp, min()\n  */\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived, const OtherDerived>\ncwiseMax(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const\n{\n  return CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived, const OtherDerived>(derived(), other.derived());\n}\n\n/** \\returns an expression of the coefficient-wise max of *this and scalar \\a other\n  *\n  * \\sa class CwiseBinaryOp, min()\n  */\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived, const ConstantReturnType>\ncwiseMax(const Scalar &other) const\n{\n  return cwiseMax(Derived::Constant(rows(), cols(), other));\n}\n\n\n/** \\returns an expression of the coefficient-wise quotient of *this and \\a other\n  *\n  * Example: \\include MatrixBase_cwiseQuotient.cpp\n  * Output: \\verbinclude MatrixBase_cwiseQuotient.out\n  *\n  * \\sa class CwiseBinaryOp, cwiseProduct(), cwiseInverse()\n  */\ntemplate<typename OtherDerived>\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>\ncwiseQuotient(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const\n{\n  return CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>(derived(), other.derived());\n}\n\ntypedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar,Scalar,internal::cmp_EQ>, const Derived, const ConstantReturnType> CwiseScalarEqualReturnType;\n\n/** \\returns an expression of the coefficient-wise == operator of \\c *this and a scalar \\a s\n  *\n  * \\warning this performs an exact comparison, which is generally a bad idea with floating-point types.\n  * In order to check for equality between two vectors or matrices with floating-point coefficients, it is\n  * generally a far better idea to use a fuzzy comparison as provided by isApprox() and\n  * isMuchSmallerThan().\n  *\n  * \\sa cwiseEqual(const MatrixBase<OtherDerived> &) const\n  */\nEIGEN_DEVICE_FUNC\ninline const CwiseScalarEqualReturnType\ncwiseEqual(const Scalar& s) const\n{\n  return CwiseScalarEqualReturnType(derived(), Derived::Constant(rows(), cols(), s), internal::scalar_cmp_op<Scalar,Scalar,internal::cmp_EQ>());\n}\n"
  },
  {
    "path": "include/externals/Eigen/src/plugins/MatrixCwiseUnaryOps.h",
    "content": "// This file is part of Eigen, a lightweight C++ template library\n// for linear algebra.\n//\n// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>\n// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>\n//\n// This Source Code Form is subject to the terms of the Mozilla\n// Public License v. 2.0. If a copy of the MPL was not distributed\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n// This file is included into the body of the base classes supporting matrix specific coefficient-wise functions.\n// This include MatrixBase and SparseMatrixBase.\n\n\ntypedef CwiseUnaryOp<internal::scalar_abs_op<Scalar>, const Derived> CwiseAbsReturnType;\ntypedef CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const Derived> CwiseAbs2ReturnType;\ntypedef CwiseUnaryOp<internal::scalar_sqrt_op<Scalar>, const Derived> CwiseSqrtReturnType;\ntypedef CwiseUnaryOp<internal::scalar_sign_op<Scalar>, const Derived> CwiseSignReturnType;\ntypedef CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const Derived> CwiseInverseReturnType;\n\n/// \\returns an expression of the coefficient-wise absolute value of \\c *this\n///\n/// Example: \\include MatrixBase_cwiseAbs.cpp\n/// Output: \\verbinclude MatrixBase_cwiseAbs.out\n///\nEIGEN_DOC_UNARY_ADDONS(cwiseAbs,absolute value)\n///\n/// \\sa cwiseAbs2()\n///\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const CwiseAbsReturnType\ncwiseAbs() const { return CwiseAbsReturnType(derived()); }\n\n/// \\returns an expression of the coefficient-wise squared absolute value of \\c *this\n///\n/// Example: \\include MatrixBase_cwiseAbs2.cpp\n/// Output: \\verbinclude MatrixBase_cwiseAbs2.out\n///\nEIGEN_DOC_UNARY_ADDONS(cwiseAbs2,squared absolute value)\n///\n/// \\sa cwiseAbs()\n///\nEIGEN_DEVICE_FUNC\nEIGEN_STRONG_INLINE const CwiseAbs2ReturnType\ncwiseAbs2() const { return CwiseAbs2ReturnType(derived()); }\n\n/// \\returns an expression of the coefficient-wise square root of *this.\n///\n/// Example: \\include MatrixBase_cwiseSqrt.cpp\n/// Output: \\verbinclude MatrixBase_cwiseSqrt.out\n///\nEIGEN_DOC_UNARY_ADDONS(cwiseSqrt,square-root)\n///\n/// \\sa cwisePow(), cwiseSquare()\n///\nEIGEN_DEVICE_FUNC\ninline const CwiseSqrtReturnType\ncwiseSqrt() const { return CwiseSqrtReturnType(derived()); }\n\n/// \\returns an expression of the coefficient-wise signum of *this.\n///\n/// Example: \\include MatrixBase_cwiseSign.cpp\n/// Output: \\verbinclude MatrixBase_cwiseSign.out\n///\nEIGEN_DOC_UNARY_ADDONS(cwiseSign,sign function)\n///\nEIGEN_DEVICE_FUNC\ninline const CwiseSignReturnType\ncwiseSign() const { return CwiseSignReturnType(derived()); }\n\n\n/// \\returns an expression of the coefficient-wise inverse of *this.\n///\n/// Example: \\include MatrixBase_cwiseInverse.cpp\n/// Output: \\verbinclude MatrixBase_cwiseInverse.out\n///\nEIGEN_DOC_UNARY_ADDONS(cwiseInverse,inverse)\n///\n/// \\sa cwiseProduct()\n///\nEIGEN_DEVICE_FUNC\ninline const CwiseInverseReturnType\ncwiseInverse() const { return CwiseInverseReturnType(derived()); }\n\n\n"
  },
  {
    "path": "include/externals/gl_core_4_0.h",
    "content": "#include <stdlib.h>\n#include <string.h>\n#include <stddef.h>\n\n#ifndef POINTER_C_GENERATED_HEADER_OPENGL_H\n#define POINTER_C_GENERATED_HEADER_OPENGL_H\n\n#if defined(__glew_h__) || defined(__GLEW_H__)\n#error Attempt to include auto-generated header after including glew.h\n#endif\n#if defined(__gl_h_) || defined(__GL_H__)\n#error Attempt to include auto-generated header after including gl.h\n#endif\n#if defined(__glext_h_) || defined(__GLEXT_H_)\n#error Attempt to include auto-generated header after including glext.h\n#endif\n#if defined(__gltypes_h_)\n#error Attempt to include auto-generated header after gltypes.h\n#endif\n#if defined(__gl_ATI_h_)\n#error Attempt to include auto-generated header after including glATI.h\n#endif\n\n#define __glew_h__\n#define __GLEW_H__\n#define __gl_h_\n#define __GL_H__\n#define __glext_h_\n#define __GLEXT_H_\n#define __gltypes_h_\n#define __gl_ATI_h_\n\n#ifndef APIENTRY\n\t#if defined(__MINGW32__)\n\t\t#ifndef WIN32_LEAN_AND_MEAN\n\t\t\t#define WIN32_LEAN_AND_MEAN 1\n\t\t#endif\n\t\t#ifndef NOMINMAX\n\t\t\t#define NOMINMAX\n\t\t#endif\n\t\t#include <windows.h>\n\t#elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__)\n\t\t#ifndef WIN32_LEAN_AND_MEAN\n\t\t\t#define WIN32_LEAN_AND_MEAN 1\n\t\t#endif\n\t\t#ifndef NOMINMAX\n\t\t\t#define NOMINMAX\n\t\t#endif\n\t\t#include <windows.h>\n\t#else\n\t\t#define APIENTRY\n\t#endif\n#endif /*APIENTRY*/\n\n#ifndef CODEGEN_FUNCPTR\n\t#define CODEGEN_REMOVE_FUNCPTR\n\t#if defined(_WIN32)\n\t\t#define CODEGEN_FUNCPTR APIENTRY\n\t#else\n\t\t#define CODEGEN_FUNCPTR\n\t#endif\n#endif /*CODEGEN_FUNCPTR*/\n\n#ifndef GLAPI\n\t#define GLAPI extern\n#endif\n\n\n#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n\n\n#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/\n\n\n#include <stddef.h>\n#ifndef GLEXT_64_TYPES_DEFINED\n/* This code block is duplicated in glxext.h, so must be protected */\n#define GLEXT_64_TYPES_DEFINED\n/* Define int32_t, int64_t, and uint64_t types for UST/MSC */\n/* (as used in the GL_EXT_timer_query extension). */\n#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n#include <inttypes.h>\n#elif defined(__sun__) || defined(__digital__)\n#include <inttypes.h>\n#if defined(__STDC__)\n#if defined(__arch64__) || defined(_LP64)\ntypedef long int int64_t;\ntypedef unsigned long int uint64_t;\n#else\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#endif /* __arch64__ */\n#endif /* __STDC__ */\n#elif defined( __VMS ) || defined(__sgi)\n#include <inttypes.h>\n#elif defined(__SCO__) || defined(__USLC__)\n#include <stdint.h>\n#elif defined(__UNIXOS2__) || defined(__SOL64__)\ntypedef long int int32_t;\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#elif defined(_WIN32) && defined(__GNUC__)\n#include <stdint.h>\n#elif defined(_WIN32)\ntypedef __int32 int32_t;\ntypedef __int64 int64_t;\ntypedef unsigned __int64 uint64_t;\n#else\n/* Fallback if nothing above works */\n#include <inttypes.h>\n#endif\n#endif\n\ttypedef unsigned int GLenum;\n\ttypedef unsigned char GLboolean;\n\ttypedef unsigned int GLbitfield;\n\ttypedef void GLvoid;\n\ttypedef signed char GLbyte;\n\ttypedef short GLshort;\n\ttypedef int GLint;\n\ttypedef unsigned char GLubyte;\n\ttypedef unsigned short GLushort;\n\ttypedef unsigned int GLuint;\n\ttypedef int GLsizei;\n\ttypedef float GLfloat;\n\ttypedef float GLclampf;\n\ttypedef double GLdouble;\n\ttypedef double GLclampd;\n\ttypedef char GLchar;\n\ttypedef char GLcharARB;\n\t#ifdef __APPLE__\ntypedef void *GLhandleARB;\n#else\ntypedef unsigned int GLhandleARB;\n#endif\n\t\ttypedef unsigned short GLhalfARB;\n\t\ttypedef unsigned short GLhalf;\n\t\ttypedef GLint GLfixed;\n\t\ttypedef ptrdiff_t GLintptr;\n\t\ttypedef ptrdiff_t GLsizeiptr;\n\t\ttypedef int64_t GLint64;\n\t\ttypedef uint64_t GLuint64;\n\t\ttypedef ptrdiff_t GLintptrARB;\n\t\ttypedef ptrdiff_t GLsizeiptrARB;\n\t\ttypedef int64_t GLint64EXT;\n\t\ttypedef uint64_t GLuint64EXT;\n\t\ttypedef struct __GLsync *GLsync;\n\t\tstruct _cl_context;\n\t\tstruct _cl_event;\n\t\ttypedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);\n\t\ttypedef unsigned short GLhalfNV;\n\t\ttypedef GLintptr GLvdpauSurfaceNV;\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /*__cplusplus*/\n\n#define GL_ALPHA 0x1906\n#define GL_ALWAYS 0x0207\n#define GL_AND 0x1501\n#define GL_AND_INVERTED 0x1504\n#define GL_AND_REVERSE 0x1502\n#define GL_BACK 0x0405\n#define GL_BACK_LEFT 0x0402\n#define GL_BACK_RIGHT 0x0403\n#define GL_BLEND 0x0BE2\n#define GL_BLEND_DST 0x0BE0\n#define GL_BLEND_SRC 0x0BE1\n#define GL_BLUE 0x1905\n#define GL_BYTE 0x1400\n#define GL_CCW 0x0901\n#define GL_CLEAR 0x1500\n#define GL_COLOR 0x1800\n#define GL_COLOR_BUFFER_BIT 0x00004000\n#define GL_COLOR_CLEAR_VALUE 0x0C22\n#define GL_COLOR_LOGIC_OP 0x0BF2\n#define GL_COLOR_WRITEMASK 0x0C23\n#define GL_COPY 0x1503\n#define GL_COPY_INVERTED 0x150C\n#define GL_CULL_FACE 0x0B44\n#define GL_CULL_FACE_MODE 0x0B45\n#define GL_CW 0x0900\n#define GL_DECR 0x1E03\n#define GL_DEPTH 0x1801\n#define GL_DEPTH_BUFFER_BIT 0x00000100\n#define GL_DEPTH_CLEAR_VALUE 0x0B73\n#define GL_DEPTH_COMPONENT 0x1902\n#define GL_DEPTH_FUNC 0x0B74\n#define GL_DEPTH_RANGE 0x0B70\n#define GL_DEPTH_TEST 0x0B71\n#define GL_DEPTH_WRITEMASK 0x0B72\n#define GL_DITHER 0x0BD0\n#define GL_DONT_CARE 0x1100\n#define GL_DOUBLE 0x140A\n#define GL_DOUBLEBUFFER 0x0C32\n#define GL_DRAW_BUFFER 0x0C01\n#define GL_DST_ALPHA 0x0304\n#define GL_DST_COLOR 0x0306\n#define GL_EQUAL 0x0202\n#define GL_EQUIV 0x1509\n#define GL_EXTENSIONS 0x1F03\n#define GL_FALSE 0\n#define GL_FASTEST 0x1101\n#define GL_FILL 0x1B02\n#define GL_FLOAT 0x1406\n#define GL_FRONT 0x0404\n#define GL_FRONT_AND_BACK 0x0408\n#define GL_FRONT_FACE 0x0B46\n#define GL_FRONT_LEFT 0x0400\n#define GL_FRONT_RIGHT 0x0401\n#define GL_GEQUAL 0x0206\n#define GL_GREATER 0x0204\n#define GL_GREEN 0x1904\n#define GL_INCR 0x1E02\n#define GL_INT 0x1404\n#define GL_INVALID_ENUM 0x0500\n#define GL_INVALID_OPERATION 0x0502\n#define GL_INVALID_VALUE 0x0501\n#define GL_INVERT 0x150A\n#define GL_KEEP 0x1E00\n#define GL_LEFT 0x0406\n#define GL_LEQUAL 0x0203\n#define GL_LESS 0x0201\n#define GL_LINE 0x1B01\n#define GL_LINEAR 0x2601\n#define GL_LINEAR_MIPMAP_LINEAR 0x2703\n#define GL_LINEAR_MIPMAP_NEAREST 0x2701\n#define GL_LINES 0x0001\n#define GL_LINE_LOOP 0x0002\n#define GL_LINE_SMOOTH 0x0B20\n#define GL_LINE_SMOOTH_HINT 0x0C52\n#define GL_LINE_STRIP 0x0003\n#define GL_LINE_WIDTH 0x0B21\n#define GL_LINE_WIDTH_GRANULARITY 0x0B23\n#define GL_LINE_WIDTH_RANGE 0x0B22\n#define GL_LOGIC_OP_MODE 0x0BF0\n#define GL_MAX_TEXTURE_SIZE 0x0D33\n#define GL_MAX_VIEWPORT_DIMS 0x0D3A\n#define GL_NAND 0x150E\n#define GL_NEAREST 0x2600\n#define GL_NEAREST_MIPMAP_LINEAR 0x2702\n#define GL_NEAREST_MIPMAP_NEAREST 0x2700\n#define GL_NEVER 0x0200\n#define GL_NICEST 0x1102\n#define GL_NONE 0\n#define GL_NOOP 0x1505\n#define GL_NOR 0x1508\n#define GL_NOTEQUAL 0x0205\n#define GL_NO_ERROR 0\n#define GL_ONE 1\n#define GL_ONE_MINUS_DST_ALPHA 0x0305\n#define GL_ONE_MINUS_DST_COLOR 0x0307\n#define GL_ONE_MINUS_SRC_ALPHA 0x0303\n#define GL_ONE_MINUS_SRC_COLOR 0x0301\n#define GL_OR 0x1507\n#define GL_OR_INVERTED 0x150D\n#define GL_OR_REVERSE 0x150B\n#define GL_OUT_OF_MEMORY 0x0505\n#define GL_PACK_ALIGNMENT 0x0D05\n#define GL_PACK_LSB_FIRST 0x0D01\n#define GL_PACK_ROW_LENGTH 0x0D02\n#define GL_PACK_SKIP_PIXELS 0x0D04\n#define GL_PACK_SKIP_ROWS 0x0D03\n#define GL_PACK_SWAP_BYTES 0x0D00\n#define GL_POINT 0x1B00\n#define GL_POINTS 0x0000\n#define GL_POINT_SIZE 0x0B11\n#define GL_POINT_SIZE_GRANULARITY 0x0B13\n#define GL_POINT_SIZE_RANGE 0x0B12\n#define GL_POLYGON_MODE 0x0B40\n#define GL_POLYGON_OFFSET_FACTOR 0x8038\n#define GL_POLYGON_OFFSET_FILL 0x8037\n#define GL_POLYGON_OFFSET_LINE 0x2A02\n#define GL_POLYGON_OFFSET_POINT 0x2A01\n#define GL_POLYGON_OFFSET_UNITS 0x2A00\n#define GL_POLYGON_SMOOTH 0x0B41\n#define GL_POLYGON_SMOOTH_HINT 0x0C53\n#define GL_PROXY_TEXTURE_1D 0x8063\n#define GL_PROXY_TEXTURE_2D 0x8064\n#define GL_QUADS 0x0007\n#define GL_R3_G3_B2 0x2A10\n#define GL_READ_BUFFER 0x0C02\n#define GL_RED 0x1903\n#define GL_RENDERER 0x1F01\n#define GL_REPEAT 0x2901\n#define GL_REPLACE 0x1E01\n#define GL_RGB 0x1907\n#define GL_RGB10 0x8052\n#define GL_RGB10_A2 0x8059\n#define GL_RGB12 0x8053\n#define GL_RGB16 0x8054\n#define GL_RGB4 0x804F\n#define GL_RGB5 0x8050\n#define GL_RGB5_A1 0x8057\n#define GL_RGB8 0x8051\n#define GL_RGBA 0x1908\n#define GL_RGBA12 0x805A\n#define GL_RGBA16 0x805B\n#define GL_RGBA2 0x8055\n#define GL_RGBA4 0x8056\n#define GL_RGBA8 0x8058\n#define GL_RIGHT 0x0407\n#define GL_SCISSOR_BOX 0x0C10\n#define GL_SCISSOR_TEST 0x0C11\n#define GL_SET 0x150F\n#define GL_SHORT 0x1402\n#define GL_SRC_ALPHA 0x0302\n#define GL_SRC_ALPHA_SATURATE 0x0308\n#define GL_SRC_COLOR 0x0300\n#define GL_STENCIL 0x1802\n#define GL_STENCIL_BUFFER_BIT 0x00000400\n#define GL_STENCIL_CLEAR_VALUE 0x0B91\n#define GL_STENCIL_FAIL 0x0B94\n#define GL_STENCIL_FUNC 0x0B92\n#define GL_STENCIL_INDEX 0x1901\n#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95\n#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96\n#define GL_STENCIL_REF 0x0B97\n#define GL_STENCIL_TEST 0x0B90\n#define GL_STENCIL_VALUE_MASK 0x0B93\n#define GL_STENCIL_WRITEMASK 0x0B98\n#define GL_STEREO 0x0C33\n#define GL_SUBPIXEL_BITS 0x0D50\n#define GL_TEXTURE 0x1702\n#define GL_TEXTURE_1D 0x0DE0\n#define GL_TEXTURE_2D 0x0DE1\n#define GL_TEXTURE_ALPHA_SIZE 0x805F\n#define GL_TEXTURE_BINDING_1D 0x8068\n#define GL_TEXTURE_BINDING_2D 0x8069\n#define GL_TEXTURE_BLUE_SIZE 0x805E\n#define GL_TEXTURE_BORDER_COLOR 0x1004\n#define GL_TEXTURE_GREEN_SIZE 0x805D\n#define GL_TEXTURE_HEIGHT 0x1001\n#define GL_TEXTURE_INTERNAL_FORMAT 0x1003\n#define GL_TEXTURE_MAG_FILTER 0x2800\n#define GL_TEXTURE_MIN_FILTER 0x2801\n#define GL_TEXTURE_RED_SIZE 0x805C\n#define GL_TEXTURE_WIDTH 0x1000\n#define GL_TEXTURE_WRAP_S 0x2802\n#define GL_TEXTURE_WRAP_T 0x2803\n#define GL_TRIANGLES 0x0004\n#define GL_TRIANGLE_FAN 0x0006\n#define GL_TRIANGLE_STRIP 0x0005\n#define GL_TRUE 1\n#define GL_UNPACK_ALIGNMENT 0x0CF5\n#define GL_UNPACK_LSB_FIRST 0x0CF1\n#define GL_UNPACK_ROW_LENGTH 0x0CF2\n#define GL_UNPACK_SKIP_PIXELS 0x0CF4\n#define GL_UNPACK_SKIP_ROWS 0x0CF3\n#define GL_UNPACK_SWAP_BYTES 0x0CF0\n#define GL_UNSIGNED_BYTE 0x1401\n#define GL_UNSIGNED_INT 0x1405\n#define GL_UNSIGNED_SHORT 0x1403\n#define GL_VENDOR 0x1F00\n#define GL_VERSION 0x1F02\n#define GL_VIEWPORT 0x0BA2\n#define GL_XOR 0x1506\n#define GL_ZERO 0\n\n#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E\n#define GL_BGR 0x80E0\n#define GL_BGRA 0x80E1\n#define GL_CLAMP_TO_EDGE 0x812F\n#define GL_MAX_3D_TEXTURE_SIZE 0x8073\n#define GL_MAX_ELEMENTS_INDICES 0x80E9\n#define GL_MAX_ELEMENTS_VERTICES 0x80E8\n#define GL_PACK_IMAGE_HEIGHT 0x806C\n#define GL_PACK_SKIP_IMAGES 0x806B\n#define GL_PROXY_TEXTURE_3D 0x8070\n#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23\n#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22\n#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13\n#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12\n#define GL_TEXTURE_3D 0x806F\n#define GL_TEXTURE_BASE_LEVEL 0x813C\n#define GL_TEXTURE_BINDING_3D 0x806A\n#define GL_TEXTURE_DEPTH 0x8071\n#define GL_TEXTURE_MAX_LEVEL 0x813D\n#define GL_TEXTURE_MAX_LOD 0x813B\n#define GL_TEXTURE_MIN_LOD 0x813A\n#define GL_TEXTURE_WRAP_R 0x8072\n#define GL_UNPACK_IMAGE_HEIGHT 0x806E\n#define GL_UNPACK_SKIP_IMAGES 0x806D\n#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362\n#define GL_UNSIGNED_BYTE_3_3_2 0x8032\n#define GL_UNSIGNED_INT_10_10_10_2 0x8036\n#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368\n#define GL_UNSIGNED_INT_8_8_8_8 0x8035\n#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367\n#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366\n#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033\n#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365\n#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034\n#define GL_UNSIGNED_SHORT_5_6_5 0x8363\n#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364\n\n#define GL_ACTIVE_TEXTURE 0x84E0\n#define GL_CLAMP_TO_BORDER 0x812D\n#define GL_COMPRESSED_RGB 0x84ED\n#define GL_COMPRESSED_RGBA 0x84EE\n#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C\n#define GL_MULTISAMPLE 0x809D\n#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2\n#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B\n#define GL_SAMPLES 0x80A9\n#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE 0x809F\n#define GL_SAMPLE_BUFFERS 0x80A8\n#define GL_SAMPLE_COVERAGE 0x80A0\n#define GL_SAMPLE_COVERAGE_INVERT 0x80AB\n#define GL_SAMPLE_COVERAGE_VALUE 0x80AA\n#define GL_TEXTURE0 0x84C0\n#define GL_TEXTURE1 0x84C1\n#define GL_TEXTURE10 0x84CA\n#define GL_TEXTURE11 0x84CB\n#define GL_TEXTURE12 0x84CC\n#define GL_TEXTURE13 0x84CD\n#define GL_TEXTURE14 0x84CE\n#define GL_TEXTURE15 0x84CF\n#define GL_TEXTURE16 0x84D0\n#define GL_TEXTURE17 0x84D1\n#define GL_TEXTURE18 0x84D2\n#define GL_TEXTURE19 0x84D3\n#define GL_TEXTURE2 0x84C2\n#define GL_TEXTURE20 0x84D4\n#define GL_TEXTURE21 0x84D5\n#define GL_TEXTURE22 0x84D6\n#define GL_TEXTURE23 0x84D7\n#define GL_TEXTURE24 0x84D8\n#define GL_TEXTURE25 0x84D9\n#define GL_TEXTURE26 0x84DA\n#define GL_TEXTURE27 0x84DB\n#define GL_TEXTURE28 0x84DC\n#define GL_TEXTURE29 0x84DD\n#define GL_TEXTURE3 0x84C3\n#define GL_TEXTURE30 0x84DE\n#define GL_TEXTURE31 0x84DF\n#define GL_TEXTURE4 0x84C4\n#define GL_TEXTURE5 0x84C5\n#define GL_TEXTURE6 0x84C6\n#define GL_TEXTURE7 0x84C7\n#define GL_TEXTURE8 0x84C8\n#define GL_TEXTURE9 0x84C9\n#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514\n#define GL_TEXTURE_COMPRESSED 0x86A1\n#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0\n#define GL_TEXTURE_COMPRESSION_HINT 0x84EF\n#define GL_TEXTURE_CUBE_MAP 0x8513\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519\n\n#define GL_BLEND_COLOR 0x8005\n#define GL_BLEND_DST_ALPHA 0x80CA\n#define GL_BLEND_DST_RGB 0x80C8\n#define GL_BLEND_EQUATION 0x8009\n#define GL_BLEND_SRC_ALPHA 0x80CB\n#define GL_BLEND_SRC_RGB 0x80C9\n#define GL_CONSTANT_ALPHA 0x8003\n#define GL_CONSTANT_COLOR 0x8001\n#define GL_DECR_WRAP 0x8508\n#define GL_DEPTH_COMPONENT16 0x81A5\n#define GL_DEPTH_COMPONENT24 0x81A6\n#define GL_DEPTH_COMPONENT32 0x81A7\n#define GL_FUNC_ADD 0x8006\n#define GL_FUNC_REVERSE_SUBTRACT 0x800B\n#define GL_FUNC_SUBTRACT 0x800A\n#define GL_INCR_WRAP 0x8507\n#define GL_MAX 0x8008\n#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD\n#define GL_MIN 0x8007\n#define GL_MIRRORED_REPEAT 0x8370\n#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004\n#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002\n#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128\n#define GL_TEXTURE_COMPARE_FUNC 0x884D\n#define GL_TEXTURE_COMPARE_MODE 0x884C\n#define GL_TEXTURE_DEPTH_SIZE 0x884A\n#define GL_TEXTURE_LOD_BIAS 0x8501\n\n#define GL_ARRAY_BUFFER 0x8892\n#define GL_ARRAY_BUFFER_BINDING 0x8894\n#define GL_BUFFER_ACCESS 0x88BB\n#define GL_BUFFER_MAPPED 0x88BC\n#define GL_BUFFER_MAP_POINTER 0x88BD\n#define GL_BUFFER_SIZE 0x8764\n#define GL_BUFFER_USAGE 0x8765\n#define GL_CURRENT_QUERY 0x8865\n#define GL_DYNAMIC_COPY 0x88EA\n#define GL_DYNAMIC_DRAW 0x88E8\n#define GL_DYNAMIC_READ 0x88E9\n#define GL_ELEMENT_ARRAY_BUFFER 0x8893\n#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895\n#define GL_QUERY_COUNTER_BITS 0x8864\n#define GL_QUERY_RESULT 0x8866\n#define GL_QUERY_RESULT_AVAILABLE 0x8867\n#define GL_READ_ONLY 0x88B8\n#define GL_READ_WRITE 0x88BA\n#define GL_SAMPLES_PASSED 0x8914\n#define GL_SRC1_ALPHA 0x8589\n#define GL_STATIC_COPY 0x88E6\n#define GL_STATIC_DRAW 0x88E4\n#define GL_STATIC_READ 0x88E5\n#define GL_STREAM_COPY 0x88E2\n#define GL_STREAM_DRAW 0x88E0\n#define GL_STREAM_READ 0x88E1\n#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F\n#define GL_WRITE_ONLY 0x88B9\n\n#define GL_ACTIVE_ATTRIBUTES 0x8B89\n#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A\n#define GL_ACTIVE_UNIFORMS 0x8B86\n#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87\n#define GL_ATTACHED_SHADERS 0x8B85\n#define GL_BLEND_EQUATION_ALPHA 0x883D\n#define GL_BLEND_EQUATION_RGB 0x8009\n#define GL_BOOL 0x8B56\n#define GL_BOOL_VEC2 0x8B57\n#define GL_BOOL_VEC3 0x8B58\n#define GL_BOOL_VEC4 0x8B59\n#define GL_COMPILE_STATUS 0x8B81\n#define GL_CURRENT_PROGRAM 0x8B8D\n#define GL_CURRENT_VERTEX_ATTRIB 0x8626\n#define GL_DELETE_STATUS 0x8B80\n#define GL_DRAW_BUFFER0 0x8825\n#define GL_DRAW_BUFFER1 0x8826\n#define GL_DRAW_BUFFER10 0x882F\n#define GL_DRAW_BUFFER11 0x8830\n#define GL_DRAW_BUFFER12 0x8831\n#define GL_DRAW_BUFFER13 0x8832\n#define GL_DRAW_BUFFER14 0x8833\n#define GL_DRAW_BUFFER15 0x8834\n#define GL_DRAW_BUFFER2 0x8827\n#define GL_DRAW_BUFFER3 0x8828\n#define GL_DRAW_BUFFER4 0x8829\n#define GL_DRAW_BUFFER5 0x882A\n#define GL_DRAW_BUFFER6 0x882B\n#define GL_DRAW_BUFFER7 0x882C\n#define GL_DRAW_BUFFER8 0x882D\n#define GL_DRAW_BUFFER9 0x882E\n#define GL_FLOAT_MAT2 0x8B5A\n#define GL_FLOAT_MAT3 0x8B5B\n#define GL_FLOAT_MAT4 0x8B5C\n#define GL_FLOAT_VEC2 0x8B50\n#define GL_FLOAT_VEC3 0x8B51\n#define GL_FLOAT_VEC4 0x8B52\n#define GL_FRAGMENT_SHADER 0x8B30\n#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B\n#define GL_INFO_LOG_LENGTH 0x8B84\n#define GL_INT_VEC2 0x8B53\n#define GL_INT_VEC3 0x8B54\n#define GL_INT_VEC4 0x8B55\n#define GL_LINK_STATUS 0x8B82\n#define GL_LOWER_LEFT 0x8CA1\n#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D\n#define GL_MAX_DRAW_BUFFERS 0x8824\n#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49\n#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872\n#define GL_MAX_VARYING_FLOATS 0x8B4B\n#define GL_MAX_VERTEX_ATTRIBS 0x8869\n#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C\n#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A\n#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0\n#define GL_SAMPLER_1D 0x8B5D\n#define GL_SAMPLER_1D_SHADOW 0x8B61\n#define GL_SAMPLER_2D 0x8B5E\n#define GL_SAMPLER_2D_SHADOW 0x8B62\n#define GL_SAMPLER_3D 0x8B5F\n#define GL_SAMPLER_CUBE 0x8B60\n#define GL_SHADER_SOURCE_LENGTH 0x8B88\n#define GL_SHADER_TYPE 0x8B4F\n#define GL_SHADING_LANGUAGE_VERSION 0x8B8C\n#define GL_STENCIL_BACK_FAIL 0x8801\n#define GL_STENCIL_BACK_FUNC 0x8800\n#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802\n#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803\n#define GL_STENCIL_BACK_REF 0x8CA3\n#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4\n#define GL_STENCIL_BACK_WRITEMASK 0x8CA5\n#define GL_UPPER_LEFT 0x8CA2\n#define GL_VALIDATE_STATUS 0x8B83\n#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622\n#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A\n#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645\n#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623\n#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624\n#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625\n#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642\n#define GL_VERTEX_SHADER 0x8B31\n\n#define GL_COMPRESSED_SRGB 0x8C48\n#define GL_COMPRESSED_SRGB_ALPHA 0x8C49\n#define GL_FLOAT_MAT2x3 0x8B65\n#define GL_FLOAT_MAT2x4 0x8B66\n#define GL_FLOAT_MAT3x2 0x8B67\n#define GL_FLOAT_MAT3x4 0x8B68\n#define GL_FLOAT_MAT4x2 0x8B69\n#define GL_FLOAT_MAT4x3 0x8B6A\n#define GL_PIXEL_PACK_BUFFER 0x88EB\n#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED\n#define GL_PIXEL_UNPACK_BUFFER 0x88EC\n#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF\n#define GL_SRGB 0x8C40\n#define GL_SRGB8 0x8C41\n#define GL_SRGB8_ALPHA8 0x8C43\n#define GL_SRGB_ALPHA 0x8C42\n\n#define GL_BGRA_INTEGER 0x8D9B\n#define GL_BGR_INTEGER 0x8D9A\n#define GL_BLUE_INTEGER 0x8D96\n#define GL_BUFFER_ACCESS_FLAGS 0x911F\n#define GL_BUFFER_MAP_LENGTH 0x9120\n#define GL_BUFFER_MAP_OFFSET 0x9121\n#define GL_CLAMP_READ_COLOR 0x891C\n#define GL_CLIP_DISTANCE0 0x3000\n#define GL_CLIP_DISTANCE1 0x3001\n#define GL_CLIP_DISTANCE2 0x3002\n#define GL_CLIP_DISTANCE3 0x3003\n#define GL_CLIP_DISTANCE4 0x3004\n#define GL_CLIP_DISTANCE5 0x3005\n#define GL_CLIP_DISTANCE6 0x3006\n#define GL_CLIP_DISTANCE7 0x3007\n#define GL_COLOR_ATTACHMENT0 0x8CE0\n#define GL_COLOR_ATTACHMENT1 0x8CE1\n#define GL_COLOR_ATTACHMENT10 0x8CEA\n#define GL_COLOR_ATTACHMENT11 0x8CEB\n#define GL_COLOR_ATTACHMENT12 0x8CEC\n#define GL_COLOR_ATTACHMENT13 0x8CED\n#define GL_COLOR_ATTACHMENT14 0x8CEE\n#define GL_COLOR_ATTACHMENT15 0x8CEF\n#define GL_COLOR_ATTACHMENT2 0x8CE2\n#define GL_COLOR_ATTACHMENT3 0x8CE3\n#define GL_COLOR_ATTACHMENT4 0x8CE4\n#define GL_COLOR_ATTACHMENT5 0x8CE5\n#define GL_COLOR_ATTACHMENT6 0x8CE6\n#define GL_COLOR_ATTACHMENT7 0x8CE7\n#define GL_COLOR_ATTACHMENT8 0x8CE8\n#define GL_COLOR_ATTACHMENT9 0x8CE9\n#define GL_COMPARE_REF_TO_TEXTURE 0x884E\n#define GL_COMPRESSED_RED 0x8225\n#define GL_COMPRESSED_RED_RGTC1 0x8DBB\n#define GL_COMPRESSED_RG 0x8226\n#define GL_COMPRESSED_RG_RGTC2 0x8DBD\n#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC\n#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE\n#define GL_CONTEXT_FLAGS 0x821E\n#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001\n#define GL_DEPTH24_STENCIL8 0x88F0\n#define GL_DEPTH32F_STENCIL8 0x8CAD\n#define GL_DEPTH_ATTACHMENT 0x8D00\n#define GL_DEPTH_COMPONENT32F 0x8CAC\n#define GL_DEPTH_STENCIL 0x84F9\n#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A\n#define GL_DRAW_FRAMEBUFFER 0x8CA9\n#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6\n#define GL_FIXED_ONLY 0x891D\n#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD\n#define GL_FRAMEBUFFER 0x8D40\n#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215\n#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214\n#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210\n#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211\n#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216\n#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0\n#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212\n#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2\n#define GL_FRAMEBUFFER_BINDING 0x8CA6\n#define GL_FRAMEBUFFER_COMPLETE 0x8CD5\n#define GL_FRAMEBUFFER_DEFAULT 0x8218\n#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6\n#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB\n#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56\n#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC\n#define GL_FRAMEBUFFER_SRGB 0x8DB9\n#define GL_FRAMEBUFFER_UNDEFINED 0x8219\n#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD\n#define GL_GREEN_INTEGER 0x8D95\n#define GL_HALF_FLOAT 0x140B\n#define GL_INTERLEAVED_ATTRIBS 0x8C8C\n#define GL_INT_SAMPLER_1D 0x8DC9\n#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE\n#define GL_INT_SAMPLER_2D 0x8DCA\n#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF\n#define GL_INT_SAMPLER_3D 0x8DCB\n#define GL_INT_SAMPLER_CUBE 0x8DCC\n#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506\n#define GL_MAJOR_VERSION 0x821B\n#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010\n#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008\n#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004\n#define GL_MAP_READ_BIT 0x0001\n#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020\n#define GL_MAP_WRITE_BIT 0x0002\n#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF\n#define GL_MAX_CLIP_DISTANCES 0x0D32\n#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF\n#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905\n#define GL_MAX_RENDERBUFFER_SIZE 0x84E8\n#define GL_MAX_SAMPLES 0x8D57\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80\n#define GL_MAX_VARYING_COMPONENTS 0x8B4B\n#define GL_MINOR_VERSION 0x821C\n#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904\n#define GL_NUM_EXTENSIONS 0x821D\n#define GL_PRIMITIVES_GENERATED 0x8C87\n#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19\n#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B\n#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16\n#define GL_QUERY_BY_REGION_WAIT 0x8E15\n#define GL_QUERY_NO_WAIT 0x8E14\n#define GL_QUERY_WAIT 0x8E13\n#define GL_R11F_G11F_B10F 0x8C3A\n#define GL_R16 0x822A\n#define GL_R16F 0x822D\n#define GL_R16I 0x8233\n#define GL_R16UI 0x8234\n#define GL_R32F 0x822E\n#define GL_R32I 0x8235\n#define GL_R32UI 0x8236\n#define GL_R8 0x8229\n#define GL_R8I 0x8231\n#define GL_R8UI 0x8232\n#define GL_RASTERIZER_DISCARD 0x8C89\n#define GL_READ_FRAMEBUFFER 0x8CA8\n#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA\n#define GL_RED_INTEGER 0x8D94\n#define GL_RENDERBUFFER 0x8D41\n#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53\n#define GL_RENDERBUFFER_BINDING 0x8CA7\n#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52\n#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54\n#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51\n#define GL_RENDERBUFFER_HEIGHT 0x8D43\n#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44\n#define GL_RENDERBUFFER_RED_SIZE 0x8D50\n#define GL_RENDERBUFFER_SAMPLES 0x8CAB\n#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55\n#define GL_RENDERBUFFER_WIDTH 0x8D42\n#define GL_RG 0x8227\n#define GL_RG16 0x822C\n#define GL_RG16F 0x822F\n#define GL_RG16I 0x8239\n#define GL_RG16UI 0x823A\n#define GL_RG32F 0x8230\n#define GL_RG32I 0x823B\n#define GL_RG32UI 0x823C\n#define GL_RG8 0x822B\n#define GL_RG8I 0x8237\n#define GL_RG8UI 0x8238\n#define GL_RGB16F 0x881B\n#define GL_RGB16I 0x8D89\n#define GL_RGB16UI 0x8D77\n#define GL_RGB32F 0x8815\n#define GL_RGB32I 0x8D83\n#define GL_RGB32UI 0x8D71\n#define GL_RGB8I 0x8D8F\n#define GL_RGB8UI 0x8D7D\n#define GL_RGB9_E5 0x8C3D\n#define GL_RGBA16F 0x881A\n#define GL_RGBA16I 0x8D88\n#define GL_RGBA16UI 0x8D76\n#define GL_RGBA32F 0x8814\n#define GL_RGBA32I 0x8D82\n#define GL_RGBA32UI 0x8D70\n#define GL_RGBA8I 0x8D8E\n#define GL_RGBA8UI 0x8D7C\n#define GL_RGBA_INTEGER 0x8D99\n#define GL_RGB_INTEGER 0x8D98\n#define GL_RG_INTEGER 0x8228\n#define GL_SAMPLER_1D_ARRAY 0x8DC0\n#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3\n#define GL_SAMPLER_2D_ARRAY 0x8DC1\n#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4\n#define GL_SAMPLER_CUBE_SHADOW 0x8DC5\n#define GL_SEPARATE_ATTRIBS 0x8C8D\n#define GL_STENCIL_ATTACHMENT 0x8D20\n#define GL_STENCIL_INDEX1 0x8D46\n#define GL_STENCIL_INDEX16 0x8D49\n#define GL_STENCIL_INDEX4 0x8D47\n#define GL_STENCIL_INDEX8 0x8D48\n#define GL_TEXTURE_1D_ARRAY 0x8C18\n#define GL_TEXTURE_2D_ARRAY 0x8C1A\n#define GL_TEXTURE_ALPHA_TYPE 0x8C13\n#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C\n#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D\n#define GL_TEXTURE_BLUE_TYPE 0x8C12\n#define GL_TEXTURE_DEPTH_TYPE 0x8C16\n#define GL_TEXTURE_GREEN_TYPE 0x8C11\n#define GL_TEXTURE_RED_TYPE 0x8C10\n#define GL_TEXTURE_SHARED_SIZE 0x8C3F\n#define GL_TEXTURE_STENCIL_SIZE 0x88F1\n#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88\n#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83\n#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76\n#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B\n#define GL_UNSIGNED_INT_24_8 0x84FA\n#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E\n#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1\n#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6\n#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2\n#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7\n#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3\n#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4\n#define GL_UNSIGNED_INT_VEC2 0x8DC6\n#define GL_UNSIGNED_INT_VEC3 0x8DC7\n#define GL_UNSIGNED_INT_VEC4 0x8DC8\n#define GL_UNSIGNED_NORMALIZED 0x8C17\n#define GL_VERTEX_ARRAY_BINDING 0x85B5\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD\n\n#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36\n#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35\n#define GL_COPY_READ_BUFFER 0x8F36\n#define GL_COPY_WRITE_BUFFER 0x8F37\n#define GL_INT_SAMPLER_2D_RECT 0x8DCD\n#define GL_INT_SAMPLER_BUFFER 0x8DD0\n#define GL_INVALID_INDEX 0xFFFFFFFF\n#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33\n#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E\n#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31\n#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8\n#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B\n#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30\n#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F\n#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B\n#define GL_PRIMITIVE_RESTART 0x8F9D\n#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E\n#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7\n#define GL_R16_SNORM 0x8F98\n#define GL_R8_SNORM 0x8F94\n#define GL_RG16_SNORM 0x8F99\n#define GL_RG8_SNORM 0x8F95\n#define GL_RGB16_SNORM 0x8F9A\n#define GL_RGB8_SNORM 0x8F96\n#define GL_RGBA16_SNORM 0x8F9B\n#define GL_RGBA8_SNORM 0x8F97\n#define GL_SAMPLER_2D_RECT 0x8B63\n#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64\n#define GL_SAMPLER_BUFFER 0x8DC2\n#define GL_SIGNED_NORMALIZED 0x8F9C\n#define GL_TEXTURE_BINDING_BUFFER 0x8C2C\n#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6\n#define GL_TEXTURE_BUFFER 0x8C2A\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D\n#define GL_TEXTURE_RECTANGLE 0x84F5\n#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43\n#define GL_UNIFORM_BLOCK_BINDING 0x8A3F\n#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40\n#define GL_UNIFORM_BLOCK_INDEX 0x8A3A\n#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44\n#define GL_UNIFORM_BUFFER 0x8A11\n#define GL_UNIFORM_BUFFER_BINDING 0x8A28\n#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34\n#define GL_UNIFORM_BUFFER_SIZE 0x8A2A\n#define GL_UNIFORM_BUFFER_START 0x8A29\n#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E\n#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D\n#define GL_UNIFORM_NAME_LENGTH 0x8A39\n#define GL_UNIFORM_OFFSET 0x8A3B\n#define GL_UNIFORM_SIZE 0x8A38\n#define GL_UNIFORM_TYPE 0x8A37\n#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8\n\n#define GL_ALREADY_SIGNALED 0x911A\n#define GL_CONDITION_SATISFIED 0x911C\n#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002\n#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001\n#define GL_CONTEXT_PROFILE_MASK 0x9126\n#define GL_DEPTH_CLAMP 0x864F\n#define GL_FIRST_VERTEX_CONVENTION 0x8E4D\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8\n#define GL_GEOMETRY_INPUT_TYPE 0x8917\n#define GL_GEOMETRY_OUTPUT_TYPE 0x8918\n#define GL_GEOMETRY_SHADER 0x8DD9\n#define GL_GEOMETRY_VERTICES_OUT 0x8916\n#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109\n#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C\n#define GL_LAST_VERTEX_CONVENTION 0x8E4E\n#define GL_LINES_ADJACENCY 0x000A\n#define GL_LINE_STRIP_ADJACENCY 0x000B\n#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E\n#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F\n#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125\n#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123\n#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF\n#define GL_MAX_INTEGER_SAMPLES 0x9110\n#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59\n#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111\n#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122\n#define GL_OBJECT_TYPE 0x9112\n#define GL_PROGRAM_POINT_SIZE 0x8642\n#define GL_PROVOKING_VERTEX 0x8E4F\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103\n#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C\n#define GL_SAMPLER_2D_MULTISAMPLE 0x9108\n#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B\n#define GL_SAMPLE_MASK 0x8E51\n#define GL_SAMPLE_MASK_VALUE 0x8E52\n#define GL_SAMPLE_POSITION 0x8E50\n#define GL_SIGNALED 0x9119\n#define GL_SYNC_CONDITION 0x9113\n#define GL_SYNC_FENCE 0x9116\n#define GL_SYNC_FLAGS 0x9115\n#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001\n#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117\n#define GL_SYNC_STATUS 0x9114\n#define GL_TEXTURE_2D_MULTISAMPLE 0x9100\n#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105\n#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F\n#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107\n#define GL_TEXTURE_SAMPLES 0x9106\n#define GL_TIMEOUT_EXPIRED 0x911B\n#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF\n#define GL_TRIANGLES_ADJACENCY 0x000C\n#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D\n#define GL_UNSIGNALED 0x9118\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D\n#define GL_WAIT_FAILED 0x911D\n\n#define GL_ANY_SAMPLES_PASSED 0x8C2F\n#define GL_INT_2_10_10_10_REV 0x8D9F\n#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC\n#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB\n#define GL_ONE_MINUS_SRC1_COLOR 0x88FA\n#define GL_RGB10_A2UI 0x906F\n#define GL_SAMPLER_BINDING 0x8919\n#define GL_SRC1_COLOR 0x88F9\n#define GL_TEXTURE_SWIZZLE_A 0x8E45\n#define GL_TEXTURE_SWIZZLE_B 0x8E44\n#define GL_TEXTURE_SWIZZLE_G 0x8E43\n#define GL_TEXTURE_SWIZZLE_R 0x8E42\n#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46\n#define GL_TIMESTAMP 0x8E28\n#define GL_TIME_ELAPSED 0x88BF\n#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE\n\n#define GL_ACTIVE_SUBROUTINES 0x8DE5\n#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48\n#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6\n#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47\n#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49\n#define GL_COMPATIBLE_SUBROUTINES 0x8E4B\n#define GL_DOUBLE_MAT2 0x8F46\n#define GL_DOUBLE_MAT2x3 0x8F49\n#define GL_DOUBLE_MAT2x4 0x8F4A\n#define GL_DOUBLE_MAT3 0x8F47\n#define GL_DOUBLE_MAT3x2 0x8F4B\n#define GL_DOUBLE_MAT3x4 0x8F4C\n#define GL_DOUBLE_MAT4 0x8F48\n#define GL_DOUBLE_MAT4x2 0x8F4D\n#define GL_DOUBLE_MAT4x3 0x8F4E\n#define GL_DOUBLE_VEC2 0x8FFC\n#define GL_DOUBLE_VEC3 0x8FFD\n#define GL_DOUBLE_VEC4 0x8FFE\n#define GL_DRAW_INDIRECT_BUFFER 0x8F3F\n#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43\n#define GL_FRACTIONAL_EVEN 0x8E7C\n#define GL_FRACTIONAL_ODD 0x8E7B\n#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D\n#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F\n#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E\n#define GL_ISOLINES 0x8E7A\n#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E\n#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F\n#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C\n#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A\n#define GL_MAX_PATCH_VERTICES 0x8E7D\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F\n#define GL_MAX_SUBROUTINES 0x8DE7\n#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8\n#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C\n#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83\n#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81\n#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85\n#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89\n#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F\n#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D\n#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86\n#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82\n#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A\n#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80\n#define GL_MAX_TESS_GEN_LEVEL 0x8E7E\n#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84\n#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70\n#define GL_MAX_VERTEX_STREAMS 0x8E71\n#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B\n#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E\n#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37\n#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A\n#define GL_PATCHES 0x000E\n#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73\n#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74\n#define GL_PATCH_VERTICES 0x8E72\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B\n#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C\n#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D\n#define GL_SAMPLE_SHADING 0x8C36\n#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75\n#define GL_TESS_CONTROL_SHADER 0x8E88\n#define GL_TESS_EVALUATION_SHADER 0x8E87\n#define GL_TESS_GEN_MODE 0x8E76\n#define GL_TESS_GEN_POINT_MODE 0x8E79\n#define GL_TESS_GEN_SPACING 0x8E77\n#define GL_TESS_GEN_VERTEX_ORDER 0x8E78\n#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A\n#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009\n#define GL_TRANSFORM_FEEDBACK 0x8E22\n#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25\n#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24\n#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1\n#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum);\n#define glBlendFunc _ptrc_glBlendFunc\nextern void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield);\n#define glClear _ptrc_glClear\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat);\n#define glClearColor _ptrc_glClearColor\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble);\n#define glClearDepth _ptrc_glClearDepth\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint);\n#define glClearStencil _ptrc_glClearStencil\nextern void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean);\n#define glColorMask _ptrc_glColorMask\nextern void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum);\n#define glCullFace _ptrc_glCullFace\nextern void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum);\n#define glDepthFunc _ptrc_glDepthFunc\nextern void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean);\n#define glDepthMask _ptrc_glDepthMask\nextern void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble, GLdouble);\n#define glDepthRange _ptrc_glDepthRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum);\n#define glDisable _ptrc_glDisable\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum);\n#define glDrawBuffer _ptrc_glDrawBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum);\n#define glEnable _ptrc_glEnable\nextern void (CODEGEN_FUNCPTR *_ptrc_glFinish)();\n#define glFinish _ptrc_glFinish\nextern void (CODEGEN_FUNCPTR *_ptrc_glFlush)();\n#define glFlush _ptrc_glFlush\nextern void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum);\n#define glFrontFace _ptrc_glFrontFace\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *);\n#define glGetBooleanv _ptrc_glGetBooleanv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *);\n#define glGetDoublev _ptrc_glGetDoublev\nextern GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)();\n#define glGetError _ptrc_glGetError\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *);\n#define glGetFloatv _ptrc_glGetFloatv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *);\n#define glGetIntegerv _ptrc_glGetIntegerv\nextern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum);\n#define glGetString _ptrc_glGetString\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *);\n#define glGetTexImage _ptrc_glGetTexImage\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *);\n#define glGetTexLevelParameterfv _ptrc_glGetTexLevelParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *);\n#define glGetTexLevelParameteriv _ptrc_glGetTexLevelParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum, GLenum, GLfloat *);\n#define glGetTexParameterfv _ptrc_glGetTexParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint *);\n#define glGetTexParameteriv _ptrc_glGetTexParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum);\n#define glHint _ptrc_glHint\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum);\n#define glIsEnabled _ptrc_glIsEnabled\nextern void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat);\n#define glLineWidth _ptrc_glLineWidth\nextern void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum);\n#define glLogicOp _ptrc_glLogicOp\nextern void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat);\n#define glPixelStoref _ptrc_glPixelStoref\nextern void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint);\n#define glPixelStorei _ptrc_glPixelStorei\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat);\n#define glPointSize _ptrc_glPointSize\nextern void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum);\n#define glPolygonMode _ptrc_glPolygonMode\nextern void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum);\n#define glReadBuffer _ptrc_glReadBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);\n#define glReadPixels _ptrc_glReadPixels\nextern void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei);\n#define glScissor _ptrc_glScissor\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint);\n#define glStencilFunc _ptrc_glStencilFunc\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint);\n#define glStencilMask _ptrc_glStencilMask\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum);\n#define glStencilOp _ptrc_glStencilOp\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *);\n#define glTexImage1D _ptrc_glTexImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);\n#define glTexImage2D _ptrc_glTexImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum, GLenum, GLfloat);\n#define glTexParameterf _ptrc_glTexParameterf\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum, GLenum, const GLfloat *);\n#define glTexParameterfv _ptrc_glTexParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint);\n#define glTexParameteri _ptrc_glTexParameteri\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *);\n#define glTexParameteriv _ptrc_glTexParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei);\n#define glViewport _ptrc_glViewport\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint);\n#define glBindTexture _ptrc_glBindTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);\n#define glCopyTexImage1D _ptrc_glCopyTexImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);\n#define glCopyTexImage2D _ptrc_glCopyTexImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei);\n#define glCopyTexSubImage1D _ptrc_glCopyTexSubImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);\n#define glCopyTexSubImage2D _ptrc_glCopyTexSubImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *);\n#define glDeleteTextures _ptrc_glDeleteTextures\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei);\n#define glDrawArrays _ptrc_glDrawArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *);\n#define glDrawElements _ptrc_glDrawElements\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *);\n#define glGenTextures _ptrc_glGenTextures\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint);\n#define glIsTexture _ptrc_glIsTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat);\n#define glPolygonOffset _ptrc_glPolygonOffset\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);\n#define glTexSubImage1D _ptrc_glTexSubImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);\n#define glTexSubImage2D _ptrc_glTexSubImage2D\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat);\n#define glBlendColor _ptrc_glBlendColor\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum);\n#define glBlendEquation _ptrc_glBlendEquation\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);\n#define glCopyTexSubImage3D _ptrc_glCopyTexSubImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);\n#define glDrawRangeElements _ptrc_glDrawRangeElements\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);\n#define glTexImage3D _ptrc_glTexImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);\n#define glTexSubImage3D _ptrc_glTexSubImage3D\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum);\n#define glActiveTexture _ptrc_glActiveTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);\n#define glCompressedTexImage1D _ptrc_glCompressedTexImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);\n#define glCompressedTexImage2D _ptrc_glCompressedTexImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);\n#define glCompressedTexImage3D _ptrc_glCompressedTexImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);\n#define glCompressedTexSubImage1D _ptrc_glCompressedTexSubImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);\n#define glCompressedTexSubImage2D _ptrc_glCompressedTexSubImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);\n#define glCompressedTexSubImage3D _ptrc_glCompressedTexSubImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *);\n#define glGetCompressedTexImage _ptrc_glGetCompressedTexImage\nextern void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean);\n#define glSampleCoverage _ptrc_glSampleCoverage\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum);\n#define glBlendFuncSeparate _ptrc_glBlendFuncSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei);\n#define glMultiDrawArrays _ptrc_glMultiDrawArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei);\n#define glMultiDrawElements _ptrc_glMultiDrawElements\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum, GLfloat);\n#define glPointParameterf _ptrc_glPointParameterf\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum, const GLfloat *);\n#define glPointParameterfv _ptrc_glPointParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint);\n#define glPointParameteri _ptrc_glPointParameteri\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *);\n#define glPointParameteriv _ptrc_glPointParameteriv\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint);\n#define glBeginQuery _ptrc_glBeginQuery\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum, GLuint);\n#define glBindBuffer _ptrc_glBindBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum);\n#define glBufferData _ptrc_glBufferData\nextern void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid *);\n#define glBufferSubData _ptrc_glBufferSubData\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei, const GLuint *);\n#define glDeleteBuffers _ptrc_glDeleteBuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei, const GLuint *);\n#define glDeleteQueries _ptrc_glDeleteQueries\nextern void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum);\n#define glEndQuery _ptrc_glEndQuery\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei, GLuint *);\n#define glGenBuffers _ptrc_glGenBuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei, GLuint *);\n#define glGenQueries _ptrc_glGenQueries\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum, GLenum, GLint *);\n#define glGetBufferParameteriv _ptrc_glGetBufferParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum, GLenum, GLvoid **);\n#define glGetBufferPointerv _ptrc_glGetBufferPointerv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum, GLintptr, GLsizeiptr, GLvoid *);\n#define glGetBufferSubData _ptrc_glGetBufferSubData\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint, GLenum, GLint *);\n#define glGetQueryObjectiv _ptrc_glGetQueryObjectiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint, GLenum, GLuint *);\n#define glGetQueryObjectuiv _ptrc_glGetQueryObjectuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum, GLenum, GLint *);\n#define glGetQueryiv _ptrc_glGetQueryiv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint);\n#define glIsBuffer _ptrc_glIsBuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint);\n#define glIsQuery _ptrc_glIsQuery\nextern void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum, GLenum);\n#define glMapBuffer _ptrc_glMapBuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum);\n#define glUnmapBuffer _ptrc_glUnmapBuffer\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint, GLuint);\n#define glAttachShader _ptrc_glAttachShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint, GLuint, const GLchar *);\n#define glBindAttribLocation _ptrc_glBindAttribLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum, GLenum);\n#define glBlendEquationSeparate _ptrc_glBlendEquationSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint);\n#define glCompileShader _ptrc_glCompileShader\nextern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)();\n#define glCreateProgram _ptrc_glCreateProgram\nextern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum);\n#define glCreateShader _ptrc_glCreateShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint);\n#define glDeleteProgram _ptrc_glDeleteProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint);\n#define glDeleteShader _ptrc_glDeleteShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint, GLuint);\n#define glDetachShader _ptrc_glDetachShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint);\n#define glDisableVertexAttribArray _ptrc_glDisableVertexAttribArray\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei, const GLenum *);\n#define glDrawBuffers _ptrc_glDrawBuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint);\n#define glEnableVertexAttribArray _ptrc_glEnableVertexAttribArray\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);\n#define glGetActiveAttrib _ptrc_glGetActiveAttrib\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);\n#define glGetActiveUniform _ptrc_glGetActiveUniform\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *);\n#define glGetAttachedShaders _ptrc_glGetAttachedShaders\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint, const GLchar *);\n#define glGetAttribLocation _ptrc_glGetAttribLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetProgramInfoLog _ptrc_glGetProgramInfoLog\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint, GLenum, GLint *);\n#define glGetProgramiv _ptrc_glGetProgramiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetShaderInfoLog _ptrc_glGetShaderInfoLog\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetShaderSource _ptrc_glGetShaderSource\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint, GLenum, GLint *);\n#define glGetShaderiv _ptrc_glGetShaderiv\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint, const GLchar *);\n#define glGetUniformLocation _ptrc_glGetUniformLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint, GLint, GLfloat *);\n#define glGetUniformfv _ptrc_glGetUniformfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint, GLint, GLint *);\n#define glGetUniformiv _ptrc_glGetUniformiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint, GLenum, GLvoid **);\n#define glGetVertexAttribPointerv _ptrc_glGetVertexAttribPointerv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint, GLenum, GLdouble *);\n#define glGetVertexAttribdv _ptrc_glGetVertexAttribdv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint, GLenum, GLfloat *);\n#define glGetVertexAttribfv _ptrc_glGetVertexAttribfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint, GLenum, GLint *);\n#define glGetVertexAttribiv _ptrc_glGetVertexAttribiv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint);\n#define glIsProgram _ptrc_glIsProgram\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint);\n#define glIsShader _ptrc_glIsShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint);\n#define glLinkProgram _ptrc_glLinkProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint, GLsizei, const GLchar *const*, const GLint *);\n#define glShaderSource _ptrc_glShaderSource\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint);\n#define glStencilFuncSeparate _ptrc_glStencilFuncSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum, GLuint);\n#define glStencilMaskSeparate _ptrc_glStencilMaskSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum);\n#define glStencilOpSeparate _ptrc_glStencilOpSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint, GLfloat);\n#define glUniform1f _ptrc_glUniform1f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint, GLsizei, const GLfloat *);\n#define glUniform1fv _ptrc_glUniform1fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint, GLint);\n#define glUniform1i _ptrc_glUniform1i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint, GLsizei, const GLint *);\n#define glUniform1iv _ptrc_glUniform1iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint, GLfloat, GLfloat);\n#define glUniform2f _ptrc_glUniform2f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint, GLsizei, const GLfloat *);\n#define glUniform2fv _ptrc_glUniform2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint, GLint, GLint);\n#define glUniform2i _ptrc_glUniform2i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint, GLsizei, const GLint *);\n#define glUniform2iv _ptrc_glUniform2iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint, GLfloat, GLfloat, GLfloat);\n#define glUniform3f _ptrc_glUniform3f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint, GLsizei, const GLfloat *);\n#define glUniform3fv _ptrc_glUniform3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint, GLint, GLint, GLint);\n#define glUniform3i _ptrc_glUniform3i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint, GLsizei, const GLint *);\n#define glUniform3iv _ptrc_glUniform3iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);\n#define glUniform4f _ptrc_glUniform4f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint, GLsizei, const GLfloat *);\n#define glUniform4fv _ptrc_glUniform4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint, GLint, GLint, GLint, GLint);\n#define glUniform4i _ptrc_glUniform4i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint, GLsizei, const GLint *);\n#define glUniform4iv _ptrc_glUniform4iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix2fv _ptrc_glUniformMatrix2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix3fv _ptrc_glUniformMatrix3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix4fv _ptrc_glUniformMatrix4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint);\n#define glUseProgram _ptrc_glUseProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint);\n#define glValidateProgram _ptrc_glValidateProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint, GLdouble);\n#define glVertexAttrib1d _ptrc_glVertexAttrib1d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint, const GLdouble *);\n#define glVertexAttrib1dv _ptrc_glVertexAttrib1dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint, GLfloat);\n#define glVertexAttrib1f _ptrc_glVertexAttrib1f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint, const GLfloat *);\n#define glVertexAttrib1fv _ptrc_glVertexAttrib1fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint, GLshort);\n#define glVertexAttrib1s _ptrc_glVertexAttrib1s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint, const GLshort *);\n#define glVertexAttrib1sv _ptrc_glVertexAttrib1sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint, GLdouble, GLdouble);\n#define glVertexAttrib2d _ptrc_glVertexAttrib2d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint, const GLdouble *);\n#define glVertexAttrib2dv _ptrc_glVertexAttrib2dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint, GLfloat, GLfloat);\n#define glVertexAttrib2f _ptrc_glVertexAttrib2f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint, const GLfloat *);\n#define glVertexAttrib2fv _ptrc_glVertexAttrib2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint, GLshort, GLshort);\n#define glVertexAttrib2s _ptrc_glVertexAttrib2s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint, const GLshort *);\n#define glVertexAttrib2sv _ptrc_glVertexAttrib2sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint, GLdouble, GLdouble, GLdouble);\n#define glVertexAttrib3d _ptrc_glVertexAttrib3d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint, const GLdouble *);\n#define glVertexAttrib3dv _ptrc_glVertexAttrib3dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat);\n#define glVertexAttrib3f _ptrc_glVertexAttrib3f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint, const GLfloat *);\n#define glVertexAttrib3fv _ptrc_glVertexAttrib3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint, GLshort, GLshort, GLshort);\n#define glVertexAttrib3s _ptrc_glVertexAttrib3s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint, const GLshort *);\n#define glVertexAttrib3sv _ptrc_glVertexAttrib3sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint, const GLbyte *);\n#define glVertexAttrib4Nbv _ptrc_glVertexAttrib4Nbv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint, const GLint *);\n#define glVertexAttrib4Niv _ptrc_glVertexAttrib4Niv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint, const GLshort *);\n#define glVertexAttrib4Nsv _ptrc_glVertexAttrib4Nsv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte);\n#define glVertexAttrib4Nub _ptrc_glVertexAttrib4Nub\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint, const GLubyte *);\n#define glVertexAttrib4Nubv _ptrc_glVertexAttrib4Nubv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint, const GLuint *);\n#define glVertexAttrib4Nuiv _ptrc_glVertexAttrib4Nuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint, const GLushort *);\n#define glVertexAttrib4Nusv _ptrc_glVertexAttrib4Nusv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint, const GLbyte *);\n#define glVertexAttrib4bv _ptrc_glVertexAttrib4bv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble);\n#define glVertexAttrib4d _ptrc_glVertexAttrib4d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint, const GLdouble *);\n#define glVertexAttrib4dv _ptrc_glVertexAttrib4dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat);\n#define glVertexAttrib4f _ptrc_glVertexAttrib4f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint, const GLfloat *);\n#define glVertexAttrib4fv _ptrc_glVertexAttrib4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint, const GLint *);\n#define glVertexAttrib4iv _ptrc_glVertexAttrib4iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint, GLshort, GLshort, GLshort, GLshort);\n#define glVertexAttrib4s _ptrc_glVertexAttrib4s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint, const GLshort *);\n#define glVertexAttrib4sv _ptrc_glVertexAttrib4sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint, const GLubyte *);\n#define glVertexAttrib4ubv _ptrc_glVertexAttrib4ubv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint, const GLuint *);\n#define glVertexAttrib4uiv _ptrc_glVertexAttrib4uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint, const GLushort *);\n#define glVertexAttrib4usv _ptrc_glVertexAttrib4usv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);\n#define glVertexAttribPointer _ptrc_glVertexAttribPointer\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix2x3fv _ptrc_glUniformMatrix2x3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix2x4fv _ptrc_glUniformMatrix2x4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix3x2fv _ptrc_glUniformMatrix3x2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix3x4fv _ptrc_glUniformMatrix3x4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix4x2fv _ptrc_glUniformMatrix4x2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *);\n#define glUniformMatrix4x3fv _ptrc_glUniformMatrix4x3fv\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint, GLenum);\n#define glBeginConditionalRender _ptrc_glBeginConditionalRender\nextern void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum);\n#define glBeginTransformFeedback _ptrc_glBeginTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum, GLuint, GLuint);\n#define glBindBufferBase _ptrc_glBindBufferBase\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr);\n#define glBindBufferRange _ptrc_glBindBufferRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint, GLuint, const GLchar *);\n#define glBindFragDataLocation _ptrc_glBindFragDataLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum, GLuint);\n#define glBindFramebuffer _ptrc_glBindFramebuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum, GLuint);\n#define glBindRenderbuffer _ptrc_glBindRenderbuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint);\n#define glBindVertexArray _ptrc_glBindVertexArray\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);\n#define glBlitFramebuffer _ptrc_glBlitFramebuffer\nextern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum);\n#define glCheckFramebufferStatus _ptrc_glCheckFramebufferStatus\nextern void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum, GLenum);\n#define glClampColor _ptrc_glClampColor\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum, GLint, GLfloat, GLint);\n#define glClearBufferfi _ptrc_glClearBufferfi\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum, GLint, const GLfloat *);\n#define glClearBufferfv _ptrc_glClearBufferfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum, GLint, const GLint *);\n#define glClearBufferiv _ptrc_glClearBufferiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum, GLint, const GLuint *);\n#define glClearBufferuiv _ptrc_glClearBufferuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean);\n#define glColorMaski _ptrc_glColorMaski\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei, const GLuint *);\n#define glDeleteFramebuffers _ptrc_glDeleteFramebuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei, const GLuint *);\n#define glDeleteRenderbuffers _ptrc_glDeleteRenderbuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei, const GLuint *);\n#define glDeleteVertexArrays _ptrc_glDeleteVertexArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum, GLuint);\n#define glDisablei _ptrc_glDisablei\nextern void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum, GLuint);\n#define glEnablei _ptrc_glEnablei\nextern void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)();\n#define glEndConditionalRender _ptrc_glEndConditionalRender\nextern void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)();\n#define glEndTransformFeedback _ptrc_glEndTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr);\n#define glFlushMappedBufferRange _ptrc_glFlushMappedBufferRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint);\n#define glFramebufferRenderbuffer _ptrc_glFramebufferRenderbuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, GLint);\n#define glFramebufferTexture1D _ptrc_glFramebufferTexture1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint);\n#define glFramebufferTexture2D _ptrc_glFramebufferTexture2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum, GLenum, GLenum, GLuint, GLint, GLint);\n#define glFramebufferTexture3D _ptrc_glFramebufferTexture3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint);\n#define glFramebufferTextureLayer _ptrc_glFramebufferTextureLayer\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei, GLuint *);\n#define glGenFramebuffers _ptrc_glGenFramebuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei, GLuint *);\n#define glGenRenderbuffers _ptrc_glGenRenderbuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei, GLuint *);\n#define glGenVertexArrays _ptrc_glGenVertexArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum);\n#define glGenerateMipmap _ptrc_glGenerateMipmap\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum, GLuint, GLboolean *);\n#define glGetBooleani_v _ptrc_glGetBooleani_v\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint, const GLchar *);\n#define glGetFragDataLocation _ptrc_glGetFragDataLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *);\n#define glGetFramebufferAttachmentParameteriv _ptrc_glGetFramebufferAttachmentParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum, GLuint, GLint *);\n#define glGetIntegeri_v _ptrc_glGetIntegeri_v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *);\n#define glGetRenderbufferParameteriv _ptrc_glGetRenderbufferParameteriv\nextern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum, GLuint);\n#define glGetStringi _ptrc_glGetStringi\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum, GLenum, GLint *);\n#define glGetTexParameterIiv _ptrc_glGetTexParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum, GLenum, GLuint *);\n#define glGetTexParameterIuiv _ptrc_glGetTexParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *);\n#define glGetTransformFeedbackVarying _ptrc_glGetTransformFeedbackVarying\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint, GLint, GLuint *);\n#define glGetUniformuiv _ptrc_glGetUniformuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint, GLenum, GLint *);\n#define glGetVertexAttribIiv _ptrc_glGetVertexAttribIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *);\n#define glGetVertexAttribIuiv _ptrc_glGetVertexAttribIuiv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum, GLuint);\n#define glIsEnabledi _ptrc_glIsEnabledi\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint);\n#define glIsFramebuffer _ptrc_glIsFramebuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint);\n#define glIsRenderbuffer _ptrc_glIsRenderbuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint);\n#define glIsVertexArray _ptrc_glIsVertexArray\nextern void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield);\n#define glMapBufferRange _ptrc_glMapBufferRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei);\n#define glRenderbufferStorage _ptrc_glRenderbufferStorage\nextern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei);\n#define glRenderbufferStorageMultisample _ptrc_glRenderbufferStorageMultisample\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum, GLenum, const GLint *);\n#define glTexParameterIiv _ptrc_glTexParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum, GLenum, const GLuint *);\n#define glTexParameterIuiv _ptrc_glTexParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar *const*, GLenum);\n#define glTransformFeedbackVaryings _ptrc_glTransformFeedbackVaryings\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint, GLuint);\n#define glUniform1ui _ptrc_glUniform1ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint, GLsizei, const GLuint *);\n#define glUniform1uiv _ptrc_glUniform1uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint, GLuint, GLuint);\n#define glUniform2ui _ptrc_glUniform2ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint, GLsizei, const GLuint *);\n#define glUniform2uiv _ptrc_glUniform2uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint, GLuint, GLuint, GLuint);\n#define glUniform3ui _ptrc_glUniform3ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint, GLsizei, const GLuint *);\n#define glUniform3uiv _ptrc_glUniform3uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint);\n#define glUniform4ui _ptrc_glUniform4ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint, GLsizei, const GLuint *);\n#define glUniform4uiv _ptrc_glUniform4uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint, GLint);\n#define glVertexAttribI1i _ptrc_glVertexAttribI1i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint, const GLint *);\n#define glVertexAttribI1iv _ptrc_glVertexAttribI1iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint, GLuint);\n#define glVertexAttribI1ui _ptrc_glVertexAttribI1ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint, const GLuint *);\n#define glVertexAttribI1uiv _ptrc_glVertexAttribI1uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint, GLint, GLint);\n#define glVertexAttribI2i _ptrc_glVertexAttribI2i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint, const GLint *);\n#define glVertexAttribI2iv _ptrc_glVertexAttribI2iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint, GLuint, GLuint);\n#define glVertexAttribI2ui _ptrc_glVertexAttribI2ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint, const GLuint *);\n#define glVertexAttribI2uiv _ptrc_glVertexAttribI2uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint, GLint, GLint, GLint);\n#define glVertexAttribI3i _ptrc_glVertexAttribI3i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint, const GLint *);\n#define glVertexAttribI3iv _ptrc_glVertexAttribI3iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint, GLuint, GLuint, GLuint);\n#define glVertexAttribI3ui _ptrc_glVertexAttribI3ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint, const GLuint *);\n#define glVertexAttribI3uiv _ptrc_glVertexAttribI3uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint, const GLbyte *);\n#define glVertexAttribI4bv _ptrc_glVertexAttribI4bv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint);\n#define glVertexAttribI4i _ptrc_glVertexAttribI4i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint, const GLint *);\n#define glVertexAttribI4iv _ptrc_glVertexAttribI4iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint, const GLshort *);\n#define glVertexAttribI4sv _ptrc_glVertexAttribI4sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint, const GLubyte *);\n#define glVertexAttribI4ubv _ptrc_glVertexAttribI4ubv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint);\n#define glVertexAttribI4ui _ptrc_glVertexAttribI4ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint, const GLuint *);\n#define glVertexAttribI4uiv _ptrc_glVertexAttribI4uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint, const GLushort *);\n#define glVertexAttribI4usv _ptrc_glVertexAttribI4usv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *);\n#define glVertexAttribIPointer _ptrc_glVertexAttribIPointer\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr);\n#define glCopyBufferSubData _ptrc_glCopyBufferSubData\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei);\n#define glDrawArraysInstanced _ptrc_glDrawArraysInstanced\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei);\n#define glDrawElementsInstanced _ptrc_glDrawElementsInstanced\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetActiveUniformBlockName _ptrc_glGetActiveUniformBlockName\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *);\n#define glGetActiveUniformBlockiv _ptrc_glGetActiveUniformBlockiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetActiveUniformName _ptrc_glGetActiveUniformName\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *);\n#define glGetActiveUniformsiv _ptrc_glGetActiveUniformsiv\nextern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint, const GLchar *);\n#define glGetUniformBlockIndex _ptrc_glGetUniformBlockIndex\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint, GLsizei, const GLchar *const*, GLuint *);\n#define glGetUniformIndices _ptrc_glGetUniformIndices\nextern void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint);\n#define glPrimitiveRestartIndex _ptrc_glPrimitiveRestartIndex\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum, GLenum, GLuint);\n#define glTexBuffer _ptrc_glTexBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint, GLuint, GLuint);\n#define glUniformBlockBinding _ptrc_glUniformBlockBinding\n\nextern GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync, GLbitfield, GLuint64);\n#define glClientWaitSync _ptrc_glClientWaitSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync);\n#define glDeleteSync _ptrc_glDeleteSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLint);\n#define glDrawElementsBaseVertex _ptrc_glDrawElementsBaseVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint);\n#define glDrawElementsInstancedBaseVertex _ptrc_glDrawElementsInstancedBaseVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint);\n#define glDrawRangeElementsBaseVertex _ptrc_glDrawRangeElementsBaseVertex\nextern GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum, GLbitfield);\n#define glFenceSync _ptrc_glFenceSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum, GLenum, GLuint, GLint);\n#define glFramebufferTexture _ptrc_glFramebufferTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *);\n#define glGetBufferParameteri64v _ptrc_glGetBufferParameteri64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum, GLuint, GLint64 *);\n#define glGetInteger64i_v _ptrc_glGetInteger64i_v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum, GLint64 *);\n#define glGetInteger64v _ptrc_glGetInteger64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum, GLuint, GLfloat *);\n#define glGetMultisamplefv _ptrc_glGetMultisamplefv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *);\n#define glGetSynciv _ptrc_glGetSynciv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync);\n#define glIsSync _ptrc_glIsSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *);\n#define glMultiDrawElementsBaseVertex _ptrc_glMultiDrawElementsBaseVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum);\n#define glProvokingVertex _ptrc_glProvokingVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint, GLbitfield);\n#define glSampleMaski _ptrc_glSampleMaski\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean);\n#define glTexImage2DMultisample _ptrc_glTexImage2DMultisample\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean);\n#define glTexImage3DMultisample _ptrc_glTexImage3DMultisample\nextern void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync, GLbitfield, GLuint64);\n#define glWaitSync _ptrc_glWaitSync\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint, GLuint, GLuint, const GLchar *);\n#define glBindFragDataLocationIndexed _ptrc_glBindFragDataLocationIndexed\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint, GLuint);\n#define glBindSampler _ptrc_glBindSampler\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei, const GLuint *);\n#define glDeleteSamplers _ptrc_glDeleteSamplers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei, GLuint *);\n#define glGenSamplers _ptrc_glGenSamplers\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint, const GLchar *);\n#define glGetFragDataIndex _ptrc_glGetFragDataIndex\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint, GLenum, GLint64 *);\n#define glGetQueryObjecti64v _ptrc_glGetQueryObjecti64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint, GLenum, GLuint64 *);\n#define glGetQueryObjectui64v _ptrc_glGetQueryObjectui64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint, GLenum, GLint *);\n#define glGetSamplerParameterIiv _ptrc_glGetSamplerParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint, GLenum, GLuint *);\n#define glGetSamplerParameterIuiv _ptrc_glGetSamplerParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *);\n#define glGetSamplerParameterfv _ptrc_glGetSamplerParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint, GLenum, GLint *);\n#define glGetSamplerParameteriv _ptrc_glGetSamplerParameteriv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint);\n#define glIsSampler _ptrc_glIsSampler\nextern void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint, GLenum);\n#define glQueryCounter _ptrc_glQueryCounter\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint, GLenum, const GLint *);\n#define glSamplerParameterIiv _ptrc_glSamplerParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint, GLenum, const GLuint *);\n#define glSamplerParameterIuiv _ptrc_glSamplerParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint, GLenum, GLfloat);\n#define glSamplerParameterf _ptrc_glSamplerParameterf\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint, GLenum, const GLfloat *);\n#define glSamplerParameterfv _ptrc_glSamplerParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint, GLenum, GLint);\n#define glSamplerParameteri _ptrc_glSamplerParameteri\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint, GLenum, const GLint *);\n#define glSamplerParameteriv _ptrc_glSamplerParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint, GLuint);\n#define glVertexAttribDivisor _ptrc_glVertexAttribDivisor\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint, GLenum, GLboolean, GLuint);\n#define glVertexAttribP1ui _ptrc_glVertexAttribP1ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint, GLenum, GLboolean, const GLuint *);\n#define glVertexAttribP1uiv _ptrc_glVertexAttribP1uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint, GLenum, GLboolean, GLuint);\n#define glVertexAttribP2ui _ptrc_glVertexAttribP2ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint, GLenum, GLboolean, const GLuint *);\n#define glVertexAttribP2uiv _ptrc_glVertexAttribP2uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint, GLenum, GLboolean, GLuint);\n#define glVertexAttribP3ui _ptrc_glVertexAttribP3ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint, GLenum, GLboolean, const GLuint *);\n#define glVertexAttribP3uiv _ptrc_glVertexAttribP3uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint, GLenum, GLboolean, GLuint);\n#define glVertexAttribP4ui _ptrc_glVertexAttribP4ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint, GLenum, GLboolean, const GLuint *);\n#define glVertexAttribP4uiv _ptrc_glVertexAttribP4uiv\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBeginQueryIndexed)(GLenum, GLuint, GLuint);\n#define glBeginQueryIndexed _ptrc_glBeginQueryIndexed\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindTransformFeedback)(GLenum, GLuint);\n#define glBindTransformFeedback _ptrc_glBindTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparatei)(GLuint, GLenum, GLenum);\n#define glBlendEquationSeparatei _ptrc_glBlendEquationSeparatei\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationi)(GLuint, GLenum);\n#define glBlendEquationi _ptrc_glBlendEquationi\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparatei)(GLuint, GLenum, GLenum, GLenum, GLenum);\n#define glBlendFuncSeparatei _ptrc_glBlendFuncSeparatei\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendFunci)(GLuint, GLenum, GLenum);\n#define glBlendFunci _ptrc_glBlendFunci\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteTransformFeedbacks)(GLsizei, const GLuint *);\n#define glDeleteTransformFeedbacks _ptrc_glDeleteTransformFeedbacks\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysIndirect)(GLenum, const GLvoid *);\n#define glDrawArraysIndirect _ptrc_glDrawArraysIndirect\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsIndirect)(GLenum, GLenum, const GLvoid *);\n#define glDrawElementsIndirect _ptrc_glDrawElementsIndirect\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawTransformFeedback)(GLenum, GLuint);\n#define glDrawTransformFeedback _ptrc_glDrawTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawTransformFeedbackStream)(GLenum, GLuint, GLuint);\n#define glDrawTransformFeedbackStream _ptrc_glDrawTransformFeedbackStream\nextern void (CODEGEN_FUNCPTR *_ptrc_glEndQueryIndexed)(GLenum, GLuint);\n#define glEndQueryIndexed _ptrc_glEndQueryIndexed\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenTransformFeedbacks)(GLsizei, GLuint *);\n#define glGenTransformFeedbacks _ptrc_glGenTransformFeedbacks\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineName)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetActiveSubroutineName _ptrc_glGetActiveSubroutineName\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineUniformName)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *);\n#define glGetActiveSubroutineUniformName _ptrc_glGetActiveSubroutineUniformName\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineUniformiv)(GLuint, GLenum, GLuint, GLenum, GLint *);\n#define glGetActiveSubroutineUniformiv _ptrc_glGetActiveSubroutineUniformiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramStageiv)(GLuint, GLenum, GLenum, GLint *);\n#define glGetProgramStageiv _ptrc_glGetProgramStageiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryIndexediv)(GLenum, GLuint, GLenum, GLint *);\n#define glGetQueryIndexediv _ptrc_glGetQueryIndexediv\nextern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetSubroutineIndex)(GLuint, GLenum, const GLchar *);\n#define glGetSubroutineIndex _ptrc_glGetSubroutineIndex\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetSubroutineUniformLocation)(GLuint, GLenum, const GLchar *);\n#define glGetSubroutineUniformLocation _ptrc_glGetSubroutineUniformLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformSubroutineuiv)(GLenum, GLint, GLuint *);\n#define glGetUniformSubroutineuiv _ptrc_glGetUniformSubroutineuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformdv)(GLuint, GLint, GLdouble *);\n#define glGetUniformdv _ptrc_glGetUniformdv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTransformFeedback)(GLuint);\n#define glIsTransformFeedback _ptrc_glIsTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glMinSampleShading)(GLfloat);\n#define glMinSampleShading _ptrc_glMinSampleShading\nextern void (CODEGEN_FUNCPTR *_ptrc_glPatchParameterfv)(GLenum, const GLfloat *);\n#define glPatchParameterfv _ptrc_glPatchParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glPatchParameteri)(GLenum, GLint);\n#define glPatchParameteri _ptrc_glPatchParameteri\nextern void (CODEGEN_FUNCPTR *_ptrc_glPauseTransformFeedback)();\n#define glPauseTransformFeedback _ptrc_glPauseTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glResumeTransformFeedback)();\n#define glResumeTransformFeedback _ptrc_glResumeTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1d)(GLint, GLdouble);\n#define glUniform1d _ptrc_glUniform1d\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1dv)(GLint, GLsizei, const GLdouble *);\n#define glUniform1dv _ptrc_glUniform1dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2d)(GLint, GLdouble, GLdouble);\n#define glUniform2d _ptrc_glUniform2d\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2dv)(GLint, GLsizei, const GLdouble *);\n#define glUniform2dv _ptrc_glUniform2dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3d)(GLint, GLdouble, GLdouble, GLdouble);\n#define glUniform3d _ptrc_glUniform3d\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3dv)(GLint, GLsizei, const GLdouble *);\n#define glUniform3dv _ptrc_glUniform3dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4d)(GLint, GLdouble, GLdouble, GLdouble, GLdouble);\n#define glUniform4d _ptrc_glUniform4d\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4dv)(GLint, GLsizei, const GLdouble *);\n#define glUniform4dv _ptrc_glUniform4dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix2dv _ptrc_glUniformMatrix2dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix2x3dv _ptrc_glUniformMatrix2x3dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix2x4dv _ptrc_glUniformMatrix2x4dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix3dv _ptrc_glUniformMatrix3dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix3x2dv _ptrc_glUniformMatrix3x2dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix3x4dv _ptrc_glUniformMatrix3x4dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix4dv _ptrc_glUniformMatrix4dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix4x2dv _ptrc_glUniformMatrix4x2dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3dv)(GLint, GLsizei, GLboolean, const GLdouble *);\n#define glUniformMatrix4x3dv _ptrc_glUniformMatrix4x3dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformSubroutinesuiv)(GLenum, GLsizei, const GLuint *);\n#define glUniformSubroutinesuiv _ptrc_glUniformSubroutinesuiv\n\nenum ogl_LoadStatus\n{\n\togl_LOAD_FAILED = 0,\n\togl_LOAD_SUCCEEDED = 1,\n};\n\nint ogl_LoadFunctions();\n\nint ogl_GetMinorVersion();\nint ogl_GetMajorVersion();\nint ogl_IsVersionGEQ(int majorVersion, int minorVersion);\n\n#ifdef __cplusplus\n}\n#endif /*__cplusplus*/\n\n#endif //POINTER_C_GENERATED_HEADER_OPENGL_H\n\n\n#ifdef GL_CORE_4\n#define GL_CORE_4\n\n#if defined(__APPLE__)\n#include <mach-o/dyld.h>\n\nstatic void* AppleGLGetProcAddress (const GLubyte *name)\n{\n  static const struct mach_header* image = NULL;\n  NSSymbol symbol;\n  char* symbolName;\n  if (NULL == image)\n  {\n    image = NSAddImage(\"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL\", NSADDIMAGE_OPTION_RETURN_ON_ERROR);\n  }\n  /* prepend a '_' for the Unix C symbol mangling convention */\n  symbolName = malloc(strlen((const char*)name) + 2);\n  strcpy(symbolName+1, (const char*)name);\n  symbolName[0] = '_';\n  symbol = NULL;\n  /* if (NSIsSymbolNameDefined(symbolName))\n     symbol = NSLookupAndBindSymbol(symbolName); */\n  symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL;\n  free(symbolName);\n  return symbol ? NSAddressOfSymbol(symbol) : NULL;\n}\n#endif /* __APPLE__ */\n\n#if defined(__sgi) || defined (__sun)\n#include <dlfcn.h>\n#include <stdio.h>\n\nstatic void* SunGetProcAddress (const GLubyte* name)\n{\n  static void* h = NULL;\n  static void* gpa;\n\n  if (h == NULL)\n  {\n    if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL;\n    gpa = dlsym(h, \"glXGetProcAddress\");\n  }\n\n  if (gpa != NULL)\n    return ((void*(*)(const GLubyte*))gpa)(name);\n  else\n    return dlsym(h, (const char*)name);\n}\n#endif /* __sgi || __sun */\n\n#if defined(_WIN32)\n\n#ifdef _MSC_VER\n#pragma warning(disable: 4055)\n#pragma warning(disable: 4054)\n#endif\n\nstatic int TestPointer(const PROC pTest)\n{\n    ptrdiff_t iTest;\n    if(!pTest) return 0;\n    iTest = (ptrdiff_t)pTest;\n\n    if(iTest == 1 || iTest == 2 || iTest == 3 || iTest == -1) return 0;\n\n    return 1;\n}\n\nstatic PROC WinGetProcAddress(const char *name)\n{\n    HMODULE glMod = NULL;\n    PROC pFunc = wglGetProcAddress((LPCSTR)name);\n    if(TestPointer(pFunc))\n    {\n        return pFunc;\n    }\n    glMod = GetModuleHandleA(\"OpenGL32.dll\");\n    return (PROC)GetProcAddress(glMod, (LPCSTR)name);\n}\n\n#define IntGetProcAddress(name) WinGetProcAddress(name)\n#else\n    #if defined(__APPLE__)\n        #define IntGetProcAddress(name) AppleGLGetProcAddress(name)\n    #else\n        #if defined(__sgi) || defined(__sun)\n            #define IntGetProcAddress(name) SunGetProcAddress(name)\n        #else /* GLX */\n            #include <GL/glx.h>\n\n            #define IntGetProcAddress(name) (*glXGetProcAddressARB)((const GLubyte*)name)\n        #endif\n    #endif\n#endif\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFinish)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFlush)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *) = NULL;\nGLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *) = NULL;\nconst GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum, GLenum, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum, GLenum, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum, GLenum, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum, GLenum, GLvoid **) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum, GLintptr, GLsizeiptr, GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint, GLenum, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum, GLenum, GLint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint) = NULL;\nvoid * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum, GLenum) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint, GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint) = NULL;\nGLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)() = NULL;\nGLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei, const GLenum *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint, GLenum, GLint *) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint, GLint, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint, GLint, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint, GLenum, GLvoid **) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint, GLenum, GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint, GLenum, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint, GLenum, GLint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint, GLsizei, const GLchar *const*, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint, GLsizei, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint, GLsizei, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint, GLsizei, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint, GLsizei, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint, GLsizei, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint, GLint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint, GLsizei, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint, GLsizei, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint, GLint, GLint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint, GLsizei, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint, GLshort) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint, GLshort, GLshort) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint, GLdouble, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint, GLshort, GLshort, GLshort) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint, const GLbyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint, const GLubyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint, const GLushort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint, const GLbyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint, GLshort, GLshort, GLshort, GLshort) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint, const GLubyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint, const GLushort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint, GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum) = NULL;\nGLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum, GLint, GLfloat, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum, GLint, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum, GLint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum, GLint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum, GLenum, GLenum, GLuint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum, GLuint, GLboolean *) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum, GLuint, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *) = NULL;\nconst GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum, GLenum, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint, GLint, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum, GLuint) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint) = NULL;\nvoid * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum, GLenum, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum, GLenum, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar *const*, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint, GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint, GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint, GLuint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint, GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint, GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint, GLint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint, GLuint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint, const GLbyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint, const GLshort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint, const GLubyte *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint, const GLushort *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *) = NULL;\nGLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint, GLsizei, const GLchar *const*, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum, GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint, GLuint, GLuint) = NULL;\n\nGLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync, GLbitfield, GLuint64) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint) = NULL;\nGLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum, GLbitfield) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum, GLenum, GLuint, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum, GLuint, GLint64 *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum, GLint64 *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum, GLuint, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint, GLbitfield) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync, GLbitfield, GLuint64) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint, GLuint, GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei, GLuint *) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint, GLenum, GLint64 *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint, GLenum, GLuint64 *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint, GLenum, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint, GLenum, GLint *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint, GLenum, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint, GLenum, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint, GLenum, GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint, GLenum, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint, GLenum, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint, GLenum, const GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint, GLenum, GLboolean, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint, GLenum, GLboolean, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint, GLenum, GLboolean, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint, GLenum, GLboolean, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBeginQueryIndexed)(GLenum, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindTransformFeedback)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparatei)(GLuint, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendEquationi)(GLuint, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparatei)(GLuint, GLenum, GLenum, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendFunci)(GLuint, GLenum, GLenum) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteTransformFeedbacks)(GLsizei, const GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawArraysIndirect)(GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElementsIndirect)(GLenum, GLenum, const GLvoid *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawTransformFeedback)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawTransformFeedbackStream)(GLenum, GLuint, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEndQueryIndexed)(GLenum, GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenTransformFeedbacks)(GLsizei, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineName)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineUniformName)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveSubroutineUniformiv)(GLuint, GLenum, GLuint, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetProgramStageiv)(GLuint, GLenum, GLenum, GLint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryIndexediv)(GLenum, GLuint, GLenum, GLint *) = NULL;\nGLuint (CODEGEN_FUNCPTR *_ptrc_glGetSubroutineIndex)(GLuint, GLenum, const GLchar *) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetSubroutineUniformLocation)(GLuint, GLenum, const GLchar *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformSubroutineuiv)(GLenum, GLint, GLuint *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformdv)(GLuint, GLint, GLdouble *) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTransformFeedback)(GLuint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glMinSampleShading)(GLfloat) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPatchParameterfv)(GLenum, const GLfloat *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPatchParameteri)(GLenum, GLint) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPauseTransformFeedback)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glResumeTransformFeedback)() = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1d)(GLint, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1dv)(GLint, GLsizei, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2d)(GLint, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2dv)(GLint, GLsizei, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3d)(GLint, GLdouble, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3dv)(GLint, GLsizei, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4d)(GLint, GLdouble, GLdouble, GLdouble, GLdouble) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4dv)(GLint, GLsizei, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3dv)(GLint, GLsizei, GLboolean, const GLdouble *) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformSubroutinesuiv)(GLenum, GLsizei, const GLuint *) = NULL;\n\nstatic int Load_Version_4_0()\n{\n    int numFailed = 0;\n    _ptrc_glBlendFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glBlendFunc\");\n    if(!_ptrc_glBlendFunc) numFailed++;\n    _ptrc_glClear = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress(\"glClear\");\n    if(!_ptrc_glClear) numFailed++;\n    _ptrc_glClearColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glClearColor\");\n    if(!_ptrc_glClearColor) numFailed++;\n    _ptrc_glClearDepth = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress(\"glClearDepth\");\n    if(!_ptrc_glClearDepth) numFailed++;\n    _ptrc_glClearStencil = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress(\"glClearStencil\");\n    if(!_ptrc_glClearStencil) numFailed++;\n    _ptrc_glColorMask = (void (CODEGEN_FUNCPTR *)(GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress(\"glColorMask\");\n    if(!_ptrc_glColorMask) numFailed++;\n    _ptrc_glCullFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glCullFace\");\n    if(!_ptrc_glCullFace) numFailed++;\n    _ptrc_glDepthFunc = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glDepthFunc\");\n    if(!_ptrc_glDepthFunc) numFailed++;\n    _ptrc_glDepthMask = (void (CODEGEN_FUNCPTR *)(GLboolean))IntGetProcAddress(\"glDepthMask\");\n    if(!_ptrc_glDepthMask) numFailed++;\n    _ptrc_glDepthRange = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress(\"glDepthRange\");\n    if(!_ptrc_glDepthRange) numFailed++;\n    _ptrc_glDisable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glDisable\");\n    if(!_ptrc_glDisable) numFailed++;\n    _ptrc_glDrawBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glDrawBuffer\");\n    if(!_ptrc_glDrawBuffer) numFailed++;\n    _ptrc_glEnable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glEnable\");\n    if(!_ptrc_glEnable) numFailed++;\n    _ptrc_glFinish = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glFinish\");\n    if(!_ptrc_glFinish) numFailed++;\n    _ptrc_glFlush = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glFlush\");\n    if(!_ptrc_glFlush) numFailed++;\n    _ptrc_glFrontFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glFrontFace\");\n    if(!_ptrc_glFrontFace) numFailed++;\n    _ptrc_glGetBooleanv = (void (CODEGEN_FUNCPTR *)(GLenum, GLboolean *))IntGetProcAddress(\"glGetBooleanv\");\n    if(!_ptrc_glGetBooleanv) numFailed++;\n    _ptrc_glGetDoublev = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble *))IntGetProcAddress(\"glGetDoublev\");\n    if(!_ptrc_glGetDoublev) numFailed++;\n    _ptrc_glGetError = (GLenum (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glGetError\");\n    if(!_ptrc_glGetError) numFailed++;\n    _ptrc_glGetFloatv = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat *))IntGetProcAddress(\"glGetFloatv\");\n    if(!_ptrc_glGetFloatv) numFailed++;\n    _ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress(\"glGetIntegerv\");\n    if(!_ptrc_glGetIntegerv) numFailed++;\n    _ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glGetString\");\n    if(!_ptrc_glGetString) numFailed++;\n    _ptrc_glGetTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLenum, GLvoid *))IntGetProcAddress(\"glGetTexImage\");\n    if(!_ptrc_glGetTexImage) numFailed++;\n    _ptrc_glGetTexLevelParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLfloat *))IntGetProcAddress(\"glGetTexLevelParameterfv\");\n    if(!_ptrc_glGetTexLevelParameterfv) numFailed++;\n    _ptrc_glGetTexLevelParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint *))IntGetProcAddress(\"glGetTexLevelParameteriv\");\n    if(!_ptrc_glGetTexLevelParameteriv) numFailed++;\n    _ptrc_glGetTexParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress(\"glGetTexParameterfv\");\n    if(!_ptrc_glGetTexParameterfv) numFailed++;\n    _ptrc_glGetTexParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetTexParameteriv\");\n    if(!_ptrc_glGetTexParameteriv) numFailed++;\n    _ptrc_glHint = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glHint\");\n    if(!_ptrc_glHint) numFailed++;\n    _ptrc_glIsEnabled = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glIsEnabled\");\n    if(!_ptrc_glIsEnabled) numFailed++;\n    _ptrc_glLineWidth = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress(\"glLineWidth\");\n    if(!_ptrc_glLineWidth) numFailed++;\n    _ptrc_glLogicOp = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glLogicOp\");\n    if(!_ptrc_glLogicOp) numFailed++;\n    _ptrc_glPixelStoref = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress(\"glPixelStoref\");\n    if(!_ptrc_glPixelStoref) numFailed++;\n    _ptrc_glPixelStorei = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress(\"glPixelStorei\");\n    if(!_ptrc_glPixelStorei) numFailed++;\n    _ptrc_glPointSize = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress(\"glPointSize\");\n    if(!_ptrc_glPointSize) numFailed++;\n    _ptrc_glPolygonMode = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glPolygonMode\");\n    if(!_ptrc_glPolygonMode) numFailed++;\n    _ptrc_glReadBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glReadBuffer\");\n    if(!_ptrc_glReadBuffer) numFailed++;\n    _ptrc_glReadPixels = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *))IntGetProcAddress(\"glReadPixels\");\n    if(!_ptrc_glReadPixels) numFailed++;\n    _ptrc_glScissor = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glScissor\");\n    if(!_ptrc_glScissor) numFailed++;\n    _ptrc_glStencilFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLuint))IntGetProcAddress(\"glStencilFunc\");\n    if(!_ptrc_glStencilFunc) numFailed++;\n    _ptrc_glStencilMask = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glStencilMask\");\n    if(!_ptrc_glStencilMask) numFailed++;\n    _ptrc_glStencilOp = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum))IntGetProcAddress(\"glStencilOp\");\n    if(!_ptrc_glStencilOp) numFailed++;\n    _ptrc_glTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexImage1D\");\n    if(!_ptrc_glTexImage1D) numFailed++;\n    _ptrc_glTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexImage2D\");\n    if(!_ptrc_glTexImage2D) numFailed++;\n    _ptrc_glTexParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress(\"glTexParameterf\");\n    if(!_ptrc_glTexParameterf) numFailed++;\n    _ptrc_glTexParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress(\"glTexParameterfv\");\n    if(!_ptrc_glTexParameterfv) numFailed++;\n    _ptrc_glTexParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress(\"glTexParameteri\");\n    if(!_ptrc_glTexParameteri) numFailed++;\n    _ptrc_glTexParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress(\"glTexParameteriv\");\n    if(!_ptrc_glTexParameteriv) numFailed++;\n    _ptrc_glViewport = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glViewport\");\n    if(!_ptrc_glViewport) numFailed++;\n    _ptrc_glBindTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindTexture\");\n    if(!_ptrc_glBindTexture) numFailed++;\n    _ptrc_glCopyTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint))IntGetProcAddress(\"glCopyTexImage1D\");\n    if(!_ptrc_glCopyTexImage1D) numFailed++;\n    _ptrc_glCopyTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint))IntGetProcAddress(\"glCopyTexImage2D\");\n    if(!_ptrc_glCopyTexImage2D) numFailed++;\n    _ptrc_glCopyTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei))IntGetProcAddress(\"glCopyTexSubImage1D\");\n    if(!_ptrc_glCopyTexSubImage1D) numFailed++;\n    _ptrc_glCopyTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glCopyTexSubImage2D\");\n    if(!_ptrc_glCopyTexSubImage2D) numFailed++;\n    _ptrc_glDeleteTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteTextures\");\n    if(!_ptrc_glDeleteTextures) numFailed++;\n    _ptrc_glDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei))IntGetProcAddress(\"glDrawArrays\");\n    if(!_ptrc_glDrawArrays) numFailed++;\n    _ptrc_glDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *))IntGetProcAddress(\"glDrawElements\");\n    if(!_ptrc_glDrawElements) numFailed++;\n    _ptrc_glGenTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenTextures\");\n    if(!_ptrc_glGenTextures) numFailed++;\n    _ptrc_glIsTexture = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsTexture\");\n    if(!_ptrc_glIsTexture) numFailed++;\n    _ptrc_glPolygonOffset = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress(\"glPolygonOffset\");\n    if(!_ptrc_glPolygonOffset) numFailed++;\n    _ptrc_glTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexSubImage1D\");\n    if(!_ptrc_glTexSubImage1D) numFailed++;\n    _ptrc_glTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexSubImage2D\");\n    if(!_ptrc_glTexSubImage2D) numFailed++;\n    _ptrc_glBlendColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glBlendColor\");\n    if(!_ptrc_glBlendColor) numFailed++;\n    _ptrc_glBlendEquation = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glBlendEquation\");\n    if(!_ptrc_glBlendEquation) numFailed++;\n    _ptrc_glCopyTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glCopyTexSubImage3D\");\n    if(!_ptrc_glCopyTexSubImage3D) numFailed++;\n    _ptrc_glDrawRangeElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))IntGetProcAddress(\"glDrawRangeElements\");\n    if(!_ptrc_glDrawRangeElements) numFailed++;\n    _ptrc_glTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexImage3D\");\n    if(!_ptrc_glTexImage3D) numFailed++;\n    _ptrc_glTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glTexSubImage3D\");\n    if(!_ptrc_glTexSubImage3D) numFailed++;\n    _ptrc_glActiveTexture = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glActiveTexture\");\n    if(!_ptrc_glActiveTexture) numFailed++;\n    _ptrc_glCompressedTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexImage1D\");\n    if(!_ptrc_glCompressedTexImage1D) numFailed++;\n    _ptrc_glCompressedTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexImage2D\");\n    if(!_ptrc_glCompressedTexImage2D) numFailed++;\n    _ptrc_glCompressedTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexImage3D\");\n    if(!_ptrc_glCompressedTexImage3D) numFailed++;\n    _ptrc_glCompressedTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexSubImage1D\");\n    if(!_ptrc_glCompressedTexSubImage1D) numFailed++;\n    _ptrc_glCompressedTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexSubImage2D\");\n    if(!_ptrc_glCompressedTexSubImage2D) numFailed++;\n    _ptrc_glCompressedTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress(\"glCompressedTexSubImage3D\");\n    if(!_ptrc_glCompressedTexSubImage3D) numFailed++;\n    _ptrc_glGetCompressedTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLvoid *))IntGetProcAddress(\"glGetCompressedTexImage\");\n    if(!_ptrc_glGetCompressedTexImage) numFailed++;\n    _ptrc_glSampleCoverage = (void (CODEGEN_FUNCPTR *)(GLfloat, GLboolean))IntGetProcAddress(\"glSampleCoverage\");\n    if(!_ptrc_glSampleCoverage) numFailed++;\n    _ptrc_glBlendFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress(\"glBlendFuncSeparate\");\n    if(!_ptrc_glBlendFuncSeparate) numFailed++;\n    _ptrc_glMultiDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *, const GLsizei *, GLsizei))IntGetProcAddress(\"glMultiDrawArrays\");\n    if(!_ptrc_glMultiDrawArrays) numFailed++;\n    _ptrc_glMultiDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei))IntGetProcAddress(\"glMultiDrawElements\");\n    if(!_ptrc_glMultiDrawElements) numFailed++;\n    _ptrc_glPointParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress(\"glPointParameterf\");\n    if(!_ptrc_glPointParameterf) numFailed++;\n    _ptrc_glPointParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress(\"glPointParameterfv\");\n    if(!_ptrc_glPointParameterfv) numFailed++;\n    _ptrc_glPointParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress(\"glPointParameteri\");\n    if(!_ptrc_glPointParameteri) numFailed++;\n    _ptrc_glPointParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress(\"glPointParameteriv\");\n    if(!_ptrc_glPointParameteriv) numFailed++;\n    _ptrc_glBeginQuery = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBeginQuery\");\n    if(!_ptrc_glBeginQuery) numFailed++;\n    _ptrc_glBindBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindBuffer\");\n    if(!_ptrc_glBindBuffer) numFailed++;\n    _ptrc_glBufferData = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const GLvoid *, GLenum))IntGetProcAddress(\"glBufferData\");\n    if(!_ptrc_glBufferData) numFailed++;\n    _ptrc_glBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, const GLvoid *))IntGetProcAddress(\"glBufferSubData\");\n    if(!_ptrc_glBufferSubData) numFailed++;\n    _ptrc_glDeleteBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteBuffers\");\n    if(!_ptrc_glDeleteBuffers) numFailed++;\n    _ptrc_glDeleteQueries = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteQueries\");\n    if(!_ptrc_glDeleteQueries) numFailed++;\n    _ptrc_glEndQuery = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glEndQuery\");\n    if(!_ptrc_glEndQuery) numFailed++;\n    _ptrc_glGenBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenBuffers\");\n    if(!_ptrc_glGenBuffers) numFailed++;\n    _ptrc_glGenQueries = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenQueries\");\n    if(!_ptrc_glGenQueries) numFailed++;\n    _ptrc_glGetBufferParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetBufferParameteriv\");\n    if(!_ptrc_glGetBufferParameteriv) numFailed++;\n    _ptrc_glGetBufferPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLvoid **))IntGetProcAddress(\"glGetBufferPointerv\");\n    if(!_ptrc_glGetBufferPointerv) numFailed++;\n    _ptrc_glGetBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, GLvoid *))IntGetProcAddress(\"glGetBufferSubData\");\n    if(!_ptrc_glGetBufferSubData) numFailed++;\n    _ptrc_glGetQueryObjectiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetQueryObjectiv\");\n    if(!_ptrc_glGetQueryObjectiv) numFailed++;\n    _ptrc_glGetQueryObjectuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress(\"glGetQueryObjectuiv\");\n    if(!_ptrc_glGetQueryObjectuiv) numFailed++;\n    _ptrc_glGetQueryiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetQueryiv\");\n    if(!_ptrc_glGetQueryiv) numFailed++;\n    _ptrc_glIsBuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsBuffer\");\n    if(!_ptrc_glIsBuffer) numFailed++;\n    _ptrc_glIsQuery = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsQuery\");\n    if(!_ptrc_glIsQuery) numFailed++;\n    _ptrc_glMapBuffer = (void * (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glMapBuffer\");\n    if(!_ptrc_glMapBuffer) numFailed++;\n    _ptrc_glUnmapBuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glUnmapBuffer\");\n    if(!_ptrc_glUnmapBuffer) numFailed++;\n    _ptrc_glAttachShader = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glAttachShader\");\n    if(!_ptrc_glAttachShader) numFailed++;\n    _ptrc_glBindAttribLocation = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, const GLchar *))IntGetProcAddress(\"glBindAttribLocation\");\n    if(!_ptrc_glBindAttribLocation) numFailed++;\n    _ptrc_glBlendEquationSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glBlendEquationSeparate\");\n    if(!_ptrc_glBlendEquationSeparate) numFailed++;\n    _ptrc_glCompileShader = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glCompileShader\");\n    if(!_ptrc_glCompileShader) numFailed++;\n    _ptrc_glCreateProgram = (GLuint (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glCreateProgram\");\n    if(!_ptrc_glCreateProgram) numFailed++;\n    _ptrc_glCreateShader = (GLuint (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glCreateShader\");\n    if(!_ptrc_glCreateShader) numFailed++;\n    _ptrc_glDeleteProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glDeleteProgram\");\n    if(!_ptrc_glDeleteProgram) numFailed++;\n    _ptrc_glDeleteShader = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glDeleteShader\");\n    if(!_ptrc_glDeleteShader) numFailed++;\n    _ptrc_glDetachShader = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glDetachShader\");\n    if(!_ptrc_glDetachShader) numFailed++;\n    _ptrc_glDisableVertexAttribArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glDisableVertexAttribArray\");\n    if(!_ptrc_glDisableVertexAttribArray) numFailed++;\n    _ptrc_glDrawBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLenum *))IntGetProcAddress(\"glDrawBuffers\");\n    if(!_ptrc_glDrawBuffers) numFailed++;\n    _ptrc_glEnableVertexAttribArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glEnableVertexAttribArray\");\n    if(!_ptrc_glEnableVertexAttribArray) numFailed++;\n    _ptrc_glGetActiveAttrib = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *))IntGetProcAddress(\"glGetActiveAttrib\");\n    if(!_ptrc_glGetActiveAttrib) numFailed++;\n    _ptrc_glGetActiveUniform = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *))IntGetProcAddress(\"glGetActiveUniform\");\n    if(!_ptrc_glGetActiveUniform) numFailed++;\n    _ptrc_glGetAttachedShaders = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLuint *))IntGetProcAddress(\"glGetAttachedShaders\");\n    if(!_ptrc_glGetAttachedShaders) numFailed++;\n    _ptrc_glGetAttribLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetAttribLocation\");\n    if(!_ptrc_glGetAttribLocation) numFailed++;\n    _ptrc_glGetProgramInfoLog = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetProgramInfoLog\");\n    if(!_ptrc_glGetProgramInfoLog) numFailed++;\n    _ptrc_glGetProgramiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetProgramiv\");\n    if(!_ptrc_glGetProgramiv) numFailed++;\n    _ptrc_glGetShaderInfoLog = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetShaderInfoLog\");\n    if(!_ptrc_glGetShaderInfoLog) numFailed++;\n    _ptrc_glGetShaderSource = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetShaderSource\");\n    if(!_ptrc_glGetShaderSource) numFailed++;\n    _ptrc_glGetShaderiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetShaderiv\");\n    if(!_ptrc_glGetShaderiv) numFailed++;\n    _ptrc_glGetUniformLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetUniformLocation\");\n    if(!_ptrc_glGetUniformLocation) numFailed++;\n    _ptrc_glGetUniformfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLfloat *))IntGetProcAddress(\"glGetUniformfv\");\n    if(!_ptrc_glGetUniformfv) numFailed++;\n    _ptrc_glGetUniformiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint *))IntGetProcAddress(\"glGetUniformiv\");\n    if(!_ptrc_glGetUniformiv) numFailed++;\n    _ptrc_glGetVertexAttribPointerv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLvoid **))IntGetProcAddress(\"glGetVertexAttribPointerv\");\n    if(!_ptrc_glGetVertexAttribPointerv) numFailed++;\n    _ptrc_glGetVertexAttribdv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLdouble *))IntGetProcAddress(\"glGetVertexAttribdv\");\n    if(!_ptrc_glGetVertexAttribdv) numFailed++;\n    _ptrc_glGetVertexAttribfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat *))IntGetProcAddress(\"glGetVertexAttribfv\");\n    if(!_ptrc_glGetVertexAttribfv) numFailed++;\n    _ptrc_glGetVertexAttribiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetVertexAttribiv\");\n    if(!_ptrc_glGetVertexAttribiv) numFailed++;\n    _ptrc_glIsProgram = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsProgram\");\n    if(!_ptrc_glIsProgram) numFailed++;\n    _ptrc_glIsShader = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsShader\");\n    if(!_ptrc_glIsShader) numFailed++;\n    _ptrc_glLinkProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glLinkProgram\");\n    if(!_ptrc_glLinkProgram) numFailed++;\n    _ptrc_glShaderSource = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, const GLint *))IntGetProcAddress(\"glShaderSource\");\n    if(!_ptrc_glShaderSource) numFailed++;\n    _ptrc_glStencilFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint, GLuint))IntGetProcAddress(\"glStencilFuncSeparate\");\n    if(!_ptrc_glStencilFuncSeparate) numFailed++;\n    _ptrc_glStencilMaskSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glStencilMaskSeparate\");\n    if(!_ptrc_glStencilMaskSeparate) numFailed++;\n    _ptrc_glStencilOpSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress(\"glStencilOpSeparate\");\n    if(!_ptrc_glStencilOpSeparate) numFailed++;\n    _ptrc_glUniform1f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat))IntGetProcAddress(\"glUniform1f\");\n    if(!_ptrc_glUniform1f) numFailed++;\n    _ptrc_glUniform1fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform1fv\");\n    if(!_ptrc_glUniform1fv) numFailed++;\n    _ptrc_glUniform1i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress(\"glUniform1i\");\n    if(!_ptrc_glUniform1i) numFailed++;\n    _ptrc_glUniform1iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform1iv\");\n    if(!_ptrc_glUniform1iv) numFailed++;\n    _ptrc_glUniform2f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat))IntGetProcAddress(\"glUniform2f\");\n    if(!_ptrc_glUniform2f) numFailed++;\n    _ptrc_glUniform2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform2fv\");\n    if(!_ptrc_glUniform2fv) numFailed++;\n    _ptrc_glUniform2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress(\"glUniform2i\");\n    if(!_ptrc_glUniform2i) numFailed++;\n    _ptrc_glUniform2iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform2iv\");\n    if(!_ptrc_glUniform2iv) numFailed++;\n    _ptrc_glUniform3f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glUniform3f\");\n    if(!_ptrc_glUniform3f) numFailed++;\n    _ptrc_glUniform3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform3fv\");\n    if(!_ptrc_glUniform3fv) numFailed++;\n    _ptrc_glUniform3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress(\"glUniform3i\");\n    if(!_ptrc_glUniform3i) numFailed++;\n    _ptrc_glUniform3iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform3iv\");\n    if(!_ptrc_glUniform3iv) numFailed++;\n    _ptrc_glUniform4f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glUniform4f\");\n    if(!_ptrc_glUniform4f) numFailed++;\n    _ptrc_glUniform4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform4fv\");\n    if(!_ptrc_glUniform4fv) numFailed++;\n    _ptrc_glUniform4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint))IntGetProcAddress(\"glUniform4i\");\n    if(!_ptrc_glUniform4i) numFailed++;\n    _ptrc_glUniform4iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform4iv\");\n    if(!_ptrc_glUniform4iv) numFailed++;\n    _ptrc_glUniformMatrix2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix2fv\");\n    if(!_ptrc_glUniformMatrix2fv) numFailed++;\n    _ptrc_glUniformMatrix3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix3fv\");\n    if(!_ptrc_glUniformMatrix3fv) numFailed++;\n    _ptrc_glUniformMatrix4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix4fv\");\n    if(!_ptrc_glUniformMatrix4fv) numFailed++;\n    _ptrc_glUseProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glUseProgram\");\n    if(!_ptrc_glUseProgram) numFailed++;\n    _ptrc_glValidateProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glValidateProgram\");\n    if(!_ptrc_glValidateProgram) numFailed++;\n    _ptrc_glVertexAttrib1d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble))IntGetProcAddress(\"glVertexAttrib1d\");\n    if(!_ptrc_glVertexAttrib1d) numFailed++;\n    _ptrc_glVertexAttrib1dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib1dv\");\n    if(!_ptrc_glVertexAttrib1dv) numFailed++;\n    _ptrc_glVertexAttrib1f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat))IntGetProcAddress(\"glVertexAttrib1f\");\n    if(!_ptrc_glVertexAttrib1f) numFailed++;\n    _ptrc_glVertexAttrib1fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib1fv\");\n    if(!_ptrc_glVertexAttrib1fv) numFailed++;\n    _ptrc_glVertexAttrib1s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort))IntGetProcAddress(\"glVertexAttrib1s\");\n    if(!_ptrc_glVertexAttrib1s) numFailed++;\n    _ptrc_glVertexAttrib1sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib1sv\");\n    if(!_ptrc_glVertexAttrib1sv) numFailed++;\n    _ptrc_glVertexAttrib2d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble))IntGetProcAddress(\"glVertexAttrib2d\");\n    if(!_ptrc_glVertexAttrib2d) numFailed++;\n    _ptrc_glVertexAttrib2dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib2dv\");\n    if(!_ptrc_glVertexAttrib2dv) numFailed++;\n    _ptrc_glVertexAttrib2f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat))IntGetProcAddress(\"glVertexAttrib2f\");\n    if(!_ptrc_glVertexAttrib2f) numFailed++;\n    _ptrc_glVertexAttrib2fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib2fv\");\n    if(!_ptrc_glVertexAttrib2fv) numFailed++;\n    _ptrc_glVertexAttrib2s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort))IntGetProcAddress(\"glVertexAttrib2s\");\n    if(!_ptrc_glVertexAttrib2s) numFailed++;\n    _ptrc_glVertexAttrib2sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib2sv\");\n    if(!_ptrc_glVertexAttrib2sv) numFailed++;\n    _ptrc_glVertexAttrib3d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble))IntGetProcAddress(\"glVertexAttrib3d\");\n    if(!_ptrc_glVertexAttrib3d) numFailed++;\n    _ptrc_glVertexAttrib3dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib3dv\");\n    if(!_ptrc_glVertexAttrib3dv) numFailed++;\n    _ptrc_glVertexAttrib3f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glVertexAttrib3f\");\n    if(!_ptrc_glVertexAttrib3f) numFailed++;\n    _ptrc_glVertexAttrib3fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib3fv\");\n    if(!_ptrc_glVertexAttrib3fv) numFailed++;\n    _ptrc_glVertexAttrib3s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort))IntGetProcAddress(\"glVertexAttrib3s\");\n    if(!_ptrc_glVertexAttrib3s) numFailed++;\n    _ptrc_glVertexAttrib3sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib3sv\");\n    if(!_ptrc_glVertexAttrib3sv) numFailed++;\n    _ptrc_glVertexAttrib4Nbv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress(\"glVertexAttrib4Nbv\");\n    if(!_ptrc_glVertexAttrib4Nbv) numFailed++;\n    _ptrc_glVertexAttrib4Niv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttrib4Niv\");\n    if(!_ptrc_glVertexAttrib4Niv) numFailed++;\n    _ptrc_glVertexAttrib4Nsv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib4Nsv\");\n    if(!_ptrc_glVertexAttrib4Nsv) numFailed++;\n    _ptrc_glVertexAttrib4Nub = (void (CODEGEN_FUNCPTR *)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte))IntGetProcAddress(\"glVertexAttrib4Nub\");\n    if(!_ptrc_glVertexAttrib4Nub) numFailed++;\n    _ptrc_glVertexAttrib4Nubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress(\"glVertexAttrib4Nubv\");\n    if(!_ptrc_glVertexAttrib4Nubv) numFailed++;\n    _ptrc_glVertexAttrib4Nuiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttrib4Nuiv\");\n    if(!_ptrc_glVertexAttrib4Nuiv) numFailed++;\n    _ptrc_glVertexAttrib4Nusv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress(\"glVertexAttrib4Nusv\");\n    if(!_ptrc_glVertexAttrib4Nusv) numFailed++;\n    _ptrc_glVertexAttrib4bv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress(\"glVertexAttrib4bv\");\n    if(!_ptrc_glVertexAttrib4bv) numFailed++;\n    _ptrc_glVertexAttrib4d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress(\"glVertexAttrib4d\");\n    if(!_ptrc_glVertexAttrib4d) numFailed++;\n    _ptrc_glVertexAttrib4dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib4dv\");\n    if(!_ptrc_glVertexAttrib4dv) numFailed++;\n    _ptrc_glVertexAttrib4f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glVertexAttrib4f\");\n    if(!_ptrc_glVertexAttrib4f) numFailed++;\n    _ptrc_glVertexAttrib4fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib4fv\");\n    if(!_ptrc_glVertexAttrib4fv) numFailed++;\n    _ptrc_glVertexAttrib4iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttrib4iv\");\n    if(!_ptrc_glVertexAttrib4iv) numFailed++;\n    _ptrc_glVertexAttrib4s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort, GLshort))IntGetProcAddress(\"glVertexAttrib4s\");\n    if(!_ptrc_glVertexAttrib4s) numFailed++;\n    _ptrc_glVertexAttrib4sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib4sv\");\n    if(!_ptrc_glVertexAttrib4sv) numFailed++;\n    _ptrc_glVertexAttrib4ubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress(\"glVertexAttrib4ubv\");\n    if(!_ptrc_glVertexAttrib4ubv) numFailed++;\n    _ptrc_glVertexAttrib4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttrib4uiv\");\n    if(!_ptrc_glVertexAttrib4uiv) numFailed++;\n    _ptrc_glVertexAttrib4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress(\"glVertexAttrib4usv\");\n    if(!_ptrc_glVertexAttrib4usv) numFailed++;\n    _ptrc_glVertexAttribPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *))IntGetProcAddress(\"glVertexAttribPointer\");\n    if(!_ptrc_glVertexAttribPointer) numFailed++;\n    _ptrc_glUniformMatrix2x3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix2x3fv\");\n    if(!_ptrc_glUniformMatrix2x3fv) numFailed++;\n    _ptrc_glUniformMatrix2x4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix2x4fv\");\n    if(!_ptrc_glUniformMatrix2x4fv) numFailed++;\n    _ptrc_glUniformMatrix3x2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix3x2fv\");\n    if(!_ptrc_glUniformMatrix3x2fv) numFailed++;\n    _ptrc_glUniformMatrix3x4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix3x4fv\");\n    if(!_ptrc_glUniformMatrix3x4fv) numFailed++;\n    _ptrc_glUniformMatrix4x2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix4x2fv\");\n    if(!_ptrc_glUniformMatrix4x2fv) numFailed++;\n    _ptrc_glUniformMatrix4x3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix4x3fv\");\n    if(!_ptrc_glUniformMatrix4x3fv) numFailed++;\n    _ptrc_glBeginConditionalRender = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress(\"glBeginConditionalRender\");\n    if(!_ptrc_glBeginConditionalRender) numFailed++;\n    _ptrc_glBeginTransformFeedback = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glBeginTransformFeedback\");\n    if(!_ptrc_glBeginTransformFeedback) numFailed++;\n    _ptrc_glBindBufferBase = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint))IntGetProcAddress(\"glBindBufferBase\");\n    if(!_ptrc_glBindBufferBase) numFailed++;\n    _ptrc_glBindBufferRange = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr))IntGetProcAddress(\"glBindBufferRange\");\n    if(!_ptrc_glBindBufferRange) numFailed++;\n    _ptrc_glBindFragDataLocation = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, const GLchar *))IntGetProcAddress(\"glBindFragDataLocation\");\n    if(!_ptrc_glBindFragDataLocation) numFailed++;\n    _ptrc_glBindFramebuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindFramebuffer\");\n    if(!_ptrc_glBindFramebuffer) numFailed++;\n    _ptrc_glBindRenderbuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindRenderbuffer\");\n    if(!_ptrc_glBindRenderbuffer) numFailed++;\n    _ptrc_glBindVertexArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glBindVertexArray\");\n    if(!_ptrc_glBindVertexArray) numFailed++;\n    _ptrc_glBlitFramebuffer = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum))IntGetProcAddress(\"glBlitFramebuffer\");\n    if(!_ptrc_glBlitFramebuffer) numFailed++;\n    _ptrc_glCheckFramebufferStatus = (GLenum (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glCheckFramebufferStatus\");\n    if(!_ptrc_glCheckFramebufferStatus) numFailed++;\n    _ptrc_glClampColor = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glClampColor\");\n    if(!_ptrc_glClampColor) numFailed++;\n    _ptrc_glClearBufferfi = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLfloat, GLint))IntGetProcAddress(\"glClearBufferfi\");\n    if(!_ptrc_glClearBufferfi) numFailed++;\n    _ptrc_glClearBufferfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLfloat *))IntGetProcAddress(\"glClearBufferfv\");\n    if(!_ptrc_glClearBufferfv) numFailed++;\n    _ptrc_glClearBufferiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLint *))IntGetProcAddress(\"glClearBufferiv\");\n    if(!_ptrc_glClearBufferiv) numFailed++;\n    _ptrc_glClearBufferuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLuint *))IntGetProcAddress(\"glClearBufferuiv\");\n    if(!_ptrc_glClearBufferuiv) numFailed++;\n    _ptrc_glColorMaski = (void (CODEGEN_FUNCPTR *)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress(\"glColorMaski\");\n    if(!_ptrc_glColorMaski) numFailed++;\n    _ptrc_glDeleteFramebuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteFramebuffers\");\n    if(!_ptrc_glDeleteFramebuffers) numFailed++;\n    _ptrc_glDeleteRenderbuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteRenderbuffers\");\n    if(!_ptrc_glDeleteRenderbuffers) numFailed++;\n    _ptrc_glDeleteVertexArrays = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteVertexArrays\");\n    if(!_ptrc_glDeleteVertexArrays) numFailed++;\n    _ptrc_glDisablei = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glDisablei\");\n    if(!_ptrc_glDisablei) numFailed++;\n    _ptrc_glEnablei = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glEnablei\");\n    if(!_ptrc_glEnablei) numFailed++;\n    _ptrc_glEndConditionalRender = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glEndConditionalRender\");\n    if(!_ptrc_glEndConditionalRender) numFailed++;\n    _ptrc_glEndTransformFeedback = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glEndTransformFeedback\");\n    if(!_ptrc_glEndTransformFeedback) numFailed++;\n    _ptrc_glFlushMappedBufferRange = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr))IntGetProcAddress(\"glFlushMappedBufferRange\");\n    if(!_ptrc_glFlushMappedBufferRange) numFailed++;\n    _ptrc_glFramebufferRenderbuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint))IntGetProcAddress(\"glFramebufferRenderbuffer\");\n    if(!_ptrc_glFramebufferRenderbuffer) numFailed++;\n    _ptrc_glFramebufferTexture1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress(\"glFramebufferTexture1D\");\n    if(!_ptrc_glFramebufferTexture1D) numFailed++;\n    _ptrc_glFramebufferTexture2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress(\"glFramebufferTexture2D\");\n    if(!_ptrc_glFramebufferTexture2D) numFailed++;\n    _ptrc_glFramebufferTexture3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress(\"glFramebufferTexture3D\");\n    if(!_ptrc_glFramebufferTexture3D) numFailed++;\n    _ptrc_glFramebufferTextureLayer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress(\"glFramebufferTextureLayer\");\n    if(!_ptrc_glFramebufferTextureLayer) numFailed++;\n    _ptrc_glGenFramebuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenFramebuffers\");\n    if(!_ptrc_glGenFramebuffers) numFailed++;\n    _ptrc_glGenRenderbuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenRenderbuffers\");\n    if(!_ptrc_glGenRenderbuffers) numFailed++;\n    _ptrc_glGenVertexArrays = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenVertexArrays\");\n    if(!_ptrc_glGenVertexArrays) numFailed++;\n    _ptrc_glGenerateMipmap = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glGenerateMipmap\");\n    if(!_ptrc_glGenerateMipmap) numFailed++;\n    _ptrc_glGetBooleani_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLboolean *))IntGetProcAddress(\"glGetBooleani_v\");\n    if(!_ptrc_glGetBooleani_v) numFailed++;\n    _ptrc_glGetFragDataLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetFragDataLocation\");\n    if(!_ptrc_glGetFragDataLocation) numFailed++;\n    _ptrc_glGetFramebufferAttachmentParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetFramebufferAttachmentParameteriv\");\n    if(!_ptrc_glGetFramebufferAttachmentParameteriv) numFailed++;\n    _ptrc_glGetIntegeri_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLint *))IntGetProcAddress(\"glGetIntegeri_v\");\n    if(!_ptrc_glGetIntegeri_v) numFailed++;\n    _ptrc_glGetRenderbufferParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetRenderbufferParameteriv\");\n    if(!_ptrc_glGetRenderbufferParameteriv) numFailed++;\n    _ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glGetStringi\");\n    if(!_ptrc_glGetStringi) numFailed++;\n    _ptrc_glGetTexParameterIiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetTexParameterIiv\");\n    if(!_ptrc_glGetTexParameterIiv) numFailed++;\n    _ptrc_glGetTexParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint *))IntGetProcAddress(\"glGetTexParameterIuiv\");\n    if(!_ptrc_glGetTexParameterIuiv) numFailed++;\n    _ptrc_glGetTransformFeedbackVarying = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *))IntGetProcAddress(\"glGetTransformFeedbackVarying\");\n    if(!_ptrc_glGetTransformFeedbackVarying) numFailed++;\n    _ptrc_glGetUniformuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLuint *))IntGetProcAddress(\"glGetUniformuiv\");\n    if(!_ptrc_glGetUniformuiv) numFailed++;\n    _ptrc_glGetVertexAttribIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetVertexAttribIiv\");\n    if(!_ptrc_glGetVertexAttribIiv) numFailed++;\n    _ptrc_glGetVertexAttribIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress(\"glGetVertexAttribIuiv\");\n    if(!_ptrc_glGetVertexAttribIuiv) numFailed++;\n    _ptrc_glIsEnabledi = (GLboolean (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glIsEnabledi\");\n    if(!_ptrc_glIsEnabledi) numFailed++;\n    _ptrc_glIsFramebuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsFramebuffer\");\n    if(!_ptrc_glIsFramebuffer) numFailed++;\n    _ptrc_glIsRenderbuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsRenderbuffer\");\n    if(!_ptrc_glIsRenderbuffer) numFailed++;\n    _ptrc_glIsVertexArray = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsVertexArray\");\n    if(!_ptrc_glIsVertexArray) numFailed++;\n    _ptrc_glMapBufferRange = (void * (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, GLbitfield))IntGetProcAddress(\"glMapBufferRange\");\n    if(!_ptrc_glMapBufferRange) numFailed++;\n    _ptrc_glRenderbufferStorage = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLsizei, GLsizei))IntGetProcAddress(\"glRenderbufferStorage\");\n    if(!_ptrc_glRenderbufferStorage) numFailed++;\n    _ptrc_glRenderbufferStorageMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))IntGetProcAddress(\"glRenderbufferStorageMultisample\");\n    if(!_ptrc_glRenderbufferStorageMultisample) numFailed++;\n    _ptrc_glTexParameterIiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress(\"glTexParameterIiv\");\n    if(!_ptrc_glTexParameterIiv) numFailed++;\n    _ptrc_glTexParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLuint *))IntGetProcAddress(\"glTexParameterIuiv\");\n    if(!_ptrc_glTexParameterIuiv) numFailed++;\n    _ptrc_glTransformFeedbackVaryings = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, GLenum))IntGetProcAddress(\"glTransformFeedbackVaryings\");\n    if(!_ptrc_glTransformFeedbackVaryings) numFailed++;\n    _ptrc_glUniform1ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint))IntGetProcAddress(\"glUniform1ui\");\n    if(!_ptrc_glUniform1ui) numFailed++;\n    _ptrc_glUniform1uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform1uiv\");\n    if(!_ptrc_glUniform1uiv) numFailed++;\n    _ptrc_glUniform2ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint))IntGetProcAddress(\"glUniform2ui\");\n    if(!_ptrc_glUniform2ui) numFailed++;\n    _ptrc_glUniform2uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform2uiv\");\n    if(!_ptrc_glUniform2uiv) numFailed++;\n    _ptrc_glUniform3ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glUniform3ui\");\n    if(!_ptrc_glUniform3ui) numFailed++;\n    _ptrc_glUniform3uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform3uiv\");\n    if(!_ptrc_glUniform3uiv) numFailed++;\n    _ptrc_glUniform4ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glUniform4ui\");\n    if(!_ptrc_glUniform4ui) numFailed++;\n    _ptrc_glUniform4uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform4uiv\");\n    if(!_ptrc_glUniform4uiv) numFailed++;\n    _ptrc_glVertexAttribI1i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint))IntGetProcAddress(\"glVertexAttribI1i\");\n    if(!_ptrc_glVertexAttribI1i) numFailed++;\n    _ptrc_glVertexAttribI1iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI1iv\");\n    if(!_ptrc_glVertexAttribI1iv) numFailed++;\n    _ptrc_glVertexAttribI1ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI1ui\");\n    if(!_ptrc_glVertexAttribI1ui) numFailed++;\n    _ptrc_glVertexAttribI1uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI1uiv\");\n    if(!_ptrc_glVertexAttribI1uiv) numFailed++;\n    _ptrc_glVertexAttribI2i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint))IntGetProcAddress(\"glVertexAttribI2i\");\n    if(!_ptrc_glVertexAttribI2i) numFailed++;\n    _ptrc_glVertexAttribI2iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI2iv\");\n    if(!_ptrc_glVertexAttribI2iv) numFailed++;\n    _ptrc_glVertexAttribI2ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI2ui\");\n    if(!_ptrc_glVertexAttribI2ui) numFailed++;\n    _ptrc_glVertexAttribI2uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI2uiv\");\n    if(!_ptrc_glVertexAttribI2uiv) numFailed++;\n    _ptrc_glVertexAttribI3i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint))IntGetProcAddress(\"glVertexAttribI3i\");\n    if(!_ptrc_glVertexAttribI3i) numFailed++;\n    _ptrc_glVertexAttribI3iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI3iv\");\n    if(!_ptrc_glVertexAttribI3iv) numFailed++;\n    _ptrc_glVertexAttribI3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI3ui\");\n    if(!_ptrc_glVertexAttribI3ui) numFailed++;\n    _ptrc_glVertexAttribI3uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI3uiv\");\n    if(!_ptrc_glVertexAttribI3uiv) numFailed++;\n    _ptrc_glVertexAttribI4bv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress(\"glVertexAttribI4bv\");\n    if(!_ptrc_glVertexAttribI4bv) numFailed++;\n    _ptrc_glVertexAttribI4i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint, GLint))IntGetProcAddress(\"glVertexAttribI4i\");\n    if(!_ptrc_glVertexAttribI4i) numFailed++;\n    _ptrc_glVertexAttribI4iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI4iv\");\n    if(!_ptrc_glVertexAttribI4iv) numFailed++;\n    _ptrc_glVertexAttribI4sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttribI4sv\");\n    if(!_ptrc_glVertexAttribI4sv) numFailed++;\n    _ptrc_glVertexAttribI4ubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress(\"glVertexAttribI4ubv\");\n    if(!_ptrc_glVertexAttribI4ubv) numFailed++;\n    _ptrc_glVertexAttribI4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI4ui\");\n    if(!_ptrc_glVertexAttribI4ui) numFailed++;\n    _ptrc_glVertexAttribI4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI4uiv\");\n    if(!_ptrc_glVertexAttribI4uiv) numFailed++;\n    _ptrc_glVertexAttribI4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress(\"glVertexAttribI4usv\");\n    if(!_ptrc_glVertexAttribI4usv) numFailed++;\n    _ptrc_glVertexAttribIPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress(\"glVertexAttribIPointer\");\n    if(!_ptrc_glVertexAttribIPointer) numFailed++;\n    _ptrc_glCopyBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr))IntGetProcAddress(\"glCopyBufferSubData\");\n    if(!_ptrc_glCopyBufferSubData) numFailed++;\n    _ptrc_glDrawArraysInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glDrawArraysInstanced\");\n    if(!_ptrc_glDrawArraysInstanced) numFailed++;\n    _ptrc_glDrawElementsInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei))IntGetProcAddress(\"glDrawElementsInstanced\");\n    if(!_ptrc_glDrawElementsInstanced) numFailed++;\n    _ptrc_glGetActiveUniformBlockName = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetActiveUniformBlockName\");\n    if(!_ptrc_glGetActiveUniformBlockName) numFailed++;\n    _ptrc_glGetActiveUniformBlockiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetActiveUniformBlockiv\");\n    if(!_ptrc_glGetActiveUniformBlockiv) numFailed++;\n    _ptrc_glGetActiveUniformName = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetActiveUniformName\");\n    if(!_ptrc_glGetActiveUniformName) numFailed++;\n    _ptrc_glGetActiveUniformsiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLuint *, GLenum, GLint *))IntGetProcAddress(\"glGetActiveUniformsiv\");\n    if(!_ptrc_glGetActiveUniformsiv) numFailed++;\n    _ptrc_glGetUniformBlockIndex = (GLuint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetUniformBlockIndex\");\n    if(!_ptrc_glGetUniformBlockIndex) numFailed++;\n    _ptrc_glGetUniformIndices = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, GLuint *))IntGetProcAddress(\"glGetUniformIndices\");\n    if(!_ptrc_glGetUniformIndices) numFailed++;\n    _ptrc_glPrimitiveRestartIndex = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glPrimitiveRestartIndex\");\n    if(!_ptrc_glPrimitiveRestartIndex) numFailed++;\n    _ptrc_glTexBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint))IntGetProcAddress(\"glTexBuffer\");\n    if(!_ptrc_glTexBuffer) numFailed++;\n    _ptrc_glUniformBlockBinding = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress(\"glUniformBlockBinding\");\n    if(!_ptrc_glUniformBlockBinding) numFailed++;\n    _ptrc_glClientWaitSync = (GLenum (CODEGEN_FUNCPTR *)(GLsync, GLbitfield, GLuint64))IntGetProcAddress(\"glClientWaitSync\");\n    if(!_ptrc_glClientWaitSync) numFailed++;\n    _ptrc_glDeleteSync = (void (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress(\"glDeleteSync\");\n    if(!_ptrc_glDeleteSync) numFailed++;\n    _ptrc_glDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLint))IntGetProcAddress(\"glDrawElementsBaseVertex\");\n    if(!_ptrc_glDrawElementsBaseVertex) numFailed++;\n    _ptrc_glDrawElementsInstancedBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint))IntGetProcAddress(\"glDrawElementsInstancedBaseVertex\");\n    if(!_ptrc_glDrawElementsInstancedBaseVertex) numFailed++;\n    _ptrc_glDrawRangeElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint))IntGetProcAddress(\"glDrawRangeElementsBaseVertex\");\n    if(!_ptrc_glDrawRangeElementsBaseVertex) numFailed++;\n    _ptrc_glFenceSync = (GLsync (CODEGEN_FUNCPTR *)(GLenum, GLbitfield))IntGetProcAddress(\"glFenceSync\");\n    if(!_ptrc_glFenceSync) numFailed++;\n    _ptrc_glFramebufferTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLint))IntGetProcAddress(\"glFramebufferTexture\");\n    if(!_ptrc_glFramebufferTexture) numFailed++;\n    _ptrc_glGetBufferParameteri64v = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint64 *))IntGetProcAddress(\"glGetBufferParameteri64v\");\n    if(!_ptrc_glGetBufferParameteri64v) numFailed++;\n    _ptrc_glGetInteger64i_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLint64 *))IntGetProcAddress(\"glGetInteger64i_v\");\n    if(!_ptrc_glGetInteger64i_v) numFailed++;\n    _ptrc_glGetInteger64v = (void (CODEGEN_FUNCPTR *)(GLenum, GLint64 *))IntGetProcAddress(\"glGetInteger64v\");\n    if(!_ptrc_glGetInteger64v) numFailed++;\n    _ptrc_glGetMultisamplefv = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLfloat *))IntGetProcAddress(\"glGetMultisamplefv\");\n    if(!_ptrc_glGetMultisamplefv) numFailed++;\n    _ptrc_glGetSynciv = (void (CODEGEN_FUNCPTR *)(GLsync, GLenum, GLsizei, GLsizei *, GLint *))IntGetProcAddress(\"glGetSynciv\");\n    if(!_ptrc_glGetSynciv) numFailed++;\n    _ptrc_glIsSync = (GLboolean (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress(\"glIsSync\");\n    if(!_ptrc_glIsSync) numFailed++;\n    _ptrc_glMultiDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *))IntGetProcAddress(\"glMultiDrawElementsBaseVertex\");\n    if(!_ptrc_glMultiDrawElementsBaseVertex) numFailed++;\n    _ptrc_glProvokingVertex = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glProvokingVertex\");\n    if(!_ptrc_glProvokingVertex) numFailed++;\n    _ptrc_glSampleMaski = (void (CODEGEN_FUNCPTR *)(GLuint, GLbitfield))IntGetProcAddress(\"glSampleMaski\");\n    if(!_ptrc_glSampleMaski) numFailed++;\n    _ptrc_glTexImage2DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean))IntGetProcAddress(\"glTexImage2DMultisample\");\n    if(!_ptrc_glTexImage2DMultisample) numFailed++;\n    _ptrc_glTexImage3DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean))IntGetProcAddress(\"glTexImage3DMultisample\");\n    if(!_ptrc_glTexImage3DMultisample) numFailed++;\n    _ptrc_glWaitSync = (void (CODEGEN_FUNCPTR *)(GLsync, GLbitfield, GLuint64))IntGetProcAddress(\"glWaitSync\");\n    if(!_ptrc_glWaitSync) numFailed++;\n    _ptrc_glBindFragDataLocationIndexed = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, const GLchar *))IntGetProcAddress(\"glBindFragDataLocationIndexed\");\n    if(!_ptrc_glBindFragDataLocationIndexed) numFailed++;\n    _ptrc_glBindSampler = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glBindSampler\");\n    if(!_ptrc_glBindSampler) numFailed++;\n    _ptrc_glDeleteSamplers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteSamplers\");\n    if(!_ptrc_glDeleteSamplers) numFailed++;\n    _ptrc_glGenSamplers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenSamplers\");\n    if(!_ptrc_glGenSamplers) numFailed++;\n    _ptrc_glGetFragDataIndex = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetFragDataIndex\");\n    if(!_ptrc_glGetFragDataIndex) numFailed++;\n    _ptrc_glGetQueryObjecti64v = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint64 *))IntGetProcAddress(\"glGetQueryObjecti64v\");\n    if(!_ptrc_glGetQueryObjecti64v) numFailed++;\n    _ptrc_glGetQueryObjectui64v = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint64 *))IntGetProcAddress(\"glGetQueryObjectui64v\");\n    if(!_ptrc_glGetQueryObjectui64v) numFailed++;\n    _ptrc_glGetSamplerParameterIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetSamplerParameterIiv\");\n    if(!_ptrc_glGetSamplerParameterIiv) numFailed++;\n    _ptrc_glGetSamplerParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress(\"glGetSamplerParameterIuiv\");\n    if(!_ptrc_glGetSamplerParameterIuiv) numFailed++;\n    _ptrc_glGetSamplerParameterfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat *))IntGetProcAddress(\"glGetSamplerParameterfv\");\n    if(!_ptrc_glGetSamplerParameterfv) numFailed++;\n    _ptrc_glGetSamplerParameteriv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetSamplerParameteriv\");\n    if(!_ptrc_glGetSamplerParameteriv) numFailed++;\n    _ptrc_glIsSampler = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsSampler\");\n    if(!_ptrc_glIsSampler) numFailed++;\n    _ptrc_glQueryCounter = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress(\"glQueryCounter\");\n    if(!_ptrc_glQueryCounter) numFailed++;\n    _ptrc_glSamplerParameterIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLint *))IntGetProcAddress(\"glSamplerParameterIiv\");\n    if(!_ptrc_glSamplerParameterIiv) numFailed++;\n    _ptrc_glSamplerParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLuint *))IntGetProcAddress(\"glSamplerParameterIuiv\");\n    if(!_ptrc_glSamplerParameterIuiv) numFailed++;\n    _ptrc_glSamplerParameterf = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat))IntGetProcAddress(\"glSamplerParameterf\");\n    if(!_ptrc_glSamplerParameterf) numFailed++;\n    _ptrc_glSamplerParameterfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLfloat *))IntGetProcAddress(\"glSamplerParameterfv\");\n    if(!_ptrc_glSamplerParameterfv) numFailed++;\n    _ptrc_glSamplerParameteri = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint))IntGetProcAddress(\"glSamplerParameteri\");\n    if(!_ptrc_glSamplerParameteri) numFailed++;\n    _ptrc_glSamplerParameteriv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLint *))IntGetProcAddress(\"glSamplerParameteriv\");\n    if(!_ptrc_glSamplerParameteriv) numFailed++;\n    _ptrc_glVertexAttribDivisor = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glVertexAttribDivisor\");\n    if(!_ptrc_glVertexAttribDivisor) numFailed++;\n    _ptrc_glVertexAttribP1ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP1ui\");\n    if(!_ptrc_glVertexAttribP1ui) numFailed++;\n    _ptrc_glVertexAttribP1uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP1uiv\");\n    if(!_ptrc_glVertexAttribP1uiv) numFailed++;\n    _ptrc_glVertexAttribP2ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP2ui\");\n    if(!_ptrc_glVertexAttribP2ui) numFailed++;\n    _ptrc_glVertexAttribP2uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP2uiv\");\n    if(!_ptrc_glVertexAttribP2uiv) numFailed++;\n    _ptrc_glVertexAttribP3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP3ui\");\n    if(!_ptrc_glVertexAttribP3ui) numFailed++;\n    _ptrc_glVertexAttribP3uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP3uiv\");\n    if(!_ptrc_glVertexAttribP3uiv) numFailed++;\n    _ptrc_glVertexAttribP4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP4ui\");\n    if(!_ptrc_glVertexAttribP4ui) numFailed++;\n    _ptrc_glVertexAttribP4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP4uiv\");\n    if(!_ptrc_glVertexAttribP4uiv) numFailed++;\n    _ptrc_glBeginQueryIndexed = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint))IntGetProcAddress(\"glBeginQueryIndexed\");\n    if(!_ptrc_glBeginQueryIndexed) numFailed++;\n    _ptrc_glBindTransformFeedback = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindTransformFeedback\");\n    if(!_ptrc_glBindTransformFeedback) numFailed++;\n    _ptrc_glBlendEquationSeparatei = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLenum))IntGetProcAddress(\"glBlendEquationSeparatei\");\n    if(!_ptrc_glBlendEquationSeparatei) numFailed++;\n    _ptrc_glBlendEquationi = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress(\"glBlendEquationi\");\n    if(!_ptrc_glBlendEquationi) numFailed++;\n    _ptrc_glBlendFuncSeparatei = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLenum, GLenum, GLenum))IntGetProcAddress(\"glBlendFuncSeparatei\");\n    if(!_ptrc_glBlendFuncSeparatei) numFailed++;\n    _ptrc_glBlendFunci = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLenum))IntGetProcAddress(\"glBlendFunci\");\n    if(!_ptrc_glBlendFunci) numFailed++;\n    _ptrc_glDeleteTransformFeedbacks = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteTransformFeedbacks\");\n    if(!_ptrc_glDeleteTransformFeedbacks) numFailed++;\n    _ptrc_glDrawArraysIndirect = (void (CODEGEN_FUNCPTR *)(GLenum, const GLvoid *))IntGetProcAddress(\"glDrawArraysIndirect\");\n    if(!_ptrc_glDrawArraysIndirect) numFailed++;\n    _ptrc_glDrawElementsIndirect = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLvoid *))IntGetProcAddress(\"glDrawElementsIndirect\");\n    if(!_ptrc_glDrawElementsIndirect) numFailed++;\n    _ptrc_glDrawTransformFeedback = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glDrawTransformFeedback\");\n    if(!_ptrc_glDrawTransformFeedback) numFailed++;\n    _ptrc_glDrawTransformFeedbackStream = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint))IntGetProcAddress(\"glDrawTransformFeedbackStream\");\n    if(!_ptrc_glDrawTransformFeedbackStream) numFailed++;\n    _ptrc_glEndQueryIndexed = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glEndQueryIndexed\");\n    if(!_ptrc_glEndQueryIndexed) numFailed++;\n    _ptrc_glGenTransformFeedbacks = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenTransformFeedbacks\");\n    if(!_ptrc_glGenTransformFeedbacks) numFailed++;\n    _ptrc_glGetActiveSubroutineName = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetActiveSubroutineName\");\n    if(!_ptrc_glGetActiveSubroutineName) numFailed++;\n    _ptrc_glGetActiveSubroutineUniformName = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetActiveSubroutineUniformName\");\n    if(!_ptrc_glGetActiveSubroutineUniformName) numFailed++;\n    _ptrc_glGetActiveSubroutineUniformiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetActiveSubroutineUniformiv\");\n    if(!_ptrc_glGetActiveSubroutineUniformiv) numFailed++;\n    _ptrc_glGetProgramStageiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetProgramStageiv\");\n    if(!_ptrc_glGetProgramStageiv) numFailed++;\n    _ptrc_glGetQueryIndexediv = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetQueryIndexediv\");\n    if(!_ptrc_glGetQueryIndexediv) numFailed++;\n    _ptrc_glGetSubroutineIndex = (GLuint (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLchar *))IntGetProcAddress(\"glGetSubroutineIndex\");\n    if(!_ptrc_glGetSubroutineIndex) numFailed++;\n    _ptrc_glGetSubroutineUniformLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLchar *))IntGetProcAddress(\"glGetSubroutineUniformLocation\");\n    if(!_ptrc_glGetSubroutineUniformLocation) numFailed++;\n    _ptrc_glGetUniformSubroutineuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLuint *))IntGetProcAddress(\"glGetUniformSubroutineuiv\");\n    if(!_ptrc_glGetUniformSubroutineuiv) numFailed++;\n    _ptrc_glGetUniformdv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLdouble *))IntGetProcAddress(\"glGetUniformdv\");\n    if(!_ptrc_glGetUniformdv) numFailed++;\n    _ptrc_glIsTransformFeedback = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsTransformFeedback\");\n    if(!_ptrc_glIsTransformFeedback) numFailed++;\n    _ptrc_glMinSampleShading = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress(\"glMinSampleShading\");\n    if(!_ptrc_glMinSampleShading) numFailed++;\n    _ptrc_glPatchParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress(\"glPatchParameterfv\");\n    if(!_ptrc_glPatchParameterfv) numFailed++;\n    _ptrc_glPatchParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress(\"glPatchParameteri\");\n    if(!_ptrc_glPatchParameteri) numFailed++;\n    _ptrc_glPauseTransformFeedback = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glPauseTransformFeedback\");\n    if(!_ptrc_glPauseTransformFeedback) numFailed++;\n    _ptrc_glResumeTransformFeedback = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress(\"glResumeTransformFeedback\");\n    if(!_ptrc_glResumeTransformFeedback) numFailed++;\n    _ptrc_glUniform1d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble))IntGetProcAddress(\"glUniform1d\");\n    if(!_ptrc_glUniform1d) numFailed++;\n    _ptrc_glUniform1dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLdouble *))IntGetProcAddress(\"glUniform1dv\");\n    if(!_ptrc_glUniform1dv) numFailed++;\n    _ptrc_glUniform2d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble, GLdouble))IntGetProcAddress(\"glUniform2d\");\n    if(!_ptrc_glUniform2d) numFailed++;\n    _ptrc_glUniform2dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLdouble *))IntGetProcAddress(\"glUniform2dv\");\n    if(!_ptrc_glUniform2dv) numFailed++;\n    _ptrc_glUniform3d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble, GLdouble, GLdouble))IntGetProcAddress(\"glUniform3d\");\n    if(!_ptrc_glUniform3d) numFailed++;\n    _ptrc_glUniform3dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLdouble *))IntGetProcAddress(\"glUniform3dv\");\n    if(!_ptrc_glUniform3dv) numFailed++;\n    _ptrc_glUniform4d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress(\"glUniform4d\");\n    if(!_ptrc_glUniform4d) numFailed++;\n    _ptrc_glUniform4dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLdouble *))IntGetProcAddress(\"glUniform4dv\");\n    if(!_ptrc_glUniform4dv) numFailed++;\n    _ptrc_glUniformMatrix2dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix2dv\");\n    if(!_ptrc_glUniformMatrix2dv) numFailed++;\n    _ptrc_glUniformMatrix2x3dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix2x3dv\");\n    if(!_ptrc_glUniformMatrix2x3dv) numFailed++;\n    _ptrc_glUniformMatrix2x4dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix2x4dv\");\n    if(!_ptrc_glUniformMatrix2x4dv) numFailed++;\n    _ptrc_glUniformMatrix3dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix3dv\");\n    if(!_ptrc_glUniformMatrix3dv) numFailed++;\n    _ptrc_glUniformMatrix3x2dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix3x2dv\");\n    if(!_ptrc_glUniformMatrix3x2dv) numFailed++;\n    _ptrc_glUniformMatrix3x4dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix3x4dv\");\n    if(!_ptrc_glUniformMatrix3x4dv) numFailed++;\n    _ptrc_glUniformMatrix4dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix4dv\");\n    if(!_ptrc_glUniformMatrix4dv) numFailed++;\n    _ptrc_glUniformMatrix4x2dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix4x2dv\");\n    if(!_ptrc_glUniformMatrix4x2dv) numFailed++;\n    _ptrc_glUniformMatrix4x3dv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLdouble *))IntGetProcAddress(\"glUniformMatrix4x3dv\");\n    if(!_ptrc_glUniformMatrix4x3dv) numFailed++;\n    _ptrc_glUniformSubroutinesuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLuint *))IntGetProcAddress(\"glUniformSubroutinesuiv\");\n    if(!_ptrc_glUniformSubroutinesuiv) numFailed++;\n    return numFailed;\n}\n\ntypedef int (*PFN_LOADFUNCPOINTERS)();\ntypedef struct ogl_StrToExtMap_s\n{\n    char *extensionName;\n    int *extensionVariable;\n    PFN_LOADFUNCPOINTERS LoadExtension;\n} ogl_StrToExtMap;\n\nstatic ogl_StrToExtMap ExtensionMap[1] = {\n    {\"\", NULL, NULL},\n};\n\nstatic int g_extensionMapSize = 0;\n\nstatic ogl_StrToExtMap *FindExtEntry(const char *extensionName)\n{\n    int loop;\n    ogl_StrToExtMap *currLoc = ExtensionMap;\n    for(loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc)\n    {\n        if(strcmp(extensionName, currLoc->extensionName) == 0)\n            return currLoc;\n    }\n\n    return NULL;\n}\n\nstatic void ClearExtensionVars()\n{\n}\n\n\nstatic void LoadExtByName(const char *extensionName)\n{\n    ogl_StrToExtMap *entry = NULL;\n    entry = FindExtEntry(extensionName);\n    if(entry)\n    {\n        if(entry->LoadExtension)\n        {\n            int numFailed = entry->LoadExtension();\n            if(numFailed == 0)\n            {\n                *(entry->extensionVariable) = ogl_LOAD_SUCCEEDED;\n            }\n            else\n            {\n                *(entry->extensionVariable) = ogl_LOAD_SUCCEEDED + numFailed;\n            }\n        }\n        else\n        {\n            *(entry->extensionVariable) = ogl_LOAD_SUCCEEDED;\n        }\n    }\n}\n\n\nstatic void ProcExtsFromExtList()\n{\n    GLint iLoop;\n    GLint iNumExtensions = 0;\n    _ptrc_glGetIntegerv(GL_NUM_EXTENSIONS, &iNumExtensions);\n\n    for(iLoop = 0; iLoop < iNumExtensions; iLoop++)\n    {\n        const char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop);\n        LoadExtByName(strExtensionName);\n    }\n}\n\nint ogl_LoadFunctions()\n{\n    int numFailed = 0;\n    ClearExtensionVars();\n\n    _ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress(\"glGetIntegerv\");\n    if(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED;\n    _ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glGetStringi\");\n    if(!_ptrc_glGetStringi) return ogl_LOAD_FAILED;\n\n    ProcExtsFromExtList();\n    numFailed = Load_Version_4_0();\n\n    if(numFailed == 0)\n        return ogl_LOAD_SUCCEEDED;\n    else\n        return ogl_LOAD_SUCCEEDED + numFailed;\n}\n\nstatic int g_major_version = 0;\nstatic int g_minor_version = 0;\n\nstatic void GetGLVersion()\n{\n    glGetIntegerv(GL_MAJOR_VERSION, &g_major_version);\n    glGetIntegerv(GL_MINOR_VERSION, &g_minor_version);\n}\n\nint ogl_GetMajorVersion()\n{\n    if(g_major_version == 0)\n        GetGLVersion();\n    return g_major_version;\n}\n\nint ogl_GetMinorVersion()\n{\n    if(g_major_version == 0) //Yes, check the major version to get the minor one.\n        GetGLVersion();\n    return g_minor_version;\n}\n\nint ogl_IsVersionGEQ(int majorVersion, int minorVersion)\n{\n    if(g_major_version == 0)\n        GetGLVersion();\n\n    if(majorVersion > g_major_version) return 1;\n    if(majorVersion < g_major_version) return 0;\n    if(minorVersion >= g_minor_version) return 1;\n    return 0;\n}\n#endif //#define GL_CORE_4\n"
  },
  {
    "path": "include/externals/tinyexr/tinyexr.h",
    "content": "/*\nCopyright (c) 2014 - 2015, Syoyo Fujita\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the <organization> nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#ifndef __TINYEXR_H__\n#define __TINYEXR_H__\n\n//\n// \n//   Do this:\n//    #define TINYEXR_IMPLEMENTATION\n//   before you include this file in *one* C or C++ file to create the implementation.\n//\n//   // i.e. it should look like this:\n//   #include ...\n//   #include ...\n//   #include ...\n//   #define TINYEXR_IMPLEMENTATION\n//   #include \"tinyexr.h\"\n//\n//\n\n#include <stddef.h> // for size_t\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// pixel type: possible values are: UINT = 0 HALF = 1 FLOAT = 2\n#define TINYEXR_PIXELTYPE_UINT (0)\n#define TINYEXR_PIXELTYPE_HALF (1)\n#define TINYEXR_PIXELTYPE_FLOAT (2)\n\n#define TINYEXR_MAX_ATTRIBUTES  (128)\n\ntypedef struct _EXRAttribute {\n  char *name; \n  char *type;\n  int   size;\n  unsigned char *value; // uint8_t*\n} EXRAttribute;\n\ntypedef struct _EXRImage {\n  // Custom attributes(exludes required attributes(e.g. `channels`, `compression`, etc)\n  EXRAttribute custom_attributes[TINYEXR_MAX_ATTRIBUTES];\n  int num_custom_attributes;\n\n  int num_channels;\n  const char **channel_names;\n\n  unsigned char **images; // image[channels][pixels]\n  int *pixel_types; // Loaded pixel type(TINYEXR_PIXELTYPE_*) of `images` for\n                    // each channel\n\n  int *requested_pixel_types; // Filled initially by\n                              // ParseEXRHeaderFrom(Meomory|File), then users\n                              // can edit it(only valid for HALF pixel type\n                              // channel)\n\n  int width;\n  int height;\n  float pixel_aspect_ratio;\n  int line_order;\n  int data_window[4];\n  int display_window[4];\n  float screen_window_center[2];\n  float screen_window_width;\n} EXRImage;\n\ntypedef struct _DeepImage {\n  int num_channels;\n  const char **channel_names;\n  float ***image;     // image[channels][scanlines][samples]\n  int **offset_table; // offset_table[scanline][offsets]\n  int width;\n  int height;\n} DeepImage;\n\n// @deprecated { to be removed. }\n// Loads single-frame OpenEXR image. Assume EXR image contains RGB(A) channels.\n// Application must free image data as returned by `out_rgba`\n// Result image format is: float x RGBA x width x hight\n// Return 0 if success\n// Returns error string in `err` when there's an error\ninline int LoadEXR(float **out_rgba, int *width, int *height,\n                   const char *filename, const char **err);\n\n// Parse single-frame OpenEXR header from a file and initialize `EXRImage`\n// struct.\n// Users then call LoadMultiChannelEXRFromFile to actually load image data into\n// `EXRImage`\ninline int ParseMultiChannelEXRHeaderFromFile(EXRImage *image,\n                                              const char *filename,\n                                              const char **err);\n\n// Parse single-frame OpenEXR header from a memory and initialize `EXRImage`\n// struct.\n// Users then call LoadMultiChannelEXRFromMemory to actually load image data\n// into `EXRImage`\ninline int ParseMultiChannelEXRHeaderFromMemory(EXRImage *image,\n                                                const unsigned char *memory,\n                                                const char **err);\n\n// Loads multi-channel, single-frame OpenEXR image from a file.\n// Application must setup `ParseMultiChannelEXRHeaderFromFile` before calling\n// `LoadMultiChannelEXRFromFile`.\n// Application can free EXRImage using `FreeExrImage`\n// Return 0 if success\n// Returns error string in `err` when there's an error\ninline int LoadMultiChannelEXRFromFile(EXRImage *image, const char *filename,\n                                       const char **err);\n\n// Loads multi-channel, single-frame OpenEXR image from a memory.\n// Application must setup `EXRImage` with `ParseMultiChannelEXRHeaderFromMemory`\n// before calling `LoadMultiChannelEXRFromMemory`.\n// Application can free EXRImage using `FreeExrImage`\n// Return 0 if success\n// Returns error string in `err` when there's an error\ninline int LoadMultiChannelEXRFromMemory(EXRImage *image,\n                                         const unsigned char *memory,\n                                         const char **err);\n\n// Saves floating point RGBA image as OpenEXR.\n// Image is compressed with ZIP.\n// Return 0 if success\n// Returns error string in `err` when there's an error\n// extern int SaveEXR(const float *in_rgba, int width, int height,\n//                   const char *filename, const char **err);\n\n// Saves multi-channel, single-frame OpenEXR image to a file.\n// Application must free EXRImage\n// Returns 0 if success\n// Returns error string in `err` when there's an error\ninline int SaveMultiChannelEXRToFile(const EXRImage *image,\n                                     const char *filename, const char **err);\n\n// Saves multi-channel, single-frame OpenEXR image to a memory.\n// Application must free EXRImage\n// Return the number of bytes if succes.\n// Retruns 0 if success, negative number when failed.\n// Returns error string in `err` when there's an error\ninline size_t SaveMultiChannelEXRToMemory(const EXRImage *image,\n                                          unsigned char **memory,\n                                          const char **err);\n\n// Loads single-frame OpenEXR deep image.\n// Application must free memory of variables in DeepImage(image, offset_table)\n// Returns 0 if success\n// Returns error string in `err` when there's an error\ninline int LoadDeepEXR(DeepImage *out_image, const char *filename,\n                       const char **err);\n\n// NOT YET IMPLEMENTED:\n// Saves single-frame OpenEXR deep image.\n// Return 0 if success\n// Returns error string in `err` when there's an error\n// extern int SaveDeepEXR(const DeepImage *in_image, const char *filename,\n//                       const char **err);\n\n// NOT YET IMPLEMENTED:\n// Loads multi-part OpenEXR deep image.\n// Application must free memory of variables in DeepImage(image, offset_table)\n// extern int LoadMultiPartDeepEXR(DeepImage **out_image, int num_parts, const\n// char *filename,\n//                       const char **err);\n\n// Initialize of EXRImage struct\ninline void InitEXRImage(EXRImage *exrImage);\n\n// Free's internal data of EXRImage struct\n// Returns 0 if success.\ninline int FreeEXRImage(EXRImage *exrImage);\n\n// For emscripten.\n// Parse single-frame OpenEXR header from memory.\n// Return 0 if success\ninline int ParseEXRHeaderFromMemory(EXRAttribute* customAttributes, int *numCustomAttributes, int *width, int *height,\n                                    const unsigned char *memory);\n\n// For emscripten.\n// Loads single-frame OpenEXR image from memory. Assume EXR image contains\n// RGB(A) channels.\n// `out_rgba` must have enough memory(at least sizeof(float) x 4(RGBA) x width x\n// hight)\n// Return 0 if success\n// Returns error string in `err` when there's an error\ninline int LoadEXRFromMemory(float *out_rgba, const unsigned char *memory,\n                             const char **err);\n\n#ifdef __cplusplus\n}\n#endif\n\n#ifdef TINYEXR_IMPLEMENTATION\n#include <cstdio>\n#include <cstdlib>\n#include <cassert>\n#include <cstring>\n#include <algorithm>\n\n#include <string>\n#include <vector>\n\n#include \"tinyexr.h\"\n\n#ifdef _OPENMP\n#include <omp.h>\n#endif\n\nnamespace {\n//#define MINIZ_NO_ARCHIVE_APIS\n//#define MINIZ_NO_STDIO\nnamespace miniz {\n\n/* miniz.c v1.15 - public domain deflate/inflate, zlib-subset, ZIP\n   reading/writing/appending, PNG writing\n   See \"unlicense\" statement at the end of this file.\n   Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013\n   Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951:\n   http://www.ietf.org/rfc/rfc1951.txt\n\n   Most API's defined in miniz.c are optional. For example, to disable the\n   archive related functions just define\n   MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO\n   (see the list below for more macros).\n\n   * Change History\n     10/13/13 v1.15 r4 - Interim bugfix release while I work on the next major\n   release with Zip64 support (almost there!):\n       - Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug\n   (thanks kahmyong.moon@hp.com) which could cause locate files to not find\n   files. This bug\n        would only have occured in earlier versions if you explicitly used this\n   flag, OR if you used mz_zip_extract_archive_file_to_heap() or\n   mz_zip_add_mem_to_archive_file_in_place()\n        (which used this flag). If you can't switch to v1.15 but want to fix\n   this bug, just remove the uses of this flag from both helper funcs (and of\n   course don't use the flag).\n       - Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when\n   pUser_read_buf is not NULL and compressed size is > uncompressed size\n       - Fixing mz_zip_reader_extract_*() funcs so they don't try to extract\n   compressed data from directory entries, to account for weird zipfiles which\n   contain zero-size compressed data on dir entries.\n         Hopefully this fix won't cause any issues on weird zip archives,\n   because it assumes the low 16-bits of zip external attributes are DOS\n   attributes (which I believe they always are in practice).\n       - Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the\n   internal attributes, just the filename and external attributes\n       - mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed\n       - Added cmake support for Linux builds which builds all the examples,\n   tested with clang v3.3 and gcc v4.6.\n       - Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti\n       - Merged MZ_FORCEINLINE fix from hdeanclark\n       - Fix <time.h> include before config #ifdef, thanks emil.brink\n       - Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping\n   (super useful for OpenGL apps), and explicit control over the compression\n   level (so you can\n        set it to 1 for real-time compression).\n       - Merged in some compiler fixes from paulharris's github repro.\n       - Retested this build under Windows (VS 2010, including static analysis),\n   tcc  0.9.26, gcc v4.6 and clang v3.3.\n       - Added example6.c, which dumps an image of the mandelbrot set to a PNG\n   file.\n       - Modified example2 to help test the\n   MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more.\n       - In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix\n   possible src file fclose() leak if alignment bytes+local header file write\n   faiiled\n                 - In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader():\n   Was pushing the wrong central dir header offset, appears harmless in this\n   release, but it became a problem in the zip64 branch\n     5/20/12 v1.14 - MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE,\n   #include <time.h> (thanks fermtect).\n     5/19/12 v1.13 - From jason@cornsyrup.org and kelwert@mtu.edu - Fix\n   mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit.\n       - Temporarily/locally slammed in \"typedef unsigned long mz_ulong\" and\n   re-ran a randomized regression test on ~500k files.\n       - Eliminated a bunch of warnings when compiling with GCC 32-bit/64.\n       - Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze\n   (static analysis) option and fixed all warnings (except for the silly\n        \"Use of the comma-operator in a tested expression..\" analysis warning,\n   which I purposely use to work around a MSVC compiler warning).\n       - Created 32-bit and 64-bit Codeblocks projects/workspace. Built and\n   tested Linux executables. The codeblocks workspace is compatible with\n   Linux+Win32/x64.\n       - Added miniz_tester solution/project, which is a useful little app\n   derived from LZHAM's tester app that I use as part of the regression test.\n       - Ran miniz.c and tinfl.c through another series of regression testing on\n   ~500,000 files and archives.\n       - Modified example5.c so it purposely disables a bunch of high-level\n   functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the\n   MINIZ_NO_STDIO bug report.)\n       - Fix ftell() usage in examples so they exit with an error on files which\n   are too large (a limitation of the examples, not miniz itself).\n     4/12/12 v1.12 - More comments, added low-level example5.c, fixed a couple\n   minor level_and_flags issues in the archive API's.\n      level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce\n   Dawson <bruced@valvesoftware.com> for the feedback/bug report.\n     5/28/11 v1.11 - Added statement from unlicense.org\n     5/27/11 v1.10 - Substantial compressor optimizations:\n      - Level 1 is now ~4x faster than before. The L1 compressor's throughput\n   now varies between 70-110MB/sec. on a\n      - Core i7 (actual throughput varies depending on the type of data, and x64\n   vs. x86).\n      - Improved baseline L2-L9 compression perf. Also, greatly improved\n   compression perf. issues on some file types.\n      - Refactored the compression code for better readability and\n   maintainability.\n      - Added level 10 compression level (L10 has slightly better ratio than\n   level 9, but could have a potentially large\n       drop in throughput on some files).\n     5/15/11 v1.09 - Initial stable release.\n\n   * Low-level Deflate/Inflate implementation notes:\n\n     Compression: Use the \"tdefl\" API's. The compressor supports raw, static,\n   and dynamic blocks, lazy or\n     greedy parsing, match length filtering, RLE-only, and Huffman-only streams.\n   It performs and compresses\n     approximately as well as zlib.\n\n     Decompression: Use the \"tinfl\" API's. The entire decompressor is\n   implemented as a single function\n     coroutine: see tinfl_decompress(). It supports decompression into a 32KB\n   (or larger power of 2) wrapping buffer, or into a memory\n     block large enough to hold the entire file.\n\n     The low-level tdefl/tinfl API's do not make any use of dynamic memory\n   allocation.\n\n   * zlib-style API notes:\n\n     miniz.c implements a fairly large subset of zlib. There's enough\n   functionality present for it to be a drop-in\n     zlib replacement in many apps:\n        The z_stream struct, optional memory allocation callbacks\n        deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound\n        inflateInit/inflateInit2/inflate/inflateEnd\n        compress, compress2, compressBound, uncompress\n        CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly\n   routines.\n        Supports raw deflate streams or standard zlib streams with adler-32\n   checking.\n\n     Limitations:\n      The callback API's are not implemented yet. No support for gzip headers or\n   zlib static dictionaries.\n      I've tried to closely emulate zlib's various flavors of stream flushing\n   and return status codes, but\n      there are no guarantees that miniz.c pulls this off perfectly.\n\n   * PNG writing: See the tdefl_write_image_to_png_file_in_memory() function,\n   originally written by\n     Alex Evans. Supports 1-4 bytes/pixel images.\n\n   * ZIP archive API notes:\n\n     The ZIP archive API's where designed with simplicity and efficiency in\n   mind, with just enough abstraction to\n     get the job done with minimal fuss. There are simple API's to retrieve file\n   information, read files from\n     existing archives, create new archives, append new files to existing\n   archives, or clone archive data from\n     one archive to another. It supports archives located in memory or the heap,\n   on disk (using stdio.h),\n     or you can specify custom file read/write callbacks.\n\n     - Archive reading: Just call this function to read a single file from a\n   disk archive:\n\n      void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const\n   char *pArchive_name,\n        size_t *pSize, mz_uint zip_flags);\n\n     For more complex cases, use the \"mz_zip_reader\" functions. Upon opening an\n   archive, the entire central\n     directory is located and read as-is into memory, and subsequent file access\n   only occurs when reading individual files.\n\n     - Archives file scanning: The simple way is to use this function to scan a\n   loaded archive for a specific file:\n\n     int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName,\n   const char *pComment, mz_uint flags);\n\n     The locate operation can optionally check file comments too, which (as one\n   example) can be used to identify\n     multiple versions of the same file in an archive. This function uses a\n   simple linear search through the central\n     directory, so it's not very fast.\n\n     Alternately, you can iterate through all the files in an archive (using\n   mz_zip_reader_get_num_files()) and\n     retrieve detailed info on each file by calling mz_zip_reader_file_stat().\n\n     - Archive creation: Use the \"mz_zip_writer\" functions. The ZIP writer\n   immediately writes compressed file data\n     to disk and builds an exact image of the central directory in memory. The\n   central directory image is written\n     all at once at the end of the archive file when the archive is finalized.\n\n     The archive writer can optionally align each file's local header and file\n   data to any power of 2 alignment,\n     which can be useful when the archive will be read from optical media. Also,\n   the writer supports placing\n     arbitrary data blobs at the very beginning of ZIP archives. Archives\n   written using either feature are still\n     readable by any ZIP tool.\n\n     - Archive appending: The simple way to add a single file to an archive is\n   to call this function:\n\n      mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename,\n   const char *pArchive_name,\n        const void *pBuf, size_t buf_size, const void *pComment, mz_uint16\n   comment_size, mz_uint level_and_flags);\n\n     The archive will be created if it doesn't already exist, otherwise it'll be\n   appended to.\n     Note the appending is done in-place and is not an atomic operation, so if\n   something goes wrong\n     during the operation it's possible the archive could be left without a\n   central directory (although the local\n     file headers and file data will be fine, so the archive will be\n   recoverable).\n\n     For more complex archive modification scenarios:\n     1. The safest way is to use a mz_zip_reader to read the existing archive,\n   cloning only those bits you want to\n     preserve into a new archive using using the\n   mz_zip_writer_add_from_zip_reader() function (which compiles the\n     compressed file data as-is). When you're done, delete the old archive and\n   rename the newly written archive, and\n     you're done. This is safe but requires a bunch of temporary disk space or\n   heap memory.\n\n     2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using\n   mz_zip_writer_init_from_reader(),\n     append new files as needed, then finalize the archive which will write an\n   updated central directory to the\n     original archive. (This is basically what\n   mz_zip_add_mem_to_archive_file_in_place() does.) There's a\n     possibility that the archive's central directory could be lost with this\n   method if anything goes wrong, though.\n\n     - ZIP archive support limitations:\n     No zip64 or spanning support. Extraction functions can only handle\n   unencrypted, stored or deflated files.\n     Requires streams capable of seeking.\n\n   * This is a header file library, like stb_image.c. To get only a header file,\n   either cut and paste the\n     below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then\n   include miniz.c from it.\n\n   * Important: For best perf. be sure to customize the below macros for your\n   target platform:\n     #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1\n     #define MINIZ_LITTLE_ENDIAN 1\n     #define MINIZ_HAS_64BIT_REGISTERS 1\n\n   * On platforms using glibc, Be sure to \"#define _LARGEFILE64_SOURCE 1\" before\n   including miniz.c to ensure miniz\n     uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be\n   able to process large files\n     (i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes).\n*/\n\n#ifndef MINIZ_HEADER_INCLUDED\n#define MINIZ_HEADER_INCLUDED\n\n#include <stdlib.h>\n\n// Defines to completely disable specific portions of miniz.c:\n// If all macros here are defined the only functionality remaining will be\n// CRC-32, adler-32, tinfl, and tdefl.\n\n// Define MINIZ_NO_STDIO to disable all usage and any functions which rely on\n// stdio for file I/O.\n//#define MINIZ_NO_STDIO\n\n// If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able\n// to get the current time, or\n// get/set file times, and the C run-time funcs that get/set times won't be\n// called.\n// The current downside is the times written to your archives will be from 1979.\n//#define MINIZ_NO_TIME\n\n// Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's.\n//#define MINIZ_NO_ARCHIVE_APIS\n\n// Define MINIZ_NO_ARCHIVE_APIS to disable all writing related ZIP archive\n// API's.\n//#define MINIZ_NO_ARCHIVE_WRITING_APIS\n\n// Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression\n// API's.\n//#define MINIZ_NO_ZLIB_APIS\n\n// Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent\n// conflicts against stock zlib.\n//#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES\n\n// Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc.\n// Note if MINIZ_NO_MALLOC is defined then the user must always provide custom\n// user alloc/free/realloc\n// callbacks to the zlib and archive API's, and a few stand-alone helper API's\n// which don't provide custom user\n// functions (such as tdefl_compress_mem_to_heap() and\n// tinfl_decompress_mem_to_heap()) won't work.\n//#define MINIZ_NO_MALLOC\n\n#if defined(__TINYC__) && (defined(__linux) || defined(__linux__))\n// TODO: Work around \"error: include file 'sys\\utime.h' when compiling with tcc\n// on Linux\n#define MINIZ_NO_TIME\n#endif\n\n#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS)\n#include <time.h>\n#endif\n\n#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) ||                \\\n    defined(__i386) || defined(__i486__) || defined(__i486) ||                 \\\n    defined(i386) || defined(__ia64__) || defined(__x86_64__)\n// MINIZ_X86_OR_X64_CPU is only used to help set the below macros.\n#define MINIZ_X86_OR_X64_CPU 1\n#endif\n\n#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU\n// Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian.\n#define MINIZ_LITTLE_ENDIAN 1\n#endif\n\n#if MINIZ_X86_OR_X64_CPU\n// Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient\n// integer loads and stores from unaligned addresses.\n//#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1\n#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0 // disable to suppress compiler warnings\n#endif\n\n#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) ||              \\\n    defined(_LP64) || defined(__LP64__) || defined(__ia64__) ||                \\\n    defined(__x86_64__)\n// Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are\n// reasonably fast (and don't involve compiler generated calls to helper\n// functions).\n#define MINIZ_HAS_64BIT_REGISTERS 1\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// ------------------- zlib-style API Definitions.\n\n// For more compatibility with zlib, miniz.c uses unsigned long for some\n// parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits!\ntypedef unsigned long mz_ulong;\n\n// mz_free() internally uses the MZ_FREE() macro (which by default calls free()\n// unless you've modified the MZ_MALLOC macro) to release a block allocated from\n// the heap.\ninline void mz_free(void *p);\n\n#define MZ_ADLER32_INIT (1)\n// mz_adler32() returns the initial adler-32 value to use when called with\n// ptr==NULL.\ninline mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);\n\n#define MZ_CRC32_INIT (0)\n// mz_crc32() returns the initial CRC-32 value to use when called with\n// ptr==NULL.\ninline mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);\n\n// Compression strategies.\nenum {\n  MZ_DEFAULT_STRATEGY = 0,\n  MZ_FILTERED = 1,\n  MZ_HUFFMAN_ONLY = 2,\n  MZ_RLE = 3,\n  MZ_FIXED = 4\n};\n\n// Method\n#define MZ_DEFLATED 8\n\n#ifndef MINIZ_NO_ZLIB_APIS\n\n// Heap allocation callbacks.\n// Note that mz_alloc_func parameter types purpsosely differ from zlib's:\n// items/size is size_t, not unsigned long.\ntypedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size);\ntypedef void (*mz_free_func)(void *opaque, void *address);\ntypedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items,\n                                 size_t size);\n\n#define MZ_VERSION \"9.1.15\"\n#define MZ_VERNUM 0x91F0\n#define MZ_VER_MAJOR 9\n#define MZ_VER_MINOR 1\n#define MZ_VER_REVISION 15\n#define MZ_VER_SUBREVISION 0\n\n// Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The\n// other values are for advanced use (refer to the zlib docs).\nenum {\n  MZ_NO_FLUSH = 0,\n  MZ_PARTIAL_FLUSH = 1,\n  MZ_SYNC_FLUSH = 2,\n  MZ_FULL_FLUSH = 3,\n  MZ_FINISH = 4,\n  MZ_BLOCK = 5\n};\n\n// Return status codes. MZ_PARAM_ERROR is non-standard.\nenum {\n  MZ_OK = 0,\n  MZ_STREAM_END = 1,\n  MZ_NEED_DICT = 2,\n  MZ_ERRNO = -1,\n  MZ_STREAM_ERROR = -2,\n  MZ_DATA_ERROR = -3,\n  MZ_MEM_ERROR = -4,\n  MZ_BUF_ERROR = -5,\n  MZ_VERSION_ERROR = -6,\n  MZ_PARAM_ERROR = -10000\n};\n\n// Compression levels: 0-9 are the standard zlib-style levels, 10 is best\n// possible compression (not zlib compatible, and may be very slow),\n// MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL.\nenum {\n  MZ_NO_COMPRESSION = 0,\n  MZ_BEST_SPEED = 1,\n  MZ_BEST_COMPRESSION = 9,\n  MZ_UBER_COMPRESSION = 10,\n  MZ_DEFAULT_LEVEL = 6,\n  MZ_DEFAULT_COMPRESSION = -1\n};\n\n// Window bits\n#define MZ_DEFAULT_WINDOW_BITS 15\n\nstruct mz_internal_state;\n\n// Compression/decompression stream struct.\ntypedef struct mz_stream_s {\n  const unsigned char *next_in; // pointer to next byte to read\n  unsigned int avail_in;        // number of bytes available at next_in\n  mz_ulong total_in;            // total number of bytes consumed so far\n\n  unsigned char *next_out; // pointer to next byte to write\n  unsigned int avail_out;  // number of bytes that can be written to next_out\n  mz_ulong total_out;      // total number of bytes produced so far\n\n  char *msg;                       // error msg (unused)\n  struct mz_internal_state *state; // internal state, allocated by zalloc/zfree\n\n  mz_alloc_func\n      zalloc;         // optional heap allocation function (defaults to malloc)\n  mz_free_func zfree; // optional heap free function (defaults to free)\n  void *opaque;       // heap alloc function user pointer\n\n  int data_type;     // data_type (unused)\n  mz_ulong adler;    // adler32 of the source or uncompressed data\n  mz_ulong reserved; // not used\n} mz_stream;\n\ntypedef mz_stream *mz_streamp;\n\n// Returns the version string of miniz.c.\nconst char *mz_version(void);\n\n// mz_deflateInit() initializes a compressor with default options:\n// Parameters:\n//  pStream must point to an initialized mz_stream struct.\n//  level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION].\n//  level 1 enables a specially optimized compression function that's been\n//  optimized purely for performance, not ratio.\n//  (This special func. is currently only enabled when\n//  MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.)\n// Return values:\n//  MZ_OK on success.\n//  MZ_STREAM_ERROR if the stream is bogus.\n//  MZ_PARAM_ERROR if the input parameters are bogus.\n//  MZ_MEM_ERROR on out of memory.\nPIC_INLINE int mz_deflateInit(mz_streamp pStream, int level);\n\n// mz_deflateInit2() is like mz_deflate(), except with more control:\n// Additional parameters:\n//   method must be MZ_DEFLATED\n//   window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with\n//   zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no\n//   header or footer)\n//   mem_level must be between [1, 9] (it's checked but ignored by miniz.c)\nPIC_INLINE int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits,\n                    int mem_level, int strategy);\n\n// Quickly resets a compressor without having to reallocate anything. Same as\n// calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2().\nint mz_deflateReset(mz_streamp pStream);\n\n// mz_deflate() compresses the input to output, consuming as much of the input\n// and producing as much output as possible.\n// Parameters:\n//   pStream is the stream to read from and write to. You must initialize/update\n//   the next_in, avail_in, next_out, and avail_out members.\n//   flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or\n//   MZ_FINISH.\n// Return values:\n//   MZ_OK on success (when flushing, or if more input is needed but not\n//   available, and/or there's more output to be written but the output buffer\n//   is full).\n//   MZ_STREAM_END if all input has been consumed and all output bytes have been\n//   written. Don't call mz_deflate() on the stream anymore.\n//   MZ_STREAM_ERROR if the stream is bogus.\n//   MZ_PARAM_ERROR if one of the parameters is invalid.\n//   MZ_BUF_ERROR if no forward progress is possible because the input and/or\n//   output buffers are empty. (Fill up the input buffer or free up some output\n//   space and try again.)\nPIC_INLINE int mz_deflate(mz_streamp pStream, int flush);\n\n// mz_deflateEnd() deinitializes a compressor:\n// Return values:\n//  MZ_OK on success.\n//  MZ_STREAM_ERROR if the stream is bogus.\nint mz_deflateEnd(mz_streamp pStream);\n\n// mz_deflateBound() returns a (very) conservative upper bound on the amount of\n// data that could be generated by deflate(), assuming flush is set to only\n// MZ_NO_FLUSH or MZ_FINISH.\nmz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len);\n\n// Single-call compression functions mz_compress() and mz_compress2():\n// Returns MZ_OK on success, or one of the error codes from mz_deflate() on\n// failure.\nint mz_compress(unsigned char *pDest, mz_ulong *pDest_len,\n                const unsigned char *pSource, mz_ulong source_len);\nint mz_compress2(unsigned char *pDest, mz_ulong *pDest_len,\n                 const unsigned char *pSource, mz_ulong source_len, int level);\n\n// mz_compressBound() returns a (very) conservative upper bound on the amount of\n// data that could be generated by calling mz_compress().\nmz_ulong mz_compressBound(mz_ulong source_len);\n\n// Initializes a decompressor.\nint mz_inflateInit(mz_streamp pStream);\n\n// mz_inflateInit2() is like mz_inflateInit() with an additional option that\n// controls the window size and whether or not the stream has been wrapped with\n// a zlib header/footer:\n// window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or\n// -MZ_DEFAULT_WINDOW_BITS (raw deflate).\nint mz_inflateInit2(mz_streamp pStream, int window_bits);\n\n// Decompresses the input stream to the output, consuming only as much of the\n// input as needed, and writing as much to the output as possible.\n// Parameters:\n//   pStream is the stream to read from and write to. You must initialize/update\n//   the next_in, avail_in, next_out, and avail_out members.\n//   flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH.\n//   On the first call, if flush is MZ_FINISH it's assumed the input and output\n//   buffers are both sized large enough to decompress the entire stream in a\n//   single call (this is slightly faster).\n//   MZ_FINISH implies that there are no more source bytes available beside\n//   what's already in the input buffer, and that the output buffer is large\n//   enough to hold the rest of the decompressed data.\n// Return values:\n//   MZ_OK on success. Either more input is needed but not available, and/or\n//   there's more output to be written but the output buffer is full.\n//   MZ_STREAM_END if all needed input has been consumed and all output bytes\n//   have been written. For zlib streams, the adler-32 of the decompressed data\n//   has also been verified.\n//   MZ_STREAM_ERROR if the stream is bogus.\n//   MZ_DATA_ERROR if the deflate stream is invalid.\n//   MZ_PARAM_ERROR if one of the parameters is invalid.\n//   MZ_BUF_ERROR if no forward progress is possible because the input buffer is\n//   empty but the inflater needs more input to continue, or if the output\n//   buffer is not large enough. Call mz_inflate() again\n//   with more input data, or with more room in the output buffer (except when\n//   using single call decompression, described above).\nint mz_inflate(mz_streamp pStream, int flush);\n\n// Deinitializes a decompressor.\nint mz_inflateEnd(mz_streamp pStream);\n\n// Single-call decompression.\n// Returns MZ_OK on success, or one of the error codes from mz_inflate() on\n// failure.\nint mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len,\n                  const unsigned char *pSource, mz_ulong source_len);\n\n// Returns a string description of the specified error code, or NULL if the\n// error code is invalid.\nconst char *mz_error(int err);\n\n// Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used\n// as a drop-in replacement for the subset of zlib that miniz.c supports.\n// Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you\n// use zlib in the same project.\n#ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES\ntypedef unsigned char Byte;\ntypedef unsigned int uInt;\ntypedef mz_ulong uLong;\ntypedef Byte Bytef;\ntypedef uInt uIntf;\ntypedef char charf;\ntypedef int intf;\ntypedef void *voidpf;\ntypedef uLong uLongf;\ntypedef void *voidp;\ntypedef void *const voidpc;\n#define Z_NULL 0\n#define Z_NO_FLUSH MZ_NO_FLUSH\n#define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH\n#define Z_SYNC_FLUSH MZ_SYNC_FLUSH\n#define Z_FULL_FLUSH MZ_FULL_FLUSH\n#define Z_FINISH MZ_FINISH\n#define Z_BLOCK MZ_BLOCK\n#define Z_OK MZ_OK\n#define Z_STREAM_END MZ_STREAM_END\n#define Z_NEED_DICT MZ_NEED_DICT\n#define Z_ERRNO MZ_ERRNO\n#define Z_STREAM_ERROR MZ_STREAM_ERROR\n#define Z_DATA_ERROR MZ_DATA_ERROR\n#define Z_MEM_ERROR MZ_MEM_ERROR\n#define Z_BUF_ERROR MZ_BUF_ERROR\n#define Z_VERSION_ERROR MZ_VERSION_ERROR\n#define Z_PARAM_ERROR MZ_PARAM_ERROR\n#define Z_NO_COMPRESSION MZ_NO_COMPRESSION\n#define Z_BEST_SPEED MZ_BEST_SPEED\n#define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION\n#define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION\n#define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY\n#define Z_FILTERED MZ_FILTERED\n#define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY\n#define Z_RLE MZ_RLE\n#define Z_FIXED MZ_FIXED\n#define Z_DEFLATED MZ_DEFLATED\n#define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS\n#define alloc_func mz_alloc_func\n#define free_func mz_free_func\n#define internal_state mz_internal_state\n#define z_stream mz_stream\n#define deflateInit mz_deflateInit\n#define deflateInit2 mz_deflateInit2\n#define deflateReset mz_deflateReset\n#define deflate mz_deflate\n#define deflateEnd mz_deflateEnd\n#define deflateBound mz_deflateBound\n#define compress mz_compress\n#define compress2 mz_compress2\n#define compressBound mz_compressBound\n#define inflateInit mz_inflateInit\n#define inflateInit2 mz_inflateInit2\n#define inflate mz_inflate\n#define inflateEnd mz_inflateEnd\n#define uncompress mz_uncompress\n#define crc32 mz_crc32\n#define adler32 mz_adler32\n#define MAX_WBITS 15\n#define MAX_MEM_LEVEL 9\n#define zError mz_error\n#define ZLIB_VERSION MZ_VERSION\n#define ZLIB_VERNUM MZ_VERNUM\n#define ZLIB_VER_MAJOR MZ_VER_MAJOR\n#define ZLIB_VER_MINOR MZ_VER_MINOR\n#define ZLIB_VER_REVISION MZ_VER_REVISION\n#define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION\n#define zlibVersion mz_version\n#define zlib_version mz_version()\n#endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES\n\n#endif // MINIZ_NO_ZLIB_APIS\n\n// ------------------- Types and macros\n\ntypedef unsigned char mz_uint8;\ntypedef signed short mz_int16;\ntypedef unsigned short mz_uint16;\ntypedef unsigned int mz_uint32;\ntypedef unsigned int mz_uint;\ntypedef long long mz_int64;\ntypedef unsigned long long mz_uint64;\ntypedef int mz_bool;\n\n#define MZ_FALSE (0)\n#define MZ_TRUE (1)\n\n// An attempt to work around MSVC's spammy \"warning C4127: conditional\n// expression is constant\" message.\n#ifdef _MSC_VER\n#define MZ_MACRO_END while (0, 0)\n#else\n#define MZ_MACRO_END while (0)\n#endif\n\n// ------------------- ZIP archive reading/writing\n\n#ifndef MINIZ_NO_ARCHIVE_APIS\n\nenum {\n  MZ_ZIP_MAX_IO_BUF_SIZE = 64 * 1024,\n  MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 260,\n  MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 256\n};\n\ntypedef struct {\n  mz_uint32 m_file_index;\n  mz_uint32 m_central_dir_ofs;\n  mz_uint16 m_version_made_by;\n  mz_uint16 m_version_needed;\n  mz_uint16 m_bit_flag;\n  mz_uint16 m_method;\n#ifndef MINIZ_NO_TIME\n  time_t m_time;\n#endif\n  mz_uint32 m_crc32;\n  mz_uint64 m_comp_size;\n  mz_uint64 m_uncomp_size;\n  mz_uint16 m_internal_attr;\n  mz_uint32 m_external_attr;\n  mz_uint64 m_local_header_ofs;\n  mz_uint32 m_comment_size;\n  char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE];\n  char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE];\n} mz_zip_archive_file_stat;\n\ntypedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs,\n                                    void *pBuf, size_t n);\ntypedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs,\n                                     const void *pBuf, size_t n);\n\nstruct mz_zip_internal_state_tag;\ntypedef struct mz_zip_internal_state_tag mz_zip_internal_state;\n\ntypedef enum {\n  MZ_ZIP_MODE_INVALID = 0,\n  MZ_ZIP_MODE_READING = 1,\n  MZ_ZIP_MODE_WRITING = 2,\n  MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3\n} mz_zip_mode;\n\ntypedef struct mz_zip_archive_tag {\n  mz_uint64 m_archive_size;\n  mz_uint64 m_central_directory_file_ofs;\n  mz_uint m_total_files;\n  mz_zip_mode m_zip_mode;\n\n  mz_uint m_file_offset_alignment;\n\n  mz_alloc_func m_pAlloc;\n  mz_free_func m_pFree;\n  mz_realloc_func m_pRealloc;\n  void *m_pAlloc_opaque;\n\n  mz_file_read_func m_pRead;\n  mz_file_write_func m_pWrite;\n  void *m_pIO_opaque;\n\n  mz_zip_internal_state *m_pState;\n\n} mz_zip_archive;\n\ntypedef enum {\n  MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100,\n  MZ_ZIP_FLAG_IGNORE_PATH = 0x0200,\n  MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400,\n  MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800\n} mz_zip_flags;\n\n// ZIP archive reading\n\n// Inits a ZIP archive reader.\n// These functions read and validate the archive's central directory.\ninline mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size,\n                           mz_uint32 flags);\ninline mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem,\n                               size_t size, mz_uint32 flags);\n\n#ifndef MINIZ_NO_STDIO\ninline mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename,\n                                mz_uint32 flags);\n#endif\n\n// Returns the total number of files in the archive.\ninline mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip);\n\n// Returns detailed information about an archive file entry.\ninline mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index,\n                                mz_zip_archive_file_stat *pStat);\n\n// Determines if an archive file entry is a directory entry.\ninline mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip,\n                                          mz_uint file_index);\ninline mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip,\n                                        mz_uint file_index);\n\n// Retrieves the filename of an archive file entry.\n// Returns the number of bytes written to pFilename, or if filename_buf_size is\n// 0 this function returns the number of bytes needed to fully store the\n// filename.\ninline mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index,\n                                   char *pFilename, mz_uint filename_buf_size);\n\n// Attempts to locates a file in the archive's central directory.\n// Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH\n// Returns -1 if the file cannot be found.\ninline int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName,\n                              const char *pComment, mz_uint flags);\n\n// Extracts a archive file to a memory buffer using no memory allocation.\ninline mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip,\n                                              mz_uint file_index, void *pBuf,\n                                              size_t buf_size, mz_uint flags,\n                                              void *pUser_read_buf,\n                                              size_t user_read_buf_size);\ninline mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(\n    mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size,\n    mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);\n\n// Extracts a archive file to a memory buffer.\ninline mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index,\n                                     void *pBuf, size_t buf_size,\n                                     mz_uint flags);\ninline mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip,\n                                          const char *pFilename, void *pBuf,\n                                          size_t buf_size, mz_uint flags);\n\n// Extracts a archive file to a dynamically allocated heap buffer.\ninline void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index,\n                                    size_t *pSize, mz_uint flags);\ninline void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip,\n                                         const char *pFilename, size_t *pSize,\n                                         mz_uint flags);\n\n// Extracts a archive file using a callback function to output the file's data.\ninline mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip,\n                                          mz_uint file_index,\n                                          mz_file_write_func pCallback,\n                                          void *pOpaque, mz_uint flags);\ninline mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip,\n                                               const char *pFilename,\n                                               mz_file_write_func pCallback,\n                                               void *pOpaque, mz_uint flags);\n\n#ifndef MINIZ_NO_STDIO\n// Extracts a archive file to a disk file and sets its last accessed and\n// modified times.\n// This function only extracts files, not archive directory records.\ninline mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index,\n                                      const char *pDst_filename, mz_uint flags);\ninline mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip,\n                                           const char *pArchive_filename,\n                                           const char *pDst_filename,\n                                           mz_uint flags);\n#endif\n\n// Ends archive reading, freeing all allocations, and closing the input archive\n// file if mz_zip_reader_init_file() was used.\ninline mz_bool mz_zip_reader_end(mz_zip_archive *pZip);\n\n// ZIP archive writing\n\n#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS\n\n// Inits a ZIP archive writer.\ninline mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size);\ninline mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip,\n                                size_t size_to_reserve_at_beginning,\n                                size_t initial_allocation_size);\n\n#ifndef MINIZ_NO_STDIO\ninline mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename,\n                                mz_uint64 size_to_reserve_at_beginning);\n#endif\n\n// Converts a ZIP archive reader object into a writer object, to allow efficient\n// in-place file appends to occur on an existing archive.\n// For archives opened using mz_zip_reader_init_file, pFilename must be the\n// archive's filename so it can be reopened for writing. If the file can't be\n// reopened, mz_zip_reader_end() will be called.\n// For archives opened using mz_zip_reader_init_mem, the memory block must be\n// growable using the realloc callback (which defaults to realloc unless you've\n// overridden it).\n// Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's\n// user provided m_pWrite function cannot be NULL.\n// Note: In-place archive modification is not recommended unless you know what\n// you're doing, because if execution stops or something goes wrong before\n// the archive is finalized the file's central directory will be hosed.\ninline mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip,\n                                       const char *pFilename);\n\n// Adds the contents of a memory buffer to an archive. These functions record\n// the current local time into the archive.\n// To add a directory entry, call this method with an archive name ending in a\n// forwardslash with empty buffer.\n// level_and_flags - compression level (0-10, see MZ_BEST_SPEED,\n// MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or\n// just set to MZ_DEFAULT_COMPRESSION.\ninline mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name,\n                              const void *pBuf, size_t buf_size,\n                              mz_uint level_and_flags);\ninline mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip,\n                                 const char *pArchive_name, const void *pBuf,\n                                 size_t buf_size, const void *pComment,\n                                 mz_uint16 comment_size,\n                                 mz_uint level_and_flags, mz_uint64 uncomp_size,\n                                 mz_uint32 uncomp_crc32);\n\n#ifndef MINIZ_NO_STDIO\n// Adds the contents of a disk file to an archive. This function also records\n// the disk file's modified time into the archive.\n// level_and_flags - compression level (0-10, see MZ_BEST_SPEED,\n// MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or\n// just set to MZ_DEFAULT_COMPRESSION.\ninline mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name,\n                               const char *pSrc_filename, const void *pComment,\n                               mz_uint16 comment_size, mz_uint level_and_flags);\n#endif\n\n// Adds a file to an archive by fully cloning the data from another archive.\n// This function fully clones the source file's compressed data (no\n// recompression), along with its full filename, extra data, and comment fields.\ninline mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip,\n                                          mz_zip_archive *pSource_zip,\n                                          mz_uint file_index);\n\n// Finalizes the archive by writing the central directory records followed by\n// the end of central directory record.\n// After an archive is finalized, the only valid call on the mz_zip_archive\n// struct is mz_zip_writer_end().\n// An archive must be manually finalized by calling this function for it to be\n// valid.\ninline mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip);\ninline mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf,\n                                            size_t *pSize);\n\n// Ends archive writing, freeing all allocations, and closing the output file if\n// mz_zip_writer_init_file() was used.\n// Note for the archive to be valid, it must have been finalized before ending.\ninline mz_bool mz_zip_writer_end(mz_zip_archive *pZip);\n\n// Misc. high-level helper functions:\n\n// mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically)\n// appends a memory blob to a ZIP archive.\n// level_and_flags - compression level (0-10, see MZ_BEST_SPEED,\n// MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or\n// just set to MZ_DEFAULT_COMPRESSION.\ninline mz_bool mz_zip_add_mem_to_archive_file_in_place(\n    const char *pZip_filename, const char *pArchive_name, const void *pBuf,\n    size_t buf_size, const void *pComment, mz_uint16 comment_size,\n    mz_uint level_and_flags);\n\n// Reads a single file from an archive into a heap block.\n// Returns NULL on failure.\ninline void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename,\n                                          const char *pArchive_name,\n                                          size_t *pSize, mz_uint zip_flags);\n\n#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS\n\n#endif // #ifndef MINIZ_NO_ARCHIVE_APIS\n\n// ------------------- Low-level Decompression API Definitions\n\n// Decompression flags used by tinfl_decompress().\n// TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and\n// ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the\n// input is a raw deflate stream.\n// TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available\n// beyond the end of the supplied input buffer. If clear, the input buffer\n// contains all remaining input.\n// TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large\n// enough to hold the entire decompressed stream. If clear, the output buffer is\n// at least the size of the dictionary (typically 32KB).\n// TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the\n// decompressed bytes.\nenum {\n  TINFL_FLAG_PARSE_ZLIB_HEADER = 1,\n  TINFL_FLAG_HAS_MORE_INPUT = 2,\n  TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4,\n  TINFL_FLAG_COMPUTE_ADLER32 = 8\n};\n\n// High level decompression functions:\n// tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block\n// allocated via malloc().\n// On entry:\n//  pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data\n//  to decompress.\n// On return:\n//  Function returns a pointer to the decompressed data, or NULL on failure.\n//  *pOut_len will be set to the decompressed data's size, which could be larger\n//  than src_buf_len on uncompressible data.\n//  The caller must call mz_free() on the returned block when it's no longer\n//  needed.\ninline void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len,\n                                   size_t *pOut_len, int flags);\n\n// tinfl_decompress_mem_to_mem() decompresses a block in memory to another block\n// in memory.\n// Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes\n// written on success.\n#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1))\ninline size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len,\n                                   const void *pSrc_buf, size_t src_buf_len,\n                                   int flags);\n\n// tinfl_decompress_mem_to_callback() decompresses a block in memory to an\n// internal 32KB buffer, and a user provided callback function will be called to\n// flush the buffer.\n// Returns 1 on success or 0 on failure.\ntypedef int (*tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);\ninline int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size,\n                                     tinfl_put_buf_func_ptr pPut_buf_func,\n                                     void *pPut_buf_user, int flags);\n\nstruct tinfl_decompressor_tag;\ntypedef struct tinfl_decompressor_tag tinfl_decompressor;\n\n// Max size of LZ dictionary.\n#define TINFL_LZ_DICT_SIZE 32768\n\n// Return status.\ntypedef enum {\n  TINFL_STATUS_BAD_PARAM = -3,\n  TINFL_STATUS_ADLER32_MISMATCH = -2,\n  TINFL_STATUS_FAILED = -1,\n  TINFL_STATUS_DONE = 0,\n  TINFL_STATUS_NEEDS_MORE_INPUT = 1,\n  TINFL_STATUS_HAS_MORE_OUTPUT = 2\n} tinfl_status;\n\n// Initializes the decompressor to its initial state.\n#define tinfl_init(r)                                                          \\\n  do {                                                                         \\\n    (r)->m_state = 0;                                                          \\\n  }                                                                            \\\n  MZ_MACRO_END\n#define tinfl_get_adler32(r) (r)->m_check_adler32\n\n// Main low-level decompressor coroutine function. This is the only function\n// actually needed for decompression. All the other functions are just\n// high-level helpers for improved usability.\n// This is a universal API, i.e. it can be used as a building block to build any\n// desired higher level decompression API. In the limit case, it can be called\n// once per every byte input or output.\ntinfl_status tinfl_decompress(tinfl_decompressor *r,\n                              const mz_uint8 *pIn_buf_next,\n                              size_t *pIn_buf_size, mz_uint8 *pOut_buf_start,\n                              mz_uint8 *pOut_buf_next, size_t *pOut_buf_size,\n                              const mz_uint32 decomp_flags);\n\n// Internal/private bits follow.\nenum {\n  TINFL_MAX_HUFF_TABLES = 3,\n  TINFL_MAX_HUFF_SYMBOLS_0 = 288,\n  TINFL_MAX_HUFF_SYMBOLS_1 = 32,\n  TINFL_MAX_HUFF_SYMBOLS_2 = 19,\n  TINFL_FAST_LOOKUP_BITS = 10,\n  TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS\n};\n\ntypedef struct {\n  mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0];\n  mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE],\n      m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2];\n} tinfl_huff_table;\n\n#if MINIZ_HAS_64BIT_REGISTERS\n#define TINFL_USE_64BIT_BITBUF 1\n#endif\n\n#if TINFL_USE_64BIT_BITBUF\ntypedef mz_uint64 tinfl_bit_buf_t;\n#define TINFL_BITBUF_SIZE (64)\n#else\ntypedef mz_uint32 tinfl_bit_buf_t;\n#define TINFL_BITBUF_SIZE (32)\n#endif\n\nstruct tinfl_decompressor_tag {\n  mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type,\n      m_check_adler32, m_dist, m_counter, m_num_extra,\n      m_table_sizes[TINFL_MAX_HUFF_TABLES];\n  tinfl_bit_buf_t m_bit_buf;\n  size_t m_dist_from_out_buf_start;\n  tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES];\n  mz_uint8 m_raw_header[4],\n      m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137];\n};\n\n// ------------------- Low-level Compression API Definitions\n\n// Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly\n// slower, and raw/dynamic blocks will be output more frequently).\n#define TDEFL_LESS_MEMORY 0\n\n// tdefl_init() compression flags logically OR'd together (low 12 bits contain\n// the max. number of probes per dictionary search):\n// TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes\n// per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap\n// compression), 4095=Huffman+LZ (slowest/best compression).\nenum {\n  TDEFL_HUFFMAN_ONLY = 0,\n  TDEFL_DEFAULT_MAX_PROBES = 128,\n  TDEFL_MAX_PROBES_MASK = 0xFFF\n};\n\n// TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before\n// the deflate data, and the Adler-32 of the source data at the end. Otherwise,\n// you'll get raw deflate data.\n// TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even\n// when not writing zlib headers).\n// TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more\n// efficient lazy parsing.\n// TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's\n// initialization time to the minimum, but the output may vary from run to run\n// given the same input (depending on the contents of memory).\n// TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1)\n// TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled.\n// TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables.\n// TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks.\n// The low 12 bits are reserved to control the max # of hash probes per\n// dictionary lookup (see TDEFL_MAX_PROBES_MASK).\nenum {\n  TDEFL_WRITE_ZLIB_HEADER = 0x01000,\n  TDEFL_COMPUTE_ADLER32 = 0x02000,\n  TDEFL_GREEDY_PARSING_FLAG = 0x04000,\n  TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000,\n  TDEFL_RLE_MATCHES = 0x10000,\n  TDEFL_FILTER_MATCHES = 0x20000,\n  TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000,\n  TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000\n};\n\n// High level compression functions:\n// tdefl_compress_mem_to_heap() compresses a block in memory to a heap block\n// allocated via malloc().\n// On entry:\n//  pSrc_buf, src_buf_len: Pointer and size of source block to compress.\n//  flags: The max match finder probes (default is 128) logically OR'd against\n//  the above flags. Higher probes are slower but improve compression.\n// On return:\n//  Function returns a pointer to the compressed data, or NULL on failure.\n//  *pOut_len will be set to the compressed data's size, which could be larger\n//  than src_buf_len on uncompressible data.\n//  The caller must free() the returned block when it's no longer needed.\nvoid *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len,\n                                 size_t *pOut_len, int flags);\n\n// tdefl_compress_mem_to_mem() compresses a block in memory to another block in\n// memory.\n// Returns 0 on failure.\nsize_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len,\n                                 const void *pSrc_buf, size_t src_buf_len,\n                                 int flags);\n\n// Compresses an image to a compressed PNG file in memory.\n// On entry:\n//  pImage, w, h, and num_chans describe the image to compress. num_chans may be\n//  1, 2, 3, or 4.\n//  The image pitch in bytes per scanline will be w*num_chans. The leftmost\n//  pixel on the top scanline is stored first in memory.\n//  level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED,\n//  MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL\n//  If flip is true, the image will be flipped on the Y axis (useful for OpenGL\n//  apps).\n// On return:\n//  Function returns a pointer to the compressed data, or NULL on failure.\n//  *pLen_out will be set to the size of the PNG image file.\n//  The caller must mz_free() the returned heap block (which will typically be\n//  larger than *pLen_out) when it's no longer needed.\nvoid *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w,\n                                                 int h, int num_chans,\n                                                 size_t *pLen_out,\n                                                 mz_uint level, mz_bool flip);\nvoid *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h,\n                                              int num_chans, size_t *pLen_out);\n\n// Output stream interface. The compressor uses this interface to write\n// compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time.\ntypedef mz_bool (*tdefl_put_buf_func_ptr)(const void *pBuf, int len,\n                                          void *pUser);\n\n// tdefl_compress_mem_to_output() compresses a block to an output stream. The\n// above helpers use this function internally.\nmz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len,\n                                     tdefl_put_buf_func_ptr pPut_buf_func,\n                                     void *pPut_buf_user, int flags);\n\nenum {\n  TDEFL_MAX_HUFF_TABLES = 3,\n  TDEFL_MAX_HUFF_SYMBOLS_0 = 288,\n  TDEFL_MAX_HUFF_SYMBOLS_1 = 32,\n  TDEFL_MAX_HUFF_SYMBOLS_2 = 19,\n  TDEFL_LZ_DICT_SIZE = 32768,\n  TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1,\n  TDEFL_MIN_MATCH_LEN = 3,\n  TDEFL_MAX_MATCH_LEN = 258\n};\n\n// TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed\n// output block (using static/fixed Huffman codes).\n#if TDEFL_LESS_MEMORY\nenum {\n  TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024,\n  TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10,\n  TDEFL_MAX_HUFF_SYMBOLS = 288,\n  TDEFL_LZ_HASH_BITS = 12,\n  TDEFL_LEVEL1_HASH_SIZE_MASK = 4095,\n  TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3,\n  TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS\n};\n#else\nenum {\n  TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024,\n  TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10,\n  TDEFL_MAX_HUFF_SYMBOLS = 288,\n  TDEFL_LZ_HASH_BITS = 15,\n  TDEFL_LEVEL1_HASH_SIZE_MASK = 4095,\n  TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3,\n  TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS\n};\n#endif\n\n// The low-level tdefl functions below may be used directly if the above helper\n// functions aren't flexible enough. The low-level functions don't make any heap\n// allocations, unlike the above helper functions.\ntypedef enum {\n  TDEFL_STATUS_BAD_PARAM = -2,\n  TDEFL_STATUS_PUT_BUF_FAILED = -1,\n  TDEFL_STATUS_OKAY = 0,\n  TDEFL_STATUS_DONE = 1,\n} tdefl_status;\n\n// Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums\ntypedef enum {\n  TDEFL_NO_FLUSH = 0,\n  TDEFL_SYNC_FLUSH = 2,\n  TDEFL_FULL_FLUSH = 3,\n  TDEFL_FINISH = 4\n} tdefl_flush;\n\n// tdefl's compression state structure.\ntypedef struct {\n  tdefl_put_buf_func_ptr m_pPut_buf_func;\n  void *m_pPut_buf_user;\n  mz_uint m_flags, m_max_probes[2];\n  int m_greedy_parsing;\n  mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size;\n  mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end;\n  mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in,\n      m_bit_buffer;\n  mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit,\n      m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index,\n      m_wants_to_finish;\n  tdefl_status m_prev_return_status;\n  const void *m_pIn_buf;\n  void *m_pOut_buf;\n  size_t *m_pIn_buf_size, *m_pOut_buf_size;\n  tdefl_flush m_flush;\n  const mz_uint8 *m_pSrc;\n  size_t m_src_buf_left, m_out_buf_ofs;\n  mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1];\n  mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];\n  mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];\n  mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];\n  mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE];\n  mz_uint16 m_next[TDEFL_LZ_DICT_SIZE];\n  mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE];\n  mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE];\n} tdefl_compressor;\n\n// Initializes the compressor.\n// There is no corresponding deinit() function because the tdefl API's do not\n// dynamically allocate memory.\n// pBut_buf_func: If NULL, output data will be supplied to the specified\n// callback. In this case, the user should call the tdefl_compress_buffer() API\n// for compression.\n// If pBut_buf_func is NULL the user should always call the tdefl_compress()\n// API.\n// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER,\n// etc.)\ninline tdefl_status tdefl_init(tdefl_compressor *d,\n                        tdefl_put_buf_func_ptr pPut_buf_func,\n                        void *pPut_buf_user, int flags);\n\n// Compresses a block of data, consuming as much of the specified input buffer\n// as possible, and writing as much compressed data to the specified output\n// buffer as possible.\ninline tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf,\n                            size_t *pIn_buf_size, void *pOut_buf,\n                            size_t *pOut_buf_size, tdefl_flush flush);\n\n// tdefl_compress_buffer() is only usable when the tdefl_init() is called with a\n// non-NULL tdefl_put_buf_func_ptr.\n// tdefl_compress_buffer() always consumes the entire input buffer.\ninline tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf,\n                                   size_t in_buf_size, tdefl_flush flush);\n\ninline tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d);\nPIC_INLINE  mz_uint32 tdefl_get_adler32(tdefl_compressor *d);\n\n// Can't use tdefl_create_comp_flags_from_zip_params if MINIZ_NO_ZLIB_APIS isn't\n// defined, because it uses some of its macros.\n#ifndef MINIZ_NO_ZLIB_APIS\n// Create tdefl_compress() flags given zlib-style compression parameters.\n// level may range from [0,10] (where 10 is absolute max compression, but may be\n// much slower on some files)\n// window_bits may be -15 (raw deflate) or 15 (zlib)\n// strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY,\n// MZ_RLE, or MZ_FIXED\nmz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits,\n                                                int strategy);\n#endif // #ifndef MINIZ_NO_ZLIB_APIS\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif // MINIZ_HEADER_INCLUDED\n\n// ------------------- End of Header: Implementation follows. (If you only want\n// the header, define MINIZ_HEADER_FILE_ONLY.)\n\n#ifndef MINIZ_HEADER_FILE_ONLY\n\ntypedef unsigned char mz_validate_uint16[sizeof(mz_uint16) == 2 ? 1 : -1];\ntypedef unsigned char mz_validate_uint32[sizeof(mz_uint32) == 4 ? 1 : -1];\ntypedef unsigned char mz_validate_uint64[sizeof(mz_uint64) == 8 ? 1 : -1];\n\n#include <string.h>\n#include <assert.h>\n\n#define MZ_ASSERT(x) assert(x)\n\n#ifdef MINIZ_NO_MALLOC\n#define MZ_MALLOC(x) NULL\n#define MZ_FREE(x) (void) x, ((void)0)\n#define MZ_REALLOC(p, x) NULL\n#else\n#define MZ_MALLOC(x) malloc(x)\n#define MZ_FREE(x) free(x)\n#define MZ_REALLOC(p, x) realloc(p, x)\n#endif\n\n#define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b))\n#define MZ_MIN(a, b) (((a) < (b)) ? (a) : (b))\n#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj))\n\n#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN\n#define MZ_READ_LE16(p) *((const mz_uint16 *)(p))\n#define MZ_READ_LE32(p) *((const mz_uint32 *)(p))\n#else\n#define MZ_READ_LE16(p)                                                        \\\n  ((mz_uint32)(((const mz_uint8 *)(p))[0]) |                                   \\\n   ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U))\n#define MZ_READ_LE32(p)                                                        \\\n  ((mz_uint32)(((const mz_uint8 *)(p))[0]) |                                   \\\n   ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) |                           \\\n   ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) |                          \\\n   ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U))\n#endif\n\n#ifdef _MSC_VER\n#define MZ_FORCEINLINE __forceinline\n#elif defined(__GNUC__)\n#define MZ_FORCEINLINE inline __attribute__((__always_inline__))\n#else\n#define MZ_FORCEINLINE inline\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// ------------------- zlib-style API's\n\nmz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) {\n  mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16);\n  size_t block_len = buf_len % 5552;\n  if (!ptr)\n    return MZ_ADLER32_INIT;\n  while (buf_len) {\n    for (i = 0; i + 7 < block_len; i += 8, ptr += 8) {\n      s1 += ptr[0], s2 += s1;\n      s1 += ptr[1], s2 += s1;\n      s1 += ptr[2], s2 += s1;\n      s1 += ptr[3], s2 += s1;\n      s1 += ptr[4], s2 += s1;\n      s1 += ptr[5], s2 += s1;\n      s1 += ptr[6], s2 += s1;\n      s1 += ptr[7], s2 += s1;\n    }\n    for (; i < block_len; ++i)\n      s1 += *ptr++, s2 += s1;\n    s1 %= 65521U, s2 %= 65521U;\n    buf_len -= block_len;\n    block_len = 5552;\n  }\n  return (s2 << 16) + s1;\n}\n\n// Karl Malbrain's compact CRC-32. See \"A compact CCITT crc16 and crc32 C\n// implementation that balances processor cache usage against speed\":\n// http://www.geocities.com/malbrain/\nmz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) {\n  static const mz_uint32 s_crc32[16] = {\n      0,          0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4,\n      0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,\n      0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c};\n  mz_uint32 crcu32 = (mz_uint32)crc;\n  if (!ptr)\n    return MZ_CRC32_INIT;\n  crcu32 = ~crcu32;\n  while (buf_len--) {\n    mz_uint8 b = *ptr++;\n    crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)];\n    crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)];\n  }\n  return ~crcu32;\n}\n\nvoid mz_free(void *p) { MZ_FREE(p); }\n\n#ifndef MINIZ_NO_ZLIB_APIS\n\nstatic void *def_alloc_func(void *opaque, size_t items, size_t size) {\n  (void)opaque, (void)items, (void)size;\n  return MZ_MALLOC(items * size);\n}\nstatic void def_free_func(void *opaque, void *address) {\n  (void)opaque, (void)address;\n  MZ_FREE(address);\n}\nstatic void *def_realloc_func(void *opaque, void *address, size_t items,\n                              size_t size) {\n  (void)opaque, (void)address, (void)items, (void)size;\n  return MZ_REALLOC(address, items * size);\n}\n\ninline const char *mz_version(void) { return MZ_VERSION; }\n\ninline int mz_deflateInit(mz_streamp pStream, int level) {\n  return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9,\n                         MZ_DEFAULT_STRATEGY);\n}\n\ninline int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits,\n                    int mem_level, int strategy) {\n  tdefl_compressor *pComp;\n  mz_uint comp_flags =\n      TDEFL_COMPUTE_ADLER32 |\n      tdefl_create_comp_flags_from_zip_params(level, window_bits, strategy);\n\n  if (!pStream)\n    return MZ_STREAM_ERROR;\n  if ((method != MZ_DEFLATED) || ((mem_level < 1) || (mem_level > 9)) ||\n      ((window_bits != MZ_DEFAULT_WINDOW_BITS) &&\n       (-window_bits != MZ_DEFAULT_WINDOW_BITS)))\n    return MZ_PARAM_ERROR;\n\n  pStream->data_type = 0;\n  pStream->adler = MZ_ADLER32_INIT;\n  pStream->msg = NULL;\n  pStream->reserved = 0;\n  pStream->total_in = 0;\n  pStream->total_out = 0;\n  if (!pStream->zalloc)\n    pStream->zalloc = def_alloc_func;\n  if (!pStream->zfree)\n    pStream->zfree = def_free_func;\n\n  pComp = (tdefl_compressor *)pStream->zalloc(pStream->opaque, 1,\n                                              sizeof(tdefl_compressor));\n  if (!pComp)\n    return MZ_MEM_ERROR;\n\n  pStream->state = (struct mz_internal_state *)pComp;\n\n  if (tdefl_init(pComp, NULL, NULL, comp_flags) != TDEFL_STATUS_OKAY) {\n    mz_deflateEnd(pStream);\n    return MZ_PARAM_ERROR;\n  }\n\n  return MZ_OK;\n}\n\ninline int mz_deflateReset(mz_streamp pStream) {\n  if ((!pStream) || (!pStream->state) || (!pStream->zalloc) ||\n      (!pStream->zfree))\n    return MZ_STREAM_ERROR;\n  pStream->total_in = pStream->total_out = 0;\n  tdefl_init((tdefl_compressor *)pStream->state, NULL, NULL,\n             ((tdefl_compressor *)pStream->state)->m_flags);\n  return MZ_OK;\n}\n\ninline int mz_deflate(mz_streamp pStream, int flush) {\n  size_t in_bytes, out_bytes;\n  mz_ulong orig_total_in, orig_total_out;\n  int mz_status = MZ_OK;\n\n  if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) ||\n      (!pStream->next_out))\n    return MZ_STREAM_ERROR;\n  if (!pStream->avail_out)\n    return MZ_BUF_ERROR;\n\n  if (flush == MZ_PARTIAL_FLUSH)\n    flush = MZ_SYNC_FLUSH;\n\n  if (((tdefl_compressor *)pStream->state)->m_prev_return_status ==\n      TDEFL_STATUS_DONE)\n    return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR;\n\n  orig_total_in = pStream->total_in;\n  orig_total_out = pStream->total_out;\n  for (;;) {\n    tdefl_status defl_status;\n    in_bytes = pStream->avail_in;\n    out_bytes = pStream->avail_out;\n\n    defl_status = tdefl_compress((tdefl_compressor *)pStream->state,\n                                 pStream->next_in, &in_bytes, pStream->next_out,\n                                 &out_bytes, (tdefl_flush)flush);\n    pStream->next_in += (mz_uint)in_bytes;\n    pStream->avail_in -= (mz_uint)in_bytes;\n    pStream->total_in += (mz_uint)in_bytes;\n    pStream->adler = tdefl_get_adler32((tdefl_compressor *)pStream->state);\n\n    pStream->next_out += (mz_uint)out_bytes;\n    pStream->avail_out -= (mz_uint)out_bytes;\n    pStream->total_out += (mz_uint)out_bytes;\n\n    if (defl_status < 0) {\n      mz_status = MZ_STREAM_ERROR;\n      break;\n    } else if (defl_status == TDEFL_STATUS_DONE) {\n      mz_status = MZ_STREAM_END;\n      break;\n    } else if (!pStream->avail_out)\n      break;\n    else if ((!pStream->avail_in) && (flush != MZ_FINISH)) {\n      if ((flush) || (pStream->total_in != orig_total_in) ||\n          (pStream->total_out != orig_total_out))\n        break;\n      return MZ_BUF_ERROR; // Can't make forward progress without some input.\n    }\n  }\n  return mz_status;\n}\n\ninline int mz_deflateEnd(mz_streamp pStream) {\n  if (!pStream)\n    return MZ_STREAM_ERROR;\n  if (pStream->state) {\n    pStream->zfree(pStream->opaque, pStream->state);\n    pStream->state = NULL;\n  }\n  return MZ_OK;\n}\n\ninline mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len) {\n  (void)pStream;\n  // This is really over conservative. (And lame, but it's actually pretty\n  // tricky to compute a true upper bound given the way tdefl's blocking works.)\n  return MZ_MAX(128 + (source_len * 110) / 100,\n                128 + source_len + ((source_len / (31 * 1024)) + 1) * 5);\n}\n\ninline int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len,\n                 const unsigned char *pSource, mz_ulong source_len, int level) {\n  int status;\n  mz_stream stream;\n  memset(&stream, 0, sizeof(stream));\n\n  // In case mz_ulong is 64-bits (argh I hate longs).\n  if ((source_len | *pDest_len) > 0xFFFFFFFFU)\n    return MZ_PARAM_ERROR;\n\n  stream.next_in = pSource;\n  stream.avail_in = (mz_uint32)source_len;\n  stream.next_out = pDest;\n  stream.avail_out = (mz_uint32)*pDest_len;\n\n  status = mz_deflateInit(&stream, level);\n  if (status != MZ_OK)\n    return status;\n\n  status = mz_deflate(&stream, MZ_FINISH);\n  if (status != MZ_STREAM_END) {\n    mz_deflateEnd(&stream);\n    return (status == MZ_OK) ? MZ_BUF_ERROR : status;\n  }\n\n  *pDest_len = stream.total_out;\n  return mz_deflateEnd(&stream);\n}\n\ninline int mz_compress(unsigned char *pDest, mz_ulong *pDest_len,\n                const unsigned char *pSource, mz_ulong source_len) {\n  return mz_compress2(pDest, pDest_len, pSource, source_len,\n                      MZ_DEFAULT_COMPRESSION);\n}\n\ninline mz_ulong mz_compressBound(mz_ulong source_len) {\n  return mz_deflateBound(NULL, source_len);\n}\n\ntypedef struct {\n  tinfl_decompressor m_decomp;\n  mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed;\n  int m_window_bits;\n  mz_uint8 m_dict[TINFL_LZ_DICT_SIZE];\n  tinfl_status m_last_status;\n} inflate_state;\n\ninline int mz_inflateInit2(mz_streamp pStream, int window_bits) {\n  inflate_state *pDecomp;\n  if (!pStream)\n    return MZ_STREAM_ERROR;\n  if ((window_bits != MZ_DEFAULT_WINDOW_BITS) &&\n      (-window_bits != MZ_DEFAULT_WINDOW_BITS))\n    return MZ_PARAM_ERROR;\n\n  pStream->data_type = 0;\n  pStream->adler = 0;\n  pStream->msg = NULL;\n  pStream->total_in = 0;\n  pStream->total_out = 0;\n  pStream->reserved = 0;\n  if (!pStream->zalloc)\n    pStream->zalloc = def_alloc_func;\n  if (!pStream->zfree)\n    pStream->zfree = def_free_func;\n\n  pDecomp = (inflate_state *)pStream->zalloc(pStream->opaque, 1,\n                                             sizeof(inflate_state));\n  if (!pDecomp)\n    return MZ_MEM_ERROR;\n\n  pStream->state = (struct mz_internal_state *)pDecomp;\n\n  tinfl_init(&pDecomp->m_decomp);\n  pDecomp->m_dict_ofs = 0;\n  pDecomp->m_dict_avail = 0;\n  pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT;\n  pDecomp->m_first_call = 1;\n  pDecomp->m_has_flushed = 0;\n  pDecomp->m_window_bits = window_bits;\n\n  return MZ_OK;\n}\n\ninline int mz_inflateInit(mz_streamp pStream) {\n  return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS);\n}\n\ninline int mz_inflate(mz_streamp pStream, int flush) {\n  inflate_state *pState;\n  mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32;\n  size_t in_bytes, out_bytes, orig_avail_in;\n  tinfl_status status;\n\n  if ((!pStream) || (!pStream->state))\n    return MZ_STREAM_ERROR;\n  if (flush == MZ_PARTIAL_FLUSH)\n    flush = MZ_SYNC_FLUSH;\n  if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH))\n    return MZ_STREAM_ERROR;\n\n  pState = (inflate_state *)pStream->state;\n  if (pState->m_window_bits > 0)\n    decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER;\n  orig_avail_in = pStream->avail_in;\n\n  first_call = pState->m_first_call;\n  pState->m_first_call = 0;\n  if (pState->m_last_status < 0)\n    return MZ_DATA_ERROR;\n\n  if (pState->m_has_flushed && (flush != MZ_FINISH))\n    return MZ_STREAM_ERROR;\n  pState->m_has_flushed |= (flush == MZ_FINISH);\n\n  if ((flush == MZ_FINISH) && (first_call)) {\n    // MZ_FINISH on the first call implies that the input and output buffers are\n    // large enough to hold the entire compressed/decompressed file.\n    decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF;\n    in_bytes = pStream->avail_in;\n    out_bytes = pStream->avail_out;\n    status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes,\n                              pStream->next_out, pStream->next_out, &out_bytes,\n                              decomp_flags);\n    pState->m_last_status = status;\n    pStream->next_in += (mz_uint)in_bytes;\n    pStream->avail_in -= (mz_uint)in_bytes;\n    pStream->total_in += (mz_uint)in_bytes;\n    pStream->adler = tinfl_get_adler32(&pState->m_decomp);\n    pStream->next_out += (mz_uint)out_bytes;\n    pStream->avail_out -= (mz_uint)out_bytes;\n    pStream->total_out += (mz_uint)out_bytes;\n\n    if (status < 0)\n      return MZ_DATA_ERROR;\n    else if (status != TINFL_STATUS_DONE) {\n      pState->m_last_status = TINFL_STATUS_FAILED;\n      return MZ_BUF_ERROR;\n    }\n    return MZ_STREAM_END;\n  }\n  // flush != MZ_FINISH then we must assume there's more input.\n  if (flush != MZ_FINISH)\n    decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT;\n\n  if (pState->m_dict_avail) {\n    n = MZ_MIN(pState->m_dict_avail, pStream->avail_out);\n    memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);\n    pStream->next_out += n;\n    pStream->avail_out -= n;\n    pStream->total_out += n;\n    pState->m_dict_avail -= n;\n    pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1);\n    return ((pState->m_last_status == TINFL_STATUS_DONE) &&\n            (!pState->m_dict_avail))\n               ? MZ_STREAM_END\n               : MZ_OK;\n  }\n\n  for (;;) {\n    in_bytes = pStream->avail_in;\n    out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs;\n\n    status = tinfl_decompress(\n        &pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict,\n        pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags);\n    pState->m_last_status = status;\n\n    pStream->next_in += (mz_uint)in_bytes;\n    pStream->avail_in -= (mz_uint)in_bytes;\n    pStream->total_in += (mz_uint)in_bytes;\n    pStream->adler = tinfl_get_adler32(&pState->m_decomp);\n\n    pState->m_dict_avail = (mz_uint)out_bytes;\n\n    n = MZ_MIN(pState->m_dict_avail, pStream->avail_out);\n    memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);\n    pStream->next_out += n;\n    pStream->avail_out -= n;\n    pStream->total_out += n;\n    pState->m_dict_avail -= n;\n    pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1);\n\n    if (status < 0)\n      return MZ_DATA_ERROR; // Stream is corrupted (there could be some\n                            // uncompressed data left in the output dictionary -\n                            // oh well).\n    else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in))\n      return MZ_BUF_ERROR; // Signal caller that we can't make forward progress\n                           // without supplying more input or by setting flush\n                           // to MZ_FINISH.\n    else if (flush == MZ_FINISH) {\n      // The output buffer MUST be large to hold the remaining uncompressed data\n      // when flush==MZ_FINISH.\n      if (status == TINFL_STATUS_DONE)\n        return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END;\n      // status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's\n      // at least 1 more byte on the way. If there's no more room left in the\n      // output buffer then something is wrong.\n      else if (!pStream->avail_out)\n        return MZ_BUF_ERROR;\n    } else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) ||\n               (!pStream->avail_out) || (pState->m_dict_avail))\n      break;\n  }\n\n  return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail))\n             ? MZ_STREAM_END\n             : MZ_OK;\n}\n\ninline int mz_inflateEnd(mz_streamp pStream) {\n  if (!pStream)\n    return MZ_STREAM_ERROR;\n  if (pStream->state) {\n    pStream->zfree(pStream->opaque, pStream->state);\n    pStream->state = NULL;\n  }\n  return MZ_OK;\n}\n\ninline int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len,\n                  const unsigned char *pSource, mz_ulong source_len) {\n  mz_stream stream;\n  int status;\n  memset(&stream, 0, sizeof(stream));\n\n  // In case mz_ulong is 64-bits (argh I hate longs).\n  if ((source_len | *pDest_len) > 0xFFFFFFFFU)\n    return MZ_PARAM_ERROR;\n\n  stream.next_in = pSource;\n  stream.avail_in = (mz_uint32)source_len;\n  stream.next_out = pDest;\n  stream.avail_out = (mz_uint32)*pDest_len;\n\n  status = mz_inflateInit(&stream);\n  if (status != MZ_OK)\n    return status;\n\n  status = mz_inflate(&stream, MZ_FINISH);\n  if (status != MZ_STREAM_END) {\n    mz_inflateEnd(&stream);\n    return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR\n                                                            : status;\n  }\n  *pDest_len = stream.total_out;\n\n  return mz_inflateEnd(&stream);\n}\n\ninline const char *mz_error(int err) {\n  static struct {\n    int m_err;\n    const char *m_pDesc;\n  } s_error_descs[] = {{MZ_OK, \"\"},\n                       {MZ_STREAM_END, \"stream end\"},\n                       {MZ_NEED_DICT, \"need dictionary\"},\n                       {MZ_ERRNO, \"file error\"},\n                       {MZ_STREAM_ERROR, \"stream error\"},\n                       {MZ_DATA_ERROR, \"data error\"},\n                       {MZ_MEM_ERROR, \"out of memory\"},\n                       {MZ_BUF_ERROR, \"buf error\"},\n                       {MZ_VERSION_ERROR, \"version error\"},\n                       {MZ_PARAM_ERROR, \"parameter error\"}};\n  mz_uint i;\n  for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i)\n    if (s_error_descs[i].m_err == err)\n      return s_error_descs[i].m_pDesc;\n  return NULL;\n}\n\n#endif // MINIZ_NO_ZLIB_APIS\n\n// ------------------- Low-level Decompression (completely independent from all\n// compression API's)\n\n#define TINFL_MEMCPY(d, s, l) memcpy(d, s, l)\n#define TINFL_MEMSET(p, c, l) memset(p, c, l)\n\n#define TINFL_CR_BEGIN                                                         \\\n  switch (r->m_state) {                                                        \\\n  case 0:\n#define TINFL_CR_RETURN(state_index, result)                                   \\\n  do {                                                                         \\\n    status = result;                                                           \\\n    r->m_state = state_index;                                                  \\\n    goto common_exit;                                                          \\\n  case state_index:                                                            \\\n    ;                                                                          \\\n  }                                                                            \\\n  MZ_MACRO_END\n#define TINFL_CR_RETURN_FOREVER(state_index, result)                           \\\n  do {                                                                         \\\n    for (;;) {                                                                 \\\n      TINFL_CR_RETURN(state_index, result);                                    \\\n    }                                                                          \\\n  }                                                                            \\\n  MZ_MACRO_END\n#define TINFL_CR_FINISH }\n\n// TODO: If the caller has indicated that there's no more input, and we attempt\n// to read beyond the input buf, then something is wrong with the input because\n// the inflator never\n// reads ahead more than it needs to. Currently TINFL_GET_BYTE() pads the end of\n// the stream with 0's in this scenario.\n#define TINFL_GET_BYTE(state_index, c)                                         \\\n  do {                                                                         \\\n    if (pIn_buf_cur >= pIn_buf_end) {                                          \\\n      for (;;) {                                                               \\\n        if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) {                        \\\n          TINFL_CR_RETURN(state_index, TINFL_STATUS_NEEDS_MORE_INPUT);         \\\n          if (pIn_buf_cur < pIn_buf_end) {                                     \\\n            c = *pIn_buf_cur++;                                                \\\n            break;                                                             \\\n          }                                                                    \\\n        } else {                                                               \\\n          c = 0;                                                               \\\n          break;                                                               \\\n        }                                                                      \\\n      }                                                                        \\\n    } else                                                                     \\\n      c = *pIn_buf_cur++;                                                      \\\n  }                                                                            \\\n  MZ_MACRO_END\n\n#define TINFL_NEED_BITS(state_index, n)                                        \\\n  do {                                                                         \\\n    mz_uint c;                                                                 \\\n    TINFL_GET_BYTE(state_index, c);                                            \\\n    bit_buf |= (((tinfl_bit_buf_t)c) << num_bits);                             \\\n    num_bits += 8;                                                             \\\n  } while (num_bits < (mz_uint)(n))\n#define TINFL_SKIP_BITS(state_index, n)                                        \\\n  do {                                                                         \\\n    if (num_bits < (mz_uint)(n)) {                                             \\\n      TINFL_NEED_BITS(state_index, n);                                         \\\n    }                                                                          \\\n    bit_buf >>= (n);                                                           \\\n    num_bits -= (n);                                                           \\\n  }                                                                            \\\n  MZ_MACRO_END\n#define TINFL_GET_BITS(state_index, b, n)                                      \\\n  do {                                                                         \\\n    if (num_bits < (mz_uint)(n)) {                                             \\\n      TINFL_NEED_BITS(state_index, n);                                         \\\n    }                                                                          \\\n    b = bit_buf & ((1 << (n)) - 1);                                            \\\n    bit_buf >>= (n);                                                           \\\n    num_bits -= (n);                                                           \\\n  }                                                                            \\\n  MZ_MACRO_END\n\n// TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes\n// remaining in the input buffer falls below 2.\n// It reads just enough bytes from the input stream that are needed to decode\n// the next Huffman code (and absolutely no more). It works by trying to fully\n// decode a\n// Huffman code by using whatever bits are currently present in the bit buffer.\n// If this fails, it reads another byte, and tries again until it succeeds or\n// until the\n// bit buffer contains >=15 bits (deflate's max. Huffman code size).\n#define TINFL_HUFF_BITBUF_FILL(state_index, pHuff)                             \\\n  do {                                                                         \\\n    temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)];         \\\n    if (temp >= 0) {                                                           \\\n      code_len = temp >> 9;                                                    \\\n      if ((code_len) && (num_bits >= code_len))                                \\\n        break;                                                                 \\\n    } else if (num_bits > TINFL_FAST_LOOKUP_BITS) {                            \\\n      code_len = TINFL_FAST_LOOKUP_BITS;                                       \\\n      do {                                                                     \\\n        temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)];         \\\n      } while ((temp < 0) && (num_bits >= (code_len + 1)));                    \\\n      if (temp >= 0)                                                           \\\n        break;                                                                 \\\n    }                                                                          \\\n    TINFL_GET_BYTE(state_index, c);                                            \\\n    bit_buf |= (((tinfl_bit_buf_t)c) << num_bits);                             \\\n    num_bits += 8;                                                             \\\n  } while (num_bits < 15);\n\n// TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex\n// than you would initially expect because the zlib API expects the decompressor\n// to never read\n// beyond the final byte of the deflate stream. (In other words, when this macro\n// wants to read another byte from the input, it REALLY needs another byte in\n// order to fully\n// decode the next Huffman code.) Handling this properly is particularly\n// important on raw deflate (non-zlib) streams, which aren't followed by a byte\n// aligned adler-32.\n// The slow path is only executed at the very end of the input buffer.\n#define TINFL_HUFF_DECODE(state_index, sym, pHuff)                             \\\n  do {                                                                         \\\n    int temp;                                                                  \\\n    mz_uint code_len, c;                                                       \\\n    if (num_bits < 15) {                                                       \\\n      if ((pIn_buf_end - pIn_buf_cur) < 2) {                                   \\\n        TINFL_HUFF_BITBUF_FILL(state_index, pHuff);                            \\\n      } else {                                                                 \\\n        bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) |           \\\n                   (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8));      \\\n        pIn_buf_cur += 2;                                                      \\\n        num_bits += 16;                                                        \\\n      }                                                                        \\\n    }                                                                          \\\n    if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= \\\n        0)                                                                     \\\n      code_len = temp >> 9, temp &= 511;                                       \\\n    else {                                                                     \\\n      code_len = TINFL_FAST_LOOKUP_BITS;                                       \\\n      do {                                                                     \\\n        temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)];         \\\n      } while (temp < 0);                                                      \\\n    }                                                                          \\\n    sym = temp;                                                                \\\n    bit_buf >>= code_len;                                                      \\\n    num_bits -= code_len;                                                      \\\n  }                                                                            \\\n  MZ_MACRO_END\n\ninline tinfl_status tinfl_decompress(tinfl_decompressor *r,\n                              const mz_uint8 *pIn_buf_next,\n                              size_t *pIn_buf_size, mz_uint8 *pOut_buf_start,\n                              mz_uint8 *pOut_buf_next, size_t *pOut_buf_size,\n                              const mz_uint32 decomp_flags) {\n  static const int s_length_base[31] = {\n      3,  4,  5,  6,  7,  8,  9,  10,  11,  13,  15,  17,  19,  23, 27, 31,\n      35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0,  0};\n  static const int s_length_extra[31] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,\n                                         1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,\n                                         4, 4, 5, 5, 5, 5, 0, 0, 0};\n  static const int s_dist_base[32] = {\n      1,    2,    3,    4,    5,    7,     9,     13,    17,  25,   33,\n      49,   65,   97,   129,  193,  257,   385,   513,   769, 1025, 1537,\n      2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0,   0};\n  static const int s_dist_extra[32] = {0, 0, 0,  0,  1,  1,  2,  2,  3,  3,\n                                       4, 4, 5,  5,  6,  6,  7,  7,  8,  8,\n                                       9, 9, 10, 10, 11, 11, 12, 12, 13, 13};\n  static const mz_uint8 s_length_dezigzag[19] = {\n      16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n  static const int s_min_table_sizes[3] = {257, 1, 4};\n\n  tinfl_status status = TINFL_STATUS_FAILED;\n  mz_uint32 num_bits, dist, counter, num_extra;\n  tinfl_bit_buf_t bit_buf;\n  const mz_uint8 *pIn_buf_cur = pIn_buf_next,\n                 *const pIn_buf_end = pIn_buf_next + *pIn_buf_size;\n  mz_uint8 *pOut_buf_cur = pOut_buf_next,\n           *const pOut_buf_end = pOut_buf_next + *pOut_buf_size;\n  size_t out_buf_size_mask =\n             (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)\n                 ? (size_t)-1\n                 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1,\n         dist_from_out_buf_start;\n\n  // Ensure the output buffer's size is a power of 2, unless the output buffer\n  // is large enough to hold the entire output file (in which case it doesn't\n  // matter).\n  if (((out_buf_size_mask + 1) & out_buf_size_mask) ||\n      (pOut_buf_next < pOut_buf_start)) {\n    *pIn_buf_size = *pOut_buf_size = 0;\n    return TINFL_STATUS_BAD_PARAM;\n  }\n\n  num_bits = r->m_num_bits;\n  bit_buf = r->m_bit_buf;\n  dist = r->m_dist;\n  counter = r->m_counter;\n  num_extra = r->m_num_extra;\n  dist_from_out_buf_start = r->m_dist_from_out_buf_start;\n  TINFL_CR_BEGIN\n\n  bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0;\n  r->m_z_adler32 = r->m_check_adler32 = 1;\n  if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) {\n    TINFL_GET_BYTE(1, r->m_zhdr0);\n    TINFL_GET_BYTE(2, r->m_zhdr1);\n    counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) ||\n               (r->m_zhdr1 & 32) || ((r->m_zhdr0 & 15) != 8));\n    if (!(decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))\n      counter |= (((1U << (8U + (r->m_zhdr0 >> 4))) > 32768U) ||\n                  ((out_buf_size_mask + 1) <\n                   (size_t)(1U << (8U + (r->m_zhdr0 >> 4)))));\n    if (counter) {\n      TINFL_CR_RETURN_FOREVER(36, TINFL_STATUS_FAILED);\n    }\n  }\n\n  do {\n    TINFL_GET_BITS(3, r->m_final, 3);\n    r->m_type = r->m_final >> 1;\n    if (r->m_type == 0) {\n      TINFL_SKIP_BITS(5, num_bits & 7);\n      for (counter = 0; counter < 4; ++counter) {\n        if (num_bits)\n          TINFL_GET_BITS(6, r->m_raw_header[counter], 8);\n        else\n          TINFL_GET_BYTE(7, r->m_raw_header[counter]);\n      }\n      if ((counter = (r->m_raw_header[0] | (r->m_raw_header[1] << 8))) !=\n          (mz_uint)(0xFFFF ^\n                    (r->m_raw_header[2] | (r->m_raw_header[3] << 8)))) {\n        TINFL_CR_RETURN_FOREVER(39, TINFL_STATUS_FAILED);\n      }\n      while ((counter) && (num_bits)) {\n        TINFL_GET_BITS(51, dist, 8);\n        while (pOut_buf_cur >= pOut_buf_end) {\n          TINFL_CR_RETURN(52, TINFL_STATUS_HAS_MORE_OUTPUT);\n        }\n        *pOut_buf_cur++ = (mz_uint8)dist;\n        counter--;\n      }\n      while (counter) {\n        size_t n;\n        while (pOut_buf_cur >= pOut_buf_end) {\n          TINFL_CR_RETURN(9, TINFL_STATUS_HAS_MORE_OUTPUT);\n        }\n        while (pIn_buf_cur >= pIn_buf_end) {\n          if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) {\n            TINFL_CR_RETURN(38, TINFL_STATUS_NEEDS_MORE_INPUT);\n          } else {\n            TINFL_CR_RETURN_FOREVER(40, TINFL_STATUS_FAILED);\n          }\n        }\n        n = MZ_MIN(MZ_MIN((size_t)(pOut_buf_end - pOut_buf_cur),\n                          (size_t)(pIn_buf_end - pIn_buf_cur)),\n                   counter);\n        TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n);\n        pIn_buf_cur += n;\n        pOut_buf_cur += n;\n        counter -= (mz_uint)n;\n      }\n    } else if (r->m_type == 3) {\n      TINFL_CR_RETURN_FOREVER(10, TINFL_STATUS_FAILED);\n    } else {\n      if (r->m_type == 1) {\n        mz_uint8 *p = r->m_tables[0].m_code_size;\n        mz_uint i;\n        r->m_table_sizes[0] = 288;\n        r->m_table_sizes[1] = 32;\n        TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32);\n        for (i = 0; i <= 143; ++i)\n          *p++ = 8;\n        for (; i <= 255; ++i)\n          *p++ = 9;\n        for (; i <= 279; ++i)\n          *p++ = 7;\n        for (; i <= 287; ++i)\n          *p++ = 8;\n      } else {\n        for (counter = 0; counter < 3; counter++) {\n          TINFL_GET_BITS(11, r->m_table_sizes[counter], \"\\05\\05\\04\"[counter]);\n          r->m_table_sizes[counter] += s_min_table_sizes[counter];\n        }\n        MZ_CLEAR_OBJ(r->m_tables[2].m_code_size);\n        for (counter = 0; counter < r->m_table_sizes[2]; counter++) {\n          mz_uint s;\n          TINFL_GET_BITS(14, s, 3);\n          r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s;\n        }\n        r->m_table_sizes[2] = 19;\n      }\n      for (; (int)r->m_type >= 0; r->m_type--) {\n        int tree_next, tree_cur;\n        tinfl_huff_table *pTable;\n        mz_uint i, j, used_syms, total, sym_index, next_code[17],\n            total_syms[16];\n        pTable = &r->m_tables[r->m_type];\n        MZ_CLEAR_OBJ(total_syms);\n        MZ_CLEAR_OBJ(pTable->m_look_up);\n        MZ_CLEAR_OBJ(pTable->m_tree);\n        for (i = 0; i < r->m_table_sizes[r->m_type]; ++i)\n          total_syms[pTable->m_code_size[i]]++;\n        used_syms = 0, total = 0;\n        next_code[0] = next_code[1] = 0;\n        for (i = 1; i <= 15; ++i) {\n          used_syms += total_syms[i];\n          next_code[i + 1] = (total = ((total + total_syms[i]) << 1));\n        }\n        if ((65536 != total) && (used_syms > 1)) {\n          TINFL_CR_RETURN_FOREVER(35, TINFL_STATUS_FAILED);\n        }\n        for (tree_next = -1, sym_index = 0;\n             sym_index < r->m_table_sizes[r->m_type]; ++sym_index) {\n          mz_uint rev_code = 0, l, cur_code,\n                  code_size = pTable->m_code_size[sym_index];\n          if (!code_size)\n            continue;\n          cur_code = next_code[code_size]++;\n          for (l = code_size; l > 0; l--, cur_code >>= 1)\n            rev_code = (rev_code << 1) | (cur_code & 1);\n          if (code_size <= TINFL_FAST_LOOKUP_BITS) {\n            mz_int16 k = (mz_int16)((code_size << 9) | sym_index);\n            while (rev_code < TINFL_FAST_LOOKUP_SIZE) {\n              pTable->m_look_up[rev_code] = k;\n              rev_code += (1 << code_size);\n            }\n            continue;\n          }\n          if (0 ==\n              (tree_cur = pTable->m_look_up[rev_code &\n                                            (TINFL_FAST_LOOKUP_SIZE - 1)])) {\n            pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)] =\n                (mz_int16)tree_next;\n            tree_cur = tree_next;\n            tree_next -= 2;\n          }\n          rev_code >>= (TINFL_FAST_LOOKUP_BITS - 1);\n          for (j = code_size; j > (TINFL_FAST_LOOKUP_BITS + 1); j--) {\n            tree_cur -= ((rev_code >>= 1) & 1);\n            if (!pTable->m_tree[-tree_cur - 1]) {\n              pTable->m_tree[-tree_cur - 1] = (mz_int16)tree_next;\n              tree_cur = tree_next;\n              tree_next -= 2;\n            } else\n              tree_cur = pTable->m_tree[-tree_cur - 1];\n          }\n          tree_cur -= ((rev_code >>= 1) & 1);\n          pTable->m_tree[-tree_cur - 1] = (mz_int16)sym_index;\n        }\n        if (r->m_type == 2) {\n          for (counter = 0;\n               counter < (r->m_table_sizes[0] + r->m_table_sizes[1]);) {\n            mz_uint s;\n            TINFL_HUFF_DECODE(16, dist, &r->m_tables[2]);\n            if (dist < 16) {\n              r->m_len_codes[counter++] = (mz_uint8)dist;\n              continue;\n            }\n            if ((dist == 16) && (!counter)) {\n              TINFL_CR_RETURN_FOREVER(17, TINFL_STATUS_FAILED);\n            }\n            num_extra = \"\\02\\03\\07\"[dist - 16];\n            TINFL_GET_BITS(18, s, num_extra);\n            s += \"\\03\\03\\013\"[dist - 16];\n            TINFL_MEMSET(r->m_len_codes + counter,\n                         (dist == 16) ? r->m_len_codes[counter - 1] : 0, s);\n            counter += s;\n          }\n          if ((r->m_table_sizes[0] + r->m_table_sizes[1]) != counter) {\n            TINFL_CR_RETURN_FOREVER(21, TINFL_STATUS_FAILED);\n          }\n          TINFL_MEMCPY(r->m_tables[0].m_code_size, r->m_len_codes,\n                       r->m_table_sizes[0]);\n          TINFL_MEMCPY(r->m_tables[1].m_code_size,\n                       r->m_len_codes + r->m_table_sizes[0],\n                       r->m_table_sizes[1]);\n        }\n      }\n      for (;;) {\n        mz_uint8 *pSrc;\n        for (;;) {\n          if (((pIn_buf_end - pIn_buf_cur) < 4) ||\n              ((pOut_buf_end - pOut_buf_cur) < 2)) {\n            TINFL_HUFF_DECODE(23, counter, &r->m_tables[0]);\n            if (counter >= 256)\n              break;\n            while (pOut_buf_cur >= pOut_buf_end) {\n              TINFL_CR_RETURN(24, TINFL_STATUS_HAS_MORE_OUTPUT);\n            }\n            *pOut_buf_cur++ = (mz_uint8)counter;\n          } else {\n            int sym2;\n            mz_uint code_len;\n#if TINFL_USE_64BIT_BITBUF\n            if (num_bits < 30) {\n              bit_buf |=\n                  (((tinfl_bit_buf_t)MZ_READ_LE32(pIn_buf_cur)) << num_bits);\n              pIn_buf_cur += 4;\n              num_bits += 32;\n            }\n#else\n            if (num_bits < 15) {\n              bit_buf |=\n                  (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits);\n              pIn_buf_cur += 2;\n              num_bits += 16;\n            }\n#endif\n            if ((sym2 =\n                     r->m_tables[0]\n                         .m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >=\n                0)\n              code_len = sym2 >> 9;\n            else {\n              code_len = TINFL_FAST_LOOKUP_BITS;\n              do {\n                sym2 = r->m_tables[0]\n                           .m_tree[~sym2 + ((bit_buf >> code_len++) & 1)];\n              } while (sym2 < 0);\n            }\n            counter = sym2;\n            bit_buf >>= code_len;\n            num_bits -= code_len;\n            if (counter & 256)\n              break;\n\n#if !TINFL_USE_64BIT_BITBUF\n            if (num_bits < 15) {\n              bit_buf |=\n                  (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits);\n              pIn_buf_cur += 2;\n              num_bits += 16;\n            }\n#endif\n            if ((sym2 =\n                     r->m_tables[0]\n                         .m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >=\n                0)\n              code_len = sym2 >> 9;\n            else {\n              code_len = TINFL_FAST_LOOKUP_BITS;\n              do {\n                sym2 = r->m_tables[0]\n                           .m_tree[~sym2 + ((bit_buf >> code_len++) & 1)];\n              } while (sym2 < 0);\n            }\n            bit_buf >>= code_len;\n            num_bits -= code_len;\n\n            pOut_buf_cur[0] = (mz_uint8)counter;\n            if (sym2 & 256) {\n              pOut_buf_cur++;\n              counter = sym2;\n              break;\n            }\n            pOut_buf_cur[1] = (mz_uint8)sym2;\n            pOut_buf_cur += 2;\n          }\n        }\n        if ((counter &= 511) == 256)\n          break;\n\n        num_extra = s_length_extra[counter - 257];\n        counter = s_length_base[counter - 257];\n        if (num_extra) {\n          mz_uint extra_bits;\n          TINFL_GET_BITS(25, extra_bits, num_extra);\n          counter += extra_bits;\n        }\n\n        TINFL_HUFF_DECODE(26, dist, &r->m_tables[1]);\n        num_extra = s_dist_extra[dist];\n        dist = s_dist_base[dist];\n        if (num_extra) {\n          mz_uint extra_bits;\n          TINFL_GET_BITS(27, extra_bits, num_extra);\n          dist += extra_bits;\n        }\n\n        dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start;\n        if ((dist > dist_from_out_buf_start) &&\n            (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) {\n          TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED);\n        }\n\n        pSrc = pOut_buf_start +\n               ((dist_from_out_buf_start - dist) & out_buf_size_mask);\n\n        if ((MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end) {\n          while (counter--) {\n            while (pOut_buf_cur >= pOut_buf_end) {\n              TINFL_CR_RETURN(53, TINFL_STATUS_HAS_MORE_OUTPUT);\n            }\n            *pOut_buf_cur++ =\n                pOut_buf_start[(dist_from_out_buf_start++ - dist) &\n                               out_buf_size_mask];\n          }\n          continue;\n        }\n#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES\n        else if ((counter >= 9) && (counter <= dist)) {\n          const mz_uint8 *pSrc_end = pSrc + (counter & ~7);\n          do {\n            ((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0];\n            ((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1];\n            pOut_buf_cur += 8;\n          } while ((pSrc += 8) < pSrc_end);\n          if ((counter &= 7) < 3) {\n            if (counter) {\n              pOut_buf_cur[0] = pSrc[0];\n              if (counter > 1)\n                pOut_buf_cur[1] = pSrc[1];\n              pOut_buf_cur += counter;\n            }\n            continue;\n          }\n        }\n#endif\n        do {\n          pOut_buf_cur[0] = pSrc[0];\n          pOut_buf_cur[1] = pSrc[1];\n          pOut_buf_cur[2] = pSrc[2];\n          pOut_buf_cur += 3;\n          pSrc += 3;\n        } while ((int)(counter -= 3) > 2);\n        if ((int)counter > 0) {\n          pOut_buf_cur[0] = pSrc[0];\n          if ((int)counter > 1)\n            pOut_buf_cur[1] = pSrc[1];\n          pOut_buf_cur += counter;\n        }\n      }\n    }\n  } while (!(r->m_final & 1));\n  if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) {\n    TINFL_SKIP_BITS(32, num_bits & 7);\n    for (counter = 0; counter < 4; ++counter) {\n      mz_uint s;\n      if (num_bits)\n        TINFL_GET_BITS(41, s, 8);\n      else\n        TINFL_GET_BYTE(42, s);\n      r->m_z_adler32 = (r->m_z_adler32 << 8) | s;\n    }\n  }\n  TINFL_CR_RETURN_FOREVER(34, TINFL_STATUS_DONE);\n  TINFL_CR_FINISH\n\ncommon_exit:\n  r->m_num_bits = num_bits;\n  r->m_bit_buf = bit_buf;\n  r->m_dist = dist;\n  r->m_counter = counter;\n  r->m_num_extra = num_extra;\n  r->m_dist_from_out_buf_start = dist_from_out_buf_start;\n  *pIn_buf_size = pIn_buf_cur - pIn_buf_next;\n  *pOut_buf_size = pOut_buf_cur - pOut_buf_next;\n  if ((decomp_flags &\n       (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32)) &&\n      (status >= 0)) {\n    const mz_uint8 *ptr = pOut_buf_next;\n    size_t buf_len = *pOut_buf_size;\n    mz_uint32 i, s1 = r->m_check_adler32 & 0xffff,\n                 s2 = r->m_check_adler32 >> 16;\n    size_t block_len = buf_len % 5552;\n    while (buf_len) {\n      for (i = 0; i + 7 < block_len; i += 8, ptr += 8) {\n        s1 += ptr[0], s2 += s1;\n        s1 += ptr[1], s2 += s1;\n        s1 += ptr[2], s2 += s1;\n        s1 += ptr[3], s2 += s1;\n        s1 += ptr[4], s2 += s1;\n        s1 += ptr[5], s2 += s1;\n        s1 += ptr[6], s2 += s1;\n        s1 += ptr[7], s2 += s1;\n      }\n      for (; i < block_len; ++i)\n        s1 += *ptr++, s2 += s1;\n      s1 %= 65521U, s2 %= 65521U;\n      buf_len -= block_len;\n      block_len = 5552;\n    }\n    r->m_check_adler32 = (s2 << 16) + s1;\n    if ((status == TINFL_STATUS_DONE) &&\n        (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) &&\n        (r->m_check_adler32 != r->m_z_adler32))\n      status = TINFL_STATUS_ADLER32_MISMATCH;\n  }\n  return status;\n}\n\n// Higher level helper functions.\ninline void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len,\n                                   size_t *pOut_len, int flags) {\n  tinfl_decompressor decomp;\n  void *pBuf = NULL, *pNew_buf;\n  size_t src_buf_ofs = 0, out_buf_capacity = 0;\n  *pOut_len = 0;\n  tinfl_init(&decomp);\n  for (;;) {\n    size_t src_buf_size = src_buf_len - src_buf_ofs,\n           dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity;\n    tinfl_status status = tinfl_decompress(\n        &decomp, (const mz_uint8 *)pSrc_buf + src_buf_ofs, &src_buf_size,\n        (mz_uint8 *)pBuf, pBuf ? (mz_uint8 *)pBuf + *pOut_len : NULL,\n        &dst_buf_size, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) |\n                           TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF);\n    if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT)) {\n      MZ_FREE(pBuf);\n      *pOut_len = 0;\n      return NULL;\n    }\n    src_buf_ofs += src_buf_size;\n    *pOut_len += dst_buf_size;\n    if (status == TINFL_STATUS_DONE)\n      break;\n    new_out_buf_capacity = out_buf_capacity * 2;\n    if (new_out_buf_capacity < 128)\n      new_out_buf_capacity = 128;\n    pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity);\n    if (!pNew_buf) {\n      MZ_FREE(pBuf);\n      *pOut_len = 0;\n      return NULL;\n    }\n    pBuf = pNew_buf;\n    out_buf_capacity = new_out_buf_capacity;\n  }\n  return pBuf;\n}\n\ninline size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len,\n                                   const void *pSrc_buf, size_t src_buf_len,\n                                   int flags) {\n  tinfl_decompressor decomp;\n  tinfl_status status;\n  tinfl_init(&decomp);\n  status =\n      tinfl_decompress(&decomp, (const mz_uint8 *)pSrc_buf, &src_buf_len,\n                       (mz_uint8 *)pOut_buf, (mz_uint8 *)pOut_buf, &out_buf_len,\n                       (flags & ~TINFL_FLAG_HAS_MORE_INPUT) |\n                           TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF);\n  return (status != TINFL_STATUS_DONE) ? TINFL_DECOMPRESS_MEM_TO_MEM_FAILED\n                                       : out_buf_len;\n}\n\ninline int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size,\n                                     tinfl_put_buf_func_ptr pPut_buf_func,\n                                     void *pPut_buf_user, int flags) {\n  int result = 0;\n  tinfl_decompressor decomp;\n  mz_uint8 *pDict = (mz_uint8 *)MZ_MALLOC(TINFL_LZ_DICT_SIZE);\n  size_t in_buf_ofs = 0, dict_ofs = 0;\n  if (!pDict)\n    return TINFL_STATUS_FAILED;\n  tinfl_init(&decomp);\n  for (;;) {\n    size_t in_buf_size = *pIn_buf_size - in_buf_ofs,\n           dst_buf_size = TINFL_LZ_DICT_SIZE - dict_ofs;\n    tinfl_status status =\n        tinfl_decompress(&decomp, (const mz_uint8 *)pIn_buf + in_buf_ofs,\n                         &in_buf_size, pDict, pDict + dict_ofs, &dst_buf_size,\n                         (flags &\n                          ~(TINFL_FLAG_HAS_MORE_INPUT |\n                            TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)));\n    in_buf_ofs += in_buf_size;\n    if ((dst_buf_size) &&\n        (!(*pPut_buf_func)(pDict + dict_ofs, (int)dst_buf_size, pPut_buf_user)))\n      break;\n    if (status != TINFL_STATUS_HAS_MORE_OUTPUT) {\n      result = (status == TINFL_STATUS_DONE);\n      break;\n    }\n    dict_ofs = (dict_ofs + dst_buf_size) & (TINFL_LZ_DICT_SIZE - 1);\n  }\n  MZ_FREE(pDict);\n  *pIn_buf_size = in_buf_ofs;\n  return result;\n}\n\n// ------------------- Low-level Compression (independent from all decompression\n// API's)\n\n// Purposely making these tables static for faster init and thread safety.\nstatic const mz_uint16 s_tdefl_len_sym[256] = {\n    257, 258, 259, 260, 261, 262, 263, 264, 265, 265, 266, 266, 267, 267, 268,\n    268, 269, 269, 269, 269, 270, 270, 270, 270, 271, 271, 271, 271, 272, 272,\n    272, 272, 273, 273, 273, 273, 273, 273, 273, 273, 274, 274, 274, 274, 274,\n    274, 274, 274, 275, 275, 275, 275, 275, 275, 275, 275, 276, 276, 276, 276,\n    276, 276, 276, 276, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,\n    277, 277, 277, 277, 277, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,\n    278, 278, 278, 278, 278, 278, 279, 279, 279, 279, 279, 279, 279, 279, 279,\n    279, 279, 279, 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, 280, 280,\n    280, 280, 280, 280, 280, 280, 280, 280, 281, 281, 281, 281, 281, 281, 281,\n    281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281,\n    281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 282, 282, 282, 282, 282,\n    282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282,\n    282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 283, 283, 283,\n    283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283,\n    283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 284,\n    284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,\n    284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,\n    285};\n\nstatic const mz_uint8 s_tdefl_len_extra[256] = {\n    0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,\n    2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,\n    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n    4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0};\n\nstatic const mz_uint8 s_tdefl_small_dist_sym[512] = {\n    0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,\n    8,  8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9,  10, 10, 10, 10, 10, 10,\n    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,\n    11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,\n    12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,\n    12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,\n    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14,\n    14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,\n    14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,\n    14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,\n    14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,\n    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,\n    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,\n    15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,\n    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,\n    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,\n    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,\n    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,\n    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,\n    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,\n    16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,\n    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,\n    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,\n    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,\n    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,\n    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,\n    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17};\n\nstatic const mz_uint8 s_tdefl_small_dist_extra[512] = {\n    0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,\n    3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n    5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n    6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7};\n\nstatic const mz_uint8 s_tdefl_large_dist_sym[128] = {\n    0,  0,  18, 19, 20, 20, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24,\n    24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26,\n    26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n    27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n    28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n    28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,\n    29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29};\n\nstatic const mz_uint8 s_tdefl_large_dist_extra[128] = {\n    0,  0,  8,  8,  9,  9,  9,  9,  10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11,\n    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12,\n    12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,\n    12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,\n    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,\n    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,\n    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13};\n\n// Radix sorts tdefl_sym_freq[] array by 16-bit key m_key. Returns ptr to sorted\n// values.\ntypedef struct { mz_uint16 m_key, m_sym_index; } tdefl_sym_freq;\nstatic tdefl_sym_freq *tdefl_radix_sort_syms(mz_uint num_syms,\n                                             tdefl_sym_freq *pSyms0,\n                                             tdefl_sym_freq *pSyms1) {\n  mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2];\n  tdefl_sym_freq *pCur_syms = pSyms0, *pNew_syms = pSyms1;\n  MZ_CLEAR_OBJ(hist);\n  for (i = 0; i < num_syms; i++) {\n    mz_uint freq = pSyms0[i].m_key;\n    hist[freq & 0xFF]++;\n    hist[256 + ((freq >> 8) & 0xFF)]++;\n  }\n  while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256]))\n    total_passes--;\n  for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8) {\n    const mz_uint32 *pHist = &hist[pass << 8];\n    mz_uint offsets[256], cur_ofs = 0;\n    for (i = 0; i < 256; i++) {\n      offsets[i] = cur_ofs;\n      cur_ofs += pHist[i];\n    }\n    for (i = 0; i < num_syms; i++)\n      pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] =\n          pCur_syms[i];\n    {\n      tdefl_sym_freq *t = pCur_syms;\n      pCur_syms = pNew_syms;\n      pNew_syms = t;\n    }\n  }\n  return pCur_syms;\n}\n\n// tdefl_calculate_minimum_redundancy() originally written by: Alistair Moffat,\n// alistair@cs.mu.oz.au, Jyrki Katajainen, jyrki@diku.dk, November 1996.\nstatic void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n) {\n  int root, leaf, next, avbl, used, dpth;\n  if (n == 0)\n    return;\n  else if (n == 1) {\n    A[0].m_key = 1;\n    return;\n  }\n  A[0].m_key += A[1].m_key;\n  root = 0;\n  leaf = 2;\n  for (next = 1; next < n - 1; next++) {\n    if (leaf >= n || A[root].m_key < A[leaf].m_key) {\n      A[next].m_key = A[root].m_key;\n      A[root++].m_key = (mz_uint16)next;\n    } else\n      A[next].m_key = A[leaf++].m_key;\n    if (leaf >= n || (root < next && A[root].m_key < A[leaf].m_key)) {\n      A[next].m_key = (mz_uint16)(A[next].m_key + A[root].m_key);\n      A[root++].m_key = (mz_uint16)next;\n    } else\n      A[next].m_key = (mz_uint16)(A[next].m_key + A[leaf++].m_key);\n  }\n  A[n - 2].m_key = 0;\n  for (next = n - 3; next >= 0; next--)\n    A[next].m_key = A[A[next].m_key].m_key + 1;\n  avbl = 1;\n  used = dpth = 0;\n  root = n - 2;\n  next = n - 1;\n  while (avbl > 0) {\n    while (root >= 0 && (int)A[root].m_key == dpth) {\n      used++;\n      root--;\n    }\n    while (avbl > used) {\n      A[next--].m_key = (mz_uint16)(dpth);\n      avbl--;\n    }\n    avbl = 2 * used;\n    dpth++;\n    used = 0;\n  }\n}\n\n// Limits canonical Huffman code table's max code size.\nenum { TDEFL_MAX_SUPPORTED_HUFF_CODESIZE = 32 };\nstatic void tdefl_huffman_enforce_max_code_size(int *pNum_codes,\n                                                int code_list_len,\n                                                int max_code_size) {\n  int i;\n  mz_uint32 total = 0;\n  if (code_list_len <= 1)\n    return;\n  for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++)\n    pNum_codes[max_code_size] += pNum_codes[i];\n  for (i = max_code_size; i > 0; i--)\n    total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i));\n  while (total != (1UL << max_code_size)) {\n    pNum_codes[max_code_size]--;\n    for (i = max_code_size - 1; i > 0; i--)\n      if (pNum_codes[i]) {\n        pNum_codes[i]--;\n        pNum_codes[i + 1] += 2;\n        break;\n      }\n    total--;\n  }\n}\n\nstatic void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num,\n                                         int table_len, int code_size_limit,\n                                         int static_table) {\n  int i, j, l, num_codes[1 + TDEFL_MAX_SUPPORTED_HUFF_CODESIZE];\n  mz_uint next_code[TDEFL_MAX_SUPPORTED_HUFF_CODESIZE + 1];\n  MZ_CLEAR_OBJ(num_codes);\n  if (static_table) {\n    for (i = 0; i < table_len; i++)\n      num_codes[d->m_huff_code_sizes[table_num][i]]++;\n  } else {\n    tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS],\n        *pSyms;\n    int num_used_syms = 0;\n    const mz_uint16 *pSym_count = &d->m_huff_count[table_num][0];\n    for (i = 0; i < table_len; i++)\n      if (pSym_count[i]) {\n        syms0[num_used_syms].m_key = (mz_uint16)pSym_count[i];\n        syms0[num_used_syms++].m_sym_index = (mz_uint16)i;\n      }\n\n    pSyms = tdefl_radix_sort_syms(num_used_syms, syms0, syms1);\n    tdefl_calculate_minimum_redundancy(pSyms, num_used_syms);\n\n    for (i = 0; i < num_used_syms; i++)\n      num_codes[pSyms[i].m_key]++;\n\n    tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms,\n                                        code_size_limit);\n\n    MZ_CLEAR_OBJ(d->m_huff_code_sizes[table_num]);\n    MZ_CLEAR_OBJ(d->m_huff_codes[table_num]);\n    for (i = 1, j = num_used_syms; i <= code_size_limit; i++)\n      for (l = num_codes[i]; l > 0; l--)\n        d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (mz_uint8)(i);\n  }\n\n  next_code[1] = 0;\n  for (j = 0, i = 2; i <= code_size_limit; i++)\n    next_code[i] = j = ((j + num_codes[i - 1]) << 1);\n\n  for (i = 0; i < table_len; i++) {\n    mz_uint rev_code = 0, code, code_size;\n    if ((code_size = d->m_huff_code_sizes[table_num][i]) == 0)\n      continue;\n    code = next_code[code_size]++;\n    for (l = code_size; l > 0; l--, code >>= 1)\n      rev_code = (rev_code << 1) | (code & 1);\n    d->m_huff_codes[table_num][i] = (mz_uint16)rev_code;\n  }\n}\n\n#define TDEFL_PUT_BITS(b, l)                                                   \\\n  do {                                                                         \\\n    mz_uint bits = b;                                                          \\\n    mz_uint len = l;                                                           \\\n    MZ_ASSERT(bits <= ((1U << len) - 1U));                                     \\\n    d->m_bit_buffer |= (bits << d->m_bits_in);                                 \\\n    d->m_bits_in += len;                                                       \\\n    while (d->m_bits_in >= 8) {                                                \\\n      if (d->m_pOutput_buf < d->m_pOutput_buf_end)                             \\\n        *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer);                     \\\n      d->m_bit_buffer >>= 8;                                                   \\\n      d->m_bits_in -= 8;                                                       \\\n    }                                                                          \\\n  }                                                                            \\\n  MZ_MACRO_END\n\n#define TDEFL_RLE_PREV_CODE_SIZE()                                             \\\n  {                                                                            \\\n    if (rle_repeat_count) {                                                    \\\n      if (rle_repeat_count < 3) {                                              \\\n        d->m_huff_count[2][prev_code_size] = (mz_uint16)(                      \\\n            d->m_huff_count[2][prev_code_size] + rle_repeat_count);            \\\n        while (rle_repeat_count--)                                             \\\n          packed_code_sizes[num_packed_code_sizes++] = prev_code_size;         \\\n      } else {                                                                 \\\n        d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1);      \\\n        packed_code_sizes[num_packed_code_sizes++] = 16;                       \\\n        packed_code_sizes[num_packed_code_sizes++] =                           \\\n            (mz_uint8)(rle_repeat_count - 3);                                  \\\n      }                                                                        \\\n      rle_repeat_count = 0;                                                    \\\n    }                                                                          \\\n  }\n\n#define TDEFL_RLE_ZERO_CODE_SIZE()                                             \\\n  {                                                                            \\\n    if (rle_z_count) {                                                         \\\n      if (rle_z_count < 3) {                                                   \\\n        d->m_huff_count[2][0] =                                                \\\n            (mz_uint16)(d->m_huff_count[2][0] + rle_z_count);                  \\\n        while (rle_z_count--)                                                  \\\n          packed_code_sizes[num_packed_code_sizes++] = 0;                      \\\n      } else if (rle_z_count <= 10) {                                          \\\n        d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1);      \\\n        packed_code_sizes[num_packed_code_sizes++] = 17;                       \\\n        packed_code_sizes[num_packed_code_sizes++] =                           \\\n            (mz_uint8)(rle_z_count - 3);                                       \\\n      } else {                                                                 \\\n        d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1);      \\\n        packed_code_sizes[num_packed_code_sizes++] = 18;                       \\\n        packed_code_sizes[num_packed_code_sizes++] =                           \\\n            (mz_uint8)(rle_z_count - 11);                                      \\\n      }                                                                        \\\n      rle_z_count = 0;                                                         \\\n    }                                                                          \\\n  }\n\nstatic mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = {\n    16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n\nstatic void tdefl_start_dynamic_block(tdefl_compressor *d) {\n  int num_lit_codes, num_dist_codes, num_bit_lengths;\n  mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count,\n      rle_repeat_count, packed_code_sizes_index;\n  mz_uint8\n      code_sizes_to_pack[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1],\n      packed_code_sizes[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1],\n      prev_code_size = 0xFF;\n\n  d->m_huff_count[0][256] = 1;\n\n  tdefl_optimize_huffman_table(d, 0, TDEFL_MAX_HUFF_SYMBOLS_0, 15, MZ_FALSE);\n  tdefl_optimize_huffman_table(d, 1, TDEFL_MAX_HUFF_SYMBOLS_1, 15, MZ_FALSE);\n\n  for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--)\n    if (d->m_huff_code_sizes[0][num_lit_codes - 1])\n      break;\n  for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--)\n    if (d->m_huff_code_sizes[1][num_dist_codes - 1])\n      break;\n\n  memcpy(code_sizes_to_pack, &d->m_huff_code_sizes[0][0], num_lit_codes);\n  memcpy(code_sizes_to_pack + num_lit_codes, &d->m_huff_code_sizes[1][0],\n         num_dist_codes);\n  total_code_sizes_to_pack = num_lit_codes + num_dist_codes;\n  num_packed_code_sizes = 0;\n  rle_z_count = 0;\n  rle_repeat_count = 0;\n\n  memset(&d->m_huff_count[2][0], 0,\n         sizeof(d->m_huff_count[2][0]) * TDEFL_MAX_HUFF_SYMBOLS_2);\n  for (i = 0; i < total_code_sizes_to_pack; i++) {\n    mz_uint8 code_size = code_sizes_to_pack[i];\n    if (!code_size) {\n      TDEFL_RLE_PREV_CODE_SIZE();\n      if (++rle_z_count == 138) {\n        TDEFL_RLE_ZERO_CODE_SIZE();\n      }\n    } else {\n      TDEFL_RLE_ZERO_CODE_SIZE();\n      if (code_size != prev_code_size) {\n        TDEFL_RLE_PREV_CODE_SIZE();\n        d->m_huff_count[2][code_size] =\n            (mz_uint16)(d->m_huff_count[2][code_size] + 1);\n        packed_code_sizes[num_packed_code_sizes++] = code_size;\n      } else if (++rle_repeat_count == 6) {\n        TDEFL_RLE_PREV_CODE_SIZE();\n      }\n    }\n    prev_code_size = code_size;\n  }\n  if (rle_repeat_count) {\n    TDEFL_RLE_PREV_CODE_SIZE();\n  } else {\n    TDEFL_RLE_ZERO_CODE_SIZE();\n  }\n\n  tdefl_optimize_huffman_table(d, 2, TDEFL_MAX_HUFF_SYMBOLS_2, 7, MZ_FALSE);\n\n  TDEFL_PUT_BITS(2, 2);\n\n  TDEFL_PUT_BITS(num_lit_codes - 257, 5);\n  TDEFL_PUT_BITS(num_dist_codes - 1, 5);\n\n  for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--)\n    if (d->m_huff_code_sizes\n            [2][s_tdefl_packed_code_size_syms_swizzle[num_bit_lengths]])\n      break;\n  num_bit_lengths = MZ_MAX(4, (num_bit_lengths + 1));\n  TDEFL_PUT_BITS(num_bit_lengths - 4, 4);\n  for (i = 0; (int)i < num_bit_lengths; i++)\n    TDEFL_PUT_BITS(\n        d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[i]], 3);\n\n  for (packed_code_sizes_index = 0;\n       packed_code_sizes_index < num_packed_code_sizes;) {\n    mz_uint code = packed_code_sizes[packed_code_sizes_index++];\n    MZ_ASSERT(code < TDEFL_MAX_HUFF_SYMBOLS_2);\n    TDEFL_PUT_BITS(d->m_huff_codes[2][code], d->m_huff_code_sizes[2][code]);\n    if (code >= 16)\n      TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++],\n                     \"\\02\\03\\07\"[code - 16]);\n  }\n}\n\nstatic void tdefl_start_static_block(tdefl_compressor *d) {\n  mz_uint i;\n  mz_uint8 *p = &d->m_huff_code_sizes[0][0];\n\n  for (i = 0; i <= 143; ++i)\n    *p++ = 8;\n  for (; i <= 255; ++i)\n    *p++ = 9;\n  for (; i <= 279; ++i)\n    *p++ = 7;\n  for (; i <= 287; ++i)\n    *p++ = 8;\n\n  memset(d->m_huff_code_sizes[1], 5, 32);\n\n  tdefl_optimize_huffman_table(d, 0, 288, 15, MZ_TRUE);\n  tdefl_optimize_huffman_table(d, 1, 32, 15, MZ_TRUE);\n\n  TDEFL_PUT_BITS(1, 2);\n}\n\nstatic const mz_uint mz_bitmasks[17] = {\n    0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF,\n    0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF};\n\n#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN &&             \\\n    MINIZ_HAS_64BIT_REGISTERS\nstatic mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) {\n  mz_uint flags;\n  mz_uint8 *pLZ_codes;\n  mz_uint8 *pOutput_buf = d->m_pOutput_buf;\n  mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf;\n  mz_uint64 bit_buffer = d->m_bit_buffer;\n  mz_uint bits_in = d->m_bits_in;\n\n#define TDEFL_PUT_BITS_FAST(b, l)                                              \\\n  {                                                                            \\\n    bit_buffer |= (((mz_uint64)(b)) << bits_in);                               \\\n    bits_in += (l);                                                            \\\n  }\n\n  flags = 1;\n  for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end;\n       flags >>= 1) {\n    if (flags == 1)\n      flags = *pLZ_codes++ | 0x100;\n\n    if (flags & 1) {\n      mz_uint s0, s1, n0, n1, sym, num_extra_bits;\n      mz_uint match_len = pLZ_codes[0],\n              match_dist = *(const mz_uint16 *)(pLZ_codes + 1);\n      pLZ_codes += 3;\n\n      MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);\n      TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]],\n                          d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);\n      TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]],\n                          s_tdefl_len_extra[match_len]);\n\n      // This sequence coaxes MSVC into using cmov's vs. jmp's.\n      s0 = s_tdefl_small_dist_sym[match_dist & 511];\n      n0 = s_tdefl_small_dist_extra[match_dist & 511];\n      s1 = s_tdefl_large_dist_sym[match_dist >> 8];\n      n1 = s_tdefl_large_dist_extra[match_dist >> 8];\n      sym = (match_dist < 512) ? s0 : s1;\n      num_extra_bits = (match_dist < 512) ? n0 : n1;\n\n      MZ_ASSERT(d->m_huff_code_sizes[1][sym]);\n      TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym],\n                          d->m_huff_code_sizes[1][sym]);\n      TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits],\n                          num_extra_bits);\n    } else {\n      mz_uint lit = *pLZ_codes++;\n      MZ_ASSERT(d->m_huff_code_sizes[0][lit]);\n      TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit],\n                          d->m_huff_code_sizes[0][lit]);\n\n      if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) {\n        flags >>= 1;\n        lit = *pLZ_codes++;\n        MZ_ASSERT(d->m_huff_code_sizes[0][lit]);\n        TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit],\n                            d->m_huff_code_sizes[0][lit]);\n\n        if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) {\n          flags >>= 1;\n          lit = *pLZ_codes++;\n          MZ_ASSERT(d->m_huff_code_sizes[0][lit]);\n          TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit],\n                              d->m_huff_code_sizes[0][lit]);\n        }\n      }\n    }\n\n    if (pOutput_buf >= d->m_pOutput_buf_end)\n      return MZ_FALSE;\n\n    *(mz_uint64 *)pOutput_buf = bit_buffer;\n    pOutput_buf += (bits_in >> 3);\n    bit_buffer >>= (bits_in & ~7);\n    bits_in &= 7;\n  }\n\n#undef TDEFL_PUT_BITS_FAST\n\n  d->m_pOutput_buf = pOutput_buf;\n  d->m_bits_in = 0;\n  d->m_bit_buffer = 0;\n\n  while (bits_in) {\n    mz_uint32 n = MZ_MIN(bits_in, 16);\n    TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n);\n    bit_buffer >>= n;\n    bits_in -= n;\n  }\n\n  TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]);\n\n  return (d->m_pOutput_buf < d->m_pOutput_buf_end);\n}\n#else\nstatic mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) {\n  mz_uint flags;\n  mz_uint8 *pLZ_codes;\n\n  flags = 1;\n  for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf;\n       flags >>= 1) {\n    if (flags == 1)\n      flags = *pLZ_codes++ | 0x100;\n    if (flags & 1) {\n      mz_uint sym, num_extra_bits;\n      mz_uint match_len = pLZ_codes[0],\n              match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8));\n      pLZ_codes += 3;\n\n      MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);\n      TDEFL_PUT_BITS(d->m_huff_codes[0][s_tdefl_len_sym[match_len]],\n                     d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);\n      TDEFL_PUT_BITS(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]],\n                     s_tdefl_len_extra[match_len]);\n\n      if (match_dist < 512) {\n        sym = s_tdefl_small_dist_sym[match_dist];\n        num_extra_bits = s_tdefl_small_dist_extra[match_dist];\n      } else {\n        sym = s_tdefl_large_dist_sym[match_dist >> 8];\n        num_extra_bits = s_tdefl_large_dist_extra[match_dist >> 8];\n      }\n      MZ_ASSERT(d->m_huff_code_sizes[1][sym]);\n      TDEFL_PUT_BITS(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]);\n      TDEFL_PUT_BITS(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits);\n    } else {\n      mz_uint lit = *pLZ_codes++;\n      MZ_ASSERT(d->m_huff_code_sizes[0][lit]);\n      TDEFL_PUT_BITS(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);\n    }\n  }\n\n  TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]);\n\n  return (d->m_pOutput_buf < d->m_pOutput_buf_end);\n}\n#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN &&\n       // MINIZ_HAS_64BIT_REGISTERS\n\nstatic mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block) {\n  if (static_block)\n    tdefl_start_static_block(d);\n  else\n    tdefl_start_dynamic_block(d);\n  return tdefl_compress_lz_codes(d);\n}\n\nstatic int tdefl_flush_block(tdefl_compressor *d, int flush) {\n  mz_uint saved_bit_buf, saved_bits_in;\n  mz_uint8 *pSaved_output_buf;\n  mz_bool comp_block_succeeded = MZ_FALSE;\n  int n, use_raw_block =\n             ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) &&\n             (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size;\n  mz_uint8 *pOutput_buf_start =\n      ((d->m_pPut_buf_func == NULL) &&\n       ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE))\n          ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs)\n          : d->m_output_buf;\n\n  d->m_pOutput_buf = pOutput_buf_start;\n  d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16;\n\n  MZ_ASSERT(!d->m_output_flush_remaining);\n  d->m_output_flush_ofs = 0;\n  d->m_output_flush_remaining = 0;\n\n  *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left);\n  d->m_pLZ_code_buf -= (d->m_num_flags_left == 8);\n\n  if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index)) {\n    TDEFL_PUT_BITS(0x78, 8);\n    TDEFL_PUT_BITS(0x01, 8);\n  }\n\n  TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1);\n\n  pSaved_output_buf = d->m_pOutput_buf;\n  saved_bit_buf = d->m_bit_buffer;\n  saved_bits_in = d->m_bits_in;\n\n  if (!use_raw_block)\n    comp_block_succeeded =\n        tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) ||\n                                    (d->m_total_lz_bytes < 48));\n\n  // If the block gets expanded, forget the current contents of the output\n  // buffer and send a raw block instead.\n  if (((use_raw_block) ||\n       ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >=\n                                  d->m_total_lz_bytes))) &&\n      ((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size)) {\n    mz_uint i;\n    d->m_pOutput_buf = pSaved_output_buf;\n    d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in;\n    TDEFL_PUT_BITS(0, 2);\n    if (d->m_bits_in) {\n      TDEFL_PUT_BITS(0, 8 - d->m_bits_in);\n    }\n    for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF) {\n      TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16);\n    }\n    for (i = 0; i < d->m_total_lz_bytes; ++i) {\n      TDEFL_PUT_BITS(\n          d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK],\n          8);\n    }\n  }\n  // Check for the extremely unlikely (if not impossible) case of the compressed\n  // block not fitting into the output buffer when using dynamic codes.\n  else if (!comp_block_succeeded) {\n    d->m_pOutput_buf = pSaved_output_buf;\n    d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in;\n    tdefl_compress_block(d, MZ_TRUE);\n  }\n\n  if (flush) {\n    if (flush == TDEFL_FINISH) {\n      if (d->m_bits_in) {\n        TDEFL_PUT_BITS(0, 8 - d->m_bits_in);\n      }\n      if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER) {\n        mz_uint i, a = d->m_adler32;\n        for (i = 0; i < 4; i++) {\n          TDEFL_PUT_BITS((a >> 24) & 0xFF, 8);\n          a <<= 8;\n        }\n      }\n    } else {\n      mz_uint i, z = 0;\n      TDEFL_PUT_BITS(0, 3);\n      if (d->m_bits_in) {\n        TDEFL_PUT_BITS(0, 8 - d->m_bits_in);\n      }\n      for (i = 2; i; --i, z ^= 0xFFFF) {\n        TDEFL_PUT_BITS(z & 0xFFFF, 16);\n      }\n    }\n  }\n\n  MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end);\n\n  memset(&d->m_huff_count[0][0], 0,\n         sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0);\n  memset(&d->m_huff_count[1][0], 0,\n         sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1);\n\n  d->m_pLZ_code_buf = d->m_lz_code_buf + 1;\n  d->m_pLZ_flags = d->m_lz_code_buf;\n  d->m_num_flags_left = 8;\n  d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes;\n  d->m_total_lz_bytes = 0;\n  d->m_block_index++;\n\n  if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0) {\n    if (d->m_pPut_buf_func) {\n      *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf;\n      if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user))\n        return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED);\n    } else if (pOutput_buf_start == d->m_output_buf) {\n      int bytes_to_copy = (int)MZ_MIN(\n          (size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs));\n      memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf,\n             bytes_to_copy);\n      d->m_out_buf_ofs += bytes_to_copy;\n      if ((n -= bytes_to_copy) != 0) {\n        d->m_output_flush_ofs = bytes_to_copy;\n        d->m_output_flush_remaining = n;\n      }\n    } else {\n      d->m_out_buf_ofs += n;\n    }\n  }\n\n  return d->m_output_flush_remaining;\n}\n\n#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES\n#define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16 *)(p)\nstatic MZ_FORCEINLINE void\ntdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist,\n                 mz_uint max_match_len, mz_uint *pMatch_dist,\n                 mz_uint *pMatch_len) {\n  mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK,\n                match_len = *pMatch_len, probe_pos = pos, next_probe_pos,\n                probe_len;\n  mz_uint num_probes_left = d->m_max_probes[match_len >= 32];\n  const mz_uint16 *s = (const mz_uint16 *)(d->m_dict + pos), *p, *q;\n  mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]),\n            s01 = TDEFL_READ_UNALIGNED_WORD(s);\n  MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN);\n  if (max_match_len <= match_len)\n    return;\n  for (;;) {\n    for (;;) {\n      if (--num_probes_left == 0)\n        return;\n#define TDEFL_PROBE                                                            \\\n  next_probe_pos = d->m_next[probe_pos];                                       \\\n  if ((!next_probe_pos) ||                                                     \\\n      ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist))       \\\n    return;                                                                    \\\n  probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK;                        \\\n  if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) \\\n    break;\n      TDEFL_PROBE;\n      TDEFL_PROBE;\n      TDEFL_PROBE;\n    }\n    if (!dist)\n      break;\n    q = (const mz_uint16 *)(d->m_dict + probe_pos);\n    if (TDEFL_READ_UNALIGNED_WORD(q) != s01)\n      continue;\n    p = s;\n    probe_len = 32;\n    do {\n    } while (\n        (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&\n        (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&\n        (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&\n        (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&\n        (--probe_len > 0));\n    if (!probe_len) {\n      *pMatch_dist = dist;\n      *pMatch_len = MZ_MIN(max_match_len, TDEFL_MAX_MATCH_LEN);\n      break;\n    } else if ((probe_len = ((mz_uint)(p - s) * 2) +\n                            (mz_uint)(*(const mz_uint8 *)p ==\n                                      *(const mz_uint8 *)q)) > match_len) {\n      *pMatch_dist = dist;\n      if ((*pMatch_len = match_len = MZ_MIN(max_match_len, probe_len)) ==\n          max_match_len)\n        break;\n      c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]);\n    }\n  }\n}\n#else\nstatic MZ_FORCEINLINE void\ntdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist,\n                 mz_uint max_match_len, mz_uint *pMatch_dist,\n                 mz_uint *pMatch_len) {\n  mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK,\n                match_len = *pMatch_len, probe_pos = pos, next_probe_pos,\n                probe_len;\n  mz_uint num_probes_left = d->m_max_probes[match_len >= 32];\n  const mz_uint8 *s = d->m_dict + pos, *p, *q;\n  mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1];\n  MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN);\n  if (max_match_len <= match_len)\n    return;\n  for (;;) {\n    for (;;) {\n      if (--num_probes_left == 0)\n        return;\n#define TDEFL_PROBE                                                            \\\n  next_probe_pos = d->m_next[probe_pos];                                       \\\n  if ((!next_probe_pos) ||                                                     \\\n      ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist))       \\\n    return;                                                                    \\\n  probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK;                        \\\n  if ((d->m_dict[probe_pos + match_len] == c0) &&                              \\\n      (d->m_dict[probe_pos + match_len - 1] == c1))                            \\\n    break;\n      TDEFL_PROBE;\n      TDEFL_PROBE;\n      TDEFL_PROBE;\n    }\n    if (!dist)\n      break;\n    p = s;\n    q = d->m_dict + probe_pos;\n    for (probe_len = 0; probe_len < max_match_len; probe_len++)\n      if (*p++ != *q++)\n        break;\n    if (probe_len > match_len) {\n      *pMatch_dist = dist;\n      if ((*pMatch_len = match_len = probe_len) == max_match_len)\n        return;\n      c0 = d->m_dict[pos + match_len];\n      c1 = d->m_dict[pos + match_len - 1];\n    }\n  }\n}\n#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES\n\n#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN\nstatic mz_bool tdefl_compress_fast(tdefl_compressor *d) {\n  // Faster, minimally featured LZRW1-style match+parse loop with better\n  // register utilization. Intended for applications where raw throughput is\n  // valued more highly than ratio.\n  mz_uint lookahead_pos = d->m_lookahead_pos,\n          lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size,\n          total_lz_bytes = d->m_total_lz_bytes,\n          num_flags_left = d->m_num_flags_left;\n  mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags;\n  mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK;\n\n  while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size))) {\n    const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096;\n    mz_uint dst_pos =\n        (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK;\n    mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(\n        d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size);\n    d->m_src_buf_left -= num_bytes_to_process;\n    lookahead_size += num_bytes_to_process;\n\n    while (num_bytes_to_process) {\n      mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process);\n      memcpy(d->m_dict + dst_pos, d->m_pSrc, n);\n      if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1))\n        memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc,\n               MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos));\n      d->m_pSrc += n;\n      dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK;\n      num_bytes_to_process -= n;\n    }\n\n    dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size);\n    if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE))\n      break;\n\n    while (lookahead_size >= 4) {\n      mz_uint cur_match_dist, cur_match_len = 1;\n      mz_uint8 *pCur_dict = d->m_dict + cur_pos;\n      mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF;\n      mz_uint hash =\n          (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) &\n          TDEFL_LEVEL1_HASH_SIZE_MASK;\n      mz_uint probe_pos = d->m_hash[hash];\n      d->m_hash[hash] = (mz_uint16)lookahead_pos;\n\n      if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <=\n           dict_size) &&\n          ((*(const mz_uint32 *)(d->m_dict +\n                                 (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) &\n            0xFFFFFF) == first_trigram)) {\n        const mz_uint16 *p = (const mz_uint16 *)pCur_dict;\n        const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos);\n        mz_uint32 probe_len = 32;\n        do {\n        } while ((TDEFL_READ_UNALIGNED_WORD(++p) ==\n                  TDEFL_READ_UNALIGNED_WORD(++q)) &&\n                 (TDEFL_READ_UNALIGNED_WORD(++p) ==\n                  TDEFL_READ_UNALIGNED_WORD(++q)) &&\n                 (TDEFL_READ_UNALIGNED_WORD(++p) ==\n                  TDEFL_READ_UNALIGNED_WORD(++q)) &&\n                 (TDEFL_READ_UNALIGNED_WORD(++p) ==\n                  TDEFL_READ_UNALIGNED_WORD(++q)) &&\n                 (--probe_len > 0));\n        cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) +\n                        (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q);\n        if (!probe_len)\n          cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0;\n\n        if ((cur_match_len < TDEFL_MIN_MATCH_LEN) ||\n            ((cur_match_len == TDEFL_MIN_MATCH_LEN) &&\n             (cur_match_dist >= 8U * 1024U))) {\n          cur_match_len = 1;\n          *pLZ_code_buf++ = (mz_uint8)first_trigram;\n          *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);\n          d->m_huff_count[0][(mz_uint8)first_trigram]++;\n        } else {\n          mz_uint32 s0, s1;\n          cur_match_len = MZ_MIN(cur_match_len, lookahead_size);\n\n          MZ_ASSERT((cur_match_len >= TDEFL_MIN_MATCH_LEN) &&\n                    (cur_match_dist >= 1) &&\n                    (cur_match_dist <= TDEFL_LZ_DICT_SIZE));\n\n          cur_match_dist--;\n\n          pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN);\n          *(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist;\n          pLZ_code_buf += 3;\n          *pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80);\n\n          s0 = s_tdefl_small_dist_sym[cur_match_dist & 511];\n          s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8];\n          d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++;\n\n          d->m_huff_count[0][s_tdefl_len_sym[cur_match_len -\n                                             TDEFL_MIN_MATCH_LEN]]++;\n        }\n      } else {\n        *pLZ_code_buf++ = (mz_uint8)first_trigram;\n        *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);\n        d->m_huff_count[0][(mz_uint8)first_trigram]++;\n      }\n\n      if (--num_flags_left == 0) {\n        num_flags_left = 8;\n        pLZ_flags = pLZ_code_buf++;\n      }\n\n      total_lz_bytes += cur_match_len;\n      lookahead_pos += cur_match_len;\n      dict_size = MZ_MIN(dict_size + cur_match_len, TDEFL_LZ_DICT_SIZE);\n      cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK;\n      MZ_ASSERT(lookahead_size >= cur_match_len);\n      lookahead_size -= cur_match_len;\n\n      if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) {\n        int n;\n        d->m_lookahead_pos = lookahead_pos;\n        d->m_lookahead_size = lookahead_size;\n        d->m_dict_size = dict_size;\n        d->m_total_lz_bytes = total_lz_bytes;\n        d->m_pLZ_code_buf = pLZ_code_buf;\n        d->m_pLZ_flags = pLZ_flags;\n        d->m_num_flags_left = num_flags_left;\n        if ((n = tdefl_flush_block(d, 0)) != 0)\n          return (n < 0) ? MZ_FALSE : MZ_TRUE;\n        total_lz_bytes = d->m_total_lz_bytes;\n        pLZ_code_buf = d->m_pLZ_code_buf;\n        pLZ_flags = d->m_pLZ_flags;\n        num_flags_left = d->m_num_flags_left;\n      }\n    }\n\n    while (lookahead_size) {\n      mz_uint8 lit = d->m_dict[cur_pos];\n\n      total_lz_bytes++;\n      *pLZ_code_buf++ = lit;\n      *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);\n      if (--num_flags_left == 0) {\n        num_flags_left = 8;\n        pLZ_flags = pLZ_code_buf++;\n      }\n\n      d->m_huff_count[0][lit]++;\n\n      lookahead_pos++;\n      dict_size = MZ_MIN(dict_size + 1, TDEFL_LZ_DICT_SIZE);\n      cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK;\n      lookahead_size--;\n\n      if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) {\n        int n;\n        d->m_lookahead_pos = lookahead_pos;\n        d->m_lookahead_size = lookahead_size;\n        d->m_dict_size = dict_size;\n        d->m_total_lz_bytes = total_lz_bytes;\n        d->m_pLZ_code_buf = pLZ_code_buf;\n        d->m_pLZ_flags = pLZ_flags;\n        d->m_num_flags_left = num_flags_left;\n        if ((n = tdefl_flush_block(d, 0)) != 0)\n          return (n < 0) ? MZ_FALSE : MZ_TRUE;\n        total_lz_bytes = d->m_total_lz_bytes;\n        pLZ_code_buf = d->m_pLZ_code_buf;\n        pLZ_flags = d->m_pLZ_flags;\n        num_flags_left = d->m_num_flags_left;\n      }\n    }\n  }\n\n  d->m_lookahead_pos = lookahead_pos;\n  d->m_lookahead_size = lookahead_size;\n  d->m_dict_size = dict_size;\n  d->m_total_lz_bytes = total_lz_bytes;\n  d->m_pLZ_code_buf = pLZ_code_buf;\n  d->m_pLZ_flags = pLZ_flags;\n  d->m_num_flags_left = num_flags_left;\n  return MZ_TRUE;\n}\n#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN\n\nstatic MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d,\n                                                mz_uint8 lit) {\n  d->m_total_lz_bytes++;\n  *d->m_pLZ_code_buf++ = lit;\n  *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1);\n  if (--d->m_num_flags_left == 0) {\n    d->m_num_flags_left = 8;\n    d->m_pLZ_flags = d->m_pLZ_code_buf++;\n  }\n  d->m_huff_count[0][lit]++;\n}\n\nstatic MZ_FORCEINLINE void\ntdefl_record_match(tdefl_compressor *d, mz_uint match_len, mz_uint match_dist) {\n  mz_uint32 s0, s1;\n\n  MZ_ASSERT((match_len >= TDEFL_MIN_MATCH_LEN) && (match_dist >= 1) &&\n            (match_dist <= TDEFL_LZ_DICT_SIZE));\n\n  d->m_total_lz_bytes += match_len;\n\n  d->m_pLZ_code_buf[0] = (mz_uint8)(match_len - TDEFL_MIN_MATCH_LEN);\n\n  match_dist -= 1;\n  d->m_pLZ_code_buf[1] = (mz_uint8)(match_dist & 0xFF);\n  d->m_pLZ_code_buf[2] = (mz_uint8)(match_dist >> 8);\n  d->m_pLZ_code_buf += 3;\n\n  *d->m_pLZ_flags = (mz_uint8)((*d->m_pLZ_flags >> 1) | 0x80);\n  if (--d->m_num_flags_left == 0) {\n    d->m_num_flags_left = 8;\n    d->m_pLZ_flags = d->m_pLZ_code_buf++;\n  }\n\n  s0 = s_tdefl_small_dist_sym[match_dist & 511];\n  s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127];\n  d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++;\n\n  if (match_len >= TDEFL_MIN_MATCH_LEN)\n    d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++;\n}\n\nstatic mz_bool tdefl_compress_normal(tdefl_compressor *d) {\n  const mz_uint8 *pSrc = d->m_pSrc;\n  size_t src_buf_left = d->m_src_buf_left;\n  tdefl_flush flush = d->m_flush;\n\n  while ((src_buf_left) || ((flush) && (d->m_lookahead_size))) {\n    mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos;\n    // Update dictionary and hash chains. Keeps the lookahead size equal to\n    // TDEFL_MAX_MATCH_LEN.\n    if ((d->m_lookahead_size + d->m_dict_size) >= (TDEFL_MIN_MATCH_LEN - 1)) {\n      mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) &\n                        TDEFL_LZ_DICT_SIZE_MASK,\n              ins_pos = d->m_lookahead_pos + d->m_lookahead_size - 2;\n      mz_uint hash = (d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK]\n                      << TDEFL_LZ_HASH_SHIFT) ^\n                     d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK];\n      mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(\n          src_buf_left, TDEFL_MAX_MATCH_LEN - d->m_lookahead_size);\n      const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process;\n      src_buf_left -= num_bytes_to_process;\n      d->m_lookahead_size += num_bytes_to_process;\n      while (pSrc != pSrc_end) {\n        mz_uint8 c = *pSrc++;\n        d->m_dict[dst_pos] = c;\n        if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1))\n          d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c;\n        hash = ((hash << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1);\n        d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash];\n        d->m_hash[hash] = (mz_uint16)(ins_pos);\n        dst_pos = (dst_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK;\n        ins_pos++;\n      }\n    } else {\n      while ((src_buf_left) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) {\n        mz_uint8 c = *pSrc++;\n        mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) &\n                          TDEFL_LZ_DICT_SIZE_MASK;\n        src_buf_left--;\n        d->m_dict[dst_pos] = c;\n        if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1))\n          d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c;\n        if ((++d->m_lookahead_size + d->m_dict_size) >= TDEFL_MIN_MATCH_LEN) {\n          mz_uint ins_pos = d->m_lookahead_pos + (d->m_lookahead_size - 1) - 2;\n          mz_uint hash = ((d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK]\n                           << (TDEFL_LZ_HASH_SHIFT * 2)) ^\n                          (d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK]\n                           << TDEFL_LZ_HASH_SHIFT) ^\n                          c) &\n                         (TDEFL_LZ_HASH_SIZE - 1);\n          d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash];\n          d->m_hash[hash] = (mz_uint16)(ins_pos);\n        }\n      }\n    }\n    d->m_dict_size =\n        MZ_MIN(TDEFL_LZ_DICT_SIZE - d->m_lookahead_size, d->m_dict_size);\n    if ((!flush) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN))\n      break;\n\n    // Simple lazy/greedy parsing state machine.\n    len_to_move = 1;\n    cur_match_dist = 0;\n    cur_match_len =\n        d->m_saved_match_len ? d->m_saved_match_len : (TDEFL_MIN_MATCH_LEN - 1);\n    cur_pos = d->m_lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK;\n    if (d->m_flags & (TDEFL_RLE_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS)) {\n      if ((d->m_dict_size) && (!(d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) {\n        mz_uint8 c = d->m_dict[(cur_pos - 1) & TDEFL_LZ_DICT_SIZE_MASK];\n        cur_match_len = 0;\n        while (cur_match_len < d->m_lookahead_size) {\n          if (d->m_dict[cur_pos + cur_match_len] != c)\n            break;\n          cur_match_len++;\n        }\n        if (cur_match_len < TDEFL_MIN_MATCH_LEN)\n          cur_match_len = 0;\n        else\n          cur_match_dist = 1;\n      }\n    } else {\n      tdefl_find_match(d, d->m_lookahead_pos, d->m_dict_size,\n                       d->m_lookahead_size, &cur_match_dist, &cur_match_len);\n    }\n    if (((cur_match_len == TDEFL_MIN_MATCH_LEN) &&\n         (cur_match_dist >= 8U * 1024U)) ||\n        (cur_pos == cur_match_dist) ||\n        ((d->m_flags & TDEFL_FILTER_MATCHES) && (cur_match_len <= 5))) {\n      cur_match_dist = cur_match_len = 0;\n    }\n    if (d->m_saved_match_len) {\n      if (cur_match_len > d->m_saved_match_len) {\n        tdefl_record_literal(d, (mz_uint8)d->m_saved_lit);\n        if (cur_match_len >= 128) {\n          tdefl_record_match(d, cur_match_len, cur_match_dist);\n          d->m_saved_match_len = 0;\n          len_to_move = cur_match_len;\n        } else {\n          d->m_saved_lit = d->m_dict[cur_pos];\n          d->m_saved_match_dist = cur_match_dist;\n          d->m_saved_match_len = cur_match_len;\n        }\n      } else {\n        tdefl_record_match(d, d->m_saved_match_len, d->m_saved_match_dist);\n        len_to_move = d->m_saved_match_len - 1;\n        d->m_saved_match_len = 0;\n      }\n    } else if (!cur_match_dist)\n      tdefl_record_literal(d,\n                           d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]);\n    else if ((d->m_greedy_parsing) || (d->m_flags & TDEFL_RLE_MATCHES) ||\n             (cur_match_len >= 128)) {\n      tdefl_record_match(d, cur_match_len, cur_match_dist);\n      len_to_move = cur_match_len;\n    } else {\n      d->m_saved_lit = d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)];\n      d->m_saved_match_dist = cur_match_dist;\n      d->m_saved_match_len = cur_match_len;\n    }\n    // Move the lookahead forward by len_to_move bytes.\n    d->m_lookahead_pos += len_to_move;\n    MZ_ASSERT(d->m_lookahead_size >= len_to_move);\n    d->m_lookahead_size -= len_to_move;\n    d->m_dict_size = MZ_MIN(d->m_dict_size + len_to_move, TDEFL_LZ_DICT_SIZE);\n    // Check if it's time to flush the current LZ codes to the internal output\n    // buffer.\n    if ((d->m_pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) ||\n        ((d->m_total_lz_bytes > 31 * 1024) &&\n         (((((mz_uint)(d->m_pLZ_code_buf - d->m_lz_code_buf) * 115) >> 7) >=\n           d->m_total_lz_bytes) ||\n          (d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS)))) {\n      int n;\n      d->m_pSrc = pSrc;\n      d->m_src_buf_left = src_buf_left;\n      if ((n = tdefl_flush_block(d, 0)) != 0)\n        return (n < 0) ? MZ_FALSE : MZ_TRUE;\n    }\n  }\n\n  d->m_pSrc = pSrc;\n  d->m_src_buf_left = src_buf_left;\n  return MZ_TRUE;\n}\n\nstatic tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d) {\n  if (d->m_pIn_buf_size) {\n    *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf;\n  }\n\n  if (d->m_pOut_buf_size) {\n    size_t n = MZ_MIN(*d->m_pOut_buf_size - d->m_out_buf_ofs,\n                      d->m_output_flush_remaining);\n    memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs,\n           d->m_output_buf + d->m_output_flush_ofs, n);\n    d->m_output_flush_ofs += (mz_uint)n;\n    d->m_output_flush_remaining -= (mz_uint)n;\n    d->m_out_buf_ofs += n;\n\n    *d->m_pOut_buf_size = d->m_out_buf_ofs;\n  }\n\n  return (d->m_finished && !d->m_output_flush_remaining) ? TDEFL_STATUS_DONE\n                                                         : TDEFL_STATUS_OKAY;\n}\n\ntdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf,\n                            size_t *pIn_buf_size, void *pOut_buf,\n                            size_t *pOut_buf_size, tdefl_flush flush) {\n  if (!d) {\n    if (pIn_buf_size)\n      *pIn_buf_size = 0;\n    if (pOut_buf_size)\n      *pOut_buf_size = 0;\n    return TDEFL_STATUS_BAD_PARAM;\n  }\n\n  d->m_pIn_buf = pIn_buf;\n  d->m_pIn_buf_size = pIn_buf_size;\n  d->m_pOut_buf = pOut_buf;\n  d->m_pOut_buf_size = pOut_buf_size;\n  d->m_pSrc = (const mz_uint8 *)(pIn_buf);\n  d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0;\n  d->m_out_buf_ofs = 0;\n  d->m_flush = flush;\n\n  if (((d->m_pPut_buf_func != NULL) ==\n       ((pOut_buf != NULL) || (pOut_buf_size != NULL))) ||\n      (d->m_prev_return_status != TDEFL_STATUS_OKAY) ||\n      (d->m_wants_to_finish && (flush != TDEFL_FINISH)) ||\n      (pIn_buf_size && *pIn_buf_size && !pIn_buf) ||\n      (pOut_buf_size && *pOut_buf_size && !pOut_buf)) {\n    if (pIn_buf_size)\n      *pIn_buf_size = 0;\n    if (pOut_buf_size)\n      *pOut_buf_size = 0;\n    return (d->m_prev_return_status = TDEFL_STATUS_BAD_PARAM);\n  }\n  d->m_wants_to_finish |= (flush == TDEFL_FINISH);\n\n  if ((d->m_output_flush_remaining) || (d->m_finished))\n    return (d->m_prev_return_status = tdefl_flush_output_buffer(d));\n\n#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN\n  if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) &&\n      ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) &&\n      ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS |\n                      TDEFL_RLE_MATCHES)) == 0)) {\n    if (!tdefl_compress_fast(d))\n      return d->m_prev_return_status;\n  } else\n#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN\n  {\n    if (!tdefl_compress_normal(d))\n      return d->m_prev_return_status;\n  }\n\n  if ((d->m_flags & (TDEFL_WRITE_ZLIB_HEADER | TDEFL_COMPUTE_ADLER32)) &&\n      (pIn_buf))\n    d->m_adler32 =\n        (mz_uint32)mz_adler32(d->m_adler32, (const mz_uint8 *)pIn_buf,\n                              d->m_pSrc - (const mz_uint8 *)pIn_buf);\n\n  if ((flush) && (!d->m_lookahead_size) && (!d->m_src_buf_left) &&\n      (!d->m_output_flush_remaining)) {\n    if (tdefl_flush_block(d, flush) < 0)\n      return d->m_prev_return_status;\n    d->m_finished = (flush == TDEFL_FINISH);\n    if (flush == TDEFL_FULL_FLUSH) {\n      MZ_CLEAR_OBJ(d->m_hash);\n      MZ_CLEAR_OBJ(d->m_next);\n      d->m_dict_size = 0;\n    }\n  }\n\n  return (d->m_prev_return_status = tdefl_flush_output_buffer(d));\n}\n\ntdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf,\n                                   size_t in_buf_size, tdefl_flush flush) {\n  MZ_ASSERT(d->m_pPut_buf_func);\n  return tdefl_compress(d, pIn_buf, &in_buf_size, NULL, NULL, flush);\n}\n\ntdefl_status tdefl_init(tdefl_compressor *d,\n                        tdefl_put_buf_func_ptr pPut_buf_func,\n                        void *pPut_buf_user, int flags) {\n  d->m_pPut_buf_func = pPut_buf_func;\n  d->m_pPut_buf_user = pPut_buf_user;\n  d->m_flags = (mz_uint)(flags);\n  d->m_max_probes[0] = 1 + ((flags & 0xFFF) + 2) / 3;\n  d->m_greedy_parsing = (flags & TDEFL_GREEDY_PARSING_FLAG) != 0;\n  d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3;\n  if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG))\n    MZ_CLEAR_OBJ(d->m_hash);\n  d->m_lookahead_pos = d->m_lookahead_size = d->m_dict_size =\n      d->m_total_lz_bytes = d->m_lz_code_buf_dict_pos = d->m_bits_in = 0;\n  d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished =\n      d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0;\n  d->m_pLZ_code_buf = d->m_lz_code_buf + 1;\n  d->m_pLZ_flags = d->m_lz_code_buf;\n  d->m_num_flags_left = 8;\n  d->m_pOutput_buf = d->m_output_buf;\n  d->m_pOutput_buf_end = d->m_output_buf;\n  d->m_prev_return_status = TDEFL_STATUS_OKAY;\n  d->m_saved_match_dist = d->m_saved_match_len = d->m_saved_lit = 0;\n  d->m_adler32 = 1;\n  d->m_pIn_buf = NULL;\n  d->m_pOut_buf = NULL;\n  d->m_pIn_buf_size = NULL;\n  d->m_pOut_buf_size = NULL;\n  d->m_flush = TDEFL_NO_FLUSH;\n  d->m_pSrc = NULL;\n  d->m_src_buf_left = 0;\n  d->m_out_buf_ofs = 0;\n  memset(&d->m_huff_count[0][0], 0,\n         sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0);\n  memset(&d->m_huff_count[1][0], 0,\n         sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1);\n  return TDEFL_STATUS_OKAY;\n}\n\ntdefl_status tdefl_get_prev_return_status(tdefl_compressor *d) {\n  return d->m_prev_return_status;\n}\n\nmz_uint32 tdefl_get_adler32(tdefl_compressor *d) { return d->m_adler32; }\n\ninline mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len,\n                                     tdefl_put_buf_func_ptr pPut_buf_func,\n                                     void *pPut_buf_user, int flags) {\n  tdefl_compressor *pComp;\n  mz_bool succeeded;\n  if (((buf_len) && (!pBuf)) || (!pPut_buf_func))\n    return MZ_FALSE;\n  pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor));\n  if (!pComp)\n    return MZ_FALSE;\n  succeeded = (tdefl_init(pComp, pPut_buf_func, pPut_buf_user, flags) ==\n               TDEFL_STATUS_OKAY);\n  succeeded =\n      succeeded && (tdefl_compress_buffer(pComp, pBuf, buf_len, TDEFL_FINISH) ==\n                    TDEFL_STATUS_DONE);\n  MZ_FREE(pComp);\n  return succeeded;\n}\n\ntypedef struct {\n  size_t m_size, m_capacity;\n  mz_uint8 *m_pBuf;\n  mz_bool m_expandable;\n} tdefl_output_buffer;\n\nstatic mz_bool tdefl_output_buffer_putter(const void *pBuf, int len,\n                                          void *pUser) {\n  tdefl_output_buffer *p = (tdefl_output_buffer *)pUser;\n  size_t new_size = p->m_size + len;\n  if (new_size > p->m_capacity) {\n    size_t new_capacity = p->m_capacity;\n    mz_uint8 *pNew_buf;\n    if (!p->m_expandable)\n      return MZ_FALSE;\n    do {\n      new_capacity = MZ_MAX(128U, new_capacity << 1U);\n    } while (new_size > new_capacity);\n    pNew_buf = (mz_uint8 *)MZ_REALLOC(p->m_pBuf, new_capacity);\n    if (!pNew_buf)\n      return MZ_FALSE;\n    p->m_pBuf = pNew_buf;\n    p->m_capacity = new_capacity;\n  }\n  memcpy((mz_uint8 *)p->m_pBuf + p->m_size, pBuf, len);\n  p->m_size = new_size;\n  return MZ_TRUE;\n}\n\ninline void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len,\n                                 size_t *pOut_len, int flags) {\n  tdefl_output_buffer out_buf;\n  MZ_CLEAR_OBJ(out_buf);\n  if (!pOut_len)\n    return MZ_FALSE;\n  else\n    *pOut_len = 0;\n  out_buf.m_expandable = MZ_TRUE;\n  if (!tdefl_compress_mem_to_output(\n          pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags))\n    return NULL;\n  *pOut_len = out_buf.m_size;\n  return out_buf.m_pBuf;\n}\n\ninline size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len,\n                                 const void *pSrc_buf, size_t src_buf_len,\n                                 int flags) {\n  tdefl_output_buffer out_buf;\n  MZ_CLEAR_OBJ(out_buf);\n  if (!pOut_buf)\n    return 0;\n  out_buf.m_pBuf = (mz_uint8 *)pOut_buf;\n  out_buf.m_capacity = out_buf_len;\n  if (!tdefl_compress_mem_to_output(\n          pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags))\n    return 0;\n  return out_buf.m_size;\n}\n\n#ifndef MINIZ_NO_ZLIB_APIS\nstatic const mz_uint s_tdefl_num_probes[11] = {0,   1,   6,   32,  16,  32,\n                                               128, 256, 512, 768, 1500};\n\n// level may actually range from [0,10] (10 is a \"hidden\" max level, where we\n// want a bit more compression and it's fine if throughput to fall off a cliff\n// on some files).\ninline mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits,\n                                                int strategy) {\n  mz_uint comp_flags =\n      s_tdefl_num_probes[(level >= 0) ? MZ_MIN(10, level) : MZ_DEFAULT_LEVEL] |\n      ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0);\n  if (window_bits > 0)\n    comp_flags |= TDEFL_WRITE_ZLIB_HEADER;\n\n  if (!level)\n    comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS;\n  else if (strategy == MZ_FILTERED)\n    comp_flags |= TDEFL_FILTER_MATCHES;\n  else if (strategy == MZ_HUFFMAN_ONLY)\n    comp_flags &= ~TDEFL_MAX_PROBES_MASK;\n  else if (strategy == MZ_FIXED)\n    comp_flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS;\n  else if (strategy == MZ_RLE)\n    comp_flags |= TDEFL_RLE_MATCHES;\n\n  return comp_flags;\n}\n#endif // MINIZ_NO_ZLIB_APIS\n\n#ifdef _MSC_VER\n#pragma warning(push)\n#pragma warning(disable : 4204) // nonstandard extension used : non-constant\n                                // aggregate initializer (also supported by GNU\n                                // C and C99, so no big deal)\n#endif\n\n// Simple PNG writer function by Alex Evans, 2011. Released into the public\n// domain: https://gist.github.com/908299, more context at\n// http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/.\n// This is actually a modification of Alex's original code so PNG files\n// generated by this function pass pngcheck.\ninline void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w,\n                                                 int h, int num_chans,\n                                                 size_t *pLen_out,\n                                                 mz_uint level, mz_bool flip) {\n  // Using a local copy of this array here in case MINIZ_NO_ZLIB_APIS was\n  // defined.\n  static const mz_uint s_tdefl_png_num_probes[11] = {\n      0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500};\n  tdefl_compressor *pComp =\n      (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor));\n  tdefl_output_buffer out_buf;\n  int i, bpl = w * num_chans, y, z;\n  mz_uint32 c;\n  *pLen_out = 0;\n  if (!pComp)\n    return NULL;\n  MZ_CLEAR_OBJ(out_buf);\n  out_buf.m_expandable = MZ_TRUE;\n  out_buf.m_capacity = 57 + MZ_MAX(64, (1 + bpl) * h);\n  if (NULL == (out_buf.m_pBuf = (mz_uint8 *)MZ_MALLOC(out_buf.m_capacity))) {\n    MZ_FREE(pComp);\n    return NULL;\n  }\n  // write dummy header\n  for (z = 41; z; --z)\n    tdefl_output_buffer_putter(&z, 1, &out_buf);\n  // compress image data\n  tdefl_init(pComp, tdefl_output_buffer_putter, &out_buf,\n             s_tdefl_png_num_probes[MZ_MIN(10, level)] |\n                 TDEFL_WRITE_ZLIB_HEADER);\n  for (y = 0; y < h; ++y) {\n    tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH);\n    tdefl_compress_buffer(pComp,\n                          (mz_uint8 *)pImage + (flip ? (h - 1 - y) : y) * bpl,\n                          bpl, TDEFL_NO_FLUSH);\n  }\n  if (tdefl_compress_buffer(pComp, NULL, 0, TDEFL_FINISH) !=\n      TDEFL_STATUS_DONE) {\n    MZ_FREE(pComp);\n    MZ_FREE(out_buf.m_pBuf);\n    return NULL;\n  }\n  // write real header\n  *pLen_out = out_buf.m_size - 41;\n  {\n    static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06};\n    mz_uint8 pnghdr[41] = {\n        0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,\n        0x49, 0x48, 0x44, 0x52, 0, 0, (mz_uint8)(w >> 8), (mz_uint8)w, 0, 0,\n        (mz_uint8)(h >> 8), (mz_uint8)h, 8, chans[num_chans], 0, 0, 0, 0, 0, 0,\n        0, (mz_uint8)(*pLen_out >> 24), (mz_uint8)(*pLen_out >> 16),\n        (mz_uint8)(*pLen_out >> 8), (mz_uint8)*pLen_out, 0x49, 0x44, 0x41,\n        0x54};\n    c = (mz_uint32)mz_crc32(MZ_CRC32_INIT, pnghdr + 12, 17);\n    for (i = 0; i < 4; ++i, c <<= 8)\n      ((mz_uint8 *)(pnghdr + 29))[i] = (mz_uint8)(c >> 24);\n    memcpy(out_buf.m_pBuf, pnghdr, 41);\n  }\n  // write footer (IDAT CRC-32, followed by IEND chunk)\n  if (!tdefl_output_buffer_putter(\n          \"\\0\\0\\0\\0\\0\\0\\0\\0\\x49\\x45\\x4e\\x44\\xae\\x42\\x60\\x82\", 16, &out_buf)) {\n    *pLen_out = 0;\n    MZ_FREE(pComp);\n    MZ_FREE(out_buf.m_pBuf);\n    return NULL;\n  }\n  c = (mz_uint32)mz_crc32(MZ_CRC32_INIT, out_buf.m_pBuf + 41 - 4,\n                          *pLen_out + 4);\n  for (i = 0; i < 4; ++i, c <<= 8)\n    (out_buf.m_pBuf + out_buf.m_size - 16)[i] = (mz_uint8)(c >> 24);\n  // compute final size of file, grab compressed data buffer and return\n  *pLen_out += 57;\n  MZ_FREE(pComp);\n  return out_buf.m_pBuf;\n}\ninline void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h,\n                                              int num_chans, size_t *pLen_out) {\n  // Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we\n  // can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's\n  // where #defined out)\n  return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans,\n                                                    pLen_out, 6, MZ_FALSE);\n}\n\n#ifdef _MSC_VER\n#pragma warning(pop)\n#endif\n\n// ------------------- .ZIP archive reading\n\n#ifndef MINIZ_NO_ARCHIVE_APIS\n\n#ifdef MINIZ_NO_STDIO\n#define MZ_FILE void *\n#else\n#include <stdio.h>\n#include <sys/stat.h>\n\n#if defined(_MSC_VER) || defined(__MINGW64__)\nstatic FILE *mz_fopen(const char *pFilename, const char *pMode) {\n  FILE *pFile = NULL;\n  fopen_s(&pFile, pFilename, pMode);\n  return pFile;\n}\nstatic FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream) {\n  FILE *pFile = NULL;\n  if (freopen_s(&pFile, pPath, pMode, pStream))\n    return NULL;\n  return pFile;\n}\n#ifndef MINIZ_NO_TIME\n#include <sys/utime.h>\n#endif\n#define MZ_FILE FILE\n#define MZ_FOPEN mz_fopen\n#define MZ_FCLOSE fclose\n#define MZ_FREAD fread\n#define MZ_FWRITE fwrite\n#define MZ_FTELL64 _ftelli64\n#define MZ_FSEEK64 _fseeki64\n#define MZ_FILE_STAT_STRUCT _stat\n#define MZ_FILE_STAT _stat\n#define MZ_FFLUSH fflush\n#define MZ_FREOPEN mz_freopen\n#define MZ_DELETE_FILE remove\n#elif defined(__MINGW32__)\n#ifndef MINIZ_NO_TIME\n#include <sys/utime.h>\n#endif\n#define MZ_FILE FILE\n#define MZ_FOPEN(f, m) fopen(f, m)\n#define MZ_FCLOSE fclose\n#define MZ_FREAD fread\n#define MZ_FWRITE fwrite\n#define MZ_FTELL64 ftello64\n#define MZ_FSEEK64 fseeko64\n#define MZ_FILE_STAT_STRUCT _stat\n#define MZ_FILE_STAT _stat\n#define MZ_FFLUSH fflush\n#define MZ_FREOPEN(f, m, s) freopen(f, m, s)\n#define MZ_DELETE_FILE remove\n#elif defined(__TINYC__)\n#ifndef MINIZ_NO_TIME\n#include <sys/utime.h>\n#endif\n#define MZ_FILE FILE\n#define MZ_FOPEN(f, m) fopen(f, m)\n#define MZ_FCLOSE fclose\n#define MZ_FREAD fread\n#define MZ_FWRITE fwrite\n#define MZ_FTELL64 ftell\n#define MZ_FSEEK64 fseek\n#define MZ_FILE_STAT_STRUCT stat\n#define MZ_FILE_STAT stat\n#define MZ_FFLUSH fflush\n#define MZ_FREOPEN(f, m, s) freopen(f, m, s)\n#define MZ_DELETE_FILE remove\n#elif defined(__GNUC__) && _LARGEFILE64_SOURCE\n#ifndef MINIZ_NO_TIME\n#include <utime.h>\n#endif\n#define MZ_FILE FILE\n#define MZ_FOPEN(f, m) fopen64(f, m)\n#define MZ_FCLOSE fclose\n#define MZ_FREAD fread\n#define MZ_FWRITE fwrite\n#define MZ_FTELL64 ftello64\n#define MZ_FSEEK64 fseeko64\n#define MZ_FILE_STAT_STRUCT stat64\n#define MZ_FILE_STAT stat64\n#define MZ_FFLUSH fflush\n#define MZ_FREOPEN(p, m, s) freopen64(p, m, s)\n#define MZ_DELETE_FILE remove\n#else\n#ifndef MINIZ_NO_TIME\n#include <utime.h>\n#endif\n#define MZ_FILE FILE\n#define MZ_FOPEN(f, m) fopen(f, m)\n#define MZ_FCLOSE fclose\n#define MZ_FREAD fread\n#define MZ_FWRITE fwrite\n#define MZ_FTELL64 ftello\n#define MZ_FSEEK64 fseeko\n#define MZ_FILE_STAT_STRUCT stat\n#define MZ_FILE_STAT stat\n#define MZ_FFLUSH fflush\n#define MZ_FREOPEN(f, m, s) freopen(f, m, s)\n#define MZ_DELETE_FILE remove\n#endif // #ifdef _MSC_VER\n#endif // #ifdef MINIZ_NO_STDIO\n\n#define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c))\n\n// Various ZIP archive enums. To completely avoid cross platform compiler\n// alignment and platform endian issues, miniz.c doesn't use structs for any of\n// this stuff.\nenum {\n  // ZIP archive identifiers and record sizes\n  MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50,\n  MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50,\n  MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50,\n  MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30,\n  MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46,\n  MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22,\n  // Central directory header record offsets\n  MZ_ZIP_CDH_SIG_OFS = 0,\n  MZ_ZIP_CDH_VERSION_MADE_BY_OFS = 4,\n  MZ_ZIP_CDH_VERSION_NEEDED_OFS = 6,\n  MZ_ZIP_CDH_BIT_FLAG_OFS = 8,\n  MZ_ZIP_CDH_METHOD_OFS = 10,\n  MZ_ZIP_CDH_FILE_TIME_OFS = 12,\n  MZ_ZIP_CDH_FILE_DATE_OFS = 14,\n  MZ_ZIP_CDH_CRC32_OFS = 16,\n  MZ_ZIP_CDH_COMPRESSED_SIZE_OFS = 20,\n  MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS = 24,\n  MZ_ZIP_CDH_FILENAME_LEN_OFS = 28,\n  MZ_ZIP_CDH_EXTRA_LEN_OFS = 30,\n  MZ_ZIP_CDH_COMMENT_LEN_OFS = 32,\n  MZ_ZIP_CDH_DISK_START_OFS = 34,\n  MZ_ZIP_CDH_INTERNAL_ATTR_OFS = 36,\n  MZ_ZIP_CDH_EXTERNAL_ATTR_OFS = 38,\n  MZ_ZIP_CDH_LOCAL_HEADER_OFS = 42,\n  // Local directory header offsets\n  MZ_ZIP_LDH_SIG_OFS = 0,\n  MZ_ZIP_LDH_VERSION_NEEDED_OFS = 4,\n  MZ_ZIP_LDH_BIT_FLAG_OFS = 6,\n  MZ_ZIP_LDH_METHOD_OFS = 8,\n  MZ_ZIP_LDH_FILE_TIME_OFS = 10,\n  MZ_ZIP_LDH_FILE_DATE_OFS = 12,\n  MZ_ZIP_LDH_CRC32_OFS = 14,\n  MZ_ZIP_LDH_COMPRESSED_SIZE_OFS = 18,\n  MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22,\n  MZ_ZIP_LDH_FILENAME_LEN_OFS = 26,\n  MZ_ZIP_LDH_EXTRA_LEN_OFS = 28,\n  // End of central directory offsets\n  MZ_ZIP_ECDH_SIG_OFS = 0,\n  MZ_ZIP_ECDH_NUM_THIS_DISK_OFS = 4,\n  MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS = 6,\n  MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 8,\n  MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS = 10,\n  MZ_ZIP_ECDH_CDIR_SIZE_OFS = 12,\n  MZ_ZIP_ECDH_CDIR_OFS_OFS = 16,\n  MZ_ZIP_ECDH_COMMENT_SIZE_OFS = 20,\n};\n\ntypedef struct {\n  void *m_p;\n  size_t m_size, m_capacity;\n  mz_uint m_element_size;\n} mz_zip_array;\n\nstruct mz_zip_internal_state_tag {\n  mz_zip_array m_central_dir;\n  mz_zip_array m_central_dir_offsets;\n  mz_zip_array m_sorted_central_dir_offsets;\n  MZ_FILE *m_pFile;\n  void *m_pMem;\n  size_t m_mem_size;\n  size_t m_mem_capacity;\n};\n\n#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size)                 \\\n  (array_ptr)->m_element_size = element_size\n#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index)                   \\\n  ((element_type *)((array_ptr)->m_p))[index]\n\nstatic MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip,\n                                              mz_zip_array *pArray) {\n  pZip->m_pFree(pZip->m_pAlloc_opaque, pArray->m_p);\n  memset(pArray, 0, sizeof(mz_zip_array));\n}\n\nstatic mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip,\n                                            mz_zip_array *pArray,\n                                            size_t min_new_capacity,\n                                            mz_uint growing) {\n  void *pNew_p;\n  size_t new_capacity = min_new_capacity;\n  MZ_ASSERT(pArray->m_element_size);\n  if (pArray->m_capacity >= min_new_capacity)\n    return MZ_TRUE;\n  if (growing) {\n    new_capacity = MZ_MAX(1, pArray->m_capacity);\n    while (new_capacity < min_new_capacity)\n      new_capacity *= 2;\n  }\n  if (NULL == (pNew_p = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pArray->m_p,\n                                         pArray->m_element_size, new_capacity)))\n    return MZ_FALSE;\n  pArray->m_p = pNew_p;\n  pArray->m_capacity = new_capacity;\n  return MZ_TRUE;\n}\n\nstatic MZ_FORCEINLINE mz_bool\nmz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray,\n                     size_t new_capacity, mz_uint growing) {\n  if (new_capacity > pArray->m_capacity) {\n    if (!mz_zip_array_ensure_capacity(pZip, pArray, new_capacity, growing))\n      return MZ_FALSE;\n  }\n  return MZ_TRUE;\n}\n\nstatic MZ_FORCEINLINE mz_bool\nmz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size,\n                    mz_uint growing) {\n  if (new_size > pArray->m_capacity) {\n    if (!mz_zip_array_ensure_capacity(pZip, pArray, new_size, growing))\n      return MZ_FALSE;\n  }\n  pArray->m_size = new_size;\n  return MZ_TRUE;\n}\n\nstatic MZ_FORCEINLINE mz_bool\nmz_zip_array_ensure_room(mz_zip_archive *pZip, mz_zip_array *pArray, size_t n) {\n  return mz_zip_array_reserve(pZip, pArray, pArray->m_size + n, MZ_TRUE);\n}\n\nstatic MZ_FORCEINLINE mz_bool\nmz_zip_array_push_back(mz_zip_archive *pZip, mz_zip_array *pArray,\n                       const void *pElements, size_t n) {\n  size_t orig_size = pArray->m_size;\n  if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE))\n    return MZ_FALSE;\n  memcpy((mz_uint8 *)pArray->m_p + orig_size * pArray->m_element_size,\n         pElements, n * pArray->m_element_size);\n  return MZ_TRUE;\n}\n\n#ifndef MINIZ_NO_TIME\nstatic time_t mz_zip_dos_to_time_t(int dos_time, int dos_date) {\n  struct tm tm;\n  memset(&tm, 0, sizeof(tm));\n  tm.tm_isdst = -1;\n  tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900;\n  tm.tm_mon = ((dos_date >> 5) & 15) - 1;\n  tm.tm_mday = dos_date & 31;\n  tm.tm_hour = (dos_time >> 11) & 31;\n  tm.tm_min = (dos_time >> 5) & 63;\n  tm.tm_sec = (dos_time << 1) & 62;\n  return mktime(&tm);\n}\n\nstatic void mz_zip_time_to_dos_time(time_t time, mz_uint16 *pDOS_time,\n                                    mz_uint16 *pDOS_date) {\n#ifdef _MSC_VER\n  struct tm tm_struct;\n  struct tm *tm = &tm_struct;\n  errno_t err = localtime_s(tm, &time);\n  if (err) {\n    *pDOS_date = 0;\n    *pDOS_time = 0;\n    return;\n  }\n#else\n  struct tm *tm = localtime(&time);\n#endif\n  *pDOS_time = (mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) +\n                           ((tm->tm_sec) >> 1));\n  *pDOS_date = (mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) +\n                           ((tm->tm_mon + 1) << 5) + tm->tm_mday);\n}\n#endif\n\n#ifndef MINIZ_NO_STDIO\nstatic mz_bool mz_zip_get_file_modified_time(const char *pFilename,\n                                             mz_uint16 *pDOS_time,\n                                             mz_uint16 *pDOS_date) {\n#ifdef MINIZ_NO_TIME\n  (void)pFilename;\n  *pDOS_date = *pDOS_time = 0;\n#else\n  struct MZ_FILE_STAT_STRUCT file_stat;\n  // On Linux with x86 glibc, this call will fail on large files (>= 0x80000000\n  // bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh.\n  if (MZ_FILE_STAT(pFilename, &file_stat) != 0)\n    return MZ_FALSE;\n  mz_zip_time_to_dos_time(file_stat.st_mtime, pDOS_time, pDOS_date);\n#endif // #ifdef MINIZ_NO_TIME\n  return MZ_TRUE;\n}\n\n#ifndef MINIZ_NO_TIME\nstatic mz_bool mz_zip_set_file_times(const char *pFilename, time_t access_time,\n                                     time_t modified_time) {\n  struct utimbuf t;\n  t.actime = access_time;\n  t.modtime = modified_time;\n  return !utime(pFilename, &t);\n}\n#endif // #ifndef MINIZ_NO_TIME\n#endif // #ifndef MINIZ_NO_STDIO\n\nstatic mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip,\n                                           mz_uint32 flags) {\n  (void)flags;\n  if ((!pZip) || (pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID))\n    return MZ_FALSE;\n\n  if (!pZip->m_pAlloc)\n    pZip->m_pAlloc = def_alloc_func;\n  if (!pZip->m_pFree)\n    pZip->m_pFree = def_free_func;\n  if (!pZip->m_pRealloc)\n    pZip->m_pRealloc = def_realloc_func;\n\n  pZip->m_zip_mode = MZ_ZIP_MODE_READING;\n  pZip->m_archive_size = 0;\n  pZip->m_central_directory_file_ofs = 0;\n  pZip->m_total_files = 0;\n\n  if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(\n                   pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state))))\n    return MZ_FALSE;\n  memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state));\n  MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir,\n                                sizeof(mz_uint8));\n  MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets,\n                                sizeof(mz_uint32));\n  MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets,\n                                sizeof(mz_uint32));\n  return MZ_TRUE;\n}\n\nstatic MZ_FORCEINLINE mz_bool\nmz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array,\n                            const mz_zip_array *pCentral_dir_offsets,\n                            mz_uint l_index, mz_uint r_index) {\n  const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(\n                           pCentral_dir_array, mz_uint8,\n                           MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32,\n                                                l_index)),\n                 *pE;\n  const mz_uint8 *pR =\n      &MZ_ZIP_ARRAY_ELEMENT(\n          pCentral_dir_array, mz_uint8,\n          MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index));\n  mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS),\n          r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS);\n  mz_uint8 l = 0, r = 0;\n  pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;\n  pR += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;\n  pE = pL + MZ_MIN(l_len, r_len);\n  while (pL < pE) {\n    if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR)))\n      break;\n    pL++;\n    pR++;\n  }\n  return (pL == pE) ? (l_len < r_len) : (l < r);\n}\n\n#define MZ_SWAP_UINT32(a, b)                                                   \\\n  do {                                                                         \\\n    mz_uint32 t = a;                                                           \\\n    a = b;                                                                     \\\n    b = t;                                                                     \\\n  }                                                                            \\\n  MZ_MACRO_END\n\n// Heap sort of lowercased filenames, used to help accelerate plain central\n// directory searches by mz_zip_reader_locate_file(). (Could also use qsort(),\n// but it could allocate memory.)\nstatic void\nmz_zip_reader_sort_central_dir_offsets_by_filename(mz_zip_archive *pZip) {\n  mz_zip_internal_state *pState = pZip->m_pState;\n  const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets;\n  const mz_zip_array *pCentral_dir = &pState->m_central_dir;\n  mz_uint32 *pIndices =\n      &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32,\n                            0);\n  const int size = pZip->m_total_files;\n  int start = (size - 2) >> 1, end;\n  while (start >= 0) {\n    int child, root = start;\n    for (;;) {\n      if ((child = (root << 1) + 1) >= size)\n        break;\n      child +=\n          (((child + 1) < size) &&\n           (mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets,\n                                        pIndices[child], pIndices[child + 1])));\n      if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets,\n                                       pIndices[root], pIndices[child]))\n        break;\n      MZ_SWAP_UINT32(pIndices[root], pIndices[child]);\n      root = child;\n    }\n    start--;\n  }\n\n  end = size - 1;\n  while (end > 0) {\n    int child, root = 0;\n    MZ_SWAP_UINT32(pIndices[end], pIndices[0]);\n    for (;;) {\n      if ((child = (root << 1) + 1) >= end)\n        break;\n      child +=\n          (((child + 1) < end) &&\n           mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets,\n                                       pIndices[child], pIndices[child + 1]));\n      if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets,\n                                       pIndices[root], pIndices[child]))\n        break;\n      MZ_SWAP_UINT32(pIndices[root], pIndices[child]);\n      root = child;\n    }\n    end--;\n  }\n}\n\nstatic mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip,\n                                              mz_uint32 flags) {\n  mz_uint cdir_size, num_this_disk, cdir_disk_index;\n  mz_uint64 cdir_ofs;\n  mz_int64 cur_file_ofs;\n  const mz_uint8 *p;\n  mz_uint32 buf_u32[4096 / sizeof(mz_uint32)];\n  mz_uint8 *pBuf = (mz_uint8 *)buf_u32;\n  mz_bool sort_central_dir =\n      ((flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0);\n  // Basic sanity checks - reject files which are too small, and check the first\n  // 4 bytes of the file to make sure a local header is there.\n  if (pZip->m_archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)\n    return MZ_FALSE;\n  // Find the end of central directory record by scanning the file from the end\n  // towards the beginning.\n  cur_file_ofs =\n      MZ_MAX((mz_int64)pZip->m_archive_size - (mz_int64)sizeof(buf_u32), 0);\n  for (;;) {\n    int i,\n        n = (int)MZ_MIN(sizeof(buf_u32), pZip->m_archive_size - cur_file_ofs);\n    if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint)n)\n      return MZ_FALSE;\n    for (i = n - 4; i >= 0; --i)\n      if (MZ_READ_LE32(pBuf + i) == MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG)\n        break;\n    if (i >= 0) {\n      cur_file_ofs += i;\n      break;\n    }\n    if ((!cur_file_ofs) || ((pZip->m_archive_size - cur_file_ofs) >=\n                            (0xFFFF + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)))\n      return MZ_FALSE;\n    cur_file_ofs = MZ_MAX(cur_file_ofs - (sizeof(buf_u32) - 3), 0);\n  }\n  // Read and verify the end of central directory record.\n  if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf,\n                    MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) !=\n      MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)\n    return MZ_FALSE;\n  if ((MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_SIG_OFS) !=\n       MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) ||\n      ((pZip->m_total_files =\n            MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS)) !=\n       MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS)))\n    return MZ_FALSE;\n\n  num_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_THIS_DISK_OFS);\n  cdir_disk_index = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS);\n  if (((num_this_disk | cdir_disk_index) != 0) &&\n      ((num_this_disk != 1) || (cdir_disk_index != 1)))\n    return MZ_FALSE;\n\n  if ((cdir_size = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_SIZE_OFS)) <\n      pZip->m_total_files * MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)\n    return MZ_FALSE;\n\n  cdir_ofs = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_OFS_OFS);\n  if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size)\n    return MZ_FALSE;\n\n  pZip->m_central_directory_file_ofs = cdir_ofs;\n\n  if (pZip->m_total_files) {\n    mz_uint i, n;\n\n    // Read the entire central directory into a heap block, and allocate another\n    // heap block to hold the unsorted central dir file record offsets, and\n    // another to hold the sorted indices.\n    if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size,\n                              MZ_FALSE)) ||\n        (!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets,\n                              pZip->m_total_files, MZ_FALSE)))\n      return MZ_FALSE;\n\n    if (sort_central_dir) {\n      if (!mz_zip_array_resize(pZip,\n                               &pZip->m_pState->m_sorted_central_dir_offsets,\n                               pZip->m_total_files, MZ_FALSE))\n        return MZ_FALSE;\n    }\n\n    if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs,\n                      pZip->m_pState->m_central_dir.m_p,\n                      cdir_size) != cdir_size)\n      return MZ_FALSE;\n\n    // Now create an index into the central directory file records, do some\n    // basic sanity checking on each record, and check for zip64 entries (which\n    // are not yet supported).\n    p = (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p;\n    for (n = cdir_size, i = 0; i < pZip->m_total_files; ++i) {\n      mz_uint total_header_size, comp_size, decomp_size, disk_index;\n      if ((n < MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) ||\n          (MZ_READ_LE32(p) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG))\n        return MZ_FALSE;\n      MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32,\n                           i) =\n          (mz_uint32)(p - (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p);\n      if (sort_central_dir)\n        MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_sorted_central_dir_offsets,\n                             mz_uint32, i) = i;\n      comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);\n      decomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);\n      if (((!MZ_READ_LE32(p + MZ_ZIP_CDH_METHOD_OFS)) &&\n           (decomp_size != comp_size)) ||\n          (decomp_size && !comp_size) || (decomp_size == 0xFFFFFFFF) ||\n          (comp_size == 0xFFFFFFFF))\n        return MZ_FALSE;\n      disk_index = MZ_READ_LE16(p + MZ_ZIP_CDH_DISK_START_OFS);\n      if ((disk_index != num_this_disk) && (disk_index != 1))\n        return MZ_FALSE;\n      if (((mz_uint64)MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS) +\n           MZ_ZIP_LOCAL_DIR_HEADER_SIZE + comp_size) > pZip->m_archive_size)\n        return MZ_FALSE;\n      if ((total_header_size = MZ_ZIP_CENTRAL_DIR_HEADER_SIZE +\n                               MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) +\n                               MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS) +\n                               MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS)) >\n          n)\n        return MZ_FALSE;\n      n -= total_header_size;\n      p += total_header_size;\n    }\n  }\n\n  if (sort_central_dir)\n    mz_zip_reader_sort_central_dir_offsets_by_filename(pZip);\n\n  return MZ_TRUE;\n}\n\nmz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size,\n                           mz_uint32 flags) {\n  if ((!pZip) || (!pZip->m_pRead))\n    return MZ_FALSE;\n  if (!mz_zip_reader_init_internal(pZip, flags))\n    return MZ_FALSE;\n  pZip->m_archive_size = size;\n  if (!mz_zip_reader_read_central_dir(pZip, flags)) {\n    mz_zip_reader_end(pZip);\n    return MZ_FALSE;\n  }\n  return MZ_TRUE;\n}\n\nstatic size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs,\n                                   void *pBuf, size_t n) {\n  mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;\n  size_t s = (file_ofs >= pZip->m_archive_size)\n                 ? 0\n                 : (size_t)MZ_MIN(pZip->m_archive_size - file_ofs, n);\n  memcpy(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s);\n  return s;\n}\n\nmz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem,\n                               size_t size, mz_uint32 flags) {\n  if (!mz_zip_reader_init_internal(pZip, flags))\n    return MZ_FALSE;\n  pZip->m_archive_size = size;\n  pZip->m_pRead = mz_zip_mem_read_func;\n  pZip->m_pIO_opaque = pZip;\n#ifdef __cplusplus\n  pZip->m_pState->m_pMem = const_cast<void *>(pMem);\n#else\n  pZip->m_pState->m_pMem = (void *)pMem;\n#endif\n  pZip->m_pState->m_mem_size = size;\n  if (!mz_zip_reader_read_central_dir(pZip, flags)) {\n    mz_zip_reader_end(pZip);\n    return MZ_FALSE;\n  }\n  return MZ_TRUE;\n}\n\n#ifndef MINIZ_NO_STDIO\nstatic size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs,\n                                    void *pBuf, size_t n) {\n  mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;\n  mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile);\n  if (((mz_int64)file_ofs < 0) ||\n      (((cur_ofs != (mz_int64)file_ofs)) &&\n       (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET))))\n    return 0;\n  return MZ_FREAD(pBuf, 1, n, pZip->m_pState->m_pFile);\n}\n\nmz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename,\n                                mz_uint32 flags) {\n  mz_uint64 file_size;\n  MZ_FILE *pFile = MZ_FOPEN(pFilename, \"rb\");\n  if (!pFile)\n    return MZ_FALSE;\n  if (MZ_FSEEK64(pFile, 0, SEEK_END)) {\n    MZ_FCLOSE(pFile);\n    return MZ_FALSE;\n  }\n  file_size = MZ_FTELL64(pFile);\n  if (!mz_zip_reader_init_internal(pZip, flags)) {\n    MZ_FCLOSE(pFile);\n    return MZ_FALSE;\n  }\n  pZip->m_pRead = mz_zip_file_read_func;\n  pZip->m_pIO_opaque = pZip;\n  pZip->m_pState->m_pFile = pFile;\n  pZip->m_archive_size = file_size;\n  if (!mz_zip_reader_read_central_dir(pZip, flags)) {\n    mz_zip_reader_end(pZip);\n    return MZ_FALSE;\n  }\n  return MZ_TRUE;\n}\n#endif // #ifndef MINIZ_NO_STDIO\n\nmz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip) {\n  return pZip ? pZip->m_total_files : 0;\n}\n\nstatic MZ_FORCEINLINE const mz_uint8 *\nmz_zip_reader_get_cdh(mz_zip_archive *pZip, mz_uint file_index) {\n  if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files) ||\n      (pZip->m_zip_mode != MZ_ZIP_MODE_READING))\n    return NULL;\n  return &MZ_ZIP_ARRAY_ELEMENT(\n             &pZip->m_pState->m_central_dir, mz_uint8,\n             MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets,\n                                  mz_uint32, file_index));\n}\n\nmz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip,\n                                        mz_uint file_index) {\n  mz_uint m_bit_flag;\n  const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);\n  if (!p)\n    return MZ_FALSE;\n  m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS);\n  return (m_bit_flag & 1);\n}\n\nmz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip,\n                                          mz_uint file_index) {\n  mz_uint filename_len, external_attr;\n  const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);\n  if (!p)\n    return MZ_FALSE;\n\n  // First see if the filename ends with a '/' character.\n  filename_len = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);\n  if (filename_len) {\n    if (*(p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_len - 1) == '/')\n      return MZ_TRUE;\n  }\n\n  // Bugfix: This code was also checking if the internal attribute was non-zero,\n  // which wasn't correct.\n  // Most/all zip writers (hopefully) set DOS file/directory attributes in the\n  // low 16-bits, so check for the DOS directory flag and ignore the source OS\n  // ID in the created by field.\n  // FIXME: Remove this check? Is it necessary - we already check the filename.\n  external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS);\n  if ((external_attr & 0x10) != 0)\n    return MZ_TRUE;\n\n  return MZ_FALSE;\n}\n\nmz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index,\n                                mz_zip_archive_file_stat *pStat) {\n  mz_uint n;\n  const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);\n  if ((!p) || (!pStat))\n    return MZ_FALSE;\n\n  // Unpack the central directory record.\n  pStat->m_file_index = file_index;\n  pStat->m_central_dir_ofs = MZ_ZIP_ARRAY_ELEMENT(\n      &pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index);\n  pStat->m_version_made_by = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS);\n  pStat->m_version_needed = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_NEEDED_OFS);\n  pStat->m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS);\n  pStat->m_method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS);\n#ifndef MINIZ_NO_TIME\n  pStat->m_time =\n      mz_zip_dos_to_time_t(MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_TIME_OFS),\n                           MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_DATE_OFS));\n#endif\n  pStat->m_crc32 = MZ_READ_LE32(p + MZ_ZIP_CDH_CRC32_OFS);\n  pStat->m_comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);\n  pStat->m_uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);\n  pStat->m_internal_attr = MZ_READ_LE16(p + MZ_ZIP_CDH_INTERNAL_ATTR_OFS);\n  pStat->m_external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS);\n  pStat->m_local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS);\n\n  // Copy as much of the filename and comment as possible.\n  n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);\n  n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE - 1);\n  memcpy(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n);\n  pStat->m_filename[n] = '\\0';\n\n  n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS);\n  n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1);\n  pStat->m_comment_size = n;\n  memcpy(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE +\n                               MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) +\n                               MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS),\n         n);\n  pStat->m_comment[n] = '\\0';\n\n  return MZ_TRUE;\n}\n\nmz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index,\n                                   char *pFilename, mz_uint filename_buf_size) {\n  mz_uint n;\n  const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);\n  if (!p) {\n    if (filename_buf_size)\n      pFilename[0] = '\\0';\n    return 0;\n  }\n  n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);\n  if (filename_buf_size) {\n    n = MZ_MIN(n, filename_buf_size - 1);\n    memcpy(pFilename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n);\n    pFilename[n] = '\\0';\n  }\n  return n + 1;\n}\n\nstatic MZ_FORCEINLINE mz_bool\nmz_zip_reader_string_equal(const char *pA, const char *pB, mz_uint len,\n                           mz_uint flags) {\n  mz_uint i;\n  if (flags & MZ_ZIP_FLAG_CASE_SENSITIVE)\n    return 0 == memcmp(pA, pB, len);\n  for (i = 0; i < len; ++i)\n    if (MZ_TOLOWER(pA[i]) != MZ_TOLOWER(pB[i]))\n      return MZ_FALSE;\n  return MZ_TRUE;\n}\n\nstatic MZ_FORCEINLINE int\nmz_zip_reader_filename_compare(const mz_zip_array *pCentral_dir_array,\n                               const mz_zip_array *pCentral_dir_offsets,\n                               mz_uint l_index, const char *pR, mz_uint r_len) {\n  const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(\n                           pCentral_dir_array, mz_uint8,\n                           MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32,\n                                                l_index)),\n                 *pE;\n  mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS);\n  mz_uint8 l = 0, r = 0;\n  pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;\n  pE = pL + MZ_MIN(l_len, r_len);\n  while (pL < pE) {\n    if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR)))\n      break;\n    pL++;\n    pR++;\n  }\n  return (pL == pE) ? (int)(l_len - r_len) : (l - r);\n}\n\nstatic int mz_zip_reader_locate_file_binary_search(mz_zip_archive *pZip,\n                                                   const char *pFilename) {\n  mz_zip_internal_state *pState = pZip->m_pState;\n  const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets;\n  const mz_zip_array *pCentral_dir = &pState->m_central_dir;\n  mz_uint32 *pIndices =\n      &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32,\n                            0);\n  const int size = pZip->m_total_files;\n  const mz_uint filename_len = (mz_uint)strlen(pFilename);\n  int l = 0, h = size - 1;\n  while (l <= h) {\n    int m = (l + h) >> 1, file_index = pIndices[m],\n        comp =\n            mz_zip_reader_filename_compare(pCentral_dir, pCentral_dir_offsets,\n                                           file_index, pFilename, filename_len);\n    if (!comp)\n      return file_index;\n    else if (comp < 0)\n      l = m + 1;\n    else\n      h = m - 1;\n  }\n  return -1;\n}\n\nint mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName,\n                              const char *pComment, mz_uint flags) {\n  mz_uint file_index;\n  size_t name_len, comment_len;\n  if ((!pZip) || (!pZip->m_pState) || (!pName) ||\n      (pZip->m_zip_mode != MZ_ZIP_MODE_READING))\n    return -1;\n  if (((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) &&\n      (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size))\n    return mz_zip_reader_locate_file_binary_search(pZip, pName);\n  name_len = strlen(pName);\n  if (name_len > 0xFFFF)\n    return -1;\n  comment_len = pComment ? strlen(pComment) : 0;\n  if (comment_len > 0xFFFF)\n    return -1;\n  for (file_index = 0; file_index < pZip->m_total_files; file_index++) {\n    const mz_uint8 *pHeader =\n        &MZ_ZIP_ARRAY_ELEMENT(\n            &pZip->m_pState->m_central_dir, mz_uint8,\n            MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets,\n                                 mz_uint32, file_index));\n    mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS);\n    const char *pFilename =\n        (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;\n    if (filename_len < name_len)\n      continue;\n    if (comment_len) {\n      mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS),\n              file_comment_len =\n                  MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS);\n      const char *pFile_comment = pFilename + filename_len + file_extra_len;\n      if ((file_comment_len != comment_len) ||\n          (!mz_zip_reader_string_equal(pComment, pFile_comment,\n                                       file_comment_len, flags)))\n        continue;\n    }\n    if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len)) {\n      int ofs = filename_len - 1;\n      do {\n        if ((pFilename[ofs] == '/') || (pFilename[ofs] == '\\\\') ||\n            (pFilename[ofs] == ':'))\n          break;\n      } while (--ofs >= 0);\n      ofs++;\n      pFilename += ofs;\n      filename_len -= ofs;\n    }\n    if ((filename_len == name_len) &&\n        (mz_zip_reader_string_equal(pName, pFilename, filename_len, flags)))\n      return file_index;\n  }\n  return -1;\n}\n\nmz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip,\n                                              mz_uint file_index, void *pBuf,\n                                              size_t buf_size, mz_uint flags,\n                                              void *pUser_read_buf,\n                                              size_t user_read_buf_size) {\n  int status = TINFL_STATUS_DONE;\n  mz_uint64 needed_size, cur_file_ofs, comp_remaining,\n      out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail;\n  mz_zip_archive_file_stat file_stat;\n  void *pRead_buf;\n  mz_uint32\n      local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) /\n                       sizeof(mz_uint32)];\n  mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;\n  tinfl_decompressor inflator;\n\n  if ((buf_size) && (!pBuf))\n    return MZ_FALSE;\n\n  if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat))\n    return MZ_FALSE;\n\n  // Empty file, or a directory (but not always a directory - I've seen odd zips\n  // with directories that have compressed data which inflates to 0 bytes)\n  if (!file_stat.m_comp_size)\n    return MZ_TRUE;\n\n  // Entry is a subdirectory (I've seen old zips with dir entries which have\n  // compressed deflate data which inflates to 0 bytes, but these entries claim\n  // to uncompress to 512 bytes in the headers).\n  // I'm torn how to handle this case - should it fail instead?\n  if (mz_zip_reader_is_file_a_directory(pZip, file_index))\n    return MZ_TRUE;\n\n  // Encryption and patch files are not supported.\n  if (file_stat.m_bit_flag & (1 | 32))\n    return MZ_FALSE;\n\n  // This function only supports stored and deflate.\n  if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) &&\n      (file_stat.m_method != MZ_DEFLATED))\n    return MZ_FALSE;\n\n  // Ensure supplied output buffer is large enough.\n  needed_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size\n                                                      : file_stat.m_uncomp_size;\n  if (buf_size < needed_size)\n    return MZ_FALSE;\n\n  // Read and parse the local directory entry.\n  cur_file_ofs = file_stat.m_local_header_ofs;\n  if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header,\n                    MZ_ZIP_LOCAL_DIR_HEADER_SIZE) !=\n      MZ_ZIP_LOCAL_DIR_HEADER_SIZE)\n    return MZ_FALSE;\n  if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)\n    return MZ_FALSE;\n\n  cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE +\n                  MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) +\n                  MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);\n  if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size)\n    return MZ_FALSE;\n\n  if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) {\n    // The file is stored or the caller has requested the compressed data.\n    if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf,\n                      (size_t)needed_size) != needed_size)\n      return MZ_FALSE;\n    return ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) != 0) ||\n           (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf,\n                     (size_t)file_stat.m_uncomp_size) == file_stat.m_crc32);\n  }\n\n  // Decompress the file either directly from memory or from a file input\n  // buffer.\n  tinfl_init(&inflator);\n\n  if (pZip->m_pState->m_pMem) {\n    // Read directly from the archive in memory.\n    pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs;\n    read_buf_size = read_buf_avail = file_stat.m_comp_size;\n    comp_remaining = 0;\n  } else if (pUser_read_buf) {\n    // Use a user provided read buffer.\n    if (!user_read_buf_size)\n      return MZ_FALSE;\n    pRead_buf = (mz_uint8 *)pUser_read_buf;\n    read_buf_size = user_read_buf_size;\n    read_buf_avail = 0;\n    comp_remaining = file_stat.m_comp_size;\n  } else {\n    // Temporarily allocate a read buffer.\n    read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE);\n#ifdef _MSC_VER\n    if (((0, sizeof(size_t) == sizeof(mz_uint32))) &&\n        (read_buf_size > 0x7FFFFFFF))\n#else\n    if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF))\n#endif\n      return MZ_FALSE;\n    if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1,\n                                            (size_t)read_buf_size)))\n      return MZ_FALSE;\n    read_buf_avail = 0;\n    comp_remaining = file_stat.m_comp_size;\n  }\n\n  do {\n    size_t in_buf_size,\n        out_buf_size = (size_t)(file_stat.m_uncomp_size - out_buf_ofs);\n    if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) {\n      read_buf_avail = MZ_MIN(read_buf_size, comp_remaining);\n      if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf,\n                        (size_t)read_buf_avail) != read_buf_avail) {\n        status = TINFL_STATUS_FAILED;\n        break;\n      }\n      cur_file_ofs += read_buf_avail;\n      comp_remaining -= read_buf_avail;\n      read_buf_ofs = 0;\n    }\n    in_buf_size = (size_t)read_buf_avail;\n    status = tinfl_decompress(\n        &inflator, (mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size,\n        (mz_uint8 *)pBuf, (mz_uint8 *)pBuf + out_buf_ofs, &out_buf_size,\n        TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF |\n            (comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0));\n    read_buf_avail -= in_buf_size;\n    read_buf_ofs += in_buf_size;\n    out_buf_ofs += out_buf_size;\n  } while (status == TINFL_STATUS_NEEDS_MORE_INPUT);\n\n  if (status == TINFL_STATUS_DONE) {\n    // Make sure the entire file was decompressed, and check its CRC.\n    if ((out_buf_ofs != file_stat.m_uncomp_size) ||\n        (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf,\n                  (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32))\n      status = TINFL_STATUS_FAILED;\n  }\n\n  if ((!pZip->m_pState->m_pMem) && (!pUser_read_buf))\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n\n  return status == TINFL_STATUS_DONE;\n}\n\nmz_bool mz_zip_reader_extract_file_to_mem_no_alloc(\n    mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size,\n    mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) {\n  int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags);\n  if (file_index < 0)\n    return MZ_FALSE;\n  return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size,\n                                               flags, pUser_read_buf,\n                                               user_read_buf_size);\n}\n\nmz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index,\n                                     void *pBuf, size_t buf_size,\n                                     mz_uint flags) {\n  return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size,\n                                               flags, NULL, 0);\n}\n\nmz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip,\n                                          const char *pFilename, void *pBuf,\n                                          size_t buf_size, mz_uint flags) {\n  return mz_zip_reader_extract_file_to_mem_no_alloc(pZip, pFilename, pBuf,\n                                                    buf_size, flags, NULL, 0);\n}\n\nvoid *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index,\n                                    size_t *pSize, mz_uint flags) {\n  mz_uint64 comp_size, uncomp_size, alloc_size;\n  const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);\n  void *pBuf;\n\n  if (pSize)\n    *pSize = 0;\n  if (!p)\n    return NULL;\n\n  comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);\n  uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);\n\n  alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size;\n#ifdef _MSC_VER\n  if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))\n#else\n  if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))\n#endif\n    return NULL;\n  if (NULL ==\n      (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size)))\n    return NULL;\n\n  if (!mz_zip_reader_extract_to_mem(pZip, file_index, pBuf, (size_t)alloc_size,\n                                    flags)) {\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);\n    return NULL;\n  }\n\n  if (pSize)\n    *pSize = (size_t)alloc_size;\n  return pBuf;\n}\n\nvoid *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip,\n                                         const char *pFilename, size_t *pSize,\n                                         mz_uint flags) {\n  int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags);\n  if (file_index < 0) {\n    if (pSize)\n      *pSize = 0;\n    return MZ_FALSE;\n  }\n  return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags);\n}\n\nmz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip,\n                                          mz_uint file_index,\n                                          mz_file_write_func pCallback,\n                                          void *pOpaque, mz_uint flags) {\n  int status = TINFL_STATUS_DONE;\n  mz_uint file_crc32 = MZ_CRC32_INIT;\n  mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining,\n                           out_buf_ofs = 0, cur_file_ofs;\n  mz_zip_archive_file_stat file_stat;\n  void *pRead_buf = NULL;\n  void *pWrite_buf = NULL;\n  mz_uint32\n      local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) /\n                       sizeof(mz_uint32)];\n  mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;\n\n  if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat))\n    return MZ_FALSE;\n\n  // Empty file, or a directory (but not always a directory - I've seen odd zips\n  // with directories that have compressed data which inflates to 0 bytes)\n  if (!file_stat.m_comp_size)\n    return MZ_TRUE;\n\n  // Entry is a subdirectory (I've seen old zips with dir entries which have\n  // compressed deflate data which inflates to 0 bytes, but these entries claim\n  // to uncompress to 512 bytes in the headers).\n  // I'm torn how to handle this case - should it fail instead?\n  if (mz_zip_reader_is_file_a_directory(pZip, file_index))\n    return MZ_TRUE;\n\n  // Encryption and patch files are not supported.\n  if (file_stat.m_bit_flag & (1 | 32))\n    return MZ_FALSE;\n\n  // This function only supports stored and deflate.\n  if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) &&\n      (file_stat.m_method != MZ_DEFLATED))\n    return MZ_FALSE;\n\n  // Read and parse the local directory entry.\n  cur_file_ofs = file_stat.m_local_header_ofs;\n  if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header,\n                    MZ_ZIP_LOCAL_DIR_HEADER_SIZE) !=\n      MZ_ZIP_LOCAL_DIR_HEADER_SIZE)\n    return MZ_FALSE;\n  if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)\n    return MZ_FALSE;\n\n  cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE +\n                  MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) +\n                  MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);\n  if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size)\n    return MZ_FALSE;\n\n  // Decompress the file either directly from memory or from a file input\n  // buffer.\n  if (pZip->m_pState->m_pMem) {\n    pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs;\n    read_buf_size = read_buf_avail = file_stat.m_comp_size;\n    comp_remaining = 0;\n  } else {\n    read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE);\n    if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1,\n                                            (size_t)read_buf_size)))\n      return MZ_FALSE;\n    read_buf_avail = 0;\n    comp_remaining = file_stat.m_comp_size;\n  }\n\n  if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) {\n    // The file is stored or the caller has requested the compressed data.\n    if (pZip->m_pState->m_pMem) {\n#ifdef _MSC_VER\n      if (((0, sizeof(size_t) == sizeof(mz_uint32))) &&\n          (file_stat.m_comp_size > 0xFFFFFFFF))\n#else\n      if (((sizeof(size_t) == sizeof(mz_uint32))) &&\n          (file_stat.m_comp_size > 0xFFFFFFFF))\n#endif\n        return MZ_FALSE;\n      if (pCallback(pOpaque, out_buf_ofs, pRead_buf,\n                    (size_t)file_stat.m_comp_size) != file_stat.m_comp_size)\n        status = TINFL_STATUS_FAILED;\n      else if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))\n        file_crc32 =\n            (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf,\n                                (size_t)file_stat.m_comp_size);\n      cur_file_ofs += file_stat.m_comp_size;\n      out_buf_ofs += file_stat.m_comp_size;\n      comp_remaining = 0;\n    } else {\n      while (comp_remaining) {\n        read_buf_avail = MZ_MIN(read_buf_size, comp_remaining);\n        if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf,\n                          (size_t)read_buf_avail) != read_buf_avail) {\n          status = TINFL_STATUS_FAILED;\n          break;\n        }\n\n        if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))\n          file_crc32 = (mz_uint32)mz_crc32(\n              file_crc32, (const mz_uint8 *)pRead_buf, (size_t)read_buf_avail);\n\n        if (pCallback(pOpaque, out_buf_ofs, pRead_buf,\n                      (size_t)read_buf_avail) != read_buf_avail) {\n          status = TINFL_STATUS_FAILED;\n          break;\n        }\n        cur_file_ofs += read_buf_avail;\n        out_buf_ofs += read_buf_avail;\n        comp_remaining -= read_buf_avail;\n      }\n    }\n  } else {\n    tinfl_decompressor inflator;\n    tinfl_init(&inflator);\n\n    if (NULL == (pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1,\n                                             TINFL_LZ_DICT_SIZE)))\n      status = TINFL_STATUS_FAILED;\n    else {\n      do {\n        mz_uint8 *pWrite_buf_cur =\n            (mz_uint8 *)pWrite_buf + (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1));\n        size_t in_buf_size,\n            out_buf_size =\n                TINFL_LZ_DICT_SIZE - (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1));\n        if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) {\n          read_buf_avail = MZ_MIN(read_buf_size, comp_remaining);\n          if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf,\n                            (size_t)read_buf_avail) != read_buf_avail) {\n            status = TINFL_STATUS_FAILED;\n            break;\n          }\n          cur_file_ofs += read_buf_avail;\n          comp_remaining -= read_buf_avail;\n          read_buf_ofs = 0;\n        }\n\n        in_buf_size = (size_t)read_buf_avail;\n        status = tinfl_decompress(\n            &inflator, (const mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size,\n            (mz_uint8 *)pWrite_buf, pWrite_buf_cur, &out_buf_size,\n            comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0);\n        read_buf_avail -= in_buf_size;\n        read_buf_ofs += in_buf_size;\n\n        if (out_buf_size) {\n          if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) !=\n              out_buf_size) {\n            status = TINFL_STATUS_FAILED;\n            break;\n          }\n          file_crc32 =\n              (mz_uint32)mz_crc32(file_crc32, pWrite_buf_cur, out_buf_size);\n          if ((out_buf_ofs += out_buf_size) > file_stat.m_uncomp_size) {\n            status = TINFL_STATUS_FAILED;\n            break;\n          }\n        }\n      } while ((status == TINFL_STATUS_NEEDS_MORE_INPUT) ||\n               (status == TINFL_STATUS_HAS_MORE_OUTPUT));\n    }\n  }\n\n  if ((status == TINFL_STATUS_DONE) &&\n      (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))) {\n    // Make sure the entire file was decompressed, and check its CRC.\n    if ((out_buf_ofs != file_stat.m_uncomp_size) ||\n        (file_crc32 != file_stat.m_crc32))\n      status = TINFL_STATUS_FAILED;\n  }\n\n  if (!pZip->m_pState->m_pMem)\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n  if (pWrite_buf)\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pWrite_buf);\n\n  return status == TINFL_STATUS_DONE;\n}\n\nmz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip,\n                                               const char *pFilename,\n                                               mz_file_write_func pCallback,\n                                               void *pOpaque, mz_uint flags) {\n  int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags);\n  if (file_index < 0)\n    return MZ_FALSE;\n  return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque,\n                                           flags);\n}\n\n#ifndef MINIZ_NO_STDIO\nstatic size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs,\n                                         const void *pBuf, size_t n) {\n  (void)ofs;\n  return MZ_FWRITE(pBuf, 1, n, (MZ_FILE *)pOpaque);\n}\n\nmz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index,\n                                      const char *pDst_filename,\n                                      mz_uint flags) {\n  mz_bool status;\n  mz_zip_archive_file_stat file_stat;\n  MZ_FILE *pFile;\n  if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat))\n    return MZ_FALSE;\n  pFile = MZ_FOPEN(pDst_filename, \"wb\");\n  if (!pFile)\n    return MZ_FALSE;\n  status = mz_zip_reader_extract_to_callback(\n      pZip, file_index, mz_zip_file_write_callback, pFile, flags);\n  if (MZ_FCLOSE(pFile) == EOF)\n    return MZ_FALSE;\n#ifndef MINIZ_NO_TIME\n  if (status)\n    mz_zip_set_file_times(pDst_filename, file_stat.m_time, file_stat.m_time);\n#endif\n  return status;\n}\n#endif // #ifndef MINIZ_NO_STDIO\n\nmz_bool mz_zip_reader_end(mz_zip_archive *pZip) {\n  if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) ||\n      (pZip->m_zip_mode != MZ_ZIP_MODE_READING))\n    return MZ_FALSE;\n\n  if (pZip->m_pState) {\n    mz_zip_internal_state *pState = pZip->m_pState;\n    pZip->m_pState = NULL;\n    mz_zip_array_clear(pZip, &pState->m_central_dir);\n    mz_zip_array_clear(pZip, &pState->m_central_dir_offsets);\n    mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets);\n\n#ifndef MINIZ_NO_STDIO\n    if (pState->m_pFile) {\n      MZ_FCLOSE(pState->m_pFile);\n      pState->m_pFile = NULL;\n    }\n#endif // #ifndef MINIZ_NO_STDIO\n\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pState);\n  }\n  pZip->m_zip_mode = MZ_ZIP_MODE_INVALID;\n\n  return MZ_TRUE;\n}\n\n#ifndef MINIZ_NO_STDIO\nmz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip,\n                                           const char *pArchive_filename,\n                                           const char *pDst_filename,\n                                           mz_uint flags) {\n  int file_index =\n      mz_zip_reader_locate_file(pZip, pArchive_filename, NULL, flags);\n  if (file_index < 0)\n    return MZ_FALSE;\n  return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags);\n}\n#endif\n\n// ------------------- .ZIP archive writing\n\n#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS\n\nstatic void mz_write_le16(mz_uint8 *p, mz_uint16 v) {\n  p[0] = (mz_uint8)v;\n  p[1] = (mz_uint8)(v >> 8);\n}\nstatic void mz_write_le32(mz_uint8 *p, mz_uint32 v) {\n  p[0] = (mz_uint8)v;\n  p[1] = (mz_uint8)(v >> 8);\n  p[2] = (mz_uint8)(v >> 16);\n  p[3] = (mz_uint8)(v >> 24);\n}\n#define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v))\n#define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v))\n\nmz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size) {\n  if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) ||\n      (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID))\n    return MZ_FALSE;\n\n  if (pZip->m_file_offset_alignment) {\n    // Ensure user specified file offset alignment is a power of 2.\n    if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1))\n      return MZ_FALSE;\n  }\n\n  if (!pZip->m_pAlloc)\n    pZip->m_pAlloc = def_alloc_func;\n  if (!pZip->m_pFree)\n    pZip->m_pFree = def_free_func;\n  if (!pZip->m_pRealloc)\n    pZip->m_pRealloc = def_realloc_func;\n\n  pZip->m_zip_mode = MZ_ZIP_MODE_WRITING;\n  pZip->m_archive_size = existing_size;\n  pZip->m_central_directory_file_ofs = 0;\n  pZip->m_total_files = 0;\n\n  if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(\n                   pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state))))\n    return MZ_FALSE;\n  memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state));\n  MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir,\n                                sizeof(mz_uint8));\n  MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets,\n                                sizeof(mz_uint32));\n  MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets,\n                                sizeof(mz_uint32));\n  return MZ_TRUE;\n}\n\nstatic size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs,\n                                     const void *pBuf, size_t n) {\n  mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;\n  mz_zip_internal_state *pState = pZip->m_pState;\n  mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size);\n#ifdef _MSC_VER\n  if ((!n) ||\n      ((0, sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF)))\n#else\n  if ((!n) ||\n      ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF)))\n#endif\n    return 0;\n  if (new_size > pState->m_mem_capacity) {\n    void *pNew_block;\n    size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity);\n    while (new_capacity < new_size)\n      new_capacity *= 2;\n    if (NULL == (pNew_block = pZip->m_pRealloc(\n                     pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity)))\n      return 0;\n    pState->m_pMem = pNew_block;\n    pState->m_mem_capacity = new_capacity;\n  }\n  memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n);\n  pState->m_mem_size = (size_t)new_size;\n  return n;\n}\n\nmz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip,\n                                size_t size_to_reserve_at_beginning,\n                                size_t initial_allocation_size) {\n  pZip->m_pWrite = mz_zip_heap_write_func;\n  pZip->m_pIO_opaque = pZip;\n  if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning))\n    return MZ_FALSE;\n  if (0 != (initial_allocation_size = MZ_MAX(initial_allocation_size,\n                                             size_to_reserve_at_beginning))) {\n    if (NULL == (pZip->m_pState->m_pMem = pZip->m_pAlloc(\n                     pZip->m_pAlloc_opaque, 1, initial_allocation_size))) {\n      mz_zip_writer_end(pZip);\n      return MZ_FALSE;\n    }\n    pZip->m_pState->m_mem_capacity = initial_allocation_size;\n  }\n  return MZ_TRUE;\n}\n\n#ifndef MINIZ_NO_STDIO\nstatic size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs,\n                                     const void *pBuf, size_t n) {\n  mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;\n  mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile);\n  if (((mz_int64)file_ofs < 0) ||\n      (((cur_ofs != (mz_int64)file_ofs)) &&\n       (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET))))\n    return 0;\n  return MZ_FWRITE(pBuf, 1, n, pZip->m_pState->m_pFile);\n}\n\nmz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename,\n                                mz_uint64 size_to_reserve_at_beginning) {\n  MZ_FILE *pFile;\n  pZip->m_pWrite = mz_zip_file_write_func;\n  pZip->m_pIO_opaque = pZip;\n  if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning))\n    return MZ_FALSE;\n  if (NULL == (pFile = MZ_FOPEN(pFilename, \"wb\"))) {\n    mz_zip_writer_end(pZip);\n    return MZ_FALSE;\n  }\n  pZip->m_pState->m_pFile = pFile;\n  if (size_to_reserve_at_beginning) {\n    mz_uint64 cur_ofs = 0;\n    char buf[4096];\n    MZ_CLEAR_OBJ(buf);\n    do {\n      size_t n = (size_t)MZ_MIN(sizeof(buf), size_to_reserve_at_beginning);\n      if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_ofs, buf, n) != n) {\n        mz_zip_writer_end(pZip);\n        return MZ_FALSE;\n      }\n      cur_ofs += n;\n      size_to_reserve_at_beginning -= n;\n    } while (size_to_reserve_at_beginning);\n  }\n  return MZ_TRUE;\n}\n#endif // #ifndef MINIZ_NO_STDIO\n\nmz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip,\n                                       const char *pFilename) {\n  mz_zip_internal_state *pState;\n  if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING))\n    return MZ_FALSE;\n  // No sense in trying to write to an archive that's already at the support max\n  // size\n  if ((pZip->m_total_files == 0xFFFF) ||\n      ((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE +\n        MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  pState = pZip->m_pState;\n\n  if (pState->m_pFile) {\n#ifdef MINIZ_NO_STDIO\n    pFilename;\n    return MZ_FALSE;\n#else\n    // Archive is being read from stdio - try to reopen as writable.\n    if (pZip->m_pIO_opaque != pZip)\n      return MZ_FALSE;\n    if (!pFilename)\n      return MZ_FALSE;\n    pZip->m_pWrite = mz_zip_file_write_func;\n    if (NULL ==\n        (pState->m_pFile = MZ_FREOPEN(pFilename, \"r+b\", pState->m_pFile))) {\n      // The mz_zip_archive is now in a bogus state because pState->m_pFile is\n      // NULL, so just close it.\n      mz_zip_reader_end(pZip);\n      return MZ_FALSE;\n    }\n#endif // #ifdef MINIZ_NO_STDIO\n  } else if (pState->m_pMem) {\n    // Archive lives in a memory block. Assume it's from the heap that we can\n    // resize using the realloc callback.\n    if (pZip->m_pIO_opaque != pZip)\n      return MZ_FALSE;\n    pState->m_mem_capacity = pState->m_mem_size;\n    pZip->m_pWrite = mz_zip_heap_write_func;\n  }\n  // Archive is being read via a user provided read function - make sure the\n  // user has specified a write function too.\n  else if (!pZip->m_pWrite)\n    return MZ_FALSE;\n\n  // Start writing new files at the archive's current central directory\n  // location.\n  pZip->m_archive_size = pZip->m_central_directory_file_ofs;\n  pZip->m_zip_mode = MZ_ZIP_MODE_WRITING;\n  pZip->m_central_directory_file_ofs = 0;\n\n  return MZ_TRUE;\n}\n\nmz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name,\n                              const void *pBuf, size_t buf_size,\n                              mz_uint level_and_flags) {\n  return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0,\n                                  level_and_flags, 0, 0);\n}\n\ntypedef struct {\n  mz_zip_archive *m_pZip;\n  mz_uint64 m_cur_archive_file_ofs;\n  mz_uint64 m_comp_size;\n} mz_zip_writer_add_state;\n\nstatic mz_bool mz_zip_writer_add_put_buf_callback(const void *pBuf, int len,\n                                                  void *pUser) {\n  mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser;\n  if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque,\n                                    pState->m_cur_archive_file_ofs, pBuf,\n                                    len) != len)\n    return MZ_FALSE;\n  pState->m_cur_archive_file_ofs += len;\n  pState->m_comp_size += len;\n  return MZ_TRUE;\n}\n\nstatic mz_bool mz_zip_writer_create_local_dir_header(\n    mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size,\n    mz_uint16 extra_size, mz_uint64 uncomp_size, mz_uint64 comp_size,\n    mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags,\n    mz_uint16 dos_time, mz_uint16 dos_date) {\n  (void)pZip;\n  memset(pDst, 0, MZ_ZIP_LOCAL_DIR_HEADER_SIZE);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_SIG_OFS, MZ_ZIP_LOCAL_DIR_HEADER_SIG);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_VERSION_NEEDED_OFS, method ? 20 : 0);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_BIT_FLAG_OFS, bit_flags);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_METHOD_OFS, method);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_TIME_OFS, dos_time);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_DATE_OFS, dos_date);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_CRC32_OFS, uncomp_crc32);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS, comp_size);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS, uncomp_size);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILENAME_LEN_OFS, filename_size);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_EXTRA_LEN_OFS, extra_size);\n  return MZ_TRUE;\n}\n\nstatic mz_bool mz_zip_writer_create_central_dir_header(\n    mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size,\n    mz_uint16 extra_size, mz_uint16 comment_size, mz_uint64 uncomp_size,\n    mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method,\n    mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date,\n    mz_uint64 local_header_ofs, mz_uint32 ext_attributes) {\n  (void)pZip;\n  memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_TIME_OFS, dos_time);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_DATE_OFS, dos_date);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_CRC32_OFS, uncomp_crc32);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, comp_size);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, uncomp_size);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILENAME_LEN_OFS, filename_size);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_EXTRA_LEN_OFS, extra_size);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_COMMENT_LEN_OFS, comment_size);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, ext_attributes);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_header_ofs);\n  return MZ_TRUE;\n}\n\nstatic mz_bool mz_zip_writer_add_to_central_dir(\n    mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size,\n    const void *pExtra, mz_uint16 extra_size, const void *pComment,\n    mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size,\n    mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags,\n    mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs,\n    mz_uint32 ext_attributes) {\n  mz_zip_internal_state *pState = pZip->m_pState;\n  mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size;\n  size_t orig_central_dir_size = pState->m_central_dir.m_size;\n  mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE];\n\n  // No zip64 support yet\n  if ((local_header_ofs > 0xFFFFFFFF) ||\n      (((mz_uint64)pState->m_central_dir.m_size +\n        MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size +\n        comment_size) > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  if (!mz_zip_writer_create_central_dir_header(\n          pZip, central_dir_header, filename_size, extra_size, comment_size,\n          uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time,\n          dos_date, local_header_ofs, ext_attributes))\n    return MZ_FALSE;\n\n  if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header,\n                               MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) ||\n      (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename,\n                               filename_size)) ||\n      (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra,\n                               extra_size)) ||\n      (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment,\n                               comment_size)) ||\n      (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets,\n                               &central_dir_ofs, 1))) {\n    // Try to push the central directory array back into its original state.\n    mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size,\n                        MZ_FALSE);\n    return MZ_FALSE;\n  }\n\n  return MZ_TRUE;\n}\n\nstatic mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name) {\n  // Basic ZIP archive filename validity checks: Valid filenames cannot start\n  // with a forward slash, cannot contain a drive letter, and cannot use\n  // DOS-style backward slashes.\n  if (*pArchive_name == '/')\n    return MZ_FALSE;\n  while (*pArchive_name) {\n    if ((*pArchive_name == '\\\\') || (*pArchive_name == ':'))\n      return MZ_FALSE;\n    pArchive_name++;\n  }\n  return MZ_TRUE;\n}\n\nstatic mz_uint\nmz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip) {\n  mz_uint32 n;\n  if (!pZip->m_file_offset_alignment)\n    return 0;\n  n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1));\n  return (pZip->m_file_offset_alignment - n) &\n         (pZip->m_file_offset_alignment - 1);\n}\n\nstatic mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip,\n                                         mz_uint64 cur_file_ofs, mz_uint32 n) {\n  char buf[4096];\n  memset(buf, 0, MZ_MIN(sizeof(buf), n));\n  while (n) {\n    mz_uint32 s = MZ_MIN(sizeof(buf), n);\n    if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s)\n      return MZ_FALSE;\n    cur_file_ofs += s;\n    n -= s;\n  }\n  return MZ_TRUE;\n}\n\nmz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip,\n                                 const char *pArchive_name, const void *pBuf,\n                                 size_t buf_size, const void *pComment,\n                                 mz_uint16 comment_size,\n                                 mz_uint level_and_flags, mz_uint64 uncomp_size,\n                                 mz_uint32 uncomp_crc32) {\n  mz_uint16 method = 0, dos_time = 0, dos_date = 0;\n  mz_uint level, ext_attributes = 0, num_alignment_padding_bytes;\n  mz_uint64 local_dir_header_ofs = pZip->m_archive_size,\n            cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0;\n  size_t archive_name_size;\n  mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE];\n  tdefl_compressor *pComp = NULL;\n  mz_bool store_data_uncompressed;\n  mz_zip_internal_state *pState;\n\n  if ((int)level_and_flags < 0)\n    level_and_flags = MZ_DEFAULT_LEVEL;\n  level = level_and_flags & 0xF;\n  store_data_uncompressed =\n      ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA));\n\n  if ((!pZip) || (!pZip->m_pState) ||\n      (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) ||\n      (!pArchive_name) || ((comment_size) && (!pComment)) ||\n      (pZip->m_total_files == 0xFFFF) || (level > MZ_UBER_COMPRESSION))\n    return MZ_FALSE;\n\n  pState = pZip->m_pState;\n\n  if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size))\n    return MZ_FALSE;\n  // No zip64 support yet\n  if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF))\n    return MZ_FALSE;\n  if (!mz_zip_writer_validate_archive_name(pArchive_name))\n    return MZ_FALSE;\n\n#ifndef MINIZ_NO_TIME\n  {\n    time_t cur_time;\n    time(&cur_time);\n    mz_zip_time_to_dos_time(cur_time, &dos_time, &dos_date);\n  }\n#endif // #ifndef MINIZ_NO_TIME\n\n  archive_name_size = strlen(pArchive_name);\n  if (archive_name_size > 0xFFFF)\n    return MZ_FALSE;\n\n  num_alignment_padding_bytes =\n      mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);\n\n  // no zip64 support yet\n  if ((pZip->m_total_files == 0xFFFF) ||\n      ((pZip->m_archive_size + num_alignment_padding_bytes +\n        MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE +\n        comment_size + archive_name_size) > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/')) {\n    // Set DOS Subdirectory attribute bit.\n    ext_attributes |= 0x10;\n    // Subdirectories cannot contain data.\n    if ((buf_size) || (uncomp_size))\n      return MZ_FALSE;\n  }\n\n  // Try to do any allocations before writing to the archive, so if an\n  // allocation fails the file remains unmodified. (A good idea if we're doing\n  // an in-place modification.)\n  if ((!mz_zip_array_ensure_room(pZip, &pState->m_central_dir,\n                                 MZ_ZIP_CENTRAL_DIR_HEADER_SIZE +\n                                     archive_name_size + comment_size)) ||\n      (!mz_zip_array_ensure_room(pZip, &pState->m_central_dir_offsets, 1)))\n    return MZ_FALSE;\n\n  if ((!store_data_uncompressed) && (buf_size)) {\n    if (NULL == (pComp = (tdefl_compressor *)pZip->m_pAlloc(\n                     pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor))))\n      return MZ_FALSE;\n  }\n\n  if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs,\n                                 num_alignment_padding_bytes +\n                                     sizeof(local_dir_header))) {\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n    return MZ_FALSE;\n  }\n  local_dir_header_ofs += num_alignment_padding_bytes;\n  if (pZip->m_file_offset_alignment) {\n    MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) ==\n              0);\n  }\n  cur_archive_file_ofs +=\n      num_alignment_padding_bytes + sizeof(local_dir_header);\n\n  MZ_CLEAR_OBJ(local_dir_header);\n  if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name,\n                     archive_name_size) != archive_name_size) {\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n    return MZ_FALSE;\n  }\n  cur_archive_file_ofs += archive_name_size;\n\n  if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) {\n    uncomp_crc32 =\n        (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, buf_size);\n    uncomp_size = buf_size;\n    if (uncomp_size <= 3) {\n      level = 0;\n      store_data_uncompressed = MZ_TRUE;\n    }\n  }\n\n  if (store_data_uncompressed) {\n    if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pBuf,\n                       buf_size) != buf_size) {\n      pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n      return MZ_FALSE;\n    }\n\n    cur_archive_file_ofs += buf_size;\n    comp_size = buf_size;\n\n    if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)\n      method = MZ_DEFLATED;\n  } else if (buf_size) {\n    mz_zip_writer_add_state state;\n\n    state.m_pZip = pZip;\n    state.m_cur_archive_file_ofs = cur_archive_file_ofs;\n    state.m_comp_size = 0;\n\n    if ((tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state,\n                    tdefl_create_comp_flags_from_zip_params(\n                        level, -15, MZ_DEFAULT_STRATEGY)) !=\n         TDEFL_STATUS_OKAY) ||\n        (tdefl_compress_buffer(pComp, pBuf, buf_size, TDEFL_FINISH) !=\n         TDEFL_STATUS_DONE)) {\n      pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n      return MZ_FALSE;\n    }\n\n    comp_size = state.m_comp_size;\n    cur_archive_file_ofs = state.m_cur_archive_file_ofs;\n\n    method = MZ_DEFLATED;\n  }\n\n  pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n  pComp = NULL;\n\n  // no zip64 support yet\n  if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  if (!mz_zip_writer_create_local_dir_header(\n          pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size,\n          comp_size, uncomp_crc32, method, 0, dos_time, dos_date))\n    return MZ_FALSE;\n\n  if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header,\n                     sizeof(local_dir_header)) != sizeof(local_dir_header))\n    return MZ_FALSE;\n\n  if (!mz_zip_writer_add_to_central_dir(\n          pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment,\n          comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0,\n          dos_time, dos_date, local_dir_header_ofs, ext_attributes))\n    return MZ_FALSE;\n\n  pZip->m_total_files++;\n  pZip->m_archive_size = cur_archive_file_ofs;\n\n  return MZ_TRUE;\n}\n\n#ifndef MINIZ_NO_STDIO\nmz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name,\n                               const char *pSrc_filename, const void *pComment,\n                               mz_uint16 comment_size,\n                               mz_uint level_and_flags) {\n  mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes;\n  mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0;\n  mz_uint64 local_dir_header_ofs = pZip->m_archive_size,\n            cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0,\n            comp_size = 0;\n  size_t archive_name_size;\n  mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE];\n  MZ_FILE *pSrc_file = NULL;\n\n  if ((int)level_and_flags < 0)\n    level_and_flags = MZ_DEFAULT_LEVEL;\n  level = level_and_flags & 0xF;\n\n  if ((!pZip) || (!pZip->m_pState) ||\n      (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) ||\n      ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION))\n    return MZ_FALSE;\n  if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)\n    return MZ_FALSE;\n  if (!mz_zip_writer_validate_archive_name(pArchive_name))\n    return MZ_FALSE;\n\n  archive_name_size = strlen(pArchive_name);\n  if (archive_name_size > 0xFFFF)\n    return MZ_FALSE;\n\n  num_alignment_padding_bytes =\n      mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);\n\n  // no zip64 support yet\n  if ((pZip->m_total_files == 0xFFFF) ||\n      ((pZip->m_archive_size + num_alignment_padding_bytes +\n        MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE +\n        comment_size + archive_name_size) > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date))\n    return MZ_FALSE;\n\n  pSrc_file = MZ_FOPEN(pSrc_filename, \"rb\");\n  if (!pSrc_file)\n    return MZ_FALSE;\n  MZ_FSEEK64(pSrc_file, 0, SEEK_END);\n  uncomp_size = MZ_FTELL64(pSrc_file);\n  MZ_FSEEK64(pSrc_file, 0, SEEK_SET);\n\n  if (uncomp_size > 0xFFFFFFFF) {\n    // No zip64 support yet\n    MZ_FCLOSE(pSrc_file);\n    return MZ_FALSE;\n  }\n  if (uncomp_size <= 3)\n    level = 0;\n\n  if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs,\n                                 num_alignment_padding_bytes +\n                                     sizeof(local_dir_header))) {\n    MZ_FCLOSE(pSrc_file);\n    return MZ_FALSE;\n  }\n  local_dir_header_ofs += num_alignment_padding_bytes;\n  if (pZip->m_file_offset_alignment) {\n    MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) ==\n              0);\n  }\n  cur_archive_file_ofs +=\n      num_alignment_padding_bytes + sizeof(local_dir_header);\n\n  MZ_CLEAR_OBJ(local_dir_header);\n  if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name,\n                     archive_name_size) != archive_name_size) {\n    MZ_FCLOSE(pSrc_file);\n    return MZ_FALSE;\n  }\n  cur_archive_file_ofs += archive_name_size;\n\n  if (uncomp_size) {\n    mz_uint64 uncomp_remaining = uncomp_size;\n    void *pRead_buf =\n        pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE);\n    if (!pRead_buf) {\n      MZ_FCLOSE(pSrc_file);\n      return MZ_FALSE;\n    }\n\n    if (!level) {\n      while (uncomp_remaining) {\n        mz_uint n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining);\n        if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) ||\n            (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf,\n                            n) != n)) {\n          pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n          MZ_FCLOSE(pSrc_file);\n          return MZ_FALSE;\n        }\n        uncomp_crc32 =\n            (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n);\n        uncomp_remaining -= n;\n        cur_archive_file_ofs += n;\n      }\n      comp_size = uncomp_size;\n    } else {\n      mz_bool result = MZ_FALSE;\n      mz_zip_writer_add_state state;\n      tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc(\n          pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor));\n      if (!pComp) {\n        pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n        MZ_FCLOSE(pSrc_file);\n        return MZ_FALSE;\n      }\n\n      state.m_pZip = pZip;\n      state.m_cur_archive_file_ofs = cur_archive_file_ofs;\n      state.m_comp_size = 0;\n\n      if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state,\n                     tdefl_create_comp_flags_from_zip_params(\n                         level, -15, MZ_DEFAULT_STRATEGY)) !=\n          TDEFL_STATUS_OKAY) {\n        pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n        pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n        MZ_FCLOSE(pSrc_file);\n        return MZ_FALSE;\n      }\n\n      for (;;) {\n        size_t in_buf_size =\n            (mz_uint32)MZ_MIN(uncomp_remaining, MZ_ZIP_MAX_IO_BUF_SIZE);\n        tdefl_status status;\n\n        if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size)\n          break;\n\n        uncomp_crc32 = (mz_uint32)mz_crc32(\n            uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size);\n        uncomp_remaining -= in_buf_size;\n\n        status = tdefl_compress_buffer(pComp, pRead_buf, in_buf_size,\n                                       uncomp_remaining ? TDEFL_NO_FLUSH\n                                                        : TDEFL_FINISH);\n        if (status == TDEFL_STATUS_DONE) {\n          result = MZ_TRUE;\n          break;\n        } else if (status != TDEFL_STATUS_OKAY)\n          break;\n      }\n\n      pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n\n      if (!result) {\n        pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n        MZ_FCLOSE(pSrc_file);\n        return MZ_FALSE;\n      }\n\n      comp_size = state.m_comp_size;\n      cur_archive_file_ofs = state.m_cur_archive_file_ofs;\n\n      method = MZ_DEFLATED;\n    }\n\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n  }\n\n  MZ_FCLOSE(pSrc_file);\n  pSrc_file = NULL;\n\n  // no zip64 support yet\n  if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  if (!mz_zip_writer_create_local_dir_header(\n          pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size,\n          comp_size, uncomp_crc32, method, 0, dos_time, dos_date))\n    return MZ_FALSE;\n\n  if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header,\n                     sizeof(local_dir_header)) != sizeof(local_dir_header))\n    return MZ_FALSE;\n\n  if (!mz_zip_writer_add_to_central_dir(\n          pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment,\n          comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0,\n          dos_time, dos_date, local_dir_header_ofs, ext_attributes))\n    return MZ_FALSE;\n\n  pZip->m_total_files++;\n  pZip->m_archive_size = cur_archive_file_ofs;\n\n  return MZ_TRUE;\n}\n#endif // #ifndef MINIZ_NO_STDIO\n\nmz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip,\n                                          mz_zip_archive *pSource_zip,\n                                          mz_uint file_index) {\n  mz_uint n, bit_flags, num_alignment_padding_bytes;\n  mz_uint64 comp_bytes_remaining, local_dir_header_ofs;\n  mz_uint64 cur_src_file_ofs, cur_dst_file_ofs;\n  mz_uint32\n      local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) /\n                       sizeof(mz_uint32)];\n  mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;\n  mz_uint8 central_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE];\n  size_t orig_central_dir_size;\n  mz_zip_internal_state *pState;\n  void *pBuf;\n  const mz_uint8 *pSrc_central_header;\n\n  if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING))\n    return MZ_FALSE;\n  if (NULL ==\n      (pSrc_central_header = mz_zip_reader_get_cdh(pSource_zip, file_index)))\n    return MZ_FALSE;\n  pState = pZip->m_pState;\n\n  num_alignment_padding_bytes =\n      mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);\n\n  // no zip64 support yet\n  if ((pZip->m_total_files == 0xFFFF) ||\n      ((pZip->m_archive_size + num_alignment_padding_bytes +\n        MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) >\n       0xFFFFFFFF))\n    return MZ_FALSE;\n\n  cur_src_file_ofs =\n      MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS);\n  cur_dst_file_ofs = pZip->m_archive_size;\n\n  if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs,\n                           pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) !=\n      MZ_ZIP_LOCAL_DIR_HEADER_SIZE)\n    return MZ_FALSE;\n  if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)\n    return MZ_FALSE;\n  cur_src_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE;\n\n  if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs,\n                                 num_alignment_padding_bytes))\n    return MZ_FALSE;\n  cur_dst_file_ofs += num_alignment_padding_bytes;\n  local_dir_header_ofs = cur_dst_file_ofs;\n  if (pZip->m_file_offset_alignment) {\n    MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) ==\n              0);\n  }\n\n  if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pLocal_header,\n                     MZ_ZIP_LOCAL_DIR_HEADER_SIZE) !=\n      MZ_ZIP_LOCAL_DIR_HEADER_SIZE)\n    return MZ_FALSE;\n  cur_dst_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE;\n\n  n = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) +\n      MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);\n  comp_bytes_remaining =\n      n + MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);\n\n  if (NULL ==\n      (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1,\n                             (size_t)MZ_MAX(sizeof(mz_uint32) * 4,\n                                            MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE,\n                                                   comp_bytes_remaining)))))\n    return MZ_FALSE;\n\n  while (comp_bytes_remaining) {\n    n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining);\n    if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf,\n                             n) != n) {\n      pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);\n      return MZ_FALSE;\n    }\n    cur_src_file_ofs += n;\n\n    if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) {\n      pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);\n      return MZ_FALSE;\n    }\n    cur_dst_file_ofs += n;\n\n    comp_bytes_remaining -= n;\n  }\n\n  bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS);\n  if (bit_flags & 8) {\n    // Copy data descriptor\n    if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf,\n                             sizeof(mz_uint32) * 4) != sizeof(mz_uint32) * 4) {\n      pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);\n      return MZ_FALSE;\n    }\n\n    n = sizeof(mz_uint32) * ((MZ_READ_LE32(pBuf) == 0x08074b50) ? 4 : 3);\n    if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) {\n      pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);\n      return MZ_FALSE;\n    }\n\n    cur_src_file_ofs += n;\n    cur_dst_file_ofs += n;\n  }\n  pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);\n\n  // no zip64 support yet\n  if (cur_dst_file_ofs > 0xFFFFFFFF)\n    return MZ_FALSE;\n\n  orig_central_dir_size = pState->m_central_dir.m_size;\n\n  memcpy(central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE);\n  MZ_WRITE_LE32(central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS,\n                local_dir_header_ofs);\n  if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_header,\n                              MZ_ZIP_CENTRAL_DIR_HEADER_SIZE))\n    return MZ_FALSE;\n\n  n = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_FILENAME_LEN_OFS) +\n      MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS) +\n      MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_COMMENT_LEN_OFS);\n  if (!mz_zip_array_push_back(\n          pZip, &pState->m_central_dir,\n          pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n)) {\n    mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size,\n                        MZ_FALSE);\n    return MZ_FALSE;\n  }\n\n  if (pState->m_central_dir.m_size > 0xFFFFFFFF)\n    return MZ_FALSE;\n  n = (mz_uint32)orig_central_dir_size;\n  if (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &n, 1)) {\n    mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size,\n                        MZ_FALSE);\n    return MZ_FALSE;\n  }\n\n  pZip->m_total_files++;\n  pZip->m_archive_size = cur_dst_file_ofs;\n\n  return MZ_TRUE;\n}\n\nmz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip) {\n  mz_zip_internal_state *pState;\n  mz_uint64 central_dir_ofs, central_dir_size;\n  mz_uint8 hdr[MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE];\n\n  if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING))\n    return MZ_FALSE;\n\n  pState = pZip->m_pState;\n\n  // no zip64 support yet\n  if ((pZip->m_total_files > 0xFFFF) ||\n      ((pZip->m_archive_size + pState->m_central_dir.m_size +\n        MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  central_dir_ofs = 0;\n  central_dir_size = 0;\n  if (pZip->m_total_files) {\n    // Write central directory\n    central_dir_ofs = pZip->m_archive_size;\n    central_dir_size = pState->m_central_dir.m_size;\n    pZip->m_central_directory_file_ofs = central_dir_ofs;\n    if (pZip->m_pWrite(pZip->m_pIO_opaque, central_dir_ofs,\n                       pState->m_central_dir.m_p,\n                       (size_t)central_dir_size) != central_dir_size)\n      return MZ_FALSE;\n    pZip->m_archive_size += central_dir_size;\n  }\n\n  // Write end of central directory record\n  MZ_CLEAR_OBJ(hdr);\n  MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_SIG_OFS,\n                MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG);\n  MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS,\n                pZip->m_total_files);\n  MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS, pZip->m_total_files);\n  MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_SIZE_OFS, central_dir_size);\n  MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_OFS_OFS, central_dir_ofs);\n\n  if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr,\n                     sizeof(hdr)) != sizeof(hdr))\n    return MZ_FALSE;\n#ifndef MINIZ_NO_STDIO\n  if ((pState->m_pFile) && (MZ_FFLUSH(pState->m_pFile) == EOF))\n    return MZ_FALSE;\n#endif // #ifndef MINIZ_NO_STDIO\n\n  pZip->m_archive_size += sizeof(hdr);\n\n  pZip->m_zip_mode = MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED;\n  return MZ_TRUE;\n}\n\nmz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf,\n                                            size_t *pSize) {\n  if ((!pZip) || (!pZip->m_pState) || (!pBuf) || (!pSize))\n    return MZ_FALSE;\n  if (pZip->m_pWrite != mz_zip_heap_write_func)\n    return MZ_FALSE;\n  if (!mz_zip_writer_finalize_archive(pZip))\n    return MZ_FALSE;\n\n  *pBuf = pZip->m_pState->m_pMem;\n  *pSize = pZip->m_pState->m_mem_size;\n  pZip->m_pState->m_pMem = NULL;\n  pZip->m_pState->m_mem_size = pZip->m_pState->m_mem_capacity = 0;\n  return MZ_TRUE;\n}\n\nmz_bool mz_zip_writer_end(mz_zip_archive *pZip) {\n  mz_zip_internal_state *pState;\n  mz_bool status = MZ_TRUE;\n  if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) ||\n      ((pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) &&\n       (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED)))\n    return MZ_FALSE;\n\n  pState = pZip->m_pState;\n  pZip->m_pState = NULL;\n  mz_zip_array_clear(pZip, &pState->m_central_dir);\n  mz_zip_array_clear(pZip, &pState->m_central_dir_offsets);\n  mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets);\n\n#ifndef MINIZ_NO_STDIO\n  if (pState->m_pFile) {\n    MZ_FCLOSE(pState->m_pFile);\n    pState->m_pFile = NULL;\n  }\n#endif // #ifndef MINIZ_NO_STDIO\n\n  if ((pZip->m_pWrite == mz_zip_heap_write_func) && (pState->m_pMem)) {\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pState->m_pMem);\n    pState->m_pMem = NULL;\n  }\n\n  pZip->m_pFree(pZip->m_pAlloc_opaque, pState);\n  pZip->m_zip_mode = MZ_ZIP_MODE_INVALID;\n  return status;\n}\n\n#ifndef MINIZ_NO_STDIO\nmz_bool mz_zip_add_mem_to_archive_file_in_place(\n    const char *pZip_filename, const char *pArchive_name, const void *pBuf,\n    size_t buf_size, const void *pComment, mz_uint16 comment_size,\n    mz_uint level_and_flags) {\n  mz_bool status, created_new_archive = MZ_FALSE;\n  mz_zip_archive zip_archive;\n  struct MZ_FILE_STAT_STRUCT file_stat;\n  MZ_CLEAR_OBJ(zip_archive);\n  if ((int)level_and_flags < 0)\n    level_and_flags = MZ_DEFAULT_LEVEL;\n  if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) ||\n      ((comment_size) && (!pComment)) ||\n      ((level_and_flags & 0xF) > MZ_UBER_COMPRESSION))\n    return MZ_FALSE;\n  if (!mz_zip_writer_validate_archive_name(pArchive_name))\n    return MZ_FALSE;\n  if (MZ_FILE_STAT(pZip_filename, &file_stat) != 0) {\n    // Create a new archive.\n    if (!mz_zip_writer_init_file(&zip_archive, pZip_filename, 0))\n      return MZ_FALSE;\n    created_new_archive = MZ_TRUE;\n  } else {\n    // Append to an existing archive.\n    if (!mz_zip_reader_init_file(&zip_archive, pZip_filename,\n                                 level_and_flags |\n                                     MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY))\n      return MZ_FALSE;\n    if (!mz_zip_writer_init_from_reader(&zip_archive, pZip_filename)) {\n      mz_zip_reader_end(&zip_archive);\n      return MZ_FALSE;\n    }\n  }\n  status =\n      mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size,\n                               pComment, comment_size, level_and_flags, 0, 0);\n  // Always finalize, even if adding failed for some reason, so we have a valid\n  // central directory. (This may not always succeed, but we can try.)\n  if (!mz_zip_writer_finalize_archive(&zip_archive))\n    status = MZ_FALSE;\n  if (!mz_zip_writer_end(&zip_archive))\n    status = MZ_FALSE;\n  if ((!status) && (created_new_archive)) {\n    // It's a new archive and something went wrong, so just delete it.\n    int ignoredStatus = MZ_DELETE_FILE(pZip_filename);\n    (void)ignoredStatus;\n  }\n  return status;\n}\n\nvoid *mz_zip_extract_archive_file_to_heap(const char *pZip_filename,\n                                          const char *pArchive_name,\n                                          size_t *pSize, mz_uint flags) {\n  int file_index;\n  mz_zip_archive zip_archive;\n  void *p = NULL;\n\n  if (pSize)\n    *pSize = 0;\n\n  if ((!pZip_filename) || (!pArchive_name))\n    return NULL;\n\n  MZ_CLEAR_OBJ(zip_archive);\n  if (!mz_zip_reader_init_file(&zip_archive, pZip_filename,\n                               flags |\n                                   MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY))\n    return NULL;\n\n  if ((file_index = mz_zip_reader_locate_file(&zip_archive, pArchive_name, NULL,\n                                              flags)) >= 0)\n    p = mz_zip_reader_extract_to_heap(&zip_archive, file_index, pSize, flags);\n\n  mz_zip_reader_end(&zip_archive);\n  return p;\n}\n\n#endif // #ifndef MINIZ_NO_STDIO\n\n#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS\n\n#endif // #ifndef MINIZ_NO_ARCHIVE_APIS\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif // MINIZ_HEADER_FILE_ONLY\n\n/*\n  This is free and unencumbered software released into the public domain.\n\n  Anyone is free to copy, modify, publish, use, compile, sell, or\n  distribute this software, either in source code form or as a compiled\n  binary, for any purpose, commercial or non-commercial, and by any\n  means.\n\n  In jurisdictions that recognize copyright laws, the author or authors\n  of this software dedicate any and all copyright interest in the\n  software to the public domain. We make this dedication for the benefit\n  of the public at large and to the detriment of our heirs and\n  successors. We intend this dedication to be an overt act of\n  relinquishment in perpetuity of all present and future rights to this\n  software under copyright law.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\n  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n  OTHER DEALINGS IN THE SOFTWARE.\n\n  For more information, please refer to <http://unlicense.org/>\n*/\n\n// ---------------------- end of miniz ----------------------------------------\n}\n\nbool IsBigEndian(void) {\n  union {\n    unsigned int i;\n    char c[4];\n  } bint = {0x01020304};\n\n  return bint.c[0] == 1;\n}\n\nvoid swap2(unsigned short *val) {\n  unsigned short tmp = *val;\n  unsigned char *dst = (unsigned char *)val;\n  unsigned char *src = (unsigned char *)&tmp;\n\n  dst[0] = src[1];\n  dst[1] = src[0];\n}\n\nvoid swap4(unsigned int *val) {\n  unsigned int tmp = *val;\n  unsigned char *dst = (unsigned char *)val;\n  unsigned char *src = (unsigned char *)&tmp;\n\n  dst[0] = src[3];\n  dst[1] = src[2];\n  dst[2] = src[1];\n  dst[3] = src[0];\n}\n\nvoid swap8(unsigned long long *val) {\n  unsigned long long tmp = (*val);\n  unsigned char *dst = (unsigned char *)val;\n  unsigned char *src = (unsigned char *)&tmp;\n\n  dst[0] = src[7];\n  dst[1] = src[6];\n  dst[2] = src[5];\n  dst[3] = src[4];\n  dst[4] = src[3];\n  dst[5] = src[2];\n  dst[6] = src[1];\n  dst[7] = src[0];\n}\n\n// https://gist.github.com/rygorous/2156668\n// Reuse MINIZ_LITTLE_ENDIAN flag from miniz.\nunion FP32 {\n  unsigned int u;\n  float f;\n  struct {\n#if MINIZ_LITTLE_ENDIAN\n    unsigned int Mantissa : 23;\n    unsigned int Exponent : 8;\n    unsigned int Sign : 1;\n#else\n    unsigned int Sign : 1;\n    unsigned int Exponent : 8;\n    unsigned int Mantissa : 23;\n#endif\n  } s;\n};\n\nunion FP16 {\n  unsigned short u;\n  struct {\n#if MINIZ_LITTLE_ENDIAN\n    unsigned int Mantissa : 10;\n    unsigned int Exponent : 5;\n    unsigned int Sign : 1;\n#else\n    unsigned int Sign : 1;\n    unsigned int Exponent : 5;\n    unsigned int Mantissa : 10;\n#endif\n  } s;\n};\n\nFP32 half_to_float(FP16 h) {\n  static const FP32 magic = {113 << 23};\n  static const unsigned int shifted_exp = 0x7c00\n                                          << 13; // exponent mask after shift\n  FP32 o;\n\n  o.u = (h.u & 0x7fff) << 13;            // exponent/mantissa bits\n  unsigned int exp_ = shifted_exp & o.u; // just the exponent\n  o.u += (127 - 15) << 23;               // exponent adjust\n\n  // handle exponent special cases\n  if (exp_ == shifted_exp)   // Inf/NaN?\n    o.u += (128 - 16) << 23; // extra exp adjust\n  else if (exp_ == 0)        // Zero/Denormal?\n  {\n    o.u += 1 << 23; // extra exp adjust\n    o.f -= magic.f; // renormalize\n  }\n\n  o.u |= (h.u & 0x8000) << 16; // sign bit\n  return o;\n}\n\nFP16 float_to_half_full(FP32 f) {\n  FP16 o = {0};\n\n  // Based on ISPC reference code (with minor modifications)\n  if (f.s.Exponent == 0) // Signed zero/denormal (which will underflow)\n    o.s.Exponent = 0;\n  else if (f.s.Exponent == 255) // Inf or NaN (all exponent bits set)\n  {\n    o.s.Exponent = 31;\n    o.s.Mantissa = f.s.Mantissa ? 0x200 : 0; // NaN->qNaN and Inf->Inf\n  } else                                     // Normalized number\n  {\n    // Exponent unbias the single, then bias the halfp\n    int newexp = f.s.Exponent - 127 + 15;\n    if (newexp >= 31) // Overflow, return signed infinity\n      o.s.Exponent = 31;\n    else if (newexp <= 0) // Underflow\n    {\n      if ((14 - newexp) <= 24) // Mantissa might be non-zero\n      {\n        unsigned int mant = f.s.Mantissa | 0x800000; // Hidden 1 bit\n        o.s.Mantissa = mant >> (14 - newexp);\n        if ((mant >> (13 - newexp)) & 1) // Check for rounding\n          o.u++; // Round, might overflow into exp bit, but this is OK\n      }\n    } else {\n      o.s.Exponent = newexp;\n      o.s.Mantissa = f.s.Mantissa >> 13;\n      if (f.s.Mantissa & 0x1000) // Check for rounding\n        o.u++;                   // Round, might overflow to inf, this is OK\n    }\n  }\n\n  o.s.Sign = f.s.Sign;\n  return o;\n}\n\n// NOTE: From OpenEXR code\n// #define IMF_INCREASING_Y  0\n// #define IMF_DECREASING_Y  1\n// #define IMF_RAMDOM_Y    2\n//\n// #define IMF_NO_COMPRESSION  0\n// #define IMF_RLE_COMPRESSION 1\n// #define IMF_ZIPS_COMPRESSION  2\n// #define IMF_ZIP_COMPRESSION 3\n// #define IMF_PIZ_COMPRESSION 4\n// #define IMF_PXR24_COMPRESSION 5\n// #define IMF_B44_COMPRESSION 6\n// #define IMF_B44A_COMPRESSION  7\n\nPIC_INLINE const char *ReadString(std::string &s, const char *ptr) {\n  // Read untile NULL(\\0).\n  const char *p = ptr;\n  const char *q = ptr;\n  while ((*q) != 0)\n    q++;\n\n  s = std::string(p, q);\n\n  return q + 1; // skip '\\0'\n}\n\nPIC_INLINE const char *ReadAttribute(std::string &name, std::string &ty,\n                          std::vector<unsigned char> &data, const char *ptr) {\n\n  if ((*ptr) == 0) {\n    // end of attribute.\n    return NULL;\n  }\n\n  const char *p = ReadString(name, ptr);\n\n  p = ReadString(ty, p);\n\n  int dataLen;\n  memcpy(&dataLen, p, sizeof(int));\n  p += 4;\n\n  if (IsBigEndian()) {\n    swap4(reinterpret_cast<unsigned int *>(&dataLen));\n  }\n\n  data.resize(dataLen);\n  memcpy(&data.at(0), p, dataLen);\n  p += dataLen;\n\n  return p;\n}\n\nPIC_INLINE void WriteAttribute(FILE *fp, const char *name, const char *type,\n                    const unsigned char *data, int len) {\n  size_t n = fwrite(name, 1, strlen(name) + 1, fp);\n  assert(n == strlen(name) + 1);\n\n  n = fwrite(type, 1, strlen(type) + 1, fp);\n  assert(n == strlen(type) + 1);\n\n  int outLen = len;\n  if (IsBigEndian()) {\n    swap4(reinterpret_cast<unsigned int *>(&outLen));\n  }\n  n = fwrite(&outLen, 1, sizeof(int), fp);\n  assert(n == sizeof(int));\n\n  n = fwrite(data, 1, len, fp);\n  assert(n == (size_t)len);\n\n  (void)n;\n}\n\nPIC_INLINE void WriteAttributeToMemory(std::vector<unsigned char> &out, const char *name,\n                            const char *type, const unsigned char *data,\n                            int len) {\n  out.insert(out.end(), name, name + strlen(name) + 1);\n  out.insert(out.end(), type, type + strlen(type) + 1);\n\n  int outLen = len;\n  if (IsBigEndian()) {\n    swap4(reinterpret_cast<unsigned int *>(&outLen));\n  }\n  out.insert(out.end(), reinterpret_cast<unsigned char *>(&outLen),\n             reinterpret_cast<unsigned char *>(&outLen) + sizeof(int));\n  out.insert(out.end(), data, data + len);\n}\n\ntypedef struct {\n  std::string name; // less than 255 bytes long\n  int pixelType;\n  unsigned char pLinear;\n  int xSampling;\n  int ySampling;\n} ChannelInfo;\n\nPIC_INLINE void ReadChannelInfo(std::vector<ChannelInfo> &channels,\n                     const std::vector<unsigned char> &data) {\n  const char *p = reinterpret_cast<const char *>(&data.at(0));\n\n  for (;;) {\n    if ((*p) == 0) {\n      break;\n    }\n    ChannelInfo info;\n    p = ReadString(info.name, p);\n\n    memcpy(&info.pixelType, p, sizeof(int));\n    p += 4;\n    info.pLinear = p[0];                     // uchar\n    p += 1 + 3;                              // reserved: uchar[3]\n    memcpy(&info.xSampling, p, sizeof(int)); // int\n    p += 4;\n    memcpy(&info.ySampling, p, sizeof(int)); // int\n    p += 4;\n\n    if (IsBigEndian()) {\n      swap4(reinterpret_cast<unsigned int *>(&info.pixelType));\n      swap4(reinterpret_cast<unsigned int *>(&info.xSampling));\n      swap4(reinterpret_cast<unsigned int *>(&info.ySampling));\n    }\n\n    channels.push_back(info);\n  }\n}\n\nPIC_INLINE void WriteChannelInfo(std::vector<unsigned char> &data,\n                      const std::vector<ChannelInfo> &channels) {\n\n  size_t sz = 0;\n\n  // Calculate total size.\n  for (size_t c = 0; c < channels.size(); c++) {\n    sz += strlen(channels[c].name.c_str()) + 1; // +1 for \\0\n    sz += 16;                                   // 4 * int\n  }\n  data.resize(sz + 1);\n\n  unsigned char *p = &data.at(0);\n\n  for (size_t c = 0; c < channels.size(); c++) {\n    memcpy(p, channels[c].name.c_str(), strlen(channels[c].name.c_str()));\n    p += strlen(channels[c].name.c_str());\n    (*p) = '\\0';\n    p++;\n\n    int pixelType = channels[c].pixelType;\n    int xSampling = channels[c].xSampling;\n    int ySampling = channels[c].ySampling;\n    if (IsBigEndian()) {\n      swap4(reinterpret_cast<unsigned int *>(&pixelType));\n      swap4(reinterpret_cast<unsigned int *>(&xSampling));\n      swap4(reinterpret_cast<unsigned int *>(&ySampling));\n    }\n\n    memcpy(p, &pixelType, sizeof(int));\n    p += sizeof(int);\n\n    (*p) = channels[c].pLinear;\n    p += 4;\n\n    memcpy(p, &xSampling, sizeof(int));\n    p += sizeof(int);\n\n    memcpy(p, &ySampling, sizeof(int));\n    p += sizeof(int);\n  }\n\n  (*p) = '\\0';\n}\n\nPIC_INLINE void CompressZip(unsigned char *dst, unsigned long long &compressedSize,\n                 const unsigned char *src, unsigned long srcSize) {\n\n  std::vector<unsigned char> tmpBuf(srcSize);\n\n  //\n  // Apply EXR-specific? postprocess. Grabbed from OpenEXR's\n  // ImfZipCompressor.cpp\n  //\n\n  //\n  // Reorder the pixel data.\n  //\n\n  {\n    char *t1 = (char *)&tmpBuf.at(0);\n    char *t2 = (char *)&tmpBuf.at(0) + (srcSize + 1) / 2;\n    const char *stop = (const char *)src + srcSize;\n\n    while (true) {\n      if ((const char *)src < stop)\n        *(t1++) = *(src++);\n      else\n        break;\n\n      if ((const char *)src < stop)\n        *(t2++) = *(src++);\n      else\n        break;\n    }\n  }\n\n  //\n  // Predictor.\n  //\n\n  {\n    unsigned char *t = &tmpBuf.at(0) + 1;\n    unsigned char *stop = &tmpBuf.at(0) + srcSize;\n    int p = t[-1];\n\n    while (t < stop) {\n      int d = int(t[0]) - p + (128 + 256);\n      p = t[0];\n      t[0] = d;\n      ++t;\n    }\n  }\n\n  //\n  // Compress the data using miniz\n  //\n\n  miniz::mz_ulong outSize = miniz::mz_compressBound(srcSize);\n  int ret = miniz::mz_compress(dst, &outSize,\n                               (const unsigned char *)&tmpBuf.at(0), srcSize);\n  assert(ret == miniz::MZ_OK);\n  (void)ret;\n\n  compressedSize = outSize;\n}\n\nPIC_INLINE void DecompressZip(unsigned char *dst, unsigned long &uncompressedSize,\n                   const unsigned char *src, unsigned long srcSize) {\n  std::vector<unsigned char> tmpBuf(uncompressedSize);\n\n  int ret =\n      miniz::mz_uncompress(&tmpBuf.at(0), &uncompressedSize, src, srcSize);\n  assert(ret == miniz::MZ_OK);\n  (void)ret;\n\n  //\n  // Apply EXR-specific? postprocess. Grabbed from OpenEXR's\n  // ImfZipCompressor.cpp\n  //\n\n  // Predictor.\n  {\n    unsigned char *t = &tmpBuf.at(0) + 1;\n    unsigned char *stop = &tmpBuf.at(0) + uncompressedSize;\n\n    while (t < stop) {\n      int d = int(t[-1]) + int(t[0]) - 128;\n      t[0] = d;\n      ++t;\n    }\n  }\n\n  // Reorder the pixel data.\n  {\n    const char *t1 = reinterpret_cast<const char *>(&tmpBuf.at(0));\n    const char *t2 = reinterpret_cast<const char *>(&tmpBuf.at(0)) +\n                     (uncompressedSize + 1) / 2;\n    char *s = reinterpret_cast<char *>(dst);\n    char *stop = s + uncompressedSize;\n\n    while (true) {\n      if (s < stop)\n        *(s++) = *(t1++);\n      else\n        break;\n\n      if (s < stop)\n        *(s++) = *(t2++);\n      else\n        break;\n    }\n  }\n}\n\n//\n// PIZ compress/uncompress, based on OpenEXR's ImfPizCompressor.cpp\n//\n// -----------------------------------------------------------------\n// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas\n// Digital Ltd. LLC)\n// (3 clause BSD license)\n//\n\nstruct PIZChannelData {\n  unsigned short *start;\n  unsigned short *end;\n  int nx;\n  int ny;\n  int ys;\n  int size;\n};\n\n//-----------------------------------------------------------------------------\n//\n//  16-bit Haar Wavelet encoding and decoding\n//\n//  The source code in this file is derived from the encoding\n//  and decoding routines written by Christian Rouet for his\n//  PIZ image file format.\n//\n//-----------------------------------------------------------------------------\n\n//\n// Wavelet basis functions without modulo arithmetic; they produce\n// the best compression ratios when the wavelet-transformed data are\n// Huffman-encoded, but the wavelet transform works only for 14-bit\n// data (untransformed data values must be less than (1 << 14)).\n//\n\n#if 0 // @todo\ninline void wenc14(unsigned short a, unsigned short b, unsigned short &l,\n                   unsigned short &h) {\n  short as = a;\n  short bs = b;\n\n  short ms = (as + bs) >> 1;\n  short ds = as - bs;\n\n  l = ms;\n  h = ds;\n}\n#endif\n\ninline void wdec14(unsigned short l, unsigned short h, unsigned short &a,\n                   unsigned short &b) {\n  short ls = l;\n  short hs = h;\n\n  int hi = hs;\n  int ai = ls + (hi & 1) + (hi >> 1);\n\n  short as = ai;\n  short bs = ai - hi;\n\n  a = as;\n  b = bs;\n}\n\n//\n// Wavelet basis functions with modulo arithmetic; they work with full\n// 16-bit data, but Huffman-encoding the wavelet-transformed data doesn't\n// compress the data quite as well.\n//\n\nconst int NBITS = 16;\nconst int A_OFFSET = 1 << (NBITS - 1);\n//const int M_OFFSET = 1 << (NBITS - 1);\nconst int MOD_MASK = (1 << NBITS) - 1;\n\n#if 0 // @ood\ninline void wenc16(unsigned short a, unsigned short b, unsigned short &l,\n                   unsigned short &h) {\n  int ao = (a + A_OFFSET) & MOD_MASK;\n  int m = ((ao + b) >> 1);\n  int d = ao - b;\n\n  if (d < 0)\n    m = (m + M_OFFSET) & MOD_MASK;\n\n  d &= MOD_MASK;\n\n  l = m;\n  h = d;\n}\n#endif\n\ninline void wdec16(unsigned short l, unsigned short h, unsigned short &a,\n                   unsigned short &b) {\n  int m = l;\n  int d = h;\n  int bb = (m - (d >> 1)) & MOD_MASK;\n  int aa = (d + bb - A_OFFSET) & MOD_MASK;\n  b = bb;\n  a = aa;\n}\n\n//\n// 2D Wavelet encoding:\n//\n\n#if 0 // @todo\nPIC_INLINE void wav2Encode(unsigned short *in, // io: values are transformed in place\n                int nx,             // i : x size\n                int ox,             // i : x offset\n                int ny,             // i : y size\n                int oy,             // i : y offset\n                unsigned short mx)  // i : maximum in[x][y] value\n{\n  bool w14 = (mx < (1 << 14));\n  int n = (nx > ny) ? ny : nx;\n  int p = 1;  // == 1 <<  level\n  int p2 = 2; // == 1 << (level+1)\n\n  //\n  // Hierachical loop on smaller dimension n\n  //\n\n  while (p2 <= n) {\n    unsigned short *py = in;\n    unsigned short *ey = in + oy * (ny - p2);\n    int oy1 = oy * p;\n    int oy2 = oy * p2;\n    int ox1 = ox * p;\n    int ox2 = ox * p2;\n    unsigned short i00, i01, i10, i11;\n\n    //\n    // Y loop\n    //\n\n    for (; py <= ey; py += oy2) {\n      unsigned short *px = py;\n      unsigned short *ex = py + ox * (nx - p2);\n\n      //\n      // X loop\n      //\n\n      for (; px <= ex; px += ox2) {\n        unsigned short *p01 = px + ox1;\n        unsigned short *p10 = px + oy1;\n        unsigned short *p11 = p10 + ox1;\n\n        //\n        // 2D wavelet encoding\n        //\n\n        if (w14) {\n          wenc14(*px, *p01, i00, i01);\n          wenc14(*p10, *p11, i10, i11);\n          wenc14(i00, i10, *px, *p10);\n          wenc14(i01, i11, *p01, *p11);\n        } else {\n          wenc16(*px, *p01, i00, i01);\n          wenc16(*p10, *p11, i10, i11);\n          wenc16(i00, i10, *px, *p10);\n          wenc16(i01, i11, *p01, *p11);\n        }\n      }\n\n      //\n      // Encode (1D) odd column (still in Y loop)\n      //\n\n      if (nx & p) {\n        unsigned short *p10 = px + oy1;\n\n        if (w14)\n          wenc14(*px, *p10, i00, *p10);\n        else\n          wenc16(*px, *p10, i00, *p10);\n\n        *px = i00;\n      }\n    }\n\n    //\n    // Encode (1D) odd line (must loop in X)\n    //\n\n    if (ny & p) {\n      unsigned short *px = py;\n      unsigned short *ex = py + ox * (nx - p2);\n\n      for (; px <= ex; px += ox2) {\n        unsigned short *p01 = px + ox1;\n\n        if (w14)\n          wenc14(*px, *p01, i00, *p01);\n        else\n          wenc16(*px, *p01, i00, *p01);\n\n        *px = i00;\n      }\n    }\n\n    //\n    // Next level\n    //\n\n    p = p2;\n    p2 <<= 1;\n  }\n}\n#endif\n\n//\n// 2D Wavelet decoding:\n//\n\nPIC_INLINE void wav2Decode(unsigned short *in, // io: values are transformed in place\n                int nx,             // i : x size\n                int ox,             // i : x offset\n                int ny,             // i : y size\n                int oy,             // i : y offset\n                unsigned short mx)  // i : maximum in[x][y] value\n{\n  bool w14 = (mx < (1 << 14));\n  int n = (nx > ny) ? ny : nx;\n  int p = 1;\n  int p2;\n\n  //\n  // Search max level\n  //\n\n  while (p <= n)\n    p <<= 1;\n\n  p >>= 1;\n  p2 = p;\n  p >>= 1;\n\n  //\n  // Hierarchical loop on smaller dimension n\n  //\n\n  while (p >= 1) {\n    unsigned short *py = in;\n    unsigned short *ey = in + oy * (ny - p2);\n    int oy1 = oy * p;\n    int oy2 = oy * p2;\n    int ox1 = ox * p;\n    int ox2 = ox * p2;\n    unsigned short i00, i01, i10, i11;\n\n    //\n    // Y loop\n    //\n\n    for (; py <= ey; py += oy2) {\n      unsigned short *px = py;\n      unsigned short *ex = py + ox * (nx - p2);\n\n      //\n      // X loop\n      //\n\n      for (; px <= ex; px += ox2) {\n        unsigned short *p01 = px + ox1;\n        unsigned short *p10 = px + oy1;\n        unsigned short *p11 = p10 + ox1;\n\n        //\n        // 2D wavelet decoding\n        //\n\n        if (w14) {\n          wdec14(*px, *p10, i00, i10);\n          wdec14(*p01, *p11, i01, i11);\n          wdec14(i00, i01, *px, *p01);\n          wdec14(i10, i11, *p10, *p11);\n        } else {\n          wdec16(*px, *p10, i00, i10);\n          wdec16(*p01, *p11, i01, i11);\n          wdec16(i00, i01, *px, *p01);\n          wdec16(i10, i11, *p10, *p11);\n        }\n      }\n\n      //\n      // Decode (1D) odd column (still in Y loop)\n      //\n\n      if (nx & p) {\n        unsigned short *p10 = px + oy1;\n\n        if (w14)\n          wdec14(*px, *p10, i00, *p10);\n        else\n          wdec16(*px, *p10, i00, *p10);\n\n        *px = i00;\n      }\n    }\n\n    //\n    // Decode (1D) odd line (must loop in X)\n    //\n\n    if (ny & p) {\n      unsigned short *px = py;\n      unsigned short *ex = py + ox * (nx - p2);\n\n      for (; px <= ex; px += ox2) {\n        unsigned short *p01 = px + ox1;\n\n        if (w14)\n          wdec14(*px, *p01, i00, *p01);\n        else\n          wdec16(*px, *p01, i00, *p01);\n\n        *px = i00;\n      }\n    }\n\n    //\n    // Next level\n    //\n\n    p2 = p;\n    p >>= 1;\n  }\n}\n\n//-----------------------------------------------------------------------------\n//\n//\t16-bit Huffman compression and decompression.\n//\n//\tThe source code in this file is derived from the 8-bit\n//\tHuffman compression and decompression routines written\n//\tby Christian Rouet for his PIZ image file format.\n//\n//-----------------------------------------------------------------------------\n\n// Adds some modification for tinyexr.\n\nconst int HUF_ENCBITS = 16; // literal (value) bit length\nconst int HUF_DECBITS = 14; // decoding bit size (>= 8)\n\nconst int HUF_ENCSIZE = (1 << HUF_ENCBITS) + 1; // encoding table size\nconst int HUF_DECSIZE = 1 << HUF_DECBITS;       // decoding table size\nconst int HUF_DECMASK = HUF_DECSIZE - 1;\n\nstruct HufDec { // short code\t\tlong code\n  //-------------------------------\n  int len : 8;  // code length\t\t0\n  int lit : 24; // lit\t\t\tp size\n  int *p;       // 0\t\t\tlits\n};\ninline long long hufLength(long long code) { return code & 63; }\n\ninline long long hufCode(long long code) { return code >> 6; }\n\n#if 0  \ninline void outputBits(int nBits, long long bits, long long &c, int &lc,\n                       char *&out) {\n  c <<= nBits;\n  lc += nBits;\n\n  c |= bits;\n\n  while (lc >= 8)\n    *out++ = (c >> (lc -= 8));\n}\n#endif\n\ninline long long getBits(int nBits, long long &c, int &lc, const char *&in) {\n  while (lc < nBits) {\n    c = (c << 8) | *(unsigned char *)(in++);\n    lc += 8;\n  }\n\n  lc -= nBits;\n  return (c >> lc) & ((1 << nBits) - 1);\n}\n\n//\n// ENCODING TABLE BUILDING & (UN)PACKING\n//\n\n//\n// Build a \"canonical\" Huffman code table:\n//\t- for each (uncompressed) symbol, hcode contains the length\n//\t  of the corresponding code (in the compressed data)\n//\t- canonical codes are computed and stored in hcode\n//\t- the rules for constructing canonical codes are as follows:\n//\t  * shorter codes (if filled with zeroes to the right)\n//\t    have a numerically higher value than longer codes\n//\t  * for codes with the same length, numerical values\n//\t    increase with numerical symbol values\n//\t- because the canonical code table can be constructed from\n//\t  symbol lengths alone, the code table can be transmitted\n//\t  without sending the actual code values\n//\t- see http://www.compressconsult.com/huffman/\n//\n\nvoid hufCanonicalCodeTable(long long hcode[HUF_ENCSIZE]) {\n  long long n[59];\n\n  //\n  // For each i from 0 through 58, count the\n  // number of different codes of length i, and\n  // store the count in n[i].\n  //\n\n  for (int i = 0; i <= 58; ++i)\n    n[i] = 0;\n\n  for (int i = 0; i < HUF_ENCSIZE; ++i)\n    n[hcode[i]] += 1;\n\n  //\n  // For each i from 58 through 1, compute the\n  // numerically lowest code with length i, and\n  // store that code in n[i].\n  //\n\n  long long c = 0;\n\n  for (int i = 58; i > 0; --i) {\n    long long nc = ((c + n[i]) >> 1);\n    n[i] = c;\n    c = nc;\n  }\n\n  //\n  // hcode[i] contains the length, l, of the\n  // code for symbol i.  Assign the next available\n  // code of length l to the symbol and store both\n  // l and the code in hcode[i].\n  //\n\n  for (int i = 0; i < HUF_ENCSIZE; ++i) {\n    int l = hcode[i];\n\n    if (l > 0)\n      hcode[i] = l | (n[l]++ << 6);\n  }\n}\n\n//\n// Compute Huffman codes (based on frq input) and store them in frq:\n//\t- code structure is : [63:lsb - 6:msb] | [5-0: bit length];\n//\t- max code length is 58 bits;\n//\t- codes outside the range [im-iM] have a null length (unused values);\n//\t- original frequencies are destroyed;\n//\t- encoding tables are used by hufEncode() and hufBuildDecTable();\n//\n#if 0 // @todo\n\nstruct FHeapCompare {\n  bool operator()(long long *a, long long *b) { return *a > *b; }\n};\n\nvoid hufBuildEncTable(\n    long long *frq, // io: input frequencies [HUF_ENCSIZE], output table\n    int *im,        //  o: min frq index\n    int *iM)        //  o: max frq index\n{\n  //\n  // This function assumes that when it is called, array frq\n  // indicates the frequency of all possible symbols in the data\n  // that are to be Huffman-encoded.  (frq[i] contains the number\n  // of occurrences of symbol i in the data.)\n  //\n  // The loop below does three things:\n  //\n  // 1) Finds the minimum and maximum indices that point\n  //    to non-zero entries in frq:\n  //\n  //     frq[im] != 0, and frq[i] == 0 for all i < im\n  //     frq[iM] != 0, and frq[i] == 0 for all i > iM\n  //\n  // 2) Fills array fHeap with pointers to all non-zero\n  //    entries in frq.\n  //\n  // 3) Initializes array hlink such that hlink[i] == i\n  //    for all array entries.\n  //\n\n  int hlink[HUF_ENCSIZE];\n  long long *fHeap[HUF_ENCSIZE];\n\n  *im = 0;\n\n  while (!frq[*im])\n    (*im)++;\n\n  int nf = 0;\n\n  for (int i = *im; i < HUF_ENCSIZE; i++) {\n    hlink[i] = i;\n\n    if (frq[i]) {\n      fHeap[nf] = &frq[i];\n      nf++;\n      *iM = i;\n    }\n  }\n\n  //\n  // Add a pseudo-symbol, with a frequency count of 1, to frq;\n  // adjust the fHeap and hlink array accordingly.  Function\n  // hufEncode() uses the pseudo-symbol for run-length encoding.\n  //\n\n  (*iM)++;\n  frq[*iM] = 1;\n  fHeap[nf] = &frq[*iM];\n  nf++;\n\n  //\n  // Build an array, scode, such that scode[i] contains the number\n  // of bits assigned to symbol i.  Conceptually this is done by\n  // constructing a tree whose leaves are the symbols with non-zero\n  // frequency:\n  //\n  //     Make a heap that contains all symbols with a non-zero frequency,\n  //     with the least frequent symbol on top.\n  //\n  //     Repeat until only one symbol is left on the heap:\n  //\n  //         Take the two least frequent symbols off the top of the heap.\n  //         Create a new node that has first two nodes as children, and\n  //         whose frequency is the sum of the frequencies of the first\n  //         two nodes.  Put the new node back into the heap.\n  //\n  // The last node left on the heap is the root of the tree.  For each\n  // leaf node, the distance between the root and the leaf is the length\n  // of the code for the corresponding symbol.\n  //\n  // The loop below doesn't actually build the tree; instead we compute\n  // the distances of the leaves from the root on the fly.  When a new\n  // node is added to the heap, then that node's descendants are linked\n  // into a single linear list that starts at the new node, and the code\n  // lengths of the descendants (that is, their distance from the root\n  // of the tree) are incremented by one.\n  //\n\n  std::make_heap(&fHeap[0], &fHeap[nf], FHeapCompare());\n\n  long long scode[HUF_ENCSIZE];\n  memset(scode, 0, sizeof(long long) * HUF_ENCSIZE);\n\n  while (nf > 1) {\n    //\n    // Find the indices, mm and m, of the two smallest non-zero frq\n    // values in fHeap, add the smallest frq to the second-smallest\n    // frq, and remove the smallest frq value from fHeap.\n    //\n\n    int mm = fHeap[0] - frq;\n    std::pop_heap(&fHeap[0], &fHeap[nf], FHeapCompare());\n    --nf;\n\n    int m = fHeap[0] - frq;\n    std::pop_heap(&fHeap[0], &fHeap[nf], FHeapCompare());\n\n    frq[m] += frq[mm];\n    std::push_heap(&fHeap[0], &fHeap[nf], FHeapCompare());\n\n    //\n    // The entries in scode are linked into lists with the\n    // entries in hlink serving as \"next\" pointers and with\n    // the end of a list marked by hlink[j] == j.\n    //\n    // Traverse the lists that start at scode[m] and scode[mm].\n    // For each element visited, increment the length of the\n    // corresponding code by one bit. (If we visit scode[j]\n    // during the traversal, then the code for symbol j becomes\n    // one bit longer.)\n    //\n    // Merge the lists that start at scode[m] and scode[mm]\n    // into a single list that starts at scode[m].\n    //\n\n    //\n    // Add a bit to all codes in the first list.\n    //\n\n    for (int j = m; true; j = hlink[j]) {\n      scode[j]++;\n\n      assert(scode[j] <= 58);\n\n      if (hlink[j] == j) {\n        //\n        // Merge the two lists.\n        //\n\n        hlink[j] = mm;\n        break;\n      }\n    }\n\n    //\n    // Add a bit to all codes in the second list\n    //\n\n    for (int j = mm; true; j = hlink[j]) {\n      scode[j]++;\n\n      assert(scode[j] <= 58);\n\n      if (hlink[j] == j)\n        break;\n    }\n  }\n\n  //\n  // Build a canonical Huffman code table, replacing the code\n  // lengths in scode with (code, code length) pairs.  Copy the\n  // code table from scode into frq.\n  //\n\n  hufCanonicalCodeTable(scode);\n  memcpy(frq, scode, sizeof(long long) * HUF_ENCSIZE);\n}\n#endif\n\n//\n// Pack an encoding table:\n//\t- only code lengths, not actual codes, are stored\n//\t- runs of zeroes are compressed as follows:\n//\n//\t  unpacked\t\tpacked\n//\t  --------------------------------\n//\t  1 zero\t\t0\t(6 bits)\n//\t  2 zeroes\t\t59\n//\t  3 zeroes\t\t60\n//\t  4 zeroes\t\t61\n//\t  5 zeroes\t\t62\n//\t  n zeroes (6 or more)\t63 n-6\t(6 + 8 bits)\n//\n\nconst int SHORT_ZEROCODE_RUN = 59;\nconst int LONG_ZEROCODE_RUN = 63;\nconst int SHORTEST_LONG_RUN = 2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN;\n//const int LONGEST_LONG_RUN = 255 + SHORTEST_LONG_RUN;\n\n#if 0\nvoid hufPackEncTable(const long long *hcode, // i : encoding table [HUF_ENCSIZE]\n                     int im,                 // i : min hcode index\n                     int iM,                 // i : max hcode index\n                     char **pcode) //  o: ptr to packed table (updated)\n{\n  char *p = *pcode;\n  long long c = 0;\n  int lc = 0;\n\n  for (; im <= iM; im++) {\n    int l = hufLength(hcode[im]);\n\n    if (l == 0) {\n      int zerun = 1;\n\n      while ((im < iM) && (zerun < LONGEST_LONG_RUN)) {\n        if (hufLength(hcode[im + 1]) > 0)\n          break;\n        im++;\n        zerun++;\n      }\n\n      if (zerun >= 2) {\n        if (zerun >= SHORTEST_LONG_RUN) {\n          outputBits(6, LONG_ZEROCODE_RUN, c, lc, p);\n          outputBits(8, zerun - SHORTEST_LONG_RUN, c, lc, p);\n        } else {\n          outputBits(6, SHORT_ZEROCODE_RUN + zerun - 2, c, lc, p);\n        }\n        continue;\n      }\n    }\n\n    outputBits(6, l, c, lc, p);\n  }\n\n  if (lc > 0)\n    *p++ = (unsigned char)(c << (8 - lc));\n\n  *pcode = p;\n}\n#endif\n\n//\n// Unpack an encoding table packed by hufPackEncTable():\n//\n\nbool hufUnpackEncTable(const char **pcode, // io: ptr to packed table (updated)\n                       int ni,             // i : input size (in bytes)\n                       int im,             // i : min hcode index\n                       int iM,             // i : max hcode index\n                       long long *hcode)   //  o: encoding table [HUF_ENCSIZE]\n{\n  memset(hcode, 0, sizeof(long long) * HUF_ENCSIZE);\n\n  const char *p = *pcode;\n  long long c = 0;\n  int lc = 0;\n\n  for (; im <= iM; im++) {\n    if (p - *pcode > ni) {\n      return false;\n    }\n\n    long long l = hcode[im] = getBits(6, c, lc, p); // code length\n\n    if (l == (long long)LONG_ZEROCODE_RUN) {\n      if (p - *pcode > ni) {\n        return false;\n      }\n\n      int zerun = getBits(8, c, lc, p) + SHORTEST_LONG_RUN;\n\n      if (im + zerun > iM + 1) {\n        return false;\n      }\n\n      while (zerun--)\n        hcode[im++] = 0;\n\n      im--;\n    } else if (l >= (long long)SHORT_ZEROCODE_RUN) {\n      int zerun = l - SHORT_ZEROCODE_RUN + 2;\n\n      if (im + zerun > iM + 1) {\n        return false;\n      }\n\n      while (zerun--)\n        hcode[im++] = 0;\n\n      im--;\n    }\n  }\n\n  *pcode = const_cast<char *>(p);\n\n  hufCanonicalCodeTable(hcode);\n\n  return true;\n}\n\n//\n// DECODING TABLE BUILDING\n//\n\n//\n// Clear a newly allocated decoding table so that it contains only zeroes.\n//\n\nvoid hufClearDecTable(HufDec *hdecod) // io: (allocated by caller)\n                                      //     decoding table [HUF_DECSIZE]\n{\n  for (int i = 0; i < HUF_DECSIZE; i++) {\n    hdecod[i].len = 0;\n    hdecod[i].lit = 0;\n    hdecod[i].p = NULL;\n  }\n  //memset(hdecod, 0, sizeof(HufDec) * HUF_DECSIZE);\n}\n\n//\n// Build a decoding hash table based on the encoding table hcode:\n//\t- short codes (<= HUF_DECBITS) are resolved with a single table access;\n//\t- long code entry allocations are not optimized, because long codes are\n//\t  unfrequent;\n//\t- decoding tables are used by hufDecode();\n//\n\nbool hufBuildDecTable(const long long *hcode, // i : encoding table\n                      int im,                 // i : min index in hcode\n                      int iM,                 // i : max index in hcode\n                      HufDec *hdecod)         //  o: (allocated by caller)\n//     decoding table [HUF_DECSIZE]\n{\n  //\n  // Init hashtable & loop on all codes.\n  // Assumes that hufClearDecTable(hdecod) has already been called.\n  //\n\n  for (; im <= iM; im++) {\n    long long c = hufCode(hcode[im]);\n    int l = hufLength(hcode[im]);\n\n    if (c >> l) {\n      //\n      // Error: c is supposed to be an l-bit code,\n      // but c contains a value that is greater\n      // than the largest l-bit number.\n      //\n\n      // invalidTableEntry();\n      return false;\n    }\n\n    if (l > HUF_DECBITS) {\n      //\n      // Long code: add a secondary entry\n      //\n\n      HufDec *pl = hdecod + (c >> (l - HUF_DECBITS));\n\n      if (pl->len) {\n        //\n        // Error: a short code has already\n        // been stored in table entry *pl.\n        //\n\n        // invalidTableEntry();\n        return false;\n      }\n\n      pl->lit++;\n\n      if (pl->p) {\n        int *p = pl->p;\n        pl->p = new int[pl->lit];\n\n        for (int i = 0; i < pl->lit - 1; ++i)\n          pl->p[i] = p[i];\n\n        delete[] p;\n      } else {\n        pl->p = new int[1];\n      }\n\n      pl->p[pl->lit - 1] = im;\n    } else if (l) {\n      //\n      // Short code: init all primary entries\n      //\n\n      HufDec *pl = hdecod + (c << (HUF_DECBITS - l));\n\n      for (long long i = 1 << (HUF_DECBITS - l); i > 0; i--, pl++) {\n        if (pl->len || pl->p) {\n          //\n          // Error: a short code or a long code has\n          // already been stored in table entry *pl.\n          //\n\n          // invalidTableEntry();\n          return false;\n        }\n\n        pl->len = l;\n        pl->lit = im;\n      }\n    }\n  }\n\n  return true;\n}\n\n//\n// Free the long code entries of a decoding table built by hufBuildDecTable()\n//\n\nvoid hufFreeDecTable(HufDec *hdecod) // io: Decoding table\n{\n  for (int i = 0; i < HUF_DECSIZE; i++) {\n    if (hdecod[i].p) {\n      delete[] hdecod[i].p;\n      hdecod[i].p = 0;\n    }\n  }\n}\n\n//\n// ENCODING\n//\n\n#if 0 // @todo\ninline void outputCode(long long code, long long &c, int &lc, char *&out) {\n  outputBits(hufLength(code), hufCode(code), c, lc, out);\n}\n\ninline void sendCode(long long sCode, int runCount, long long runCode,\n                     long long &c, int &lc, char *&out) {\n  //\n  // Output a run of runCount instances of the symbol sCount.\n  // Output the symbols explicitly, or if that is shorter, output\n  // the sCode symbol once followed by a runCode symbol and runCount\n  // expressed as an 8-bit number.\n  //\n\n  if (hufLength(sCode) + hufLength(runCode) + 8 < hufLength(sCode) * runCount) {\n    outputCode(sCode, c, lc, out);\n    outputCode(runCode, c, lc, out);\n    outputBits(8, runCount, c, lc, out);\n  } else {\n    while (runCount-- >= 0)\n      outputCode(sCode, c, lc, out);\n  }\n}\n\n//\n// Encode (compress) ni values based on the Huffman encoding table hcode:\n//\n\nint hufEncode                  // return: output size (in bits)\n    (const long long *hcode,   // i : encoding table\n     const unsigned short *in, // i : uncompressed input buffer\n     const int ni,             // i : input buffer size (in bytes)\n     int rlc,                  // i : rl code\n     char *out)                //  o: compressed output buffer\n{\n  char *outStart = out;\n  long long c = 0; // bits not yet written to out\n  int lc = 0;      // number of valid bits in c (LSB)\n  int s = in[0];\n  int cs = 0;\n\n  //\n  // Loop on input values\n  //\n\n  for (int i = 1; i < ni; i++) {\n    //\n    // Count same values or send code\n    //\n\n    if (s == in[i] && cs < 255) {\n      cs++;\n    } else {\n      sendCode(hcode[s], cs, hcode[rlc], c, lc, out);\n      cs = 0;\n    }\n\n    s = in[i];\n  }\n\n  //\n  // Send remaining code\n  //\n\n  sendCode(hcode[s], cs, hcode[rlc], c, lc, out);\n\n  if (lc)\n    *out = (c << (8 - lc)) & 0xff;\n\n  return (out - outStart) * 8 + lc;\n}\n#endif\n\n//\n// DECODING\n//\n\n//\n// In order to force the compiler to inline them,\n// tiny_exr_getChar() and getCode() are implemented as macros\n// instead of \"inline\" functions.\n//\n\n#define tiny_exr_getChar(c, lc, in)                                                     \\\n  {                                                                            \\\n    c = (c << 8) | *(unsigned char *)(in++);                                   \\\n    lc += 8;                                                                   \\\n  }\n\n#define getCode(po, rlc, c, lc, in, out, oe)                                   \\\n  {                                                                            \\\n    if (po == rlc) {                                                           \\\n      if (lc < 8)                                                              \\\n        tiny_exr_getChar(c, lc, in);                                                    \\\n                                                                               \\\n      lc -= 8;                                                                 \\\n                                                                               \\\n      unsigned char cs = (c >> lc);                                            \\\n                                                                               \\\n      if (out + cs > oe)                                                       \\\n        return false;                                                          \\\n                                                                               \\\n      unsigned short s = out[-1];                                              \\\n                                                                               \\\n      while (cs-- > 0)                                                         \\\n        *out++ = s;                                                            \\\n    } else if (out < oe) {                                                     \\\n      *out++ = po;                                                             \\\n    } else {                                                                   \\\n      return false;                                                            \\\n    }                                                                          \\\n  }\n\n//\n// Decode (uncompress) ni bits based on encoding & decoding tables:\n//\n\nbool hufDecode(const long long *hcode, // i : encoding table\n               const HufDec *hdecod,   // i : decoding table\n               const char *in,         // i : compressed input buffer\n               int ni,                 // i : input size (in bits)\n               int rlc,                // i : run-length code\n               int no,                 // i : expected output size (in bytes)\n               unsigned short *out)    //  o: uncompressed output buffer\n{\n  long long c = 0;\n  int lc = 0;\n  unsigned short *outb = out;\n  unsigned short *oe = out + no;\n  const char *ie = in + (ni + 7) / 8; // input byte size\n\n  //\n  // Loop on input bytes\n  //\n\n  while (in < ie) {\n    tiny_exr_getChar(c, lc, in);\n\n    //\n    // Access decoding table\n    //\n\n    while (lc >= HUF_DECBITS) {\n      const HufDec pl = hdecod[(c >> (lc - HUF_DECBITS)) & HUF_DECMASK];\n\n      if (pl.len) {\n        //\n        // Get short code\n        //\n\n        lc -= pl.len;\n        getCode(pl.lit, rlc, c, lc, in, out, oe);\n      } else {\n        if (!pl.p) {\n          return false;\n        }\n        // invalidCode(); // wrong code\n\n        //\n        // Search long code\n        //\n\n        int j;\n\n        for (j = 0; j < pl.lit; j++) {\n          int l = hufLength(hcode[pl.p[j]]);\n\n          while (lc < l && in < ie) // get more bits\n            tiny_exr_getChar(c, lc, in);\n\n          if (lc >= l) {\n            if (hufCode(hcode[pl.p[j]]) ==\n                ((c >> (lc - l)) & (((long long)(1) << l) - 1))) {\n              //\n              // Found : get long code\n              //\n\n              lc -= l;\n              getCode(pl.p[j], rlc, c, lc, in, out, oe);\n              break;\n            }\n          }\n        }\n\n        if (j == pl.lit) {\n          return false;\n          // invalidCode(); // Not found\n        }\n      }\n    }\n  }\n\n  //\n  // Get remaining (short) codes\n  //\n\n  int i = (8 - ni) & 7;\n  c >>= i;\n  lc -= i;\n\n  while (lc > 0) {\n    const HufDec pl = hdecod[(c << (HUF_DECBITS - lc)) & HUF_DECMASK];\n\n    if (pl.len) {\n      lc -= pl.len;\n      getCode(pl.lit, rlc, c, lc, in, out, oe);\n    } else {\n      return false;\n      // invalidCode(); // wrong (long) code\n    }\n  }\n\n  if (out - outb != no) {\n    return false;\n  }\n  // notEnoughData ();\n\n  return true;\n}\n\n#if 0 // @todo\nvoid countFrequencies(long long freq[HUF_ENCSIZE],\n                      const unsigned short data[/*n*/], int n) {\n  for (int i = 0; i < HUF_ENCSIZE; ++i)\n    freq[i] = 0;\n\n  for (int i = 0; i < n; ++i)\n    ++freq[data[i]];\n}\n\nvoid writeUInt(char buf[4], unsigned int i) {\n  unsigned char *b = (unsigned char *)buf;\n\n  b[0] = i;\n  b[1] = i >> 8;\n  b[2] = i >> 16;\n  b[3] = i >> 24;\n}\n#endif\n\nunsigned int readUInt(const char buf[4]) {\n  const unsigned char *b = (const unsigned char *)buf;\n\n  return (b[0] & 0x000000ff) | ((b[1] << 8) & 0x0000ff00) |\n         ((b[2] << 16) & 0x00ff0000) | ((b[3] << 24) & 0xff000000);\n}\n\n//\n// EXTERNAL INTERFACE\n//\n\n#if 0 // @todo\nint hufCompress(const unsigned short raw[], int nRaw, char compressed[]) {\n  if (nRaw == 0)\n    return 0;\n\n  long long freq[HUF_ENCSIZE];\n\n  countFrequencies(freq, raw, nRaw);\n\n  int im = 0;\n  int iM = 0;\n  hufBuildEncTable(freq, &im, &iM);\n\n  char *tableStart = compressed + 20;\n  char *tableEnd = tableStart;\n  hufPackEncTable(freq, im, iM, &tableEnd);\n  int tableLength = tableEnd - tableStart;\n\n  char *dataStart = tableEnd;\n  int nBits = hufEncode(freq, raw, nRaw, iM, dataStart);\n  int dataLength = (nBits + 7) / 8;\n\n  writeUInt(compressed, im);\n  writeUInt(compressed + 4, iM);\n  writeUInt(compressed + 8, tableLength);\n  writeUInt(compressed + 12, nBits);\n  writeUInt(compressed + 16, 0); // room for future extensions\n\n  return dataStart + dataLength - compressed;\n}\n#endif\n\nbool hufUncompress(const char compressed[], int nCompressed,\n                   unsigned short raw[], int nRaw) {\n  if (nCompressed == 0) {\n    if (nRaw != 0)\n      return false;\n\n    return false;\n  }\n\n  int im = readUInt(compressed);\n  int iM = readUInt(compressed + 4);\n  // int tableLength = readUInt (compressed + 8);\n  int nBits = readUInt(compressed + 12);\n\n  if (im < 0 || im >= HUF_ENCSIZE || iM < 0 || iM >= HUF_ENCSIZE)\n    return false;\n\n  const char *ptr = compressed + 20;\n\n  //\n  // Fast decoder needs at least 2x64-bits of compressed data, and\n  // needs to be run-able on this platform. Otherwise, fall back\n  // to the original decoder\n  //\n\n  // if (FastHufDecoder::enabled() && nBits > 128)\n  //{\n  //    FastHufDecoder fhd (ptr, nCompressed - (ptr - compressed), im, iM, iM);\n  //    fhd.decode ((unsigned char*)ptr, nBits, raw, nRaw);\n  //}\n  // else\n  {\n    std::vector<long long> freq(HUF_ENCSIZE);\n    std::vector<HufDec> hdec(HUF_DECSIZE);\n\n    hufClearDecTable(&hdec.at(0));\n\n    hufUnpackEncTable(&ptr, nCompressed - (ptr - compressed), im, iM, &freq.at(0));\n\n    {\n      if (nBits > 8 * (nCompressed - (ptr - compressed))) {\n        return false;\n      }\n\n      hufBuildDecTable(&freq.at(0), im, iM, &hdec.at(0));\n      hufDecode(&freq.at(0), &hdec.at(0), ptr, nBits, iM, nRaw, raw);\n    }\n    // catch (...)\n    //{\n    //    hufFreeDecTable (hdec);\n    //    throw;\n    //}\n\n    hufFreeDecTable(&hdec.at(0));\n  }\n\n  return true;\n}\n\n//\n// Functions to compress the range of values in the pixel data\n//\n\nconst int USHORT_RANGE = (1 << 16);\nconst int BITMAP_SIZE = (USHORT_RANGE >> 3);\n\n#if 0 // @todo\n\nvoid bitmapFromData(const unsigned short data[/*nData*/], int nData,\n                    unsigned char bitmap[BITMAP_SIZE],\n                    unsigned short &minNonZero, unsigned short &maxNonZero) {\n  for (int i = 0; i < BITMAP_SIZE; ++i)\n    bitmap[i] = 0;\n\n  for (int i = 0; i < nData; ++i)\n    bitmap[data[i] >> 3] |= (1 << (data[i] & 7));\n\n  bitmap[0] &= ~1; // zero is not explicitly stored in\n                   // the bitmap; we assume that the\n                   // data always contain zeroes\n  minNonZero = BITMAP_SIZE - 1;\n  maxNonZero = 0;\n\n  for (int i = 0; i < BITMAP_SIZE; ++i) {\n    if (bitmap[i]) {\n      if (minNonZero > i)\n        minNonZero = i;\n      if (maxNonZero < i)\n        maxNonZero = i;\n    }\n  }\n}\n\nunsigned short forwardLutFromBitmap(const unsigned char bitmap[BITMAP_SIZE],\n                                    unsigned short lut[USHORT_RANGE]) {\n  int k = 0;\n\n  for (int i = 0; i < USHORT_RANGE; ++i) {\n    if ((i == 0) || (bitmap[i >> 3] & (1 << (i & 7))))\n      lut[i] = k++;\n    else\n      lut[i] = 0;\n  }\n\n  return k - 1; // maximum value stored in lut[],\n} // i.e. number of ones in bitmap minus 1\n#endif\n\nunsigned short reverseLutFromBitmap(const unsigned char bitmap[BITMAP_SIZE],\n                                    unsigned short lut[USHORT_RANGE]) {\n  int k = 0;\n\n  for (int i = 0; i < USHORT_RANGE; ++i) {\n    if ((i == 0) || (bitmap[i >> 3] & (1 << (i & 7))))\n      lut[k++] = i;\n  }\n\n  int n = k - 1;\n\n  while (k < USHORT_RANGE)\n    lut[k++] = 0;\n\n  return n; // maximum k where lut[k] is non-zero,\n} // i.e. number of ones in bitmap minus 1\n\nvoid applyLut(const unsigned short lut[USHORT_RANGE],\n              unsigned short data[/*nData*/], int nData) {\n  for (int i = 0; i < nData; ++i)\n    data[i] = lut[data[i]];\n}\n\n#if 0 // @todo\nbool CompressPiz(unsigned char *outPtr, unsigned int &outSize) {\n  unsigned char bitmap[BITMAP_SIZE];\n  unsigned short minNonZero;\n  unsigned short maxNonZero;\n\n  if (IsBigEndian()) {\n    // @todo { PIZ compression on BigEndian architecture. }\n    assert(0);\n    return false;\n  }\n\n  std::vector<unsigned short> tmpBuffer;\n  int nData = tmpBuffer.size();\n\n  bitmapFromData(&tmpBuffer.at(0), nData, bitmap, minNonZero, maxNonZero);\n\n  unsigned short lut[USHORT_RANGE];\n  //unsigned short maxValue = forwardLutFromBitmap(bitmap, lut);\n  applyLut(lut, &tmpBuffer.at(0), nData);\n\n  //\n  // Store range compression info in _outBuffer\n  //\n\n  char *buf = reinterpret_cast<char *>(outPtr);\n\n  memcpy(buf, &minNonZero, sizeof(unsigned short));\n  buf += sizeof(unsigned short);\n  memcpy(buf, &maxNonZero, sizeof(unsigned short));\n  buf += sizeof(unsigned short);\n\n  if (minNonZero <= maxNonZero) {\n    memcpy(buf, (char *)&bitmap[0] + minNonZero, maxNonZero - minNonZero + 1);\n    buf += maxNonZero - minNonZero + 1;\n  }\n\n#if 0 // @todo\n    //\n    // Apply wavelet encoding\n    //\n\n    for (int i = 0; i < channels; ++i)\n    {\n      ChannelData &cd = _channelData[i];\n\n      for (int j = 0; j < cd.size; ++j)\n      {\n          wav2Encode (cd.start + j,\n              cd.nx, cd.size,\n              cd.ny, cd.nx * cd.size,\n              maxValue);\n      }\n    }\n\n    //\n    // Apply Huffman encoding; append the result to _outBuffer\n    //\n\n    char *lengthPtr = buf;\n    int zero = 0;\n    memcpy(buf, &zero, sizeof(int)); buf += sizeof(int);\n\n    int length = hufCompress (_tmpBuffer, tmpBufferEnd - _tmpBuffer, buf);\n    memcpy(lengthPtr, tmpBuffer, length);\n    //Xdr::write <CharPtrIO> (lengthPtr, length);\n\n    outPtr = _outBuffer;\n    return buf - _outBuffer + length;\n#endif\n  assert(0);\n\n  return true;\n}\n#endif\n\nbool DecompressPiz(unsigned char *outPtr, unsigned int &outSize,\n                   const unsigned char *inPtr, size_t tmpBufSize,\n                   const std::vector<ChannelInfo> &channelInfo, int dataWidth,\n                   int numLines) {\n  unsigned char bitmap[BITMAP_SIZE];\n  unsigned short minNonZero;\n  unsigned short maxNonZero;\n\n  if (IsBigEndian()) {\n    // @todo { PIZ compression on BigEndian architecture. }\n    assert(0);\n    return false;\n  }\n\n  memset(bitmap, 0, BITMAP_SIZE);\n\n  const unsigned char *ptr = inPtr;\n  minNonZero = *(reinterpret_cast<const unsigned short *>(ptr));\n  maxNonZero = *(reinterpret_cast<const unsigned short *>(ptr + 2));\n  ptr += 4;\n\n  if (maxNonZero >= BITMAP_SIZE) {\n    return false;\n  }\n\n  if (minNonZero <= maxNonZero) {\n    memcpy((char *)&bitmap[0] + minNonZero, ptr, maxNonZero - minNonZero + 1);\n    ptr += maxNonZero - minNonZero + 1;\n  }\n\n  unsigned short lut[USHORT_RANGE];\n  memset(lut, 0, sizeof(unsigned short) * USHORT_RANGE);\n  unsigned short maxValue = reverseLutFromBitmap(bitmap, lut);\n\n  //\n  // Huffman decoding\n  //\n\n  int length;\n\n  length = *(reinterpret_cast<const int *>(ptr));\n  ptr += sizeof(int);\n\n  std::vector<unsigned short> tmpBuffer(tmpBufSize);\n  hufUncompress(reinterpret_cast<const char *>(ptr), length, &tmpBuffer.at(0),\n                tmpBufSize);\n\n  //\n  // Wavelet decoding\n  //\n\n  std::vector<PIZChannelData> channelData(channelInfo.size());\n\n  unsigned short *tmpBufferEnd = &tmpBuffer.at(0);\n\n  for (size_t i = 0; i < channelInfo.size(); ++i) {\n    const ChannelInfo &chan = channelInfo[i];\n\n    int pixelSize = sizeof(int); // UINT and FLOAT\n    if (chan.pixelType == TINYEXR_PIXELTYPE_HALF) {\n      pixelSize = sizeof(short);\n    }\n\n    channelData[i].start = tmpBufferEnd;\n    channelData[i].end = channelData[i].start;\n    channelData[i].nx = dataWidth;\n    channelData[i].ny = numLines;\n    // channelData[i].ys = 1;\n    channelData[i].size = pixelSize / sizeof(short);\n\n    tmpBufferEnd += channelData[i].nx * channelData[i].ny * channelData[i].size;\n  }\n\n  for (size_t i = 0; i < channelData.size(); ++i) {\n    PIZChannelData &cd = channelData[i];\n\n    for (int j = 0; j < cd.size; ++j) {\n      wav2Decode(cd.start + j, cd.nx, cd.size, cd.ny, cd.nx * cd.size,\n                 maxValue);\n    }\n  }\n\n  //\n  // Expand the pixel data to their original range\n  //\n\n  applyLut(lut, &tmpBuffer.at(0), tmpBufSize);\n\n  // @todo { Xdr }\n\n  for (int y = 0; y < numLines; y++) {\n    for (size_t i = 0; i < channelData.size(); ++i) {\n      PIZChannelData &cd = channelData[i];\n\n      // if (modp (y, cd.ys) != 0)\n      //    continue;\n\n      int n = cd.nx * cd.size;\n      memcpy(outPtr, cd.end, n * sizeof(unsigned short));\n      outPtr += n * sizeof(unsigned short);\n      cd.end += n;\n    }\n  }\n\n  return true;\n}\n//\n// -----------------------------------------------------------------\n//\n\n} // namespace\n\nint LoadEXR(float **out_rgba, int *width, int *height, const char *filename,\n            const char **err) {\n\n  if (out_rgba == NULL) {\n    if (err) {\n      (*err) = \"Invalid argument.\\n\";\n    }\n    return -1;\n  }\n\n  EXRImage exrImage;\n  InitEXRImage(&exrImage);\n\n  {\n    int ret = ParseMultiChannelEXRHeaderFromFile(&exrImage, filename, err);\n    if (ret != 0) {\n      return ret;\n    }\n  }\n\n  // Read HALF channel as FLOAT.\n  for (int i = 0; i < exrImage.num_channels; i++) {\n    if (exrImage.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) {\n      exrImage.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT;\n    }\n  }\n\n  {\n    int ret = LoadMultiChannelEXRFromFile(&exrImage, filename, err);\n    if (ret != 0) {\n      return ret;\n    }\n  }\n\n  // RGBA\n  int idxR = -1;\n  int idxG = -1;\n  int idxB = -1;\n  int idxA = -1;\n  for (int c = 0; c < exrImage.num_channels; c++) {\n    if (strcmp(exrImage.channel_names[c], \"R\") == 0) {\n      idxR = c;\n    } else if (strcmp(exrImage.channel_names[c], \"G\") == 0) {\n      idxG = c;\n    } else if (strcmp(exrImage.channel_names[c], \"B\") == 0) {\n      idxB = c;\n    } else if (strcmp(exrImage.channel_names[c], \"A\") == 0) {\n      idxA = c;\n    }\n  }\n\n  if (idxR == -1) {\n    if (err) {\n      (*err) = \"R channel not found\\n\";\n    }\n\n    // @todo { free exrImage }\n    return -1;\n  }\n\n  if (idxG == -1) {\n    if (err) {\n      (*err) = \"G channel not found\\n\";\n    }\n    // @todo { free exrImage }\n    return -1;\n  }\n\n  if (idxB == -1) {\n    if (err) {\n      (*err) = \"B channel not found\\n\";\n    }\n    // @todo { free exrImage }\n    return -1;\n  }\n\n  (*out_rgba) =\n      (float *)malloc(4 * sizeof(float) * exrImage.width * exrImage.height);\n  for (int i = 0; i < exrImage.width * exrImage.height; i++) {\n    (*out_rgba)[4 * i + 0] =\n        reinterpret_cast<float **>(exrImage.images)[idxR][i];\n    (*out_rgba)[4 * i + 1] =\n        reinterpret_cast<float **>(exrImage.images)[idxG][i];\n    (*out_rgba)[4 * i + 2] =\n        reinterpret_cast<float **>(exrImage.images)[idxB][i];\n    if (idxA > 0) {\n      (*out_rgba)[4 * i + 3] =\n          reinterpret_cast<float **>(exrImage.images)[idxA][i];\n    } else {\n      (*out_rgba)[4 * i + 3] = 1.0;\n    }\n  }\n\n  (*width) = exrImage.width;\n  (*height) = exrImage.height;\n\n  // @todo { free exrImage }\n  return 0;\n}\n\nint ParseEXRHeaderFromMemory(EXRAttribute* customAttributes, int *numCustomAttributes, int *width, int *height,\n                             const unsigned char *memory) {\n\n  if (memory == NULL) {\n    // Invalid argument\n    return -1;\n  }\n\n  const char *buf = reinterpret_cast<const char *>(memory);\n\n  const char *marker = &buf[0];\n\n  // Header check.\n  {\n    const char header[] = {0x76, 0x2f, 0x31, 0x01};\n\n    if (memcmp(marker, header, 4) != 0) {\n      // if (err) {\n      //  (*err) = \"Header mismatch.\";\n      //}\n      return -3;\n    }\n    marker += 4;\n  }\n\n  // Version, scanline.\n  {\n    // must be [2, 0, 0, 0]\n    if (marker[0] != 2 || marker[1] != 0 || marker[2] != 0 || marker[3] != 0) {\n      // if (err) {\n      //  (*err) = \"Unsupported version or scanline.\";\n      //}\n      return -4;\n    }\n\n    marker += 4;\n  }\n\n  int dx = -1;\n  int dy = -1;\n  int dw = -1;\n  int dh = -1;\n  int lineOrder = 0; // @fixme\n  int displayWindow[4] = {-1, -1, -1, -1}; // @fixme\n  float screenWindowCenter[2] = {0.0f, 0.0f}; // @fixme\n  float screenWindowWidth = 1.0f; // @fixme\n  int numChannels = -1;\n  float pixelAspectRatio = 1.0f; // @fixme\n  std::vector<ChannelInfo> channels;\n  std::vector<EXRAttribute> attribs;\n\n  if (numCustomAttributes) {\n    (*numCustomAttributes) = 0;\n  }\n\n  // Read attributes\n  for (;;) {\n    std::string attrName;\n    std::string attrType;\n    std::vector<unsigned char> data;\n    const char *marker_next = ReadAttribute(attrName, attrType, data, marker);\n    if (marker_next == NULL) {\n      marker++; // skip '\\0'\n      break;\n    }\n\n    if (attrName.compare(\"compression\") == 0) {\n      // must be 0:No compression, 1: RLE or 3: ZIP\n      //      if (data[0] != 0 && data[0] != 1 && data[0] != 3) {\n\n      //\tmwkm\n      //\t0 : NO_COMPRESSION\n      //\t1 : RLE\n      //\t2 : ZIPS (Single scanline)\n      //\t3 : ZIP (16-line block)\n      //\t4 : PIZ (32-line block)\n      if (data[0] > 4) {\n        // if (err) {\n        //  (*err) = \"Unsupported compression type.\";\n        //}\n        return -5;\n      }\n\n    } else if (attrName.compare(\"channels\") == 0) {\n\n      // name: zero-terminated string, from 1 to 255 bytes long\n      // pixel type: int, possible values are: UINT = 0 HALF = 1 FLOAT = 2\n      // pLinear: unsigned char, possible values are 0 and 1\n      // reserved: three chars, should be zero\n      // xSampling: int\n      // ySampling: int\n\n      ReadChannelInfo(channels, data);\n\n      numChannels = channels.size();\n\n      if (numChannels < 1) {\n        // if (err) {\n        //  (*err) = \"Invalid channels format.\";\n        //}\n        return -6;\n      }\n\n    } else if (attrName.compare(\"dataWindow\") == 0) {\n      memcpy(&dx, &data.at(0), sizeof(int));\n      memcpy(&dy, &data.at(4), sizeof(int));\n      memcpy(&dw, &data.at(8), sizeof(int));\n      memcpy(&dh, &data.at(12), sizeof(int));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&dx));\n        swap4(reinterpret_cast<unsigned int *>(&dy));\n        swap4(reinterpret_cast<unsigned int *>(&dw));\n        swap4(reinterpret_cast<unsigned int *>(&dh));\n      }\n    } else if (attrName.compare(\"displayWindow\") == 0) {\n      memcpy(&displayWindow[0], &data.at(0), sizeof(int));\n      memcpy(&displayWindow[1], &data.at(4), sizeof(int));\n      memcpy(&displayWindow[2], &data.at(8), sizeof(int));\n      memcpy(&displayWindow[3], &data.at(12), sizeof(int));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&displayWindow[0]));\n        swap4(reinterpret_cast<unsigned int *>(&displayWindow[1]));\n        swap4(reinterpret_cast<unsigned int *>(&displayWindow[2]));\n        swap4(reinterpret_cast<unsigned int *>(&displayWindow[3]));\n      }\n    } else if (attrName.compare(\"lineOrder\") == 0) {\n      memcpy(&lineOrder, &data.at(0), sizeof(float));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&lineOrder));\n      }\n    } else if (attrName.compare(\"pixelAspectRatio\") == 0) {\n      memcpy(&pixelAspectRatio, &data.at(0), sizeof(float));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&pixelAspectRatio));\n      }\n    } else if (attrName.compare(\"screenWindowCenter\") == 0) {\n      memcpy(&screenWindowCenter[0], &data.at(0), sizeof(float));\n      memcpy(&screenWindowCenter[1], &data.at(4), sizeof(float));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&screenWindowCenter[0]));\n        swap4(reinterpret_cast<unsigned int *>(&screenWindowCenter[1]));\n      }\n    } else if (attrName.compare(\"screenWindowWidth\") == 0) {\n      memcpy(&screenWindowWidth, &data.at(0), sizeof(float));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&screenWindowWidth));\n      }\n      \n    } else {\n      // Custom attribute(up to TINYEXR_MAX_ATTRIBUTES)\n      if (numCustomAttributes && ((*numCustomAttributes) < TINYEXR_MAX_ATTRIBUTES)) {\n        printf(\"custom\\n\");\n        EXRAttribute attrib;\n        attrib.name = strdup(attrName.c_str());\n        attrib.type = strdup(attrType.c_str());\n        attrib.size = data.size();\n        attrib.value = (unsigned char*)malloc(data.size());\n        memcpy((char*)attrib.value, &data.at(0), data.size());\n        attribs.push_back(attrib);\n      }\n    }\n\n    marker = marker_next;\n  }\n\n  assert(dx >= 0);\n  assert(dy >= 0);\n  assert(dw >= 0);\n  assert(dh >= 0);\n  assert(numChannels >= 1);\n\n  int dataWidth = dw - dx + 1;\n  int dataHeight = dh - dy + 1;\n\n  (*width) = dataWidth;\n  (*height) = dataHeight;\n\n  if (numCustomAttributes) {\n    assert(attribs.size() < TINYEXR_MAX_ATTRIBUTES);\n    (*numCustomAttributes) = attribs.size();\n\n    // Assume the pointer to customAttributes has enough memory to store.\n    for (int i = 0; i < (int)attribs.size(); i++) {\n      customAttributes[i] = attribs[i];\n    }\n  } \n\n  return 0;\n}\n\nint LoadEXRFromMemory(float *out_rgba, const unsigned char *memory,\n                      const char **err) {\n\n  if (out_rgba == NULL || memory == NULL) {\n    if (err) {\n      (*err) = \"Invalid argument.\\n\";\n    }\n    return -1;\n  }\n\n  EXRImage exrImage;\n  InitEXRImage(&exrImage);\n  int ret = LoadMultiChannelEXRFromMemory(&exrImage, memory, err);\n  if (ret != 0) {\n    return ret;\n  }\n\n  // RGBA\n  int idxR = -1;\n  int idxG = -1;\n  int idxB = -1;\n  int idxA = -1;\n  for (int c = 0; c < exrImage.num_channels; c++) {\n    if (strcmp(exrImage.channel_names[c], \"R\") == 0) {\n      idxR = c;\n    } else if (strcmp(exrImage.channel_names[c], \"G\") == 0) {\n      idxG = c;\n    } else if (strcmp(exrImage.channel_names[c], \"B\") == 0) {\n      idxB = c;\n    } else if (strcmp(exrImage.channel_names[c], \"A\") == 0) {\n      idxA = c;\n    }\n  }\n\n  if (idxR == -1) {\n    if (err) {\n      (*err) = \"R channel not found\\n\";\n    }\n\n    // @todo { free exrImage }\n    return -1;\n  }\n\n  if (idxG == -1) {\n    if (err) {\n      (*err) = \"G channel not found\\n\";\n    }\n    // @todo { free exrImage }\n    return -1;\n  }\n\n  if (idxB == -1) {\n    if (err) {\n      (*err) = \"B channel not found\\n\";\n    }\n    // @todo { free exrImage }\n    return -1;\n  }\n\n  // Assume `out_rgba` have enough memory allocated.\n  for (int i = 0; i < exrImage.width * exrImage.height; i++) {\n    out_rgba[4 * i + 0] = reinterpret_cast<float **>(exrImage.images)[idxR][i];\n    out_rgba[4 * i + 1] = reinterpret_cast<float **>(exrImage.images)[idxG][i];\n    out_rgba[4 * i + 2] = reinterpret_cast<float **>(exrImage.images)[idxB][i];\n    if (idxA > 0) {\n      out_rgba[4 * i + 3] =\n          reinterpret_cast<float **>(exrImage.images)[idxA][i];\n    } else {\n      out_rgba[4 * i + 3] = 1.0;\n    }\n  }\n\n  return 0;\n}\n\nint LoadMultiChannelEXRFromFile(EXRImage *exrImage, const char *filename,\n                                const char **err) {\n  if (exrImage == NULL) {\n    if (err) {\n      (*err) = \"Invalid argument.\";\n    }\n    return -1;\n  }\n\n  FILE *fp = fopen(filename, \"rb\");\n  if (!fp) {\n    if (err) {\n      (*err) = \"Cannot read file.\";\n    }\n    return -1;\n  }\n\n  size_t filesize;\n  // Compute size\n  fseek(fp, 0, SEEK_END);\n  filesize = ftell(fp);\n  fseek(fp, 0, SEEK_SET);\n\n  std::vector<unsigned char> buf(filesize); // @todo { use mmap }\n  {\n    size_t ret;\n    ret = fread(&buf[0], 1, filesize, fp);\n    assert(ret == filesize);\n    fclose(fp);\n    (void)ret;\n  }\n\n  return LoadMultiChannelEXRFromMemory(exrImage, &buf.at(0), err);\n}\n\nint LoadMultiChannelEXRFromMemory(EXRImage *exrImage,\n                                  const unsigned char *memory,\n                                  const char **err) {\n  if (exrImage == NULL || memory == NULL) {\n    if (err) {\n      (*err) = \"Invalid argument.\";\n    }\n    return -1;\n  }\n\n  const char *buf = reinterpret_cast<const char *>(memory);\n\n  const char *head = &buf[0];\n  const char *marker = &buf[0];\n\n  // Header check.\n  {\n    const char header[] = {0x76, 0x2f, 0x31, 0x01};\n\n    if (memcmp(marker, header, 4) != 0) {\n      if (err) {\n        (*err) = \"Header mismatch.\";\n      }\n      return -3;\n    }\n    marker += 4;\n  }\n\n  // Version, scanline.\n  {\n    // must be [2, 0, 0, 0]\n    if (marker[0] != 2 || marker[1] != 0 || marker[2] != 0 || marker[3] != 0) {\n      if (err) {\n        (*err) = \"Unsupported version or scanline.\";\n      }\n      return -4;\n    }\n\n    marker += 4;\n  }\n\n  int dx = -1;\n  int dy = -1;\n  int dw = -1;\n  int dh = -1;\n  int numScanlineBlocks = 1; // 16 for ZIP compression.\n  int compressionType = -1;\n  int numChannels = -1;\n  unsigned char lineOrder = 0; // 0 -> increasing y; 1 -> decreasing\n  std::vector<ChannelInfo> channels;\n\n  // Read attributes\n  for (;;) {\n    std::string attrName;\n    std::string attrType;\n    std::vector<unsigned char> data;\n    const char *marker_next = ReadAttribute(attrName, attrType, data, marker);\n    if (marker_next == NULL) {\n      marker++; // skip '\\0'\n      break;\n    }\n\n    if (attrName.compare(\"compression\") == 0) {\n      //\tmwkm\n      //\t0 : NO_COMPRESSION\n      //\t1 : RLE\n      //\t2 : ZIPS (Single scanline)\n      //\t3 : ZIP (16-line block)\n      //\t4 : PIZ (32-line block)\n      if (data[0] != 0 && data[0] != 2 && data[0] != 3 && data[0] != 4) {\n\n        if (err) {\n          (*err) = \"Unsupported compression type.\";\n        }\n        return -5;\n      }\n\n      compressionType = data[0];\n\n      if (compressionType == 3) { // ZIP\n        numScanlineBlocks = 16;\n      } else if (compressionType == 4) { // PIZ\n        numScanlineBlocks = 32;\n      }\n\n    } else if (attrName.compare(\"channels\") == 0) {\n\n      // name: zero-terminated string, from 1 to 255 bytes long\n      // pixel type: int, possible values are: UINT = 0 HALF = 1 FLOAT = 2\n      // pLinear: unsigned char, possible values are 0 and 1\n      // reserved: three chars, should be zero\n      // xSampling: int\n      // ySampling: int\n\n      ReadChannelInfo(channels, data);\n\n      numChannels = channels.size();\n\n      if (numChannels < 1) {\n        if (err) {\n          (*err) = \"Invalid channels format.\";\n        }\n        return -6;\n      }\n\n    } else if (attrName.compare(\"dataWindow\") == 0) {\n      memcpy(&dx, &data.at(0), sizeof(int));\n      memcpy(&dy, &data.at(4), sizeof(int));\n      memcpy(&dw, &data.at(8), sizeof(int));\n      memcpy(&dh, &data.at(12), sizeof(int));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&dx));\n        swap4(reinterpret_cast<unsigned int *>(&dy));\n        swap4(reinterpret_cast<unsigned int *>(&dw));\n        swap4(reinterpret_cast<unsigned int *>(&dh));\n      }\n    } else if (attrName.compare(\"displayWindow\") == 0) {\n      int x, y, w, h;\n      memcpy(&x, &data.at(0), sizeof(int));\n      memcpy(&y, &data.at(4), sizeof(int));\n      memcpy(&w, &data.at(8), sizeof(int));\n      memcpy(&h, &data.at(12), sizeof(int));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&x));\n        swap4(reinterpret_cast<unsigned int *>(&y));\n        swap4(reinterpret_cast<unsigned int *>(&w));\n        swap4(reinterpret_cast<unsigned int *>(&h));\n      }\n    } else if (attrName.compare(\"lineOrder\") == 0) {\n      memcpy(&lineOrder, &data.at(0), sizeof(lineOrder));\n    }\n\n    marker = marker_next;\n  }\n\n  assert(dx >= 0);\n  assert(dy >= 0);\n  assert(dw >= 0);\n  assert(dh >= 0);\n  assert(numChannels >= 1);\n\n  int dataWidth = dw - dx + 1;\n  int dataHeight = dh - dy + 1;\n\n  // Read offset tables.\n  int numBlocks = dataHeight / numScanlineBlocks;\n  if (numBlocks * numScanlineBlocks < dataHeight) {\n    numBlocks++;\n  }\n\n  std::vector<long long> offsets(numBlocks);\n\n  for (int y = 0; y < numBlocks; y++) {\n    long long offset;\n    memcpy(&offset, marker, sizeof(long long));\n    if (IsBigEndian()) {\n      swap8(reinterpret_cast<unsigned long long *>(&offset));\n    }\n    marker += sizeof(long long); // = 8\n    offsets[y] = offset;\n  }\n\n  //\tmwkm\n  //\tSupported : 0, 2(ZIPS), 3(ZIP), 4(PIZ)\n  if (compressionType != 0 && compressionType != 2 && compressionType != 3 &&\n      compressionType != 4) {\n    if (err) {\n      (*err) = \"Unsupported format.\";\n    }\n    return -10;\n  }\n\n  exrImage->images = reinterpret_cast<unsigned char **>(\n      (float **)malloc(sizeof(float *) * numChannels));\n\n  std::vector<size_t> channelOffsetList(numChannels);\n  int pixelDataSize = 0;\n  size_t channelOffset = 0;\n  for (int c = 0; c < numChannels; c++) {\n    channelOffsetList[c] = channelOffset;\n    if (channels[c].pixelType == TINYEXR_PIXELTYPE_HALF) {\n      pixelDataSize += sizeof(unsigned short);\n      channelOffset += sizeof(unsigned short);\n      // Alloc internal image for half type.\n      if (exrImage->requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) {\n        exrImage->images[c] =\n            reinterpret_cast<unsigned char *>((unsigned short *)malloc(\n                sizeof(unsigned short) * dataWidth * dataHeight));\n      } else if (exrImage->requested_pixel_types[c] ==\n                 TINYEXR_PIXELTYPE_FLOAT) {\n        exrImage->images[c] = reinterpret_cast<unsigned char *>(\n            (float *)malloc(sizeof(float) * dataWidth * dataHeight));\n      } else {\n        assert(0);\n      }\n    } else if (channels[c].pixelType == TINYEXR_PIXELTYPE_FLOAT) {\n      pixelDataSize += sizeof(float);\n      channelOffset += sizeof(float);\n      exrImage->images[c] = reinterpret_cast<unsigned char *>(\n          (float *)malloc(sizeof(float) * dataWidth * dataHeight));\n    } else if (channels[c].pixelType == TINYEXR_PIXELTYPE_UINT) {\n      pixelDataSize += sizeof(unsigned int);\n      channelOffset += sizeof(unsigned int);\n      exrImage->images[c] = reinterpret_cast<unsigned char *>((\n          unsigned int *)malloc(sizeof(unsigned int) * dataWidth * dataHeight));\n    } else {\n      assert(0);\n    }\n  }\n\n#ifdef _OPENMP\n#pragma omp parallel for\n#endif\n  for (int y = 0; y < numBlocks; y++) {\n    const unsigned char *dataPtr =\n        reinterpret_cast<const unsigned char *>(head + offsets[y]);\n    // 4 byte: scan line\n    // 4 byte: data size\n    // ~     : pixel data(uncompressed or compressed)\n    int lineNo;\n    memcpy(&lineNo, dataPtr, sizeof(int));\n    int dataLen;\n    memcpy(&dataLen, dataPtr + 4, sizeof(int));\n    if (IsBigEndian()) {\n      swap4(reinterpret_cast<unsigned int *>(&lineNo));\n      swap4(reinterpret_cast<unsigned int *>(&dataLen));\n    }\n\n    int endLineNo = (std::min)(lineNo + numScanlineBlocks, dataHeight);\n\n    int numLines = endLineNo - lineNo;\n\n    if (compressionType == 4) { // PIZ\n      // Allocate original data size.\n      std::vector<unsigned char> outBuf(dataWidth * numLines * pixelDataSize);\n      unsigned int dstLen;\n      size_t tmpBufLen = dataWidth * numLines * pixelDataSize;\n\n      DecompressPiz(reinterpret_cast<unsigned char *>(&outBuf.at(0)), dstLen,\n                    dataPtr + 8, tmpBufLen, channels, dataWidth, numLines);\n\n      bool isBigEndian = IsBigEndian();\n\n      // For ZIP_COMPRESSION:\n      //   pixel sample data for channel 0 for scanline 0\n      //   pixel sample data for channel 1 for scanline 0\n      //   pixel sample data for channel ... for scanline 0\n      //   pixel sample data for channel n for scanline 0\n      //   pixel sample data for channel 0 for scanline 1\n      //   pixel sample data for channel 1 for scanline 1\n      //   pixel sample data for channel ... for scanline 1\n      //   pixel sample data for channel n for scanline 1\n      //   ...\n      for (int c = 0; c < numChannels; c++) {\n\n        if (channels[c].pixelType == TINYEXR_PIXELTYPE_HALF) {\n          for (int v = 0; v < numLines; v++) {\n            const unsigned short *linePtr = reinterpret_cast<unsigned short *>(\n                &outBuf.at(v * pixelDataSize * dataWidth +\n                           channelOffsetList[c] * dataWidth));\n            for (int u = 0; u < dataWidth; u++) {\n              FP16 hf;\n\n              hf.u = linePtr[u];\n\n              if (isBigEndian) {\n                swap2(reinterpret_cast<unsigned short *>(&hf.u));\n              }\n\n              if (exrImage->requested_pixel_types[c] ==\n                  TINYEXR_PIXELTYPE_HALF) {\n                unsigned short *image =\n                    reinterpret_cast<unsigned short **>(exrImage->images)[c];\n                if (lineOrder == 0) {\n                  image += (lineNo + v) * dataWidth + u;\n                } else {\n                  image += (dataHeight - 1 - (lineNo + v)) * dataWidth + u;\n                }\n                *image = hf.u;\n              } else { // HALF -> FLOAT\n                FP32 f32 = half_to_float(hf);\n                float *image = reinterpret_cast<float **>(exrImage->images)[c];\n                if (lineOrder == 0) {\n                  image += (lineNo + v) * dataWidth + u;\n                } else {\n                  image += (dataHeight - 1 - (lineNo + v)) * dataWidth + u;\n                }\n                *image = f32.f;\n              }\n            }\n          }\n        } else if (channels[c].pixelType == TINYEXR_PIXELTYPE_UINT) {\n\n          assert(exrImage->requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT);\n\n          for (int v = 0; v < numLines; v++) {\n            const unsigned int *linePtr = reinterpret_cast<unsigned int *>(\n                &outBuf.at(v * pixelDataSize * dataWidth +\n                           channelOffsetList[c] * dataWidth));\n            for (int u = 0; u < dataWidth; u++) {\n\n              unsigned int val = linePtr[u];\n\n              if (isBigEndian) {\n                swap4(&val);\n              }\n\n              unsigned int *image =\n                  reinterpret_cast<unsigned int **>(exrImage->images)[c];\n              if (lineOrder == 0) {\n                image += (lineNo + v) * dataWidth + u;\n              } else {\n                image += (dataHeight - 1 - (lineNo + v)) * dataWidth + u;\n              }\n              *image = val;\n            }\n          }\n        } else if (channels[c].pixelType == TINYEXR_PIXELTYPE_FLOAT) {\n          assert(exrImage->requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT);\n          for (int v = 0; v < numLines; v++) {\n            const float *linePtr = reinterpret_cast<float *>(\n                &outBuf.at(v * pixelDataSize * dataWidth +\n                           channelOffsetList[c] * dataWidth));\n            for (int u = 0; u < dataWidth; u++) {\n\n              float val = linePtr[u];\n\n              if (isBigEndian) {\n                swap4(reinterpret_cast<unsigned int *>(&val));\n              }\n\n              float *image = reinterpret_cast<float **>(exrImage->images)[c];\n              if (lineOrder == 0) {\n                image += (lineNo + v) * dataWidth + u;\n              } else {\n                image += (dataHeight - 1 - (lineNo + v)) * dataWidth + u;\n              }\n              *image = val;\n            }\n          }\n        } else {\n          assert(0);\n        }\n      }\n\n      //\tmwkm, ZIPS or ZIP both good to go\n    } else if (compressionType == 2 || compressionType == 3) { // ZIP\n\n      // Allocate original data size.\n      std::vector<unsigned char> outBuf(dataWidth * numLines * pixelDataSize);\n\n      unsigned long dstLen = outBuf.size();\n      DecompressZip(reinterpret_cast<unsigned char *>(&outBuf.at(0)), dstLen,\n                    dataPtr + 8, dataLen);\n\n      bool isBigEndian = IsBigEndian();\n\n      // For ZIP_COMPRESSION:\n      //   pixel sample data for channel 0 for scanline 0\n      //   pixel sample data for channel 1 for scanline 0\n      //   pixel sample data for channel ... for scanline 0\n      //   pixel sample data for channel n for scanline 0\n      //   pixel sample data for channel 0 for scanline 1\n      //   pixel sample data for channel 1 for scanline 1\n      //   pixel sample data for channel ... for scanline 1\n      //   pixel sample data for channel n for scanline 1\n      //   ...\n      for (int c = 0; c < numChannels; c++) {\n\n        if (channels[c].pixelType == TINYEXR_PIXELTYPE_HALF) {\n          for (int v = 0; v < numLines; v++) {\n            const unsigned short *linePtr = reinterpret_cast<unsigned short *>(\n                &outBuf.at(v * pixelDataSize * dataWidth +\n                           channelOffsetList[c] * dataWidth));\n            for (int u = 0; u < dataWidth; u++) {\n              FP16 hf;\n\n              hf.u = linePtr[u];\n\n              if (isBigEndian) {\n                swap2(reinterpret_cast<unsigned short *>(&hf.u));\n              }\n\n              if (exrImage->requested_pixel_types[c] ==\n                  TINYEXR_PIXELTYPE_HALF) {\n                unsigned short *image =\n                    reinterpret_cast<unsigned short **>(exrImage->images)[c];\n                if (lineOrder == 0) {\n                  image += (lineNo + v) * dataWidth + u;\n                } else {\n                  image += (dataHeight - 1 - (lineNo + v)) * dataWidth + u;\n                }\n                *image = hf.u;\n              } else { // HALF -> FLOAT\n                FP32 f32 = half_to_float(hf);\n                float *image = reinterpret_cast<float **>(exrImage->images)[c];\n                if (lineOrder == 0) {\n                  image += (lineNo + v) * dataWidth + u;\n                } else {\n                  image += (dataHeight - 1 - (lineNo + v)) * dataWidth + u;\n                }\n                *image = f32.f;\n              }\n            }\n          }\n        } else if (channels[c].pixelType == TINYEXR_PIXELTYPE_UINT) {\n\n          assert(exrImage->requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT);\n\n          for (int v = 0; v < numLines; v++) {\n            const unsigned int *linePtr = reinterpret_cast<unsigned int *>(\n                &outBuf.at(v * pixelDataSize * dataWidth +\n                           channelOffsetList[c] * dataWidth));\n            for (int u = 0; u < dataWidth; u++) {\n\n              unsigned int val = linePtr[u];\n\n              if (isBigEndian) {\n                swap4(&val);\n              }\n\n              unsigned int *image =\n                  reinterpret_cast<unsigned int **>(exrImage->images)[c];\n              if (lineOrder == 0) {\n                image += (lineNo + v) * dataWidth + u;\n              } else {\n                image += (dataHeight - 1 - (lineNo + v)) * dataWidth + u;\n              }\n              *image = val;\n            }\n          }\n        } else if (channels[c].pixelType == TINYEXR_PIXELTYPE_FLOAT) {\n          assert(exrImage->requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT);\n          for (int v = 0; v < numLines; v++) {\n            const float *linePtr = reinterpret_cast<float *>(\n                &outBuf.at(v * pixelDataSize * dataWidth +\n                           channelOffsetList[c] * dataWidth));\n            for (int u = 0; u < dataWidth; u++) {\n\n              float val = linePtr[u];\n\n              if (isBigEndian) {\n                swap4(reinterpret_cast<unsigned int *>(&val));\n              }\n\n              float *image = reinterpret_cast<float **>(exrImage->images)[c];\n              if (lineOrder == 0) {\n                image += (lineNo + v) * dataWidth + u;\n              } else {\n                image += (dataHeight - 1 - (lineNo + v)) * dataWidth + u;\n              }\n              *image = val;\n            }\n          }\n        } else {\n          assert(0);\n        }\n      }\n\n    } else if (compressionType == 0) { // No compression\n\n      bool isBigEndian = IsBigEndian();\n\n      for (int c = 0; c < numChannels; c++) {\n\n        if (channels[c].pixelType == TINYEXR_PIXELTYPE_HALF) {\n\n          const unsigned short *linePtr =\n              reinterpret_cast<const unsigned short *>(\n                  dataPtr + 8 + c * dataWidth * sizeof(unsigned short));\n\n          if (exrImage->requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) {\n            unsigned short *outLine =\n                reinterpret_cast<unsigned short *>(exrImage->images[c]);\n            if (lineOrder == 0) {\n              outLine += y * dataWidth;\n            } else {\n              outLine += (dataHeight - 1 - y) * dataWidth;\n            }\n\n            for (int u = 0; u < dataWidth; u++) {\n              FP16 hf;\n\n              hf.u = linePtr[u];\n\n              if (isBigEndian) {\n                swap2(reinterpret_cast<unsigned short *>(&hf.u));\n              }\n\n              outLine[u] = hf.u;\n            }\n          } else if (exrImage->requested_pixel_types[c] ==\n                     TINYEXR_PIXELTYPE_FLOAT) {\n            float *outLine = reinterpret_cast<float *>(exrImage->images[c]);\n            if (lineOrder == 0) {\n              outLine += y * dataWidth;\n            } else {\n              outLine += (dataHeight - 1 - y) * dataWidth;\n            }\n\n            for (int u = 0; u < dataWidth; u++) {\n              FP16 hf;\n\n              hf.u = linePtr[u];\n\n              if (isBigEndian) {\n                swap2(reinterpret_cast<unsigned short *>(&hf.u));\n              }\n\n              FP32 f32 = half_to_float(hf);\n\n              outLine[u] = f32.f;\n            }\n          } else {\n            assert(0);\n          }\n        } else if (channels[c].pixelType == TINYEXR_PIXELTYPE_FLOAT) {\n\n          const float *linePtr = reinterpret_cast<const float *>(\n              dataPtr + 8 + c * dataWidth * sizeof(float));\n\n          float *outLine = reinterpret_cast<float *>(exrImage->images[c]);\n          if (lineOrder == 0) {\n            outLine += y * dataWidth;\n          } else {\n            outLine += (dataHeight - 1 - y) * dataWidth;\n          }\n\n          for (int u = 0; u < dataWidth; u++) {\n            float val = linePtr[u];\n\n            if (isBigEndian) {\n              swap4(reinterpret_cast<unsigned int *>(&val));\n            }\n\n            outLine[u] = val;\n          }\n        } else if (channels[c].pixelType == TINYEXR_PIXELTYPE_UINT) {\n\n          const unsigned int *linePtr = reinterpret_cast<const unsigned int *>(\n              dataPtr + 8 + c * dataWidth * sizeof(unsigned int));\n\n          unsigned int *outLine =\n              reinterpret_cast<unsigned int *>(exrImage->images[c]);\n          if (lineOrder == 0) {\n            outLine += y * dataWidth;\n          } else {\n            outLine += (dataHeight - 1 - y) * dataWidth;\n          }\n\n          for (int u = 0; u < dataWidth; u++) {\n            unsigned int val = linePtr[u];\n\n            if (isBigEndian) {\n              swap4(reinterpret_cast<unsigned int *>(&val));\n            }\n\n            outLine[u] = val;\n          }\n        }\n      }\n    }\n  } // omp parallel\n\n  {\n    exrImage->channel_names =\n        (const char **)malloc(sizeof(const char *) * numChannels);\n    for (int c = 0; c < numChannels; c++) {\n#ifdef _WIN32\n      exrImage->channel_names[c] = _strdup(channels[c].name.c_str());\n#else\n      exrImage->channel_names[c] = strdup(channels[c].name.c_str());\n#endif\n    }\n    exrImage->num_channels = numChannels;\n\n    exrImage->width = dataWidth;\n    exrImage->height = dataHeight;\n\n    // Fill with requested_pixel_types.\n    exrImage->pixel_types = (int *)malloc(sizeof(int *) * numChannels);\n    for (int c = 0; c < numChannels; c++) {\n      exrImage->pixel_types[c] = exrImage->requested_pixel_types[c];\n    }\n  }\n\n  return 0; // OK\n}\n\n// @deprecated\n#if 0\nint SaveEXR(const float *in_rgba, int width, int height, const char *filename,\n            const char **err) {\n  if (in_rgba == NULL || filename == NULL) {\n    if (err) {\n      (*err) = \"Invalid argument.\";\n    }\n    return -1;\n  }\n\n  FILE *fp = fopen(filename, \"wb\");\n  if (!fp) {\n    if (err) {\n      (*err) = \"Cannot write a file.\";\n    }\n    return -1;\n  }\n\n  // Header\n  {\n    const char header[] = {0x76, 0x2f, 0x31, 0x01};\n    size_t n = fwrite(header, 1, 4, fp);\n    assert(n == 4);\n  }\n\n  // Version, scanline.\n  {\n    const char marker[] = {2, 0, 0, 0};\n    size_t n = fwrite(marker, 1, 4, fp);\n    assert(n == 4);\n  }\n\n  int numScanlineBlocks = 16; // 16 for ZIP compression.\n\n  // Write attributes.\n  {\n    unsigned char data[] = {\n        'A', 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,   0,   'B',\n        0,   1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,   'G', 0,\n        1,   0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 'R', 0,   1,\n        0,   0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0}; // last 0 =\n                                                           // terminator.\n\n    WriteAttribute(fp, \"channels\", \"chlist\", data, 18 * 4 + 1); // +1 = null\n  }\n\n  {\n    int compressionType = 3; // ZIP compression\n    WriteAttribute(fp, \"compression\", \"compression\",\n                   reinterpret_cast<const unsigned char *>(&compressionType),\n                   1);\n  }\n\n  {\n    int data[4] = {0, 0, width - 1, height - 1};\n    WriteAttribute(fp, \"dataWindow\", \"box2i\",\n                   reinterpret_cast<const unsigned char *>(data),\n                   sizeof(int) * 4);\n    WriteAttribute(fp, \"displayWindow\", \"box2i\",\n                   reinterpret_cast<const unsigned char *>(data),\n                   sizeof(int) * 4);\n  }\n\n  {\n    unsigned char lineOrder = 0; // increasingY\n    WriteAttribute(fp, \"lineOrder\", \"lineOrder\", &lineOrder, 1);\n  }\n\n  {\n    float aspectRatio = 1.0f;\n    WriteAttribute(fp, \"pixelAspectRatio\", \"float\",\n                   reinterpret_cast<const unsigned char *>(&aspectRatio),\n                   sizeof(float));\n  }\n\n  {\n    float center[2] = {0.0f, 0.0f};\n    WriteAttribute(fp, \"screenWindowCenter\", \"v2f\",\n                   reinterpret_cast<const unsigned char *>(center),\n                   2 * sizeof(float));\n  }\n\n  {\n    float w = (float)width;\n    WriteAttribute(fp, \"screenWindowWidth\", \"float\",\n                   reinterpret_cast<const unsigned char *>(&w), sizeof(float));\n  }\n\n  { // end of header\n    unsigned char e = 0;\n    fwrite(&e, 1, 1, fp);\n  }\n\n  int numBlocks = height / numScanlineBlocks;\n  if (numBlocks * numScanlineBlocks < height) {\n    numBlocks++;\n  }\n\n  std::vector<long long> offsets(numBlocks);\n\n  size_t headerSize = ftell(fp); // sizeof(header)\n  long long offset =\n      headerSize +\n      numBlocks * sizeof(long long); // sizeof(header) + sizeof(offsetTable)\n\n  std::vector<unsigned char> data;\n\n  for (int i = 0; i < numBlocks; i++) {\n    int startY = numScanlineBlocks * i;\n    int endY = (std::min)(numScanlineBlocks * (i + 1), height);\n    int h = endY - startY;\n\n    std::vector<unsigned short> buf(4 * width * h);\n\n    for (int y = 0; y < h; y++) {\n      for (int x = 0; x < width; x++) {\n        FP32 r, g, b, a;\n        r.f = in_rgba[4 * ((y + startY) * width + x) + 0];\n        g.f = in_rgba[4 * ((y + startY) * width + x) + 1];\n        b.f = in_rgba[4 * ((y + startY) * width + x) + 2];\n        a.f = in_rgba[4 * ((y + startY) * width + x) + 3];\n\n        FP16 hr, hg, hb, ha;\n        hr = float_to_half_full(r);\n        hg = float_to_half_full(g);\n        hb = float_to_half_full(b);\n        ha = float_to_half_full(a);\n\n        // Assume increasing Y\n        buf[4 * y * width + 3 * width + x] = hr.u;\n        buf[4 * y * width + 2 * width + x] = hg.u;\n        buf[4 * y * width + 1 * width + x] = hb.u;\n        buf[4 * y * width + 0 * width + x] = ha.u;\n      }\n    }\n\n    int bound = miniz::mz_compressBound(buf.size() * sizeof(unsigned short));\n\n    std::vector<unsigned char> block(\n        miniz::mz_compressBound(buf.size() * sizeof(unsigned short)));\n    unsigned long long outSize = block.size();\n\n    CompressZip(&block.at(0), outSize,\n                reinterpret_cast<const unsigned char *>(&buf.at(0)),\n                buf.size() * sizeof(unsigned short));\n\n    // 4 byte: scan line\n    // 4 byte: data size\n    // ~     : pixel data(compressed)\n    std::vector<unsigned char> header(8);\n    unsigned int dataLen = outSize; // truncate\n    memcpy(&header.at(0), &startY, sizeof(int));\n    memcpy(&header.at(4), &dataLen, sizeof(unsigned int));\n\n    data.insert(data.end(), header.begin(), header.end());\n    data.insert(data.end(), block.begin(), block.begin() + dataLen);\n\n    offsets[i] = offset;\n    offset += dataLen + 8; // 8 = sizeof(blockHeader)\n  }\n\n  fwrite(&offsets.at(0), 1, sizeof(unsigned long long) * numBlocks, fp);\n\n  fwrite(&data.at(0), 1, data.size(), fp);\n\n  fclose(fp);\n\n  return 0; // OK\n}\n#endif\n\nsize_t SaveMultiChannelEXRToMemory(const EXRImage *exrImage,\n                                   unsigned char **memory_out,\n                                   const char **err) {\n  if (exrImage == NULL || memory_out == NULL) {\n    if (err) {\n      (*err) = \"Invalid argument.\";\n    }\n    return -1;\n  }\n\n  std::vector<unsigned char> memory;\n\n  // Header\n  {\n    const char header[] = {0x76, 0x2f, 0x31, 0x01};\n    memory.insert(memory.end(), header, header + 4);\n  }\n\n  // Version, scanline.\n  {\n    const char marker[] = {2, 0, 0, 0};\n    memory.insert(memory.end(), marker, marker + 4);\n  }\n\n  int numScanlineBlocks =\n      16; // 1 for no compress & ZIPS, 16 for ZIP compression.\n\n  // Write attributes.\n  {\n    std::vector<unsigned char> data;\n\n    std::vector<ChannelInfo> channels;\n    for (int c = 0; c < exrImage->num_channels; c++) {\n      ChannelInfo info;\n      info.pLinear = 0;\n      info.pixelType = exrImage->requested_pixel_types[c];\n      info.xSampling = 1;\n      info.ySampling = 1;\n      info.name = std::string(exrImage->channel_names[c]);\n      channels.push_back(info);\n    }\n\n    WriteChannelInfo(data, channels);\n\n    WriteAttributeToMemory(memory, \"channels\", \"chlist\", &data.at(0),\n                           data.size()); // +1 = null\n  }\n\n  {\n    int compressionType = 3; // ZIP compression\n    if (IsBigEndian()) {\n      swap4(reinterpret_cast<unsigned int *>(&compressionType));\n    }\n    WriteAttributeToMemory(\n        memory, \"compression\", \"compression\",\n        reinterpret_cast<const unsigned char *>(&compressionType), 1);\n  }\n\n  {\n    int data[4] = {0, 0, exrImage->width - 1, exrImage->height - 1};\n    if (IsBigEndian()) {\n      swap4(reinterpret_cast<unsigned int *>(&data[0]));\n      swap4(reinterpret_cast<unsigned int *>(&data[1]));\n      swap4(reinterpret_cast<unsigned int *>(&data[2]));\n      swap4(reinterpret_cast<unsigned int *>(&data[3]));\n    }\n    WriteAttributeToMemory(memory, \"dataWindow\", \"box2i\",\n                           reinterpret_cast<const unsigned char *>(data),\n                           sizeof(int) * 4);\n    WriteAttributeToMemory(memory, \"displayWindow\", \"box2i\",\n                           reinterpret_cast<const unsigned char *>(data),\n                           sizeof(int) * 4);\n  }\n\n  {\n    unsigned char lineOrder = 0; // increasingY\n    WriteAttributeToMemory(memory, \"lineOrder\", \"lineOrder\", &lineOrder, 1);\n  }\n\n  {\n    float aspectRatio = 1.0f;\n    if (IsBigEndian()) {\n      swap4(reinterpret_cast<unsigned int *>(&aspectRatio));\n    }\n    WriteAttributeToMemory(\n        memory, \"pixelAspectRatio\", \"float\",\n        reinterpret_cast<const unsigned char *>(&aspectRatio), sizeof(float));\n  }\n\n  {\n    float center[2] = {0.0f, 0.0f};\n    if (IsBigEndian()) {\n      swap4(reinterpret_cast<unsigned int *>(&center[0]));\n      swap4(reinterpret_cast<unsigned int *>(&center[1]));\n    }\n    WriteAttributeToMemory(memory, \"screenWindowCenter\", \"v2f\",\n                           reinterpret_cast<const unsigned char *>(center),\n                           2 * sizeof(float));\n  }\n\n  {\n    float w = (float)exrImage->width;\n    if (IsBigEndian()) {\n      swap4(reinterpret_cast<unsigned int *>(&w));\n    }\n    WriteAttributeToMemory(memory, \"screenWindowWidth\", \"float\",\n                           reinterpret_cast<const unsigned char *>(&w),\n                           sizeof(float));\n  }\n\n  // Custom attributes\n  if (exrImage->num_custom_attributes > 0) {\n    printf(\"custom\\n\");\n    // @todo { endian }\n    for (int i = 0; i < exrImage->num_custom_attributes; i++) {\n      WriteAttributeToMemory(memory, exrImage->custom_attributes[i].name, exrImage->custom_attributes[i].type,\n                             reinterpret_cast<const unsigned char *>(&exrImage->custom_attributes[i].value),\n                             exrImage->custom_attributes[i].size);\n        \n    }\n  }\n\n  { // end of header\n    unsigned char e = 0;\n    memory.push_back(e);\n  }\n\n  int numBlocks = exrImage->height / numScanlineBlocks;\n  if (numBlocks * numScanlineBlocks < exrImage->height) {\n    numBlocks++;\n  }\n\n  std::vector<long long> offsets(numBlocks);\n\n  size_t headerSize = memory.size();\n  long long offset =\n      headerSize +\n      numBlocks * sizeof(long long); // sizeof(header) + sizeof(offsetTable)\n\n  std::vector<unsigned char> data;\n\n  bool isBigEndian = IsBigEndian();\n\n  std::vector<std::vector<unsigned char> > dataList(numBlocks);\n  std::vector<size_t> channelOffsetList(exrImage->num_channels);\n\n  int pixelDataSize = 0;\n  size_t channelOffset = 0;\n  for (int c = 0; c < exrImage->num_channels; c++) {\n    channelOffsetList[c] = channelOffset;\n    if (exrImage->requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) {\n      pixelDataSize += sizeof(unsigned short);\n      channelOffset += sizeof(unsigned short);\n    } else if (exrImage->requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) {\n      pixelDataSize += sizeof(float);\n      channelOffset += sizeof(float);\n    } else if (exrImage->requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT) {\n      pixelDataSize += sizeof(unsigned int);\n      channelOffset += sizeof(unsigned int);\n    } else {\n      assert(0);\n    }\n  }\n\n#ifdef _OPENMP\n#pragma omp parallel for\n#endif\n  for (int i = 0; i < numBlocks; i++) {\n    int startY = numScanlineBlocks * i;\n    int endY = (std::min)(numScanlineBlocks * (i + 1), exrImage->height);\n    int h = endY - startY;\n\n    std::vector<unsigned char> buf(exrImage->width * h * pixelDataSize);\n\n    for (int c = 0; c < exrImage->num_channels; c++) {\n      if (exrImage->pixel_types[c] == TINYEXR_PIXELTYPE_HALF) {\n\n        if (exrImage->requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) {\n          for (int y = 0; y < h; y++) {\n            for (int x = 0; x < exrImage->width; x++) {\n              FP16 h16;\n              h16.u = reinterpret_cast<unsigned short **>(\n                  exrImage->images)[c][(y + startY) * exrImage->width + x];\n\n              FP32 f32 = half_to_float(h16);\n\n              if (isBigEndian) {\n                swap4(reinterpret_cast<unsigned int *>(&f32.f));\n              }\n\n              // Assume increasing Y\n              float *linePtr = reinterpret_cast<float *>(\n                  &buf.at(pixelDataSize * y * exrImage->width +\n                          channelOffsetList[c] * exrImage->width));\n              linePtr[x] = f32.f;\n            }\n          }\n        } else if (exrImage->requested_pixel_types[c] ==\n                   TINYEXR_PIXELTYPE_HALF) {\n          for (int y = 0; y < h; y++) {\n            for (int x = 0; x < exrImage->width; x++) {\n              unsigned short val = reinterpret_cast<unsigned short **>(\n                  exrImage->images)[c][(y + startY) * exrImage->width + x];\n\n              if (isBigEndian) {\n                swap2(&val);\n              }\n\n              // Assume increasing Y\n              unsigned short *linePtr = reinterpret_cast<unsigned short *>(\n                  &buf.at(pixelDataSize * y * exrImage->width +\n                          channelOffsetList[c] * exrImage->width));\n              linePtr[x] = val;\n            }\n          }\n        } else {\n          assert(0);\n        }\n\n      } else if (exrImage->pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) {\n\n        if (exrImage->requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) {\n          for (int y = 0; y < h; y++) {\n            for (int x = 0; x < exrImage->width; x++) {\n              FP32 f32;\n              f32.f = reinterpret_cast<float **>(\n                  exrImage->images)[c][(y + startY) * exrImage->width + x];\n\n              FP16 h16;\n              h16 = float_to_half_full(f32);\n\n              if (isBigEndian) {\n                swap2(reinterpret_cast<unsigned short *>(&h16.u));\n              }\n\n              // Assume increasing Y\n              unsigned short *linePtr = reinterpret_cast<unsigned short *>(\n                  &buf.at(pixelDataSize * y * exrImage->width +\n                          channelOffsetList[c] * exrImage->width));\n              linePtr[x] = h16.u;\n            }\n          }\n        } else if (exrImage->requested_pixel_types[c] ==\n                   TINYEXR_PIXELTYPE_FLOAT) {\n          for (int y = 0; y < h; y++) {\n            for (int x = 0; x < exrImage->width; x++) {\n              float val = reinterpret_cast<float **>(\n                  exrImage->images)[c][(y + startY) * exrImage->width + x];\n\n              if (isBigEndian) {\n                swap4(reinterpret_cast<unsigned int *>(&val));\n              }\n\n              // Assume increasing Y\n              float *linePtr = reinterpret_cast<float *>(\n                  &buf.at(pixelDataSize * y * exrImage->width +\n                          channelOffsetList[c] * exrImage->width));\n              linePtr[x] = val;\n            }\n          }\n        } else {\n          assert(0);\n        }\n      } else if (exrImage->pixel_types[c] == TINYEXR_PIXELTYPE_UINT) {\n\n        for (int y = 0; y < h; y++) {\n          for (int x = 0; x < exrImage->width; x++) {\n            unsigned int val = reinterpret_cast<unsigned int **>(\n                exrImage->images)[c][(y + startY) * exrImage->width + x];\n\n            if (isBigEndian) {\n              swap4(&val);\n            }\n\n            // Assume increasing Y\n            unsigned int *linePtr = reinterpret_cast<unsigned int *>(\n                &buf.at(pixelDataSize * y * exrImage->width +\n                        channelOffsetList[c] * exrImage->width));\n            linePtr[x] = val;\n          }\n        }\n      }\n    }\n\n    std::vector<unsigned char> block(miniz::mz_compressBound(buf.size()));\n    unsigned long long outSize = block.size();\n\n    CompressZip(&block.at(0), outSize,\n                reinterpret_cast<const unsigned char *>(&buf.at(0)),\n                buf.size());\n\n    // 4 byte: scan line\n    // 4 byte: data size\n    // ~     : pixel data(compressed)\n    std::vector<unsigned char> header(8);\n    unsigned int dataLen = outSize; // truncate\n    memcpy(&header.at(0), &startY, sizeof(int));\n    memcpy(&header.at(4), &dataLen, sizeof(unsigned int));\n\n    if (IsBigEndian()) {\n      swap4(reinterpret_cast<unsigned int *>(&header.at(0)));\n      swap4(reinterpret_cast<unsigned int *>(&header.at(4)));\n    }\n\n    dataList[i].insert(dataList[i].end(), header.begin(), header.end());\n    dataList[i].insert(dataList[i].end(), block.begin(),\n                       block.begin() + dataLen);\n\n    // data.insert(data.end(), header.begin(), header.end());\n    // data.insert(data.end(), block.begin(), block.begin() + dataLen);\n\n    // offsets[i] = offset;\n    // if (IsBigEndian()) {\n    //  swap8(reinterpret_cast<unsigned long long*>(&offsets[i]));\n    //}\n    // offset += dataLen + 8; // 8 = sizeof(blockHeader)\n  } // omp parallel\n\n  for (int i = 0; i < numBlocks; i++) {\n\n    data.insert(data.end(), dataList[i].begin(), dataList[i].end());\n\n    offsets[i] = offset;\n    if (IsBigEndian()) {\n      swap8(reinterpret_cast<unsigned long long *>(&offsets[i]));\n    }\n    offset += dataList[i].size();\n  }\n\n  {\n    memory.insert(memory.end(),\n                  reinterpret_cast<unsigned char *>(&offsets.at(0)),\n                  reinterpret_cast<unsigned char *>(&offsets.at(0)) +\n                      sizeof(unsigned long long) * numBlocks);\n  }\n\n  { memory.insert(memory.end(), data.begin(), data.end()); }\n\n  assert(memory.size() > 0);\n\n  (*memory_out) = (unsigned char *)malloc(memory.size());\n  memcpy((*memory_out), &memory.at(0), memory.size());\n\n  return memory.size(); // OK\n}\n\nint SaveMultiChannelEXRToFile(const EXRImage *exrImage, const char *filename,\n                              const char **err) {\n  if (exrImage == NULL || filename == NULL) {\n    if (err) {\n      (*err) = \"Invalid argument.\";\n    }\n    return -1;\n  }\n\n  FILE *fp = fopen(filename, \"wb\");\n  if (!fp) {\n    if (err) {\n      (*err) = \"Cannot write a file.\";\n    }\n    return -1;\n  }\n\n  unsigned char *mem = NULL;\n  size_t mem_size = SaveMultiChannelEXRToMemory(exrImage, &mem, err);\n\n  if ((mem_size > 0) && mem) {\n\n    fwrite(mem, 1, mem_size, fp);\n  }\n  free(mem);\n\n  fclose(fp);\n\n  return 0; // OK\n}\n\nint LoadDeepEXR(DeepImage *deepImage, const char *filename, const char **err) {\n  if (deepImage == NULL) {\n    if (err) {\n      (*err) = \"Invalid argument.\";\n    }\n    return -1;\n  }\n\n  FILE *fp = fopen(filename, \"rb\");\n  if (!fp) {\n    if (err) {\n      (*err) = \"Cannot read file.\";\n    }\n    return -1;\n  }\n\n  size_t filesize;\n  // Compute size\n  fseek(fp, 0, SEEK_END);\n  filesize = ftell(fp);\n  fseek(fp, 0, SEEK_SET);\n\n  if (filesize == 0) {\n    fclose(fp);\n    if (err) {\n      (*err) = \"File size is zero.\";\n    }\n    return -1;\n  }\n\n  std::vector<char> buf(filesize); // @todo { use mmap }\n  {\n    size_t ret;\n    ret = fread(&buf[0], 1, filesize, fp);\n    assert(ret == filesize);\n    (void)ret;\n  }\n  fclose(fp);\n\n  const char *head = &buf[0];\n  const char *marker = &buf[0];\n\n  // Header check.\n  {\n    const char header[] = {0x76, 0x2f, 0x31, 0x01};\n\n    if (memcmp(marker, header, 4) != 0) {\n      if (err) {\n        (*err) = \"Header mismatch.\";\n      }\n      return -3;\n    }\n    marker += 4;\n  }\n\n  // Version, scanline.\n  {\n    // ver 2.0, scanline, deep bit on(0x800)\n    // must be [2, 0, 0, 0]\n    if (marker[0] != 2 || marker[1] != 8 || marker[2] != 0 || marker[3] != 0) {\n      if (err) {\n        (*err) = \"Unsupported version or scanline.\";\n      }\n      return -4;\n    }\n\n    marker += 4;\n  }\n\n  int dx = -1;\n  int dy = -1;\n  int dw = -1;\n  int dh = -1;\n  int numScanlineBlocks = 1; // 16 for ZIP compression.\n  int compressionType = -1;\n  int numChannels = -1;\n  std::vector<ChannelInfo> channels;\n\n  // Read attributes\n  for (;;) {\n    std::string attrName;\n    std::string attrType;\n    std::vector<unsigned char> data;\n    const char *marker_next = ReadAttribute(attrName, attrType, data, marker);\n    if (marker_next == NULL) {\n      marker++; // skip '\\0'\n      break;\n    }\n\n    if (attrName.compare(\"compression\") == 0) {\n      // must be 0:No compression, 1: RLE, 2: ZIPs or 3: ZIP\n      if (data[0] > 3) {\n        if (err) {\n          (*err) = \"Unsupported compression type.\";\n        }\n        return -5;\n      }\n\n      compressionType = data[0];\n\n      if (compressionType == 3) { // ZIP\n        numScanlineBlocks = 16;\n      }\n\n    } else if (attrName.compare(\"channels\") == 0) {\n\n      // name: zero-terminated string, from 1 to 255 bytes long\n      // pixel type: int, possible values are: UINT = 0 HALF = 1 FLOAT = 2\n      // pLinear: unsigned char, possible values are 0 and 1\n      // reserved: three chars, should be zero\n      // xSampling: int\n      // ySampling: int\n\n      ReadChannelInfo(channels, data);\n\n      numChannels = channels.size();\n\n      if (numChannels < 1) {\n        if (err) {\n          (*err) = \"Invalid channels format.\";\n        }\n        return -6;\n      }\n\n    } else if (attrName.compare(\"dataWindow\") == 0) {\n      memcpy(&dx, &data.at(0), sizeof(int));\n      memcpy(&dy, &data.at(4), sizeof(int));\n      memcpy(&dw, &data.at(8), sizeof(int));\n      memcpy(&dh, &data.at(12), sizeof(int));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&dx));\n        swap4(reinterpret_cast<unsigned int *>(&dy));\n        swap4(reinterpret_cast<unsigned int *>(&dw));\n        swap4(reinterpret_cast<unsigned int *>(&dh));\n      }\n\n    } else if (attrName.compare(\"displayWindow\") == 0) {\n      int x;\n      int y;\n      int w;\n      int h;\n      memcpy(&x, &data.at(0), sizeof(int));\n      memcpy(&y, &data.at(4), sizeof(int));\n      memcpy(&w, &data.at(8), sizeof(int));\n      memcpy(&h, &data.at(12), sizeof(int));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&x));\n        swap4(reinterpret_cast<unsigned int *>(&y));\n        swap4(reinterpret_cast<unsigned int *>(&w));\n        swap4(reinterpret_cast<unsigned int *>(&h));\n      }\n    }\n\n    marker = marker_next;\n  }\n\n  assert(dx >= 0);\n  assert(dy >= 0);\n  assert(dw >= 0);\n  assert(dh >= 0);\n  assert(numChannels >= 1);\n\n  int dataWidth = dw - dx + 1;\n  int dataHeight = dh - dy + 1;\n\n  std::vector<float> image(dataWidth * dataHeight * 4); // 4 = RGBA\n\n  // Read offset tables.\n  int numBlocks = dataHeight / numScanlineBlocks;\n  if (numBlocks * numScanlineBlocks < dataHeight) {\n    numBlocks++;\n  }\n\n  std::vector<long long> offsets(numBlocks);\n\n  for (int y = 0; y < numBlocks; y++) {\n    long long offset;\n    memcpy(&offset, marker, sizeof(long long));\n    if (IsBigEndian()) {\n      swap8(reinterpret_cast<unsigned long long *>(&offset));\n    }\n    marker += sizeof(long long); // = 8\n    offsets[y] = offset;\n  }\n\n  if (compressionType != 0 && compressionType != 2 && compressionType != 3) {\n    if (err) {\n      (*err) = \"Unsupported format.\";\n    }\n    return -10;\n  }\n\n  deepImage->image = (float ***)malloc(sizeof(float **) * numChannels);\n  for (int c = 0; c < numChannels; c++) {\n    deepImage->image[c] = (float **)malloc(sizeof(float *) * dataHeight);\n    for (int y = 0; y < dataHeight; y++) {\n    }\n  }\n\n  deepImage->offset_table = (int **)malloc(sizeof(int *) * dataHeight);\n  for (int y = 0; y < dataHeight; y++) {\n    deepImage->offset_table[y] = (int *)malloc(sizeof(int) * dataWidth);\n  }\n\n  for (int y = 0; y < numBlocks; y++) {\n    const unsigned char *dataPtr =\n        reinterpret_cast<const unsigned char *>(head + offsets[y]);\n\n    // int: y coordinate\n    // int64: packed size of pixel offset table\n    // int64: packed size of sample data\n    // int64: unpacked size of sample data\n    // compressed pixel offset table\n    // compressed sample data\n    int lineNo;\n    long long packedOffsetTableSize;\n    long long packedSampleDataSize;\n    long long unpackedSampleDataSize;\n    memcpy(&lineNo, dataPtr, sizeof(int));\n    memcpy(&packedOffsetTableSize, dataPtr + 4, sizeof(long long));\n    memcpy(&packedSampleDataSize, dataPtr + 12, sizeof(long long));\n    memcpy(&unpackedSampleDataSize, dataPtr + 20, sizeof(long long));\n\n    if (IsBigEndian()) {\n      swap4(reinterpret_cast<unsigned int *>(&lineNo));\n      swap8(reinterpret_cast<unsigned long long *>(&packedOffsetTableSize));\n      swap8(reinterpret_cast<unsigned long long *>(&packedSampleDataSize));\n      swap8(reinterpret_cast<unsigned long long *>(&unpackedSampleDataSize));\n    }\n\n    std::vector<int> pixelOffsetTable(dataWidth);\n\n    // decode pixel offset table.\n    {\n      unsigned long dstLen = pixelOffsetTable.size() * sizeof(int);\n      DecompressZip(reinterpret_cast<unsigned char *>(&pixelOffsetTable.at(0)),\n                    dstLen, dataPtr + 28, packedOffsetTableSize);\n\n      assert(dstLen == pixelOffsetTable.size() * sizeof(int));\n      for (int i = 0; i < dataWidth; i++) {\n        deepImage->offset_table[y][i] = pixelOffsetTable[i];\n      }\n    }\n\n    std::vector<unsigned char> sampleData(unpackedSampleDataSize);\n\n    // decode sample data.\n    {\n      unsigned long dstLen = unpackedSampleDataSize;\n      DecompressZip(reinterpret_cast<unsigned char *>(&sampleData.at(0)),\n                    dstLen, dataPtr + 28 + packedOffsetTableSize,\n                    packedSampleDataSize);\n      assert(dstLen == (unsigned long)unpackedSampleDataSize);\n    }\n\n    // decode sample\n    int sampleSize = -1;\n    std::vector<int> channelOffsetList(numChannels);\n    {\n      int channelOffset = 0;\n      for (int i = 0; i < numChannels; i++) {\n        channelOffsetList[i] = channelOffset;\n        if (channels[i].pixelType == TINYEXR_PIXELTYPE_UINT) { // UINT\n          channelOffset += 4;\n        } else if (channels[i].pixelType == TINYEXR_PIXELTYPE_HALF) { // half\n          channelOffset += 2;\n        } else if (channels[i].pixelType == TINYEXR_PIXELTYPE_FLOAT) { // float\n          channelOffset += 4;\n        } else {\n          assert(0);\n        }\n      }\n      sampleSize = channelOffset;\n    }\n    assert(sampleSize >= 2);\n\n    assert((size_t)(pixelOffsetTable[dataWidth - 1] * sampleSize) == sampleData.size());\n    int samplesPerLine = sampleData.size() / sampleSize;\n\n    //\n    // Alloc memory\n    //\n\n    //\n    // pixel data is stored as image[channels][pixel_samples]\n    //\n    {\n      unsigned long long dataOffset = 0;\n      for (int c = 0; c < numChannels; c++) {\n\n        deepImage->image[c][y] =\n            (float *)malloc(sizeof(float) * samplesPerLine);\n\n        if (channels[c].pixelType == 0) { // UINT\n          for (int x = 0; x < samplesPerLine; x++) {\n            unsigned int ui = *reinterpret_cast<unsigned int *>(\n                                  &sampleData.at(dataOffset + x * sizeof(int)));\n            deepImage->image[c][y][x] = (float)ui; // @fixme\n          }\n          dataOffset += sizeof(unsigned int) * samplesPerLine;\n        } else if (channels[c].pixelType == 1) { // half\n          for (int x = 0; x < samplesPerLine; x++) {\n            FP16 f16;\n            f16.u = *reinterpret_cast<unsigned short *>(\n                        &sampleData.at(dataOffset + x * sizeof(short)));\n            FP32 f32 = half_to_float(f16);\n            deepImage->image[c][y][x] = f32.f;\n          }\n          dataOffset += sizeof(short) * samplesPerLine;\n        } else { // float\n          for (int x = 0; x < samplesPerLine; x++) {\n            float f = *reinterpret_cast<float *>(\n                          &sampleData.at(dataOffset + x * sizeof(float)));\n            deepImage->image[c][y][x] = f;\n          }\n          dataOffset += sizeof(float) * samplesPerLine;\n        }\n      }\n    }\n\n  } // y\n\n  deepImage->width = dataWidth;\n  deepImage->height = dataHeight;\n\n  deepImage->channel_names =\n      (const char **)malloc(sizeof(const char *) * numChannels);\n  for (int c = 0; c < numChannels; c++) {\n#ifdef _WIN32\n    deepImage->channel_names[c] = _strdup(channels[c].name.c_str());\n#else\n    deepImage->channel_names[c] = strdup(channels[c].name.c_str());\n#endif\n  }\n  deepImage->num_channels = numChannels;\n\n  return 0; // OK\n}\n\ninline int SaveDeepEXR(const DeepImage *deepImage, const char *filename,\n                const char **err) {\n  if (deepImage == NULL || filename == NULL) {\n    if (err) {\n      (*err) = \"Invalid argument.\";\n    }\n    return -1;\n  }\n\n  FILE *fp = fopen(filename, \"rb\");\n  if (!fp) {\n    if (err) {\n      (*err) = \"Cannot write file.\";\n    }\n    return -1;\n  }\n\n  // Write header check.\n  {\n    const char header[] = {0x76, 0x2f, 0x31, 0x01};\n    size_t n = fwrite(header, 1, 4, fp);\n    if (n != 4) {\n      if (err) {\n        (*err) = \"Header write failed.\";\n      }\n      fclose(fp);\n      return -3;\n    }\n  }\n\n  // Version, scanline.\n  {\n    // ver 2.0, scanline, deep bit on(0x800)\n    const char data[] = {2, 8, 0, 0};\n    size_t n = fwrite(data, 1, 4, fp);\n    if (n != 4) {\n      if (err) {\n        (*err) = \"Flag write failed.\";\n      }\n      fclose(fp);\n      return -3;\n    }\n  }\n\n  // Write attributes.\n  {\n    int data = 2; // ZIPS\n    WriteAttribute(fp, \"compression\", \"compression\",\n                   reinterpret_cast<const unsigned char *>(&data), sizeof(int));\n  }\n\n  {\n    int data[4] = {0, 0, deepImage->width - 1, deepImage->height - 1};\n    WriteAttribute(fp, \"dataWindow\", \"box2i\",\n                   reinterpret_cast<const unsigned char *>(data),\n                   sizeof(int) * 4);\n    WriteAttribute(fp, \"displayWindow\", \"box2i\",\n                   reinterpret_cast<const unsigned char *>(data),\n                   sizeof(int) * 4);\n  }\n\n  int numScanlineBlocks = 1;\n  // Write offset tables.\n  int numBlocks = deepImage->height / numScanlineBlocks;\n  if (numBlocks * numScanlineBlocks < deepImage->height) {\n    numBlocks++;\n  }\n\n#if 0 // @todo\n  std::vector<long long> offsets(numBlocks);\n\n  //std::vector<int> pixelOffsetTable(dataWidth);\n\n  // compress pixel offset table.\n  {\n      unsigned long dstLen = pixelOffsetTable.size() * sizeof(int);\n      Compresses(reinterpret_cast<unsigned char *>(&pixelOffsetTable.at(0)),\n                    dstLen, dataPtr + 28, packedOffsetTableSize);\n\n      assert(dstLen == pixelOffsetTable.size() * sizeof(int));\n      //      int ret =\n      //          miniz::mz_uncompress(reinterpret_cast<unsigned char\n      //          *>(&pixelOffsetTable.at(0)), &dstLen, dataPtr + 28,\n      //          packedOffsetTableSize);\n      //      printf(\"ret = %d, dstLen = %d\\n\", ret, (int)dstLen);\n      //\n      for (int i = 0; i < dataWidth; i++) {\n        // printf(\"offt[%d] = %d\\n\", i, pixelOffsetTable[i]);\n        deepImage->offset_table[y][i] = pixelOffsetTable[i];\n      }\n    }\n\n\n  for (int y = 0; y < numBlocks; y++) {\n    //long long offset = *(reinterpret_cast<const long long *>(marker));\n    // printf(\"offset[%d] = %lld\\n\", y, offset);\n    //marker += sizeof(long long); // = 8\n    offsets[y] = offset;\n  }\n\n  // Write offset table.\n  fwrite(&offsets.at(0), sizeof(long long), numBlocks, fp);\n\n  for (int y = 0; y < numBlocks; y++) {\n    const unsigned char *dataPtr =\n        reinterpret_cast<const unsigned char *>(head + offsets[y]);\n\n    // int: y coordinate\n    // int64: packed size of pixel offset table\n    // int64: packed size of sample data\n    // int64: unpacked size of sample data\n    // compressed pixel offset table\n    // compressed sample data\n    int lineNo = *reinterpret_cast<const int *>(dataPtr);\n    long long packedOffsetTableSize =\n        *reinterpret_cast<const long long *>(dataPtr + 4);\n    long long packedSampleDataSize =\n        *reinterpret_cast<const long long *>(dataPtr + 12);\n    long long unpackedSampleDataSize =\n        *reinterpret_cast<const long long *>(dataPtr + 20);\n    // printf(\"line: %d, %lld/%lld/%lld\\n\", lineNo, packedOffsetTableSize,\n    // packedSampleDataSize, unpackedSampleDataSize);\n\n    int endLineNo = (std::min)(lineNo + numScanlineBlocks, dataHeight);\n\n    int numLines = endLineNo - lineNo;\n    // printf(\"numLines: %d\\n\", numLines);\n\n    std::vector<int> pixelOffsetTable(dataWidth);\n\n    // decode pixel offset table.\n    {\n      unsigned long dstLen = pixelOffsetTable.size() * sizeof(int);\n      DecompressZip(reinterpret_cast<unsigned char *>(&pixelOffsetTable.at(0)),\n                    dstLen, dataPtr + 28, packedOffsetTableSize);\n\n      assert(dstLen == pixelOffsetTable.size() * sizeof(int));\n      //      int ret =\n      //          miniz::mz_uncompress(reinterpret_cast<unsigned char\n      //          *>(&pixelOffsetTable.at(0)), &dstLen, dataPtr + 28,\n      //          packedOffsetTableSize);\n      //      printf(\"ret = %d, dstLen = %d\\n\", ret, (int)dstLen);\n      //\n      for (int i = 0; i < dataWidth; i++) {\n        // printf(\"offt[%d] = %d\\n\", i, pixelOffsetTable[i]);\n        deepImage->offset_table[y][i] = pixelOffsetTable[i];\n      }\n    }\n\n    std::vector<unsigned char> sampleData(unpackedSampleDataSize);\n\n    // decode sample data.\n    {\n      unsigned long dstLen = unpackedSampleDataSize;\n      // printf(\"dstLen = %d\\n\", dstLen);\n      // printf(\"srcLen = %d\\n\", packedSampleDataSize);\n      DecompressZip(reinterpret_cast<unsigned char *>(&sampleData.at(0)),\n                    dstLen, dataPtr + 28 + packedOffsetTableSize,\n                    packedSampleDataSize);\n      assert(dstLen == unpackedSampleDataSize);\n    }\n\n    // decode sample\n    int sampleSize = -1;\n    std::vector<int> channelOffsetList(numChannels);\n    {\n      int channelOffset = 0;\n      for (int i = 0; i < numChannels; i++) {\n        // printf(\"offt[%d] = %d\\n\", i, channelOffset);\n        channelOffsetList[i] = channelOffset;\n        if (channels[i].pixelType == 0) { // UINT\n          channelOffset += 4;\n        } else if (channels[i].pixelType == 1) { // half\n          channelOffset += 2;\n        } else if (channels[i].pixelType == 2) { // float\n          channelOffset += 4;\n        } else {\n          assert(0);\n        }\n      }\n      sampleSize = channelOffset;\n    }\n    assert(sampleSize >= 2);\n\n    assert(pixelOffsetTable[dataWidth - 1] * sampleSize == sampleData.size());\n    int samplesPerLine = sampleData.size() / sampleSize;\n\n    //\n    // Alloc memory\n    //\n\n    //\n    // pixel data is stored as image[channels][pixel_samples]\n    //\n    {\n      unsigned long long dataOffset = 0;\n      for (int c = 0; c < numChannels; c++) {\n\n        deepImage->image[c][y] =\n            (float *)malloc(sizeof(float) * samplesPerLine);\n\n        // unsigned int channelOffset = channelOffsetList[c];\n        // unsigned int i = channelOffset;\n        // printf(\"channel = %d. name = %s. ty = %d\\n\", c,\n        // channels[c].name.c_str(), channels[c].pixelType);\n\n        // printf(\"dataOffset = %d\\n\", (int)dataOffset);\n\n        if (channels[c].pixelType == 0) { // UINT\n          for (int x = 0; x < samplesPerLine; x++) {\n            unsigned int ui = *reinterpret_cast<unsigned int *>(\n                                  &sampleData.at(dataOffset + x * sizeof(int)));\n            deepImage->image[c][y][x] = (float)ui; // @fixme\n          }\n          dataOffset += sizeof(unsigned int) * samplesPerLine;\n        } else if (channels[c].pixelType == 1) { // half\n          for (int x = 0; x < samplesPerLine; x++) {\n            FP16 f16;\n            f16.u = *reinterpret_cast<unsigned short *>(\n                        &sampleData.at(dataOffset + x * sizeof(short)));\n            FP32 f32 = half_to_float(f16);\n            deepImage->image[c][y][x] = f32.f;\n            // printf(\"c[%d]  f(half) = %f (0x%08x)\\n\", c, f32.f, f16.u);\n          }\n          dataOffset += sizeof(short) * samplesPerLine;\n        } else { // float\n          for (int x = 0; x < samplesPerLine; x++) {\n            float f = *reinterpret_cast<float *>(\n                          &sampleData.at(dataOffset + x * sizeof(float)));\n            // printf(\"  f = %f(0x%08x)\\n\", f, *((unsigned int *)&f));\n            deepImage->image[c][y][x] = f;\n          }\n          dataOffset += sizeof(float) * samplesPerLine;\n        }\n      }\n      // printf(\"total: %d\\n\", dataOffset);\n    }\n\n  } // y\n#endif\n  fclose(fp);\n\n  return 0; // OK\n}\n\nvoid InitEXRImage(EXRImage *exrImage) {\n  if (exrImage == NULL) {\n    return;\n  }\n\n  exrImage->num_custom_attributes = 0;\n  exrImage->num_channels = 0;\n  exrImage->channel_names = NULL;\n  exrImage->images = NULL;\n  exrImage->pixel_types = NULL;\n  exrImage->requested_pixel_types = NULL;\n}\n\nint FreeEXRImage(EXRImage *exrImage) {\n\n  if (exrImage == NULL) {\n    return -1; // Err\n  }\n\n  for (int i = 0; i < exrImage->num_channels; i++) {\n\n    if (exrImage->channel_names && exrImage->channel_names[i]) {\n      free((char *)exrImage->channel_names[i]); // remove const\n    }\n\n    if (exrImage->images && exrImage->images[i]) {\n      free(exrImage->images[i]);\n    }\n  }\n\n  if (exrImage->channel_names) {\n    free(exrImage->channel_names);\n  }\n\n  if (exrImage->images) {\n    free(exrImage->images);\n  }\n\n  if (exrImage->pixel_types) {\n    free(exrImage->pixel_types);\n  }\n\n  if (exrImage->requested_pixel_types) {\n    free(exrImage->requested_pixel_types);\n  }\n\n  for (int i = 0; i < exrImage->num_custom_attributes; i++) {\n    if (exrImage->custom_attributes[i].name) {\n      free(exrImage->custom_attributes[i].name);\n    }\n    if (exrImage->custom_attributes[i].type) {\n      free(exrImage->custom_attributes[i].type);\n    }\n    if (exrImage->custom_attributes[i].value) {\n      free(exrImage->custom_attributes[i].value);\n    }\n  }\n\n  return 0;\n}\n\ninline int ParseMultiChannelEXRHeaderFromFile(EXRImage *exrImage, const char *filename,\n                                       const char **err) {\n  if (exrImage == NULL) {\n    if (err) {\n      (*err) = \"Invalid argument.\";\n    }\n    return -1;\n  }\n\n  FILE *fp = fopen(filename, \"rb\");\n  if (!fp) {\n    if (err) {\n      (*err) = \"Cannot read file.\";\n    }\n    return -1;\n  }\n\n  size_t filesize;\n  // Compute size\n  fseek(fp, 0, SEEK_END);\n  filesize = ftell(fp);\n  fseek(fp, 0, SEEK_SET);\n\n  std::vector<unsigned char> buf(filesize); // @todo { use mmap }\n  {\n    size_t ret;\n    ret = fread(&buf[0], 1, filesize, fp);\n    assert(ret == filesize);\n    fclose(fp);\n    (void)ret;\n  }\n\n  return ParseMultiChannelEXRHeaderFromMemory(exrImage, &buf.at(0), err);\n}\n\nint ParseMultiChannelEXRHeaderFromMemory(EXRImage *exrImage,\n                                         const unsigned char *memory,\n                                         const char **err) {\n  if (exrImage == NULL || memory == NULL) {\n    if (err) {\n      (*err) = \"Invalid argument.\";\n    }\n    return -1;\n  }\n\n  const char *buf = reinterpret_cast<const char *>(memory);\n\n  const char *marker = &buf[0];\n\n  // Header check.\n  {\n    const char header[] = {0x76, 0x2f, 0x31, 0x01};\n\n    if (memcmp(marker, header, 4) != 0) {\n      if (err) {\n        (*err) = \"Header mismatch.\";\n      }\n      return -3;\n    }\n    marker += 4;\n  }\n\n  // Version, scanline.\n  {\n    // must be [2, 0, 0, 0]\n    if (marker[0] != 2 || marker[1] != 0 || marker[2] != 0 || marker[3] != 0) {\n      if (err) {\n        (*err) = \"Unsupported version or scanline.\";\n      }\n      return -4;\n    }\n\n    marker += 4;\n  }\n\n  int dx = -1;\n  int dy = -1;\n  int dw = -1;\n  int dh = -1;\n  int numChannels = -1;\n  int displayWindow[4] = {-1, -1, -1, -1}; // @fixme.\n  float screenWindowCenter[2] = {0.0f, 0.0f}; // @fixme\n  float screenWindowWidth = 1.0f; // @fixme\n  float pixelAspectRatio = 1.0f;\n  unsigned char lineOrder = 0; // 0 -> increasing y; 1 -> decreasing\n  std::vector<ChannelInfo> channels;\n\n  int numCustomAttributes = 0;\n  std::vector<EXRAttribute> customAttribs;\n\n  // Read attributes\n  for (;;) {\n    std::string attrName;\n    std::string attrType;\n    std::vector<unsigned char> data;\n    const char *marker_next = ReadAttribute(attrName, attrType, data, marker);\n    if (marker_next == NULL) {\n      marker++; // skip '\\0'\n      break;\n    }\n\n    if (attrName.compare(\"compression\") == 0) {\n      // must be 0:No compression, 1: RLE, 2: ZIPs, 3: ZIP or 4: PIZ\n      if (data[0] > 4) {\n        if (err) {\n          (*err) = \"Unsupported compression type.\";\n        }\n        return -5;\n      }\n\n    } else if (attrName.compare(\"channels\") == 0) {\n\n      // name: zero-terminated string, from 1 to 255 bytes long\n      // pixel type: int, possible values are: UINT = 0 HALF = 1 FLOAT = 2\n      // pLinear: unsigned char, possible values are 0 and 1\n      // reserved: three chars, should be zero\n      // xSampling: int\n      // ySampling: int\n\n      ReadChannelInfo(channels, data);\n\n      numChannels = channels.size();\n\n      if (numChannels < 1) {\n        if (err) {\n          (*err) = \"Invalid channels format.\";\n        }\n        return -6;\n      }\n\n    } else if (attrName.compare(\"dataWindow\") == 0) {\n      memcpy(&dx, &data.at(0), sizeof(int));\n      memcpy(&dy, &data.at(4), sizeof(int));\n      memcpy(&dw, &data.at(8), sizeof(int));\n      memcpy(&dh, &data.at(12), sizeof(int));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&dx));\n        swap4(reinterpret_cast<unsigned int *>(&dy));\n        swap4(reinterpret_cast<unsigned int *>(&dw));\n        swap4(reinterpret_cast<unsigned int *>(&dh));\n      }\n    } else if (attrName.compare(\"displayWindow\") == 0) {\n      memcpy(&displayWindow[0], &data.at(0), sizeof(int));\n      memcpy(&displayWindow[1], &data.at(4), sizeof(int));\n      memcpy(&displayWindow[2], &data.at(8), sizeof(int));\n      memcpy(&displayWindow[3], &data.at(12), sizeof(int));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&displayWindow[0]));\n        swap4(reinterpret_cast<unsigned int *>(&displayWindow[1]));\n        swap4(reinterpret_cast<unsigned int *>(&displayWindow[2]));\n        swap4(reinterpret_cast<unsigned int *>(&displayWindow[3]));\n      }\n    } else if (attrName.compare(\"lineOrder\") == 0) {\n      memcpy(&lineOrder, &data.at(0), sizeof(lineOrder));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&lineOrder));\n      }\n    } else if (attrName.compare(\"pixelAspectRatio\") == 0) {\n      memcpy(&pixelAspectRatio, &data.at(0), sizeof(float));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&pixelAspectRatio));\n      }\n    } else if (attrName.compare(\"screenWindowCenter\") == 0) {\n      memcpy(&screenWindowCenter[0], &data.at(0), sizeof(float));\n      memcpy(&screenWindowCenter[1], &data.at(4), sizeof(float));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&screenWindowCenter[0]));\n        swap4(reinterpret_cast<unsigned int *>(&screenWindowCenter[1]));\n      }\n    } else if (attrName.compare(\"screenWindowWidth\") == 0) {\n      memcpy(&screenWindowWidth, &data.at(0), sizeof(float));\n      if (IsBigEndian()) {\n        swap4(reinterpret_cast<unsigned int *>(&screenWindowWidth));\n      }\n    } else {\n      // Custom attribute(up to TINYEXR_MAX_ATTRIBUTES)\n      if (numCustomAttributes < TINYEXR_MAX_ATTRIBUTES) {\n        EXRAttribute attrib;\n        attrib.name = strdup(attrName.c_str());\n        attrib.type = strdup(attrType.c_str());\n        attrib.size = data.size();\n        attrib.value = (unsigned char*)malloc(data.size());\n        memcpy((char*)attrib.value, &data.at(0), data.size());\n        customAttribs.push_back(attrib);\n      }\n    }\n\n    marker = marker_next;\n  }\n\n  assert(dx >= 0);\n  assert(dy >= 0);\n  assert(dw >= 0);\n  assert(dh >= 0);\n  assert(numChannels >= 1);\n\n  int dataWidth = dw - dx + 1;\n  int dataHeight = dh - dy + 1;\n\n  {\n    exrImage->channel_names =\n        (const char **)malloc(sizeof(const char *) * numChannels);\n    for (int c = 0; c < numChannels; c++) {\n#ifdef _WIN32\n      exrImage->channel_names[c] = _strdup(channels[c].name.c_str());\n#else\n      exrImage->channel_names[c] = strdup(channels[c].name.c_str());\n#endif\n    }\n    exrImage->num_channels = numChannels;\n\n    exrImage->width = dataWidth;\n    exrImage->height = dataHeight;\n    exrImage->pixel_aspect_ratio = pixelAspectRatio;\n    exrImage->screen_window_center[0] = screenWindowCenter[0];\n    exrImage->screen_window_center[1] = screenWindowCenter[1];\n    exrImage->screen_window_width = screenWindowWidth;\n    exrImage->display_window[0] = displayWindow[0];\n    exrImage->display_window[1] = displayWindow[1];\n    exrImage->display_window[2] = displayWindow[2];\n    exrImage->display_window[3] = displayWindow[3];\n    exrImage->data_window[0] = dx;\n    exrImage->data_window[1] = dy;\n    exrImage->data_window[2] = dw;\n    exrImage->data_window[3] = dh;\n    exrImage->line_order = lineOrder;\n\n    exrImage->pixel_types = (int *)malloc(sizeof(int) * numChannels);\n    for (int c = 0; c < numChannels; c++) {\n      exrImage->pixel_types[c] = channels[c].pixelType;\n    }\n\n    // Initially fill with values of `pixel-types`\n    exrImage->requested_pixel_types = (int *)malloc(sizeof(int) * numChannels);\n    for (int c = 0; c < numChannels; c++) {\n      exrImage->requested_pixel_types[c] = channels[c].pixelType;\n    }\n  }\n\n  if (numCustomAttributes > 0) {\n    assert(customAttribs.size() < TINYEXR_MAX_ATTRIBUTES);\n    exrImage->num_custom_attributes = numCustomAttributes;\n\n    for (int i = 0; i < (int)customAttribs.size(); i++) {\n      exrImage->custom_attributes[i] = customAttribs[i];\n    }\n  } \n\n  return 0; // OK\n}\n\n#endif\n\n#endif // __TINYEXR_H__\n"
  },
  {
    "path": "include/features_matching/binary_feature_brute_force_matcher.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_BINARY_FEATURE_BRUTE_FORCE_MATCHER\n#define PIC_FEATURES_MATCHING_BINARY_FEATURE_BRUTE_FORCE_MATCHER\n\n#include <vector>\n\n#include \"../features_matching/feature_matcher.hpp\"\n\nnamespace pic{\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief The BinaryFeatureBruteForceMatcher class\n */\nclass BinaryFeatureBruteForceMatcher : public FeatureMatcher<unsigned int>\n{\npublic:\n\n    /**\n     * @brief BinaryFeatureBruteForceMatcher\n     * @param descs\n     * @param n\n     */\n    BinaryFeatureBruteForceMatcher(std::vector<unsigned int *> *descs, unsigned int desc_size) : FeatureMatcher<unsigned int>(descs, desc_size)\n    {\n    }\n\n    /**\n     * @brief getMatch\n     * @param desc0\n     * @param matched_j\n     * @param dist_1\n     * @return\n     */\n    bool getMatch(unsigned int *desc, int &matched_j, unsigned int &dist_1)\n    {\n        unsigned int dist_2 = 0;\n\n        dist_1 = 0;\n\n        matched_j = -1;\n\n        for(unsigned int j = 0; j < descs->size(); j++) {\n            unsigned int dist = BRIEFDescriptor::match(desc, descs->at(j), desc_size);\n\n            if(dist > dist_1) {\n                dist_2 = dist_1;\n                dist_1 = dist;\n                matched_j = j;\n             } else {\n                if(dist > dist_2) {\n                    dist_2 = dist;\n                }\n            }\n        }\n\n        return ((dist_1 * 100 > dist_2 * 105) && matched_j != -1);\n    }\n};\n\n#endif\n\n}\n\n#endif // PIC_FEATURES_MATCHING_BINARY_FEATURE_BRUTE_FORCE_MATCHER\n"
  },
  {
    "path": "include/features_matching/binary_feature_lsh_matcher.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_BINARY_FEATURE_LSH_MATCHER_HPP\n#define PIC_FEATURES_MATCHING_BINARY_FEATURE_LSH_MATCHER_HPP\n\n#include <vector>\n\n#include \"../base.hpp\"\n#include \"../features_matching/hash_table_lsh.hpp\"\n#include \"../features_matching/feature_matcher.hpp\"\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief The LSH class\n */\nclass BinaryFeatureLSHMatcher: public FeatureMatcher<uint>\n{\nprotected:\n    std::vector< HashTableLSH* > tables;\n    uint R;\n\npublic:\n\n    /**\n     * @brief LSH\n     */\n    BinaryFeatureLSHMatcher(std::vector< uint *> *descs, uint desc_size, uint nTables = 32, uint hash_size = 8) : FeatureMatcher<uint>(descs, desc_size)\n    {\n        this->R = ((desc_size * sizeof(uint) * 8) * 90) / 100;\n\n        std::mt19937 m_rnd(1);\n\n        for(uint i=0; i < nTables; i++) {\n            uint n = desc_size * sizeof(uint) * 8;\n            uint *g_f = getHash(m_rnd, n, hash_size);\n            HashTableLSH *tmp = new HashTableLSH(hash_size, g_f, descs, desc_size);\n            tables.push_back(tmp);\n        }\n    }\n\n    /**\n     * @brief getHash\n     * @param dim\n     * @param hash_size\n     * @param seed\n     * @return\n     */\n    static uint *getHash(std::mt19937 &m, uint dim, uint hash_size = 0)\n    {\n        if(hash_size == 0) {\n            hash_size = 8;\n        }\n\n        uint *out = new uint[hash_size];\n\n        std::set<uint> tmp;\n\n        int c = 0;\n        while (tmp.size() < hash_size) {\n            uint val = m() % dim;\n            auto result = tmp.insert(val);\n\n            if(result.second) {\n                out[c] = val;\n                c++;\n            }\n        }\n\n        return out;\n    }\n\n    /**\n     * @brief getMatch\n     * @param desc0\n     * @param matched_j\n     * @param dist_1\n     * @return\n     */\n    bool getMatch(uint *desc, int &matched_j, uint &dist_1)\n    {\n        uint dist_2 = 0;\n\n        dist_1 = R;\n        matched_j = -1;\n\n        for(uint i = 0; i < tables.size(); i++) {\n            tables[i]->getNearest(desc, matched_j, dist_1, dist_2);\n        }\n\n        return (matched_j != -1);// && (dist_1 * 100 > dist_2 * 105);\n    }\n};\n\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_BINARY_FEATURE_LSH_MATCHER_HPP */\n\n"
  },
  {
    "path": "include/features_matching/brief_descriptor.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_BRIEF_DESCRIPTOR_HPP\n#define PIC_FEATURES_MATCHING_BRIEF_DESCRIPTOR_HPP\n\n#include <random>\n#include <chrono>\n#include <vector>\n\n#include \"../base.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../util/math.hpp\"\n#include \"../image.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief The BRIEFDescriptor class\n */\nclass BRIEFDescriptor\n{\nprotected:\n    int S;\n    unsigned int n;\n    float sigma_sq_2, sigma_sq;\n    std::mt19937 *m;\n\n    //samples coordinates\n    int *x, *y;\n\n    /**\n     * @brief generateSample\n     * @param sample\n     */\n    void generateSample(int *sample)\n    {\n        float theta = C_PI_2 * getRandom((*m)());\n\n        float u = getRandom((*m)());\n        float r = sqrtf(MAX(-logf(u) * sigma_sq_2, 0.0f));\n\n        sample[0] = int(r * cosf(theta));\n        sample[1] = int(r * sinf(theta));\n    }\n\n    /**\n     * @brief generateSamples\n     * @param n\n     */\n    void generateSamples(unsigned int n)\n    {\n        this->n = n;\n        unsigned int n2 = n * 2;\n\n        x = new int [n2];\n        y = new int [n2];\n\n        for(unsigned int i = 0; i < n2; i += 2) {\n            generateSample(&x[i]);\n            generateSample(&y[i]);\n        }\n    }\n\n    /**\n     * @brief countZeros\n     * @param x\n     * @return\n     */\n    static unsigned int countZeros(unsigned int x)\n    {\n        unsigned int n = sizeof(unsigned int) * 8;\n\n        unsigned int ret = 0;\n\n        for(unsigned int i = 0; i < n; i++) {\n            if((x & (1 << i)) == 0) {\n                ret++;\n            }\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief getAux computes a descriptor at position (x0,y0) with size n.\n     * @param img\n     * @param x0\n     * @param y0\n     * @param desc\n     * @return\n     */\n    uint* getAux(Image *img, int x0, int y0, int *x, int *y, uint *desc = NULL)\n    {\n        unsigned int bits = sizeof(unsigned int) * 8;\n        unsigned int subBlock = n / bits;\n\n        if(desc == NULL) {\n            desc = new unsigned int[subBlock];\n        }\n\n        int c = 0;\n\n        for(unsigned int i = 0; i < subBlock; i++) {\n            unsigned int value = 0;\n\n            for(unsigned int j = 0; j < bits; j++) {\n                int cShifted = c * 2;\n\n                float *p_x_val = (*img)(x0 + x[cShifted], y0 + x[cShifted + 1]);\n                float *p_y_val = (*img)(x0 + y[cShifted], y0 + y[cShifted + 1]);\n\n                float p_x = 0.0f;\n                float p_y = 0.0f;\n\n                for(int k = 0; k < img->channels; k++) {\n                    p_x\t+= p_x_val[k];\n                    p_y\t+= p_y_val[k];\n                }\n\n                unsigned int ret = (p_x < p_y) ? 1 : 0;\n\n                value += (ret << j);\n\n                c++;\n            }\n\n            desc[i] = value;\n        }\n\n        return desc;\n    }\n\npublic:\n\n    /**\n     * @brief BRIEFDescriptor\n     * @param S\n     * @param n\n     */\n    BRIEFDescriptor(int S = 32, int n = 256, int seed = 1)\n    {\n        if(seed >= 0) {\n            m = new std::mt19937(seed);\n        } else {\n            auto seed_time = std::chrono::system_clock::now().time_since_epoch().count();\n            m = new std::mt19937(int (seed_time));\n        }\n\n        this->S = S;\n        this->sigma_sq = float(S * S) / 25.0f;\n        this->sigma_sq_2 = 2.0f * this->sigma_sq;\n\n        generateSamples(n);\n    }\n\n    ~BRIEFDescriptor()\n    {\n        release();\n    }\n\n    /**\n     * @brief Release deallocates memory.\n     */\n    void release()\n    {\n        m = delete_s(m);\n        x = delete_s(x);\n        y = delete_s(y);\n    }\n\n    /**\n     * @brief get computes a descriptor at position (x0,y0) with size n.\n     * @param img\n     * @param x0\n     * @param y0\n     * @param desc\n     * @return\n     */\n    uint *get(Image *img, int x0, int y0, uint *desc = NULL)\n    {\n        if(img == NULL) {\n            return NULL;\n        }\n\n        if(!img->checkCoordinates(x0, y0)) {\n            return NULL;\n        }\n\n        return getAux(img, x0, y0, x, y, desc);\n    }\n\n    #ifndef PIC_DISABLE_EIGEN\n    /**\n     * @brief getAll\n     * @param descs\n     * @param corners\n     * @param img\n     */\n    void getAll(Image *img,\n                std::vector< Eigen::Vector2f > &corners,\n                std::vector< uint* > &descs)\n    {\n        descs.clear();\n\n        for(unsigned int i = 0; i < corners.size(); i++) {\n            int x0 = int(corners[i][0]);\n            int y0 = int(corners[i][1]);\n            descs.push_back(get(img, x0, y0, NULL));\n        }\n    }\n    #endif\n\n    /**\n     * @brief getDescriptorSize returns the descriptor size.\n     * @return the descriptor size.\n     */\n    int getDescriptorSize() {\n        return n / (sizeof(unsigned int) * 8);\n    }  \n\n    /**\n     * @brief match matches two descriptors. Note: Higher scores means better matching.\n     * @param fv0\n     * @param fv1\n     * @param nfv\n     * @return\n     */\n    static uint match(uint *fv0, uint *fv1, uint nfv)\n    {\n        if((fv0 == NULL) || (fv1 == NULL)) {\n            return 0;\n        }\n\n        uint ret = 0;\n        for(uint i = 0; i < nfv; i++) {\n            ret += countZeros(fv0[i] ^ fv1[i]);\n        }\n\n        return ret;\n    }\n};\n\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_BRIEF_DESCRIPTOR_HPP */\n\n"
  },
  {
    "path": "include/features_matching/canny_edge_detector.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_CANNY_EDGE_DETECTOR_HPP\n#define PIC_FEATURES_MATCHING_CANNY_EDGE_DETECTOR_HPP\n\n#include \"../util/vec.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../image.hpp\"\n\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n#include \"../filtering/filter_gradient.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The CannyEdgeDetector class\n */\nclass CannyEdgeDetector\n{\nprotected:\n    bool  bLum;\n    Image *lum;\n\n    float sigma, threshold_1, threshold_2;\n\n    /**\n     * @brief release frees allocated memory for this class.\n     */\n    void release()\n    {\n        lum = delete_s(lum);\n        bLum = false;\n    }\n\npublic:\n    /**\n     * @brief CannyEdgeDetector\n     */\n    CannyEdgeDetector()\n    {\n        lum = NULL;\n        bLum = false;\n\n        update();\n    }\n\n    ~CannyEdgeDetector()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param sigma\n     * @param threshold_1\n     * @param threshold_2\n     */\n    void update(float sigma = 1.4f, float threshold_1 = 0.05f, float threshold_2 = 0.3f)\n    {\n        this->sigma = sigma > 0.0f ? sigma : 1.4f;\n        this->threshold_1 = threshold_1 > 0.0f ? threshold_1 : 0.05f;\n        this->threshold_2 = threshold_2 > 0.0f ? threshold_1 : 0.3f;\n\n        if(threshold_2 < threshold_1) {\n            float tmp = threshold_1;\n            threshold_1 = threshold_2;\n            threshold_2 = tmp;\n        }\n    }\n\n    /**\n     * @brief execute executes Canny edge detector on img and ouputs imgEdges as results.\n     * @param img\n     * @param imgEdges\n     * @return\n     */\n    Image *execute(Image *img, Image *imgOut)\n    {\n        if(img == NULL) {\n            return imgOut;\n        }\n\n        if(img->channels == 1) {\n            release();\n            lum = img;\n        } else {\n            bLum = true;\n            lum = FilterLuminance::execute(img, lum, LT_CIE_LUMINANCE);\n        }\n\n        //filter the image\n        FilterGaussian2D flt(sigma);\n        Image *lum_flt = flt.Process(Single(lum), NULL);\n\n        FilterGradient fltGrad(0, G_SOBEL);\n        Image *grad = fltGrad.Process(Single(lum_flt), NULL);\n\n        //non-maximum suppression\n        if(imgOut == NULL) {\n            imgOut = lum->allocateSimilarOne();\n        }\n\n        imgOut->setZero();\n\n        int dx0[] = {1, 1, 0, -1, 1};\n        int dy0[] = {0, 1, 1,  1, 0};\n\n        int dx1[] = {-1, -1,  0,  1, -1};\n        int dy1[] = { 0, -1, -1, -1,  0};\n\n        for(int i = 0; i < grad->height; i++) {\n            for(int j = 0; j < grad->width; j++) {\n\n                float *tmp_grad = (*grad)(j, i);\n\n                float angle = atan2(tmp_grad[1], tmp_grad[0]);\n\n                angle = Rad2Deg(angle < 0.0f ? C_PI + angle : angle);\n                int k = int(lround(angle / 45.0f));\n\n                bool bMax = (tmp_grad[2] > (*grad)(j + dx0[k], i + dy0[k])[2]) &&\n                            (tmp_grad[2] > (*grad)(j + dx1[k], i + dy1[k])[2]);\n\n                /*\n                bool bMax = false;\n\n                if(((angle >=   0.0f) && (angle < 22.5f)) ||\n                   ((angle >= 157.5f))) {\n                    bMax = (tmp_grad[2] > (*grad)(j + 1, i)[2]) &&\n                           (tmp_grad[2] > (*grad)(j - 1, i)[2]);\n                }\n\n                if((angle >= 22.5f) && (angle < 67.5f)) {\n                    bMax = (tmp_grad[2] > (*grad)(j + 1, i + 1)[2]) &&\n                           (tmp_grad[2] > (*grad)(j - 1, i - 1)[2]);\n                }\n\n                if((angle >= 67.5f) && (angle < 112.5f)) {\n                    bMax = (tmp_grad[2] > (*grad)(j, i + 1)[2]) &&\n                           (tmp_grad[2] > (*grad)(j, i - 1)[2]);\n                }\n\n                if((angle >= 112.5f) && (angle < 157.5f)) {\n                    bMax = (tmp_grad[2] > (*grad)(j - 1, i + 1)[2]) &&\n                           (tmp_grad[2] > (*grad)(j + 1, i - 1)[2]);\n                }*/\n\n                float *imgOut_ji = (*imgOut)(j, i);\n\n                imgOut_ji[0] = bMax ? tmp_grad[2] : 0.0f;\n            }\n        }\n\n        //double thresholding\n        for(int i = 0; i < imgOut->height; i++) {\n            for(int j = 0; j < imgOut->width; j++) {\n                float *imgOut_ji = (*imgOut)(j, i);\n\n                if(imgOut_ji[0] > threshold_2) {\n                    imgOut_ji[0] = 1.0f; //strong edge\n                } else {\n                    //0.5f --> weak edge\n                    //0.0f --> no edge\n                    imgOut_ji[0] = imgOut_ji[0] > threshold_1 ? 0.5f : 0.0f;\n                }\n            }\n        }\n\n        //remove false edges: a weak edge is a strong one\n        //if it is connected to a strong edge\n        int x[] = {1, 1, 0, -1, -1, -1,  0,  1};\n        int y[] = {0, 1, 1,  1,  0, -1, -1, -1};\n\n        for(int i = 0; i < imgOut->height; i++) {\n            for(int j = 0; j < imgOut->width; j++) {\n                float *imgOut_ji = (*imgOut)(j, i);\n\n                if((imgOut_ji[0] > 0.4f) && (imgOut_ji[0] < 0.6f)) {\n                    bool bRemove = true;\n\n                    for(int k = 0; k < 8; k++) {\n                        float *imgOut_ji_xy = (*imgOut)(j + x[k], i + y[k]);\n\n                        if(imgOut_ji_xy[0] > 0.9f) {\n                            bRemove = false;\n                            break;\n                        }\n                    }\n\n                    imgOut_ji[0] = bRemove ? 0.0f : 1.0f;\n                }\n            }\n        }\n\n        delete lum_flt;\n        delete grad;\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_CANNY_EDGE_DETECTOR_HPP */\n\n"
  },
  {
    "path": "include/features_matching/fast_corner_detector.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_FAST_CORNER_DETECTOR_HPP\n#define PIC_FEATURES_MATCHING_FAST_CORNER_DETECTOR_HPP\n\n#include \"../util/vec.hpp\"\n#include \"../util/std_util.hpp\"\n\n#include \"../image.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n\n#include \"../features_matching/general_corner_detector.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\nclass FastCornerDetector: public GeneralCornerDetector\n{\nprotected:\n    Image *lum_flt;\n    bool bexecuteThreshold;\n\n    float sigma, threshold;\n    int radius;\n\npublic:\n    /**\n     * @brief FastCornerDetector\n     * @param sigma\n     * @param radius\n     * @param threshold\n     */\n    FastCornerDetector(float sigma = 1.0f, int radius = 1, float threshold = 0.001f) : GeneralCornerDetector()\n    {\n        bexecuteThreshold = true;\n\n        lum_flt = NULL;\n\n        update(sigma, radius, threshold);\n    }\n\n    ~FastCornerDetector()\n    {\n        lum = delete_s(lum);\n        lum_flt = delete_s(lum_flt);\n    }\n\n    /**\n     * @brief update\n     * @param sigma\n     * @param radius\n     * @param threshold\n     */\n    void update(float sigma = 1.0f, int radius = 1, float threshold = 0.001f)\n    {\n        this->sigma = sigma > 0.0f ? sigma : 1.0f;\n        this->radius = radius > 0 ? radius : 1;\n        this->threshold = threshold > 0.001f ? threshold : 0.001f;\n    }\n\n    /**\n     * @brief execute\n     * @param img\n     * @param corners\n     */\n    void execute(Image *img, std::vector< Eigen::Vector2f > *corners)\n    {\n        if(img == NULL || corners == NULL) {\n            return;\n        }\n\n        if(img->channels == 1) {\n            bLum = false;\n            lum = img;\n        } else {\n            bLum = true;\n            lum = FilterLuminance::execute(img, lum, LT_CIE_LUMINANCE);\n        }\n\n        corners->clear();\n\n        std::vector< Eigen::Vector3f > corners_w_quality;\n\n        //filter the input image\n        FilterGaussian2D flt(sigma);\n        lum_flt = flt.Process(Single(lum), lum_flt);\n\n        int x[] = {0, 1, 2, 3, 3,  3,  2,  1,  0, -1, -2, -3, -3, -3, -2, -1};\n        int y[] = {3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -2, -1,  0,  1,  2,  3};\n\n        int width  = lum_flt->width;\n        int height = lum_flt->height;\n\n        bool *corners_map = new bool[width * height];\n\n        memset(corners_map, 0, sizeof(bool) * width *  height);\n\n        Image V(1,width, height, 1);\n        V.setZero();\n\n        for(int i=3; i<(height - 3); i++) {\n            for(int j=3; j<(width - 3); j++) {\n                int ind = i * width + j;\n\n                float p = lum_flt->data[ind];\n\n                bool bDark[16];\n                bool bBright[16];\n                float v[16];\n\n                float sum = p;\n\n                for(int k=0; k<16; k++){\n                    float value = (*lum_flt)(j + x[k], i + y[k])[0];\n                    v[k] = value;\n                    sum += value;\n                }\n\n                //compute the threshold\n                float thr;\n                if(bexecuteThreshold) {\n                    thr = 0.2f * sum / 16.0f;\n                    thr = (thr > 1e-9f ) ? thr : threshold;\n\n                } else {\n                    thr = threshold;\n                }\n\n                //test\n                float p_thr_dark   = p - thr;\n                float p_thr_bright = p + thr;\n\n                for(int k=0; k<16; k++){\n                    bDark[k]   = v[k] <= p_thr_dark;\n                    bBright[k] = v[k] >= p_thr_bright;\n                }\n\n                //first test: 0, 4, 8, 12\n                int cDark   = bDark[0]   + bDark[4]   + bDark[8]   + bDark[12];\n                int cBright = bBright[0] + bBright[4] + bBright[8] + bBright[12];\n\n                if((cDark < 3) && (cBright < 3) ){\n                    //corners_map[ind] = false;\n                    continue;\n                }\n\n                //second test: check for 12 continuous true values in bDark or cBright\n                int counter_dark   = 0;\n                int counter_bright = 0;\n\n                //corners_map[ind] = false;\n                for(int k=0; k<16; k++){\n                    if(bDark[k]){\n                        counter_dark++;\n                    } else {\n                        counter_dark = 0;\n                    }\n\n                    if(bBright[k]){\n                        counter_bright++;\n                    } else {\n                        counter_dark = 0;\n                    }\n\n                    if((counter_bright > 11) || (counter_dark > 11)) {\n                        corners_map[ind] = true;\n\n                        //Computing V function\n                        float V_dark   = 0.0f;\n                        float V_bright = 0.0f;\n                        for(int k=0; k<16; k++){\n                            if(bDark[k]) {\n                                V_bright += fabsf(v[k] - p) - thr;\n                            }\n\n                            if(bBright[k]) {\n                                V_dark += fabsf(p - v[k]) - thr;\n                            }\n                        }\n                        V.data[ind] = MAX(V_bright, V_dark);\n\n                        break;\n                    }\n                }\n            }\n        }\n\n        //non-maximal supression\n        int side = radius * 2 + 1;\n        int *indices = new int[side * side];\n\n        for(int i=3; i<(height - 3); i++) {\n            for(int j=3; j<(width - 3); j++) {\n                int ind = i * width + j;\n\n                if(!corners_map[ind]){\n                    continue;\n                }\n\n                indices[0] = ind;\n                int counter = 1;\n\n                for(int k = -radius; k <= radius; k++) {\n                    int yy = CLAMP(i + k, height);\n\n                    for(int l = -radius; l <= radius; l++) {\n\n                        if((l == 0)&&(k == 0)) {\n                            continue;\n                        }\n\n                        int xx = CLAMP(j + l, width);\n\n                        ind = yy * width + xx;\n\n                        if(corners_map[ind]){\n                            indices[counter] = ind;\n                            counter++;\n                        }\n\n                    }\n                }\n\n                //are other corners near-by?\n                if(counter > 1) {\n                    //finding the maximum value\n                    float V_value = V.data[indices[0]];\n                    int index = 0;\n\n                    for(int k=1; k<counter; k++){\n                        if(V.data[indices[k]] > V_value) {\n                            V_value = V.data[indices[k]];\n                            index = k;\n                        }\n                    }\n\n                    if(index == 0){\n                        corners_w_quality.push_back(Eigen::Vector3f (float(j), float(i), 1.0f) );\n                    }\n                } else {\n                    corners_w_quality.push_back(Eigen::Vector3f (float(j), float(i), 1.0f) );\n                }\n\n            }\n        }\n\n        sortCornersAndTransfer(&corners_w_quality, corners);\n\n        delete[] indices;\n    }\n};\n\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_FAST_CORNER_DETECTOR_HPP */\n\n"
  },
  {
    "path": "include/features_matching/feature_matcher.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_FEATURE_MATCHER\n#define PIC_FEATURES_MATCHING_FEATURE_MATCHER\n\n#include <vector>\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n\n#endif\n\nnamespace pic{\n\n/**\n * @brief The FeatureMatcher class\n */\ntemplate<class T>\nclass FeatureMatcher\n{\nprotected:\n    std::vector<T *> *descs;\n    T desc_size;\n\npublic:\n\n    /**\n     * @brief FeatureMatcher\n     * @param descs\n     * @param n\n     */\n    FeatureMatcher(std::vector<T *> *descs, T desc_size)\n    {\n        update(descs, desc_size);\n    }\n\n    /**\n     * @brief update\n     * @param descs\n     * @param desc_size\n     */\n    void update(std::vector<T *> *descs, T desc_size)\n    {\n        this->desc_size = desc_size;\n        this->descs = descs;\n    }\n\n    /**\n     * @brief getMatch\n     * @param desc0\n     * @param matched_j\n     * @param dist_1\n     * @return\n     */\n    virtual bool getMatch(T *desc, int &matched_j, T &dist_1)\n    {\n        return false;\n    }\n\n#ifndef PIC_DISABLE_EIGEN\n    void getAllMatches(std::vector<unsigned int *> &descs0, std::vector< Eigen::Vector3i > &matches)\n    {\n        matches.clear();\n\n        for(unsigned int i = 0; i< descs0.size(); i++) {\n            int matched_j;\n            T dist_1;\n\n            if(getMatch(descs0.at(i), matched_j, dist_1)) {\n                matches.push_back(Eigen::Vector3i(i, matched_j, dist_1));\n            }\n        }\n    }\n\n    /**\n     * @brief filterMatches\n     * @param c0\n     * @param c1\n     * @param matches\n     * @param p0\n     * @param p1\n     */\n    static void filterMatches(  std::vector< Eigen::Vector2f > &c0,\n                                std::vector< Eigen::Vector2f > &c1,\n                                std::vector< Eigen::Vector3i > &matches,\n                                std::vector< Eigen::Vector2f > &p0,\n                                std::vector< Eigen::Vector2f > &p1)\n    {\n        p0.clear();\n        p1.clear();\n\n        for(size_t i = 0; i < matches.size(); i++) {\n            int I0 = matches[i][0];\n            int I1 = matches[i][1];\n\n            Eigen::Vector2f x = c0.at(I0);\n            Eigen::Vector2f y = c1.at(I1);\n\n            p0.push_back(x);\n            p1.push_back(y);\n\n            #ifdef PIC_DEBUG\n            printf(\"I1: %d (%d %d) -- I2: %d (%d %d) -- Score: %d\\n\",\n                   I0, int(x[0]), int(x[1]), I1, int(y[0]), int(y[1]), matches[i][2]);\n            #endif\n        }\n    }\n\n#endif\n};\n\n}\n\n#endif // PIC_FEATURES_MATCHING_FEATURE_MATCHER\n"
  },
  {
    "path": "include/features_matching/float_feature_brute_force_matcher.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_FLOAT_FEATURE_BRUTE_FORCE_MATCHER\n#define PIC_FEATURES_MATCHING_FLOAT_FEATURE_BRUTE_FORCE_MATCHER\n\n#include <vector>\n\n#include \"../features_matching/feature_matcher.hpp\"\n#include \"../features_matching/sift_descriptor.hpp\"\n\nnamespace pic{\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief The FloatFeatureBruteForceMatcher class\n */\nclass FloatFeatureBruteForceMatcher : public FeatureMatcher<float>\n{\npublic:\n\n    /**\n     * @brief FloatFeatureBruteForceMatcher\n     * @param descs\n     * @param n\n     */\n    FloatFeatureBruteForceMatcher(std::vector<unsigned int *> *descs, unsigned int desc_size) : FeatureMatcher<float>(descs, desc_size)\n    {\n    }\n\n    /**\n     * @brief getMatch\n     * @param desc0\n     * @param matched_j\n     * @param dist_1\n     * @return\n     */\n    bool getMatch(float *desc, int &matched_j, float &dist_1)\n    {\n        float dist_2 = 1e32f;\n\n        dist_1 = 1e32f;\n\n        matched_j = -1;\n\n        for(unsigned int j = 0; j < descs->size(); j++) {\n            float dist = SIFTDescriptor::match(desc, descs->at(j), desc_size);\n\n            if(dist < dist_1) {\n                dist_2 = dist_1;\n                dist_1 = dist;\n                matched_j = j;\n             } else {\n                if(dist < dist_2) {\n                    dist_2 = dist;\n                }\n            }\n        }\n\n        return ((dist_1 > dist_2 * 1.2f) && matched_j != -1);\n    }\n};\n\n#endif\n\n}\n\n#endif // PIC_FEATURES_MATCHING_FLOAT_FEATURE_BRUTE_FORCE_MATCHER\n"
  },
  {
    "path": "include/features_matching/general_corner_detector.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_GENERAL_CORNER_DETECTOR_HPP\n#define PIC_FEATURES_MATCHING_GENERAL_CORNER_DETECTOR_HPP\n\n#include \"../image.hpp\"\n#include \"../util/string.hpp\"\n#include \"../util/string.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief The GeneralCornerDetector class\n */\nclass GeneralCornerDetector\n{\nprotected:\n    Image *lum;\n    bool bLum;\n\n    static bool scD (Eigen::Vector3f i, Eigen::Vector3f  j)\n    {\n        return (i[2] > j [2]);\n    }\n\n    static bool scA (Eigen::Vector3f i, Eigen::Vector3f  j)\n    {\n        return (i[2] < j [2]);\n    }\n\npublic:\n    /**\n     * @brief GeneralCornerDetector\n     */\n    GeneralCornerDetector()\n    {\n        lum = NULL;\n        bLum = false;\n    }\n\n    ~GeneralCornerDetector()\n    {\n    }\n\n    /**\n     * @brief execute\n     * @param img\n     * @param corners\n     */\n    virtual void execute(Image *img, std::vector< Eigen::Vector2f > *corners)\n    {\n\n    }\n\n    /**\n     * @brief getCornersImage\n     * @param corners\n     * @param imgOut\n     * @param bColor\n     * @return\n     */\n    Image *getCornersImage(std::vector< Eigen::Vector2f > *corners,\n                              Image *imgOut, unsigned int width, unsigned int height, bool bColor)\n    {\n        if(corners == NULL) {\n            return imgOut;\n        }\n\n        if(imgOut == NULL) {\n            if((width < 1) || (height < 1)){\n                return NULL;\n            }\n\n            imgOut = new Image(width, height, 1);\n        }\n\n        imgOut->setZero();\n\n        for(unsigned int i = 0; i < corners->size(); i++) {\n            int x = int((*corners)[i][0]);\n            int y = int((*corners)[i][1]);\n\n            if(bColor) {\n                (*imgOut)(x, y)[0] = 1.0f;\n            } else {\n                (*imgOut)(x, y)[0] = (*corners)[i][2];\n            }\n        }\n\n        return imgOut;\n    }\n\n    /**\n     * @brief sortCornersAndTransfer\n     * @param corners\n     * @param cornersOut\n     * @param nBestPoints\n     * @param bDescend\n     */\n    static void sortCornersAndTransfer(std::vector< Eigen::Vector3f > *corners,\n                                       std::vector< Eigen::Vector2f > *cornersOut,\n                                       int nBestPoints = -1,\n                                       bool bDescend = true)\n    {\n        sortCorners(corners, bDescend);\n\n        int a, b;\n\n        int n = int(corners->size());\n        if(nBestPoints < 0) {\n            a = 0;\n            b = n;\n        } else {\n            if(bDescend) {\n                a = 0;\n                b = MIN(nBestPoints, n);\n            } else {\n                b = MIN(int(corners->size()), n);\n                a = MAX(b - nBestPoints, 0);\n            }\n        }\n\n        for(int i = a; i < b; i++) {\n            Eigen::Vector3f tmp = corners->at(i);\n            Eigen::Vector2f p;\n            p[0] = tmp[0];\n            p[1] = tmp[1];\n\n            cornersOut->push_back(p);\n        }\n    }\n\n    /**\n     * @brief sortCorners\n     * @param corners\n     */\n    static void sortCorners(std::vector< Eigen::Vector3f > *corners, bool bDescend = true)\n    {\n        if(bDescend) {\n            std::sort(corners->begin(), corners->end(), scD);\n        } else {\n            std::sort(corners->begin(), corners->end(), scA);\n        }\n    }\n\n    /**\n     * @brief exportToString\n     * @param corners\n     * @return\n     */\n    static std::string exportToString(std::vector< Eigen::Vector2f > *corners)\n    {\n        std::string out = \"[\";\n        uint n = corners->size();\n\n        for(uint i = 0; i < (n - 1); i++) {\n            out += fromNumberToString(corners->at(i)[0]) + \" \";\n            out += fromNumberToString(corners->at(i)[1]) + \"; \";\n        }\n        out += fromNumberToString(corners->at(n - 1)[0]) + \" \";\n        out += fromNumberToString(corners->at(n - 1)[1]) + \"]\";\n        return out;\n    }\n\n    /**\n     * @brief removeClosestCorners\n     */\n    static void removeClosestCorners(std::vector< Eigen::Vector2f > *corners,\n                                     std::vector< Eigen::Vector2f > *out,\n                                     float threshold,\n                                     int max_limit)\n    {\n        int n = MIN(int(corners->size()), max_limit);\n        bool *processed = new bool [n];\n        memset(processed, 0, sizeof(bool) * n);\n\n        for(int i = 0; i < n; i++) {\n            //find the closest\n            if(!processed[i]) {\n                processed[i] = true;\n\n                std::vector< int > indices;\n                for(int j = 0; j < n; j++) {\n                    if(j != i) {\n                        continue;\n                    }\n\n                    if(!processed[j]) {\n                        float dx = (*corners)[j][0] - (*corners)[i][0];\n                        float dy = (*corners)[j][1] - (*corners)[i][1];\n                        float dist = sqrtf(dx * dx + dy * dy);\n\n                        if(dist < threshold) {\n                            //processed[j] = true;\n                            indices.push_back(j);\n                        }\n                    }\n                }\n\n                auto n_i = indices.size();\n                Eigen::Vector2f point;\n\n                if(n_i > 0) {\n                    point[0] = (*corners)[i][0];\n                    point[1] = (*corners)[i][1];\n                    int point_c = 1;\n\n                    for(uint j = 0; j < indices.size(); j++) {\n                        auto k = indices[j];\n                        if(!processed[k]) {\n                            processed[k] = true;\n                            point[0] += (*corners)[k][0];\n                            point[1] += (*corners)[k][1];\n                            point_c++;\n                        }\n                    }\n\n                    point[0] /= float(point_c);\n                    point[1] /= float(point_c);\n                } else {\n                    point[0] = (*corners)[i][0];\n                    point[1] = (*corners)[i][1];\n                }\n                out->push_back(point);\n            }\n        }\n\n        delete[] processed;\n    }\n\n    /**\n     * @brief test\n     * @param gcd\n     */\n    static void test(GeneralCornerDetector *gcd)\n    {\n        if(gcd == NULL){\n            return;\n        }\n\n        Image full_image(1, 512, 512, 3);\n        full_image.setZero();\n\n        Image quad(1, 128, 128, 3);\n        quad = 1.0f;\n\n        full_image.copySubImage(&quad, 192, 192);\n\n        std::vector< Eigen::Vector2f > corners;\n        gcd->execute(&full_image, &corners);\n\n        printf(\"\\n Corner Detector Test:\\n\");\n\n        for(unsigned int i = 0; i < corners.size(); i++) {\n            printf(\"X: %f Y: %f\\n\", corners[i][0], corners[i][1]);\n        }\n\n        printf(\"\\n\");\n\n        Image *img_corners = gcd->getCornersImage(&corners, NULL, 512, 512, true);\n        img_corners->Write(\"general_corner_test_image.hdr\");\n    }\n};\n\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_GENERAL_CORNER_DETECTOR_HPP */\n\n"
  },
  {
    "path": "include/features_matching/harris_corner_detector.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_HARRIS_CORNER_DETECTOR_HPP\n#define PIC_FEATURES_MATCHING_HARRIS_CORNER_DETECTOR_HPP\n\n#include <vector>\n\n#include \"../util/vec.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../util/polynomial.hpp\"\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n#include \"../filtering/filter_gradient_harris_opt.hpp\"\n#include \"../filtering/filter_max.hpp\"\n#include \"../features_matching/general_corner_detector.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n\n#endif\n\nnamespace pic {\n\nenum CORENE_DETECTOR_TYPE{CD_SHI_TOMASI, CD_HARRIS, CD_NOBLE};\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief The HarrisCornerDetector class\n */\nclass HarrisCornerDetector: public GeneralCornerDetector\n{\nprotected:\n    Image *I_grad;\n    Image *I_grad_flt;\n    Image *ret;\n\n    //Harris Corners detector parameters\n    float sigma, threshold, ki;\n    int radius;\n    CORENE_DETECTOR_TYPE type;\n\n    //previous values\n    int width, height;\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        lum = delete_s(lum);\n        I_grad = delete_s(I_grad);\n        I_grad_flt = delete_s(I_grad_flt);\n        ret = delete_s(ret);\n    }\n\n    /**\n     * @brief setNULL\n     */\n    void setNULL()\n    {\n        type = CD_NOBLE;\n        width = -1;\n        height = -1;\n        lum = NULL;\n        I_grad = NULL;\n        I_grad_flt = NULL;\n        ret = NULL;        \n    }\n\npublic:\n\n    /**\n     * @brief HarrisCornerDetector\n     * @param sigma\n     * @param radius\n     * @param threshold\n     */\n    HarrisCornerDetector(float sigma = 1.0f, int radius = 3,\n                         float threshold = 0.001f, float ki = 0.04f,\n                         CORENE_DETECTOR_TYPE type = CD_NOBLE) : GeneralCornerDetector()\n    {\n        setNULL();\n        update(sigma, radius, threshold, type);\n    }\n\n    ~HarrisCornerDetector()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param sigma\n     * @param radius\n     * @param threshold\n     */\n    void update(float sigma = 1.0f, int radius = 3,\n                float threshold = 0.001f, float ki = 0.04f,\n                CORENE_DETECTOR_TYPE type = CD_NOBLE)\n    {\n        this->sigma = sigma > 0.0f ? sigma : 1.0f;\n        this->radius = radius > 0 ? radius : 1;\n        this->threshold = threshold;\n        this->type = type;\n        this->ki = CLAMPi(ki, 0.04f, 0.06f);\n    }\n\n    /**\n     * @brief execute\n     * @param img\n     * @param corners\n     */\n    void execute(Image *img, std::vector< Eigen::Vector2f > *corners)\n    {\n        if(img == NULL || corners == NULL) {\n            return;\n        }\n\n        if((img->width != width) || (img->height != height)) {\n            width = img->width;\n            height = img->height;\n\n            release();\n        }\n\n        if(img->channels == 1) {\n            lum = img->clone();\n        } else {\n            lum = FilterLuminance::execute(img, lum, LT_CIE_LUMINANCE);\n        }\n\n        float minL, maxL;\n        lum->getMinVal(NULL, &minL);\n        lum->getMaxVal(NULL, &maxL);\n\n        float delta = maxL - minL;\n\n        *lum -= minL;\n        *lum *= delta;\n\n        corners->clear();\n\n        std::vector< Eigen::Vector3f > corners_w_quality;\n\n        //compute gradients\n        I_grad = FilterGradientHarrisOPT::execute(lum, I_grad, 0);\n\n        float eps = 2.2204e-16f;\n\n        //filter gradient values\n        FilterGaussian2D flt(sigma);\n        I_grad_flt = flt.Process(Single(I_grad), I_grad_flt);\n\n        if(ret == NULL) {\n            ret = lum->allocateSimilarOne();\n        }\n\n        //ret = (Ix2.*Iy2 - Ixy.^2)./(Ix2 + Iy2 + eps);\n        for(int i = 0; i < height; i++) {\n            for(int j = 0; j < width; j++) {\n                float *data_ret = (*ret)(j, i);\n\n                float *I_grad_val = (*I_grad_flt)(j, i);\n\n                float x2 = I_grad_val[0];\n                float y2 = I_grad_val[1];\n                float xy = I_grad_val[2];\n\n                float detA = x2 * y2 - xy * xy;\n                float trA = x2 + y2;\n\n                switch(type)\n                {\n                    case CD_SHI_TOMASI: {\n\n                        float x0, x1;\n                        if(Polynomial::getSecondOrderRoots(1.0f, -trA, detA, &x0, &x1)) {\n                            data_ret[0] = x0 < x1 ? x0 : x1;\n                        } else {\n                            data_ret[0] = -1.0f;\n                        }\n                    } break;\n\n                    case CD_HARRIS: {\n                       data_ret[0] = detA - ki * trA * trA;\n                    } break;\n\n                    case CD_NOBLE: {\n                        data_ret[0] = detA / (trA + eps);\n                    } break;\n                }\n\n            }\n        }\n\n        //non-maximal supression\n        lum = FilterMax::execute(ret, lum, (radius << 1) + 1);\n        Image* ret_flt = lum;\n\n        float w = 1.0f;\n\n        int bestPoints = -1;\n\n        if(threshold < 0.0f) { //the best i-th points\n            bestPoints = int(-threshold);\n            threshold = -FLT_MAX;\n        }\n\n        for(int i = 0; i < height; i++) {\n            float i_f = float(i);\n            float cx, cy, ax, ay, bx, by, x, y;\n\n            for(int j = 0; j < width; j++) {\n\n                float R = (*ret)(j, i)[0];\n                float R_flt = (*ret_flt)(j, i)[0];\n\n                if((R == R_flt) && (R > threshold)) {\n                    float Rr = (*ret)(j, i + 1)[0];\n                    float Rl = (*ret)(j, i - 1)[0];\n                    float Ru = (*ret)(j + 1, i)[0];\n                    float Rd = (*ret)(j - 1, i)[0];\n\n                    cx = R;\n                    ax = (Rl + Rr) / 2.0f - cx;\n                    bx = ax + cx - Rl;\n\n                    if(ax != 0.0f) {\n                        x = -w * bx / (2.0f * ax);\n                    } else {\n                        x = 0.0f;\n                    }\n\n                    cy = R;\n                    ay = (Rd + Ru) / 2.0f - cy;\n                    by = ay + cy - Rd;\n\n                    if(ay != 0.0f) {\n                        y = -w * by / (2.0f * ay);\n                    } else {\n                        y = 0.0f;\n                    }\n\n                    corners_w_quality.push_back(Eigen::Vector3f(float(j) + x, i_f + y, R));\n                }\n            }\n        }\n\n        sortCornersAndTransfer(&corners_w_quality, corners, bestPoints);\n    }\n};\n\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_HARRIS_CORNER_DETECTOR_HPP */\n\n"
  },
  {
    "path": "include/features_matching/hash_table_lsh.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_HASH_TABLE_LSH_HPP\n#define PIC_FEATURES_MATCHING_HASH_TABLE_LSH_HPP\n\n#include <vector>\n#include <math.h>\n#include <set>\n\n#include \"../features_matching/brief_descriptor.hpp\"\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief The Hash class\n */\nclass HashTableLSH\n{\npublic:\n    unsigned int *g_f;\n\n    std::vector< unsigned int *> *descs;\n    std::vector< unsigned int > *table;\n    unsigned int nTable;\n    unsigned int hash_size, desc_size, size_ui;\n\n    HashTableLSH(unsigned int hash_size, unsigned int *g_f, std::vector< unsigned int *> *descs, unsigned int desc_size)\n    {\n        if(hash_size == 0) {\n            hash_size = 8;\n        }\n\n        this->hash_size = hash_size;\n\n        nTable = 1 << hash_size;\n        table = new std::vector< unsigned int >[nTable];\n\n        //hash function\n        this->g_f = g_f;\n\n        //insert descriptors\n        this->descs = descs;\n        this->desc_size = desc_size;\n        size_ui = sizeof(unsigned int) * 8;\n\n        for(unsigned int i = 0; i < descs->size();  i++) {\n            unsigned int address = getAddress(descs->at(i));\n            table[address].push_back(i);\n        }\n    }\n\n    /**\n     * @brief getAddress\n     * @param point\n     * @return\n     */\n    unsigned int getAddress(unsigned int *desc)\n    {\n        unsigned int address = 0;\n        for(unsigned int i=0; i<hash_size; i++) {\n            unsigned int pos = g_f[i];\n\n            unsigned int block = pos / size_ui;\n            unsigned int pos_block = pos % size_ui;\n\n            unsigned int bit = (desc[block] >> pos_block) & 0x1;\n\n            if(bit == 1) {\n                address += (1 << i);\n            }\n        }\n\n        return address;\n    }\n\n    /**\n     * @brief getNearest\n     * @param desc\n     * @param matched_j\n     * @param dist_1\n     * @param dist_2\n     */\n    void getNearest(unsigned int * desc, int &matched_j, unsigned int &dist_1, unsigned int &dist_2)\n    {\n        unsigned int address = getAddress(desc);\n\n        for(unsigned int i=0; i<table[address].size(); i++) {\n            unsigned int j = table[address].at(i);\n            unsigned int dist = BRIEFDescriptor::match(desc, descs->at(j), desc_size);\n\n            if(dist > dist_1) {\n                dist_2 = dist_1;\n                dist_1 = dist;\n                matched_j = j;\n             } else {\n                if(dist > dist_2) {\n                    dist_2 = dist;\n                }\n            }\n        }\n    }\n};\n\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_HASH_TABLE_LSH_HPP */\n\n"
  },
  {
    "path": "include/features_matching/lucid_descriptor.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_LUCID_DESCRIPTOR_HPP\n#define PIC_FEATURES_MATCHING_LUCID_DESCRIPTOR_HPP\n\n#include \"../util/math.hpp\"\n#include \"../image.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The LUCIDDescriptor class\n */\nclass LUCIDDescriptor\n{\nprotected:\n    int patchSize, halfPatchSize;\n    int area;\n\npublic:\n\n    /**\n     * @brief LUCIDDescriptor\n     * @param patchSize\n     */\n    LUCIDDescriptor(int patchSize = 31)\n    {\n        if(patchSize < 2) {\n            patchSize = 31;\n        }\n\n        this->patchSize = patchSize;\n        this->halfPatchSize = patchSize >> 1;\n\n        int tmp = (halfPatchSize << 1 ) + 1;\n        area = tmp * tmp;\n    }\n\n    /**\n     * @brief get computes a descriptor at position (x0,y0) with size n.\n     * @param img\n     * @param x0\n     * @param y0\n     * @param desc\n     * @param nDesc\n     * @return\n     */\n    unsigned int *get(Image *img, int x0, int y0, unsigned int *desc, unsigned int &nDesc)\n    {\n        if(img == NULL) {\n            return NULL;\n        }\n\n        nDesc = area * img->channels;\n\n        if(desc == NULL) {\n            desc = new unsigned int[nDesc];\n        }\n\n        std::vector< std::pair<float, unsigned int> > data;\n\n\n        for(int k = 0; k < img->channels; k++) {\n            for(int i = -halfPatchSize; i <= halfPatchSize; i++) {\n                int y = y0 + i;\n\n                for(int j = -halfPatchSize; j <= halfPatchSize; j++) {\n                    int x = x0 + j;\n\n                    float *tmp_val = (*img)(x, y);\n\n                    float f = tmp_val[k];\n                    int s = int(data.size());\n\n                    std::pair<float, int> pair = std::make_pair(f, s);\n                    data.push_back(pair);\n                }\n            }\n        }\n\n        std::sort(data.begin(), data.end());\n\n        for(unsigned int i = 0; i < data.size(); i++) {\n            desc[i] = data[i].second;\n        }\n\n        return desc;\n    }\n\n    /**\n     * @brief match matches two descriptors. Note: higher scores means better matching.\n     * @param fv0\n     * @param fv1\n     * @param nfv\n     * @return\n     */\n    static unsigned int match(unsigned int *fv0, unsigned int *fv1, unsigned int nfv)\n    {\n        if((fv0 == NULL) && (fv1 == NULL)) {\n            return 0;\n        }\n\n        unsigned int ret = 0;\n\n        for(unsigned int i = 0; i < nfv; i++) {\n            ret += (fv0[i] == fv1[i]) ? 1 : 0;\n        }\n\n        return ret;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_LUCID_DESCRIPTOR_HPP */\n\n"
  },
  {
    "path": "include/features_matching/motion_estimation.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_MOTION_ESTIMATION_HPP\n#define PIC_FEATURES_MATCHING_MOTION_ESTIMATION_HPP\n\n#include <functional>\n\n#include \"../image.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../features_matching/patch_comp.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The MotionEstimation class\n */\nclass MotionEstimation\n{\nprotected:\n    int shift, blockSize, halfBlockSize;\n    int width, height;\n    PatchComp *pmc;\n\n    /**\n     * @brief processAux\n     * @param tiles\n     * @param imgOut\n     */\n    void processAux(TileList *tiles, Image *imgOut)\n    {\n        bool state = true;\n\n        while(state) {\n            unsigned int currentTile = tiles->getNext();\n\n            if(currentTile < tiles->tiles.size()) {\n                int x = tiles->tiles[currentTile].startX;\n                int y = tiles->tiles[currentTile].startY;\n\n                int x0 = x + halfBlockSize;\n                int y0 = y + halfBlockSize;\n\n\n                int x_e = MAX((x + blockSize), imgOut->width);\n                int y_e = MAX((y + blockSize), imgOut->height);\n\n                int dx = 0;\n                int dy = 0;\n                float err = FLT_MAX;\n\n\n                for(int k=-shift; k<=shift; k++) {\n                    int y1 = y0 + k;\n\n                    for(int l=-shift; l<=shift; l++) {\n                        int x1 = x0 + l;\n\n                        float tmp_err = pmc->getSSD(x0, y0, x1, y1);\n\n                        if(tmp_err < err) {\n                            err = tmp_err;\n                            dx = l;\n                            dy = k;\n                        }\n                    }\n                }\n\n                for(int k=y; k<y_e; k++) {\n                    for(int l=x; l<x_e; l++) {\n\n                        float *data = (*imgOut)(l, k);\n                        data[0] = float(dx);\n                        data[1] = float(dy);\n                        data[2] = err;\n                    }\n                }\n\n            } else {\n                state = false;\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief MotionEstimation\n     * @param img0\n     * @param img1\n     * @param blockSize\n     * @param maxRadius\n     */\n    MotionEstimation(Image *img0, Image *img1, int blockSize, int maxRadius)\n    {\n        pmc = NULL;\n\n        setup(img0, img1, blockSize, maxRadius);\n    }\n\n    ~MotionEstimation()\n    {\n        delete_s(pmc);\n    }\n\n    /**\n     * @brief setup\n     * @param img0\n     * @param img1\n     * @param blockSize\n     * @param maxRadius\n     */\n    void setup(Image *img0, Image *img1, int blockSize, int maxRadius)\n    {\n        if(img0 == NULL || img1 == NULL) {\n            return;\n        }\n\n        if(!img0->isSimilarType(img1)) {\n            return;\n        }\n\n        if(maxRadius < 1) {\n            maxRadius = 1;\n        }\n\n        //estimate the blockSize if not given\n        if(blockSize < 1) {\n            float nPixels = float(img0->nPixels());\n            float tmp = ceilf(log10f(nPixels));\n            blockSize = MAX(int(powf(2.0f, tmp)), 4);\n        }\n\n        this->blockSize = blockSize;\n        this->halfBlockSize = blockSize >> 1;\n        this->shift = maxRadius * blockSize;\n\n        this->width = img0->width;\n        this->height = img0->height;\n\n        pmc = new PatchComp(img0, img1, blockSize);\n    }\n\n    /**\n     * @brief execute\n     * @param imgOut\n     * @return\n     */\n    Image *process(Image *imgOut)\n    {\n        if(imgOut == NULL) {\n            imgOut = new Image(1, width, height, 3);\n        }\n\n        TileList lst(blockSize, width, height);\n\n        //create threads\n        int numCores = std::thread::hardware_concurrency();\n\n        std::thread **thrd = new std::thread*[numCores];\n\n        for(int i = 0; i < numCores; i++) {\n            thrd[i] = new std::thread(\n                std::bind(&MotionEstimation::processAux, this, &lst, imgOut));\n        }\n\n        //threads join\n        for(int i = 0; i < numCores; i++) {\n            thrd[i]->join();\n        }\n\n        return imgOut;\n    }\n\n    /**\n     * @brief Execute\n     * @param img0\n     * @param img1\n     * @param blockSize\n     * @param maxRadius\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *img0, Image *img1, int blockSize, int maxRadius, Image *imgOut)\n    {\n        MotionEstimation me(img0, img1, blockSize, maxRadius);\n\n        return me.process(imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_MOTION_ESTIMATION_HPP */\n"
  },
  {
    "path": "include/features_matching/orb_descriptor.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_ORB_DESCRIPTOR_HPP\n#define PIC_FEATURES_MATCHING_ORB_DESCRIPTOR_HPP\n\n#include <vector>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../features_matching/brief_descriptor.hpp\"\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief The ORBDescriptor class\n */\nclass ORBDescriptor: public BRIEFDescriptor\n{\nprotected:\n    std::vector< int* > x_theta, y_theta;\n\n    /**\n     * @brief rotate2D\n     * @param x\n     * @param y\n     * @param x_out\n     * @param y_out\n     * @param angle\n     */\n    void rotate2D(int x, int y, int &x_out, int &y_out, float angle)\n    {\n        float cosAng = cosf(angle);\n        float sinAng = sinf(angle);\n\n        float x_f = float(x);\n        float y_f = float(y);\n\n        x_out = int(x_f * cosAng - y_f * sinAng);\n        y_out = int(x_f * sinAng + y_f * cosAng);\n    }\n\n    /**\n     * @brief rotateSamples rotates x and y samples\n     */\n    void rotateSamples()\n    {\n        uint n2 = n * 2;\n\n        for(uint i = 0; i < 360; i += 12) {\n            int * X_r = new int[n2];\n            int * Y_r = new int[n2];\n\n            float ang = (float(i) * C_PI_2) / 360.0f;\n\n            for(uint j = 0; j < n2; j += 2) {\n                rotate2D(x[j], x[j + 1], X_r[j], X_r[j + 1], ang);\n                rotate2D(y[j], y[j + 1], Y_r[j], Y_r[j + 1], ang);\n            }\n\n            x_theta.push_back(X_r);\n            y_theta.push_back(Y_r);\n        }\n    }\n\n    int halfS;\n\npublic:\n\n    /**\n     * @brief ORBDescriptor\n     * @param S\n     * @param n\n     */\n    ORBDescriptor(int S = 31, int n = 256, unsigned int seed = 1)\n    {\n        m = new std::mt19937(seed);\n\n        this->S = S;\n        this->halfS = S >> 1;\n        this->sigma_sq = float(S * S) / 25.0f;\n        this->sigma_sq_2 = 2.0f * this->sigma_sq;\n\n        generateSamples(n);\n        rotateSamples();\n    }\n\n    ~ORBDescriptor()\n    {\n        release();\n    }\n\n    /**\n     * @brief get computes a descriptor at position (x0,y0) with size n.\n     * @param img\n     * @param x0\n     * @param y0\n     * @param desc\n     * @return\n     */\n    uint *get(Image *img, int x0, int y0, uint* desc = NULL)\n    {\n        if(img == NULL){\n            return NULL;\n        }\n\n        if(!img->checkCoordinates(x0, y0)) {\n            return NULL;\n        }\n\n        float grad[2];\n\n        img->getMomentsVal(x0, y0, S, grad);\n\n        float theta = atan2f(grad[1], grad[0]);\n\n        if(theta < 0.0f) {\n            theta = CLAMPi(C_PI_2 + theta, 0.0f, C_PI_2);\n        }\n\n        //float theta_nor = CLAMPi(theta / C_PI_2, 0.0f, 1.0f);\n\n        uint theta_nor = CLAMPi(uint(theta * 255.0f / C_PI_2), 0, 255);\n\n        uint n = x_theta.size() - 1;\n\n        uint index = (n * theta_nor) >> 8;\n\n        return getAux(img, x0, y0, x_theta[index], y_theta[index], desc);\n    }\n};\n\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_ORB_DESCRIPTOR_HPP */\n\n"
  },
  {
    "path": "include/features_matching/patch_comp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_PATCH_COMP_HPP\n#define PIC_FEATURES_MATCHING_PATCH_COMP_HPP\n\n#include \"../image.hpp\"\n\n#include \"../util/math.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../util/array.hpp\"\n\n#include \"../image_samplers/image_sampler_bilinear.hpp\"\n\n#include \"../features_matching/transform_data.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The PatchComp class\n */\nclass PatchComp\n{\nprotected:\n    ImageSamplerBilinear isb;\n\n    Image *img0, *img1, *img0_g, *img1_g;\n\n    //patchsize\n    int patchSize, halfPatchSize;\n    float patchSize_sq;\n\n    //stereo\n    float alpha;\n\npublic:\n\n    /**\n     * @brief PatchComp\n     */\n    PatchComp()\n    {\n        setNULL();\n    }\n\n    /**\n     * @brief PatchComp\n     * @param img0\n     * @param img1\n     * @param patchSize\n     */\n    PatchComp(Image *img0, Image *img1, int patchSize)\n    {\n        setNULL();\n\n        setup(img0, img1, NULL, NULL, patchSize, 0.05f);\n    }\n\n    /**\n     * @brief PatchComp\n     * @param img0\n     * @param img1\n     * @param patchSize\n     * @param alpha\n     */\n    PatchComp(Image *img0, Image *img1,\n              Image *img0_g, Image *img1_g,\n              int patchSize, float alpha)\n    {\n        setNULL();\n        setup(img0, img1, img0_g, img1_g, patchSize, alpha);\n    }\n\n    /**\n     * @brief setNULL\n     */\n    void setNULL()\n    {\n        img0   = NULL;\n        img0_g = NULL;\n        img1   = NULL;\n        img1_g = NULL;\n\n        alpha = -1.0f;\n\n        patchSize = -1;\n        halfPatchSize = -1;\n    }\n\n    /**\n     * @brief setup\n     * @param img0\n     * @param img1\n     * @param patchSize\n     */\n    void setup(Image *img0,   Image *img1,\n               Image *img0_g, Image *img1_g,\n               int patchSize, float alpha)\n    {\n        if(patchSize < 1) {\n            return;\n        }\n\n        this->img0 = img0;\n        this->img1 = img1;\n        this->img0_g = img0_g;\n        this->img1_g = img1_g;\n\n        this->alpha = CLAMPi(alpha, 0.0f, 1.0f);\n\n        if(this->patchSize != patchSize) {\n            this->patchSize_sq = float(patchSize * patchSize);\n            this->halfPatchSize = patchSize >> 1;\n            this->patchSize = (halfPatchSize << 1) + 1;\n        }\n    }\n\n    /**\n     * @brief getSSDSmooth\n     * @param x0\n     * @param y0\n     * @param x1\n     * @param y1\n     * @return\n     */\n    float getSSDSmooth(int x0, int y0, int x1, int y1)\n    {\n        float alpha_i = 1.0f - alpha;\n\n        float ret = 0.0f;\n\n        for(int i = -halfPatchSize; i <= halfPatchSize; i++) {\n            for(int j = -halfPatchSize; j <= halfPatchSize; j++) {\n                float *img0_ij = (*img0)(x0 + j, y0 + i);\n                float *img1_ij = (*img1)(x1 + j, y1 + i);\n\n                float *img0_g_ij = (*img0_g)(x0 + j, y0 + i);\n                float *img1_g_ij = (*img1_g)(x1 + j, y1 + i);\n\n                //color term\n                float err_col = sqrtf(Arrayf::distanceSq(img1_ij, img0_ij, img0->channels));\n\n                //gradient term\n                float err_grad = sqrtf(Arrayf::distanceSq(img0_g_ij, img1_g_ij, 2));\n\n                //err term\n                ret += alpha_i * err_col + alpha * err_grad;\n\n            }            \n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief getSSD\n     * @param x0\n     * @param y0\n     * @param x1\n     * @param y1\n     * @return\n     */\n    float getSSD(int x0, int y0, int x1, int y1)\n    {\n        float ret = 0.0f;\n        for(int i = -halfPatchSize; i <= halfPatchSize; i++) {\n            for(int j = -halfPatchSize; j <= halfPatchSize; j++) {\n                float *img0_ij = (*img0)(x0 + j, y0 + i);\n                float *img1_ij = (*img1)(x1 + j, y1 + i);\n\n                ret += Arrayf::distanceSq(img0_ij, img1_ij, img0->channels);\n            }\n        }\n\n        return ret;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_PATCH_COMP_HPP */\n\n"
  },
  {
    "path": "include/features_matching/poisson_descriptor.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_POISSON_DESCRIPTOR_HPP\n#define PIC_FEATURES_MATCHING_POISSON_DESCRIPTOR_HPP\n\n#include <random>\n#include \"../util/math.hpp\"\n#include \"../image.hpp\"\n#include \"../point_samplers/sampler_random.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The PoissonDescriptor class\n */\nclass PoissonDescriptor\n{\nprotected:\n    int kernelSize, nSamples;\n    unsigned int subBlock;\n    std::mt19937 *m;\n\n    RandomSampler<2> *rs;\n\n    /**\n     * @brief generateSamples\n     * @param kernelSize\n     */\n    void generateSamples(unsigned int kernelSize)\n    {\n        rs = new RandomSampler<2>(ST_BRIDSON, kernelSize, kernelSize, 1);\n        nSamples = rs->samplesR.size() >> 1;\n    }\n\n    /**\n     * @brief getAux computes a descriptor at position (x0,y0) with size n.\n     * @param img\n     * @param x0\n     * @param y0\n     * @param desc\n     * @return\n     */\n    unsigned int *getAux(Image *img, int x0, int y0, unsigned int *desc = NULL)\n    {\n        unsigned int bits = sizeof(unsigned int) * 8;\n        subBlock = (nSamples * (nSamples - 1)) / bits;\n\n        if(desc == NULL) {\n            desc = new unsigned int[subBlock];\n            memset(desc, 0, sizeof(unsigned int) * subBlock);\n        }\n\n        int x[2], y[2];\n\n        int c = 0;\n        for(int i = 0; i < nSamples; i++) {\n            x[0] = rs->samplesR[(i << 1)];\n            x[1] = rs->samplesR[(i << 1) + 1];\n\n            for(int j = 0; j < nSamples; j++) {\n                if(i == j) {\n                    continue;\n                }\n\n                y[0] = rs->samplesR[(j << 1)];\n                y[1] = rs->samplesR[(j << 1) + 1];\n\n                float *p_x_val = (*img)(x0 + x[0], y0 + x[1]);\n                float *p_y_val = (*img)(x0 + y[0], y0 + y[1]);\n\n                float p_x = 0.0f;\n                float p_y = 0.0f;\n\n                for(int k = 0; k < img->channels; k++) {\n                    p_x\t+= p_x_val[k];\n                    p_y\t+= p_y_val[k];\n                }\n\n                int p = c / bits;\n                int shift = c % bits;\n\n                unsigned int ret = (p_x < p_y) ? 1 : 0;\n                desc[p] += (ret << shift);\n                c++;\n\n            }\n\n        }\n\n        return desc;\n    }\n\npublic:\n\n    /**\n     * @brief PoissonDescriptor\n     * @param kernelSize\n     */\n    PoissonDescriptor(int kernelSize = 16, unsigned int seed = 1)\n    {\n        subBlock = 0;\n        m = new std::mt19937(seed);\n\n        generateSamples(kernelSize);\n    }\n\n    ~PoissonDescriptor()\n    {\n        release();\n    }\n\n    /**\n     * @brief release deallocates memory.\n     */\n    void release()\n    {\n        delete m;\n    }\n\n    /**\n     * @brief get computes a descriptor at position (x0,y0) with size n for a given image img.\n     * @param img is the input image\n     * @param x0 is the x-coordinate where to compute the descriptor\n     * @param y0 is the y-coordinate where to compute the descriptor\n     * @param desc is the output descriptor, if it is NULL, memory will be allocated\n     * @return it returns a pointer to the descriptor\n     */\n    unsigned int *get(Image *img, int x0, int y0, unsigned int *desc = NULL)\n    {\n        if(img == NULL) {\n            return NULL;\n        }\n\n        if(!img->checkCoordinates(x0, y0)) {\n            return NULL;\n        }\n\n        return getAux(img, x0, y0, desc);\n    }\n\n    /**\n     * @brief getDescriptorSize returns the descriptor size.\n     * @return the descriptor size.\n     */\n    int getDescriptorSize()\n    {\n        return subBlock;\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_BRIEF_DESCRIPTOR_HPP */\n\n"
  },
  {
    "path": "include/features_matching/sift_descriptor.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_SIFT_DESCRIPTOR_HPP\n#define PIC_SIFT_DESCRIPTOR_HPP\n\n#include \"../image.hpp\"\n#include \"../util/array.hpp\"\n\nnamespace pic {\n\nclass SIFTDescriptor\n{\nprotected:\n    float thr_weak, sigma, sigma_sq_2;\n\n    float *reference_angles;\n    float sector_angle, nBinf;\n\n    float reference_angles_orientation[36];\n    float sector_angle_orientation;\n\n    int patchSize, half_patchSize, subPatchSize, subPatchSize_sq, nBin, tot;\n\npublic:\n\n    SIFTDescriptor(float thr_weak = 0.01f, int patchSize = 16, int subPatchSize = 4, int nBin = 8)\n    {\n        reference_angles = NULL;\n        update(thr_weak, patchSize, subPatchSize, nBin);\n    }\n\n    /**\n     * @brief update\n     * @param thr_weak\n     * @param patchSize\n     * @param subPatchSize\n     * @param nBin\n     */\n    void update(float thr_weak = 0.05f, int patchSize = 16, int subPatchSize = 4, int nBin = 8)\n    {\n        thr_weak = MAX(thr_weak, 0.05f);\n        nBin = MAX(nBin, 4);\n\n        this->thr_weak = thr_weak;\n        this->nBin = nBin;\n\n        half_patchSize = patchSize >> 1;\n        this->patchSize = (half_patchSize << 1) + 1;\n        this->subPatchSize = subPatchSize;\n\n        subPatchSize_sq = subPatchSize *  subPatchSize;\n        tot = subPatchSize_sq * nBin;\n\n        sigma = float(patchSize) * 1.5f;\n        sigma_sq_2 = sigma * sigma * 2.0f;\n\n        reference_angles = delete_vec_s(reference_angles);\n        reference_angles = new float[nBin];\n        nBinf = float(nBin);\n\n        for(int i = 0; i < nBin; i++) {\n            reference_angles[i] = (float(i) * C_PI_2) / nBinf;\n        }\n        sector_angle = C_PI_2 / float(nBin);\n\n        for(int i = 0; i < 36; i++) {\n            reference_angles_orientation[i] = (float(i) * C_PI_2) / 36.0f;\n        }\n        sector_angle_orientation = C_PI_2 / 36.0f;\n\n    }\n\n    /**\n     * @brief getDescriptorSize returns the descriptor size.\n     * @return the descriptor size.\n     */\n    int getDescriptorSize()\n    {\n        return tot;\n    }\n\n    /**\n     * @brief computePatchOrientation\n     * @param imgGrad\n     * @param x0\n     * @param y0\n     * @return\n     */\n    float computePatchOrientation(Image *imgGrad, int x0, int y0)\n    {\n        float orientation[36];\n        Arrayf::assign(0.0f, orientation, 36);\n\n        int nBin = 36;\n        float nBinf = float(nBin);\n\n        for(int i = 0; i < patchSize; i ++) {\n            int y_local = i - half_patchSize;\n            int y = y_local + y0;\n\n            for(int j = 0; j < patchSize; j ++) {\n                int x_local = j  - half_patchSize;\n                int x = x_local + x0;\n\n                float *grad = (*imgGrad)(x, y);\n\n                //compute current (x,y) angle\n                float angle = atan2f(grad[1], grad[0]);\n                angle = (angle >= 0.0f) ? angle : angle + C_PI_2;\n                angle = CLAMPi(angle, 0.0f, C_PI_2);\n\n                //place it in the bin\n                float index_f = nBinf * (angle / C_PI_2);\n                int index = int(floorf(index_f));\n                int index_1 = (index + 1) % nBin;\n\n                float dist = (angle - reference_angles_orientation[index]) / sector_angle_orientation;\n                dist = CLAMPi(dist, 0.0f, 1.0f);\n\n                int squared = x_local * x_local + y_local * y_local;\n\n                float mag = grad[2] * expf(-float(squared) / sigma_sq_2);\n\n                orientation[index]   += mag * (1.0f - dist);\n                orientation[index_1] += mag * dist;\n            }\n        }\n\n        int index;\n        Arrayf::getMax(orientation, 36, index);\n\n        return reference_angles_orientation[index];\n    }\n\n    /**\n     * @brief get computes a descriptor at position (x0,y0) with size n for a given image gradient imgGrad.\n     * @param img is the gradient of the input image\n     * @param x0 is the x-coordinate where to compute the descriptor\n     * @param y0 is the y-coordinate where to compute the descriptor\n     * @param desc is the output descriptor, if it is NULL, memory will be allocated\n     * @return it returns a pointer to the descriptor\n     */\n    float *get(Image *imgGrad, int x0, int y0, float *desc = NULL)\n    {\n        if(imgGrad == NULL) {\n            return desc;\n        }\n\n        if(desc == NULL) {\n            desc = new float[tot];\n        }\n\n        memset(desc, 0, sizeof(float) * tot);\n\n        float kp_angle = computePatchOrientation(imgGrad, x0, y0);\n\n        float cosAngle = cosf(-kp_angle);\n        float sinAngle = sinf(-kp_angle);\n\n        //compute the descriptor\n        int counter = 0;\n\n        for(int i = 0; i < patchSize; i += subPatchSize) {\n            int tmp_y = y0 + i - half_patchSize;\n\n            for(int j = 0; j < patchSize; j += subPatchSize) {\n                int tmp_x = x0 + j - half_patchSize;\n\n                for(int k = 0; k < subPatchSize; k++) {\n                    int y = tmp_y + k;\n\n                    for(int l = 0; l < subPatchSize; l++) {\n                        int x = tmp_x + l;\n\n                        float *grad = (*imgGrad)(x, y);\n\n                        if(grad[2] <= thr_weak) {\n                            continue;\n                        }\n\n                        //rotate gradients according to the patch's main orientation\n                        float r_gx = grad[0] * cosAngle - grad[1] * sinAngle;\n                        float r_gy = grad[0] * sinAngle + grad[1] * cosAngle;\n\n                        float angle = atan2f(r_gy, r_gx);\n                        angle = (angle >= 0.0f) ? angle : angle + C_PI_2;\n                        angle = CLAMPi(angle, 0.0f, C_PI_2);\n\n                        //find the bin\n                        float index_f = nBinf * (angle / C_PI_2);\n                        int index = int(floorf(index_f));\n                        int index_1 = (index + 1) % nBin;\n\n                        float dist = (angle - reference_angles[index]) / sector_angle;\n                        dist = CLAMPi(dist, 0.0f, 1.0f);\n\n                        int y_local = i + k - half_patchSize;\n                        int x_local = j + l - half_patchSize;\n                        int squared = x_local * x_local + y_local * y_local;\n\n                        float mag = grad[2] * expf(-float(squared) / sigma_sq_2);\n\n                        desc[counter + index]   += mag * (1.0f - dist);\n                        desc[counter + index_1] += mag * dist;\n                   }\n\n                }\n\n                counter += nBin;\n            }\n        }\n\n        //normalize desc\n        Array<float>::normalize(desc, tot);\n\n        //remove strong edges; i.e., over 0.2\n        for(int i = 0; i < tot; i++) {\n            desc[i] = desc[i] > 0.2f ? desc[i] : 0.2f;\n        }\n\n        //re-normalize desc\n        Array<float>::normalize(desc, tot);\n\n        return desc;\n    }\n\n    /***match: matches two descriptors*/\n    static float match(float *fv0, float *fv1, int nfv)\n    {\n        if(fv0 == NULL || fv1 == NULL || nfv < 1) {\n            return -1.0f;\n        }\n\n        return Array<float>::distanceSq(fv0, fv1, nfv);\n    }\n};\n\n} // end namespace NSF\n\n#endif /* NSF_SIFT_DESCRIPTOR_HPP */\n\n"
  },
  {
    "path": "include/features_matching/susan_corner_detector.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_SUSAN_CORNER_DETECTOR_HPP\n#define PIC_FEATURES_MATCHING_SUSAN_CORNER_DETECTOR_HPP\n\n#include \"../util/vec.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../image.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n\n#include \"../features_matching/general_corner_detector.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief The SusanCornerDetector class\n */\nclass SusanCornerDetector: public GeneralCornerDetector\n{\nprotected:\n    Image *lum_flt;\n    bool  bComputeThreshold;\n\n    float sigma, threshold;\n    int   radius, radius_maxima;\n\n    void release()\n    {\n        lum = delete_s(lum);\n        lum_flt = delete_s(lum_flt);\n    }\n\npublic:\n    /**\n     * @brief SusanCornerDetector\n     */\n    SusanCornerDetector() : GeneralCornerDetector()\n    {\n        lum_flt = NULL;\n\n        bComputeThreshold = true;\n        update();\n    }\n\n    ~SusanCornerDetector()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param sigma\n     * @param radius_maxima\n     * @param radius\n     * @param threshold\n     */\n    void update(float sigma = 1.0f, int radius_maxima = 5, int radius = 3, float threshold = 0.001f)\n    {\n        this->sigma = sigma > 0.0f ? sigma : 1.0f;\n        this->radius = radius > 0 ? radius : 3;\n        this->threshold = threshold > 0.0f ? threshold : 0.001f;\n        this->radius_maxima = radius_maxima > 0 ? radius_maxima : 5;\n    }\n\n    /**\n     * @brief execute\n     * @param img\n     * @param corners\n     */\n    void execute(Image *img, std::vector< Eigen::Vector2f > *corners)\n    {\n        if(img == NULL || corners == NULL) {\n            return;\n        }\n\n        if(img->channels == 1) {\n            bLum = false;\n            lum = img;\n        } else {\n            bLum = true;\n            lum = FilterLuminance::execute(img, lum, LT_CIE_LUMINANCE);\n        }\n\n        corners->clear();\n\n        std::vector< Eigen::Vector3f > corners_w_quality;\n\n        //filter the input image\n        FilterGaussian2D flt(sigma);\n        lum_flt = flt.Process(Single(lum), NULL);\n\n        //\"rasterizing\" a circle\n        std::vector< int > x, y;\n        int radius_sq = radius * radius;\n        for(int i=-radius; i<=radius; i++) {\n            int i_sq = i * i;\n            for(int j=-radius; j<=radius; j++) {\n\n                if((j == 0) && (i == 0)) {\n                    continue;\n                }\n\n                int r_sq = i_sq + j * j;\n                if(r_sq <= radius_sq){\n                    x.push_back(j);\n                    y.push_back(i);\n                }\n            }\n        }\n\n        int width  = lum_flt->width;\n        int height = lum_flt->height;\n\n        float C = float(x.size());\n\n        float t = 0.05f; //depends on image noise\n\n        float g = C * 0.5f; //geometric constant for determing corners\n\n        Image R(1,width, height, 1);\n        R.setZero();\n        for(int i = radius; i < (height - radius - 1); i++) {\n            for(int j = radius; j < (width - radius - 1); j++) {\n\n                int ind = i * width + j;\n\n                float sum = 0.0f;\n\n                for(unsigned int k = 0; k < x.size(); k++) {\n                    int ind_c = (i + y[k]) * width + (j + x[k]);\n\n                    float diff = (lum_flt->data[ind_c] - lum_flt->data[ind]) / t;\n                    float diff_2 = diff * diff;\n                    float diff_4 = diff_2 * diff_2;\n                    float diff_6 = diff_4 * diff_2;\n\n                    sum += expf(-diff_6);\n                }\n\n                if(sum < g) {\n                    R.data[ind] = g - sum;\n                }\n            }\n        }\n\n        //non-maximal supression\n        int side = radius_maxima * 2 + 1;\n        int *indices = new int [side * side];\n\n        for(int i = radius_maxima; i< (height - radius_maxima - 1); i++) {\n\n            int tmp = i * width;\n\n            for(int j = radius_maxima; j < (width - radius_maxima - 1); j++) {\n                int ind = tmp + j;\n\n                if(R.data[ind] <= 0.0f) {\n                    continue;\n                }\n\n                indices[0] = ind;\n                int counter = 1;\n\n                for(int k = -radius_maxima; k <= radius_maxima; k++) {\n                    int yy = CLAMP(i + k, height);\n\n                    for(int l = -radius_maxima; l <= radius_maxima; l++) {\n\n                        if((l == 0) && (k == 0)) {\n                            continue;\n                        }\n\n                        int xx = CLAMP(j + l, width);\n\n                        ind = yy * width + xx;\n\n                        if(R.data[ind]>0.0f){\n                            indices[counter] = ind;\n                            counter++;\n                        }\n\n                    }\n                }\n\n                //are other corners near-by?\n                if(counter > 1) {\n                    //find the maximum value\n                    float R_value = R.data[indices[0]];\n                    int index = 0;\n\n                    for(int k = 1; k < counter; k++){\n                        if(R.data[indices[k]] > R_value) {\n                            R_value = R.data[indices[k]];\n                            index = k;\n                        }\n                    }\n\n                    if(index == 0){\n                        corners_w_quality.push_back(Eigen::Vector3f (float(j), float(i), 1.0f) );\n                    }\n                } else {\n                    corners_w_quality.push_back(Eigen::Vector3f (float(j), float(i), 1.0f) );\n                }\n            }\n        }\n\n        sortCornersAndTransfer(&corners_w_quality, corners);\n\n        if(indices != NULL) {\n            delete[] indices;\n            indices = NULL;\n        }\n    }\n};\n\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_SUSAN_CORNER_DETECTOR_HPP */\n\n"
  },
  {
    "path": "include/features_matching/transform_data.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_TRANSFORM_DATA_HPP\n#define PIC_FEATURES_MATCHING_TRANSFORM_DATA_HPP\n\nnamespace pic {\n\n/**\n * @brief The TransformData class\n */\nclass TransformData\n{\npublic:\n    int   x, y;\n    float angle, scale;\n    float gain, bias;\n    float quality;\n\n    /**\n     * @brief TransformData\n     */\n    TransformData()\n    {\n        this->quality = -1.0f;\n    }\n\n    /**\n     * @brief TransformData\n     * @param x\n     * @param y\n     */\n    TransformData(int x, int y)\n    {\n        this->x = x;\n        this->y = y;\n        this->quality = -1.0f;\n    }\n\n    /**\n     * @brief TransformData\n     * @param x\n     * @param y\n     * @param angle\n     * @param scale\n     */\n    TransformData(int x, int y, float angle, float scale)\n    {\n        this->x = x;\n        this->y = y;\n        this->angle = angle;\n        this->scale = scale;\n\n        this->quality = -1.0f;\n    }\n\n    /**\n     * @brief set\n     * @param values\n     */\n    void set(float *values)\n    {\n        x = int(values[0]);\n        y = int(values[1]);\n        angle = values[2];\n        scale = values[3];\n        quality = values[4];\n    }\n\n    /**\n     * @brief set\n     * @param values\n     */\n    void get(float *values)\n    {\n        values[0] = float(x);\n        values[1] = float(y);\n        values[2] = angle;\n        values[3] = scale;\n        values[4] = quality;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_TRANSFORM_DATA_HPP */\n\n"
  },
  {
    "path": "include/features_matching/ward_alignment.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_WARD_ALIGNMENT_HPP\n#define PIC_FEATURES_MATCHING_WARD_ALIGNMENT_HPP\n\n#include <vector>\n\n#include \"../image.hpp\"\n#include \"../util/vec.hpp\"\n#include \"../util/string.hpp\"\n#include \"../image_samplers/image_sampler_bilinear.hpp\"\n#include \"../filtering/filter_downsampler_2d.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The WardAlignment class\n */\nclass WardAlignment\n{\nprotected:\n    float tolerance, percentile;\n\npublic:\n    ImageVec img1_v, img2_v, luminance;\n    std::vector< bool* > tb1_v, tb2_v, eb2_shifted_v, tb2_shifted_v;\n\n    /**\n     * @brief WardAlignment\n     */\n    WardAlignment()\n    {\n        update(0.5f, 0.015625f);\n    }\n\n    ~WardAlignment()\n    {\n        for(unsigned int i=0; i< luminance.size(); i++) {\n            delete luminance[i];\n        }\n\n        for(unsigned int i=0; i< img1_v.size(); i++) {\n            delete img1_v[i];\n        }\n\n        for(unsigned int i=0; i< img2_v.size(); i++) {\n            delete img2_v[i];\n        }\n\n        for(unsigned int i=0; i< tb1_v.size(); i++) {\n            delete[] tb1_v[i];\n        }\n\n        for(unsigned int i=0; i< tb2_v.size(); i++) {\n            delete[] tb2_v[i];\n        }\n\n        for(unsigned int i=0; i< eb2_shifted_v.size(); i++) {\n            delete[] eb2_shifted_v[i];\n        }\n\n        for(unsigned int i=0; i<tb2_shifted_v.size(); i++) {\n            delete[] tb2_shifted_v[i];\n        }\n    }\n\n    /**\n     * @brief update sets parameters up for MTB\n     * @param percentile\n     * @param tolerance\n     */\n    void update(float percentile, float tolerance)\n    {\n        if(percentile < 0.0f && percentile > 1.0f) {\n            percentile = 0.5f;\n        }\n\n        if(tolerance > 0.0625f) {\n            tolerance = 0.015625f;\n        }\n\n        this->percentile = percentile;\n        this->tolerance = tolerance;\n    }\n\n    /**\n     * @brief MTB computes the median threshold mask\n     * @param img\n     * @param L\n     * @return\n     */\n    bool *MTB(Image *img, Image *L)\n    {\n        bool bDelete = (L == NULL);\n\n        if(img->channels == 1)\n        {\n            bDelete = false;\n            L = img;\n        } else {\n            L = FilterLuminance::execute(img, L, LT_WARD_LUMINANCE);\n        }\n\n        int n = L->nPixels();\n        bool *maskThr = new bool[n * 2];\n        bool *maskEb = &maskThr[n];\n\n        float *ret = L->getPercentileVal(percentile, NULL, NULL);\n        float medVal = ret[0];\n\n        float A = medVal - tolerance;\n        float B = medVal + tolerance;\n\n        for(int i = 0; i < n; i++) {\n            maskThr[i] = L->data[i] > medVal;\n            maskEb[i]  = !((L->data[i] >= A) && (L->data[i] <= B));\n        }\n\n        if(bDelete) {\n            delete L;\n        }\n\n        return maskThr;\n    }\n\n    /**\n     * @brief getExpShift computes the shift vector for moving an img1 onto img2\n     * @param img1\n     * @param img2\n     * @param shift_bits\n     * @return\n     */\n    Vec2i getExpShift(Image *img1, Image *img2,\n                                   int shift_bits = 6)\n    {\n        if(img1 == NULL || img2 == NULL) {\n            return Vec2i(0, 0);\n        }\n\n        if(!img1->isSimilarType(img2)) {\n            return Vec2i(0, 0);\n        }\n\n        Image *L1, *L2;\n\n        if(img1->channels == 1) {\n            L1 = img1;\n        } else {\n            L1 = FilterLuminance::execute(img1, NULL, LT_WARD_LUMINANCE);\n            luminance.push_back(L1);\n        }\n\n        if(img2->channels == 1) {\n            L2 = img2;\n        } else {\n            L2 = FilterLuminance::execute(img2, NULL, LT_WARD_LUMINANCE);\n            luminance.push_back(L2);\n        }\n\n        int min_coord = MIN(L1->width, L1->height);\n         if(min_coord < (1 << shift_bits)) {\n             shift_bits = MAX(log2(min_coord) - 1, 1);\n         }\n\n        Vec2i cur_shift, ret_shift;\n\n        cur_shift = Vec2i(0, 0);\n        ret_shift = Vec2i(0, 0);\n\n        //downsample\n        Image *tmp_1 = L1;\n        Image *tmp_2 = L2;\n        for(int i = 0; i < shift_bits; i++) {\n            Image* sml_img1 = FilterDownSampler2D::execute(tmp_1, NULL, 0.5f);\n            Image* sml_img2 = FilterDownSampler2D::execute(tmp_2, NULL, 0.5f);\n\n            img1_v.push_back(sml_img1);\n            img2_v.push_back(sml_img2);\n\n            tmp_1 = sml_img1;\n            tmp_2 = sml_img2;\n        }\n\n        //compute the shift\n        while(shift_bits > 0) {\n            Image* sml_img1 = img1_v[shift_bits - 1];\n            Image* sml_img2 = img2_v[shift_bits - 1];\n\n            int width  = sml_img1->width;\n            int height = sml_img1->height;\n            int n = width * height;\n\n             //compute the median threshold mask\n            bool *tb1 = MTB(sml_img1, NULL);\n            bool *eb1  = &tb1[n];\n\n            bool *tb2 = MTB(sml_img2, NULL);\n            bool *eb2  = &tb2[n];\n\n            //track memory\n            tb1_v.push_back(tb1);\n            tb2_v.push_back(tb2);\n            \n            int min_err = n;\n\n            bool *tb2_shifted = new bool[n];\n            bool *eb2_shifted = new bool[n];\n\n            tb2_shifted_v.push_back(tb2_shifted);\n            eb2_shifted_v.push_back(eb2_shifted);\n\n            for(int i = -1; i <= 1; i++) {\n\n                for(int j = -1; j <= 1; j++) {\n\n                    int xs = cur_shift[0] + i;\n                    int ys = cur_shift[1] + j;\n\n                    Buffer<bool>::shift(tb2_shifted, tb2, xs, ys, true, width, height, 1, 1);\n                    Buffer<bool>::shift(eb2_shifted, eb2, xs, ys, true, width, height, 1, 1);\n\n                    int err = 0;\n                    for(int k=0; k<n; k++) {\n                        bool diff_b = tb1[k] ^ tb2_shifted[k];\n                        diff_b = diff_b & eb1[k];\n                        diff_b = diff_b & eb2_shifted[k];\n\n                        if(diff_b) {\n                            err++;\n                        }\n                    }\n\n                    if(err < min_err) {\n                        ret_shift[0] = xs;\n                        ret_shift[1] = ys;\n                        min_err = err;\n                    }\n                }\n            }\n\n            shift_bits--;\n\n            cur_shift[0] = ret_shift[0] * 2;\n            cur_shift[1] = ret_shift[1] * 2;\n        }\n\n        return cur_shift;\n    }\n\n    static Vec2i execute(Image *imgTarget, Image *imgSource)\n    {\n        Vec2i shift;\n        WardAlignment wa;\n\n        if(imgTarget == NULL || imgSource == NULL) {\n            return shift;\n        }\n\n        if(!imgTarget->isSimilarType(imgSource)) {\n            return shift;\n        }\n\n        shift = wa.getExpShift(imgTarget, imgSource);\n\n        return shift;\n    }\n\n    static Image *shiftImage(Image *img, Vec2i shift, Image *ret = NULL)\n    {\n        if(img == NULL) {\n            return ret;\n        }\n\n        if(ret == NULL) {\n            ret = img->allocateSimilarOne();\n        } else {\n            if(!ret->isSimilarType(img)) {\n                ret = img->allocateSimilarOne();\n            }\n        }\n\n        ret->setZero();\n        Buffer<float>::shift(ret->data, img->data,\n                             shift[0], shift[1], true,\n                            img->width, img->height,\n                            img->channels, img->frames);\n\n        return ret;\n    }\n\n\n    /**\n     * @brief execute aligns imgSource to imgTarget\n     * @param imgTarget\n     * @param imgSource\n     * @param shift\n     * @return\n     */\n    static Image *execute(Image *imgTarget, Image *imgSource, Vec2i &shift)\n    {\n        shift = execute(imgTarget, imgSource);\n\n        if(shift[0] != 0 && shift[1] != 0) {\n            Image *ret = shiftImage(imgSource, shift, NULL);\n            return ret;\n        } else {\n            return imgSource;\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FEATURES_MATCHING_WARD_ALIGNMENT_HPP */\n\n"
  },
  {
    "path": "include/features_matching.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FEATURES_MATCHING_HPP\n#define PIC_FEATURES_MATCHING_HPP\n\n#include \"util/eigen_util.hpp\"\n\n//Corner descriptors\n#include \"features_matching/general_corner_detector.hpp\"\n#include \"features_matching/harris_corner_detector.hpp\"\n#include \"features_matching/susan_corner_detector.hpp\"\n#include \"features_matching/fast_corner_detector.hpp\"\n\n//Edge descriptors\n#include \"features_matching/canny_edge_detector.hpp\"\n\n//Feature descriptors\n#include \"features_matching/lucid_descriptor.hpp\"\n#include \"features_matching/brief_descriptor.hpp\"\n#include \"features_matching/orb_descriptor.hpp\"\n#include \"features_matching/sift_descriptor.hpp\"\n\n#include \"features_matching/patch_comp.hpp\"\n#include \"features_matching/transform_data.hpp\"\n\n#include \"features_matching/ward_alignment.hpp\"\n#include \"features_matching/motion_estimation.hpp\"\n\n//binary feature matcher\n#include \"features_matching/feature_matcher.hpp\"\n#include \"features_matching/binary_feature_brute_force_matcher.hpp\"\n#include \"features_matching/binary_feature_lsh_matcher.hpp\"\n\n#endif /* PIC_FEATURES_MATCHING_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_HPP\n#define PIC_FILTERING_FILTER_HPP\n\n#ifndef PIC_DISABLE_THREAD\n#include <thread>\n#endif\n\n#include <functional>\n\n#include \"../image.hpp\"\n#include \"../image_vec.hpp\"\n#include \"../util/tile_list.hpp\"\n#include \"../util/string.hpp\"\n\nnamespace pic {\n\n//NOTE: This depends on the architecture!\n#define TILE_SIZE 64\n\nstruct FilterFData\n{\n    int x, y, z;\n    float *out;\n\n    Image *dst;\n    ImageVec src;\n    int nSrc;\n};\n\n/**\n * @brief The Filter class\n */\nclass Filter\n{\nprotected:\n    float scale;\n    std::vector< float > param_f;\n\n    int minInputImages;\n\n    /**\n     * @brief checkInput\n     * @param imgIn\n     * @return\n     */\n    bool checkInput(ImageVec &imgIn);\n\n    /**\n     * @brief f\n     * @param data\n     */\n    virtual void f(FilterFData *data)\n    {\n\n    }\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    virtual void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        FilterFData f_data;\n        f_data.src = src;\n        f_data.dst = dst;\n        f_data.nSrc = int(src.size());\n\n        for(int k = box->z0; k < box->z1; k++) {\n            f_data.z = k;\n\n            for(int j = box->y0; j < box->y1; j++) {\n                f_data.y = j;\n\n                for(int i = box->x0; i < box->x1; i++) {\n                    f_data.x = i;\n                    f_data.out = (*dst)(i, j);\n\n                    f(&f_data);\n                }\n            }\n        }\n    }\n\n    /**\n     * @brief ProcessP\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *ProcessP(ImageVec imgIn, Image *imgOut);\n\n    /**\n     * @brief setupAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    virtual Image *setupAux(ImageVec imgIn, Image *imgOut);\n\npublic:\n    bool cachedOnly, bDelete;\n    std::vector<Filter *> filters;\n\n    /**\n     * @brief Filter\n     */\n    Filter()\n    {\n        bDelete = false;\n        minInputImages = 1;\n        cachedOnly = false;\n        scale = 1.0f;\n    }\n\n    ~Filter()\n    {\n        release();\n    }\n\n    /**\n     * @brief release\n     */\n    virtual void release()\n    {\n\n    }\n\n    /**\n     * @brief changePass changes the pass direction.\n     * @param pass\n     * @param tPass\n     */\n    virtual void changePass(int pass, int tPass) {}\n\n    /**\n     * @brief signature returns the signature for the filter.\n     * @return\n     */\n    virtual std::string signature()\n    {\n        return \"FLT\";\n    }\n\n    /**\n     * @brief checkHalfSize\n     * @param size\n     * @return\n     */\n    int checkHalfSize(int size){\n        if(size > 1)\n        {\n            return size >> 1;\n        } else {\n            return 1;\n        }\n    }\n\n    /**\n     * @brief getOutPutName\n     * @param nameIn\n     * @return\n     */\n    std::string getOutPutName(std::string nameIn);\n\n    /**\n     * @brief CachedProcess\n     * @param imgIn\n     * @param imgOut\n     * @param nameIn\n     * @return\n     */\n    Image *cachedProcess(ImageVec imgIn, Image *imgOut,\n                            std::string nameIn);\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    virtual void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = imgIn[0]->channels;\n        frames      = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief allocateOutputMemory\n     * @param imgIn\n     * @param imgOut\n     * @param bDelete\n     * @return\n     */\n    Image *allocateOutputMemory(ImageVec imgIn, Image *imgOut, bool bDelete)\n    {\n        int w, h, c, f;\n        OutputSize(imgIn, w, h, c, f);\n\n        if(imgOut == NULL) {            \n            imgOut = new Image(f, w, h, c);\n        } else {\n            bool bSame = (imgOut->width == w) &&\n                         (imgOut->height == h) &&\n                         (imgOut->channels == c) &&\n                         (imgOut->frames == f);\n\n            if(!bSame) {\n                if(bDelete) {\n                    delete imgOut;\n                }\n\n                imgOut = new Image(f, w, h, c);\n            }\n        }\n\n        return imgOut;\n    }\n\n    /**\n     * @brief insertFilter\n     * @param flt\n     */\n    void insertFilter(Filter *flt, bool asSingle = false)\n    {\n        if(flt == NULL) {\n            return;\n        }\n\n        if(asSingle || flt->filters.empty()) {\n            filters.push_back(flt);\n        } else {\n            for(unsigned int i = 0; i < flt->filters.size(); i++) {\n                insertFilter(flt->filters[i]);\n            }\n        }\n    }\n\n    /**\n     * @brief setFloatParameters sets float parameters.\n     * @param param_f\n     */\n    void setFloatParameters(std::vector< float > param_f)\n    {\n        this->param_f.insert(this->param_f.begin(), param_f.begin(), param_f.end());\n    }\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @param tiles\n     */\n    virtual void ProcessAux(ImageVec imgIn, Image *imgOut,\n                             TileList *tiles);\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    virtual Image *Process(ImageVec imgIn, Image *imgOut);\n};\n\nPIC_INLINE Image *Filter::setupAux(ImageVec imgIn, Image *imgOut)\n{\n    return allocateOutputMemory(imgIn, imgOut, bDelete);\n}\n\nPIC_INLINE std::string Filter::getOutPutName(std::string nameIn)\n{\n    std::string outputName = nameIn;\n\n    size_t found = outputName.find(\".\");\n\n    if(found != std::string::npos) {\n        outputName.erase(outputName.end() - 4, outputName.end());\n    }\n\n    outputName += \"_filtered_\";\n    outputName += signature().c_str();\n    outputName += \".pfm\";\n    return outputName;\n}\n\nPIC_INLINE Image *Filter::cachedProcess(ImageVec imgIn, Image *imgOut,\n        std::string nameIn)\n{\n    std::string outputName = getOutPutName(nameIn);\n\n    //check if it is chaced\n    Image *imgOut2 = new Image(outputName);\n\n    if(imgOut2->data == NULL) {\n        if(!cachedOnly) {\n            imgOut = Process(imgIn, imgOut);\n            imgOut->Write(outputName);\n            return imgOut;\n        } else {\n            return NULL;\n        }\n    } else {\n        if(imgOut != NULL) {\n            imgOut->assign(imgOut2);\n            return imgOut;\n        } else {\n            return imgOut2;\n        }\n    }\n}\n\nPIC_INLINE void Filter::ProcessAux(ImageVec imgIn, Image *imgOut,\n                                    TileList *tiles)\n{\n    bool state = true;\n    while(state) {\n        unsigned int currentTile = tiles->getNext();\n\n        if(currentTile < tiles->tiles.size()) {\n            BBox box = tiles->getBBox(currentTile);\n            box.z0 = 0;\n            box.z1 = imgOut->frames;\n            ProcessBBox(imgOut, imgIn, &box);\n        } else {\n            state = false;\n        }\n    }\n}\n\nPIC_INLINE Image *Filter::ProcessP(ImageVec imgIn, Image *imgOut)\n{\n    if((imgOut->width  < TILE_SIZE) &&\n       (imgOut->height < TILE_SIZE)) {\n        BBox box(imgOut->width, imgOut->height, imgOut->frames);\n\n        ProcessBBox(imgOut, imgIn, &box);\n        return imgOut;\n    }\n\n    //create threads\n    int numCores = std::thread::hardware_concurrency();\n\n    std::thread **thrd = new std::thread*[numCores];\n    TileList lst(TILE_SIZE, imgOut->width, imgOut->height);\n\n    for(int i = 0; i < numCores; i++) {\n        thrd[i] = new std::thread(\n            std::bind(&Filter::ProcessAux, this, imgIn, imgOut, &lst));\n    }\n\n    //join threads\n    for(int i = 0; i < numCores; i++) {\n        thrd[i]->join();\n        delete thrd[i];\n    }\n\n    delete[] thrd;\n\n    return imgOut;\n}\n\nPIC_INLINE bool Filter::checkInput(ImageVec &imgIn)\n{\n    return ImageVecCheck(imgIn, minInputImages);\n}\n\nPIC_INLINE Image *Filter::Process(ImageVec imgIn, Image *imgOut)\n{\n    if(!checkInput(imgIn)) {\n        return imgOut;\n    }\n\n    imgOut = setupAux(imgIn, imgOut);\n\n    if(imgOut == NULL) {\n        return imgOut;\n    }\n\n    return ProcessP(imgIn, imgOut);\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_absolute_difference.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_ABSOLUTE_DIFFERENCE_HPP\n#define PIC_FILTERING_FILTER_ABSOLUTE_DIFFERENCE_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterAbsoluteDifference class\n */\nclass FilterAbsoluteDifference: public Filter\n{\nprotected:\n\n    /**\n     * @brief f\n     * @param data\n     */\n    void f(FilterFData *data)\n    {\n        float *dataIn0 = (*data->src[0])(data->x, data->y);\n        float *dataIn1 = (*data->src[1])(data->x, data->y);\n\n        for(int k = 0; k < data->dst->channels; k++) {\n            data->out[k] = fabsf(dataIn1[k] - dataIn0[k]);\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterAbsoluteDifference\n     */\n    FilterAbsoluteDifference() : Filter()\n    {\n\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn1\n     * @param imgIn2\n     * @return\n     */\n    static Image *execute(Image *imgIn1, Image *imgIn2)\n    {\n        FilterAbsoluteDifference filter;\n        return filter.Process(Double(imgIn1, imgIn2), NULL);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_ABSOLUTE_DIFFERENCE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_anisotropic_diffusion.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_ANISOTROPIC_DIFFUSION_HPP\n#define PIC_FILTERING_FILTER_ANISOTROPIC_DIFFUSION_HPP\n\n#include \"../base.hpp\"\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_iterative.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterAnsiotropicDiffusion class\n */\nclass FilterAnsiotropicDiffusion: public Filter\n{\nprotected:\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\n    float k, k_sq, delta_t;\n    unsigned int mode;\n\npublic:\n\n    /**\n     * @brief FilterAnsiotropicDiffusion\n     * @param k\n     * @param mode\n     */\n    FilterAnsiotropicDiffusion(float k, unsigned int mode);\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param k\n     * @param mode\n     * @param iterations\n     * @return\n     */\n    static Image *execute(ImageVec imgIn, Image *imgOut,\n                                          float k, unsigned int mode, unsigned int iterations)\n    {\n        FilterAnsiotropicDiffusion ansio_flt(k, mode);\n        FilterIterative iter_flt(&ansio_flt, iterations);\n        imgOut = iter_flt.Process(imgIn, imgOut);\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma_s\n     * @param sigma_r\n     * @param maxIterations\n     * @return\n     */\n    static Image *execute(ImageVec imgIn, Image *imgOut,\n                                          float sigma_s, float sigma_r, int maxIterations = -1)\n    {\n        if(sigma_s <= 0.0f) {\n            sigma_s = 1.0f;\n        }\n\n        if(sigma_r <= 0.0f) {\n            sigma_r = 0.05f;\n        }\n\n        int iterations = 0;\n\n        if(maxIterations > 0) {\n            iterations = maxIterations;\n        } else {\n            iterations = int(ceilf(5.0f * sigma_s));\n        }\n\n        FilterAnsiotropicDiffusion ansio_flt(sigma_r, 2);\n        FilterIterative iter_flt(&ansio_flt, iterations);\n        imgOut = iter_flt.Process(imgIn, imgOut);\n        return imgOut;\n    }\n\n};\n\nPIC_INLINE FilterAnsiotropicDiffusion::FilterAnsiotropicDiffusion(float k,\n        unsigned int mode)\n{\n    if(k <= 0.0f) {\n        k = 0.11f;\n    }\n\n    if(mode > 2\n        ) {\n        mode = 0;\n    }\n\n    delta_t = 1.0f / 7.0f;\n\n    this->k = k;\n    this->k_sq = k * k;\n\n    this->mode = mode;\n}\n\nPIC_INLINE void FilterAnsiotropicDiffusion::ProcessBBox(Image *dst, ImageVec src,\n        BBox *box)\n{\n    Image *img = src[0];\n    int channels = img->channels;\n\n    float *gN = new float [channels];\n    float *gS = new float [channels];\n    float *gW = new float [channels];\n    float *gE = new float [channels];\n\n    for(int j = box->y0; j < box->y1; j++) {\n        for(int i = box->x0; i < box->x1; i++) {\n\n            float *dst_data  = (*dst)(i, j);\n            float *img_data  = (*img)(i, j);\n\n            float *img_dataN = (*img)(i + 1, j    );\n            float *img_dataS = (*img)(i - 1, j    );\n            float *img_dataW = (*img)(i    , j - 1);\n            float *img_dataE = (*img)(i    , j + 1);\n\n            float cN = 0.0f;\n            float cS = 0.0f;\n            float cW = 0.0f;\n            float cE = 0.0f;\n\n            for(int p = 0; p < channels; p++) {\n                gN[p] = img_dataN[p] - img_data[p];\n                gS[p] = img_dataS[p] - img_data[p];\n                gW[p] = img_dataW[p] - img_data[p];\n                gE[p] = img_dataE[p] - img_data[p];\n\n                cN += gN[p] * gN[p];\n                cS += gS[p] * gS[p];\n                cW += gW[p] * gW[p];\n                cE += gE[p] * gE[p];\n            }\n\n            switch(mode) {\n                case 1:\n                {\n                    cN = 1.0f / (1.0f + cN / k_sq);\n                    cS = 1.0f / (1.0f + cS / k_sq);\n                    cW = 1.0f / (1.0f + cW / k_sq);\n                    cE = 1.0f / (1.0f + cE / k_sq);\n                } break;\n\n                case 2:\n                {\n                    float t;\n                    t = 1.0f - expf(-3.315f / powf(cN / k_sq, 8.0f));\n                    cN = cN > 0.0f ? t : 1.0f;\n\n                    t = 1.0f - expf(-3.315f / powf(cS / k_sq, 8.0f));\n                    cS = cS > 0.0f ? t : 1.0f;\n\n                    t = 1.0f - expf(-3.315f / powf(cW / k_sq, 8.0f));\n                    cW = cW > 0.0f ? t : 1.0f;\n\n                    t = 1.0f - expf(-3.315f / powf(cE / k_sq, 8.0f));\n                    cE = cE > 0.0f ? t : 1.0f;\n                } break;\n\n                default:\n                {\n                    cN = expf(-cN / k_sq);\n                    cS = expf(-cS / k_sq);\n                    cW = expf(-cW / k_sq);\n                    cE = expf(-cE / k_sq);\n                } break;\n            }\n\n            for(int p = 0; p < channels; p++) {\n                dst_data[p] = img_data[p] + delta_t *\n                        (cN * gN[p] + cS * gS[p] + cW * gW[p] + cE * gE[p]);\n            }\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_ANISOTROPIC_DIFFUSION_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_assemble_hdr.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_ASSEMBLE_HDR_HPP\n#define PIC_FILTERING_FILTER_ASSEMBLE_HDR_HPP\n\n#include \"../filtering/filter.hpp\"\n\n#include \"../util/array.hpp\"\n\n#include \"../algorithms/camera_response_function.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The HDR_REC_DOMAIN enum\n * HRD_LOG: assembling HDR image in the log-domain\n\n * HRD_LIN: assembling HDR image in the linear domain\n *\n * HRD_SQ: assembling HDR image in the linear domain with t^2 trick\n * for reducing noise [Robertson et al.]\n */\nenum HDR_REC_DOMAIN {HRD_LOG, HRD_LIN, HRD_SQ};\n\n/**\n * @brief The FilterAssembleHDR class\n */\nclass FilterAssembleHDR: public Filter\n{\nprotected:\n    CameraResponseFunction *crf;\n    HDR_REC_DOMAIN domain;\n    CRF_WEIGHT weight_type;\n    float delta_value;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        int width = dst->width;\n        int channels = dst->channels;\n\n        int n = int(src.size());\n\n        float t_min = src[0]->exposure;\n        int i_min = 0;\n\n        float t_max = src[0]->exposure;\n        int i_max = 0;\n\n        for(int j = 1; j < n; j++) {\n            if(src[j]->exposure < t_min) {\n                t_min = src[j]->exposure;\n                i_min = j;\n            }\n            \n            if(src[j]->exposure > t_max) {\n                t_max = src[j]->exposure;\n                i_max = j;\n            }\n        }\n        \n        //check i_min\n        bool bMin = false;\n        Image *img_min = src[i_min];\n        for(int i = 0; i < img_min->size(); i++) {\n            if(img_min->data[i] > 0.9f) {\n                bMin = true;\n                break;\n            }\n        }\n\n        //check i_max\n        bool bMax = false;\n        Image *img_max = src[i_max];\n        for(int i = 0; i < img_max->size(); i++) {\n            if(img_max->data[i] < 0.1f) {\n                bMax = true;\n                break;\n            }\n        }\n\n        CRF_WEIGHT *weight_type_arr = new CRF_WEIGHT[n];\n        for(int l = 0; l < n; l++) {\n\n            weight_type_arr[l] = weight_type;\n\n            if((l == i_min) && bMin) {\n                weight_type_arr[l] = CW_IDENTITY;\n            }\n\n            if((l == i_max) && bMax) {\n                weight_type_arr[l] = CW_REVERSE;\n            }\n        }\n\n        float *acc = new float[channels];\n        float *totWeight = new float[channels];\n\n        for(int j = box->y0; j < box->y1; j++) {\n            int ind = j * width;\n\n            for(int i = box->x0; i < box->x1; i++) {\n                int c = (ind + i) * channels;\n\n                Arrayf::assign(0.0f, acc, channels);\n                Arrayf::assign(0.0f, totWeight, channels);\n\n                //for each exposure...\n\n                for(int l = 0; l < n; l++) {\n\n                    float x = Arrayf::sum(&src[l]->data[c], channels) / dst->channelsf;\n                    \n                    float weight = weightFunction(x, weight_type_arr[l]);\n\n                    if(domain == HRD_SQ) {\n                        weight *= (src[l]->exposure * src[l]->exposure);\n                    }\n\n                    for(int k = 0; k < channels; k++) {\n                        float x_lin = crf->remove(src[l]->data[c + k], k);\n\n                        //merge HDR pixels\n                        switch(domain) {\n                            case HRD_LIN: {\n                                acc[k] += (weight * x_lin) / src[l]->exposure;\n                            } break;\n\n                            case HRD_LOG: {\n                                acc[k] += weight * (logf(x_lin + delta_value) - logf(src[l]->exposure));\n                            } break;\n\n                            case HRD_SQ: {\n                                acc[k] += (weight * x_lin) * src[l]->exposure;\n                            } break;\n                        }\n\n                        totWeight[k] += weight;\n                    }\n                }\n\n                for(int k = 0; k < channels; k++) {\n                    acc[k] /= totWeight[k];\n                    if(domain == HRD_LOG) {\n                        acc[k] = expf(acc[k]);\n                    }\n                    dst->data[c + k] = acc[k];\n                }\n            }\n        }\n\n        delete[] weight_type_arr;\n        delete[] totWeight;\n        delete[] acc;\n    }\n\npublic:\n\n    /**\n     * @brief FilterAssembleHDR\n     * @param weight_type\n     * @param linearization_type\n     * @param icrf\n     */\n    FilterAssembleHDR(CameraResponseFunction *crf = NULL, CRF_WEIGHT weight_type = CW_DEB97, HDR_REC_DOMAIN domain = HRD_LOG)\n    {\n        update(crf, weight_type, domain);\n        minInputImages = 2;\n\n        //a numerical stability value when assembling images in the log-domain\n        this->delta_value = 1.0f / 65535.0f;\n    }\n\n    /**\n     * @brief update\n     * @param crf\n     * @param weight_type\n     * @param domain\n     */\n    void update(CameraResponseFunction *crf, CRF_WEIGHT weight_type = CW_DEB97, HDR_REC_DOMAIN domain = HRD_LOG)\n    {        \n        this->crf = crf;\n\n        this->weight_type = weight_type;\n\n        this->domain = domain;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_ASSEMBLE_HDR_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_backward_difference.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_BACKWARD_DIFFERENCE_HPP\n#define PIC_FILTERING_FILTER_BACKWARD_DIFFERENCE_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterBackwardDifference class\n */\nclass FilterBackwardDifference: public Filter\n{\nprotected:\n\n    /**\n     * @brief f\n     * @param data\n     */\n    void f(FilterFData *data)\n    {\n        float *in   = (*data->src[0])(data->x,     data->y);\n        float *inXm = (*data->src[0])(data->x + 1, data->y);\n        float *inYm = (*data->src[0])(data->x,     data->y + 1);\n\n        for(int k = 0; k < data->dst->channels; k++) {\n            int tmp = k << 1;\n            data->out[tmp  ]   = inXm[k] - in[k];\n            data->out[tmp + 1] = inYm[k] - in[k];\n        }\n    }\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     *\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        //Filtering\n        Image *img = src[0];\n        int channels = img->channels;\n\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *dst_data   = (*dst)(i  , j);\n\n                float *img_data   = (*img)(i  , j);\n                float *img_dataXm = (*img)(i + 1, j);\n                float *img_dataYm = (*img)(i  , j + 1);\n\n                for(int k = 0; k < channels; k++) {\n\n                }\n            }\n        }\n    }*/\n\npublic:\n    /**\n     * @brief FilterBackwardDifference\n     */\n    FilterBackwardDifference() : Filter()\n    {\n\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = imgIn[0]->channels * 2;\n        frames      = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        FilterBackwardDifference filter;\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_BACKWARD_DIFFERENCE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_bilateral_1d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_BILATERAL_1D_HPP\n#define PIC_FILTERING_FILTER_BILATERAL_1D_HPP\n\n#include \"../util/precomputed_gaussian.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../util/array.hpp\"\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterBilateral1D class\n */\nclass FilterBilateral1D: public Filter\n{\nprotected:\n    PrecomputedGaussian *pg;\n    int dirs[3];\n    float sigma_r_sq_2;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n\n    float sigma_s, sigma_r;\n\n    /**\n     * @brief FilterBilateral1D\n     * @param sigma_s\n     * @param sigma_r\n     */\n    FilterBilateral1D(float sigma_s, float sigma_r);\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_r\n     */\n    void update(float sigma_s, float sigma_r);\n\n    /**\n     * @brief signature\n     * @return\n     */\n    std::string signature()\n    {\n        return genBilString(\"1D\", sigma_s, sigma_r);\n    }\n\n    /**\n     * @brief changePass\n     * @param pass\n     * @param tPass\n     */\n    void changePass(int pass, int tPass);\n};\n\nPIC_INLINE FilterBilateral1D::FilterBilateral1D(float sigma_s, float sigma_r) : Filter()\n{\n    pg = NULL;\n    update(sigma_s, sigma_r);\n}\n\nPIC_INLINE void FilterBilateral1D::update(float sigma_s, float sigma_r)\n{\n    //protected values are assigned/computed\n    this->sigma_s = sigma_s > 0.0f ? sigma_s : 1.0f;\n    this->sigma_r = sigma_r > 0.0f ? sigma_r : 0.01f;\n    this->sigma_r_sq_2 = this->sigma_r * this->sigma_r * 2.0f;\n\n    //Precomputation of the Gaussian filter\n    dirs[0] = dirs[1] = dirs[2] = 0;\n\n    pg = delete_s(pg);\n\n    pg = new PrecomputedGaussian(sigma_s);\n}\n\nPIC_INLINE void FilterBilateral1D::changePass(int pass, int tPass)\n{\n    /*\ttPass++;\n    \tdirs[ pass%tPass] = 1;\n    \tfor(int i=1;i<tPass;i++)\n    \t\tdirs[(pass+i)%tPass] = 0;\n    */\n    int tMod;\n\n    if(tPass > 1) {\n        tMod = 3;\n    } else {\n        if(tPass == 1) {\n            tMod = 2;\n        } else {\n            printf(\"ERROR: FilterGaussian1D::ChangePass\\n\");\n            return;\n        }\n    }\n\n    dirs[ pass % tMod] = 1;\n\n    for(int i = 1; i < tMod; i++) {\n        dirs[(pass + i) % tMod] = 0;\n    }\n\n#ifdef PIC_DEBUG\n    printf(\"%d %d %d\\n\", dirs[0], dirs[1], dirs[2]);\n#endif\n}\n\nPIC_INLINE void FilterBilateral1D::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n    Image *edge, *base;\n\n    if(src.size() == 2) {\n        //Joint/Cross Bilateral Filtering\n        base = src[0];\n        edge = src[1];\n    } else {\n        base = src[0];\n        edge = src[0];\n    }\n\n    for(int m = box->z0; m < box->z1; m++) {\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *tmpDst  = (*dst )(i, j, m);\n                float *tmpEdge = (*edge)(i, j, m);\n\n                Arrayf::assign(0.0f, tmpDst, dst->channels);\n\n                float sum = 0.0f;\n\n                for(int k = 0; k < pg->kernelSize; k++) {\n                    //Spatial filtering\n                    float weight = pg->coeff[k];\n\n                    int tmpCoord = k - pg->halfKernelSize;\n\n                    //Address cj\n                    int cj = j + tmpCoord * dirs[0];\n                    //Address ci\n                    int ci = i + tmpCoord * dirs[1];\n                    //Address cm\n                    int cm = m + tmpCoord * dirs[2];\n\n\n                    //Range filtering\n                    float *curEdge = (*edge)(ci, cj, cm); \n\n                    float edgeDist = Arrayf::distanceSq(curEdge, tmpEdge, dst->channels);\n                    edgeDist = expf(-edgeDist / sigma_r_sq_2);\n\n                    //Weight\n                    weight *= edgeDist;\n\n                    //filter\n                    float *curBase = (*base)(ci, cj, cm);\n                    for(int l = 0; l < dst->channels; l++) {\n                        tmpDst[l] += curBase[l] * weight;\n                    }\n\n                    sum += weight;\n                }\n\n                //Normalization\n                if(sum > 0.0f) {\n                    Arrayf::div(tmpDst, dst->channels, sum);\n                } else {\n                    float *base = (*edge)(i, j, m);\n                    Arrayf::assign(base, dst->channels, tmpDst);\n                }\n            }\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_BILATERAL_1D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_bilateral_2das.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_BILATERAL_2DAS_HPP\n#define PIC_FILTERING_FILTER_BILATERAL_2DAS_HPP\n\n#include <random>\n\n#include \"../base.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../util/precomputed_gaussian.hpp\"\n#include \"../filtering/filter_sampling_map.hpp\"\n#include \"../point_samplers/sampler_random_m.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterBilateral2DAS class\n */\nclass FilterBilateral2DAS: public Filter\n{\nprotected:\n    float sigma_s, sigma_r, sigma_r_sq_2;\n    PrecomputedGaussian *pg;\n    ImageSamplerBilinear isb;\n    int seed;\n    Image *samplingMap;\n\n    MRSamplers<2> *ms;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n    /**\n     * @brief FilterBilateral2DAS\n     */\n    FilterBilateral2DAS();\n\n    /**\n     * @brief FilterBilateral2DAS\n     * @param type\n     * @param sigma_s\n     * @param sigma_r\n     * @param mult\n     */\n    FilterBilateral2DAS(float sigma_s, float sigma_r, int mult, SAMPLER_TYPE type);\n\n    ~FilterBilateral2DAS();\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_r\n     * @param mult\n     * @param type\n     */\n    void update(float sigma_s, float sigma_r, int mult, SAMPLER_TYPE type);\n\n    /**\n     * @brief setupAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *setupAux(ImageVec imgIn, Image *imgOut)\n    {\n        FilterSamplingMap fsm(sigma_s);\n\n        samplingMap = fsm.Process(imgIn, samplingMap);\n        float maxVal;\n        samplingMap->getMaxVal(NULL, &maxVal);\n        *samplingMap /= maxVal;\n\n        return allocateOutputMemory(imgIn, imgOut, bDelete);\n    }\n\n    /**\n     * @brief Signature\n     * @return\n     */\n    std::string signature()\n    {\n        return genBilString(\"AS\", sigma_s, sigma_r);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma_s\n     * @param sigma_r\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float sigma_s, float sigma_r)\n    {\n        FilterBilateral2DAS flt(sigma_s, sigma_r, 1, ST_DARTTHROWING);\n        imgOut = flt.Process(Single(imgIn), imgOut);\n        return imgOut;\n    }\n};\n\nPIC_INLINE FilterBilateral2DAS::FilterBilateral2DAS() : Filter()\n{\n    seed = 1;\n    pg = NULL;\n    ms = NULL;\n    samplingMap = NULL;\n}\n\nPIC_INLINE FilterBilateral2DAS::FilterBilateral2DAS(float sigma_s,\n        float sigma_r, int mult = 1, SAMPLER_TYPE type = ST_BRIDSON) : Filter()\n{\n    seed = 1;\n    pg = NULL;\n    ms = NULL;\n    samplingMap = NULL;\n\n    update(sigma_s, sigma_r, mult, type);\n}\n\nPIC_INLINE FilterBilateral2DAS::~FilterBilateral2DAS()\n{\n    pg = delete_s(pg);\n    ms = delete_s(ms);\n    samplingMap = delete_s(samplingMap);\n}\n\nPIC_INLINE void FilterBilateral2DAS::update(float sigma_s,\n        float sigma_r, int mult = 1, SAMPLER_TYPE type = ST_BRIDSON)\n{\n    //protected values are assigned/computed\n    this->sigma_s = sigma_s > 0.0f ? sigma_s : 1.0f;\n    this->sigma_r = sigma_r > 0.0f ? sigma_r : 0.01f;\n    this->sigma_r_sq_2 = this->sigma_r * this->sigma_r * 2.0f;\n\n    //precompute the Gaussian Kernel\n    pg = delete_s(pg);\n    pg = new PrecomputedGaussian(sigma_s);\n\n    //Poisson samples\n    Vec2i window = Vec2i(pg->halfKernelSize, pg->halfKernelSize);\n\n    ms = delete_s(ms);\n    if(mult > 0) {\n        ms = new MRSamplers<2>(type, window, pg->halfKernelSize * mult, 3, 64);\n    } else if(mult < 0) {\n        mult = -mult;\n        ms = new MRSamplers<2>(type, window, pg->halfKernelSize / mult, 3, 64);\n    }\n\n    seed = 1;\n}\n\nPIC_INLINE void FilterBilateral2DAS::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n    int channels = dst->channels;\n\n    //filter\n    Image *edge, *base;\n\n    switch(src.size()) {\n        case 1: {\n            base = src[0];\n            edge = src[0];\n        } break;\n\n        default: {\n            base = src[0];\n            edge = src[1];\n        } break;\n\n    }\n\n    RandomSampler<2> *ps;\n    float valOut;\n\n    //Mersenne Twister\n    std::mt19937 m(seed);\n\n    for(int i = box->y0; i < box->y1; i++) {\n        float x = float(i) / dst->heightf;\n\n        for(int j = box->x0; j < box->x1; j++) {\n\n            //convolve with the kernel\n            float *dst_data = (*dst)(j, i);\n            float *edge_data = (*edge)(j, i);\n\n            Arrayf::assign(0.0f, dst_data, channels);\n\n            ps = ms->getSampler(&m);\n\n            //calculate the number of samples\n            float y = float(j) / dst->widthf;\n            isb.SampleImage(samplingMap, x, y, &valOut);\n\n            float tmpValOut = 1.0f - valOut; //+valOut[1]+valOut[2])/3.0f;\n            float levelVal = CLAMPi(tmpValOut, 0.0f, 0.9f) * float(ps->levelsR.size());\n\n            int levelInt = int(floorf(levelVal));\n            int nSamples = ps->levelsR[levelInt];\n\n            int levelsRsize = int(ps->levelsR.size()) - 1;\n            if(levelInt < levelsRsize) {\n                if((levelVal - float(levelInt)) > 0.0f) {\n                    nSamples += int(float(ps->levelsR[levelInt + 1] - ps->levelsR[levelInt]) *\n                                (levelVal - float(levelInt)));\n                }\n            }\n\n            if((nSamples % 2) == 1) {\n                nSamples++;\n            }\n\n            nSamples = MIN(nSamples, pg->halfKernelSize * pg->halfKernelSize * 2);\n\n            float sum = 0.0f;\n            for(int k = 0; k < nSamples; k += 2) {\n                //fetch addresses\n                int cj = j + ps->samplesR[k    ];\n                int ci = i + ps->samplesR[k + 1];\n\n                //\n                //Spatial Gaussian kernel\n                //\n                float G1 = pg->coeff[ps->samplesR[k    ] + pg->halfKernelSize] *\n                           pg->coeff[ps->samplesR[k + 1] + pg->halfKernelSize];\n\n\n                float *cur_edge = (*edge)(cj, ci);\n\n                //\n                //Range Gaussian Kernel\n                //\n                float tmp = Arrayf::distanceSq(cur_edge, edge_data, channels);\n                float G2 = expf(-tmp / sigma_r_sq_2);\n\n                //Weight\n                float weight = G1 * G2;\n                sum += weight;\n\n                //filter\n                float *base_data_ci_cj = (*base)(cj, ci);\n\n                for(int l = 0; l < channels; l++) {\n                    dst_data[l] += base_data_ci_cj[l] * weight;\n                }\n            }\n\n            //normalization\n            if(sum > 0.0f) {\n                Arrayf::div(dst_data, channels, sum);\n            } else {\n                float *base_data = (*base)(j, i);\n                Arrayf::assign(base_data, channels, dst_data);\n            }\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_BILATERAL_2DAS_HPP */\n"
  },
  {
    "path": "include/filtering/filter_bilateral_2df.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_BILATERAL_2DF_HPP\n#define PIC_FILTERING_FILTER_BILATERAL_2DF_HPP\n\n#include \"../base.hpp\"\n\n#include \"../util/std_util.hpp\"\n\n#include \"../util/array.hpp\"\n\n#include \"../util/precomputed_gaussian.hpp\"\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterBilateral2DF class\n */\nclass FilterBilateral2DF: public Filter\n{\nprotected:\n    float sigma_s, sigma_r, sigma_r_sq_2;\n\n    PrecomputedGaussian *pg;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n    /**\n     * @brief FilterBilateral2DF\n     */\n    FilterBilateral2DF();\n\n    /**\n     * @brief FilterBilateral2DF\n     * @param sigma_s\n     * @param sigma_r\n     */\n    FilterBilateral2DF(float sigma_s, float sigma_r);\n\n    ~FilterBilateral2DF();\n\n    /**\n     * @brief signature\n     * @return\n     */\n    std::string signature()\n    {\n        return genBilString(\"F\", sigma_s, sigma_r);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma_s\n     * @param sigma_r\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut,\n                             float sigma_s, float sigma_r)\n    {\n        //filter\n        FilterBilateral2DF filter(sigma_s, sigma_r);\n        Image *out = filter.Process(Single(imgIn), imgOut);\n        return out;\n    }\n};\n\nPIC_INLINE FilterBilateral2DF::FilterBilateral2DF() : Filter()\n{\n    pg = NULL;\n}\n\nPIC_INLINE FilterBilateral2DF::FilterBilateral2DF(float sigma_s, float sigma_r) : Filter()\n{\n    //protected values are assigned/computed\n    this->sigma_s = sigma_s > 0.0f ? sigma_s : 1.0f;\n    this->sigma_r = sigma_r > 0.0f ? sigma_r : 0.01f;\n    this->sigma_r_sq_2 = this->sigma_r * this->sigma_r * 2.0f;\n\n    //Precomputation of the Gaussian filter\n    pg = new PrecomputedGaussian(sigma_s);\n}\n\nPIC_INLINE FilterBilateral2DF::~FilterBilateral2DF()\n{\n    pg = delete_s(pg);\n}\n\nPIC_INLINE void FilterBilateral2DF::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n    int channels = dst->channels;\n\n    //Filtering\n    Image *edge, *base;\n\n    if(src.size() > 1) {\n        //Joint/Cross Bilateral Filtering\n        base = src[0];\n        edge = src[1];\n    } else {\n        base = src[0];\n        edge = src[0];\n    }\n\n    for(int j = box->y0; j < box->y1; j++) {\n        for(int i = box->x0; i < box->x1; i++) {\n            //Convolution kernel\n            float *dst_data = (*dst)(i, j);\n\n            float *data_edge = (*edge)(i, j);\n\n            Arrayf::assign(0.0f, dst_data, channels);\n\n            float sum = 0.0f;\n            for(int k = 0; k < pg->kernelSize; k++) {\n                int cj = j + k - pg->halfKernelSize;\n\n                for(int l = 0; l < pg->kernelSize; l++) {\n                    int ci = i + l - pg->halfKernelSize;\n\n                    //Spatial weight\n                    float G1 = pg->coeff[k] * pg->coeff[l];\n\n                    //Range weight\n                    float *cur_edge = (*edge)(ci, cj);\n\n                    float tmp = Arrayf::distanceSq(data_edge, cur_edge, edge->channels);\n                    float G2 = expf(-tmp / sigma_r_sq_2);\n\n                    //Weight\n                    float weight = G1 * G2;\n\n                    //filter\n                    float *base_data_cur = (*base)(ci, cj);\n\n                    for(int m = 0; m < channels; m++) {\n                        dst_data[m] += base_data_cur[m] * weight;\n                    }\n\n                    sum += weight;\n                }\n            }\n\n            //normalization\n            if(sum > 0.0f) {\n                Arrayf::div(dst_data, channels, sum);\n            } else {\n                float *base_data = (*base)(i, j);\n                Arrayf::assign(base_data, channels, dst_data);\n            }\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_BILATERAL_2DF_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_bilateral_2dg.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_BILATERAL_2DG_HPP\n#define PIC_FILTERING_FILTER_BILATERAL_2DG_HPP\n\n//#define BILATERAL_GRID_MULTI_PASS\n\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_gaussian_3d.hpp\"\n#include \"../image_samplers/image_sampler_bilinear.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterBilateral2DG class\n */\nclass FilterBilateral2DG: public Filter\n{\nprotected:\n    ImageSamplerBilinear isb;\n    FilterGaussian3D *fltG;\n    int width, height, range;\n    float sigma_s, sigma_r;\n\n    Image *grid, *gridBlur;\n    bool parallel;\n\n    /**\n     * @brief Splat splats values into the grid.\n     * @param base\n     * @param edge\n     * @param channel\n     * @return\n     */\n    Image *Splat(Image *base, Image *edge, int channel);\n\n    /**\n     * @brief Slice slices the grid into the output image\n     * @param out\n     * @param base\n     * @param edge\n     * @param channels\n     */\n    void Slice(Image *out, Image *base, Image *edge, int channels);\n\npublic:\n\n    /**\n     * @brief FilterBilateral2DG\n     * @param sigma_s\n     * @param sigma_r\n     */\n    FilterBilateral2DG(float sigma_s, float sigma_r);\n\n    ~FilterBilateral2DG();\n\n    float s_S, s_R, mul_E;\n\n    /**\n     * @brief Signature\n     * @return\n     */\n    std::string signature()\n    {\n        return genBilString(\"G\", sigma_s, sigma_r);\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut);\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma_s\n     * @param sigma_r\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float sigma_s,\n                             float sigma_r)\n    {\n        FilterBilateral2DG filter(sigma_s, sigma_r);\n\n        //long t0 = timeGetTime();\n\n        imgOut = filter.Process(Single(imgIn), NULL); //Filtering\n\n        //long t1 = timeGetTime();\n        //printf(\"Bilateral Grid Filter time: %f\\n\", float(t1 - t0) / 1000.0f);\n\n        return imgOut;\n    }\n};\n\nPIC_INLINE FilterBilateral2DG::FilterBilateral2DG(float sigma_s, float sigma_r) : Filter()\n{\n    //protected values are assigned/computed\n    this->sigma_s = sigma_s;\n    this->sigma_r = sigma_r;\n\n    parallel = false;\n\n    grid = NULL;\n    gridBlur = NULL;\n\n    fltG = new FilterGaussian3D(1.0f);\n}\n\nPIC_INLINE FilterBilateral2DG::~FilterBilateral2DG()\n{\n    delete_s(grid);\n    delete_s(gridBlur);\n    delete_s(fltG);\n}\n\nPIC_INLINE Image *FilterBilateral2DG::Splat(Image *base, Image *edge, int channels)\n{\n    if(grid == NULL) {\n        #ifdef PIC_DEBUG\n            printf(\"S Rate: %f R Rate: %f Mul E: %f\\n\", s_S, s_R, mul_E);\n        #endif\n\n        width =  int(ceilf(float(base->width) * s_S));\n        height = int(ceilf(float(base->height) * s_S));\n        range =  int(ceilf(s_R));\n\n        #ifdef PIC_DEBUG\n            printf(\"Grid Size: %d %d %d\\n\", width, height, range);\n        #endif\n\n#ifdef PIC_BILATERAL_GRID_MULTI_PASS\n        #ifdef PIC_DEBUG\n        printf(\"Grid - Memory Mb: %3.2f\\n\",\n               float(width + 1)*float(height + 1)*float(range + 1) * 8.0f /\n               (1024.0f * 1024.0f));\n        #endif\n\n        grid = new Image(range + 1, width + 1, height + 1, 2);\n        gridBlur = new Image(range + 1, width + 1, height + 1, 2);\n#else\n        #ifdef PIC_DEBUG\n        printf(\"Grid - Memory Mb: %3.2f\\n\",\n               float(width + 1)*float(height + 1)*float(range + 1) * 16.0f /\n               (1024.0f * 1024.0f));\n        #endif\n\n        grid = new Image(range + 1, width + 1, height + 1, base->channels + 1);\n        gridBlur = new Image(range + 1, width + 1, height + 1, base->channels + 1);\n#endif\n    }\n\n    grid->setZero();\n\n    for(int j = 0; j < base->height; j++) {\n        int y = int(lround(float(j) * s_S));\n\n        for(int i = 0; i < base->width; i++) {\n\n            int ind = i * base->xstride + j * base->ystride;\n\n#ifdef PIC_BILATERAL_GRID_MULTI_PASS\n            float E = edge->data[ind + channel];\n#else\n            float E = 0.0f;\n\n            for(int k = 0; k < edge->channels; k++) {\n                E += edge->data[ind + k];\n            }\n\n#endif\n            E *= mul_E;\n\n            int x = int(lround(float(i) * s_S));\n            int r = int(lround(E));\n\n            int grdInd = x * grid->xstride + y * grid->ystride + r * grid->tstride;\n\n#ifdef PIC_BILATERAL_GRID_MULTI_PASS\n            grid->data[grdInd + 0] += base->data[ind + channels];\n            grid->data[grdInd + 1] += 1.0f;\n#else\n\n            for(int k = 0; k < base->channels; k++) {\n                grid->data[grdInd + k] += base->data[ind + k];\n            }\n\n            grid->data[grdInd + base->channels] += 1.0f;\t//Counter\n#endif\n        }\n    }\n    return grid;\n}\n\nPIC_INLINE void FilterBilateral2DG::Slice(Image *out, Image *base, Image *edge,\n                               int channels)\n{\n    float widthf = float(grid->width);\n    float heightf = float(grid->height);\n    float rangef = float(grid->frames);\n\n#ifdef PIC_BILATERAL_GRID_MULTI_PASS\n    float vOut[2];\n#else\n    float *vOut = new float [out->channels + 1];\n#endif\n\n    for(int j = 0; j < out->height; j++) {\n        for(int i = 0; i < out->width; i++) {\n            int ind = i * out->xstride + j * out->ystride;\n\n            float x = float(i) * s_S;\n            float y = float(j) * s_S;\n\n#ifdef PIC_BILATERAL_GRID_MULTI_PASS\n            float E = edge->data[ind + channels];\n#else\n            float E = Arrayf::sum(&edge->data[ind], out->channels);\n\n#endif\n            E *= mul_E;\n\n            //Trilinear filtering\n            isb.SampleImage(gridBlur, x / widthf, y / heightf, E / rangef, vOut);\n\n#ifdef PIC_BILATERAL_GRID_MULTI_PASS\n\n            if(vOut[1] > 0.0f) {\n                out->data[ind + channels] = vOut[0] / vOut[1];\n            } else {\n                out->data[ind + channels] = 0.0f;\n            }\n\n#else\n            if(vOut[out->channels] > 0.0f) {\n                for(int k = 0; k < out->channels; k++) {\n                    out->data[ind + k] = vOut[k] / vOut[out->channels];\n                }\n            } else {\n                Arrayf::assign(0.0f, &out->data[ind], out->channels);\n            }\n\n#endif\n        }\n    }\n}\n\nPIC_INLINE Image *FilterBilateral2DG::Process(ImageVec imgIn, Image *imgOut)\n{\n    if(!checkInput(imgIn)) {\n        return imgOut;\n    }\n\n    imgOut = setupAux(imgIn, imgOut);\n\n    if(imgOut == NULL) {\n        return imgOut;\n    }\n\n    Image *base, *edge;\n\n    base = imgIn[0];\n\n    int ind;\n    float *baseMaxmaxVal = base->getMaxVal(NULL, NULL);\n    float maxVal = Arrayf::getMax(baseMaxmaxVal, base->channels, ind);\n    delete[] baseMaxmaxVal;\n\n    if(imgIn.size() == 2) {\n        edge = imgIn[1];\n\n        float *edgeMaxVal = edge->getMaxVal(NULL, NULL);\n\n        maxVal = MAX(maxVal, Arrayf::getMax(edgeMaxVal, edge->channels, ind));\n\n        delete[] edgeMaxVal;\n\n        *edge /= maxVal;\n    } else {\n        edge = imgIn[0];\n    }\n\n    //Range in [0,1]\n    *base /= maxVal;\n    float tmpSigma_r = sigma_r;\n    sigma_r /= maxVal;\n\n    //Grid's Initialization\n    s_S = 1.0f / sigma_s;\t//Spatial Sampling rate\n    s_R = 1.0f / sigma_r; //Range Sampling rate\n\n#ifdef PIC_BILATERAL_GRID_MULTI_PASS\n    int n = imgIn[0]->channels;\n    mul_E = s_R;\n#else\n    int n = 1;\n    mul_E = s_R / float(imgIn[0]->channels);\n#endif\n\n    for(int i = 0; i < n; i++) {\n        //splat\n        Splat(base, edge, i);\n\n        //blur\n        fltG->Process(Single(grid), gridBlur);\n\n        //slice\n        Slice(imgOut, base, edge, i);\n    }\n\n    *imgOut *= maxVal;\n    sigma_r = tmpSigma_r;\n\n    return imgOut;\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_BILATERAL_2DG_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_bilateral_2ds.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_BILATERAL_2DS_HPP\n#define PIC_FILTERING_FILTER_BILATERAL_2DS_HPP\n\n#include <random>\n\n#include \"../base.hpp\"\n#include \"../util/string.hpp\"\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter.hpp\"\n#include \"../util/precomputed_gaussian.hpp\"\n#include \"../point_samplers/sampler_random_m.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterBilateral2DS class\n */\nclass FilterBilateral2DS: public Filter\n{\nprotected:\n    float sigma_s, sigma_r, sigma_r_sq_2;\n    PrecomputedGaussian *pg;\n    MRSamplers<2> *ms;\n    int seed;\n    int nSamples;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n\n    /**\n     * @brief FilterBilateral2DS\n     */\n    FilterBilateral2DS()\n    {\n        seed = 1;\n        pg = NULL;\n        ms = NULL;\n    }\n\n    ~FilterBilateral2DS()\n    {\n        delete_s(pg);\n        delete_s(ms);\n    }\n\n    /**\n     * @brief FilterBilateral2DS\n     * @param nameFile\n     * @param sigma_r\n     */\n    FilterBilateral2DS(std::string nameFile, float sigma_r);\n\n    /**\n     * @brief FilterBilateral2DS\n     * @param type\n     * @param sigma_s\n     * @param sigma_r\n     * @param mult\n     */\n    FilterBilateral2DS(float sigma_s, float sigma_r, int mult, SAMPLER_TYPE type);\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_r\n     * @param mult\n     * @param type\n     */\n    void update(float sigma_s, float sigma_r, int mult, SAMPLER_TYPE type);\n\n    /**\n     * @brief signature\n     * @return\n     */\n    std::string signature()\n    {\n        return genBilString(\"S\", sigma_s, sigma_r);\n    }\n\n    /**\n     * @brief Write\n     * @param filename\n     * @return\n     */\n    bool Write(std::string filename);\n\n    /**\n     * @brief Read\n     * @param filename\n     * @return\n     */\n    bool Read(std::string filename);\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param sigma_s\n     * @param sigma_r\n     * @return\n     */\n    static Image *execute(Image *imgIn,\n                             float sigma_s, float sigma_r)\n    {\n        //create the filter\n        FilterBilateral2DS filter(sigma_s, sigma_r, 1, ST_BRIDSON);\n        //filter\n        Image *imgOut = filter.Process(Single(imgIn), NULL);\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgEdge\n     * @param sigma_s\n     * @param sigma_r\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgEdge,\n                             float sigma_s, float sigma_r)\n    {\n        FilterBilateral2DS filter(sigma_s, sigma_r, 1, ST_BRIDSON);\n        Image *imgOut;\n\n        if(imgEdge == NULL) {\n            imgOut = filter.Process(Single(imgIn), NULL);\n        } else {\n            imgOut = filter.Process(Double(imgIn, imgEdge), NULL);\n        }\n        return imgOut;\n    }\n\n    /**\n     * @brief getK\n     * @param kernelSize\n     * @return\n     */\n    static inline float getK(int kernelSize)\n    {\n        //\tfloat ret = 0.9577f/(0.6466f*float(kernelSize)-0.9175f)+0.4505;\n        float ret = 0.4055f / (0.6437f * float(kernelSize) - 1.1083f) + 0.7347f;\n        ret = (ret > 0.0f) ? ret : 3.0f;\n\n        return ret;\n    }\n\n    /**\n     * @brief getK2\n     * @param kernelSize\n     * @return\n     */\n    static inline float getK2(int kernelSize)\n    {\n        float ret = 0.3233f / (0.5053f * float(kernelSize) - 0.8272f) + 0.7366f;\n        ret = (ret > 0.0f) ? ret : 2.5f;\n        return ret;\n    }\n\n    /**precomputeKernels\n     * @brief PrecomputedKernels\n     */\n    static void precomputeKernels()\n    {\n        for(int i = 0; i < 6; i++) {\n            float sigma_s = powf(2.0f, float(i));\n\n            int nSamples = PrecomputedGaussian::getKernelSize(sigma_s);\n            int nSamplesDiv2  = nSamples / 2;\n            int nMaxSamples = nSamplesDiv2 * nSamplesDiv2;\n            int oldNSamples = -1;\n\n            printf(\"Compute kernel sigma_s: %f\\n\", sigma_s);\n\n            for(int j = 1; j <= 16; j++) {\n                printf(\"Multiplier: %d\\n\", j);\n                nSamples = MIN((nSamplesDiv2 * j), nMaxSamples);\n\n                if(nSamples == oldNSamples) {\n                    break;\n                }\n\n                FilterBilateral2DS f2DS(sigma_s, 0.01f, j, ST_BRIDSON);\n                f2DS.Write(\"kernel_\" + fromNumberToString(sigma_s) + \"_\" + fromNumberToString(j) + \".txt\");\n                oldNSamples = nSamples;\n            }\n        }\n    }\n};\n\nPIC_INLINE FilterBilateral2DS::FilterBilateral2DS(std::string nameFile,\n        float sigma_r) : Filter()\n{\n    ms = NULL;\n    pg = NULL;\n    Read(nameFile);\n    this->sigma_r = sigma_r;\n}\n\nPIC_INLINE FilterBilateral2DS::FilterBilateral2DS(\n        float sigma_s, float sigma_r, int mult = 1, SAMPLER_TYPE type = ST_BRIDSON) : Filter()\n{\n    pg = NULL;\n    ms = NULL;\n    update(sigma_s, sigma_r, mult, type);\n}\n\nPIC_INLINE void FilterBilateral2DS::update( float sigma_s,\n        float sigma_r, int mult = 1, SAMPLER_TYPE type = ST_BRIDSON)\n{\n    //protected values are assigned/computed\n    this->sigma_s = sigma_s > 0.0f ? sigma_s : 1.0f;\n    this->sigma_r = sigma_r > 0.0f ? sigma_r : 0.01f;\n    this->sigma_r_sq_2 = this->sigma_r * this->sigma_r * 2.0f;\n\n    //Precomputation of the Gaussian Kernel\n    pg = delete_s(pg);\n    pg = new PrecomputedGaussian(sigma_s);//, sigma_r);\n\n    //Poisson samples\n    int nMaxSamples = pg->halfKernelSize * pg->halfKernelSize;\n\n    int nSamples = int(lround(float(pg->kernelSize)) * getK(int(sigma_s))) * mult;\n\n    nSamples = MIN(nSamples, nMaxSamples);\n    //\tnSamples = MIN(\t(pg->halfKernelSize*mult), nMaxSamples);\n\n#ifdef PIC_DEBUG\n    printf(\"Nsamples: %d %f\\n\", nSamples, sigma_s);\n#endif\n\n    Vec2i window = Vec2i(pg->halfKernelSize, pg->halfKernelSize);\n\n    ms = delete_s(ms);\n    ms = new MRSamplers<2>(type, window, nSamples, 1, 64);\n\n    seed = 1;\n}\n\nPIC_INLINE void FilterBilateral2DS::ProcessBBox(Image *dst, ImageVec src,\n        BBox *box)\n{\n    Image *edge, *base;\n\n    switch(src.size()) {\n    //cross bilateral filter\n    case 2:\n        base = src[0];\n        edge = src[1];\n        break;\n\n    default:\n        base = src[0];\n        edge = src[0];\n    }\n\n    int channels = dst->channels;\n    int edgeChannels = edge->channels;\n\n    //Mersenne Twister\n    std::mt19937 m(seed);\n\n    for(int j = box->y0; j < box->y1; j++) {\n        for(int i = box->x0; i < box->x1; i++) {\n            float *dst_data  = (*dst )(i, j);\n            float *edge_data = (*edge)(i, j);\n\n            Array<float>::assign(0.0f, dst_data, channels);\n\n            RandomSampler<2> *ps = ms->getSampler(&m);\n            int nSamples = int(ps->samplesR.size());\n\n            float sum = 0.0f;\n            for(int k = 0; k < nSamples; k += 2) {\n                //fetch addresses\n                int ci = i + ps->samplesR[k    ];\n                int cj = j + ps->samplesR[k + 1];\n\n                //\n                //fetch the precomputed Spatial Gaussian kernel\n                //\n                float G1 = pg->coeff[ps->samplesR[k    ] + pg->halfKernelSize] *\n                           pg->coeff[ps->samplesR[k + 1] + pg->halfKernelSize];\n\n                float *edge_data_ci_cj = (*edge)(ci, cj);\n\n                //\n                //compute the Range Gaussian kernel\n                //\n                float acc_delta_range_sq = Arrayf::distanceSq(edge_data_ci_cj, edge_data, edgeChannels);\n\n                float G2 = exp(-acc_delta_range_sq / sigma_r_sq_2);\n\n                //\n                //compute the final weight\n                //\n                float weight = G1 * G2;\n                sum += weight;\n\n                float *base_data_ci_cj = (*base)(ci, cj);\n\n                //filter\n                for(int l = 0; l < channels; l++) {\n                    dst_data[l] += base_data_ci_cj[l] * weight;\n                }\n            }\n\n            //normalization\n            if(sum > 0.0f) {\n                Arrayf::div(dst_data, channels, sum);\n            } else {\n                float *base_data = (*base)(i, j);\n                Arrayf::assign(base_data, channels, dst_data);\n            }\n\n        }\n    }\n}\n\nPIC_INLINE bool FilterBilateral2DS::Write(std::string nameFile)\n{\n    //TODO: add the writing of (sigms_s, sigma_r)\n    return ms->Write(nameFile);\n}\n\nPIC_INLINE bool FilterBilateral2DS::Read(std::string filename)\n{\n    //TODO: add the reading of (sigms_s, sigma_r)\n    //Precomputation of the Gaussian Kernel\n    pg = delete_s(pg);\n    pg = new PrecomputedGaussian(sigma_s);\n\n    ms = delete_s(ms);\n    ms = new MRSamplers<2>();\n    return ms->Read(filename);\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_BILATERAL_2DS_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_bilateral_2dsp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_BILATERAL_2DSP_HPP\n#define PIC_FILTERING_FILTER_BILATERAL_2DSP_HPP\n\n#include \"../util/std_util.hpp\"\n#include \"../filtering/filter_bilateral_1d.hpp\"\n#include \"../filtering/filter_npasses.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterBilateral2DSP class\n */\nclass FilterBilateral2DSP: public FilterNPasses\n{\nprotected:\n    FilterBilateral1D *bilateralFilter;\n\npublic:\n    /**\n     * @brief FilterBilateral2DSP\n     * @param sigma_s\n     * @param sigma_r\n     */\n    FilterBilateral2DSP(float sigma_s, float sigma_r) : FilterNPasses()\n    {\n        bilateralFilter = new FilterBilateral1D(sigma_s, sigma_r);\n\n        insertFilter(bilateralFilter);\n        insertFilter(bilateralFilter);\n    }\n\n    ~FilterBilateral2DSP()\n    {\n        release();\n        delete_s(bilateralFilter);\n    }\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_r\n     */\n    void update(float sigma_s, float sigma_r)\n    {\n        bilateralFilter->update(sigma_s, sigma_r);\n    }\n    \n    /**\n     * @brief signature\n     * @return\n     */\n    std::string signature()\n    {\n        return genBilString(\"SP\", bilateralFilter->sigma_s, bilateralFilter->sigma_r);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma_s\n     * @param sigma_r\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float sigma_s,\n                             float sigma_r)\n    {\n        FilterBilateral2DSP filter(sigma_s, sigma_r);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_BILATERAL_2DSP_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_channel.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_CHANNEL_HPP\n#define PIC_FILTERING_FILTER_CHANNEL_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief SingleInt\n * @param v0\n * @return\n */\nPIC_INLINE std::vector<int> SingleInt(int v0)\n{\n    std::vector<int> ret;\n    ret.push_back(MAX(v0, 0));\n    return ret;\n}\n\n/**\n * @brief TripleInt\n * @param v0\n * @param v1\n * @param v2\n * @return\n */\nPIC_INLINE std::vector<int> TripleInt(int v0, int v1, int v2)\n{\n    std::vector<int> ret;\n    ret.push_back(MAX(v0, 0));\n    ret.push_back(MAX(v1, 0));\n    ret.push_back(MAX(v2, 0));\n    return ret;\n}\n\n/**\n * @brief The FilterChannel class\n */\nclass FilterChannel: public Filter\n{\nprotected:\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        int totChannels =  CLAMPi(int(channels_vec.size()), 0, src[0]->channels);\n\n        for(int p = box->z0; p < box->z1; p++) {\n            for(int j = box->y0; j < box->y1; j++) {\n                for(int i = box->x0; i < box->x1; i++) {\n\n                    float *dataOut = (*dst)(i, j, p);\n                    float *dataIn = (*src[0])(i, j, p);\n\n                    for(int k = 0; k < totChannels; k++) {\n                        int index = channels_vec[k];\n                        dataOut[k] = dataIn[index];\n                    }\n                }\n            }\n        }\n    }\n\n    std::vector<int> channels_vec;\n\npublic:\n\n    /**\n     * @brief FilterChannel\n     * @param channels_vec\n     */\n    FilterChannel(std::vector<int> channels_vec) : Filter()\n    {\n        update(channels_vec);\n    }\n\n    /**\n     * @brief update\n     * @param channels_vec\n     */\n    void update(std::vector<int> channels_vec)\n    {\n        this->channels_vec = channels_vec;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = MAX(1, int(this->channels_vec.size()));\n        frames      = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param channel\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, int channel = 0)\n    {\n        FilterChannel fltCh(SingleInt(channel));\n        return fltCh.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param channel\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, std::vector<int> channels_vec)\n    {\n        FilterChannel fltCh(channels_vec);\n        return fltCh.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief removeAlpha\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *removeAlpha(Image *imgIn, Image *imgOut)\n    {\n        imgOut = execute(imgIn, imgOut, TripleInt(0, 1, 2));\n        return imgOut;\n    }\n\n    /**\n     * @brief test\n     */\n    static void test()\n    {\n        Image imgIn(1, 512, 512, 3);\n        imgIn = 1.0f;\n\n        Image *outR = execute(&imgIn, NULL, SingleInt(0));\n        Image *outG = execute(&imgIn, NULL, SingleInt(1));\n        Image *outB = execute(&imgIn, NULL, SingleInt(2));\n\n        outR->Write(\"channel_R.pfm\");\n        outG->Write(\"channel_G.pfm\");\n        outB->Write(\"channel_B.pfm\");\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_CHANNEL_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_clahe.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_CLAHE_HPP\n#define PIC_FILTERING_FILTER_CLAHE_HPP\n\n#include \"../base.hpp\"\n#include \"../histogram.hpp\"\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilerCLAHE class\n */\nclass FilerCLAHE: public Filter\n{\nprotected:\n    int halfSize, nBin;\n    uint value;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        Histogram hist, hist_uni;\n        hist_uni.uniform(0.0f,\n                         1.0f,\n                         value, VS_LIN, nBin);\n        float *c_t = hist_uni.cumulativef(true);\n        int channels = src[0]->channels;\n\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *in  = (*src[0]) (i, j);\n                float *out = (*dst) (i, j);\n\n                BBox box_ij(i - halfSize, i + halfSize, j - halfSize, j + halfSize);\n\n                for(int ch = 0; ch < channels; ch++) {\n                    hist.calculate(src[0], VS_LIN, nBin, &box_ij, ch);\n                    float *c_s = hist.cumulativef(true);\n\n                    hist_uni.update(hist.getfMin(), hist.getfMax());\n\n                    int ind_source = hist.project(in[ch]);\n\n                    float x = c_s[ind_source];\n                    float *ptr = std::upper_bound(c_t, c_t + nBin, x);\n                    int ind_target = MAX((int)(ptr - c_t), 0);\n\n                    out[ch] = hist_uni.unproject(ind_target);\n                }\n            }\n        }\n    }\n\npublic:\n    /**\n     * @brief FilerCLAHE\n     * @param size\n     */\n    FilerCLAHE(int size) : Filter()\n    {\n        update(size);\n    }\n\n    /**\n     * @brief update\n     * @param size\n     */\n    void update(int size)\n    {\n        this->halfSize = checkHalfSize(size);\n        this->nBin = 1024;//size;\n\n        uint area = halfSize * halfSize;\n        this->value = MAX(area / nBin, 1);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param size\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, int size)\n    {\n        FilerCLAHE filter(size);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_CLAHE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_color_conv.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_COLOR_CONV_HPP\n#define PIC_FILTERING_FILTER_COLOR_CONV_HPP\n\n#include \"../filtering/filter.hpp\"\n#include \"../colors/color_conv.hpp\"\n#include \"../colors/color_conv_rgb_to_xyz.hpp\"\n#include \"../colors/color_conv_xyz_to_logluv.hpp\"\n#include \"../colors/color_conv_xyz_to_cielab.hpp\"\n\nnamespace pic {\n\nstruct ColorConvTransform\n{\n    ColorConv *f;\n    bool bDirection;\n};\n\n/**\n * @brief The FilterColorConv class\n */\nclass FilterColorConv: public Filter\n{\nprotected:\n    std::vector<ColorConvTransform> list;\n    bool bDirection;\n    unsigned int n;\n    bool bEven;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        if(n < 1) {\n            return;\n        }\n\n        int channels = src[0]->channels;\n\n        float *tmpCol = new float [channels];\n        float *tmp[2];\n\n        tmp[1] = tmpCol;\n\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *dataIn  = (*src[0])(i, j);\n                float *dataOut = (*dst) (i, j);\n\n                if(bEven) {\n                    tmp[1] = dataOut;\n                    tmp[0] = tmpCol;\n                } else {\n                    tmp[0] = dataOut;\n                    tmp[1] = tmpCol;\n                }\n\n                if(bDirection) { //direct color transform\n                    list[0].f->transform(dataIn, tmp[0], list[0].bDirection);\n                    for(unsigned int k = 1; k < n; k++) {\n                        list[k].f->transform(tmp[(k + 1) % 2], tmp[k % 2], list[k].bDirection);\n                    }\n                } else { //inverse color transform\n                    list[n - 1].f->transform(dataIn, tmp[0], !list[n - 1].bDirection);\n                    for(unsigned int k = 1; k < n; k++) {\n                        list[n - k - 1].f->transform(tmp[(k + 1) % 2], tmp[k % 2], !list[n - k - 1].bDirection);\n                    }\n                }\n            }\n        }\n\n        delete[] tmpCol;\n    }\n\npublic:\n\n    /**\n     * @brief FilterColorConv\n     */\n    FilterColorConv() : Filter()\n    {\n        this->bDirection = true;\n        n = -1;\n    }\n\n    /**\n     * @brief insertColorConv\n     * @param transform\n     * @param bDirection\n     */\n    void insertColorConv(ColorConv *transform, bool bDirection)\n    {\n        if(transform != NULL) {\n            ColorConvTransform entry;\n            entry.f = transform;\n            entry.bDirection = bDirection;\n\n            list.push_back(entry);\n        }\n\n        n = int(list.size());\n        bEven = (n % 2) == 0;\n    }\n\n    /**\n     * @brief update\n     * @param bDirection\n     */\n    void update(bool bDirection)\n    {\n        this->bDirection = bDirection;\n    }\n\n    /**\n     * @brief fromRGBtoXYZ\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *fromRGBtoXYZ(Image *imgIn, Image *imgOut)\n    {\n        ColorConvRGBtoXYZ    cc_from_RGB_to_XYZ;\n\n        FilterColorConv flt;\n\n        flt.insertColorConv(&cc_from_RGB_to_XYZ,    true);\n        return flt.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief fromRGBtoCIELAB\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *fromRGBtoCIELAB(Image *imgIn, Image *imgOut)\n    {\n        ColorConvRGBtoXYZ    cc_from_RGB_to_XYZ;\n        ColorConvXYZtoCIELAB cc_from_XYZ_to_CIELAB;\n\n        FilterColorConv flt;\n\n        flt.insertColorConv(&cc_from_RGB_to_XYZ,    true);\n        flt.insertColorConv(&cc_from_XYZ_to_CIELAB, true);\n\n        return flt.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n    * @brief fromRGBtoLogLuv\n    * @param imgIn\n    * @param imgOut\n    * @return\n    */\n    static Image *fromRGBtoLogLuv(Image *imgIn, Image *imgOut)\n    {\n        ColorConvRGBtoXYZ    cc_from_RGB_to_XYZ;\n        ColorConvXYZtoLogLuv cc_from_XYZ_to_LogLuv;\n\n        FilterColorConv flt;\n\n        flt.insertColorConv(&cc_from_RGB_to_XYZ, true);\n        flt.insertColorConv(&cc_from_XYZ_to_LogLuv, true);\n\n        return flt.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief fromCIELABtoRGB\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *fromCIELABtoRGB(Image *imgIn, Image *imgOut)\n    {\n        ColorConvRGBtoXYZ    cc_from_RGB_to_XYZ;\n        ColorConvXYZtoCIELAB cc_from_XYZ_to_CIELAB;\n\n        FilterColorConv flt;\n\n        flt.insertColorConv(&cc_from_XYZ_to_CIELAB, false);\n        flt.insertColorConv(&cc_from_RGB_to_XYZ,    false);\n\n        return flt.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief fromCIELABtoRGB2\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *fromCIELABtoRGB2(Image *imgIn, Image *imgOut)\n    {\n        ColorConvRGBtoXYZ    cc_from_RGB_to_XYZ;\n        ColorConvXYZtoCIELAB cc_from_XYZ_to_CIELAB;\n\n        FilterColorConv flt;\n\n        flt.insertColorConv(&cc_from_RGB_to_XYZ,    true);\n        flt.insertColorConv(&cc_from_XYZ_to_CIELAB, true);\n\n        flt.update(false);\n\n        return flt.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_COLOR_CONV_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_color_correction_pouli.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_COLOR_CORRECTION_POULI_HPP\n#define PIC_FILTERING_FILTER_COLOR_CORRECTION_POULI_HPP\n\n#include \"../filtering/filter.hpp\"\n#include \"../colors/color_conv_rgb_to_lms.hpp\"\n#include \"../colors/color_conv_lms_to_ipt.hpp\"\n#include \"../colors/color_conv_ipt_to_ich.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterColorCorrectionPouli class\n */\nclass FilterColorCorrectionPouli: public Filter\n{\nprotected:\n    ColorConvRGBtoLMS cLMS;\n    ColorConvLMStoIPT cIPT;\n    ColorConvIPTtoICH cICH;\n    float mHDR, mTMO;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        float ICh_hdr[3];\n        float ICh_tmo[3];\n        float nHDR[3], nTMO[3], tHDR[3], tTMO[3];\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *data_hdr = (*src[0])(i, j);\n                float *data_tmo = (*src[1])(i, j);\n\n                //normalize inputs\n                for(int k = 0; k < 3; k++) {\n                    nHDR[k] = data_hdr[k] / mHDR;\n                    nTMO[k] = data_tmo[k] / mTMO;\n                }\n\n                //RGB --> LMS\n                cLMS.direct(nHDR, tHDR);\n                cLMS.direct(nTMO, tTMO);\n\n                //LMS --> IPT\n                cIPT.direct(tHDR, nHDR);\n                cIPT.direct(tTMO, nTMO);\n\n                //IPT --> ICh\n                cICH.direct(nHDR, ICh_hdr);\n                cICH.direct(nTMO, ICh_tmo);\n\n                float tmp = ICh_tmo[0];\n                ICh_tmo[0] += 1e-5f;\n                ICh_tmo[1] += 1e-5f;\n                ICh_hdr[0] += 1e-5f;\n                ICh_hdr[1] += 1e-5f;\n\n                float C_tmo_prime = ICh_tmo[1] * ICh_hdr[0] / ICh_tmo[0];\n                float s1 = saturation(ICh_hdr[1], ICh_hdr[0]);\n                float s2 = saturation(C_tmo_prime, ICh_tmo[0]);\n\n                ICh_tmo[0] = tmp;\n                ICh_tmo[1] = (C_tmo_prime * s1) / s2;\n                ICh_tmo[2] = ICh_hdr[2];\n\n                //output\n                float *data_dst = (*dst)(i, j);\n\n                cICH.inverse(ICh_tmo, tTMO);\n                cIPT.inverse(tTMO, nTMO);\n                cLMS.inverse(nTMO, data_dst);\n\n                Arrayf::mul(data_dst, 3, mTMO);\n                Arrayf::clamp(data_dst, 3, 0.0f, 1.0f);\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterColorCorrectionPouli\n     */\n    FilterColorCorrectionPouli() : Filter()\n    {\n        minInputImages = 2;\n    }\n\n    void update(float mHDR, float mTMO)\n    {\n        this->mHDR = mHDR;\n        this->mTMO = mTMO;\n    }\n\n    /**\n     * @brief saturation\n     * @param C\n     * @param I\n     * @return\n     */\n    static float saturation(float C, float I)\n    {\n        float sum = C * C + I * I;\n        if(sum > 0.0f) {\n            return C / sqrtf(sum);\n        } else {\n            return -1.0f;\n        }\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param gamma\n     * @param fstop\n     * @return\n     */\n    static Image *execute(Image *imgHDR, Image *imgTMO, Image *imgOut)\n    {\n        if(imgHDR == NULL || imgTMO == NULL) {\n            return imgOut;\n        }\n\n        if(imgHDR->channels != 3 || imgTMO->channels != 3) {\n            return imgOut;\n        }\n\n        float mHDR[3], mTMO[3];\n\n        imgHDR->getMaxVal(NULL, mHDR);\n        imgTMO->getMaxVal(NULL, mTMO);\n\n        int ind;\n        float maxHDR = Arrayf::getMax(mHDR, 3, ind);\n        float maxTMO = Arrayf::getMax(mTMO, 3, ind);\n\n        if(maxHDR > 0.0f && maxTMO > 0.0f) {\n            FilterColorCorrectionPouli filter;\n            filter.update(maxHDR, maxTMO);\n            return filter.Process(Double(imgHDR, imgTMO), imgOut);\n        } else {\n            return imgOut;\n        }\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_COLOR_CORRECTION_POULI_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_color_distance.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_COLOR_DISTANCE_HPP\n#define PIC_FILTERING_FILTER_COLOR_DISTANCE_HPP\n\n#include \"../filtering/filter.hpp\"\n#include \"../util/array.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterColorDistance class\n */\nclass FilterColorDistance: public Filter\n{\nprotected:\n    float *color, sigma, sigma_sq_2;\n\n    /**\n     * @brief f\n     * @param data\n     */\n    void f(FilterFData *data)\n    {\n        float *in = (*data->src[0])(data->x, data->y);\n\n        float sum = Arrayf::distanceSq(in, color, data->dst->channels);\n\n        data->out[0] = expf(- sum / sigma_sq_2);\n    }\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    /*\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        int width = dst->width;\n        int channels = src[0]->channels;\n        float *data = src[0]->data;\n\n        for(int j = box->y0; j < box->y1; j++) {\n            int c = j * width;\n\n            for(int i = box->x0; i < box->x1; i++) {\n                int c1 = (c + i);\n                int c2 = c1 * channels;\n\n                float sum = 0.0f;\n\n                for(int k = 0; k < channels; k++) {\n                    float tmp = data[c2 + k] - color[k];\n                    sum += tmp * tmp;\n                }\n\n                dst->data[c1] = expf(-sum / sigma_sq_2);\n            }\n        }\n    }\n    */\n\npublic:\n\n    /**\n     * @brief FilterColorDistance\n     * @param color\n     * @param sigma\n     */\n    FilterColorDistance(float *color, float sigma) : Filter()\n    {\n        update(color, sigma);\n    }\n\n    /**\n     * @brief update\n     * @param color\n     * @param sigma\n     */\n    void update(float *color, float sigma)\n    {\n        if(color != NULL) {\n            this->color = color;\n        }\n\n        sigma = sigma > 0.0f ? sigma : 1.0f;\n        this->sigma = sigma;\n        sigma_sq_2 = sigma * sigma * 2.0f;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width = imgIn[0]->width;\n        height = imgIn[0]->height;\n        channels = 1;\n        frames = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param color\n     * @param sigma\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float *color,\n                             float sigma)\n    {\n        FilterColorDistance fltColDst(color, sigma);\n        return fltColDst.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_COLOR_DISTANCE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_combine.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_COMBINE_HPP\n#define PIC_FILTERING_FILTER_COMBINE_HPP\n\n#include \"../filtering/filter.hpp\"\n\n#include \"../filtering/filter_channel.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterCombine class\n */\nclass FilterCombine: public Filter\n{\nprotected:\n\n    /**\n     * @brief f\n     * @param data\n     */\n    virtual void f(FilterFData *data)\n    {\n        int k2 = 0;\n\n        for(auto i = 0; i < data->nSrc; i++) {\n            float *tmp_src = (*data->src[i])(data->x, data->y);\n\n            for(int k = 0; k < data->src[i]->channels; k++) {\n                data->out[k2] = tmp_src[k];\n                k2++;\n            }\n        }\n    }\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    /*\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        for(int p = box->z0; p < box->z1; p++) {\n            for(int j = box->y0; j < box->y1; j++) {\n                for(int i = box->x0; i < box->x1; i++) {\n                    int c  = p * dst->tstride + j * dst->ystride + i * dst->xstride;\n                    int k2 = 0;\n\n                    for(unsigned int im = 0; im < src.size(); im++) {\n                        int c2 = p * src[im]->tstride + j * src[im]->ystride + i * src[im]->xstride;\n\n                        for(int k = 0; k < src[im]->channels; k++) {\n                            dst->data[c + k2] = src[im]->data[c2 + k];\n                            k2++;\n                        }\n                    }\n                }\n            }\n        }\n    }*/\n\n    /**\n     * @brief setupAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *setupAux(ImageVec imgIn, Image *imgOut)\n    {\n        int channels = imgIn[0]->channels;\n        for(unsigned int i = 1; i < imgIn.size(); i++) {\n            channels += imgIn[i]->channels;\n\n            if(!imgIn[0]->isSimilarType(imgIn[i])) {\n                return NULL;\n            }\n        }\n\n        if(imgOut == NULL) {\n            imgOut = new Image(imgIn[0]->frames, imgIn[0]->width, imgIn[0]->height,\n                                  channels);\n        } else {\n            bool bAllocate = false;\n            if(!imgOut->isValid()) {\n                bAllocate = true;\n            } else {\n                bAllocate = imgOut->channels != channels;\n            }\n\n            if(bAllocate) {\n                imgOut = new Image(imgIn[0]->frames, imgIn[0]->width, imgIn[0]->height,\n                        channels);\n            }\n        }\n\n        return imgOut;\n    }\n\npublic:\n\n    /**\n     * @brief FilterCombine\n     */\n    FilterCombine() : Filter()\n    {\n\n    }\n\n    /**\n     * @brief addAlpha\n     * @param imgIn\n     * @param imgOut\n     * @param value\n     * @return\n     */\n    static Image *addAlpha(Image *imgIn, Image *imgOut, float value)\n    {\n        //create an alpha channel\n        Image *alpha = new Image(imgIn->frames, imgIn->width, imgIn->height, 1);\n        *alpha = value;\n\n        //add the channel to the image\n        ImageVec src;\n        src.push_back(imgIn);\n        src.push_back(alpha);\n\n        FilterCombine filterC;\n        imgOut = filterC.Process(src, imgOut);\n\n        delete alpha;\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(ImageVec imgIn, Image *imgOut)\n    {\n        FilterCombine filterC;\n        return filterC.Process(imgIn, imgOut);\n    }\n\n    /**\n     * @brief getOnlyRGB\n     * @param nameIn\n     * @param nameOut\n     * @return\n     */\n    static Image *getOnlyRGB(Image *imgIn, Image *imgOut)\n    {\n        ImageVec src;\n        FilterChannel filter(SingleInt(0));\n\n        for(int i = 0; i < 3; i++) {\n            Image *out = filter.Process(Single(imgIn), NULL);\n            src.push_back(out);\n            filter.update(SingleInt(i + 1));\n        }\n\n        imgOut = execute(src, NULL);\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_COMBINE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_conv_1d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_CONV_1D_HPP\n#define PIC_FILTERING_FILTER_CONV_1D_HPP\n\n#include \"../base.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../util/array.hpp\"\n#include \"../filtering/filter.hpp\"\n#include \"../util/precomputed_gaussian.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterConv1D class\n */\nclass FilterConv1D: public Filter\n{\nprotected:\n    int dirs[3];\n    float *data; //NOTE: this an external pointer; NEVER release it!\n    int kernelSize, halfKernelSize;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n\n    /**\n     * @brief FilterConv1D\n     */\n    FilterConv1D();\n\n    /**\n     * @brief FilterConv1D\n     * @param data\n     * @param n\n     * @param direction\n     */\n    FilterConv1D(float *data, int kernelSize, int direction);\n\n    ~FilterConv1D();\n\n    /**\n     * @brief update\n     * @param data\n     * @param n\n     * @param direction\n     */\n    void update(float *data, int kernelSize, int direction);\n\n    /**\n     * @brief changePass\n     * @param pass\n     * @param tPass\n     */\n    void changePass(int pass, int tPass);\n\n    /**\n     * @brief ChangePass\n     * @param x\n     * @param y\n     * @param z\n     */\n    void changePass(int x, int y, int z);\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param data\n     * @param n\n     * @param XorY\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float *data, int n,\n                             bool XorY = true)\n    {\n        FilterConv1D filter(data, n, 0);\n\n        if(XorY) {\n            filter.changePass(1, 0, 0);\n        } else {\n            filter.changePass(0, 1, 0);\n        }\n\n        return filter.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief getKernelMean creates an 1D mean kernel.\n     * @param kernelSize\n     * @return\n     */\n    static float *getKernelMean(int kernelSize)\n    {\n        if(kernelSize < 3) {\n            kernelSize = 3;\n        }\n        \n        if((kernelSize % 2) == 0) {\n            kernelSize++;\n        }\n        \n        float *kernel = new float[kernelSize];\n\n        float val = 1.0f / float(kernelSize);\n\n        for(int i = 0; i < kernelSize; i++) {\n            kernel[i] = val;\n        }\n\n        return kernel;\n    }\n};\n\nPIC_INLINE FilterConv1D::FilterConv1D()\n{\n    kernelSize = 0;\n    halfKernelSize = 0;\n    data = NULL;\n\n    dirs[0] = 0;\n    dirs[1] = 0;\n    dirs[2] = 0;\n}\n\nPIC_INLINE FilterConv1D::FilterConv1D(float *data, int kernelSize, int direction = 0)\n{\n    update(data, kernelSize, direction);\n}\n\nPIC_INLINE FilterConv1D::~FilterConv1D()\n{\n    data = NULL;\n    kernelSize = -1;\n    halfKernelSize = -1;\n}\n\nPIC_INLINE void FilterConv1D::update(float *data, int kernelSize, int direction)\n{\n    if(data == NULL || kernelSize < 1) {\n        return;\n    }\n\n    this->data = data;\n    this->kernelSize = kernelSize;\n\n    this->halfKernelSize = kernelSize >> 1;\n\n    if(direction > 0) {\n        dirs[ direction      % 3] = 1;\n        dirs[(direction + 1) % 3] = 0;\n        dirs[(direction + 2) % 3] = 0;\n    }\n}\n\nPIC_INLINE void FilterConv1D::changePass(int pass, int tPass)\n{\n    int tMod;\n\n    if(tPass > 1) {\n        tMod = 3;\n    } else {\n        if(tPass == 1) {\n            tMod = 2;\n        } else {\n            printf(\"ERROR: FilterConv1D::ChangePass\");\n            return;\n        }\n    }\n\n    dirs[pass % tMod] = 1;\n\n    for(int i = 1; i < tMod; i++) {\n        dirs[(pass + i) % tMod] = 0;\n    }\n    \n    #ifdef PIC_DEBUG\n        printf(\"%d %d %d\\n\",dirs[0],dirs[1],dirs[2]);\n    #endif\n}\n\nPIC_INLINE void FilterConv1D::changePass(int x, int y, int z)\n{\n    dirs[0] = y;\n    dirs[1] = x;\n    dirs[2] = z;\n}\n\nPIC_INLINE void FilterConv1D::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n    Image *source = src[0];\n\n    for(int m = box->z0; m < box->z1; m++) {\n\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n                float *dst_data = (*dst)(i, j, m);\n\n                Arrayf::assign(0.0f, dst_data, dst->channels);\n\n                for(int k = 0; k < kernelSize; k++) { //1D Filtering\n                    int tmpCoord = k - halfKernelSize;\n\n                    //Address cj\n                    int cj = j + tmpCoord * dirs[0];\n                    //Address ci\n                    int ci = i + tmpCoord * dirs[1];\n                    //Address cm\n                    int cm = m + tmpCoord * dirs[2];\n\n                    float *tmpSource = (*source)(ci, cj, cm);\n\n                    for(int l = 0; l < dst->channels; l++) {\n                        dst_data[l] += tmpSource[l] * data[k];\n                    }\n                }\n            }\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_CONV_1D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_conv_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_CONV_2D_HPP\n#define PIC_FILTERING_FILTER_CONV_2D_HPP\n\n#include \"../util/array.hpp\"\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterConv2D class\n */\nclass FilterConv2D: public Filter\n{\nprotected:\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        Image *img  = src[0];\n        Image *conv = src[1];\n\n        int channels = dst->channels;\n\n        int c_w_h = (conv->width >> 1);\n        int c_h_h = (conv->height >> 1);\n\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *dst_data = (*dst)(i, j);\n\n                Arrayf::assign(0.0f, dst_data, channels);\n\n                for(int k = -c_h_h; k <= c_h_h; k++) {\n                    for(int l = -c_w_h; l <= c_w_h; l++) {\n\n                        float *img_data  = (*img)(i + l, j + k);\n                        float *conv_data = (*conv)(l + c_w_h, k + c_h_h);\n\n                        for(int c = 0; c < channels; c++) {\n                            int c2 = c % conv->channels;\n                            dst_data[c] += img_data[c] * conv_data[c2];\n                        }\n                    }\n                }\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterConv2D\n     */\n    FilterConv2D() : Filter()\n    {\n        minInputImages = 2;\n    }\n\n    /**\n     * @brief execute\n     * @param img\n     * @param conv\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *img, Image *conv, Image *imgOut)\n    {\n        FilterConv2D flt;\n        return flt.Process(Double(img, conv), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_CONV_2D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_conv_2dsp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_CONV_2DSP_HPP\n#define PIC_FILTERING_FILTER_CONV_2DSP_HPP\n\n#include \"../filtering/filter_npasses.hpp\"\n#include \"../filtering/filter_conv_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterConv2DSP class\n */\nclass FilterConv2DSP: public FilterNPasses\n{\nprotected:\n    FilterConv1D *conv1DFltX, *conv1DFltY;\n\npublic:\n\n    /**\n     * @brief FilterConv2DSP\n     * @param data\n     * @param n\n     */\n    FilterConv2DSP(float *data, int n)\n    {\n        conv1DFltX = new FilterConv1D(data, n);\n\n        insertFilter(conv1DFltX);\n        insertFilter(conv1DFltX);\n    }\n\n    /**\n     * @brief FilterConv2DSP\n     * @param dataX\n     * @param nX\n     * @param dataY\n     * @param nY\n     */\n    FilterConv2DSP(float *dataX, int nX, float *dataY, int nY) : FilterNPasses()\n    {\n        conv1DFltX = new FilterConv1D(dataX, nX);\n        insertFilter(conv1DFltX);\n\n        conv1DFltY = new FilterConv1D(dataY, nY);\n        insertFilter(conv1DFltY);\n    }\n\n    ~FilterConv2DSP()\n    {\n        release();\n\n        if(conv1DFltX != NULL) {\n            delete conv1DFltX;\n        }\n\n        conv1DFltX = NULL;\n\n        if(conv1DFltY != NULL) {\n            delete conv1DFltY;\n        }\n\n        conv1DFltY = NULL;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param data\n     * @param n\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float *data, int n)\n    {\n        FilterConv2DSP filter(data, n);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_CONV_2DSP_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_conv_sparse.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_CONV_SPARSE_HPP\n#define PIC_FILTERING_FILTER_CONV_SPARSE_HPP\n\n#include \"../util/vec.hpp\"\n#include \"../util/array.hpp\"\n#include \"../filtering/filter.hpp\"\n#include \"../util/precomputed_gaussian.hpp\"\n\nnamespace pic {\n\nstruct SparseKernelPoint\n{\n    Vec<3, int> pos;\n    float value;\n};\n\nclass SparseKernel\n{\npublic:\n    std::vector<SparseKernelPoint> data;\n\n    /**\n     * @brief SparseKernel\n     */\n    SparseKernel()\n    {\n\n    }\n\n    /**\n     * @brief normalize\n     */\n    void normalize()\n    {\n        float sum = 0.0f;\n        for(int i = 0; i < kernel.size(); i++) {\n            sum += kernel[i].value;\n        }\n\n        if(sum > 0.0f) {\n            for(int i = 0; i < kernel.size(); i++) {\n                kernel[i].valu /= sum;\n            }\n        }\n    }\n};\n\n/**\n * @brief The FilterConvSparse class\n */\nclass FilterConvSparse: public Filter\n{\nprotected:\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\n    SparseKernel kernel;\n\npublic:\n\n    /**\n     * @brief FilterConvSparse\n     */\n    FilterConvSparse();\n\n    /**\n     * @brief FilterConvSparse\n     * @param kernel\n     */\n    FilterConvSparse(SparseKernel kernel);\n\n    /**\n     * @brief update\n     * @param kernel\n     */\n    void update(SparseKernel kernel);\n\n    ~FilterConvSparse();\n};\n\nPIC_INLINE FilterConvSparse::FilterConvSparse()\n{\n\n}\n\nPIC_INLINE FilterConvSparse::FilterConvSparse(SparseKernel kernel)\n{\n    update(kernel);\n}\n\nPIC_INLINE void FilterConvSparse::update(SparseKernel kernel)\n{\n    this->kernel = kernel;\n}\n\nPIC_INLINE FilterConvSparse::~FilterConvSparse()\n{\n}\n\nPIC_INLINE void FilterConvSparse::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n    int channels = dst->channels;\n\n    Image *source = src[0];\n\n    for(int m = box->z0; m < box->z1; m++) {\n\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n                float *dataOut = (*dst)(i, j, m);\n\n                Arrayf::assign(0.0f, dataOut, channels);\n\n                for(int k = 0; k < kernel.data.size(); i++) {\n                    float *dataIn = (*source)(i + kernel.data[k].pos[0],\n                                              j + kernel.data[k].pos[1],\n                                              m + kernel.data[k].pos[2]);\n\n                    for(int ch = 0; ch < channels; ch++) {\n                        dataOut[ch] += dataIn[ch] * kernel.data[k].value;\n                    }\n                }\n            }\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_CONV_SPARSE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_crop.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_CROP_HPP\n#define PIC_FILTERING_FILTER_CROP_HPP\n\n#include \"../filtering/filter.hpp\"\n#include \"../util/vec.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterCrop class\n */\nclass FilterCrop: public Filter\n{\nprotected:\n    bool flag;\n    Vec4i mini, maxi;\n    Vec3f minf, maxf;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n\n    /**\n     * @brief FilterCrop\n     * @param min\n     * @param max\n     */\n    FilterCrop(Vec2i min, Vec2i max);\n\n    /**\n     * @brief FilterCrop\n     * @param min\n     * @param max\n     */\n    FilterCrop(Vec3i min, Vec3i max);\n\n    /**\n     * @brief FilterCrop\n     * @param min\n     * @param max\n     */\n    FilterCrop(Vec4i min, Vec4i max);\n\n    /**\n     * @brief FilterCrop\n     * @param min\n     * @param max\n     */\n    FilterCrop(Vec3f min, Vec3f max);\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames);\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param min\n     * @param max\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, Vec4i min,\n                             Vec4i max)\n    {\n        FilterCrop fltCrop(min, max);\n        return fltCrop.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param min\n     * @param max\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, Vec2i min,\n                             Vec2i max)\n    {\n        FilterCrop fltCrop(min, max);\n        return fltCrop.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief test\n     */\n    static void test()\n    {\n        Image img(1, 512, 512, 3);\n        img = 1.0f;\n\n        FilterCrop flt(Vec2i(100, 100), Vec2i(200, 200));\n\n        Image *out = flt.Process(Single(&img), NULL);\n\n        out->Write(\"test_crop_2d_output.png\");\n    }\n};\n\nPIC_INLINE FilterCrop::FilterCrop(Vec2i min, Vec2i max) : Filter()\n{\n    mini[0] = min[0];\n    mini[1] = min[1];\n    mini[2] = 0;\n    mini[3] = 0;\n\n    maxi[0] = max[0];\n    maxi[1] = max[1];\n    maxi[2] = 1;\n    maxi[3] = INT_MAX;\n\n    flag = false;\n}\n\nPIC_INLINE FilterCrop::FilterCrop(Vec3i min, Vec3i max) : Filter()\n{\n    for(int i = 0; i < 3; i++) {\n        this->mini[i] = min[i];\n        this->maxi[i] = max[i];\n    }\n\n    mini[3] = 0;\n    maxi[3] = INT_MAX;\n\n    flag = false;\n}\n\nPIC_INLINE FilterCrop::FilterCrop(Vec4i min, Vec4i max) : Filter()\n{\n    this->mini = min;\n    this->maxi = max;\n\n    flag = false;\n}\n\nPIC_INLINE FilterCrop::FilterCrop(Vec3f min, Vec3f max) : Filter()\n{\n    this->minf = min;\n    this->maxf = max;\n\n    flag = true;\n}\n\nPIC_INLINE void FilterCrop::OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n{\n    if(flag) {\n        mini[0] = int(minf[0] * imgIn[0]->widthf);\n        mini[1] = int(minf[1] * imgIn[0]->heightf);\n        mini[2] = int(minf[2] * imgIn[0]->framesf);\n\n        maxi[0] = int(maxf[0] * imgIn[0]->widthf);\n        maxi[1] = int(maxf[1] * imgIn[0]->heightf);\n        maxi[2] = int(maxf[2] * imgIn[0]->framesf);\n    }\n\n    channels = MIN(imgIn[0]->channels, maxi[3]) - mini[3];\n\n    if(mini[3] > 0) {\n        channels++;\n    }\n\n    int delta[3];\n    for(int i = 0; i < 3; i++) {\n        delta[i] = maxi[i] - mini[i];\n    }\n\n    if(delta[0] <= 0) {\n        delta[0] = imgIn[0]->width;\n        mini[0]  = 0;\n        maxi[0]  = imgIn[0]->width;\n    }\n\n    if(delta[1] <= 0) {\n        delta[1] = imgIn[0]->height;\n        mini[1]  = 0;\n        maxi[1]  = imgIn[0]->height;\n    }\n\n    if(delta[2] <= 0) {\n        delta[2] = imgIn[0]->frames;\n        mini[2]  = 0;\n        maxi[2]  = imgIn[0]->frames;\n    }\n\n    width = delta[0];\n    height = delta[1];\n    frames = delta[2];\n}\n\nPIC_INLINE void FilterCrop::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n    maxi[3] = MIN(maxi[3], src[0]->channels);\n\n    for(int p = box->z0; p < box->z1; p++) {\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *dst_data = (*dst)(i - mini[0], j - mini[1], p - mini[2]);\n                float *src_data = (*src[0])(i, j, p);\n\n                for(int k = mini[3]; k <= maxi[3]; k++) {\n                    dst_data[k - mini[3]] = src_data[k];\n                }\n            }\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_CROP_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_dct_1d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DCT_1D_HPP\n#define PIC_FILTERING_FILTER_DCT_1D_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDCT1D class\n */\nclass FilterDCT1D: public Filter\n{\nprotected:\n    int     dirs[3];\n    float   *coeff, sqr[2];\n    int     nCoeff;\n    bool    bForward;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n\n    /**\n     * @brief FilterDCT1D\n     * @param nCoeff\n     * @param bForward\n     */\n    FilterDCT1D(int nCoeff, bool bForward);\n\n    ~FilterDCT1D();\n\n    /**\n     * @brief setForward\n     */\n    void setForward()\n    {\n        this->bForward = true;\n\n        if(coeff != NULL) {\n            delete[] coeff;\n            coeff = NULL;\n        }\n\n        coeff = createCoefficientsTransform(nCoeff);\n    }\n\n    /**\n     * @brief setInverse\n     */\n    void setInverse()\n    {\n        this->bForward = false;\n\n        if(coeff != NULL) {\n            delete[] coeff;\n            coeff = NULL;\n        }\n\n        coeff = createCoefficientsInverse(nCoeff);\n    }\n\n    /**\n     * @brief createCoefficientsTransform\n     * @param size\n     * @return\n     */\n    static float *createCoefficientsTransform(int size)\n    {\n        if(size < 1) {\n            return NULL;\n        }\n\n        float size2 = float(size * 2);\n        float *ret = new float[size * size];\n        int val;\n\n        int ind = 0;\n\n        for(int u = 0; u < size; u++) {\n            for(int x = 0; x < size; x++) {\n                val\t\t = u * (2 * x + 1);\n                ret[ind] = cosf(C_PI * float(val) / size2);\n                ind++;\n            }\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief createCoefficientsInverse\n     * @param size\n     * @return\n     */\n    static float *createCoefficientsInverse(int size)\n    {\n        if(size < 1) {\n            return NULL;\n        }\n\n        float size2 = float(size * 2);\n        float *ret = new float[size * size];\n        int val;\n\n        float \tsqr[2];\n        sqr[0] = sqrtf(1.0f / float(size));\n        sqr[1] = sqrtf(2.0f / float(size));\n\n        int ind = 0;\n\n        for(int x = 0; x < size; x++) {\n            for(int u = 0; u < size; u++) {\n                val\t\t = u * (2 * x + 1);\n                ret[ind] = cosf(C_PI * float(val) / size2);\n\n                if(u == 0) {\n                    ret[ind] *= sqr[0];\n                } else {\n                    ret[ind] *= sqr[1];\n                }\n\n                ind++;\n            }\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief changePass\n     * @param pass\n     * @param tPass\n     */\n    void changePass(int pass, int tPass);\n\n    /**\n     * @brief changePass\n     * @param x\n     * @param y\n     * @param z\n     */\n    void changePass(int x, int y, int z);\n};\n\nPIC_INLINE FilterDCT1D::FilterDCT1D(int nCoeff, bool bForward)\n{\n    this->coeff = NULL;\n    this->nCoeff = nCoeff;\n\n    if(bForward) {\n        setForward();\n    } else {\n        setInverse();\n    }\n\n    sqr[0] = sqrtf(1.0f / float(nCoeff));\n    sqr[1] = sqrtf(2.0f / float(nCoeff));\n\n    dirs[0] = 1;\n    dirs[1] = 0;\n    dirs[2] = 0;\n}\n\nPIC_INLINE FilterDCT1D::~FilterDCT1D()\n{\n    if(coeff != NULL) {\n        delete[] coeff;\n    }\n}\n\nPIC_INLINE void FilterDCT1D::changePass(int pass, int tPass)\n{\n    int tMod;\n\n    if(tPass > 1) {\n        tMod = 3;\n    } else {\n        if(tPass == 1) {\n            tMod = 2;\n        } else {\n            printf(\"ERROR: FilterDCT1D::changePass\");\n            return;\n        }\n    }\n\n    dirs[pass % tMod] = 1;\n\n    for(int i = 1; i < tMod; i++) {\n        dirs[(pass + i) % tMod] = 0;\n    }\n\n}\n\nPIC_INLINE void FilterDCT1D::changePass(int x, int y, int z)\n{\n    dirs[0] = y;\n    dirs[1] = x;\n    dirs[2] = z;\n}\n\nPIC_INLINE void FilterDCT1D::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n    int channels = dst->channels;\n\n    Image *source = src[0];\n\n    for(int m = box->z0; m < box->z1; m++) {\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *tmpDst = (*dst)(i, j, m);\n\n                for(int l = 0; l < channels; l++) {\n                    tmpDst[l] = 0.0f;\n                }\n\n                int ind = (j * dirs[0] + i * dirs[1] + m * dirs[2]) % nCoeff;\n                int ind2 = ind * nCoeff;\n\n                for(int k = 0; k < nCoeff; k++) { //1D Filtering\n                    int k2 = k - ind;\n                    //Address cj\n                    int cj = j + k2 * dirs[0];\n                    //Address ci\n                    int ci = i + k2 * dirs[1];\n                    //Address cm\n                    int cm = m + k2 * dirs[2];\n\n                    float *tmpSource = (*source)(ci, cj, cm);\n\n                    float tmpCoeff = coeff[ind2];\n\n                    for(int l = 0; l < channels; l++) {\n                        tmpDst[l] += tmpSource[l] * tmpCoeff;\n                    }\n\n                    ind2++;\n                }\n\n                if(bForward) {\n                    int select = (ind == 0) ? 0 : 1;\n                    for(int l = 0; l < channels; l++) {\n                        tmpDst[l] *= sqr[select];\n                    }\n                }\n            }\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DCT_1D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_dct_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DCT_2D_HPP\n#define PIC_FILTERING_FILTER_DCT_2D_HPP\n\n#include \"../filtering/filter_npasses.hpp\"\n#include \"../filtering/filter_dct_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDCT2D class\n */\nclass FilterDCT2D: public FilterNPasses\n{\nprotected:\n    FilterDCT1D *fltDCT1D;\n\npublic:\n    /**\n     * @brief FilterDCT2D\n     * @param nCoeff\n     * @param bForward\n     */\n    FilterDCT2D(int nCoeff, bool bForward)\n    {\n        //DCT 1D filter\n        fltDCT1D = new FilterDCT1D(nCoeff, bForward);\n\n        insertFilter(fltDCT1D);\n        insertFilter(fltDCT1D);\n    }\n\n    ~FilterDCT2D()\n    {\n        release();\n\n        if(fltDCT1D != NULL) {\n            delete fltDCT1D;\n        }\n\n        fltDCT1D = NULL;\n    }\n\n    /**\n     * @brief SetForward\n     */\n    void setForward()\n    {\n        fltDCT1D->setForward();\n    }\n\n    /**\n     * @brief setInverse\n     */\n    void setInverse()\n    {\n        fltDCT1D->setInverse();\n    }\n\n    /**\n     * @brief transform\n     * @param imgIn\n     * @param imgOut\n     * @param nCoeff\n     * @return\n     */\n    static Image *transform(Image *imgIn, Image *imgOut, int nCoeff)\n    {\n        FilterDCT2D filter(nCoeff, true);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief inverse\n     * @param imgIn\n     * @param imgOut\n     * @param nCoeff\n     * @return\n     */\n    static Image *inverse(Image *imgIn, Image *imgOut, int nCoeff)\n    {\n        FilterDCT2D filter(nCoeff, false);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DCT_2D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_deconvolution.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DECONVOLUTION_HPP\n#define PIC_FILTERING_FILTER_DECONVOLUTION_HPP\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n#include \"../filtering/filter_conv_2d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDeconvolution class\n */\nclass FilterDeconvolution: public Filter\n{\nprotected:\n    Image *psf_hat;\n    Image *img_est_conv;\n    Image *img_err;\n    Image *img_rel_blur;\n    FilterConv2D *flt_conv;\n\n    int nIterations;\n\npublic:\n\n    /**\n     * @brief FilterDeconvolution\n     * @param nIterations\n     */\n    FilterDeconvolution(int nIterations) : Filter()\n    {\n        minInputImages = 2;\n        psf_hat = NULL;\n        img_est_conv = NULL;\n        img_err = NULL;\n        img_rel_blur = NULL;\n        flt_conv = new FilterConv2D();\n\n        this->nIterations = 0;\n        setup(nIterations);\n    }\n\n    /**\n     * @brief setup\n     * @param nIterations\n     */\n    void setup(int nIterations)\n    {\n        this->nIterations = nIterations > 0 ? nIterations : 16;\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut)\n    {\n        if (!checkInput(imgIn)) {\n            return imgOut;\n        }\n\n        imgOut = setupAux(imgIn, imgOut);\n\n        if (imgOut == NULL) {\n            return imgOut;\n        }\n\n        //\n        //\n        //\n\n        Image *psf = imgIn[1];\n\n        if(psf_hat == NULL) {\n            psf_hat = psf->clone();\n        } else {\n            psf_hat->assign(psf);\n        }\n\n        psf_hat->flipHV();\n\n        *imgOut = 0.5f;\n\n        img_rel_blur = allocateOutputMemory(imgIn, img_rel_blur, true);\n        img_est_conv = allocateOutputMemory(imgIn, img_est_conv, true);\n        img_err = allocateOutputMemory(imgIn, img_err, true);\n\n        ImageVec vec = Double(imgOut, psf);\n        ImageVec vec_err = Double(img_rel_blur, psf_hat);\n\n        for(int i = 0; i < nIterations; i++) {\n\n            #ifdef PIC_DEBUG\n                printf(\"%d\\n\", i);\n            #endif\n\n            img_est_conv = flt_conv->Process(vec, img_est_conv);\n\n            img_rel_blur->assign(imgIn[0]);\n            *img_rel_blur /= *img_est_conv;\n\n            img_err = flt_conv->Process(vec_err, img_err);\n\n            *imgOut *= *img_err;\n        }\n\n        return imgOut;\n    }\n\n\n    /**\n     * @brief execute\n     */\n    static Image *execute(Image *imgIn, Image *psf, Image *imgOut, int nIterations)\n    {\n        FilterDeconvolution flt(nIterations);\n        return flt.Process(Double(imgIn, psf), imgOut);\n    }\n};\n\n}\n\n#endif //PIC_FILTERING_FILTER_DECONVOLUTION_HPP\n"
  },
  {
    "path": "include/filtering/filter_deform_grid.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DEFORM_GRID_HPP\n#define PIC_FILTERING_FILTER_DEFORM_GRID_HPP\n\n#include \"../util/vec.hpp\"\n\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter.hpp\"\n#include \"../image_samplers/image_sampler_bicubic.hpp\"\n#include \"../image_samplers/image_sampler_bilinear.hpp\"\n#include \"../image_samplers/image_sampler_nearest.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDeformGrid class\n */\nclass FilterDeformGrid: public Filter\n{\nprotected:\n    ImageSamplerBicubic isb;\n    ImageSamplerNearest isb_lin;\n    Image *grid_rest, *grid_move, grid_diff;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        float vDiff[3];\n        for(int j = box->y0; j < box->y1; j++) {\n            float y = float(j) / dst->height1f;\n\n            for(int i = box->x0; i < box->x1; i++) {\n                float *tmp_dst = (*dst)(i, j);\n\n                float x = float(i) / dst->width1f;\n\n                isb.SampleImage(&grid_diff, x, y, vDiff);\n\n                isb.SampleImage(src[0], x + vDiff[0], y + vDiff[1] , tmp_dst);\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterDeformGrid\n     * @param type\n     */\n    FilterDeformGrid(Image *grid_move)\n    {\n        this->grid_rest = getUniformGrid(grid_move->width, grid_move->height);\n        this->grid_move = grid_move;\n\n        grid_diff = *grid_rest - *grid_move;\n    }\n\n    ~FilterDeformGrid()\n    {\n        delete_s(grid_rest);\n    }\n\n    /**\n     * @brief getUniformGrid\n     * @param sampleX\n     * @param sampleY\n     * @return\n     */\n    static Image* getUniformGrid(int sampleX, int sampleY)\n    {\n        if(sampleX < 1) {\n            sampleX = 5;\n        }\n\n        if(sampleY < 1) {\n            sampleY = 5;\n        }\n\n        //the grid has sampleX \\times sampleY squares, so it has to have\n        //some one extra control point for each direction\n\n        Image *ret = new Image(1, sampleX, sampleY, 3);\n\n        float tmp_x = 1.0f / float(sampleX - 1);\n        float tmp_y = 1.0f / float(sampleY - 1);\n\n        for(int y = 0; y < sampleY; y++) {\n            float y_f = float(y) * tmp_y;\n\n            for(int x = 0; x < sampleX; x++) {\n                float *ret_val = (*ret)(x, y);\n\n                ret_val[0]= float(x) * tmp_x;\n                ret_val[1]= y_f;\n            }\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief getCoordinatesAfterTransform\n     * @param x is normalized in [0,1]\n     * @param y is normalized in [0,1]\n     * @param xOut\n     * @param yOut\n     */\n    void getCoordinatesAfterTransform(float x, float y, float &xOut, float &yOut)\n    {\n        float vDiff[3];\n        isb.SampleImage(&grid_diff, x, y, vDiff);\n\n        xOut = x + vDiff[0];\n        yOut = y + vDiff[1];\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_LUMINANCE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_demosaic.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DEMOSAIC_HPP\n#define PIC_FILTERING_FILTER_DEMOSAIC_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDemosaic class\n */\nclass FilterDemosaic: public Filter\n{\nprotected:\n\n    /**\n     * @brief LinearUpSamplingGCGreen this upsamples the green channel with gradient correction\n     * @param imgIn\n     * @param imgOut\n     */\n    void LinearUpSamplingGCGreen(Image *imgIn, Image *imgOut)\n    {\n        int height = imgIn->height;\n        int width = imgIn->width;\n\n        float *dataIn = imgIn->data;\n        float *dataOut = imgOut->data;\n\n        //copy the original Green pixels into the U16RGB buffer\n        for(int j = 0; j < height; j++) {\n            int tmp = j * width;\n            for(int i = ((j + 1) % 2); i < width; i += 2) {\n                int current = tmp + i;\n                dataOut[current * 3 + 1] = dataIn[current];\n            }\n        }\n\n        //edge-aware interpolation for the missing Green pixels\n        //#pragma omp parallel for\n        for(int k = 0; k < 2; k++) {\n            for(int j = k; j < (height); j += 2) {\n                float tmpG, sum, Grad, final;\n\n                int tmp = j * width;\n\n                for(int i = k; i < (width); i += 2) {\n                    //    -1\n                    //     2\n                    //-1 2 4 2 -1\n                    //     2\n                    //    -1\n\n                    int current = tmp + i;\n\n                    tmpG  = (dataIn[imgIn->getAddress(i + 1, j)] +\n                             dataIn[imgIn->getAddress(i - 1, j)] +\n                             dataIn[imgIn->getAddress(i, j + 1)] +\n                             dataIn[imgIn->getAddress(i, j - 1)]) * 0.25f;\n\n                    sum  = (dataIn[imgIn->getAddress(i + 2, j)] +\n                            dataIn[imgIn->getAddress(i - 2, j)] +\n                            dataIn[imgIn->getAddress(i, j + 2)] +\n                            dataIn[imgIn->getAddress(i, j - 2)]);\n\n                    Grad = dataIn[current] - sum * 0.25f;\n\n                    final = tmpG + Grad * 0.5f;\n\n                    dataOut[current * 3 + 1] = CLAMPi(final, 0.0f, 1.0f);\n                }\n            }\n        }\n    }\n\n    /**\n     * @brief LinearUpSamplingGCRB this linearly upsamples Red and Blue channels\n     * @param imgIn\n     * @param imgOut\n     * @param sx\n     * @param sy\n     */\n    void LinearUpSamplingGCRB(Image *imgIn, Image *imgOut, int sx,\n                                         int sy)\n    {\n        int i, j;\n        int shifter = sx + sy;\n\n        int height = imgIn->height;\n        int width = imgIn->width;\n        float *dataIn = imgIn->data;\n        float *data = imgOut->data;\n\n        //copy the original pixels!\n        //#pragma omp parallel for\n        for(j = sy; j < height; j += 2) {\n            for(i = sx; i < width; i += 2) {\n                int current = j * width + i;\n                data[current * 3 + shifter] = dataIn[current];\n            }\n        }\n\n        //Edge-aware interpolation for the missing Green pixels\n        int ssx = 0;\n        int ssy = 0;\n\n        if(shifter == 0) {\n            ssx = 1;\n            ssy = 0;\n        }\n\n        if(shifter == 2) {\n            ssx = 0;\n            ssy = 1;\n        }\n\n        //First Mask\n        //#pragma omp parallel for\n        for(j = ssy; j < (height); j += 2) {\n            float tmp;\n\n            for(i = ssx; i < (width); i += 2) {\n                //\n                //          0.5\n                //      -1   0  -1\n                //  -1   4   5   4   -1\n                //      -1   0  -1\n                //          0.5\n                //\n                int current = j * width + i;\n\n                tmp =\t5.0f *\tdataIn[current] +\n                        4.0f * (dataIn[imgIn->getAddress(i + 1, j)] +\tdataIn[imgIn->getAddress(i - 1,\n                                j)]) +\n                        0.5f * (dataIn[imgIn->getAddress(i, j + 2)] +\tdataIn[imgIn->getAddress(i,\n                                j - 2)]) -\n                        (dataIn[imgIn->getAddress(i + 1, j + 1)] +\tdataIn[imgIn->getAddress(i + 1,\n                                j - 1)] +\n                         dataIn[imgIn->getAddress(i - 1, j + 1)] +\tdataIn[imgIn->getAddress(i - 1,\n                                 j - 1)] +\n                         dataIn[imgIn->getAddress(i - 2, j)] +\tdataIn[imgIn->getAddress(i + 2, j)]);\n                tmp /= 8.0f;\n                data[current * 3 + shifter] = CLAMPi(tmp, 0.0f, 1.0f);\n            }\n        }\n\n        //Second Mask\n        if(shifter == 0) {\n            ssx = 0;\n            ssy = 1;\n        }\n\n        if(shifter == 2) {\n            ssx = 1;\n            ssy = 0;\n        }\n\n        //#pragma omp parallel for\n        for(j = ssy; j < (height); j += 2) {\n            float tmp;\n\n            for(i = ssx; i < (width); i += 2) {\n                //\n                //           -1\n                //       -1   4  -1\n                //  0.5   0   5   0   0.5\n                //       -1   4  -1\n                //           -1\n                //\n                int current = j * width + i;\n\n                tmp =\t5.0f * dataIn[current] +\n                        4.0f * (dataIn[imgIn->getAddress(i, j + 1)] +\tdataIn[imgIn->getAddress(i,\n                                j - 1)]) +\n                        +0.5f * (dataIn[imgIn->getAddress(i - 2, j)] +\tdataIn[imgIn->getAddress(i + 2,\n                                 j)]) -\n                        (dataIn[imgIn->getAddress(i + 1, j + 1)] +\tdataIn[imgIn->getAddress(i + 1,\n                                j - 1)] +\n                         dataIn[imgIn->getAddress(i - 1, j + 1)] +\tdataIn[imgIn->getAddress(i - 1,\n                                 j - 1)] +\n                         dataIn[imgIn->getAddress(i, j + 2)] +\tdataIn[imgIn->getAddress(i, j - 2)]);\n\n                tmp /= 8.0f;\n                data[current * 3 + shifter] = CLAMPi(tmp, 0.0f, 1.0f);\n            }\n        }\n\n        //Third Mask\n        if(shifter == 0) {\n            ssx = 1;\n            ssy = 1;\n        }\n\n        if(shifter == 2) {\n            ssx = 0;\n            ssy = 0;\n        }\n\n        //#pragma omp parallel for\n        for(j = ssy; j < (height); j += 2) {\n            float tmp;\n\n            for(i = ssx; i < (width); i += 2) {\n                //\n                //           -3/2\n                //         2   0   2\n                //  -3/2   0   6   0   -3/2\n                //         2   0   2\n                //           -3/2\n                //\n                int current = j * width + i;\n                tmp =\t6.0f *\tdataIn[current] +\n                        2.0f * (dataIn[imgIn->getAddress(i + 1, j + 1)] +\tdataIn[imgIn->getAddress(i + 1,\n                                j - 1)] +\n                                dataIn[imgIn->getAddress(i - 1, j + 1)] +\tdataIn[imgIn->getAddress(i - 1,\n                                        j - 1)]) -\n                        1.5f * (dataIn[imgIn->getAddress(i + 2, j)] +\tdataIn[imgIn->getAddress(i - 2,\n                                j)] +\n                                dataIn[imgIn->getAddress(i, j + 2)] +\tdataIn[imgIn->getAddress(i, j - 2)]);\n\n                tmp /= 8.0f;\n                data[current * 3 + shifter] = CLAMPi(tmp, 0.0f, 1.0f);\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterDemosaic\n     * @param type\n     */\n    FilterDemosaic() : Filter()\n    {\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = 3;\n        frames      = imgIn[0]->frames;\n    }\n\n    /**\n      * @brief Filter::Process\n      * @param imgIn\n      * @param imgOut\n      * @return\n      */\n    Image *Process(ImageVec imgIn, Image *imgOut)\n    {\n        if(imgIn[0] == NULL) {\n            return NULL;\n        }\n\n        if((!imgIn[0]->isValid()) && (imgIn[0]->channels != 1)) {\n            return imgOut;\n        }\n\n        imgOut = setupAux(imgIn, imgOut);\n\n        LinearUpSamplingGCGreen(imgIn[0], imgOut);\n        LinearUpSamplingGCRB(imgIn[0], imgOut, 0, 0);\n        LinearUpSamplingGCRB(imgIn[0], imgOut, 1, 1);\n\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        FilterDemosaic flt;\n        return flt.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DEMOSAIC_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_diff_gauss_1d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DIFF_GAUSS_1D_HPP\n#define PIC_FILTERING_FILTER_DIFF_GAUSS_1D_HPP\n\n#include \"../filtering/filter_conv_1d.hpp\"\n#include \"../util/precomputed_diff_of_gaussians.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDiffGauss1D class\n */\nclass FilterDiffGauss1D: public FilterConv1D\n{\nprotected:\n    float sigma1, sigma2;\n    PrecomputedDiffOfGaussians *pdog;\n    bool bpdogOwned;\n\npublic:\n\n    /**\n     * @brief FilterDiffGauss1D\n     * @param sigma\n     * @param direction\n     */\n    FilterDiffGauss1D(float sigma1, float sigma2, int direction);\n\n    /**\n     * @brief FilterDiffGauss1D\n     * @param pdog\n     * @param direction\n     */\n    FilterDiffGauss1D(PrecomputedDiffOfGaussians *pdog, int direction);\n\n    ~FilterDiffGauss1D();\n\n    static Image *execute(Image *imgIn, Image *imgOut,\n                          float sigma1, float sigma2,\n                          int direction)\n    {\n        FilterDiffGauss1D filter(sigma1, sigma2, direction);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\nPIC_INLINE FilterDiffGauss1D::FilterDiffGauss1D(float sigma1, float sigma2, int direction = 0)\n{\n    this->sigma1 = sigma1;\n    this->sigma2 = sigma2;\n    pdog = new PrecomputedDiffOfGaussians(sigma1, sigma2);\n\n    bpdogOwned = true;\n    update(pdog->coeff, pdog->kernelSize, direction);\n}\n\nPIC_INLINE FilterDiffGauss1D::FilterDiffGauss1D(PrecomputedDiffOfGaussians *pdog, int direction = 0)\n{\n    if(pdog == NULL) {\n        #ifdef PICE_DEBUG\n            printf(\"Error no precomputed gaussian values.\\n\");\n        #endif\n        return;\n    }\n\n    bpdogOwned = false;\n\n    update(pdog->coeff, pdog->kernelSize, direction);\n}\n\nPIC_INLINE FilterDiffGauss1D::~FilterDiffGauss1D()\n{\n    if(pdog != NULL && bpdogOwned) {\n        delete pdog;\n        pdog = NULL;\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DIFF_GAUSS_1D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_diff_gauss_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DIFF_GAUSS_2D_HPP\n#define PIC_FILTERING_FILTER_DIFF_GAUSS_2D_HPP\n\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDiffGauss class\n */\nclass FilterDiffGauss: public Filter\n{\nprotected:\n    FilterGaussian2D *filter_1, *filter_2;\n    Image *tmp;\n\npublic:\n    /**\n     * @brief FilterDiffGauss\n     * @param sigma_1\n     * @param sigma_2\n     */\n    FilterDiffGauss(float sigma_1, float sigma_2)\n    {\n        filter_1 = new FilterGaussian2D(sigma_1);\n        filter_2 = new FilterGaussian2D(sigma_2);\n        tmp = NULL;\n    }\n\n    ~FilterDiffGauss()\n    {\n        if(filter_1 != NULL) {\n            delete filter_1;\n        }\n\n        if(filter_2 != NULL) {\n            delete filter_2;\n        }\n\n        if(tmp != NULL) {\n            delete tmp;\n        }\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut)\n    {\n        imgOut = filter_1->Process(imgIn, imgOut);\n\n        //MEMORY-LEAK: to check\n        tmp = filter_2->Process(imgIn, tmp);\n        *imgOut -= *tmp;\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma_1\n     * @param sigma_2\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float sigma_1,\n                             float sigma_2)\n    {\n        FilterDiffGauss filter(sigma_1, sigma_2);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DIFF_GAUSS_2D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_diff_gauss_2d_opt.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DIFF_GAUSS_2D_OPT_HPP\n#define PIC_FILTERING_FILTER_DIFF_GAUSS_2D_OPT_HPP\n\n#include \"../filtering/filter_npasses.hpp\"\n#include \"../filtering/filter_diff_gauss_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDiffGaussOpt class\n */\n\nclass FilterDiffGaussOpt: public FilterNPasses\n{\nprotected:\n    FilterDiffGauss1D *flt_dog_1d;\n\npublic:\n    /**\n     * @brief FilterDiffGaussOpt\n     * @param sigma_1\n     * @param sigma_2\n     */\n    FilterDiffGaussOpt(float sigma1, float sigma2)\n    {\n        //Gaussian filter\n        flt_dog_1d = new FilterDiffGauss1D(sigma1, sigma2);\n\n        insertFilter(flt_dog_1d);\n        insertFilter(flt_dog_1d);\n    }\n\n    ~FilterDiffGaussOpt()\n    {\n        release();\n\n        if(flt_dog_1d != NULL) {\n            delete flt_dog_1d;\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DIFF_GAUSS_2D_OPT_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_disparity.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DISPARITY_HPP\n#define PIC_FILTERING_FILTER_DISPARITY_HPP\n\n#include \"../filtering/filter.hpp\"\n\n#include \"../features_matching/patch_comp.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDisparity class\n */\nclass FilterDisparity: public Filter\n{\nprotected:\n\n    int maxDisparity, halfMaxDisparity, patchSize;\n    float lambda;\n    PatchComp *pc;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        float maxDisparityf = float(maxDisparity);\n        float patchSize_sq = float (patchSize * patchSize);\n\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *prevL = (*dst)(i - 1, j    );\n                float *prevU = (*dst)(i    , j - 1);\n\n                int xB = -1;\n                float dB = FLT_MAX;\n\n                int minX = MAX(i - halfMaxDisparity, 0);\n                int maxX = MIN(i + halfMaxDisparity, src[1]->width);\n\n                for(int x = minX; x < maxX; x++) {\n\n                    float dist = pc->getSSDSmooth(i, j, x, j) / patchSize_sq;\n\n                    //regularization\n                    float reg = 0.0f;//float(x1 - x0);\n\n                    if(prevL[1] >= 0.0f) {\n                        float deltaL = fabsf(prevL[0] - x);\n                        reg += deltaL / maxDisparityf;\n                    }\n\n                    if(prevU[1] >= 0.0f) {\n                        float deltaU = fabsf(prevU[0] - x);\n                        reg += deltaU / maxDisparityf;\n                    }\n\n                    dist += lambda * reg;\n\n                    if(dist < dB) {\n                        xB = x;\n                        dB = dist;\n                    }\n                }\n\n                float *out = (*dst)(i, j);\n\n                out[1] = dB;\n                out[0] = float(xB);\n            }\n        }\n    }\n\n    /**\n     * @brief setupAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *setupAux(ImageVec imgIn, Image *imgOut)\n    {\n        if(imgIn.size() == 4) {\n            pc = new PatchComp(imgIn[0], imgIn[1], imgIn[2], imgIn[3], patchSize, 0.9f);\n        } else {\n            return NULL;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = new Image(1, imgIn[0]->width, imgIn[0]->height, 2);\n        } else {\n            if(imgOut->isValid()) {\n\n                if((imgIn[0]->width  != imgOut->width)  ||\n                   (imgIn[0]->height != imgOut->height) ||\n                   (imgOut->channels != 2)) {\n                    imgOut = new Image(1, imgIn[0]->width, imgIn[0]->height, 2);\n                }\n            } else {\n                imgOut->allocateSimilarTo(imgIn[0]);\n            }\n        }\n\n        *imgOut = -1.0f;\n\n        return imgOut;\n    }\n\npublic:\n\n    /**\n     * @brief FilterDisparity\n     */\n    FilterDisparity()\n    {\n        update(200, 7, 0.05f);\n    }\n\n    /**\n     * @brief FilterDisparity\n     * @param maxDisparity\n     * @param patchSize\n     * @param lambda\n     */\n    FilterDisparity(int maxDisparity, int patchSize, float lambda) : Filter()\n    {\n        pc = NULL;\n        update(maxDisparity, patchSize, lambda);\n    }\n\n    ~FilterDisparity()\n    {\n        delete_s(pc);\n    }\n\n    /**\n     * @brief update\n     * @param maxDisparity\n     */\n    void update(int maxDisparity, int patchSize, float lambda)\n    {\n        if(this->patchSize != patchSize) {\n            delete_s(pc);\n        }\n\n        this->lambda = lambda > 0.0f ? lambda : 0.05f;\n\n        this->maxDisparity = maxDisparity;\n        this->halfMaxDisparity = maxDisparity >> 1;\n        this->patchSize = patchSize;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(Image *imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn->width;\n        height      = imgIn->height;\n        channels    = 2;\n        frames      = imgIn->frames;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DISPARITY_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_divergence.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DIVERGENCE_HPP\n#define PIC_FILTERING_FILTER_DIVERGENCE_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDivergence class\n */\nclass FilterDivergence: public Filter\n{\nprotected:\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n    /**\n     * @brief FilterDivergence\n     */\n    FilterDivergence()\n    {\n\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        FilterDivergence filter;\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\nPIC_INLINE void FilterDivergence::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n    int width = dst->width;\n    int height = dst->height;\n\n    float *data = src[0]->data;\n    float gradX, gradY;\n\n    int channels = src[0]->channels;\n    int c, ci, cj, ci1, cj1, tmpc, ind;\n\n    for(int j = box->y0; j < box->y1; j++) {\n        ind = j * width;\n\n        for(int i = box->x0; i < box->x1; i++) {\n            c = (ind + i) * channels;\n            //Positions\n            ci  = CLAMP(i + 1, width);\n            cj  = CLAMP(j + 1, height);\n            ci1 = CLAMP(i - 1, width);\n            cj1 = CLAMP(j - 1, height);\n\n            //Grad X\n            tmpc  = (ind + ci) * channels;\n            gradX = data[tmpc];\n\n            tmpc  = (ind + ci1) * channels;\n            gradX -= data[tmpc];\n\n            //Grad Y\n            tmpc  = (cj * width + i) * channels;\n            gradY = data[tmpc];\n\n            tmpc  = (cj1 * width + i) * channels;\n            gradY -= data[tmpc];\n\n            //Divergence\n            dst->data[c] = (gradX + gradY) * 0.5f;\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DIVERGENCE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_down_pp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DOWN_PP_HPP\n#define PIC_FILTERING_FILTER_DOWN_PP_HPP\n\n#include \"../util/array.hpp\"\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDownPP class\n */\nclass FilterDownPP: public Filter\n{\nprotected:\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        int channels = src[0]->channels;\n\n        for(int i2 = box->y0; i2 < box->y1; i2++) {\n            int i = i2 << 1;\n\n            for(int j2 = box->x0; j2 < box->x1; j2++) {\n                int j = j2 << 1;\n\n                float *tmp[4];\n                tmp[0] = (*src[0])(j    , i);\n                tmp[1] = (*src[0])(j + 1, i);\n                tmp[2] = (*src[0])(j    , i + 1);\n                tmp[3] = (*src[0])(j + 1, i + 1);\n\n                int counter = 0;\n                float *out = (*dst)(j2, i2);\n\n                Arrayf::assign(0.0f, out, channels);\n\n                for(int k = 0; k < 4; k++) {\n                    if(Arrayf::distanceSq(tmp[k], value, channels) > threshold) {\n                        counter++;\n\n                        for(int l = 0; l < channels; l++) {\n                            out[l] += tmp[k][l];\n                        }\n                    }\n                }\n\n                if(counter > 0) {\n                    float counter_f = float(counter);                    \n                    Arrayf::div(out, channels, counter_f);\n                } else {\n                    Arrayf::assign(value, channels, out);\n                }\n            }\n        }\n    }\n\n    float *value, threshold;\n\npublic:\n\n    /**\n     * @brief FilterDownPP\n     * @param value\n     * @param threshold\n     */\n    FilterDownPP(float *value, float threshold) : Filter()\n    {\n        update(value, threshold);\n    }\n\n    ~FilterDownPP()\n    {\n    }\n\n    /**\n     * @brief update\n     * @param value\n     * @param threshold\n     */\n    void update(float *value, float threshold)\n    {\n        this->value = value;\n\n        if(value == NULL) {\n            printf(\"ERROR in FilterDownPP\");\n        }\n\n        this->threshold = (threshold > 0.0f) ? threshold : 1e-4f;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        if(imgIn.size() == 1) {\n            width       = imgIn[0]->width >> 1;\n            height      = imgIn[0]->height >> 1;\n        } else {\n            width       = imgIn[1]->width;\n            height      = imgIn[1]->height;\n\n        }\n\n        channels    = imgIn[0]->channels;\n        frames      = imgIn[0]->frames;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DOWN_PP_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_downsampler_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DOWNSAMPLER_2D_HPP\n#define PIC_FILTERING_FILTER_DOWNSAMPLER_2D_HPP\n\n#include \"../util/std_util.hpp\"\n#include \"../filtering/filter_npasses.hpp\"\n#include \"../filtering/filter_sampler_1d.hpp\"\n#include \"../image_samplers/image_sampler_nearest.hpp\"\n#include \"../image_samplers/image_sampler_gaussian.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDownSampler2D class\n */\nclass FilterDownSampler2D: public FilterNPasses\n{\nprotected:\n    ImageSamplerGaussian *isg[2];\n    FilterSampler1D *flt[2];\n\n    bool swh;\n    float scale[2];\n    int width, height;\n\n    /**\n     * @brief allocate\n     */\n    void allocate()\n    {\n        for(int i = 0; i < 2; i++) {\n            if(isg[i] == NULL) {\n                isg[i] = new ImageSamplerGaussian();\n            }\n\n            if(flt[i] == NULL) {\n                flt[i] = new FilterSampler1D(scale[i], i, isg[i]);\n            } else {\n                flt[i]->update(scale[i], i, isg[i]);\n            }\n\n            insertFilter(flt[i]);\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterDownSampler2D\n     * @param scaleX\n     * @param scaleY\n     */\n    FilterDownSampler2D(float scaleX, float scaleY);\n\n    /**\n     * @brief FilterDownSampler2D\n     * @param width\n     * @param height\n     */\n    FilterDownSampler2D(int width, int height);\n\n    ~FilterDownSampler2D();\n\n    /**\n     * @brief release\n     */\n    void release();\n    \n    /**\n     * @brief PreProcess\n     * @param imgIn\n     * @param imgOut\n     */\n    void PreProcess(ImageVec imgIn, Image *imgOut);\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param width\n     * @param height\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, int width,\n                             int height)\n    {\n        FilterDownSampler2D flt(width, height);\n        return flt.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param scaleX\n     * @param scaleY\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float scaleX,\n                             float scaleY)\n    {\n        FilterDownSampler2D flt(scaleX, scaleY);\n        return flt.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param scaleXY\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float scaleXY)\n    {\n        FilterDownSampler2D flt(scaleXY, scaleXY);\n        return flt.Process(Single(imgIn), imgOut);\n    }\n};\n\nPIC_INLINE FilterDownSampler2D::FilterDownSampler2D(float scaleX, float scaleY = -1.0f) : FilterNPasses()\n{\n    for(int i = 0; i < 2; i++) {\n        this->isg[i] = NULL;\n        this->flt[i] = NULL;\n        this->scale[i] = 1.0f;\n    }\n\n    if(scaleX > 0.0f) {\n        this->scale[0] = scaleX;\n        this->scale[1] = scaleY > 0.0f ? scaleY : scaleX;\n    }\n\n    width  = -1;\n    height = -1;\n\n    allocate();\n\n    swh = true;\n}\n\nPIC_INLINE FilterDownSampler2D::FilterDownSampler2D(int width, int height) : FilterNPasses()\n{\n    for(int i = 0; i < 2; i++) {\n        this->isg[i] = NULL;\n        this->flt[i] = NULL;\n        this->scale[i] = 1.0f;\n    }\n\n    if(width > 0) {\n        this->width  = width;\n    }\n\n    if(height > 0) {\n        this->height = height;\n    }\n\n    allocate();\n\n    swh = (width < 1 ||  height < 1);\n}\n\nPIC_INLINE FilterDownSampler2D::~FilterDownSampler2D()\n{\n    release();\n}\n\nPIC_INLINE void FilterDownSampler2D::release()\n{\n    for (int i = 0; i < 2; i++) {\n        flt[i] = delete_s(flt[i]);\n        isg[i] = delete_s(isg[i]);\n    }\n}\n\nPIC_INLINE void FilterDownSampler2D::PreProcess(ImageVec imgIn,\n        Image *imgOut)\n{\n    if(!swh) {\n        scale[0] = float(width)  / imgIn[0]->widthf;\n        scale[1] = float(height) / imgIn[0]->heightf;\n    }\n\n    for(int i = 0; i < 2; i++) {\n        isg[i]->update(1.0f / (5.0f * scale[i]), i);\n        flt[i]->update(scale[i], i, isg[i]);\n    }\n\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DOWNSAMPLER_2D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_drago_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_DRAGO_TMO_HPP\n#define PIC_FILTERING_FILTER_DRAGO_TMO_HPP\n\n#include \"../util/array.hpp\"\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterDragoTMO class\n */\nclass FilterDragoTMO: public Filter\n{\nprotected:\n    float constant1, constant2, Lw_Max_scaled, Lw_a_scaled;\n    float b, Ld_Max, Lw_Max, Lw_a;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n    /**\n     * @brief FilterDragoTMO\n     */\n    FilterDragoTMO();\n\n    /**\n     * @brief FilterDragoTMO\n     * @param Ld_Max\n     * @param b\n     * @param Lw_Max\n     * @param Lwa\n     */\n    FilterDragoTMO(float Ld_Max, float b, float Lw_Max, float Lwa);\n\n    /**\n     * @brief update\n     * @param Ld_Max\n     * @param b\n     * @param Lw_Max\n     * @param Lwa\n     */\n    void update(float Ld_Max, float b, float Lw_Max, float Lwa);\n};\n\nPIC_INLINE FilterDragoTMO::FilterDragoTMO() : Filter()\n{\n    update(100.0f, 0.95f, 1e6f, 0.5f);\n}\n\nPIC_INLINE FilterDragoTMO::FilterDragoTMO(float Ld_Max, float b, float Lw_Max,\n                               float Lw_a) : Filter()\n{\n    update(Ld_Max, b, Lw_Max, Lw_a);\n}\n\nPIC_INLINE void FilterDragoTMO::update(float Ld_Max, float b, float Lw_Max,\n                            float Lw_a)\n{\n    //protected values are assigned/computed\n    this->Ld_Max = (Ld_Max > 0.0f) ? Ld_Max : 100.0f;\n    this->b = (b > 0.0f) ? b : 0.95f;\n    this->Lw_Max = (Lw_Max > 0.0f) ? Lw_Max : 1e6f;\n    this->Lw_a = (Lw_a > 0.0f) ? Lw_a : 0.5f;\n\n    //constants\n    Lw_a_scaled   = this->Lw_a / powf(1.0f + b - 0.85f, 5.0f);\n    Lw_Max_scaled = this->Lw_Max / Lw_a_scaled;\n\n    constant1 = logf(b) / logf(0.5f);\n    constant2 = (Ld_Max / 100.0f) / (log10f(1.0f + Lw_Max_scaled));\n}\n\nPIC_INLINE void FilterDragoTMO::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n    int channels = src[0]->channels;\n\n    for(int j = box->y0; j < box->y1; j++) {\n\n        for(int i = box->x0; i < box->x1; i++) {\n\n            float *dataIn  = (*src[0])(i, j);\n            float *dataLum = (*src[1])(i, j);\n            float *dataOut = (*dst   )(i, j);\n\n            if(dataLum[0] > 0.0f) {\n                float L_scaled = dataLum[0] / Lw_a_scaled;\n\n                float tmp = powf((L_scaled / Lw_Max_scaled), constant1);\n                float Ld = constant2 * logf(1.0f + L_scaled) / logf(2.0f + 8.0f * tmp);\n\n                for(int k = 0; k < channels; k++) {\n                    dataOut[k] = (dataIn[k] * Ld) / dataLum[0];\n                }\n            } else {\n                Array<float>::assign(0.0f, dataOut, src[0]->channels);\n            }\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DRAGO_TMO_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_exposure_fusion_weights.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_EXPOSURE_FUSION_WEIGHTS\n#define PIC_FILTERING_FILTER_EXPOSURE_FUSION_WEIGHTS\n\n#include \"../filtering/filter.hpp\"\n\n#include \"../colors/saturation.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterExposureFusionWeights class\n */\nclass FilterExposureFusionWeights: public Filter\n{\nprotected:\n    float wC, wE, wS;\n    float mu, sigma_sq_2;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *pCur0 = (*src[0])(i, j);\n                float *pCur1 = (*src[1])(i, j);\n\n                //saturation\n                float pSat = computeSaturation(pCur1, src[1]->channels);\n\n                //contrast\n                float *pCurN0 = (*src[0])(i, j + 1);\n                float *pCurS0 = (*src[0])(i, j - 1);\n                float *pCurE0 = (*src[0])(i + 1, j);\n                float *pCurW0 = (*src[0])(i - 1, j);\n\n                float pCon = fabsf(-4.0f * pCur0[0] +\n                        pCurN0[0] + pCurS0[0] + pCurE0[0] + pCurW0[0]);\n\n                //well-exposedness\n                float pExp = 0.0f;\n                for(int c = 0; c < src[1]->channels; c++) {\n                    float delta = pCur1[c] - mu;\n                    pExp += delta * delta;\n                }\n                pExp = expf(-pExp / sigma_sq_2);\n\n                //final weights\n                float *out = (*dst)(i, j);\n                out[0] = powf(pCon, wC) * powf(pExp, wE) * powf(pSat, wS) + 1e-12f;\n                out[0] = CLAMPi(out[0], 0.0f, 1.0f);\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterExposureFusionWeights\n     * @param wC\n     * @param wE\n     * @param wS\n     */\n    FilterExposureFusionWeights(float wC = 1.0f, float wE = 1.0f, float wS = 1.0f) : Filter()\n    {\n        update(wC, wE, wS);\n        minInputImages = 2;\n    }\n\n    /**\n     * @brief update\n     * @param wC\n     * @param wE\n     * @param wS\n     */\n    void update(float wC = 1.0f, float wE = 1.0f, float wS = 1.0f)\n    {\n        float sigma = 0.2f;\n\n        mu = 0.5f;\n        sigma_sq_2 = 2.0f * sigma * sigma;\n\n        this->wC = wC > 0.0f ? MIN(wC, 1.0f) : 1.0f;\n        this->wE = wE > 0.0f ? MIN(wE, 1.0f) : 1.0f;\n        this->wS = wS > 0.0f ? MIN(wS, 1.0f) : 1.0f;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_EXPOSURE_FUSION_WEIGHTS */\n\n"
  },
  {
    "path": "include/filtering/filter_gaussian_1d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_GAUSSIAN_1D_HPP\n#define PIC_FILTERING_FILTER_GAUSSIAN_1D_HPP\n\n#include \"../filtering/filter_conv_1d.hpp\"\n#include \"../util/precomputed_gaussian.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGaussian1D class\n */\nclass FilterGaussian1D: public FilterConv1D\n{\nprotected:\n    float               sigma;\n    PrecomputedGaussian *pg;\n    bool                bPgOwned;\n\npublic:\n    /**\n     * @brief FilterGaussian1D\n     */\n    FilterGaussian1D();\n\n    /**\n     * @brief FilterGaussian1D\n     * @param sigma\n     * @param direction\n     */\n    FilterGaussian1D(float sigma, int direction);\n\n    /**\n     * @brief FilterGaussian1D\n     * @param pg\n     * @param direction\n     */\n    FilterGaussian1D(PrecomputedGaussian *pg, int direction);\n\n    ~FilterGaussian1D();\n\n    /**\n     * @brief update\n     * @param sigma\n     * @param direction\n     */\n    void update(float sigma, int direction = 0)\n    {\n        if(this->sigma != sigma) {\n            this->sigma = sigma;\n\n            if(pg != NULL) {\n                delete pg;\n            }\n\n            pg = new PrecomputedGaussian(sigma);\n        }\n\n        bPgOwned = true;\n        FilterConv1D::update(pg->coeff, pg->kernelSize, direction);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma\n     * @param direction\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float sigma,\n                             int direction)\n    {\n        FilterGaussian1D filter(sigma, direction);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\nPIC_INLINE FilterGaussian1D::FilterGaussian1D()\n{\n    sigma = 1.0f;\n    pg = new PrecomputedGaussian(sigma);\n\n    bPgOwned = true;\n    FilterConv1D::update(pg->coeff, pg->kernelSize, 0);\n}\n\nPIC_INLINE FilterGaussian1D::FilterGaussian1D(float sigma, int direction = 0)\n{\n    this->sigma = sigma;\n    pg = new PrecomputedGaussian(sigma);\n\n    bPgOwned = true;\n    FilterConv1D::update(pg->coeff, pg->kernelSize, direction);\n}\n\nPIC_INLINE FilterGaussian1D::FilterGaussian1D(PrecomputedGaussian *pg, int direction = 0)\n{\n    if(pg == NULL) {\n        #ifdef PICE_DEBUG\n            printf(\"Error no precomputed gaussian values.\\n\");\n        #endif\n        return;\n    }\n\n    bPgOwned = false;\n\n    FilterConv1D::update(pg->coeff, pg->kernelSize, direction);\n}\n\nPIC_INLINE FilterGaussian1D::~FilterGaussian1D()\n{\n    release();\n\n    if(pg != NULL && bPgOwned) {\n        delete pg;\n        pg = NULL;\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_GAUSSIAN_1D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_gaussian_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_GAUSSIAN_2D_HPP\n#define PIC_FILTERING_FILTER_GAUSSIAN_2D_HPP\n\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter_npasses.hpp\"\n#include \"../filtering/filter_gaussian_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGaussian2D class\n */\nclass FilterGaussian2D: public FilterNPasses\n{\nprotected:\n    FilterGaussian1D *filter;\n\npublic:\n\n    /**\n     * @brief FilterGaussian2D\n     */\n    FilterGaussian2D() : FilterNPasses()\n    {\n        filter = new FilterGaussian1D(1.0f);\n\n        insertFilter(filter);\n        insertFilter(filter);\n    }\n\n    /**\n     * @brief FilterGaussian2D\n     * @param sigma\n     */\n    FilterGaussian2D(float sigma) : FilterNPasses()\n    {\n        filter = new FilterGaussian1D(sigma);\n\n        insertFilter(filter);\n        insertFilter(filter);\n    }\n\n    ~FilterGaussian2D()\n    {\n        release();\n\n        filter = delete_s(filter);\n    }\n\n    /**\n     * @brief update\n     * @param sigma\n     */\n    void update(float sigma)\n    {\n        filter->update(sigma, 0);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float sigma)\n    {\n        FilterGaussian2D filter(sigma);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_GAUSSIAN_2D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_gaussian_3d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_GAUSSIAN_3D_HPP\n#define PIC_FILTERING_FILTER_GAUSSIAN_3D_HPP\n\n#include \"../filtering/filter_npasses.hpp\"\n#include \"../filtering/filter_gaussian_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGaussian3D class\n */\nclass FilterGaussian3D: public FilterNPasses\n{\n    FilterGaussian1D *gaussianFilter;\n\npublic:\n    /**\n     * @brief FilterGaussian3D\n     */\n    FilterGaussian3D()\n    {\n        gaussianFilter = NULL;\n    }\n\n    /**\n     * @brief FilterGaussian3D\n     * @param sigma\n     */\n    FilterGaussian3D(float sigma)\n    {\n        //Gaussian filter\n        gaussianFilter = new FilterGaussian1D(sigma);\n\n        insertFilter((Filter *)gaussianFilter);\n        insertFilter((Filter *)gaussianFilter);\n        insertFilter((Filter *)gaussianFilter);\n    }\n\n    ~FilterGaussian3D()\n    {\n        if(gaussianFilter != NULL) {\n            delete gaussianFilter;\n        }\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float sigma)\n    {\n        FilterGaussian3D filter(sigma);\n        Image *ret = filter.Process(Single(imgIn), imgOut);\n        return ret;\n    }\n\n    /**\n     * @brief execute\n     * @param nameIn\n     * @param nameOut\n     * @param sigma\n     * @return\n     */\n    static Image *execute(std::string nameIn, std::string nameOut, float sigma)\n    {\n        Image imgIn(nameIn);\n        Image *imgOut = execute(&imgIn, NULL, sigma);\n        imgOut->Write(nameOut);\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_GAUSSIAN_3D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_gradient.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_GRADIENT_HPP\n#define PIC_FILTERING_FILTER_GRADIENT_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\nenum GRADIENT_TYPE {G_SOBEL, G_PREWITT, G_NORMAL};\n\n/**\n * @brief The FilterGradient class\n */\nclass FilterGradient: public Filter\n{\nprotected:\n    int colorChannel;\n    GRADIENT_TYPE type;\n    float mask[3];\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n    /**\n     * @brief FilterGradient\n     */\n    FilterGradient();\n\n    /**\n     * @brief FilterGradient\n     * @param colorChannel\n     * @param type\n     */\n    FilterGradient(int colorChannel, GRADIENT_TYPE type);\n\n    /**\n     * @brief update\n     * @param colorChannel\n     * @param type\n     */\n    void update(int colorChannel, GRADIENT_TYPE type);\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = 3;\n        frames      = imgIn[0]->frames;\n    }   \n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param type\n     * @param colorChannel\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut = NULL,\n                             GRADIENT_TYPE type = G_SOBEL, int colorChannel = 0)\n    {\n        FilterGradient filter(colorChannel, type);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\nPIC_INLINE FilterGradient::FilterGradient() : Filter()\n{\n    update(0, G_NORMAL);\n}\n\nPIC_INLINE FilterGradient::FilterGradient(int colorChannel,\n        GRADIENT_TYPE type = G_NORMAL) : Filter()\n{\n    update(colorChannel, type);\n}\n\nPIC_INLINE void FilterGradient::update(int colorChannel,\n                                           GRADIENT_TYPE type = G_NORMAL)\n{\n    this->colorChannel = colorChannel;\n    this->type = type;\n\n    switch(type) {\n    case G_SOBEL: {\n        mask[0] = 1.0f;\n        mask[1] = 2.0f;\n        mask[2] = 1.0f;\n    }\n    break;\n\n    case G_PREWITT: {\n        mask[0] = 1.0f;\n        mask[1] = 1.0f;\n        mask[2] = 1.0f;\n    }\n    break;\n\n    case G_NORMAL: {\n        mask[0] = 0.0f;\n        mask[1] = 1.0f;\n        mask[2] = 0.0f;\n    }\n    break;\n\n    }\n}\n\nPIC_INLINE void FilterGradient::ProcessBBox(Image *dst, ImageVec src,\n        BBox *box)\n{\n    Image *img = src[0];\n\n    int channel = (img->channels == 1) ? 0 : colorChannel;\n\n    for(int j = box->y0; j < box->y1; j++) {\n        for(int i = box->x0; i < box->x1; i++) {\n            float gradX = 0.0f;\n            float gradY = 0.0f;\n\n            for(int k = -1; k < 2; k++) {\n                float val = mask[k + 1];\n\n                gradX += val * (*img)(i + 1, j + k)[channel];\n                gradX -= val * (*img)(i - 1, j + k)[channel];\n\n                gradY += val * (*img)(i + k, j + 1)[channel];\n                gradY -= val * (*img)(i + k, j - 1)[channel];\n            }\n\n            float *dst_data = (*dst)(i, j);\n\n            dst_data[0] = gradX;\n            dst_data[1] = gradY;\n            dst_data[2] = sqrtf(gradX * gradX + gradY * gradY);\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_GRADIENT_HPP */\n"
  },
  {
    "path": "include/filtering/filter_gradient_harris_opt.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_GRADIENT_HARRIS_OPT_HPP\n#define PIC_FILTERING_FILTER_GRADIENT_HARRIS_OPT_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGradientHarrisOPT class\n */\nclass FilterGradientHarrisOPT: public Filter\n{\nprotected:\n    int colorChannel;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n\n    /**\n     * @brief FilterGradientHarrisOPT\n     * @param colorChannel\n     */\n    FilterGradientHarrisOPT(int colorChannel);\n\n    /**\n     * @brief update\n     * @param colorChannel\n     */\n    void update(int colorChannel);\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = 3;\n        frames      = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param colorChannel\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut = NULL, int colorChannel = 0)\n    {\n        FilterGradientHarrisOPT filter(colorChannel);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\nPIC_INLINE FilterGradientHarrisOPT::FilterGradientHarrisOPT(int colorChannel) : Filter()\n{\n    this->colorChannel = 0;\n    update(colorChannel);\n}\n\nPIC_INLINE void FilterGradientHarrisOPT::update(int colorChannel)\n{\n    if(colorChannel > -1) {\n        this->colorChannel = colorChannel;\n    }\n}\n\nPIC_INLINE void FilterGradientHarrisOPT::ProcessBBox(Image *dst, ImageVec src,\n        BBox *box)\n{\n    Image *img = src[0];\n\n    int channel = (img->channels == 1) ? 0 : colorChannel;\n\n    for(int j = box->y0; j < box->y1; j++) {\n        for(int i = box->x0; i < box->x1; i++) {\n            float I_x = (*img)(i + 1, j)[channel] - (*img)(i - 1, j)[channel];\n            float I_y = (*img)(i, j + 1)[channel] - (*img)(i, j - 1)[channel];\n\n            float *dst_data = (*dst)(i, j);\n\n            dst_data[0] = I_x * I_x;\n            dst_data[1] = I_y * I_y;\n            dst_data[2] = I_x * I_y;\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_GRADIENT_HARRIS_OPT_HPP */\n"
  },
  {
    "path": "include/filtering/filter_grow_cut.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_GROW_CUT_HPP\n#define PIC_FILTERING_FILTER_GROW_CUT_HPP\n\n#include \"../filtering/filter.hpp\"\n#include \"../util/array.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGrowCut class\n */\nclass FilterGrowCut: public Filter\n{\nprotected:\n\n    int dx[8], dy[8];\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {                \n        Image *state_cur  = src[0];\n        Image *img        = src[1];\n        Image *img_max    = src[2];\n\n        Image *state_next  = dst;\n\n        int channels = img->channels;\n\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *s_cur = (*state_cur)(i, j);\n                float *s_next = (*state_next)(i, j);\n                float *col = (*img)(i, j);\n\n                float C = (*img_max)(i, j)[0];\n\n                s_next[0] = s_cur[0];\n                s_next[1] = s_cur[1];\n\n                for(int k = 0; k < 8; k++) {\n                    int x = i + dx[k];\n                    int y = j + dy[k];\n\n                    float *s_cur_k = (*state_cur)(x, y);\n                    float *col_k = (*img)(x, y);\n\n                    float dist = Arrayf::distanceSq(col, col_k, channels);\n\n                    float g_theta = 1.0f - (dist / C);\n                    g_theta *= s_cur_k[1];\n\n                    if(g_theta > s_cur[1]) {\n                        s_next[0] = s_cur_k[0];\n                        s_next[1] = g_theta;\n                    }\n                }\n            }\n        }\n    }\n\n\npublic:\n\n    /**\n     * @brief FilterGrowCut\n     */\n    FilterGrowCut() : Filter()\n    {\n        int dx_t[8] = {-1, 0, 1, -1, 1, -1,  0,  1};\n        int dy_t[8] = { 1, 1, 1,  0, 0, -1, -1, -1};\n\n        memcpy(dx, dx_t, sizeof(int) * 8);\n        memcpy(dy, dy_t, sizeof(int) * 8);\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_GROW_CUT_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_guided.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_GUIDED_HPP\n#define PIC_FILTERING_FILTER_GUIDED_HPP\n\n#include \"../filtering/filter.hpp\"\n\n#include \"../util/array.hpp\"\n\n#include \"../util/matrix_3_x_3.hpp\"\n\n#include \"../filtering/filter_guided_a_b.hpp\"\n\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGuided class\n */\nclass FilterGuided: public Filter\n{\nprotected:\n\n    int radius;\n    float e_regularization, nPixels;\n    Image *img_a_b;\n\n    FilterGuidedAB flt;\n\n    /**\n     * @brief Process1Channel\n     * @param I\n     * @param p\n     * @param q\n     * @param box\n     */\n    void Process1Channel(Image *I, Image *p, Image *q, BBox *box);\n\n    /**\n     * @brief Process3Channel\n     * @param I\n     * @param p\n     * @param q\n     * @param box\n     */\n    void Process3Channel(Image *I, Image *p, Image *q, BBox *box);\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n\n    /**\n     * @brief FilterGuided\n     */\n    FilterGuided() : Filter()\n    {\n        update(5, 0.01f);\n    }\n\n    /**\n     * @brief FilterGuided\n     * @param radius\n     * @param e_regularization\n     */\n    FilterGuided(int radius, float e_regularization) : Filter()\n    {\n        update(radius, e_regularization);\n    }\n\n    /**\n     * @brief update\n     * @param radius\n     * @param e_regularization\n     */\n    void update(int radius, float e_regularization);\n\n    /**\n     * @brief FilterGuided::Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut);\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param guide\n     * @param imgOut\n     * @param radius\n     * @param e_regularization\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *guide, Image *imgOut,\n                             int radius, float e_regularization)\n    {\n        FilterGuided filter(radius, e_regularization);\n        return filter.Process(Double(imgIn, guide), imgOut);\n    }\n};\n\nPIC_INLINE void FilterGuided::update(int radius, float e_regularization)\n{\n    img_a_b = NULL;\n\n    this->radius = radius;\n    this->e_regularization = e_regularization;\n    nPixels = float(radius * radius * 4);\n\n    flt.update(radius, e_regularization);\n}\n\nPIC_INLINE void FilterGuided::Process1Channel(Image *I, Image *p, Image *q,\n                                   BBox *box)\n{\n    float *a_b_mean = new float[img_a_b->channels];\n\n    for(int j = box->y0; j < box->y1; j++) {\n        for(int i = box->x0; i < box->x1; i++) {\n            float *tmpQ = (*q)(i, j);\n            float *tmpI = (*I)(i, j);\n\n            BBox tmpBox(i - radius, i + radius, j - radius, j + radius);\n            img_a_b->getMeanVal(&tmpBox, a_b_mean);\n\n            for(int c = 0; c < p->channels; c++) {\n                int index = c << 1;\n                float a = a_b_mean[index];\n                float b = a_b_mean[index + 1];\n                tmpQ[c] = a * tmpI[0] + b;\n            }\n        }\n    }\n\n    delete[] a_b_mean;\n}\n\nPIC_INLINE void FilterGuided::Process3Channel(Image *I, Image *p,\n        Image *q, BBox *box)\n{\n    float *a_b_mean = new float[img_a_b->channels];\n\n    int shift = I->channels + 1;\n\n    for(int j = box->y0; j < box->y1; j++) {\n        for(int i = box->x0; i < box->x1; i++) {\n            float *tmpQ = (*q)(i, j);\n            float *tmpI = (*I)(i, j);\n\n            BBox tmpBox(i - radius, i + radius, j - radius, j + radius);\n            img_a_b->getMeanVal(&tmpBox, a_b_mean);\n\n            for(int c = 0; c < p->channels; c++) {\n\n                int index = c * shift;\n                float *a = &a_b_mean[index];\n                float b = a_b_mean[index + I->channels];\n\n                float a_dot_I = Array<float>::dot(a, tmpI, I->channels);\n\n                tmpQ[c] = a_dot_I + b;\n            }\n\n        }\n    }\n    delete[] a_b_mean;\n}\n\nPIC_INLINE void FilterGuided::ProcessBBox(Image *dst, ImageVec src,\n        BBox *box)\n{\n    Image *I, *p;\n\n    if(src.size() == 2) {\n        p = src[0];\n\n        if(src[1] != NULL) {\n            I = src[1];\n        } else {\n            I = src[0];\n        }\n    } else {\n        I = src[0];\n        p = src[0];\n    }\n\n    if(I->channels == 3) {\n        Process3Channel(I, p, dst, box);\n    } else {\n        Process1Channel(I, p, dst, box);\n    }\n}\n\nPIC_INLINE Image *FilterGuided::Process(ImageVec imgIn, Image *imgOut)\n{\n    if(!checkInput(imgIn)) {\n        return imgOut;\n    }\n\n    imgOut = setupAux(imgIn, imgOut);\n\n    if(imgOut == NULL) {\n        return imgOut;\n    }\n\n    img_a_b = flt.Process(imgIn, img_a_b);\n\n    return ProcessP(imgIn, imgOut);\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_GUIDED_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_guided_a_b.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_GUIDED_A_B_HPP\n#define PIC_FILTERING_FILTER_GUIDED_A_B_HPP\n\n#include \"../filtering/filter.hpp\"\n\n#include \"../util/array.hpp\"\n\n#include \"../util/matrix_3_x_3.hpp\"\n\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGuidedAB class\n */\nclass FilterGuidedAB: public Filter\n{\nprotected:\n\n    int radius;\n    float e_regularization, nPixels;\n\n    /**\n     * @brief Process1Channel\n     * @param I\n     * @param p\n     * @param q\n     * @param box\n     */\n    void Process1Channel(Image *I, Image *p, Image *q, BBox *box);\n\n    /**\n     * @brief Process3Channel\n     * @param I\n     * @param p\n     * @param q\n     * @param box\n     */\n    void Process3Channel(Image *I, Image *p, Image *q, BBox *box);\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n\n    /**\n     * @brief FilterGuidedAB\n     */\n    FilterGuidedAB() : Filter()\n    {\n        update(8, 0.01f);\n    }\n\n    /**\n     * @brief FilterGuidedAB\n     * @param radius\n     * @param e_regularization\n     */\n    FilterGuidedAB(int radius, float e_regularization) : Filter()\n    {\n        update(radius, e_regularization);\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width = imgIn[0]->width;\n        height = imgIn[0]->height;\n        channels = getp(imgIn)->channels * (getI(imgIn)->channels + 1);\n        frames = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief getI\n     * @param imgIn\n     * @return\n     */\n    Image *getI(ImageVec &imgIn)\n    {\n        auto n = imgIn.size();\n        if(n == 1) {\n            return imgIn[0];\n        } else {\n            if(n > 1) {\n                return imgIn[1];\n            } else {\n                return NULL;\n            }\n        }\n    }\n\n    /**\n     * @brief getp\n     * @param imgIn\n     * @return\n     */\n    Image *getp(ImageVec &imgIn)\n    {\n        auto n = imgIn.size();\n        if(n == 1) {\n            return imgIn[0];\n        } else {\n            if(n > 1) {\n                return imgIn[0];\n            } else {\n                return NULL;\n            }\n        }\n    }\n\n    /**\n     * @brief update\n     * @param radius\n     * @param e_regularization\n     */\n    void update(int radius, float e_regularization);\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param guide\n     * @param imgOut\n     * @param radius\n     * @param e_regularization\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *guide, Image *imgOut,\n                             int radius, float e_regularization)\n    {\n        FilterGuidedAB filter(radius, e_regularization);\n        return filter.Process(Double(imgIn, guide), imgOut);\n    }\n};\n\nPIC_INLINE void FilterGuidedAB::update(int radius, float e_regularization)\n{\n    this->radius = radius;\n    this->e_regularization = e_regularization;\n    nPixels = float(radius * radius * 4);\n}\n\nPIC_INLINE void FilterGuidedAB::Process1Channel(Image *I, Image *p, Image *q,\n                                   BBox *box)\n{\n    float I_mean, I_var;\n    float *p_mean = new float [p->channels];\n\n    for(int j = box->y0; j < box->y1; j++) {\n        for(int i = box->x0; i < box->x1; i++) {\n            float *tmpQ = (*q)(i, j);\n\n            BBox tmpBox(i - radius, i + radius, j - radius, j + radius);\n\n            I->getMeanVal(&tmpBox, &I_mean);\n            I->getVarianceVal(&I_mean, &tmpBox, &I_var);\n\n            p->getMeanVal(&tmpBox, p_mean);\n\n            for(int c = 0; c < p->channels; c++) {\n                float I_mean_p_mean = I_mean * p_mean[c];\n                float a = 0.0f;\n\n                for(int k = -radius; k < radius; k++) {\n                    for(int l = -radius; l < radius; l++) {\n                        float *I_i = (*I)(i + l, j + k);\n                        float *p_i = (*p)(i + l, j + k);\n                        a += I_i[0] * p_i[c] - I_mean_p_mean;\n                    }\n                }\n\n                a /= (nPixels * (I_var + e_regularization));\n                float b = p_mean[c] - a * I_mean;\n\n                int index = c << 1;\n                tmpQ[index] = a;\n                tmpQ[index + 1] = b;\n            }\n        }\n    }\n\n    delete[] p_mean;\n}\n\nPIC_INLINE void FilterGuidedAB::Process3Channel(Image *I, Image *p,\n        Image *q, BBox *box)\n{\n    float *I_mean = new float[I->channels];\n    float *p_mean = new float[p->channels];\n\n    float *a = new float[I->channels];\n    float *tmp_A = new float[I->channels];\n\n    Matrix3x3 cov, inv;\n\n    for(int j = box->y0; j < box->y1; j++) {\n        for(int i = box->x0; i < box->x1; i++) {\n            float *tmpQ = (*q)(i, j);\n\n            BBox tmpBox(i - radius, i + radius, j - radius, j + radius);\n\n            I->getMeanVal(&tmpBox, I_mean);\n            I->getCovMtxVal(I_mean, &tmpBox, cov.data);\n\n            //regularization\n            cov.add(e_regularization);\n            //invert matrix\n            cov.inverse(&inv);\n\n            p->getMeanVal(&tmpBox, p_mean);\n\n            int index = 0;\n            for(int c = 0; c < p->channels; c++) {\n\n                Array<float>::assign(0.0f, tmp_A, I->channels);\n\n                for(int k = -radius; k < radius; k++) {\n                    for(int l = -radius; l < radius; l++) {\n                        float *I_i = (*I)(i + l, j + k);\n                        float *p_i = (*p)(i + l, j + k);\n\n                        for(int n = 0; n < I->channels; n++) {\n                            tmp_A[n] += I_i[n] * p_i[c] - I_mean[n] * p_mean[c];\n                        }\n                    }\n                }\n\n                Array<float>::div(tmp_A, I->channels, nPixels);\n\n                //multiply for inverted matrix\n                a = inv.mul(tmp_A, a);\n\n                float a_dot_I_mean = Array<float>::dot(a, I_mean, I->channels);\n                //float a_dot_I = Array<float>::dot(a, tmpI, channels);\n\n                for(int n = 0; n < I->channels; n++) {\n                    tmpQ[index] = a[n];\n                    index++;\n                }\n\n                //b\n                tmpQ[index] = p_mean[c] - a_dot_I_mean;\n                index++;\n            }\n        }\n    }\n}\n\nPIC_INLINE void FilterGuidedAB::ProcessBBox(Image *dst, ImageVec src,\n        BBox *box)\n{\n    Image *I = getI(src);\n    Image *p = getp(src);\n\n    if(I->channels == 1) {\n        Process1Channel(I, p, dst, box);\n    }\n\n    if(I->channels == 3) {\n        Process3Channel(I, p, dst, box);\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_GUIDED_A_B_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_integral_image.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_INTEGRAL_IMAGE\n#define PIC_FILTERING_FILTER_INTEGRAL_IMAGE\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterIntegralImage class\n */\nclass FilterIntegralImage: public Filter\n{\npublic:\n\n    /**\n     * @brief FilterIntegralImage\n     */\n    FilterIntegralImage() : Filter()\n    {\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut)\n    {\n        if(imgIn.empty()){\n            return imgOut;\n        }\n\n        if(imgIn[0] == NULL) {\n            return imgOut;\n        }\n\n        imgOut = setupAux(imgIn, imgOut);\n\n        int width = imgIn[0]->width;\n        int height = imgIn[0]->height;\n        int channels = imgIn[0]->channels;\n\n        //set up the first pixel (0,0)\n        for(int k = 0; k < channels; k++) {\n            imgOut->data[k] = imgIn[0]->data[k];\n        }\n\n        //set up the first row\n        for(int j=1; j<width; j++) {\n            int ind1 = j * channels;\n            int ind2 = ind1 - channels;\n\n            for(int k=0; k<channels; k++) {\n                imgOut->data[ind1 + k] = imgIn[0]->data[ind1 + k] + imgOut->data[ind2 + k];\n            }\n        }\n\n        //set up the first column\n        int c1 = width * channels;\n        for(int i=1; i<height; i++){\n            int ind1 = i * c1;\n            int ind2 = ind1 - c1;\n            for(int k=0; k<channels; k++) {\n                imgOut->data[ind1 + k] = imgIn[0]->data[ind1 + k] + imgOut->data[ind2 + k];\n            }\n        }\n\n        int c2 = (width + 1) * channels;\n\n        for(int i=1; i<height; i++) {\n            int ind = i * width;\n            for(int j=1; j<width; j++) {\n                int ind1 = (ind + j) * channels;\n                int ind2 = ind1 - channels;\n                int ind3 = ind1 - c1;\n                int ind4 = ind1 - c2;\n\n                for(int k=0; k<channels; k++) {\n                    imgOut->data[ind1 + k] = imgIn[0]->data[ind1 + k] +\n                                             imgOut->data[ind2 + k] +\n                                             imgOut->data[ind3 + k] -\n                                             imgOut->data[ind4 + k];\n                }\n            }\n        }\n\n        return imgOut;\n    }\n\n    /**\n     * @brief ProcessP\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *ProcessP(ImageVec imgIn, Image *imgOut)\n    {\n        return Process(imgIn, imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_INTEGRAL_IMAGE_HPP */\n"
  },
  {
    "path": "include/filtering/filter_iterative.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_ITERATIVE_HPP\n#define PIC_FILTERING_FILTER_ITERATIVE_HPP\n\n#include \"../filtering/filter_npasses.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterIterative class\n */\nclass FilterIterative: public FilterNPasses\n{\nprotected:\n    int iterations;\n\n    /**\n     * @brief getFilter\n     * @param i\n     * @return\n     */\n    Filter* getFilter(int i);\n\n    /**\n     * @brief getFilter\n     * @param i\n     * @return\n     */\n    int getIterations();\n\npublic:\n\n    /**\n     * @brief FilterIterative\n     * @param flt\n     * @param iterations\n     */\n    FilterIterative(Filter *flt, int iterations);\n\n    /**\n     * @brief update\n     * @param flt\n     * @param iterations\n     */\n    void update(Filter *flt, int iterations);\n\n};\n\nPIC_INLINE FilterIterative::FilterIterative(Filter *flt, int iterations) : FilterNPasses()\n{\n    printf(\"\\n\\n%d\\n\\n\", iterations);\n    update(flt, iterations);\n}\n\nPIC_INLINE void FilterIterative::update(Filter *flt, int iterations)\n{\n    if(iterations > 0) {\n        this->iterations = iterations;\n    }\n\n    if(flt == NULL) {\n        return;\n    }\n\n    if(!filters.empty()) {\n        filters.clear();\n    }\n\n    filters.push_back(flt);\n}\n\nPIC_INLINE Filter* FilterIterative::getFilter(int i)\n{\n    return filters[0];\n}\n\nPIC_INLINE int FilterIterative::getIterations()\n{\n    return iterations;\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_ITERATIVE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_kuwahara.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_KUWAHARA_HPP\n#define PIC_FILTERING_FILTER_KUWAHARA_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterKuwahara class\n */\nclass FilterKuwahara: public Filter\n{\nprotected:\n    unsigned int  kernelSize;\n    unsigned int  halfKernelSize;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        int channels = dst->channels;\n\n        Image *source = src[0];\n\n        float *buf = new float[channels * 8];\n\n        int start = 0;\n        float *m00 = &buf[start];\n        start += channels;\n        float *m10 = &buf[start];\n        start += channels;\n        float *m01 = &buf[start];\n        start += channels;\n        float *m11 = &buf[start];\n        start += channels;\n        float *s00 = &buf[start];\n        start += channels;\n        float *s10 = &buf[start];\n        start += channels;\n        float *s01 = &buf[start];\n        start += channels;\n        float *s11 = &buf[start];\n\n        for(int m = box->z0; m < box->z1; m++) {\n            for(int j = box->y0; j < box->y1; j++) {\n                for(int i = box->x0; i < box->x1; i++) {\n                    //1D Filtering\n                    float mean = FLT_MAX;\n                    int indx;\n                    float tmpMean;\n\n                    float *tmpDst = (*dst)(i, j, m);\n\n                    //First block\n                    BBox tmp00(i - halfKernelSize, i + 1, j - halfKernelSize, j + 1);\n                    source->getMeanVal(&tmp00, m00);\n                    source->getVarianceVal(m00, &tmp00, s00);\n\n                    tmpMean = 0.0f;\n\n                    for(int l = 0; l < channels; l++) {\n                        tmpMean += s00[l];\n                    }\n\n                    if(tmpMean < mean) {\n                        mean = tmpMean;\n                        indx = 0;\n                    }\n\n                    //Second block\n                    BBox tmp01(i, i + halfKernelSize, j - halfKernelSize, j + 1);\n                    source->getMeanVal(&tmp01, m01);\n                    source->getVarianceVal(m01, &tmp01, s01);\n\n                    tmpMean = 0.0f;\n\n                    for(int l = 0; l < channels; l++) {\n                        tmpMean += s01[l];\n                    }\n\n                    if(tmpMean < mean) {\n                        mean = tmpMean;\n                        indx = 1;\n                    }\n\n                    //Third block\n                    BBox tmp10(i - halfKernelSize, i + 1, j, j + halfKernelSize);\n                    source->getMeanVal(&tmp10, m10);\n                    source->getVarianceVal(m10, &tmp10, s10);\n\n                    tmpMean = 0.0f;\n\n                    for(int l = 0; l < channels; l++) {\n                        tmpMean += s10[l];\n                    }\n\n                    if(tmpMean < mean) {\n                        mean = tmpMean;\n                        indx = 2;\n                    }\n\n                    //Fourth block\n                    BBox tmp11(i, i + halfKernelSize, j, j + halfKernelSize);\n                    source->getMeanVal(&tmp11, m11);\n                    source->getVarianceVal(m11, &tmp11, s11);\n\n                    tmpMean = 0.0f;\n\n                    for(int l = 0; l < channels; l++) {\n                        tmpMean += s11[l];\n                    }\n\n                    if(tmpMean < mean) {\n                        mean = tmpMean;\n                        indx = 3;\n                    }\n\n                    //final filtering\n                    switch(indx) {\n                    case 0: {\n                        for(int l = 0; l < channels; l++) {\n                            tmpDst[l] = m00[l];\n                        }\n                    }\n                    break;\n\n                    case 1: {\n                        for(int l = 0; l < channels; l++) {\n                            tmpDst[l] = m01[l];\n                        }\n                    }\n                    break;\n\n                    case 2: {\n                        for(int l = 0; l < channels; l++) {\n                            tmpDst[l] = m10[l];\n                        }\n                    }\n                    break;\n\n                    case 3: {\n                        for(int l = 0; l < channels; l++) {\n                            tmpDst[l] = m11[l];\n                        }\n                    }\n                    break;\n\n                    default: {\n                        float *tmpSrc = (*source)(i, j, m);\n                        for(int l = 0; l < channels; l++) {\n                            tmpDst[l] = tmpSrc[l];\n                        }\n                    }break;\n                    }\n                }\n            }\n        }\n\n        delete[] buf;\n    }\n\npublic:\n    /**\n     * @brief FilterKuwahara\n     * @param kernelSize\n     */\n    FilterKuwahara(int kernelSize = 3)\n    {\n        update(kernelSize);\n    }\n\n    /**\n     * @brief update\n     * @param kernelSize\n     */\n    void update(int kernelSize)\n    {\n        if(kernelSize < 3) {\n            kernelSize = 3;\n        }\n\n        this->kernelSize = kernelSize;\n        halfKernelSize = kernelSize >> 1;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param kernelSize\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, int kernelSize)\n    {\n        FilterKuwahara filter(kernelSize);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_KUWAHARA_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_laplacian.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_LAPLACIAN_HPP\n#define PIC_FILTERING_FILTER_LAPLACIAN_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterLaplacian class\n */\nclass FilterLaplacian: public Filter\n{\nprotected:\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        int channels = src[0]->channels;\n\n        Image *in = src[0];\n\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *cur = (*in)(i, j);\n                float *out = (*dst)(i, j);\n\n                //neighbors\n                float *N = (*in)(i    , j + 1);\n                float *S = (*in)(i    , j - 1);\n                float *E = (*in)(i + 1, j);\n                float *W = (*in)(i - 1, j);\n\n                for(int k = 0; k < channels; k++) {\n                    out[k] = (-4.0f * cur[k]) + N[k] + S[k] + E[k] + W[k];\n                }\n            }\n        }\n    }\n\npublic:\n    /**\n     * @brief FilterLaplacian\n     */\n    FilterLaplacian() : Filter()\n    {\n\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        FilterLaplacian filter;\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_LAPLACIAN_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_linear_color_space.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_LINEAR_COLOR_SPACE_HPP\n#define PIC_FILTERING_FILTER_LINEAR_COLOR_SPACE_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterLinearColorSpace class\n */\nclass FilterLinearColorSpace: public Filter\n{\nprotected:\n    float\t\t*matrix;\n    int\t\t\tnMatrix;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        if(src[0]->channels != nMatrix) {\n            return;\n        }\n\n        int width = dst->width;\n        int channels = src[0]->channels;\n        float *data  = src[0]->data;\n\n        for(int j = box->y0; j < box->y1; j++) {\n            int c = j * width;\n\n            for(int i = box->x0; i < box->x1; i++) {\n                int c1 = (c + i) * channels;\n\n                for(int k = 0; k < channels; k++) {\n                    float sum = 0.0f;\n                    int ind   = k * nMatrix;\n\n                    for(int l = 0; l < channels; l++) {\n                        sum += data[c1 + l] * matrix[ind + l];\n                    }\n\n                    dst->data[c1 + k] = sum;\n                }\n            }\n        }\n    }\n\npublic:\n    /**\n     * @brief FilterLinearColorSpace\n     */\n    FilterLinearColorSpace() : Filter()\n    {\n        matrix  = NULL;\n        nMatrix = 0;\n    }\n\n    ~FilterLinearColorSpace()\n    {\n        if(matrix != NULL) {\n            delete[] matrix;\n        }\n    }\n\n    /**\n     * @brief getRGB2XYZMatrix\n     * @return\n     */\n    float *getRGB2XYZMatrix()\n    {\n        if(matrix == NULL) {\n            matrix = new float[9];\n        }\n\n        nMatrix = 3;\n\n        matrix[0] = 0.4124f;\n        matrix[1] = 0.3576f;\n        matrix[2] = 0.1805f;\n        matrix[3] = 0.2126f;\n        matrix[4] = 0.7152f;\n        matrix[5] = 0.0722f;\n        matrix[6] = 0.0193f;\n        matrix[7] = 0.1192f;\n        matrix[8] = 0.9505f;\n\n        return matrix;\n    }\n\n    /**\n     * @brief getXYZ2RGBMatrix\n     * @return\n     */\n    float *getXYZ2RGBMatrix()\n    {\n        if(matrix == NULL) {\n            matrix = new float[9];\n        }\n\n        nMatrix = 3;\n\n        matrix[0] =  3.2406f;\n        matrix[1] = -1.5372f;\n        matrix[2] = -0.4986f;\n        matrix[3] = -0.9689f;\n        matrix[4] =  1.8758f;\n        matrix[5] =  0.0415f;\n        matrix[6] =  0.0557f;\n        matrix[7] = -0.2040f;\n        matrix[8] =  1.0570f;\n\n        return matrix;\n    }\n\n    /**\n     * @brief execute_RGB_to_XYZ\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute_RGB_to_XYZ(Image *imgIn, Image *imgOut)\n    {\n        FilterLinearColorSpace flt;\n\n        flt.getRGB2XYZMatrix();\n\n        return flt.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief execute_XYZ_to_RGB\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute_XYZ_to_RGB(Image *imgIn, Image *imgOut)\n    {\n        FilterLinearColorSpace flt;\n\n        flt.getXYZ2RGBMatrix();\n\n        return flt.Process(Single(imgIn), imgOut);\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_LINEAR_COLOR_SPACE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_local_extrema.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_LOCAL_EXTREMA_HPP\n#define PIC_FILTERING_FILTER_LOCAL_EXTREMA_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterLocalExtrema class\n */\nclass FilterLocalExtrema: public Filter\n{\nprotected:\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        Image *img  = src[0];\n\n        int channels = dst->channels;\n\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *dst_data = (*dst)(i, j);\n\n                float *img_data  = (*img)(i, j);\n\n                float val = 0.0f;\n\n                for(int c = 0; c < channels; c++) {\n                    val += img_data[c];\n                }\n\n                int counter_higher = 0;\n                int counter_lower = 0;\n                for(int k = -halfKernelSize; k <= halfKernelSize; k++) {\n                    for(int l = -halfKernelSize; l <= halfKernelSize; l++) {\n                        if(l == k) {\n                            continue;\n                        }\n\n                        float *img_data_lk  = (*img)(i + l, j + k);\n\n                        //accumulation\n                        float val_lk = 0.0f;\n                        for(int c = 0; c < channels; c++) {\n                            val_lk += img_data_lk[c];\n                        }\n\n                        if(val_lk >= val) {\n                            counter_higher++;\n                        }\n\n                        if(val_lk <= val) {\n                            counter_lower++;\n                        }\n                    }\n                }\n\n                if(counter_higher < kernelSize) {\n                    dst_data[0] = 1.0f;\n                } else {\n                    if(counter_lower < kernelSize) {\n                        dst_data[0] = -1.0f;\n                    } else {\n                        dst_data[0] = 0.0f;\n                    }\n                }\n            }\n        }\n    }\n\n    int kernelSize, halfKernelSize;\n\npublic:\n\n    /**\n     * @brief FilterLocalExtrema\n     */\n    FilterLocalExtrema(int kernelSize = 3) : Filter()\n    {\n        if(kernelSize < 2) {\n            kernelSize = 3;\n        }\n\n        if((kernelSize % 2) == 0) {\n            kernelSize++;\n        }\n\n        this->kernelSize = kernelSize;\n        this->halfKernelSize = kernelSize >> 1;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = 1;\n        frames      = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief execute\n     * @param img\n     * @param conv\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *img, Image *imgOut, int kernelSize = 3)\n    {\n        FilterLocalExtrema flt(kernelSize);\n        return flt.Process(Single(img), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_LOCAL_EXTREMA_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_log_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_LOG_2D_HPP\n#define PIC_FILTERING_FILTER_LOG_2D_HPP\n\n#include \"../filtering/filter_diff_gauss_2d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterLoG2D class\n */\nclass FilterLoG2D: public FilterDiffGauss\n{\n\npublic:\n    float sigma;\n\n    /**\n     * @brief FilterLoG2D\n     * @param sigma\n     */\n    FilterLoG2D(float sigma) : FilterDiffGauss(sigma * sqrtf(2.0f), sigma / sqrtf(2.0f))\n    {\n        this->sigma = sigma;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma_1\n     * @param sigma_2\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float sigma)\n    {\n        FilterLoG2D filter(sigma);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_LOG_2D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_log_2d_opt.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_LOG_2D_OPT_HPP\n#define PIC_FILTERING_FILTER_LOG_2D_OPT_HPP\n\n#include \"../filtering/filter_diff_gauss_2d_opt.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterLoG2DOpt class\n */\nclass FilterLoG2DOpt: public FilterDiffGaussOpt\n{\n\npublic:\n    float sigma;\n\n    /**\n     * @brief FilterLoG2DOpt\n     * @param sigma\n     */\n    FilterLoG2DOpt(float sigma) : FilterDiffGaussOpt(sigma * sqrtf(2), sigma / sqrtf(2.0f))\n    {\n        this->sigma = sigma;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma_1\n     * @param sigma_2\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float sigma)\n    {\n        FilterLoG2DOpt filter(sigma);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_LOG_2D_OPT_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_luminance.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_LUMINANCE_HPP\n#define PIC_FILTERING_FILTER_LUMINANCE_HPP\n\n#include \"../util/array.hpp\"\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\nenum LUMINANCE_TYPE{LT_CIE_LUMINANCE, LT_LUMA, LT_WARD_LUMINANCE, LT_MEAN};\n\n/**\n * @brief The FilterLuminance class\n */\nclass FilterLuminance: public Filter\n{\nprotected:\n\n    LUMINANCE_TYPE type;\n    float *weights;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *data_src = (*src[0])(i, j);\n                float *data_dst = (*dst)(i, j);\n\n                data_dst[0] = Arrayf::dot(data_src, weights, src[0]->channels);\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterLuminance\n     * @param type\n     */\n    FilterLuminance(LUMINANCE_TYPE type = LT_CIE_LUMINANCE) : Filter()\n    {\n        weights = NULL;\n        update(type);\n    }\n\n    ~FilterLuminance()\n    {\n        weights = delete_s(weights);\n    }\n\n    /**\n     * @brief computeWeights\n     * @param type\n     * @param weights\n     * @return\n     */\n    static float *computeWeights(LUMINANCE_TYPE type, int channels, float *weights)\n    {\n        if(weights == NULL) {\n            weights = new float[channels];\n        }\n\n        if(channels == 3) {\n            switch(type)\n            {\n            case LT_WARD_LUMINANCE:\n             {\n                weights[0] =  54.0f  / 256.0f;\n                weights[1] =  183.0f / 256.0f;\n                weights[2] =  19.0f  / 256.0f;\n            } break;\n\n            case LT_LUMA:\n            {\n                weights[0] =  0.2989f;\n                weights[1] =  0.5870f;\n                weights[2] =  0.114f;\n            } break;\n\n            case LT_CIE_LUMINANCE:\n            {\n                weights[0] =  0.2126f;\n                weights[1] =  0.7152f;\n                weights[2] =  0.0722f;\n            } break;\n\n            default:\n            {\n                weights[0] = 1.0f / 3.0f;\n                weights[1] = weights[0];\n                weights[2] = weights[0];\n            }\n            }\n        } else {\n            if(channels == 1) {\n                weights[0] = 1.0f;\n            } else {\n                Arrayf::assign(1.0f / float(channels), weights, channels);\n            }\n        }\n\n        return weights;\n    }\n\n    /**\n     * @brief update\n     * @param type\n     */\n    void update(LUMINANCE_TYPE type = LT_CIE_LUMINANCE)\n    {\n        this->type = type;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = 1;\n        frames      = imgIn[0]->frames;\n\n        weights = delete_s(weights);\n        weights = computeWeights(type, imgIn[0]->channels, weights);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param type\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, LUMINANCE_TYPE type = LT_CIE_LUMINANCE)\n    {\n        FilterLuminance fltLum(type);\n        return fltLum.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_LUMINANCE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_luminance_adaptation.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_LUMINANCE_ADAPTATION_HPP\n#define PIC_FILTERING_FILTER_LUMINANCE_ADAPTATION_HPP\n\n#include <cmath>\n\n#include \"../util/math.hpp\"\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../algorithms/connected_components.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterLuminanceAdaptation class\n */\nclass FilterLuminanceAdaptation: public Filter\n{\nprotected:\n    float threshold;\n    float bin_size_1;\n    float bin_size_2;\n    float delta_bin_size;\n    int maxLayers;\n    FilterLuminance flt;\n    Image *lum;\n\npublic:\n\n    /**\n     * @brief FilterLuminanceAdaptation\n     * @param maxLayers\n     * @param threshold\n     */\n    FilterLuminanceAdaptation(int maxLayers = 32, float threshold = 0.05f) : Filter()\n    {\n        lum = NULL;\n        update(maxLayers, threshold);\n    }\n\n    /**\n     * @brief update\n     * @param maxLayers\n     * @param threshold\n     */\n    void update(int maxLayers = 32, float threshold = 0.05f)\n    {\n        this->threshold = threshold > 0.0f ? threshold : 0.05f;\n        this->maxLayers = maxLayers > 0 ? maxLayers : 32;\n\n        bin_size_1 = 0.5f;\n        bin_size_2 = 2.0f;\n        delta_bin_size = bin_size_2 - bin_size_1;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = 1;\n        frames      = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief Filter::Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut)\n    {\n        if(!checkInput(imgIn)) {\n            return imgOut;\n        }\n\n        imgOut = setupAux(imgIn, imgOut);\n\n        if(imgOut == NULL) {\n            return imgOut;\n        }\n\n        lum = flt.Process(imgIn, lum);\n        lum->applyFunction(log10fPlusEpsilon);\n\n        float lum_min;\n        lum->getMinVal(NULL, &lum_min);\n\n        int n = imgIn[0]->width * imgIn[0]->height;\n        int *category = new int[n];\n        unsigned int *img_labels = NULL;\n\n        imgOut->setZero();\n\n        float maxLayer_m_1 = float(maxLayers - 1);\n\n        for(int i = 0; i < maxLayers; i++) {\n            float bin_size = bin_size_1 + (float(i) * delta_bin_size / maxLayer_m_1);\n\n            #pragma omp parallel for\n            for(int j = 0; j < n; j++) {\n                category[j] = int(lround((lum->data[j] - lum_min) / bin_size));\n                category[j]++;\n            }\n\n            ConnectedComponents cc_int;\n\n            std::vector<LabelOutput> labelsList;\n            img_labels = cc_int.execute(category, imgIn[0]->width, imgIn[0]->height, img_labels, labelsList);\n\n            ConnectedComponents::mergeIsolatedAreasWithThreshold(img_labels, lum->width, lum->height, labelsList);\n\n            ConnectedComponents::reCount(img_labels, labelsList);\n\n            for(unsigned int j_ui = 0; j_ui < labelsList.size(); j_ui++) {\n                //mean luminance\n                float La_j_ui = IndexedArrayf::mean(lum->data, labelsList[j_ui].coords);\n                IndexedArrayf::add(imgOut->data, labelsList[j_ui].coords, La_j_ui);\n            }\n        }\n        (*imgOut) /= float (maxLayers);\n\n        imgOut->applyFunction(powf10fMinusEpsilon);\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_LUMINANCE_ADAPTATION_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_max.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_MAX_HPP\n#define PIC_FILTERING_FILTER_MAX_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterMax class\n */\nclass FilterMax: public Filter\n{\nprotected:\n    int halfSize;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        int channels = dst->channels;\n        \n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *dst_data = (*dst)(i, j);\n                float *src_data = (*src[0])(i, j);\n\n                for(int k = 0; k < channels; k++) {\n                    dst_data[k] = src_data[k];\n                }\n\n                for(int k = -halfSize; k <= halfSize; k++) {\n                    for(int l = -halfSize; l <= halfSize; l++) {\n\n                        src_data = (*src[0])(i + l, j + k);\n\n                        for(int ch = 0; ch < channels; ch++) {\n                            dst_data[ch] = dst_data[ch] > src_data[ch] ?\n                                           dst_data[ch] : src_data[ch];\n                        }\n                    }\n                }\n\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterMax\n     * @param size\n     */\n    FilterMax(int size) : Filter()\n    {\n        update(size);\n    }\n\n    ~FilterMax()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param size\n     */\n    void update(int size)\n    {\n        this->halfSize = checkHalfSize(size);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param size\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, int size)\n    {\n        FilterMax filter(size);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_MAX_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_mean.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_MEAN_HPP\n#define PIC_FILTERING_FILTER_MEAN_HPP\n\n#include \"../util/std_util.hpp\"\n#include \"../filtering/filter_npasses.hpp\"\n#include \"../filtering/filter_conv_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterMean class\n */\nclass FilterMean: public FilterNPasses\n{\nprotected:\n\nprotected:\n    FilterConv1D *filter;\n    float *data; //NOTE: we own this; so it can be deleted!\n    int size;\n\npublic:\n\n    /**\n     * @brief FilterMean\n     * @param size\n     */\n    FilterMean(int size) : FilterNPasses()\n    {\n        data = NULL;\n        this->size = -1;\n\n        update(size);\n\n        filter = new FilterConv1D(data, size);\n\n        insertFilter(filter);\n        insertFilter(filter);\n    }\n\n    ~FilterMean()\n    {\n        release();\n\n        delete_s(filter);\n        delete_vec_s(data);\n    }\n\n    /**\n     * @brief update\n     * @param size\n     */\n    void update(int size)\n    {\n        size = size > 0 ? size : 3;\n\n        if(this->size != size) {\n            this->size = size;\n\n            data = delete_vec_s(data);\n            data = FilterConv1D::getKernelMean(size);\n        }        \n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param size\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, int size)\n    {\n        FilterMean filter(size);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_MEAN_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_med.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_MED_HPP\n#define PIC_FILTERING_FILTER_MED_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterMed class\n */\nclass FilterMed: public Filter\n{\nprotected:\n    int halfSize, areaKernel, midValue;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        Image *in = src[0];\n        float *values = new float[areaKernel * in->channels];\n\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n\n                int c = 0;\n                for(int k = -halfSize; k <= halfSize; k++) {\n                    for(int l = -halfSize; l <= halfSize; l++) {\n\n                        float *color = (*in)(i + l, j + k);\n\n                        for(int ch = 0; ch < in->channels; ch++) {\n                            values[areaKernel * ch + c] = color[ch];\n                        }\n\n                        c++;\n                    }\n                }\n\n                float *out = (*dst) (i, j);\n\n                for(int ch = 0; ch < in->channels; ch++) {\n                    float *tmp_v_ch = &values[areaKernel * ch];\n                    std::sort(tmp_v_ch, tmp_v_ch + areaKernel);\n\n                    out[ch] = tmp_v_ch[midValue];\n                }\n            }\n        }\n\n        delete[] values;\n    }\n\npublic:\n    /**\n     * @brief FilterMed\n     * @param size\n     */\n    FilterMed(int size) : Filter()\n    {\n        update(size);\n    }\n\n    /**\n     * @brief update\n     * @param size\n     */\n    void update(int size)\n    {\n        this->halfSize = checkHalfSize(size);\n        size = (halfSize << 1) + 1;\n        this->areaKernel = size * size;\n        this->midValue = areaKernel >> 1;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param size\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, int size)\n    {\n        FilterMed filter(size);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_MED_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_med_vec.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_MED_VEC_HPP\n#define PIC_FILTERING_FILTER_MED_VEC_HPP\n\n#include \"../filtering/filter.hpp\"\n#include \"../util/array.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterMedVec class\n */\nclass FilterMedVec: public Filter\n{\nprotected:\n    int halfSize, areaKernel, midValue;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        Image *in = src[0];\n        float *values = new float[areaKernel * in->channels];\n\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n\n                int c = 0;\n                for(int k = -halfSize; k <= halfSize; k++) {\n                    for(int l = -halfSize; l <= halfSize; l++) {\n\n                        float *color = (*in)(i + l, j + k);\n\n                        for(int ch = 0; ch < in->channels; ch++) {\n                            values[c * in->channels + ch] = color[ch];\n                        }\n\n                        c++;\n                    }\n                }\n\n                //compute distances\n                int best = -1;\n                float distBest = FLT_MAX;\n\n                for(int k = 0; k < areaKernel; k++) {\n                    int index_k = k * in->channels;\n                    float dist = 0.0f;\n\n                    for(int l = 0; l < areaKernel; l++) {\n                        int index_l = l * in->channels;\n                        float d_sq = Arrayf::distanceSq(&values[index_k], &values[index_l], in->channels);\n                        dist += sqrtf(d_sq);\n                    }\n\n                    if(dist < distBest) {\n                        distBest = dist;\n                        best = k;\n                    }\n                }\n\n                float *out = (*dst) (i, j);\n\n                int index = best * in->channels;\n\n                for(int ch = 0; ch < in->channels; ch++) {\n                    out[ch] = values[index + ch];\n                }\n            }\n        }\n\n        delete[] values;\n    }\n\npublic:\n    /**\n     * @brief FilterMedVec\n     * @param size\n     */\n    FilterMedVec(int size) : Filter()\n    {\n        update(size);\n    }\n\n    /**\n     * @brief update\n     * @param size\n     */\n    void update(int size)\n    {\n        this->halfSize = checkHalfSize(size);\n\n        int kernelSize = (halfSize << 1) + 1;\n        this->areaKernel = kernelSize * kernelSize;\n\n        this->midValue = areaKernel >> 1;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param size\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, int size)\n    {\n        FilterMedVec filter(size);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_MED_VEC_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_min.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_MIN_HPP\n#define PIC_FILTERING_FILTER_MIN_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterMin class\n */\nclass FilterMin: public Filter\n{\nprotected:\n    int halfSize;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        int channels = dst->channels;\n        float *minVal = new float[channels];\n\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *dst_data = (*dst)(i, j);\n                float *src_data = (*src[0])(i, j);\n\n                for(int k = 0; k < channels; k++) {\n                    minVal[k] = src_data[k];\n                }\n\n                for(int k = -halfSize; k <= halfSize; k++) {\n                    for(int l = -halfSize; l <= halfSize; l++) {\n\n                        src_data = (*src[0])(i + l, j + k);\n\n                        for(int ch = 0; ch < channels; ch++) {\n                            minVal[ch] = minVal[ch] < src_data[ch] ?\n                                         minVal[ch] : src_data[ch];\n                        }\n                    }\n                }\n\n                for(int k = 0; k < channels; k++) {\n                    dst_data[k] = minVal[k];\n                }\n            }\n        }\n\n        delete[] minVal;\n    }\n\npublic:\n\n    /**\n     * @brief FilterMin\n     * @param size\n     */\n    FilterMin(int size) : Filter()\n    {\n        this->halfSize = checkHalfSize(size);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param size\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, int size)\n    {\n        FilterMin filter(size);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_MIN_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_mosaic.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_MOSAIC_HPP\n#define PIC_FILTERING_FILTER_MOSAIC_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterMosaic class\n */\nclass FilterMosaic: public Filter\n{\nprotected:\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        if(src[0]->channels != 3){\n            return;\n        }\n\n        int width = dst->width;\n        float *data = src[0]->data;\n\n        for(int j = box->y0; j < box->y1; j++) {\n            int c = j * width;\n            int mody = j % 2;\n\n            for(int i = box->x0; i < box->x1; i++) {\n                int modx = i % 2;\n\n                //indecies\n                int c1 = c + i;\n                int c3 = c1 * 3;\n\n                if(mody == 0 && modx == 0) { //Red\n                    dst->data[c1] = data[c3];\n                }\n\n                if(mody == 0 && modx == 1) { //Green\n                    dst->data[c1] = data[c3 + 1];\n                }\n\n                if(mody == 1 && modx == 0) { //Green\n                    dst->data[c1] = data[c3 + 1];\n                }\n\n                if(mody == 1 && modx == 1) { //Blue\n                    dst->data[c1] = data[c3 + 2];\n                }\n            }\n        }\n    }\n\npublic:\n    /**\n     * @brief FilterMosaic\n     */\n    FilterMosaic() : Filter()\n    {\n\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width    = imgIn[0]->width;\n        height   = imgIn[0]->height;\n        channels = 1;\n        frames   = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        FilterMosaic flt;\n        return flt.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_MOSAIC_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_nearest_neighbors.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_NEAREST_NEIGHBORS_HPP\n#define PIC_FILTERING_FILTER_NEAREST_NEIGHBORS_HPP\n\n#include \"../features_matching/patch_comp.hpp\"\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterNearestNeighbors class\n */\nclass FilterNearestNeighbors: public Filter\n{\nprotected:\n\n    PatchComp *pc;\n    int patchSize, halfPatchSize, stride;\n    int width_ps, height_ps;\n\n    /**\n     * @brief f\n     * @param data\n     */\n    void f(FilterFData *data)\n    {\n        int xb, yb;\n        float db = FLT_MAX;\n        for(int i = halfPatchSize; i < height_ps; i+= stride) {\n            for(int j = halfPatchSize; j < width_ps; j+= stride) {\n\n                float tmp_d = pc->getSSD(data->x, data->y, j, i);\n\n                if(tmp_d < db) {\n                    db = tmp_d;\n                    xb = j;\n                    yb = i;\n                }\n            }\n        }\n        data->out[0] = float(xb);\n        data->out[1] = float(yb);\n        data->out[1] = db;\n    }\n\n    /**\n     * @brief setupAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *setupAux(ImageVec imgIn, Image *imgOut)\n    {\n        height_ps = imgIn[1]->height - halfPatchSize;\n        width_ps = imgIn[1]->width - halfPatchSize;\n\n        pc = new PatchComp(imgIn[0], imgIn[1], patchSize);\n\n        return allocateOutputMemory(imgIn, imgOut, bDelete);\n    }\n\npublic:\n\n    /**\n     * @brief FilterNearestNeighbors\n     */\n    FilterNearestNeighbors() : Filter()\n    {\n        pc = NULL;\n        this->minInputImages = 2;\n    }\n\n    ~FilterNearestNeighbors()\n    {\n        delete_s(pc);\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = 3;\n        frames      = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief setup\n     * @param patchSize\n     * @param stride\n     */\n    void setup(int patchSize, int stride)\n    {\n        patchSize = (patchSize > 2) ? patchSize : 3;\n\n        if((patchSize % 2) == 0) {\n            patchSize++;\n        }\n\n        stride = stride > 0 ? stride : 1;\n\n        this->stride = stride;\n        this->patchSize = patchSize;\n\n        pc = delete_s(pc);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_NEAREST_NEIGHBORS_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_noise_estimation.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_NOISE_ESTIMATION_HPP\n#define PIC_FILTERING_FILTER_NOISE_ESTIMATION_HPP\n\n#include \"../util/math.hpp\"\n\n#include \"../filtering/filter.hpp\"\n\n#include \"../filtering/filter_conv_2d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterNoiseEstimation class\n */\nclass FilterNoiseEstimation: public Filter\n{\nprotected:\n    FilterConv2D flt;\n    Image *img_conv;\n    float *data;\n\npublic:\n\n    /**\n     * @brief FilterNoiseEstimation\n     * @param type\n     */\n    FilterNoiseEstimation() : Filter()\n    {\n        data = new float[9];\n\n        data[0] =  1.0f;\n        data[1] = -2.0f;\n        data[2] =  1.0f;\n\n        data[3] = -2.0f;\n        data[4] =  4.0f;\n        data[5] = -2.0f;\n\n        data[6] =  1.0f;\n        data[7] = -2.0f;\n        data[8] =  1.0f;\n\n        img_conv = new Image(1, 3, 3, 1, data);\n    }\n\n    ~FilterNoiseEstimation()\n    {\n        if(img_conv != NULL) {\n            delete img_conv;\n        }\n\n        if(data != NULL) {\n            delete[] data;\n        }\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut)\n    {\n        if(!checkInput(imgIn)) {\n            return imgOut;\n        }\n\n        imgOut = flt.Process(Double(imgIn[0], img_conv), imgOut);\n\n        if(imgOut == NULL) {\n            return imgOut;\n        }\n\n        imgOut->applyFunction(square);\n\n        *imgOut /= 36.0f;\n\n        return imgOut;\n    }\n\n    /**\n     * @brief getNoiseEstimation\n     * @param imgNoise\n     * @return\n     */\n    static float *getNoiseEstimation(Image *imgNoise, float *ret)\n    {\n        if(ret == NULL) {\n            ret = new float[imgNoise->channels];\n        }\n\n        BBox box = imgNoise->getFullBox();\n\n        box.x0++;\n        box.x1--;\n        box.y0++;\n        box.y1--;\n\n        ret = imgNoise->getMeanVal(&box, ret);\n\n        return ret;\n    }\n\n\n    /**\n     * @brief getNoiseEstimation\n     * @param imgNoise\n     * @return\n     */\n    static float *getNoiseEstimation(Image *img, Image *imgNoise, float *ret)\n    {\n\n        FilterNoiseEstimation flt;\n        imgNoise = flt.execute(img, imgNoise);\n\n        ret = getNoiseEstimation(imgNoise, ret);\n\n        return ret;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        FilterNoiseEstimation flt;\n        return flt.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_NOISE_ESTIMATION_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_normal.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_NORMAL_HPP\n#define PIC_FILTERING_FILTER_NORMAL_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterNormal class\n */\nclass FilterNormal: public Filter\n{\nprotected:\n    int colorChannel;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n    /**\n     * @brief FilterNormal\n     */\n    FilterNormal();\n\n    /**\n     * @brief FilterNormal\n     * @param colorChannel\n     */\n    FilterNormal(int colorChannel);\n\n    /**\n     * @brief update\n     * @param colorChannel\n     */\n    void update(int colorChannel);\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = 3;\n        frames      = imgIn[0]->frames;\n    }\n};\n\nPIC_INLINE FilterNormal::FilterNormal() : Filter()\n{\n    update(0);\n}\n\nPIC_INLINE FilterNormal::FilterNormal(int colorChannel) : Filter()\n{\n    update(colorChannel);\n}\n\nPIC_INLINE void FilterNormal::update(int colorChannel)\n{\n    if(colorChannel<0) {\n        colorChannel = 0;\n    }\n\n    this->colorChannel = colorChannel;\n}\n\nPIC_INLINE void FilterNormal::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n    int width    = dst->width;\n    int height   = dst->height;\n    int channels = src[0]->channels;\n\n    if(colorChannel>(channels - 1)) {\n        colorChannel = 0;\n    }\n\n    float *data = src[0]->data;\n    float gradX, gradY;\n\n\n    for(int j = box->y0; j < box->y1; j++) {\n        int ind = j * width;\n\n        for(int i = box->x0; i < box->x1; i++) {\n            //Convolution kernel\n            int ind2 = (ind + i) * 3;\n\n            //Positions\n            int ci  = CLAMP(i + 1, width);\n            int cj  = CLAMP(j + 1, height);\n            int ci1 = CLAMP(i - 1, width);\n            int cj1 = CLAMP(j - 1, height);\n\n            //Grad X\n            int tmpc  = (ind + ci) * channels;\n            gradX = data[tmpc + colorChannel];\n\n            tmpc   = (ind + ci1) * channels;\n            gradX -= data[tmpc + colorChannel];\n\n            //Grad Y\n            tmpc  = (cj * width + i) * channels;\n            gradY = data[tmpc + colorChannel];\n\n            tmpc   = (cj1 * width + i) * channels;\n            gradY -= data[tmpc + colorChannel];\n\n            /*gx[0]=1.0f; gx[1]=0.0f; gx[2]=gradX;\n            gy[1]=1.0f; gy[0]=0.0f; gy[2]=gradY;\n\n            dst->data[ind2  ] = gx[1] * gy[2] - gy[1] * gx[2];\n            dst->data[ind2+1] = gx[2] * gy[0] - gy[2] * gx[0];\n            dst->data[ind2+2] = gx[0] * gy[1] - gy[0] * gx[1];*/\n\n            dst->data[ind2    ] = gradX;\n            dst->data[ind2 + 1] = gradY;\n            dst->data[ind2 + 2] = 1.0f;\n\n            float norm = gradX * gradX + gradY * gradY + 1.0f;\n\n            if(norm > 0.0f) {\n                norm = sqrtf(norm);\n                dst->data[ind2    ] /= norm;\n                dst->data[ind2 + 1] /= norm;\n                dst->data[ind2 + 2] /= norm;\n            } else {\n                dst->data[ind2    ] = 0.0f;\n                dst->data[ind2 + 1] = 0.0f;\n                dst->data[ind2 + 2] = 0.0f;\n            }\n        }\n    }\n}\n\n/*\nvoid genLight(float *L, int x, int y, int width, int height)\n{\n    float xf = float(x) / float(width);\n    float yf = float(y) / float(height);\n\n    L[0] = (xf - 0.5f) * 2.0f;\n    L[1] = (yf - 0.5f) * 2.0f;\n    L[2] = 1.0f;\n\n    float norm = L[0] * L[0] + L[1] * L[1] + L[2] * L[2];\n\n    if(norm > 0.0f) {\n        norm = 1.0f / sqrtf(norm);\n        L[0] *= norm;\n        L[1] *= norm;\n        L[2] *= norm;\n    };\n};\n*/\n\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_NORMAL_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_npasses.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_NPASSES_HPP\n#define PIC_FILTERING_FILTER_NPASSES_HPP\n\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterNPasses class\n */\nclass FilterNPasses: public Filter\n{\nprotected:\n    Image *imgAllocated;\n    Image *imgTmpSame[2];\n    ImageVec imgTmp;\n\n    /**\n     * @brief PreProcess\n     * @param imgIn\n     * @param imgOut\n     */\n    virtual void PreProcess(ImageVec imgIn, Image *imgOut){}\n\n    /**\n     * @brief setupAuxNGen\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *setupAuxNGen(ImageVec imgIn, Image *imgOut);\n\n    /**\n     * @brief setupAuxNSame\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *setupAuxNSame(ImageVec imgIn, Image *imgOut);\n\n    /**\n     * @brief getFilter\n     * @param i\n     * @return\n     */\n    virtual Filter* getFilter(int i);\n\n    /**\n     * @brief getIterations\n     * @return\n     */\n    virtual int getIterations();\n\n    /**\n     * @brief release\n     */\n    void release();\n\n    /**\n     * @brief ProcessGen\n     * @param imgIn\n     * @param imgOut\n     * @param parallel\n     * @return\n     */\n    Image *ProcessGen(ImageVec imgIn, Image *imgOut, bool parallel);\n\n    /**\n     * @brief ProcessSame\n     * @param imgIn\n     * @param imgOut\n     * @param parallel\n     * @return\n     */\n    Image *ProcessSame(ImageVec imgIn, Image *imgOut, bool parallel);\n\npublic:\n\n    /**\n     * @brief FilterNPasses\n     */\n    FilterNPasses();\n\n    ~FilterNPasses();\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames);\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut);\n};\n\nPIC_INLINE FilterNPasses::FilterNPasses() : Filter()\n{\n    imgAllocated = NULL;\n\n    for(int i = 0; i < 2; i++) {\n        imgTmpSame[i] = NULL;\n    }\n\n    imgTmp.clear();\n}\n\nPIC_INLINE FilterNPasses::~FilterNPasses()\n{\n    release();\n}\n\nPIC_INLINE void FilterNPasses::release()\n{\n    if(imgAllocated != NULL) {\n        delete imgAllocated;\n        imgAllocated = NULL;\n    }\n\n    imgTmpSame[0] = NULL;\n    imgTmpSame[1] = NULL;\n\n    stdVectorClear<Image>(imgTmp);\n}\n\nPIC_INLINE Filter* FilterNPasses::getFilter(int i)\n{\n    int j = i % filters.size();\n    return filters[j];\n}\n\nPIC_INLINE int FilterNPasses::getIterations()\n{\n    return int(filters.size());\n}\n\nPIC_INLINE void FilterNPasses::OutputSize(ImageVec imgIn, int &width, int &height, int &frames, int &channels)\n{\n    Image *imgIn0 = new Image(imgIn[0], false);\n\n    auto *tmp = imgIn[0];\n    imgIn[0] = imgIn0;\n\n    int n = getIterations();\n\n    for(int i = 0; i < n; i++) {\n        auto flt_i = getFilter(i);\n        flt_i->changePass(i, n);\n        flt_i->OutputSize(imgIn, width, height, channels, frames);\n\n        imgIn0->width = width;\n        imgIn0->height = height;\n        imgIn0->channels = channels;\n        imgIn0->frames = frames;\n    }\n\n    imgIn[0] = tmp;\n\n    delete imgIn0;\n}\n\nPIC_INLINE Image *FilterNPasses::setupAuxNGen(ImageVec imgIn,\n        Image *imgOut)\n{   \n    int width, height, frames, channels;\n    OutputSize(imgIn, width, height, frames, channels);\n\n    int n = getIterations();\n\n    if(imgTmp.empty()) {\n        setToANullVector<Image>(imgTmp, n);\n    } else {\n        int tw, th, tf, tc;\n\n        filters[0]->OutputSize(imgIn, tw, th, tf, tc);\n\n        if(tw != imgTmp[0]->width ||\n           th != imgTmp[0]->height ||\n           tf != imgTmp[0]->frames ||\n           tc != imgTmp[0]->channels) {\n\n            stdVectorClear<Image>(imgTmp);\n\n            setToANullVector<Image>(imgTmp, n);\n        }\n    }\n\n    //output\n    if(imgOut == NULL) {\n        imgOut = new Image(frames, width, height, channels);\n    } else {\n        if(imgOut->height != height ||\n           imgOut->width != width ||\n           imgOut->channels != channels ||\n           imgOut->frames != frames) {\n           imgOut = new Image(frames, width, height, channels);\n        }\n    }\n\n    return imgOut;\n}\n\nPIC_INLINE Image *FilterNPasses::setupAuxNSame(ImageVec imgIn,\n        Image *imgOut)\n{\n    if(imgOut == NULL) {\n        imgOut = imgIn[0]->allocateSimilarOne();\n    } else {\n        if(!imgOut->isSimilarType(imgIn[0])) {\n            imgOut = imgIn[0]->allocateSimilarOne();\n        }\n    }\n\n    if(imgAllocated == NULL) {\n        imgAllocated = imgIn[0]->allocateSimilarOne();\n    } else {\n        if(!imgAllocated->isSimilarType(imgIn[0])) {\n            delete imgAllocated;\n            imgAllocated = imgIn[0]->allocateSimilarOne();\n        }\n    }\n\n    if((getIterations() % 2) == 0) {\n        imgTmpSame[0] = imgAllocated;\n        imgTmpSame[1] = imgOut;\n    } else {\n        imgTmpSame[0] = imgOut;\n        imgTmpSame[1] = imgAllocated;\n    }\n\n    return imgOut;\n}\n\nPIC_INLINE Image *FilterNPasses::ProcessGen(ImageVec imgIn, Image *imgOut,\n        bool parallel = false)\n{\n    imgOut = setupAuxNGen(imgIn, imgOut);\n\n    int n = getIterations();\n    int n2 = n - 1;\n    \n    for(int i = 0; i < n2; i++) {\n        auto flt_i = getFilter(i);\n        flt_i->changePass(i, n);\n\n        imgTmp[i] = flt_i->Process(imgIn, imgTmp[i]);\n\n        imgIn[0] = imgTmp[i];\n    }\n\n    auto flt_n = getFilter(n2);\n    flt_n->changePass(n2, n);\n\n    imgOut = filters[n2]->Process(imgIn, imgOut);\n\n    return imgOut;\n}\n\nPIC_INLINE Image *FilterNPasses::ProcessSame(ImageVec imgIn, Image *imgOut,\n        bool parallel = false)\n{\n    //setup\n    imgOut = setupAuxNSame(imgIn, imgOut);\n\n    int n = getIterations();\n    auto flt_0 = getFilter(0);\n    flt_0->changePass(0, n);\n\n    flt_0->Process(imgIn, imgTmpSame[0]);\n\n    for(int i = 1; i < n; i++) {\n        auto flt_i = getFilter(i);\n        flt_i->changePass(i, n);\n\n        imgIn[0] = imgTmpSame[(i + 1) % 2];\n\n        flt_i->Process(imgIn, imgTmpSame[i % 2]);\n    }\n\n    return imgOut;\n}\n\nPIC_INLINE Image *FilterNPasses::Process(ImageVec imgIn, \n        Image *imgOut)\n{\n    if(imgIn.empty() || filters.empty()) {\n        return imgOut;\n    }\n\n    PreProcess(imgIn, imgOut);\n\n    int width, height, frames, channels;\n    OutputSize(imgIn, width, height, frames, channels);\n\n    bool bSame = (imgIn[0]->width == width) &&\n                 (imgIn[0]->height == height) &&\n                 (imgIn[0]->frames == frames) &&\n                 (imgIn[0]->channels == channels);\n\n    if(bSame) {\n        imgOut = ProcessSame(imgIn, imgOut);\n    } else {\n        imgOut = ProcessGen(imgIn, imgOut);\n    }\n\n    return imgOut;\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_NPASSES_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_nswe.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_NSWE_HPP\n#define PIC_FILTERING_FILTER_NSWE_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterNSWE class\n */\nclass FilterNSWE: public Filter\n{\nprotected:\n    /**\n     * @brief f\n     * @param data\n     */\n    void f(FilterFData *data)\n    {\n        float *img_data  = (*data->src[0])(data->x    , data->y);\n        float *img_dataN = (*data->src[0])(data->x + 1, data->y);\n        float *img_dataS = (*data->src[0])(data->x - 1, data->y);\n        float *img_dataW = (*data->src[0])(data->x    , data->y - 1);\n        float *img_dataE = (*data->src[0])(data->x    , data->y + 1);\n\n        for(int k = 0; k < data->src[0]->channels; k++) {\n            int tmp = k << 2;\n            data->out[tmp    ] = img_dataN[k] - img_data[k];\n            data->out[tmp + 1] = img_dataS[k] - img_data[k];\n            data->out[tmp + 2] = img_dataW[k] - img_data[k];\n            data->out[tmp + 3] = img_dataE[k] - img_data[k];\n        }\n    }\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    /*\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        Image *img = src[0];\n        int channels = img->channels;\n\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *dst_data   = (*dst)(i  , j);\n\n                float *img_data  = (*img)(i    , j);\n                float *img_dataN = (*img)(i + 1, j);\n                float *img_dataS = (*img)(i - 1, j);\n                float *img_dataW = (*img)(i    , j - 1);\n                float *img_dataE = (*img)(i    , j + 1);\n\n                for(int k = 0; k < channels; k++) {\n                    int tmp = k * 4;\n                    dst_data[tmp    ] = img_dataN[k] - img_data[k];\n                    dst_data[tmp + 1] = img_dataS[k] - img_data[k];\n                    dst_data[tmp + 2] = img_dataW[k] - img_data[k];\n                    dst_data[tmp + 3] = img_dataE[k] - img_data[k];\n                }\n            }\n        }\n    }\n    */\n\npublic:\n    /**\n     * @brief FilterNSWE\n     */\n    FilterNSWE() : Filter()\n    {\n\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width    = imgIn[0]->width;\n        height   = imgIn[0]->height;\n        channels = imgIn[0]->channels << 2;\n        frames   = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        FilterNSWE filter;\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_NSWE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_radial_basis_function.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_RADIAL_BASIS_FUNCTION\n#define PIC_FILTERING_FILTER_RADIAL_BASIS_FUNCTION\n\nnamespace pic {\n\n#include \"../algorithms/radial_basis_function.hpp\"\n\n#include \"../filtering/filter.hpp\"\n\n/**\n * @brief The FilterRadialBasisFunction class\n */\nclass FilterRadialBasisFunction: public Filter\n{\nprotected:\n\n    RadialBasisFunction *rbf;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        if(rbf == NULL) {\n            return;\n        }\n\n        int channels = src[0]->channels;\n\n        if(rbf->nDim != channels) {\n            return;\n        }\n\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *dataIn  = (*src[0]) (i, j);\n                float *dataOut = (*dst)    (i, j);\n\n                dataOut[0] = rbf->eval(dataIn);\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterRadialBasisFunction\n     */\n    FilterRadialBasisFunction() : Filter()\n    {\n        rbf = NULL;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width    = imgIn[0]->width;\n        height   = imgIn[0]->height;\n        channels = 1;\n        frames   = imgIn[0]->frames;\n    }\n\n    /**\n      * @brief update\n      * @param rbf\n      */\n    void update(RadialBasisFunction *rbf)\n    {\n        if(rbf != NULL) {\n            this->rbf = rbf;\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_RADIAL_BASIS_FUNCTION */\n\n"
  },
  {
    "path": "include/filtering/filter_reconstruct.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_RECONSTRUCT_HPP\n#define PIC_FILTERING_FILTER_RECONSTRUCT_HPP\n\n#include \"../util/array.hpp\"\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\nclass FilterReconstruct: public Filter\n{\nprotected:\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        int channels = src[0]->channels;\n\n        for(int j = box->y0; j < box->y1; j++) {\n\n            for(int i = box->x0; i < box->x1; i++) {\n                float *tmp_ann = (*src[1])(i, j);\n                int x = int(tmp_ann[0]);\n                int y = int(tmp_ann[1]);\n\n                float *tmp_dst = (*dst)(i, j);\n                float *tmp_src = (*src[0])(x, y);\n\n                Arrayf::assign(tmp_src, channels, tmp_dst);\n            }\n        }\n    }\n\npublic:\n    /**\n     * @brief FilterReconstruct\n     */\n    FilterReconstruct() : Filter()\n    {\n        minInputImages = 2;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    virtual void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[1]->width;\n        height      = imgIn[1]->height;\n        channels    = imgIn[1]->channels;\n        frames      = imgIn[1]->frames;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param ann\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *ann, Image *imgOut = NULL)\n    {\n        FilterReconstruct fltRec;\n        return fltRec.Process(Double(imgIn, ann), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_RECONSTRUCT_HPP */\n"
  },
  {
    "path": "include/filtering/filter_remove_inf_nan.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_REMOVE_INF_NAN_HPP\n#define PIC_FILTERING_FILTER_REMOVE_INF_NAN_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterRemoveInfNaN class\n */\nclass FilterRemoveInfNaN: public Filter\n{\nprotected:\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        float values[9];\n\n        int channels = dst->channels;\n\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *tmp_data = (*src[0])(i, j);\n                float *tmp_dst  = (*dst   )(i, j);\n\n                for(int ch = 0; ch < channels; ch++) {\n\n                    float val = tmp_data[ch];\n\n                    if(isinf(val) || isnan(val)) {\n                        int c2 = 0;\n\n                        for(int k = -1; k <= 1; k++) {\n                            for(int l = -1; l <= 1; l++) {\n\n                                float *tmp_val = (*src[0])(i + l, j + k);\n\n                                if(!(isnan(tmp_val[ch]) || isinf(tmp_val[ch]))) {\n                                    values[c2] = tmp_val[ch];\n                                    c2++;\n                                }\n                            }\n                        }\n\n                        if(c2 == 0) {\n                            tmp_dst[ch] = 0.0f;\n                        } else {\n                            std::sort(values, values + c2);\n                            tmp_dst[ch] = values[5];\n                        }\n                    } else {\n                        tmp_dst[ch] = val;\n                    }\n                }\n            }\n        }\n    }\n     \n\npublic:\n    /**\n     * @brief FilterRemoveInfNaN\n     */\n    FilterRemoveInfNaN() : Filter()\n    {\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param threshold_nuked\n     * @return\n     */\n    static Image* execute(Image *imgIn, Image *imgOut)\n    {\n        FilterRemoveInfNaN filter;\n        imgOut = filter.Process(Single(imgIn), imgOut);\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_REMOVE_INF_NAN_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_remove_nuked.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_REMOVE_NUKED_HPP\n#define PIC_FILTERING_FILTER_REMOVE_NUKED_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterRemoveNuked class\n */\nclass FilterRemoveNuked: public Filter\n{\nprotected:\n    float threshold_nuked;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        float maxVal;\n        float values[9];\n\n        int channels = dst->channels;\n\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n\n                float *tmp_data = (*src[0])(i, j);\n                float *tmp_dst  = (*dst   )(i, j);\n            \n                for(int ch = 0; ch < channels; ch++) {\n\n                    maxVal = -FLT_MAX;\n                    int c2 = 0;\n                    int nuked = 0;\n                    float val = tmp_data[ch];\n\n                    for(int k = -1; k <= 1; k++) {\n                        for(int l = -1; l <= 1; l++) {\n\n                            float *tmp_val = (*src[0])(i + l, j + k);\n                            values[c2] = tmp_val[ch];\n\n                            float t_new = threshold_nuked * tmp_val[ch];\n                            if(fabsf(tmp_val[ch] - tmp_data[ch]) > t_new) {\n                                nuked++;\n                            }\n\n                            c2++;\n                        }\n                    }\n\n                    if(nuked > 5) {//are nuked pixels the majority?\n                        std::sort(values, values + 9);\n                        tmp_dst[ch] = values[5];\n                    } else {\n                        tmp_dst[ch] = val;\n                    }\n                }\n            }\n        }\n    }\n     \n\npublic:\n    /**\n     * @brief FilterRemoveNuked\n     * @param threshold_nuked\n     */\n    FilterRemoveNuked(float threshold_nuked = 1e4f)\n    {\n        this->threshold_nuked = threshold_nuked;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param threshold_nuked\n     * @return\n     */\n    static Image* execute(Image *imgIn, Image *imgOut, float threshold_nuked = 1e4)\n    {\n        FilterRemoveNuked filter(threshold_nuked);\n        imgOut = filter.Process(Single(imgIn), imgOut);\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_REMOVE_NUKED_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_rotation.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_ROTATION_HPP\n#define PIC_FILTERING_FILTER_ROTATION_HPP\n\n#include \"../filtering/filter.hpp\"\n#include \"../image_samplers/image_sampler_bilinear.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n    #include \"../externals/Eigen/Geometry\"\n#else\n    #include <Eigen/Dense>\n    #include <Eigen/Geometry>\n#endif\n\n#endif\n\nnamespace pic {\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief The FilterRotation class\n */\nclass FilterRotation: public Filter\n{\nprotected:\n\n    ImageSamplerBilinear isb;\n\n    //rotation\n    float angleX, angleY, angleZ;\n\n    //the rotation matrix of (theta, phi)\n    Eigen::Matrix3f mtxRot, mtxRot_inv;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        float c1 = C_PI   / dst->heightf;\n        float c2 = C_PI_2 / dst->widthf;\n\n        for(int j = box->y0; j < box->y1; j++) {\n            float theta = float(j) * c1;\n            float sinTheta = sinf(theta);\n            float cosTheta = cosf(theta);\n\n            Eigen::Vector3f d;\n\n            for(int i = box->x0; i < box->x1; i++) {\n                float phi = float(i) * c2;\n\n                d[0] = sinTheta * cosf(phi);\n                d[1] = cosTheta;\n                d[2] = sinTheta * sinf(phi);\n\n                auto Rd = (mtxRot_inv * d).normalized();\n\n\n          /*    printf(\"\\nwrong: %f correct: %f Rd: %f\\n\",\n                       sinTheta * cosf(phi + this->phi),\n                       sinTheta * cosf(phi - this->phi),\n                       Rd[0]\n                       );*/\n\n                float xt = 1.0f - ((atan2f(Rd[2], -Rd[0]) * C_INV_PI) * 0.5f + 0.5f);\n                float yt = (acosf(Rd[1]) * C_INV_PI);\n\n                float *data_dst = (*dst)(i, j);\n                isb.SampleImage(src[0], xt, yt, data_dst);\n            }\n        }\n    }\n\n    /**\n     * @brief fromAnglesToVector\n     * @param theta\n     * @param phi\n     * @return\n     */\n    Eigen::Vector3f fromAnglesToVector(float theta, float phi)\n    {\n        Eigen::Vector3f ret;\n        float sinTheta = sinf(theta);\n        float cosTheta = cosf(theta);\n\n        ret[0] = sinTheta * cosf(phi);\n        ret[1] = cosTheta;\n        ret[2] = sinTheta * sinf(phi);\n\n        return ret;\n    }\n\npublic:\n\n    /**\n     * @brief FilterRotation\n     */\n    FilterRotation() : Filter()\n    {\n        update(0.0f, 0.0f, 0.0f);\n    }\n\n    /**\n     * @brief FilterRotation\n     * @param angleX\n     * @param angleY\n     * @param angleZ\n     */\n    FilterRotation(float angleX, float angleY, float angleZ) : Filter()\n    {\n        update(angleX, angleY, angleZ);\n    }\n\n    /**\n     * @brief FilterRotation\n     * @param mtx\n     */\n    FilterRotation(Eigen::Matrix3f mtx) : Filter()\n    {\n        update(mtx);\n    }\n\n    /**\n     * @brief update\n     * @param angleX\n     * @param angleY\n     * @param angleZ\n     */\n    void update(float angleX, float angleY, float angleZ)\n    {\n        this->angleX = angleX;\n        this->angleY = angleY;\n        this->angleZ = angleZ;\n\n        Eigen::Matrix3f mtx;\n        mtx = Eigen::AngleAxisf(angleZ, Eigen::Vector3f::UnitZ()) *\n              Eigen::AngleAxisf(angleY, Eigen::Vector3f::UnitY()) *\n              Eigen::AngleAxisf(angleX, Eigen::Vector3f::UnitX());\n\n        update(mtx);\n    }\n\n    /**\n     * @param theta\n     * @brief update\n     * @param phi\n     */\n    void update(Eigen::Matrix3f mtx)\n    {\n        this->mtxRot = mtx;\n        this->mtxRot_inv = Eigen::Transpose< Eigen::Matrix3f >(mtx);\n    }\n\n    /**\n     * @brief getMtxRot\n     * @return\n     */\n    Eigen::Matrix3f getMtxRot()\n    {\n        return mtxRot;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param theta\n     * @param phi\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float angleX, float angleY, float angleZ)\n    {\n        FilterRotation fltRot(angleX, angleY, angleZ);\n        return fltRot.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param mtx\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, Eigen::Matrix3f &mtx)\n    {\n        FilterRotation fltRot(mtx);\n        return fltRot.Process(Single(imgIn), imgOut);\n    }\n};\n\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_ROTATION_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_sampler_1d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_SAMPLER_1D_HPP\n#define PIC_FILTERING_FILTER_SAMPLER_1D_HPP\n\n#define X_DIRECTION 0\n#define Y_DIRECTION 1\n#define Z_DIRECTION 2\n\n#include \"../filtering/filter.hpp\"\n#include \"../image_samplers/image_sampler_bilinear.hpp\"\n#include \"../image_samplers/image_sampler_bsplines.hpp\"\n#include \"../image_samplers/image_sampler_gaussian.hpp\"\n#include \"../image_samplers/image_sampler_nearest.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterSampler1D class\n */\nclass FilterSampler1D: public Filter\n{\nprotected:\n    ImageSamplerNearest isb_default;\n    ImageSampler *isb;\n    int dirs[3];\n    int size;\n    bool swh;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\n    /**\n     * @brief setDirection\n     * @param direction\n     */\n    void setDirection(int direction);\n\n    /**\n     * @brief setImageSampler\n     * @param isb\n     */\n    void setImageSampler(ImageSampler *isb);\n\npublic:\n    /**\n     * @brief FilterSampler1D\n     * @param scale\n     * @param direction\n     * @param isb\n     */\n    FilterSampler1D(float scale, int direction, ImageSampler *isb);\n\n    /**\n     * @brief FilterSampler1D\n     * @param size\n     * @param direction\n     * @param isb\n     */\n    FilterSampler1D(int size, int direction, ImageSampler *isb);\n\n    /**\n     * @brief update\n     * @param scale\n     * @param direction\n     * @param isb\n     */\n    void update(float scale, int direction, ImageSampler *isb);\n\n    /**\n     * @brief update\n     * @param size\n     * @param direction\n     * @param isb\n     */\n    void update(int size, int direction, ImageSampler *isb);\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        if(swh) {\n            float scaleX = (dirs[X_DIRECTION] == 1) ? scale : 1.0f;\n            float scaleY = (dirs[Y_DIRECTION] == 1) ? scale : 1.0f;\n\n            width  = int(imgIn[0]->widthf  * scaleX);\n            height = int(imgIn[0]->heightf * scaleY);\n        } else {\n            width  = (dirs[X_DIRECTION] == 1) ? size : imgIn[0]->width;\n            height = (dirs[Y_DIRECTION] == 1) ? size : imgIn[0]->height;\n        }\n\n        channels = imgIn[0]->channels;\n        frames   = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param scale\n     * @param direction\n     * @param isb\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float scale,\n                             int direction, ImageSampler *isb)\n    {\n        FilterSampler1D filter(scale, direction, isb);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\nPIC_INLINE FilterSampler1D::FilterSampler1D(float scale, int direction = 0,\n        ImageSampler *isb = NULL) : Filter()\n{\n    this->isb = NULL;\n    update(scale, direction, isb);\n}\n\nPIC_INLINE FilterSampler1D::FilterSampler1D(int size, int direction = 0,\n        ImageSampler *isb = NULL) : Filter()\n{\n    this->isb = NULL;\n    update(size, direction, isb);\n}\n\nPIC_INLINE void FilterSampler1D::update(float scale, int direction,\n                                        ImageSampler *isb)\n{\n    this->scale = scale;\n    this->swh   = true;\n\n    setDirection(direction);\n    setImageSampler(isb);\n}\n\nPIC_INLINE void FilterSampler1D::update(int size, int direction,\n                                        ImageSampler *isb)\n{\n    this->size = size;\n    this->swh  = false;\n\n    setDirection(direction);\n    setImageSampler(isb);\n}\n\nPIC_INLINE void FilterSampler1D::setDirection(int direction = 0)\n{\n    dirs[ direction      % 3] = 1;\n    dirs[(direction + 1) % 3] = 0;\n    dirs[(direction + 2) % 3] = 0;\n}\n\nPIC_INLINE void FilterSampler1D::setImageSampler(ImageSampler *isb)\n{\n    if(isb == NULL) {\n        if(this->isb == NULL) {\n            this->isb = &isb_default;\n        }\n    } else {\n        this->isb = isb;\n    }\n}\n\nPIC_INLINE void FilterSampler1D::ProcessBBox(Image *dst, ImageVec src,\n        BBox *box)\n{\n    float width1f  = float(box->width  - 1);\n    float height1f = float(box->height - 1);\n\n    for(int j = box->y0; j < box->y1; j++) {\n        float y = float(j) / height1f;\n\n        for(int i = box->x0; i < box->x1; i++) {\n            float x = float(i) / width1f;\n\n            float *tmp_data = (*dst)(i, j);\n            isb->SampleImage(src[0], x, y, tmp_data);\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_SAMPLER_1D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_sampler_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_SAMPLER_2D_HPP\n#define PIC_FILTERING_FILTER_SAMPLER_2D_HPP\n\n#include \"../filtering/filter.hpp\"\n#include \"../image_samplers/image_sampler_bilinear.hpp\"\n#include \"../image_samplers/image_sampler_bsplines.hpp\"\n#include \"../image_samplers/image_sampler_gaussian.hpp\"\n#include \"../image_samplers/image_sampler_nearest.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterSampler2D class\n */\nclass FilterSampler2D: public Filter\n{\nprotected:\n    ImageSamplerNearest isb_default;\n    ImageSampler *isb;\n    float scaleX, scaleY;\n    int width, height;\n    bool swh;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n\n    /**\n     * @brief FilterSample2D\n     */\n    FilterSampler2D() : Filter()\n    {\n        scaleX = -1.0f;\n        scaleY = -1.0f;\n        width = -1;\n        height = -1;\n        isb = NULL;\n    }\n\n    /**\n     * @brief FilterSampler2D\n     * @param scale\n     * @param isb\n     */\n    FilterSampler2D(float scale, ImageSampler *isb);\n\n    /**\n     * @brief FilterSampler2D\n     * @param scaleX\n     * @param scaleY\n     * @param isb\n     */\n    FilterSampler2D(float scaleX, float scaleY, ImageSampler *isb);\n\n    /**\n     * @brief FilterSampler2D\n     * @param width\n     * @param height\n     * @param isb\n     */\n    FilterSampler2D(int width, int height, ImageSampler *isb);\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        if(imgIn.empty()) {\n            width = -2;\n            height = -2;\n            channels = -2;\n            frames = -2;\n            return;\n        }\n\n        if(imgIn.size() == 1) {\n            if(swh) {\n                width  = int(imgIn[0]->widthf  * scaleX);\n                height = int(imgIn[0]->heightf * scaleY);\n            } else {\n                width = this->width;\n                height = this->height;\n            }\n        } else {\n            width = imgIn[1]->width;\n            height = imgIn[1]->height;\n        }\n\n        channels = imgIn[0]->channels;\n        frames = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief update\n     * @param width\n     * @param height\n     * @param isb\n     */\n    void update(int width, int height, ImageSampler *isb)\n    {\n        this->width  = width;\n        this->height = height;\n\n        this->swh = false;\n\n        if(isb == NULL) {\n            this->isb = new ImageSamplerNearest();\n        } else {\n            this->isb = isb;\n        }\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param scale\n     * @param isb\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float scale,\n                             ImageSampler *isb = NULL)\n    {\n        FilterSampler2D filter(scale, isb);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param scaleX\n     * @param scaleY\n     * @param isb\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float scaleX,\n                             float scaleY, ImageSampler *isb = NULL)\n    {\n        FilterSampler2D filter(scaleX, scaleY, isb);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param width\n     * @param height\n     * @param isb\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, int width,\n                             int height, ImageSampler *isb = NULL)\n    {\n        FilterSampler2D filter(width, height, isb);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n\n};\n\nPIC_INLINE FilterSampler2D::FilterSampler2D(float scale,\n        ImageSampler *isb = NULL): Filter()\n{\n    this->scale  = scale;\n    this->scaleX = scale;\n    this->scaleY = scale;\n\n    this->swh = true;\n\n    if(isb == NULL) {\n        this->isb = new ImageSamplerNearest();\n    } else {\n        this->isb = isb;\n    }\n}\n\nPIC_INLINE FilterSampler2D::FilterSampler2D(float scaleX, float scaleY,\n        ImageSampler *isb = NULL): Filter()\n{\n    this->scaleX = scaleX;\n    this->scaleY = scaleY;\n\n    this->swh = true;\n\n    if(isb == NULL) {\n        this->isb = &isb_default;\n    } else {\n        this->isb = isb;\n    }\n}\n\nPIC_INLINE FilterSampler2D::FilterSampler2D(int width, int height,\n        ImageSampler *isb = NULL): Filter()\n{\n    update(width, height, isb);\n}\n\nPIC_INLINE void FilterSampler2D::ProcessBBox(Image *dst, ImageVec src,\n        BBox *box)\n{\n    float height1f = float(box->height - 1);\n    float width1f = float(box->width - 1);\n\n    for(int j = box->y0; j < box->y1; j++) {\n        float y = float(j) / height1f;\n\n        for(int i = box->x0; i < box->x1; i++) {\n\n            float x = float(i) / width1f;\n\n            float *tmp_dst = (*dst)(i, j);\n\n            isb->SampleImage(src[0], x, y, tmp_dst);\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_SAMPLER_2D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_sampler_2dadd.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_SAMPLER_2DADD_HPP\n#define PIC_FILTERING_FILTER_SAMPLER_2DADD_HPP\n\n#include \"../filtering/filter.hpp\"\n\n#include \"../image_samplers/image_sampler.hpp\"\n#include \"../image_samplers/image_sampler_bilinear.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterSampler2DAdd class\n */\nclass FilterSampler2DAdd: public Filter\n{\nprotected:\n    ImageSamplerBilinear isb_default;\n    ImageSampler *isb;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        float *vSrc1  = new float[dst->channels];\n\n        float height1f = float(box->height - 1);\n        float width1f = float(box->width - 1);\n\n        for(int j = box->y0; j < box->y1; j++) {\n            float y = float(j) / height1f;\n\n            for(int i = box->x0; i < box->x1; i++) {\n                float x = float(i) / width1f;\n\n                float *tmp_dst  = (*dst )(i, j);\n\n                isb->SampleImage(src[0], x, y, tmp_dst);\n                isb->SampleImage(src[1], x, y, vSrc1);\n\n                Arrayf::add(vSrc1, dst->channels, tmp_dst);\n            }\n        }\n\n        delete_s(vSrc1);\n    }\n\npublic:\n\n    /**\n     * @brief FilterSampler2DAdd\n     * @param isb\n     */\n    FilterSampler2DAdd(ImageSampler *isb) : Filter()\n    {\n        this->minInputImages = 2;\n\n        if(isb != NULL) {\n            this->isb = isb;\n        } else {\n            this->isb = &isb_default;\n        }\n    }\n\n    ~FilterSampler2DAdd()\n    {\n    }\n\n    /**\n     * @brief update\n     * @param isb\n     */\n    void update(ImageSampler *isb)\n    {\n        this->isb = isb;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param isb\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, ImageSampler *isb)\n    {\n        FilterSampler2DAdd filter(isb);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_SAMPLER_2DADD_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_sampler_2dsub.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_SAMPLER_2DSUB_HPP\n#define PIC_FILTERING_FILTER_SAMPLER_2DSUB_HPP\n\n#include \"../filtering/filter.hpp\"\n#include \"../image_samplers/image_sampler_bilinear.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterSampler2DSub class\n */\nclass FilterSampler2DSub: public Filter\n{\nprotected:\n    ImageSamplerBilinear isb_default;\n    ImageSampler *isb;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        float *vSrc1 = new float[dst->channels];\n\n        float height1f = float(box->height - 1);\n        float width1f = float(box->width - 1);\n\n        for(int j = box->y0; j < box->y1; j++) {\n            float y = float(j) / height1f;\n\n            for(int i = box->x0; i < box->x1; i++) {\n                float x = float(i) / width1f;\n\n                float *out = (*dst )(i, j);\n\n                isb->SampleImage(src[0], x, y, out);\n                isb->SampleImage(src[1], x, y, vSrc1);\n\n                for(int k = 0; k < dst->channels; k++) {\n                    out[k] -= vSrc1[k];\n                }\n            }\n        }\n\n        delete[] vSrc1;\n    }\n\npublic:\n\n    /**\n     * @brief FilterSampler2DSub\n     * @param isb\n     */\n    FilterSampler2DSub(ImageSampler *isb) : Filter()\n    {\n        this->minInputImages = 2;\n\n        if(isb != NULL) {\n            this->isb = isb;\n        } else {\n            this->isb = &isb_default;\n        }\n    }\n\n    ~FilterSampler2DSub()\n    {\n    }\n\n    /**\n     * @brief update\n     * @param isb\n     */\n    void update(ImageSampler *isb)\n    {\n        if(isb != NULL) {\n            this->isb = isb;\n        }\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param isb\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, ImageSampler *isb)\n    {\n        FilterSampler2DSub filter(isb);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_SAMPLER_2DSUB_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_sampler_3d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_SAMPLER_3D_HPP\n#define PIC_FILTERING_FILTER_SAMPLER_3D_HPP\n\n#include \"../filtering/filter.hpp\"\n#include \"../image_samplers/image_sampler.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterSampler3D class\n */\nclass FilterSampler3D: public Filter\n{\nprotected:\n    ImageSampler *isb;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n    /**\n     * @brief FilterSampler3D\n     * @param scale\n     * @param isb\n     */\n    FilterSampler3D(float scale, ImageSampler *isb);\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width  = int(imgIn[0]->widthf  * scale);\n        height = int(imgIn[0]->heightf * scale);\n        frames = int(imgIn[0]->framesf * scale);\n        channels = imgIn[0]->channels;\n    }\n\n    /**\n     * @brief execute\n     * @param in\n     * @param isb\n     * @param scale\n     * @return\n     */\n    static Image *execute(Image *in, ImageSampler *isb, float scale)\n    {\n        FilterSampler3D filterUp(scale, isb);\n        Image *out = filterUp.Process(Single(in), NULL);\n        return out;\n    }\n};\n\nPIC_INLINE FilterSampler3D::FilterSampler3D(float scale, ImageSampler *isb) : Filter()\n{\n    this->scale = scale;\n    this->isb = isb;\n}\n\nPIC_INLINE void FilterSampler3D::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n    Image *source = src[0];\n\n    for(int p = box->z0; p < box->z1; p++) {\n        float t = float(p) / float(box->frames - 1);\n\n        for(int j = box->y0; j < box->y1; j++) {\n            float y = float(j) / float(box->height - 1);\n\n            for(int i = box->x0; i < box->x1; i++) {\n                float x = float(i) / float(box->width - 1);\n\n                int c = p * source->tstride + j * source->ystride + i * source->xstride;\n\n                isb->SampleImage(source, x, y, t, &dst->data[c]);\n            }\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_SAMPLER_3D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_sampling_map.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_SAMPLING_MAP_HPP\n#define PIC_FILTERING_FILTER_SAMPLING_MAP_HPP\n\n#include \"../filtering/filter_npasses.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gradient.hpp\"\n#include \"../filtering/filter_sigmoid_tmo.hpp\"\n#include \"../filtering/filter_sampler_2d.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n#include \"../filtering/filter_channel.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterSamplingMap class\n */\nclass FilterSamplingMap: public FilterNPasses\n{\nprotected:\n    ImageSamplerBilinear isb;\n    float scale;\n\n    FilterLuminance *fltL;\n    FilterGradient *fltG;\n    FilterSigmoidTMO *fltS;\n    FilterSampler2D *fltD;\n    FilterGaussian2D *fltG2D;\n    FilterChannel *fltC;\n\npublic:\n    /**\n     * @brief FilterSamplingMap\n     * @param sigma\n     */\n    FilterSamplingMap(float sigma);\n\n    /**\n     * @brief FilterSamplingMap\n     * @param sigma\n     * @param scale\n     */\n    FilterSamplingMap(float sigma, float scale);\n\n    ~FilterSamplingMap();\n\n    /**\n     * @brief update\n     * @param sigma\n     * @param scale\n     */\n    void update(float sigma, float scale);\n\n    /**\n     * @brief getScale\n     * @return\n     */\n    float getScale()\n    {\n        return scale;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma\n     * @param scale\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float sigma)\n    {\n        FilterSamplingMap filter(sigma);\n        imgOut = filter.Process(Single(imgIn), NULL);\n\n        return imgOut;\n    }\n};\n\nPIC_INLINE FilterSamplingMap::FilterSamplingMap(float sigma) : FilterNPasses()\n{\n    fltL = NULL;\n    fltD = NULL;\n    fltS = NULL;\n    fltG = NULL;\n    fltG2D = NULL;\n    fltC = NULL;\n\n    float rateScale = 2.0f;\n    update(rateScale, rateScale / sigma);\n}\n\nPIC_INLINE FilterSamplingMap::FilterSamplingMap(float sigma, float scale) : FilterNPasses()\n{\n    fltL = NULL;\n    fltD = NULL;\n    fltS = NULL;\n    fltG = NULL;\n    fltG2D = NULL;\n\n    update(sigma * scale, scale);\n}\n\nPIC_INLINE FilterSamplingMap::~FilterSamplingMap()\n{\n    delete_s(fltL);\n    delete_s(fltD);\n    delete_s(fltS);\n    delete_s(fltC);\n    delete_s(fltG);\n    delete_s(fltG2D);\n}\n\nPIC_INLINE void FilterSamplingMap::update(float sigma, float scale)\n{\n    this->scale = scale;\n\n    //allocate filters\n    fltL = new FilterLuminance(LT_CIE_LUMINANCE);\n    fltD = new FilterSampler2D(scale, &isb);\n    fltS = new FilterSigmoidTMO();\n    fltG = new FilterGradient();\n    fltC = new FilterChannel(SingleInt(2));\n    fltG2D = new FilterGaussian2D(sigma);\n\n    insertFilter(fltL);     //Luminance\n    insertFilter(fltD);     //Downsampling\n    insertFilter(fltS);     //Sigmoid TMO\n    insertFilter(fltG);     //Gradient\n    insertFilter(fltC);     //Gradient\n    insertFilter(fltG2D, true);   //Gaussian\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_SAMPLING_MAP_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_sigmoid_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_SIGMOID_TMO_HPP\n#define PIC_FILTERING_FILTER_SIGMOID_TMO_HPP\n\n#include \"../util/array.hpp\"\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n\nnamespace pic {\n\nenum SIGMOID_MODE {SIG_TMO, SIG_TMO_WP, SIG_SDM};\n\n/**\n * @brief The FilterSigmoidTMO class\n */\nclass FilterSigmoidTMO: public Filter\n{\nprotected:\n    bool temporal;\n    float *lum_weights, *lum_weights_flt;\n    float c, alpha, epsilon, wp, wp_sq;\n    SIGMOID_MODE type;\n\n    /**\n     * @brief calculateEpsilon\n     * @param imgIn\n     * @return\n     */\n    float calculateEpsilon(ImageVec imgIn);\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box);\n\npublic:\n\\\n    /**\n     * @brief FilterSigmoidTMO\n     */\n    FilterSigmoidTMO();\n\n    /**\n     * @brief FilterSigmoidTMO\n     * @param type\n     * @param alpha\n     * @param wp\n     * @param epsilon\n     * @param temporal\n     */\n    FilterSigmoidTMO(SIGMOID_MODE type, float alpha, float wp, float epsilon,\n                     bool temporal);\n\n    ~FilterSigmoidTMO()\n    {\n        delete_s(lum_weights);\n        delete_s(lum_weights_flt);\n    }\n\n    /**\n     * @brief update\n     * @param type\n     * @param alpha\n     * @param wp\n     * @param epsilon\n     * @param temporal\n     */\n    void update(SIGMOID_MODE type, float alpha, float wp, float epsilon,\n                     bool temporal);\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        if(epsilon <= 0.0f || temporal) {\n            epsilon = calculateEpsilon(imgIn);\n        }\n\n        lum_weights = delete_s(lum_weights);\n        lum_weights_flt = delete_s(lum_weights_flt);\n\n        lum_weights = FilterLuminance::computeWeights(LT_CIE_LUMINANCE, imgIn[0]->channels, NULL);\n\n        int whichImage = (imgIn.size() > 1) ? 1 : 0;\n        lum_weights_flt = FilterLuminance::computeWeights(LT_CIE_LUMINANCE, imgIn[whichImage]->channels, NULL);\n\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = imgIn[0]->channels;\n        frames      = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        FilterSigmoidTMO filter(SIG_TMO, 0.18f, 1e9f, -1.0f, false);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\nPIC_INLINE FilterSigmoidTMO::FilterSigmoidTMO() : Filter()\n{\n    lum_weights = NULL;\n    lum_weights_flt = NULL;\n    update(SIG_TMO, 0.18f, 1e6f, -1.0f, false);\n}\n\nPIC_INLINE FilterSigmoidTMO::FilterSigmoidTMO(SIGMOID_MODE type, float alpha,\n                                   float wp, float epsilon, bool temporal) : Filter()\n{\n    lum_weights = NULL;\n    lum_weights_flt = NULL;\n    update(type, alpha, wp, epsilon, temporal);\n}\n\nPIC_INLINE void FilterSigmoidTMO::update(SIGMOID_MODE type, float alpha,\n                                   float wp = 1e9f, float epsilon = -1.0f, bool temporal = false)\n{\n    this->type = type;\n    this->alpha = alpha;\n    this->wp = wp;\n    this->wp_sq = wp * wp;\n\n    this->epsilon = epsilon;\n    this->temporal = temporal;\n}\n\nPIC_INLINE float FilterSigmoidTMO::calculateEpsilon(ImageVec imgIn)\n{\n    float tmpEpsilon, retEpsilon;\n\n    switch(type) {\n    case SIG_TMO:\n        imgIn[0]->getLogMeanVal(NULL, &tmpEpsilon);\n        break;\n\n    case SIG_TMO_WP:\n        imgIn[0]->getLogMeanVal(NULL, &tmpEpsilon);\n        break;\n\n    case SIG_SDM:\n        tmpEpsilon = 1.0f;\n        break;\n\n    default:\n        tmpEpsilon = 1.0f;\n    }\n\n    if(temporal) {\n        if(epsilon > 0.0f) {\n            retEpsilon = (epsilon + tmpEpsilon) / 2.0f;\n        } else {\n            retEpsilon = tmpEpsilon;\n        }\n    } else {\n        retEpsilon = tmpEpsilon;\n    }\n\n    return retEpsilon;\n}\n\nPIC_INLINE void FilterSigmoidTMO::ProcessBBox(Image *dst, ImageVec src, BBox *box)\n{\n\n    Image *img, *img_flt;\n\n    img = src[0];\n\n    if(src.size() > 1) {\n        img_flt = src[1];\n    } else {\n        img_flt = src[0];\n    }\n\n    float alpha_over_epsilon = alpha / epsilon;\n\n    for(int j = box->y0; j < box->y1; j++) {\n\n        for(int i = box->x0; i < box->x1; i++) {\n\n            float *p = (*img)(i, j);\n            float *p_flt = (*img_flt)(i, j);\n\n            float *dstOut = (*dst)(i, j);\n\n            float L = Arrayf::dot(p, lum_weights, img->channels);\n\n            if(L > 0.0f) {\n                float L_flt = Arrayf::dot(p_flt, lum_weights_flt, img_flt->channels);\n\n                float Lm = L * alpha_over_epsilon;\n                float Lm_flt = L_flt * alpha_over_epsilon;\n                float Ld;\n\n                if(type == SIG_TMO_WP) {\n                    Ld = L * (1.0f + L / wp_sq) / (1.0f + Lm_flt);\n                } else {\n                    Ld = Lm / (1.0f + Lm_flt);\n                }\n\n                for(int k = 0; k < dst->channels; k++) {\n                    dstOut[k] = (p[k] * Ld) / L;\n                }\n            } else {\n                Arrayf::assign(0.0f, dstOut, dst->channels);\n            }\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_SIGMOID_TMO_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_simple_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_SIMPLE_TMO_HPP\n#define PIC_FILTERING_FILTER_SIMPLE_TMO_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterSimpleTMO class\n */\nclass FilterSimpleTMO: public Filter\n{\nprotected:\n    float gamma, fstop, exposure;\n\n    /**\n     * @brief f\n     * @param data\n     */\n    void f(FilterFData *data)\n    {\n        float *dataIn = (*data->src[0])(data->x, data->y);\n\n        for(int k = 0; k < data->dst->channels; k++) {\n            data->out[k] = powf((dataIn[k] * exposure), gamma);\n        }\n    }\n\npublic:\n    /**\n     * @brief FilterSimpleTMO\n     * @param gamma\n     * @param fstop\n     */\n    FilterSimpleTMO(float gamma, float fstop) : Filter()\n    {\n        update(gamma, fstop);\n    }\n\n    /**\n     * @brief update\n     * @param gamma\n     * @param fstop\n     */\n    void update(float gamma, float fstop)\n    {\n        this->gamma = 1.0f / gamma;\n        this->fstop = fstop;\n        exposure = powf(2.0f, fstop);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param gamma\n     * @param fstop\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut, float gamma,\n                             float fstop)\n    {\n        FilterSimpleTMO filter(gamma, fstop);\n        return filter.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_SIMPLE_TMO_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_ssim.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_SSIM_HPP\n#define PIC_FILTERING_FILTER_SSIM_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterSSIM class\n */\nclass FilterSSIM: public Filter\n{\nprotected:\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        int width    = src[0]->width;\n        int channels = src[0]->channels;\n\n        for(int j = box->y0; j < box->y1; j++) {\n            int c = j * width;\n\n            for(int i = box->x0; i < box->x1; i++) {\n                int ind = (c + i) *  channels;\n\n                float mu1 = src[0]->data[ind];\n                float mu1_sq = mu1 * mu1;\n\n                float mu2 = src[1]->data[ind];\n                float mu2_sq = mu2 * mu2;\n\n                float sigma1_sq = src[2]->data[ind] - mu1_sq;\n                float sigma2_sq = src[3]->data[ind] - mu2_sq;\n                float mu1_mu2 = mu1 * mu2;\n                float sigma1_sigma2 = src[4]->data[ind] - mu1_mu2;\n\n                //numerator\n               float tmp1 = (mu1_mu2 * 2.0f + C0) *\n                            (sigma1_sigma2 * 2.0f + C1);\n\n               //denominator\n               float tmp2 = (mu1_sq + mu2_sq + C0 ) *\n                            (sigma1_sq + sigma2_sq + C1);\n\n               dst->data[ind] = tmp1 / tmp2;\n            }\n        }\n    }\n\n    float C0, C1;\n\npublic:\n\n    /**\n     * @brief FilterSSIM\n     * @param type\n     */\n    FilterSSIM() : Filter()\n    {\n        minInputImages = 5;\n    }\n\n    /**\n     * @brief FilterSSIM\n     * @param type\n     */\n    FilterSSIM(float C0, float C1) : Filter()\n    {\n        minInputImages = 5;\n        update(C0, C1);\n    }\n\n    /**\n     * @brief update\n     * @param C0\n     * @param C1\n     */\n    void update(float C0, float C1)\n    {\n        this->C0 = C0;\n        this->C1 = C1;\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_SSIM_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_threshold.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_THRESHOLD_HPP\n#define PIC_FILTERING_FILTER_THRESHOLD_HPP\n\n#include \"../image.hpp\"\n#include \"../histogram.hpp\"\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterThreshold class\n */\nclass FilterThreshold: public Filter\n{\nprotected:\n    float threshold;\n    bool bAdaptive;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        Image* img = src[0];\n\n        if(bAdaptive) {\n            if(src.size() < 2) {\n                return;\n            }\n\n            Image* img_ada = src[1];\n\n            for(int j = box->y0; j < box->y1; j++) {\n\n                for(int i = box->x0; i < box->x1; i++) {\n                    float *dst_val = (*dst)(i, j);\n                    float *img_val = (*img)(i, j);\n                    float *img_ada_val = (*img_ada)(i, j);\n\n                    dst_val[0] = img_val[0] > img_ada_val[0] ? 1.0f : 0.0f;\n                }\n            }\n        } else {\n            for(int j = box->y0; j < box->y1; j++) {\n\n                for(int i = box->x0; i < box->x1; i++) {\n                    float *dst_val = (*dst)(i, j);\n                    float *img_val = (*img)(i, j);\n\n                    dst_val[0] = img_val[0] > threshold ? 1.0f : 0.0f;\n                }\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterThreshold\n     * @param threshold\n     * @param bAdaptive\n     */\n    FilterThreshold(float threshold = 0.5f, bool bAdaptive = false) : Filter()\n    {\n        update(threshold, bAdaptive);\n    }\n\n    /**\n     * @brief update\n     * @param threshold\n     * @param bAdaptive\n     */\n    void update(float threshold, bool bAdaptive)\n    {\n        this->threshold = threshold;\n        this->bAdaptive = bAdaptive;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = 1;\n        frames      = imgIn[0]->frames;\n    }\n\n    static Image* execute(Image* imgIn, Image *imgOut, float threshold, bool bAdaptive)\n    {\n        FilterThreshold flt(threshold, bAdaptive);\n        imgOut = flt.Process(Single(imgIn), imgOut);\n        return imgOut;\n    }\n\n    static Image* Otsu(Image* imgIn, Image *imgOut)\n    {\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        pic::Image *imgLum;\n        if(imgIn->channels == 3) {\n            imgLum = pic::FilterLuminance::execute(imgIn, NULL);\n        } else {\n            imgLum = imgIn;\n        }\n\n        pic::Histogram h;\n        h.calculate(imgLum, pic::VS_LIN, 1024, NULL, 0);\n        float thr = h.getOtsu();\n        imgOut = pic::FilterThreshold::execute(imgLum, imgOut, thr, false);\n\n        if(imgIn->channels == 3) {\n            delete imgLum;\n        }\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_THRESHOLD_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_tmqi.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_TMQI_HPP\n#define PIC_FILTERING_FILTER_TMQI_HPP\n\n#include \"../util/math.hpp\"\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterTMQI class\n */\nclass FilterTMQI: public Filter\n{\nprotected:\n\n    float C1, C2;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *out = (*dst)(i, j);\n\n                float sigma1 = (*src[0])(i, j)[0];\n                float sigma1p = normalCDF(sigma1, u_hdr, sig_hdr);\n\n                float sigma2 = (*src[1])(i, j)[0];\n                float sigma2p = normalCDF(sigma2, u_ldr, sig_ldr);\n\n                float sigma12 = (*src[2])(i, j)[0];\n\n                out[0] = (((2*sigma1p*sigma2p)+C1)/((sigma1p*sigma1p)+(sigma2p*sigma2p)+C1))*((sigma12+C2)/(sigma1*sigma2 + C2));\n            }\n        }\n    }\n\n    float u_hdr, sig_hdr, u_ldr, sig_ldr;\n\npublic:\n\n    /**\n     * @brief FilterTMQI\n     * @param type\n     */\n    FilterTMQI() : Filter()\n    {\n        C1 = 0.01f;\n        C2 = 10.0f;\n        minInputImages = 3;\n    }\n\n    /**\n     * @brief MannosCSF\n     * @param sf\n     * @return\n     */\n    static float MannosCSF(float sf)\n    {\n        return 100.0f * 2.6f *\n                (0.0192f + 0.114f * sf) *\n                expf(-powf(0.114f * sf, 1.1f));\n    }\n\n    /**\n     * @brief update\n     */\n    void update(float sf)\n    {\n        float CSF = MannosCSF(sf);\n\n        u_hdr = 128.0f / (1.4f * CSF);\n        sig_hdr = u_hdr / 3.0f;\n\n        u_ldr = u_hdr;\n        sig_ldr = u_ldr / 3.0f;\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_TMQI_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_up_pp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_UP_PP_HPP\n#define PIC_FILTERING_FILTER_UP_PP_HPP\n\n#include \"../util/array.hpp\"\n\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_down_pp.hpp\"\n#include \"../image_samplers/image_sampler_bilinear.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterUpPP class\n */\nclass FilterUpPP: public Filter\n{\nprotected:\n\n    ImageSamplerBilinear isb;\n\n    float *value, threshold;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        for(int i = box->y0; i < box->y1; i++) {\n            float y = float(i) / dst->heightf;\n\n            for(int j = box->x0; j < box->x1; j++) {\n                float x = float(j) / dst->widthf;\n\n                float *data = (*dst)(j, i);\n\n                float dist = Arrayf::distanceSq(data, value, src[0]->channels);\n\n                if(dist <= threshold) {\n                    isb.SampleImage(src[0], x, y, data);\n                }\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterUpPP\n     * @param value\n     * @param threshold\n     */\n    FilterUpPP(float *value, float threshold) : Filter()\n    {\n        update(value, threshold);\n    }\n\n    ~FilterUpPP()\n    {\n    }\n\n    /**\n     * @brief update\n     * @param value\n     * @param threshold\n     */\n    void update(float *value, float threshold)\n    {\n        this->value = value;\n\n        if(value == NULL) {\n            printf(\"ERROR in FilterUpPP\");\n        }\n\n        this->value = value;\n\n        this->threshold = (threshold > 0.0f) ? threshold : 1e-6f;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        if(imgIn.size() == 1) {\n            width       = imgIn[0]->width << 1;\n            height      = imgIn[0]->height << 1;\n        } else {\n            width       = imgIn[1]->width;\n            height      = imgIn[1]->height;\n        }\n\n        channels    = imgIn[0]->channels;\n        frames      = imgIn[0]->frames;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_DOWN_PP_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_warp_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_WARP_2D_HPP\n#define PIC_GL_FILTERING_FILTER_WARP_2D_HPP\n\n#include \"../util/matrix_3_x_3.hpp\"\n\n#include \"../filtering/filter.hpp\"\n#include \"../image_samplers/image_sampler_bilinear.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterWarp2D class\n */\nclass FilterWarp2D: public Filter\n{\nprotected:\n    ImageSamplerBilinear isb;\n    Matrix3x3 h, h_inv;\n    int bmin[2], bmax[2];\n    float mid[2];\n    bool bComputeBoundingBox;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        int channels = src[0]->channels;\n\n        float pos[2], pos_out[2];\n\n        for(int j = box->y0; j < box->y1; j++) {\n            pos[1] = float(j + bmin[1]) - mid[1];\n\n            for(int i = box->x0; i < box->x1; i++) {\n                float *tmp_dst = (*dst)(i, j);\n\n                pos[0] = float(i + bmin[0]) - mid[0];\n\n                h_inv.projection(pos, pos_out);\n\n                pos_out[0] += mid[0];\n                pos_out[1] += mid[1];\n\n                if(pos_out[0] >= 0.0f && pos_out[0] <= src[0]->width1f &&\n                   pos_out[1] >= 0.0f && pos_out[1] <= src[0]->height1f) {\n                    isb.SampleImageUC(src[0], pos_out[0], pos_out[1], tmp_dst);\n                } else {\n                    Arrayf::assign(0.0f, tmp_dst, channels);\n                }\n            }\n        }\n    }\n\n    bool bSameSize, bCentroid;\n\npublic:\n\n    /**\n     * @brief FilterWarp2D\n     */\n    FilterWarp2D() : Filter()\n    {\n        this->bComputeBoundingBox = true;\n        this->bCentroid = false;\n        this->bSameSize = false;\n\n        h.getIdentity();\n        h_inv.getIdentity();\n    }\n\n    /**\n     * @brief FilterWarp2D\n     * @param h\n     * @param bSameSize\n     * @param bCentroid\n     */\n    FilterWarp2D(Matrix3x3 h, bool bSameSize = false, bool bCentroid = false) : Filter()\n    {\n        this->bComputeBoundingBox = true;\n        update(h, bSameSize, bCentroid);\n    }\n\n    /**\n     * @brief getBCentroid\n     * @return\n     */\n    bool getBCentroid()\n    {\n        return bCentroid;\n    }\n\n    /**\n     * @brief computeBoundingBox\n     * @param h\n     * @param bCentroid\n     * @param width\n     * @param height\n     * @param bmin\n     * @param bmax\n     */\n    static void computeBoundingBox(Matrix3x3 &h, bool bCentroid,\n                                   float width, float height,\n                                   int *bmin, int *bmax ) {\n        float bbox[4][2];\n        float bbox_out[4][2];\n\n        bbox[0][0] = 0.0f;\n        bbox[0][1] = 0.0f;\n\n        bbox[1][0] = 0.0f;\n        bbox[1][1] = height;\n\n        bbox[2][0] = width;\n        bbox[2][1] = 0.0f;\n\n        bbox[3][0] = width;\n        bbox[3][1] = height;\n\n        float mid[2];\n\n        if(bCentroid) {\n            mid[0] = width  * 0.5f;\n            mid[1] = height * 0.5f;\n        } else {\n            mid[0] = 0.0f;\n            mid[1] = 0.0f;\n        }\n\n        //compute the bounding box\n        bmin[0] = 1 << 24;\n        bmin[1] = 1 << 24;\n\n        bmax[0] = -1;\n        bmax[1] = -1;\n\n        for(int i = 0; i < 4; i++) {\n\n            bbox[i][0] -= mid[0];\n            bbox[i][1] -= mid[1];\n\n            h.projection(&bbox[i][0], &bbox_out[i][0]);\n\n            bbox_out[i][0] += mid[0];\n            bbox_out[i][1] += mid[1];\n\n            int x = int(bbox_out[i][0]);\n            int y = int(bbox_out[i][1]);\n\n            //min point\n            bmin[0] = (x < bmin[0]) ? x : bmin[0];\n            bmin[1] = (y < bmin[1]) ? y : bmin[1];\n\n            bmax[0] = (x > bmax[0]) ? x : bmax[0];\n            bmax[1] = (y > bmax[1]) ? y : bmax[1];\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"%d %d %d %d\\n\", bmax[0], bmin[0], bmax[1], bmin[1]);\n        #endif\n    }\n\n    /**\n     * @brief setBoundingBox\n     * @param bmin\n     * @param bmax\n     */\n    void setBoundingBox(int *bmin, int *bmax)\n    {\n        memcpy(this->bmin, bmin, sizeof(int) * 2);\n        memcpy(this->bmax, bmax, sizeof(int) * 2);\n        bComputeBoundingBox = false;\n    }\n\n    /**\n     * @brief update\n     * @param h\n     * @param bSameSize\n     * @param bCentroid\n     */\n    void update(Matrix3x3 h, bool bSameSize, bool bCentroid = false)\n    {\n        this->bComputeBoundingBox = true;\n\n        this->bSameSize = bSameSize;\n        this->bCentroid = bCentroid;\n\n        this->h = h;\n        h.inverse(&h_inv);\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        if(bCentroid) {\n            mid[0] = imgIn[0]->widthf;\n            mid[1] = imgIn[0]->heightf;\n        } else {\n            mid[0] = 0.0f;\n            mid[1] = 0.0f;\n        }\n\n        if(!bSameSize) {\n            if(bComputeBoundingBox) {\n                computeBoundingBox(h, bCentroid,\n                                   imgIn[0]->widthf, imgIn[0]->heightf,\n                                   bmin, bmax);\n            }\n\n            width  = bmax[0] - bmin[0];\n            height = bmax[1] - bmin[1];\n        } else {\n            bmin[0] = 0;\n            bmin[1] = 0;\n\n            bmax[0] = 0;\n            bmax[1] = 0;\n\n            width  = imgIn[0]->width;\n            height = imgIn[0]->height;\n        }\n\n        frames   = imgIn[0]->frames;\n        channels = imgIn[0]->channels;\n    }\n\n    /**\n     * @brief execute\n     * @param img\n     * @param imgOut\n     * @param h\n     * @param bSameSize\n     * @param bCentroid\n     * @return\n     */\n    static Image *execute(Image *img, Image *imgOut, Matrix3x3 h, bool bSameSize = false, bool bCentroid = false)\n    {\n        FilterWarp2D flt(h, bSameSize, bCentroid);\n        imgOut = flt.Process(Single(img), imgOut);\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_WARP_2D_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_white_balance.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_WHITE_BALANCE_HPP\n#define PIC_FILTERING_FILTER_WHITE_BALANCE_HPP\n\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter.hpp\"\n#include \"../util/array.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterWhiteBalance class\n */\nclass FilterWhiteBalance: public Filter\n{\nprotected:\n\n    float *white;\n    int nWhite;\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        if(white == NULL) {\n            return;\n        }\n\n        int width    = src[0]->width;\n        int channels = src[0]->channels;\n        float *data  = src[0]->data;\n\n        int transformChannels = MIN(channels, nWhite);\n\n        for(int j = box->y0; j < box->y1; j++) {\n            int c = j * width;\n\n            for(int i = box->x0; i < box->x1; i++) {\n                int indOut = c + i;\n                int ind = indOut * channels;\n\n                for(int k = 0; k < transformChannels; k++) {\n                    dst->data[ind + k] = data[ind + k] * white[k];\n                }\n            }\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterWhiteBalance\n     * @param type\n     */\n    FilterWhiteBalance()\n    {\n        white = NULL;\n        nWhite = -1;\n    }\n\n    /**\n     * @brief FilterWhiteBalance\n     * @param white\n     * @param nWhite\n     * @param bComputeScalingFactors\n     */\n    FilterWhiteBalance(float *white, unsigned int nWhite, bool bComputeScalingFactors)\n    {\n        this->white = NULL;\n        this->nWhite = -1;\n\n        update(white, nWhite, bComputeScalingFactors);\n    }\n\n    ~FilterWhiteBalance()\n    {\n        delete_vec_s(white);\n        nWhite = -1;\n    }\n\n    /**\n     * @brief getScalingFactors\n     * @param white\n     * @param nWhite\n     * @return\n     */\n    static float *getScalingFactors(float *white, int nWhite)\n    {\n        if(white == NULL || nWhite < 1) {\n            return NULL;\n        }\n\n        float white_mean = Arrayf::sum(white, nWhite) / float(nWhite);\n\n        float *out = new float[nWhite];\n\n        for(int i = 0; i < nWhite; i++) {\n            if(white[i] > 0.0f) {\n                out[i] = white_mean / white[i];\n            } else {\n                out[i] = 1.0f;\n            }\n        }\n\n        return out;\n    }\n\n    /**\n     * @brief update\n     * @param white\n     * @param nWhite\n     * @param bComputeScalingFactors\n     */\n    void update(float *white, unsigned int nWhite, bool bComputeScalingFactors)\n    {\n        this->nWhite = nWhite;\n\n        delete_vec_s(this->white);\n\n        if(bComputeScalingFactors) {\n             this->white = getScalingFactors(white, nWhite);\n        } else {\n            this->white = new float[nWhite];\n            memcpy(this->white, white, sizeof(float) * nWhite);\n        }\n\n        for(unsigned int i = 0; i < nWhite; i++) {\n            if(fabsf(this->white[i]) <= 1e-9f) {\n                this->white[i] = 1.0f;\n            }\n        }\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param white_color\n     * @param out\n     * @return\n     */\n    static Image* execute(Image *imgIn, float *white_color, Image *out)\n    {\n        if(imgIn == NULL || white_color == NULL) {\n            return NULL;\n        }\n\n        FilterWhiteBalance flt_wb(white_color, imgIn->channels, true);\n        out = flt_wb.Process(Single(imgIn), out);\n\n        return out;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param x\n     * @param y\n     * @param bRobust\n     * @param out\n     * @return\n     */\n    static Image* execute(Image *imgIn, int x, int y, bool bRobust = true, Image *out = NULL)\n    {\n        if(imgIn == NULL) {\n            return NULL;\n        }\n\n        float *white_color = NULL;\n\n        int patchSize = 5;\n\n        if(!bRobust) {\n            white_color = (*imgIn)(x, y);\n        } else {\n            BBox patch(x - patchSize, x + patchSize, y - patchSize, y + patchSize);\n            white_color = imgIn->getMeanVal(&patch, NULL);\n        }\n\n        out = execute(imgIn, white_color, out);\n\n        if(bRobust) {\n            delete_vec_s(white_color);\n        }\n\n        return out;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_WHITE_BALANCE_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_wls.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_WLS_HPP\n#define PIC_FILTERING_FILTER_WLS_HPP\n\n#include \"../filtering/filter.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Sparse\"\n    #include \"../externals/Eigen/src/SparseCore/SparseMatrix.h\"\n#else\n    #include <Eigen/Sparse>\n    #include <Eigen/src/SparseCore/SparseMatrix.h>\n#endif\n\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\nclass FilterWLS: public Filter\n{\nprotected:\n    /**\n     * @brief singleChannel applies WLS smoothing filter for gray-scale images.\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *singleChannel(ImageVec imgIn, Image *imgOut)\n    {\n        Image *L = imgIn[0];\n\n        int width  = L->width;\n        int height = L->height;\n        int tot    = height * width;\n\n        Eigen::VectorXd b, x;\n        b = Eigen::VectorXd::Zero(tot);\n\n        #ifdef PIC_DEBUG\n            printf(\"Init matrix...\");\n        #endif\n\n        std::vector< Eigen::Triplet< double > > tL;\n\n        for(int i = 0; i < height; i++) {\n            int tmpInd = i * width;\n\n            for(int j = 0; j < width; j++) {\n\n                float Ltmp, tmp;\n                int indJ;\n                int indI = tmpInd + j;\n                float Lref = L->data[indI];\n\n                b[indI] = Lref;\n\n                float sum = 0.0f;\n\n                if((i - 1) >= 0) {\n                    indJ = indI - width;\n                    Ltmp = L->data[indJ];\n                    tmp  = -lambda / (powf(fabsf(Ltmp - Lref), alpha) + epsilon);\n                    tL.push_back(Eigen::Triplet< double > (indI, indJ, tmp));\n                    sum += tmp;\n                }\n\n                if((i + 1) < height) {\n                    indJ = indI + width;\n                    Ltmp = L->data[indJ];\n                    tmp  = -lambda / (powf(fabsf(Ltmp - Lref), alpha) + epsilon);\n                    tL.push_back(Eigen::Triplet< double > (indI, indJ, tmp));\n                    sum += tmp;\n                }\n\n                if((j - 1) >= 0) {\n                    indJ = indI - 1;\n                    Ltmp = L->data[indJ];\n                    tmp  = -lambda / (powf(fabsf(Ltmp - Lref), alpha) + epsilon);\n                    tL.push_back(Eigen::Triplet< double > (indI, indJ, tmp));\n                    sum += tmp;\n                }\n\n                if((j + 1) < width) {\n                    indJ = indI + 1;\n                    Ltmp = L->data[indJ];\n                    tmp  = -lambda / (powf(fabsf(Ltmp - Lref), alpha) + epsilon);\n                    tL.push_back(Eigen::Triplet< double > (indI, indJ, tmp));\n                    sum += tmp;\n                }\n\n                tL.push_back(Eigen::Triplet< double > (indI, indI, 1.0f - sum));\n            }\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"Ok\\n\");\n        #endif\n\n        Eigen::SparseMatrix<double> A = Eigen::SparseMatrix<double>(tot, tot);\n        A.setFromTriplets(tL.begin(), tL.end());\n\n        Eigen::SimplicialCholesky<Eigen::SparseMatrix<double> > solver(A);\n        x = solver.solve(b);\n\n        if(solver.info() != Eigen::Success) {\n            #ifdef PIC_DEBUG\n                printf(\"SOLVER FAILED!\\n\");\n            #endif\n            return NULL;\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"SOLVER SUCCESS!\\n\");\n        #endif\n\n        #pragma omp parallel for\n\n        for(int i = 0; i < tot; i++) {\n            imgOut->data[i] = float(x(i));\n        }\n\n        return imgOut;\n    }\n\n    /**\n     * @brief multiChannel applies WLS filter for color images.\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *multiChannel(ImageVec imgIn, Image *imgOut)\n    {\n        Image *img = imgIn[0];\n\n        int width  = img->width;\n        int height = img->height;\n        int tot    = height * width;\n\n        alpha /= 2.0f;\n\n        int stridex = width * img->channels;\n\n        #ifdef PIC_DEBUG\n            printf(\"Init matrix...\");\n        #endif\n\n        std::vector< Eigen::Triplet< double > > tL;\n\n        for(int i = 0; i < height; i++) {\n            int tmpInd = i * width;\n\n            for(int j = 0; j < width; j++) {\n\n                float sum = 0.0f;\n                float tmp;\n                int indJ;\n                int indI = tmpInd + j;\n                int indImg = indI * img->channels;\n\n                if((i - 1) >= 0) {\n                    indJ = indImg - stridex;\n                    float diff = 0.0f;\n\n                    for(int p = 0; p < img->channels; p++) {\n                        float tmpDiff = img->data[indJ + p] - img->data[indImg + p];\n                        diff += tmpDiff * tmpDiff;\n                    }\n\n                    tmp  = -lambda / (powf(diff, alpha) + epsilon);\n\n                    tL.push_back(Eigen::Triplet< double > (indI, indI - width , tmp));\n\n                    sum += tmp;\n                }\n\n                if((i + 1) < height) {\n                    indJ = indImg + stridex;\n                    float diff = 0.0f;\n\n                    for(int p = 0; p < img->channels; p++) {\n                        float tmpDiff = img->data[indJ + p] - img->data[indImg + p];\n                        diff += tmpDiff * tmpDiff;\n                    }\n\n                    tmp  = -lambda / (powf(diff, alpha) + epsilon);\n                    tL.push_back(Eigen::Triplet< double > (indI, indI + width , tmp));\n                    sum += tmp;\n                }\n\n                if((j - 1) >= 0) {\n                    indJ = indImg - img->channels;\n                    float diff = 0.0f;\n\n                    for(int p = 0; p < img->channels; p++) {\n                        float tmpDiff = img->data[indJ + p] - img->data[indImg + p];\n                        diff += tmpDiff * tmpDiff;\n                    }\n\n                    tmp  = -lambda / (powf(diff, alpha) + epsilon);\n                    tL.push_back(Eigen::Triplet< double > (indI, indI - 1 , tmp));\n                    sum += tmp;\n                }\n\n                if((j + 1) < width) {\n                    indJ = indImg + img->channels;\n                    float diff = 0.0f;\n\n                    for(int p = 0; p < img->channels; p++) {\n                        float tmpDiff = img->data[indJ + p] - img->data[indImg + p];\n                        diff += tmpDiff * tmpDiff;\n                    }\n\n                    tmp  = -lambda / (powf(diff, alpha) + epsilon);\n\n                    tL.push_back(Eigen::Triplet< double > (indI, indI + 1 , tmp));\n                    sum += tmp;\n                }\n\n                tL.push_back(Eigen::Triplet< double > (indI, indI, 1.0f - sum));\n            }\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"Ok\\n\");\n        #endif\n\n        Eigen::SparseMatrix<double> A = Eigen::SparseMatrix<double>(tot, tot);\n\n        A.setFromTriplets(tL.begin(), tL.end());\n\n        Eigen::SimplicialCholesky< Eigen::SparseMatrix< double > > solver(A);\n\n        for(int i = 0; i < imgOut->channels; i++) {\n            Eigen::VectorXd b, x;\n\n            b = Eigen::VectorXd::Zero(tot);\n            #pragma omp parallel for\n\n            for(int j = 0; j < tot; j++) {\n                b[j] = img->data[j * img->channels + i];\n            }\n\n            x = solver.solve(b);\n\n            if(solver.info() == Eigen::Success) {\n\n                #ifdef PIC_DEBUG\n                    printf(\"SOLVER SUCCESS!\\n\");\n                #endif\n\n                #pragma omp parallel for\n\n                for(int j = 0; j < tot; j++) {\n                    imgOut->data[j * imgOut->channels + i] = float(x(j));\n                }\n            } else {\n                #ifdef PIC_DEBUG\n                    printf(\"SOLVER FAILED!\\n\");\n                #endif\n            }\n\n        }\n\n        return imgOut;\n    }\n\n    float alpha, lambda, epsilon;\n\npublic:\n\n    /**\n     * @brief FilterWLS\n     */\n    FilterWLS() : Filter()\n    {\n        update(1.2f, 1.0f);\n    }\n\n    /**\n     * @brief FilterWLS\n     * @param alpha\n     * @param lambda\n     */\n    FilterWLS(float alpha, float lambda) : Filter()\n    {\n        update(alpha, lambda);\n    }\n\n    /**\n     * @brief update\n     * @param alpha\n     * @param lambda\n     */\n    void update(float alpha, float lambda)\n    {\n        epsilon = 0.0001f;\n\n        if(alpha <= 0.0f) {\n            alpha = 1.2f;\n        }\n\n        if(lambda <= 0.0f) {\n            lambda = 1.0f;\n        }\n\n        this->alpha = alpha;\n        this->lambda = lambda;\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut)\n    {\n        if(imgIn.empty()){\n            return imgOut;\n        }\n\n        if(imgIn[0] == NULL) {\n            return imgOut;\n        }\n\n        imgOut = setupAux(imgIn, imgOut);\n\n        if(imgOut == NULL) {\n            return imgOut;\n        }\n\n        //convolution\n        if(imgIn[0]->channels == 1) {\n            return singleChannel(imgIn, imgOut);\n        } else {\n            return multiChannel(imgIn, imgOut);\n        }\n    }\n\n    /**\n     * @brief main\n     * @param argc\n     * @param argv\n     * @return\n     */\n    static int main(int argc, char* argv[])\n    {\n        if(argc < 4) {\n            printf(\"Usage: name_input alpha lambad\\n\");\n            return 0;\n        }\n\n        std::string nameIn = argv[1];\n        std::string name = removeExtension(nameIn);\n        std::string ext = getExtension(nameIn);\n\n        float alpha = float(atof(argv[2]));\n        float lambda = float(atof(argv[3]));\n\n        std::string nameOut = name + \"_wls.\" + ext; \n\n        Image img(nameIn);\n\n        FilterWLS *filter = new FilterWLS(alpha, lambda);\n\n        filter->Process(Single(&img), NULL)->Write(nameOut);\n\n        return 0;\n    }\n};\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_WLS_HPP */\n\n"
  },
  {
    "path": "include/filtering/filter_zero_crossing.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_ZERO_CROSSING_HPP\n#define PIC_FILTERING_FILTER_ZERO_CROSSING_HPP\n\n#include \"../filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterZeroCrossing class\n */\nclass FilterZeroCrossing: public Filter\n{\nprotected:\n\n    /**\n     * @brief f\n     * @param data\n     */\n    void f(FilterFData *data)\n    {\n\n        float value;\n\n        float *data_src  = (*data->src[0])(data->x, data->y);\n        float *data_src0 = (*data->src[0])(data->x, data->y + 1);\n        float *data_src1 = (*data->src[0])(data->x + 1, data->y);\n\n        for(int k = 0; k < data->src[0]->channels; k++) {\n            value = (data_src[k] == 0.0f) ? 1.0f : 0.0f;\n            value = (data_src[k] > 0.0f && data_src0[k] < 0.0f) ? 1.0f : value;\n            value = (data_src[k] < 0.0f && data_src0[k] > 0.0f) ? 1.0f : value;\n            value = (data_src[k] > 0.0f && data_src1[k] < 0.0f) ? 1.0f : value;\n            value = (data_src[k] < 0.0f && data_src1[k] > 0.0f) ? 1.0f : value;\n            data->out[k] = value;\n        }\n    }\n\n    /**\n     * @brief ProcessBBox\n     * @param dst\n     * @param src\n     * @param box\n     */\n    /*\n    void ProcessBBox(Image *dst, ImageVec src, BBox *box)\n    {\n        Image *src_p = src[0];\n\n        int channels = src_p->channels;\n        float value;\n\n        for(int i = box->y0; i < box->y1; i++) {\n\n            for(int j = box->x0; j < box->x1; j++) {\n\n                float *data_src = (*src_p)(j, i);\n                float *data_dst = (*dst)(j, i);\n\n                float *data_src0 = (*src_p)(j, i + 1);\n                float *data_src1 = (*src_p)(j + 1, i);\n\n                for(int k = 0; k < channels; k++) {\n                    value = (data_src[k] == 0.0f) ? 1.0f : 0.0f;\n                    value = (data_src[k] > 0.0f && data_src0[k] < 0.0f) ? 1.0f : value;\n                    value = (data_src[k] < 0.0f && data_src0[k] > 0.0f) ? 1.0f : value;\n                    value = (data_src[k] > 0.0f && data_src1[k] < 0.0f) ? 1.0f : value;\n                    value = (data_src[k] < 0.0f && data_src1[k] > 0.0f) ? 1.0f : value;\n                    data_dst[k] = value;\n                }\n            }\n        }\n    }\n    */\n\npublic:\n\n    /**\n     * @brief FilterZeroCrossing\n     * @param type\n     */\n    FilterZeroCrossing() : Filter()\n    {\n    }\n\n    ~FilterZeroCrossing()\n    {\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        FilterZeroCrossing flt;\n        return flt.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_ZERO_CROSSING_HPP */\n\n"
  },
  {
    "path": "include/filtering.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n\n#ifndef PIC_FILTERING_HPP\n#define PIC_FILTERING_HPP\n\n#include \"filtering/filter.hpp\"\n#include \"filtering/filter_down_pp.hpp\"\n#include \"filtering/filter_up_pp.hpp\"\n#include \"filtering/filter_white_balance.hpp\"\n#include \"filtering/filter_integral_image.hpp\"\n#include \"filtering/filter_reconstruct.hpp\"\n#include \"filtering/filter_local_extrema.hpp\"\n#include \"filtering/filter_warp_2d.hpp\"\n#include \"filtering/filter_absolute_difference.hpp\"\n#include \"filtering/filter_anisotropic_diffusion.hpp\"\n#include \"filtering/filter_assemble_hdr.hpp\"\n#include \"filtering/filter_backward_difference.hpp\"\n#include \"filtering/filter_bilateral_1d.hpp\"\n#include \"filtering/filter_bilateral_2das.hpp\"\n#include \"filtering/filter_bilateral_2df.hpp\"\n#include \"filtering/filter_bilateral_2dg.hpp\"\n#include \"filtering/filter_bilateral_2ds.hpp\"\n#include \"filtering/filter_bilateral_2dsp.hpp\"\n#include \"filtering/filter_channel.hpp\"\n#include \"filtering/filter_color_conv.hpp\"\n#include \"filtering/filter_color_distance.hpp\"\n#include \"filtering/filter_combine.hpp\"\n#include \"filtering/filter_conv_1d.hpp\"\n#include \"filtering/filter_conv_2d.hpp\"\n#include \"filtering/filter_conv_2dsp.hpp\"\n#include \"filtering/filter_crop.hpp\"\n#include \"filtering/filter_dct_1d.hpp\"\n#include \"filtering/filter_dct_2d.hpp\"\n#include \"filtering/filter_diff_gauss_2d.hpp\"\n#include \"filtering/filter_diff_gauss_2d_opt.hpp\"\n#include \"filtering/filter_log_2d.hpp\"\n#include \"filtering/filter_log_2d_opt.hpp\"\n#include \"filtering/filter_divergence.hpp\"\n#include \"filtering/filter_downsampler_2d.hpp\"\n#include \"filtering/filter_drago_tmo.hpp\"\n#include \"filtering/filter_gaussian_1d.hpp\"\n#include \"filtering/filter_gaussian_2d.hpp\"\n#include \"filtering/filter_gaussian_3d.hpp\"\n#include \"filtering/filter_gradient.hpp\"\n#include \"filtering/filter_gradient_harris_opt.hpp\"\n#include \"filtering/filter_guided_a_b.hpp\"\n#include \"filtering/filter_guided.hpp\"\n#include \"filtering/filter_iterative.hpp\"\n#include \"filtering/filter_kuwahara.hpp\"\n#include \"filtering/filter_laplacian.hpp\"\n#include \"filtering/filter_linear_color_space.hpp\"\n#include \"filtering/filter_luminance.hpp\"\n#include \"filtering/filter_max.hpp\"\n#include \"filtering/filter_mean.hpp\"\n#include \"filtering/filter_med.hpp\"\n#include \"filtering/filter_med_vec.hpp\"\n#include \"filtering/filter_min.hpp\"\n#include \"filtering/filter_mosaic.hpp\"\n#include \"filtering/filter_demosaic.hpp\"\n#include \"filtering/filter_normal.hpp\"\n#include \"filtering/filter_npasses.hpp\"\n#include \"filtering/filter_nswe.hpp\"\n#include \"filtering/filter_zero_crossing.hpp\"\n#include \"filtering/filter_remove_nuked.hpp\"\n#include \"filtering/filter_remove_inf_nan.hpp\"\n#include \"filtering/filter_sampler_1d.hpp\"\n#include \"filtering/filter_sampler_2d.hpp\"\n#include \"filtering/filter_sampler_2dadd.hpp\"\n#include \"filtering/filter_sampler_2dsub.hpp\"\n#include \"filtering/filter_sampler_3d.hpp\"\n#include \"filtering/filter_sampling_map.hpp\"\n#include \"filtering/filter_sigmoid_tmo.hpp\"\n#include \"filtering/filter_simple_tmo.hpp\"\n#include \"filtering/filter_wls.hpp\"\n#include \"filtering/filter_grow_cut.hpp\"\n#include \"filtering/filter_deform_grid.hpp\"\n#include \"filtering/filter_radial_basis_function.hpp\"\n#include \"filtering/filter_disparity.hpp\"\n#include \"filtering/filter_deconvolution.hpp\"\n#include \"filtering/filter_noise_estimation.hpp\"\n#include \"filtering/filter_tmqi.hpp\"\n#include \"filtering/filter_nearest_neighbors.hpp\"\n#include \"filtering/filter_luminance_adaptation.hpp\"\n#include \"filtering/filter_clahe.hpp\"\n#include \"filtering/filter_color_correction_pouli.hpp\"\n\n//360 panoramic images\n#include \"filtering/filter_rotation.hpp\"\n\n#endif /* PIC_FILTERING_HPP */\n\n"
  },
  {
    "path": "include/gl/algorithms/color_to_gray.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_ALGORITHMS_COLOR_TO_GRAY_HPP\n#define PIC_GL_ALGORITHMS_COLOR_TO_GRAY_HPP\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/image.hpp\"\n#include \"../../gl/filtering/filter_channel.hpp\"\n#include \"../../gl/tone_mapping/exposure_fusion.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorToGrayGL class\n */\nclass ColorToGrayGL\n{\nprotected:\n    FilterGLChannel  *flt;\n    ExposureFusionGL *ef;\n    ImageGLVec       img_vec;\n\npublic:\n    /**\n     * @brief ColorToGray\n     */\n    ColorToGrayGL()\n    {\n        flt = NULL;\n        ef = NULL;\n    }\n\n    ~ColorToGrayGL()\n    {\n        delete_s(flt);\n        delete_s(ef);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL execute(ImageGL *imgIn, ImageGL *imgOut)\n    {\n        if(imgIn == NULL){\n            return imgOut;\n        }\n\n        if(imgIn->channels != 3) {\n            return imgOut;\n        }\n\n        if(imgOut == NULL){\n            imgOut = new ImageGL(1, imgIn->width, imgIn->height, 1, IMG_GPU, GL_TEXTURE_2D);\n        }\n\n        ImageGLVec input = SingleGL(imgIn);\n\n        if(flt == NULL) {\n            flt = new FilterGLChannel(0);\n        }\n\n        int channels = imgIn->channels;\n\n        if(img_vec.empty()) {\n            for(int i = 0; i < channels; i++) {\n                img_vec.push_back(flt->Process(input, NULL));\n                flt->update(i + 1);\n            }\n        } else {\n            for(int i = 0; i < channels; i++) {\n                flt->Process(input, img_vec[i]);\n                flt->update(i + 1);\n            }\n        }\n\n        if(ef == NULL) {\n            ef = new ExposureFusionGL(1.0f, 1.0f, 0.0f);\n        }\n\n        imgOut = ef->ProcessStack(img_vec, imgOut);\n\n        return imgOut;\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_ALGORITHMS_COLOR_TO_GRAY_HPP */\n\n"
  },
  {
    "path": "include/gl/algorithms/grow_cut.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_ALGORITHMS_GROW_CUT_HPP\n#define PIC_GL_ALGORITHMS_GROW_CUT_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/image.hpp\"\n#include \"../../gl/image_vec.hpp\"\n\n#include \"../../gl/filtering/filter_op.hpp\"\n#include \"../../gl/filtering/filter_max.hpp\"\n#include \"../../gl/filtering/filter_grow_cut.hpp\"\n#include \"../../gl/filtering/filter_channel.hpp\"\n\nnamespace pic {\n\nclass GrowCutGL\n{\nprotected:\n    FilterGLGrowCut *flt;\n    FilterGLMax *fltMax;\n    FilterGLOp *fltSeeds;\n    FilterGLOp *fltAssign;\n    ImageGL *img_max, *state_next;\n\npublic:\n\n    /**\n     * @brief GrowCutGL\n     */\n    GrowCutGL()\n    {\n        flt = NULL;\n        fltMax = NULL;\n        img_max = NULL;\n        state_next = NULL;\n        fltSeeds = NULL;\n        fltAssign = NULL;\n    }\n\n    ~GrowCutGL()\n    {\n        delete_s(flt);\n        delete_s(fltMax);\n        delete_s(fltSeeds);\n        delete_s(img_max);\n        delete_s(state_next);\n        delete_s(fltAssign);\n    }\n\n    /**\n     * @brief fromStrokeImageToSeeds\n     * @param strokes\n     * @param out\n     * @return\n     */\n    ImageGL *fromStrokeImageToSeeds(ImageGL *strokes, ImageGL *imgOut)\n    {\n        if(strokes == NULL) {\n            return imgOut;\n        }\n\n        if(!strokes->isValid() && strokes->channels < 3) {\n            return imgOut;\n        }\n\n        //red  --> +1\n        //blue --> -1\n\n        if(fltSeeds == NULL) {\n            float red[]  = {1.0f, 0.0f, 0.0f, 1.0f};\n            float blue[] = {0.0f, 0.0f, 1.0f, 1.0f};\n            fltSeeds = new FilterGLOp(\"vec4(vec3(dot(I0.xyz, C0.xyz) - dot(I0.xyz, C1.xyz)), 1.0)\",\n                                        false, red, blue);\n        }\n\n        return fltSeeds->Process(SingleGL(strokes), imgOut);\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *Process(ImageGLVec imgIn, ImageGL *imgOut = NULL)\n    {\n        if(!ImageGLVecCheck(imgIn, 2)) {\n            return imgOut;\n        }\n\n        auto img = imgIn[0];\n        auto seeds = imgIn[1];\n\n        if(imgOut == NULL) {\n            imgOut = new ImageGL(1, img->width, img->height, 3, IMG_GPU, GL_TEXTURE_2D);\n        }\n\n        if(fltMax == NULL) {\n            fltMax = new FilterGLMax(5);\n        }\n\n        if(flt == NULL) {\n            flt = new FilterGLGrowCut();\n        }\n\n        auto state_cur = imgOut;\n\n        if(state_next == NULL) {\n            state_next = state_cur->allocateSimilarOneGL();\n        }\n\n        //compute max\n        img_max = fltMax->Process(SingleGL(img), img_max);\n\n        if(fltAssign == NULL) {\n            fltAssign = new FilterGLOp(\"vec4(I0.x, abs(I0.x) > 0.0 ? 1.0 : 0.0, 0.0, 1.0)\", false, NULL, NULL);\n        }\n\n        state_cur = fltAssign->Process(SingleGL(seeds), state_cur);\n\n        //iterative filtering...\n        int iterations = int(img->getDiagonalSize());\n\n        if((iterations % 2) == 1) {\n            iterations++;\n        }\n\n        ImageGLVec input = TripleGL(state_cur, img, img_max);\n        ImageGL *output = state_next;\n\n        for(int i = 0; i < iterations; i++) {\n            output = flt->Process(input, output);\n\n            auto tmp = input[0];\n            input[0] = output;\n            output = tmp;\n        }\n\n        return imgOut;\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_ALGORITHMS_GROW_CUT_HPP */\n\n"
  },
  {
    "path": "include/gl/algorithms/pushpull.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_ALGORITHMS_PUSHPULL_HPP\n#define PIC_GL_ALGORITHMS_PUSHPULL_HPP\n\n#include \"../../gl/image.hpp\"\n#include \"../../gl/image_vec.hpp\"\n\n#include \"../../util/array.hpp\"\n\n#include \"../../gl/filtering/filter_down_pp.hpp\"\n#include \"../../gl/filtering/filter_up_pp.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The PushPullGL class\n */\nclass PushPullGL\n{\nprotected:\n\n    FilterGLDownPP  *flt_down;\n    FilterGLUpPP    *flt_up;\n\n    ImageGLVec      stack;\n\n    /**\n     * @brief release\n     */\n    void release() {\n        for(unsigned int i = 1; i < stack.size(); i++) {\n            delete stack[i];\n        }\n\n        stack.clear();\n    }\n\npublic:\n\n    /**\n     * @brief PushPullGL\n     */\n    PushPullGL()\n    {\n        flt_down = NULL;\n        flt_up = NULL;\n    }\n\n    ~PushPullGL()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param value\n     * @param threshold\n     */\n    void update(float *value, float threshold = 1e-6f)\n    {\n        if(flt_down == NULL) {\n            flt_down = new FilterGLDownPP(value, threshold);\n        } else {\n            flt_down->update(value, threshold);\n        }\n\n        if(flt_up == NULL) {\n            flt_up = new FilterGLUpPP(value, threshold);\n        } else {\n            flt_up->update(value, threshold);\n        }\n    }\n\n    /**\n     * @brief Process computes push-pull.\n     * @param img\n     * @param value\n     * @return\n     */\n    ImageGL *Process(ImageGL *imgIn, ImageGL *imgOut)\n    {\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = imgIn->cloneGL();\n        } else {\n            *imgOut = *imgIn;\n        }\n\n        ImageGL *work = imgOut;\n        if(stack.empty()) { //create the pyramid: Pull\n            stack.push_back(imgOut);\n\n            while(MIN(work->width, work->height) > 1) {\n                ImageGL *tmp = flt_down->Process(SingleGL(work), NULL);\n\n                if(tmp != NULL) {\n                    stack.push_back(tmp);\n                    work = tmp;\n                }\n            }\n        } else { //update previously created pyramid: Pull\n            int c = 1;\n            while(MIN(work->width, work->height) > 1) {\n                flt_down->Process(DoubleGL(work, stack[c]), stack[c]);\n\n                work = stack[c];\n                c++;\n            }\n        }\n\n        //sampling from the pyramid (stack): Push\n        int n = int(stack.size() - 2);\n\n        for(int i = n; i >= 0; i--) {\n            flt_up->Process(DoubleGL(stack[i + 1], stack[i]), stack[i]);\n        }\n\n        return imgOut;\n    }\n\n    /**\n     * @brief Execute\n     * @param img\n     * @param imgOut\n     * @param value\n     * @return\n     */\n    static ImageGL *execute(ImageGL *img,  ImageGL *imgOut, float value)\n    {\n        PushPullGL pp;\n\n        float *tmp_value = new float[img->channels];\n        Arrayf::assign(value, tmp_value, img->channels);\n\n        pp.update(tmp_value, 1e-4f);\n        imgOut = pp.Process(img, imgOut);\n\n        delete[] tmp_value;\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_ALGORITHMS_PUSHPULL_HPP */\n\n"
  },
  {
    "path": "include/gl/algorithms/pyramid.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_ALGORITHMS_PYRAMID_HPP\n#define PIC_GL_ALGORITHMS_PYRAMID_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/image.hpp\"\n\n#include \"../../gl/filtering/filter_gaussian_2d.hpp\"\n#include \"../../gl/filtering/filter_sampler_2d.hpp\"\n#include \"../../gl/filtering/filter_blend.hpp\"\n#include \"../../gl/filtering/filter_op.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The PyramidGL class\n */\nclass PyramidGL\n{\nprotected:\n    bool lapGauss, bCreated;\n    int limitLevel;\n\n    FilterGLGaussian2D *flt_gauss;\n    FilterGLSampler2D *flt_sampler;\n    FilterGLOp *flt_add, *flt_sub;\n    FilterGLBlend  *flt_blend;\n    std::vector<FilterGL *> filters;\n\n    ImageGLVec trackerRec, trackerUp;\n\n    /**\n     * @brief initFilters\n     */\n    void initFilters();\n\n    /**\n     * @brief create\n     * @param img\n     * @param width\n     * @param height\n     * @param channels\n     * @param lapGauss\n     * @param limitLevel\n     */\n    void create(ImageGL *img, bool lapGauss, int limitLevel);\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        stdVectorClear<ImageGL>(stack);\n        stdVectorClear<ImageGL>(trackerUp);\n        stdVectorClear<ImageGL>(trackerRec);\n        stdVectorClear<FilterGL>(filters);\n    }\n\npublic:\n\n    ImageGLVec stack;\n\n    /**\n     * @brief PyramidGL\n     * @param img\n     * @param lapGauss\n     * @param limitLevel\n     */\n    PyramidGL(ImageGL *img, bool lapGauss, int limitLevel);\n\n    /**\n     * @brief PyramidGL\n     * @param width\n     * @param height\n     * @param channels\n     * @param lapGauss\n     * @param limitLevel\n     */\n    PyramidGL(int width, int height, int channels, bool lapGauss, int limitLevel);\n\n    ~PyramidGL();\n\n    /**\n     * @brief update\n     * @param img\n     */\n    void update(ImageGL *img);\n\n    /**\n     * @brief setValue\n     * @param value\n     */\n    void setValue(float value);\n\n    /**\n     * @brief mul\n     * @param pyr\n     */\n    void mul(const PyramidGL *pyr);\n\n    /**\n     * @brief mulNeg\n     * @param pyr\n     */\n    void mulNeg(const PyramidGL *pyr);\n\n    /**\n     * @brief add\n     * @param pyr\n     */\n    void add(const PyramidGL *pyr);\n\n    /**\n     * @brief reconstruct\n     * @param imgOut\n     * @return\n     */\n    ImageGL *reconstruct(ImageGL *imgOut);\n\n    /**\n     * @brief blend\n     * @param pyr\n     * @param weight\n     */\n    void blend(PyramidGL *pyr, PyramidGL *weight);\n\n    /**\n     * @brief size\n     * @return\n     */\n    int size()\n    {\n        return int(stack.size());\n    }\n\n    /**\n     * @brief get\n     * @param index\n     * @return\n     */\n    Image *get(int index)\n    {\n        return stack[index % stack.size()];\n    }\n\n    /**\n     * @brief setNULL\n     */\n    void setNULL()\n    {\n        release();\n\n        flt_gauss = NULL;\n        flt_sampler = NULL;\n        flt_sub = NULL;\n        flt_add = NULL;\n        flt_blend = NULL;\n\n        bCreated = false;\n    }\n};\n\nPIC_INLINE PyramidGL::PyramidGL(ImageGL *img, bool lapGauss, int limitLevel = 1)\n{\n    setNULL();\n\n    create(img, lapGauss, limitLevel);\n}\n\nPIC_INLINE PyramidGL::PyramidGL(int width, int height, int channels, bool lapGauss, int limitLevel = 1)\n{\n    setNULL();\n\n    ImageGL *img = new ImageGL(1, width, height, channels, IMG_GPU, GL_TEXTURE_2D);\n    *img = 0.0f;\n\n    create(img, lapGauss, limitLevel);\n\n    delete img;\n}\n\nPIC_INLINE PyramidGL::~PyramidGL()\n{\n    release();\n}\n\nPIC_INLINE void PyramidGL::initFilters()\n{\n    if(!bCreated) {\n        flt_gauss = new FilterGLGaussian2D(1.0f);\n        filters.push_back(flt_gauss);\n\n        flt_sampler = new FilterGLSampler2D(0.5f);\n        filters.push_back(flt_sampler);\n\n        flt_add  = FilterGLOp::CreateOpAdd(false);\n        filters.push_back(flt_add);\n\n        flt_sub  = FilterGLOp::CreateOpSub(false);\n        filters.push_back(flt_sub);\n\n        flt_blend = new FilterGLBlend();\n        filters.push_back(flt_blend);\n\n        bCreated = true;\n    }\n}\n\nPIC_INLINE void PyramidGL::create(ImageGL *img, bool lapGauss, int limitLevel = 1)\n{\n    if(img == NULL) {\n        return;\n    }\n\n    limitLevel = MAX(limitLevel, 0);\n\n    this->limitLevel = limitLevel;\n    this->lapGauss = lapGauss;\n\n    initFilters();\n\n    int levels = MAX(log2(MIN(img->width, img->height)) - limitLevel, 0);\n\n    ImageGL *tmpImg = img;\n    ImageGL *tmpG   = NULL;\n    ImageGL *tmpD   = NULL;\n\n    for(int i = 0; i < levels; i++) {\n        tmpG = flt_gauss->Process(SingleGL(tmpImg), NULL);\n        tmpD = flt_sampler->Process(SingleGL(tmpG), NULL);\n\n        if(lapGauss) { //Laplacian Pyramid\n            flt_sub->Process(DoubleGL(tmpImg, tmpD), tmpG);\n            stack.push_back(tmpG);\n        } else { //Gaussian Pyramid\n            *tmpG = *tmpImg;\n            stack.push_back(tmpG);\n        }\n\n        if(i < (levels - 1)) {\n            trackerUp.push_back(tmpD);\n        }\n\n        tmpImg = tmpD;\n    }\n\n    if(tmpD != NULL) {\n        stack.push_back(tmpD);\n    }\n\n#ifdef PIC_DEBUG\n    printf(\"PyramidGL size: %d\\n\", int(stack.size()));\n#endif\n}\n\nPIC_INLINE void PyramidGL::update(ImageGL *img)\n{\n    if(img == NULL) {\n        return;\n    }\n\n    if(stack.empty()) {\n        return;\n    }\n\n    if(!stack[0]->isSimilarType(img)) {\n        return;\n    }\n\n    ImageGL *tmpG = NULL;\n    ImageGL *tmpD = NULL;\n    ImageGL *tmpImg = img;\n\n    int levels = MAX(log2(MIN(tmpImg->width, tmpImg->height)) - limitLevel, 1);\n\n    for(int i = 0; i < levels; i++) {\n        tmpG = flt_gauss->Process(SingleGL(tmpImg), stack[i]);\n\n        if(i == (levels - 1) ) {\n            tmpD = flt_sampler->Process(DoubleGL(tmpG, stack[i + 1]), stack[i + 1]);\n        } else {\n            tmpD = flt_sampler->Process(DoubleGL(tmpG, trackerUp[i]), trackerUp[i]);\n        }\n\n        if(lapGauss) { //Laplacian Pyramid\n            flt_sub->Process(DoubleGL(tmpImg, tmpD), tmpG);\n        } else { //Gaussian Pyramid\n            *tmpG = *tmpImg;\n        }\n\n        tmpImg = tmpD;\n    }\n}\n\nPIC_INLINE ImageGL *PyramidGL::reconstruct(ImageGL *imgOut = NULL)\n{\n    if(stack.size() < 2) {\n        return imgOut;\n    }\n\n    int n = int(stack.size()) - 1;\n    ImageGL *tmp = stack[n];\n\n    if(trackerRec.empty()) {\n        for(int i = n; i >= 2; i--) {\n            ImageGL *tmp2 = flt_add->Process(DoubleGL(stack[i - 1], tmp), NULL);\n            trackerRec.push_back(tmp2);\n            tmp = tmp2;\n        }\n    } else {\n        int c = 0;\n\n        for(int i = n; i >= 2; i--) {\n            flt_add->Process(DoubleGL(stack[i - 1], tmp), trackerRec[c]);\n            tmp = trackerRec[c];\n            c++;\n        }\n    }\n\n    imgOut = flt_add->Process(DoubleGL(stack[0], tmp), imgOut);\n\n    return imgOut;\n}\n\nPIC_INLINE void PyramidGL::setValue(float value)\n{\n    for(unsigned int i = 0; i < stack.size(); i++) {\n        *stack[i] = value;\n    }\n}\n\nPIC_INLINE void PyramidGL::mul(const PyramidGL *pyr)\n{\n    if(stack.size() != pyr->stack.size()) {\n        return;\n    }\n\n    for(unsigned int i = 0; i < stack.size(); i++) {\n        *stack[i] *= *pyr->stack[i];\n    }\n}\n\nPIC_INLINE void PyramidGL::add(const PyramidGL *pyr)\n{\n    if(stack.size() != pyr->stack.size()) {\n        return;\n    }\n\n    for(unsigned int i = 0; i < stack.size(); i++) {\n        *stack[i] += *pyr->stack[i];\n    }\n}\n\nPIC_INLINE void PyramidGL::blend(PyramidGL *pyr, PyramidGL *weight)\n{\n    if(stack.size() != pyr->stack.size() ||\n       stack.size() != weight->stack.size()) {\n        return;\n    }\n\n    for(unsigned int i = 0; i < stack.size(); i++) {\n        flt_blend->Process(TripleGL(stack[i], pyr->stack[i], weight->stack[i]), stack[i]);\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_ALGORITHMS_PYRAMID_HPP */\n\n"
  },
  {
    "path": "include/gl/algorithms/richardson_lucy_deconvolution.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_ALGORITHMS_RICHARDSON_LUCY_DECONVOLUTION_GL_HPP\n#define PIC_GL_ALGORITHMS_RICHARDSON_LUCY_DECONVOLUTION_GL_HPP\n\n#include \"../../gl/image.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../gl/filtering/filter_conv_2d.hpp\"\n\nnamespace pic {\n\nclass RichardsonLucyDeconvolutionGL\n{\npublic:\n    ImageGL *psf, *psf_hat;\n    ImageGL *img_est_conv;\n    ImageGL *img_err;\n    ImageGL *img_rel_blur;\n\n    FilterGLConv2D *flt_conv;\n    int nIterations;\n\n    RichardsonLucyDeconvolutionGL()\n    {\n        flt_conv = NULL;\n        psf_hat = NULL;\n        img_est_conv = NULL;\n        img_err = NULL;\n        img_rel_blur = NULL;\n    }\n\n    ~RichardsonLucyDeconvolutionGL()\n    {\n        delete flt_conv;\n        delete psf_hat;\n        delete img_est_conv;\n        delete img_err;\n        delete img_rel_blur;\n    }\n\n    /**\n     * @brief setup\n     * @param psf\n     * @param nIterations\n     */\n    void setup(ImageGL *psf, int nIterations)\n    {\n        nIterations = MAX(nIterations, 16);\n        this->nIterations = nIterations;\n\n        if(psf != NULL) {\n            this->psf = psf;\n            psf_hat = psf->cloneGL();\n            psf_hat->flipHV();\n        }\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut)\n    {\n        if((imgIn == NULL) || (psf == NULL)) {\n            return imgOut;\n        }\n\n        if(flt_conv == NULL) {\n            flt_conv = new FilterGLConv2D(GL_TEXTURE_2D);\n        }\n\n        auto imgIn_vec = SingleGL(imgIn);\n        /*\n        imgOut = FilterGL::allocateOutputMemory(imgIn_vec, imgOut, false);\n        img_est_conv = FilterGL::allocateOutputMemory(imgIn_vec, img_est_conv, true);\n        img_err = FilterGL::allocateOutputMemory(imgIn_vec, img_err, true);\n        img_rel_blur = FilterGL::allocateOutputMemory(imgIn_vec, img_rel_blur, true);\n        */\n\n\n        ImageGLVec vec = DoubleGL(imgOut, psf);\n        ImageGLVec vec_err = DoubleGL(img_rel_blur, psf_hat);\n\n        *imgOut = 0.5f;\n\n        for(int i = 0; i < nIterations; i++) {\n\n            #ifdef PIC_DEBUG\n                printf(\"%d\\n\", i);\n            #endif\n\n            img_rel_blur = imgIn;\n\n            img_est_conv = flt_conv->Process(vec, img_est_conv);\n            *img_rel_blur /= *img_est_conv;\n\n            img_err = flt_conv->Process(vec_err, img_err);\n\n            *imgOut *= *img_err;\n        }\n\n        return imgOut;\n    }\n\n};\n\n}\n\n#endif //PIC_GL_ALGORITHMS_RICHARDSON_LUCY_DECONVOLUTION_GL_HPP\n"
  },
  {
    "path": "include/gl/colors/color_conv.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_COLORS_COLOR_CONV_HPP\n#define PIC_GL_COLORS_COLOR_CONV_HPP\n\n#include <string>\n\n#include \"../../util/gl/technique.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvGL class\n */\nclass ColorConvGL\n{\nprotected:\n    int direct;\n    TechniqueGL techniques[2];\n\npublic:\n\n    /**\n     * @brief ColorConv\n     */\n    ColorConvGL(bool direct = true)\n    {\n        setTransform(direct);\n    }\n\n    virtual ~ColorConvGL() = default;\n\n    /**\n     * @brief getDirectFunction\n     * @return\n     */\n    virtual std::string getDirectFunction() = 0;\n\n    /**\n     * @brief getDirectFunctionAux\n     * @return\n     */\n    virtual std::string getDirectFunctionAux() = 0;\n\n    /**\n     * @brief getDirectUniforms\n     * @return\n     */\n    virtual std::string getDirectUniforms() = 0;\n\n    /**\n     * @brief getInverseFunction\n     * @return\n     */\n    virtual std::string getInverseFunction() = 0;\n\n    /**\n     * @brief getInverseUniforms\n     * @return\n     */\n    virtual std::string getInverseUniforms() = 0;\n\n    /**\n     * @brief getInverseFunctionAux\n     * @return\n     */\n    virtual std::string getInverseFunctionAux() = 0;\n\n    /**\n     * @brief generatePrograms\n     * @param vertex_source\n     */\n    void generatePrograms(std::string vertex_source)\n    {\n        //direct transform\n        techniques[0].initStandard(\"330\", vertex_source, getDirectFunction(), \"ColorConv (direct)\");\n\n        techniques[0].bind();\n        techniques[0].setUniform1i(\"u_tex\", 0);\n        techniques[0].unbind();\n\n        //inverse transform\n        techniques[1].initStandard(\"330\", vertex_source, getInverseFunction(), \"ColorConv (inverse)\");\n\n        techniques[1].bind();\n        techniques[1].setUniform1i(\"u_tex\", 0);\n        techniques[1].unbind();\n    }\n\n    /**\n     * @brief setTransform\n     * @param direct\n     */\n    void setTransform(bool direct)\n    {\n        this->direct = direct ? 0 : 1;\n    }\n\n    /**\n     * @brief bindProgram\n     */\n    void bindProgram()\n    {\n        techniques[direct].bind();\n    }\n\n    /**\n     * @brief unbindProgram\n     */\n    void unbindProgram()\n    {\n        techniques[direct].unbind();\n    }\n    \n    /**\n     * @brief setUniforms\n     */\n    virtual void setUniforms()\n    {        \n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_COLORS_COLOR_CONV_HPP */\n\n"
  },
  {
    "path": "include/gl/colors/color_conv_linear.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_COLORS_COLOR_CONV_LINEAR_HPP\n#define PIC_GL_COLORS_COLOR_CONV_LINEAR_HPP\n\n#include \"../../colors/color_conv_rgb_to_xyz.hpp\"\n\n#include \"../../gl/colors/color_conv.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvGLLinear class\n */\nclass ColorConvGLLinear: public ColorConvGL\n{\nprotected:\n    float mtx[9], mtx_inv[9];\n\npublic:\n\n    /**\n     * @brief ColorConvGLLinear\n     */\n    ColorConvGLLinear(bool direct = true) : ColorConvGL(direct)\n    {\n    }\n\n    /**\n     * @brief getDirectFunction\n     * @return\n     */\n    std::string getDirectFunction()\n    {\n        std::string fragment_source = MAKE_STRING\n                          (\n        uniform sampler2D u_tex; \\n\n        uniform mat3 mtx; \\n\n        out     vec4 f_color; \\n\n        \\n\n        void main(void) {\n            \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n            vec3 colIn = texelFetch(u_tex, coords, 0).xyz; \\n\n            vec3 colOut = mtx * colIn;\n            f_color = vec4(colOut, 1.0); \\n\n            \\n\n        }\n                          );\n        return fragment_source;\n    }\n\n    /**\n     * @brief getInverseFunction\n     * @return\n     */\n    std::string getInverseFunction()\n    {\n        return getDirectFunction();\n    }\n\n    /**\n     * @brief setUniforms\n     */\n    void setUniforms()\n    {\n        if(direct) {\n            techniques[0].bind();\n            techniques[0].setUniform3x3(\"mtx\", mtx, true);\n            techniques[0].unbind();\n        } else {\n            techniques[1].bind();\n            techniques[1].setUniform3x3(\"mtx\", mtx_inv, true);\n            techniques[1].unbind();\n        }\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_COLORS_COLOR_CONV_LINEAR_HPP */\n\n"
  },
  {
    "path": "include/gl/colors/color_conv_rgb_to_hsl.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_COLORS_COLOR_CONV_RGB_TO_HSL_HPP\n#define PIC_GL_COLORS_COLOR_CONV_RGB_TO_HSL_HPP\n\n#include \"../../gl/colors/color_conv.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvGLRGBtoHSL class\n */\nclass ColorConvGLRGBtoHSL: public ColorConvGL\n{\npublic:\n\n    /**\n     * @brief ColorConvGLRGBtoHSL\n     */\n    ColorConvGLRGBtoHSL(bool direct = true) : ColorConvGL(direct)\n    {\n    }\n\n    /**\n     * @brief getDirect\n     * @return\n     */\n    static std::string getDirect()\n    {\n        std::string fun = MAKE_STRING(\n                    const vec3 LUM_XYZ =   vec3(0.213,  0.715,   0.072);\n                    const vec3 ALPHA_VAL = vec3(0.0,    0.866,  -0.866);\n                    const vec3 BETA_VAL =  vec3(1.0,   -0.5,    -0.5);\n\n                    vec3 RGB2HSL(vec3 col) {\n                        vec3 ret;\n\n                        //Intensity\n                        ret.y = dot(col, LUM_XYZ);\n\n                        //alpha beta\n                        float alpha = dot(col, BETA_VAL);\n                        float beta =  dot(col, ALPHA_VAL);\n\n                        //Hue\n                        if(alpha == 0.0 && beta == 0.0) {\n                            ret.x = 0.0;\n                            ret.z = 0.0;\n                        } else {\n                            ret.x = atan(alpha, beta); //atan2(x,y) == atan(y,x)\n                            ret.z = sqrt(alpha * alpha + beta * beta);\n                        }\n\n                        return ret;\n                    }\n         );\n        return fun;\n    }\n\n    /**\n     * @brief getInverse\n     * @return\n     */\n    static std::string getInverse()\n    {\n        std::string fun = MAKE_STRING(\n                    const vec3 R_VAL =\tvec3(0.9990,    -0.3709,    0.7862);\n                    const vec3 G_VAL =\tvec3(0.9990,     0.2065,   -0.2138);\n                    const vec3 B_VAL =\tvec3(0.9990,    -0.9482,   -0.2138);\n                    out     vec4 f_color; \\n\n                    \\n\n\n                  vec3 HSL2RGB(vec3 col) {\n                      vec3 ret;\n                      vec3 tmp;\n                      tmp.x = col.y;\t\t\t\t//Luminance\n                      tmp.y = col.z * cos(col.x);\t//Alpha\n                      tmp.z = col.z * sin(col.x);\t//Beta\n\n                      ret.x = dot(tmp, R_VAL);\n                      ret.y = dot(tmp, G_VAL);\n                      ret.z = dot(tmp, B_VAL);\n\n                      return ret;\n                  }\n                    );\n        return fun;\n    }\n\n    /**\n     * @brief getDirectFunction\n     * @return\n     */\n    std::string getDirectFunction()\n    {\n        std::string fragment_source = getDirect() + MAKE_STRING(\n            uniform sampler2D u_tex; \\n                \n            out vec4 f_color; \\n\n\n            void main(void) {\n                ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n                vec3 color = texelFetch(u_tex, coords, 0).xyz; \\n\n                f_color = vec4(RGB2HSL(color), 1.0); \\n\n                \\n\n            }\n        );\n\n        return fragment_source;\n    }\n\n    /**\n     * @brief getInverseFunction\n     * @return\n     */\n    std::string getInverseFunction()\n    {\n        std::string fragment_source = getInverse() + MAKE_STRING(\n            uniform sampler2D u_tex; \\n\n            out     vec4 f_color; \\n\n            void main(void) {\\n\n                ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n                vec3 color = texelFetch(u_tex, coords, 0).xyz; \\n\n                f_color = vec4(HSL2RGB(color), 1.0); \\n\n            \\n\n            }\n        );\n\n        return fragment_source;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_COLORS_COLOR_CONV_RGB_TO_HSL_HPP */\n\n"
  },
  {
    "path": "include/gl/colors/color_conv_rgb_to_srgb.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_COLORS_COLOR_CONV_RGB_TO_SRGB_HPP\n#define PIC_GL_COLORS_COLOR_CONV_RGB_TO_SRGB_HPP\n\n#include \"../../gl/colors/color_conv.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvGLRGBtosRGB class\n */\nclass ColorConvGLRGBtosRGB: public ColorConvGL\n{\npublic:\n\n    /**\n     * @brief ColorConvGLRGBtosRGB\n     */\n    ColorConvGLRGBtosRGB(bool direct = true) : ColorConvGL(direct)\n    {\n    }\n\n    // a = 0.055\n    // gamma = 2.4\n\n    /**\n     * @brief getDirectFunction\n     * @return\n     */\n    std::string getDirectFunction()\n    {\n        std::string fragment_source = MAKE_STRING(\n            uniform sampler2D u_tex; \\n\n            out     vec4 f_color; \\n\n            \\n\n            float fromRGBtosRGB(float x) {\n                if(x > 0.0031308) {\n                    return 1.055 * pow(x, 1.0 / 2.4) - 0.055;\n                } else {\n                    return x * 12.92;\n                }\n            }\n\n            void main(void) {\n                ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n                vec3 colIn = texelFetch(u_tex, coords, 0).xyz; \\n\n                vec3 colOut = vec3(fromRGBtosRGB(colIn.x),\n                                   fromRGBtosRGB(colIn.y),\n                                   fromRGBtosRGB(colIn.z));\n                f_color = vec4(colOut, 1.0); \\n\n                \\n\n            }\n                              );\n\n        return fragment_source;\n    }\n\n    /**\n     * @brief getInverseFunction\n     * @return\n     */\n    std::string getInverseFunction()\n    {\n        std::string fragment_source = MAKE_STRING(\n            uniform sampler2D u_tex; \\n\n            out     vec4 f_color; \\n\n            \\n\n            float fromsRGBtoRGB(float x) {\n                if(x > 0.04045) {\n                    return pow((x + 0.055) / (1.055), 2.4);\n                } else {\n                    return x / 12.92;\n                }\n            }\n\n            void main(void) {\n                \\n\n                ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n                vec3 colIn = texelFetch(u_tex, coords, 0).xyz; \\n\n                vec3 colOut = vec3(fromsRGBtoRGB(colIn.x),\n                                   fromsRGBtoRGB(colIn.y),\n                                   fromsRGBtoRGB(colIn.z)); \\n\n                f_color = vec4(colOut, 1.0); \\n\n            \\n\n            }\n                );\n\n        return fragment_source;\n    }\n\n    /**\n     * @brief getDirectFunctionAux\n     * @return\n     */\n    std::string getDirectFunctionAux()\n    {\n        return \"\";\n    }\n\n    /**\n     * @brief getInverseFunctionAux\n     * @return\n     */\n    std::string getInverseFunctionAux()\n    {\n        return \"\";\n    }\n\n    /**\n     * @brief getDirectUniforms\n     * @return\n     */\n    std::string getDirectUniforms()\n    {\n        return \"\";\n    }\n\n    /**\n     * @brief getInverseUniforms\n     * @return\n     */\n    std::string getInverseUniforms()\n    {\n        return \"\";\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_COLORS_COLOR_CONV_RGB_TO_SRGB_HPP */\n\n"
  },
  {
    "path": "include/gl/colors/color_conv_rgb_to_xyz.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_COLORS_COLOR_CONV_RGB_TO_XYZ_HPP\n#define PIC_GL_COLORS_COLOR_CONV_RGB_TO_XYZ_HPP\n\n#include \"../../colors/color_conv_rgb_to_xyz.hpp\"\n\n#include \"../../gl/colors/color_conv_linear.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvGLRGBtoXYZ class\n */\nclass ColorConvGLRGBtoXYZ: public ColorConvGLLinear\n{\npublic:\n\n    /**\n     * @brief ColorConvGLRGBtoXYZ\n     */\n    ColorConvGLRGBtoXYZ(bool direct = true) : ColorConvGLLinear(direct)\n    {\n        memcpy(mtx, mtxRGBtoXYZ, 9 * sizeof(float));\n        memcpy(mtx_inv, mtxXYZtoRGB, 9 * sizeof(float));\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_COLORS_COLOR_CONV_RGB_TO_XYZ_HPP */\n\n"
  },
  {
    "path": "include/gl/colors/color_conv_xyz_to_cielab.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_COLORS_COLOR_CONV_XYZ_TO_CIE_LAB_HPP\n#define PIC_GL_COLORS_COLOR_CONV_XYZ_TO_CIE_LAB_HPP\n\n#include \"../../gl/colors/color_conv.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvGLXYZtoCIELAB class\n */\nclass ColorConvGLXYZtoCIELAB: public ColorConvGL\n{\nprotected:\n    float\t\twhite_point[3];\n\npublic:\n\n    /**\n     * @brief ColorConvGLXYZtoCIELAB\n     */\n    ColorConvGLXYZtoCIELAB(bool direct = true) : ColorConvGL(direct)\n    {\n        white_point[0] = 1.0f;\n        white_point[1] = 1.0f;\n        white_point[2] = 1.0f;\n    }\n\n    /**\n     * @brief getDirectFunction\n     * @return\n     */\n    std::string getDirectFunction()\n    {\n        std::string fragment_source = MAKE_STRING\n                          (\n        uniform sampler2D u_tex; \\n\n        uniform vec3 white_point; \\n\n        out     vec4 f_color; \\n\n        \\n\n\n        const float C_SIX_OVER_TWENTY_NINE_CUBIC = 0.00885645167903563081717167575546;\n        const float C_FOUR_OVER_TWENTY_NINE = 0.13793103448275862068965517241379;\n        const float C_CIELAB_C1 = 7.787037037037037037037037037037;\n\n        float f(float t) {\n            if(t > C_SIX_OVER_TWENTY_NINE_CUBIC) {\n                return pow(t, 1.0 / 3.0);\n            } else {\n                return C_CIELAB_C1 * t +\n                       C_FOUR_OVER_TWENTY_NINE;\n            }\n        }\n\n        void main(void) {\n            \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n            vec3 colIn = texelFetch(u_tex, coords, 0).xyz; \\n\n\n            vec3 colOut;\n            float fY_Yn = f(colIn[1] / white_point[1]);\n\n            colOut[0] = 116.0 * fY_Yn - 16.0;\n            colOut[1] = 500.0 * (f(colIn[0] / white_point[0]) - fY_Yn);\n            colOut[2] = 200.0 * (fY_Yn - f(colIn[2] / white_point[2]));\n\n            f_color = vec4(colOut, 1.0); \\n\n            \\n\n        }\n                          );\n        return fragment_source;\n    }\n\n    /**\n     * @brief getInverseFunction\n     * @return\n     */\n    std::string getInverseFunction()\n    {\n        std::string fragment_source = MAKE_STRING\n                          (\n        uniform sampler2D u_tex; \\n\n        uniform vec3 white_point; \\n\n        out     vec4 f_color; \\n\n        const float C_CIELAB_C1_INV = 0.12841854934601664684898929845422; \\n\n        const float C_FOUR_OVER_TWENTY_NINE = 0.13793103448275862068965517241379; \\n\n        const float C_SIX_OVER_TWENTY_NINE = 0.20689655172413793103448275862069; \\n\n        \\n\n        \\n\n        float f_inv(float t) {\n            if(t > C_SIX_OVER_TWENTY_NINE ){\n                return pow(t, 3.0);\n            } else {\n                return (t - C_FOUR_OVER_TWENTY_NINE) * C_CIELAB_C1_INV;\n            }\n        }\n\n        void main(void) {\n            \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n            vec3 colIn = texelFetch(u_tex, coords, 0).xyz; \\n\n            vec3 colOut;\n\n             float tmp = (colIn[0] + 16.0f) / 116.0;\n\n             colOut[1] = white_point[1] * f_inv(tmp);\n             colOut[0] = white_point[0] * f_inv(tmp + colIn[1] / 500.0);\n             colOut[2] = white_point[2] * f_inv(tmp - colIn[2] / 200.0);\n\n            f_color = vec4(colOut, 1.0); \\n\n            \\n\n        }\n                          );\n        return fragment_source;\n    }\n\n    /**\n     * @brief setUniforms\n     */\n    void setUniforms()\n    {\n        if(direct) {\n            techniques[0].bind();\n            techniques[0].setUniform3fv(\"white_point\", white_point);\n            techniques[0].unbind();\n        } else {\n            techniques[1].bind();\n            techniques[1].setUniform3fv(\"white_point\", white_point);\n            techniques[1].unbind();\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_COLORS_COLOR_CONV_XYZ_TO_CIE_LAB_HPP */\n\n"
  },
  {
    "path": "include/gl/colors/color_conv_xyz_to_lms.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_COLORS_COLOR_CONV_XYZ_TO_LMS_HPP\n#define PIC_GL_COLORS_COLOR_CONV_XYZ_TO_LMS_HPP\n\n#include \"../../colors/color_conv_xyz_to_lms.hpp\"\n\n#include \"../../gl/colors/color_conv_linear.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ColorConvGLXYZtoLMS class\n */\nclass ColorConvGLXYZtoLMS: public ColorConvGLLinear\n{\npublic:\n\n    /**\n     * @brief ColorConvGLXYZtoLMS\n     */\n    ColorConvGLXYZtoLMS(bool direct = true) : ColorConvGLLinear(direct)\n    {\n        memcpy(mtx, mtxXYZtoLMS, 9 * sizeof(float));\n        memcpy(mtx_inv, mtxLMStoXYZ, 9 * sizeof(float));\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_COLORS_COLOR_CONV_XYZ_TO_LMS_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_HPP\n#define PIC_GL_FILTERING_FILTER_HPP\n\n#include \"../../base.hpp\"\n#include \"../../util/array.hpp\"\n#include \"../../util/std_util.hpp\"\n#include \"../../gl/image.hpp\"\n#include \"../../gl/image_vec.hpp\"\n#include \"../../util/array.hpp\"\n#include \"../../util/gl/technique.hpp\"\n#include \"../../util/gl/quad.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGL class\n */\nclass FilterGL\n{\nprotected:\n    //FBO\n    Fbo *fbo;\n\n    //Quad\n    QuadGL *quad;\n\n    //Shaders\n    TechniqueGL technique;\n\n    GLenum target;\n\n    ImageGLVec param;\n\n    bool bFboOwn;\npublic:\n\n    bool bDelete;\n    std::vector< FilterGL* > filters;\n\n    std::string vertex_source, geometry_source, fragment_source;\n\n    /**\n     * @brief FilterGL\n     */\n    FilterGL()\n    {\n        bDelete = false;\n\n        fbo = NULL;\n\n        this->bFboOwn = true;\n        quad = new QuadGL(false, 1.0f, 1.0f);\n\n        target = GL_TEXTURE_2D;\n\n        //getting a vertex program for screen aligned quad\n        vertex_source = QuadGL::getVertexProgramV3();\n    }\n\n    ~FilterGL()\n    {\n        release();\n    }\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        quad = delete_s(quad);\n\n        if(bFboOwn) {\n            fbo = delete_s(fbo);\n        }\n\n        releaseAux();\n    }\n\n    /**\n     * @brief releaseAux\n     */\n    virtual void releaseAux()\n    {\n\n    }\n\n    /**\n     * @brief setFbo\n     * @param fbo\n     */\n    void setFbo(Fbo *fbo)\n    {\n        this->fbo = fbo;\n        this->bFboOwn = false;\n    }\n\n    /**\n     * @brief getFbo\n     * @return\n     */\n    virtual Fbo *getFbo()\n    {\n        return fbo;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    virtual void OutputSize(ImageGLVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width    = imgIn[0]->width;\n        height   = imgIn[0]->height;\n        channels = imgIn[0]->channels;\n        frames   = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief insertFilter\n     * @param flt\n     */\n    void insertFilter(FilterGL *flt)\n    {\n        if(flt == NULL) {\n            return;\n        }\n\n        if(!flt->filters.empty()) {\n            for(unsigned int i = 0; i < flt->filters.size(); i++) {\n                insertFilter(flt->filters[i]);\n            }\n        } else {\n            filters.push_back(flt);\n        }\n    }\n\n    /**\n     * @brief setTarget\n     * @param target\n     */\n    void setTarget(GLenum target)\n    {\n        this->target = target;\n    }\n\n    /**\n     * @brief changePass\n     * @param pass\n     * @param tPass\n     */\n    virtual void changePass(int pass, int tPass)\n    {\n    }\n\n    /**\n     * @brief gammaCorrection\n     * @param fragment_source\n     * @param bGammaCorrection\n     * @return\n     */\n    static std::string gammaCorrection(std::string fragment_source,\n                                       bool bGammaCorrection)\n    {\n        size_t processing_found = fragment_source.find(\"__GAMMA__CORRECTION__\");\n\n        if(processing_found != std::string::npos) {\n            if(bGammaCorrection) {\n                fragment_source.replace(processing_found, 21,\n                                        \" color = pow(color, vec3(1.0 / 2.2)); \");\n            } else {\n                fragment_source.replace(processing_found, 21, \" \");\n            }\n        }\n\n        return fragment_source;\n    }\n\n    /**\n     * @brief setupAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    virtual ImageGL *setupAux(ImageGLVec imgIn, ImageGL *imgOut)\n    {\n        return allocateOutputMemory(imgIn, imgOut, bDelete);\n    }\n\n    /**\n     * @brief allocateOutputMemory\n     * @param imgIn\n     * @param imgOut\n     * @param bDelete\n     * @return\n     */\n    ImageGL *allocateOutputMemory(ImageGLVec imgIn, ImageGL *imgOut, bool bDelete)\n    {\n        int w, h, c, f;\n        OutputSize(imgIn, w, h, c, f);\n\n        if(imgOut == NULL) {\n            imgOut = new ImageGL(f, w, h, c, IMG_GPU, imgIn[0]->getTarget());\n        } else {\n            bool bSame = imgOut->width == w &&\n                         imgOut->height == h &&\n                         imgOut->channels == c &&\n                         imgOut->frames == f;\n\n            if(!bSame) {\n                if(bDelete) {\n                    delete imgOut;\n                }\n\n                imgOut = new ImageGL(f, w, h, c, IMG_GPU, imgIn[0]->getTarget());\n            }\n        }\n\n        return imgOut;\n    }\n\n    virtual void bindTechnique()\n    {\n        technique.bind();\n    }\n\n    virtual void unbindTechnique()\n    {\n        technique.unbind();\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    virtual ImageGL *Process(ImageGLVec imgIn, ImageGL *imgOut)\n    {\n        if(imgIn.empty()) {\n            return imgOut;\n        }\n\n        if(imgIn[0] == NULL) {\n            return imgOut;\n        }\n\n        imgOut = setupAux(imgIn, imgOut);\n\n        if(imgOut == NULL) {\n            return NULL;\n        }\n\n        //create an FBO\n        if(fbo == NULL) {\n            fbo = new Fbo();\n            bFboOwn = true;\n        }\n\n        fbo->create(imgOut->width, imgOut->height, imgOut->frames, false, imgOut->getTexture());\n\n        //bind the FBO\n        fbo->bind();\n        glViewport(0, 0, (GLsizei)imgIn[0]->width, (GLsizei)imgIn[0]->height);\n\n        //bind shaders\n        bindTechnique();\n\n        //bind textures\n        int n = int(imgIn.size());\n        for(auto i = 0; i < n; i++) {\n            glActiveTexture(GL_TEXTURE0 + i);\n            imgIn[i]->bindTexture();\n        }\n\n        //bind texture internal filter parameters\n        int m = int(param.size());\n        for(auto i = 0; i < m; i++) {\n            glActiveTexture(GL_TEXTURE0 + n + i);\n            param[i]->bindTexture();\n        }\n\n        //render an aligned quad\n        quad->Render();\n\n        //unbind the FBO\n        fbo->unbind();\n\n        //unbind shaders\n        unbindTechnique();\n\n        //unbind textures\n        for(auto i = 0; i< n; i++) {\n            glActiveTexture(GL_TEXTURE0 + i);\n            imgIn[i]->unBindTexture();\n        }\n\n        for(auto i = 0; i < m; i++) {\n            glActiveTexture(GL_TEXTURE0 + n + i);\n            param[i]->unBindTexture();\n        }\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_1d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_1D_HPP\n#define PIC_GL_FILTERING_FILTER_1D_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGL1D class\n */\nclass FilterGL1D: public FilterGL\n{\nprotected:\n    ImageGL *weights;\n\n    int dirs[3], slice;\n\n    /**\n     * @brief initShaders\n     */\n    virtual void initShaders();\n\n    /**\n     * @brief FragmentShader\n     */\n    virtual void FragmentShader()\n    {\n\n    }\n\npublic:\n\n    /**\n     * @brief FilterGL1D\n     * @param direction\n     * @param target\n     */\n    FilterGL1D(int direction, GLenum target);\n\n    ~FilterGL1D()\n    {\n        release();\n    }\n\n    /**\n     * @brief changePass\n     * @param pass\n     * @param tPass\n     */\n    void changePass(int pass, int tPass);\n\n    /**\n     * @brief setUniformAux\n     */\n    virtual void setUniformAux()\n    {\n\n    }\n\n    /**\n     * @brief setUniform\n     */\n    void setUniform();\n\n    /**\n     * @brief setSlice\n     * @param slice\n     */\n    void setSlice(int slice)\n    {\n        this->slice = slice;\n        setUniform();\n    }\n\n    /**\n     * @brief setSlice2\n     * @param slice\n     */\n    void setSlice2(int slice)\n    {\n        this->slice = slice;\n        technique.setUniform1i(\"slice\", slice);\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *Process(ImageGLVec imgIn, ImageGL *imgOut);\n};\n\nPIC_INLINE FilterGL1D::FilterGL1D(int direction, GLenum target): FilterGL()\n{\n    weights = NULL;\n\n    //protected values are assigned/computed\n    this->target = target;\n\n    slice = 0;\n\n    dirs[0] = dirs[1] = dirs[2] = 0;\n\n    switch(target) {\n    case GL_TEXTURE_2D: {\n        dirs[direction % 2] = 1;\n    } break;\n\n    case GL_TEXTURE_2D_ARRAY: {\n        dirs[direction % 3] = 1;\n    } break;\n\n    case GL_TEXTURE_3D: {\n        dirs[direction % 3] = 1;\n    } break;\n    }\n}\n\nPIC_INLINE void FilterGL1D::changePass(int pass, int tPass)\n{\n\n    if(target == GL_TEXTURE_2D) {\n        dirs[ pass % 2 ] = 1;\n        dirs[(pass + 1) % 2 ] = 0;\n    } else {\n        if(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) {\n            dirs[ pass % 3 ] = 1;\n            dirs[(pass + 1) % 3 ] = 0;\n            dirs[(pass + 2) % 3 ] = 0;\n        }\n    }\n\n    setUniform();\n}\n\nPIC_INLINE void FilterGL1D::setUniform()\n{\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    setUniformAux();\n\n    technique.setUniform1i(\"iX\", dirs[0]);\n    technique.setUniform1i(\"iY\", dirs[1]);\n\n    if(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) {\n        technique.setUniform1i(\"iZ\", dirs[2]);\n        technique.setUniform1i(\"slice\", slice);\n    }\n\n    technique.unbind();\n}\n\nPIC_INLINE void FilterGL1D::initShaders()\n{\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLConv1D\");\n\n    setUniform();\n}\n\nPIC_INLINE ImageGL *FilterGL1D::Process(ImageGLVec imgIn, ImageGL *imgOut)\n{\n    if(imgIn[0] == NULL || imgIn.size() > 1) {\n        return imgOut;\n    }\n\n    int w = imgIn[0]->width;\n    int h = imgIn[0]->height;\n    int f = imgIn[0]->frames;\n\n    if(imgOut == NULL) {\n        imgOut = new ImageGL(f, w, h, imgIn[0]->channels, IMG_GPU, imgIn[0]->getTarget());\n    }\n\n    if(fbo == NULL) {\n        fbo = new Fbo();\n    }\n\n    fbo->create(w, h, f, false, imgOut->getTexture());\n\n    ImageGL *base = imgIn[0];\n\n    //bind textures\n    glActiveTexture(GL_TEXTURE0);\n    base->bindTexture();\n\n    if(weights != NULL) {\n        glActiveTexture(GL_TEXTURE1);\n        weights->bindTexture();\n    }\n\n    glViewport(0, 0, (GLsizei)w, (GLsizei)h);\n\n    //bind shaders\n    technique.bind();\n\n    //bind the fbo\n    fbo->bindSimple();\n\n    //render an aligned quad\n    for(int z = 0; z < f; z++) {\n        setSlice2(z);\n        fbo->attachColorBuffer2(0, target, z);\n\n        quad->Render();\n    }\n\n    //unbind the fbo\n    fbo->unbindSimple();\n\n    //unbingd shaders\n    technique.unbind();\n\n    //unbind textures\n    if(weights != NULL) {\n        glActiveTexture(GL_TEXTURE1);\n        weights->unBindTexture();\n    }\n\n    glActiveTexture(GL_TEXTURE0);\n    base->unBindTexture();\n\n    return imgOut;\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_1D_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_anisotropic_diffusion.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_ANISOTROPIC_DIFFUSION_HPP\n#define PIC_GL_FILTERING_FILTER_ANISOTROPIC_DIFFUSION_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../gl/filtering/filter_iterative.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLAnisotropicDiffusion class\n */\nclass FilterGLAnisotropicDiffusion: public FilterGL\n{\nprotected:\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\n    float delta_t, k;\n    unsigned int iterations;\n    FilterGLIterative *flt;\n\npublic:\n    /**\n     * @brief FilterGLAnisotropicDiffusion\n     * @param k\n     * @param iterations\n     */\n    FilterGLAnisotropicDiffusion(float k, unsigned int iterations);\n\n    /**\n     * @brief FilterGLAnisotropicDiffusion\n     * @param sigma_s\n     * @param sigma_r\n     */\n    FilterGLAnisotropicDiffusion(float sigma_s, float sigma_r);\n\n    ~FilterGLAnisotropicDiffusion();\n\n    void releaseAux()\n    {\n        delete_s(flt);\n    }\n\n    /**\n     * @brief update\n     * @param k\n     */\n    void update(float k);\n\n    /**\n     * @brief AnisotropicDiffusion\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *AnisotropicDiffusion(ImageGLVec imgIn, ImageGL *imgOut)\n    {\n        if(flt == NULL) {\n            flt = new FilterGLIterative(this, iterations);\n        }\n\n        return flt->Process(imgIn, imgOut);\n    }\n};\n\nPIC_INLINE FilterGLAnisotropicDiffusion::FilterGLAnisotropicDiffusion(float k,\n        unsigned int iterations): FilterGL()\n{\n    if(iterations < 1) {\n        iterations = 1;\n    }\n\n    flt = NULL;\n\n    this->k = k;\n    this->iterations = iterations;\n\n    //protected values are assigned/computed\n    FragmentShader();\n    initShaders();\n\n    update(k);\n}\n\nPIC_INLINE FilterGLAnisotropicDiffusion::FilterGLAnisotropicDiffusion(float sigma_s,\n        float sigma_r): FilterGL()\n{\n    sigma_r = sigma_r <= 0.0f ? 0.11f : sigma_r;\n\n    flt = NULL;\n\n    iterations = int(ceilf(5.0f * sigma_s));\n\n    //protected values are assigned/computed\n    FragmentShader();\n    initShaders();\n\n    update(sigma_r);\n\n}\n\nPIC_INLINE FilterGLAnisotropicDiffusion::~FilterGLAnisotropicDiffusion()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLAnisotropicDiffusion::FragmentShader()\n{\n    fragment_source = MAKE_STRING\n                      (\n                          uniform sampler2D u_tex; \\n\n                          uniform float\t  k_sq; \\n\n                          uniform float\t  delta_t; \\n\n                          out     vec4      f_color; \\n\n\n    void main(void) {\n        \\n\n        ivec2 coords = ivec2(gl_FragCoord.xy);\n        \\n\n        vec3 cB = texelFetch(u_tex, coords           , 0).xyz;\n        \\n\n        vec3 c0 = texelFetch(u_tex, coords + ivec2(1, 0), 0).xyz;\n        \\n\n        vec3 c1 = texelFetch(u_tex, coords - ivec2(1, 0), 0).xyz;\n        \\n\n        vec3 c2 = texelFetch(u_tex, coords + ivec2(0, 1), 0).xyz;\n        \\n\n        vec3 c3 = texelFetch(u_tex, coords - ivec2(0, 1), 0).xyz;\n        \\n\n        vec3 gN = c2 - cB;\n        \\n\n        vec3 gS = c3 - cB;\n        \\n\n        vec3 gW = c1 - cB;\n        \\n\n        vec3 gE = c0 - cB;\n        \\n\n        vec4 c = vec4(dot(gN, gN), dot(gS, gS), dot(gW, gW), dot(gE, gE));\n        \\n\n        c = exp(-c / vec4(k_sq));\n        \\n\n        f_color = vec4(cB + delta_t *(c.x * gN + c.y * gS + c.z * gW + c.w * gE), 1.0);\n        \\n\n    }\n                      );\n}\n\nPIC_INLINE void FilterGLAnisotropicDiffusion::initShaders()\n{\n    FragmentShader();\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLAnisotropicDiffusion\");\n}\n\nPIC_INLINE void FilterGLAnisotropicDiffusion::update(float k)\n{\n    this->k = k > 0.0f ? this->k : 0.11f;\n    float k_sq = this->k * this->k;\n\n    this->delta_t = 1.0f / 7.0f;\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.setUniform1f(\"k_sq\", k_sq);\n    technique.setUniform1f(\"delta_t\", delta_t);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_ANISOTROPIC_DIFFUSION_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_bilateral_1d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_BILATERAL_1D_HPP\n#define PIC_GL_FILTERING_FILTER_BILATERAL_1D_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/filtering/filter_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLBilateral1D class\n */\nclass FilterGLBilateral1D: public FilterGL1D\n{\nprotected:\n    float sigma_s, sigma_r;\n\n    void FragmentShader();\n\npublic:\n\n    /**\n     * @brief FilterGLBilateral1D\n     * @param sigma_s\n     * @param sigma_r\n     * @param direction\n     * @param target\n     */\n    FilterGLBilateral1D(float sigma_s, float sigma_r, int direction,\n                        GLenum target);\n\n    ~FilterGLBilateral1D();\n\n    /**\n     * @brief setUniformAux\n     */\n    void setUniformAux();\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_r\n     */\n    void update(float sigma_s, float sigma_r);\n};\n\nPIC_INLINE FilterGLBilateral1D::FilterGLBilateral1D(float sigma_s, float sigma_r,\n        int direction, GLenum target): FilterGL1D(direction, target)\n{\n    //protected values are assigned/computed\n    this->sigma_s = sigma_s;\n    this->sigma_r = sigma_r;\n\n    FragmentShader();\n    initShaders();\n}\n\nPIC_INLINE FilterGLBilateral1D::~FilterGLBilateral1D()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLBilateral1D::FragmentShader()\n{\n    std::string fragment_source_2D = MAKE_STRING\n                                     (\n                                         uniform sampler2D  u_tex;\n                                         uniform float      sigma_s2;\n                                         uniform float      sigma_r2;\n                                         uniform int        iX;\n                                         uniform int        iY;\n                                         uniform int        halfKernelSize;\n                                         out     vec4       f_color;\n\n    void main(void) {\n        vec3  color = vec3(0.0);\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n        vec3 tmpCol;\n        float weight = 0.0;\n        vec3 colRef = texelFetch(u_tex, coordsFrag.xy, 0).xyz;\n\n        for(int i = -halfKernelSize; i <= halfKernelSize; i++) {\n            //Coordinates\n            ivec2 coords = ivec2(i * iX, i * iY);\n            //Texture fetch\n            tmpCol = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0).xyz;\n            vec3 tmpCol2 = tmpCol - colRef;\n            float dstR = dot(tmpCol2.xyz, tmpCol2.xyz);\n            float tmp = exp(-dstR / sigma_r2 - float(coords.x * coords.x + coords.y *\n                            coords.y) / sigma_s2);\n            color.xyz += tmpCol.xyz * tmp;\n            weight += tmp;\n        }\n\n        color = weight > 0.0 ? color / weight : colRef;\n        f_color = vec4(color.xyz, 1.0);\n    }\n                                     );\n\n    std::string fragment_source_3D = MAKE_STRING\n                                     (\n                                         uniform sampler2DArray\tu_tex;\n                                         uniform float\t\tsigma_s2;\n                                         uniform float\t\tsigma_r2;\n                                         uniform int\t\tslice;\n                                         uniform int\t\tiX;\n                                         uniform int\t\tiY;\n                                         uniform int\t\tiZ;\n                                         out     vec4\t\tf_color;\n\n    void main(void) {\n        vec3 color = vec3(0.0);\n        ivec3 coordsFrag = ivec3(ivec2(gl_FragCoord.xy), slice);\n        vec3 tmpCol;\n        float weight = 0.0;\n        vec3 colRef = texelFetch(u_tex, coordsFrag, 0).xyz;\n\n        for(int i = -halfKernelSize; i <= halfKernelSize; i++) {\n            //Coordinates\n            ivec3 coords = coordsFrag.xyz + ivec3(i * iX, i * iY, i * iZ);\n            //Texture fetch\n            tmpCol = texelFetch(u_tex, coordsFrag + coords, 0).xyz;\n            vec3 tmpCol2 = tmpCol - colRef;\n            float dstR = dot(tmpCol2.xyz, tmpCol2.xyz);\n            float tmp = exp(-dstR / sigma_r2 - float(coords.x * coords.x + coords.y *\n                            coords.y) / sigma_s2);\n            color.xyz += tmpCol.xyz * tmp;\n            weight += tmp;\n        }\n\n        color = weight > 0.0 ? color / weight : colRef;\n        f_color = vec4(color.xyz, 1.0);\n    }\n                                     );\n\n    switch(target) {\n    case GL_TEXTURE_2D: {\n        fragment_source = fragment_source_2D;\n    }\n    break;\n\n    case GL_TEXTURE_2D_ARRAY: {\n        fragment_source = fragment_source_3D;\n    }\n    break;\n\n    case GL_TEXTURE_3D: {\n        fragment_source = fragment_source_3D;\n    }\n    break;\n    }\n}\n\nPIC_INLINE void FilterGLBilateral1D::setUniformAux()\n{\n    float sigma_s_sq2 = 2.0f * sigma_s * sigma_s;\n    float sigma_r_sq2 = 2.0f * sigma_r * sigma_r;\n\n    //Precomputation of the Gaussian Kernel\n    int halfKernelSize = PrecomputedGaussian::getKernelSize(MAX(sigma_s, sigma_r)) >> 1;\n\n    technique.setUniform1f(\"sigma_s2\",\tsigma_s_sq2);\n    technique.setUniform1f(\"sigma_r2\",\tsigma_r_sq2);\n    technique.setUniform1i(\"halfKernelSize\", halfKernelSize);\n}\n\nPIC_INLINE void FilterGLBilateral1D::update(float sigma_s, float sigma_r)\n{\n    this->sigma_s = sigma_s;\n    this->sigma_r = sigma_r;\n\n    setUniform();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_BILATERAL_1D_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_bilateral_2das.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_BILATERAL_2DAS_HPP\n#define PIC_GL_FILTERING_FILTER_BILATERAL_2DAS_HPP\n\n#include \"../../util/vec.hpp\"\n#include \"../../util/std_util.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../gl/filtering/filter_sampling_map.hpp\"\n#include \"../../gl/point_samplers/sampler_random_m.hpp\"\n\nnamespace pic {\n\nclass FilterGLBilateral2DAS: public FilterGL\n{\nprotected:\n    float sigma_s, sigma_r;\n    MRSamplersGL<2> *ms;\n\n    //Random numbers tile\n    ImageGL *imageRand;\n\n    //Sampling map\n    FilterGLSamplingMap *fGLsm;\n    ImageGL *sampleMap;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\n    /**\n     * @brief updateParam\n     */\n    void updateParam()\n    {\n        param.clear();\n\n        param.push_back(ms->getImage());\n        param.push_back(ms->getImageLevelsR());\n        param.push_back(imageRand);\n\n        if(sampleMap != NULL) {\n            param.push_back(sampleMap);\n        }\n    }\n\n    /**\n     * @brief setNULL\n     */\n    void setNULL()\n    {\n        ms = NULL;\n        imageRand = NULL;\n        fGLsm = NULL;\n        sampleMap = NULL;\n        sigma_s = -1.0f;\n        sigma_r = -1.0f;\n    }\n\npublic:\n\n    /**\n     * @brief FilterGLBilateral2DAS\n     */\n    FilterGLBilateral2DAS();\n\n    ~FilterGLBilateral2DAS();\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux()\n    {\n        delete_s(ms);\n        delete_s(imageRand);\n        delete_s(fGLsm);\n        delete_s(sampleMap);\n    }\n\n    /**\n     * @brief FilterGLBilateral2DAS\n     * @param sigma_s\n     * @param sigma_r\n     */\n    FilterGLBilateral2DAS(float sigma_s, float sigma_r);\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_r\n     */\n    void update(float sigma_s, float sigma_r);\n\n    /**\n     * @brief setupAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *setupAux(ImageGLVec imgIn, ImageGL *imgOut)\n    {\n        //calculate the sampling map\n        sampleMap = fGLsm->Process(imgIn, sampleMap);\n\n        if(param.size() == 3) {\n            param.push_back(sampleMap);\n        }\n\n        return allocateOutputMemory(imgIn, imgOut, bDelete);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param sigma_s\n     * @param sigma_r\n     * @return\n     */\n    static ImageGL *execute(ImageGL *imgIn, float sigma_s, float sigma_r)\n    {\n        FilterGLBilateral2DAS *filter = new FilterGLBilateral2DAS(sigma_s, sigma_r);\n\n        ImageGL *imgOut = filter->Process(SingleGL(imgIn), NULL);\n\n        delete filter;\n        return imgOut;\n    }\n};\n\nPIC_INLINE FilterGLBilateral2DAS::FilterGLBilateral2DAS(): FilterGL()\n{\n    setNULL();\n}\n\nPIC_INLINE FilterGLBilateral2DAS::~FilterGLBilateral2DAS()\n{\n    release();\n}\n\nPIC_INLINE FilterGLBilateral2DAS::FilterGLBilateral2DAS(float sigma_s,\n        float sigma_r): FilterGL()\n{\n    setNULL();\n\n    FragmentShader();\n\n    initShaders();\n\n    update(sigma_s, sigma_r);\n}\n\nPIC_INLINE void FilterGLBilateral2DAS::FragmentShader()\n{\n    fragment_source = MAKE_STRING\n                      (\n                          uniform sampler2D\tu_tex;\n                          uniform isampler2D\tu_poisson;\n                          uniform sampler2D\tu_sample;\n                          uniform isampler2D\tu_rand;\n                          uniform isampler2D\tu_levelsR;\n                          uniform float\t\tsigmas2;\n                          uniform float\t\tsigmar2;\n                          uniform int           levelsR_Size;\n                          out     vec4          f_color;\n\n                          //Calculate the number of samples\n    int CalculateSamples(int shifter, ivec2 tSize) {\n        //Fetch to the sampling map\n        float levelVal = dot(texture(u_sample, gl_FragCoord.xy / tSize.xy).xyz, vec3(1.0)) / 3.0;\n        levelVal = clamp(1.0f - levelVal, 0.0, 1.0) * float(levelsR_Size);\n\n        int levelInt = int(floor(levelVal));\n\n        int nSamples = texelFetch(u_levelsR, ivec2(levelInt, shifter), 0).x;\n\n        if(levelInt < (levelsR_Size - 1)) {\n            float tmp = (levelVal - float(levelInt));\n\n            if(tmp > 0.0) {\n                int nSamples1 = texelFetch(u_levelsR, ivec2(levelInt + 1, shifter), 0).x;\n\n                nSamples += int(float(nSamples1 - nSamples) * tmp);\n            }\n        }\n\n        return nSamples / 2;\n    }\n\n    void main(void) {\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n\n        //Coordinates\n        int shifter = texelFetch(u_rand, coordsFrag.xy % 128, 0).x;\n\n        //Calculating the number of samples\n        ivec2 tSize =  textureSize(u_tex, 0);\n\n        int nSamples = CalculateSamples(shifter, tSize);\n\n        //Filtering\n        vec3 tmpCol;\n        vec3 colRef = texelFetch(u_tex, coordsFrag, 0).xyz;\n        vec3  color = vec3(0.0);\n        float weight = 0.0;\n\n        for(int i = 0; i < nSamples; i++) {\n            ivec4 coords = texelFetch(u_poisson, ivec2(i, shifter), 0);\n\n            //Texture fetch\n            tmpCol = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0).xyz;\n            vec3 tmpCol2 = tmpCol - colRef;\n            float dstR = dot(tmpCol2.xyz, tmpCol2.xyz);\n            float tmp = exp(-dstR / sigmar2 - float(coords.z) / sigmas2);\n            color += tmpCol * tmp;\n            weight += tmp;\n        }\n\n        color = weight > 0.0 ? color / weight : colRef;\n        f_color = vec4(color, 1.0);\n    }\n                      );\n}\n\nPIC_INLINE void FilterGLBilateral2DAS::initShaders()\n{\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLBilateral2DAS\");\n}\n\nPIC_INLINE void FilterGLBilateral2DAS::update(float sigma_s, float sigma_r)\n{\n    bool flag = false;\n\n    if(sigma_s > 0.0f) {\n        this->sigma_s = sigma_s;\n        flag = (this->sigma_s == sigma_s);\n    }\n\n    if(sigma_r > 0.0f) {\n        this->sigma_r = sigma_r;\n        flag = flag || (this->sigma_r == sigma_r);\n    }\n\n    if(fGLsm == NULL) {\n        fGLsm = new FilterGLSamplingMap(sigma_s);\n    }\n\n    int nRand = 32;\n\n    if(imageRand == NULL) {\n        Image tmp_image_rand(1, 128, 128, 1);\n        tmp_image_rand.setRand(1);\n        tmp_image_rand *= float(nRand - 1);\n\n        imageRand = new ImageGL(&tmp_image_rand, true);\n        imageRand->generateTextureGL(GL_TEXTURE_2D, GL_INT, false);\n    }\n\n    if(flag) {\n        //shader update\n        int kernelSize = PrecomputedGaussian::getKernelSize(this->sigma_s);\n        int halfKernelSize = kernelSize >> 1;\n        Vec2i window = Vec2i(halfKernelSize, halfKernelSize);\n\n        //Poisson samples\n        #ifdef PIC_DEBUG\n            printf(\"Window: %d\\n\", halfKernelSize);\n        #endif\n\n        if(ms == NULL) {\n            ms = new MRSamplersGL<2>(ST_BRIDSON, window, halfKernelSize, 3, nRand);\n            ms->generateTexture();\n            ms->generateLevelsRTexture();\n            #ifdef PIC_DEBUG\n                printf(\"Number of samples: %d\\n\", ms->nSamples >> 1);\n            #endif\n        } else {\n            ms->updateGL(window, halfKernelSize);\n        }\n\n        updateParam();\n    }\n\n    //shader update\n    float sigmas2 = 2.0f * this->sigma_s * this->sigma_s;\n    float sigmar2 = 2.0f * this->sigma_r * this->sigma_r;\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\",      0);\n    technique.setUniform1i(\"u_poisson\",  1);\n    technique.setUniform1i(\"u_levelsR\",\t 2);\n    technique.setUniform1i(\"u_rand\",\t 3);\n    technique.setUniform1i(\"u_sample\",\t 4);\n    technique.setUniform1f(\"sigmas2\",  sigmas2);\n    technique.setUniform1f(\"sigmar2\",  sigmar2);\n    technique.setUniform1i(\"levelsR_Size\", ms->nLevels);\n    technique.unbind();    \n}\n/*\n    //Textures\n\n    glActiveTexture(GL_TEXTURE3);\n    imgTmp->bindTexture();\n\n    glActiveTexture(GL_TEXTURE4);\n    glBindTexture(GL_TEXTURE_2D, ms->getLevelsRTexture());\n\n    glActiveTexture(GL_TEXTURE2);\n    imageRand->bindTexture();\n\n    glActiveTexture(GL_TEXTURE1);\n    glBindTexture(GL_TEXTURE_2D, ms->getTexture());\n\n    glActiveTexture(GL_TEXTURE0);\n    base->bindTexture();\n */\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_BILATERAL_2DAS_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_bilateral_2df.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_BILATERAL_2DF_HPP\n#define PIC_GL_FILTERING_FILTER_BILATERAL_2DF_HPP\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLBilateral2DF class provides\n * an HW accelerated bilateral filter implementation without\n * approximations.\n */\nclass FilterGLBilateral2DF: public FilterGL\n{\nprotected:\n    float sigma_s, sigma_r;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\npublic:\n\n    /**\n     * @brief FilterGLBilateral2DF\n     */\n    FilterGLBilateral2DF();\n\n    /**\n     * @brief FilterGLBilateral2DF\n     * @param sigma_s\n     * @param sigma_r\n     */\n    FilterGLBilateral2DF(float sigma_s, float sigma_r);\n\n    ~FilterGLBilateral2DF();\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_r\n     */\n    void update(float sigma_s, float sigma_r);\n\n    /**\n     * @brief setupAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *setupAux(ImageGLVec imgIn, ImageGL *imgOut)\n    {\n        imgOut = allocateOutputMemory(imgIn, imgOut, false);\n\n        if(imgIn.size() == 1) {\n            param.clear();\n            param.push_back(imgIn[0]);\n        }\n\n        return imgOut;\n    }\n};\n\nPIC_INLINE FilterGLBilateral2DF::FilterGLBilateral2DF(): FilterGL()\n{\n}\n\nPIC_INLINE FilterGLBilateral2DF::~FilterGLBilateral2DF()\n{\n    release();\n}\n\nPIC_INLINE FilterGLBilateral2DF::FilterGLBilateral2DF(float sigma_s,\n        float sigma_r): FilterGL()\n{\n    //protected values are assigned/computed\n    this->sigma_s = sigma_s;\n    this->sigma_r = sigma_r;\n\n    FragmentShader();\n    initShaders();\n}\n\nPIC_INLINE void FilterGLBilateral2DF::FragmentShader()\n{\n    fragment_source = MAKE_STRING\n                      (\n                          uniform sampler2D u_tex;\n                          uniform float     sigmas2;\n                          uniform float     sigmar2;\n                          uniform int       halfKernelSize;\n                          out     vec4      f_color;\n\n    void main(void) {\n        vec3  color = vec3(0.0, 0.0, 0.0);\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n        vec3 tmpCol;\n\n        vec3 colRef = texelFetch(u_tex, coordsFrag, 0).xyz;\n\n        float weight = 0.0;\n\n        for(int i = -halfKernelSize; i <= halfKernelSize; i++) {\n            for(int j = -halfKernelSize; j <= halfKernelSize; j++) {\n                //Coordinates\n                ivec2 coords = ivec2(i, j);\n                //Texture fetch\n                tmpCol = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0).xyz;\n                vec3 tmpCol2 = tmpCol - colRef;\n                float dstR = dot(tmpCol2.xyz, tmpCol2.xyz);\n                float tmp = exp(-dstR / sigmar2 - float(coords.x * coords.x + coords.y *\n                                                        coords.y) / sigmas2);\n                color.xyz += tmpCol * tmp;\n                weight += tmp;\n            }\n        }\n\n        color = weight > 0.0 ? color / weight : colRef;\n        f_color = vec4(color.xyz, 1.0);\n    }\n                      );\n}\n\nPIC_INLINE void FilterGLBilateral2DF::initShaders()\n{\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLBilateral2DF\");\n\n    update(-1.0f, -1.0f);\n}\n\nPIC_INLINE void FilterGLBilateral2DF::update(float sigma_s, float sigma_r)\n{\n    if(sigma_s > 0.0f) {\n        this->sigma_s = sigma_s;\n    }\n\n    if(sigma_r > 0.0f) {\n        this->sigma_r = sigma_r;\n    }\n\n    float sigmas2 = 2.0f * this->sigma_s * this->sigma_s;\n    float sigmar2 = 2.0f * this->sigma_r * this->sigma_r;\n\n    //Precomputation of the Gaussian Kernel\n    int halfKernelSize = PrecomputedGaussian::getKernelSize(this->sigma_s) >> 1;\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.setUniform1f(\"sigmas2\", sigmas2);\n    technique.setUniform1f(\"sigmar2\", sigmar2);\n    technique.setUniform1i(\"halfKernelSize\", halfKernelSize);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_BILATERAL_2DF_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_bilateral_2dg.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_BILATERAL_2DG_HPP\n#define PIC_GL_FILTERING_FILTER_BILATERAL_2DG_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../gl/filtering/filter_slicer.hpp\"\n#include \"../../gl/filtering/filter_scatter.hpp\"\n#include \"../../gl/filtering/filter_gaussian_3d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLBilateral2DG class\n */\nclass FilterGLBilateral2DG: public FilterGL\n{\nprotected:\n    float sigma_s, sigma_r, s_S, s_R;\n\n    FilterGLScatter     *scatter;\n    FilterGLGaussian3D  *gauss3D;\n    ImageGL             *gridGL, *gridBlurGL;\n\npublic:\n    FilterGLSlicer      *slicer;\n\n    /**\n     * @brief FilterGLBilateral2DG\n     * @param sigma_s\n     * @param sigma_r\n     * @param width\n     * @param height\n     */\n    FilterGLBilateral2DG(float sigma_s, float sigma_r);\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *Process(ImageGLVec imgIn, ImageGL *imgOut);\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param sigma_s\n     * @param sigma_r\n     * @return\n     */\n    static ImageGL *execute(ImageGL *imgIn, float sigma_s, float sigma_r)\n    {\n        FilterGLBilateral2DG *filter = new FilterGLBilateral2DG(sigma_s, sigma_r);\n        GLuint testTQ1 = glBeginTimeQuery();\n        ImageGL *imgOut = filter->Process(SingleGL(imgIn), NULL);\n        GLuint64EXT timeVal = glEndTimeQuery(testTQ1);\n\n        printf(\"Bilateral 2DG Filter on GPU time: %f ms\\n\",\n               double(timeVal) / 1000000.0);\n\n        return imgOut;\n    }\n\n    static ImageGL *execute(std::string nameIn, std::string nameOut,\n                               float sigma_s, float sigma_r, int testing = 1)\n    {\n        Image tmp_imgIn(nameIn);\n        float maxVal = tmp_imgIn.getMaxVal()[0];\n        tmp_imgIn /= maxVal;\n        sigma_r = sigma_r / maxVal;\n\n        ImageGL imgIn(&tmp_imgIn, true);\n        imgIn.generateTextureGL();\n\n        FilterGLBilateral2DG *filter = new FilterGLBilateral2DG(sigma_s, sigma_r);//, imgIn.channels);\n\n        ImageGL *imgOut = new ImageGL(1, imgIn.width, imgIn.height, 4,\n                                      IMG_GPU_CPU, GL_TEXTURE_2D);\n\n        GLuint testTQ1;\n\n        if(testing > 1) {\n            filter->Process(SingleGL(&imgIn), imgOut);\n\n            testTQ1 = glBeginTimeQuery();\n\n            for(int i = 0; i < testing; i++) {\n                filter->Process(SingleGL(&imgIn), imgOut);\n            }\n        } else {\n            testTQ1 = glBeginTimeQuery();\n            filter->Process(SingleGL(&imgIn), imgOut);\n        }\n\n       // GLuint64EXT timeVal = glEndTimeQuery(testTQ1);\n\n      //  double ms = double(timeVal) / (double(testing) * 1000000.0);\n      //  printf(\"Bilateral Grid on the GPU time: %g ms\\n\", ms);\n\n        std::string sign = genBilString(\"G\", sigma_s, sigma_r);\n\n        /*\n        std::string nameTime = FileLister::FileNumber(sign, \"txt\");\n\n        FILE *file = fopen(nameTime.c_str(), \"w\");\n\n        if(file != NULL) {\n            fprintf(file, \"%f\", ms);\n            fclose(file);\n        }*/\n\n        //Read from the GPU\n        *imgOut /= maxVal;\n        imgOut->loadToMemory();\n        imgOut->Write(nameOut);\n\n        return imgOut;\n    }\n};\n\nPIC_INLINE FilterGLBilateral2DG::FilterGLBilateral2DG(float sigma_s, float sigma_r): FilterGL()\n{\n    this->sigma_s = sigma_s;\n    this->sigma_r = sigma_r;\n\n    s_S = 1.0f / sigma_s; //Spatial Sampling rate\n    s_R = 1.0f / sigma_r; //Range Sampling rate\n\n    gridGL = NULL;\n    gridBlurGL = NULL;\n\n    scatter = NULL;\n    gauss3D = new FilterGLGaussian3D(1.0f);\n    slicer  = new FilterGLSlicer(s_S, s_R);\n}\n\nPIC_INLINE ImageGL *FilterGLBilateral2DG::Process(ImageGLVec imgIn,\n        ImageGL *imgOut)\n{\n    if(imgIn[0] == NULL || imgIn.size() > 1) {\n        return imgOut;\n    }\n\n    if(imgOut == NULL) {\n        imgOut = imgIn[0]->allocateSimilarOneGL();\n    }\n\n    if(scatter == NULL) {\n        scatter = new FilterGLScatter(s_S, s_R, imgIn[0]->width, imgIn[0]->height);\n    }\n\n    //splat\n    gridGL = scatter->Process(imgIn, gridGL);\n\n    //blur\n    gridBlurGL = gauss3D->Process(SingleGL(gridGL), gridBlurGL);\n\n    //slice\n    imgOut = slicer->Process(DoubleGL(imgIn[0], gridBlurGL), imgOut);\n\n    return imgOut;\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_BILATERAL_2DG_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_bilateral_2ds.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_BILATERAL_2DS_HPP\n#define PIC_GL_FILTERING_FILTER_BILATERAL_2DS_HPP\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../util/file_lister.hpp\"\n#include \"../../gl/point_samplers/sampler_random_m.hpp\"\n\nnamespace pic {\n\nenum BF_TYPE {BF_CLASSIC, BF_CROSS, BF_BRUSH};\n\n/**\n * @brief getValueBF\n * @param type\n * @return\n */\nPIC_INLINE int getValueBF(BF_TYPE type)\n{\n    int ret = -1;\n    switch(type) {\n    case BF_CLASSIC:\n        ret = 0;\n        break;\n\n    case BF_CROSS:\n        ret = 1;\n        break;\n\n    case BF_BRUSH:\n        ret = 2;\n        break;\n\n    default:\n        ret = 0;\n        break;\n    }\n\n    return ret;\n}\n\n/**\n * @brief The FilterGLBilateral2DS class\n */\nclass FilterGLBilateral2DS: public FilterGL\n{\nprotected:\n    float sigma_s, sigma_r;\n    BF_TYPE type;\n\n    //Random numbers tile\n    MRSamplersGL<2> *ms;\n    ImageGL *imageRand;\n    //Fragment Brush\n    std::vector<std::string> fragment_sources;\n\n    void initShaders();\n    void FragmentShader();\n\npublic:\n    /**\n     * @brief FilterGLBilateral2DS\n     * @param sigma_s\n     * @param sigma_r\n     * @param type\n     */\n    FilterGLBilateral2DS(float sigma_s, float sigma_r, BF_TYPE type);\n\n    ~FilterGLBilateral2DS();\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_r\n     * @param type\n     */\n    void update(float sigma_s, float sigma_r, BF_TYPE type);\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux()\n    {\n        delete_s(imageRand);\n        delete_s(ms);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param sigma_s\n     * @param sigma_r\n     * @return\n     */\n    static ImageGL *execute(ImageGL *imgIn, float sigma_s, float sigma_r)\n    {\n        FilterGLBilateral2DS *filter = new FilterGLBilateral2DS(sigma_s, sigma_r,\n                BF_CLASSIC);\n\n        ImageGL *imgOut = filter->Process(SingleGL(imgIn), NULL);\n\n        delete filter;\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param nameFile\n     * @param nameOut\n     * @param sigma_s\n     * @param sigma_r\n     * @param testing\n     * @return\n     */\n    static ImageGL *execute(std::string nameFile, std::string nameOut,\n                               float sigma_s, float sigma_r, int testing = 1)\n    {\n        ImageGL imgIn(nameFile);\n        imgIn.generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n\n        FilterGLBilateral2DS *filter = new FilterGLBilateral2DS(sigma_s, sigma_r,\n                BF_CLASSIC);\n\n        ImageGL *imgOut = new ImageGL(1, imgIn.width, imgIn.height, imgIn.channels,\n                                            IMG_GPU_CPU, GL_TEXTURE_2D);\n\n        GLuint testTQ1;\n\n        if(testing > 1) {\n            filter->Process(SingleGL(&imgIn), imgOut);\n\n            testTQ1 = glBeginTimeQuery();\n\n            for(int i = 0; i < testing; i++) {\n                filter->Process(SingleGL(&imgIn), imgOut);\n            }\n        } else {\n            testTQ1 = glBeginTimeQuery();\n            filter->Process(SingleGL(&imgIn), imgOut);\n        }\n\n        GLuint64EXT timeVal = glEndTimeQuery(testTQ1);\n        double ms = double(timeVal) / (double(testing) * 1000000.0);\n        printf(\"Stochastic Bilateral Filter on GPU time: %f ms\\n\", ms);\n\n        std::string nameTime = FileLister::getFileNumber(genBilString(\"S\", sigma_s,\n                               sigma_r), \"txt\");\n\n        FILE *file = fopen(nameTime.c_str(), \"w\");\n\n        if(file != NULL) {\n            fprintf(file, \"%f\", ms);\n            fclose(file);\n        }\n\n        //Read from the GPU\n        imgOut->loadToMemory();\n        imgOut->Write(nameOut);\n\n        return imgOut;\n    }\n\n    /**\n     * @brief setupAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *setupAux(ImageGLVec imgIn, ImageGL *imgOut)\n    {\n        imgOut = allocateOutputMemory(imgIn, imgOut, false);\n        return imgOut;\n    }\n};\n\nPIC_INLINE FilterGLBilateral2DS::FilterGLBilateral2DS(float sigma_s, float sigma_r,\n        BF_TYPE type = BF_CLASSIC): FilterGL()\n{\n    ms = NULL;\n    imageRand = NULL;\n\n    this->type = type;\n\n    FragmentShader();\n\n    initShaders();\n\n    update(sigma_s, sigma_r, type);\n}\n\nPIC_INLINE FilterGLBilateral2DS::~FilterGLBilateral2DS()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLBilateral2DS::FragmentShader()\n{\n    std::string fragment_source_classic = MAKE_STRING\n                                          (\n                                                  uniform sampler2D  u_tex;\n                                                  uniform isampler2D u_poisson;\n                                                  uniform sampler2D  u_rand;\n                                                  uniform int   nSamples;\n                                                  uniform float sigma_s_sq_2;\n                                                  uniform float sigma_r_sq_2;\n                                                  uniform int kernelSize;\n                                                  uniform float kernelSizef;\n                                                  out     vec4  f_color;\n\n    void main(void) {\n        vec3  color = vec3(0.0, 0.0, 0.0);\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n        vec3 tmpCol;\n\n        vec3 colRef = texelFetch(u_tex, coordsFrag, 0).xyz;\n        float weight = 0.0;\n\n        float shifter = texture(u_rand, gl_FragCoord.xy).x;\n\n        for(int i = 0; i < nSamples; i++) {\n            //Coordinates\n            ivec3 coords = texelFetch(u_poisson, ivec2(i, shifter), 0).xyz;\n\n            //Texture fetch\n            tmpCol = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0).xyz;\n            vec3 tmpCol2 = tmpCol - colRef;\n            float dstR = dot(tmpCol2.xyz, tmpCol2.xyz);\n            int coordsz = coords.x * coords.x + coords.y * coords.y;\n            float tmp = exp(-dstR / sigma_r_sq_2 - float(coordsz) / sigma_s_sq_2);\n            color.xyz += tmpCol * tmp;\n            weight += tmp;\n        }\n\n        f_color = vec4(weight > 0 ? (color / weight) : colRef, 1.0);\n    }\n                                          );\n\n    std::string fragment_source_cross = MAKE_STRING\n                                        (\n                                            uniform sampler2D\tu_tex;\n                                            uniform sampler2D\tu_edge;\n                                            uniform isampler2D\tu_poisson;\n                                            uniform sampler2D\tu_rand;\n                                            uniform int\t\t\tnSamples;\n                                            uniform float\t\tsigma_s_sq_2;\n                                            uniform float\t\tsigma_r_sq_2;\n                                            out     vec4\t\tf_color;\n\n    void main(void) {\n        vec3  color = vec3(0.0, 0.0, 0.0);\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n\n        vec3 colRef  = texelFetch(u_tex, coordsFrag, 0).xyz;\n        vec3 edgeRef = texelFetch(u_edge, coordsFrag, 0).xyz;\n\n        float weight = 0.0;\n        float shifter = texture(u_rand, gl_FragCoord.xy, 0).x;\n\n        for(int i = 0; i < nSamples; i++) {\n            //Coordinates\n            ivec3 coords = texelFetch(u_poisson, ivec2(i, shifter), 0).xyz;\n\n            //Range difference\n            vec3 tmpEdge = texelFetch(u_edge, coordsFrag.xy + coords.xy, 0).xyz;\n            vec3 tmpEdge2 = tmpEdge - edgeRef;\n            float dstR = dot(tmpEdge2.xyz, tmpEdge2.xyz);\n            float tmp = exp(-dstR / sigma_r_sq_2 - float(coords.z) / sigma_s_sq_2);\n\n            //Texture Fetch\n            vec3 tmpCol = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0).xyz;\n            color.xyz += tmpCol * tmp;\n            weight += tmp;\n        }\n\n        f_color = vec4(weight > 0.0 ? color / weight : colRef, 1.0);\n    }\n                                        );\n\n    std::string fragment_source_brush = MAKE_STRING\n                                        (\n                                            uniform sampler2D  u_tex;\n                                            uniform isampler2D u_poisson;\n                                            uniform sampler2D  u_rand;\n                                            uniform sampler2D  u_mask;\n                                            uniform int   nSamples;\n                                            uniform float sigma_s_sq_2;\n                                            uniform float sigma_r_sq_2;\n                                            out     vec4      f_color;\n\n    void main(void) {\n        vec3  color = vec3(0.0, 0.0, 0.0);\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n        vec3 tmpCol;\n\n        float w = texelFetch(u_mask, coordsFrag, 0).x;\n        vec3 colRef = texelFetch(u_tex, coordsFrag, 0).xyz;\n\n        if(w > 0.0f) {\n            w = min(w, 1.0f);\n            float weight = 0.0;\n            float shifter = texture(u_rand, gl_FragCoord.xy, 0).x;\n\n            for(int i = 0; i < nSamples; i++) {\n                //Coordinates\n                ivec3 coords = texelFetch(u_poisson, ivec2(i, shifter), 0).xyz;\n                //Texture fetch\n                tmpCol = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0).xyz;\n                vec3 tmpCol2 = tmpCol - colRef;\n                float dstR = dot(tmpCol2.xyz, tmpCol2.xyz);\n                float tmp = exp(-dstR / sigma_r_sq_2 - float(coords.z) / sigma_s_sq_2);\n                color.xyz += tmpCol * tmp;\n                weight += tmp;\n            }\n\n            color = weight > 0.0 ? color / weight : colRef;\n            f_color = vec4(color.xyz * w + (1 - w) * colRef.xyz, 1.0);\n        } else {\n            f_color = vec4(colRef.xyz, 1.0);\n        }\n    }\n                                        );\n\n    fragment_sources.push_back(fragment_source_classic);\n    fragment_sources.push_back(fragment_source_cross);\n    fragment_sources.push_back(fragment_source_brush);\n}\n\nPIC_INLINE void FilterGLBilateral2DS::initShaders()\n{\n    technique.initStandard(\"330\", vertex_source, fragment_sources[getValueBF(type)], \"FilterGLBilateral2DS\");\n}\n\nPIC_INLINE void FilterGLBilateral2DS::update(float sigma_s, float sigma_r, BF_TYPE type)\n{\n    this->type = type;\n\n    bool flag = false;\n\n    if(sigma_s > 0.0f) {\n        flag = (this->sigma_s != sigma_s);\n        this->sigma_s = sigma_s;\n    }\n\n    if(sigma_r > 0.0f) {\n        flag = flag || (this->sigma_r != sigma_r);\n        this->sigma_r = sigma_r;\n    }\n\n    int kernelSize = PrecomputedGaussian::getKernelSize(this->sigma_s);\n    int halfKernelSize = kernelSize >> 1;\n\n    //Poisson samples\n#ifdef PIC_DEBUG\n    printf(\"Window: %d\\n\", halfKernelSize);\n#endif\n\n    if(imageRand == NULL) {\n        imageRand = new ImageGL(1, 128, 128, 1, IMG_CPU, GL_TEXTURE_2D);\n        imageRand->setRand(1);\n        imageRand->loadFromMemory();\n        *imageRand -= 0.5f;\n    }\n\n    if(flag) {\n        int nSamplers = 1;\n        Vec2i window = Vec2i(halfKernelSize, halfKernelSize);\n\n        if(ms == NULL) {\n            ms = new MRSamplersGL<2>(ST_BRIDSON, window, halfKernelSize, 1,\n                                     nSamplers);\n            ms->generateTexture();\n        } else {\n            ms->updateGL(window, halfKernelSize);\n            param.clear();\n        }\n\n    #ifdef PIC_DEBUG\n        printf(\"Number of samples: %d\\n\", ms->nSamples);\n    #endif\n\n        if(param.empty()) {\n            param.push_back(ms->getImage());\n            param.push_back(imageRand);\n        }\n    }\n\n    //shader update\n    float sigma_s_sq_2 = 2.0f * this->sigma_s * this->sigma_s;\n    float sigma_r_sq_2 = 2.0f * this->sigma_r * this->sigma_r;\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n\n    if(type == BF_CROSS) {\n        technique.setUniform1i(\"u_edge\", 1);\n        technique.setUniform1i(\"u_poisson\", 2);\n        technique.setUniform1i(\"u_rand\", 3);\n        technique.setUniform1i(\"u_mask\", 4);\n    } else {\n        technique.setUniform1i(\"u_poisson\", 1);\n        technique.setUniform1i(\"u_rand\", 2);\n        technique.setUniform1i(\"u_mask\", 3);\n    }\n\n    technique.setUniform1f(\"sigma_s_sq_2\", sigma_s_sq_2);\n    technique.setUniform1f(\"sigma_r_sq_2\", sigma_r_sq_2);\n    technique.setUniform1i(\"kernelSize\", kernelSize);\n    technique.setUniform1f(\"kernelSizef\", float(kernelSize));\n    technique.setUniform1i(\"nSamples\", ms->nSamples >> 1);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_BILATERAL_2DS_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_bilateral_2ds_e.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_BILATERAL_2DSE_HPP\n#define PIC_GL_FILTERING_FILTER_BILATERAL_2DSE_HPP\n\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../util/file_lister.hpp\"\n#include \"../../gl/point_samplers/sampler_random_m.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLBilateral2DSE class\n */\nclass FilterGLBilateral2DSE: public FilterGL\n{\nprotected:\n    float sigma_s, sigma_p, sigma_n, sigma_a;\n    MRSamplersGL<2> *ms;\n\n    //Random numbers tile\n    ImageGL *imageRand;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\npublic:\n    /**\n     * @brief FilterGLBilateral2DSE\n     * @param sigma_s\n     * @param sigma_p\n     * @param sigma_n\n     * @param sigma_a\n     */\n    FilterGLBilateral2DSE(float sigma_s, float sigma_p, float sigma_n, float sigma_a);\n\n    ~FilterGLBilateral2DSE();\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_p\n     * @param sigma_n\n     * @param sigma_a\n     */\n    void update(float sigma_s, float sigma_p, float sigma_n, float sigma_a);\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *Process(ImageGLVec imgIn, ImageGL *imgOut);\n\n    /**\n     * @brief main\n     * @param argc\n     * @param argv\n     * @return\n     */\n    static int main(int argc, char* argv[])\n    {\n        if(argc < 6) {\n            printf(\"Usage: name_input sigma_s sigma_pos sigma_nor sigma_alb\\n\");\n            return 0;\n        }\n\n        execute(argv[1], float(atof(argv[2])), float(atof(argv[3])), float(atof(argv[4])), float(atof(argv[5])));\n\n        return 0;\n    }\n\n    /**\n     * @brief execute\n     * @param nameIn\n     * @param sigma_s\n     * @param sigma_p\n     * @param sigma_n\n     * @param sigma_a\n     * @param testing\n     * @return\n     */\n    static ImageGL *execute( std::string nameIn,\n                                float sigma_s, float sigma_p, float sigma_n, float sigma_a, int testing = 1)\n    {\n\n        std::string name = removeExtension(nameIn);\n        std::string ext = getExtension(nameIn);\n\n        std::string nameOut = name + \"_flt.\" + ext; \n\n        std::string namePos = name +\"_pos.\" + ext;\n        std::string nameNor = name +\"_nor.\" + ext;\n        std::string nameAlb = name +\"_alb.\" + ext;\n\n\n        ImageGL imgIn(nameIn);\n        imgIn.generateTextureGL(GL_TEXTURE_2D, false);\n\n        ImageGL imgPos(namePos);\n        imgPos.generateTextureGL(GL_TEXTURE_2D, false);\n\n        ImageGL imgNor(nameNor);\n        imgNor.generateTextureGL(GL_TEXTURE_2D, false);\n\n        ImageGL imgAlb(nameAlb);\n        imgAlb.generateTextureGL(GL_TEXTURE_2D, false);\n\n        ImageGLVec vec;\n        vec.push_back(&imgIn);\n        vec.push_back(&imgPos);\n        vec.push_back(&imgNor);\n        vec.push_back(&imgAlb);\n\n        FilterGLBilateral2DSE *filter = new FilterGLBilateral2DSE(sigma_s, sigma_p,\n                    sigma_n, sigma_a);\n\n        ImageGL *imgOut = new ImageGL(1, imgIn.width, imgIn.height, imgIn.channels,\n                                            IMG_GPU_CPU, GL_TEXTURE_2D);\n\n        GLuint testTQ1;\n\n        if(testing > 1) {\n            filter->Process(vec, imgOut);\n\n            testTQ1 = glBeginTimeQuery();\n\n            for(int i = 0; i < testing; i++) {\n                filter->Process(vec, imgOut);\n            }\n        } else {\n            testTQ1 = glBeginTimeQuery();\n            filter->Process(vec, imgOut);\n        }\n\n        GLuint64EXT timeVal = glEndTimeQuery(testTQ1);\n        double ms = double(timeVal) / (double(testing) * 1000000.0);\n        printf(\"Cross Bilateral Filter with G-buffer on GPU time: %f ms\\n\", ms);\n\n        //Read from the GPU\n        imgOut->loadToMemory();\n        imgOut->Write(nameOut);\n\n        return imgOut;\n    }\n\n};\n\nPIC_INLINE FilterGLBilateral2DSE::FilterGLBilateral2DSE(float sigma_s, float sigma_p, float sigma_n, float sigma_a): FilterGL()\n{\n    //protected values are assigned/computed\n    this->sigma_s = sigma_s;\n    this->sigma_p = sigma_p;\n    this->sigma_n = sigma_n;\n    this->sigma_a = sigma_a;\n\n    //Precomputation of the Gaussian Kernel\n    int kernelSize = PrecomputedGaussian::getKernelSize(sigma_s);//,sigma_r);\n    int halfKernelSize = kernelSize >> 1;\n\n    //Random numbers\n    int nRand = 32;\n    int nSamplers;\n\n    Image tmp_imageRand(1, 128, 128, 1);\n    tmp_imageRand.setRand();\n    tmp_imageRand *= float(nRand - 1);\n\n    imageRand = new ImageGL(&tmp_imageRand, true);\n    imageRand->generateTextureGL(GL_TEXTURE_2D, GL_INT);\n\n    nSamplers = nRand;\n\n    //Poisson samples\n#ifdef PIC_DEBUG\n    printf(\"Window: %d\\n\", halfKernelSize);\n#endif\n\n    Vec2i window = Vec2i(halfKernelSize, halfKernelSize);\n    ms = new MRSamplersGL<2>(ST_BRIDSON, window, 4*halfKernelSize, 1,\n                             nSamplers);\n    ms->generateTexture();\n\n    FragmentShader();\n    initShaders();\n}\n\nPIC_INLINE FilterGLBilateral2DSE::~FilterGLBilateral2DSE()\n{\n    delete imageRand;\n    delete ms;\n\n    //free shader etc...\n}\n\nPIC_INLINE void FilterGLBilateral2DSE::FragmentShader()\n{\n    fragment_source = MAKE_STRING(\n    uniform sampler2D\tu_tex;\n    uniform sampler2D\tu_edge_pos;\n    uniform sampler2D\tu_edge_nor;\n    uniform sampler2D\tu_edge_alb;\n    uniform isampler2D\tu_poisson;\n    uniform sampler2D\tu_rand;\n    uniform int\t\t\tnSamples;\n    uniform float\t\tsigma_s2;\n    uniform float\t\tsigma_pos2;\n    uniform float\t\tsigma_nor2;\n    uniform float\t\tsigma_alb2;\n    out     vec4\t\tf_color;\n\n    void main(void) {\n        vec3  color = vec3(0.0, 0.0, 0.0);\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n\n        vec3 colRef      = texelFetch(u_tex, coordsFrag, 0).xyz;\n        vec3 edge_posRef = texelFetch(u_edge_pos, coordsFrag, 0).xyz;\n        vec3 edge_norRef = texelFetch(u_edge_nor, coordsFrag, 0).xyz;\n        vec3 edge_albRef = texelFetch(u_edge_alb, coordsFrag, 0).xyz;\n\n        float weight = 0.0;\n        float shifter = texture2D(u_rand, gl_FragCoord.xy, 0).x;\n\n        for(int i = 0; i < nSamples; i++) {\n            //Coordinates\n            ivec3 coords = texelFetch(u_poisson, ivec2(i, shifter), 0).xyz;\n            //pos difference\n            vec3 tmpEdge = texelFetch(u_edge_pos, coordsFrag.xy + coords.xy, 0).xyz;\n            vec3 tmpEdge2 = tmpEdge - edge_posRef;\n            float dstPos = dot(tmpEdge2.xyz, tmpEdge2.xyz);\n            //nor difference\n            tmpEdge = texelFetch(u_edge_nor, coordsFrag.xy + coords.xy, 0).xyz;\n            float dstNor = 1.0 - abs(dot(tmpEdge, edge_norRef));\n            //alb difference\n            tmpEdge = texelFetch(u_edge_alb, coordsFrag.xy + coords.xy, 0).xyz;\n            tmpEdge2 = tmpEdge - edge_albRef;\n            float dstAlb = dot(tmpEdge2.xyz, tmpEdge2.xyz);\n\n            float tmp = dstPos / sigma_pos2 + dstAlb / sigma_alb2 + float(coords.z) / sigma_s2 + dstNor / sigma_nor2 ;\n            tmp = exp(-tmp);\n            //Texture Fetch\n            vec3 tmpCol = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0).xyz;\n            color.xyz += tmpCol * tmp;\n            weight += tmp;\n        }\n\n        f_color = vec4(weight > 0.0 ? color / weight : colRef, 1.0);\n    }\n                                        );\n\n}\n\nPIC_INLINE void FilterGLBilateral2DSE::initShaders()\n{\n#ifdef PIC_DEBUG\n    printf(\"Number of samples: %d\\n\", ms->nSamples);\n#endif\n\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLBilateral2DSE\");\n\n    update(-1.0f, -1.0f, -1.0f, -1.0f);\n}\n\nPIC_INLINE void FilterGLBilateral2DSE::update(float sigma_s, float sigma_p, float sigma_n, float sigma_a)\n{\n\n    bool flag = false;\n\n    if(sigma_s > 0.0f) {\n        flag = (this->sigma_s == sigma_s);\n        this->sigma_s = sigma_s;\n    }\n\n    if(sigma_p > 0.0f) {\n        flag = flag || (this->sigma_p == sigma_p);\n        this->sigma_p = sigma_p;\n    }\n\n    if(sigma_n > 0.0f) {\n        flag = flag || (this->sigma_n == sigma_n);\n        this->sigma_n = sigma_n;\n    }\n\n    if(sigma_a > 0.0f) {\n        flag = flag || (this->sigma_a == sigma_a);\n        this->sigma_a = sigma_a;\n    }\n\n    int kernelSize = PrecomputedGaussian::getKernelSize(this->sigma_s);\n    int halfKernelSize = kernelSize >> 1;\n\n    if(flag) {\n        Vec2i window = Vec2i(halfKernelSize, halfKernelSize);\n        ms->updateGL(window, halfKernelSize);\n    }\n    \n    //shader update\n    float sigmas2 = 2.0f * this->sigma_s * this->sigma_s;\n    float sigmap2 = 2.0f * this->sigma_p * this->sigma_p;\n    float sigman2 = 2.0f * this->sigma_n * this->sigma_n;\n    float sigmaa2 = 2.0f * this->sigma_a * this->sigma_a;\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\",     0);\n    technique.setUniform1i(\"u_poisson\",  1);\n    technique.setUniform1i(\"u_rand\",\t2);\n\n    technique.setUniform1i(\"u_edge_pos\",  3);\n    technique.setUniform1i(\"u_edge_nor\",  4);\n    technique.setUniform1i(\"u_edge_alb\",  5);\n\n    technique.setUniform1i(\"kernelSize\", kernelSize);\n    technique.setUniform1f(\"kernelSizef\", float(kernelSize));\n    technique.setUniform1f(\"sigma_s2\", sigmas2);\n    technique.setUniform1f(\"sigma_pos2\", sigmap2);\n    technique.setUniform1f(\"sigma_nor2\", sigman2);\n    technique.setUniform1f(\"sigma_alb2\", sigmaa2);\n    technique.setUniform1i(\"nSamples\", ms->nSamples >> 1);\n    technique.unbind();\n}\n\nPIC_INLINE ImageGL *FilterGLBilateral2DSE::Process(ImageGLVec imgIn,\n        ImageGL *imgOut)\n{\n    if(imgIn[0] == NULL) {\n        return imgOut;\n    }\n\n    int w = imgIn[0]->width;\n    int h = imgIn[0]->height;\n\n    //TODO: check if other have height and frames swapped\n    if(imgOut == NULL) {\n        imgOut = new ImageGL(imgIn[0]->frames, w, h, imgIn[0]->channels, IMG_GPU, GL_TEXTURE_2D);\n    }\n\n    if(fbo == NULL) {\n        fbo = new Fbo();\n    }\n\n    fbo->create(w, h, imgIn[0]->frames, false, imgOut->getTexture());\n\n    ImageGL *base     = imgIn[0];\n    ImageGL *edge_pos = imgIn[1];\n    ImageGL *edge_nor = imgIn[2];\n    ImageGL *edge_alb = imgIn[3];\n\n    //Rendering\n    fbo->bind();\n    glViewport(0, 0, (GLsizei)w, (GLsizei)h);\n\n    //Shaders\n    technique.bind();\n\n    //Textures\n    glActiveTexture(GL_TEXTURE5);\n    glBindTexture(GL_TEXTURE_2D, edge_alb->getTexture());\n\n    glActiveTexture(GL_TEXTURE4);\n    glBindTexture(GL_TEXTURE_2D, edge_nor->getTexture());\n\n    glActiveTexture(GL_TEXTURE3);\n    glBindTexture(GL_TEXTURE_2D, edge_pos->getTexture());\n\n    glActiveTexture(GL_TEXTURE2);\n    glBindTexture(GL_TEXTURE_2D, imageRand->getTexture());\n\n    glActiveTexture(GL_TEXTURE1);\n    glBindTexture(GL_TEXTURE_2D, ms->getTexture());\n\n    glActiveTexture(GL_TEXTURE0);\n    glBindTexture(GL_TEXTURE_2D, base->getTexture());\n\n    //Rendering aligned quad\n    quad->Render();\n\n    //Fbo\n    fbo->unbind();\n\n    //Shaders\n    technique.unbind();\n\n    //Textures\n    glActiveTexture(GL_TEXTURE5);\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    glActiveTexture(GL_TEXTURE4);\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    glActiveTexture(GL_TEXTURE3);\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    glActiveTexture(GL_TEXTURE2);\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    glActiveTexture(GL_TEXTURE1);\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    glActiveTexture(GL_TEXTURE0);\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    return imgOut;\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_BILATERAL_2DS_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_bilateral_2dsp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_BILATERAL_2DSP_HPP\n#define PIC_GL_FILTERING_FILTER_BILATERAL_2DSP_HPP\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/filtering/filter_bilateral_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLBilateral2DSP class provides\n * an approximated 2D bilateral filter using two\n * 1D bilateral filtes; i.e. using the separable\n * approximation.\n */\nclass FilterGLBilateral2DSP: public FilterGLNPasses\n{\nprotected:\n    FilterGLBilateral1D *filter;\n\npublic:\n    /**\n     * @brief FilterGLBilateral2DSP\n     */\n    FilterGLBilateral2DSP();\n\n    /**\n     * @brief FilterGLBilateral2DSP\n     * @param sigma_s\n     * @param sigma_r\n     */\n    FilterGLBilateral2DSP(float sigma_s, float sigma_r);\n\n    ~FilterGLBilateral2DSP();\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux()\n    {\n       delete_s(filter);\n    }\n\n    /**\n    * @brief update\n    * @param sigma_s\n    * @param sigma_r\n    */\n    void update(float sigma_s, float sigma_r);\n\n    /**\n     * @brief execute\n     * @param nameIn\n     * @param nameOut\n     * @param sigma_s\n     * @param sigma_r\n     * @param testing\n     * @return\n     */\n    static ImageGL *execute(std::string nameIn, std::string nameOut,\n                               float sigma_s, float sigma_r, int testing)\n    {\n        GLuint testTQ = glBeginTimeQuery();\n        glEndTimeQuery(testTQ);\n\n        ImageGL imgIn(nameIn);\n        imgIn.generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n\n        FilterGLBilateral2DSP filter(sigma_s, sigma_r);\n        ImageGL *imgRet = new ImageGL(1, imgIn.width, imgIn.height, 3, IMG_GPU, GL_TEXTURE_2D);\n\n        GLuint testTQ1;\n\n        if(testing > 1) {\n            filter.Process(SingleGL(&imgIn), imgRet);\n\n            testTQ1 = glBeginTimeQuery();\n\n            for(int i = 0; i < testing; i++) {\n                filter.Process(SingleGL(&imgIn), imgRet);\n            }\n        } else {\n            testTQ1 = glBeginTimeQuery();\n            filter.Process(SingleGL(&imgIn), imgRet);\n        }\n\n        GLuint64EXT timeVal = glEndTimeQuery(testTQ1);\n        double ms = double(timeVal) / (double(testing) * 1000000.0);\n        printf(\"Separate Bilateral Filter on GPU time: %f ms\\n\", ms);\n\n        std::string sign = genBilString(\"S\", sigma_s, sigma_r);\n        std::string nameTime = FileLister::getFileNumber(sign, \"txt\");\n\n        FILE *file = fopen(nameTime.c_str(), \"w\");\n\n        if(file != NULL) {\n            fprintf(file, \"%f\", ms);\n            fclose(file);\n        }\n\n        ImageGL *imgWrite = new ImageGL(1, imgIn.width, imgIn.height, 4, IMG_CPU, GL_TEXTURE_2D);\n        imgWrite->readFromFBO(filter.getFbo());\n        imgWrite->Write(nameOut);\n        return imgRet;\n    }\n};\n\nPIC_INLINE FilterGLBilateral2DSP::FilterGLBilateral2DSP(): FilterGLNPasses()\n{\n    target = GL_TEXTURE_2D;\n\n    filter = new FilterGLBilateral1D(1.0f, 0.01f, 0, GL_TEXTURE_2D);\n    insertFilter(filter);\n    insertFilter(filter);\n}\n\nPIC_INLINE FilterGLBilateral2DSP::FilterGLBilateral2DSP(float sigma_s,\n        float sigma_r): FilterGLNPasses()\n{\n    target = GL_TEXTURE_2D;\n\n    filter = new FilterGLBilateral1D(sigma_s, sigma_r, 0, GL_TEXTURE_2D);\n    insertFilter(filter);\n    insertFilter(filter);\n}\n\nPIC_INLINE FilterGLBilateral2DSP::~FilterGLBilateral2DSP()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLBilateral2DSP::update(float sigma_s, float sigma_r)\n{\n    filter->update(sigma_s, sigma_r);\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_BILATERAL_2DSP_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_bilateral_3ds.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_BILATERAL_3DS_HPP\n#define PIC_GL_FILTERING_FILTER_BILATERAL_3DS_HPP\n\n#include \"../../base.hpp\"\n#include \"../../util/vec.hpp\"\n#include \"../../util/std_util.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLBilateral3DS class\n */\nclass FilterGLBilateral3DS: public FilterGL\n{\nprotected:\n    float sigma_s, sigma_r, sigma_t;\n    float sigmas2, sigmar2, sigmat2;\n    int\t  frame, kernelSizeTime;\n    MRSamplersGL<3> *ms;\n\n    //Random numbers tile\n    ImageGL *imageRand;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\npublic:\n\n    /**\n     * @brief FilterGLBilateral3DS\n     * @param sigma_s\n     * @param sigma_r\n     * @param sigma_t\n     */\n    FilterGLBilateral3DS(float sigma_s, float sigma_r, float sigma_t);\n\n    ~FilterGLBilateral3DS();\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_r\n     * @param sigma_t\n     */\n    void update(float sigma_s, float sigma_r, float sigma_t);\n\n    /**\n     * @brief setUniform\n     */\n    void setUniform();\n\n    /**\n     * @brief setFrame\n     * @param frame\n     */\n    void setFrame(int frame)\n    {\n        this->frame = frame;\n    }\n\n    /**\n     * @brief nextFrame\n     */\n    void nextFrame()\n    {\n        frame++;\n    }\n\n    /**\n     * @brief getFrame\n     * @return\n     */\n    int  getFrame()\n    {\n        return frame;\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *Process(ImageGLVec imgIn, ImageGL *imgOut);\n};\n\nPIC_INLINE FilterGLBilateral3DS::FilterGLBilateral3DS(float sigma_s, float sigma_r,\n        float sigma_t): FilterGL()\n{\n    //protected values are assigned/computed\n    this->sigma_s = sigma_s;\n    this->sigma_r = sigma_r;\n    this->sigma_t = sigma_t;\n\n    int nRand = 32;\n    imageRand = new ImageGL(1, 256, 256, 1, IMG_CPU, GL_TEXTURE_2D);\n    imageRand->setRand(1);\n    imageRand->generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n    *imageRand *= float(nRand - 1);\n\n    //Precomputation of the Gaussian Kernel\n    int kernelSizeSpace = PrecomputedGaussian::getKernelSize(sigma_s);\n    kernelSizeTime  = PrecomputedGaussian::getKernelSize(sigma_t);\n\n    int kernelSize = MAX(kernelSizeSpace, kernelSizeTime);\n    int halfKernelSize = kernelSize >> 1;\n    int halfKernelSizeTime = kernelSizeTime >> 1;\n\n    frame = halfKernelSizeTime;\n\n    //Poisson samples\n    Vec3i window = Vec3i(halfKernelSize, halfKernelSize, halfKernelSizeTime);\n    ms = new MRSamplersGL<3>(ST_BRIDSON, window, 2 * kernelSize, 1, nRand);\n    ms->generateTexture();\n\n#ifdef PIC_DEBUG\n    printf(\"Window Space: %d Window Time: %d\\n\", halfKernelSize,\n           halfKernelSizeTime);\n    printf(\"Nsamples: %d\\n\", ms->nSamples / 3);\n#endif\n\n    FragmentShader();\n    initShaders();\n}\n\nPIC_INLINE FilterGLBilateral3DS::~FilterGLBilateral3DS()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLBilateral3DS::FragmentShader()\n{\n    fragment_source = MAKE_STRING\n                      (\n                          uniform sampler2DArray  u_tex;\n//\t\tuniform sampler3D\t\tu_tex;\n                          uniform isampler2D\t\tu_poisson;\n                          uniform sampler2D\t\tu_rand;\n                          uniform int\t\t\tTOKEN_BANANA;\n                          uniform int\t\t\tframe;\n                          uniform float\t\t\tsigmas2;\n                          uniform float\t\t\tsigmar2;\n                          uniform float\t\t\tsigmat2;\n                          out     vec4\t\t\tf_color;\n\n    void main(void) {\n        vec3 tmpCol;\n        vec3  color = vec3(0.0, 0.0, 0.0);\n        ivec3 texSize = textureSize(u_tex, 0);\n        ivec3 coordsFrag = ivec3(gl_FragCoord.xy, frame % texSize.z);\n\n        vec3 colRef = texelFetch(u_tex, coordsFrag, 0).xyz;\n        float weight = 0.0;\n\n        for(int i = 0; i < TOKEN_BANANA; i++) {\n            //Coordinates\n            float shifter = texelFetch(u_rand, coordsFrag.xy % 128, 0).x;\n            ivec4 coords = texelFetch(u_poisson, ivec2(i, shifter), 0).xyzw;\n            //Texture fetch\n            ivec3 tmpCoords;\n            tmpCoords.xy = coords.xy + coordsFrag.xy;\n            tmpCoords.z = (frame + coords.z) % texSize.z;\n\n            tmpCol = texelFetch(u_tex, tmpCoords, 0).xyz;\n            vec3 tmpCol2 = tmpCol - colRef;\n            float dstR = dot(tmpCol2.xyz, tmpCol2.xyz);\n            float tmp = exp(-dstR / sigmar2 - float(coords.w) / sigmas2 - float(\n                                coords.z * coords.z) / sigmat2);\n            color.xyz += tmpCol * tmp;\n            weight += tmp;\n        }\n\n        f_color = vec4(weight > 0.0 ? (color / weight) : vec3(1.0), 1.0);\n    }\n                      );\n}\n\nPIC_INLINE void FilterGLBilateral3DS::initShaders()\n{\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLBilateral3DS\");\n\n    sigmas2 = 2.0f * sigma_s * sigma_s;\n    sigmat2 = 2.0f * sigma_t * sigma_t;\n    sigmar2 = 2.0f * sigma_r * sigma_r;\n    setUniform();\n}\n\nPIC_INLINE void FilterGLBilateral3DS::update(float sigma_s, float sigma_r, float sigma_t)\n{\n\n    bool flag = false;\n\n    if(sigma_s > 0.0f) {\n        flag = (this->sigma_s == sigma_s);\n        this->sigma_s = sigma_s;\n    }\n\n    if(sigma_r > 0.0f) {\n        flag = flag || (this->sigma_r == sigma_r);\n        this->sigma_r = sigma_r;\n    }\n\n    if(sigma_t > 0.0f) {\n        flag = flag || (this->sigma_t == sigma_t);\n        this->sigma_t = sigma_t;\n    }\n\n    if(!flag) {\n    }\n\n    int kernelSize = PrecomputedGaussian::getKernelSize(this->sigma_s);\n    int halfKernelSize = kernelSize >> 1;\n\n    Vec3i window = Vec3i(halfKernelSize, halfKernelSize, halfKernelSize);\n    ms->updateGL(window, halfKernelSize);\n\n    //shader update\n    sigmas2 = 2.0f * this->sigma_s * this->sigma_s;\n    sigmat2 = 2.0f * this->sigma_t *this->sigma_t;\n    sigmar2 = 2.0f * this->sigma_r * this->sigma_r;\n\n    setUniform();\n}\n\nPIC_INLINE void FilterGLBilateral3DS::setUniform()\n{\n    technique.bind();\n    technique.setUniform1i(\"u_tex\",      0);\n    technique.setUniform1i(\"u_poisson\",  1);\n    technique.setUniform1i(\"u_rand\",\t 2);\n\n    technique.setUniform1f(\"sigmas2\",  sigmas2);\n    technique.setUniform1f(\"sigmat2\",  sigmat2);\n    technique.setUniform1f(\"sigmar2\",  sigmar2);\n    technique.setUniform1i(\"TOKEN_BANANA\",  ms->nSamples / 3);\n    technique.setUniform1i(\"frame\",  frame);\n\n    technique.unbind();\n}\n\nPIC_INLINE ImageGL *FilterGLBilateral3DS::Process(ImageGLVec imgIn,\n        ImageGL *imgOut)\n{\n    if(imgIn[0] == NULL) {\n        return imgOut;\n    }\n\n    int w = imgIn[0]->width;\n    int h = imgIn[0]->height;\n\n    if(imgOut == NULL) {\n        imgOut = new ImageGL(1, w, h, imgIn[0]->channels, IMG_GPU, imgIn[0]->getTarget());\n    }\n\n    if(fbo == NULL) {\n        fbo = new Fbo();\n        fbo->create(w, h, 1, false, imgOut->getTexture());\n    }\n\n    ImageGL *base = imgIn[0];\n\n    //Rendering\n    fbo->bind();\n    glViewport(0, 0, (GLsizei)w, (GLsizei)h);\n\n    //Shaders\n    technique.bind();\n\n    //Textures\n    glActiveTexture(GL_TEXTURE2);\n    imageRand->bindTexture();\n\n    glActiveTexture(GL_TEXTURE1);\n    glBindTexture(GL_TEXTURE_2D, ms->getTexture());\n\n    glActiveTexture(GL_TEXTURE0);\n    base->bindTexture();\n\n    //Rendering aligned quad\n    quad->Render();\n\n    //Fbo\n    fbo->unbind();\n\n    //Shaders\n    technique.unbind();\n\n    //Textures\n    glActiveTexture(GL_TEXTURE2);\n    imageRand->unBindTexture();\n\n    glActiveTexture(GL_TEXTURE1);\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    glActiveTexture(GL_TEXTURE0);\n    base->unBindTexture();\n\n    return imgOut;\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_BILATERAL_3DS_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_bilateral_3dsp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_BILATERAL_3DSP_HPP\n#define PIC_GL_FILTERING_FILTER_BILATERAL_3DSP_HPP\n\n#include \"../../base.hpp\"\n#include \"../../util/std_util.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLBilateral3DSP class\n */\nclass FilterGLBilateral3DSP: public FilterGLNPasses\n{\nprotected:\n    FilterGLBilateral1D *filterS;\n    FilterGLBilateral1D *filterT;\n\npublic:\n    /**\n     * @brief FilterGLBilateral3DSP\n     */\n    FilterGLBilateral3DSP();\n\n    /**\n     * @brief FilterGLBilateral3DSP\n     * @param sigma_s\n     * @param sigma_r\n     * @param sigma_t\n     */\n    FilterGLBilateral3DSP(float sigma_s, float sigma_r, float sigma_t);\n\n    ~FilterGLBilateral3DSP();\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux()\n    {\n        delete_s(filterS);\n        delete_s(filterT);\n    }\n\n    /**\n     * @brief setFrame\n     * @param frame\n     */\n    void setFrame(int frame)\n    {\n        filterS->setSlice(frame);\n        filterT->setSlice(frame);\n    }\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_r\n     * @param sigma_t\n     */\n    void update(float sigma_s,  float sigma_r, float sigma_t);\n\n    /**\n     * @brief execute\n     * @param nameIn\n     * @param nameOut\n     * @param sigma_s\n     * @param sigma_r\n     * @param sigma_t\n     * @return\n     */\n    static ImageGL *execute(std::string nameIn, std::string nameOut,\n                               float sigma_s, float sigma_r, float sigma_t)\n    {\n        return NULL;\n    }\n};\n\nPIC_INLINE FilterGLBilateral3DSP::FilterGLBilateral3DSP(): FilterGLNPasses()\n{\n    target = GL_TEXTURE_2D_ARRAY;\n    filterS = filterT = NULL;\n}\n\nPIC_INLINE FilterGLBilateral3DSP::~FilterGLBilateral3DSP()\n{\n    release();\n}\n\nPIC_INLINE FilterGLBilateral3DSP::FilterGLBilateral3DSP(float sigma_s, float sigma_r,\n        float sigma_t): FilterGLNPasses()\n{\n    target = GL_TEXTURE_2D_ARRAY;\n    filterS = new FilterGLBilateral1D(sigma_s, sigma_r, 0, target);\n    filterT = new FilterGLBilateral1D(sigma_t, sigma_r, 0, target);\n\n    insertFilter(filterS);\n    insertFilter(filterS);\n    insertFilter(filterT);\n}\n\nPIC_INLINE void FilterGLBilateral3DSP::update(float sigma_s, float sigma_r, float sigma_t)\n{\n    filterS->update(sigma_s, sigma_r);\n    filterT->update(sigma_t, sigma_r);\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_BILATERAL_3DSP_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_blend.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_BLEND_HPP\n#define PIC_GL_FILTERING_FILTER_BLEND_HPP\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLBlend class\n */\nclass FilterGLBlend: public FilterGL\n{\nprotected:\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        fragment_source = MAKE_STRING\n                          (\n                              uniform sampler2D u_tex0; \\n\n                              uniform sampler2D u_tex1; \\n\n                              uniform sampler2D u_texMask; \\n\n                              out vec4      f_color;\t\\n\n\n        void main(void) {\n            \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy);\\n\n            vec4  color0 = texelFetch(u_tex0, coords, 0);\\n\n            vec4  color1 = texelFetch(u_tex1, coords, 0);\\n\n            float weight = texelFetch(u_texMask, coords, 0).x;\\n\n            f_color = mix(color0, color1, weight);\n        }\\n\n                          );\n\n        technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLBlend\");\n\n        technique.bind();\n        technique.setUniform1i(\"u_tex0\", 0);\n        technique.setUniform1i(\"u_tex1\", 1);\n        technique.setUniform1i(\"u_texMask\", 2);\n        technique.unbind();\n    }\n\npublic:\n\n    /**\n     * @brief FilterGLBlend\n     */\n    FilterGLBlend() : FilterGL()\n    {\n        //protected values are assigned/computed\n        initShaders();\n    }\n\n    ~FilterGLBlend()\n    {\n        release();\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_BLEND_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_channel.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_CHANNEL_HPP\n#define PIC_GL_FILTERING_FILTER_CHANNEL_HPP\n\n#include \"../../base.hpp\"\n#include \"../../util/math.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLChannel class\n */\nclass FilterGLChannel: public FilterGL\n{\nprotected:\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        fragment_source = MAKE_STRING\n                          (\n        uniform sampler2D u_tex; \\n\n        uniform int channel; \\n\n        out     vec4 f_color; \\n\n        \\n\n        void main(void) {\n            \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n            vec4 color = texelFetch(u_tex, coords, 0); \\n\n            float v = color[channel]; \\n\n            f_color = vec4(v, v, v, 1.0); \\n\n\n        }\n                          );\n\n        technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLChannel\");\n    }\n\n    int channel;\n\npublic:\n\n    /**\n     * @brief FilterGLChannel\n     * @param channel\n     */\n    FilterGLChannel(int channel) : FilterGL()\n    {\n        initShaders();\n        update(channel);\n    }\n\n    ~FilterGLChannel()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param channel\n     */\n    void update(int channel)\n    {\n        this->channel = CLAMP(channel, 4);\n\n        if(technique.isValid()) {\n            technique.bind();\n            technique.setUniform1i(\"u_tex\", 0);\n            technique.setUniform1i(\"channel\", channel);\n            technique.unbind();\n        }\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageGLVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = 1;\n        frames      = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param channel\n     * @return\n     */\n    static ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut, int channel = 0)\n    {\n        FilterGLChannel flt(channel);\n        return flt.Process(SingleGL(imgIn), imgOut);\n    }\n\n    /**\n     * @brief Test\n     */\n    static void Test()\n    {\n        ImageGL imgIn(1, 512, 512, 3, IMG_GPU_CPU, GL_TEXTURE_2D);\n\n        for(auto i = 0; i < imgIn.size(); i += 3) {\n            imgIn.data[i    ] = 1.0f;\n            imgIn.data[i + 1] = 0.5f;\n            imgIn.data[i + 2] = 0.25f;\n        }\n\n        imgIn.generateTextureGL();\n\n        FilterGLChannel filter(0);\n        ImageGL *outR = filter.Process(SingleGL(&imgIn), NULL);\n\n        filter.update(1);\n        ImageGL *outG = filter.Process(SingleGL(&imgIn), NULL);\n\n        filter.update(2);\n        ImageGL *outB = filter.Process(SingleGL(&imgIn), NULL);\n\n        outR->loadToMemory();\n        outR->Write(\"channel_R.bmp\");\n        outG->loadToMemory();\n        outG->Write(\"channel_G.bmp\");\n        outB->loadToMemory();\n        outB->Write(\"channel_B.bmp\");\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_CHANNEL_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_color_conv.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_COLOR_CONV_HPP\n#define PIC_GL_FILTERING_FILTER_COLOR_CONV_HPP\n\n#include \"../../base.hpp\"\n#include \"../../util/std_util.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLColorConv class\n */\nclass FilterGLColorConv: public FilterGL\n{\nprotected:\n\n    ColorConvGL *color_conv;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        color_conv->generatePrograms(vertex_source);\n    }\n\npublic:\n    /**\n     * @brief FilterGLColorConv\n     */\n    FilterGLColorConv(ColorConvGL *color_conv, bool direct) : FilterGL()\n    {\n        this->color_conv = color_conv;\n\n        initShaders();\n        setup(direct);\n    }\n\n    ~FilterGLColorConv()\n    {\n        release();\n    }\n\n    void releaseAux()\n    {\n        delete_s(color_conv);\n    }\n\n    /**\n     * @brief setup\n     * @param direct\n     */\n    void setup(bool direct)\n    {\n        color_conv->setTransform(direct);\n        color_conv->setUniforms();\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageGLVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width    = imgIn[0]->width;\n        height   = imgIn[0]->height;\n        channels = 3;\n        frames   = imgIn[0]->frames;\n    }\n\n    void bindTechnique()\n    {\n        color_conv->bindProgram();\n    }\n\n    void unbindTechnique()\n    {\n        color_conv->unbindProgram();\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_COLOR_CONV_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_color_correction_pouli.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_COLOR_CORRECTION_POULI_HPP\n#define PIC_GL_FILTERING_FILTER_COLOR_CORRECTION_POULI_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../colors/color_conv_rgb_to_lms.hpp\"\n#include \"../../colors/color_conv_lms_to_ipt.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../gl/filtering/filter_luminance.hpp\"\n#include \"../../filtering/filter_color_correction_pouli.hpp\"\nnamespace pic {\n\n/**\n * @brief The FilterGLColorCorrectionPouli class\n */\nclass FilterGLColorCorrectionPouli: public FilterGL\n{\nprotected:\n    bool bGammaCorrection;\n\n    float mtx_RGBtoLMS[9], mtx_RGBtoLMS_inv[9];\n    float mtx_LMStoIPT[9], mtx_LMStoIPT_inv[9];\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        FragmentShader();\n        technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLColorCorrectionPouli\");\n    }\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader()\n    {\n        fragment_source = MAKE_STRING\n                          (\n        uniform sampler2D u_hdr;\\n\n        uniform sampler2D u_tmo;\\n\n        uniform float mHDR;\\n\n        uniform float mTMO;\\n\n        uniform mat3 mRGBtoLMS;\\n\n        uniform mat3 mLMStoIPT;\\n\n        uniform mat3 mRGBtoLMS_inv;\\n\n        uniform mat3 mLMStoIPT_inv;\\n\n\n        out     vec4  f_color;\\n\n\n        vec3 ccRGBtoICh(vec3 col, vec3 g)\n        {\n            vec3 LMS = mRGBtoLMS * col;\n\n            vec3 s = sign(LMS);\n            vec3 LMSp = pow(abs(LMS), g) * s;\n\n            vec3 IPT = mLMStoIPT * LMSp;\n\n            vec3 ICh;\n            ICh.x = IPT.x;\n            ICh.y = sqrt(dot(IPT.yz, IPT.yz));\n            ICh.z = atan(IPT.y, IPT.z);\n            return ICh;\n        }\n\n        vec3 ccIChtoRGB(vec3 col, vec3 g)\n        {\n            vec3 IPT;\n            IPT.x = col.x;\n            IPT.y = col.y * sin(col.z);\n            IPT.z = col.y * cos(col.z);\n\n            vec3 LMSp = mLMStoIPT_inv * IPT;\n\n            vec3 s = sign(LMSp);\n            vec3 LMS = pow(abs(LMSp), g) * s;\n\n            vec3 rgb = mRGBtoLMS_inv * LMS;\n            return rgb;\n        }\n\n        float saturation(float C, float I)\n        {\n            return C / sqrt(C * C + I * I);\n        }\n\n        void main(void) {\n            \\n\n            ivec2 coords   = ivec2(gl_FragCoord.xy);\\n\n            vec3 cHDR    = texelFetch(u_hdr, coords, 0).xyz / mHDR;\\n\n            vec3 cTMO    = texelFetch(u_tmo, coords, 0).xyz / mTMO;\\n\n            vec3 ICh_hdr =  ccRGBtoICh(cHDR, vec3(0.43));\\n\n            vec3 ICh_tmo =  ccRGBtoICh(cTMO, vec3(0.43));\\n\n\n            float I_tmo = ICh_tmo.x;\\n\n            ICh_hdr.xy += vec2(1e-5);\\n\n            ICh_tmo.xy += vec2(1e-5);\\n\n\n            float C_tmo_p = (ICh_tmo.y * ICh_hdr.x) / ICh_tmo.x;\\n\n            float s1 = saturation(ICh_hdr.y, ICh_hdr.x);\\n\n            float s2 = saturation(C_tmo_p, ICh_tmo.x);\\n\n            ICh_tmo.y = I_tmo;\\n\n            ICh_tmo.y = (C_tmo_p * s1) / s2;\\n\n            ICh_tmo.z = ICh_hdr.z;\\n\n            vec3 col = ccIChtoRGB(ICh_tmo, vec3(2.3256));\\n\n            col = clamp(col * mTMO, vec3(0.0), vec3(1.0));\\n\n            f_color = vec4(col, 1.0);\\n\n        }\\n\n                          );\n\n    }\n\npublic:\n    /**\n     * @brief FilterGLColorCorrectionPouli\n     */\n    FilterGLColorCorrectionPouli() : FilterGL()\n    {\n        ColorConvRGBtoLMS RGBtoLMS;\n        ColorConvLMStoIPT LMStoIPT;\n\n        memcpy(mtx_RGBtoLMS, RGBtoLMS.getMatrix(), 9 * sizeof(float));\n        memcpy(mtx_RGBtoLMS_inv, RGBtoLMS.getMatrixInverse(), 9 * sizeof(float));\n        memcpy(mtx_LMStoIPT, LMStoIPT.getMatrix(), 9 * sizeof(float));\n        memcpy(mtx_LMStoIPT_inv, LMStoIPT.getMatrixInverse(), 9 * sizeof(float));\n\n        initShaders();\n\n        update(1.0f, 1.0f);\n    }\n\n    ~FilterGLColorCorrectionPouli()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param Ld_Max\n     * @param b\n     * @param LMax\n     * @param Lwa\n     */\n    void update(float mHDR, float mTMO)\n    {\n        technique.bind();\n        technique.setUniform1i(\"u_hdr\", 0);\n        technique.setUniform1i(\"u_tmo\", 1);\n\n        technique.setUniform1f(\"mHDR\", mHDR);\n        technique.setUniform1f(\"mTMO\", mTMO);\n\n        technique.setUniform3x3(\"mRGBtoLMS\", mtx_RGBtoLMS, true);\n        technique.setUniform3x3(\"mLMStoIPT\", mtx_LMStoIPT, true);\n        technique.setUniform3x3(\"mRGBtoLMS_inv\", mtx_RGBtoLMS_inv, true);\n        technique.setUniform3x3(\"mLMStoIPT_inv\", mtx_LMStoIPT_inv, true);\n\n        technique.unbind();\n    }\n\n    static ImageGL *execute(FilterGLColorCorrectionPouli *flt,\n                            ImageGL *imgHDR, ImageGL *imgTMO, ImageGL *imgOut)\n    {\n        if(imgHDR == NULL || imgTMO == NULL) {\n            return imgOut;\n        }\n\n        if(imgHDR->channels != 3 || imgTMO->channels != 3) {\n            return imgOut;\n        }\n\n        float mHDR[3], mTMO[3];\n\n        imgHDR->getMaxVal(mHDR);\n        imgTMO->getMaxVal(mTMO);\n\n        int ind;\n        float maxHDR = Arrayf::getMax(mHDR, 3, ind);\n        float maxTMO = Arrayf::getMax(mTMO, 3, ind);\n        printf(\"%f %f\", maxHDR, maxTMO);\n\n        if(maxHDR > 0.0f && maxTMO > 0.0f) {\n            printf(\"AAA\");\n            flt->update(maxHDR, maxTMO);\n            imgOut = flt->Process(DoubleGL(imgHDR, imgTMO), imgOut);\n        }\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_COLOR_CORRECTION_POULI_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_conv_1d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_CONV_1D_HPP\n#define PIC_GL_FILTERING_FILTER_CONV_1D_HPP\n\n#include \"../../base.hpp\"\n#include \"../../gl/filtering/filter_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLConv1D class\n */\nclass FilterGLConv1D: public FilterGL1D\n{\nprotected:\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\npublic:\n\n    /**\n     * @brief FilterGLConv1D\n     */\n    FilterGLConv1D();\n\n    /**\n     * @brief FilterGLConv1D\n     * @param weights\n     * @param direction\n     * @param target\n     */\n    FilterGLConv1D(ImageGL *weights, int direction, GLenum target);\n\n    ~FilterGLConv1D();\n\n    /**\n     * @brief setUniformAux\n     * @return\n     */\n    void setUniformAux()\n    {\n        int kernelSize = 0;\n        int halfKernelSize = 0;\n\n        if(weights != NULL) {\n            kernelSize = weights->width;\n            halfKernelSize = kernelSize >> 1;\n        }\n\n        technique.setUniform1i(\"u_weights\", 1);\n        technique.setUniform1i(\"halfKernelSize\", halfKernelSize);\n        technique.setUniform1i(\"kernelSize\", kernelSize);\n    }\n};\n\nPIC_INLINE FilterGLConv1D::FilterGLConv1D(ImageGL *weights, int direction,\n                                       GLenum target): FilterGL1D(direction, target)\n{\n    this->weights = weights;\n\n    FragmentShader();\n    initShaders();\n}\n\nPIC_INLINE FilterGLConv1D::~FilterGLConv1D()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLConv1D::FragmentShader()\n{\n    std::string fragment_source_2D = MAKE_STRING\n                                     (\n                                         uniform sampler2D u_tex;\n                                         uniform sampler2D u_weights;\n                                         uniform int       iX;\n                                         uniform int       iY;\n                                         uniform int       halfKernelSize;\n                                         uniform int       kernelSize;\n                                         out    vec4       f_color;\n\n    void main(void) {\n        vec4  color = vec4(0.0);\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n        vec4 tmpCol;\n        float weight = 0.0;\n\n        for(int i = 0; i < kernelSize; i++) {\n            //Coordinates\n            int j = i - halfKernelSize;\n            ivec2 coords = ivec2(j * iX, j * iY);\n            //Texture fetch\n            tmpCol = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0);\n            //Weight\n            float tmp = texelFetch(u_weights, ivec2(i, 0), 0).x;\n            color  += tmpCol * tmp;\n            weight += tmp;\n        }\n\n        f_color = vec4(color / weight);\n    }\n                                     );\n\n    std::string fragment_source_3D = MAKE_STRING\n                                     (\n                                         uniform sampler3D  u_tex;\n                                         uniform sampler2D  u_weights;\n                                         uniform int        slice;\n                                         uniform int        iX;\n                                         uniform int        iY;\n                                         uniform int        iZ;\n                                         uniform int        halfKernelSize;\n                                         uniform int        kernelSize;\n                                         out     vec4       f_color;\n\n    void main(void) {\n        vec4  color = vec4(0.0);\n        ivec3 coordsFrag = ivec3(ivec2(gl_FragCoord.xy), slice);\n        vec4 tmpCol;\n        float weight = 0.0;\n\n        for(int i = 0; i < kernelSize; i++) {\n            //Coordinates\n            int j = i - halfKernelSize;\n            ivec3 coords = coordsFrag.xyz + ivec3(j * iX, j * iY, j * iZ);\n            //Texture fetch\n            tmpCol = texelFetch(u_tex, coords.xyz, 0);\n            //Weight\n            float tmp = texelFetch(u_weights, ivec2(i, 0), 0).x;\n            color += tmpCol * tmp;\n            weight += tmp;\n        }\n\n        f_color = vec4(color / weight);\n    }\n                                     );\n\n    switch(target) {\n    case GL_TEXTURE_2D: {\n        fragment_source = fragment_source_2D;\n    }\n    break;\n\n    case GL_TEXTURE_3D: {\n        fragment_source = fragment_source_3D;\n    }\n    break;\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_CONV_1D_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_conv_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_CONV_2D_HPP\n#define PIC_GL_FILTERING_FILTER_CONV_2D_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLConv2D class\n */\nclass FilterGLConv2D: public FilterGL\n{\nprotected:\n\n    GLenum target;\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\npublic:\n\n    /**\n     * @brief FilterGLConv2D\n     * @param target\n     */\n    FilterGLConv2D(GLenum target);\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief setUniform\n     * @return\n     */\n    void setUniform()\n    {\n        technique.bind();\n        technique.setUniform1i(\"u_tex\", 0);\n        technique.setUniform1i(\"u_weights\", 1);\n\n        if(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) {\n           // technique.setUniform(\"slice\", slice);\n        }\n\n        technique.unbind();\n    }\n};\n\nPIC_INLINE FilterGLConv2D::FilterGLConv2D(GLenum target): FilterGL()\n{\n    this->target = target;\n\n    FragmentShader();\n    initShaders();\n}\n\nPIC_INLINE void FilterGLConv2D::initShaders()\n{\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLConv2D\");\n\n    setUniform();\n}\n\nPIC_INLINE void FilterGLConv2D::FragmentShader()\n{\n    std::string fragment_source_2D = MAKE_STRING\n                                     (\n                                         uniform sampler2D u_tex;\n                                         uniform sampler2D u_weights;\n                                         out     vec4      f_color;\n\n    void main(void) {\n        ivec2 kernelSize = textureSize(u_weights, 0);\n        ivec2 halfKernelSize = kernelSize >> 1;\n\n        ivec2 shift = ivec2(halfKernelSize.x, halfKernelSize.y);\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy) - shift;\n\n        vec4  color = vec4(0.0);\n\n        for(int i = 0; i < kernelSize.y; i++) {\n\n            for(int j = 0; j < kernelSize.x; j++) {\n                //do a texture fetch\n                vec4 tmpCol = texelFetch(u_tex, coordsFrag.xy + ivec2(j, i), 0);\n\n                //weight\n                color += tmpCol * texelFetch(u_weights, ivec2(j, i), 0);\n            }\n        }\n\n        f_color = color;\n    }\n                                     );\n\n    switch(target) {\n    case GL_TEXTURE_2D: {\n        fragment_source = fragment_source_2D;\n    }\n    break;\n\n    case GL_TEXTURE_3D: {\n        //fragment_source = fragment_source_3D;\n    }\n    break;\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_CONV_2D_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_deform_grid.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_DEFORM_GRID_HPP\n#define PIC_GL_FILTERING_FILTER_DEFORM_GRID_HPP\n\n#include \"../../base.hpp\"\n#include \"../../util/std_util.hpp\"\n#include \"../../util/gl/bicubic.hpp\"\n#include \"../../image_samplers/image_sampler_bicubic.hpp\"\n#include \"../../filtering/filter_deform_grid.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLDeformGrid class\n */\nclass FilterGLDeformGrid: public FilterGL\n{\nprotected:\n    ImageSamplerBicubic isb;\n\n    Image *grid_rest, *grid_move, grid_diff;\n    ImageGL *grid_diff_gl;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\npublic:\n    /**\n     * @brief FilterGLDeformGrid\n     */\n    FilterGLDeformGrid(Image *grid_move);\n\n    ~FilterGLDeformGrid();\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux();\n\n    /**\n     * @brief update\n     * @param type\n     */\n    void update(Image *grid_move);\n\n    /**\n     * @brief getCoordinatesAfterTransform\n     * @param x is normalized in [0,1]\n     * @param y is normalized in [0,1]\n     * @param xOut\n     * @param yOut\n     */\n    void getCoordinatesAfterTransform(float x, float y, float &xOut, float &yOut)\n    {\n        float vDiff[3];\n        isb.SampleImage(&grid_diff, x, y, vDiff);\n\n        xOut = x + vDiff[0];\n        yOut = y + vDiff[1];\n    }\n};\n\nPIC_INLINE FilterGLDeformGrid::FilterGLDeformGrid(Image *grid_move): FilterGL()\n{\n    this->grid_rest = FilterDeformGrid::getUniformGrid(grid_move->width, grid_move->height);\n    this->grid_move = grid_move;\n\n    grid_diff = *grid_rest - *grid_move;\n\n    grid_diff_gl = new ImageGL(&grid_diff, true);\n    grid_diff_gl->generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n    param.push_back(grid_diff_gl);\n\n    initShaders();\n}\n\nPIC_INLINE FilterGLDeformGrid::~FilterGLDeformGrid()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLDeformGrid::releaseAux()\n{\n    grid_rest = delete_s(grid_rest);\n    grid_diff_gl = delete_s(grid_diff_gl);\n}\n\nPIC_INLINE void FilterGLDeformGrid::initShaders()\n{\n    fragment_source  = GLSL_BICUBIC();\n    fragment_source += GLSL_TEXTURE_BICUBIC();\n\n    fragment_source += MAKE_STRING\n                      (\n    uniform sampler2D u_tex; \\n\n    uniform sampler2D u_grid; \\n\n    out     vec4 f_color; \\n\n    \\n\n\n    void main(void) {\n        vec2 tSize = vec2(textureSize(u_tex, 0));\n        vec2 coords = gl_FragCoord.xy / tSize.xy; \\n\n\n        vec2 shifts = textureBicubic(u_grid, coords.xy).xy;\n        f_color = texture(u_tex, coords + shifts.xy);\n    }\n                      );\n\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLDeformGrid\");\n\n    update(NULL);\n}\n\nPIC_INLINE void FilterGLDeformGrid::update(Image *grid_move)\n{\n    if(grid_move != NULL) {\n\n        this->grid_move = grid_move;\n\n        grid_diff = *grid_rest;\n        grid_diff -= *this->grid_move;\n\n        grid_diff_gl->loadFromMemory();\n    }\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.setUniform1i(\"u_grid\", 1);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_DEFORM_GRID_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_disp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_DISP_HPP\n#define PIC_GL_FILTERING_FILTER_DISP_HPP\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n#define DEBUG_GL\n\n/**\n * @brief The FilterGLDisp class\n */\nclass FilterGLDisp: public FilterGL\n{\nprotected:\n\n    float sigma;\n    float sigma_s;\n    float sigma_r;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\npublic:\n\n    /**\n     * @brief FilterGLDisp\n     */\n    FilterGLDisp();\n\n    /**\n     * @brief update\n     * @param sigma\n     * @param sigma_s\n     * @param sigma_r\n     * @param bUse\n     * @param bLeft\n     */\n    void update(float sigma, float sigma_s, float sigma_r, bool bUse, bool bLeft);\n\n    /**\n     * @brief execute\n     * @param nameLeft\n     * @param nameRight\n     * @param nameDisp\n     * @param nameOut\n     * @return\n     */\n    static ImageGL *execute(std::string nameLeft,\n                               std::string nameRight,\n                               std::string nameDisp,\n                               std::string nameOut)\n    {\n        ImageGL imgL(nameLeft);\n        ImageGL imgR(nameRight);\n        ImageGL imgD(nameDisp);\n\n        imgL.generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n        imgR.generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n        imgD.generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n\n        FilterGLDisp filter;\n\n        ImageGL *imgOut = filter.Process(TripleGL(&imgL, &imgR, &imgD), NULL);\n        imgOut->loadToMemory();\n        imgOut->Write(nameOut);\n        return imgOut;\n    }\n};\n\nPIC_INLINE FilterGLDisp::FilterGLDisp(): FilterGL()\n{\n    sigma = 2.0f;\n    sigma_s = 2.0f;\n    sigma_r = 0.05f;\n    initShaders();\n}\n\nPIC_INLINE void FilterGLDisp::initShaders()\n{\n    fragment_source = MAKE_STRING\n                      (\n                          uniform sampler2D u_texL; \\n\n                          uniform sampler2D u_texR; \\n\n                          uniform sampler2D u_texD; \\n\n                          uniform int halfKernelSize; \\n\n                          uniform float\tsigma; \\n\n                          uniform float\tsigma_s2; \\n\n                          uniform float\tsigma_r2; \\n\n                          uniform float\tbUse; \\n\n                          uniform float bLeft; \\n\n                          out     vec4 f_color; \\n\n\n    vec4 fetchDispCol(ivec2 coords) {\n        float shiftf = texelFetch(u_texD, coords, 0).x;\n\n        if(shiftf > 1e-3) {\n            coords.x += int(shiftf);\n            vec3  col_R = texelFetch(u_texR, coords, 0).xyz;\n            return vec4(col_R, shiftf);\n        } else {\n            return vec4(0.0);\n        }\n    }\n\n    /*\t(x --> disp)\n    \t(y --> mask)\n    \t(z --> score)\t*/\n\n    void main(void) {\n        \\n\n        f_color = vec4(0.0);\n        ivec2 coords = ivec2(gl_FragCoord.xy);\n        \\n\n        vec2 delta;\n        vec3 acc = vec3(0.0);\n        float tot = 0.0;\n        vec3 refDisp = texelFetch(u_texD, coords, 0).xyz;\n        vec3 refCol = texelFetch(u_texL, coords, 0).xyz;\n\n        for(int i = -halfKernelSize; i <= halfKernelSize; i++) {\n            delta.y = float(i);\n\n            for(int j = -halfKernelSize; j <= halfKernelSize; j++) {\n                delta.x = float(j);\n\n                //Color fetch\n                ivec2 tmpCoords = coords + ivec2(j, i);\n                vec3  tmpCol = texelFetch(u_texL, tmpCoords, 0).xyz;\n\n                //Disparity fetch\n                vec3  tmpDisp = texelFetch(u_texD, tmpCoords, 0).xyz;\n                tmpCoords.x += int(bLeft * tmpDisp.x);\n                vec3  tmpCol2 = texelFetch(u_texR, tmpCoords, 0).xyz;\n\n                //Spatial weight\n                float ws = exp(-dot(delta, delta) / sigma_s2);\n\n                //Disparity weight\n                float deltaDisp = tmpDisp.x - refDisp.x;\n                float wd = exp(-deltaDisp * deltaDisp / sigma_r2);\n\n                //Other pixels: color similarity\n                vec3 diffCol = tmpCol - refCol;\n                float wc = exp(-dot(diffCol, diffCol) / sigma);\n\n                if(bUse < 0.5f) {\n                    wc = 1.0f;\n                }\n\n                //((tmpDisp.z+1e-6)*sigma/tmpDisp.y))*bUse;\n\n                //Weights\n                float w = wd * ws;\n                tot += w * wc;\n                acc += tmpCol * w * wc;\n                /*\t\t\t\t\tacc += (tmpCol+tmpCol2*wc)*w;\n                \t\t\t\t\ttot += (1.0+wc)*w;*/\n            }\n        }\n\n        acc /= tot;\n        f_color = vec4(acc, 1.0);\n    }\n                      );\n\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLDisp\");\n\n    float sigma_s2 = 2.0f * sigma_s * sigma_s;\n    float sigma_r2 = 2.0f * sigma_r * sigma_r;\n    int halfKernelSize = PrecomputedGaussian::getKernelSize(sigma_s) >> 1;\n\n    technique.bind();\n    technique.setUniform1f(\"sigma_s2\", sigma_s2);\n    technique.setUniform1f(\"sigma_r2\", sigma_r2);\n    technique.setUniform1f(\"sigma\", sigma * sigma * 2.0f);\n    technique.setUniform1i(\"halfKernelSize\", halfKernelSize);\n    technique.setUniform1f(\"bUse\", 1.0f);\n    technique.setUniform1f(\"bLeft\", -1.0f);\n\n    technique.setUniform1i(\"u_texL\", 0);\n    technique.setUniform1i(\"u_texR\", 1);\n    technique.setUniform1i(\"u_texD\", 2);\n    technique.unbind();\n}\n\nPIC_INLINE void FilterGLDisp::update(float sigma, float sigma_s, float sigma_r, bool bUse,\n                          bool bLeft)\n{\n    this->sigma = sigma;\n    this->sigma_r = sigma_r;\n    this->sigma_s = sigma_s;\n\n    int halfKernelSize = PrecomputedGaussian::getKernelSize(sigma_s) >> 1;\n\n    float sigma_s2 = 2.0f * sigma_s * sigma_s;\n    float sigma_r2 = 2.0f * sigma_r * sigma_r;\n\n    technique.bind();\n    technique.setUniform1i(\"u_texL\",      0);\n    technique.setUniform1i(\"u_texR\",      1);\n    technique.setUniform1i(\"u_texD\",      2);\n    technique.setUniform1f(\"sigma_s2\",\tsigma_s2);\n    technique.setUniform1f(\"sigma_r2\",\tsigma_r2);\n\n    if(bUse) {\n        technique.setUniform1f(\"bUse\", 1.0f);\n    } else {\n        technique.setUniform1f(\"bUse\", 0.0f);\n    }\n\n    if(bLeft) {\n        technique.setUniform1f(\"bLeft\", 1.0f);\n    } else {\n        technique.setUniform1f(\"bLeft\", -1.0f);\n    }\n\n    technique.setUniform1f(\"sigma\", sigma * sigma * 2.0f);\n    technique.setUniform1i(\"halfKernelSize\", halfKernelSize);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_DISP_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_down_pp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_DOWN_PP_HPP\n#define PIC_GL_FILTERING_FILTER_DOWN_PP_HPP\n\n#include \"../../gl/filtering/filter.hpp\"\n\n#include \"../../util/array.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLDownPP class\n */\nclass FilterGLDownPP: public FilterGL\n{\nprotected:\n\n    float threshold, *value;\n    int channels;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        fragment_source = MAKE_STRING\n                          (\n                              uniform sampler2D u_tex; \\n\n                              uniform vec4    value; \\n\n                              uniform float   threshold; \\n\n                              out     vec4    f_color; \\n\n\n        void main(void) { \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy) * ivec2(2); \\n\n            vec3 color[4]; \\n\n            color[0] = texelFetch(u_tex, coords              , 0).xyz; \\n\n            color[1] = texelFetch(u_tex, coords + ivec2(1, 0), 0).xyz; \\n\n            color[2] = texelFetch(u_tex, coords + ivec2(0, 1), 0).xyz; \\n\n            color[3] = texelFetch(u_tex, coords + ivec2(1, 1), 0).xyz; \\n\n\n            int counter = 0;\n            vec3 ret = vec3(0.0);\n\n            for(int i = 0; i < 4; i++) {\n                if(distance(color[i], value.xyz) > threshold) {\n                    ret += color[i];\n                    counter++;\n                }\n            }\n\n            if(counter > 0) {\n                ret /= vec3(counter);\n            } else {\n                ret = value.xyz;\n            }\n\n            f_color = vec4(ret.xyz, 1.0); \\n\n        }\n                          );\n\n        technique.init(\"330\", vertex_source, fragment_source);\n\n    #ifdef PIC_DEBUG\n        technique.printLog(\"FilterGLDownPP\");\n    #endif\n\n        technique.bind();\n        technique.setAttributeIndex(\"a_position\", 0);\n        technique.setOutputFragmentShaderIndex(\"f_color\", 0);\n        technique.link();\n        technique.unbind();\n    }\n\npublic:\n    /**\n     * @brief FilterGLDownPP\n     * @param scale\n     */\n    FilterGLDownPP(float *value, float threshold) : FilterGL()\n    {\n        initShaders();\n        update(value, threshold);\n    }\n\n    ~FilterGLDownPP()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param value\n     * @param threshold\n     */\n    void update(float *value, float threshold)\n    {\n        if(value == NULL) {\n            printf(\"ERROR in FilterGLDownPP\");\n        }\n\n        this->value = value;\n\n        this->threshold = (threshold > 0.0f) ? threshold : 1e-6f;\n\n        technique.bind();\n        technique.setUniform1i(\"u_tex\", 0);\n        technique.setUniform1f(\"threshold\", this->threshold);\n        technique.setUniform4fv(\"value\", this->value);\n        technique.unbind();\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageGLVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        if(imgIn.size() == 1) {\n            width = imgIn[0]->width >> 1;\n            height = imgIn[0]->height >> 1;\n        } else {\n            width = imgIn[1]->width;\n            height = imgIn[1]->height;\n        }\n\n        channels = imgIn[0]->channels;\n        frames = imgIn[0]->frames;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_DOWN_PP_HPP */\n"
  },
  {
    "path": "include/gl/filtering/filter_drago_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_DRAGO_TMO_HPP\n#define PIC_GL_FILTERING_FILTER_DRAGO_TMO_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../gl/filtering/filter_luminance.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLDragoTMO class\n */\nclass FilterGLDragoTMO: public FilterGL\n{\nprotected:\n    float b, Ld_Max, LMax, LMax_scaled, Lwa, Lwa_scaled;\n    float constant1, constant2;\n    bool bGammaCorrection;\n\n    /**\n     * @brief computeConstants\n     */\n    void computeConstants();\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\npublic:\n    /**\n     * @brief FilterGLDragoTMO\n     */\n    FilterGLDragoTMO();\n\n    ~FilterGLDragoTMO();\n\n    /**\n     * @brief update\n     * @param Ld_Max\n     * @param b\n     * @param LMax\n     * @param Lwa\n     */\n    void update(float Ld_Max, float b, float LMax, float Lwa);\n};\n\nPIC_INLINE FilterGLDragoTMO::FilterGLDragoTMO(): FilterGL()\n{\n    Ld_Max\t=  100.0f;\n    b\t\t=  0.95f;\n    LMax\t=  1e6f;\n    Lwa\t\t= -1.0f;\n\n    bGammaCorrection = false;\n\n    FragmentShader();\n    initShaders();\n}\n\nPIC_INLINE FilterGLDragoTMO::~FilterGLDragoTMO()\n{\n    release();\n}\n\n\nPIC_INLINE void FilterGLDragoTMO::FragmentShader()\n{\n    fragment_source = MAKE_STRING\n                      (\n    uniform sampler2D u_tex;\\n\n    uniform float constant1;\\n\n    uniform float constant2;\\n\n    uniform float LMax;\\n\n    uniform float Lwa;\\n\n    out     vec4  f_color;\\n\n\n    void main(void) {\n        \\n\n        ivec2 coords   = ivec2(gl_FragCoord.xy);\\n\n        vec3  color    = texelFetch(u_tex, coords, 0).xyz;\\n\n        float L        = dot(vec3(0.213, 0.715, 0.072), color);\n        float L_scaled = L / Lwa;\\n\n        float tmp      = pow((L_scaled / LMax), constant1);\\n\n        float Ld       = constant2 * log(1.0 + L_scaled) / log(2.0 + 8.0 * tmp);\\n\n        color\t\t   = (color * Ld) / L;\\n\n        __GAMMA__CORRECTION__ \\n\n        f_color        = vec4(color, 1.0);\\n\n        \\n\n    }\\n\n                      );\n\n    fragment_source = gammaCorrection(fragment_source, bGammaCorrection);\n}\n\nPIC_INLINE void FilterGLDragoTMO::initShaders()\n{\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLDragoTMO\");\n    update(Ld_Max, b, LMax, Lwa);\n}\n\nPIC_INLINE void FilterGLDragoTMO::update(float Ld_Max, float b, float LMax, float Lwa)\n{\n    this->Ld_Max = Ld_Max > 0.0f ? Ld_Max : 100.0f;\n    this->b = b > 0.0f ? b : 0.95f;\n    this->LMax = LMax > 0.0f ? LMax : 1e6f;\n    this->Lwa = Lwa > 0.0f ? Lwa : 1.0f;\n\n    Lwa_scaled  = Lwa / powf(1.0f + b - 0.85f, 5.0f);\n    LMax_scaled = LMax / Lwa_scaled;\n    constant1   = logf(b) / logf(0.5f);\n    constant2   = (Ld_Max / 100.0f) / (log10(1 + LMax_scaled));\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.setUniform1f(\"constant1\", constant1);\n    technique.setUniform1f(\"constant2\", constant2);\n    technique.setUniform1f(\"LMax\", LMax_scaled);\n    technique.setUniform1f(\"Lwa\", Lwa_scaled);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_DRAGO_TMO_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_durand_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_DURAND_TMO_HPP\n#define PIC_GL_FILTERING_FILTER_DURAND_TMO_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../gl/filtering/filter_luminance.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLDurandTMO class\n */\nclass FilterGLDurandTMO: public FilterGL\n{\nprotected:\n    float compression_factor, log_absolute;\n    bool bGammaCorrection;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\npublic:\n\n    /**\n     * @brief FilterGLDurandTMO\n     */\n    FilterGLDurandTMO();\n\n    /**\n     * @brief FilterGLDurandTMO\n     * @param compression_factor\n     * @param log_absolute\n     * @param bGammaCorrection\n     */\n    FilterGLDurandTMO(float compression_factor, float log_absolute,\n                     bool bGammaCorrection);\n\n    ~FilterGLDurandTMO();\n\n    /**\n     * @brief update\n     * @param compression_factor\n     * @param log_absolute\n     */\n    void update(float compression_factor, float log_absolute);\n};\n\nPIC_INLINE FilterGLDurandTMO::FilterGLDurandTMO() : FilterGL()\n{\n    this->compression_factor = log10fPlusEpsilon(5.0f);\n    this->log_absolute = this->compression_factor * 6.0f;\n\n    this->bGammaCorrection = false;\n\n    FragmentShader();\n    initShaders();\n}\n\nPIC_INLINE FilterGLDurandTMO::FilterGLDurandTMO(float compression_factor, float log_absolute,\n                                   bool bGammaCorrection = false): FilterGL()\n{\n    this->bGammaCorrection = bGammaCorrection;\n\n    FragmentShader();\n    initShaders();\n\n    update(compression_factor, log_absolute);\n}\n\nPIC_INLINE FilterGLDurandTMO::~FilterGLDurandTMO()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLDurandTMO::FragmentShader()\n{\n    fragment_source = MAKE_STRING\n                      (\n    uniform sampler2D u_tex;        \\n\n    uniform sampler2D u_lum_log;    \\n\n    uniform sampler2D u_base;       \\n\n    uniform float     compression_factor;\\n\n    uniform float     log_absolute;\\n\n    out     vec4      f_color;\t\\n\n\n    void main(void) {\\n\n        \\n\n        ivec2 coords = ivec2(gl_FragCoord.xy);\\n\n        vec3 color = texelFetch(u_tex, coords, 0).xyz;\\n\n        float L = dot(vec3(0.213, 0.715, 0.072), color);\\n\n        float L_log  = texelFetch(u_lum_log, coords, 0).x;\\n\n        float base = texelFetch(u_base, coords, 0).x;\\n\n        float detail = L_log - base;\\n\n        float L_comp = (base * compression_factor + detail) -  log_absolute;\\n\n        L_comp = pow(10.0, L_comp);\\n\n        color = (color * L_comp / L);\\n\n        __GAMMA__CORRECTION__ \\n\n        f_color = vec4(color, 1.0);\\n\n        \\n\n    }\\n\n                      );\n\n    fragment_source = gammaCorrection(fragment_source, bGammaCorrection);\n}\n\nPIC_INLINE void FilterGLDurandTMO::initShaders()\n{\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLDurandTMO\");\n}\n\nPIC_INLINE void FilterGLDurandTMO::update(float compression_factor, float log_absolute)\n{\n    this->compression_factor = compression_factor;\n    this->log_absolute = log_absolute;\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.setUniform1i(\"u_lum_log\", 1);\n    technique.setUniform1i(\"u_base\", 2);\n    technique.setUniform1f(\"compression_factor\", compression_factor);\n    technique.setUniform1f(\"log_absolute\", log_absolute);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_DURAND_TMO_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_exposure_fusion_weights.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_EXPOSURE_FUSION_WEIGHTS_HPP\n#define PIC_GL_FILTERING_FILTER_EXPOSURE_FUSION_WEIGHTS_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLExposureFusionWeights class\n */\nclass FilterGLExposureFusionWeights: public FilterGL\n{\nprotected:\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\n    float sigma_sq_2, mu;\n    float wC, wE, wS;\n\npublic:\n\n    /**\n     * @brief FilterGLExposureFusionWeights\n     * @param wC\n     * @param wE\n     * @param wS\n     */\n    FilterGLExposureFusionWeights(float wC = 1.0f, float wE = 1.0f, float wS = 1.0f) : FilterGL()\n    {\n        float sigma = 0.2f;\n        mu = 0.5f;\n        sigma_sq_2 = 2.0f * sigma * sigma;\n\n        this->wC = wC >= 0.0f ? wC : 1.0f;\n        this->wE = wE >= 0.0f ? wE : 1.0f;\n        this->wS = wS >= 0.0f ? wS : 1.0f;\n\n        //protected values are assigned/computed\n        initShaders();\n    }\n\n    ~FilterGLExposureFusionWeights()\n    {\n        release();\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageGLVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width    = imgIn[0]->width;\n        height   = imgIn[0]->height;\n        channels = 1;\n        frames   = imgIn[0]->frames;\n    }\n};\n\nPIC_INLINE void FilterGLExposureFusionWeights::FragmentShader()\n{\n    fragment_source = MAKE_STRING\n                      (\n                          uniform sampler2D u_tex; \\n\n                          uniform sampler2D u_tex_lum; \\n\n                          uniform float wC;   \\n\n                          uniform float wE;   \\n\n                          uniform float wS;   \\n\n                          uniform float sigma_sq_2; \\n\n                          uniform float mu; \\n\n                          out vec4      f_color;\t\\n\n\n    void main(void) {\n        \\n\n        ivec2 coords = ivec2(gl_FragCoord.xy);\\n\n\n        //saturation weight\n        vec3 color = texelFetch(u_tex, coords, 0).xyz;\\n\n        float tmpMu = dot(color.xyz, vec3(1.0)) / 3.0;\\n\n        vec3 tmpVar = color - vec3(tmpMu);\\n\n        float pSat = sqrt( dot(tmpVar, tmpVar) / 3.0);\\n\n        pSat = pow(pSat, wS);\\n\n\n        //well-exposedness weight\n        vec3 delta = color - vec3(mu);\\n\n        float pExp = exp(-dot(delta, delta) / sigma_sq_2);\\n\n        pExp = pow(pExp, wE);\\n\n\n        //contrast weight\n        float pCon = -4.0 * texelFetch(u_tex_lum, coords, 0).x+\n                     texelFetch(u_tex_lum, coords + ivec2(1, 0), 0).x+\\n\n                     texelFetch(u_tex_lum, coords - ivec2(1, 0), 0).x+\\n\n                     texelFetch(u_tex_lum, coords + ivec2(0, 1), 0).x+\\n\n                     texelFetch(u_tex_lum, coords - ivec2(0, 1), 0).x;\\n\n        pCon = pow(abs(pCon), wC);\\n\n\n        f_color = vec4(vec3(pCon * pExp * pSat + 1e-12), 1.0);\\n\n    }\\n\n                      );\n}\n\nPIC_INLINE void FilterGLExposureFusionWeights::initShaders()\n{\n    FragmentShader();\n\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLExposureFusionWeights\");\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex_lum\", 0);\n    technique.setUniform1i(\"u_tex\", 1);\n    technique.setUniform1f(\"wC\", wC);\n    technique.setUniform1f(\"wE\", wE);\n    technique.setUniform1f(\"wS\", wS);\n    technique.setUniform1f(\"mu\", mu);\n    technique.setUniform1f(\"sigma_sq_2\", sigma_sq_2);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_EXPOSURE_FUSION_WEIGHTS_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_from_stroke_to_mask.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_FROM_STROKE_TO_MASK_HPP\n#define PIC_GL_FILTERING_FILTER_FROM_STROKE_TO_MASK_HPP\n\n#include \"../../base.hpp\"\n#include \"../../filtering/filter_luminance.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLFromStrokeToMask class\n */\nclass FilterGLFromStrokeToMask: public FilterGL\n{\nprotected:\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\npublic:\n    /**\n     * @brief FilterGLFromStrokeToMask\n     */\n    FilterGLFromStrokeToMask();\n\n    /**\n     * @brief FilterGLFromStrokeToMask\n     */\n    FilterGLFromStrokeToMask(LUMINANCE_TYPE type);\n\n    ~FilterGLFromStrokeToMask();\n\n    /**\n     * @brief update\n     * @param type\n     */\n    void update(LUMINANCE_TYPE type);\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut)\n    {\n        FilterGLFromStrokeToMask filter(LT_CIE_LUMINANCE);\n        imgOut = filter.Process(SingleGL(imgIn), imgOut);\n        return imgOut;\n    }\n};\n\nPIC_INLINE FilterGLFromStrokeToMask::FilterGLFromStrokeToMask(): FilterGL()\n{\n    this->type = LT_CIE_LUMINANCE;\n\n    initShaders();\n}\n\nPIC_INLINE FilterGLFromStrokeToMask::FilterGLFromStrokeToMask(LUMINANCE_TYPE type): FilterGL()\n{\n    this->type = type;\n\n    initShaders();\n}\n\nPIC_INLINE FilterGLFromStrokeToMask::~FilterGLFromStrokeToMask()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLFromStrokeToMask::initShaders()\n{\n    fragment_source = MAKE_STRING\n                      (\n    uniform sampler2D u_tex; \\n\n    uniform vec3 weights; \\n\n    out     vec4 f_color; \\n\n    \\n\n    void main(void) {\n        \\n\n        ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n        vec3 color = texelFetch(u_tex, coords, 0).xyz; \\n\n        float L = dot(color, weights); \\n\n        f_color = vec4(L, L, L, 1.0); \\n\n        \\n\n    }\n                      );\n\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLFromStrokeToMask\");\n\n    update(type);\n}\n\nPIC_INLINE void FilterGLFromStrokeToMask::update()\n{\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_FROM_STROKE_TO_MASK_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_gaussian_1d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_GAUSSIAN_1D_HPP\n#define PIC_GL_FILTERING_FILTER_GAUSSIAN_1D_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../util/precomputed_gaussian.hpp\"\n\n#include \"../../gl/filtering/filter_conv_1d.hpp\"\n\nnamespace pic {\n\nclass FilterGLGaussian1D: public FilterGLConv1D\n{\nprotected:\n    float sigma;\n    PrecomputedGaussian *pg;\n    bool bWeightsOwn;\n\npublic:\n\n    /**\n     * @brief FilterGLGaussian1D\n     * @param sigma\n     * @param direction\n     * @param target\n     */\n    FilterGLGaussian1D(float sigma, int direction, GLenum target);\n\n    ~FilterGLGaussian1D();\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux()\n    {\n        pg = delete_s(pg);\n\n        if(bWeightsOwn) {\n            weights = delete_s(weights);\n        }\n    }\n\n    /**\n     * @brief update\n     * @param sigma\n     */\n    void update(float sigma);\n\n    /**\n     * @brief execute\n     * @param nameIn\n     * @param nameOut\n     * @param sigma\n     * @return\n     */\n    static ImageGL *execute(std::string nameIn, std::string nameOut, float sigma)\n    {\n        ImageGL imgIn(nameIn);\n        imgIn.generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n\n        FilterGLGaussian1D filter(sigma, true, GL_TEXTURE_2D);\n\n        GLuint testTQ1 = glBeginTimeQuery();\n        ImageGL *imgOut = filter.Process(SingleGL(&imgIn), NULL);\n        GLuint64EXT timeVal = glEndTimeQuery(testTQ1);\n        printf(\"Gaussian 1D Filter on GPU time: %g ms\\n\",\n               double(timeVal) / 100000000.0);\n\n        imgOut->loadToMemory();\n        imgOut->Write(nameOut);\n        return imgOut;\n    }\n};\n\nPIC_INLINE FilterGLGaussian1D::FilterGLGaussian1D(float sigma, int direction = 0,\n                                       GLenum target = GL_TEXTURE_2D): FilterGLConv1D(NULL, direction, target)\n{\n    pg = NULL;\n    bWeightsOwn = false;\n    this->sigma = -1.0f;\n\n    update(sigma);\n}\n\nPIC_INLINE FilterGLGaussian1D::~FilterGLGaussian1D()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLGaussian1D::update(float sigma)\n{\n    bool bChanges = false;\n\n    if((this->sigma != sigma) && sigma > 0.0f) {\n        this->sigma = sigma;\n        bChanges = true;\n    }\n\n    if(pg != NULL) {\n        pg = delete_s(pg);\n    }\n\n    if(pg == NULL) {        \n        pg = new PrecomputedGaussian(this->sigma);\n    }\n\n    if(bChanges || weights == NULL) {\n        weights = delete_s(weights);\n\n        weights = new ImageGL(1, pg->kernelSize, 1, 1, pg->coeff);\n        weights->generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n        bWeightsOwn = true;\n    }\n    setUniform();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_GAUSSIAN_1D_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_gaussian_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_GAUSSIAN_2D_HPP\n#define PIC_GL_FILTERING_FILTER_GAUSSIAN_2D_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/filtering/filter_npasses.hpp\"\n#include \"../../gl/filtering/filter_gaussian_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLGaussian2D class\n */\nclass FilterGLGaussian2D: public FilterGLNPasses\n{\nprotected:\n    FilterGLGaussian1D *filter;\n\npublic:\n    /**\n     * @brief FilterGLGaussian2D\n     */\n    FilterGLGaussian2D() : FilterGLNPasses()\n    {\n        target = GL_TEXTURE_2D;\n\n        filter = new FilterGLGaussian1D(1.0f, 0, target);\n        insertFilter(filter);\n        insertFilter(filter);\n    }\n\n    /**\n     * @brief FilterGLGaussian2D\n     * @param sigma\n     */\n    FilterGLGaussian2D(float sigma)\n    {\n        target = GL_TEXTURE_2D;\n\n        filter = new FilterGLGaussian1D(sigma, 0, target);\n        insertFilter(filter);\n        insertFilter(filter);\n    }\n\n    ~FilterGLGaussian2D()\n    {\n        release();\n\n        delete_s(filter);\n    }\n\n    /**\n     * @brief update\n     * @param sigma\n     */\n    void update(float sigma)\n    {\n        filter->update(sigma);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_GAUSSIAN_2D_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_gaussian_3d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_GAUSSIAN_3D_HPP\n#define PIC_GL_FILTERING_FILTER_GAUSSIAN_3D_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/filtering/filter_npasses.hpp\"\n#include \"../../gl/filtering/filter_gaussian_1d.hpp\"\n\nnamespace pic {\n\nclass FilterGLGaussian3D: public FilterGLNPasses\n{\nprotected:\n    FilterGLGaussian1D *filter;\n\npublic:\n    /**\n     * @brief FilterGLGaussian3D\n     */\n    FilterGLGaussian3D() : FilterGLNPasses()\n    {\n        target = GL_TEXTURE_3D;\n    }\n\n    ~FilterGLGaussian3D()\n    {\n        release();\n\n        delete_s(filter);\n    }\n\n    /**\n     * @brief FilterGLGaussian3D\n     * @param sigma\n     */\n    FilterGLGaussian3D(float sigma) : FilterGLNPasses()\n    {\n        filter = new FilterGLGaussian1D(sigma, 0, GL_TEXTURE_3D);\n        target = GL_TEXTURE_3D;\n\n        insertFilter(filter);\n        insertFilter(filter);\n        insertFilter(filter);\n    }\n\n    /**\n     * @brief update\n     * @param sigma\n     */\n    void update(float sigma)\n    {\n        filter->update(sigma);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_GAUSSIAN_3D_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_gradient.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_GRADIENT_HPP\n#define PIC_GL_FILTERING_FILTER_GRADIENT_HPP\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLGradient class\n */\nclass FilterGLGradient: public FilterGL\n{\nprotected:\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        fragment_source = MAKE_STRING\n                          (\n                              uniform sampler2D u_tex; \\n\n                              out vec4      f_color;\t\\n\n\n        void main(void) {\n            \\n d\n            ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n            vec3  c0 = texelFetch(u_tex, coords + ivec2(1, 0), 0).xyz; \\n\n            vec3  c1 = texelFetch(u_tex, coords - ivec2(1, 0), 0).xyz; \\n\n            vec3  c2 = texelFetch(u_tex, coords + ivec2(0, 1), 0).xyz; \\n\n            vec3  c3 = texelFetch(u_tex, coords - ivec2(0, 1), 0).xyz; \\n\n            vec3 Gx = c1 - c0; \\n\n            vec3 Gy = c2 - c3; \\n\n            f_color = vec4(sqrt(Gx.xyz * Gx.xyz + Gy.xyz * Gy.xyz), 1.0);\\n d d\n        }\\n\n                          );\n\n        //\n        //\n        //\n\n        technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLGradient\");\n\n        technique.bind();\n        technique.setUniform1i(\"u_tex\", 0);\n        technique.unbind();\n    }\n\npublic:\n\n    /**\n     * @brief FilterGLGradient\n     */\n    FilterGLGradient() : FilterGL()\n    {\n        //protected values are assigned/computed\n        initShaders();\n    }\n\n    ~FilterGLGradient()\n    {\n        release();\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_GRADIENT_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_grow_cut.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_GROW_CUT_HPP\n#define PIC_GL_FILTERING_FILTER_GROW_CUT_HPP\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLGrowCut class\n */\nclass FilterGLGrowCut: public FilterGL\n{\nprotected:\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        fragment_source = MAKE_STRING\n                          (\n        uniform sampler2D u_tex; \\n\n        uniform sampler2D u_max; \\n\n        uniform sampler2D u_state_cur; \\n\n        const int dx[8] = int[](-1, 0, 1, -1, 1, -1,  0,  1); \\n\n        const int dy[8] = int[]( 1, 1, 1,  0, 0, -1, -1, -1); \\n\n        out  vec4 f_color; \\n\n        \\n\n        void main(void) { \\n\n            \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n            vec3 col = texelFetch(u_tex, coords, 0).xyz; \\n\n            vec2 cur = texelFetch(u_state_cur, coords, 0).xy; \\n\n            vec3 col_max = texelFetch(u_max, coords, 0).xyz; \\n\n            float C = dot(col_max, col_max); \\n\n            vec2 next = cur; \\n\n            \\n\n            for(int k = 0; k < 8; k++) {\\n\n                ivec2 coords_k = coords + ivec2(dx[k], dy[k]);\\n\n\n                vec2 cur_k = texelFetch(u_state_cur, coords_k, 0).xy; \\n\n                vec3 col_k = texelFetch(u_tex, coords_k, 0).xyz; \\n\n                vec3 delta_col = col - col_k;\\n\n                float g_theta = 1.0 - (dot(delta_col, delta_col) / C);\n                g_theta *= cur_k.y;\\n\n                if(g_theta > cur.y) {\\n\n                    next.x = cur_k.x;\\n\n                    next.y = g_theta;\\n\n                 }\\n\n            }\\n\n            f_color = vec4(next.x, next.y, 0.0, 1.0); \\n\n        }\n                          );\n\n        technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLGrowCut\");\n\n        update();\n    }\n\npublic:\n\n    /**\n     * @brief FilterGLGrowCut\n     * @param channel\n     */\n    FilterGLGrowCut() : FilterGL()\n    {\n        initShaders();\n    }\n\n    ~FilterGLGrowCut()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     */\n    void update()\n    {\n        technique.bind();\n        technique.setUniform1i(\"u_state_cur\", 0);\n        technique.setUniform1i(\"u_tex\", 1);\n        technique.setUniform1i(\"u_max\", 2);\n        technique.unbind();\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_GROW_CUT_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_hsl_replace.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_HSL_REPLACE_HPP\n#define PIC_GL_FILTERING_FILTER_HSL_REPLACE_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/colors/color_conv_rgb_to_hsl.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLHSLReplace class\n */\nclass FilterGLHSLReplace: public FilterGL\n{\nprotected:\n    float delta_hue, delta_saturation;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        fragment_source = MAKE_STRING\n                          (\n                              uniform float\t  delta_hue; \\n\n                              uniform float\t  delta_saturation; \\n\n                              uniform sampler2D u_tex; \\n\n                              uniform sampler2D u_change; \\n\n                              out     vec4      f_color; \\n\n\n        void main(void) {\n            \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy);\n            \\n\n            vec3  color = texelFetch(u_tex, coords, 0).xyz;\n            \\n\n            float weight = texelFetch(u_change, coords, 0).x;\n            weight = min(max(weight, 0.0), 1.0);\n\n            if(weight > 0.0) {\n                color = RGB2HSL(color);\n                \\n\n                color.x += delta_hue * weight;\n                \\n\n                color.z += max(delta_saturation * weight, 0.0);\n                \\n\n                color = HSL2RGB(color);\n                \\n\n            }\n\n            f_color = vec4(color.xyz, 1.0);\n            \\n\n        }\n                          );\n\n        //Final fragment source\n        std::string final_fragment_source;\n        final_fragment_source  = ColorConvGLRGBtoHSL::getDirect();\n        final_fragment_source += ColorConvGLRGBtoHSL::getInverse();\n        final_fragment_source += fragment_source;\n\n        technique.initStandard(\"330\", vertex_source, final_fragment_source, \"FilterGLGradient\");\n\n        technique.bind();\n        technique.setUniform1i(\"u_tex\",      0);\n        technique.setUniform1i(\"u_change\",   1);\n        technique.setUniform1f(\"delta_hue\",  delta_hue);\n        technique.setUniform1f(\"delta_saturation\",  delta_saturation);\n        technique.unbind();\n    }\n\npublic:\n    /**\n     * @brief FilterGLHSLReplace\n     * @param delta_hue\n     * @param delta_saturation\n     */\n    FilterGLHSLReplace(float delta_hue, float delta_saturation) : FilterGL()\n    {\n        this->delta_hue = delta_hue;\n        this->delta_saturation = delta_saturation;\n        initShaders();\n    }\n\n    ~FilterGLHSLReplace()\n    {\n        release();\n    }\n\n    /**\n     * @brief setDeltaHue\n     * @param delta_hue\n     */\n    void setDeltaHue(float delta_hue)\n    {\n        this->delta_hue = delta_hue;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_HSL_REPLACE_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_iterative.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_ITERATIVE_HPP\n#define PIC_GL_FILTERING_FILTER_ITERATIVE_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/gl/fbo.hpp\"\n\n#include \"../../gl/filtering/filter_npasses.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLIterative class\n */\nclass FilterGLIterative: public FilterGLNPasses\n{\nprotected:\n    int iterations;\n\n    /**\n     * @brief getFilter\n     * @param i\n     * @return\n     */\n    FilterGL* getFilter(int i);\n\n    /**\n     * @brief getFilter\n     * @param i\n     * @return\n     */\n    int getIterations();\n\npublic:\n\n    /**\n     * @brief FilterGLIterative\n     * @param flt\n     * @param iterations\n     */\n    FilterGLIterative(FilterGL *flt, int iterations);\n\n    ~FilterGLIterative();\n\n    /**\n     * @brief update\n     * @param flt\n     * @param iterations\n     */\n    void update(FilterGL *flt, int iterations);\n};\n\nPIC_INLINE FilterGLIterative::FilterGLIterative(FilterGL *flt, int iterations) : FilterGLNPasses()\n{\n    update(flt, iterations);\n}\n\nPIC_INLINE FilterGLIterative::~FilterGLIterative()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLIterative::update(FilterGL *flt, int iterations)\n{\n    if(iterations > 0) {\n        this->iterations = iterations;\n    }\n\n    if(flt == NULL) {\n        return;\n    }\n\n    if(!filters.empty()) {\n        filters.clear();\n    }\n\n    filters.push_back(flt);\n}\n\nPIC_INLINE FilterGL* FilterGLIterative::getFilter(int i)\n{\n    return filters[0];\n}\n\nPIC_INLINE int FilterGLIterative::getIterations()\n{\n    return iterations;\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_ITERATIVE_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_laplacian.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_LAPLACIAN_HPP\n#define PIC_GL_FILTERING_FILTER_LAPLACIAN_HPP\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLLaplacian class\n */\nclass FilterGLLaplacian: public FilterGL\n{\nprotected:\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        fragment_source = MAKE_STRING\n                          (\n                              uniform sampler2D u_tex; \\n\n                              out vec4      f_color;\t\\n\n\n        void main(void) {\n            \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy);\\n\n            vec3  color = -4.0 * texelFetch(u_tex, coords, 0).xyz;\\n\n            color += texelFetch(u_tex, coords + ivec2(1, 0), 0).xyz;\\n\n            color += texelFetch(u_tex, coords - ivec2(1, 0), 0).xyz;\\n\n            color += texelFetch(u_tex, coords + ivec2(0, 1), 0).xyz;\\n\n            color += texelFetch(u_tex, coords - ivec2(0, 1), 0).xyz;\\n\n            f_color = vec4(color, 1.0);\n        }\\n\n                          );\n\n        //\n        //\n        //\n\n        technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLLaplacian\");\n    }\n\npublic:\n\n    /**\n     * @brief FilterGLLaplacian\n     */\n    FilterGLLaplacian() : FilterGL()\n    {\n        //protected values are assigned/computed\n        initShaders();\n    }\n\n    ~FilterGLLaplacian()\n    {\n        release();\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_LAPLACIAN_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_luminance.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_LUMINANCE_HPP\n#define PIC_GL_FILTERING_FILTER_LUMINANCE_HPP\n\n#include \"../../base.hpp\"\n#include \"../../filtering/filter_luminance.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLLuminance class\n */\nclass FilterGLLuminance: public FilterGL\n{\nprotected:\n\n    LUMINANCE_TYPE type;\n    float weights[3];\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\npublic:\n\n    /**\n     * @brief FilterGLLuminance\n     */\n    FilterGLLuminance();\n\n    ~FilterGLLuminance()\n    {\n        release();\n    }\n\n    /**\n     * @brief FilterGLLuminance\n     */\n    FilterGLLuminance(LUMINANCE_TYPE type);\n\n    /**\n     * @brief update\n     * @param type\n     */\n    void update(LUMINANCE_TYPE type);\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut)\n    {\n        FilterGLLuminance filter(LT_CIE_LUMINANCE);\n        imgOut = filter.Process(SingleGL(imgIn), imgOut);\n        return imgOut;\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageGLVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        width       = imgIn[0]->width;\n        height      = imgIn[0]->height;\n        channels    = 1;\n        frames      = imgIn[0]->frames;\n    }\n};\n\nPIC_INLINE FilterGLLuminance::FilterGLLuminance(): FilterGL()\n{\n    this->type = LT_CIE_LUMINANCE;\n\n    initShaders();\n}\n\nPIC_INLINE FilterGLLuminance::FilterGLLuminance(LUMINANCE_TYPE type): FilterGL()\n{\n    this->type = type;\n\n    initShaders();\n}\n\nPIC_INLINE void FilterGLLuminance::initShaders()\n{\n    fragment_source = MAKE_STRING\n                      (\n    uniform sampler2D u_tex; \\n\n    uniform vec3 weights; \\n\n    out     vec4 f_color; \\n\n    void main(void) {\\n\n        ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n        vec3 color = texelFetch(u_tex, coords, 0).xyz; \\n\n        float L = dot(color, weights); \\n\n        f_color = vec4(L, L, L, 1.0); \\n\n    }\n    );\n\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLLuminance\");\n\n    update(type);\n}\n\nPIC_INLINE void FilterGLLuminance::update(LUMINANCE_TYPE type)\n{\n    this->type = type;\n\n    FilterLuminance::computeWeights(type, 3, weights);\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.setUniform3f(\"weights\", weights[0], weights[1], weights[2]);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_LUMINANCE_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_max.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_GL_MAX_HPP\n#define PIC_FILTERING_FILTER_GL_MAX_HPP\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/filtering/filter_npasses.hpp\"\n#include \"../../gl/filtering/filter_non_linear_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLMax class\n */\nclass FilterGLMax: public FilterGLNPasses\n{\nprotected:\n\nprotected:\n    FilterGLNonLinear1D *filter;\n    int kernelSize;\n\npublic:\n\n    /**\n     * @brief FilterMax\n     * @param kernelSize\n     */\n    FilterGLMax(int kernelSize) : FilterGLNPasses()\n    {\n        filter = new FilterGLNonLinear1D(kernelSize, \"max\", GL_TEXTURE_2D);\n\n        insertFilter(filter);\n        insertFilter(filter);\n    }\n\n    ~FilterGLMax()\n    {\n        release();\n        delete_s(filter);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param size\n     * @return\n     */\n    static ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut, int size)\n    {\n        FilterGLMax filter(size);\n        return filter.Process(SingleGL(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_GL_MAX_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_mean.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_GL_MEAN_HPP\n#define PIC_FILTERING_FILTER_GL_MEAN_HPP\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/filtering/filter_npasses.hpp\"\n#include \"../../gl/filtering/filter_conv_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLMean class\n */\nclass FilterGLMean: public FilterGLNPasses\n{\nprotected:\n\nprotected:\n    FilterGLConv1D *filter;\n    ImageGL *weights;\n    float *data;\n    int kernelSize;\n\npublic:\n\n    /**\n     * @brief FilterMean\n     * @param kernelSize\n     */\n    FilterGLMean(int kernelSize) : FilterGLNPasses()\n    {\n        data = NULL;\n        weights = NULL;\n        this->kernelSize = -1;\n\n        update(kernelSize);\n\n        filter = new FilterGLConv1D(weights, 0, GL_TEXTURE_2D);\n\n        insertFilter(filter);\n        insertFilter(filter);\n    }\n\n    ~FilterGLMean()\n    {\n        release();\n        delete_s(filter);\n        delete_vec_s(data);\n    }\n\n    /**\n     * @brief update\n     * @param size\n     */\n    void update(int kernelSize)\n    {\n        kernelSize = kernelSize > 0 ? kernelSize : 3;\n\n        if(this->kernelSize != kernelSize)\n        {\n            this->kernelSize = kernelSize;\n\n            data = delete_vec_s(data);\n            data = FilterConv1D::getKernelMean(kernelSize);\n        }\n\n        weights = delete_s(weights);\n\n        weights = new ImageGL(1, kernelSize, 1, 1, data);\n        weights->generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param kernelSize\n     * @return\n     */\n    static ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut, int kernelSize)\n    {\n        FilterGLMean filter(kernelSize);\n        return filter.Process(SingleGL(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_GL_MEAN_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_min.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_FILTERING_FILTER_GL_MIN_HPP\n#define PIC_FILTERING_FILTER_GL_MIN_HPP\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/filtering/filter_npasses.hpp\"\n#include \"../../gl/filtering/filter_non_linear_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLMin class\n */\nclass FilterGLMin: public FilterGLNPasses\n{\nprotected:\n\nprotected:\n    FilterGLNonLinear1D *filter;\n    int kernelSize;\n\npublic:\n\n    /**\n     * @brief FilterGLMin\n     * @param kernelSize\n     */\n    FilterGLMin(int kernelSize) : FilterGLNPasses()\n    {\n        filter = new FilterGLNonLinear1D(kernelSize, \"min\", GL_TEXTURE_2D);\n\n        insertFilter(filter);\n        insertFilter(filter);\n    }\n\n    ~FilterGLMin()\n    {\n        release();\n        delete_s(filter);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param kernelSize\n     * @return\n     */\n    static ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut, int kernelSize)\n    {\n        FilterGLMin filter(kernelSize);\n        return filter.Process(SingleGL(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_FILTERING_FILTER_GL_MIN_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_non_linear_1d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_NON_LINEAR_1D_HPP\n#define PIC_GL_FILTERING_FILTER_NON_LINEAR_1D_HPP\n\n#include \"../../gl/filtering/filter_1d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLNonLinear1D class\n */\nclass FilterGLNonLinear1D: public FilterGL1D\n{\nprotected:\n    int kernelSize, halfKernelSize;\n    std::string acc_operator;\n\n    /**\n     * @brief FragmentShader\n     * @param weights\n     * @param direction\n     * @param target\n     */\n    void FragmentShader(ImageGL *weights, int direction, GLenum target)\n    {\n        std::string fragment_source_2D = MAKE_STRING\n                                         (\n                                             uniform sampler2D\tu_tex;\n                                             uniform int        iX;\n                                             uniform int        iY;\n                                             uniform int        halfKernelSize;\n                                             uniform int        kernelSize;\n                                             out     vec4\tf_color;\n\n        void main(void) {\n            ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n            vec4 tmpCol;\n\n            //Texture fetch\n            ivec2 coords = ivec2(-halfKernelSize * iX, -halfKernelSize * iY);\n            vec4 color = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0);\n\n            for(int i = 1; i < kernelSize; i++) {\n                //Coordinates\n                int j = i - halfKernelSize;\n                ivec2 coords = ivec2(j * iX, j * iY);\n                //Texture fetch\n                tmpCol = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0);\n                color = _ACC_FUNCTION(color, tmpCol);\n            }\n\n            f_color = color;\n        }\n                                         );\n\n        std::string fragment_source_3D = MAKE_STRING\n                                         (\n                                             uniform sampler3D  u_tex;\n                                             uniform int        slice;\n                                             uniform int        iX;\n                                             uniform int        iY;\n                                             uniform int        iZ;\n                                             uniform int        halfKernelSize;\n                                             uniform int        kernelSize;\n                                             out     vec4       f_color;\n\n        void main(void) {\n            vec4  color = vec4(0.0);\n            ivec3 coordsFrag = ivec3(ivec2(gl_FragCoord.xy), slice);\n            vec4 tmpCol;\n\n            for(int i = 0; i < kernelSize; i++) {\n                //Coordinates\n                int j = i - halfKernelSize;\n                ivec3 coords = coordsFrag.xyz + ivec3(j * iX, j * iY, j * iZ);\n                //Texture fetch\n                tmpCol = texelFetch(u_tex, coords.xyz, 0);\n                color = _ACC_FUNCTION(color, tmpCol);\n            }\n\n            f_color = color;\n        }\n                                         );\n\n        switch(target) {\n        case GL_TEXTURE_2D: {\n            fragment_source = fragment_source_2D;\n        }\n        break;\n\n        case GL_TEXTURE_3D: {\n            fragment_source = fragment_source_3D;\n        }\n        break;\n        }\n\n        size_t I_found = fragment_source.find(\"_ACC_FUNCTION\");\n\n        if(I_found != std::string::npos) {\n                fragment_source.replace(I_found, 13, acc_operator);\n        }\n    }\n\npublic:\n\n    /**\n     * @brief FilterGLNonLinear1D\n     */\n    FilterGLNonLinear1D(int kernelSize, std::string acc_operator, GLenum target) : FilterGL1D(0, target)\n    {\n        this->acc_operator = acc_operator;\n\n        update(kernelSize);\n\n        FragmentShader(NULL, 0, GL_TEXTURE_2D);\n        initShaders();\n    }\n\n    ~FilterGLNonLinear1D()\n    {\n        release();\n    }\n\n    /**\n     * @brief setUniformAux\n     */\n    void setUniformAux()\n    {\n        technique.setUniform1i(\"halfKernelSize\", halfKernelSize);\n        technique.setUniform1i(\"kernelSize\", kernelSize);\n    }\n\n    /**\n     * @brief update\n     * @param kernelSize\n     */\n    void update(int kernelSize)\n    {\n        kernelSize = (kernelSize > 0) ? kernelSize : 3;\n\n        if((kernelSize % 2) == 0) {\n            kernelSize++;\n        }\n\n        this->kernelSize = kernelSize;\n        this->halfKernelSize = kernelSize >> 1;\n    }\n};\n\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_NON_LINEAR_1D_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_npasses.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_NPASSES_HPP\n#define PIC_GL_FILTERING_FILTER_NPASSES_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../util/array.hpp\"\n\n#include \"../../util/gl/fbo.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLNPasses class\n */\nclass FilterGLNPasses: public FilterGL\n{\nprotected:\n    ImageGL *imgAllocated;\n    ImageGL *imgTmpSame[2];\n    ImageGLVec imgTmp;\n\n    /**\n     * @brief PreProcess\n     * @param imgIn\n     * @param imgOut\n     */\n    virtual void PreProcess(ImageGLVec imgIn, ImageGL *imgOut){}\n\n    /**\n     * @brief setupAuxNGen\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *setupAuxNGen(ImageGLVec imgIn, ImageGL *imgOut);\n\n    /**\n     * @brief setupAuxNSame\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *setupAuxNSame(ImageGLVec imgIn, ImageGL *imgOut);\n\n    /**\n     * @brief getFilter\n     * @param i\n     * @return\n     */\n    virtual FilterGL* getFilter(int i);\n\n    /**\n     * @brief getIterations\n     * @return\n     */\n    virtual int getIterations();\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux();\n\n    /**\n     * @brief ProcessGen\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *ProcessGen(ImageGLVec imgIn, ImageGL *imgOut);\n\n    /**\n     * @brief ProcessSame\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *ProcessSame(ImageGLVec imgIn, ImageGL *imgOut);\n\npublic:\n\n    /**\n     * @brief FilterGLNPasses\n     */\n    FilterGLNPasses();\n\n    ~FilterGLNPasses();\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param frames\n     * @param channels\n     */\n    void OutputSize(ImageGLVec imgIn, int &width, int &height, int &frames, int &channels);\n\n    /**\n     * @brief getFbo\n     * @return\n     */\n    Fbo *getFbo()\n    {\n        return filters.back()->getFbo();\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *Process(ImageGLVec imgIn, ImageGL *imgOut);\n};\n\nPIC_INLINE FilterGLNPasses::FilterGLNPasses() : FilterGL()\n{\n    imgAllocated = NULL;\n\n    for(int i = 0; i < 2; i++) {\n        imgTmpSame[i] = NULL;\n    }\n\n    target = GL_TEXTURE_2D;\n}\n\nPIC_INLINE FilterGLNPasses::~FilterGLNPasses()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLNPasses::releaseAux()\n{\n    delete_s(imgAllocated);\n\n    imgTmpSame[0] = NULL;\n    imgTmpSame[1] = NULL;\n\n    stdVectorClear<ImageGL>(imgTmp);\n}\n\nPIC_INLINE FilterGL* FilterGLNPasses::getFilter(int i)\n{\n    int j = i % filters.size();\n    return filters[j];\n}\n\nPIC_INLINE int FilterGLNPasses::getIterations()\n{\n    return int(filters.size());\n}\n\nPIC_INLINE void FilterGLNPasses::OutputSize(ImageGLVec imgIn, int &width, int &height, int &frames, int &channels)\n{\n    ImageGL *imgIn0 = new ImageGL(imgIn[0], false);\n\n    auto *tmp = imgIn[0];\n    imgIn[0] = imgIn0;\n\n    int n = getIterations();\n\n    for(int i = 0; i < n; i++) {\n        auto flt_i = getFilter(i);\n        flt_i->changePass(i, n);\n        flt_i->OutputSize(imgIn, width, height, channels, frames);\n\n        imgIn0->width = width;\n        imgIn0->height = height;\n        imgIn0->channels = channels;\n        imgIn0->frames = frames;\n        imgIn0->allocateAux();\n    }\n\n    imgIn[0] = tmp;\n\n    delete imgIn0;\n}\n\nPIC_INLINE ImageGL *FilterGLNPasses::setupAuxNGen(ImageGLVec imgIn,\n        ImageGL *imgOut)\n{\n    int width, height, frames, channels;\n    OutputSize(imgIn, width, height, frames, channels);\n\n    int n = getIterations();\n\n    if(imgTmp.empty()) {\n        setToANullVector<ImageGL>(imgTmp, n);\n    } else {\n        int tw, th, tf, tc;\n\n        filters[0]->OutputSize(imgIn, tw, th, tf, tc);\n\n        if(tw != imgTmp[0]->width ||\n           th != imgTmp[0]->height ||\n           tf != imgTmp[0]->frames ||\n           tc != imgTmp[0]->channels) {\n            stdVectorClear<ImageGL>(imgTmp);\n\n            setToANullVector<ImageGL>(imgTmp, n);\n        }\n    }\n\n    //output\n    if(imgOut == NULL) {\n        imgOut = new ImageGL(frames, width, height, channels, IMG_GPU, GL_TEXTURE_2D);\n    } else {\n        if(imgOut->height != height ||\n           imgOut->width != width ||\n           imgOut->channels != channels ||\n           imgOut->frames != frames) {\n           imgOut = new ImageGL(frames, width, height, channels, IMG_GPU, GL_TEXTURE_2D);\n        }\n    }\n\n    return imgOut;\n}\n\nPIC_INLINE ImageGL *FilterGLNPasses::setupAuxNSame(ImageGLVec imgIn,\n        ImageGL *imgOut)\n{\n    if(imgOut == NULL) {\n        imgOut = imgIn[0]->allocateSimilarOneGL();\n    } else {\n        if(!imgOut->isSimilarType(imgIn[0])) {\n            imgOut = imgIn[0]->allocateSimilarOneGL();\n        }\n    }\n\n    if(imgAllocated == NULL) {\n        imgAllocated = imgIn[0]->allocateSimilarOneGL();\n    } else {\n        if(!imgAllocated->isSimilarType(imgIn[0])) {\n            delete imgAllocated;\n            imgAllocated = imgIn[0]->allocateSimilarOneGL();\n        }\n    }\n\n    int nIterations = getIterations();\n    if((nIterations % 2) == 0) {\n        imgTmpSame[0] = imgAllocated;\n        imgTmpSame[1] = imgOut;\n    } else {\n        imgTmpSame[0] = imgOut;\n        imgTmpSame[1] = imgAllocated;\n    }\n\n    return imgOut;\n}\n\nPIC_INLINE ImageGL *FilterGLNPasses::ProcessGen(ImageGLVec imgIn, ImageGL *imgOut)\n{\n    if(imgIn.empty() || filters.empty()) {\n        return imgOut;\n    }\n\n    imgOut = setupAuxNGen(imgIn, imgOut);\n\n    int n = getIterations();\n    int n2 = n - 1;\n\n    for(int i = 0; i < n2; i++) {\n        auto flt_i = getFilter(i);\n        flt_i->changePass(i, n);\n        imgTmp[i] = flt_i->Process(imgIn, imgTmp[i]);\n\n        imgIn[0] = imgTmp[i];\n    }\n\n    auto flt_n = getFilter(n2);\n    flt_n->changePass(n2, n);\n    imgOut = filters[n2]->Process(imgIn, imgOut);\n\n    return imgOut;\n}\n\nPIC_INLINE ImageGL *FilterGLNPasses::ProcessSame(ImageGLVec imgIn, ImageGL *imgOut)\n{\n    if((imgIn.size() <= 0) || (filters.size() < 1)) {\n        return imgOut;\n    }\n\n    //setup\n    imgOut = setupAuxNSame(imgIn, imgOut);\n\n    int n = getIterations();\n    auto flt_0 = getFilter(0);\n    flt_0->changePass(0, n);\n    flt_0->Process(imgIn, imgTmpSame[0]);\n\n    for(auto i = 1; i < n; i++) {\n        auto flt_i = getFilter(0);\n        flt_i->changePass(i, n);\n\n        imgIn[0] = imgTmpSame[(i + 1) % 2];\n        flt_i->Process(imgIn, imgTmpSame[i % 2]);\n    }\n\n    return imgOut;\n}\n\nPIC_INLINE ImageGL *FilterGLNPasses::Process(ImageGLVec imgIn,\n        ImageGL *imgOut)\n{\n    if(imgIn.empty() || filters.empty()) {\n        return imgOut;\n    }\n\n    PreProcess(imgIn, imgOut);\n\n    int width, height, frames, channels;\n    OutputSize(imgIn, width, height, frames, channels);\n\n    bool bSame = (imgIn[0]->width == width) &&\n                 (imgIn[0]->height == height) &&\n                 (imgIn[0]->channels == channels) &&\n                 (imgIn[0]->frames == frames);\n\n    if(bSame) {\n        imgOut = ProcessSame(imgIn, imgOut);\n    } else {\n        imgOut = ProcessGen(imgIn, imgOut);\n    }\n\n    return imgOut;\n}\n\n/*\nif(fbo==NULL)\n    fbo = new Fbo();\n\nfbo->create(imgOut->width,imgOut->height,imgOut->frames, false, imgOut->getTexture());\n\nfor(unsigned int i=0;i<filters.size();i++)\n    filters[i]->setFbo(fbo);*/\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_NPASSES_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_op.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_OP_HPP\n#define PIC_GL_FILTERING_FILTER_OP_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../util/string.hpp\"\n\nnamespace pic {\n\nclass FilterGLOp: public FilterGL\n{\nprotected:\n    std::string op;\n    float c0[4], c1[4];\n    bool bTexelFetch;\n\n    void initShaders();\n\npublic:\n\n    /**\n     * @brief FilterGLOp\n     * @param op\n     * @param bTexelFetch\n     * @param c0\n     * @param c1\n     */\n    FilterGLOp(std::string op, bool bTexelFetch, float *c0, float *c1);\n\n    /**\n     * @brief update\n     * @param c0\n     * @param c1\n     */\n    void update(float *c0, float *c1);\n\n    /**\n     * @brief CreateOpSetZero\n     * @return\n     */\n    static FilterGLOp *CreateOpSetZero()\n    {\n        float val[4] = {0.0f, 0.0f, 0.0f, 1.0f};\n        FilterGLOp *filter = new FilterGLOp(\"C0\", true, val, NULL);\n        return filter;\n    }\n\n    /**\n     * @brief CreateOpSetOne\n     * @return\n     */\n    static FilterGLOp *CreateOpSetOne()\n    {\n        float val[4] = {1.0f, 1.0f, 1.0f, 1.0f};\n        FilterGLOp *filter = new FilterGLOp(\"C0\", true, val, NULL);\n        return filter;\n    }\n\n    /**\n     * @brief CreateOpIdentity\n     * @param bType\n     * @return\n     */\n    static FilterGLOp *CreateOpIdentity(bool bType)\n    {\n        FilterGLOp *filter = new FilterGLOp(\"I0\", bType, NULL, NULL);\n        return filter;\n    }\n\n    /**\n     * @brief CreateOpSegmentation\n     * @param bType\n     * @param minVal\n     * @return\n     */\n    static FilterGLOp *CreateOpSegmentation(bool bType, float minVal)\n    {\n        float tmp[4];\n        tmp[0] = tmp[1] = tmp[2] = tmp[3] = minVal;\n        FilterGLOp *filter = new FilterGLOp(\"(I0.x > 0.0) ? floor(log(I0) / 2.3026) : C0 \",\n                                            bType, tmp, NULL);\n        return filter;\n    }\n\n    /**\n     * @brief CreateOpAdd\n     * @param bType\n     * @return\n     */\n    static FilterGLOp *CreateOpAdd(bool bType)\n    {\n        FilterGLOp *filter = new FilterGLOp(\"I0 + I1\", bType, NULL, NULL);\n        return filter;\n    }\n\n    /**\n     * @brief CreateOpMulNeg\n     * @param bType\n     * @return\n     */\n    static FilterGLOp *CreateOpMulNeg(bool bType)\n    {\n        FilterGLOp *filter = new FilterGLOp(\"(vec4(1.0) - I1) * I0\", bType, NULL, NULL);\n        return filter;\n    }\n\n    /**\n     * @brief CreateOpMul\n     * @param bType\n     * @return\n     */\n    static FilterGLOp *CreateOpMul(bool bType)\n    {\n        FilterGLOp *filter = new FilterGLOp(\"I0 * I1\", bType, NULL, NULL);\n        return filter;\n    }\n\n    /**\n     * @brief CreateOpSub\n     * @param bType\n     * @return\n     */\n    static FilterGLOp *CreateOpSub(bool bType)\n    {\n        FilterGLOp *filter = new FilterGLOp(\"I0 - I1\", bType, NULL, NULL);\n        return filter;\n    }\n\n    /**\n     * @brief CreateOpDiv\n     * @param bType\n     * @return\n     */\n    static FilterGLOp *CreateOpDiv(bool bType)\n    {\n        FilterGLOp *filter = new FilterGLOp(\"I0 / I1\", bType, NULL, NULL);\n        return filter;\n    }\n\n    /**\n     * @brief CreateOpDivConst\n     * @param bType\n     * @return\n     */\n    static FilterGLOp *CreateOpDivConst(bool bType)\n    {\n        FilterGLOp *filter = new FilterGLOp(\"I0 / C0\", bType, NULL, NULL);\n        return filter;\n    }\n};\n\nPIC_INLINE FilterGLOp::FilterGLOp(std::string op, bool bTexelFetch = false,\n                       float *c0 = NULL, float *c1 = NULL): FilterGL()\n{\n    if(c0 != NULL) {\n        memcpy(this->c0, c0, 4 * sizeof(float));\n    } else {\n        Arrayf::assign(1.0f, this->c0, 4);\n    }\n\n    if(c1 != NULL) {\n        memcpy(this->c1, c1, 4 * sizeof(float));\n    } else {\n        Arrayf::assign(1.0f, this->c1, 4);\n    }\n\n    this->op = op;\n    this->bTexelFetch = bTexelFetch;\n\n    if(!bTexelFetch) {\n\n        if(quad != NULL) {\n            delete quad;\n        }\n\n        quad = new QuadGL(true);\n        vertex_source = QuadGL::getVertexProgramWithTexCoordinates();\n    }\n\n    initShaders();\n}\n\nPIC_INLINE void FilterGLOp::initShaders()\n{\n    std::string strOp = \"ret = \";\n    strOp.append(op);\n    strOp.append(\";\\n\");\n    int counter;\n\n    //I0\n    counter = countSubString(strOp, \"I0\");\n\n    if(counter == 1) {\n        size_t I_found = strOp.find(\"I0\");\n\n        if(I_found != std::string::npos) {\n            if(bTexelFetch) {\n                strOp.replace(I_found, 2, \"texelFetch(u_tex_0, coords, 0)\");\n            } else {\n                strOp.replace(I_found, 2, \"texture(u_tex_0, coords)\");\n            }\n        }\n    } else {\n        if(counter > 1) {\n            if(bTexelFetch) {\n                strOp = \"vec4 tmp0 = texelFetch(u_tex_0, coords, 0);\\n\" + strOp;\n            } else {\n                strOp = \"vec4 tmp0 = texture(u_tex_0, coords);\\n\" + strOp;\n            }\n\n            strOp = stdStringRepAll(strOp, \"I0\", \"tmp0\");\n        }\n    }\n\n    //I1\n    counter = countSubString(strOp, \"I1\");\n\n    if(counter == 1) {\n        size_t I_found = strOp.find(\"I1\");\n\n        if(I_found != std::string::npos) {\n            if(bTexelFetch) {\n                strOp.replace(I_found, 2, \"texelFetch(u_tex_1, coords, 0)\");\n            } else {\n                strOp.replace(I_found, 2, \"texture(u_tex_1, coords)\");\n            }\n        }\n    } else {\n        if(counter > 1) {\n            if(bTexelFetch) {\n                strOp = \"vec4 tmp1 = texelFetch(u_tex_1, coords, 0);\\n\" + strOp;\n            } else {\n                strOp = \"vec4 tmp1 = texture(u_tex_1, coords);\\n\" + strOp;\n            }\n\n            strOp = stdStringRepAll(strOp, \"I1\", \"tmp1\");\n        }\n    }\n\n    //C1 and C2\n    strOp = stdStringRepAll(strOp, \"C0\", \"u_val_0\");\n    strOp = stdStringRepAll(strOp, \"C1\", \"u_val_1\");\n\n    fragment_source = MAKE_STRING\n                      (\n                          uniform sampler2D u_tex_0; \\n\n                          uniform sampler2D u_tex_1; \\n\n                          uniform vec4      u_val_0; \\n\n                          uniform vec4      u_val_1; \\n\n                          out     vec4      f_color; \\n\n                          in      vec2      v_tex_coord; \\n\n                          \\n\n    void main(void) {\n        \\n\n        _COORDINATES_FOR_FETCHING_ \\n\n        vec4 ret;\n        \\n\n        _PROCESSING_OPERATOR_ \\n\n        f_color = ret;\n        \\n\n    }\n                      );\n\n    if(bTexelFetch) {\n        size_t processing_found = fragment_source.find(\"_COORDINATES_FOR_FETCHING_\");\n        fragment_source.replace(processing_found, 27,\n                                \"ivec2 coords = ivec2(gl_FragCoord.xy);\\n\");\n    } else {\n        size_t processing_found = fragment_source.find(\"_COORDINATES_FOR_FETCHING_\");\n        fragment_source.replace(processing_found, 27,\n                                \"vec2 coords = v_tex_coord.xy;\\n\");\n    }\n\n    size_t processing_found = fragment_source.find(\"_PROCESSING_OPERATOR_\");\n    fragment_source.replace(processing_found, 21, strOp);\n\n    technique.init(\"330\", vertex_source, fragment_source);\n\n#ifdef PIC_DEBUG\n    technique.printLog(\"FilterOp\");\n#endif\n\n    technique.bind();\n    technique.setAttributeIndex(\"a_position\", 0);\n\n    if(!bTexelFetch) {\n        technique.setAttributeIndex(\"a_tex_coord\",  1);\n    }\n\n    technique.setOutputFragmentShaderIndex(\"f_color\", 0);\n    technique.link();\n    technique.unbind();\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex_0\",  0);\n    technique.setUniform1i(\"u_tex_1\",  1);\n    technique.setUniform4fv(\"u_val_0\", c0);\n    technique.setUniform4fv(\"u_val_1\", c1);\n    technique.unbind();\n}\n\nPIC_INLINE void FilterGLOp::update(float *c0, float *c1)\n{\n    if(c0 != NULL) {\n        for(int i = 0; i < 4; i++) {\n            this->c0[i] = c0[i];\n        }\n    }\n\n    if(c1 != NULL) {\n        for(int i = 0; i < 4; i++) {\n            this->c1[i] = c1[i];\n        }\n    }\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex_0\",  0);\n    technique.setUniform1i(\"u_tex_1\",  1);\n    technique.setUniform4fv(\"u_val_0\", this->c0);\n    technique.setUniform4fv(\"u_val_1\", this->c1);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_OP_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_reinhard_single_pass.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_REINHARD_TMO_SINGLE_PASS_HPP\n#define PIC_GL_FILTERING_REINHARD_TMO_SINGLE_PASS_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/vec.hpp\"\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../util/file_lister.hpp\"\n#include \"../../gl/point_samplers/sampler_random_m.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLReinhardSinglePass class\n */\nclass FilterGLReinhardSinglePass: public FilterGL\n{\nprotected:\n    float sigma_s, sigma_r, sigmoid_constant;\n    MRSamplersGL<2> *ms;\n\n    //tmo\n    float alpha;\n\n    //Random numbers tile\n    ImageGL *imageRand;\n\n    void initShaders();\n    void FragmentShader();\n\npublic:\n    float Lwa;\n\n    /**\n     * @brief FilterGLReinhardSinglePass\n     * @param sigma_s\n     * @param sigma_r\n     * @param type\n     */\n    FilterGLReinhardSinglePass(float alpha, float phi);\n\n    ~FilterGLReinhardSinglePass();\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux()\n    {\n        delete_s(imageRand);\n        delete_s(ms);\n    }\n\n    /**\n     * @brief update\n     * @param sigma_s\n     * @param sigma_r\n     */\n    void update(float sigma_s, float sigma_r, float Lwa);\n};\n\nPIC_INLINE FilterGLReinhardSinglePass::FilterGLReinhardSinglePass(float alpha, float phi = 8.0f): FilterGL()\n{\n    this->sigma_s = -1.0f;\n    this->sigma_r = -1.0f;\n    this->alpha = alpha;\n    float epsilon = 0.05f;\n    float s_max = 8.0f;\n    float sigma_s = 1.6f;\n    float sigma_r = epsilon / 2.0f;\n\n    this->sigmoid_constant = (powf(2.0f, phi) * alpha / (s_max * s_max)) * epsilon;\n\n    ms = NULL;\n    imageRand = NULL;\n\n    FragmentShader();\n    initShaders();\n\n    update(sigma_s, sigma_r, 1.0f);\n}\n\nPIC_INLINE FilterGLReinhardSinglePass::~FilterGLReinhardSinglePass()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLReinhardSinglePass::FragmentShader()\n{\n    fragment_source = MAKE_STRING\n                                          (\n                                                  uniform sampler2D  u_tex;\n                                                  uniform sampler2D  u_tex_col;\n                                                  uniform isampler2D u_poisson;\n                                                  uniform sampler2D  u_rand;\n                                                  uniform int   nSamples;\n                                                  uniform float sigmoid_constant;\n                                                  uniform float sigmas2;\n                                                  uniform float sigmar2;\n                                                  uniform int kernelSize;\n                                                  uniform float kernelSizef;\n                                                  uniform float a;\n                                                  out     vec4  f_color;\n\n    void main(void) {\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n\n        float colRef = texelFetch(u_tex, coordsFrag, 0).x;\n        float Lw = colRef;\n\n        colRef = colRef / (colRef + sigmoid_constant);\n\n        float shifter = texture(u_rand, gl_FragCoord.xy).x;\n        float  color = 0.0;\n        float weight = 0.0;\n\n        for(int i = 0; i < nSamples; i++) {\n            //coordinates\n            ivec3 coords = texelFetch(u_poisson, ivec2(i, shifter), 0).xyz;\n\n            //texture fetch\n            float tmpCol = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0).x;\n            tmpCol = tmpCol / (tmpCol + sigmoid_constant);\n\n            float tmpCol2 = tmpCol - colRef;\n            float dstR = tmpCol2 * tmpCol2;\n\n            int coordsz = coords.x * coords.x + coords.y * coords.y;\n            float tmp = exp(-dstR / sigmar2 - float(coordsz) / sigmas2);\n\n            color += tmpCol * tmp;\n            weight += tmp;\n\n        }\n\n        float bilateral = weight > 0.0 ? (color / weight) : colRef;\n        bilateral = (bilateral * sigmoid_constant) / (1.0 - bilateral);\n\n        Lw = Lw < 1e-9 ? 1e-9 : Lw;\n        vec3 color_hdr = texelFetch(u_tex_col, coordsFrag, 0).xyz / Lw;\n\n        float Ld = (Lw * a) / (bilateral * a + 1.0);\n\n        f_color = vec4(color_hdr * Ld, 1.0);\n    }\n    );\n\n}\n\nPIC_INLINE void FilterGLReinhardSinglePass::initShaders()\n{\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLReinhardSinglePass\");\n}\n\nPIC_INLINE void FilterGLReinhardSinglePass::update(float sigma_s, float sigma_r, float Lwa)\n{\n    bool flag = false;\n\n    if(sigma_s > 0.0f) {\n        flag = (this->sigma_s != sigma_s);\n        this->sigma_s = sigma_s;\n    }\n\n    if(sigma_r > 0.0f) {\n        flag = flag || (this->sigma_r != sigma_r);\n        this->sigma_r = sigma_r;\n    }\n\n    this->Lwa = Lwa > 0.0f ? Lwa : this->Lwa;\n\n    //precomputation of the Gaussian Kernel\n    int kernelSize = PrecomputedGaussian::getKernelSize(this->sigma_s);\n    int halfKernelSize = kernelSize >> 1;\n\n    if(imageRand == NULL) {\n        imageRand = new ImageGL(1, 128, 128, 1, IMG_CPU, GL_TEXTURE_2D);\n        imageRand->setRand(1);\n        imageRand->loadFromMemory();\n        *imageRand -= 0.5f;\n    }\n\n    if(flag) {\n        Vec2i window = Vec2i(halfKernelSize, halfKernelSize);\n\n        if(ms == NULL) {\n            int nSamplers = 1;\n\n            //Poisson samples\n        #ifdef PIC_DEBUG\n            printf(\"Window: %d\\n\", halfKernelSize);\n        #endif\n            ms = new MRSamplersGL<2>(ST_BRIDSON, window, halfKernelSize, 1,\n                                     nSamplers);\n            ms->generateTexture();\n        } else {\n            ms->updateGL(window, halfKernelSize);\n            param.clear();\n        }\n\n        if(param.empty()) {\n            param.push_back(imageRand);\n            param.push_back(ms->getImage());\n        }\n    }\n\n    //shader update\n    float sigmas2 = 2.0f * this->sigma_s * this->sigma_s;\n    float sigmar2 = 2.0f * this->sigma_r * this->sigma_r;\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex_col\",   0);\n    technique.setUniform1i(\"u_tex\",       1);\n    technique.setUniform1i(\"u_rand\",      2);\n    technique.setUniform1i(\"u_poisson\",   3);\n\n    technique.setUniform1f(\"sigmas2\",         sigmas2);\n    technique.setUniform1f(\"a\",               alpha / Lwa);\n    technique.setUniform1f(\"sigmoid_constant\", sigmoid_constant);\n\n    technique.setUniform1f(\"sigmar2\",         sigmar2);\n    technique.setUniform1i(\"kernelSize\",      kernelSize);\n    technique.setUniform1f(\"kernelSizef\",     float(kernelSize));\n    technique.setUniform1i(\"nSamples\",        ms->nSamples >> 1);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_REINHARD_TMO_SINGLE_PASS_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_remapping.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_REMAPPING_HPP\n#define PIC_GL_FILTERING_FILTER_REMAPPING_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLRemapping class\n */\nclass FilterGLRemapping: public FilterGL\n{\nprotected:\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        /*\n         *\n         * 0 ---> Drago et al. 2003\n         * 1 ---> Reinhard et al. 2002\n         * LumZone     = [-2, -1, 0, 1, 2, 3, 4];\n         * TMOForZone =  [ 0,  0, 1, 0, 1, 0, 0];\n        */\n\n        fragment_source = MAKE_STRING\n                          (\n                              uniform sampler2D u_tex; \\n\n                              s out     vec4     f_color; \\n\n        void main(void) { \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n            int indx = int(texelFetch(u_tex, coords, 0).x + 2.0); \\n\n            indx = (indx == 2) ? 1 : 0; \\n\n            indx = (indx == 4) ? 1 : indx;\\n\n            f_color = vec4(vec3(float(indx)), 1.0);\\n\n        }\n                          );\n\n        technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLRemapping\");\n\n        technique.bind();\n        technique.setUniform1i(\"u_tex\", 0);\n        technique.unbind();\n    }\n\npublic:\n    /**\n     * @brief FilterGLRemapping\n     */\n    FilterGLRemapping() : FilterGL()\n    {\n        initShaders();\n    }\n\n    ~FilterGLRemapping()\n    {\n        release();\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_REMAPPING_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_remove_nuked.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_REMOVE_NUKED_HPP\n#define PIC_GL_FILTERING_FILTER_REMOVE_NUKED_HPP\n\n#include \"../../base.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLRemoveNuked class\n */\nclass FilterGLRemoveNuked: public FilterGL\n{\nprotected:\n    float threshold;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\npublic:\n    /**\n     * @brief FilterGLRemoveNuked\n     * @param threshold\n     */\n    FilterGLRemoveNuked(float threshold);\n\n    /**\n     * @brief update\n     * @param threshold\n     */\n    void update(float threshold);\n};\n\nPIC_INLINE FilterGLRemoveNuked::FilterGLRemoveNuked(float threshold): FilterGL()\n{\n    this->threshold = threshold;\n\n    FragmentShader();\n    initShaders();\n}\n\nPIC_INLINE void FilterGLRemoveNuked::FragmentShader()\n{\n    fragment_source = MAKE_STRING\n                      (\n                          uniform sampler2D\tu_tex;\n                          uniform float\t\tthreshold;\n                          out     vec4\t\tf_color;\n\n    void main(void) {\n\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n\n        float ref = texelFetch(u_tex, coordsFrag, 0).x;\n        float tmp;\n\n        int count = 0;\n\n        vec3 colorNuked = vec3(0.0);\n\n        for(int i = -2; i < 3; i++) {\n            for(int j = -2; j < 3; j++) {\n                //Coordinates\n                ivec2 coords = ivec2(i, j);\n                //Texture fetch\n                tmp = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0).x;\n                float tmp2 = abs(tmp - ref);\n\n                if(tmp2 > threshold) {\n                    count = count + 1;\n                    colorNuked = vec3(tmp);\n                }\n            }\\n\n        }\\n\n\n        vec3 color = vec3(ref);\n        \\n\n\n        if(count > 12)\\n\n            color = colorNuked;\n\n        \\n\n        f_color = vec4(color, 1.0);\n        \\n\n    }\\n\n                      );\n}\n\nPIC_INLINE void FilterGLRemoveNuked::initShaders()\n{\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLRemoveNuked\");\n\n    update(-1.0f);\n}\n\nPIC_INLINE void FilterGLRemoveNuked::update(float threshold)\n{\n    if(threshold > 0.0f) {\n        this->threshold = threshold;\n    }\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.setUniform1f(\"threshold\", this->threshold);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_REMOVE_NUKED_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_sampler_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_SAMPLER_2D_HPP\n#define PIC_GL_FILTERING_FILTER_SAMPLER_2D_HPP\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLSampler2D class\n */\nclass FilterGLSampler2D: public FilterGL\n{\nprotected:\n    float scale;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        fragment_source = MAKE_STRING\n                          (\n                              uniform sampler2D u_tex; \\n\n                              uniform float   scale; \\n\n                              out     vec4    f_color; \\n\n\n        void main(void) { \\n\n            vec2 coords = gl_FragCoord.xy / vec2(scale);\n            vec3  color = texelFetch(u_tex, ivec2(coords), 0).xyz; \\n\n            f_color = vec4(color.xyz, 1.0); \\n\n        }\n                          );\n\n        technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLSampler2D\");\n    }\n\npublic:\n    /**\n     * @brief FilterGLSampler2D\n     * @param scale\n     */\n    FilterGLSampler2D(float scale) : FilterGL()\n    {\n        initShaders();\n        update(scale);\n    }\n\n    ~FilterGLSampler2D()\n    {\n        release();\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageGLVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        if(imgIn.empty()) {\n            width = -1;\n            height = -2;\n            channels = -2;\n            frames = -2;\n        }\n\n        if(imgIn.size() == 1) {\n            width = int(imgIn[0]->widthf * scale);\n            height = int(imgIn[0]->heightf * scale);\n        } else {\n            width = imgIn[1]->width;\n            height = imgIn[1]->height;\n        }\n\n        channels = imgIn[0]->channels;\n        frames = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief update\n     * @param scale\n     */\n    void update(float scale)\n    {\n        if(scale > 0.0f) {\n            this->scale = scale;\n        }\n\n        if(technique.isValid()) {\n            technique.bind();\n            technique.setUniform1f(\"scale\", scale);\n            technique.unbind();\n        }\n    }        \n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param scale\n     * @return\n     */\n    static ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut, float scale)\n    {\n        imgIn->generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);\n\n        FilterGLSampler2D filter(scale);\n\n        imgOut = filter.Process(SingleGL(imgIn), imgOut);\n\n        return imgOut;\n    }\n};\n\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_SAMPLER_2D_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_sampling_map.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_SAMPLING_MAP_HPP\n#define PIC_GL_FILTERING_FILTER_SAMPLING_MAP_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../util/gl/fbo.hpp\"\n\n#include \"../../gl/filtering/filter_npasses.hpp\"\n#include \"../../gl/filtering/filter_gradient.hpp\"\n#include \"../../gl/filtering/filter_sigmoid_tmo.hpp\"\n#include \"../../gl/filtering/filter_sampler_2d.hpp\"\n#include \"../../gl/filtering/filter_gaussian_2d.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLSamplingMap class\n */\nclass FilterGLSamplingMap: public FilterGLNPasses\n{\nprotected:\n    float scale, sigma;\n\n    FilterGLGradient *filterG;\n    FilterGLSigmoidTMO *filterS;\n    FilterGLSampler2D *filterD;\n    FilterGLGaussian2D *filterG2D;\n\n    /**\n     * @brief update\n     * @param sigma\n     * @param scale\n     */\n    void update(float sigma, float scale)\n    {\n        this->sigma = sigma;\n        this->scale = scale;\n\n        filterD = new FilterGLSampler2D(scale);\n        filterS = new FilterGLSigmoidTMO();\n        filterG = new FilterGLGradient();\n        filterG2D = new FilterGLGaussian2D(sigma);\n\n        insertFilter(filterD);\n        insertFilter(filterS);\n        insertFilter(filterG);\n        insertFilter(filterG2D);\n    }\n\npublic:\n    /**\n     * @brief FilterGLSamplingMap\n     * @param sigma\n     */\n    FilterGLSamplingMap(float sigma) : FilterGLNPasses()\n    {\n        target = GL_TEXTURE_2D;\n        float rateScale = 2.0f;\n        update(rateScale, rateScale / sigma);\n    }\n\n\n    /**\n     * @brief FilterGLSamplingMap\n     * @param sigma\n     * @param scale\n     */\n    FilterGLSamplingMap(float sigma, float scale) : FilterGLNPasses()\n    {\n        target = GL_TEXTURE_2D;\n        update(sigma * scale, scale);\n    }\n\n    ~FilterGLSamplingMap()\n    {\n        release();\n    }\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux()\n    {\n        delete_s(filterD);\n        delete_s(filterS);\n        delete_s(filterG);\n        delete_s(filterG2D);\n    }\n\n    /**\n     * @brief getScale\n     * @return\n     */\n    float getScale()\n    {\n        return scale;\n    }\n\n    /**\n     * @brief getFbo\n     * @return\n     */\n    Fbo *getFbo()\n    {\n        if(filters.empty()) {\n            return NULL;\n        }\n\n        return filters[filters.size() - 1]->getFbo();\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param sigma\n     * @return\n     */\n    static ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut, float sigma)\n    {\n        FilterGLSamplingMap filter(sigma);\n\n        imgOut = filter.Process(SingleGL(imgIn), imgOut);\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_SAMPLING_MAP_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_scatter.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_SCATTER_HPP\n#define PIC_GL_FILTERING_FILTER_SCATTER_HPP\n\n#include \"../../base.hpp\"\n#include \"../../util/std_util.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLScatter class implement\n * the bilateral grid approximation of the bilateral\n * filter.\n */\nclass FilterGLScatter: public FilterGL\n{\nprotected:\n\n    GLfloat *vertex_array;\n    int nVertex_array;\n    GLuint vbo, vao;\n\n    /**\n     * @brief generateVertexArray\n     * @param width\n     * @param height\n     */\n    void generateVertexArray(int width, int height);\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief FragmentShader\n     */\n    void FragmentShader();\n\n    float s_S, s_R, mul_E;\n\npublic:\n\n    /**\n     * @brief FilterGLScatter\n     * @param s_S\n     * @param s_R\n     * @param width\n     * @param height\n     */\n    FilterGLScatter(float s_S, float s_R, int width, int height);\n\n    ~FilterGLScatter();\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux()\n    {\n        vertex_array = delete_vec_s(vertex_array);\n\n        if(vbo != 0) {\n            glDeleteBuffers(1, &vbo);\n            vbo = 0;\n        }\n\n        if(vao != 0) {\n            glDeleteVertexArrays(1, &vao);\n            vao = 0;\n        }\n    }\n\n    /**\n     * @brief update\n     * @param s_S\n     * @param s_R\n     */\n    void update(float s_S, float s_R);\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *Process(ImageGLVec imgIn, ImageGL *imgOut);\n};\n\nPIC_INLINE FilterGLScatter::FilterGLScatter(float s_S, float s_R, int width, int height)\n{\n    this->s_S = s_S;\n    this->s_R = s_R;\n\n    vertex_array = NULL;\n\n    generateVertexArray(width, height);\n\n    FragmentShader();\n    initShaders();\n}\n\nPIC_INLINE FilterGLScatter::~FilterGLScatter()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLScatter::generateVertexArray(int width, int height)\n{\n    vertex_array = delete_vec_s(vertex_array);\n\n    vertex_array = new GLfloat[2 * width * height];\n    nVertex_array = width * height;\n\n    int index = 0;\n\n    for(int i = 0; i < height; i++) {\n        float i_f = float(i);\n\n        for(int j = 0; j < width; j++) {\n            vertex_array[index++] = float(j);\n            vertex_array[index++] = i_f;\n        }\n    }\n\n    //Vertex Buffer Object\n    glGenBuffers(1, &vbo);\n    glBindBuffer(GL_ARRAY_BUFFER, vbo);\n    glBufferData(GL_ARRAY_BUFFER, 2 * nVertex_array * sizeof(GLfloat), vertex_array,\n                 GL_STATIC_DRAW);\n    glBindBuffer(GL_ARRAY_BUFFER, 0);\n\n    //Vertex Array Object\n    glGenVertexArrays(1, &vao);\n    glBindVertexArray(vao);\n    glBindBuffer(GL_ARRAY_BUFFER, vbo);\n\n    glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);\n\n    glEnableVertexAttribArray(0);\n    glBindVertexArray(0);\n    glDisableVertexAttribArray(0);\n    glBindBuffer(GL_ARRAY_BUFFER, 0);\n}\n\nPIC_INLINE void FilterGLScatter::FragmentShader()\n{\n    vertex_source = MAKE_STRING(\n\n                        uniform sampler2D\tu_tex;\n                        uniform float\t\ts_S;\n                        uniform float\t\tmul_E;\n\n                        layout(location = 0) in vec2 a_position;\n\n                        flat out vec4 v2g_color;\n                        flat out int  v2g_layer;\n\n    void main(void) {\n        //Texture Fetch\n        vec4 data = texelFetch(u_tex, ivec2(a_position), 0);\n\n        //Output coordinate\n        vec2 coord = vec2(a_position) / vec2(textureSize(u_tex, 0) - ivec2(1));\n        coord = coord * 2.0 - vec2(1.0);\n\n        v2g_color  = vec4(data.xyz, 1.0);\n        v2g_layer  = int(floor(dot(data.xyz, vec3(1.0)) * mul_E));\n\n        gl_Position = vec4(coord, 0.0, 1.0);\n    }\n                    );\n\n    geometry_source = MAKE_STRING(\n\n                          layout(points) in;\n                          layout(points, max_vertices = 1) out;\n\n                          flat in vec4  v2g_color[1];\n                          flat in int   v2g_layer[1];\n                          flat out vec4 g2f_color;\n\n    void main(void) {\n        g2f_color   = v2g_color[0];\n        gl_Layer    = v2g_layer[0];\n\n        gl_PointSize = 1.0;\n        gl_Position = gl_in[0].gl_Position;\n        EmitVertex();\n\n        EndPrimitive();\n    }\n                      );\n\n    fragment_source = MAKE_STRING(\n                          flat in\tvec4\tg2f_color;\n                          layout(location = 0) out vec4    f_color;\n\n    void main(void) {\n        f_color = g2f_color;\n    }\n                      );\n}\n\nPIC_INLINE void FilterGLScatter::initShaders()\n{\n    technique.initStandard(\"410\", vertex_source, fragment_source, geometry_source, \"FilterGLScatter\");\n\n    update(s_S, s_R);\n}\n\nPIC_INLINE void FilterGLScatter::update(float s_S, float s_R)\n{\n    this->s_S = s_S;\n    this->s_R = s_R;\n\n    mul_E = s_R / 3.0f;\n\n    #ifdef PIC_DEBUG\n        printf(\"Rate S: %f Rate R: %f Mul E: %f\\n\", s_S, s_R, mul_E);\n    #endif\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.setUniform1f(\"s_S\", s_S);\n    technique.setUniform1f(\"mul_E\", mul_E);\n    technique.unbind();\n}\n\nPIC_INLINE ImageGL *FilterGLScatter::Process(ImageGLVec imgIn, ImageGL *imgOut)\n{\n    if(imgIn.size() < 1 && imgIn[0] == NULL) {\n        return imgOut;\n    }\n\n    int width, height, range;\n    width =  int(ceilf(float(imgIn[0]->width)  * s_S));\n    height = int(ceilf(float(imgIn[0]->height) * s_S));\n    range =  int(ceilf(s_R));\n\n    if(imgOut == NULL) {\n        imgOut = new ImageGL(range + 1, width + 1, height + 1,\n                                imgIn[0]->channels + 1, IMG_GPU, GL_TEXTURE_3D);\n    }\n\n    if(fbo == NULL) {\n        fbo = new Fbo();\n        fbo->create(width + 1, height + 1, range + 1, false, imgOut->getTexture());\n    }\n\n    //Rendering\n    fbo->bind();\n\n    glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,\n                            imgOut->getTexture(), 0);\n\n    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);\n    glClear(GL_COLOR_BUFFER_BIT);\n\n    glViewport(0, 0, (GLsizei)width, (GLsizei)height);\n\n    //Shaders\n    technique.bind();\n\n    //Textures\n    glActiveTexture(GL_TEXTURE0);\n    imgIn[0]->bindTexture();\n\n    glEnable(GL_BLEND);\n    glBlendFunc(GL_ONE, GL_ONE);\n\n    glBindVertexArray(vao);\n    glDrawArrays(GL_POINTS, 0, nVertex_array);\n    glBindVertexArray(0);\n\n    glDisable(GL_BLEND);\n\n    //Fbo\n    fbo->unbind();\n\n    //Shaders\n    technique.unbind();\n\n    //Textures\n    glActiveTexture(GL_TEXTURE0);\n    imgIn[0]->unBindTexture();\n\n    return imgOut;\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_SCATTER_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_sigmoid_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_SIGMOID_TMO_HPP\n#define PIC_GL_FILTERING_FILTER_SIGMOID_TMO_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n#include \"../../gl/filtering/filter_luminance.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLSigmoidTMO class\n */\nclass FilterGLSigmoidTMO: public FilterGL\n{\nprotected:\n    float alpha, epsilon;\n    bool  bGammaCorrection, bLocal;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\npublic:\n    /**\n     * @brief FilterGLSigmoidTMO\n     */\n    FilterGLSigmoidTMO();\n\n    ~FilterGLSigmoidTMO();\n\n    /**\n     * @brief FilterGLSigmoidTMO\n     * @param alpha\n     * @param bLocal\n     * @param bGammaCorrection\n     */\n    FilterGLSigmoidTMO(float alpha, bool bLocal, bool bGammaCorrection);\n\n    /**\n     * @brief update\n     * @param alpha\n     */\n    void update(float alpha);\n};\n\nPIC_INLINE FilterGLSigmoidTMO::FilterGLSigmoidTMO(): FilterGL()\n{\n    alpha = 0.15f;\n    bGammaCorrection = false;\n    bLocal = false;\n    epsilon = 1.0f;\n\n    initShaders();\n}\n\nPIC_INLINE FilterGLSigmoidTMO::~FilterGLSigmoidTMO()\n{\n    release();\n}\n\nPIC_INLINE FilterGLSigmoidTMO::FilterGLSigmoidTMO(float alpha, bool bLocal,\n                                       bool bGammaCorrection): FilterGL()\n{\n    this->alpha = alpha;\n    this->bLocal = bLocal;\n    this->bGammaCorrection = bGammaCorrection;\n    epsilon = 1.0f;\n\n    initShaders();\n}\n\nPIC_INLINE void FilterGLSigmoidTMO::initShaders()\n{\n    fragment_source = MAKE_STRING\n                      (\n                          uniform sampler2D\tu_tex; \\n\n                          uniform sampler2D\tu_tex_adapt; \\n\n                          uniform float\t\talpha; \\n\n                          uniform float\t\tepsilon; \\n\n                          out     vec4\t\tf_color; \\n\n                          const\tvec3\t\tLUM_XYZ =\tvec3(0.213, 0.715, 0.072); \\n\n\n    void main(void) {\n        \\n\n        ivec2  coords = ivec2(gl_FragCoord.xy);\n        \\n\n        vec3   color  = texelFetch(u_tex, coords, 0).xyz;\n        \\n\n        __LOCAL__1__ \\n\n        float Lw =\tdot(color,\t\tLUM_XYZ);\n        \\n\n        __LOCAL__2__ \\n\n        color = (color.xyz * Ld) / Lw;\n        \\n\n        __GAMMA__CORRECTION__ \\n\n        f_color = vec4(color, 1.0);\n        \\n\n    }\\n\n                      );\n\n    size_t processing_found1 = fragment_source.find(\"__LOCAL__1__\");\n\n    if(bLocal) {\n        fragment_source.replace(processing_found1, 12,\n                                \" float Lwa = texelFetch(u_tex_adapt,\tcoords,0).x; \");\n\n        size_t processing_found2 = fragment_source.find(\"__LOCAL__2__\");\n        fragment_source.replace(processing_found2, 12,\n                                \" float Ld  = (Lw * alpha)/(Lwa * alpha + epsilon); \");\n    } else {\n        fragment_source.replace(processing_found1, 12, \" \");\n\n        size_t processing_found2 = fragment_source.find(\"__LOCAL__2__\");\n        fragment_source.replace(processing_found2, 12,\n                                \" float Lscale = Lw * alpha;\\n float Ld = Lscale / (Lscale + epsilon); \");\n    }\n\n    fragment_source = gammaCorrection(fragment_source, bGammaCorrection);\n\n    //\n    //\n    //\n\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLSigmoidTMO\");\n\n    update(alpha);\n}\n\nPIC_INLINE void FilterGLSigmoidTMO::update(float alpha)\n{\n    if(alpha > 0.0f) {\n        this->alpha = alpha;\n    }\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.setUniform1i(\"u_tex_adapt\", 1);\n    technique.setUniform1f(\"alpha\", this->alpha);\n    technique.setUniform1f(\"epsilon\", epsilon);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_SIGMOID_TMO_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_simple_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_SIMPLE_TMO_HPP\n#define PIC_GL_FILTERING_FILTER_SIMPLE_TMO_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLSimpleTMO class\n */\nclass FilterGLSimpleTMO: public FilterGL\n{\nprotected:\n    float fstop, gamma;\n\n    void initShaders()\n    {\n        fragment_source = MAKE_STRING\n                          (\n                              uniform sampler2D u_tex; \\n\n                              uniform float\t  tn_gamma; \\n\n                              uniform float\t  tn_exposure; \\n\n                              out     vec4      f_color;\t\\n\n\n        void main(void) { \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n            vec3  color = texelFetch(u_tex, coords, 0).xyz; \\n\n            color = pow(color * tn_exposure, vec3(tn_gamma));\n            f_color = vec4(color, 1.0);\n            \\n\n        }\\n\n                          );\n\n        technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLSimpleTMO\");\n    }\n\npublic:\n    /**\n     * @brief FilterGLSimpleTMO\n     */\n    FilterGLSimpleTMO(): FilterGL()\n    {\n        initShaders();\n        update(2.2f, 0.0f);\n    }\n\n    /**\n     * @brief FilterGLSimpleTMO\n     * @param fstop\n     * @param gamma\n     */\n    FilterGLSimpleTMO(float gamma, float fstop) : FilterGL()\n    {\n        initShaders();\n        update(gamma, fstop);\n    }\n\n    /**\n     * @brief update\n     * @param fstop\n     * @param gamma\n     */\n    void update(float gamma, float fstop)\n    {\n        gamma = gamma > 0.0f ? gamma : 2.2f;\n\n        this->gamma = gamma;\n        this->fstop = fstop;\n\n        float invGamma = 1.0f / gamma;\n        float exposure = powf(2.0f, fstop);\n\n        if(technique.isValid()) {\n            technique.bind();\n            technique.setUniform1i(\"u_tex\", 0);\n            technique.setUniform1f(\"tn_gamma\", invGamma);\n            technique.setUniform1f(\"tn_exposure\", exposure);\n            technique.unbind();\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_SIMPLE_TMO_HPP */\n\n"
  },
  {
    "path": "include/gl/filtering/filter_slicer.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_SLICER_HPP\n#define PIC_GL_FILTERING_FILTER_SLICER_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLSlicer class\n */\nclass FilterGLSlicer: public FilterGL\n{\nprotected:\n\n    void initShaders();\n    void FragmentShader();\n\n    float s_S, s_R, mul_E;\n\npublic:\n    /**\n     * @brief FilterGLSlicer\n     * @param s_S\n     * @param s_R\n     */\n    FilterGLSlicer(float s_S, float s_R);\n\n    ~FilterGLSlicer();\n\n    /**\n     * @brief update\n     * @param s_S\n     * @param s_R\n     */\n    void update(float s_S, float s_R);\n};\n\nPIC_INLINE FilterGLSlicer::FilterGLSlicer(float s_S, float s_R): FilterGL()\n{\n    this->s_S = s_S;\n    this->s_R = s_R;\n\n    FragmentShader();\n    initShaders();\n}\n\nPIC_INLINE FilterGLSlicer::~FilterGLSlicer()\n{\n    release();\n}\n\nPIC_INLINE void FilterGLSlicer::FragmentShader()\n{\n    fragment_source = MAKE_STRING\n                      (\n                          uniform sampler2D\tu_tex;\n                          uniform sampler3D\tu_grid;\n                          uniform float\t\tmul_E;\n                          uniform float\t\ts_S;\n\n                          out     vec4       f_color;\n\n    void main(void) {\n        //Fetch texture color\n        ivec2 coordsFrag = ivec2(gl_FragCoord.xy);\n        vec4 colRef = texelFetch(u_tex, coordsFrag, 0);\n\n        //Fetch E\n        vec3 tSize3 = vec3(textureSize(u_grid, 0));\n        float E = dot(colRef.xyz, vec3(1.0)) * mul_E;\n        E /= tSize3.z;\n\n        //Fetch from the grid\n        vec2 coord = (gl_FragCoord.xy * s_S) / tSize3.xy;\n        vec4 sliced = texture(u_grid, vec3(coord.xy, E));\n\n        vec3 color = sliced.w > 0.0 ? sliced.xyz / sliced.w : vec3(0.0);\n\n        f_color = vec4(color.xyz, 1.0);\n    }\n                      );\n}\n\nPIC_INLINE void FilterGLSlicer::initShaders()\n{\n    technique.initStandard(\"400\", vertex_source, fragment_source, \"FilterGLSlicer\");\n\n    update(s_S, s_R);\n}\n\nPIC_INLINE void FilterGLSlicer::update(float s_S, float s_R)\n{\n    this->s_S = s_S;\n    this->s_R = s_R;\n\n    mul_E = s_R / 3.0f;\n\n#ifdef PIC_DEBUG\n    printf(\"Rate S: %f Rate R: %f Mul E: %f\\n\", s_S, s_R, mul_E);\n#endif\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.setUniform1i(\"u_grid\", 1);\n    technique.setUniform1f(\"s_S\", s_S);\n    technique.setUniform1f(\"mul_E\", mul_E);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_SLICER_HPP */\n"
  },
  {
    "path": "include/gl/filtering/filter_up_pp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_FILTER_UP_PP_HPP\n#define PIC_GL_FILTERING_FILTER_UP_PP_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/array.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLUpPP class\n */\nclass FilterGLUpPP: public FilterGL\n{\nprotected:\n\n    float threshold, *value;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders()\n    {\n        fragment_source = MAKE_STRING\n                          (\n                              uniform sampler2D u_tex0; \\n\n                              uniform sampler2D u_tex1; \\n\n                              uniform vec4    value; \\n\n                              uniform float   threshold; \\n\n                              out     vec4    f_color; \\n\n\n        void main(void) { \\n\n            ivec2 coords = ivec2(gl_FragCoord.xy); \\n\n            vec3 color = texelFetch(u_tex1, coords, 0).xyz; \\n\n\n            vec3 ret;\n\n            if(distance(color, value.xyz) < threshold) { \\n\n                ret = texelFetch(u_tex0, coords / ivec2(2), 0).xyz; \\n\n            } else { \\n\n                ret = color.xyz; \\n\n            }\\n\n\n            f_color = vec4(ret.xyz, 1.0); \\n\n        }\n                          );\n\n        technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLUpPP\");\n\n    }\n\npublic:\n    /**\n     * @brief FilterGLUpPP\n     * @param scale\n     */\n    FilterGLUpPP(float *value, float threshold) : FilterGL()\n    {\n        initShaders();\n        update(value, threshold);\n    }\n\n    ~FilterGLUpPP()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param value\n     * @param threshold\n     */\n    void update(float *value, float threshold)\n    {\n        this->value = value;\n\n        if(value == NULL) {\n            printf(\"Error in FilterGLUpPP\\n\");\n        }\n\n        this->threshold = (threshold > 0.0f) ? threshold : 1e-4f;\n\n        technique.bind();\n        technique.setUniform1i(\"u_tex0\", 0);\n        technique.setUniform1i(\"u_tex1\", 1);\n        technique.setUniform1f(\"threshold\", this->threshold);\n        technique.setUniform4fv(\"value\", this->value);\n        technique.unbind();\n    }\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageGLVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        if(imgIn.size() == 1) {\n            width = imgIn[0]->width << 1;\n            height = imgIn[0]->height << 1;\n        } else {\n            width = imgIn[1]->width;\n            height = imgIn[1]->height;\n        }\n\n        channels = imgIn[0]->channels;\n        frames = imgIn[0]->frames;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_UP_PP_HPP */\n"
  },
  {
    "path": "include/gl/filtering/filter_warp_2d.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_FILTERING_GL_FILTER_WARP_2D_HPP\n#define PIC_GL_FILTERING_GL_FILTER_WARP_2D_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/gl/fbo.hpp\"\n\n#include \"../../util/matrix_3_x_3.hpp\"\n#include \"../../filtering/filter_warp_2d.hpp\"\n#include \"../../gl/filtering/filter.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FilterGLWarp2D class\n */\nclass FilterGLWarp2D: public FilterGL\n{\nprotected:\n\n    int bmin[2], bmax[2];\n\n    Matrix3x3 h, h_inv;\n    bool bSameSize, bCentroid;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\npublic:\n\n    /**\n     * @brief FilterGLWarp2D\n     * @param h\n     * @param bSameSize\n     * @param bCentroid\n     */\n    FilterGLWarp2D();\n\n    /**\n     * @brief update\n     * @param h\n     * @param bSameSize\n     * @param bCentroid\n     */\n    void update(Matrix3x3 h, bool bSameSize, bool bCentroid);\n\n    /**\n     * @brief OutputSize\n     * @param imgIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    void OutputSize(ImageGLVec imgIn, int &width, int &height, int &channels, int &frames)\n    {\n        if(!bSameSize) {\n            FilterWarp2D::computeBoundingBox(h, bCentroid, imgIn[0]->widthf, imgIn[0]->heightf, bmin, bmax);\n        } else {\n            bmin[0] = 0;\n            bmin[1] = 0;\n\n            bmax[0] = imgIn[0]->width;\n            bmax[1] = imgIn[0]->height;\n        }\n\n        width = bmax[0] - bmin[0];\n        height = bmax[1] - bmin[1];\n        channels = imgIn[0]->channels;\n        frames = imgIn[0]->frames;\n    }\n\n    /**\n     * @brief setupAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *setupAux(ImageGLVec imgIn, ImageGL *imgOut)\n    {       \n        imgOut = allocateOutputMemory(imgIn, imgOut, false);\n\n        //update the technique\n        float mid[2];\n\n        if(bCentroid) {\n            mid[0] = imgIn[0]->widthf  * 0.5f;\n            mid[1] = imgIn[0]->heightf * 0.5f;\n        } else {\n            mid[0] = 0.0f;\n            mid[1] = 0.0f;\n        }\n\n        technique.bind();\n        technique.setUniform2f(\"mid\", mid[0], mid[1]);\n        technique.setUniform2f(\"inv_tSize\", 1.0f / imgIn[0]->widthf, 1.0f / imgIn[0]->heightf);\n        technique.unbind();\n\n        return imgOut;\n    }\n};\n\nPIC_INLINE FilterGLWarp2D::FilterGLWarp2D() : FilterGL()\n{\n    initShaders();\n\n    Matrix3x3 h;\n    update(h, false, false);\n}\n\nPIC_INLINE void FilterGLWarp2D::update(Matrix3x3 h, bool bSameSize = false, bool bCentroid = false)\n{\n    this->bSameSize = bSameSize;\n    this->bCentroid = bCentroid;\n\n    this->h = h;\n    h.inverse(&h_inv);\n\n    technique.bind();\n    technique.setUniform3x3(\"h_inv\", h_inv.data, true);\n    technique.unbind();\n}\n\nPIC_INLINE void FilterGLWarp2D::initShaders()\n{\n    //fragment program\n    fragment_source = MAKE_STRING\n                      (\n    uniform sampler2D u_tex; \\n\n    uniform mat3 h_inv; \\n\n    uniform vec2 mid; \\n\n    uniform vec2 inv_tSize; \\n\n    out  vec4 f_color; \\n\n    \\n\n    void main(void) {\n        vec2 coords   = gl_FragCoord.xy - mid;\\n\n        vec3 point_proj = h_inv * vec3(coords, 1.0);\n        point_proj /= point_proj.z;\n        point_proj.xy += mid;\n        point_proj.xy *= inv_tSize;\n        vec3 color = vec3(0.0);\n        if(point_proj.x >= 0.0 && point_proj.x <= 1.0 &&\n           point_proj.y >= 0.0 && point_proj.y <= 1.0) {\n            color = texture(u_tex, point_proj.xy).xyz;\\n\n        } \\n\n        f_color = vec4(color, 1.0); \\n\n    }\n    );\n\n    technique.initStandard(\"330\", vertex_source, fragment_source, \"FilterGLWarp2D\");\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex\", 0);\n    technique.unbind();\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_FILTERING_FILTER_WARP_2D_HPP */\n\n"
  },
  {
    "path": "include/gl/image.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_IMAGE_RAW_HPP\n#define PIC_GL_IMAGE_RAW_HPP\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n\n#include \"../gl.hpp\"\n#include \"../util/gl/fbo.hpp\"\n#include \"../util/gl/formats.hpp\"\n#include \"../util/gl/timings.hpp\"\n#include \"../util/gl/buffer_ops.hpp\"\n#include \"../util/gl/buffer_allocation.hpp\"\n#include \"../util/gl/mask.hpp\"\n#include \"../util/gl/redux.hpp\"\n#include \"../util/gl/redux_ops.hpp\"\n\nnamespace pic {\n\nenum IMAGESTORE {IMG_GPU_CPU, IMG_CPU_GPU, IMG_CPU, IMG_GPU, IMG_NULL};\n\n/**\n * @brief The ImageGL class\n */\nclass ImageGL: public Image\n{\nprotected:\n    GLuint      texture;\n    GLenum      target;\n    IMAGESTORE  mode;\t        //TODO: check if the mode is always correctly updated\n    bool        notOwnedGL;     //do we own the OpenGL texture??\n    Fbo         *tmpFbo;\n\n    //stack for statistics\n    std::vector<GLuint> stack;\n\n    /**\n     * @brief releaseGL\n     */\n    void releaseGL();\n\n    /**\n     * @brief assignGL assigns an (r, g, b, a) value to an image using glClearColor.\n     * @param r is the value for the red channel.\n     * @param g is the value for the green channel.\n     * @param b is the value for the blue channel.\n     * @param a is the value for the alpha channel.\n     */\n    void assignGL(float r = 0.0f, float g = 0.0f, float b = 0.0f,\n                  float a = 1.0f)\n    {\n        if(tmpFbo == NULL) {\n            tmpFbo = new Fbo();\n            tmpFbo->create(width, height, 1, false, texture);\n        }\n\n        glClearColor(r, g, b, a);\n\n        //Rendering\n        tmpFbo->bind();\n        glViewport(0, 0, (GLsizei)width, (GLsizei)height);\n        glClear(GL_COLOR_BUFFER_BIT);\n\n        //Fbo\n        tmpFbo->unbind();\n    }\n\n    /**\n     * @brief thisOperatorConst\n     * @param a\n     * @param op\n     */\n    inline void thisOperatorConst(const float &a, BOGL op)\n    {\n        BufferOpsGL *ops = BufferOpsGL::getInstance();\n\n        ops->list[op]->update(a);\n        ops->list[op]->Process(getTexture(), 0, getTexture(), width, height);\n    }\n\n    /**\n     * @brief thisOperatorConstColor\n     * @param a\n     * @param op\n     */\n    inline void thisOperatorConstColor(const Arrayf &a, BOGL op)\n    {\n        BufferOpsGL *ops = BufferOpsGL::getInstance();\n\n        float c0[4];\n        Arrayf::assign(a.data, MIN(a.nData, 4), c0);\n\n        ops->list[op]->update(c0);\n        ops->list[op]->Process(getTexture(), 0, getTexture(), width, height);\n    }\n\n    /**\n     * @brief thisOperatorImage\n     * @param a\n     * @param op\n     */\n    inline void thisOperatorImage(const ImageGL &a, BOGL op)\n    {\n        BufferOpsGL *ops = BufferOpsGL::getInstance();\n\n        if(channels == a.channels && width == a.width && height == a.height) {\n            ops->list[op]->Process(getTexture(), a.getTexture(), getTexture(), width, height);\n        } else {\n            if((nPixels() == a.nPixels()) && (a.channels == 1)) {\n                ops->list[op + 8]->Process(getTexture(), a.getTexture(), getTexture(), width, height);\n            }\n        }\n    }\n\n    /**\n     * @brief newOperatorConstColor\n     * @param a\n     * @param op\n     * @return\n     */\n    inline ImageGL newOperatorConstColor(const Arrayf &a, BOGL op)\n    {\n        ImageGL ret(frames, width, height, channels, IMG_GPU, target);\n        BufferOpsGL *ops = BufferOpsGL::getInstance();\n\n        float c0[4];\n        Arrayf::assign(a.data, MIN(a.nData, 4), c0);\n\n        ops->list[op]->update(c0);\n        ops->list[op]->Process(getTexture(), 0, ret.getTexture(), width, height);\n\n        return ret;\n    }\n\n    /**\n     * @brief newOperatorConst\n     * @param a\n     * @param op\n     * @return\n     */\n    inline ImageGL newOperatorConst(const float &a, BOGL op)\n    {\n        ImageGL ret(frames, width, height, channels, IMG_GPU, target);\n        BufferOpsGL *ops = BufferOpsGL::getInstance();\n\n        ops->list[op]->update(a);\n        ops->list[op]->Process(getTexture(), 0, ret.getTexture(), width, height);\n\n        return ret;\n    }\n\n    /**\n     * @brief newOperatorImage\n     * @param a\n     * @param op\n     */\n    inline ImageGL newOperatorImage(const ImageGL &a, BOGL op)\n    {\n        ImageGL ret(frames, width, height, channels, IMG_GPU, target);\n\n        BufferOpsGL *ops = BufferOpsGL::getInstance();\n\n        if(channels == a.channels && width == a.width && height == a.height) {\n            ops->list[op]->Process(getTexture(), a.getTexture(), ret.getTexture(), width, height);\n        } else {\n            if((nPixels() == a.nPixels()) && ((a.channels == 1) || (channels == 1))) {\n                if(a.channels == 1) {\n                    ops->list[op + 8]->Process(getTexture(), a.getTexture(), ret.getTexture(), width, height);\n                } else {\n                    ops->list[op + 8]->Process(a.getTexture(), getTexture(), ret.getTexture(), width, height);\n                }\n            }\n        }\n\n        return ret;\n    }\n\npublic:\n\n    /**\n     * @brief ImageGL\n     */\n    ImageGL();\n\n    ~ImageGL();\n\n    /**\n     * @brief ImageGL\n     * @param texture\n     * @param target\n     */\n    ImageGL(GLuint texture, GLenum target);\n\n    /**\n     * @brief ImageGL\n     * @param img\n     * @param transferOwnership\n     */\n    ImageGL(Image *img, bool transferOwnership);\n\n    /**\n     * @brief ImageGL\n     * @param img\n     * @param target\n     * @param mipmap\n     * @param transferOwnership\n     */\n    ImageGL(Image *img, GLenum target, bool mipmap, bool transferOwnership);\n\n    /**\n     * @brief ImageGL\n     * @param nameFile\n     */\n    ImageGL(std::string nameFile): Image(nameFile)\n    {\n        notOwnedGL = false;\n        mode = IMG_CPU;\n        texture = 0;\n        target = 0;\n        tmpFbo = NULL;\n    }\n\n    /**\n     * @brief Image\n     * @param frames\n     * @param width\n     * @param height\n     * @param channels\n     * @param data\n     */\n    ImageGL(int frames, int width, int height, int channels, float *data) : Image (frames, width, height, channels, data)\n    {\n        notOwnedGL = false;\n        mode = IMG_CPU;\n        texture = 0;\n        target = 0;\n        tmpFbo = NULL;\n    }\n\n    /**\n     * @brief ImageGL\n     * @param frames\n     * @param width\n     * @param height\n     * @param channels\n     * @param mode\n     */\n    ImageGL(int frames, int width, int height, int channels, IMAGESTORE mode, GLenum target);\n\n    /**\n     * @brief allocateSimilarOneGL\n     * @return\n     */\n    ImageGL *allocateSimilarOneGL();\n\n    /**\n     * @brief cloneGL\n     * @return\n     */\n    ImageGL *cloneGL();\n\n    /**\n     * @brief generateTextureGL\n     * @param target\n     * @param format_type\n     * @param mipmap\n     * @return\n     */\n    GLuint generateTextureGL(GLenum target, GLenum format_type, bool mipmap);\n\n    /**\n     * @brief loadSliceIntoTexture\n     * @param i\n     */\n    void loadSliceIntoTexture(int i);\n\n    /**\n     * @brief loadAllSlicesIntoTexture\n     */\n    void loadAllSlicesIntoTexture();\n\n    /**\n     * @brief loadFromMemory\n     */\n    void loadFromMemory();\n\n    /**\n     * @brief loadToMemory\n     */\n    void loadToMemory();\n\n    /**\n     * @brief readFromBindedFBO\n     */\n    void readFromBindedFBO();\n\n    /**\n     * @brief readFromFBO\n     * @param fbo\n     */\n    void readFromFBO(Fbo *fbo);\n\n    /**\n     * @brief readFromFBO\n     * @param fbo\n     * @param format\n     */\n    void readFromFBO(Fbo *fbo, GLenum format);\n\n    /**\n     * @brief bindTexture\n     */\n    void bindTexture();\n\n    /**\n     * @brief unBindTexture\n     */\n    void unBindTexture();\n\n    /**\n     * @brief updateModeGPU\n     */\n    void updateModeGPU()\n    {\n        if(mode == IMG_NULL) {\n            mode = IMG_GPU;\n        }\n\n        if(mode == IMG_CPU) {\n            mode = IMG_CPU_GPU;\n        }\n    }\n\n    /**\n     * @brief updateModeCPU\n     */\n    void updateModeCPU()\n    {\n        if(mode == IMG_NULL) {\n            mode = IMG_CPU;\n        }\n\n        if(mode == IMG_GPU) {\n            mode = IMG_CPU_GPU;\n        }\n    }\n\n    /**\n     * @brief getTexture\n     * @return\n     */\n    GLuint getTexture() const\n    {\n        return texture;\n    }\n\n    /**\n     * @brief setTexture\n     * @param texture\n     */\n    void setTexture(GLuint texture)\n    {\n        //TODO: UNSAFE!\n        this->texture = texture;\n    }\n\n    /**\n     * @brief getTarget\n     * @return\n     */\n    GLenum getTarget()\n    {\n        return target;\n    }\n\n    /**\n     * @brief getVal\n     * @param ret\n     * @param flt\n     * @return\n     */\n    float *getVal(float *ret, ReduxGL *flt)\n    {\n        if(texture == 0) {\n            return ret;\n        }\n\n        if(ret == NULL) {\n            ret = new float [channels];\n        }\n\n        if(stack.empty()) {\n            ReduxGL::allocateReduxData(width, height, channels, stack, 1);\n        }\n\n        GLuint output = flt->Redux(texture, width, height, channels, stack);\n\n        //copy data from GPU to main memory\n        int mode, modeInternalFormat;\n        getModesGL(channels, mode, modeInternalFormat);\n\n        glBindTexture(GL_TEXTURE_2D, output);\n        glGetTexImage(GL_TEXTURE_2D, 0, mode, GL_FLOAT, ret);\n        glBindTexture(GL_TEXTURE_2D, 0);\n\n        return ret;\n    }\n\n    /**\n     * @brief getMinVal\n     * @param imgIn\n     * @return\n     */\n    float *getMinVal(float *ret = NULL)\n    {\n        ReduxOpsGL *ops = ReduxOpsGL::getInstance();\n        return getVal(ret, ops->list[REDGL_MIN]);\n    }\n\n    /**\n     * @brief getMaxVal\n     * @param imgIn\n     * @param ret\n     * @return\n     */\n    float *getMaxVal(float *ret = NULL)\n    {\n        ReduxOpsGL *ops = ReduxOpsGL::getInstance();\n        return getVal(ret, ops->list[REDGL_MAX]);\n    }\n\n    /**\n     * @brief getSumVal\n     * @param imgIn\n     * @param ret\n     * @return\n     */\n    float *getSumVal(float *ret = NULL)\n    {\n        ReduxOpsGL *ops = ReduxOpsGL::getInstance();\n        return getVal(ret, ops->list[REDGL_SUM]);\n    }\n\n    /**\n     * @brief getMeanVal\n     * @param imgIn\n     * @return\n     */\n    float *getMeanVal(float *ret = NULL)\n    {\n        ReduxOpsGL *ops = ReduxOpsGL::getInstance();\n        return getVal(ret, ops->list[REDGL_MEAN]);\n    }\n\n    /**\n     * @brief getLogMeanVal\n     * @param imgIn\n     * @return\n     */\n    float *getLogMeanVal(float *ret = NULL)\n    {\n        ReduxOpsGL *ops = ReduxOpsGL::getInstance();\n\n        ret = getVal(ret, ops->list[REDGL_LOG_MEAN]);\n\n        for(int i = 0; i < channels; i++) {\n            ret[i] = expf(ret[i]);\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief clamp\n     * @param a\n     * @param b\n     */\n    void clamp(float a, float b);\n\n    /**\n     * @brief operator =\n     * @param a\n     */\n    void operator =(const ImageGL &a);\n\n    /**\n     * @brief operator =\n     * @param a\n     */\n    void operator =(const float &a);\n\n    /**\n     * @brief operator +=\n     * @param a\n     */\n    void operator +=(const ImageGL &a);\n\n    /**\n     * @brief operator +=\n     * @param a\n     */\n    void operator +=(const float &a);\n\n    /**\n     * @brief operator +\n     * @param a\n     * @return\n     */\n    ImageGL operator +(const ImageGL &a);\n\n    /**\n     * @brief operator +\n     * @param a\n     * @return\n     */\n    ImageGL operator +(const float &a);\n\n    /**\n     * @brief operator -=\n     * @param a\n     */\n    void operator -=(const ImageGL &a);\n\n    /**\n     * @brief operator -=\n     * @param a\n     */\n    void operator -=(const float &a);\n\n    /**\n     * @brief operator -\n     * @param a\n     * @return\n     */\n    ImageGL operator -(const ImageGL &a);\n\n    /**\n     * @brief operator -\n     * @param a\n     * @return\n     */\n    ImageGL operator -(const float &a);\n\n    /**\n     * @brief operator *=\n     * @param a\n     */\n    void operator *=(const ImageGL &a);\n\n    /**\n     * @brief operator *=\n     * @param a\n     */\n    void operator *=(const float &a);\n\n    /**\n     * @brief operator *\n     * @param a\n     * @return\n     */\n    ImageGL operator *(const ImageGL &a);\n\n    /**\n     * @brief operator *\n     * @param a\n     * @return\n     */\n    ImageGL operator *(const float &a);\n\n    /**\n     * @brief operator /=\n     * @param a\n     */\n    void operator /=(const ImageGL &a);\n\n    /**\n     * @brief operator /=\n     * @param a\n     */\n    void operator /=(const float &a);\n\n    /**\n     * @brief operator /=\n     * @param a\n     */\n    void operator /=(const Arrayf &a);\n\n    /**\n     * @brief operator /\n     * @param a\n     * @return\n     */\n    ImageGL operator /(const ImageGL &a);\n\n    /**\n     * @brief operator /\n     * @param a\n     * @return\n     */\n    ImageGL operator /(const float &a);\n};\n\nPIC_INLINE ImageGL::ImageGL() : Image()\n{\n    notOwnedGL = false;\n    texture = 0;\n    target = 0;\n    mode = IMG_NULL;\n    tmpFbo = NULL;\n}\n\nPIC_INLINE ImageGL::ImageGL(GLuint texture, GLuint target) : Image()\n{\n    notOwnedGL = true;\n\n    tmpFbo = NULL;\n\n    mode = IMG_GPU;\n\n    this->texture = texture;\n\n    this->target = target;\n\n    getTextureInformationGL(texture, target, width, height, frames, channels);\n\n    allocateAux();\n}\n\nPIC_INLINE ImageGL::ImageGL(Image *img, GLenum target, bool mipmap, bool transferOwnership = false): Image()\n{\n    if(transferOwnership) {\n        notOwned = false;\n        img->changeOwnership(true);\n    } else {\n        notOwned = true;\n    }\n\n    notOwnedGL = false;\n\n    tmpFbo = NULL;\n\n    width    = img->width;\n    height   = img->height;\n    frames   = img->frames;\n    channels = img->channels;\n    data     = img->data;\n\n    allocateAux();\n\n    texture = 0;\n\n    generateTextureGL(target, GL_FLOAT, mipmap);\n\n    mode = IMG_CPU_GPU;\n}\n\nPIC_INLINE ImageGL::ImageGL(Image *img, bool transferOwnership = false) : Image()\n{\n    if(transferOwnership) {\n        notOwned = false;\n        img->changeOwnership(true);\n    } else {\n        notOwned = true;\n    }\n\n    notOwnedGL = false;\n\n    tmpFbo = NULL;\n\n    width    = img->width;\n    height   = img->height;\n    frames   = img->frames;\n    channels = img->channels;\n    data     = img->data;\n\n    allocateAux();\n\n    texture = 0;\n\n    mode = IMG_CPU;\n}\n\nPIC_INLINE ImageGL::ImageGL(int frames, int width, int height, int channels,\n                       IMAGESTORE mode, GLenum target) : Image()\n{\n    notOwnedGL = false;\n    tmpFbo = NULL;\n\n    this->mode = mode;\n\n    if(this->mode == IMG_GPU_CPU) {\n        this->mode = IMG_CPU_GPU;\n    }\n\n    switch(this->mode) {\n\n    case IMG_CPU_GPU: {\n        allocate(width, height, channels, frames);\n\n        generateTextureGL(target, GL_FLOAT, false);\n    }\n    break;\n\n    case IMG_CPU: {\n        allocate(width, height, channels, frames);\n    }\n    break;\n\n    case IMG_GPU: {\n        this->width = width;\n        this->height = height;\n        this->frames = frames;\n        this->depth = frames;\n        this->channels = channels;\n\n        allocateAux();\n\n        generateTextureGL(target, GL_FLOAT, false);\n    }\n    break;\n\n    default: {\n\n    }break;\n\n    }\n}\n\nPIC_INLINE ImageGL::~ImageGL()\n{   \n    releaseGL();\n    release();\n}\n\n/**\n * @brief ImageGL::generateTextureGL\n * @param target\n * @param format_type\n * @param mipmap\n * @return\n */\nPIC_INLINE GLuint ImageGL::generateTextureGL(GLenum target = GL_TEXTURE_2D, GLenum format_type = GL_FLOAT, bool mipmap = false)\n{\n    this->texture = 0;\n    this->target  = target;\n\n    updateModeGPU();\n\n    if(format_type == GL_INT) {\n        int *buffer = new int[width * height * channels];\n\n        for(int i = 0; i < (width * height * channels); i++) {\n            buffer[i] = int(lround(data[i]));\n        }\n\n        texture = generateTexture2DU32GL(width, height, channels, buffer);\n\n        delete[] buffer;\n\n        return texture;\n    }\n\n    switch(target) {\n        case GL_TEXTURE_2D:\n        {\n            texture = generateTexture2DGL(width, height, channels, data, mipmap);\n        } break;\n\n        case GL_TEXTURE_3D:\n        {\n            if(frames > 1) {\n                texture = generateTexture3DGL(width, height, channels, frames, data);\n            } else {\n                texture = generateTexture2DGL(width, height, channels, data, mipmap);\n                this->target = GL_TEXTURE_2D;\n            }\n        } break;\n\n        case GL_TEXTURE_2D_ARRAY: {\n            texture = generateTexture2DArrayGL(width, height, channels, frames, data);\n        } break;\n\n        case GL_TEXTURE_CUBE_MAP: {\n            if(frames > 5) {\n                texture = generateTextureCubeMapGL(width, height, channels, frames, data);\n            } else {\n                if(frames > 1) {\n                    texture = generateTexture2DArrayGL(width, height, channels, frames, data);\n                    this->target = GL_TEXTURE_2D_ARRAY;\n                } else {\n                    texture = generateTexture2DGL(width, height, channels, data, mipmap);\n                    this->target = GL_TEXTURE_2D;\n                }\n            }\n        } break;\n    }\n\n    return texture;\n}\n\nPIC_INLINE ImageGL *ImageGL::cloneGL()\n{\n    //call Image clone function\n    Image *tmp = this->clone();\n\n    //wrap tmp into an ImageGL\n    return new ImageGL(tmp, target, false, true);\n}\n\nPIC_INLINE void ImageGL::releaseGL()\n{\n    if(notOwnedGL) {\n        return;\n    }\n\n    if(texture != 0) {\n        glDeleteTextures(1, &texture);\n        texture = 0;\n        target = 0;\n    }\n\n    uint n = stack.size();\n    for(uint i = 0; i < n; i++) {\n        if(stack[i] != 0) {\n            glDeleteTextures(1, &stack[i]);\n            stack[i] = 0;\n        }\n    }\n}\n\nPIC_INLINE ImageGL *ImageGL::allocateSimilarOneGL()\n{\n#ifdef PIC_DEBUG\n    printf(\"ImageGL::allocateSimilarOneGL -- %d %d %d %d %d\\n\", frames, width, height, channels, mode);\n#endif\n\n    ImageGL *ret = new ImageGL(frames, width, height, channels, mode, target);\n    return ret;\n}\n\nPIC_INLINE void ImageGL::loadFromMemory()\n{\n    int mode, modeInternalFormat;\n    getModesGL(channels, mode, modeInternalFormat);\n\n    glBindTexture(target, texture);\n\n    switch(target) {\n        case GL_TEXTURE_2D: {\n            glTexImage2D(target, 0, modeInternalFormat, width, height, 0,\n                         mode, GL_FLOAT, data);\n\n        } break;\n\n        case GL_TEXTURE_3D: {\n            glTexImage3D(GL_TEXTURE_3D, 0, modeInternalFormat, width, height, frames, 0,\n                         mode, GL_FLOAT, data);\n        } break;\n    }\n\n    glBindTexture(target, 0);\n}\n\nPIC_INLINE void ImageGL::loadToMemory()\n{\n    if(texture == 0) {\n        #ifdef PIC_DEBUG\n            printf(\"This texture can not be trasferred from GPU memory\\n\");\n        #endif\n        return;\n    }\n\n    if(data == NULL) {\n        #ifdef PIC_DEBUG\n            printf(\"RAM memory allocated: %d %d %d %d\\n\", width, height, channels, frames);\n        #endif\n\n        allocate(width, height, channels, frames);\n        this->mode = IMG_CPU_GPU;\n    }\n\n    int mode, modeInternalFormat;\n    getModesGL(channels, mode, modeInternalFormat);\n\n    bindTexture();\n\n    glGetTexImage(target, 0, mode, GL_FLOAT, data);\n\n    unBindTexture();\n}\n\nPIC_INLINE void ImageGL::loadSliceIntoTexture(int i)\n{\n    int mode, modeInternalFormat;\n    getModesGL(channels, mode, modeInternalFormat);\n\n    glBindTexture(target, texture);\n    i = i % frames;\n    glTexSubImage3D(target, 0, 0, 0, i, width, height, 1, mode, GL_FLOAT,\n                    &data[i * tstride]);\n\n    glBindTexture(target, 0);\n}\n\nPIC_INLINE void ImageGL::loadAllSlicesIntoTexture()\n{\n    if(target != GL_TEXTURE_3D && target != GL_TEXTURE_2D_ARRAY) {\n        return;\n    }\n\n    for(int i = 0; i < frames; i++) {\n        loadSliceIntoTexture(i);\n    }\n}\n\nPIC_INLINE void ImageGL::readFromFBO(Fbo *fbo, GLenum format)\n{\n    //TO DO: check data\n    bool bCheck =   (fbo->width  != width) ||\n                    (fbo->height != height);\n\n    if(data == NULL || bCheck) {\n        allocate(fbo->width, fbo->height, 4, 1);\n    }\n\n    //ReadPixels from the FBO\n    fbo->bind();\n    glReadPixels(0, 0, width, height, format, GL_FLOAT, data);\n    fbo->unbind();\n\n    /*\tglBindTexture(GL_TEXTURE_2D, fbo->tex);\n    \tglGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, data);\n    \tglBindTexture(GL_TEXTURE_2D, 0);*/\n}\n\nPIC_INLINE void ImageGL::readFromFBO(Fbo *fbo)\n{\n    if(mode == IMG_NULL) {\n        mode = IMG_CPU;\n    }\n\n    readFromFBO(fbo, GL_RGBA);\n}\n\nPIC_INLINE void ImageGL::readFromBindedFBO()\n{\n\n    int mode, modeInternalFormat;\n    getModesGL(channels, mode, modeInternalFormat);\n\n    if(mode == 0x0) {\n        #ifdef PIC_DEBUG\n            printf(\"void ImageGL::readFromBindedFBO(): error unknown format!\");\n        #endif\n        return;\n    }\n\n    //TODO: check width height and data (mode and modeInternalFormat)\n\n    glReadPixels(0, 0, width, height, mode, GL_FLOAT, data);\n    flipV();\n}\n\nPIC_INLINE void ImageGL::bindTexture()\n{\n    glBindTexture(target, texture);\n}\n\nPIC_INLINE void ImageGL::unBindTexture()\n{\n    glBindTexture(target, 0);\n}\n\nPIC_INLINE void ImageGL::clamp(float a = 0.0f, float b = 1.0f)\n{\n    BufferOpsGL *ops = BufferOpsGL::getInstance();\n    ops->list[BOGL_CLAMP]->update(a, b);\n    ops->list[BOGL_CLAMP]->Process(getTexture(), 0, getTexture(), width, height);\n}\n\nPIC_INLINE void ImageGL::operator =(const ImageGL &a)\n{\n    thisOperatorImage(a, BOGL_ID);\n}\n\nPIC_INLINE void ImageGL::operator =(const float &a)\n{\n    thisOperatorConst(a, BOGL_ID_CONST);\n}\n\nPIC_INLINE void ImageGL::operator +=(const ImageGL &a)\n{\n    thisOperatorImage(a, BOGL_ADD);\n}\n\nPIC_INLINE void ImageGL::operator +=(const float &a)\n{\n    thisOperatorConst(a, BOGL_ADD_CONST);\n}\n\nPIC_INLINE ImageGL ImageGL::operator +(const ImageGL &a)\n{\n    return newOperatorImage(a, BOGL_ADD);\n}\n\nPIC_INLINE ImageGL ImageGL::operator +(const float &a)\n{\n    return newOperatorConst(a, BOGL_ADD_CONST);\n}\n\nPIC_INLINE void ImageGL::operator -=(const ImageGL &a)\n{\n    thisOperatorImage(a, BOGL_SUB);\n}\n\nPIC_INLINE void ImageGL::operator -=(const float &a)\n{\n    thisOperatorConst(a, BOGL_SUB_CONST);\n}\n\nPIC_INLINE ImageGL ImageGL::operator -(const ImageGL &a)\n{\n    return newOperatorImage(a, BOGL_SUB);\n}\n\nPIC_INLINE ImageGL ImageGL::operator -(const float &a)\n{\n    return newOperatorConst(a, BOGL_SUB_CONST);\n}\n\nPIC_INLINE void ImageGL::operator *=(const ImageGL &a)\n{\n    thisOperatorImage(a, BOGL_MUL);\n}\n\nPIC_INLINE void ImageGL::operator *=(const float &a)\n{\n    thisOperatorConst(a, BOGL_MUL_CONST);\n}\n\nPIC_INLINE ImageGL ImageGL::operator *(const ImageGL &a)\n{\n    return newOperatorImage(a, BOGL_MUL);\n}\n\nPIC_INLINE ImageGL ImageGL::operator *(const float &a)\n{\n    return newOperatorConst(a, BOGL_MUL_CONST);\n}\n\nPIC_INLINE void ImageGL::operator /=(const ImageGL &a)\n{\n    thisOperatorImage(a, BOGL_DIV);\n}\n\nPIC_INLINE void ImageGL::operator /=(const float &a)\n{\n    thisOperatorConst(a, BOGL_DIV_CONST);\n}\n\nPIC_INLINE void ImageGL::operator /=(const Arrayf &a)\n{\n    thisOperatorConstColor(a, BOGL_DIV_CONST);\n}\n\nPIC_INLINE ImageGL ImageGL::operator /(const ImageGL &a)\n{\n    return newOperatorImage(a, BOGL_DIV);\n}\n\nPIC_INLINE ImageGL ImageGL::operator /(const float &a)\n{\n    return newOperatorConst(a, BOGL_DIV_CONST);\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_IMAGE_RAW_HPP */\n\n"
  },
  {
    "path": "include/gl/image_vec.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_IMAGE_RAW_VEC_HPP\n#define PIC_GL_IMAGE_RAW_VEC_HPP\n\n#include <vector>\n\n#include \"../base.hpp\"\n\n#include \"../gl/image.hpp\"\n\nnamespace pic {\n\n/**\n * @brief ImageGLVec an std::vector of pic::ImageGL\n */\ntypedef\tstd::vector<ImageGL*> ImageGLVec;\n\n/**\n * @brief SingleGL creates a single for filters input.\n * @param img\n * @return\n */\nPIC_INLINE ImageGLVec SingleGL(ImageGL *img)\n{\n    ImageGLVec ret;\n    ret.push_back(img);\n    return ret;\n}\n\n/**\n * @brief DoubleGL creates a couple for filters input.\n * @param img1\n * @param img2\n * @return\n */\nPIC_INLINE ImageGLVec DoubleGL(ImageGL *img1, ImageGL *img2)\n{\n    ImageGLVec ret;\n    ret.push_back(img1);\n    ret.push_back(img2);\n    return ret;\n}\n\n/**\n * @brief TripleGL creates a triple for filters input.\n * @param img1\n * @param img2\n * @param img3\n * @return\n */\nPIC_INLINE ImageGLVec TripleGL(ImageGL *img1, ImageGL *img2, ImageGL *img3)\n{\n    ImageGLVec ret;\n    ret.push_back(img1);\n    ret.push_back(img2);\n    ret.push_back(img3);\n    return ret;\n}\n\n/**\n * @brief ImageGLVecCheck\n * @param vec\n * @param minInputImages\n * @return\n */\nPIC_INLINE bool ImageGLVecCheck(ImageGLVec &imgIn, int minInputImages)\n{\n    int n;\n    if(minInputImages < 0) {\n        n = int(imgIn.size());\n    } else {\n        if(int(imgIn.size()) < minInputImages) {\n            return false;\n        }\n\n        n = minInputImages;\n    }\n\n    for(int i = 0; i < n; i ++) {\n        if(imgIn[i] == NULL) {\n            return false;\n        } else {\n           /*\n            *  if(!imgIn[i]->isValid()) {\n                return false;\n            }*/\n        }\n    }\n\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_IMAGE_RAW_VEC_HPP */\n\n"
  },
  {
    "path": "include/gl/point_samplers/sampler_random_m.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_POINT_SAMPLERS_SAMPLER_RANDOM_M_HPP\n#define PIC_GL_POINT_SAMPLERS_SAMPLER_RANDOM_M_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl/image.hpp\"\n\n#include \"../../point_samplers/sampler_random_m.hpp\"\n\nnamespace pic {\n\n/**\n * @brief glGetPrintError\n */\nPIC_INLINE void glGetPrintError()\n{\n    GLenum err = glGetError();\n\n    if(err != GL_NO_ERROR) {\n        printf(\"----------- %d\\n\", err);\n    }\n}\n\n/**\n * @brief The MRSamplersGL class\n */\ntemplate <unsigned int N>\nclass MRSamplersGL: public MRSamplers<N>\n{\nprotected:\n    GLuint texture;\n    GLuint levelsRtexture;\n    int width, height;\n\npublic:\n    int\t\tnSamples;\n\n    /**\n     * @brief MRSamplersGL\n     * @param type\n     * @param window\n     * @param nSamples\n     * @param nLevels\n     * @param nSamplers\n     */\n    MRSamplersGL(SAMPLER_TYPE type, Vec<N, int> window, int nSamples, int nLevels,\n                 int nSamplers): MRSamplers<N>(type, window, nSamples, nLevels, nSamplers)\n    {\n        texture = 0;\n    }\n\n    /**\n     * @brief updateGL\n     * @param window\n     * @param nSamples\n     */\n    void   updateGL(Vec<N, int> window, int nSamples);\n\n    /**\n     * @brief getTexture\n     * @return\n     */\n    GLuint getTexture()\n    {\n        return texture;\n    }\n\n    /**\n     * @brief getImage\n     * @return\n     */\n    ImageGL *getImage()\n    {\n        ImageGL *ret = new ImageGL(texture, GL_TEXTURE_2D);\n\n        return ret;\n    }\n\n    /**\n     * @brief getImageLevelsR\n     * @return\n     */\n    ImageGL *getImageLevelsR()\n    {\n        ImageGL *ret = new ImageGL(levelsRtexture, GL_TEXTURE_2D);\n\n        return ret;\n    }\n\n    /**\n     * @brief generateTexture\n     * @return\n     */\n    GLuint generateTexture();\n\n    /**\n     * @brief getLevelsRTexture\n     * @return\n     */\n    GLuint getLevelsRTexture()\n    {\n        return levelsRtexture;\n    }\n\n    /**\n     * @brief generateLevelsRTexture\n     * @return\n     */\n    GLuint generateLevelsRTexture();\n};\n\ntemplate <unsigned int N> void MRSamplersGL<N>::updateGL(Vec<N, int> window,\n        int nSamples)\n{\n    if(texture == -1) {\n        return;\n    }\n\n#ifdef PIC_DEBUG\n    printf(\"window: %d %d\\n\", window[0], window[1]);\n#endif\n\n    if(!this->update(window, nSamples)) {\n        return;\n    }\n\n    glDeleteTextures(1, &texture);\n    generateTexture();\n\n    this->oldSamples = nSamples;\n    this->oldWindow = window;\n}\n\ntemplate <unsigned int N> GLuint MRSamplersGL<N>::generateTexture()\n{\n    if(this->nSamplers <= 0) {\n        texture = 0;\n\n#ifdef PIC_DEBUG\n        printf(\"No samplers in MRSamplersGL.\\n\");\n#endif\n        nSamples = -1;\n        return 0;\n    }\n\n    nSamples = int(this->samplers[0]->samplesR.size());\n\n    for(int i = 1; i < this->nSamplers; i++) {\n        nSamples = MIN(nSamples, int(this->samplers[i]->samplesR.size()));\n    }\n\n#ifdef PIC_DEBUG\n    printf(\"Samples in samplers: %d %d\\n\", nSamples / N, N);\n#endif\n\n    //Create the buffer in the main memory\n    int *buffer = new int [this->nSamplers * (nSamples / N) * 4];\n\n    int ind = 0;\n\n    for(int i = 0; i < this->nSamplers; i++) {\n        for(int j = 0; j < nSamples; j += N) {\n            int ind2 = ind * 4;\n\n            for(int k = 0; k < 4; k++) {\n                buffer[ind2 + k] = 0;\n            }\n\n            for(int k = 0; k < N; k++) {\n                buffer[ind2 + k]   = this->samplers[i]->samplesR[j + k];\n            }\n\n            buffer[ind2 + N] =\tthis->samplers[i]->samplesR[j]\t*\n                                this->samplers[i]->samplesR[j] +\n                                this->samplers[i]->samplesR[j + 1] * this->samplers[i]->samplesR[j + 1];\n            ind++;\n        }\n    }\n\n    //Transfer the buffer into graphics card's memory\n    glGenTextures(1, &texture);\n    glBindTexture(GL_TEXTURE_2D, texture);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);\n    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);\n\n    width = nSamples / N;\n    height = this->nSamplers;\n\n    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32I, width, height, 0,\n                 GL_RGBA_INTEGER, GL_INT, buffer);\n\n    //nSamples = nSamples>>1;\n    //glGenerateMipmap(GL_TEXTURE_2D);\n\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    //release memory from the buffer\n    delete[] buffer;\n    return texture;\n}\n\ntemplate <unsigned int N> GLuint MRSamplersGL<N>::generateLevelsRTexture()\n{\n    //Create the buffer in the main memory\n    int *buffer = new int [this->nSamplers * this->nLevels];\n    int ind = 0;\n\n    for(int i = 0; i < this->nSamplers; i++) {\n        for(int j = 0; j < this->nLevels; j++) {\n            buffer[ind] = this->samplers[i]->levelsR[j];\n            printf(\"%d \", buffer[ind]);\n            ind++;\n        }\n\n        printf(\"\\n\");\n    }\n\n    //Transfer the buffer into graphics card's memory\n    glGenTextures(1, &levelsRtexture);\n    glBindTexture(GL_TEXTURE_2D, levelsRtexture);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);\n    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);\n\n    glTexImage2D(GL_TEXTURE_2D, 0, GL_R32I, this->nLevels, this->nSamplers, 0,\n                 GL_RED_INTEGER, GL_INT, buffer);\n\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    //release memory from the buffer\n    delete[] buffer;\n    return levelsRtexture;\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_POINT_SAMPLERS_SAMPLER_RANDOM_M_HPP */\n\n"
  },
  {
    "path": "include/gl/tone_mapping/drago_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_TONE_MAPPING_DRAGO_TMO_HPP\n#define PIC_GL_TONE_MAPPING_DRAGO_TMO_HPP\n\n#include <vector>\n\n#include \"../../util/array.hpp\"\n#include \"../../util/math.hpp\"\n#include \"../../gl/filtering/filter_luminance.hpp\"\n#include \"../../gl/filtering/filter_drago_tmo.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The DragoTMOGL class\n */\nclass DragoTMOGL\n{\nprotected:\n    FilterGLLuminance *flt_lum;\n    FilterGLDragoTMO  *flt_tmo;\n    std::vector<FilterGL* > filters;\n\n    ImageGL *img_lum;\n    float LMax, Lwa, Ld_Max, bias;\n    bool bStatisticsRecompute, bAllocate;\n\n    /**\n     * @brief allocateFilters\n     */\n    void allocateFilters()\n    {\n        bAllocate = true;\n        flt_lum = new FilterGLLuminance();\n        flt_tmo = new FilterGLDragoTMO();\n\n        filters.push_back(flt_lum);\n        filters.push_back(flt_tmo);\n    }\n\npublic:\n    /**\n     * @brief DragoTMOGL\n     */\n    DragoTMOGL(float Ld_Max = 100.0f, float bias = 0.85f, bool bStatisticsRecompute = true)\n    {\n        update(Ld_Max, bias);\n\n        img_lum = NULL;\n\n        bAllocate = false;\n\n        LMax = -1.0f;\n        Lwa = -1.0f;\n\n        this->bStatisticsRecompute = bStatisticsRecompute;\n    }\n\n    ~DragoTMOGL()\n    {\n        stdVectorClear<FilterGL>(filters);\n        img_lum = delete_s(img_lum);\n    }\n\n    /**\n     * @brief update\n     * @param Ld_Max\n     * @param bias\n     */\n    void update(float Ld_Max = 100.0f, float bias = 0.95f)\n    {\n        this->Ld_Max = Ld_Max > 0.0f ? Ld_Max : 100.0f;\n        this->bias = CLAMPi(bias, 0.0f, 1.0f);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut = NULL)\n    {\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        if(!bAllocate) {\n            allocateFilters();\n        }\n\n        img_lum = flt_lum->Process(SingleGL(imgIn), img_lum);\n\n        if(bStatisticsRecompute || (LMax < 0.0f)) {\n            img_lum->getMaxVal(&LMax);\n            img_lum->getLogMeanVal(&Lwa);\n        }\n\n        flt_tmo->update(Ld_Max, bias, LMax, Lwa);\n        imgOut = flt_tmo->Process(DoubleGL(imgIn, img_lum), imgOut);\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_TONE_MAPPING_DRAGO_TMO_HPP */\n\n"
  },
  {
    "path": "include/gl/tone_mapping/durand_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_TONE_MAPPING_DURAND_TMO_HPP\n#define PIC_GL_TONE_MAPPING_DURAND_TMO_HPP\n\n#include \"../../util/string.hpp\"\n#include \"../../util/math.hpp\"\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/filtering/filter_luminance.hpp\"\n#include \"../../gl/filtering/filter_bilateral_2ds.hpp\"\n#include \"../../gl/filtering/filter_op.hpp\"\n#include \"../../gl/filtering/filter_durand_tmo.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The DurandTMOGL class\n */\nclass DurandTMOGL\n{\nprotected:\n    FilterGLLuminance       *flt_lum;\n    FilterGLBilateral2DS    *flt_bil;\n    FilterGLOp              *flt_log10;\n    FilterGLDurandTMO       *flt_durand;\n    ImageGL                 *img_lum, *img_lum_base;\n\n    std::vector<FilterGL*> filters;\n\n    bool bAllocate, bStatisticsRecompute;\n    float min_log_base, max_log_base, target_contrast;\n\n    float sigma_s, sigma_r;\n\n    /**\n     * @brief allocateFilters\n     */\n    void allocateFilters()\n    {\n        bAllocate = true;\n\n        flt_lum = new FilterGLLuminance();\n        flt_log10 = new FilterGLOp(\"log(I0) * \" + fromNumberToString(1.0f / logf(10.0f)), true, NULL, NULL);\n        flt_durand = new FilterGLDurandTMO();\n        flt_bil = new FilterGLBilateral2DS(sigma_s, sigma_r);\n\n        filters.push_back(flt_lum);\n        filters.push_back(flt_log10);\n        filters.push_back(flt_durand);\n        filters.push_back(flt_bil);\n    }\n\npublic:\n\n    /**\n     * @brief DurandTMOGL\n     */\n    DurandTMOGL(float target_contrast = 5.0f, bool bStatisticsRecompute = true)\n    {\n        bAllocate = false;\n\n        this->sigma_r = 0.4f;\n\n        update(target_contrast);\n\n        img_lum = NULL;\n        img_lum_base = NULL;\n\n        min_log_base = -1e10f;\n        max_log_base = -1e10f;\n\n        this->bStatisticsRecompute = bStatisticsRecompute;\n    }\n\n    ~DurandTMOGL()\n    {       \n        stdVectorClear<FilterGL>(filters);\n        delete img_lum;\n        delete img_lum_base;\n    }\n\n    /**\n     * @brief update\n     * @param target_contrast\n     */\n    void update(float target_contrast)\n    {\n        this->target_contrast = target_contrast > 0.0f ? target_contrast : 5.0f;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut = NULL)\n    {\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        if(!bAllocate) {\n            allocateFilters();\n        }\n\n        this->sigma_s = MAX(imgIn->widthf, imgIn->heightf) * 0.02f;\n        flt_bil->update(sigma_s, sigma_r, BF_CLASSIC);\n\n        img_lum = flt_lum->Process(SingleGL(imgIn), img_lum);\n\n        img_lum = flt_log10->Process(SingleGL(img_lum), img_lum);\n\n        img_lum_base = flt_bil->Process(SingleGL(img_lum), img_lum_base);\n\n         if(bStatisticsRecompute || (min_log_base < -1e6f) || (max_log_base < -1e6f)) {\n            img_lum_base->getMaxVal(&max_log_base);\n            img_lum_base->getMinVal(&min_log_base);\n         }\n\n        float compression_factor = log10fPlusEpsilon(target_contrast) / (max_log_base - min_log_base);\n        float log_absoulte = compression_factor * max_log_base;\n\n        flt_durand->update(compression_factor, log_absoulte);\n\n        return flt_durand->Process(TripleGL(imgIn, img_lum, img_lum_base), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_TONE_MAPPING_DURAND_TMO_HPP */\n\n"
  },
  {
    "path": "include/gl/tone_mapping/exposure_fusion.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_TONE_MAPPING_EXPOSURE_FUSION_TMO_HPP\n#define PIC_GL_TONE_MAPPING_EXPOSURE_FUSION_TMO_HPP\n\n#include \"../../util/math.hpp\"\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/tone_mapping/get_all_exposures.hpp\"\n\n#include \"../../gl/algorithms/pyramid.hpp\"\n#include \"../../gl/filtering/filter_luminance.hpp\"\n#include \"../../gl/filtering/filter_exposure_fusion_weights.hpp\"\n#include \"../../gl/filtering/filter_op.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ExposureFusionGL class\n */\nclass ExposureFusionGL\n{\nprotected:\n    std::vector<FilterGL *> filters;\n    std::vector<PyramidGL *> pyramids;\n    ImageGLVec images;\n\n    FilterGLLuminance *flt_lum;\n    FilterGLExposureFusionWeights *flt_weights;\n    FilterGLOp *removeNegative;\n\n    ImageGL *lum, *acc, *weights;\n\n    PyramidGL *pW, *pI, *pOut;\n\n    float wC, wS, wE;\n\n    bool bAllocatedFilters;\n    bool bAllocate;\n\n    /**\n     * @brief allocateFilters\n     */\n    void allocateFilters()\n    {\n        if(!bAllocatedFilters) {\n            flt_lum = new FilterGLLuminance();\n            flt_lum->update(LT_LUMA);\n            flt_lum->bDelete = true;\n            filters.push_back(flt_lum);\n\n            removeNegative = new FilterGLOp(\"max(I0, vec4(0.0))\", true, NULL, NULL);\n            removeNegative->bDelete = true;\n            filters.push_back(removeNegative);\n\n            flt_weights = new FilterGLExposureFusionWeights(wC, wE, wS);\n            flt_weights->bDelete = true;\n            filters.push_back(flt_weights);\n            bAllocatedFilters = true;\n        }\n    }\n\npublic:\n    /**\n     * @brief ExposureFusionGL\n     */\n    ExposureFusionGL(float wC = 1.0f, float wE = 1.0f, float wS = 1.0f)\n    {\n        bAllocate = false;\n        bAllocatedFilters = false;\n\n        update(wC, wE, wS);\n\n        lum = NULL;\n        acc = NULL;\n        weights = NULL;\n\n        pW = NULL;\n        pI = NULL;\n        pOut = NULL;\n    }\n\n    ~ExposureFusionGL()\n    {\n        stdVectorClear<ImageGL>(images);\n        stdVectorClear<PyramidGL>(pyramids);\n        stdVectorClear<FilterGL>(filters);\n    }\n\n    /**\n     * @brief update\n     * @param wC weight for preserving contrast\n     * @param wE weight for preserving exposure\n     * @param wS weight for preserving saturation\n     */\n    void update(float wC = 1.0f, float wE = 1.0f, float wS = 1.0f)\n    {\n        this->wC = CLAMPi(wC, 0.0f, 1.0f);\n        this->wE = CLAMPi(wE, 0.0f, 1.0f);\n        this->wS = CLAMPi(wS, 0.0f, 1.0f);\n    }\n\n    /**\n     * @brief allocate\n     * @param imgIn\n     */\n    void allocate(ImageGLVec imgIn)\n    {\n        if(!bAllocate) {\n\n            int width = imgIn[0]->width;\n            int height = imgIn[0]->height;\n            int channels = imgIn[0]->channels;\n\n            acc = new ImageGL(1, width, height, 1, IMG_GPU, GL_TEXTURE_2D);\n            lum = new ImageGL(1, width, height, 1, IMG_GPU, GL_TEXTURE_2D);\n            weights = new ImageGL(1, width, height, 1, IMG_GPU, GL_TEXTURE_2D);\n\n            images.push_back(acc);\n            images.push_back(lum);\n            images.push_back(weights);\n\n            int limitLevel = 2;\n            pW = new PyramidGL(width, height, 1, false, limitLevel);\n            pI = new PyramidGL(width, height, channels, true, limitLevel);\n            pOut = new PyramidGL(width, height, channels, true, limitLevel);\n\n            pyramids.push_back(pW);\n            pyramids.push_back(pI);\n            pyramids.push_back(pOut);\n\n            allocateFilters();\n\n            bAllocate = true;\n        } else {\n            if(!pOut->stack[0]->isSimilarType(imgIn[0])) {\n                bAllocate = false;\n\n                stdVectorClear<ImageGL>(images);\n                stdVectorClear<PyramidGL>(pyramids);\n\n                allocate(imgIn);\n            }\n        }\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *Process(ImageGL *imgIn, ImageGL *imgOut)\n    {\n        pic::ImageGLVec img_vec = getAllExposuresImagesGL(imgIn, 2.2f);\n\n        imgOut = ProcessStack(img_vec, imgOut);\n\n        stdVectorClear<ImageGL>(img_vec);\n\n        return imgOut;\n    }\n\n    /**\n     * @brief ProcessStack\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *ProcessStack(ImageGLVec imgIn, ImageGL *imgOut = NULL)\n    {\n        auto n = imgIn.size();\n\n        if(n < 2) {\n            return imgOut;\n        }\n\n        allocate(imgIn);\n\n        //compute weights values\n        *acc = 0.0f;\n        for(uint j = 0; j < n; j++) {\n            lum = flt_lum->Process(SingleGL(imgIn[j]), lum);\n            weights = flt_weights->Process(DoubleGL(lum, imgIn[j]), weights);\n\n            *acc += *weights;\n        }\n\n        //accumulate on a pyramid\n        pOut->setValue(0.0f);\n\n        for(uint j = 0; j < n; j++) {\n            lum = flt_lum->Process(SingleGL(imgIn[j]), lum);\n            weights = flt_weights->Process(DoubleGL(lum, imgIn[j]), weights);\n\n            //normalization\n            *weights /= *acc;\n\n            pW->update(weights);\n            pI->update(imgIn[j]);\n\n            pI->mul(pW);\n            pOut->add(pI);\n        }\n\n        //final result\n        imgOut = pOut->reconstruct(imgOut);\n\n        float *minVal = imgOut->getMinVal(NULL);\n        float *maxVal = imgOut->getMaxVal(NULL);\n\n        int ind;\n        float minV = Arrayf::getMin(minVal, imgOut->channels, ind);\n        float maxV = Arrayf::getMax(maxVal, imgOut->channels, ind);\n        *imgOut -= minV;\n        *imgOut /= (maxV - minV);\n        imgOut = removeNegative->Process(SingleGL(imgOut), imgOut);\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_TONE_MAPPING_EXPOSURE_FUSION_TMO_HPP */\n\n"
  },
  {
    "path": "include/gl/tone_mapping/get_all_exposures.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_TONE_MAPPING_GET_ALL_EXPOSURES_HPP\n#define PIC_GL_TONE_MAPPING_GET_ALL_EXPOSURES_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../tone_mapping/get_all_exposures.hpp\"\n\n#include \"../../gl/filtering/filter_simple_tmo.hpp\"\n\nnamespace pic {\n\n/**\n * @brief getAllExposuresImagesGL converts an HDR image into a stack of LDR images\n * @param imgIn\n * @return\n */\nPIC_INLINE ImageGLVec getAllExposuresImagesGL(ImageGL *imgIn, float gamma = 2.2f)\n{\n    ImageGLVec ret;\n\n    if(imgIn == NULL) {\n        return ret;\n    }\n\n    std::vector<float> fstops = getAllExposures((Image*) imgIn);\n\n    FilterGLSimpleTMO flt(gamma, 0.0f);\n\n    ImageGLVec input = SingleGL(imgIn);\n\n    for(unsigned int i = 0; i < fstops.size(); i++) {\n        flt.update(gamma, fstops[i]);\n        ImageGL *expo = flt.Process(input, NULL);\n\n        expo->exposure = powf(2.0f, fstops[i]);\n        expo->clamp(0.0f, 1.0f);\n\n        ret.push_back(expo);\n    }\n\n    return ret;\n}\n\n} // end namespace pic\n\n#endif /* PIC_GL_TONE_MAPPING_GET_ALL_EXPOSURES_HPP */\n\n"
  },
  {
    "path": "include/gl/tone_mapping/hybrid_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_TONE_MAPPING_HYBRID_TMO_HPP\n#define PIC_GL_TONE_MAPPING_HYBRID_TMO_HPP\n\n#include \"gl/tone_mapping/segmentation_tmo_approx.hpp\"\n\n#include \"gl/algorithms/pyramid.hpp\"\n\n#include \"gl/filtering/filter_remapping.hpp\"\n\n#include \"gl/tone_mapping/drago_tmo.hpp\"\n\n#include \"gl/tone_mapping/reinhard_tmo.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The HybridTMOGL class\n */\nclass HybridTMOGL\n{\nprotected:\n    SegmentationGL seg;\n    FilterGLRemapping remap;\n    ReduxGL*check;\n    ImageGL *seg_map;\n    ImageGL *imgDrago, *imgReinhard, *remapped;\n    PyramidGL *pyrA, *pyrB, *pyrWeight;\n    float Ld_Max, b;\n    bool bFirst, bAllocate;\n\n    DragoTMOGL *flt_drago;\n    ReinhardTMOGL *flt_reinhard;\n\n    /**\n     * @brief allocateFilters\n     */\n    void allocateFilters()\n    {\n        bAllocate = true;\n        flt_drago = new DragoTMOGL();\n        flt_reinhard = new ReinhardTMOGL();\n        check = ReduxGL::createCheck();\n    }\n\npublic:\n\n    /**\n     * @brief HybridTMOGL\n     */\n    HybridTMOGL()\n    {\n        bAllocate = false;\n        bFirst = true;\n\n        flt_reinhard = NULL;\n        flt_reinhard = NULL;\n        check = NULL;\n\n        imgDrago = NULL;\n        imgReinhard = NULL;\n        pyrA = NULL;\n        pyrB = NULL;\n        pyrWeight = NULL;\n        seg_map = NULL;\n        remapped = NULL;\n\n        Ld_Max = 100.0f;\n        b = 0.95f;\n    }\n\n    ~HybridTMOGL()\n    {\n\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *Process(ImageGL *imgIn, ImageGL *imgOut)\n    {\n        if(imgIn == NULL) {\n            return NULL;\n        }\n\n        if(!imgIn->isValid()) {\n            return NULL;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = new ImageGL(1, imgIn->width, imgIn->height, imgIn->channels,\n                                    IMG_GPU, GL_TEXTURE_2D);\n        }\n\n        if(bAllocate) {\n            allocateFilters();\n        }\n\n        //compute segmentation map\n#ifdef PIC_DEBUG\n        float ms, tot_ms;\n        GLuint testTQ1 = glBeginTimeQuery();\n#endif\n\n        //compute segmentation map\n        seg_map = seg.execute(imgIn, seg_map);\n\n\n#ifdef PIC_DEBUG\n        GLuint64EXT timeVal = glEndTimeQuery(testTQ1);\n        ms = float(double(timeVal) / 1000000.0);\n        tot_ms = ms;\n        printf(\"GPU time segmentation: %f ms\\n\", ms);\n#endif\n        remapped = remap.Process(SingleGL(seg_map), remapped);\n\n        /*\t0 ---> Drago et al. 2003\n        \t1 ---> Reinhard et al. 2002\n        \tLumZone     = [-2, -1, 0, 1, 2, 3, 4];\n        \tTMOForZone =  [ 0,  0, 1, 0, 1, 0, 0];\t*/\n\n        //Checking if we have different zones\n#ifdef PIC_DEBUG\n        testTQ1 = glBeginTimeQuery();\n#endif\n\n        float check_value;\n        remapped->getVal(&check_value, check);\n        int value = int(check_value);\n\n#ifdef PIC_DEBUG\n        timeVal = glEndTimeQuery(testTQ1);\n        ms = float(double(timeVal) / 1000000.0);\n        tot_ms += ms;\n\n    printf(\"GPU time Checking Different Zones: %f ms\\n\", ms);\n        testTQ1 = glBeginTimeQuery();\n#endif\n\n        switch(value) {\n        case 0: {\n            imgOut = flt_drago->execute(imgIn, imgOut);\n        }\n        break;\n\n        case 1: {\n            flt_reinhard->update(-1.0f, -1.0f, true);\n            imgOut = flt_reinhard->execute(imgIn, imgOut);\n        }\n        break;\n\n        case 10: {\n            //Drago TMO\n            imgDrago = flt_drago->execute(imgIn, imgDrago);\n            imgDrago->loadToMemory();\n            imgDrago->Write(\"tmp.pfm\");\n\n            //Reinhard TMO\n            imgReinhard = flt_reinhard->execute(imgIn, imgReinhard);\n\n            //generate/update pryamids\n            if(pyrA == NULL) {\n                pyrA = new PyramidGL(imgDrago, true);\n            } else {\n                pyrA->update(imgDrago);\n            }\n\n            if(pyrB == NULL) {\n                pyrB = new PyramidGL(imgReinhard, true);\n            } else {\n                pyrB->update(imgReinhard);\n            }\n\n            if(pyrWeight == NULL) {\n                pyrWeight = new PyramidGL(remapped, false);\n            } else {\n                pyrWeight->update(remapped);\n            }\n\n            //Blending\n            pyrA->blend(pyrB, pyrWeight);\n            imgOut = pyrA->reconstruct(imgOut);\n        }\n        break;\n        }\n\n\n#ifdef PIC_DEBUG\n        timeVal = glEndTimeQuery(testTQ1);\n        ms = float(double(timeVal) / 1000000.0);\n        tot_ms += ms;\n        printf(\"GPU time Tone Mapping+Blending: %f ms\\n\", ms);\n\n        if(!bFirst) {\n            printf(\"Total time: %f\\n\", tot_ms);\n        } else {\n            bFirst = false;\n        }\n#endif\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_TONE_MAPPING_HYBRID_TMO_HPP */\n\n"
  },
  {
    "path": "include/gl/tone_mapping/reinhard_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_TONE_MAPPING_REINHARD_TMO_HPP\n#define PIC_GL_TONE_MAPPING_REINHARD_TMO_HPP\n\n#include \"../../util/math.hpp\"\n\n#include \"../../gl/filtering/filter_luminance.hpp\"\n#include \"../../gl/filtering/filter_sigmoid_tmo.hpp\"\n#include \"../../gl/filtering/filter_bilateral_2ds.hpp\"\n#include \"../../gl/filtering/filter_op.hpp\"\n\n#include \"../../gl/filtering/filter_reinhard_single_pass.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ReinhardTMOGL class\n */\nclass ReinhardTMOGL\n{\nprotected:\n    FilterGLLuminance  *flt_lum;\n    FilterGLSigmoidTMO *flt_tmo_global;\n    std::vector<FilterGL*> filters;\n\n    ImageGL *img_lum, *img_lum_adapt;\n\n    float Lwa, alpha, phi;\n    bool bStatisticsRecompute, bGlobal, bAllocate;\n\n    FilterGLReinhardSinglePass *fTMO;\n\n    /**\n     * @brief allocateFilters\n     */\n    void allocateFilters()\n    {\n        bAllocate = true;\n        flt_lum = new FilterGLLuminance();\n        flt_tmo_global = new FilterGLSigmoidTMO(alpha, false, false);\n    }\n\n    /**\n     * @brief executeGlobal\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *executeGlobal(ImageGL *imgIn, ImageGL *imgOut = NULL)\n    {\n        img_lum = flt_lum->Process(SingleGL(imgIn), img_lum);\n\n        if(bStatisticsRecompute || (Lwa < 0.0f)) {\n            img_lum->getLogMeanVal(&Lwa);\n        }\n\n        flt_tmo_global->update(alpha / Lwa);\n        imgOut = flt_tmo_global->Process(DoubleGL(imgIn, img_lum), imgOut);\n\n        return imgOut;\n    }\n\n    /**\n     * @brief executeLocal\n     * @param imgIn\n     * @param imgOut\n     * @param alpha\n     * @param phi\n     * @param filter\n     * @return\n     */\n    ImageGL *executeLocal(ImageGL *imgIn, ImageGL *imgOut = NULL)\n    {\n        if(fTMO == NULL) {\n            fTMO = new FilterGLReinhardSinglePass(alpha, phi);\n        }\n\n        img_lum = flt_lum->Process(SingleGL(imgIn), img_lum);\n\n        if(bStatisticsRecompute || (Lwa < 0.0f)) {\n            img_lum->getLogMeanVal(&Lwa);\n            fTMO->update(-1.0f, -1.0f, Lwa);\n        }\n\n        imgOut = fTMO->Process(DoubleGL(imgIn, img_lum), imgOut);\n\n        return imgOut;\n    }\n\n    /**\n     * @brief setNULL\n     */\n    void setNULL()\n    {\n        bGlobal = false;\n        img_lum = NULL;\n        Lwa = -1.0f;\n        fTMO = NULL;\n    }\n\npublic:\n\n    /**\n     * @brief ReinhardTMOGL\n     */\n    ReinhardTMOGL(float alpha = 0.15f, float phi = 8.0f, bool bStatisticsRecompute = true, bool bGlobal = false)\n    {\n        this->alpha = 0.15f;\n        this->phi = 8.0f;\n\n        bAllocate = false;\n\n        update(alpha, phi, bGlobal);\n\n        setNULL();\n\n        this->bStatisticsRecompute = bStatisticsRecompute;\n    }\n\n    ~ReinhardTMOGL()\n    {\n        stdVectorClear<FilterGL>(filters);\n    }\n\n    /**\n     * @brief update\n     * @param alpha\n     * @param phi\n     * @param bGlobal\n     */\n    void update(float alpha, float phi, bool bGlobal = true)\n    {\n        this->bGlobal = bGlobal;\n        this->alpha = alpha > 0.0f ? alpha : this->alpha;\n        this->phi = phi > 0.0f ? phi : this->phi;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @param bGlobal\n     * @return\n     */\n    ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut = NULL)\n    {\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        if(!imgIn->isValid()) {\n            return imgOut;\n        }\n\n        if(!bAllocate) {\n            allocateFilters();\n        }\n\n        if(bGlobal) {\n            return executeGlobal(imgIn, imgOut);\n        } else {\n            return executeLocal(imgIn, imgOut);\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_TONE_MAPPING_REINHARD_TMO_HPP */\n\n"
  },
  {
    "path": "include/gl/tone_mapping/segmentation_tmo_approx.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_TONE_MAPPING_SEGMENTATION_TMO_APPROX_HPP\n#define PIC_GL_TONE_MAPPING_SEGMENTATION_TMO_APPROX_HPP\n\n#include \"../../gl/filtering/filter_luminance.hpp\"\n#include \"../../gl/filtering/filter_remove_nuked.hpp\"\n#include \"../../gl/filtering/filter_iterative.hpp\"\n#include \"../../gl/filtering/filter_bilateral_2ds.hpp\"\n#include \"../../gl/filtering/filter_op.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The SegmentationGL class\n */\nclass SegmentationGL\n{\nprotected:\n    FilterGLLuminance       *flt_lum;\n    FilterGLRemoveNuked     *flt_nuked;\n    FilterGLIterative       *flt_it;\n    FilterGLBilateral2DS    *flt_bil;\n    FilterGLOp              *flt_seg;\n    ImageGL                 *L, *imgIn_flt;\n\n    float                   perCent, nLayer;\n    int                     iterations;\n\npublic:\n    ImageGLVec stack;\n    float      minVal, maxVal;\n\n    /**\n     * @brief SegmentationGL\n     */\n    SegmentationGL()\n    {\n        flt_nuked = NULL;\n        flt_lum = NULL;\n        flt_bil = NULL;\n        flt_it  = NULL;\n        flt_seg = NULL;\n\n        nLayer = 0.0f;\n        iterations = 0;\n\n        L = NULL;\n        imgIn_flt = NULL;\n\n        maxVal = FLT_MAX;\n        minVal = 0.0f;\n\n        perCent  = 0.005f;\n    }\n\n    ~SegmentationGL()\n    {\n        delete imgIn_flt;\n        delete L;\n        delete flt_it;\n        delete flt_bil;\n        delete flt_seg;\n        delete flt_nuked;\n    }\n\n    /**\n     * @brief computeStatistics\n     * @param imgIn\n     */\n    void computeStatistics(Image *imgIn)\n    {\n        float nLevels, area;\n\n        nLevels\t\t= log10f(maxVal) - log10f(minVal) + 1.0f;\n        nLayer\t\t= ((maxVal - minVal) / nLevels) / 4.0f;\n        area\t\t= imgIn->widthf * imgIn->heightf * perCent;\n        iterations\t= MAX(int(sqrtf(area)) / 8, 1);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut)\n    {\n        if(imgIn == NULL) {\n            return imgOut;\n        }\n\n        if(!imgIn->isValid()) {\n            return imgOut;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = new ImageGL(1, imgIn->width, imgIn->height, 1, IMG_GPU, GL_TEXTURE_2D);\n        }\n\n        //compute luminance\n        if(flt_lum == NULL) {\n            flt_lum = new FilterGLLuminance();\n        }\n\n        L = flt_lum->Process(SingleGL(imgIn), L);\n\n        L->getMinVal(&minVal);\n        L->getMaxVal(&maxVal);\n\n        //iterative bilateral filtering\n        if(flt_it == NULL) {\n            flt_bil = new FilterGLBilateral2DS(1.0f, nLayer);\n            flt_it  = new FilterGLIterative(flt_bil, iterations);\n        }\n\n        imgIn_flt = flt_it->Process(SingleGL(imgIn), imgIn_flt);\n        L = flt_lum->Process(SingleGL(imgIn_flt), L);\n\n        //threshold\n        if(flt_seg == NULL) {\n            flt_seg = FilterGLOp::CreateOpSegmentation(false, floor(log10f(minVal)));\n        }\n\n        flt_seg->Process(SingleGL(L), L);\n\n        //remove nuked pixels\n        if(flt_nuked == NULL) {\n            flt_nuked = new FilterGLRemoveNuked(0.9f);\n        }\n        flt_nuked->Process(SingleGL(L), imgOut);\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_GL_TONE_MAPPING_SEGMENTATION_TMO_APPROX_HPP */\n\n"
  },
  {
    "path": "include/gl/tone_mapping/tone_mapping_operator.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_TONE_MAPPING_OPERATOR_GL_HPP\n#define PIC_TONE_MAPPING_TONE_MAPPING_OPERATOR_GL_HPP\n\n#include \"../../util/std_util.hpp\"\n\n#include \"../image.hpp\"\n#include \"../image_vec.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ToneMappingOperator class\n */\nclass ToneMappingOperatorGL\n{\nprotected:\n\n    ImageGLVec images;\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     */\n    virtual ImageGL *Process(ImageGL *imgIn, ImageGL *imgOut)\n    {\n        return imgOut;\n    }\n\npublic:\n\n    /**\n     * @brief ToneMappingOperator\n     */\n    ToneMappingOperator()\n    {\n\n    }\n\n    virtual void releaseAux()\n    {\n\n    }\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        stdVectorClear<ImageGL>(images);\n        releaseAux();\n    }\n\n    /**\n     * @brief updateImage\n     * @param imgIn\n     */\n    void updateImage(ImageGL *imgIn)\n    {\n        bool bRelease = false;\n        for(auto i = 0; i < images.size(); i++) {\n            if(images[i] != NULL) {\n                if((imgIn->width  != images[i]->width) ||\n                   (imgIn->height != images[i]->height)) {\n                    bRelease = true;\n                    break;\n                }\n            }\n        }\n\n        if(bRelease) {\n            release();\n        }\n    }\n\n    /**\n     * @brief checkInput\n     * @param imgIn\n     * @return\n     */\n    bool checkInput(ImageGL *imgIn)\n    {\n        if(imgIn == NULL) {\n            return false;\n        }\n\n        return imgIn->isValid();\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut = NULL)\n    {\n        if(!checkInput(imgIn)) {\n            return imgOut;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = imgIn->clone();\n        } else {\n            if(!imgOut->isSimilarType(imgIn)) {\n                imgOut = imgIn->allocateSimilarOneGL();\n            }\n        }\n\n        imgOut = Process(imgIn, imgOut);\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_WARD_HISTOGRAM_TMO_HPP */\n\n"
  },
  {
    "path": "include/gl.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_GL_HPP\n#define PIC_GL_HPP\n\n#ifndef PIC_DISABLE_OPENGL\n\n//OpenGL library\n#ifdef PIC_WIN32\n    #include <gl/GL.h>\n    #pragma comment( lib, \"opengl32\" )\n#else /* PIC_MAC_OS_X or PIC_UNIX */\n\n    #ifdef PIC_MAC_OS_X\n        #include <OpenGL/OpenGL.h>\n    #else\n        #include <GL/gl.h>\n    #endif\n#endif /* os selection */\n\n//end os selection\n\n#include \"util/gl/program.hpp\"\n#include \"util/gl/technique.hpp\"\n\n#include \"gl/algorithms/pyramid.hpp\"\n#include \"gl/algorithms/pushpull.hpp\"\n#include \"gl/algorithms/color_to_gray.hpp\"\n#include \"gl/algorithms/richardson_lucy_deconvolution.hpp\"\n#include \"gl/algorithms/grow_cut.hpp\"\n\n#include \"util/gl/buffer_op.hpp\"\n#include \"util/gl/buffer_ops.hpp\"\n\n#include \"gl/filtering/filter.hpp\"\n#include \"gl/filtering/filter_luminance.hpp\"\n#include \"gl/filtering/filter_channel.hpp\"\n\n//color conversion\n#include \"gl/colors/color_conv.hpp\"\n#include \"gl/colors/color_conv_linear.hpp\"\n#include \"gl/colors/color_conv_rgb_to_xyz.hpp\"\n#include \"gl/colors/color_conv_rgb_to_srgb.hpp\"\n#include \"gl/colors/color_conv_rgb_to_hsl.hpp\"\n#include \"gl/colors/color_conv_xyz_to_cielab.hpp\"\n#include \"gl/colors/color_conv_xyz_to_lms.hpp\"\n#include \"gl/filtering/filter_color_conv.hpp\"\n\n#include \"gl/filtering/filter_warp_2d.hpp\"\n#include \"gl/filtering/filter_anisotropic_diffusion.hpp\"\n#include \"gl/filtering/filter_bilateral_1d.hpp\"\n#include \"gl/filtering/filter_bilateral_2das.hpp\"\n#include \"gl/filtering/filter_bilateral_2df.hpp\"\n#include \"gl/filtering/filter_bilateral_2dg.hpp\"\n#include \"gl/filtering/filter_bilateral_2ds.hpp\"\n#include \"gl/filtering/filter_bilateral_2ds_e.hpp\"\n#include \"gl/filtering/filter_bilateral_2dsp.hpp\"\n#include \"gl/filtering/filter_bilateral_3ds.hpp\"\n#include \"gl/filtering/filter_bilateral_3dsp.hpp\"\n#include \"gl/filtering/filter_disp.hpp\"\n#include \"gl/filtering/filter_drago_tmo.hpp\"\n#include \"gl/filtering/filter_1d.hpp\"\n#include \"gl/filtering/filter_conv_1d.hpp\"\n#include \"gl/filtering/filter_conv_2d.hpp\"\n#include \"gl/filtering/filter_non_linear_1d.hpp\"\n#include \"gl/filtering/filter_mean.hpp\"\n#include \"gl/filtering/filter_min.hpp\"\n#include \"gl/filtering/filter_max.hpp\"\n#include \"gl/filtering/filter_gaussian_1d.hpp\"\n#include \"gl/filtering/filter_gaussian_2d.hpp\"\n#include \"gl/filtering/filter_gaussian_3d.hpp\"\n#include \"gl/filtering/filter_gradient.hpp\"\n#include \"gl/filtering/filter_laplacian.hpp\"\n#include \"gl/filtering/filter_hsl_replace.hpp\"\n#include \"gl/filtering/filter_iterative.hpp\"\n#include \"gl/filtering/filter_npasses.hpp\"\n#include \"gl/filtering/filter_op.hpp\"\n#include \"gl/filtering/filter_remapping.hpp\"\n#include \"gl/filtering/filter_remove_nuked.hpp\"\n#include \"gl/filtering/filter_sampler_2d.hpp\"\n#include \"gl/filtering/filter_sampling_map.hpp\"\n#include \"gl/filtering/filter_scatter.hpp\"\n#include \"gl/filtering/filter_sigmoid_tmo.hpp\"\n#include \"gl/filtering/filter_simple_tmo.hpp\"\n#include \"gl/filtering/filter_slicer.hpp\"\n#include \"gl/filtering/filter_durand_tmo.hpp\"\n#include \"gl/filtering/filter_deform_grid.hpp\"\n#include \"gl/image.hpp\"\n#include \"gl/image_vec.hpp\"\n#include \"gl/point_samplers/sampler_random_m.hpp\"\n\n//Tone mapping\n#include \"gl/tone_mapping/segmentation_tmo_approx.hpp\"\n#include \"gl/tone_mapping/drago_tmo.hpp\"\n#include \"gl/tone_mapping/reinhard_tmo.hpp\"\n#include \"gl/tone_mapping/durand_tmo.hpp\"\n#include \"gl/tone_mapping/hybrid_tmo.hpp\"\n#include \"gl/tone_mapping/get_all_exposures.hpp\"\n#include \"gl/tone_mapping/exposure_fusion.hpp\"\n\n//Post tone mapping\n#include \"gl/filtering/filter_color_correction_pouli.hpp\"\n\n//Display\n#include \"util/gl/display.hpp\"\n\n#endif /* PIC_DISABLE_OPENGL */\n\n#endif /* PIC_GL_HPP */\n\n"
  },
  {
    "path": "include/histogram.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_HISTOGRAM_HPP\n#define PIC_HISTOGRAM_HPP\n\n#include <cmath>\n\n#include \"image.hpp\"\n#include \"base.hpp\"\n\n#include \"util/bbox.hpp\"\n#include \"util/std_util.hpp\"\n#include \"util/array.hpp\"\n#include \"util/math.hpp\"\n\nnamespace pic {\n\nenum VALUE_SPACE {VS_LDR, VS_LIN, VS_LOG_2, VS_LOG_E, VS_LOG_10};\n\n/**\n * @brief The Histogram class is a class for creating,\n * managing, loading, and saving histogram for an Image.\n */\nclass Histogram\n{\nprotected:\n    float *bin_c;\n    float *bin_nor;\n    int nBin;\n    VALUE_SPACE type;\n    float fMin, fMax;\n    float deltaMaxMin, nBinf;\n    float epsilon;\n\n    /**\n     * @brief projectDomain applies the histogram domain to x.\n     * @param x is an input value.\n     * @return x is converted into the histogram domain.\n     */\n    inline float projectDomain(float x)\n    {\n        switch(type) {\n            case VS_LOG_2: {\n                return logf(x + epsilon) * C_INV_LOG_NAT_2;\n            }\n            break;\n\n            case VS_LOG_E: {\n                return logf(x + epsilon);\n            }\n            break;\n\n            case VS_LOG_10: {\n                return log10f(x + epsilon);\n            }\n            break;\n                \n            default: {\n                return x;\n            } break;\n        }\n\n        return x;\n    }\n\n    /**\n     * @brief unprojectDomain removes the histogram domain to x.\n     * @param x is an input value.\n     * @return x is converted back to its original domain.\n     */\n    inline float unprojectDomain(float x)\n    {\n        switch(type) {\n            case VS_LOG_2: {\n                return powf(2.0f, x) - epsilon;\n            }\n            break;\n\n            case VS_LOG_E: {\n                return expf(x) - epsilon;\n            }\n            break;\n\n            case VS_LOG_10: {\n                return powf(10.0f, x) - epsilon;\n            }\n            break;\n                \n            default: {\n                return x;\n            }\n            break;\n        }\n\n        return x;\n    }\n\n    /**\n     * @brief update\n     * @param x\n     */\n    inline void update(float x)\n    {\n        float val = projectDomain(x);\n\n        int indx = int(((val - fMin) * nBinf) / deltaMaxMin);\n\n        #ifdef PIC_DEBUG\n        if((indx >= nBin) || (indx < 0)) {\n            printf(\"Error in Calculate %d.\\n\",indx);\n        }\n        #endif\n\n        bin[CLAMP(indx, nBin)]++;\n    }\n\npublic:\n    uint *bin, *bin_work;\n\n    /**\n     * @brief Histogram is the basic constructor setting variables to defaults.\n     */\n    Histogram()\n    {\n        bin     = NULL;\n        bin_nor = NULL;\n        bin_c   = NULL;\n        bin_work = NULL;\n\n        nBin =  0;\n        type =  VS_LIN;\n        fMin = -FLT_MAX;\n        fMax =  FLT_MAX;\n\n        epsilon = 1e-6f;\n    }\n\n    /**\n     * @brief Histogram is an extension of the basic constructor, where calculate\n     * is called in order to populate the Histogram.\n     * @param imgIn is an input image for which Histogram needs to be computed.\n     * @param type is the space of computations (please see calculate()).\n     * @param nBin is the number of bins of the Histogram.\n     * @param channel is the color channel for which Histogram needs to be computed.\n     */\n    Histogram(Image *imgIn, VALUE_SPACE type, int nBin, int channel = 0)\n    {\n        bin     = NULL;\n        bin_nor = NULL;\n        bin_c   = NULL;\n        bin_work = NULL;\n\n        fMin = -FLT_MAX;\n        fMax =  FLT_MAX;\n\n        epsilon = 1e-6f;\n        this->nBin = 0;\n\n        calculate(imgIn, type, nBin, NULL, channel);\n    }\n\n    /**\n    * @brief ~Histogram is the basic destructor which frees memory.\n    */\n    ~Histogram()\n    {\n        release();\n\n        nBin = 0;\n        type =  VS_LIN;\n        fMin = -FLT_MAX;\n        fMax =  FLT_MAX;\n    }   \n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        bin = delete_vec_s(bin);\n        bin_c = delete_vec_s(bin_c);\n        bin_nor = delete_vec_s(bin_nor);\n        bin_work = delete_vec_s(bin_work);\n    }\n\n    /**\n     * @brief calculate computes the histogram of an input image. In the case\n     * of LDR images, they are ssumed to be normalized; i.e. with values in [0, 1].\n     * This function computes the histogram for a single color channel.\n     * @param imgIn is the input image for which the histogram needs to be computed\n     * @param type is the domain space for histogram computations.\n     * Histogram can be computed as: VS_LDR (256 bins), VS_LIN (linear space),\n     * VS_LOG_2 (logarithm 2 base), VS_LOG_E (natural logarithm space), and VS_LOG_10\n     * (logarithm 10 base).\n     * @param nBin is the number of bins of the Histogram to be computed. The default value\n     * is 256.\n     * @param box is the slice where to compute the histogram.\n     * @param channel is the color channel for which the Histogram will be computed.\n     */\n    void calculate(Image *imgIn, VALUE_SPACE type = VS_LIN, int nBin = 256,\n                   BBox *box = NULL, int channel = 0)\n    {\n        if((imgIn == NULL) || (channel < 0) ) {\n            uniform(0.0f, 1.0f, 1, type, nBin);\n            return;\n        }\n\n        if(!imgIn->isValid() || (channel >= imgIn->channels)) {\n            uniform(0.0f, 1.0f, 1, type, nBin);\n            return;\n        }\n\n        if(nBin < 1 || type == VS_LDR) {\n            nBin = 256;\n        }\n\n        bool c1 = (nBin != this->nBin) && (bin != NULL);\n        bool c2 = (bin == NULL);\n        if(c1 || c2)  {\n            release();\n\n            bin = new uint[nBin];\n            memset((void *)bin, 0, nBin * sizeof(uint));\n        } else {\n            memset((void *)bin, 0, nBin * sizeof(uint));\n        }\n\n        this->nBin = nBin;\n        this->type = type;\n\n        int size = imgIn->width * imgIn->height * imgIn->channels;\n        int channels = imgIn->channels;\n\n        //compute statistics\n        fMin =  FLT_MAX;\n        fMax = -FLT_MAX;\n\n        if(box == NULL) {\n            for(int i = channel; i < size; i += channels) {\n                float val = imgIn->data[i];\n                fMin = MIN(fMin, val);\n                fMax = MAX(fMax, val);\n            }\n        } else {\n            for(int k = box->z0; k < box->z1; k++) {\n                for(int j = box->y0; j < box->y1; j++) {\n                    for(int i = box->x0; i < box->x1; i++) {\n                        float *tmp_data = (*imgIn)(i, j, k);\n                        fMin = MIN(fMin, tmp_data[channel]);\n                        fMax = MAX(fMax, tmp_data[channel]);\n                    }\n                }\n            }\n        }\n\n        fMin = projectDomain(fMin);\n        fMax = projectDomain(fMax);\n\n        deltaMaxMin = (fMax - fMin);\n        nBinf = float(nBin - 1);\n\n        //compute the histogram\n        if(box == NULL) {\n            for(int i = channel; i < size; i += channels) {\n                update(imgIn->data[i]);\n            }\n        } else {\n            for(int k = box->z0; k < box->z1; k++) {\n                for(int j = box->y0; j < box->y1; j++) {\n                    for(int i = box->x0; i < box->x1; i++) {\n                        float *tmp_data = (*imgIn)(i, j, k);\n                        update(tmp_data[channel]);\n                    }\n                }\n            }\n        }\n    }\n\n    /**\n     * @brief uniform\n     * @param value\n     * @param type\n     * @param nBin\n     */\n    void uniform(float fMin, float fMax, uint value, VALUE_SPACE type, int nBin)\n    {\n        bool c1 = (nBin != this->nBin) && (bin != NULL);\n        bool c2 = (bin == NULL);\n        if(c1 || c2)  {\n            release();\n\n            bin = new uint[nBin];\n        }\n\n        this->nBin = nBin;\n        this->type = type;\n\n        memset((void *)bin, value, nBin * sizeof(uint));\n\n        nBinf = float(nBin - 1);\n\n        this->fMin = fMin;\n        this->fMax = fMax;\n        deltaMaxMin = (fMax - fMin);\n    }\n\n    /**\n     * @brief update\n     * @param fMin\n     * @param fMax\n     */\n    void update(float fMin, float fMax)\n    {        \n        this->fMin = projectDomain(fMin);\n        this->fMax = projectDomain(fMax);\n        deltaMaxMin = (fMax - fMin);\n    }\n\n    /**\n     * @brief project converts an input value in the histogram domain.\n     * @param x is an input value.\n     * @return x is projected in the histogram domain.\n     */\n    int project(float x)\n    {\n        if(deltaMaxMin > 0.0f) {\n            float y = projectDomain(x);\n            return int(((y - fMin) * nBinf) / deltaMaxMin);\n        } else {\n            return 0;\n        }\n    }\n\n    /**\n     * @brief unproject converts a histogram value back to its original domain.\n     * @param ind is a histogram value.\n     * @return ind is converted back to its original domain.\n     */\n    float unproject(int ind)\n    {\n        float indf = float(ind);\n        float y = ((indf * deltaMaxMin) / nBinf) + fMin;\n        return unprojectDomain(y);\n    }\n\n    /**\n     * @brief ceiling limits the maximum value of the histogram using Ward\n     * algorithm.\n     * @param k\n     */\n    void ceiling(float k)\n    {\n        //tolerance is the 2.5%\n        uint tolerance = (Array<uint>::sum(bin, nBin) * 25) / 1000;\n        uint trimmings = tolerance + 1;\n        bool  bFlag = true;\n\n        std::vector<bool> trimmed_vec;\n\n        while((trimmings > tolerance) && bFlag) {\n            trimmings = 0;\n            uint T = Array<uint>::sum(bin, nBin);\n\n            if(T <= tolerance) {\n                bFlag = false;\n            } else {\n                bool bTrimmed = false;\n                uint ceiling = uint(float(T) * k);\n\n                for(int i = 0; i < nBin; i++) {\n                    if(bin[i] > ceiling) {\n                        trimmings += (bin[i] - ceiling);\n                        bin[i] = ceiling;\n                        bTrimmed = true;\n                    }\n                }\n\n                trimmed_vec.push_back(bTrimmed);\n\n            }\n\n            int tvSize = int(trimmed_vec.size());\n            if(tvSize >= 2) {\n                bool b0 = !trimmed_vec[tvSize - 1];\n                bool b1 = !trimmed_vec[tvSize - 2];\n                if(b0 && b1) {\n                    bFlag = false;\n                }\n            }\n        }\n    }\n\n    /**\n     * @brief clip clips the histogram to value.\n     * @param value the maximum allowed value in the histogram.\n     */\n    void clip(uint value)\n    {\n        int redistrib = 0;\n        for(int i = 0; i < nBin; i++) {\n            if(bin[i] > value) {\n                redistrib += bin[i] - value + 1;\n                bin[i] = value;\n            }\n        }\n\n        int nCount = redistrib / nBin;\n\n        for(int i = 0; i < nCount; i++) {\n            for(int j = 0; j < nBin; j++) {\n                bin[j]++;\n            }\n        }\n\n        int remainder = redistrib % nBin;\n\n        for(int i =0; i < remainder; i++) {\n            bin[rand() % nBin]++;\n        }\n    }\n\n    /**\n     * @brief cumulativef computes the cumulative Histogram.\n     * @param bNormalized is a boolean value; if it is true values of\n     * the Histogram will be normalized.\n     * @return It returns the cumulative Histogram as a float pointer.\n     */\n    float *cumulativef(bool bNormalized)\n    {\n        getNormalized();\n    \n        bin_c = Arrayf::cumsum(bin_nor, nBin, bin_c);\n\n        if(bNormalized) {\n            Arrayf::div(bin_c, nBin, bin_c[nBin - 1]);\n        }\n\n        return bin_c;\n    }\n\n    /**\n     * @brief getCumulativef this function returns the cumulative\n     * Histogram. Note that cumulativef needs to be computed before otherwise\n     * the function will return a NULL pointer.\n     * @return It returns a float pointer to the cumulative Histogram.\n     */\n    float *getCumulativef()\n    {\n        return bin_c;\n    }\n\n    /**\n     * @brief getfMin\n     * @return\n     */\n    float getfMin()\n    {\n        return fMin;\n    }\n\n\n    /**\n     * @brief getfMax\n     * @return\n     */\n    float getfMax()\n    {\n        return fMax;\n    }\n\n    /**\n     * @brief getNormalized normalizes the Histogram.\n     * @return It returns the normalized Histogram as a float pointer.\n     */\n    float *getNormalized(bool bNor = true)\n    {\n        if(bin_nor == NULL) {\n            bin_nor = new float[nBin];\n        }\n\n        int ind;\n        float maxValf;\n        if(bNor) {\n            maxValf = float(Array<uint>::getMax(bin, nBin, ind));\n        } else {\n            maxValf = float(Array<uint>::sum(bin, nBin));\n        }\n\n        if(maxValf > 0.0f) {\n            for(int i = 0; i < nBin; i++) {\n                bin_nor[i] = float(bin[i]) / maxValf;\n            }\n        } else {\n            Arrayf::assign(0.0f, bin_nor, nBin);\n        }\n\n        return bin_nor;\n    }\n\n    /**\n     * @brief getOtsu\n     * @return\n     */\n    float getOtsu()\n    {\n        float *pdf = getNormalized(false);\n\n        float w0 = 0.0f;\n        float w1 = 1.0f;\n        float mu0 = 0.0f;\n        float mu1 = 0.0f;\n        int index = 0;\n        for(int i = 0; i < nBin; i++) {\n            mu1 += unproject(i) * pdf[i];\n        }\n\n        float sigma_b_max = 0.0f;\n        for(int i = 1; i < nBin; i++) {\n\n            w0 += pdf[i];\n            w1 -= pdf[i];\n\n            float tmp = unproject(i) * pdf[i];\n            mu0 += tmp;\n            mu1 -= tmp;\n\n            if(w0 > 0.0f && w1 > 0.0f) {\n                float delta = (mu0 / w0) - (mu1 / w1);\n                float sigma_b = w0 * w1 * delta * delta;\n\n                if(sigma_b > sigma_b_max) {\n                    sigma_b_max = sigma_b;\n                    index = i;\n                }\n            }\n        }\n\n        return unproject(index);\n    }\n\n    /**\n     * @brief write saves the Histogram as an Image into a file.\n     * @param name is the filename where to save the Histogram.\n     * @param bNor is a boolean value for normalizing or not the Histogram.\n     */\n    void write(std::string name, bool bNor)\n    {\n        Image img(1, nBin, 1, 1);\n\n        if(bNor) {\n            getNormalized();\n            memcpy(img.data, bin_nor, sizeof(float) * nBin);\n        } else {\n            for(int i = 0; i < nBin; i++) {\n                img.data[i] = float(bin[i]);\n            }\n        }\n\n        img.Write(name, LT_NONE);\n    }\n\n    /**\n     * @brief exposureCovering computes the exposure values for fully covering\n     * the dynamic range of the image. This function works only if the histogram\n     * was compute usign VS_LOG_2.\n     * @param nBits is the number of bit used for storing each output exposure image.\n     * The default value is 8.\n     * @param overlap is the value, in f-stops, of overlapping between two exposure images.\n     * This value is set to 1 by default.\n     * @return It returns an std::vector<float> which contains the exposure values\n     * in f-stops for all required exposures for covering information.\n     */\n    std::vector< float > exposureCovering(int nBits = 8, float overlap = 1.0f)\n    {\n        std::vector< float > ret;\n\n        if(type != VS_LOG_2) {\n            #ifdef PIC_DEBUG\n                printf(\"ERROR in ExposureCovering: this histogram has to be in log2!\\n\");\n            #endif\n            \n            return ret;\n        }\n\n        float dMM = deltaMaxMin / nBinf;\n\n        int removingBins = int(float(nBits) /dMM + overlap);\n\n        if( bin_work == NULL) {\n            bin_work = new uint [nBin];\n        }\n\n        memcpy(bin_work, bin, sizeof(uint) * nBin);\n\n        int countIndex = 0;\n        while(Array<uint>::sum(bin_work, nBin) > 0) {\n\n            int count = -1;\n            int index = 0;\n\n            for(int i = 0; i < (nBin - removingBins); i++) {\n\n                int tmpCount = Array<uint>::sum(&bin_work[i], removingBins);\n\n                if(tmpCount > count) {\n                    count = tmpCount;\n                    index = i;\n                }\n            }\n\n            if(index == 0) {\n                countIndex++;\n            }\n\n            if(countIndex > 2) {\n                break;\n            }\n\n            Array<uint>::assign(0, &bin_work[index], removingBins);\n\n            float fstop = (float(index + removingBins ) * dMM) + fMin;\n\n            ret.push_back(fstop);\n\n        }\n\n        return ret;\n    }\n};\n\n\n} // end namespace pic\n\n#endif /* PIC_HISTOGRAM_HPP */\n\n"
  },
  {
    "path": "include/image.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IMAGE_HPP\n#define PIC_IMAGE_HPP\n\n#include <string>\n#include <vector>\n#include <algorithm>\n#include <random>\n#include <math.h>\n#include <float.h>\n#include <limits>\n#include <string>\n\n#include \"base.hpp\"\n#include \"util/compability.hpp\"\n#include \"util/bbox.hpp\"\n#include \"util/buffer.hpp\"\n#include \"util/dynamic_range.hpp\"\n#include \"util/math.hpp\"\n#include \"util/array.hpp\"\n#include \"util/indexed_array.hpp\"\n#include \"util/std_util.hpp\"\n\n//IO formats\n#include \"io/bmp.hpp\"\n#include \"io/exr.hpp\"\n#include \"io/exr_tiny.hpp\"\n#include \"io/hdr.hpp\"\n#include \"io/pfm.hpp\"\n#include \"io/ppm.hpp\"\n#include \"io/pgm.hpp\"\n#include \"io/tmp.hpp\"\n#include \"io/tga.hpp\"\n#include \"io/vol.hpp\"\n#include \"io/stb.hpp\"\n#include \"io/exif.hpp\"\n#include \"util/io.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The Image class stores an image as buffer of float.\n */\nclass Image\n{\nprotected:\n\n    /**\n     * @brief setNULL sets buffers values to NULL.\n     */\n    void setNULL();\n\n    //applied rendering values\n    bool flippedEXR;\n    int  readerCounter;\n    bool notOwned;\n\n    BBox fullBox;\n\n    LDR_type typeLoad;\n\npublic:\n    float exposure;\n    int width, height, channels, frames, depth, alpha;\n\n    int tstride, ystride, xstride;\n\n    float widthf, width1f, heightf, height1f, channelsf, framesf, frames1f;\n\n    std::string nameFile;\n\n    /**\n     * @brief data is the main buffer where pixel values are stored.\n     */\n    float *data;\n\n    /**\n     * @brief dataUC is a buffer for rendering 8-bit images.\n     */\n    unsigned char *dataUC;\n\n    /**\n     * @brief dataRGBE is a buffer for rendering RGBE encoded images.\n     */\n    unsigned char *dataRGBE;\n\n    //Half-precision encoding\n#ifdef PIC_ENABLE_OPEN_EXR\n    Imf::Rgba *dataEXR;\n#endif\n\n    /**\n     * @brief the basic construct of an Image\n     */\n    Image();\n\n    /**\n     * @brief Image embeds an existing image in the new image.\n     * @param imgIn is the input image to embed.\n     * @param deepCopy enables a deep copy of img into this.\n     */\n    Image(Image *imgIn, bool deepCopy);\n\n    /**\n    * @brief Image loads an Image from a file on the disk.\n    * @param nameFile is the file name.\n    * @param typeLoad is an option for LDR images only:\n    * LT_NOR means that the input image values will be normalized in [0,1].\n    * LT_NOR_GAMMA means that the input image values will be normalized in [0,1], and\n    * gamma correction 2.2 will be removed.\n    * LT_NONE means that image values are not modified during the loading.\n    *\n    * The default value is LT_NOR_GAMMA assuming that\n    * we are storing normalized and linearized values in Image.\n    */\n    Image(std::string nameFile, LDR_type typeLoad);\n\n    /**\n    * @brief Image creates an Image with a given size.\n    * @param width is the horizontal size in pixels.\n    * @param height is the vertical size in pixels.\n    * @param channels is the number of color channels.\n    */\n    Image(int width, int height, int channels);\n\n   /**\n   * @brief Image embeds an array of float inside an Image.\n   * @param color is the pointer to an array of float values.\n   * @param channels is the color's number of elements.\n   */\n    Image(float *color, int channels);\n\n    /**\n     * @brief Image is a constructor which initializes an image defined by\n     * the input properties.\n     * @param frames is the number of temporal pixels.\n     * @param width is the number of horizontal pixels.\n     * @param height is the number of vertical pixels.\n     * @param channels is the number of color channels.\n     * @param data is a buffer of size frames * width * height * channels.\n     * If it is empty (set to NULL) a new buffer will be created.\n     */\n    Image(int frames, int width, int height, int channels, float *data);\n\n    /**\n    * @brief Image destructor. This deallocates: data, dataUC, and dataRGBE\n    */\n    ~Image();\n\n    /**\n     * @brief allocate allocates memory for the pixel buffer.\n     * @param width is the number of horizontal pixels.\n     * @param height is the number of vertical pixels.\n     * @param channels is the number of color channels.\n     * @param frames is the number of temporal pixels.\n     */\n    void allocate(int width, int height, int channels, int frames);\n\n    /**\n     * @brief allocateAux computes extra information after allocation;\n     * e.g. strides.\n     */\n    void allocateAux();\n\n    /**\n     * @brief release frees allocated buffers.\n     */\n    void release();\n\n    /**\n     * @brief copySubImage copies imgIn in the current image.\n     * The current image is written from (startX, startY).\n     * @param imgIn the image to be copied.\n     * @param startX is the horizontal coordinate in pixels.\n     * @param startY is the vertical coordinate in pixels.\n     */\n    void copySubImage(Image *imgIn, int startX, int startY);\n\n    /**\n     * @brief scaleCosine multiplies the current image by the vertical cosine\n     * assuming a longitude-latitude image.\n     */\n    void scaleCosine();\n\n    /**\n     * @brief FlipH flips horizontally the current image.\n     */\n    void flipH()\n    {\n        Buffer<float>::flipH(data, width, height, channels, frames);\n    }\n\n    /**\n     * @brief FlipV flips vertically the current image.\n     */\n    void flipV()\n    {\n        Buffer<float>::flipV(data, width, height, channels, frames);\n    }\n\n    /**\n     * @brief flipHV flips horizontally and vertically the current image.\n     */\n    void flipHV()\n    {\n        Buffer<float>::flipH(data, width, height, channels, frames);\n        Buffer<float>::flipV(data, width, height, channels, frames);\n    }\n\n    /**\n     * @brief flipVH flips vertically and horizontally the current image.\n     */\n    void flipVH()\n    {\n        Buffer<float>::flipV(data, width, height, channels, frames);\n        Buffer<float>::flipH(data, width, height, channels, frames);\n    }\n\n    /**\n     * @brief rotate90CCW rotates 90 degrees counter-clockwise the current image.\n     */\n    void rotate90CCW()\n    {\n        Buffer<float>::rotate90CCW(data, width, height, channels);\n        allocateAux();\n    }\n\n    /**\n     * @brief rotate90CW rotates 90 degrees clockwise the current image.\n     */\n    void rotate90CW()\n    {\n        Buffer<float>::rotate90CW(data, width, height, channels);\n        allocateAux();\n    }\n\n    /**\n     * @brief getDiagonalSize\n     * @return\n     */\n    float getDiagonalSize()\n    {\n        return sqrtf(widthf * widthf + heightf * heightf);\n    }\n\n    /**\n     * @brief setZero sets data to 0.0f.\n     */\n    void setZero();\n\n    /**\n     * @brief setRand\n     * @param seed\n     */\n    void setRand(unsigned int seed);\n\n    /**\n     * @brief isValid checks if the current image is valid, which means if they\n     * have an allocated buffer or not.\n     * @return This function return true if the current Image is allocated,\n     * otherwise false.\n     */\n    bool isValid();\n\n    /**\n     * @brief isSimilarType checks if the current image is similar to img;\n     * i.e. if they have the same width, height, frames, and channels.\n     * @param img is an input image\n     * @return This function returns true if the two images are similar,\n     * otherwise false.\n     */\n    bool isSimilarType(const Image *img);    \n\n    /**\n     * @brief assign\n     * @param imgIn\n     */\n    void assign(const Image *imgIn);\n\n    /**\n     * @brief blend\n     * @param img\n     * @param weight\n     */\n    void blend(Image *img, Image *weight);\n\n    /**\n     * @brief minimum is the minimum operator for Image.\n     * @param img is a and Image and the operand. This\n     * and the current Image need to have the same width,\n     * height, and color channels.\n     */\n    void minimum(Image *img);\n\n    /**\n     * @brief maximum is the maximum operator for Image.\n     * @param img is a and Image and the operand. This\n     * and the current Image need to have the same width,\n     * height, and color channels.\n     */\n    void maximum(Image *img);\n\n    /**\n     * @brief applyFunction is an operator that applies\n     * an input function to all values in data.\n     */\n    void applyFunction(float(*func)(float));\n\n    /**\n     * @brief applyFunctionParam\n     * @param param\n     */\n    void applyFunctionParam(float(*func)(float, std::vector<float>&), std::vector<float> &param);\n\n    /**\n     * @brief getFullBox computes a full BBox for this image.\n     * @return This function returns a full BBox for this image.\n     */\n    BBox getFullBox();\n\n    /**\n     * @brief getMaxVal computes the maximum value for the current Image.\n     * @param box is the bounding box where to compute the function. If it\n     * is set to NULL the function will be computed on the entire image.\n     * @param ret is an array where the function computations are stored. If it\n     * is set to NULL an array will be allocated.\n     * @return This function returns an array where the function computations\n     * are stored.\n     */\n    float *getMaxVal(BBox *box, float *ret);\n\n    /**\n     * @brief getMinVal computes the minimum value for the current Image.\n     * @param box is the bounding box where to compute the function. If it\n     * is set to NULL the function will be computed on the entire image.\n     * @param ret is an array where the function computations are stored. If it\n     * is set to NULL an array will be allocated.\n     * @return This function returns an array where the function computations\n     * are stored.\n     */\n    float *getMinVal(BBox *box, float *ret);\n\n    /**\n     * @brief getLogMeanVal computes the log mean for the current Image.\n     * @param box is the bounding box where to compute the function. If it\n     * is set to NULL the function will be computed on the entire image.\n     * @param ret is an array where the function computations are stored. If it\n     * is set to NULL an array will be allocated.\n     * @return This function returns an array where the function computations\n     * are stored.\n     */\n    float *getLogMeanVal(BBox *box, float *ret);\n\n    /**\n     * @brief getSumVal sums values for the current Image.\n     * @param box is the bounding box where to compute the function. If it\n     * is set to NULL the function will be computed on the entire image.\n     * @param ret is an array where the function computations are stored. If it\n     * is set to NULL an array will be allocated.\n     * @return This function returns an array where the function computations\n     * are stored.\n     */\n    float *getSumVal(BBox *box, float *ret);\n\n    /**\n     * @brief getMeanVal computes the mean for the current Image.\n     * @param box is the bounding box where to compute the function. If it\n     * is set to NULL the function will be computed on the entire image.\n     * @param ret is an array where the function computations are stored. If it\n     * is set to NULL an array will be allocated.\n     * @return This function returns an array where the function computations\n     * are stored.\n     */\n    float *getMeanVal(BBox *box, float *ret);\n\n    /**\n     * @brief getMomentsVal computes the moments at pixel (x0, y0).\n     * @param x0 is the horizontal coordinate.\n     * @param y0 is the vertical coordinate.\n     * @param radius is the radius of the patch.\n     * @param ret is an array where the function computations are stored. If it\n     * is set to NULL an array will be allocated.\n     * @return This function returns an array where the function computations\n     * are stored.\n     */\n    float *getMomentsVal(int x0, int y0, int radius, float *ret);\n\n    /**\n     * @brief getVarianceVal computes the variance for the current Image.\n     * @param box is the bounding box where to compute the function. If it\n     * is set to NULL the function will be computed on the entire image.\n     * @param ret is an array where the function computations are stored. If it\n     * is set to NULL an array will be allocated.\n     * @return This function returns an array where the function computations\n     * are stored.\n     */\n    float *getVarianceVal(float *meanVal, BBox *box, float *ret);\n\n    /**\n     * @brief getCovMtxVal computes the convariance matrix for the current Image.\n     * @param box is the bounding box where to compute the function. If it\n     * is set to NULL the function will be computed on the entire image.\n     * @param ret is an array where the function computations are stored. If it\n     * is set to NULL an array will be allocated.\n     * @return This function returns an array where the function computations\n     * are stored.\n     */\n    float *getCovMtxVal(float *meanVal, BBox *box, float *ret);\n\n    /**\n     * @brief getPercentileVal computes the n-th value given a percentile.\n     * @param percentile is the percentile.\n     * @param box is the bounding box where to compute the function. If it\n     * is set to NULL the function will be computed on the entire image.\n     * @param percentile is the percentile.\n     * @param ret is an array where the function computations are stored. If it\n     * is set to NULL an array will be allocated.\n     * @return This function returns an array where the function computations\n     * are stored.\n     */\n    float *getPercentileVal(float percentile, BBox *box, float *ret);\n\n\n    /**\n     * @brief getPercentileVal computes the median value value given a percentile.\n     * @param box is the bounding box where to compute the function. If it\n     * is set to NULL the function will be computed on the entire image.\n     * @param percentile is the percentile.\n     * @param ret is an array where the function computations are stored. If it\n     * is set to NULL an array will be allocated.\n     * @return This function returns an array where the function computations\n     * are stored.\n     */\n    float *getMedVal( BBox *box, float *ret);\n\n    /**\n     * @brief getDynamicRange computes the dynamic range of the image.\n     * @param bRobust is a value that enables robust computation of the dynamic range using percentile.\n     * @param percentile is the percentile value used when computing the dynamic range in a robust way.\n     * @return\n     */\n    float getDynamicRange(bool bRobust, float percentile);\n\n    /**\n     * @brief getdataUC\n     * @return\n     */\n    unsigned char *getdataUC()\n    {\n        return dataUC;\n    }\n\n    /**\n     * @brief getColorSamples\n     * @param samples\n     * @param percentage\n     * @return\n     */\n    float *getColorSamples(float *samples, int &nSamples, float percentage);\n\n    /**\n     * @brief size computes the number of values.\n     * @return This function returns the number of values of the entire image.\n     */\n    int size() const\n    {\n        return height * width * channels * frames;\n    }\n\n    /**\n     * @brief size computes the number of values.\n     * @return This function returns the number of values of a frame.\n     */\n    int sizeFrame() const\n    {\n        return height * width * channels;\n    }\n\n    /**\n     * @brief nPixels computes the number of pixels.\n     * @return This function returns the number of pixels.\n     */\n    int nPixels() const\n    {\n        return height * width * frames;\n    }\n\n    /**\n     * @brief checkCoordinates checks (x, y, z) coordinates) if they are valid or not.\n     * @param x is the horizontal coordinate.\n     * @param y is the vertical coordinate.\n     * @param z is the temporal coordinate.\n     * @return This function returns true if the coordinates are inside the bounding\n     * box of the Image.\n     */\n    bool checkCoordinates(int x, int y, int z = 0)\n    {\n        return (x > -1) && (x < width) && (y > -1) && (y < height) &&\n               (z > -1) && (z < frames);\n    }\n\n    /**\n     * @brief convertFromMask converts a boolean mask into an Image. true is mapped\n     * to 1.0f, and false is mapped to 0.0f.\n     * @param mask is a buffer of boolean values with (width * height) elements.\n     * @param width is the horizontal number of pixels.\n     * @param height is the vertical number of pixels.\n     */\n    void convertFromMask(bool *mask, int width, int height);\n\n    /**\n     * @brief convertToMask converts an Image into a boolean mask.\n     * @param color\n     * @param threshold\n     * @param cmp\n     * @param mask\n     * @return\n     */\n    bool *convertToMask(float *color, float threshold, bool cmp, bool *mask);\n\n    /**\n     * @brief getFlippedEXR returns the flippedEXR flag.\n     * @return This function returns the flippedEXR flag.\n     */\n    bool getFlippedEXR()\n    {\n        return flippedEXR;\n    }\n\n    /**\n     * @brief removeSpecials removes NaN and +/-Inf values and sets\n     * them to 0.0f.\n     */\n    void removeSpecials();\n\n    /**\n     * @brief clamp set data values in the range [a,b]\n     * @param a the minimum value.\n     * @param b the maximum value.\n     */\n    void clamp(float a, float b);\n\n    /**\n     * @brief calculateStrides computes the strides values\n     * for pixels, lines and frames.\n     */\n    void calculateStrides()\n    {\n        tstride = channels * height * width;\n        ystride = width * channels;\n        xstride = channels;\n    }\n\n    /**\n     * @brief operator () returns a pointer to a pixel at (x, y, t)\n     * @param x is the horizontal coordinate in pixels\n     * @param y is the vertical coordinate in pixels\n     * @param t is the temporal coordinate in pixels\n     * @return This function returns a pointer to data at location (x, y, t).\n     */\n    float *operator()(int x, int y, int t)\n    {\n        return data + CLAMP(t, frames) * tstride +\n                      CLAMP(x, width)  * xstride +\n                      CLAMP(y, height) * ystride;\n    }\n\n    /**\n     * @brief operator () returns a pointer to a pixel at (x, y)\n     * @param x is the horizontal coordinate in pixels\n     * @param y is the vertical coordinate in pixels\n     * @return This function returns a pointer to data at location (x, y).\n     */\n    float *operator()(int x, int y)\n    {\n        return data + CLAMP(x, width)  * xstride +\n                      CLAMP(y, height) * ystride;\n    }\n\n    /**\n     * @brief operator () returns a pointer to a pixel at (x, y)\n     * with normalized coordinates (values in [0, 1]).\n     * @param x is the horizontal coordinate in pixels\n     * @param y is the vertical coordinate in pixels\n     * @return This function returns a pointer to data at location (x, y).\n     */\n    float *operator()(float x, float y)\n    {\n        int ix = CLAMP(int(floorf(x * width)), width);\n        int iy = CLAMP(int(floorf(y * height)), height);\n        return data + ix * xstride + iy * ystride;\n    }\n\n    /**\n     * @brief getLL returns a pointer to a pixel given a normalized\n     * direction and assuming longituted-latitude mapping of the image.\n     * @param x the x-coordinate of the unit-vector\n     * @param y the y-coordinate of the unit-vector\n     * @param z the z-coordinate of the unit-vector\n     * @return This function returns a pointer to data at location (x, y, z)\n     * that is normalized; i.e., sqrt(x^2+y^2+z^2) == 1.\n     */\n    float *getLL(float x, float y, float z)\n    {\n        float xf = 1.0f - ((atan2f(z, -x) * C_INV_PI) * 0.5f + 0.5f);\n        float yf = (acosf(y) * C_INV_PI);\n\n        int ix = CLAMP(int(floorf(xf * width)), width);\n        int iy = CLAMP(int(floorf(yf * height)), height);\n\n        return data + ix * xstride + iy * ystride;\n    }\n\n    /**\n     * @brief getNormalizedCoords computes normalized coordinates\n     * (nx, ny) of (x, y).\n     * @param x is the horizontal coordinate in pixels\n     * @param y is the vertical coordinate in pixels\n     * @param nx is the horizontal coordinate in [0, 1]\n     * @param ny is the vertical coordinate in [0, 1]\n     */\n    void getNormalizedCoords(int x, int y, float &nx, float &ny)\n    {\n        nx = float(x) / width1f;\n        ny = float(y) / height1f;\n    }\n\n    /**\n     * @brief getAddress calculates a memory address from (x, y)\n     * @param x is the horizontal coordinate in pixels\n     * @param y is the vertical coordinate in pixels\n     * @return This function returns the memory address for (x, y)\n     */\n    int getAddress(int x, int y)\n    {\n        x = CLAMP(x, width);\n        y = CLAMP(y, height);\n\n        return x * xstride + y * ystride;\n    }\n\n    /**\n     * @brief getAddress calculates a memory address from (x, y, t)\n     * @param x is the horizontal coordinate in pixels\n     * @param y is the vertical coordinate in pixels\n     * @param t is the temporal coordinate in pixels\n     * @return This function returns the memory address for (x, y, t)\n     */\n    int getAddress(int x, int y, int t)\n    {\n        x = CLAMP(x, width);\n        y = CLAMP(y, height);\n        t = CLAMP(t, frames);\n\n        return x * xstride + y * ystride + t * tstride;\n    }\n\n    /**\n     * @brief reverseAddress computes (x, y) given a memory address\n     * @param ind is the memory input address\n     * @param x is the output horizontal coordinate for ind\n     * @param y is the output vertical coordinate for ind\n     */\n    void reverseAddress(int ind, int &x, int &y)\n    {\n        ind = ind / channels;\n        y   = ind / width;\n        x   = ind - (y * width);\n    }\n\n    /**\n     * @brief allocateSimilarOne creates an Image with similar size\n     * of the calling instance.\n     * @return This returns an Image with the same size of the calling instance.\n     */\n    Image *allocateSimilarOne();\n\n    /**\n     * @brief allocateSimilarTo allocate an Image with similar size\n     * of the passed by.\n     */\n    void allocateSimilarTo(Image *img);\n\n    /**\n     * @brief Clone creates a deep copy of the calling instance.\n     * @return This returns a deep copy of the calling instance.\n     */\n    Image *clone() const;\n\n    /**\n     * @brief Read opens an Image from a file on the disk.\n     * @param nameFile is the file name.\n     * @param typeLoad is an option for LDR images only:\n     * LT_NOR means that the input image values will be normalized in [0,1].\n     * LT_NOR_GAMMA means that the input image values will be normalized in [0,1], and\n     * gamma correction 2.2 will be removed.\n     * LT_NONE means that image values are not modified.\n     *\n     * The default is LT_NOR_GAMMA assuming that\n     * we are storing normalized and linearized values in Image.\n     *\n     * @return This returns true if the reading succeeds, false otherwise.\n     */\n    bool Read (std::string nameFile, LDR_type typeLoad);\n\n    /**\n     * @brief Write saves an Image into a file on the disk.\n     * @param nameFile is the file name.\n     * @param typeWrite is an option for LDR images only:\n     * LT_NOR means that Image ha normalized values and the output image\n     * values will be multiplied by 255 to have values in [0,255].\n     * LT_NOR_GAMMA means that Image ha normalized and linearized values. The output image\n     * values will be gamma corrected (2.2) and multiplied by 255 to have values in [0,255].\n     * LT_NONE means that Image values are the same of the output.\n     *\n     * The default is LT_NOR_GAMMA assuming that\n     * we are storing normalized and linearized values in Image.\n     *\n     * @param writerCounter is the frame that we want to write on the disk in the case Image is a video.\n     * The default writerCounter value is 0.\n     * @return This returns true if the writing succeeds, false otherwise.\n     */\n    bool Write(std::string nameFile, LDR_type typeWrite, int writerCounter);\n\n\n    /**\n     * @brief changeOwnership\n     * @param notOwned\n     */\n    void changeOwnership(bool notOwned)\n    {\n        this->notOwned = notOwned;\n    }\n\n    /**\n     * @brief operator =\n     * @param a\n     */\n    void operator =(const Image &a);\n\n    /**\n     * @brief operator =\n     * @param a\n     */\n    void operator =(const float &a);\n\n    /**\n     * @brief operator +=\n     * @param a\n     */\n    void operator +=(const float &a);\n\n    /**\n     * @brief operator +\n     * @param a\n     * @return it returns (this + a)\n     */\n    Image operator +(const float &a) const;\n\n    /**\n     * @brief operator +=\n     * @param a\n     */\n    void operator +=(const Image &a);\n\n    /**\n     * @brief operator +\n     * @param a\n     * @return it returns (this + a)\n     */\n    Image operator +(const Image &a) const;\n\n    /**\n     * @brief operator *=\n     * @param a\n     */\n    void operator *=(const float &a);\n\n    /**\n     * @brief operator *\n     * @param a\n     * @return it returns (this * a)\n     */\n    Image operator *(const float &a) const;\n\n    /**\n     * @brief operator *=\n     * @param a\n     */\n    void operator *=(const Image &a);\n\n    /**\n     * @brief operator *\n     * @param a\n     * @return it returns (this * a)\n     */\n    Image operator *(const Image &a) const;\n\n    /**\n     * @brief operator -=\n     * @param a\n     */\n    void operator -=(const float &a);\n\n    /**\n     * @brief operator -\n     * @param a\n     * @return it returns (this - a)\n     */\n    Image operator -(const float &a) const;\n\n    /**\n     * @brief operator -=\n     * @param a\n     */\n    void operator -=(const Image &a);\n\n    /**\n     * @brief operator -\n     * @param a\n     * @return it returns (this - a)\n     */\n    Image operator -(const Image &a) const;\n\n    /**\n     * @brief operator /=\n     * @param a\n     */\n    void operator /=(const float &a);\n\n    /**\n     * @brief operator /\n     * @param a\n     * @return it returns (this / a)\n     */\n    Image operator /(const float &a) const;\n\n    /**\n     * @brief operator /=\n     * @param a\n     */\n    void operator /=(const Image &a);\n\n    /**\n     * @brief operator /\n     * @param a\n     * @return it returns (this / a)\n     */\n    Image operator /(const Image &a) const;\n\n    /**\n     * @brief sort\n     * @return\n     */\n    float *sort()\n    {\n        if(!isValid()) {\n            return NULL;\n        }\n\n        int size_i = size();\n        float *tmp = new float[size_i];\n        memcpy(tmp, data, sizeof(float) * size_i);\n        std::sort(tmp, tmp + size_i);\n        return tmp;\n    }\n};\n\nPIC_INLINE void Image::setNULL()\n{\n    nameFile = \"\";\n    notOwned = false;\n\n    alpha = -1;\n    tstride = -1;\n    ystride = -1;\n    xstride = -1;\n    width = -1;\n    height = -1;\n    frames = -1;\n    depth = -1;\n    channels = -1;\n\n    channelsf = -1.0f;\n    widthf = -1.0f;\n    heightf = -1.0f;\n    width1f = -1.0f;\n    height1f = -1.0f;\n    framesf = -1.0f;\n    frames1f = -1.0f;\n\n    data = NULL;\n    dataUC = NULL;\n    dataRGBE = NULL;\n    typeLoad = LT_NONE;\n\n#ifdef PIC_ENABLE_OPEN_EXR\n    dataEXR = NULL;\n#endif\n\n    flippedEXR = false;\n\n    readerCounter = 0;\n    exposure = 1.0f;\n}\n\nPIC_INLINE Image::Image()\n{\n    setNULL();\n}\n\nPIC_INLINE Image::Image(Image *imgIn, bool deepCopy = true)\n{\n    setNULL();\n    \n    if(imgIn == NULL) {\n        return;\n    }\n\n    if(deepCopy) {\n        assign(imgIn);\n    } else {\n        width = imgIn->width;\n        height = imgIn->height;\n        channels = imgIn->channels;\n        frames = imgIn->frames;\n\n        widthf = imgIn->widthf;\n        heightf = imgIn->heightf;\n        channelsf = imgIn->channelsf;\n        framesf = imgIn->framesf;\n\n        data = imgIn->data;\n        dataUC = imgIn->dataUC;\n        dataRGBE = imgIn->dataRGBE;\n\n    #ifdef PIC_ENABLE_OPEN_EXR\n        dataRGBE = imgIn->dataRGBE;\n    #endif\n\n        notOwned = true;\n        exposure = imgIn->exposure;\n        nameFile = imgIn->nameFile;\n        flippedEXR = imgIn->flippedEXR;\n        typeLoad = imgIn->typeLoad;\n\n        allocateAux();\n    }\n\n}\n\nPIC_INLINE Image::Image(int width, int height, int channels = 3)\n{\n    setNULL();\n    allocate(width, height, channels, 1);\n}\n\nPIC_INLINE Image::Image(int frames, int width, int height, int channels,\n                        float *data = NULL)\n{\n    setNULL();\n\n    if(data == NULL) {\n        allocate(width, height, channels, frames);\n    } else {\n        this->frames   = frames;\n        this->channels = channels;\n        this->width    = width;\n        this->height   = height;\n        this->notOwned = true;\n        this->data = data;\n\n        allocateAux();\n    }\n}\n\nPIC_INLINE Image::Image(std::string nameFile, LDR_type typeLoad = LT_NOR_GAMMA)\n{\n    setNULL();\n    Read(nameFile, typeLoad);\n}\n\nPIC_INLINE Image::Image(float *color, int channels)\n{\n    typeLoad = LT_NONE;\n    setNULL();\n\n    if(color != NULL) {\n        allocate(1, 1, channels, 1);\n        memcpy(data, color, channels);\n    }\n}\n\nPIC_INLINE Image::~Image()\n{\n    release();\n}\n\nPIC_INLINE void Image::release()\n{\n    //release all allocated resources\n    if(!notOwned) {\n        data = delete_vec_s(data);\n        dataUC = delete_vec_s(dataUC);\n        dataRGBE = delete_vec_s(dataRGBE);\n\n        #ifdef PIC_ENABLE_OPEN_EXR\n            delete_vec_s(dataEXR);\n        #endif\n    }\n}\n\nPIC_INLINE void Image::allocate(int width, int height, int channels, int frames)\n{\n    if(width < 1 || height < 1 || channels < 1 || frames < 1) {\n        #ifdef PIC_DEBUG\n            printf(\"Image::Allocate: not a valid image to be allocated.\\n\");\n        #endif\n        return;\n    }\n\n    if(this->width > 0 && this->height > 0 && this->channels > 0 &&\n       this->frames > 0 && data != NULL) {\n        #ifdef PIC_DEBUG\n            printf(\"Image::Allocate: already allocated image.\\n\");\n        #endif\n        return;\n    }\n\n    this->frames = frames;\n    this->channels = channels;\n    this->width = width;\n    this->height = height;\n    this->notOwned = false;\n\n    data = new float [size()];\n\n    allocateAux();\n}\n\nPIC_INLINE void Image::allocateAux()\n{\n    this->fullBox = getFullBox();\n\n    this->depth    = frames;\n    this->widthf   = float(width);\n    this->width1f  = float(width - 1);\n    this->heightf  = float(height);\n    this->height1f = float(height - 1);\n    this->channelsf = float(channels);\n    this->framesf  = float(frames);\n    this->frames1f = float(frames -1);\n\n    calculateStrides();\n}\n\nPIC_INLINE BBox Image::getFullBox()\n{\n    BBox fullBox;\n    fullBox.setBox(0, width, 0, height, 0, frames, width,\n                             height, frames);\n\n    return fullBox;\n}\n\nPIC_INLINE void Image::assign(const Image *imgIn)\n{\n    if(imgIn == NULL) {\n        return;\n    }\n\n    if(!isSimilarType(imgIn)) {\n        release();\n        allocate(imgIn->width, imgIn->height, imgIn->channels, imgIn->frames);\n    }\n\n    exposure = imgIn->exposure;\n    nameFile = imgIn->nameFile;\n    typeLoad = imgIn->typeLoad;\n    flippedEXR = imgIn->flippedEXR;\n\n    memcpy(data, imgIn->data, size() * sizeof(float));\n}\n\nPIC_INLINE void Image::clamp(float a = 0.0f, float b = 1.0f)\n{\n    int size_i = size();\n\n    #pragma omp parallel for\n    for(int i = 0; i < size_i; i++) {\n        data[i] = CLAMPi(data[i], a, b);\n    }\n}\n\nPIC_INLINE void Image::removeSpecials()\n{\n    int size_i = size();\n\n    #pragma omp parallel for\n    for(int i = 0; i < size_i; i++) {\n        float val = data[i];\n\n        if(isnan(val) || isinf(val)) {\n            data[i] = 0.0f;\n        }\n    }\n}\n\nPIC_INLINE bool Image::isSimilarType(const Image *img)\n{\n    if(img == NULL) {\n        return false;\n    }\n\n    bool ret =\t(width      ==  img->width) &&\n                (height     ==  img->height) &&\n                (frames     ==  img->frames) &&\n                (channels   ==  img->channels) &&\n                (flippedEXR ==  img->flippedEXR);\n\n#ifdef PIC_DEBUG\n\n    if(!ret) {\n        printf(\"\\nImage::isSimilarType: ERROR The two compared images are not similar.\\n\");\n    }\n\n#endif\n\n    return ret;\n}\n\nPIC_INLINE bool Image::isValid()\n{\n    return (width > 0) && (height > 0) && (channels > 0) && (frames > 0) &&\n           (data != NULL);\n}\n\nPIC_INLINE void Image::copySubImage(Image *imgIn, int startX, int startY)\n{\n    Buffer<float>::copySubBuffer(imgIn->data, imgIn->width, imgIn->height, imgIn->channels,\n                                 startX, startY,\n                                 data, width, height, channels);\n}\n\nPIC_INLINE void Image::scaleCosine()\n{\n    int half_h = height >> 1;\n\n    #pragma omp parallel for\n    for(int i = 0; i < height; i++) {\n        float angle  = C_PI * float(i - half_h) / float(height);\n        float cosAng = MAX(cosf(angle), 0.0f);\n\n        for(int j = 0; j < width; j++) {\n            float *tmp_data = (*this)(j, i);\n\n            for(int k = 0; k < channels; k++) {\n                tmp_data[k] *= cosAng;\n            }\n        }\n    }\n}\n\nPIC_INLINE void Image::applyFunction(float(*func)(float))\n{\n    if(!isValid()) {\n        return;\n    }\n\n    int size_i = size();\n\n    #pragma omp parallel for\n    for(int i = 0; i < size_i; i++) {\n        data[i] = (*func)(data[i]);\n    }\n}\n\nPIC_INLINE void Image::applyFunctionParam(float(*func)(float, std::vector<float>&), std::vector<float> &param)\n{\n    if(!isValid()) {\n        return;\n    }\n\n    int size_i = size();\n\n    #pragma omp parallel for\n    for(int i = 0; i < size_i; i++) {\n        data[i] = (*func)(data[i], param);\n    }\n}\n\nPIC_INLINE float *Image::getPercentileVal(float percentile, BBox *box, float *ret)\n{\n    if(!isValid()) {\n        return ret;\n    }\n\n    if(box == NULL) {\n        box = &fullBox;\n    }\n\n    if(ret == NULL) {\n        ret = new float[channels << 1];\n    }\n\n    int size_i = box->Size();\n    float *dataTMP = new float[size_i];\n\n    for(int ch = 0; ch < channels; ch++) {\n        int counter = 0;\n        for(int k = box->z0; k < box->z1; k++) {\n            for(int j = box->y0; j < box->y1; j++) {\n                for(int i = box->x0; i < box->x1; i++) {\n                    dataTMP[counter] = (*this)(i, j, k)[ch];\n                    counter++;\n                }\n            }\n        }\n\n        std::sort(dataTMP, dataTMP + size_i);\n\n        int size_i_t = size_i - 1;\n        int index_r = ch << 1;\n\n        float index_f;\n        int index;\n\n        float size_i_t_f = float(size_i_t);\n\n        index_f = percentile * size_i_t_f;\n        index = CLAMPi(int(index_f), 0, size_i_t);\n        ret[index_r    ] = dataTMP[index];\n\n        index_f = (1.0f - percentile) * size_i_t_f;\n        index = CLAMPi(int(index_f), 0, size_i_t);\n        ret[index_r + 1] = dataTMP[index];\n    }\n\n    delete[] dataTMP;\n\n    return ret;\n}\n\nPIC_INLINE float *Image::getMedVal(BBox *box, float *ret)\n{\n    return getPercentileVal(0.5f, box, ret);\n}\n\nPIC_INLINE float Image::getDynamicRange(bool bRobust = false, float percentile = 0.99f)\n{\n    if(!isValid()) {\n        return -1.0f;\n    }\n\n    if(bRobust) {\n        if(percentile <= 0.5f) {\n            percentile = 0.99f;\n        }\n\n        float percentile_low = 1.0f - percentile;\n\n        float *values = getPercentileVal(percentile_low, NULL, NULL);\n        float min_val = values[0];\n        float max_val = values[1];\n\n        if(min_val > 0.0f) {\n            return max_val / min_val;\n        } else {\n            if(percentile > 0.5f) {\n                return getDynamicRange(true, percentile * 0.99f);\n            } else {\n                return 0.0f;\n            }\n        }\n    } else {\n        float ret = -1.0f;\n\n        float *min_val_v = getMinVal(NULL, NULL);\n        float *max_val_v = getMaxVal(NULL, NULL);\n\n        int ind;\n        float min_val = Arrayf::getMin(min_val_v, channels, ind);\n        float max_val = Arrayf::getMax(max_val_v, channels, ind);\n\n        if(min_val <= 0.0f) {\n            IntCoord coord;\n            IndexedArray<float>::findSimple(data, size(), IndexedArray<float>::bFuncNotNeg, coord);\n            min_val = IndexedArray<float>::min(data, coord);\n\n            if(min_val != max_val) {\n                if(max_val > min_val) {\n                    ret = max_val / min_val;\n                } else {\n                    ret = -2.0f;\n                }\n            } else {\n                ret = 0.0f;\n            }\n        }\n\n        delete_vec_s(min_val_v);\n        delete_vec_s(max_val_v);\n\n        return ret;\n    }\n}\n\nPIC_INLINE void Image::blend(Image *img, Image *weight)\n{\n    if(img == NULL || weight == NULL) {\n        return;\n    }\n\n    if( (weight->channels != 1) &&\n        (weight->channels != img->channels)) {\n        return;\n    }\n\n    int size = height * width;\n\n    #pragma omp parallel for\n    for(int ind = 0; ind < size; ind++) {\n        int i = ind * channels;\n\n        int indx_w = ind * weight->channels;\n        //int indx_w = i_w;// + (j % weight->channels);\n        float w0 = weight->data[indx_w];\n        float w1 = 1.0f - w0;\n\n        for(int j = 0; j < channels; j++) {\n            int indx = i + j;\n\n            data[indx] = data[indx] * w0 + img->data[indx] * w1;\n        }\n    }\n}\n\nPIC_INLINE void Image::minimum(Image *img)\n{\n    if(!isValid() || !isSimilarType(img)) {\n        return;\n    }\n\n    int n = size();\n\n    #pragma omp parallel for\n\n    for(int i = 0; i < n; i++) {\n        data[i] = data[i] > img->data[i] ? img->data[i] : data[i];\n    }\n}\n\nPIC_INLINE void Image::maximum(Image *img)\n{\n    if(!isValid() || !isSimilarType(img)) {\n        return;\n    }\n\n    int n = size();\n\n    #pragma omp parallel for\n    for(int i = 0; i < n; i++) {\n        data[i] = data[i] < img->data[i] ? img->data[i] : data[i];\n    }\n}\n\nPIC_INLINE void Image::setZero()\n{\n    if(!isValid()) {\n        return;\n    }\n\n    Buffer<float>::assign(data, size(), 0.0f);\n}\n\nPIC_INLINE void Image::setRand(unsigned int seed = 1)\n{\n    if(!isValid()) {\n        return;\n    }\n\n    std::mt19937 m(seed);\n    int n = size();\n\n    for(int i = 0; i < n; i++) {\n        data[i] = float(m()) / 4294967295.0f;\n    }\n}\n\nPIC_INLINE float *Image::getMaxVal(BBox *box = NULL, float *ret = NULL)\n{\n    if(!isValid()) {\n        return ret;\n    }\n\n    if(box == NULL) {\n        box = &fullBox;\n    }\n\n    if(ret == NULL) {\n        ret = new float[channels];\n    }\n\n    for(int l = 0; l < channels; l++) {\n        ret[l] = -FLT_MAX;\n    }\n\n    for(int k = box->z0; k < box->z1; k++) {\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *tmp_data = (*this)(i, j, k);\n\n                for(int l = 0; l < channels; l++) {\n                    ret[l] = ret[l] < tmp_data[l] ? tmp_data[l] : ret[l];\n                }\n            }\n        }\n    }\n\n    return ret;\n}\n\nPIC_INLINE float *Image::getMinVal(BBox *box = NULL, float *ret = NULL)\n{\n    if(!isValid()) {\n        return ret;\n    }\n\n    if(box == NULL) {\n        box = &fullBox;\n    }\n\n    if(ret == NULL) {\n        ret = new float[channels];\n    }\n\n    for(int l = 0; l < channels; l++) {\n        ret[l] = FLT_MAX;\n    }\n\n    for(int k = box->z0; k < box->z1; k++) {\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *tmp_data = (*this)(i, j, k);\n\n                for(int l = 0; l < channels; l++) {\n                    ret[l] = ret[l] > tmp_data[l] ? tmp_data[l] : ret[l];\n                }\n            }\n        }\n    }\n\n    return ret;\n}\n\nPIC_INLINE float *Image::getSumVal(BBox *box = NULL, float *ret = NULL)\n{\n    if(!isValid()) {\n        return ret;\n    }\n\n    if(box == NULL) {\n        box = &fullBox;\n    }\n\n    if(ret == NULL) {\n        ret = new float[channels];\n    }\n\n    Arrayf::assign(0.0f, ret, channels);\n\n    for(int k = box->z0; k < box->z1; k++) {\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *tmp_data = (*this)(i, j, k);\n\n                Arrayf::add(tmp_data, channels, ret);\n            }\n        }\n    }\n\n    return ret;\n}\n\nPIC_INLINE float *Image::getMeanVal(BBox *box = NULL, float *ret = NULL)\n{\n    if(!isValid()) {\n        return ret;\n    }\n\n    if(box == NULL) {\n        box = &fullBox;\n    }\n\n    ret = getSumVal(box, ret);\n\n    float totf = float(box->Size());\n\n    Arrayf::div(ret, channels, totf);\n\n    return ret;\n}\n\nPIC_INLINE float *Image::getMomentsVal(int x0, int y0, int radius, float *ret = NULL)\n{\n    if(!isValid()) {\n        return ret;\n    }\n\n    int channels_2 = channels << 1;\n\n    if(ret == NULL) {\n        ret = new float[channels_2];\n    }\n\n    Arrayf::assign(0.0f, ret, channels_2);\n\n    for(int j = -radius; j <= radius; j++) {\n        int y = y0 + j;\n\n        for(int i = -radius; i <= radius; i++) {\n            int x = x0 + i;\n\n            float *tmp_data = (*this)(x, y);\n\n            for(int l = 0; l < channels_2; l += 2) {\n                ret[l    ] += j * tmp_data[l];\n                ret[l + 1] += i * tmp_data[l];\n            }\n        }\n    }\n\n    return ret;\n}\n\nPIC_INLINE float *Image::getVarianceVal(float *meanVal = NULL,\n                                        BBox *box = NULL,\n                                        float *ret = NULL)\n{\n    if(!isValid()) {\n        return ret;\n    }\n\n    if(box == NULL) {\n        box = &fullBox;\n    }\n\n    bool bDeleteMeanVal = false;\n\n    if(meanVal == NULL) {\n        meanVal = getMeanVal(box, NULL);\n        bDeleteMeanVal = true;\n    }\n\n    if(ret == NULL) {\n        ret = new float[channels];\n    }\n\n    Arrayf::assign(0.0f, ret, channels);\n\n    for(int k = box->z0; k < box->z1; k++) {\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *tmp_data = (*this)(i, j, k);\n\n                for(int l = 0; l < channels; l++) {\n                    float tmp = tmp_data[l] - meanVal[l];\n                    ret[l] += tmp * tmp;\n                }\n            }\n        }\n    }\n\n    float totf = float(box->Size() - 1);\n\n    Arrayf::div(ret, channels, totf);\n\n    if(bDeleteMeanVal) {\n        delete[] meanVal;\n    }\n\n    return ret;\n}\n\n\nPIC_INLINE float *Image::getCovMtxVal(float *meanVal, BBox *box, float *ret)\n{\n    if(!isValid()) {\n        return ret;\n    }\n\n    if(box == NULL) {\n        box = &fullBox;\n    }\n\n    bool bMeanValAllocated = false;\n\n    if(meanVal == NULL) {\n        meanVal = getMeanVal(box, NULL);\n        bMeanValAllocated = true;\n    }\n\n    int n = channels * channels;\n\n    if(ret == NULL) {\n        ret = new float[n];\n    }\n\n    Arrayf::assign(0.0f, ret, n);\n\n    for(int k = box->z0; k < box->z1; k++) {\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *tmp_data = (*this)(i, j, k);\n\n                for(int l = 0; l < channels; l++) {\n                    float tmp1 = (tmp_data[l] - meanVal[l]);\n\n                    for(int m = 0; m < channels; m++) {\n                        float tmp2 = (tmp_data[m] - meanVal[m]);\n\n                        ret[l * channels + m] += tmp1 * tmp2;\n                    }\n                }\n            }\n        }\n    }\n\n    float totf = float(box->Size() - 1);\n\n    Arrayf::div(ret, n, totf);\n\n    if(bMeanValAllocated) {\n        delete[] meanVal;\n    }\n\n    return ret;\n}\n\nPIC_INLINE float *Image::getLogMeanVal(BBox *box = NULL, float *ret = NULL)\n{\n    if(!isValid()) {\n        return ret;\n    }\n\n    if(box == NULL) {\n        box = &fullBox;\n    }\n\n    if(ret == NULL) {\n        ret = new float[channels];\n    }\n\n    Arrayf::assign(0.0f, ret, channels);\n\n    for(int k = box->z0; k < box->z1; k++) {\n        for(int j = box->y0; j < box->y1; j++) {\n            for(int i = box->x0; i < box->x1; i++) {\n                float *tmp_data = (*this)(i, j, k);\n\n                for(int l = 0; l < channels; l++) {\n                    ret[l] += logf(tmp_data[l] + 1e-6f);\n                }\n            }\n        }\n    }\n\n    float totf = float(box->Size());\n\n    for(int l = 0; l < channels; l++) {\n        ret[l] = expf(ret[l] / totf);\n    }\n\n    return ret;\n}\n\nPIC_INLINE void Image::convertFromMask(bool *mask, int width, int height)\n{\n    if((mask == NULL) || (width < 1) || (height < 1)) {\n        return;\n    }\n\n    if(!isValid() || this->width != width || this->height != height) {\n        allocate(width, height, 1, 1);\n    }\n\n    int size = (width * height);\n\n    #pragma omp parallel for\n    for(int i = 0; i < size; i++) {\n        data[i] = mask[i] ? 1.0f : 0.0f;\n    }\n}\n\nPIC_INLINE bool *Image::convertToMask(float *color = NULL, float threshold = 0.25f,\n                                      bool cmp = true,  bool *mask = NULL)\n{\n    if(!isValid()) {\n        return NULL;\n    }\n    \n    bool bColorAllocated = false;\n\n    if(color == NULL) {\n        bColorAllocated = true;\n        color = new float[channels];\n\n        Arrayf::assign(0.0f, color, channels);\n    }\n\n    int n = width * height;\n\n    if(mask == NULL) {\n        mask = new bool[n];\n    }\n\n    float tmpThreshold = threshold * float(channels);\n\n    #pragma omp parallel for\n    for(int i = 0; i < n; i++) {\n        int ind = i * channels;\n\n        float val = 0.0f;\n\n        for(int k = 0; k < channels; k++) {\n            val += fabsf(data[ind + k] - color[k]);\n        }\n\n        bool bMask = val > tmpThreshold;\n        mask[i] = cmp ? bMask : !bMask;\n\n        /*\n        if(cmp) {\n            mask[i] = val > tmpThreshold;\n        } else {\n            mask[i] = val < tmpThreshold;\n        }*/\n    }\n\n    if(bColorAllocated) {\n        delete[] color;\n    }\n\n    return mask;\n}\n\nPIC_INLINE bool Image::Read(std::string nameFile,\n                               LDR_type typeLoad = LT_NOR_GAMMA)\n{\n    this->nameFile = nameFile;\n\n    this->typeLoad = typeLoad;\n\n    LABEL_IO_EXTENSION label;\n\n    bool bReturn = false;\n\n    //read the image in an HDR format\n    label = getLabelHDRExtension(nameFile);\n\n    if(label != IO_NULL) {\n        float *dataReader = NULL;\n        float *tmp = NULL;\n\n        if(data != NULL) {\n            dataReader = &data[tstride * readerCounter];\n#ifdef PIC_ENABLE_OPEN_EXR\n            dataEXR = new Imf::Rgba[width * height];\n#endif\n        } else {\n            channels = 3;\n        }\n\n        switch(label) {\n        case IO_TMP:\n            tmp = ReadTMP(nameFile, dataReader, width, height, channels, frames);\n            break;\n\n        case IO_HDR:\n            tmp = ReadHDR(nameFile, dataReader, width, height);\n            break;\n\n        case IO_PFM:\n            tmp = ReadPFM(nameFile, dataReader, width, height, channels);\n            break;\n\n        case IO_EXR:\n#ifdef PIC_ENABLE_OPEN_EXR\n            tmp = ReadEXR(nameFile, dataReader, width, height, channels, dataEXR);\n#else\n#ifndef PIC_DISABLE_TINY_EXR\n            tmp = ReadEXR(nameFile, dataReader, width, height, channels);\n#endif\n#endif\n            break;\n\n        case IO_VOL:\n            tmp = ReadVOL(nameFile, dataReader, width, height, frames, channels);\n            depth = frames;\n            break;\n\n        default:\n            tmp = NULL;\n        }\n\n        if(tmp != NULL) {\n            if(data == NULL) {\n                data = tmp;\n\n                if(frames <= 0) {\n                    frames = 1;\n                }\n            }\n\n            allocateAux();\n            bReturn = true;\n        } else {\n            bReturn = false;\n        }\n    } else {\n        //read the image using an LDR codec\n        label = getLabelLDRExtension(nameFile);\n        unsigned char *dataReader = NULL;\n        unsigned char *tmp = NULL;\n        bool bExt = false;\n\n        if(dataUC != NULL) {\n            dataReader = dataUC;\n        }\n\n        switch(label) {\n        case IO_BMP: {\n            tmp = ReadBMP(nameFile, dataReader, width, height, channels);\n        } break;\n\n        case IO_PPM: {\n            tmp = ReadPPM(nameFile, dataReader, width, height, channels);\n        } break;\n\n        case IO_PGM: {\n            tmp = ReadPGM(nameFile, dataUC, width, height, channels);\n        } break;\n\n        case IO_TGA: {\n            tmp = ReadTGA(nameFile, dataReader, width, height, channels);\n        } break;\n\n        case IO_JPG: {\n            bExt = true;\n\n            EXIFInfo info;\n            readEXIF(nameFile, info);\n            exposure = estimateAverageLuminance(info.exposureTime, info.aperture, info.iso);\n\n        } break;\n\n        case IO_PNG: {\n            bExt = true;\n        } break;\n\n        default: {\n            tmp = NULL;\n        } break;\n\n        }\n\n         if(bExt) {\n             tmp = ReadSTB(nameFile, width, height, channels);\n         }\n\n         if(tmp != NULL) { //move the handle where it's trackable\n             if(dataUC == NULL) {\n                 dataUC = tmp;\n             }\n         }\n\n         float *tmpFloat = NULL;\n\n         if(data != NULL) {\n             tmpFloat = &data[tstride * readerCounter];\n         }\n\n         float *tmpConv = convertLDR2HDR(tmp, tmpFloat, sizeFrame(), typeLoad);\n\n         dataUC = delete_vec_s(dataUC);\n\n         if(tmpConv != NULL) {\n             if(data == NULL) {\n                 data = tmpConv;                 \n                 frames = frames > 0 ? frames : 1;\n                 allocateAux();\n             }\n\n             bReturn = true;\n         } else {\n             bReturn = false;\n         }\n    }\n\n    readerCounter = (readerCounter + 1) % frames;\n    return bReturn;\n}\n\nPIC_INLINE bool Image::Write(std::string nameFile, LDR_type typeWrite = LT_NOR_GAMMA,\n                                int writerCounter = 0)\n{\n    if(!isValid()) {\n        return false;\n    }\n\n    LABEL_IO_EXTENSION label;\n\n    //read an image in an HDR format\n    label = getLabelHDRExtension(nameFile);\n\n    if(label != IO_NULL) {\n        float *dataWriter = NULL;\n\n        if((writerCounter > 0) && (writerCounter < frames)) {\n            dataWriter = &data[tstride * writerCounter];\n        } else {\n            dataWriter = data;\n        }\n\n        bool ret = false;\n\n        switch(label) {\n        case IO_TMP:\n            ret = WriteTMP(nameFile, dataWriter, width, height, channels, frames);\n            break;\n\n        case IO_HDR:\n            ret = WriteHDR(nameFile, dataWriter, width, height, channels);\n            break;\n\n        case IO_PFM:\n            ret = WritePFM(nameFile, dataWriter, width, height, channels);\n            break;\n\n        case IO_EXR:\n#ifdef PIC_ENABLE_OPEN_EXR\n            ret = WriteEXR(nameFile, dataWriter, width, height, channels);\n#else\n#ifndef PIC_DISABLE_TINY_EXR\n            ret = WriteEXR(nameFile, dataWriter, width, height, channels);\n#endif\n#endif\n            break;\n\n        case IO_VOL:\n            ret = WriteVOL(nameFile, dataWriter, width, height, frames, channels);\n            break;\n\n        default:\n            ret = false;\n        }\n\n        return ret;\n    } else {\n        //write the image into an LDR format\n        label = getLabelLDRExtension(nameFile);\n\n        bool bExt = (label == IO_JPG) || (label == IO_PNG);\n\n        //allocate memory: begin\n        float *dataWriter = NULL;\n\n        if((writerCounter > 0) && (writerCounter < frames)) {\n            dataWriter = &data[tstride * writerCounter];\n        } else {\n            dataWriter = data;\n        }\n\n        dataUC = convertHDR2LDR(dataWriter, dataUC, sizeFrame(), typeWrite);\n\n        /*\n        if(dataUC == NULL) {\n            dataUC = tmp;\n        } else {\n            dataUC = delete_vec_s(dataUC);\n            dataUC = tmp;\n        }\n        //allocate memory: end\n        */\n\n        if(bExt) {\n            return WriteSTB(nameFile, dataUC, width, height, channels);\n        } else {\n            switch(label) {\n            case IO_BMP:\n                return WriteBMP(nameFile, dataUC, width, height, channels);\n                break;\n\n            case IO_TGA:\n                //values are stored with a vertical flip\n                Buffer<unsigned char>::flipV(dataUC, width, height, channels, 1);\n\n                //values needs to be stored as BGR\n                Buffer<unsigned char>::BGRtoRGB(dataUC, width, height, channels, 1);\n\n                return WriteTGA(nameFile, dataUC, width, height, channels);\n                break;\n\n            case IO_PPM:\n                return WritePPM(nameFile, dataUC, width, height, channels);\n                break;\n\n            case IO_PGM:\n                return WritePGM(nameFile, dataUC, width, height, channels);\n                break;\n\n            default:\n                return false;\n            }\n        }\n    }\n}\n\nPIC_INLINE Image *Image::allocateSimilarOne()\n{\n    Image *ret = new Image(frames, width, height, channels);\n    ret->flippedEXR = flippedEXR;\n    ret->exposure = exposure;\n    ret->alpha = alpha;\n    return ret;\n}\n\nPIC_INLINE void Image::allocateSimilarTo(Image *img)\n{\n    if(img != NULL) {\n        if(img->isValid()) {\n            allocate(img->width, img->height, img->channels, img->frames);\n        }\n    }\n}\n\nPIC_INLINE Image *Image::clone() const\n{\n    Image *ret = new Image(frames, width, height, channels);\n\n    ret->fullBox = fullBox;\n    ret->flippedEXR = flippedEXR;\n    ret->exposure = exposure;\n    ret->nameFile = nameFile;\n    ret->alpha = alpha;\n    ret->typeLoad = typeLoad;\n\n    memcpy(ret->data, data, width * height * channels * sizeof(float));\n\n    return ret;\n}\n\nPIC_INLINE float* Image::getColorSamples(float *samples,\n                                         int &nSamples,\n                                         float percentage = 1.0f)\n{    \n    percentage = CLAMPi(percentage, 0.0f, 1.0f);\n\n    int nTot = nPixels();\n    nSamples = int(ceilf(float(nTot) * percentage));\n\n    if(samples == NULL) {\n        samples = new float[nSamples * channels];\n    }\n\n    int shift = 1;\n\n    if(nSamples < nTot) {\n        shift = nTot / nSamples;\n    }\n\n    for(int i = 0; i < nSamples; i++) {\n        int index = i * channels;\n        int index_d = index * shift;\n\n        for(int j = 0; j < channels; j++) {\n            samples[index + j] = data[index_d + j];\n        }\n    }\n\n    return samples;\n}\n\nPIC_INLINE void Image::operator =(const Image &a)\n{\n    this->assign(&a);\n}\n\nPIC_INLINE void Image::operator =(const float &a)\n{\n    Buffer<float>::assign(data, size(), a);\n}\n\nPIC_INLINE void Image::operator +=(const float &a)\n{\n    Buffer<float>::add(data, size(), a);\n}\n\nPIC_INLINE Image Image::operator +(const float &a) const\n{\n    Image *out = this->clone();\n    *out += a;\n    return Image(out, false);\n}\n\nPIC_INLINE void Image::operator +=(const Image &a)\n{\n    if(isSimilarType(&a)) {\n        Buffer<float>::add(data, a.data, size());\n    } else {\n        if((nPixels() == a.nPixels()) && (a.channels == 1)) {\n            Buffer<float>::addS(data, a.data, nPixels(), channels);\n        }\n    }\n\n}\n\nPIC_INLINE Image Image::operator +(const Image &a) const\n{\n    Image *out = this->clone();\n    *out += a;\n    return Image(out, false);\n}\n\nPIC_INLINE void Image::operator *=(const float &a)\n{\n    Buffer<float>::mul(data, size(), a);\n}\n\nPIC_INLINE Image Image::operator *(const float &a) const\n{\n    Image *out = this->clone();\n    *out *= a;\n    return Image(out, false);\n}\n\nPIC_INLINE void Image::operator *=(const Image &a)\n{\n    if(isSimilarType(&a)) {\n        Buffer<float>::mul(data, a.data, size());\n    } else {\n        if((nPixels() == a.nPixels()) && (a.channels == 1)) {\n            Buffer<float>::mulS(data, a.data, nPixels(), channels);\n        }\n    }\n}\n\nPIC_INLINE Image Image::operator *(const Image &a) const\n{\n    Image *out = this->clone();\n    *out *= a;\n    return Image(out, false);\n}\n\nPIC_INLINE void Image::operator -=(const float &a)\n{\n    Buffer<float>::sub(data, size(), a);\n}\n\nPIC_INLINE Image Image::operator -(const float &a) const\n{\n    Image *out = this->clone();\n    *out -= a;\n    return Image(out, false);\n}\n\nPIC_INLINE void Image::operator -=(const Image &a)\n{\n    if(isSimilarType(&a)) {\n        Buffer<float>::sub(data, a.data, size());\n    } else {\n        if((nPixels() == a.nPixels()) && (a.channels == 1)) {\n            Buffer<float>::subS(data, a.data, nPixels(), channels);\n        }\n    }\n}\n\nPIC_INLINE Image Image::operator -(const Image &a) const\n{\n    Image *out = this->clone();\n    *out -= a;\n    return Image(out, false);\n}\n\nPIC_INLINE void Image::operator /=(const float &a)\n{\n    Buffer<float>::div(data, size(), a);\n}\n\nPIC_INLINE Image Image::operator /(const float &a) const\n{\n    Image *out = this->clone();\n    *out /= a;\n    return Image(out, false);\n}\n\nPIC_INLINE void Image::operator /=(const Image &a)\n{\n    if(isSimilarType(&a)) {\n        Buffer<float>::div(data, a.data, size());\n    } else {\n        if((nPixels() == a.nPixels()) && (a.channels == 1)) {\n            Buffer<float>::divS(data, a.data, nPixels(), channels);\n        }\n    }\n}\n\nPIC_INLINE Image Image::operator /(const Image &a) const\n{\n    Image *out = this->clone();\n    *out /= a;\n    return Image(out, false);\n}\n\n} // end namespace pic\n\n#endif /* PIC_IMAGE_HPP */\n\n"
  },
  {
    "path": "include/image_samplers/image_sampler.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_HPP\n#define PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_HPP\n\n#include \"../image.hpp\"\n#include \"../util/image_sampler.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ImageSampler class\n */\nclass ImageSampler\n{\nprotected:\n    int dirs[3];\n\npublic:\n\n    /**\n     * @brief ImageSampler\n     */\n    ImageSampler() {}\n\n    ~ImageSampler() {}\n\n    void SetDirection(unsigned int direction)\n    {\n        dirs[ direction      % 3] = 1;\n        dirs[(direction + 1) % 3] = 0;\n        dirs[(direction + 2) % 3] = 0;\n    }\n\n    /**\n     * @brief SampleImage samples an image in uniform coordiantes.\n     * @param img\n     * @param x\n     * @param y\n     * @param vOut\n     */\n    virtual void SampleImage(Image *img, float x, float y, float *vOut) {}\n\n    /**\n     * @brief SampleImageUC samples an image in unnormalized coordinates [0,width-1]x[0,height-1].\n     * @param img\n     * @param x\n     * @param y\n     * @param vOut\n     */\n    virtual void SampleImageUC(Image *img, float x, float y, float *vOut) {}\n\n    /**\n     * @brief SampleImage samples an image in uniform coordiantes.\n     * @param img\n     * @param x\n     * @param y\n     * @param t\n     * @param vOut\n     */\n    virtual void SampleImage(Image *img, float x, float y, float t, float *vOut) {}\n};\n\n} // end namespace pic\n\n#endif /* PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_HPP */\n"
  },
  {
    "path": "include/image_samplers/image_sampler_bicubic.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_BICUBIC_HPP\n#define PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_BICUBIC_HPP\n\n#include \"../image_samplers/image_sampler.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ImageSamplerBicubic class\n */\nclass ImageSamplerBicubic: public ImageSampler\n{\npublic:\n    ImageSamplerBicubic()\n    {\n\n    }\n\n    /**\n     * @brief SampleImage samples an image in uniform coordiantes.\n     * @param img\n     * @param x\n     * @param y\n     * @param vOut\n     */\n    void SampleImage(Image *img, float x, float y, float *vOut)\n    {\n        float xx, yy, dx, dy;\n\n        //Coordiantes in [0,width-1]x[0,height-1]\n        x *= img->width1f;\n        y *= img->height1f;\n\n        //Coordinates without fractions\n        xx = floorf(x);\n        yy = floorf(y);\n\n        //Interpolation values\n        dx = (x - xx);\n        dy = (y - yy);\n\n        //Integer coordinates\n        int ix = int(xx);\n        int iy = int(yy);\n\n        for(int k = 0; k < img->channels; k++) {\n            vOut[k] = 0.0f;\n        }\n\n        //Bicubic interpolation\n        float rx, ry;\n        int ey, ex;\n        for(int j = -1; j < 3; j++) {\n            ry = Bicubic(float(j) - dy);\n            ey = CLAMP(iy + j, img->height);\n\n            for(int i = -1; i < 3; i++) {\n                rx = Bicubic(-(float(i) - dx));\n                ex = CLAMP(ix + i, img->width);\n                int ind = (ey * img->width + ex) * img->channels;\n\n                rx *= ry;\n                for(int k = 0; k < img->channels; k++) {\n                    vOut[k] += img->data[ind + k] * rx;\n                }\n            }\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_BICUBIC_HPP */\n\n"
  },
  {
    "path": "include/image_samplers/image_sampler_bilinear.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_BILINEAR_HPP\n#define PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_BILINEAR_HPP\n\n#include \"../image_samplers/image_sampler.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ImageSamplerBilinear class\n */\nclass ImageSamplerBilinear: public ImageSampler\n{\npublic:\n    ImageSamplerBilinear()\n    {\n    }\n\n    /**\n     * @brief SampleImage samples an image in normalized coordiantes (0,1).\n     * @param img\n     * @param x\n     * @param y\n     * @param vOut\n     */\n    void SampleImage(Image *img, float x, float y, float *vOut)\n    {\n        x = CLAMPi(x, 0.0f, 1.0f);\n        y = CLAMPi(y, 0.0f, 1.0f);\n\n        //Coordiantes in [0,width-1]x[0,height-1]\n        x *= img->width1f;\n        y *= img->height1f;\n        SampleImageUC(img, x, y, vOut);\n    }\n\n    /**\n     * @brief SampleImageUC samples an image in unnormalized coordinates [0,width-1]x[0,height-1].\n     * @param img\n     * @param x\n     * @param y\n     * @param vOut\n     */\n    void SampleImageUC(Image *img, float x, float y, float *vOut)\n    {\n        float xx, yy, dx, dy;\n        int ind0, ind1, ind2, ind3;\n\n        //Coordinates without fractions\n        xx = floorf(x);\n        yy = floorf(y);\n\n        //Interpolation values\n        dx = (x - xx);\n        dy = (y - yy);\n\n        //Integer coordinates\n        int ix = int(xx);\n        int iy = int(yy);\n        int ix1 = CLAMP(ix + 1, img->width);\n        int iy1 = CLAMP(iy + 1, img->height);\n\n        //Bilinear interpolation indicies\n        int t0 = iy  * img->width;\n        int t1 = iy1 * img->width;\n\n        ind0 = (ix  + t0) * img->channels;\n        ind1 = (ix1 + t0) * img->channels;\n        ind2 = (ix  + t1) * img->channels;\n        ind3 = (ix1 + t1) * img->channels;\n\n        for(int i = 0; i < img->channels; i++) {\n            vOut[i] = Bilinear<float>(img->data[ind0 + i],\n                                      img->data[ind1 + i],\n                                      img->data[ind2 + i],\n                                      img->data[ind3 + i],\n                                      dx, dy);\n        }       \n    }\n\n    /**\n     * @brief SampleImage samples an image in uniform coordiantes.\n     * @param img\n     * @param x\n     * @param y\n     * @param t\n     * @param vOut\n     */\n    void SampleImage(Image *img, float x, float y, float t, float *vOut)\n    {\n        /*\tfloat tmp = y;\n            y = t;\n            t = tmp;*/\n\n        x = CLAMPi(x, 0.0f, 1.0f);\n        y = CLAMPi(y, 0.0f, 1.0f);\n        t = CLAMPi(t, 0.0f, 1.0f);\n\n        x *= img->width1f;\n        y *= img->height1f;\n        t *= img->frames1f;\n\n        float pOut2x = floorf(x);\n        float pOut2y = floorf(y);\n        float pOut2z = floorf(t);\n\n        float deltax = x - pOut2x;\n        float deltay = y - pOut2y;\n        float deltaz = t - pOut2z;\n\n        //Integer coordinates\n        int ix = int(pOut2x);\n        int iy = int(pOut2y);\n        int iz = int(pOut2z);\n\n        int ix1 = (ix + 1) % img->width;\n        int iy1 = (iy + 1) % img->height;\n        int iz1 = (iz + 1) % img->frames;\n\n        float val[2];\n\n        for(int i = 0; i < img->channels; i++) {\n            val[0] = Bilinear<float>(\n                         *((*img)(ix,\tiy,\tiz)  + i),\n                         *((*img)(ix1,\tiy,\tiz)  + i),\n                         *((*img)(ix,\tiy,\tiz1) + i),\n                         *((*img)(ix1,\tiy,\tiz1) + i),\n                         deltax, deltaz);\n\n            val[1] = Bilinear<float>(\n                         *((*img)(ix,\tiy1,    iz)  + i),\n                         *((*img)(ix1,\tiy1,    iz)  + i),\n                         *((*img)(ix,\tiy1,    iz1) + i),\n                         *((*img)(ix1,\tiy1,    iz1) + i),\n                         deltax, deltaz);\n\n            vOut[i] = val[0] + deltay * (val[1] - val[0]);\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_BILINEAR_HPP */\n\n"
  },
  {
    "path": "include/image_samplers/image_sampler_bsplines.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_BSPLINES_HPP\n#define PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_BSPLINES_HPP\n\n#include \"../image_samplers/image_sampler.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ImageSamplerBSplines class\n */\nclass ImageSamplerBSplines: public ImageSampler\n{\npublic:\n    ImageSamplerBSplines()\n    {\n    }\n\n    /**\n     * @brief SampleImage samples an image in uniform coordiantes.\n     * @param img\n     * @param x\n     * @param y\n     * @param vOut\n     */\n    void SampleImage(Image *img, float x, float y, float *vOut)\n    {\n        //TODO: there's a reason for this, but I don't know it now\n        //\tx = CLAMPi(x, 0.0f, 1.0f);\n        //\ty = CLAMPi(y, 0.0f, 1.0f);\n\n        float xx, yy, dx, dy;\n\n        //Coordiantes in [0,width-1]x[0,height-1]\n        x *= img->width1f;\n        y *= img->height1f;\n\n        //Coordinates without fractions\n        xx = floorf(x);\n        yy = floorf(y);\n\n        //Interpolation values\n        dx = (x - xx);\n        dy = (y - yy);\n\n        //Integer coordinates\n        int ix = int(xx);\n        int iy = int(yy);\n\n        for(int k = 0; k < img->channels; k++) {\n            vOut[k] = 0.0f;\n        }\n\n        //BSplines interpolation\n        float rx, ry;\n        int ey, ex;\n        for(int j = -1; j < 3; j++) {\n            ry = Rx(float(j) - dy);\n            ey = CLAMP(iy + j, img->height);\n\n            for(int i = -1; i < 3; i++) {\n                rx = Rx(float(i) - dx) * ry;\n                ex = CLAMP(ix + i, img->width);\n                int ind = (ey * img->width + ex) * img->channels;\n\n                for(int k = 0; k < img->channels; k++) {\n                    vOut[k] += img->data[ind + k] * rx;\n                }\n            }\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_BSPLINES_HPP */\n\n"
  },
  {
    "path": "include/image_samplers/image_sampler_catmull_rom.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_CATMULL_ROM_HPP\n#define PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_CATMULL_ROM_HPP\n\n#include \"../image_samplers/image_sampler.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ImageSamplerCatmullRom class\n */\nclass ImageSamplerCatmullRom: public ImageSampler\n{\npublic:\n    ImageSamplerCatmullRom() {}\n\n    /**\n     * @brief SampleImage samples an image in uniform coordiantes.\n     * @param img\n     * @param x\n     * @param y\n     * @param vOut\n     */\n    void SampleImage(Image *img, float x, float y, float *vOut)\n    {\n        float xx, yy, dx, dy;\n\n        //Coordiantes in [0,width-1]x[0,height-1]\n        x *= img->width1f;\n        y *= img->height1f;\n\n        //Coordinates without fractions\n        xx = floorf(x);\n        yy = floorf(y);\n\n        //Interpolation values\n        dx = (x - xx);\n        dy = (y - yy);\n\n        //Integer coordinates\n        int ix = int(xx);\n        int iy = int(yy);\n\n        for(int k = 0; k < img->channels; k++) {\n            vOut[k] = 0.0f;\n        }\n\n        //Catmull-rom interpolation\n        float rx, ry;\n        int ey, ex;\n        for(int j = -1; j < 3; j++) {\n            ry = CatmullRom(float(j) - dy);\n            ey = CLAMP(iy + j, img->height);\n\n            for(int i = -1; i < 3; i++) {\n                rx = CatmullRom(-(float(i) - dx));\n                ex = CLAMP(ix + i, img->width);\n                int ind = (ey * img->width + ex) * img->channels;\n\n                rx *= ry;\n                for(int k = 0; k < img->channels; k++) {\n                    vOut[k] += img->data[ind + k] * rx;\n                }\n            }\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_CATMULL_ROM_HPP */\n\n"
  },
  {
    "path": "include/image_samplers/image_sampler_gaussian.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_GAUSSIAN_HPP\n#define PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_GAUSSIAN_HPP\n\n#include \"../image_samplers/image_sampler.hpp\"\n#include \"../util/precomputed_gaussian.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ImageSamplerGaussian class\n */\nclass ImageSamplerGaussian: public ImageSampler\n{\nprotected:\n    PrecomputedGaussian *pg;\n\npublic:\n    /**\n     * @brief ImageSamplerGaussian\n     */\n    ImageSamplerGaussian()\n    {\n        pg = NULL;\n    }\n\n    /**\n     * @brief ImageSamplerGaussian\n     * @param sigma\n     * @param direction\n     */\n    ImageSamplerGaussian(float sigma, unsigned int direction)\n    {\n        update(sigma, direction);\n    }\n\n    /**\n     * @brief update\n     * @param sigma\n     * @param direction\n     */\n    void update(float sigma, unsigned int direction)\n    {\n        delete pg;\n        pg = new PrecomputedGaussian(sigma);\n\n        SetDirection(direction);\n    }\n\n    /**\n     * @brief SampleImage samples an image in uniform coordiantes.\n     * @param img\n     * @param x\n     * @param y\n     * @param vOut\n     */\n    void SampleImage(Image *img, float x, float y, float *vOut)\n    {\n        for(int k = 0; k < img->channels; k++) {\n            vOut[k] = 0.0f;\n        }\n\n        int ix = int(x * img->widthf);\n        int iy = int(y * img->heightf);\n\n        for(int i = 0; i < pg->kernelSize ; i++) {\n            int ex = CLAMP(ix + i * dirs[0], img->width);\n            int ey = CLAMP(iy + i * dirs[1], img->height);\n\n            int ind = (ey * img->width + ex) * img->channels;\n\n            for(int k = 0; k < img->channels; k++) {\n                vOut[k] += img->data[ind] * pg->coeff[i];\n                ind++;\n            }\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_GAUSSIAN_HPP */\n\n"
  },
  {
    "path": "include/image_samplers/image_sampler_lanczos.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_LANCZOS_HPP\n#define PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_LANCZOS_HPP\n\n#include \"../image_samplers/image_sampler.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ImageSamplerLanczos class\n */\nclass ImageSamplerLanczos: public ImageSampler\n{\nprotected:\n    float a;\n    int a_i;\n\npublic:\n    /**\n     * @brief ImageSamplerLanczos\n     */\n    ImageSamplerLanczos()\n    {\n        a = 2.0f;\n        a_i = 2;\n    }\n\n    /**\n     * @brief ImageSamplerLanczos\n     * @param sigma\n     * @param direction\n     */\n    ImageSamplerLanczos(float a)\n    {\n        this->a = a;\n        a_i = int(a);\n    }\n\n    /**\n     * @brief SampleImage samples an image in uniform coordiantes.\n     * @param img\n     * @param x\n     * @param y\n     * @param vOut\n     */\n    void SampleImage(Image *img, float x, float y, float *vOut)\n    {\n        float xx, yy, dx, dy;\n\n        //Coordiantes in [0,width-1]x[0,height-1]\n        x *= img->width1f;\n        y *= img->height1f;\n\n        //Coordinates without fractions\n        xx = floorf(x);\n        yy = floorf(y);\n\n        //Interpolation values\n        dx = (x - xx);\n        dy = (y - yy);\n\n        //Integer coordinates\n        int ix = int(xx);\n        int iy = int(yy);\n\n        for(int k = 0; k < img->channels; k++) {\n            vOut[k] = 0.0f;\n        }\n\n        float rx, ry;\n        int ey, ex;\n        for(int j = - a_i + 1; j <= a_i; j++) {\n            ry = Lanczos(dy - float(j), a);\n            ey = CLAMP(iy + j, img->height);\n\n            for(int i = - a_i + 1; i <= a_i; i++) {\n                rx = Lanczos(dx - float(i), a);\n                ex = CLAMP(ix + i, img->width);\n                int ind = (ey * img->width + ex) * img->channels;\n\n                rx *= ry;\n                for(int k = 0; k < img->channels; k++) {\n                    vOut[k] += img->data[ind + k] * rx;\n                }\n            }\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_LANCZOS_HPP */\n\n"
  },
  {
    "path": "include/image_samplers/image_sampler_nearest.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_NEAREST_HPP\n#define PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_NEAREST_HPP\n\n#include \"../image_samplers/image_sampler.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ImageSamplerNearest class\n */\nclass ImageSamplerNearest: public ImageSampler\n{\npublic:\n    /**\n     * @brief ImageSamplerNearest\n     */\n    ImageSamplerNearest() {}\n\n    /**\n     * @brief SampleImage samples an image in uniform coordiantes.\n     * @param img\n     * @param x\n     * @param y\n     * @param vOut\n     */\n    void SampleImage(Image *img, float x, float y, float *vOut)\n    {\n        x = CLAMPi(x, 0.0f, 1.0f);\n        y = CLAMPi(y, 0.0f, 1.0f);\n\n        //Coordiantes in [0,width-1]x[0,height-1]\n        x = x * img->width1f;\n        y = y * img->height1f;\n\n        SampleImageUC(img, x, y, vOut);\n    }\n\n    /**\n     * @brief SampleImageUC samples an image in unnormalized coordinates [0,width-1]x[0,height-1].\n     * @param img\n     * @param x\n     * @param y\n     * @param vOut\n     */\n    void SampleImageUC(Image *img, float x, float y, float *vOut)\n    {\n        //Integer coordinates\n        int ix = CLAMP(int(x), img->width);\n        int iy = CLAMP(int(y), img->height);\n\n        //Bilinear interpolation indicies\n        int ind = (ix * img->xstride + iy * img->ystride);\n\n        for(int i = 0; i < img->channels; i++) {\n            vOut[i] = img->data[ind + i];\n        }\n    }\n\n    /**\n     * @brief SampleImage samples an image in uniform coordiantes.\n     * @param img\n     * @param x\n     * @param y\n     * @param t\n     * @param vOut\n     */\n    void SampleImage(Image *img, float x, float y, float t, float *vOut)\n    {\n        x = CLAMPi(x, 0.0f, 1.0f);\n        y = CLAMPi(y, 0.0f, 1.0f);\n        t = CLAMPi(t, 0.0f, 1.0f);\n\n        //coordiantes in [0,width-1] x [0,height-1] x [0,frames-1]\n        x = x * img->width1f;\n        y = y * img->height1f;\n        t = t * img->frames1f;\n\n        //integer coordinates\n        int ix = int(x);\n        int iy = int(y);\n        int it = int(t);\n\n        //indicies\n        int ind = (ix * img->xstride + iy * img->ystride + it * img->tstride);\n\n        for(int i = 0; i < img->channels; i++) {\n            vOut[i] = img->data[ind + i];\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_NEAREST_HPP */\n\n"
  },
  {
    "path": "include/image_samplers.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IMAGE_SAMPLERS_HPP\n#define PIC_IMAGE_SAMPLERS_HPP\n\n#include \"image_samplers/image_sampler.hpp\"\n#include \"image_samplers/image_sampler_bilinear.hpp\"\n#include \"image_samplers/image_sampler_bsplines.hpp\"\n#include \"image_samplers/image_sampler_bicubic.hpp\"\n#include \"image_samplers/image_sampler_catmull_rom.hpp\"\n#include \"image_samplers/image_sampler_gaussian.hpp\"\n#include \"image_samplers/image_sampler_lanczos.hpp\"\n#include \"image_samplers/image_sampler_nearest.hpp\"\n\n#endif /* PIC_IMAGE_SAMPLERS_HPP */\n\n"
  },
  {
    "path": "include/image_vec.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IMAGE_RAW_VEC_HPP\n#define PIC_IMAGE_RAW_VEC_HPP\n\n#include <vector>\n#include \"image.hpp\"\n\nnamespace pic {\n\n/**\n * @brief ImageVec an std::vector of pic::Image\n */\ntypedef\tstd::vector<Image *> ImageVec;\n\n/**\n * @brief Single creates an std::vector which contains img; this is for filters input.\n * @param img is a pointer to a pic::Image\n * @return It returns an std::vector which contains img.\n */\nPIC_INLINE ImageVec Single(Image *img)\n{\n    ImageVec ret;\n    ret.push_back(img);\n    return ret;\n}\n\n/**\n * @brief Double creates an std::vector which contains img1 and img2; this is for filters input.\n * @param img1 is a pointer to a pic::Image\n * @param img2 is a pointer to a pic::Image\n * @return It returns an std::vector which contains img1 and img2.\n */\nPIC_INLINE ImageVec Double(Image *img1, Image *img2)\n{\n    ImageVec ret;\n    ret.push_back(img1);\n    ret.push_back(img2);\n    return ret;\n}\n\n/**\n * @brief Triple creates an std::vector which contains img1, img2, and img3; this is for filters input.\n * @param img1 is a pointer to a pic::Image\n * @param img2 is a pointer to a pic::Image\n * @param img3 is a pointer to a pic::Image\n * @return It returns an std::vector which contains img1, img2, and img3.\n */\nPIC_INLINE ImageVec Triple(Image *img1, Image *img2, Image *img3)\n{\n    ImageVec ret;\n    ret.push_back(img1);\n    ret.push_back(img2);\n    ret.push_back(img3);\n    return ret;\n}\n\n/**\n * @brief Quad creates an std::vector which contains img1, img2, img3, and img4; this is for filters input.\n * @param img1 is a pointer to a pic::Image\n * @param img2 is a pointer to a pic::Image\n * @param img3 is a pointer to a pic::Image\n * @param img4 is a pointer to a pic::Image\n * @return It returns an std::vector which contains img1, img2, img3, and img4.\n */\nPIC_INLINE ImageVec Quad(Image *img1, Image *img2, Image *img3,\n                            Image *img4)\n{\n    ImageVec ret;\n    ret.push_back(img1);\n    ret.push_back(img2);\n    ret.push_back(img3);\n    ret.push_back(img4);\n    return ret;\n}\n\n/**\n * @brief ImageVecSortByExposureTime\n * @param stack\n */\nPIC_INLINE void ImageVecSortByExposureTime(ImageVec &stack)\n{\n    std::sort(stack.begin(), stack.end(), [](const Image *l, const Image *r)->bool{\n        if (!l || !r) {\n            return false;\n        }\n        return l->exposure < r->exposure;\n    });\n}\n\n\n/**\n * @brief ImageVecGetExposureTimesAsArray\n * @param stack\n */\nPIC_INLINE void ImageVecGetExposureTimesAsArray(ImageVec &stack, std::vector<float> &output, bool bLog)\n{\n    output.clear();\n\n    for(unsigned int i = 0; i < stack.size(); i++) {\n        float tmp = bLog ? logf(stack[i]->exposure) : stack[i]->exposure;\n        output.push_back(tmp);\n    }\n}\n\n/**\n * @brief ImageVecCheckSimilarType\n * @param stack\n * @return\n */\nPIC_INLINE bool ImageVecCheckSimilarType(ImageVec &stack)\n{\n    if(stack.size() < 2) {\n        return false;\n    }\n\n    for (unsigned int i = 1; i < stack.size(); i++) {\n        if (!stack[0]->isSimilarType(stack[i])) {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n/**\n * @brief ImageVecCheck\n * @param vec\n * @param minInputImages\n * @return\n */\nPIC_INLINE bool ImageVecCheck(ImageVec &imgIn, int minInputImages)\n{\n    int n;\n    if(minInputImages < 0) {\n        n = int(imgIn.size());\n    } else {\n        if(int(imgIn.size()) < minInputImages) {\n            return false;\n        }\n\n        n = minInputImages;\n    }\n\n    for(int i = 0; i < n; i ++) {\n        if(imgIn[i] == NULL) {\n            return false;\n        } else {\n            if(!imgIn[i]->isValid()) {\n                return false;\n            }\n        }\n    }\n\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_IMAGE_RAW_VEC_HPP */\n\n"
  },
  {
    "path": "include/io/bmp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_BMP_HPP\n#define PIC_IO_BMP_HPP\n\n#include <stdio.h>\n#include <string>\n\n#ifdef PIC_WIN32\n#include <windows.h>\n#endif\n\n#include \"../base.hpp\"\n\nnamespace pic {\n\n#ifndef PIC_WIN32\n\n/**\n * @brief The BITMAPFILEHEADER struct\n */\nstruct BITMAPFILEHEADER {\n    unsigned short  bfType;\n    unsigned int    bfSize;\n    unsigned short  bfReserved1;\n    unsigned short  bfReserved2;\n    unsigned int    bfOffBits;\n};\n\n/**\n * @brief The BITMAPINFOHEADER struct\n */\nstruct BITMAPINFOHEADER {\n    unsigned int      biSize;\n    int               biWidth;\n    int               biHeight;\n    unsigned short    biPlanes;\n    unsigned short    biBitCount;\n    unsigned int      biCompression;\n    unsigned int      biSizeImage;\n    int               biXPelsPerMeter;\n    int               biYPelsPerMeter;\n    unsigned int      biClrUsed;\n    unsigned int      biClrImportant;\n};\n\n#define BI_RGB              0L\n\n#endif\n\n/**\n * @brief BitmapPadding (SYSTEM: X POS Y POS).\n * @param bpp\n * @param width\n * @return\n */\ninline int BitmapPadding(int bpp, int width)\n{\n    int padding;\n\n    if(((width * bpp / 8) % 4) != 0) {\n        padding = 4 - ((width * bpp / 8) % 4);\n    } else {\n        padding = 0;\n    }\n\n    return padding;\n}\n\n/**\n * @brief ReadBMP reads an image as .bmp file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE unsigned char *ReadBMP(std::string nameFile, unsigned char *data,\n                                  int &width, int &height, int &channels)\n{\n    FILE *file = fopen(nameFile.c_str(), \"rb\");\n\n    if(file == NULL) {\n        return data;\n    }\n\n    BITMAPFILEHEADER    bmpfh;\n    BITMAPINFOHEADER    bmpih;\n\n    //reading the bitmap file header:\n    //this structure is 14 bytes ==> no alignment\n    //so issues for some compilers\n    fread(&bmpfh.bfType, sizeof(unsigned short), 1, file);\n    fread(&bmpfh.bfSize, sizeof(unsigned int), 1, file);\n    fread(&bmpfh.bfReserved1, sizeof(unsigned short), 1, file);\n    fread(&bmpfh.bfReserved2, sizeof(unsigned short), 1, file);\n    fread(&bmpfh.bfOffBits, sizeof(unsigned int), 1, file);\n\n    fread(&bmpih, sizeof(BITMAPINFOHEADER), 1, file);\n\n    //24-bit images only!\n    if(bmpih.biCompression != BI_RGB) {\n        fclose(file);\n        return data;\n    }\n\n    int bpp = bmpih.biBitCount;\n\n    channels = bpp / 8;\n\n    if(!(channels == 3 || channels == 1)) {\n        fclose(file);\n        return data;\n    }\n\n    fseek(file, bmpfh.bfOffBits, SEEK_SET);\n\n    width  = bmpih.biWidth;\n    height = bmpih.biHeight;\n\n    if(data == NULL) {\n        data = new unsigned char[width * height * channels];\n    }\n\n    //compute padding\n    int padding = BitmapPadding(bpp, width);\n\n    unsigned char *pads = NULL;\n\n    if(padding > 0) {\n        pads = new unsigned char[padding];\n    }\n\n    unsigned char tmp[3];\n\n    for(int j = (height - 1); j > -1; j--) {\n        int cj = j * width;\n\n        if(channels == 3) {\n            for(int i = 0; i < width; i++) {\n                int c = (cj + i) * 3;\n                fread(tmp, sizeof(unsigned char), 3, file);\n                //from BGR to RGB\n                data[c + 2] = tmp[0];\n                data[c + 1] = tmp[1];\n                data[c    ] = tmp[2];\n            }\n        }\n\n        if(channels == 1) {\n            fread(&data[cj], sizeof(unsigned char), width, file);\n        }\n\n        if(padding > 0) {\n            fread(pads, sizeof(unsigned char), padding, file);\n        }\n    }\n\n    fclose(file);\n    return data;\n}\n\n/**\n * @brief WriteBMP writes an image as a .bmp file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE bool WriteBMP(std::string nameFile, const unsigned char *data,\n                         int width, int height, int channels)\n{\n    if(data == NULL) {\n        return false;\n    }\n\n    //\t4*(bbp/32*width)\n    BITMAPFILEHEADER    bmpfh;\n    BITMAPINFOHEADER    bmpih;\n\n    //preparing the file header info\n    bmpfh.bfType = 19778;\n    //to avoid issues with 4-byte alignment\n    bmpfh.bfOffBits = 54; //sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER);\n    bmpfh.bfReserved1 = 0L;\n    bmpfh.bfReserved2 = 0L;\n    bmpfh.bfSize = 1078;\n\n    //preparing the bmp header info\n    bmpih.biBitCount = 24;\n    bmpih.biCompression = 0;\n    bmpih.biHeight = height;\n    bmpih.biWidth = width;\n    bmpih.biClrUsed = 0;\n    bmpih.biClrImportant = 0;\n    bmpih.biXPelsPerMeter = 0;\n    bmpih.biYPelsPerMeter = 0;\n    bmpih.biSize = sizeof(bmpih);\n    bmpih.biPlanes = 1;\n    bmpih.biSizeImage = 0;\n\n    FILE *file = fopen(nameFile.c_str(), \"wb\");\n\n    if(file == NULL) {\n        return false;\n    }\n\n    //writing the bitmap file header:\n    //this structure is 14 bytes ==> no alignment\n    //so issues for some compilers\n    fwrite(&bmpfh.bfType, sizeof(unsigned short), 1, file);\n    fwrite(&bmpfh.bfSize, sizeof(unsigned int), 1, file);\n    fwrite(&bmpfh.bfReserved1, sizeof(unsigned short), 1, file);\n    fwrite(&bmpfh.bfReserved2, sizeof(unsigned short), 1, file);\n    fwrite(&bmpfh.bfOffBits, sizeof(unsigned int), 1, file);\n\n    //writing the bitmap info header:\n    //this is already 4-byte aligned so no issues\n    //depending on the compiler\n    fwrite(&bmpih, sizeof(BITMAPINFOHEADER), 1, file);\n\n    //padding?\n    int bpp = 24;\n    int padding = BitmapPadding(bpp, width);\n\n    unsigned char *pads = NULL;\n\n    if(padding > 0) {\n        pads = new unsigned char[padding];\n    }\n\n    unsigned char tmp[3];\n\n    int shiftG = 1;\n    int shiftB = 2;\n\n    if(channels==1) {\n        shiftG = 0;\n        shiftB = 0;\n    }\n\n    for(int j = (height - 1); j > -1; j--) {\n        int cj = j * width;\n\n        for(int i = 0; i < width; i++) {\n            int c = (cj + i) * channels;\n            //From RGB to BGR\n            tmp[0] = data[c + shiftB];\n            tmp[1] = data[c + shiftG];\n            tmp[2] = data[c    ];\n            fwrite(tmp, sizeof(unsigned char), 3, file);\n        }\n\n        if(padding > 0) {\n            fwrite(pads, sizeof(unsigned char), padding, file);\n        }\n    }\n\n    fclose(file);\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_IO_BMP_HPP */\n\n"
  },
  {
    "path": "include/io/exif.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_EXIF\n#define PIC_IO_EXIF\n\n#include <stdio.h>\n#include <string>\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/**\n * @brief twoByteToValue\n * @param data\n * @param bMotorola\n * @return\n */\nPIC_INLINE unsigned int twoByteToValue(unsigned char data[2], bool bMotorola)\n{\n    if(bMotorola) {\n        return  (data[0] << 8) + (data[1]);\n    } else {\n        return  (data[1] << 8) + (data[0]);\n    }\n}\n\n/**\n * @brief fourByteToValue\n * @param data\n * @param bMotorola\n * @return\n */\nPIC_INLINE unsigned int fourByteToValue(unsigned char data[4], bool bMotorola)\n{\n    if(bMotorola) {\n        return (data[0] << 24) + (data[1] << 16) +\n               (data[2] << 8) + (data[3]);\n    } else {\n        return (data[3] << 24) + (data[2] << 16) +\n               (data[1] << 8) + (data[0]);\n    }\n}\n\n/**\n * @brief checkTag\n * @param tag\n * @param tag_r\n * @param bMotorola\n * @return\n */\nPIC_INLINE bool checkTag(unsigned char tag[2], unsigned short tag_r, bool bMotorola)\n{\n    unsigned char tag_ref[2];\n    tag_ref[0] = (tag_r >> 8) & 0x00ff;\n    tag_ref[1] = tag_r & 0x00ff;\n\n    bool bRet = false;\n    if(bMotorola) {\n        bRet = (tag[0] == tag_ref[0]) && (tag[1] == tag_ref[1]);\n    } else {\n        bRet = (tag[1] == tag_ref[0]) && (tag[0] == tag_ref[1]);\n    }\n\n    return bRet;\n}\n\n/**\n * @brief getTagID\n * @param tag\n * @param bMotorola\n * @return\n */\nPIC_INLINE int getTagID(unsigned char tag[2], bool bMotorola)\n{\n    if(checkTag(tag, 0x829a, bMotorola)) {\n        return 0;\n    }\n\n    if(checkTag(tag, 0x829d, bMotorola)) {\n        return 1;\n    }\n\n    if(checkTag(tag, 0x8827, bMotorola)) {\n        return 2;\n    }\n\n    if(checkTag(tag, 0x9202, bMotorola)) {\n        return 3;\n    }\n\n    if(checkTag(tag, 0x920a, bMotorola)) {\n        return 4;\n    }\n\n    return -1;\n}\n\n/**\n * @brief getBytesForComponents\n * @param value\n * @return\n */\nPIC_INLINE int getBytesForComponents(int value)\n{\n    switch(value)\n    {\n    case 1: {\n        return 1;\n    } break;\n\n    case 2: {\n        return 1;\n    } break;\n\n    case 3: {\n        return 2;\n    } break;\n\n    case 4: {\n        return 4;\n    } break;\n\n    case 5: {\n        return 8;\n    } break;\n\n    case 6: {\n        return 1;\n    } break;\n\n    case 7: {\n        return 1;\n    } break;\n\n    case 8: {\n        return 2;\n    } break;\n\n    case 9: {\n        return 4;\n    } break;\n\n    case 10: {\n        return 8;\n    } break;\n\n    case 11: {\n        return 4;\n    } break;\n\n    case 12: {\n        return 8;\n    } break;\n\n    default: {\n        return -1;\n    }\n\n    }\n}\n\n/**\n * @brief readString\n * @param file\n * @param length\n * @return\n */\nPIC_INLINE std::string readString(FILE *file, int length)\n{\n    char *tmp = new char[length];\n    fread(tmp, 1, length, file);\n    std::string str(tmp);\n\n    delete[] tmp;\n\n    return str;\n}\n\n/**\n * @brief readStringFromUChar\n * @param data\n * @return\n */\nPIC_INLINE std::string readStringFromUChar(unsigned char *data, int length)\n{\n    std::string str;\n\n    for(int i = 0; i < length; i++) {\n        str += (char) data[i];\n    }\n\n    return str;\n}\n\n/**\n * @brief readUnsignedRational\n * @param file\n * @param bMotorola\n * @return\n */\nPIC_INLINE float readUnsignedRational(FILE *file, bool bMotorola)\n{\n    unsigned char val0[4];\n    fread(val0, 1, 4, file);\n\n    unsigned char val1[4];\n    fread(val1, 1, 4, file);\n\n    auto num = fourByteToValue(val0, bMotorola);\n    auto denum = fourByteToValue(val1, bMotorola);\n\n    return float(num) / float(denum);\n}\n\nstruct EXIFInfo\n{\n    float exposureTime;\n    float fNumber;\n    float aperture;\n    float iso;\n    float focal_length;\n\n    std::string camera_maker;\n};\n\n/**\n * @brief readEXIF\n * @param name\n * @param info\n * @return\n */\nPIC_INLINE bool readEXIF(std::string name, EXIFInfo &info)\n{\n    FILE *file = fopen(name.c_str(), \"rb\");\n\n    unsigned char buf[2];\n    fread(buf, 1, 2, file);\n\n    if(!checkTag(buf, 0xffd8, true)) {\n        return false;\n    }\n\n    unsigned char buf2[2];\n    int length = 0;\n\n    bool bFound = false;\n    while (!feof(file)) {\n        size_t t0 = fread(buf2, 1, 2, file);\n\n        //printf(\"BUF: %x %x\\n\", buf2[0], buf2[1]);\n\n        unsigned char len[2];\n        size_t t1 = fread(&len, 1, 2, file);\n\n        if ((t0 == 0) || (t1 == 0)) {\n            return false;\n        }\n\n        //printf(\"LEN: %x %x\\n\", len[0], len[1]);\n        length =  (len[0] << 8) + (len[1]);\n\n        if(checkTag(buf2, 0xffe1, true)) {\n            bFound = true;\n            break;\n        }\n\n        fseek(file, length - 2, SEEK_CUR);\n    }\n\n    if(!bFound) {\n        fclose(file);\n        return false;\n    }\n\n    //EXIF header\n\n    unsigned char buf6[6];\n    fread(buf6, 1, 6, file);\n\n    if(buf6[0] != 0x45 || buf6[1] != 0x78 ||\n            buf6[2] != 0x69 || buf6[3] != 0x66 ||\n            buf6[4] != 0x00 || buf6[5] != 0x00) {\n        fclose(file);\n        return false;\n    }\n\n    //TIFF header\n    fpos_t pos;\n    fgetpos(file, &pos);\n\n    //is it Motorala mode?\n    fread(buf2, 1, 2, file);\n    bool bMotorola = (buf2[0] == 0x4d) && (buf2[1] == 0x4d);\n\n    fread(buf2, 1, 2, file);\n    bool bCheck = false;\n\n    if(!checkTag(buf2, 0x002a, bMotorola)) {\n        fclose(file);\n        return false;\n    }\n\n    unsigned char buf4[4];\n    fread(buf4, 1, 4, file); //this is the offset\n\n    if(bMotorola) {\n        bCheck = (buf4[0] == 0x00) && (buf4[1] == 0x00) &&\n                 (buf4[2] == 0x00) && (buf4[3] == 0x08);\n    } else {\n        bCheck = (buf4[0] == 0x08) && (buf4[1] == 0x00) &&\n                 (buf4[2] == 0x00) && (buf4[3] == 0x00);\n    }\n\n    if(!bCheck) {\n        fclose(file);\n        return false;\n    }\n\n    //IFD0: Image file directory\n    fread(buf2, 1, 2, file);\n\n    int nIFD = twoByteToValue(buf2, bMotorola);\n\n    //printf(\"nIFD: %d\\n\", nIFD);\n\n    unsigned int offset = 0;\n    for(int i = 0; i < nIFD; i++) {\n        unsigned char tag[2];\n        fread(tag, 1, 2, file); //TAG\n\n        unsigned char data_format[2];\n        fread(data_format, 1, 2, file); //dataformat\n\n        unsigned char num_components[4];\n        fread(num_components, 1, 4, file); //number of components\n\n        unsigned char data[4];\n        fread(data, 1, 4, file); //data or offset to data\n\n        //maker\n        if(checkTag(tag, 0x010f, bMotorola)) {\n\n            int df = twoByteToValue(data_format, bMotorola);\n            int nc = fourByteToValue(num_components, bMotorola);\n\n            int total_data_byte = getBytesForComponents(df) * nc;\n\n            if(total_data_byte > 4) {\n                int offset = fourByteToValue(data, bMotorola);\n\n                fpos_t tmp_pos;\n                fgetpos(file, &tmp_pos);\n                fseek(file, offset, SEEK_CUR);\n                info.camera_maker = readString(file, nc);\n                fsetpos(file, &tmp_pos);\n\n            } else {\n                info.camera_maker = readStringFromUChar(data, nc);\n            }\n        }\n\n        if(checkTag(tag, 0x8769, bMotorola)) {\n            offset = fourByteToValue(data, bMotorola);\n        }\n    }\n\n    unsigned char next_IFD[4];\n    fread(next_IFD, 1, 4, file);\n    int offset_next_IFD = fourByteToValue(next_IFD, bMotorola);\n    //printf(\"OFFSET: %d\\n\", offset_next_IFD);\n\n    if(offset > 0) {\n        fsetpos(file, &pos);\n        fseek(file, offset, SEEK_CUR);\n        //NOTE: this works but gives warnings --> fseek(file, pos + offset, SEEK_SET);\n    }\n\n    //\n    // IFD 1\n    //\n\n    fread(buf2, 1, 2, file);\n\n    nIFD = twoByteToValue(buf2, bMotorola);\n\n    for(int i = 0; i < nIFD; i++) {\n        unsigned char tag[2];\n\n        fread(tag, 1, 2, file); //TAG\n\n        unsigned char data_format[2];\n        fread(data_format, 1, 2, file); //dataformat\n\n        unsigned char num_components[4];\n        fread(num_components, 1, 4, file); //number of components\n\n        unsigned char data[4];\n        fread(data, 1, 4, file); //data or offset to data\n\n        int df = twoByteToValue(data_format, bMotorola);\n        int nc = fourByteToValue(num_components, bMotorola);\n        int total_data_byte = getBytesForComponents(df) * nc;\n\n        int id = getTagID(tag, bMotorola);\n\n        float data_value = 0;\n        if(total_data_byte > 4) {\n            int offset = fourByteToValue(data, bMotorola);\n\n            fpos_t tmp_pos;\n            fgetpos(file, &tmp_pos);\n\n            fsetpos(file, &pos);\n            fseek(file, offset, SEEK_CUR);\n            //fseek(file, pos + offset, SEEK_SET);\n\n            switch(df) {\n            case 5: {\n                data_value = readUnsignedRational(file, bMotorola);\n            } break;\n            }\n            //unsigned rational\n\n            fsetpos(file, &tmp_pos);\n            //fseek(file, tmp_pos, SEEK_SET);\n        } else {\n            switch(df) {\n            case 3: {\n                data_value = float(twoByteToValue(data, bMotorola));\n            } break;\n            }\n        }\n\n        switch(id) {\n        case 0:\n        {\n            info.exposureTime = data_value;\n        } break;\n\n        case 1:\n        {\n            info.fNumber = data_value;\n\n        } break;\n\n        case 2:\n        {\n            info.iso = data_value;\n\n        } break;\n\n        case 3:\n        {\n            info.aperture = data_value;\n\n        } break;\n\n        case 4:\n        {\n            info.focal_length = data_value;\n        } break;\n\n        default:\n        {\n\n        } break;\n\n        }\n    }\n\n#ifdef PIC_DEBUG\n    printf(\"%f %f %f\\n\", info.iso, info.exposureTime, info.fNumber);\n#endif\n\n    fclose(file);\n\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_IO_VOL_HPP */\n\n"
  },
  {
    "path": "include/io/exr.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_EXR_HPP\n#define PIC_IO_EXR_HPP\n\n#include \"../base.hpp\"\n\n#ifdef PIC_ENABLE_OPEN_EXR\n\n//include for OpenEXR 1.xx\n\n#include <ImfRgbaFile.h>\n#include <ImfStringAttribute.h>\n#include <ImfMatrixAttribute.h>\n#include <ImfArray.h>\n\n#ifdef PIC_WIN32\n    #pragma comment( lib, \"Iex_dll\" )\n    #pragma comment( lib, \"Half_dll\" )\n    #pragma comment( lib, \"IlmImf_dll\" )\n    #pragma comment( lib, \"IlmThread_dll\" )\n    #pragma comment( lib, \"Imath_dll\" )\n    #pragma comment( lib, \"zlib\" )\n#endif\n\n//SYSTEM: X POS Y NEG\nnamespace pic {\n\n/**\n * @brief ReadEXR reads .exr data from file\n * @param nameFile\n * @param width\n * @param height\n * @param channels\n * @param pixelBuffer\n * @return\n */\nPIC_INLINE Imf::Rgba *ReadEXR(std::string nameFile, int &width, int &height,\n                              int &channels, Imf::Rgba *pixelBuffer = NULL)\n{\n    try {\n        Imf::RgbaInputFile in(nameFile.c_str());\n        Imath::Box2i win = in.dataWindow();\n\n        Imath::V2i dim(win.max.x - win.min.x + 1, win.max.y - win.min.y + 1);\n\n        //printf(\"%d %d %d %d\\n\",win.max.x,win.min.x,win.max.y,win.min.y);\n\n        if(pixelBuffer == NULL) {\n            pixelBuffer = new Imf::Rgba[dim.x * dim.y];\n        }\n\n        int dx = win.min.x;\n        int dy = win.min.y;\n\n        in.setFrameBuffer(pixelBuffer - dx - dy * dim.x, 1, dim.x);\n        in.readPixels(win.min.y, win.max.y);\n\n        width  = dim.x;\n        height = dim.y;\n        channels = 3;\n\n        return pixelBuffer;\n\n    } catch(Iex::BaseExc &e) {\n        std::cerr << e.what() << std::endl;\n        return NULL;\n    }  \n}\n\n/**\n * @brief ReadEXR reads .exr data from file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @param pixelBuffer\n * @return\n */\nPIC_INLINE float *ReadEXR(std::string nameFile, float *data, int &width,\n                          int &height, int &channels, Imf::Rgba *pixelBuffer = NULL)\n{\n    try {\n        Imf::RgbaInputFile in(nameFile.c_str());\n        Imath::Box2i win = in.dataWindow();\n\n        Imath::V2i dim(win.max.x - win.min.x + 1, win.max.y - win.min.y + 1);\n\n        //printf(\"%d %d %d %d\\n\",win.max.x,win.min.x,win.max.y,win.min.y);\n\n        bool bPixelBufferNULL = false;\n\n        if(pixelBuffer == NULL) {\n            pixelBuffer = new Imf::Rgba[dim.x * dim.y];\n            bPixelBufferNULL = true;\n        }\n\n        int dx = win.min.x;\n        int dy = win.min.y;\n\n        in.setFrameBuffer(pixelBuffer - dx - dy * dim.x, 1, dim.x);\n        in.readPixels(win.min.y, win.max.y);\n\n        //Allocate into memory\n        if(data == NULL) {\n            data = new float[dim.x * dim.y * 3];\n        }\n\n        width  = dim.x;\n        height = dim.y;\n        channels = 3;\n\n        int tot = width * height * channels;\n\n        for(int i = 0; i < tot; i += channels) { //swizzle\n            int j = i / 3;\n            data[i    ] = pixelBuffer[j].r;\n            data[i + 1] = pixelBuffer[j].g;\n            data[i + 2] = pixelBuffer[j].b;\n        }\n\n        if(bPixelBufferNULL) {\n            delete[] pixelBuffer;\n        }\n\n        return data;\n    } catch(Iex::BaseExc &e) {\n        std::cerr << e.what() << std::endl;\n        return NULL;\n    }\n}\n\n/**\n * @brief WriteEXR writes an .exr file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @param pixelBuffer\n * @return\n */\nPIC_INLINE bool WriteEXR(std::string nameFile, const float *data, int width,\n                         int height, int channels = 3, Imf::Rgba *pixelBuffer = NULL)\n{\n    Imath::Box2i win;\n    win.max.x = width - 1;\n    win.max.y = height - 1;\n    win.min.x = 0;\n    win.min.y = 0;\n    Imf::RgbaOutputFile outC(nameFile.c_str(), win, win, Imf::WRITE_RGBA);\n\n    //Copy data\n    int tot = width * height;\n    bool bPixelBufferNULL = false;\n\n    if(pixelBuffer == NULL) {\n        pixelBuffer = new Imf::Rgba[tot];\n        bPixelBufferNULL = true;\n    }\n\n    int j = 0;\n\n    for(int i = 0; i < tot; i++) {\n        pixelBuffer[i].r = data[j];\n        j++;\n        pixelBuffer[i].g = data[j];\n        j++;\n        pixelBuffer[i].b = data[j];\n        j++;\n        pixelBuffer[i].a = 1.0f;\n    }\n\n    outC.setFrameBuffer(pixelBuffer, 1, width);\n    outC.writePixels(height);\n\n    if(bPixelBufferNULL) {\n        delete[] pixelBuffer;\n    }\n\n    return true;\n}\n\n} // end namespace pic\n#endif //PIC_ENABLE_OPEN_EXR\n\n#endif /* PIC_IO_EXR_HPP */\n\n"
  },
  {
    "path": "include/io/exr_tiny.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_EXR_TINY_HPP\n#define PIC_IO_EXR_TINY_HPP\n\n#include \"../base.hpp\"\n\n#ifndef PIC_DISABLE_TINY_EXR\n\n#define TINYEXR_IMPLEMENTATION\n\n#include \"../util/std_util.hpp\"\n\n#include \"../externals/tinyexr/tinyexr.h\"\n\nnamespace pic {\n\nPIC_INLINE float *ReadEXR(std::string nameFile, float *data, int &width, int &height, int &channels)\n{\n    EXRImage image;\n    InitEXRImage(&image);\n\n    const char* err;\n    int ret = ParseMultiChannelEXRHeaderFromFile(&image, nameFile.c_str(), &err);\n    if (ret != 0) {\n        #ifdef PIC_DEBUG\n            printf(\"Parse EXR error: %s\\n\", err);\n        #endif\n\n        return NULL;\n    }\n\n    width = image.width;\n    height = image.height;\n    channels = image.num_channels;\n\n    //Allocate into memory\n    if(data == NULL) {\n        data = new float[width * height * channels];\n    }\n\n    for (int i = 0; i < image.num_channels; i++) {\n        if (image.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) {\n            image.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT;\n        }\n    }\n\n    ret = LoadMultiChannelEXRFromFile(&image, nameFile.c_str(), &err);\n    if (ret != 0) {\n        #ifdef PIC_DEBUG\n            printf(\"Load EXR error: %s\\n\", err);\n        #endif\n        return data;\n    }\n\n    float **images = (float**) image.images;\n\n    int nPixels = width * height;\n    for (int i = 0; i < nPixels; i++){\n        int index = i * channels;\n\n        data[index    ] = images[2][i];\n        data[index + 1] = images[1][i];\n        data[index + 2] = images[0][i];\n    }\n\n    FreeEXRImage(&image);\n    return data;\n}\n\n/**\n * @brief WriteEXR\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE bool WriteEXR(std::string nameFile, float *data, int width,\n                         int height, int channels = 3)\n{\n    EXRImage image;\n    InitEXRImage(&image);\n\n     image.num_channels = channels;\n\n     const char* channel_names[] = {\"B\", \"G\", \"R\"}; // \"B\", \"G\", \"R\", \"A\" for RGBA image\n\n     std::vector< float* > images;\n     for(int i = 0; i < channels; i++) {\n         float *tmp = new float[width * height];\n         images.push_back(tmp);\n     }\n\n     int nPixels = width * height;\n     for (int i = 0; i < nPixels; i++){\n         int index = i * channels;\n\n         for(int j = 0; j < channels; j++) {\n             images[j][i] = data[index + j];\n         }\n     }\n\n     float *image_ptr[3];\n     image_ptr[0] = &(images[2][0]); // B\n     image_ptr[1] = &(images[1][0]); // G\n     image_ptr[2] = &(images[0][0]); // R\n\n     image.channel_names = channel_names;\n     image.images = (unsigned char**)image_ptr;\n     image.width = width;\n     image.height = height;\n\n     image.pixel_types = (int *)malloc(sizeof(int) * image.num_channels);\n     image.requested_pixel_types = (int *)malloc(sizeof(int) * image.num_channels);\n     for (int i = 0; i < image.num_channels; i++) {\n       image.pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; // pixel type of input image\n       image.requested_pixel_types[i] = TINYEXR_PIXELTYPE_HALF; // pixel type of output image to be stored in .EXR\n     }\n\n     const char* err;\n     int ret = SaveMultiChannelEXRToFile(&image, nameFile.c_str(), &err);\n     if (ret != 0) {\n         printf(\"Save EXR err: %s\\n\", err);\n         return false;\n     }\n\n     for(int i = 0; i < channels; i++) {\n         delete_vec_s(images[i]);\n     }\n     images.clear();\n\n     delete_vec_s(image.pixel_types);\n     delete_vec_s(image.requested_pixel_types);\n\n     return true;\n}\n\n}\n\n#endif //PIC_DISABLE_TINY_EXR\n\n#endif /* PIC_IO_EXR_TINY_HPP */\n\n"
  },
  {
    "path": "include/io/hdr.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_HDR_HPP\n#define PIC_IO_HDR_HPP\n\n#include <stdio.h>\n#include <string.h>\n\n#include \"../colors/rgbe.hpp\"\n#include \"../base.hpp\"\n//SYSTEM: X NEG Y POS\n\nnamespace pic {\n\n/**\n * @brief ReadHDR reads a .hdr/.pic file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @return\n */\nPIC_INLINE float *ReadHDR(std::string nameFile, float *data, int &width,\n                          int &height)\n{\n    FILE *file = fopen(nameFile.c_str(), \"rb\");\n\n    if(file == NULL) {\n        return NULL;\n    }\n\n    char tmp[512];\n\n    //Is it a Radiance file?\n    fscanf(file, \"%s\\n\", tmp);\n\n    if(strcmp(tmp, \"#?RADIANCE\") != 0) {\n        return NULL;\n    }\n\n    while(true) { //Reading Radiance Header\n        std::string line = \"\";\n\n        while(true) { //read property line\n            char *tmp2 = fgets(tmp, 512, file);\n\n            if(tmp2 == NULL) {\n                return NULL;\n            }\n\n            line += tmp2;\n            size_t pos = line.find(\"\\n\");\n\n            if(pos != std::string::npos) {\n                break;\n            }\n        }\n\n        if(line.compare(\"\\n\") == 0) {\n            break;\n        }\n\n        //Properties:\n        if(line.find(\"FORMAT\") != std::string::npos) { //Format\n            if(line.find(\"32-bit_rle_rgbe\") == std::string::npos) {\n                return NULL;\n            }\n        }\n\n        if(line.find(\"EXPOSURE=\") != std::string::npos) { //Exposure\n            //TODO: ...\n        }\n    }\n\n    //width and height\n    fscanf(file, \"-Y %d +X %d\", &height, &width);\n    fgetc(file);\n\n    if(data == NULL) {\n        data = new float[width * height * 3];\n    }\n\n    //File size\n    long int s_cur = ftell(file);\n    fseek(file, 0 , SEEK_END);\n    long int s_end = ftell(file);\n    fseek(file, s_cur, SEEK_SET);\n    int total = s_end - s_cur;\n\n#ifdef PIC_DEBUG\n    printf(\"%d %d\\n\", total, width * height * 4);\n#endif\n\n    //Compressed?\n    if(total == (width * height * 4)) { //uncompressed\n        unsigned char colRGBE[4];\n\n        int c = 0;\n\n        for(int i = 0; i < width; i++) {\n            for(int j = 0; j < height; j++) {\n                fread(colRGBE, 1, 4, file);\n                fromRGBEToFloat(colRGBE, &data[c]);\n                c += 3;\n            }\n        }\n    } else { //RLE compressed\n        unsigned char *buffer = new unsigned char[total];\n        fread(buffer, sizeof(unsigned char)*total, 1, file);\n\n        int line_width3 = width * 3;\n        int line_width4 = width * 4;\n\n        unsigned char *buffer_line_start;\n        unsigned char *buffer_line = new unsigned char[line_width4];\n        int c = 4;\n        int c_buffer_line = 0;\n\n        //for each line\n        for(int i = 0; i < height; i++) {\n            buffer_line_start = &buffer[c - 4];\n\n            int width_check  = buffer_line_start[2];\n            int width_check2 = buffer_line_start[3];\n\n            bool b1 = buffer_line_start[0] != 2;\n            bool b2 = buffer_line_start[1] != 2;\n            bool b3 = width_check  != (width >> 8); \n            bool b4 = width_check2 != (width & 0xFF);\n\n            if(b1 || b2 || b3 || b4) {\n                #ifdef PIC_DEBUG\n                    printf(\"ReadHDR ERROR: the file is not a RLE encoded .hdr file.\\n\");\n                #endif\n\n                fclose(file);\n\n                return NULL;\n            }\n\n            for(int j = 0; j < 4; j++) {\n                int k = 0;\n\n                //decompression of a single channel line\n                while(k < width) {\n                    int num = buffer[c];\n\n                    if(num > 128) {\n                        num -= 128;\n\n                        for(int l = k; l < (k + num); l++) {\n                            buffer_line[l * 4 + j] = buffer[c + 1];\n                        }\n\n                        c += 2;\n                        k += num;\n                    } else {\n                        for(int l = 0; l < num; l++) {\n                            buffer_line[(l + k) * 4 + j] = buffer[c + 1 + l];\n                        }\n\n                        c += num + 1;\n                        k += num;\n                    }\n                }\n            }\n\n            //From RGBE to Float\n            for(int j = 0; j < width; j++) {\n                fromRGBEToFloat(&buffer_line[j * 4], &data[c_buffer_line + j * 3]);\n            }\n\n            c += 4;\n            c_buffer_line += line_width3;\n        }\n\n        delete[] buffer_line;\n        delete[] buffer;\n    }\n\n    fclose(file);\n    return data;\n}\n\n/**\n * @brief WriteLineHDR writes a scanline of an image using RLE and RGBE encoding.\n * @param file\n * @param buffer_line\n * @param width\n */\nPIC_INLINE void WriteLineHDR(FILE *file, unsigned char *buffer_line, int width)\n{\n    int cur_pointer = 0;\n\n    while(cur_pointer < width) {\n        int run_length = 0;\n        int run_length_old = 0;\n\n        int run_start = cur_pointer;\n\n        //we need to find a long run; length>3\n        while((run_length < 4 ) && (run_start < width)) {\n            run_start += run_length;\n            run_length_old = run_length;\n\n            int start = (run_start + 1);\n            int end = MIN(run_start + 127, width); \n            unsigned char tmp = buffer_line[run_start];\n            run_length = 1;\n\n            //finding a run\n            for(int i=start; i<end; i++) {\n                if(tmp == buffer_line[i]) {\n                    run_length++;\n                } else {\n                    break;\n                }\n            }\n        }\n\n        //do we have a short run <4 before a long one?\n        if((run_length_old > 1) && (run_length_old == (run_start - cur_pointer))){\n            unsigned char length_to_write = run_length_old + 128;\n            unsigned char value_to_write = buffer_line[cur_pointer];\n            fwrite(&length_to_write, sizeof(unsigned char), 1, file);\n            fwrite(&value_to_write, sizeof(unsigned char), 1, file);\n\n            cur_pointer = run_start;\n        }\n\n        //writing non-runs\n        while(cur_pointer < run_start) {\n            int non_run_length = run_start - cur_pointer;\n\n            if(non_run_length > 128) {\n                unsigned char length_to_write = 128;\n                fwrite(&length_to_write, sizeof(unsigned char), 1, file);\n                fwrite(&buffer_line[cur_pointer], sizeof(unsigned char)*length_to_write, 1, file);\n\n                cur_pointer += length_to_write;\n            } else {\n                fwrite(&non_run_length, sizeof(unsigned char), 1, file);\n                fwrite(&buffer_line[cur_pointer], sizeof(unsigned char)*non_run_length, 1, file);\n\n                cur_pointer += non_run_length;\n            }\n        }\n\n        //writing the found long run\n        if(run_length > 3) {\n            unsigned char length_to_write = run_length + 128;\n            unsigned char value_to_write = buffer_line[run_start];\n            fwrite(&length_to_write, sizeof(unsigned char), 1, file);\n            fwrite(&value_to_write, sizeof(unsigned char), 1, file);\n\n            cur_pointer += run_length;\n        }\n\n    }\n}\n\n/**\n * @brief WriteHDR  writes a .hdr/.pic file\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @param appliedExposure\n * @param bRLE\n * @return\n */\nPIC_INLINE bool WriteHDR(std::string nameFile, float *data, int width,\n                         int height, int channels, float appliedExposure = 1.0f, bool bRLE = true)\n{\n    FILE *file;\n\n    if(data==NULL) {\n        return false;\n    }\n    \n    file = fopen(nameFile.c_str(), \"wb\");\n\n    if( file == NULL) {\n        return false;\n    }\n\n    if((channels == 2) || (channels == 0)) {\n        return false;\n    }\n\n    //writing the header...\n    fprintf(file, \"#?RADIANCE\\n\");\n    fprintf(file, \"#Spiced by Piccante\\n\");\n    fprintf(file, \"FORMAT=32-bit_rle_rgbe\\n\");\n    fprintf(file, \"EXPOSURE= %f\\n\\n\", appliedExposure);\n    fprintf(file, \"-Y %d +X %d\\n\", height, width);\n\n    //RLE encoding is not allowed in some cases\n    if(((width < 8) || (width > 32767)) && bRLE) {\n        bRLE = false;\n    }\n\n    if(bRLE) {\n        //buffers\n        unsigned char *buffer_line = new unsigned char[width * 4];\n        unsigned char buffer_rgbe[4];\n        unsigned char buffer_line_start[4];\n\n        //new line start \"header\"\n        buffer_line_start[0] = 2;\n        buffer_line_start[1] = 2;\n        buffer_line_start[2] = width >> 8;\n        buffer_line_start[3] = width & 0xFF;\n\n        int width2 = width * 2;\n        int width3 = width * 3;\n\n        for(int i=0; i<height; i++) {\n            int ind = i * width;\n\n            //Converting the line data into the RGBE format\n            for(int j = 0; j < width; j++) {\n                int ind2 = (ind + j) * channels;\n\n                if(channels == 1) {\n                    fromSingleFloatToRGBE(&data[ind2], buffer_rgbe);\n                } else {\n                    fromFloatToRGBE(&data[ind2], buffer_rgbe);\n                }\n\n                buffer_line[         j] = buffer_rgbe[0];\n                buffer_line[width  + j] = buffer_rgbe[1];\n                buffer_line[width2 + j] = buffer_rgbe[2];\n                buffer_line[width3 + j] = buffer_rgbe[3];\n            }\n\n            //Here a new line start\n            fwrite(buffer_line_start, sizeof(unsigned char)*4, 1, file);\n\n            //RLE encoding for each line\n            for(int j=0; j<4; j++) {\n                WriteLineHDR(file, &buffer_line[j * width], width);\n            }\n        }\n\n    } else {\n        unsigned char colRGBE[4];\n        for(int j = 0; j < height; j++) {\n            int ind = j * width;\n\n            for(int i = 0; i < width; i++) {\n                int c = (ind + i);\n\n                if(channels == 3) {\n                    c *= 3;\n                    fromFloatToRGBE(&data[c], colRGBE);\n                } else {\n                    fromSingleFloatToRGBE(&data[c], colRGBE);\n                }\n\n                fwrite(colRGBE, 1, 4 * sizeof(unsigned char), file);\n            }\n        }\n    }\n\n    fclose(file);\n    return true;\n}\n\n/**\n * @brief WriteHDRBlock writes a .hdr file.\n * @param nameFile\n * @param buffer_line\n * @param width\n * @param height\n * @param channels\n * @param blockID\n * @param nBlocks\n * @return\n */\nPIC_INLINE bool WriteHDRBlock(std::string nameFile, float *buffer_line, int width,\n                              int height, int channels, int blockID, int nBlocks)\n{\n    FILE *file;\n\n    if((file = fopen(nameFile.c_str(), \"wb\")) == NULL || (buffer_line == NULL)) {\n        return false;\n    }\n\n    //TODO: compressed version!\n\n    //writing the header...\n    if(nBlocks < 1) {\n        nBlocks = 10;\n    }\n\n    int blockWidth = width / nBlocks;\n\n    int xStart = blockWidth * blockID;\n    int xEnd   = xStart + blockWidth;\n\n    if(xEnd > width) {\n        xEnd = width;\n    }\n\n    blockWidth = xEnd - xStart;\n\n    fprintf(file, \"#?RADIANCE\\n\");\n    fprintf(file, \"#Spiced by Piccante\\n\");\n    fprintf(file, \"FORMAT=32-bit_rle_rgbe\\n\");\n    fprintf(file, \"EXPOSURE= 1.0\\n\\n\");\n    fprintf(file, \"-Y %d +X %d\\n\", height, blockWidth);\n\n    unsigned char colRGBE[4];\n\n    for(int j = 0; j < height; j++) {\n        int ind = j * width;\n\n        for(int i = xStart; i < xEnd; i++) {\n            int c = (ind + i);\n\n            if(channels == 3) {\n                c *= 3;\n                fromFloatToRGBE(&buffer_line[c], colRGBE);\n            } else {\n                fromSingleFloatToRGBE(&buffer_line[c], colRGBE);\n            }\n\n            fwrite(colRGBE, 1, 4 * sizeof(unsigned char), file);\n        }\n    }\n\n    fclose(file);\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_IO_HDR_HPP */\n\n"
  },
  {
    "path": "include/io/pfm.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_PFM_HPP\n#define PIC_IO_PFM_HPP\n\n#include <stdio.h>\n#include <string>\n\n#include \"../base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief convertFloatEndianess converts a float from little-endian to big-endian\n * or viceversa.\n * @param value is the input float to be converted.\n * @return It returns a big-endian float if value was stored as little-endian. Otherwise,\n * it rerturns a little-endian.\n */\nPIC_INLINE float convertFloatEndianess(float value)\n{\n    float ret;\n\n    unsigned char *c_v = (unsigned char*) &value;\n    unsigned char *c_r = (unsigned char*) &ret;\n\n    c_r[0] = c_v[3];\n    c_r[1] = c_v[2];\n    c_r[2] = c_v[1];\n    c_r[3] = c_v[0];\n\n    return ret;\n}\n\n/**\n * @brief ReadPFM loads a portable float map from a file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channel\n * @return\n */\nPIC_INLINE float *ReadPFM(std::string nameFile, float *data, int &width,\n                          int &height, int &channel)\n{\n    FILE *file = fopen(nameFile.c_str(), \"rb\");\n\n    if(file == NULL) {\n        return NULL;\n    }\n\n    char  flagc;\n    float flag;\n    char P = fgetc(file);\n\n    if(P != 'P') {\n        fclose(file);\n        return NULL;\n    }\n\n    char F = fgetc(file);\n\n    bool fCheck = false;\n\n    if(F == 'f') {\n        fCheck = true;\n        channel = 1;\n    }\n\n    if(F == 'F') {\n        fCheck = true;\n        channel = 3;\n    }\n\n    if(!fCheck) {\n        fclose(file);\n        return NULL;\n    }\n\n\n    fgetc(file);\n    fscanf(file, \"%d %d%c\", &width, &height, &flagc);\n    fscanf(file, \"%f%c\", &flag, &flagc);\n\n    if(data == NULL) {\n        data = new float[width * height * channel];\n    }\n\n    if(flag < 0.0f) {\n        //little-endian encoding\n\n        for(int i = height - 1; i > -1; i--) {\n            int ind = i * width;\n\n            for(int j = 0; j < width; j++) {\n                int tmpInd = (ind + j) * channel;\n\n                fread(&data[tmpInd], sizeof(float), channel, file);\n            }\n        }\n    } else {\n        //big-endian encoding\n\n        for(int i = height - 1; i > -1; i--) {\n            int ind = i * width;\n\n            for(int j = 0; j < width; j++) {\n                int tmpInd = (ind + j) * channel;\n\n                fread(&data[tmpInd], sizeof(float), channel, file);\n\n                for(int k = 0; k < channel; k++) {\n                    data[tmpInd + k] = convertFloatEndianess(data[tmpInd + k]);\n                }\n            }\n        }\n    }\n\n    fclose(file);\n    return data;\n}\n\n/**\n * @brief WritePFM writes an HDR image in the portable float map format into a file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE bool WritePFM(std::string nameFile, float *data, int width,\n                         int height, int channels = 3)\n{\n    if((data == NULL) || (height < 1) || (width < 1) || (channels < 1)) {\n        return false;\n    }\n\n    FILE *file = fopen(nameFile.c_str(), \"wb\");\n\n    if(file == NULL) {\n        return false;\n    }\n\n    //header\n    fputc('P', file);\n\n    if(channels != 1) {\n        fputc('F', file);\n    } else {\n        fputc('f', file);\n    }\n\n    fputc(0x0a, file);\n\n    //width and height\n    fprintf(file, \"%d %d\", width, height);\n    fputc(0x0a, file);\n\n    //flag: writing little-endian only\n    fprintf(file, \"%f\", -1.0f);\n    fputc(0x0a, file);\n\n    //data\n    int ind1 = 1;\n    int ind2 = 2;\n\n    if(channels == 2) {\n        ind1 = 1;\n        ind2 = 1;\n    }\n\n    for(int i = height - 1; i > -1; i--) {\n        int ind = i * width;\n\n        for(int j = 0; j < width; j++) {\n            int tmpInd = (ind + j) * channels;\n\n            fwrite(&data[tmpInd], sizeof(float), 1, file);\n\n            if(channels > 1) {\n                fwrite(&data[tmpInd + ind1], sizeof(float), 1, file);\n                fwrite(&data[tmpInd + ind2], sizeof(float), 1, file);\n            }\n        }\n    }\n\n    fclose(file);\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_IO_PFM_HPP */\n\n"
  },
  {
    "path": "include/io/pgm.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_PGM_HPP\n#define PIC_IO_PGM_HPP\n\n#include <iostream>\n#include <fstream>\n\n#include \"../base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief ReadPGM reads an .ppm file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE unsigned char *ReadPGM(std::string nameFile, unsigned char *data,\n                                  int &width, int &height, int &channels)\n{\n\n    std::ifstream ppm_in(nameFile.c_str(), std::ios::binary);\n\n    std::string magic_number(\"  \");\n\n    ppm_in.get(magic_number[0]);\n    ppm_in.get(magic_number[1]);\n\n    bool bBinary = true;\n\n    if(magic_number != std::string(\"P5\")) {\n        ppm_in.close();\n\n        if(magic_number == std::string(\"P2\")) {\n            bBinary = false;\n            ppm_in.open(nameFile.c_str(), std::ios::in);\n            ppm_in.get(magic_number[0]);\n            ppm_in.get(magic_number[1]);\n        } else {\n            return data;\n        }\n    }\n\n    unsigned int tmpWidth, tmpHeight, bpp;\n\n    ppm_in >> tmpWidth >> tmpHeight >> bpp;\n\n    if(bpp > 255) {\n        printf(\"ERROR ReadPGM: BPP\\n\");\n        return data;\n    }\n\n    channels = 1;\n    width = int(tmpWidth);\n    height = int(tmpHeight);\n\n    //Allocate memory\n    if(data == NULL) {\n        data = new unsigned char[width * height * channels];\n    }\n\n    for(int y = 0; y < height; y++) {\n        int ind = y * width;\n\n        for(int x = 0; x < width; x++) {\n            int c = (ind + x);\n\n            if(bBinary) {\n                char value;\n                ppm_in.get(value);\n                data[c] = (static_cast<unsigned char>(value) * 255) / bpp;\n            } else {\n                int value;\n                ppm_in >> value;\n                data[c] = (static_cast<unsigned char>(value) * 255) / bpp;\n            }\n        }\n    }\n\n    ppm_in.close();\n\n    return data;\n}\n\n/**\n * @brief WritePGM writes an .ppm file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @param bAscii\n * @return\n */\nPIC_INLINE bool WritePGM(std::string nameFile, const unsigned char *data,\n                         int width, int height, int channels, bool bAscii = false)\n{\n    std::ofstream pgm_out;\n\n    if(bAscii) {\n         pgm_out.open(nameFile.c_str(), std::ios::out);\n    } else {\n         pgm_out.open(nameFile.c_str(), std::ios::binary);\n    }\n\n    if(!pgm_out.is_open()) {\n        return false;\n    }\n\n    if(bAscii){\n        pgm_out << \"P2\";\n    } else {\n        pgm_out << \"P5\";\n    }\n\n    pgm_out << ' ';\n    pgm_out << '\\n';\n    pgm_out << width;\n    pgm_out << ' ';\n    pgm_out << height;\n    pgm_out << ' ';\n    pgm_out << '\\n';\n    pgm_out << \"255\";\n    pgm_out << '\\n';\n\n    for(int y = 0; y < height; y++) {\n        int ind = y * width;\n\n        for(int x = 0; x < width; x++) {\n            int c = (ind + x) * channels;\n\n            if(bAscii) {\n                int value = data[c];\n                pgm_out << value << ' ';\n            } else {\n                pgm_out << data[c];\n            }\n        }\n        if(bAscii) {\n            pgm_out << '\\n';\n        }\n    }\n\n    pgm_out.flush();\n    pgm_out.close();\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_IO_PPM_HPP */\n\n"
  },
  {
    "path": "include/io/ppm.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_PPM_HPP\n#define PIC_IO_PPM_HPP\n\n#include <iostream>\n#include <fstream>\n\n#include \"../base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief ReadPPM  reads an .ppm file\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE unsigned char *ReadPPM(std::string nameFile, unsigned char *data,\n                                  int &width, int &height, int &channels)\n{\n    std::ifstream ppm_in(nameFile.c_str(), std::ios::binary);\n\n    std::string magic_number(\"  \");\n\n    ppm_in.get(magic_number[0]);\n    ppm_in.get(magic_number[1]);\n\n    bool bBinary = true;\n\n    if(magic_number != std::string(\"P6\")) {\n        ppm_in.close();\n\n        if(magic_number == std::string(\"P3\")) {\n            bBinary = false;\n            ppm_in.open(nameFile.c_str(), std::ios::in);\n            ppm_in.get(magic_number[0]);\n            ppm_in.get(magic_number[1]);\n        } else {\n            return data;\n        }\n    }\n\n    unsigned tmpWidth, tmpHeight, bpp;\n\n    ppm_in >> tmpWidth >> tmpHeight >> bpp;\n\n    if(bpp > 255) {\n        printf(\"ERROR ReadPPM: BPP\\n\");\n        return data;\n    }\n\n    channels = 3;\n\n    //Allocate memory\n    if(data == NULL) {\n        data = new unsigned char[tmpWidth * tmpHeight * channels];\n    }\n\n    width = tmpWidth;\n    height = tmpHeight;\n\n    char ch;\n    ppm_in.get(ch); // Trailing white space.\n\n    for(int y = 0; y < height; y++) {\n        int ind = y * width;\n\n        for(int x = 0; x < width; x++) {\n            int c = (ind + x) * 3;\n\n            if(bBinary) {\n                char r, g, b;\n                ppm_in.get(r);\n                ppm_in.get(g);\n                ppm_in.get(b);\n\n                data[c    ] = (static_cast<unsigned char>(r) * 255) / bpp;\n                data[c + 1] = (static_cast<unsigned char>(g) * 255) / bpp;\n                data[c + 2] = (static_cast<unsigned char>(b) * 255) / bpp;\n            } else {\n                int r, g, b;\n                ppm_in >> r;\n                ppm_in >> g;\n                ppm_in >> b;\n\n                data[c    ] = (r * 255) / bpp;\n                data[c + 1] = (g * 255) / bpp;\n                data[c + 2] = (b * 255) / bpp;\n            }\n        }\n    }\n\n    ppm_in.close();\n\n    return data;\n}\n\n/**\n * @brief WritePPM  writes an .ppm file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE bool WritePPM(std::string nameFile, const unsigned char *data,\n                         int width, int height, int channels)\n{\n    std::ofstream ppm_out(nameFile.c_str(), std::ios::binary);\n\n    if(!ppm_out.is_open()) {\n        return false;\n    }\n\n    ppm_out << \"P6\";\n    ppm_out << ' ';\n    ppm_out << '\\n';\n    ppm_out << width;\n    ppm_out << ' ';\n    ppm_out << height;\n    ppm_out << ' ';\n    ppm_out << '\\n';\n    ppm_out << \"255\";\n    ppm_out << '\\n';\n\n    int shiftG = 1;\n    int shiftB = 2;\n\n    if(channels == 1) {\n        shiftG = 0;\n        shiftB = 0;\n    }\n\n    for(int y = 0; y < height; y++) {\n        int ind = y * width;\n\n        for(int x = 0; x < width; x++) {\n            int c = (ind + x) * channels;\n            ppm_out << data[c  ];\n            ppm_out << data[c + shiftG];\n            ppm_out << data[c + shiftB];\n        }\n    }\n\n    ppm_out.flush();\n    ppm_out.close();\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_IO_PPM_HPP */\n\n"
  },
  {
    "path": "include/io/stb.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_STB_HPP\n#define PIC_IO_STB_HPP\n\n#include <stdio.h>\n#include <string>\n\n#include \"../base.hpp\"\n\n\n#ifndef PIC_STB_DISABLE\n    #define PIC_STB\n    #define STBIWDEF inline\n    #define STB_IMAGE_STATIC\n    #define STB_IMAGE_WRITE_STATIC\n    #define STB_IMAGE_WRITE_IMPLEMENTATION\n    #define STB_IMAGE_IMPLEMENTATION\n\n#ifndef PIC_STB_NOT_INSTALLED_LOCAL\n    #include \"../../stb-master/stb_image_write.h\"\n    #include \"../../stb-master/stb_image.h\"\n#else\n    #include <stb/stb_image_write.h>\n    #include <stb/stb_image.h>\n#endif\n\n#endif\n\n\nnamespace pic {\n\n/**\n * @brief ReadSTB\n * @param nameFile\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE unsigned char *ReadSTB(std::string nameFile, int &width,\n                          int &height, int &channels)\n{\n    unsigned char *data = NULL;\n    \n#ifndef PIC_STB_DISABLE\n    int w, h, c;\n    stbi_info(nameFile.c_str(), &w, &h, &c);\n    data = stbi_load(nameFile.c_str(), &width, &height, &channels, c);\n#endif\n    \n    return data;\n}\n\n/**\n * @brief WriteSTB\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE bool WriteSTB(std::string nameFile, unsigned char *data, int width, int height,\n                int channels = 3)\n{\n    int tmp = 0;\n\n    #ifndef PIC_STB_DISABLE\n        tmp = stbi_write_png(nameFile.c_str(), width, height, channels, (void*) data, 0);\n    #endif\n    \n    return (tmp == 1);\n}\n\n} // end namespace pic\n\n#endif /* PIC_IO_STB_HPP */\n\n"
  },
  {
    "path": "include/io/tga.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_TGA_HPP\n#define PIC_IO_TGA_HPP\n\n#include <stdio.h>\n#include <string>\n#include <iostream>\n\n#include \"../base.hpp\"\n#include \"../util/buffer.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The TGA_HEADER struct\n */\nstruct TGA_HEADER{\n    unsigned char id_length;\n    unsigned char colormap_type;\n    unsigned char image_type;\n\n    //colormap information\n    short int     colormap_first_entry;\n    short int     colormap_length;\n    unsigned char colormap_entry_size;\n\n    //image information\n    short int     x_origin;\n    short int     y_origin;\n    short int     width;\n    short int     height;\n    unsigned char depth;\n\n    unsigned char descriptor;\n};\n\n/**\n * @brief ReadTGA reads an image in the .tga format.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE unsigned char *ReadTGA(std::string nameFile, unsigned char *data,\n                                  int &width, int &height, int &channels)\n{\n    std::ifstream tga_in(nameFile.c_str(), std::ios::binary);\n\n    if(!tga_in.is_open()) {\n        return data;\n    }\n\n    //reading the header\n    TGA_HEADER header;\n    tga_in.read((char*)(&header.id_length), 1);\n    tga_in.read((char*)(&header.colormap_type), 1);\n    tga_in.read((char*)(&header.image_type), 1);\n\n    tga_in.read((char*)(&header.colormap_first_entry), 2);\n    tga_in.read((char*)(&header.colormap_length), 2);\n    tga_in.read((char*)(&header.colormap_entry_size), 1);\n\n    tga_in.read((char*)(&header.x_origin), 2);\n    tga_in.read((char*)(&header.y_origin), 2);\n    tga_in.read((char*)(&header.width), 2);\n    tga_in.read((char*)(&header.height), 2);\n    tga_in.read((char*)(&header.depth), 1);\n    tga_in.read((char*)(&header.descriptor), 1);\n\n\n    width  = (int)(header.width);\n    height = (int)(header.height);\n\n    //extra information from the developer\n    for(int i=0; i<header.id_length; i++) {\n        char tmp;\n        tga_in.read(&tmp, 1);\n    }\n\n    //supporting only 8-bit RGB or RGBA\n    if(!((header.depth==32) || (header.depth==24))) {\n        tga_in.close();\n        return data;\n    }\n\n    channels = header.depth / 8;\n\n    int size = width * height * channels;\n    if(data == NULL) {\n        data = new unsigned char[size];\n    }\n\n    //reading uncompressed data\n    if((header.image_type > 0) && (header.image_type < 4)) {\n        tga_in.read((char*)(data), size);\n\n        //values are stored as BGR\n        Buffer<unsigned char>::BGRtoRGB(data, width, height, channels, 1);\n\n        //values are stored with a vertical flip\n        Buffer<unsigned char>::flipV(data, width, height, channels, 1);\n\n    } else {\n        //reading RLE compressed data\n\n    }\n\n    tga_in.close();\n    return data;\n}\n\n/**\n * @brief WriteTGA writes an image in the .tga format.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE bool WriteTGA(std::string nameFile, const unsigned char *data,\n                         int width, int height, int channels)\n{\n    std::ofstream tga_out(nameFile.c_str(), std::ios::binary);\n\n    if(!tga_out.is_open()) {\n        return false;\n    }\n\n    //setting the header\n    TGA_HEADER header;\n    header.id_length = 0;\n    header.colormap_type = 0; //no color map included\n\n    header.colormap_first_entry = 0;\n    header.colormap_length = 0;\n    header.colormap_entry_size = 0;\n\n    header.x_origin = 0;\n    header.y_origin = 0;\n    header.width = short(width);\n    header.height = short(height);\n    header.depth = 8 * channels;\n\n    if(channels == 4) {\n        header.descriptor = 3;\n    } else {\n        header.descriptor = 0;\n    }\n\n    if(channels == 1) {\n        header.image_type = 3; //uncompressed gray scale\n    } else {\n        header.image_type = 2; //uncompressed RGB\n    }\n\n    tga_out.write((char*)(&header.id_length), 1);\n    tga_out.write((char*)(&header.colormap_type), 1);\n    tga_out.write((char*)(&header.image_type), 1);\n\n    tga_out.write((char*)(&header.colormap_first_entry), 2);\n    tga_out.write((char*)(&header.colormap_length), 2);\n    tga_out.write((char*)(&header.colormap_entry_size), 1);\n\n    tga_out.write((char*)(&header.x_origin), 2);\n    tga_out.write((char*)(&header.y_origin), 2);\n    tga_out.write((char*)(&header.width), 2);\n    tga_out.write((char*)(&header.height), 2);\n    tga_out.write((char*)(&header.depth), 1);\n    tga_out.write((char*)(&header.descriptor), 1);\n\n//    tga_out.write((char*)(&header.components), 4);\n//    tga_out.write((char*)(&header.bytes), 4);\n\n    tga_out.write((char*)(data), width * height * channels);\n\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_IO_TMP_HPP */\n\n"
  },
  {
    "path": "include/io/tmp.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_TMP_HPP\n#define PIC_IO_TMP_HPP\n\n#include <stdio.h>\n#include <string>\n\n#include \"../base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The TMP_IMG_HEADER struct is a header for a tmp image\n */\nstruct TMP_IMG_HEADER {\n    int frames, width, height, channels;\n};\n\n\n/**\n * @brief ReadTMP reads a dump temp file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @param frames\n * @param bHeader\n * @return\n */\nPIC_INLINE float *ReadTMP(std::string nameFile, float *data, int &width,\n                          int &height, int &channels, int &frames, bool bHeader = true)\n{\n    FILE *file = fopen(nameFile.c_str(), \"rb\");\n\n    if(file == NULL) {\n        return NULL;\n    }\n\n    //read the header\n    TMP_IMG_HEADER header;\n    header.channels = -1;\n    header.frames = -1;\n    header.width = -1;\n    header.height = -1;\n\n    if(bHeader) {\n        fread(&header, sizeof(TMP_IMG_HEADER), 1, file);\n\n        if(header.channels < 1 && header.frames < 1 && header.height < 1 &&\n           header.width < 1) { //invalid image!\n            return NULL;\n        }\n    }\n\n    if(data == NULL) {\n        data = new float[width * height * channels * frames];\n    }\n\n    if(bHeader) {\n        width    = header.width;\n        height   = header.height;\n        channels = header.channels;\n        frames   = header.frames;\n    }\n\n    fread(data, sizeof(float), frames * width * height * channels, file);\n\n    fclose(file);\n\n    return data;\n}\n\n/**\n * @brief WriteTMP writes a dump temp file.\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param channels\n * @param frames\n * @param bHeader\n * @return\n */\nPIC_INLINE bool WriteTMP(std::string nameFile, float *data, int &width,\n                         int &height, int &channels, int &frames, bool bHeader = true)\n{\n\n    TMP_IMG_HEADER header;\n\n    if(bHeader) {\n        header.frames = frames;\n        header.width = width;\n        header.height = height;\n        header.channels = channels;\n    }\n\n    FILE *file = fopen(nameFile.c_str(), \"wb\");\n\n    if(file == NULL) {\n        return false;\n    }\n\n    int size = frames * width * height * channels;\n\n     if(size < 1)\n         return false;\n\n    if(bHeader) {\n        fwrite(&header, sizeof(TMP_IMG_HEADER), 1, file);\n    }\n  \n    fwrite(data, sizeof(float), size, file);\n\n    fclose(file);\n\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_IO_TMP_HPP */\n\n"
  },
  {
    "path": "include/io/vol.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_VOL_HPP\n#define PIC_IO_VOL_HPP\n\n#include <stdio.h>\n#include <string>\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/**\n * @brief ReadVOL\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param depth\n * @param channels\n * @return\n */\nPIC_INLINE float *ReadVOL(std::string nameFile, float *data, int &width,\n                          int &height, int &depth, int &channels)\n{\n    FILE *file = fopen(nameFile.c_str(), \"rb\");\n\n    if(file == NULL) {\n        return NULL;\n    }\n\n    //File size\n    fseek(file, 0, SEEK_END);\n    int fileSize = ftell(file) / 3;\n    rewind(file);\n\n    //Check size\n    int c64  = 64 * 64 * 64;\n    int c128 = 128 * 128 * 128;\n    int c256 = 256 * 256 * 256;\n\n    if(fileSize != c64 && fileSize != c128 && fileSize != c256) {\n        return NULL;\n    }\n\n    int len;\n    len = fileSize == c64  ?  64 : 128;\n    len = fileSize == c128 ? 128 : len;\n    len = fileSize == c256 ? 256 : len;\n\n    width\t= len;\n    height\t= len;\n    depth\t= len;\n\n    if(data == NULL) {\n        data = new float[len * len * len * 4];\n    }\n\n    unsigned char *tmpData = new unsigned char[fileSize * 3];\n\n    fread(tmpData, sizeof(unsigned char), fileSize * 3, file);\n\n    int ind0, ind1;\n\n    for(int i = 0; i < len; i++) {\n        int tmpI = len * len * i;\n\n        for(int j = 0; j < len; j++) {\n            int tmpJ = tmpI + len * j;\n\n            for(int k = 0; k < len; k++) {\n                ind0 = (tmpJ + k) * 3;\n                ind1 = (tmpJ + k) * channels;\n                data[ind1    ] = float(tmpData[ind0    ]) / 255.0f;\n                data[ind1 + 1] = float(tmpData[ind0 + 1]) / 255.0f;\n                data[ind1 + 2] = float(tmpData[ind0 + 2]) / 255.0f;\n                data[ind1 + 3] = sqrtf(data[ind1    ] * data[ind1    ] +\n                                       data[ind1 + 1] * data[ind1 + 1] +\n                                       data[ind1 + 2] * data[ind1 + 2]);\n//\t\t\t\tdata[ind1+3] = 1.0f;\n            }\n        }\n    };\n\n    delete[] tmpData;\n\n    fclose(file);\n\n    return data;\n}\n\n/**\n * @brief WriteVOL\n * @param nameFile\n * @param data\n * @param width\n * @param height\n * @param depth\n * @param channels\n * @return\n */\nPIC_INLINE bool WriteVOL(std::string nameFile, float *data, int width, int height,\n               int depth, int channels = 3)\n{\n\n    FILE *file = fopen(nameFile.c_str(), \"wb\");\n\n    if(file == NULL) {\n        return false;\n    }\n\n    int tot = width * height * depth * 3;\n\n    unsigned char *tmpData = new unsigned char[tot];\n\n    int sh1 = 0;\n    int sh2 = 0;\n\n    if(channels == 2) {\n        sh1 = 1;\n        sh2 = 1;\n    }\n\n    if(channels > 2) {\n        sh1 = 1;\n        sh2 = 2;\n    }\n\n    for(int i = 0; i < tot; i += 3) {\n        int j = (i / 3) * channels;\n        tmpData[i    ] = int(CLAMPi(data[j      ] * 255.0f, 0.0f, 255.0f));\n        tmpData[i + 1] = int(CLAMPi(data[j + sh1] * 255.0f, 0.0f, 255.0f));\n        tmpData[i + 2] = int(CLAMPi(data[j + sh2] * 255.0f, 0.0f, 255.0f));\n    }\n\n    fwrite(tmpData, sizeof(unsigned char), tot, file);\n\n    fclose(file);\n\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_IO_VOL_HPP */\n\n"
  },
  {
    "path": "include/io.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_HPP\n#define PIC_IO_HPP\n\n#include \"io/bmp.hpp\"\n#include \"io/exr.hpp\"\n#include \"io/exr_tiny.hpp\"\n#include \"io/hdr.hpp\"\n#include \"io/pfm.hpp\"\n#include \"io/ppm.hpp\"\n#include \"io/pgm.hpp\"\n#include \"io/tga.hpp\"\n#include \"io/tmp.hpp\"\n#include \"io/vol.hpp\"\n#include \"io/stb.hpp\"\n#include \"io/exif.hpp\"\n\n#endif /* PIC_IO_HPP */\n\n"
  },
  {
    "path": "include/metrics/base.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_BASE_HPP\n#define PIC_METRICS_BASE_HPP\n\n#include \"../util/math.hpp\"\n#include \"../metrics/pu_21.hpp\"\n\nnamespace pic {\n\nconst double C_SINGULARITY = 1e-6;\nconst double C_LARGE_DIFFERENCES = 1e6;\nconst float  C_LARGE_DIFFERENCESf = 1e6f;\n\nenum METRICS_DOMAIN{MD_LIN, MD_LOG10, MD_PU21};\n\n/**\n * @brief changeDomain\n * @param x\n * @param type\n * @return\n */\nPIC_INLINE float changeDomain(float x, METRICS_DOMAIN type = MD_LIN)\n{\n    switch(type){\n    case MD_LIN: {\n        return x;\n    } break;\n\n    case MD_LOG10: {\n        return log10f(x);\n    } break;\n\n    case MD_PU21: {\n        return PU21Encode(x);\n    } break;\n    }\n\n    return x;\n}\n\n} // end namespace pic\n\n#endif /* PIC_METRICS_BASE_HPP */\n\n"
  },
  {
    "path": "include/metrics/log_rmse.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_LOG_RMSE_HPP\n#define PIC_METRICS_LOG_RMSE_HPP\n\n#include <math.h>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../util/math.hpp\"\n#include \"../metrics/base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief logRMSE computes root mean square error (RMSE) in the log_e domain.\n * @param ori is the original image.\n * @param cmp is the distorted image.\n * @return It returns RMSE in the log_e domain.\n */\nPIC_INLINE double logRMSE(Image *ori, Image *cmp)\n{\n    if(ori == NULL || cmp == NULL) {\n        return -2.0;\n    }\n\n    if(!ori->isValid() || !cmp->isValid()) {\n        return -4.0;\n    }\n\n    if(!ori->isSimilarType(cmp)) {\n        return -1.0;\n    }\n\n    int size = ori->size();\n    int counter = 0;\n\n    double acc = 0.0;\n    for(int i = 0; i < size; i++) {\n        if(ori->data[i] > 0.0f && cmp->data[i] > 0.0f) {\n            double val = log2(ori->data[i] / cmp->data[i]);\n            acc += val * val;\n            counter++;\n        }\n    }\n\n    if(counter > 0) {\n        acc = acc / double(counter);\n        return sqrt(acc);\n    } else {\n        return -3.0;\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_METRICS_LOG_RMSE_HPP */\n\n"
  },
  {
    "path": "include/metrics/m_psnr.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_M_PSNR_HPP\n#define PIC_METRICS_M_PSNR_HPP\n\n#include <math.h>\n\n#include \"../base.hpp\"\n\n#include \"../util/array.hpp\"\n\n#include \"../image.hpp\"\n#include \"../tone_mapping/get_all_exposures.hpp\"\n#include \"../metrics/base.hpp\"\n#include \"../metrics/mse.hpp\"\n\nnamespace pic {\n\nenum MULTI_EXPOSURE_TYPE{MET_HISTOGRAM, MET_MIN_MAX, MET_FROM_INPUT};\n\n/**\n * @brief mPSNR computes the multiple-exposure peak signal-to-noise ratio (mPSNR) between two images.\n * @param ori is the original image.\n * @param cmp is the distorted image.\n * @param type.\n * @param minFstop is the minimum f-stop value of ori.\n * @param maxFstop is the maximum f-stop value of ori.\n * @return It returns the nMPSR error value between ori and cmp.\n */\nPIC_INLINE double mPSNR(Image *ori, Image *cmp, MULTI_EXPOSURE_TYPE type, int minFstop = 0, int maxFstop = 0)\n{\n    if(ori == NULL || cmp == NULL) {\n        return -2.0;\n    }\n\n    if(!ori->isValid() || !cmp->isValid()) {\n        return -3.0;\n    }\n\n    if(!ori->isSimilarType(cmp)) {\n        return -1.0;\n    }\n\n    std::vector<float> exposures;\n\n    switch (type) {\n        case MET_HISTOGRAM: {\n            exposures = getAllExposures(ori);\n        } break;\n\n        case MET_MIN_MAX: {\n            if(minFstop == maxFstop) {\n                getMinMaxFstops(ori, minFstop, maxFstop);\n            }\n\n            int nExposures_v = 0;\n            float *exposures_v = NULL;\n            Arrayf::genRange(float(minFstop), 1.0f, float(maxFstop), exposures_v, nExposures_v);\n\n            exposures.insert(exposures.begin(), exposures_v, exposures_v + nExposures_v);\n\n        } break;\n\n        case MET_FROM_INPUT: {\n            for(int i = minFstop; i <= maxFstop; i++) {\n                exposures.push_back(float(i));\n            }\n\n        } break;\n    }\n\n    if(exposures.empty()) {\n        return -5.0;\n    }\n\n    #ifdef PIC_DEBUG\n        printf(\"-------------------------------------------------------\\n\");\n        printf(\"-- mPSNR:\\n\");\n        printf(\"-- min F-stop: %d \\t max F-stop: %d\\n\", minFstop, maxFstop);\n    #endif\n\n    int nBit = 8;\n    float gamma = 2.2f; //typically 2.2\n    auto n = exposures.size();\n    double mse = 0.0;\n    for(uint i = 0; i < n; i++) {\n        double mse_i = MSE(ori, cmp, gamma, exposures[i], nBit);\n\n        #ifdef PIC_DEBUG\n            printf(\"-- Pass: %d \\t MSE: %g\\n\", i, mse_i);\n       #endif\n\n        mse += mse_i;\n    }\n\n    mse /= double(n * ori->channels);\n\n    int nValues = (1 << nBit) - 1;\n    double nValuesd = double(nValues);\n    double ret = 10.0 * log10((nValuesd * nValuesd) / mse);\n\n    #ifdef PIC_DEBUG\n        printf(\"-- value: %f\\n\", ret);\n        printf(\"-------------------------------------------------------\");\n    #endif\n\n    return ret;\n}\n\n} // end namespace pic\n\n#endif /* PIC_METRICS_M_PSNR_HPP */\n\n"
  },
  {
    "path": "include/metrics/mae.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_MAE_HPP\n#define PIC_METRICS_MAE_HPP\n\n#include <math.h>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../metrics/base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief MAE computes the mean abosulute errore (MAE) between two images.\n * @param ori is the original image.\n * @param cmp is the distorted image.\n * @param bLargeDifferences, if true, skips big differences for stability.\n * @param type is the domain where to compute RMSE (linear, logarithmic, and PU).\n * @return It returns the MAE value between ori and cmp.\n */\nPIC_INLINE double MAE(Image *ori, Image *cmp, bool bLargeDifferences = false, METRICS_DOMAIN type = MD_LIN)\n{\n    if(ori == NULL || cmp == NULL) {\n        return -2.0;\n    }\n\n    if(!ori->isValid() || !cmp->isValid()) {\n        return -4.0;\n    }\n\n    if(!ori->isSimilarType(cmp)) {\n        return -1.0;\n    }\n\n    int size = ori->size();\n\n    double largeDifferences = C_LARGE_DIFFERENCES;\n\n    if(!bLargeDifferences) {\n        largeDifferences = FLT_MAX;\n    }\n\n    double acc = 0.0;\n    int count = 0;\n    for(int i = 0; i < size; i++) {\n        double o_val = changeDomain(ori->data[i], type);\n        double c_val = changeDomain(cmp->data[i], type);\n\n        double delta = fabs(o_val - c_val);\n\n        if(delta < largeDifferences) {\n            acc += delta;\n            count++;\n        }\n    }\n\n    return acc / double(count);\n}\n\n} // end namespace pic\n\n#endif /* PIC_METRICS_MAE_HPP */\n\n"
  },
  {
    "path": "include/metrics/maximum_error.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_MAXIMUM_ERROR_HPP\n#define PIC_METRICS_MAXIMUM_ERROR_HPP\n\n#include <math.h>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../metrics/base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief MaximumError computes the maximum error between two images.\n * @param ori is the original image.\n * @param cmp is the distorted image.\n * @param bLargeDifferences, if true, skips big differences for stability.\n * @return It returns the maxium error value between ori and cmp.\n */\nPIC_INLINE float MaximumError(Image *ori, Image *cmp, bool bLargeDifferences = false)\n{\n    if(ori == NULL || cmp == NULL) {\n        return -2.0f;\n    }\n\n    if(!ori->isValid() || !cmp->isValid()) {\n        return -4.0f;\n    }\n\n    if(!ori->isSimilarType(cmp)) {\n        return -1.0f;\n    }\n\n    int size = ori->size();\n\n\n    float largeDifferences = C_LARGE_DIFFERENCESf;\n    if(!bLargeDifferences) {\n        largeDifferences = FLT_MAX;\n    }\n\n    float maxVal = -FLT_MAX;\n    for(int i = 0; i < size; i++) {\n        float delta = fabsf(ori->data[i] - cmp->data[i]);\n\n        if((delta < C_LARGE_DIFFERENCES) && (maxVal < delta)) {\n            maxVal = delta;\n        }\n    }\n\n    return maxVal;\n}\n\n} // end namespace pic\n\n#endif /* PIC_METRICS_MAXIMUM_ERROR_HPP */\n\n"
  },
  {
    "path": "include/metrics/mse.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_MSE_HPP\n#define PIC_METRICS_MSE_HPP\n\n#include <math.h>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../metrics/base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief MSE computes the mean square error (MSE) between two images.\n * @param ori is the original image.\n * @param cmp is the distorted image.\n * @param bLargeDifferences, if true, skips big differences for stability.\n * @param type is the domain where to compute MSE (linear, logarithmic, and PU).\n * @return It returns the MSE value between ori and cmp.\n */\nPIC_INLINE double MSE(Image *ori, Image *cmp, bool bLargeDifferences = false, METRICS_DOMAIN type = MD_LIN)\n{\n    if(ori == NULL || cmp == NULL) {\n        return -2.0;\n    }\n\n    if(!ori->isValid() || !cmp->isValid()) {\n        return -4.0;\n    }\n\n    if(!ori->isSimilarType(cmp)) {\n        return -1.0;\n    }\n\n    int size = ori->size();\n\n\n    int count = 0;\n\n    float largeDifferences = C_LARGE_DIFFERENCESf;\n\n    if(!bLargeDifferences) {\n        largeDifferences = FLT_MAX;\n    }\n\n    double acc = 0.0;\n    for(int i = 0; i < size; i++) {\n        float o_val = changeDomain(ori->data[i], type);\n        float c_val = changeDomain(cmp->data[i], type);\n\n        double delta = double(o_val - c_val);\n\n        if(delta <= largeDifferences) {\n            acc += delta * delta;\n            count++;\n        }\n    }\n\n    return acc / double(count);\n}\n\n/**\n * @brief MSE computes the mean square error (MSE) between two HDR images with given exposure and gamma.\n * @param ori is the original image.\n * @param cmp is the distorted image.\n * @param gamma is the encoding gamma.\n * @param fstop is the f-stop value of the image.\n * @param nBit is the number of bits used for the discretization.\n * @return It returns the MSE value between ori and cmp.\n */\nPIC_INLINE double MSE(Image *ori, Image *cmp, float gamma = 2.2f, float fstop = 0.0f, int nBit = 8)\n{\n    if(ori == NULL || cmp == NULL) {\n        return -2.0;\n    }\n\n    if(!ori->isValid() || !cmp->isValid()) {\n        return -4.0;\n    }\n\n    if(!ori->isSimilarType(cmp)) {\n        return -1.0;\n    }\n\n    float invGamma = 1.0f / gamma;\n    float exposure = powf(2.0f, fstop);\n\n    int area = ori->width * ori->height;\n    int size = area * ori->channels;\n\n    unsigned long long acc = 0;\n\n    int nValues = (1 << nBit) - 1;\n    float nValuesf = float(nValues);\n\n    for(int i = 0; i < size; i++) {\n        int oriLDR = int(nValuesf * (powf(ori->data[i] * exposure, invGamma)));\n        int cmpLDR = int(nValuesf * (powf(cmp->data[i] * exposure, invGamma)));\n\n        oriLDR = CLAMPi(oriLDR, 0, nValues);\n        cmpLDR = CLAMPi(cmpLDR, 0, nValues);\n\n        int delta = cmpLDR - oriLDR;\n\n        acc += delta * delta;\n    }\n\n    return (double(acc) / double(area));\n}\n\n/**\n * @brief RMSE computes the root mean squared error (RMSE) between two images.\n * @param ori is the original image.\n * @param cmp is the distorted image.\n * @param bLargeDifferences, if true, skips big differences for stability.\n * @param type is the domain where to compute RMSE (linear, logarithmic, and PU).\n * @return It returns the MSE value between ori and cmp.\n */\nPIC_INLINE double RMSE(Image *ori, Image *cmp, bool bLargeDifferences = false, METRICS_DOMAIN type = MD_LIN)\n{\n    return sqrt(MSE(ori, cmp, bLargeDifferences, type));\n}\n\n} // end namespace pic\n\n#endif /* PIC_METRICS_MSE_HPP */\n\n"
  },
  {
    "path": "include/metrics/psnr.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_PSNR_HPP\n#define PIC_METRICS_PSNR_HPP\n\n#include <math.h>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../util/array.hpp\"\n#include \"../metrics/base.hpp\"\n#include \"../metrics/mse.hpp\"\n\nnamespace pic {\n\n/**\n * @brief PSNR computes the peak signal to noise ratio (PSNR) between two images.\n * @param ori is the original image.\n * @param cmp is the distorted image.\n * @param max_value is the maximum value of the domain of ori and cmp. If ori and comp\n * are normalized 8-bit LDR/SDR images max_value MUST BE 1.0!\n * @param bLargeDifferences, if true, skips big differences for stability.\n * @param type is the domain where to compute MSE (linear, logarithmic, and PU).\n * @return It returns the PSNR value between ori and cmp.\n */\nPIC_INLINE double PSNR(Image *ori, Image *cmp, double max_value = -1.0, bool bLargeDifferences = false, METRICS_DOMAIN type = MD_LIN)\n{\n    if(ori == NULL || cmp == NULL) {\n        return -2.0;\n    }\n\n    if(!ori->isValid() || !cmp->isValid()) {\n        return -4.0;\n    }\n\n    if(!ori->isSimilarType(cmp)) {\n        return -1.0;\n    }\n\n    if(max_value <= 0.0) {\n        float *max_value_ori = ori->getMaxVal(NULL, NULL);\n        float *max_value_cmp = cmp->getMaxVal(NULL, NULL);\n\n        int ind;\n        float m_ori = Arrayf::getMax(max_value_ori, ori->channels, ind);\n        float m_cmp = Arrayf::getMax(max_value_cmp, cmp->channels, ind);\n\n        max_value = double(MAX(m_ori, m_cmp));\n\n        delete[] max_value_ori;\n        delete[] max_value_cmp;\n    }\n\n    double rmse_value = RMSE(ori, cmp, bLargeDifferences, type);\n\n    max_value = double(changeDomain(float(max_value), type));\n\n    if(rmse_value > 0.0) {\n        return 20.0 * log10(max_value / rmse_value);\n    } else {\n        return -3.0;\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_METRICS_PSNR_HPP */\n\n"
  },
  {
    "path": "include/metrics/pu_21.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_PU_ENCODE_HPP\n#define PIC_METRICS_PU_ENCODE_HPP\n\n#include <math.h>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../util/array.hpp\"\n\n//#include \"../metrics/pu08_data.hpp\"\n\nnamespace pic {\n\n/**\n * @brief PUEncode encodes luminance values in a perceptually uniform space.\n * @param L is a luminance value in cd/m^2; it works \n * @return it returns a perceptually uniform value\n */\nPIC_INLINE float PU21Encode(float L)\n{\n    L = Clamp(L, 0.005f, 10000.0f);\n\n    float data[] = { 0.353487901f, 0.3734658629f, 8.277049286e-05f, 0.9062562627f, 0.09150303166f, 0.9099517204f, 596.3148142f };\n\n    float L3 = powf(L, data[3]);\n    float t1 = (data[0] + data[1] * L3);\n    float t2 = (1.0f + data[2] * L3);\n    float out = data[6] * (powf(t1 / t2, data[4]) - data[5]);\n    return MAX(out, 0.0f);\n}\n\n/**\n * @brief PUDecode decodes perceptually uniform values into luminance values.\n * @param p is a perceptually uniform luminance value\n * @return it returns a luminance value in the range [10^-5, 10^10] cd/m^2\n */\nPIC_INLINE float PU21Decode(float p)\n{\n    p = MIN(p, 745.0f);\n\n    float data[] = { 0.353487901f, 0.3734658629f, 8.277049286e-05f, 0.9062562627f, 0.09150303166f, 0.9099517204f, 596.3148142f };\n\n    float t0 = MAX((p / data[6]) + data[5], 0.0f);\n    float t1 = powf(t0, 1.0f / data[4]);\n    float t2 = MAX(t1 - data[0], 0.0f);\n    float t3 = t2 / (data[1] - data[2] * t1);\n    float L = powf(t3,  1.0f / data[3]);\n    return L;\n}\n\n} // end namespace pic\n\n#endif /* PIC_METRICS_PU_ENCODE_HPP */\n\n"
  },
  {
    "path": "include/metrics/relative_error.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_RELATIVE_ERROR_HPP\n#define PIC_METRICS_RELATIVE_ERROR_HPP\n\n#include <math.h>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n\n#include \"../metrics/base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief RelativeError computes the relative error between two images.\n * @param ori is the original image.\n * @param cmp is the distorted image.\n * @param bLargeDifferences, if true, skips big differences for stability.\n * @param type is the domain where to compute MSE (linear, logarithmic, and PU).\n * @return It returns the relative error value between ori and cmp.\n */\nPIC_INLINE double RelativeError(Image *ori, Image *cmp, bool bLargeDifferences = false, METRICS_DOMAIN type = MD_LIN)\n{\n    if(ori == NULL || cmp == NULL) {\n        return -2.0;\n    }\n\n    if(!ori->isValid() || !cmp->isValid()) {\n        return -4.0;\n    }\n\n    if(!ori->isSimilarType(cmp)) {\n        return -1.0;\n    }\n\n    int size = ori->size();\n\n    double relErr = 0.0f;\n    int count = 0;\n\n    float largeDifferences = C_LARGE_DIFFERENCESf;\n    if(!bLargeDifferences) {\n        largeDifferences = FLT_MAX;\n    }\n\n    for(int i = 0; i < size; i++) {\n        double o_val = double(changeDomain(ori->data[i], type));\n        double c_val = double(changeDomain(cmp->data[i], type));\n\n        double delta = fabs(o_val - c_val);\n\n        if(delta <= largeDifferences) {\n            count++;\n\n            if(o_val > C_SINGULARITY) { //to avoid singularities\n                relErr += delta / o_val;\n            }\n        }\n    }\n\n    if(count > 0) {\n        return relErr / double(count);\n    } else {\n        return -3.0;\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_METRICS_RELATIVE_ERROR_HPP */\n\n"
  },
  {
    "path": "include/metrics/ssim_index.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_SSIM_INDEX_HPP\n#define PIC_METRICS_SSIM_INDEX_HPP\n\n#include <math.h>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../util/math.hpp\"\n#include \"../metrics/base.hpp\"\n\n#include \"../util/array.hpp\"\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n#include \"../filtering/filter_downsampler_2d.hpp\"\n#include \"../filtering/filter_ssim.hpp\"\n\nnamespace pic {\n\nclass SSIMIndex\n{\nprotected:\n    float K0, K1, sigma_window, dynamic_range;\n    bool bDownsampling;\n\n    FilterLuminance flt_lum;\n    FilterGaussian2D flt_gauss2D;\n    FilterSSIM flt_ssim;\n\n    METRICS_DOMAIN type;\n\npublic:\n\n    SSIMIndex()\n    {\n        K0 = 0.01f;\n        K1 = 0.03f;\n        dynamic_range = -1.0f;\n        sigma_window = 1.5f;\n        type = MD_LIN;\n        bDownsampling = true;\n        flt_gauss2D.update(sigma_window);\n    }\n\n    /**\n     * @brief update\n     * @param K0\n     * @param K1\n     * @param sigma_window\n     * @param dynamic_range\n     * @param bDownsampling\n     * @param type\n     */\n    void update(float K0 = 0.01f,\n                float K1 = 0.03f,\n                float sigma_window = 1.5f,\n                float dynamic_range = -1.0f,\n                bool bDownsampling = true,\n                METRICS_DOMAIN type = MD_LIN)\n    {\n        this->K0 = K0 > 0.0f ? K0 : this->K0;\n        this->K1 = K1 > 0.0f ? K1 : this->K0;\n        this->sigma_window = sigma_window > 0.0f ? sigma_window : this->sigma_window;\n        this->dynamic_range = dynamic_range > 0.0f ? dynamic_range : this->dynamic_range;\n        this->bDownsampling = bDownsampling;\n        this->type = type;\n\n        flt_gauss2D.update(sigma_window);\n    }\n\n    /**\n     * @brief execute\n     * @param ori\n     * @param cmp\n     */\n    Image *execute(ImageVec imgIn, float &ssim_index, Image *ssim_map = NULL)\n    {\n        ssim_index = -1.0f;\n\n        bool bCheckInput = ImageVecCheck(imgIn, 2) && ImageVecCheckSimilarType(imgIn);\n\n        if(!bCheckInput) {\n            return ssim_map;\n        }\n\n        Image *ori = imgIn[0];\n        Image *cmp = imgIn[1];\n\n        Image *ori_d = NULL;\n        Image *cmp_d = NULL;\n\n        bool bAllocated = false;\n        if(bDownsampling) {\n            float f = MAX(1.0f, lround(MIN(ori->widthf, ori->heightf) / 256.0f));\n\n            #ifdef PIC_DEBUG\n                printf(\"\\nDownsampling factor: %f\\n\", f);\n            #endif\n\n            if(f > 1.0f) {\n                ori_d = FilterDownSampler2D::execute(ori, NULL, 1.0f / f);\n                cmp_d = FilterDownSampler2D::execute(cmp, NULL, 1.0f / f);\n\n                ori = ori_d;\n                cmp = cmp_d;\n\n                bAllocated = true;\n            }\n        }\n\n        Image *L_ori = flt_lum.Process(Single(ori), NULL);\n        Image *L_cmp = flt_lum.Process(Single(cmp), NULL);\n\n        switch(type)\n        {\n            case MD_PU21:\n            {\n                L_ori->applyFunction(PU21Encode);\n                L_cmp->applyFunction(PU21Encode);\n            } break;\n\n            case MD_LOG10:\n            {\n                L_ori->applyFunction(log10fPlusEpsilon);\n                L_cmp->applyFunction(log10fPlusEpsilon);\n            } break;\n\n            default:\n            {\n\n            } break;\n        }\n\n        if(dynamic_range <= 0.0f) {\n            dynamic_range = L_ori->getDynamicRange(false, 1.0f);\n        }\n\n        float C0 = K0 * dynamic_range;\n        C0 = C0 * C0;\n\n        float C1 = K1 * dynamic_range;\n        C1 = C1 * C1;\n\n        Image *img_mu1 = flt_gauss2D.Process(Single(L_ori), NULL);\n        Image *img_mu2 = flt_gauss2D.Process(Single(L_cmp), NULL);\n\n        Image img_ori_cmp = (*L_ori) * (*L_cmp);\n\n        L_ori->applyFunction(square);\n        L_cmp->applyFunction(square);\n\n        Image *img_sigma1_sq = flt_gauss2D.Process(Single(L_ori), NULL);\n        Image *img_sigma2_sq = flt_gauss2D.Process(Single(L_cmp), NULL);\n        Image *img_sigma1_sigma2 = flt_gauss2D.Process(Single(&img_ori_cmp), NULL);\n\n        if(C0 > 0.0f && C1 > 0.0f) {\n            flt_ssim.update(C0, C1);\n\n            ImageVec src;\n            src.push_back(img_mu1);\n            src.push_back(img_mu2);\n            src.push_back(img_sigma1_sq);\n            src.push_back(img_sigma2_sq);\n            src.push_back(img_sigma1_sigma2);\n\n            ssim_map = flt_ssim.Process(src, ssim_map);\n\n            if(ssim_map != NULL) {\n                ssim_map->getMeanVal(NULL, &ssim_index);\n            }\n\n            stdVectorClear<Image>(src);\n        }\n\n        if(bAllocated) {\n            auto vec = Double(ori_d, cmp_d);\n            stdVectorClear<Image>(vec);\n        }\n\n        return ssim_map;\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_METRICS_SSIM_INDEX_HPP */\n\n"
  },
  {
    "path": "include/metrics/tmqi.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_TMQI_HPP\n#define PIC_METRICS_TMQI_HPP\n\n#include <math.h>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../image_vec.hpp\"\n\n#include \"../metrics/base.hpp\"\n\n#include \"../util/indexed_array.hpp\"\n#include \"../util/array.hpp\"\n#include \"../util/math.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../util/tile_list.hpp\"\n#include \"../util/string.hpp\"\n\n#include \"../algorithms/pyramid.hpp\"\n\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_gaussian_2d.hpp\"\n#include \"../filtering/filter_downsampler_2d.hpp\"\n#include \"../filtering/filter_down_pp.hpp\"\n\n#include \"../filtering/filter_tmqi.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The TMQI class\n */\nclass TMQI\n{\npublic:\n    float a, invA, alpha, beta;\n    std::vector<float> weights;\n    FilterLuminance flt_lum;\n    FilterGaussian2D flt_gauss2D;\n    FilterTMQI flt_tmqi;\n\n    /**\n     * @brief TMQI\n     */\n    TMQI()\n    {\n        a = 0.8012f;\n        invA = 1.0f - a;\n        alpha = 0.3046f;\n        beta = 0.7088f;\n\n        flt_gauss2D.update(1.5f);\n\n        weights.push_back(0.0448f);\n        weights.push_back(0.2856f);\n        weights.push_back(0.3001f);\n        weights.push_back(0.2363f);\n        weights.push_back(0.1333f);\n    }\n\n    /**\n     * @brief statisticalNaturalness\n     * @return\n     */\n    float statisticalNaturalness(Image *L_LDR)\n    {\n        if(L_LDR == NULL) {\n            return FLT_MAX;\n        }\n\n        if(L_LDR->channels != 1) {\n            return FLT_MAX;\n        }\n\n        float u;\n        L_LDR->getMeanVal(NULL, &u);\n\n        TileList tl(11, L_LDR->width, L_LDR->height);\n\n        float sig = 0.0f;\n        int n = int(tl.size());\n        for(int i = 0; i < n; i++) {\n            auto j = tl.getNext();\n\n            auto box = tl.getBBox(j);\n\n            float var_i;\n            L_LDR->getVarianceVal(NULL, &box, &var_i);\n\n            sig += sqrtf(var_i);\n        }\n\n        sig /= float(n);\n\n        float p_hat[] ={4.4f, 10.1f};\n        float beta_mode = (p_hat[0] - 1.0f) / (p_hat[0] + p_hat[1] - 2.0f);\n\n        float C_0 = betaPDF(beta_mode, p_hat[0], p_hat[1]);\n        float C = betaPDF(sig / 64.29f, p_hat[0], p_hat[1]);\n        float pc = C / C_0;\n\n        float mu_hat = 115.94f;\n        float sigma_hat = 27.99f;\n\n        float B = normalDistribution(u, mu_hat, sigma_hat);\n        float B_0 = normalDistribution(mu_hat, mu_hat, sigma_hat);\n\n        float pb = B / B_0;\n\n        return pb * pc;\n    }\n\n    /**\n     * @brief localStructuralFidelity\n     * @param L_HDR\n     * @param L_LDR\n     * @param S\n     * @param s_map\n     * @return\n     */\n    Image* localStructuralFidelity(Image *L_HDR, Image *L_LDR, float sf, float &S, Image *s_map = NULL)\n    {        \n        Image *img1 = L_HDR->clone();\n        Image *img2 = L_LDR->clone();\n\n        Image *mu1 = flt_gauss2D.Process(Single(img1), NULL);\n        Image *mu2 = flt_gauss2D.Process(Single(img2), NULL);\n\n        Image img12 = (*L_HDR) * (*L_LDR);\n\n        delete L_HDR;\n        delete L_LDR;\n\n        Image mu12 = (*mu1) * (*mu2);\n\n        mu1->applyFunction(square);\n        mu2->applyFunction(square);\n        img1->applyFunction(square);\n        img2->applyFunction(square);\n\n        Image *sigma1 = flt_gauss2D.Process(Single(img1), NULL);\n        *sigma1 -= *mu1;\n        delete mu1;\n        sigma1->applyFunction(sqrtf_s);\n\n        Image *sigma2 = flt_gauss2D.Process(Single(img2), NULL);\n        *sigma2 -= *mu2;\n        delete mu2;\n        sigma2->applyFunction(sqrtf_s);\n\n        Image *sigma12 = flt_gauss2D.Process(Single(&img12), NULL);\n        *sigma12 -= mu12;\n        mu12.release();\n\n        flt_tmqi.update(sf);\n\n        ImageVec vec = Triple(sigma1, sigma2, sigma12);\n        s_map = flt_tmqi.Process(vec, s_map);\n\n        s_map->getMeanVal(NULL, &S);\n\n        stdVectorClear<Image>(vec);\n        delete_s(img1);\n        delete_s(img2);\n\n        return s_map;\n    }\n\n    /**\n     * @brief structuralFidelity\n     * @param L_HDR\n     * @param L_LDR\n     * @return\n     */\n    float structuralFidelity(Image *L_HDR, Image *L_LDR)\n    {\n        float S = 1.0f;\n        float f = 32.0f;\n\n        Image *t_HDR = L_HDR;\n        Image *t_LDR = L_LDR;\n        for(uint i = 0; i < weights.size(); i++) {\n            f /= 2.0f;\n\n            if(t_HDR != NULL && t_LDR != NULL) {\n                float S_i;\n                localStructuralFidelity(t_HDR, t_LDR, f, S_i, NULL);\n\n                S *= powf(S_i, weights[i]);\n\n                int width = t_HDR->width >> 1;\n                int height = t_HDR->height >> 1;\n                t_HDR = FilterSampler2D::execute(t_HDR, NULL, width, height);\n                t_LDR = FilterSampler2D::execute(t_LDR, NULL, width, height);\n            } else {\n                break;\n            }\n        }\n\n        return S;\n    }\n\n    /**\n     * @brief execute\n     * @param img_HDR\n     * @param img_LDR\n     * @param Q\n     * @param N\n     * @param S\n     * @param tmqi_map\n     * @return\n     */\n    Image *execute(ImageVec imgIn, float &Q, float &N, float &S, Image *tmqi_map = NULL)\n    {\n        N = -1.0f;\n        S = -1.0f;\n        Q = -1.0f;\n\n        bool bCheckInput = ImageVecCheck(imgIn, 2) && ImageVecCheckSimilarType(imgIn);\n\n        if(!bCheckInput) {\n            return tmqi_map;\n        }\n\n        float max_img_LDR;\n        imgIn[1]->getMaxVal(NULL, &max_img_LDR);\n\n        if(max_img_LDR <= 1.0f) {\n            return tmqi_map;\n        }\n\n        Image *L_HDR = flt_lum.Process(Single(imgIn[0]), NULL);\n        Image *L_LDR = flt_lum.Process(Single(imgIn[1]), NULL);\n\n        float min_L_HDR, max_L_HDR;\n\n        L_HDR->getMinVal(NULL, &min_L_HDR);\n        L_HDR->getMaxVal(NULL, &max_L_HDR);\n\n        *L_HDR -= min_L_HDR;\n\n        float scale = (powf(2.0f, 32.0f) - 1.0f) / (max_L_HDR - min_L_HDR);\n        *L_HDR *= scale;\n\n        N = statisticalNaturalness(L_LDR);\n\n        S = structuralFidelity(L_HDR, L_LDR);\n\n        Q = a * powf(S, alpha) + invA * powf(N, beta);\n\n        return tmqi_map;\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_METRICS_TMQI_HPP */\n\n"
  },
  {
    "path": "include/metrics.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_METRICS_HPP\n#define PIC_METRICS_HPP\n\n#include \"metrics/base.hpp\"\n#include \"metrics/log_rmse.hpp\"\n#include \"metrics/m_psnr.hpp\"\n#include \"metrics/mae.hpp\"\n#include \"metrics/maximum_error.hpp\"\n#include \"metrics/mse.hpp\"\n#include \"metrics/psnr.hpp\"\n#include \"metrics/relative_error.hpp\"\n#include \"metrics/ssim_index.hpp\"\n#include \"metrics/tmqi.hpp\"\n\n#endif /* PIC_METRICS_HPP */\n\n"
  },
  {
    "path": "include/piccante.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://piccantelib.net\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n/*! \\mainpage Welcome to the PICCANTE documentation.\n *\n * \\section intro_sec Introduction\n *\n * <a href=\"http://piccantelib.net\">PICCANTE</a> is a C++11 image processing library aimed\n * to provide structures and functionalities for enabling\n * both High Dynamic Range (HDR) and standard imaging.\n *\n * \\subsection Usage\n *\n * To use <a href=\"http://piccantelib.net\">PICCANTE</a> simply set the wanted options and include \\c \"piccante.hpp\"\n *\n * The options are set with a  \\c #define and are:\n *\n * \\li \\c PIC_DEBUG used for debugging; it mostly enables some printf messages;\n * i.e. for warning when a computation succeeds or fails.\n * \\li \\c PIC_DISABLE_OPENGL disables the OpenGL support.\n * \\li \\c PIC_ENABLE_OPEN_EXR enables the support for the OpenEXR library. This may be useful to have\n * in the case .exr images are used. Note that you need to manually install OpenEXR on your developing maching in order\n * to enable this flag.\n * \\li \\c PIC_DISABLE_TINY_EXR disables the support for the reading EXR files using TinyEXR library (https://github.com/syoyo/tinyexr).\n * This may be useful to have in the case .exr images are used. Note that TinyEXR is already bundled into Piccante (include/externals).\n * \\li \\c PIC_DISABLE_STB disables the use of STB for reading/writing PNG and JPEG files (https://github.com/nothings/stb).\n * If it is not defined, picccante.hpp searchs for STB in \"../../stb\"\n * \\li \\c PIC_DISABLE_STB_LOCAL disables the use of local STB (i.e., placed in \"../../stb\")\n *\n * Note that when using Eigen types and standard containters, if you do not align containters, a good practice is to enable the following #define:\n * \\li \\c EIGEN_DONT_VECTORIZE\n * \\li \\c EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT\n *\n * If you want to use your Eigen version you need to the add the following #define:\n * \\li \\c PIC_EIGEN_NOT_BUNDLED\n *\n * \\section descr_sec Modules\n *\n * <a href=\"http://piccantelib.net\">PICCANTE</a> is a modular library with different modules. The main classes are\n * pic::Image and pic::Histogram.\n * \\li \\c pic::Image is the base class for managing an image. Pixels are stored\n * in an array of interleaved channels float values; i.e. pic::Image::data.\n * Pixels are stored as float values, because the library is meant mostly for accurate and HDR\n * imaging processing. This class provides standard functions for extracting\n * image statistics (e.g. maximum value, minimum value, mean value, etc.), image operators\n * (e.g. add, sub, mul, div, etc.) and memory management functions (e.g. allocation, cloning, etc.).\n * Note that this class supports multi-channels (e.g. alpha channel) and temporal/volumetric images.\n * It also provides an I/O interface for reading different file formats (ppm, pgm, pbm, bmp, tga, hdr, pfm, etc.)\n * natively in Piccante and through other optional external libraries (e.g. OpenEXR and QT).\n * \\li \\c pic::Histogram is a class for creating, managing, and processing LDR/HDR image histograms.\n *\n * \\subsection filters_module Filtering\n *\n * The main class of this module is pic::Filter. This is a base class for managing\n * a filter; it provides mechanisms for multi-threading, memory allocation, and so on.\n * Typically, a filter in <a href=\"http://piccantelib.net\">PICCANTE</a> can have multiple pic::Image images as input, imgIn,\n * and a single output, imgOut.\n * Many image filters are implemented in <a href=\"http://piccantelib.net\">PICCANTE</a> susch as: linear filters\n * (e.g. Gaussian, gradient based, DCT, etc.), non-linear filters\n * (e.g. bilateral, anisotropic diffusion, guided, median, etc.), and image transforms\n * (e.g. warping).\n *\n * \\subsection algo_module Algorithms\n *\n * This module contains high-level imaging functionalities such as\n * Laplacian/Gaussian pyramids, Push-pull, a simple Poisson solver, SuperPixels (SLIC),\n * a simple gradient based demosacing method, live-wire counturing, Grow-Cut segmentation, etc.\n * This module provides classes and functions for HDR imaging such as a class for\n * merging LDR images at different exposures, a class for estimating a camera response function (CRF), etc.\n *\n * \\subsection colors_module Colors\n *\n * This module provides classes and methods for editing, processing\n * and converting colors.\n * Supported color spaces:\n *\n * For example, the class pic::Color3 provides a basic type for three color\n * components representations. This can be useful for some applications\n * such as a 3D renderer.\n *\n * \\subsection io_module Input and Output\n *\n * This module provides functions for reading and writing images natively in different\n * file formats such as:\n * \\li \\c BMP: Windows bitmap file; 24-bit color images are only supported.\n * \\li \\c HDR: Greg Ward's RGBE format.\n * \\li \\c PGM: Portable Gray Map images; greyscale images.\n * \\li \\c PPM: Portable Pixel Map images; color images.\n * \\li \\c PFM: Portable Float Map images; HDR color images.\n * \\li \\c TGA: targa file; 24-bit color images are only supported.\n * \\li \\c TMP: a dump of the pic::Image data.\n * \\li \\c VOL: a volumetric format for rendering; 32-bit per voxel.\n *\n * The module provides an interface for OpenEXR, but it requires\n * either the linking with the OpenEXR library (see <a href=\"http://www.openexr.com\">the official website</a>)\n * or the use of TinyEXR (see <a href=\"https://github.com/syoyo/tinyexr\"> the official website</a>):\n * \\li \\c EXR: ILM's OpenEXR format; HDR color images at 16-bit per component.\n *\n * In addition, the module provides an interface for STB, which is a library for reading/writing LDR images. This\n * library is required for reading/writing JPEG and PNG files. This can be found at its <a href=\"https://github.com/nothings/stb\">official website</a>.\n *\n * \\subsection metrics_module Metrics\n *\n * This module provides classic objective metrics for measuring differences in images.\n * Several metrics are provided such as: PSNR, mPSNR (for HDR images), TMQI (for tone mapped images), SSIM, RMSE,\n * logRMSE (for HDR images), maximum error, relative error, etc. This metrics can be applied to HDR images using PU encoding.\n *\n * \\subsection ps_module Point Samplers\n *\n * This module provides structures and functions for generating points' set in n-dimensions using\n * different distributions such as: random, stratified random, regular, Poisson-disk, etc.\n * Points generated with such distributions may be useful for filtering algorithms.\n *\n * \\subsection is_module Image Samplers\n *\n * This module provides methods for sampling 2D and 3D images using different filters\n * such as: nearest neighbors filter, bilinear filter, bi-cubic filter, Gaussian filter,\n * etc.\n *\n * \\subsection tm_module Tone Mapping\n *\n * This module provides tone mapping operators (TMOs) for reducing the dynamic\n * range in HDR images. Several TMOs are present such as: Ward Histogram Adjustment,\n * Reinhard Photographic Tone Reproduction Operator, Lischinski Improved Photographic Tone\n * Reproduction Operator, Drago TMO, Banterle Hybrid TMO, Schlick TMO, Tumblin TMO, Ward Global TMO,\n * Raman TMO, Durand and Dorsey TMO, etc.\n *\n * \\subsection fm_module Features and Matching\n *\n * This module provides classes and functions for extracting 2D features from 2D images,\n * and matching the extracted features. This may be useful for aligning images for different\n * tasks such as: HDR exposures stack alignment, generation of panoramas, etc.\n * Different features can be extracted and matched:\n * \\li \\c Corners (Key-point): SUSAN, Harris' method, and FAST.\n * \\li \\c Edges: Canny's method, and Ward's MTB.\n * \\li \\c Key-point descriptors: BRIEF, ORB, and LUCID.\n *\n *  \\subsection cv_module Computer Vision\n *\n * This module provides classes and functions for Computer Vision tasks such as\n * checker board extraction, computation of the Essential matrix, computation of the Fundamental Matrix,\n * estimation of homographies, and triangulation.\n *\n * \\subsection gl_module OpenGL\n * This module provides GPU acceleration for some functionalities of PICCANTE through OpenGL.\n * In particular, the module uses OpenGL 4.0 Core profile only, and it is independent from OpenGL\n * loading extensions libraries; users are free to use their favourite ones.\n * Note that when using OpenGL and QT together; QT will load OpenGL functions by default\n * in order to avoid clashes.\n * In the examples (folder “examples”), we generated .h and .c files for loading OpenGL extensions\n * using glLoadGen. This is meant for learning purposes only; we do not want to force users to use\n * it; e.g. GLEW or other libraries can be employed instead.\n *\n * \\subsection utils_module Utilities\n *\n * This module provides different utilies for manipulating strings,\n * arrays, indexed arrays, math functions, 2D arrays, vectors, etc.\n *\n */\n\n#ifndef PIC_PICCANTE_HPP\n#define PIC_PICCANTE_HPP\n\n#ifdef _MSC_VER\n//we are using windows\n    #define PIC_WIN32\n    #ifndef NOMINMAX\n        #define NOMINMAX\n    #endif\n#elif __APPLE__\n    //we are using mac os x\n    #define PIC_MAC_OS_X\n#else\n    // we assume that we are using a UNIX system\n    #define PIC_UNIX\n#endif\n\n//Mac OS X\n#ifdef PIC_MAC_OS_X\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wunused-variable\"\n#pragma clang diagnostic ignored \"-Wunused-parameter\"\n#pragma clang diagnostic ignored \"-Wconversion\"\n#pragma clang diagnostic ignored \"-Wunknown-pragmas\"\n#pragma clang diagnostic ignored \"-Woverloaded-virtual\"\n#pragma clang diagnostic ignored \"-Wdelete-non-virtual-dtor\"\n#pragma clang diagnostic ignored \"-Wsign-compare\"\n#pragma clang diagnostic ignored \"-Wformat\"\n#endif\n\n//Win32\n#ifdef PIC_WIN32\n\n#pragma warning(disable:4100)\n#pragma warning(disable:4146)\n\n#ifndef _CRT_SECURE_NO_DEPRECATE\n#define _CRT_SECURE_NO_DEPRECATE\n#endif\n\n#ifndef _CRT_SECURE_NO_WARNINGS\n#define _CRT_SECURE_NO_WARNINGS\n#endif\n\n#include <windows.h>\n#include <winuser.h>\n#include <vfw.h>\n#include <tchar.h>\n#include <direct.h>\n#include <mmsystem.h>\n#define strcasecmp stricmp\n#pragma comment( lib, \"Winmm\" )\n#pragma comment( lib, \"vfw32\" )\n#endif\n\n// base stuff\n#include \"base.hpp\"\n#include \"image.hpp\"\n#include \"image_vec.hpp\"\n#include \"histogram.hpp\"\n\n// sub dirs\n#include \"algorithms.hpp\"\n#include \"colors.hpp\"\n#include \"features_matching.hpp\"\n#include \"filtering.hpp\"\n#include \"gl.hpp\"\n#include \"image_samplers.hpp\"\n#include \"io.hpp\"\n#include \"metrics.hpp\"\n#include \"point_samplers.hpp\"\n#include \"tone_mapping.hpp\"\n#include \"util.hpp\"\n#include \"computer_vision.hpp\"\n\n#include \"JNI.hpp\"\n\n#ifdef PIC_MAC_OS_X\n#pragma clang diagnostic pop\n#endif\n\n#endif /* PIC_PICCANTE_HPP */\n\n"
  },
  {
    "path": "include/point_samplers/sampler_bridson.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_POINT_SAMPLERS_SAMPLER_BRIDSON_HPP\n#define PIC_POINT_SAMPLERS_SAMPLER_BRIDSON_HPP\n\n#include <math.h>\n#include <random>\n#include \"../util/math.hpp\"\n#include \"../util/vec.hpp\"\n\nnamespace pic {\n\n/**\n * @brief checkNeighborsBruteForce\n * @param samples\n * @param x\n * @param radius\n * @return\n */\ntemplate<unsigned int N>\nbool checkNeighborsBruteForce(std::vector< Vec<N, float> > &samples,\n                              Vec<N, float> x, float radius)\n{\n    float radius_sq = radius * radius;\n\n    for(unsigned int i = 0; i < samples.size(); i++) {\n        if(x.distanceSq(samples[i]) < radius_sq) {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n/**\n * @brief getBridsonSamples\n * @param m\n * @param radius\n * @param samples\n * @param kSamples\n */\ntemplate<unsigned int N>\nvoid getBridsonSamples(std::mt19937 *m, float radius, std::vector<float> &samples,\n                    int kSamples = 30)\n{\n    if(kSamples < 1) {\n        kSamples = 30;\n    }\n\n    //Step 0: Creating an N-grid\n//\tGrid<N> grid(0.999f * radius / sqrtf(float(N)));\n\n    //Step 1: Initial sample\n    Vec<N, float> x0 = randomPoint<N>(m);\n\n    std::vector< Vec<N, float> > vecSamples;\n    std::vector<int> activeList;\n\n    vecSamples.push_back(x0);\n    activeList.push_back(0);\n//\tgrid.setValue(0, x0);\n\n    //Step 2: active list\n    while(!activeList.empty()) {\n        int i = (*m)() % activeList.size();\n\n        int ind = activeList[i];\n\n        bool bCheckSuccess = false;\n        bool bFlag = true;\n\n        int j = 0;\n\n        while(bFlag) {\n            //create samples inside the annulus around sample_i\n            Vec<N, float> x = annulusSampling<N>(m, vecSamples[ind], radius);\n\n            //check if the generated sample is in the bounding box\n            if(insideVecBBox(x)) {\n                //check if the sample does not have neighbors in grid with distance radius\n                if(checkNeighborsBruteForce(vecSamples, x, radius)) {\n                    vecSamples.push_back(x);\n                    int value = int(vecSamples.size()) - 1;\n\n                    activeList.push_back(value);\n                    //                grid.setValue(value, x);\n                    bCheckSuccess = true;\n                }\n            }\n\n            j++;\n\n            bFlag = (j < kSamples) && (!bCheckSuccess);\n        }\n\n        if(!bCheckSuccess) { //removing i-th sample from the active list\n            if(activeList.size() > 1) {\n                activeList[i] = activeList.back();\n                activeList.pop_back();\n            } else {\n                activeList.pop_back();\n            }\n        }\n    }\n\n    for(unsigned int i = 0; i < vecSamples.size(); i++) {\n        Vec<N, float> x = vecSamples[i];\n\n        for(unsigned int k = 0; k < N; k++) {\n            samples.push_back(x[k]);\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_POINT_SAMPLERS_SAMPLER_BRIDSON_HPP */\n\n"
  },
  {
    "path": "include/point_samplers/sampler_dart_throwing.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_POINT_SAMPLERS_SAMPLER_DART_THROWING_HPP\n#define PIC_POINT_SAMPLERS_SAMPLER_DART_THROWING_HPP\n\n#include <random>\n\n#include \"../util/vec.hpp\"\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\nconst int CONST_DARTTHROWING = 5000;\n\n/**\n * @brief getDartThrowingSamples\n * @param m\n * @param radius2\n * @param nSamples\n * @param samples\n */\ntemplate<unsigned int N>\nvoid getDartThrowingSamples(std::mt19937 *m, float radius2, int nSamples,\n                         std::vector<float> &samples)\n{\n    float dist2, delta;\n    Vec<N, float> val;\n\n    int counter = 0;\n\n    while(counter < (nSamples * CONST_DARTTHROWING)) {\n        for(unsigned int j = 0; j < N; j++) {\n            val[j] = ( getRandom((*m)()) * 2.0f - 1.0f);\n        }\n\n        bool bFlag = true;\n\n        for(unsigned int i = 0; i < samples.size(); i += N) {\n            dist2 = 0.0f;\n\n            for(unsigned int j = 0; j < N; j++) {\n                delta = val[j] - samples[i + j];\n                dist2 += delta * delta;\n            }\n\n            bFlag = dist2 >= radius2;\n\n            if(!bFlag) {\n                break;\n            }\n        }\n\n        if(bFlag) {\n            if(val.lengthSq() <= 1.0f) {\n                for(unsigned int j = 0; j < N; j++) {\n                    samples.push_back(val[j]);\n                }\n            }\n        }\n\n        counter++;\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_POINT_SAMPLERS_SAMPLER_DART_THROWING_HPP */\n\n"
  },
  {
    "path": "include/point_samplers/sampler_monte_carlo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_POINT_SAMPLERS_SAMPLER_MONTE_CARLO_HPP\n#define PIC_POINT_SAMPLERS_SAMPLER_MONTE_CARLO_HPP\n\n#include <random>\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/**\n * @brief getMonteCarloSamples\n * @param m\n * @param nSamples\n * @param samples\n */\ntemplate <unsigned int N> PIC_INLINE\nvoid getMonteCarloSamples(std::mt19937 *m, int nSamples, std::vector<float> &samples)\n{\n    for(int i = 0; i < nSamples; i++) {\n        for(unsigned int j = 0; j < N; j++) {\n            float val = getRandom((*m)()) * 2.0f - 1.0f;\n            samples.push_back(val);\n        }\n    }\n}\n\n/**\n * @brief getMonteCarloStratifiedSamples\n * @param m\n * @param nSamples\n * @param samples\n */\ntemplate <unsigned int N> PIC_INLINE\nvoid getMonteCarloStratifiedSamples(std::mt19937 *m, int nSamples,\n                                 std::vector<float> &samples)\n{\n    int n = int(powf(float(nSamples), 1 / float(N))) + 1; //int(sqrtf(nSamples))+1;\n    float n_f = float(n);\n    nSamples = n;\n\n    for(unsigned int i = 1; i < N; i++) {\n        nSamples *= n;\n    }\n\n    for(int i = 0; i < nSamples; i++) {\n        int div = 1;\n\n        for(unsigned int j = 0; j < N; j++) {\n            int k = (i / div) % n;\n            float val = ((getRandom((*m)()) + k) / n_f) * 2.0f - 1.0f;\n            samples.push_back(val);\n            div *= n;\n        }\n    }\n}\n\n/**\n * @brief getPatternMethodSampler\n * @param nSamples\n * @param samples\n */\ntemplate <unsigned int N> PIC_INLINE\nvoid getPatternMethodSamples(int nSamples, std::vector<float> &samples)\n{\n    int n = int(powf(float(nSamples), 1 / float(N))) + 1; //int(sqrtf(nSamples))+1;\n    nSamples = n;\n\n    for(unsigned int i = 1; i < N; i++) {\n        nSamples *= n;\n    }\n\n    for(int i = 0; i < nSamples; i++) {\n        int div = 1;\n\n        for(unsigned int j = 0; j < N; j++) {\n            int k = ((i / div)) % n;\n            float val = (float(k) / float(n)) * 2.0f - 1.0f;\n            samples.push_back(val);\n            div *= n;\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_POINT_SAMPLERS_SAMPLER_MONTE_CARLO_HPP */\n\n"
  },
  {
    "path": "include/point_samplers/sampler_random.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_POINT_SAMPLERS_SAMPLER_RANDOM_HPP\n#define PIC_POINT_SAMPLERS_SAMPLER_RANDOM_HPP\n\n#include <vector>\n#include <set>\n\n#include <iostream>\n#include <fstream>\n#include <random>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../util/math.hpp\"\n#include \"../util/point_samplers.hpp\"\n\n#include \"../point_samplers/sampler_monte_carlo.hpp\"\n#include \"../point_samplers/sampler_dart_throwing.hpp\"\n#include \"../point_samplers/sampler_bridson.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The RandomSampler class\n */\ntemplate <unsigned int N>\nclass RandomSampler\n{\nprotected:\n    SAMPLER_TYPE type;\n    std::mt19937 *m;\n    std::set<int> track;\n\npublic:\n    //Samples\n    std::vector<float>\tsamples;\n    std::vector<int>\tsamplesR;\n\n    //Boundaries for each level\n    std::vector<int>\tlevels;\n    std::vector<int>\tlevelsR;\n\n    Vec<N, int> window;\n    int nSamples;\n\n    /**\n     * @brief RandomSampler\n     */\n    RandomSampler()\n    {\n\n    }\n\n    /**\n     * @brief RandomSampler\n     * @param type\n     * @param window\n     * @param nSamples\n     * @param nLevels\n     */\n    RandomSampler(SAMPLER_TYPE type, Vec<N, int> window, int nSamples, int nLevels, unsigned int seed);\n\n    /**\n     * @brief update\n     * @param type\n     * @param window\n     * @param nSamples\n     * @param nLevels\n     */\n    void update(SAMPLER_TYPE type, Vec<N, int> window, int nSamples, int nLevels);\n\n    /**\n     * @brief render2Int\n     */\n    void render2Int();\n\n    /**\n     * @brief wrap\n     * @param alpha\n     */\n    void wrap(float alpha);\n\n    /**\n     * @brief cutRescale\n     * @param cutDim\n     */\n    void cutRescale(unsigned int cutDim);\n\n    /**\n     * @brief getSamplesPerLevel\n     * @param level\n     * @return\n     */\n    int getSamplesPerLevel(int level);\n\n    /**\n     * @brief getSampleAt\n     * @param level\n     * @param i\n     * @param x\n     * @param y\n     */\n    void getSampleAt(int level, int i, int &x, int &y);\n\n    /**\n     * @brief Write\n     * @param name\n     * @param level\n     */\n    void Write(std::string name, int level);\n\n    /**\n     * @brief generateFigureRS\n     * @param nameOut\n     * @param type\n     * @param window\n     * @param nSamples\n     * @param nLevels\n     */\n    static void generateFigureRS(std::string nameOut, SAMPLER_TYPE type, int window,\n                                 int nSamples, int nLevels)\n    {\n        Vec<2, int> w = Vec<2, int>(window, window);\n        RandomSampler<2> *p2Ds = new RandomSampler<2>(type, w, nSamples, nLevels, 0);\n\n        for(int i = 0; i < p2Ds->levelsR.size(); i++) {\n            std::string str = nameOut;\n            std::stringstream sstr;\n            sstr << i;\n            str = str + sstr.str() + \".pfm\";\n            p2Ds->Write(str, i);\n        }\n    }\n\n    /**\n     * @brief Generate\n     * @param type\n     * @param window\n     */\n    static void Generate(SAMPLER_TYPE type, int window)\n    {\n        int c = 1;\n\n        for(int i = 1; i <= 5; i++) {\n            RandomSampler<N> *p2Ds = new RandomSampler<N>(type, window * c, window * c,\n                    1); //2*c,1);\n            printf(\"Samples expected: %d \\t Real Samples: %d\\n\", (window * 2)*c,\n                   p2Ds->samplesR.size() / N);\n            std::string str = \"test_poisson_sampler_\";\n            std::stringstream sstr;\n            sstr << i;\n            str = str + sstr.str() + \".pfm\";\n            p2Ds->Write(str, 0);\n            c *= 2;\n        }\n    }\n};\n\ntemplate <unsigned int N> PIC_INLINE RandomSampler<N>::RandomSampler(\n    SAMPLER_TYPE type, Vec<N, int> window, int nSamples, int nLevels, unsigned int seed)\n{\n    m = new std::mt19937(seed);\n    update(type, window, nSamples, nLevels);\n}\n\ntemplate <unsigned int N> PIC_INLINE void RandomSampler<N>::cutRescale(\n    unsigned int cutDim)\n{\n    if(cutDim >= N) {\n#ifdef PIC_DEBUG\n        printf(\"cutRescale: not cuts.\\n\");\n#endif\n        return;\n    }\n\n    float cutValue = float(window[cutDim]) / float(window[0]);\n\n#ifdef PIC_DEBUG\n    printf(\"CutSize: %f\\n\", cutValue);\n#endif\n\n    std::vector<float> tmpCutSamples;\n    std::vector<int> tmpCutLevels;\n\n    int prevCutSamples = 0;\n\n    for(unsigned int i = 0; i < levels.size(); i++) {\n        int start, end;\n\n        if(i == 0) {\n            start = 0;\n        } else {\n            start = levels[i - 1];\n        }\n\n        end = levels[i];\n\n        for(int j = start; j < end; j += N) {\n            //cut\n            if(fabsf(samples[j + cutDim]) <= cutValue) {\n                //rescale\n                samples[j + cutDim] /= cutValue;\n\n                for(unsigned int k = 0; k < N; k++) {\n                    tmpCutSamples.push_back(samples[j + k]);\n                }\n            }\n        }\n\n        int tmpCutSamples_size = int(tmpCutSamples.size());\n        if(prevCutSamples != tmpCutSamples_size) {\n            tmpCutLevels.push_back(int(tmpCutSamples.size()));\n            prevCutSamples = int(tmpCutSamples.size());\n        }\n    }\n\n    samples.clear();\n    levels.clear();\n\n    samples.insert(samples.begin(), tmpCutSamples.begin(), tmpCutSamples.end());\n    levels.insert(levels.begin(), tmpCutLevels.begin(), tmpCutLevels.end());\n}\n\ntemplate <unsigned int N> PIC_INLINE void RandomSampler<N>::wrap(float alpha)\n{\n    float x, y, ang, r, r2;\n\n    for(int i = 0; i < samples.size(); i += 2) {\n        x = samples[i];\n        y = samples[i + 1];\n        ang = atan2f(y, x);\n        r = sqrtf(x * x + y * y);\n        r2 = powf(r, alpha);\n        samples[i]   = (r2 * cosf(ang));\n        samples[i + 1] = (r2 * sinf(ang));\n    }\n}\n\ntemplate <unsigned int N> PIC_INLINE void RandomSampler<N>::update(\n    SAMPLER_TYPE type, Vec<N, int> window, int nSamples, int nLevels)\n{\n    //Resetting vectors\n    samples.clear();\n    samplesR.clear();\n    levels.clear();\n    levelsR.clear();\n\n    nSamples = MAX(nSamples, 1);\n\n    this->type = type;\n    this->window = window;\n    this->nSamples = nSamples;\n\n    float radius = PoissonRadius(nSamples);\n\n    for(int i = 0; i < nLevels; i++) {\n        float factor = powf(2.0f, float(i));\n        float tmpRadius = radius * factor;\n\n        switch(type) {\n        case ST_BRIDSON:\n            getBridsonSamples< N >(m, tmpRadius, samples);\n            break;\n\n        case ST_DARTTHROWING:\n            getDartThrowingSamples< N >(m, tmpRadius * tmpRadius, nSamples, samples);\n            break;\n\n        case ST_MONTECARLO:\n            getMonteCarloSamples< N >(m, nSamples, samples);\n            break;\n\n        case ST_MONTECARLO_S:\n            getMonteCarloStratifiedSamples< N >(m, nSamples, samples);\n            break;\n\n        case ST_PATTERN:\n            getPatternMethodSamples< N >(nSamples, samples);\n            break;\n        }\n\n        levels.push_back(int(samples.size()));\n    }\n\n    //generate integer addresses\n    cutRescale(2);\n    render2Int();\n}\n\ntemplate <unsigned int N>  PIC_INLINE void RandomSampler<N>::render2Int()\n{\n    if(samplesR.size() > 0 || samples.size() > 0) {\n        samplesR.clear();\n        levelsR.clear();\n        track.clear();\n    }\n\n    Vec<N, float> window_f;\n\n    for(unsigned int i = 0; i < N; i++) {\n        window_f[i] = float(window[i]);\n    }\n\n    int x, coord;\n\n    //int prevSamplesR = 0;\n    for(uint i = 0; i < levels.size(); i++) {\n        int start, end;\n\n        if(i == 0) {\n            start = 0;\n        } else {\n            start = levels[i - 1];\n        }\n\n        end = levels[i];\n\n        for(int j = start; j < end; j += N) {\n            coord = 0;//rounding\n\n            for(unsigned int k = 0; k < N; k++) {\n                x = int(lround(samples[j + k] * window_f[k]));\n                coord += x * powint(window[k], k);\n            }\n\n            //Is the value in the track list?\n            if(track.find(coord) == track.end()) {\n                track.insert(coord);\n\n                for(unsigned int k = 0; k < N; k++) { //final rounding\n                    x = int(lround(samples[j + k] * window_f[k]));\n                    samplesR.push_back(x);\n                }\n            }\n        }\n\n        levelsR.push_back(int(samplesR.size()));\n    }\n\n#ifdef PIC_DEBUG\n    printf(\"render2Int: Original: %d \\t Rendered: %d\\n\", int(samples.size() / N),\n           int(track.size()));\n#endif\n}\n\ntemplate <unsigned int N>PIC_INLINE void RandomSampler<N>::Write(\n    std::string name, int level)\n{\n    Image img(1, window[0] * 2 + 1, window[1] * 2 + 1, 1);\n    img.setZero();\n\n    int start, end;\n\n    if(level == 0) {\n        start = 0;\n    } else {\n        start = levelsR[level - 1];\n    }\n\n    end = levelsR[level];\n\n    int x, y;\n\n    for(int i = start; i < end; i += N) {\n        x = samplesR[i    ] + window[0];\n        y = samplesR[i + 1] + window[1];\n        img.data[y * img.width + x] += 1.0;\n    }\n\n    img.Write(name);\n}\n\ntemplate <unsigned int N> PIC_INLINE int RandomSampler<N>::getSamplesPerLevel(int level)\n{\n    if(level<0) {\n        return -1;\n    }\n\n    if(level == 0) {\n        return (levelsR[level] / N);\n    } else {\n        return ( levelsR[level] - levelsR[level - 1]) / N;\n    }\n}\n\ntemplate <unsigned int N> PIC_INLINE void RandomSampler<N>::getSampleAt(int level, int i, int &x, int &y)\n{\n    int start, end;\n\n    if(level == 0) {\n        start = 0;\n    } else {\n        start = levelsR[level - 1];\n    }\n\n    end = levelsR[level];\n\n    i *= int(N);\n    i = CLAMPi(i + start, start, end-1);\n\n    x = samplesR[i    ] + window[0];\n    y = samplesR[i + 1] + window[1];\n}\n\ntemplate <unsigned int N>\nPIC_INLINE void ConvertVectorToPlus1(std::vector<RandomSampler<N> > &rsVec,\n                                     RandomSampler < N + 1 > &rsOut)\n{\n    //Copy data\n    int halfSize = rsVec.size() / 2;\n\n    for(int i = -halfSize; i <= halfSize; i++) {\n        for(int k = 0; k < rsVec[i].samplesR.size(); k += N) {\n            for(int l = 0; l < N; l++) {\n                rsOut.samplesR.push_back(rsVec[i].samplesR[k + l]);\n            }\n\n            rsOut.samplesR.push_back(i);\n        }\n    }\n\n    //Window assignment\n    Vec < N + 1, int > window;\n\n    for(int i = 0; i < N; i++) {\n        window[i] = rsVec[0].window[i];\n    }\n\n    window[N] = halfSize;\n    rsOut.window = window;\n}\n\n\n\n} // end namespace pic\n\n#endif /* PIC_POINT_SAMPLERS_SAMPLER_RANDOM_HPP */\n"
  },
  {
    "path": "include/point_samplers/sampler_random_m.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_POINT_SAMPLERS_SAMPLER_RANDOM_M_HPP\n#define PIC_POINT_SAMPLERS_SAMPLER_RANDOM_M_HPP\n\n#include <random>\n\n#include \"../base.hpp\"\n#include \"../util/math.hpp\"\n\n#include \"../point_samplers/sampler_random.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The MRSamplers class\n */\ntemplate<unsigned int N>\nclass MRSamplers\n{\nprotected:\n    RandomSampler<N> **samplers;\n    int nSamplers;\n    int oldSamples;\n    Vec<N, int> oldWindow;\n    SAMPLER_TYPE type;\n\npublic:\n    int nLevels;\n\n    /**\n     * @brief MRSamplers\n     */\n    MRSamplers();\n\n    /**\n     * @brief MRSamplers\n     * @param type\n     * @param window\n     * @param nSamples\n     * @param nLevels\n     * @param nSamplers\n     */\n    MRSamplers(SAMPLER_TYPE type, Vec<N, int> window, int nSamples, int nLevels,\n               int nSamplers);\n\n    /**\n     * @brief update\n     * @param window\n     * @param nSamples\n     * @return\n     */\n    bool update(Vec<N, int> window, int nSamples);\n\n    /**\n     * @brief getSampler gets a sampler at a given level\n     * @param m\n     * @return\n     */\n    RandomSampler<N> *getSampler(std::mt19937 *m);\n\n    /**\n     * @brief Write saves into an existing file\n     * @param name\n     * @return\n     */\n    bool Write(std::string name);\n\n    /**\n     * @brief Read\n     * @param name\n     * @return\n     */\n    bool Read(std::string name);\n};\n\ntemplate <unsigned int N>\nPIC_INLINE MRSamplers<N>::MRSamplers()\n{\n    samplers = NULL;\n    nSamplers = -1;\n    oldWindow = 0;\n    oldSamples = -1;\n    nLevels = -1;\n}\n\ntemplate <unsigned int N>\nPIC_INLINE MRSamplers<N>::MRSamplers(\n    SAMPLER_TYPE type, Vec<N, int> window, int nSamples, int nLevels, int nSamplers)\n{\n    this->type = type;\n    this->nSamplers = nSamplers;\n    this->nLevels = nLevels;\n    oldSamples = nSamples;\n    oldWindow = window;\n\n    samplers = new RandomSampler< N > *[nSamplers];\n\n    #pragma omp parallel for\n\n    for(int i = 0; i < nSamplers; i++) {\n        samplers[i] = new RandomSampler< N >(type, window, nSamples, nLevels, 0);\n    }\n}\n\ntemplate <unsigned int N>\nPIC_INLINE bool MRSamplers<N>::update(Vec<N, int> window, int nSamples)\n{\n    if(window.equal(oldWindow) && (oldSamples == nSamples)) {\n        return false;\n    }\n\n    //#pragma omp parallel for\n    for(int i = 0; i < nSamplers; i++) {\n        samplers[i]->update(type, window, nSamples, nLevels);\n    }\n\n    oldWindow = window;\n    oldSamples = nSamples;\n    return true;\n}\n\ntemplate <unsigned int N>\nPIC_INLINE RandomSampler<N> *MRSamplers<N>::getSampler(std::mt19937 *m)\n{\n    return samplers[(*m)() % nSamplers];\n}\n\ntemplate <unsigned int N>\nPIC_INLINE bool MRSamplers<N>::Read(std::string name)\n{\n    std::ifstream file;\n\n    file.open(name.c_str(), std::ios::in);\n\n    if(!file.is_open()) {\n        return false;\n    }\n\n    std::string tmp;\n    file >> tmp;\n    file >> nSamplers;\n\n    file >> tmp;\n    file >> oldSamples;\n\n    file >> tmp;\n    file >> nLevels;\n\n    file >> tmp;\n    for(unsigned int i = 0; i < N; i++) {\n        file >> oldWindow[i];\n    }\n\n    if(nSamplers < 1) {\n        file.close();\n\n        return false;\n    }\n\n    delete[] samplers;\n\n    samplers = new RandomSampler<N> *[nSamplers];\n\n    for(int i = 0; i < nSamplers; i++) {\n        samplers[i] = new RandomSampler<N>();\n        unsigned int samplesR = 0;\n\n        file >> tmp;\n        file >> samplesR;\n\n        int value;\n        for(unsigned int j=0; j<samplesR; j++) {\n            file >> value;\n            samplers[i]->samplesR.push_back(value);\n        }\n    }\n    /*\n    \n    int nSamplesR;\n    char tmp[512];\n    fscanf(file, \"%s\", tmp);\n    fscanf(file, \"%d\", &nSamplesR);\n\n    for(int i = 0; i < nSamplesR; i++) {\n        int tmpValue;\n        fscanf(file, \"%d\", &tmpValue);\n        samplesR.push_back(tmpValue);\n    }\n\n    levelsR.push_back(nSamplesR);**/\n\n\n    file.close();\n\n     return true;\n}\n\ntemplate <unsigned int N>\nPIC_INLINE bool MRSamplers<N>::Write(std::string name)\n{\n    std::ofstream file;\n\n    file.open(name.c_str(), std::ios::out);\n\n    if(!file.is_open()) {\n        return false;\n    }\n\n    //general parameters\n    file << \"nSamplers: \" << nSamplers << \" oldSamples: \" << oldSamples << \" nLevels: \" << nLevels << std::endl;\n\n    file << \"oldWindow: \";\n    for(unsigned int i = 0; i < N; i++) {\n        file << oldWindow[i] << \" \";\n    }\n    file << std::endl;\n\n    //write samplers\n    for(int i = 0; i < nSamplers; i++) {\n        RandomSampler< N > *rs = samplers[i];\n        //write samples\n        file << \"nSamplesR: \" << rs->samplesR.size() << std::endl;\n        for(unsigned int j=0; j< rs->samplesR.size(); j++) {\n            file << rs->samplesR[j] << \" \";\n        }\n        file << std::endl;\n    }\n\n    file.close();\n\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_POINT_SAMPLERS_SAMPLER_RANDOM_M_HPP */\n\n"
  },
  {
    "path": "include/point_samplers.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n\n#ifndef PIC_POINT_SAMPLERS_HPP\n#define PIC_POINT_SAMPLERS_HPP\n\n#include \"point_samplers/sampler_bridson.hpp\"\n#include \"point_samplers/sampler_dart_throwing.hpp\"\n#include \"point_samplers/sampler_monte_carlo.hpp\"\n#include \"point_samplers/sampler_random.hpp\"\n#include \"point_samplers/sampler_random_m.hpp\"\n\n#endif /* PIC_POINT_SAMPLERS_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/drago_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_DRAGO_TMO_HPP\n#define PIC_TONE_MAPPING_DRAGO_TMO_HPP\n\n#include \"../base.hpp\"\n\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_drago_tmo.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The DragoTMO class\n */\nclass DragoTMO: public ToneMappingOperator\n{\nprotected:\n    float Ld_Max, b;\n    FilterLuminance flt_lum;\n    FilterDragoTMO flt_drg;\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */    \n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        updateImage(imgIn[0]);\n\n        //compute luminance and its statistics\n        images[0] = flt_lum.Process(imgIn, images[0]);\n\n        float Lw_Max, Lw_a;\n        images[0]->getMaxVal(NULL, &Lw_Max);\n        images[0]->getLogMeanVal(NULL, &Lw_a);\n\n        //tone map\n        flt_drg.update(Ld_Max, b, Lw_Max, Lw_a);\n        imgOut = flt_drg.Process(Double(imgIn[0], images[0]), imgOut);\n\n        return imgOut;\n    }\n\npublic:\n\n    /**\n     * @brief DragoTMO\n     * @param Ld_Max\n     * @param b\n     */\n    DragoTMO(float Ld_Max = 100.0f, float b = 0.95f) : ToneMappingOperator()\n    {\n        images.push_back(NULL);\n        update(Ld_Max, b);\n    }\n\n    ~DragoTMO()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param Ld_Max\n     * @param b\n     */\n    void update(float Ld_Max = 100.0f, float b = 0.95f)\n    {\n        this->Ld_Max = Ld_Max;\n        this->b = b;\n\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        DragoTMO dtmo(100.0f, 0.95f);\n        return dtmo.Process(Single(imgIn), imgOut);\n    }\n};\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_DRAGO_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/durand_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_DURAND_TMO_HPP\n#define PIC_TONE_MAPPING_DURAND_TMO_HPP\n\n#include \"../base.hpp\"\n\n#include \"../util/string.hpp\"\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../algorithms/bilateral_separation.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The DurandTMO class\n */\nclass DurandTMO: public ToneMappingOperator\n{\npublic:\n\n    FilterLuminance flt_lum;\n    float target_contrast;\n\n    /**\n     * @brief DurandTMO\n     */\n    DurandTMO(float target_contrast = 5.0f)\n    {\n        images.push_back(NULL);\n        images.push_back(NULL);\n        images.push_back(NULL);\n        update(target_contrast);\n    }\n\n    ~DurandTMO()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param target_contrast\n     */\n    void update(float target_contrast = 5.0f)\n    {\n        if(target_contrast <= 0.0f) {\n            target_contrast = 5.0f;\n        }\n\n        this->target_contrast = target_contrast;\n    }\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        updateImage(imgIn[0]);\n\n        //luminance image\n        images[2] = flt_lum.Process(imgIn, images[2]);\n\n        //bilateral filter seperation\n        bilateralSeparation(images[2], images, -1.0f, 0.4f, true);\n\n        Image *base = images[0];\n        Image *detail = images[1];\n\n        float min_log_base, max_log_base;\n        base->getMinVal(NULL, &min_log_base);\n        base->getMaxVal(NULL, &max_log_base);\n\n        float compression_factor = log10fPlusEpsilon(target_contrast) / (max_log_base - min_log_base);\n        float log_absoulte = compression_factor * max_log_base;\n\n        *base *= compression_factor;\n        *base += detail;\n        *base -= log_absoulte;\n        base->applyFunction(powf10fMinusEpsilon);\n\n        *imgOut = *imgIn[0];\n        *imgOut *= base;\n        *imgOut /= images[2];\n\n        imgOut->removeSpecials();\n\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        DurandTMO dtmo(5.0f);\n        return dtmo.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_DURAND_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/exposure_fusion.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_EXPOSURE_FUSION_HPP\n#define PIC_TONE_MAPPING_EXPOSURE_FUSION_HPP\n\n#include \"../base.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../util/array.hpp\"\n#include \"../colors/saturation.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_laplacian.hpp\"\n#include \"../filtering/filter_exposure_fusion_weights.hpp\"\n\n#include \"../algorithms/pyramid.hpp\"\n\n#include \"../tone_mapping/get_all_exposures.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ExposureFusion class\n */\nclass ExposureFusion: public ToneMappingOperator\n{\nprotected:\n    FilterLuminance flt_lum;\n    FilterExposureFusionWeights flt_weights;\n\n    Pyramid *pW, *pI, *pOut;\n\n    /**\n     * @brief removeNegative\n     * @param x\n     * @return\n     */\n    static float removeNegative(float x)\n    {\n        return MAX(x, 0.0f);\n    }\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        if(imgIn.size() > 1) {\n            return ProcessAuxStack(imgIn, imgOut);\n        } else {\n            pic::ImageVec stack = getAllExposuresImages(imgIn[0]);\n\n            imgOut = ProcessAuxStack(stack, imgOut);\n\n            stdVectorClear<Image>(stack);\n\n            return imgOut;\n        }\n    }\n\n    /**\n     * @brief ProcessAuxStack\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *ProcessAuxStack(ImageVec imgIn, Image *imgOut)\n    {\n        uint n = uint(imgIn.size());\n\n        if(n < 2 || !ImageVecCheck(imgIn, -1)) {\n            return imgOut;\n        }\n\n        //compute weights values\n        int channels = imgIn[0]->channels;\n        int width = imgIn[0]->width;\n        int height = imgIn[0]->height;\n\n        updateImage(imgIn[0]);\n\n        if(images[2] == NULL) {//images[2] --> acc\n            images[2] = new Image(1, width, height, 1);\n        }\n\n        //compute weights values\n        *images[2] = 0.0f;\n        for(uint j = 0; j < n; j++) {\n            images[0] = flt_lum.Process(Single(imgIn[j]), images[0]);\n            images[1] = flt_weights.Process(Double(images[0], imgIn[j]), images[1]);\n\n            *images[2] += *images[1];\n        }\n\n        //accumulate into a Pyramid\n\n        releaseAux();\n\n        int limitLevel = 2;\n        pW = new Pyramid(width, height, 1, false, limitLevel);\n        pI = new Pyramid(width, height, channels, true, limitLevel);\n        pOut = new Pyramid(width, height, channels, true, limitLevel);\n\n        pOut->setValue(0.0f);\n\n        for(uint j = 0; j < n; j++) {\n            images[0] = flt_lum.Process(Single(imgIn[j]), images[0]);\n            images[1] = flt_weights.Process(Double(images[0], imgIn[j]), images[1]);\n\n            //normalization\n            *images[1] /= *images[2];\n\n            pW->update(images[1]);\n            pI->update(imgIn[j]);\n\n            pI->mul(pW);\n            pOut->add(pI);\n        }\n\n        //final result\n        imgOut = pOut->reconstruct(imgOut);\n\n        float *minVal = imgOut->getMinVal(NULL, NULL);\n        float *maxVal = imgOut->getMaxVal(NULL, NULL);\n\n        int ind;\n        float minV = Arrayf::getMin(minVal, imgOut->channels, ind);\n        float maxV = Arrayf::getMax(maxVal, imgOut->channels, ind);\n        *imgOut -= minV;\n        *imgOut /= (maxV- minV);\n\n        imgOut->applyFunction(removeNegative);\n\n        return imgOut;\n    }\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux()\n    {\n        pW = delete_s(pW);\n        pI = delete_s(pI);\n        pOut = delete_s(pOut);\n    }\n\npublic:\n\n    /**\n     * @brief ExposureFusion\n     * @param wC\n     * @param wE\n     * @param wS\n     */\n    ExposureFusion(float wC = 1.0f, float wE = 1.0f,\n                   float wS = 1.0f)\n    {\n        pW = NULL;\n        pI = NULL;\n        pOut = NULL;\n\n        flt_lum.update(LT_LUMA);\n        setToANullVector<Image>(images, 3);\n\n        update(wC, wE, wS);\n    }\n\n    ~ExposureFusion()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param wC\n     * @param wE\n     * @param wS\n     */\n    void update(float wC = 1.0f, float wE = 1.0f,\n                float wS = 1.0f)\n    {\n        flt_weights.update(wC, wE, wS);\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image* execute(Image *imgIn, Image *imgOut)\n    {\n        ExposureFusion ef(1.0f, 1.0f, 1.0f);\n        return ef.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief executeStack\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image* executeStack(ImageVec imgIn, Image *imgOut)\n    {\n        ExposureFusion ef(1.0f, 1.0f, 1.0f);\n        return ef.Process(imgIn, imgOut);\n    }\n};\n\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_EXPOSURE_FUSION_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/ferwerda_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_FERWERDA_TMO_HPP\n#define PIC_TONE_MAPPING_FERWERDA_TMO_HPP\n\n#include \"../base.hpp\"\n\n#include \"../util/array.hpp\"\n\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The FerwerdaTMO class\n */\nclass FerwerdaTMO: public ToneMappingOperator\n{\nprotected:\n    float Ld_Max, Ld_a, Lw_a;\n    FilterLuminance flt_lum;\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */    \n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        updateImage(imgIn[0]);\n\n        //compute luminance and its statistics\n        images[0] = flt_lum.Process(imgIn, images[0]);\n\n        if(Lw_a < 0.0f) {\n            float maxVal;\n            images[0]->getMaxVal(NULL, &maxVal);\n            Lw_a = maxVal / 2.0f;\n        }\n\n        float mC = Tp(Ld_a) / Tp(Lw_a);\n        float mR = Ts(Ld_a) / Ts(Lw_a);\n        float k = WalravenValetonK(Lw_a);\n\n        int channels = imgIn[0]->channels;\n        float *scale = new float[channels];\n\n        if(channels == 3) {\n            scale[0] = 1.05f;\n            scale[1] = 0.97f;\n            scale[2] = 1.27f;\n        } else {\n           Arrayf::assign(1.0f, scale, channels);\n        }\n\n        for(int i = 0; i < channels; i++) {\n            scale[i] *= (mR * k);\n        }\n\n        #pragma omp parallel for\n        for(int i = 0; i < imgIn[0]->size(); i += channels) {\n\n            int indexL = i / channels;\n\n            for(int j = 0; j < channels; j++) {\n                int index = i + j;\n                imgOut->data[index] = imgIn[0]->data[index] * mC +\n                                      images[0]->data[indexL] * scale[j];\n            }\n        }\n\n        //NOTE: this is done to have values in [0,1] and not in cd/m^2!\n        *imgOut /= Ld_Max;\n\n        return imgOut;\n    }\n\npublic:\n\n    /**\n     * @brief FerwerdaTMO\n     * @param Ld_Max\n     * @param Ld_a\n     * @param Lw_a\n     */\n    FerwerdaTMO(float Ld_Max = 100.0f, float Ld_a = 50.0f, float Lw_a = 50.0f) : ToneMappingOperator()\n    {\n        images.push_back(NULL);\n        update(Ld_Max, Ld_a, Lw_a);\n    }\n\n    ~FerwerdaTMO()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param Ld_Max\n     * @param Ld_a\n     * @param Lw_a\n     */\n    void update(float Ld_Max = 100.0f, float Ld_a = 50.0f, float Lw_a = 50.0f)\n    {\n        this->Ld_Max = Ld_Max > 0.0f ? Ld_Max : 100.0f;\n        this->Ld_a = Ld_a > 0.0f ? Ld_a : (this->Ld_Max / 2.0f);\n        this->Lw_a = Lw_a;\n    }\n\n    /**\n     * @brief Ts computes the gamma function used in Ferwerda TMO for Scotopic levels (rods' cells).\n     * @param x\n     * @return\n     */\n    static float Ts(float x)\n    {\n        float t = log10f(x);\n        float y;\n\n        if(t <= -3.94f) {\n            y = -2.86f;\n        } else {\n            if(t >= -1.44) {\n                y = t - 0.395f;\n            } else {\n                y = powf(0.405f * t + 1.6f, 2.18f) - 2.86f;\n            }\n        }\n\n        y = powf(10.0f, y);\n\n        return y;\n    }\n\n    /**\n     * @brief Tp computes the gamma function used in Ferwerda TMO for Photopic levels (cones' cells).\n     * @param x\n     * @return\n     */\n    static float Tp(float x)\n    {\n        float t = log10f(x);\n        float y;\n\n        if(t <= -2.6f) {\n            y = -0.72f;\n        } else {\n            if(t >= 1.9f) {\n                y = t - 1.255f;\n            } else {\n                y = powf(0.249f * t + 0.65f, 2.7f) - 0.72f;\n            }\n        }\n\n        y = powf(10.0f, y);\n\n        return y;\n    }\n\n    /**\n     * @brief WalravenValetonK\n     * @param Lw_a is the world adaptation luminance in cd/m^2\n     * @param sigma\n     * @return\n     */\n    static float WalravenValetonK(float Lw_a, float sigma = 100.0f)\n    {\n        float k = (sigma - Lw_a / 4.0f) / (sigma + Lw_a);\n        return (k > 0.0f) ?  k : 0.0f;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        FerwerdaTMO ftmo(200.0f, -1.0f, -1.0f);\n        return ftmo.Process(Single(imgIn), imgOut);\n    }\n};\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_FERWERDA_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/find_best_exposure.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_FIND_BEST_EXPOSURE_HPP\n#define PIC_TONE_MAPPING_FIND_BEST_EXPOSURE_HPP\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_simple_tmo.hpp\"\n#include \"../histogram.hpp\"\n\nnamespace pic {\n\n/**\n * @brief findBestExposureHistogram computes the best exposure value for an image, img,\n * @param img\n * @return It returns the exposure value in f-stops.\n */\nPIC_INLINE float findBestExposureHistogram(Image *img)\n{\n    if(img == NULL) {\n        return 0.0f;\n    }\n\n    if(!img->isValid()) {\n        return 0.0f;\n    }\n\n    Image *lum = NULL;\n\n    if(img->channels == 1) {\n        lum = img;\n    } else {\n        lum = FilterLuminance::execute(img, NULL, LT_CIE_LUMINANCE);\n    }\n\n    Histogram hist(lum, VS_LOG_2, 4096, 0);\n\n    std::vector<float> fstops = hist.exposureCovering(8);\n\n    if(img->channels != 1) {\n        delete lum;\n    }\n\n    return fstops[0];\n}\n\n/**\n * @brief findBestExposureMean\n * @param img\n * @return It returns the exposure value in f-stops.\n */\nPIC_INLINE float findBestExposureMean(Image *img, bool bMedian = false)\n{\n    if(img == NULL) {\n        return 0.0f;\n    }\n\n    if(!img->isValid()) {\n        return 0.0f;\n    }\n\n    Image *lum = NULL;\n\n    if(img->channels == 1) {\n        lum = img;\n    } else {\n        lum = FilterLuminance::execute(img, NULL, LT_CIE_LUMINANCE);\n    }\n\n    float lum_mean;\n    if(bMedian) {\n        lum->getMeanVal(NULL, &lum_mean);\n    } else {\n        lum->getMeanVal(NULL, &lum_mean);\n    }\n\n    float fstop = -log2f(lum_mean) - 1.0f;\n\n    if(img->channels != 1) {\n        delete lum;\n    }\n\n    return fstop;\n}\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_FIND_BEST_EXPOSURE_HPP */\n"
  },
  {
    "path": "include/tone_mapping/get_all_exposures.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_GET_ALL_EXPOSURES_HPP\n#define PIC_TONE_MAPPING_GET_ALL_EXPOSURES_HPP\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../histogram.hpp\"\n\n#include \"../util/math.hpp\"\n#include \"../util/indexed_array.hpp\"\n\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_simple_tmo.hpp\"\n\nnamespace pic {\n\n/**\n * @brief getMinMaxFstops computes the minimum and maximum f-stop values of an image.\n * @param imgIn is an image.\n * @param minFstop is the mininum f-stop of imgIn, output.\n * @param maxFstop is the maximum f-stop of imgIn, output.\n */\nPIC_INLINE void getMinMaxFstops(Image *imgIn, int &minFstop, int &maxFstop)\n{\n    if(imgIn == NULL) {\n        return;\n    }\n\n    Image *img_lum = NULL;\n\n    if(imgIn->channels == 1) {\n        img_lum = imgIn;\n    } else {\n        img_lum = FilterLuminance::execute(imgIn, NULL, LT_CIE_LUMINANCE);\n    }\n\n    int nData = img_lum->width * img_lum->height;\n\n    IntCoord coord;\n    IndexedArray<float>::findSimple(img_lum->data, nData, IndexedArray<float>::bFuncNotNeg, coord);\n\n    float commonMin = IndexedArray<float>::min(img_lum->data, coord);\n    float commonMax = IndexedArray<float>::max(img_lum->data, coord);\n\n    float tminFstop = log2f(commonMin);\n    float tmaxFstop = log2f(commonMax);\n\n    minFstop = int(lround(tminFstop));\n    maxFstop = int(lround(tmaxFstop));\n\n    int halfFstops = (maxFstop - minFstop + 1) >> 1;\n    minFstop = -halfFstops + 1;\n    maxFstop =  halfFstops - 1;\n\n    if(minFstop == maxFstop) {\n        minFstop--;\n        maxFstop++;\n    }\n\n    if(imgIn->channels != 1) {\n        delete img_lum;\n    }\n}\n\n/**\n * @brief getAllExposuresUniform computes all required exposure values for reconstructing the input image\n * using uniform sampling\n * @param imgIn is an input image\n * @return It returns an std::vector<float> with all f-stops values encoding imgIn\n */\nPIC_INLINE std::vector<float> getAllExposuresUniform(Image *imgIn)\n{\n    std::vector<float> ret;\n\n    int iMin, iMax;\n    getMinMaxFstops(imgIn, iMin, iMax);\n\n    for(int i = iMin; i <= iMax; i++) {\n        ret.push_back(float(i));\n    }\n\n    return ret;\n}\n\n/**\n * @brief getAllExposures computes all required exposure values for reconstructing the input image\n * using histogram sampling\n * @param imgIn is an input image\n * @return It returns an std::vector<float> with all exposure values encoding imgIn\n */\nPIC_INLINE std::vector<float> getAllExposures(Image *imgIn) {\n    std::vector<float> fstops;\n\n    if(imgIn == NULL) {\n        return fstops;\n    }\n\n    if(!imgIn->isValid()) {\n        return fstops;\n    }\n\n    Image *lum = NULL;\n\n    if(imgIn->channels == 1) {\n        lum = imgIn;\n    } else {\n        lum = FilterLuminance::execute(imgIn, NULL, LT_CIE_LUMINANCE);\n    }\n\n    Histogram m(lum, VS_LOG_2, 1024);\n    fstops = m.exposureCovering();\n\n    if(imgIn->channels != 1) {\n        delete lum;\n    }\n\n    return fstops;\n}\n\n/**\n * @brief getAllExposuresImages converts an image into a stack of images.\n * @param imgIn is an input image.\n * @param fstops a vector with fstops.\n * @param gamma is the gamma correction value for the output stack.\n * @return It returns an ImageVec of images which encode imgIn at different\n * exposure values.\n */\nPIC_INLINE ImageVec getAllExposuresImages(Image *imgIn, std::vector<float> &fstops, float gamma = 2.2f)\n{\n    ImageVec ret;\n    FilterSimpleTMO flt(gamma, 0.0f);\n\n    ImageVec input = Single(imgIn);\n\n    for(unsigned int i = 0; i < fstops.size(); i++) {\n        flt.update(gamma, fstops[i]);\n        Image *expo = flt.Process(input, NULL);\n\n        expo->exposure = powf(2.0f, fstops[i]);\n        expo->clamp(0.0f, 1.0f);\n\n        ret.push_back(expo);\n    }\n\n    return ret;\n}\n\n/**\n * @brief getAllExposuresImages converts an image into a stack of images.\n * @param imgIn is an input image.\n * @param gamma is the gamma correction value for the output stack.\n * @return It returns an ImageVec of images which encode imgIn at different\n * exposure values.\n */\nPIC_INLINE ImageVec getAllExposuresImages(Image *imgIn, float gamma = 2.2f)\n{\n    std::vector<float> fstops = getAllExposures(imgIn);\n    return getAllExposuresImages(imgIn, fstops, gamma);\n}\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_GET_ALL_EXPOSURES_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/hybrid_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_HYBRID_TMO_HPP\n#define PIC_TONE_MAPPING_HYBRID_TMO_HPP\n\n#include \"../algorithms/segmentation_tmo_approx.hpp\"\n#include \"../algorithms/pyramid.hpp\"\n#include \"../filtering/filter_drago_tmo.hpp\"\n#include \"../filtering/filter_sigmoid_tmo.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The HybridTMO class\n */\nclass HybridTMO\n{\nprotected:\n    Segmentation seg;\n    FilterDragoTMO fltDragoTMO;\n    FilterSigmoidTMO fltReinhardTMO;\n    Pyramid *pyrA, *pyrB, *pyrWeight;\n    float Ld_Max, b;\n\n    Image *imgDrago, *imgReinhard, *seg_map;\n\npublic:\n    /**\n     * @brief HybridTMO\n     */\n    HybridTMO()\n    {\n        imgDrago = NULL;\n        imgReinhard = NULL;\n        pyrA = NULL;\n        pyrB = NULL;\n        pyrWeight = NULL;\n        seg_map = NULL;\n\n        Ld_Max = 100.0f;\n        b = 0.95f;\n    }\n\n    /**\n     * @brief ReinhardApprox\n     * @param alpha1\n     * @param alpha2\n     */\n    void ReinhardApprox(float &alpha1, float &alpha2)\n    {\n        alpha1 = 1.0f / (2.0f * sqrtf(2.0f));\t//sigma_s\n        alpha2 = powf(1.6f, 9.0f); //sigma_r\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *execute(Image *imgIn, Image *imgOut)\n    {\n        if(imgIn == NULL) {\n            return NULL;\n        }\n\n        if(!imgIn->isValid()) {\n            return NULL;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = new Image(1, imgIn->width, imgIn->height, imgIn->channels);\n        }\n\n        //compute segmentation map\n        seg_map = seg.Process(imgIn, seg_map);\n\n        /*\t0 ---> Drago et al. 2003\n        \t1 ---> Reinhard et al. 2002\n        \tLumZone     = [-2, -1, 0, 1, 2, 3, 4];\n        \tTMOForZone =  [ 0,  0, 1, 0, 1, 0, 0];\t*/\n\n        int count[2];\n        count[0] = 0;\n        count[1] = 0;\n\n        for(int i = 0; i < seg_map->size(); i++) {\n            int indx = int(seg_map->data[i]);\n\n            if((indx == 2) || (indx == 4)) {\n                seg_map->data[i] = 1.0f;\n                count[1]++;\n            } else {\n                seg_map->data[i] = 0.0f;\n                count[0]++;\n            }\n        }\n\n#ifdef PIC_DEBUG\n        seg_map->Write(\"weight_map.pfm\");\n#endif\n\n        //check if we have different zones\n        int value = 10;\n\n        if(count[0] > 0 && count[1] > 0) {\n            value = 10;\n        }\n\n        if(count[0] > 0 && count[1] == 0) {\n            value = 0;\n        }\n\n        if(count[0] == 0 && count[1] > 0) {\n            value = 1;\n        }\n\n        switch(value) {\n        case 0: {\n            fltDragoTMO.Process(Single(imgIn), imgOut);\n        }\n        break;\n\n        case 1: {\n            fltReinhardTMO.Process(Single(imgIn), imgOut);\n        }\n        break;\n\n        case 10: {\n            //Drago TMO\n            imgDrago = fltDragoTMO.Process(Single(imgIn), imgDrago);\n\n            if(pyrA == NULL) {\n                pyrA = new Pyramid(imgDrago, true);\n            } else {\n                pyrA->update(imgDrago);\n            }\n\n            //Reinhard TMO\n            imgReinhard = fltReinhardTMO.Process(Single(imgIn), imgReinhard);\n\n            if(pyrB == NULL) {\n                pyrB = new Pyramid(imgReinhard, true);\n            } else {\n                pyrB->update(imgReinhard);\n            }\n\n            //compute blending weight\n            if(pyrWeight == NULL) {\n                pyrWeight = new Pyramid(seg_map, false);\n            } else {\n                pyrWeight->update(seg_map);\n            }\n\n            //blend\n            pyrA->blend(pyrB, pyrWeight);\n            pyrA->reconstruct(imgOut);\n        }\n        break;\n        }\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_HYBRID_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/lischinski_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_LISCHINSKI_TMO_HPP\n#define PIC_TONE_MAPPING_LISCHINSKI_TMO_HPP\n\n#include \"../base.hpp\"\n#include \"../util/math.hpp\"\n#include \"../algorithms/lischinski_minimization.hpp\"\n#include \"../tone_mapping/reinhard_tmo.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\nclass LischinskiTMO: public ToneMappingOperator\n{\nprotected:\n    FilterLuminance flt_lum;\n\n    float alpha, whitePoint;\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        updateImage(imgIn[0]);\n\n        //extract luminance\n        images[0] = flt_lum.Process(imgIn, images[0]);\n\n        float minL, maxL, Lav;\n\n        images[0]->getMinVal(NULL, &minL);\n        images[0]->getMaxVal(NULL, &maxL);\n        images[0]->getLogMeanVal(NULL, &Lav);\n\n        float minL_log = log2fPlusEpsilon(minL);\n        float maxL_log = log2fPlusEpsilon(maxL);\n\n        int Z = int(ceilf(maxL_log - minL_log));\n\n        if(Z <= 0) {\n            return imgOut;\n        }\n\n        if(alpha <= 0.0f) {\n            alpha = ReinhardTMO::estimateAlpha(minL, maxL, Lav);\n        }\n\n        if(whitePoint <= 0.0f) {\n            whitePoint = ReinhardTMO::estimateWhitePoint(minL, maxL);\n        }\n\n        float whitePoint_sq = whitePoint * whitePoint;\n\n        //choose the representative Rz for each zone\n        std::vector<float> *zones = new std::vector<float>[Z];\n        float *fstop = new float[Z];\n        float *Rz = new float[Z];\n\n        Array<float>::assign(0.0f, Rz, Z);\n        Array<float>::assign(0.0f, fstop, Z);\n\n        for(int i = 0; i < images[0]->size(); i++) {\n            float L = images[0]->data[i];\n            float L_log = log2fPlusEpsilon(L);\n\n            int zone = CLAMP(int(ceilf(L_log - minL_log)), Z);\n            zones[zone].push_back(L);\n        }\n\n        for(int i = 0; i < Z; i++) {\n            if(!zones[i].empty()) {\n                std::sort(zones[i].begin(), zones[i].end());\n                Rz[i] = zones[i][zones[i].size() >> 1];\n\n                if(Rz[i] > 0.0f) {\n                    float Rz_s = Rz[i] * alpha / Lav; //photographic operator\n                    float f = (Rz_s * (1.0f + Rz_s / whitePoint_sq) ) / (1.0f + Rz_s);\n                    fstop[i] = log2fPlusEpsilon(f / Rz[i]);\n                }\n            }\n        }\n\n        //create the fstop map\n        images[0]->applyFunction(log2fPlusEpsilon);\n\n        if(images[1] == NULL) {\n            images[1] = images[0]->allocateSimilarOne();\n        }\n\n        for(int i = 0; i < images[0]->size(); i++) {\n            float L_log = images[0]->data[i];\n            int zone = CLAMP(int(ceilf(L_log - minL_log)), Z);\n            images[1]->data[i] = fstop[zone];\n        }\n\n        //run Lischinski minimization\n        images[2] = LischinskiMinimization(images[0], images[1], NULL, 0.007f, images[2]);\n\n        images[2]->applyFunction(pow2f);\n\n        *imgOut = *imgIn[0];\n        *imgOut *= images[2];\n\n        delete[] zones;\n        delete[] Rz;\n        delete[] fstop;\n\n        return imgOut;\n    }\n\npublic:\n\n    /**\n     * @brief LischinskiTMO\n     * @param alpha\n     * @param whitePoint\n     */\n    LischinskiTMO(float alpha = 0.15f, float whitePoint = 1e6f)\n    {\n        images.push_back(NULL);\n        images.push_back(NULL);\n        images.push_back(NULL);\n        update(alpha, whitePoint);\n    }\n\n    /**\n     * @brief update\n     * @param alpha\n     * @param whitePoint\n     */\n    void update(float alpha = 0.15f, float whitePoint = 1e6f)\n    {\n        this->alpha = alpha;\n        this->whitePoint = whitePoint;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        LischinskiTMO ltmo(0.15f, 1e6f);\n        return ltmo.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_LISCHINSKI_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/pouli_cc.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_DURAND_TMO_HPP\n#define PIC_TONE_MAPPING_DURAND_TMO_HPP\n\n#include \"../base.hpp\"\n\n#include \"../util/string.hpp\"\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../algorithms/bilateral_separation.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The DurandTMO class\n */\nclass CCPOuli: public ToneMappingOperator\n{\npublic:\n\n    FilterLuminance flt_lum;\n    float target_contrast;\n\n    /**\n     * @brief DurandTMO\n     */\n    DurandTMO(float target_contrast = 5.0f)\n    {\n        images.push_back(NULL);\n        images.push_back(NULL);\n        images.push_back(NULL);\n        update(target_contrast);\n    }\n\n    ~DurandTMO()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param target_contrast\n     */\n    void update(float target_contrast = 5.0f)\n    {\n        if(target_contrast <= 0.0f) {\n            target_contrast = 5.0f;\n        }\n\n        this->target_contrast = target_contrast;\n    }\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        updateImage(imgIn[0]);\n\n        //luminance image\n        images[2] = flt_lum.Process(imgIn, images[2]);\n\n        //bilateral filter seperation\n        bilateralSeparation(images[2], images, -1.0f, 0.4f, true);\n\n        Image *base = images[0];\n        Image *detail = images[1];\n\n        float min_log_base, max_log_base;\n        base->getMinVal(NULL, &min_log_base);\n        base->getMaxVal(NULL, &max_log_base);\n\n        float compression_factor = log10fPlusEpsilon(target_contrast) / (max_log_base - min_log_base);\n        float log_absoulte = compression_factor * max_log_base;\n\n        *base *= compression_factor;\n        *base += detail;\n        *base -= log_absoulte;\n        base->applyFunction(powf10fMinusEpsilon);\n\n        *imgOut = *imgIn[0];\n        *imgOut *= base;\n        *imgOut /= images[2];\n\n        imgOut->removeSpecials();\n\n        return imgOut;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        DurandTMO dtmo(5.0f);\n        return dtmo.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_DURAND_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/raman_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_RAMAN_TMO_HPP\n#define PIC_TONE_MAPPING_RAMAN_TMO_HPP\n\n#include \"../base.hpp\"\n#include \"../util/std_util.hpp\"\n\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_bilateral_2dg.hpp\"\n\n#include \"../tone_mapping/get_all_exposures.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The RamanTMO class\n */\nclass RamanTMO: public ToneMappingOperator\n{\nprotected:\n    FilterLuminance flt_lum;\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        if(imgIn.size() > 1) {\n            return ProcessAuxStack(imgIn, imgOut);\n        } else {\n\n            std::vector<float> fstops = getAllExposuresUniform(imgIn[0]);\n            ImageVec stack = getAllExposuresImages(imgIn[0], fstops);\n            //pic::ImageVec stack = getAllExposures(imgIn[0]);\n\n            imgOut = ProcessAuxStack(stack, imgOut);\n\n            stdVectorClear<Image>(stack);\n\n            return imgOut;\n        }\n    }\n\n    /**\n     * @brief ramanFunction\n     * @param x\n     * @param param\n     * @return\n     */\n    static float ramanFunction(float x, std::vector<float>& param)\n    {\n        return fabsf(x) + param[0];\n    }\n\n    /**\n     * @brief ProcessAuxStack\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *ProcessAuxStack(ImageVec imgIn, Image *imgOut)\n    {\n        int n = int(imgIn.size());\n\n        if(n < 2 || !ImageVecCheck(imgIn, -1)) {\n            return imgOut;\n        }\n\n        //As reported in Raman and Chaudhuri Eurographics 2009 short paper\n        float K1 = 1.0f;\n        float K2 = 0.1f;\n        float C = 70.0f / 255.0f;\n\n        int width  = imgIn[0]->width;\n        int height = imgIn[0]->height;\n\n        float sigma_s = K1 * MIN(width, height);\n\n        updateImage(imgIn[0]);\n\n        std::vector<float> param;\n        param.push_back(C);\n\n        if(images[2] == NULL) {\n            //images[2] --> acc\n            images[2] = new Image(1, width, height, 1);\n        }\n\n        images[2]->setZero();\n\n        //accumulate into a Pyramid\n        #ifdef PIC_DEBUG\n            printf(\"Blending...\");\n        #endif\n\n        imgOut->setZero();\n\n        for(int j = 0; j < n; j++) {\n            images[0] = flt_lum.Process(Single(imgIn[j]), images[0]);\n\n            float min, max;\n\n            images[0]->getMinVal(NULL, &min);\n            images[0]->getMaxVal(NULL, &max);\n            float sigma_r = K2 * (max - min);\n\n            images[1] = FilterBilateral2DG::execute(images[0], images[1], sigma_s, sigma_r);\n            *images[1] -= *images[0];\n            images[1]->applyFunctionParam(ramanFunction, param);\n\n            *images[2] += *images[1];\n\n            //normalization\n            auto tmp = imgIn[j]->clone();\n            *tmp *= *images[1];\n\n            *imgOut += *tmp;\n        }\n\n        *imgOut /= *images[2];\n\n        #ifdef PIC_DEBUG\n            printf(\" ok\\n\");\n        #endif\n\n        return imgOut;\n    }\n\npublic:\n\n    /**\n     * @brief RamanTMO\n     */\n    RamanTMO()\n    {\n        setToANullVector<Image>(images, 3);\n    }\n\n    ~RamanTMO()\n    {\n        release();\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image* execute(Image *imgIn, Image *imgOut)\n    {\n        RamanTMO rtmo;\n        return rtmo.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief executeStack\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image* executeStack(ImageVec imgIn, Image *imgOut)\n    {\n        RamanTMO rtmo;\n        return rtmo.Process(imgIn, imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_RAMAN_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/reinhard_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_REINHARD_TMO_HPP\n#define PIC_TONE_MAPPING_REINHARD_TMO_HPP\n\n#include \"../base.hpp\"\n#include \"../util/string.hpp\"\n#include \"../util/math.hpp\"\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_bilateral_2ds.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_sigmoid_tmo.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ReinhardTMO class\n */\nclass ReinhardTMO : public ToneMappingOperator\n{\nprotected:\n\n    /**\n     * @brief sigmoidParam\n     * @param x\n     * @param param\n     * @return\n     */\n    static float sigmoidParam(float x, std::vector< float > &param)\n    {\n        float x_s = x * param[0];\n\n        return x_s / (x_s + param[1]);\n    }\n\n    /**\n     * @brief sigmoidInvParam\n     * @param y\n     * @param param\n     * @return\n     */\n    static float sigmoidInvParam(float y, std::vector< float > &param)\n    {\n        float x_s = y *  param[1] / (1.0f -  y);\n\n        return x_s / param[0];\n    }\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        //luminance image\n        images[0] = flt_lum.Process(imgIn, images[0]);\n\n        float LMin, LMax, LogAverage;\n        images[0]->getMaxVal(NULL, &LMax);\n        images[0]->getMinVal(NULL, &LMin);\n        images[0]->getLogMeanVal(NULL, &LogAverage);\n\n        bool bUpdate = false;\n\n        if(alpha <= 0.0f) {\n            alpha = estimateAlpha(LMin, LMax, LogAverage);\n            bUpdate = true;\n        }\n\n        if(whitePoint <= 0.0f) {\n            whitePoint = estimateWhitePoint(LMin, LMax);\n            bUpdate = true;\n        }\n\n        if(bUpdate) {\n            flt_sigmoid.update(this->sig_mode, this->alpha, this->whitePoint, -1.0f, false);\n        }\n\n        //filter luminance in the sigmoid-space\n        if(phi > 0.0f) {\n            float s_max = 8.0f;\n            float value = powf(2.0f, phi) * alpha / (s_max * s_max);\n\n            std::vector<float> param;\n            param.push_back(alpha / LogAverage);\n            param.push_back(value);\n\n            float pEpsilon = 0.05f; //threshold\n            images[0]->applyFunctionParam(sigmoidParam, param);//applyFunction(&sigmoid);\n\n\n            flt_bilateral.update(1.6f, pEpsilon / 2.0f);\n\n            images[1] = flt_bilateral.Process(Single(images[0]), images[1]);\n\n            images[0]->applyFunctionParam(sigmoidInvParam, param);\n            images[1]->applyFunctionParam(sigmoidInvParam, param);\n\n            images[2] = flt_sigmoid.Process(Double(images[0], images[1]), images[2]);\n        } else {\n            images[2] = flt_sigmoid.Process(Single(images[0]), images[2]);\n        }\n\n        //remove HDR luminance and replacing it with LDR one\n        *imgOut = *imgIn[0];\n        *imgOut /= *images[0];\n        *imgOut *= *images[2];\n\n        imgOut->removeSpecials();\n\n        return imgOut;\n    }\n\n    SIGMOID_MODE sig_mode;\n    float alpha, whitePoint, phi;\n    FilterSigmoidTMO flt_sigmoid;\n    FilterBilateral2DS flt_bilateral;\n    FilterLuminance flt_lum;\n\npublic:\n\n    /**\n     * @brief ReinhardTMO\n     * @param alpha\n     * @param whitePoint\n     * @param phi\n     * @param sig_mode\n     */\n    ReinhardTMO(float alpha = 0.18f, float whitePoint = -1.0f, float phi = 8.0f, SIGMOID_MODE sig_mode = SIG_TMO)\n    {\n        images.push_back(NULL);\n        images.push_back(NULL);\n        images.push_back(NULL);\n        update(alpha, whitePoint, phi, sig_mode);\n    }\n\n    ~ReinhardTMO()\n    {\n        release();\n    }\n\n    /**\n     * @brief estimateAlpha\n     * @param LMin\n     * @param LMax\n     * @param logAverage\n     * @return\n     */\n    static float estimateAlpha(float LMin, float LMax, float logAverage)\n    {\n        float log2f       = logf(2.0f);\n        float log2Max     = logf(LMax       + 1e-9f) / log2f;\n        float log2Min     = logf(LMin       + 1e-9f) / log2f;\n        float log2Average = logf(logAverage + 1e-9f) / log2f;\n\n        float tmp = (2.0f * log2Average - log2Min - log2Max) / (log2Max - log2Min);\n\n        return 0.18f * powf(4.0f, tmp);\n    }\n\n    /**\n     * @brief estimateWhitePoint\n     * @param LMin\n     * @param LMax\n     * @return\n     */\n    static float estimateWhitePoint(float LMin, float LMax)\n    {\n        float log2f       = logf(2.0f);\n        float log2Max     = logf(LMax + 1e-9f) / log2f;\n        float log2Min     = logf(LMin + 1e-9f) / log2f;\n\n        return 1.5f * powf(2.0f, (log2Max - log2Min - 5.0f));\n    }\n\n    /**\n     * @brief update\n     * @param alpha\n     * @param whitePoint\n     * @param phi\n     * @param sig_mode\n     */\n    void update(float alpha = 0.18f, float whitePoint = 1e6f, float phi = 8.0f, SIGMOID_MODE sig_mode = SIG_TMO)\n    {\n        this->alpha = alpha;\n        this->whitePoint = whitePoint;\n        this->phi = phi;\n        this->sig_mode = sig_mode;\n\n        flt_sigmoid.update(SIG_TMO, this->alpha, this->whitePoint, -1.0f, false);\n    }\n\n    /**\n     * @brief executeGlobal1\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image* executeGlobal1(Image *imgIn, Image *imgOut)\n    {\n        ReinhardTMO rtmo(-1.0f, -1.0f, -8.0f, SIG_TMO);\n        return rtmo.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief executeGlobal2\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image* executeGlobal2(Image *imgIn, Image *imgOut)\n    {\n        ReinhardTMO rtmo(-1.0f, -1.0f, -8.0f, SIG_TMO_WP);\n        return rtmo.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief executeLocal1\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image* executeLocal1(Image *imgIn, Image *imgOut)\n    {\n        ReinhardTMO rtmo(-1.0f, -1.0f, 8.0f, SIG_TMO);\n        return rtmo.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief executeLocal2\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image* executeLocal2(Image *imgIn, Image *imgOut)\n    {\n        ReinhardTMO rtmo(-1.0f, -1.0f, 8.0f, SIG_TMO_WP);\n        return rtmo.Process(Single(imgIn), imgOut);\n    }\n};\n\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_REINHARD_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/schlick_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_SCHLICK_TMO_HPP\n#define PIC_TONE_MAPPING_SCHLICK_TMO_HPP\n\n#include \"../base.hpp\"\n\n#include \"../util/array.hpp\"\n#include \"../util/indexed_array.hpp\"\n\n#include \"../image.hpp\"\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The SchlickTMO class\n */\nclass SchlickTMO: public ToneMappingOperator\n{\nprotected:\n    std::string mode;\n    int nBit;\n    float k, p, L0;\n    FilterLuminance flt_lum;\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */    \n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        updateImage(imgIn[0]);\n\n        //compute luminance and its statistics\n        float LMin, LMax;\n\n        images[0] = flt_lum.Process(imgIn, images[0]);\n\n        IntCoord ret;\n        IndexedArray<float>::findSimple(images[0]->data, images[0]->size(), IndexedArray<float>::bFuncNotNeg, ret, 1);\n        LMin = IndexedArray<float>::percentile(images[0]->data, ret, 0.01f);\n\n        images[0]->getMaxVal(NULL, &LMax);\n\n        int channels = imgIn[0]->channels;\n\n        bool bNonUniform = (mode.compare(\"nonuniform\") == 0);\n\n        float p_prime;\n        if((mode.compare(\"automatic\") == 0) || bNonUniform) {\n            int nValues = 1 << nBit;\n            p_prime = L0 * LMax / (float(nValues) * LMin);\n        } else {\n            p_prime = p;\n        }\n\n        float cSqrtLminLmax = sqrtf(LMin * LMax);\n\n        #pragma omp parallel for\n        for(int i = 0; i < images[0]->size(); i++) {\n\n            float Lw = images[0]->data[i];\n\n            if(Lw > 0.0f) {\n                float p_prime_w = p_prime;\n\n                if(bNonUniform) {\n                    p_prime_w *= (1.0f - k + k * Lw / cSqrtLminLmax);\n                }\n\n                float Ld = (p_prime_w * Lw) / ((p_prime_w - 1.0f) * Lw + LMax);\n\n                int index = i * channels;\n                for(int j = 0; j < channels; j++) {\n                    int k = index + j;\n                    imgOut->data[k] = (imgIn[0]->data[k] * Ld) / Lw;\n                }\n            }\n        }\n\n        return imgOut;\n    }\n\npublic:\n\n    /**\n     * @brief SchlickTMO\n     * @param mode valid values are: \"nonuniform\", \"automatic\", \"standard\"\n     * @param p is a model parameter which takes values in [1,+inf].\n     * @param nBit the number of bits of the output LDR display\n     * @param L0 is lowest value of the LDR monitor that can be perceived by the HVS.\n     * @param k is a value in [0,1].\n     */\n    SchlickTMO(std::string mode, float p, int nBit, float L0, float k) : ToneMappingOperator()\n    {\n        images.push_back(NULL);\n        update(mode, p, nBit, L0, k);\n    }\n\n    ~SchlickTMO()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param mode valid values are: \"nonuniform\", \"automatic\", \"standard\"\n     * @param p is a model parameter which takes values in [1,+inf].\n     * @param nBit the number of bits of the output LDR display\n     * @param L0 is lowest value of the LDR monitor that can be perceived by the HVS.\n     * @param k is a value in [0,1].\n     */\n    void update(std::string mode = \"automatic\", float p = 200.0f, int nBit = 8, float L0 = 1.0f, float k = 0.5f)\n    {\n        this->mode = mode;\n        this->k = CLAMPi(k, 0.0f, 1.0f);\n        this->nBit = nBit < 1 ? 8 : nBit;\n        this->p = p < 1.0f ? 200.0f : p;\n        this->L0 = L0 < 0.0f ? 1.0f : L0;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        SchlickTMO stmo(\"automatic\", 1.0f / 0.005f, 8, 1.0f, 0.5f);\n        return stmo.Process(Single(imgIn), imgOut);\n    }\n};\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_SCHLICK_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/tone_mapping_operator.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_TONE_MAPPING_OPERATOR_HPP\n#define PIC_TONE_MAPPING_TONE_MAPPING_OPERATOR_HPP\n\n#include \"../image.hpp\"\n#include \"../image_vec.hpp\"\n#include \"../util/array.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ToneMappingOperator class\n */\nclass ToneMappingOperator\n{\nprotected:\n\n    ImageVec images;\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     */\n    virtual Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        return imgOut;\n    }\n\n    /**\n     * @brief releaseAux\n     */\n    virtual void releaseAux()\n    {\n\n    }\n\npublic:\n\n    /**\n     * @brief ToneMappingOperator\n     */\n    ToneMappingOperator()\n    {\n\n    }\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        stdVectorClear<Image>(images);\n        releaseAux();\n    }\n\n    /**\n     * @brief updateImage\n     * @param imgIn\n     */\n    void updateImage(Image *imgIn)\n    {\n        bool bRelease = false;\n        for(uint i = 0; i < images.size(); i++) {\n            if(images[i] != NULL) {\n                if((imgIn->width  != images[i]->width) ||\n                   (imgIn->height != images[i]->height)) {\n                    bRelease = true;\n                    break;\n                }\n            }\n        }\n\n        if(bRelease) {\n            release();\n        }\n    }\n\n    /**\n     * @brief getScaleFiltering\n     * @param imgIn\n     * @param fx\n     * @param fy\n     */\n    static void getScaleFiltering(Image *imgIn, int &fScaleX, int &fScaleY)\n    {\n        int maxCoord = MAX(imgIn->width, imgIn->height);\n\n        float maxCoordf       = 2.0f * float(maxCoord) * 0.75f;\n        float viewAngleWidth  = 2.0f * atanf(imgIn->width / maxCoordf);\n        float viewAngleHeight = 2.0f * atanf(imgIn->height / maxCoordf);\n\n        fScaleX = int((2.0f * tanf(viewAngleWidth / 2.0f) / 0.01745f));\n        fScaleY = int((2.0f * tanf(viewAngleHeight / 2.0f) / 0.01745f));\n    }\n\n    /**\n     * @brief Process\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *Process(ImageVec imgIn, Image *imgOut = NULL)\n    {\n        if(!ImageVecCheck(imgIn, -1)) {\n            return imgOut;\n        }\n\n        if(imgOut == NULL) {\n            imgOut = imgIn[0]->clone();\n        } else {\n            if(!imgOut->isSimilarType(imgIn[0])) {\n                imgOut = imgIn[0]->allocateSimilarOne();\n            }\n        }\n\n        imgOut = ProcessAux(imgIn, imgOut);\n\n        return imgOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_WARD_HISTOGRAM_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/tumblin_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_TUMBLIN_TMO_HPP\n#define PIC_TONE_MAPPING_TUMBLIN_TMO_HPP\n\n#include \"../base.hpp\"\n\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The TumblinTMO class\n */\nclass TumblinTMO: public ToneMappingOperator\n{\nprotected:\n    float Ld_Max, Ld_a, Lw_a, C_Max;\n    FilterLuminance flt_lum;\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */    \n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        updateImage(imgIn[0]);\n\n        //compute luminance and its statistics\n        images[0] = flt_lum.Process(imgIn, images[0]);\n\n        float Lw_Max;\n        images[0]->getMaxVal(NULL, &Lw_Max);\n\n        float Lw_a_t;\n        if(Lw_a > 0.0f) {\n            Lw_a_t = Lw_a;\n        } else {\n            images[0]->getLogMeanVal(NULL, &Lw_a_t);\n        }\n\n        float gamma_w = StevenCSF(Lw_a_t);\n        float gamma_d = StevenCSF(Ld_a);\n        float gamma_wd = gamma_w / (1.855f + 0.4f * logf(Ld_a));\n        float m = powf(C_Max, (gamma_wd - 1.0f) / 2.0f);\n\n        float exponent = gamma_w / gamma_d;\n        float scale_norm = Lw_a;\n        float scale = Ld_a * m / Ld_Max;\n\n        imgOut->assign(imgIn[0]);\n\n        std::vector<float> param;\n        param.push_back(exponent);\n        param.push_back(scale_norm);\n        param.push_back(scale);\n        images[0]->applyFunctionParam(TumblinFun, param);\n\n        (*imgOut) *= (*images[0]);\n\n        return imgOut;\n    }\n\n    /**\n     * @brief TumblinFun\n     * @param x\n     * @param param\n     * @return\n     */\n    static float TumblinFun(float Lw, std::vector<float> &param)\n    {\n        if(Lw > 0.0f) {\n            float Ld = powf(Lw / param[1], param[0]) * param[2];\n\n            return Ld / Lw;\n        } else {\n            return 0.0f;\n        }\n    }\n\npublic:\n\n    /**\n     * @brief TumblinTMO\n     * @param Ld_a\n     * @param Ld_Max\n     * @param C_Max\n     * @param Lw_b\n     */\n    TumblinTMO(float Ld_a = 20.0f, float Ld_Max = 100.0f, float C_Max = 100.0f, float Lw_a = -1.0f) : ToneMappingOperator()\n    {\n        images.push_back(NULL);\n        update(Ld_a, Ld_Max, C_Max, Lw_a);\n    }\n\n    ~TumblinTMO()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param Ld_a\n     * @param Ld_Max\n     * @param C_Max\n     * @param Lw_a\n     */\n    void update(float Ld_a = 20.0f, float Ld_Max = 100.0f, float C_Max = 100.0f, float Lw_a = 1.0f)\n    {\n        this->Ld_a = Ld_a > 0.0f ? Ld_a : 20.0f;\n        this->Ld_Max = Ld_Max > 0.0f ? Ld_Max : 100.0f;\n        this->C_Max = C_Max > 0.0f ? C_Max : 100.0f;\n        this->Lw_a = Lw_a > 0.0f ? Lw_a : 1.0f;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        TumblinTMO ttmo;\n        return ttmo.Process(Single(imgIn), imgOut);\n    }\n\n    /**\n     * @brief StevenCSF\n     * @param x\n     * @return\n     */\n    static float StevenCSF(float x)\n    {\n        if(x <= 100.0f) {\n            return 1.855f + 0.4f * log10f(x + 2.3e-5f);\n        } else {\n            return 2.655f;\n        }\n    }\n};\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_TUMBLIN_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/ward_global_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_WARD_GLOBAL_TMO_HPP\n#define PIC_TONE_MAPPING_WARD_GLOBAL_TMO_HPP\n\n#include \"../base.hpp\"\n\n#include \"../filtering/filter.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The WardGlobalTMO class\n */\nclass WardGlobalTMO: public ToneMappingOperator\n{\nprotected:\n    float Ld_Max;\n    FilterLuminance flt_lum;\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */    \n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        updateImage(imgIn[0]);\n\n        //compute luminance and its statistics\n        images[0] = flt_lum.Process(imgIn, images[0]);\n\n        float Lw_a;\n        images[0]->getLogMeanVal(NULL, &Lw_a);\n\n        float m = (1.219f + powf(Ld_Max * 0.5f, 0.4f)) /\n                  (1.219f + powf(Lw_a , 0.4f));\n        m = powf(m, 2.5f);\n\n        float scale = m / Ld_Max;\n\n        imgOut->assign(imgIn[0]);\n\n        (*imgOut) *= scale;\n\n        return imgOut;\n    }\n\npublic:\n\n    /**\n     * @brief WardGlobalTMO\n     * @param Ld_Max\n     */\n    WardGlobalTMO(float Ld_Max = 100.0f) : ToneMappingOperator()\n    {\n        images.push_back(NULL);\n        update(Ld_Max);\n    }\n\n    ~WardGlobalTMO()\n    {\n        release();\n    }\n\n    /**\n     * @brief update\n     * @param Ld_Max\n     */\n    void update(float Ld_Max = 100.0f)\n    {\n        this->Ld_Max = Ld_Max > 0.0f ? Ld_Max : 100.0f;\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image *execute(Image *imgIn, Image *imgOut)\n    {\n        WardGlobalTMO wgtmo;\n        return wgtmo.Process(Single(imgIn), imgOut);\n    }\n};\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_WARD_GLOBAL_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping/ward_histogram_tmo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_WARD_HISTOGRAM_TMO_HPP\n#define PIC_TONE_MAPPING_WARD_HISTOGRAM_TMO_HPP\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../image_vec.hpp\"\n#include \"../histogram.hpp\"\n#include \"../util/array.hpp\"\n#include \"../filtering/filter_luminance.hpp\"\n#include \"../filtering/filter_sampler_2d.hpp\"\n#include \"../tone_mapping/tone_mapping_operator.hpp\"\n\nnamespace pic {\n\nclass WardHistogramTMO: public ToneMappingOperator\n{\nprotected:\n\n    /**\n     * @brief ProcessAux\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    Image *ProcessAux(ImageVec imgIn, Image *imgOut)\n    {\n        updateImage(imgIn[0]);\n\n        images[0] = flt_lum.Process(imgIn, images[0]);\n\n        int fScaleX, fScaleY;\n        getScaleFiltering(imgIn[0], fScaleX, fScaleY);\n        flt_smp.update(fScaleX, fScaleY, &isb);\n        images[1] = flt_smp.Process(Single(images[0]), images[1]);\n\n        //compute min and max luminance\n        float LMin, LMax;\n        images[1]->getMinVal(NULL, &LMin);\n        images[1]->getMaxVal(NULL, &LMax);\n\n        float log_LMin = logf(LMin + epsilon);\n        float log_LMax = logf(LMax + epsilon);\n\n        float log_LdMin = logf(LdMin + epsilon);\n        float log_LdMax = logf(LdMax + epsilon);\n\n        float delta_Ld = LdMax - LdMin;\n        float delta_log_L = (log_LMax - log_LMin);\n        float delta_log_Ld = log_LdMax - log_LdMin;\n\n        //compute the histogram with ceiling\n        h.calculate(images[1], VS_LOG_E, nBin);\n\n        if(bCeiling) {\n            h.ceiling(delta_log_L / (float(nBin) * delta_log_Ld));\n        }\n\n        Pcum = Array<uint>::cumsum(h.bin, nBin, Pcum);\n        float maxPcumf = float(Pcum[nBin - 1]);\n\n        for(int i = 0; i < nBin; i++) {\n            PcumNorm[i] = float(Pcum[i]) / maxPcumf;\n            x[i] = delta_log_L * float(i) / float(nBin - 1) + log_LMin;\n        }\n\n        #pragma omp parallel for\n        for(int i = 0; i < images[0]->size(); i++) {\n            float L_w =  images[0]->data[i];\n\n            float log_L_w = logf(L_w + epsilon);\n            float Ld = expf(delta_log_Ld * Arrayf::interp(x, PcumNorm, nBin, log_L_w) + log_LdMin) - epsilon;\n\n            float scale = (MAX(Ld, 0.0f) - LdMin) / (delta_Ld * L_w);\n            scale = MAX(scale, 0.0f);\n\n            int index = i * imgOut->channels;\n            for(int j = 0; j < imgOut->channels; j++) {\n                int k = index + j;\n                imgOut->data[k] = imgIn[0]->data[k] * scale;\n            }\n        }\n\n        imgOut->removeSpecials();\n\n        return imgOut;\n    }\n\n    /**\n     * @brief allocate\n     * @param nBin\n     */\n    void allocate(int nBin = 256)\n    {\n        nBin = nBin > 16 ? nBin : 256;\n\n        if(this->nBin == nBin) {\n            return;\n        }\n\n        releaseAux();\n\n        Pcum = new unsigned int[nBin];\n        PcumNorm = new float[nBin];\n        x = new float[nBin];\n\n        this->nBin = nBin;\n    }\n\n    int nBin;\n    float LdMin, LdMax;\n    ImageSamplerBilinear isb;\n    Histogram h;\n    float epsilon;\n\n    unsigned int *Pcum;\n    float *PcumNorm, *x;\n\n    bool bCeiling;\n    FilterLuminance flt_lum;\n    FilterSampler2D flt_smp;\n\npublic:\n\n    /**\n     * @brief WardHistogramTMO\n     * @param nBin is the number of bins of the histogram\n     * @param LdMin is the minimum luminance of the LDR display in cd/m^2\n     * @param LdMax is the maximum luminance of the LDR display in cd/m^2\n     * @param bCeiling enables histogram ceiling or not\n     */\n    WardHistogramTMO(int nBin = 256, float LdMin = 1.0f, float LdMax = 100.0f, bool bCeiling = true) : ToneMappingOperator()\n    {\n        this->Pcum = NULL;\n        this->PcumNorm = NULL;\n        this->x = NULL;\n        this->nBin = 0;\n        this->bCeiling = bCeiling;\n\n        images.clear();\n        images.push_back(NULL);\n        images.push_back(NULL);\n\n        update(nBin, LdMin, LdMax);\n    }\n\n    ~WardHistogramTMO()\n    {\n        release();\n    }\n\n    /**\n     * @brief releaseAux\n     */\n    void releaseAux()\n    {\n        Pcum = delete_vec_s(Pcum);\n        PcumNorm = delete_vec_s(PcumNorm);\n        x = delete_vec_s(x);\n    }\n\n    /**\n     * @brief update\n     * @param nBin is the number of bins of the histogram\n     * @param LdMin is the minimum luminance of the LDR display in cd/m^2\n     * @param LdMax is the maximum luminance of the LDR display in cd/m^2\n     */\n    void update(int nBin = 256, float LdMin = 1.0f, float LdMax = 100.0f)\n    {\n        allocate(nBin);\n\n        epsilon = 1e-6f;\n\n        this->LdMax = LdMax > 0.0f ? LdMax : 100.0f;\n        this->LdMin = LdMin > 0.0f ? LdMin : 1.0f;\n\n        if(this->LdMin > this->LdMax) {\n            LdMin = 1.0f;\n            LdMax = 100.0f;\n        }\n\n    }\n\n    /**\n     * @brief execute\n     * @param imgIn\n     * @param imgOut\n     * @return\n     */\n    static Image* execute(Image *imgIn, Image *imgOut)\n    {\n        WardHistogramTMO wtmo(100, 1.0f, 200.0f);\n        return wtmo.Process(Single(imgIn), imgOut);\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_TONE_MAPPING_WARD_HISTOGRAM_TMO_HPP */\n\n"
  },
  {
    "path": "include/tone_mapping.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_TONE_MAPPING_HPP\n#define PIC_TONE_MAPPING_HPP\n\n#include \"tone_mapping/get_all_exposures.hpp\"\n#include \"tone_mapping/exposure_fusion.hpp\"\n#include \"tone_mapping/find_best_exposure.hpp\"\n#include \"tone_mapping/hybrid_tmo.hpp\"\n#include \"tone_mapping/lischinski_tmo.hpp\"\n#include \"tone_mapping/reinhard_tmo.hpp\"\n#include \"tone_mapping/drago_tmo.hpp\"\n#include \"tone_mapping/ward_histogram_tmo.hpp\"\n#include \"tone_mapping/durand_tmo.hpp\"\n#include \"tone_mapping/ferwerda_tmo.hpp\"\n#include \"tone_mapping/schlick_tmo.hpp\"\n#include \"tone_mapping/raman_tmo.hpp\"\n#include \"tone_mapping/tumblin_tmo.hpp\"\n#include \"tone_mapping/ward_global_tmo.hpp\"\n\n\n#endif /* PIC_TONE_MAPPING_HPP */\n\n"
  },
  {
    "path": "include/util/array.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_ARRAY_HPP\n#define PIC_UTIL_ARRAY_HPP\n\n#include <vector>\n#include <math.h>\n\nnamespace pic {\n\n/**\n * @brief The Array class\n */\ntemplate<class T>\nclass Array\n{\nprotected:\n    bool bShallow;\n\npublic:\n    T *data;\n    int nData;\n\n    /**\n     * @brief Array\n     */\n    Array()\n    {\n        bShallow = false;\n        data = NULL;\n        nData = -1;\n    }\n\n    /**\n     * @brief Array\n     * @param n\n     */\n    Array(int n)\n    {\n        bShallow = false;\n        data = NULL;\n        allocate(n);\n    }\n\n    /**\n     * @brief Array\n     * @param data\n     * @param nData\n     * @param bShallow\n     */\n    Array(T *data, int nData, bool bShallow)\n    {\n        this->nData = nData;\n\n        if(bShallow) {\n            this->data = data;\n            this->bShallow = bShallow;\n        } else {\n            this->data = new T[nData];\n            memcpy(this->data, data, sizeof(T) * nData);\n        }\n    }\n\n    ~Array()\n    {\n        release();\n    }\n\n    /**\n     * @brief allocate\n     * @param n\n     */\n    void allocate(int n)\n    {\n        if(n < 1) {\n            return;\n        }\n\n        if((data != NULL) && (!bShallow)) {\n            delete[] data;\n        }\n\n        data = new T[n];\n        this->nData = n;\n        bShallow = false;\n    }\n\n    /**\n     * @brief release\n     */\n    void release()\n    {\n        if(nData > 0 && data != NULL && !bShallow) {\n            delete[] data;\n            data = NULL;\n            nData = -1;\n        }\n    }\n\n    /**\n     * @brief clone\n     * @return\n     */\n    Array<T> *clone()\n    {\n        Array<T> *out = new Array<T>(nData);\n        memcpy(this->data, data, sizeof(T) * nData);\n    }\n\n    /**\n     * @brief genValue\n     * @param value\n     * @param n\n     * @param ret\n     * @return\n     */\n    static T* genValue(T value, int n, T *ret)\n    {\n        if(n < 1) {\n            return ret;\n        }\n\n        if(ret == NULL) {\n            ret = new T[n];\n        }\n\n        for(int i = 0; i < n; i++) {\n            ret[i] = value;\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief genRange\n     * @param minVal\n     * @param step\n     * @param maxVal\n     * @param ret\n     */\n    static T *genRange(T minVal, T step, T maxVal, T *ret, int &n)\n    {\n        n = int((maxVal - minVal) / step) + 1;\n\n        if(ret == NULL) {\n            ret = new T[n];\n        }\n\n        ret[0] = minVal;\n        for(int i = 1; i < n; i++) {\n            ret[i] = ret[i - 1] + step;\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief linspace\n     * @param minVal\n     * @param maxVal\n     * @param n\n     * @param ret\n     * @return\n     */\n    static T *linspace(T minVal, T maxVal, int n, T *ret)\n    {\n        T step = (maxVal - minVal) / (n - 1);\n        int tmp = n;\n\n        return genRange(minVal, step, maxVal, ret, tmp);\n    }\n\n    /**\n     * @brief distanceSq\n     * @param data0\n     * @param data1\n     * @param n\n     * @return\n     */\n    static T distanceSq(T *data0, T *data1, int n)\n    {\n        T tmp = data0[0] - data1[0];\n        T distSq = tmp * tmp;\n\n        for(int k = 1; k < n; k++) {\n            tmp = data0[k] - data1[k];\n            distSq += tmp * tmp;\n        }\n\n        return distSq;\n    }\n\n    /**\n     * @brief zeros\n     * @param n\n     * @return\n     */\n    static T* zeros(int n)\n    {\n        T *ret = new T[n];\n        assign(T(0), ret, n);\n\n        return ret;\n    }\n\n    /**\n     * @brief norm_sq\n     * @param data\n     * @param n\n     * @return\n     */\n    static T norm_sq(float *data, int n)\n    {\n        T n_sq = data[0] * data[0];\n\n        for(int k = 1; k < n; k++) {\n            T tmp = data[k];\n            n_sq += tmp * tmp;\n        }\n\n        return n_sq;\n    }\n\n    /**\n     * @brief norm\n     * @param data\n     * @param n\n     * @return\n     */\n    static T norm(float *data, int n)\n    {\n        return sqrtf(Array<float>::norm(data, n));\n    }\n\n    /**\n     * @brief normalize\n     * @param data\n     * @param n\n     * @param norm_sq\n     * @return\n     */\n    static float normalize(float *data, int n, float norm_sq = -1.0f)\n    {\n        if(norm_sq < 0.0f) {\n            norm_sq = Array<float>::norm_sq(data, n);\n        }\n\n        if(norm_sq > 0.0f) {\n            norm_sq = sqrtf(norm_sq);\n\n            for(int k = 0; k < n; k++) {\n                data[k] /= norm_sq;\n            }\n        }\n\n        return norm_sq;\n    }\n\n    static void clamp(T *data, int n, T lower_bound, T upper_bound)\n    {\n        for(int i = 0; i < n; i++) {\n            data[i] = data[i] >= lower_bound ? data[i] : lower_bound;\n            data[i] = data[i] <= upper_bound ? data[i] : upper_bound;\n        }\n    }\n\n    /**\n     * @brief dot\n     * @param data0\n     * @param data1\n     * @param n\n     * @return\n     */\n    static T dot(T *data0, T *data1, int n)\n    {\n        T out = data0[0] * data1[0];\n\n        for(int k = 1; k < n; k++) {\n            out += data0[k] * data1[k];\n        }\n\n        return out;\n    }\n\n    /**\n     * @brief mul\n     * @param vec\n     * @param size\n     * @param scale\n     * @return\n     */\n    static void mul(T *data, int size, T scale)\n    {\n        if(data == NULL || size < 1) {\n            return;\n        }\n\n        for(int i = 0; i < size; i++) {\n            data[i] *= scale;\n        }\n    }\n\n    /**\n     * @brief mul\n     * @param data\n     * @param size\n     * @param ret\n     * @return\n     */\n    static void mul(T *data, int size, T *ret)\n    {\n        if(data == NULL || size < 1 || ret == NULL) {\n            return;\n        }\n\n        for(int i = 0; i < size; i++) {\n            ret[i] *= data[i];\n        }\n    }\n\n    /**\n     * @brief add\n     * @param data\n     * @param size\n     * @param ret\n     */\n    static T* add(T *data, int size, T *ret)\n    {\n        if(data == NULL || ret == NULL || size < 1) {\n            return ret;\n        }\n\n        for(int i = 0; i < size; i++) {\n            ret[i] += data[i];\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief div\n     * @param data\n     * @param size\n     * @param value\n     */\n    static void div(T *data, int size, T value)\n    {\n        for(int i = 0; i < size; i++) {\n            data[i] /= value;\n        }\n    }\n\n    /**\n     * @brief getMean\n     * @param data\n     * @param size\n     * @param ind\n     * @return\n     */\n    static T getMean(T *data, int size)\n    {\n        if(data == NULL || size < 1) {\n            return T(0);\n        }\n\n        T ret = data[0];\n\n        for(int i = 1; i < size; i++) {\n            ret += data[i];\n        }\n\n        ret /= T(size);\n\n        return ret;\n    }\n\n    /**\n     * @brief getVariance\n     * @param data\n     * @param size\n     * @return\n     */\n    static T getVariance(T *data, int size)\n    {\n        if(data == NULL || size < 2) {\n            return T(-1);\n        }\n\n        T mu = getMean(data, size);\n\n        T tmp = data[0] - mu;\n        T ret = tmp * tmp;\n\n        for(int i = 1; i < size; i++) {\n            tmp = data[i] - mu;\n            ret += tmp * tmp;\n        }\n\n        size--;\n        return ret / T(size);\n    }\n\n    /**\n     * @brief sum\n     * @param data\n     * @param size\n     * @return\n     */\n    static T sum(T *data, int size)\n    {\n        if(data == NULL || size < 1) {\n            return T(0);\n        }\n\n        T ret = data[0];\n\n        for(int i = 1; i < size; i++) {\n            ret += data[i];\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief cumsum\n     * @param vec\n     * @param size\n     * @param ret\n     * @return\n     */\n    static T *cumsum(T *vec, int size, T *ret)\n    {\n        if(vec == NULL || size < 1) {\n            return NULL;\n        }\n\n        if(ret == NULL) {\n            ret = new T[size];\n        }\n\n        ret[0] = vec[0];\n\n        for(int i = 1; i < size; i++) {\n            ret[i] = vec[i] + ret[i - 1];\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief assign\n     * @param data\n     * @param size\n     * @param ret\n     * @return\n     */\n    static T* assign (T* data, int size, T* ret)\n    {\n        memcpy(ret, data, sizeof(T) * size);\n        return ret;\n    }\n\n    /**\n     * @brief assign\n     * @param data\n     * @param ret\n     * @param size\n     * @return\n     */\n    static T* assign (T data, T* ret, int size)\n    {\n        for(int i = 0; i < size; i++) {\n            ret[i] = data;\n        }\n        return ret;\n    }\n\n    /**\n     * @brief apply\n     * @param data\n     * @param size\n     * @param ret\n     * @return\n     */\n    static T* apply(T *data,  int size, T *ret, T(*func)(T))\n    {\n        if(data == NULL || size < 1) {\n            return ret;\n        }\n\n        if(ret == NULL) {\n            ret = new T[size];\n        }\n\n        for(int i = 1; i < size; i++) {\n            ret[i] = func(data[i]);\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief getMax\n     * @param data\n     * @param size\n     * @param ind\n     * @return\n     */\n    static T getMax(T *data, int size, int &ind)\n    {\n        if(data == NULL || size < 1) {\n            return T(size + 1);\n        }\n\n        T ret = data[0];\n        ind = 0;\n\n        for(int i = 1; i < size; i++) {\n            if(ret < data[i]) {\n                ret = data[i];\n                ind = i;\n            }\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief getMin\n     * @param data\n     * @param size\n     * @param ind\n     * @return\n     */\n    static T getMin(T *data, int size, int &ind)\n    {\n        if(data == NULL || size < 1) {\n            return T(size + 1);\n        }\n\n        T ret = data[0];\n        ind = 0;\n\n        for(int i = 1; i < size; i++) {\n            if(ret > data[i]) {\n                ret = data[i];\n                ind = i;\n            }\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief interp linearly interpolates x and y data\n     * @param x\n     * @param y\n     * @param size the size of x and y\n     * @param xval\n     * @return\n     */\n    static T interp(T *x, T *y, int size, T xval)\n    {\n        int sm1 = size - 1;\n        if((xval >= x[0]) && (xval <= x[sm1])) {\n            int offset2;\n            T *ptr = std::lower_bound(&x[0], &x[sm1], xval);\n            int offset = MAX(0, (int)(ptr - x - 1));\n\n            if(offset == sm1) {\n                offset2 = offset;\n                offset  = offset2 - 1;\n            } else {\n                offset2 = MIN(size - 1, offset + 1);\n            }\n\n            T t = (xval - x[offset]) / (x[offset2] - x[offset]);\n\n            return y[offset] * (T(1) - t) + t * y[offset2];\n        } else {\n            if(xval > x[sm1]) {\n                int sm2 = size - 2;\n                T t = (xval - x[sm2]) / (x[sm1] - x[sm2]);\n                return t * (y[sm1] - y[sm2])  + y[sm2];\n            } else {\n                T t = (xval - x[0]) / (x[1] - x[0]);\n                return t * (y[1] - y[0])  + y[0];\n            }\n        }\n\n    }\n\n    /**\n     * @brief binSearchLeft\n     * @param data\n     * @param key\n     * @param low\n     * @param high\n     * @return\n     */\n    static int binSearchLeft(T *data, T key, int low, int high)\n    {\n        if( (high < low) ||\n            (key > data[high - 1]) ||\n            (key < data[low]) ) {\n\n            #ifdef PIC_DEBUG\n                printf(\"\\nbinSearchLeft: bounds error!\\n\");\n            #endif\n            return -1;\n        }\n\n        int mid;\n        while(low < high) {\n            mid = (low + high) / 2;\n\n            if(data[mid] < key) {\n                low = mid + 1;\n            } else {\n                high = mid;\n            }\n\n        }\n\n        if (low > 0) {\n            low--;\n        }\n\n        return low;\n    }\n};\n\n/**\n * @brief Arrayf\n */\ntypedef\tArray<float> Arrayf;\n\n/**\n * @brief Arrayi\n */\ntypedef\tArray<int> Arrayi;\n\n/**\n * @brief Arrayui\n */\ntypedef\tArray<unsigned int> Arrayui;\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_ARRAY_HPP */\n\n"
  },
  {
    "path": "include/util/bbox.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_BBOX_HPP\n#define PIC_UTIL_BBOX_HPP\n\n#include \"../base.hpp\"\n#include \"../util/string.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The BBox class manages the creation of bounding boxes for images.\n */\nclass BBox\n{\npublic:\n    int x0, y0, z0, x1, y1, z1;\n    int width, height, frames;\n\n    /**\n     * @brief BBox is a basic constructor. It does nothing.\n     */\n    BBox()\n    {\n\n    }\n\n    /**\n     * @brief BBox is a constructor setting the BBox up.\n     * @param width is the maxium horizontal coordinate in pixels.\n     * The minimum is set to 0.\n     * @param height is the maxium vertical coordinate in pixels.\n     * The minimum is set to 0.\n     */\n    BBox(int width, int height)\n    {\n        setBox(0, width, 0, height, 0, 1, width, height, 1);\n    }\n\n    /**\n     * @brief BBox is a constructor setting the BBox up.\n     * @param width is the maxium horizontal coordinate in pixels.\n     * The minimum is set to 0.\n     * @param height is the maxium vertical coordinate in pixels.\n     * The minimum is set to 0.\n     * @param frames is the maxium temporal coordinate in pixels.\n     * The minimum is set to 0.\n     */\n    BBox(int width, int height, int frames)\n    {\n        setBox(0, width, 0, height, 0, frames, width, height, frames);\n    }\n\n    /**\n     * @brief BBox is a constructor setting the BBox up.\n     * @param x0 is the minimum horizontal coordinate in pixels.\n     * @param x1 is the maximum horizontal coordinate in pixels.\n     * @param y0 is the minimum vertical coordinate in pixels.\n     * @param y1 is the maximum vertical coordinate in pixels.\n     */\n    BBox(int x0, int x1, int y0, int y1)\n    {\n        setBox(x0, x1, y0, y1, 0, 1, -1, -1, 1);\n    }\n\n    /**\n     * @brief BBox is a constructor setting the BBox up.\n     * @param x0 is the minimum horizontal coordinate in pixels.\n     * @param x1 is the maximum horizontal coordinate in pixels.\n     * @param y0 is the minimum vertical coordinate in pixels.\n     * @param y1 is the maximum vertical coordinate in pixels.\n     * @param width is the horizontal size in pixels.\n     * @param height is the vertical size in pixels.\n     */\n    BBox(int x0, int x1, int y0, int y1, int width, int height)\n    {\n        setBox(x0, x1, y0, y1, 0, 1, width, height, 1);\n    }\n\n    /**\n     * @brief BBox\n     * @param x0 is the horizontal coordinate in pixels.\n     * @param y0 is the vertical coordinate in pixels.\n     * @param size is the patch size\n     * @param width is the original width of the image.\n     * @param height is the original height of the image.\n     */\n    BBox(int x0, int y0, int size, int width, int height)\n    {\n        setCentered(x0, y0, size, width, height);\n    }\n\n    /**\n     * @brief Size computes the number of pixels in a bounding box.\n     * @return It returns the number of pixels in a bounding box.\n     */\n    int Size()\n    {\n        return (y1 - y0) * (x1 - x0) * (z1 - z0);\n    }\n\n    /**\n     * @brief setBox sets a BBox up.\n     * @param x0 is the minimum horizontal coordinate in pixels.\n     * @param x1 is the maximum horizontal coordinate in pixels.\n     * @param y0 is the minimum vertical coordinate in pixels.\n     * @param y1 is the maximum vertical coordinate in pixels.\n     * @param z0 is the minimum temporal coordinate in pixels.\n     * @param z1 is the maximum temporal coordinate in pixels.\n     * @param width is the original width of the image.\n     * @param height is the original height of the image.\n     * @param frames is the original length of the image.\n     */\n    void setBox(int x0, int x1, int y0, int y1, int z0, int z1, int width,\n                int height, int frames)\n    {\n        this->x0 = x0;\n        this->y0 = y0;\n        this->z0 = z0;\n\n        this->x1 = x1;\n        this->y1 = y1;\n        this->z1 = z1;\n\n        this->width = width;\n        this->height = height;\n        this->frames = frames;\n    }\n\n    /**\n     * @brief SetCentered\n     * @param x0 is the horizontal coordinate in pixels.\n     * @param y0 is the vertical coordinate in pixels.\n     * @param size is the patch size\n     * @param width is the original width of the image.\n     * @param height is the original height of the image.\n     */\n    void setCentered(int x0, int y0, int size, int width, int height)\n    {\n        this->z0 = 0;\n        this->z1 = 1;\n\n        int halfSize = size >> 1;\n\n        this->x0 = x0 - halfSize;\n        this->x1 = x0 + halfSize;\n\n        this->y0 = y0 - halfSize;\n        this->y1 = y0 + halfSize;\n\n        this->width = width;\n        this->height = height;\n        this->frames = 1;\n    }\n\n    /**\n     * @brief getFourBlocks sets the BBox as a quadrant of a given size.\n     * @param width is horizontal size in pixels.\n     * @param height is the vertical size in pixels.\n     * @param i is the i-th quadrant.\n     */\n    void getFourBlocks(int width, int height, int i)\n    {\n        int halfWidth  = width >> 1;\n        int halfHeight = height >> 1;\n\n        int dataX[] = {0, 0, halfWidth, halfWidth};\n        int dataY[] = {0, halfHeight, 0, halfHeight};\n\n        if((width % 2) == 1) {\n            halfWidth++;\n        }\n\n        if((height % 2) == 1) {\n            halfHeight++;\n        }\n\n        setBox(dataX[i], dataX[i] + halfWidth,\n               dataY[i], dataY[i] + halfHeight,\n               0, 1,\n               width, height, 1);\n        //\tprint();\n    }\n\n    /**\n     * @brief toString returns a string representation of BBox\n     * @return It returns a string with the BBox content.\n     */\n    std::string toString()\n    {\n        return \"X = (\" + fromNumberToString(x0) + \", \" + fromNumberToString(x1) + \") \" +\n               \"Y = (\" + fromNumberToString(y0) + \", \" + fromNumberToString(y1) + \") \" +\n               \"Z = (\" + fromNumberToString(z0) + \", \" + fromNumberToString(z1) + \")\";\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_BBOX_HPP */\n\n"
  },
  {
    "path": "include/util/buffer.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_BUFFER_HPP\n#define PIC_UTIL_BUFFER_HPP\n\n#include <string.h>\n\n#include \"../base.hpp\"\n#include \"../util/math.hpp\"\n#include \"../util/array.hpp\"\n\nnamespace pic {\n\ntemplate<class T>\nclass Buffer\n{\npublic:\n    Buffer()\n    {\n\n    }\n\n    /**\n     * @brief assign assigns value to buffer\n     * @param buffer is the output buffer\n     * @param n is the number of elements of the buffer\n     * @param value is the value to be assigned to all values of buffer\n     * @return it returns the pointer to buffer\n     */\n    static T *assign(T *buffer, int n, T value)\n    {\n        if(buffer == NULL) {\n            if(n > 0) {\n                buffer = new T[n];\n            } else {\n                return buffer;\n            }\n        }\n\n        #pragma omp parallel for\n        for(int i = 0; i < n; i++) {\n            buffer[i] = value;\n        }\n\n        return buffer;\n    }\n\n    /**\n     * @brief assign assigns bufferIn to bufferOut\n     * @param bufferOut is the output buffer\n     * @param bufferIn is the input buffer\n     * @param n is the number of elements of bufferIn and bufferOut\n     * (they have to be of same length)\n     * @return it returns the pointer to buffer\n     */\n    static T *assign(T *bufferOut, T *bufferIn, int n)\n    {\n        memcpy(bufferOut, bufferIn, n * sizeof(T));\n        return bufferOut;\n    }\n\n    /**\n     * @brief add peforms addition\n     * @param buffer is the output buffer\n     * @param n is the number of elements of the buffer\n     * @param value is the value to be added to all values of buffer\n     * @return it returns the pointer to buffer\n     */\n    static T *add(T *buffer, int n, T value)\n    {\n        #pragma omp parallel for\n\n        for(int i = 0; i < n; i++) {\n            buffer[i] += value;\n        }\n\n        return buffer;\n    }\n\n    /**\n     * @brief add\n     * @param bufferOut\n     * @param bufferIn0\n     * @param bufferIn1\n     * @param n\n     * @return\n     */\n    static T *add(T *bufferOut, T *bufferIn0, T *bufferIn1, int n)\n    {\n        #pragma omp parallel for\n        for(int i = 0; i < n; i++) {\n            bufferOut[i] = bufferIn0[i] + bufferIn1[i];\n        }\n\n        return bufferOut;\n    }\n\n    static T *add(T *bufferOut, T *bufferIn, int n)\n    {\n        #pragma omp parallel for\n\n        for(int i = 0; i < n; i++) {\n            bufferOut[i] += bufferIn[i];\n        }\n\n        return bufferOut;\n    }\n\n\n    static T *addS(T *bufferOut, T *bufferIn, int n, int channels)\n    {\n        #pragma omp parallel for\n        for(int ind = 0; ind < n; ind++) {\n            int i = ind * channels;\n\n            float val = bufferIn[ind];\n\n            for(int j = 0; j < channels; j++) {\n                bufferOut[i + j] += val;\n            }\n        }\n\n        return bufferOut;\n    }\n\n     /**\n     * @brief mul multiplies a constant value\n     * @param buffer\n     * @param n\n     * @param value\n     * @return\n     */\n    static T *mul(T *buffer, int n, T value)\n    {\n        #pragma omp parallel for\n        for(int i = 0; i < n; i++) {\n            buffer[i] *= value;\n        }\n\n        return buffer;\n    }\n\n\n    /**\n     * @brief mul\n     * @param bufferOut\n     * @param bufferIn0\n     * @param bufferIn1\n     * @param n\n     * @return\n     */\n    static T *mul(T *bufferOut, T *bufferIn0, T *bufferIn1, int n)\n    {\n        #pragma omp parallel for\n\n        for(int i = 0; i < n; i++) {\n            bufferOut[i] = bufferIn0[i] * bufferIn1[i];\n        }\n\n        return bufferOut;\n    }\n\n    /**\n     * @brief BufferMul\n     * @param bufferOut\n     * @param bufferIn\n     * @param n\n     * @return\n     */\n    static T *mul(T *bufferOut, T *bufferIn, int n)\n    {\n        #pragma omp parallel for\n\n        for(int i = 0; i < n; i++) {\n            bufferOut[i] *= bufferIn[i];\n        }\n\n        return bufferOut;\n    }\n\n    /**\n     * @brief mulS\n     * @param bufferOut\n     * @param bufferIn\n     * @param n\n     * @param channels\n     * @return\n     */\n    static T *mulS(T *bufferOut, T *bufferIn, int n, int channels)\n    {\n        #pragma omp parallel for\n        for(int ind = 0; ind < n; ind++) {\n            int i = ind * channels;\n\n            float val = bufferIn[ind];\n\n            for(int j = 0; j < channels; j++) {\n                bufferOut[i + j] *= val;\n            }\n        }\n\n        return bufferOut;\n    }\n\n    /**\n     * @brief sub\n     * @param buffer\n     * @param n\n     * @param value\n     * @return\n     */\n    static T *sub(T *buffer, int n, T value)\n    {\n        #pragma omp parallel for\n        for(int i = 0; i < n; i++) {\n            buffer[i] -= value;\n        }\n\n        return buffer;\n    }\n\n    /**\n     * @brief sub\n     * @param bufferOut\n     * @param bufferIn0\n     * @param bufferIn1\n     * @param n\n     * @return\n     */\n    static T *sub(T *bufferOut, T *bufferIn0, T *bufferIn1, int n)\n    {\n        #pragma omp parallel for\n        for(int i = 0; i < n; i++) {\n            bufferOut[i] = bufferIn0[i] - bufferIn1[i];\n        }\n\n        return bufferOut;\n    }\n\n    /**\n     * @brief sub\n     * @param bufferOut\n     * @param bufferIn\n     * @param n\n     * @return\n     */\n    static T *sub(T *bufferOut, T *bufferIn, int n)\n    {\n        #pragma omp parallel for\n        for(int i = 0; i < n; i++) {\n            bufferOut[i] -= bufferIn[i];\n        }\n\n        return bufferOut;\n    }\n\n    /**\n     * @brief subS\n     * @param bufferOut\n     * @param bufferIn\n     * @param n\n     * @param channels\n     * @return\n     */\n    static T *subS(T *bufferOut, T *bufferIn, int n, int channels)\n    {\n        #pragma omp parallel for\n        for(int ind = 0; ind < n; ind++) {\n            int i = ind * channels;\n\n            float val = bufferIn[ind];\n\n            for(int j = 0; j < channels; j++) {\n                bufferOut[i + j] -= val;\n            }\n        }\n\n        return bufferOut;\n    }\n\n    /**\n     * @brief div divides by a constant value\n     * @param buffer\n     * @param n\n     * @param value\n     * @return\n     */\n    static T *div(T *buffer, int n, T value)\n    {\n        #pragma omp parallel for\n        for(int i = 0; i < n; i++) {\n            buffer[i] /= value;\n        }\n\n        return buffer;\n    }\n\n    /**\n     * @brief div\n     * @param bufferOut\n     * @param bufferIn0\n     * @param bufferIn1\n     * @param n\n     * @return\n     */\n    static T *div(T *bufferOut, T *bufferIn0, T *bufferIn1, int n)\n    {\n        #pragma omp parallel for\n        for(int i = 0; i < n; i++) {\n            bufferOut[i] = bufferIn0[i] / bufferIn1[i];\n        }\n\n        return bufferOut;\n    }\n\n    /**\n     * @brief div\n     * @param bufferOut\n     * @param bufferIn\n     * @param n\n     * @return\n     */\n    static T *div(T *bufferOut, T *bufferIn, int n)\n    {\n        #pragma omp parallel for\n        for(int i = 0; i < n; i++) {\n            bufferOut[i] /= bufferIn[i];\n        }\n\n        return bufferOut;\n    }\n\n    /**\n     * @brief divS\n     * @param bufferOut\n     * @param bufferIn\n     * @param n\n     * @param channels\n     * @return\n     */\n    static T *divS(T *bufferOut, T *bufferIn, int n, int channels)\n    {\n        #pragma omp parallel for\n        for(int ind = 0; ind < n; ind++) {\n            int i = ind * channels;\n\n            float val = bufferIn[ind];\n\n            for(int j = 0; j < channels; j++) {\n                bufferOut[i + j] /= val;\n            }\n        }\n\n        return bufferOut;\n    }\n\n    /**\n     * @brief flipH flips a buffer horizontally\n     * @param buffer\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    static void flipH(T *buffer, int width, int height, int channels,\n                            int frames)\n    {\n        int steps = width >> 1;\n\n        #pragma omp parallel for\n        for(int i = 0; i < height; i++) {\n            int ind = i * width;\n\n            for(int j = 0; j < steps; j++) {\n                int i0 = (ind + j) * channels;\n                int i1 = (ind + width - j - 1) * channels;\n\n                for(int k = 0; k < channels; k++) { //swap\n                    T tmp        = buffer[i0 + k];\n                    buffer[i0 + k] = buffer[i1 + k];\n                    buffer[i1 + k] = tmp;\n                }\n            }\n        }\n    }\n\n    /**\n     * @brief flipV flips an image vertically\n     * @param buffer\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     */\n    static void flipV(T *buffer, int width, int height, int channels,\n                                int frames)\n    {\n        int steps = height >> 1;\n\n        #pragma omp parallel for\n        for(int i = 0; i < steps; i++) {\n            int ind0 = i * width;\n            int ind1 = (height - i - 1) * width;\n\n            for(int j = 0; j < width; j++) {\n                int i0 = (ind0 + j) * channels;\n                int i1 = (ind1 + j) * channels;\n\n                for(int k = 0; k < channels; k++) { //swap\n                    T tmp          = buffer[i0 + k];\n                    buffer[i0 + k] = buffer[i1 + k];\n                    buffer[i1 + k] = tmp;\n                }\n            }\n        }\n    }\n\n\n    /**\n     * @brief rotate90CW rotates an image 90 CW\n     * @param buffer\n     * @param width\n     * @param height\n     * @param channels\n     */\n    static void rotate90CW(T *buffer, int &width, int &height, int channels)\n    {\n        if(buffer==NULL) {\n            return;\n        }\n\n        if(width == height) { //in place rotation\n          //  #pragma omp parallel for\n            int n = width;\n            for(int i = 0; i < n/2; i++) {\n                int i_n = n - i  - 1 ;\n\n                for(int j = i; j < (n - i - 1); j++) {\n                    int j_n = n - j  - 1 ;\n\n                    int i0 = (i   * n + j  ) * channels;\n                    int i1 = (j_n * n + i  ) * channels;\n                    int i2 = (i_n * n + j_n) * channels;\n                    int i3 = (j   * n + i_n) * channels;\n\n\n                    for(int k = 0; k < channels; k++) { //swap\n                        T tmp          = buffer[i0 + k];\n                        buffer[i0 + k] = buffer[i1 + k];\n                        buffer[i1 + k] = buffer[i2 + k];\n                        buffer[i2 + k] = buffer[i3 + k];\n                        buffer[i3 + k] = tmp;\n                    }\n                }\n            }\n        } else {\n            T *tmpBuffer = new T[width * height * channels];\n            memcpy(tmpBuffer, buffer, sizeof(T) * width * height * channels);\n\n            #pragma omp parallel for\n            for(int i = 0; i < height; i++) {\n                for(int j = 0; j < width; j++) {\n                    int i0 = (i * width + j) * channels;\n                    int i1 = (j * height + height - i - 1) * channels;\n\n                    for(int k = 0; k < channels; k++) {\n                        buffer[i1 + k] = tmpBuffer[i0 + k];\n                    }\n                }\n            }\n\n            delete[] tmpBuffer;\n\n            int tmp = width;\n            width   = height;\n            height  = tmp;\n        }\n    }\n\n    /**\n     * @brief rotate90CCW rotates an image 90 CCW\n     * @param buffer\n     * @param width\n     * @param height\n     * @param channels\n     */\n    static void rotate90CCW(T *buffer, int &width, int &height, int channels)\n    {\n        if(buffer==NULL) {\n            return;\n        }\n\n        if(width == height) { //in place rotation\n            #pragma omp parallel for\n            for(int i = 0; i < (height - 2); i++) {\n\n                for(int j = (i + 1); j < (width - 1); j++) {\n\n                    int i0 = (i * width + j) * channels;\n                    int i1 = (j * width + i) * channels;\n\n                    for(int k = 0; k < channels; k++) { //swap\n                        T tmp          = buffer[i0 + k];\n                        buffer[i0 + k] = buffer[i1 + k];\n                        buffer[i1 + k] = tmp;\n                    }\n                }\n            }\n        } else {\n            T *tmpBuffer = new T[width * height * channels];\n            memcpy(tmpBuffer, buffer, sizeof(T) * width * height * channels);\n\n            #pragma omp parallel for\n            for(int i = 0; i < height; i++) {\n                for(int j = 0; j < width; j++) {\n                    int i0 = (i * width  + j) * channels;\n                    int i1 = ((width-j-1) * height + i) * channels;\n\n                    for(int k = 0; k < channels; k++) {\n                        buffer[i1 + k] = tmpBuffer[i0 + k];\n                    }\n                }\n            }\n\n            delete[] tmpBuffer;\n\n            int tmp = width;\n            width   = height;\n            height  = tmp;\n        }\n    }\n\n    /**\n     * @brief shift\n     * @param bufferOut\n     * @param bufferIn\n     * @param dx\n     * @param dy\n     * @param bReplicate\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     * @return\n     */\n    static T *shift(T *bufferOut, T *bufferIn, int dx, int dy, bool bReplicate,\n                    int width, int height, int channels, int frames)\n    {\n        if(bufferOut == NULL) {\n            bufferOut = new T[width * height * channels * frames];\n        }\n\n        T zero = T(0);\n        int wS, wE, hS, hE;\n        int wfS, wfE, hfS, hfE;\n        if(dx > 0) {\n            wS = 0;\n            wE = width - dx;\n\n            wfS = width - dx;\n            wfE = width;\n        } else {\n            wS = -dx;\n            wE = width;\n\n            wfS = 0;\n            wfE = -dx;\n        }\n\n        if(dy > 0) {\n            hS = 0;\n            hE = height - dy;\n\n            hfS = height - dy;\n            hfE = height;\n        } else {\n            hS = -dy;\n            hE = height;\n\n            hfS = 0;\n            hfE = -dy;\n        }\n\n        #pragma omp parallel for\n        for(int iOut = hS; iOut < hE; iOut++) {\n            int strideOut = iOut * width;\n            int iIn = iOut + dy;\n            int strideIn = iIn * width;\n\n            Array<T>::assign(&bufferIn[(strideIn + wS + dx) * channels], channels * (wE - wS),\n                             &bufferOut[(strideOut + wS) * channels]);\n            /*\n            for(int jOut = wS; jOut < wE; jOut++) {\n                int jIn = jOut + dx;\n\n                int indOut = (strideOut + jOut) * channels;\n                int indIn = (strideIn + jIn ) * channels;\n\n                Array<T>::assign(&bufferIn[indIn], channels,\n                                 &bufferOut[indOut]);\n            }*/\n        }\n\n\n        //block 1\n        int strideIn = dy > 0 ? (height - 1) * width : 0;\n        for(int iOut = hfS; iOut < hfE; iOut++) {\n            int strideOut = iOut * width;\n\n            for(int jOut = wS; jOut < wE; jOut++) {\n                int jIn = jOut + dx;\n\n                int indOut = (strideOut + jOut) * channels;\n                int indIn = (strideIn + jIn ) * channels;\n\n                if(bReplicate) {\n                    Array<T>::assign(&bufferIn[indIn], channels,\n                                     &bufferOut[indOut]);\n                } else {\n                    Array<T>::assign(zero, &bufferOut[indOut], channels);\n                }\n            }\n        }\n\n        //block 2\n        int jIn = dx > 0 ? width - 1 : 0;\n        for(int iOut = hS; iOut < hE; iOut++) {\n            int strideOut = iOut * width;\n            int iIn = iOut + dy;\n            int strideIn = iIn * width;\n\n            for(int jOut = wfS; jOut < wfE; jOut++) {\n\n                int indOut = (strideOut + jOut) * channels;\n                int indIn = (strideIn + jIn ) * channels;\n\n                if(bReplicate) {\n                    Array<T>::assign(&bufferIn[indIn], channels,\n                                     &bufferOut[indOut]);\n                } else {\n                    Array<T>::assign(zero, &bufferOut[indOut], channels);\n                }\n            }\n        }\n\n        //block3\n        jIn = dx > 0 ? width - 1 : 0;\n        strideIn = dy > 0 ? (height - 1) * width : 0;\n        int indIn = (strideIn + jIn ) * channels;\n\n        for(int iOut = hfS; iOut < hfE; iOut++) {\n            int strideOut = iOut * width;\n\n            for(int jOut = wfS; jOut < wfE; jOut++) {\n\n                int indOut = (strideOut + jOut) * channels;\n\n                if(bReplicate) {\n                    Array<T>::assign(&bufferIn[indIn], channels,\n                                     &bufferOut[indOut]);\n                } else {\n                    Array<T>::assign(zero, &bufferOut[indOut], channels);\n                }\n            }\n        }\n        return bufferOut;\n    }\n\n    /**\n     * @brief transpose transposes a buffer\n     * @param bufferOut\n     * @param bufferIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     * @return\n     */\n    static T* transpose(T *bufferOut, T *bufferIn, int width, int height,\n                        int channels, int frames)\n    {\n        if(bufferIn == NULL) {\n            return bufferOut;\n        }\n\n        if(bufferOut == NULL) {\n            bufferOut = new T[width * height * channels * frames];\n        }\n\n        for(int i = 0; i < height; i++) {\n            int indIn = i * width;\n\n            for(int j = i; j < width; j++) {\n                indIn = (indIn + j) * channels;\n\n                int indOut = ((j * height) + i) *  channels;\n\n                for(int k = 0; k < channels; k++) {\n                    bufferOut[indOut + k] = bufferIn[indIn + k];\n                }\n            }\n        }\n    }\n\n    /**\n     * @brief BGRtoRGB swizzles from BGR to RGB a buffer\n     * @param buffer\n     * @param width\n     * @param height\n     * @param channels\n     * @param frames\n     * @return\n     */\n    static T* BGRtoRGB(T *buffer, int width, int height,\n                       int channels, int frames)\n    {\n        int size = width * height * channels * frames;\n        for(int i = 0; i < size; i += channels) {\n            T tmp         = buffer[i];\n            buffer[i    ] = buffer[i + 2];\n            buffer[i + 2] = tmp;\n        }\n\n        return buffer;\n    }\n\n    /**\n     * @brief BufferFromLayerToIntervaleaved change from RGB RGB RGB... to RRR... GGG... BBB...\n     * @param bufferOut\n     * @param bufferIn\n     * @param n\n     * @param channels\n     * @return\n     */\n    static T* BufferFromLayerToIntervaleaved(T *bufferOut, T *bufferIn, int n, int channels)\n    {\n        #pragma omp parallel for\n        for(int i = 0; i < n; i++) {\n            for(int k = 0; k < channels; k++) {\n                int iIn  = k * n + i;\n                int iOut = i * channels + k;\n                bufferOut[iOut] = bufferIn[iIn];\n            }\n        }\n    }\n\n    /**\n     * @brief clone\n     * @param bufferOut\n     * @param bufferIn\n     * @param n\n     * @param channels\n     * @return\n     */\n    static T *clone(T *bufferOut, T *bufferIn, int n, int channels)\n    {\n        if(bufferIn == NULL) {\n            return bufferOut;\n        }\n\n        if(bufferOut == NULL) {\n            bufferOut = new T[n * channels];\n        }\n\n        memcpy(bufferOut, bufferIn, n * channels * sizeof(T));\n\n        return bufferOut;\n    }\n\n    /**\n     * @brief unique\n     * @param buffer\n     * @param n\n     * @param uniqueValues\n     * @return\n     */\n    static void unique(T *buffer, int n, std::set<T> &uniqueValues)\n    {\n        for(int i = 0; i < n; i++) {\n            uniqueValues.insert(buffer[i]);\n        }\n    }\n\n    /**\n     * @brief copySubBuffer\n     * @param bufIn\n     * @param bi_width\n     * @param bi_height\n     * @param bi_channels\n     * @param startX\n     * @param startY\n     * @param bufOut\n     * @param bo_width\n     * @param bo_height\n     * @param bo_channels\n     */\n    static void copySubBuffer(T *bufIn,\n                              int bi_width,\n                              int bi_height,\n                              int bi_channels,\n                              int startX,\n                              int startY,\n                              T *bufOut,\n                              int bo_width,\n                              int bo_height,\n                              int bo_channels)\n    {\n        if(bufIn == NULL || bufOut == NULL || bi_channels != bo_channels) {\n            return;\n        }\n\n        //check bounds\n        int sX, sY, eX, eY, dX, dY, shiftX, shiftY;\n\n        //start\n        sX = MIN(startX, bo_width);\n        sX = MAX(sX, 0);\n\n        sY = MIN(startY, bo_height);\n        sY = MAX(startY, 0);\n\n        dX = sX - startX;\n\n        if(dX < 0) {\n            shiftX = dX;\n        } else {\n            shiftX = -sX;\n        }\n\n        //end\n        eX = MIN(startX + bi_width, bo_width);\n        eX = MAX(eX, 0);\n\n        eY = MIN(startY + bi_height, bo_height);\n        eY = MAX(eY, 0);\n\n        dY = sY - startY;\n\n        if(dY < 0) {\n            shiftY = dY;\n        } else {\n            shiftY = -sY;\n        }\n\n        #pragma omp parallel for\n        for(int j = sY; j < eY; j++) {\n            int index_bi = (j + shiftY) * bi_width;\n            int index_bo = j * bo_width;\n\n            Array<T>::assign(bufIn + index_bi + sX + shiftY,\n                             bi_channels * (eX - sX),\n                             bufOut + index_bo + sX);\n            /*\n            for(int i = sX; i < eX; i++) {\n                Array<T>::assign(bufIn + index_bi + i + shiftY,\n                                 bi_channels,\n                                 bufOut + index_bo + i);\n            }*/\n        }\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_BUFFER_HPP */\n\n"
  },
  {
    "path": "include/util/cached_table.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_CACHED_TABLE_HPP\n#define PIC_UTIL_CACHED_TABLE_HPP\n\nnamespace pic {\n\n/**\n * @brief The CachedTable class\n */\nclass CachedTable\n{\npublic:\n    int n;\n    float COS_TABLE[512];\n    float SIN_TABLE[512];\n    float *PATCH;\n    float inv_width, inv_height;\n\n    /**\n     * @brief CachedTable creates a precomputed table of sin and cos values.\n     * @param patchSize is the size of the patch.\n     * @param width is the width of the image.\n     * @param height is the height of the image.\n     */\n    CachedTable(int patchSize, int width, int height)\n    {\n        n = 512;\n        float C_PI_2_inv_n = C_PI_2 / float(n);\n\n        for(int i = 0; i < n; i++) {\n            float value = float(i) * C_PI_2_inv_n;\n\n            COS_TABLE[i] = cosf(value);\n            SIN_TABLE[i] = sinf(value);\n        }\n\n        PATCH = new float [patchSize + 1];\n        int halfPatchSize = patchSize >> 1;\n\n        for(int i = -halfPatchSize; i <= halfPatchSize; i++) {\n            PATCH[i + halfPatchSize] = float(i);\n        }\n\n        inv_width  = 1.0f / float(width - 1);\n        inv_height = 1.0f / float(height - 1);\n\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_CACHED_TABLE_HPP */\n\n"
  },
  {
    "path": "include/util/compability.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_COMPABILITY_HPP\n#define PIC_UTIL_COMPABILITY_HPP\n\n#include \"../base.hpp\"\n\nnamespace pic {\n\n#ifndef PIC_WIN32\nPIC_INLINE int timeGetTime()\n{\n    return 1;\n}\n#endif\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_COMPABILITY_HPP */\n\n"
  },
  {
    "path": "include/util/convert_raw_to_images.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_CONVERT_RAW_TO_IMAGES_HPP\n#define PIC_UTIL_CONVERT_RAW_TO_IMAGES_HPP\n\n#include \"../base.hpp\"\n#include \"../util/raw.hpp\"\n#include \"../util/string.hpp\"\n#include \"../image.hpp\"\n\nnamespace pic {\n\n/**\n * @brief ConvertRAWtoImages converts .RAW into format\n * @param nameDirectory\n * @param format\n * @param width\n * @param height\n */\nPIC_INLINE void ConvertRAWtoImages(std::string nameDirectory, std::string format,\n                        int width, int height)\n{\n    StringVec vec;\n    FileLister::List(nameDirectory, \"raw\", &vec);\n\n    Image img;\n\n    for(unsigned int i = 0; i < vec.size(); i++) {\n        img.ReadRAW(vec[i], \"NULL\", RAW_U16_RGGB, width, height);\n\n        std::string out = removeExtension(vec[i]);\n        out += \".\";\n        out += format;\n        printf(\"%s\\n\", out.c_str());\n        img.Write(out);\n    }\n}\n\n/**\n * @brief ConvertDetect\n * @param nameDirectory\n * @param format\n * @param width\n * @param height\n */\nPIC_INLINE void ConvertDetect(std::string nameDirectory, std::string format, int width,\n                   int height)\n{\n\n    RAW<unsigned short> *imgMean = CalculateRAWMeanFromFile<unsigned short>\n                                   (nameDirectory, \"raw\", width, height);\n\n    StringVec vec;\n    FileLister::List(nameDirectory, \"raw\", &vec);\n\n    RAW<unsigned short> tmp;\n    Image img;\n\n    for(unsigned int i = 0; i < vec.size(); i++) {\n        tmp.Read(vec[i], width * height);\n\n        for(int j = 0; j < tmp.nData; j++) {\n            int diff = (tmp.data[j] - imgMean->data[j]);\n            diff = diff > 0 ? diff : -diff;\n\n            if(diff > 6200) {\n                tmp.data[j] = 10000;\n            } else {\n                tmp.data[j] = 0;\n            }\n        }\n\n        tmp.Write(\"tmpRAW.raw\");\n        img.ReadRAW(\"tmpRAW.raw\", \"NULL\", RAW_U16_RGGB, width, height);\n\n        std::string out = vec[i];\n        out += \".\";\n        out += format;\n        printf(\"%s\\n\", out.c_str());\n        img.Write(out);\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_CONVERT_RAW_TO_IMAGES_HPP */\n\n"
  },
  {
    "path": "include/util/dynamic_range.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_DYNAMIC_RANGE_HPP\n#define PIC_UTIL_DYNAMIC_RANGE_HPP\n\n#include \"../base.hpp\"\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The LDR_type enum\n */\nenum LDR_type {LT_NOR, LT_NOR_GAMMA, LT_NONE};\n\n/**\n * @brief estimateAverageLuminance estimates the average luminance of the shot.\n * @param shutter_speed is the shutter speed of the camera\n * @param aperture_value is the aperture value of the camera\n * @param iso_value is the ISO value of the camera\n * @param K_value is a value in [10.6, 13.4] depending on the camera\n * @return\n */\nPIC_INLINE float estimateAverageLuminance(float shutter_speed,\n                                          float aperture_value = 1.0f,\n                                          float iso_value = 1.0f,\n                                          float K_value = 12.5f)\n{\n    K_value = CLAMPi(K_value, 10.6f, 13.4f);\n\n    return (iso_value * shutter_speed) / (K_value * aperture_value * aperture_value);\n}\n\n/**\n * @brief checkNormalized checks if data is in [0,1].\n * @param data\n * @param size\n * @param delta\n * @return\n */\nPIC_INLINE bool checkNormalized(const float *data, int size, float delta = 1e-6f)\n{\n    float thr = 1.0f + delta;\n\n    for(int i = 0; i < size; i++) {\n        if(data[i] > thr) {\n            return false;\n        }\n    }\n\n    return true;\n}\n\n/**\n * @brief convertLDR2HDR converts a buffer of unsigned char into float.\n * @param dataIn\n * @param dataOut\n * @param size\n * @param type\n * @param gamma\n * @return\n */\nPIC_INLINE float *convertLDR2HDR(unsigned char *dataIn, float *dataOut,\n                                 int size, LDR_type type, float gamma = 2.2f)\n{\n    if(dataIn == NULL) {\n        return NULL;\n    }\n\n    if(dataOut == NULL) {\n        dataOut = new float[size];\n    }\n\n    float LUT[256];\n    for(int i = 0; i < 256; i++) {\n        float i_f = float(i);\n\n        switch(type) {\n            case LT_NOR: {//normalize in [0,1]\n                LUT[i] = i_f / 255.0f;\n            }\n            break;\n\n            case LT_NOR_GAMMA: {//normalize in [0,1] + GAMMA correction removal\n                LUT[i] = powf(i_f / 255.0f, gamma);\n            }\n            break;\n\n            case LT_NONE: { //LT_NONE\n                //do nothing\n                LUT[i] = i_f;\n            }\n        }\n    }\n\n    #pragma omp parallel for\n    for(int i = 0; i < size; i++) {\n        dataOut[i] = LUT[dataIn[i]];\n    }\n\n    return dataOut;\n}\n\n/**\n * @brief convertHDR2LDR converts a buffer of float into unsigned char.\n * @param dataIn\n * @param dataOut\n * @param size\n * @param type\n * @param gamma\n * @return\n */\nPIC_INLINE unsigned char *convertHDR2LDR(const float *dataIn, unsigned char *dataOut,\n        int size, LDR_type type, float gamma = 2.2f)\n{\n    if(dataIn == NULL) {\n        return NULL;\n    }\n\n    if(dataOut == NULL) {\n        dataOut = new unsigned char[size];\n    }\n\n    gamma = gamma > 0.0f ? gamma : 2.2f;\n\n    float invGamma = 1.0f / gamma;\n\n    switch(type) {\n        case LT_NONE: {//simple cast\n            #pragma omp parallel for\n            for(int i = 0; i < size; i++) {\n                dataOut[i] = CLAMPi(int(lround(dataIn[i])), 0, 255);\n            }\n        }\n        break;\n\n        case LT_NOR: {//convert into 8-bit\n            #pragma omp parallel for\n            for(int i = 0; i < size; i++) {\n                dataOut[i] = CLAMPi(int(lround(dataIn[i] * 255.0f)), 0, 255);\n            }\n        }\n        break;\n\n        case LT_NOR_GAMMA: {//convert into 8-bit + GAMMA correction application\n            #pragma omp parallel for\n            for(int i = 0; i < size; i++) {\n                float tmp = powf(dataIn[i], invGamma);\n                dataOut[i] = CLAMPi(int(lround(tmp * 255.0f)), 0, 255);\n            }\n        }\n        break;\n    }\n\n    return dataOut;\n}\n\n} // end namespace pic\n\n#endif //PIC_UTIL_DYNAMIC_RANGE_HPP\n"
  },
  {
    "path": "include/util/eigen_util.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#include <vector>\n\n#include \"../base.hpp\"\n\n#include \"../util/matrix_3_x_3.hpp\"\n#include \"../util/vec.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/LU\"\n    #include \"../externals/Eigen/Geometry\"\n#else\n    #include <Eigen/LU>\n    #include <Eigen/Geometry>\n#endif\n\n#endif\n\n#ifndef PIC_EIGEN_UTIL\n#define PIC_EIGEN_UTIL\n\n#ifndef PIC_DISABLE_EIGEN\nnamespace Eigen {\n    typedef Matrix<float,  3, 4> Matrix34f;\n    typedef Matrix<double, 3, 4> Matrix34d;\n}\n#endif\n\nnamespace pic {\n\n#ifndef PIC_DISABLE_EIGEN\n\n/**\n * @brief readMatrix34dFromFile\n * @param nameFile\n * @return\n */\nPIC_INLINE Eigen::Matrix34d readMatrix34dFromFile(std::string nameFile)\n{\n    Eigen::Matrix34d mat;\n\n    FILE *file = fopen(nameFile.c_str(), \"r\");\n\n    if(file == NULL) {\n        return mat;\n    }\n\n    for(int i = 0; i < 3; i++) {\n        for(int j = 0; j < 4; j++) {\n            float val;\n            fscanf(file, \"%f\", &val);\n            mat(i, j) = double(val);\n        }\n    }\n\n    fclose(file);\n\n    return mat;\n}\n\n/**\n * @brief writeMatrix34dToFile\n * @param nameFile\n * @param mat\n * @return\n */\nPIC_INLINE bool writeMatrix34dToFile(std::string nameFile, Eigen::Matrix34d &mat)\n{\n    FILE *file = fopen(nameFile.c_str(), \"w\");\n\n    if(file == NULL) {\n        return false;\n    }\n\n    for(int i = 0; i < 3; i++) {\n        for(int j = 0; j < 4; j++) {\n            fprintf(file, \"%f \", mat(i, j));\n        }\n\n        if(i < 2) {\n            fprintf(file, \"\\n\");\n        }\n    }\n\n    fclose(file);\n\n    return true;\n}\n\n/**\n * @brief DiagonalMatrix creates a diagonal matrix.\n * @param D a vector of size 3.\n * @return It returns a diagonal matrix.\n */\nPIC_INLINE Eigen::Matrix3d DiagonalMatrix(Eigen::Vector3d D)\n{\n    Eigen::Matrix3d ret;\n\n    ret.setZero();\n    ret(0, 0) = D[0];\n    ret(1, 1) = D[1];\n    ret(2, 2) = D[2];\n\n    return ret;\n}\n\n/**\n * @brief getDiagonalFromMatrix\n * @param mat\n * @return\n */\nPIC_INLINE Eigen::Vector3d getDiagonalFromMatrix(Eigen::Matrix3d &mat)\n{\n    Eigen::Vector3d D;\n\n    D[0] = mat(0, 0);\n    D[1] = mat(1, 1);\n    D[2] = mat(2, 2);\n\n    return D;\n}\n\n/**\n * @brief getSquareMatrix\n * @param mat\n * @return\n */\nPIC_INLINE Eigen::Matrix3d getSquareMatrix(Eigen::Matrix34d &mat)\n{\n    Eigen::Matrix3d ret;\n    ret(0, 0) = mat(0, 0);\n    ret(0, 1) = mat(0, 1);\n    ret(0, 2) = mat(0, 2);\n\n    ret(1, 0) = mat(1, 0);\n    ret(1, 1) = mat(1, 1);\n    ret(1, 2) = mat(1, 2);\n\n    ret(2, 0) = mat(2, 0);\n    ret(2, 1) = mat(2, 1);\n    ret(2, 2) = mat(2, 2);\n\n    return ret;\n}\n\n/**\n * @brief getLastColumn\n * @param mat\n * @return\n */\nPIC_INLINE Eigen::Vector3d getLastColumn(Eigen::Matrix34d &mat)\n{\n    Eigen::Vector3d ret;\n\n    ret[0] = mat(0, 3);\n    ret[1] = mat(1, 3);\n    ret[2] = mat(2, 3);\n\n    return ret;\n}\n\n/**\n * @brief addOne\n * @param x\n * @return\n */\nPIC_INLINE Eigen::Vector3f addOne(Eigen::Vector2f &x)\n{\n    return Eigen::Vector3f(x[0], x[1], 1.0f);\n}\n\n/**\n * @brief addOne\n * @param x\n * @return\n */\nPIC_INLINE Eigen::Vector3d addOne(Eigen::Vector2d &x)\n{\n    return Eigen::Vector3d(x[0], x[1], 1.0);\n}\n\n/**\n * @brief addOne\n * @param x\n * @return\n */\nPIC_INLINE Eigen::Vector4d addOne(Eigen::Vector3d &x)\n{\n    return Eigen::Vector4d(x[0], x[1], x[2], 1.0);\n}\n\n/**\n * @brief printfVet3d\n * @param x\n */\nPIC_INLINE void printfVet3d(Eigen::Vector3d &x)\n{\n    printf(\"%f %f %f\\n\", x[0], x[1], x[2]);\n}\n\n\n/**\n * @brief printf\n * @param mat\n */\nPIC_INLINE void printfMat(Eigen::MatrixXd mat)\n{\n    for(int i = 0; i < mat.rows(); i++){\n        for(int j = 0; j < mat.cols(); j++){\n            printf(\"%3.3f \", mat(i, j));\n        }\n        printf(\"\\n\");\n    }\n}\n\n/**\n * @brief printf\n * @param mat\n */\nPIC_INLINE void printfMat(Eigen::Matrix3f &mat)\n{\n    for(int i = 0; i < 3; i++){\n        for(int j = 0; j < 3; j++){\n            printf(\"%f \", mat(i, j));\n        }\n        printf(\"\\n\");\n    }\n}\n    \n/**\n  * @brief printf\n  * @param mat\n  */\nPIC_INLINE void printfMat34d(Eigen::Matrix34d &mat)\n{\n    for(int i = 0; i < 3; i++){\n        for(int j = 0; j < 4; j++){\n            printf(\"%.9f \", mat(i, j));\n        }\n        printf(\"\\n\");\n    }\n}\n\n/**\n * @brief fprintf\n * @param mat\n */\nPIC_INLINE void fprintfMat(Eigen::MatrixXd &mat, std::string name)\n{\n    FILE *file = fopen(name.c_str(), \"w\");\n    for(int i = 0; i < mat.rows(); i++){\n        for(int j = 0; j < mat.cols(); j++){\n            fprintf(file, \"%.9f \", mat(i, j));\n        }\n        fprintf(file, \"\\n\");\n    }\n    fclose(file);\n}\n\n/**\n * @brief printf\n * @param mat\n */\nPIC_INLINE void printfMat(Eigen::Matrix3d &mat)\n{\n    for(int i = 0; i < 3; i++){\n        for(int j = 0; j < 3; j++){\n            printf(\"%f \", mat(i, j));\n        }\n        printf(\"\\n\");\n    }\n}\n\n/**\n * @brief getShiftScaleMatrix computes a shifting and scaling matrix\n * @param info is an array with the center (0 and 1) a scaling factor (3)\n * @return It returns a scaling and shifting matrix.\n */\nPIC_INLINE Eigen::Matrix3d getShiftScaleMatrix(Eigen::Vector3f &info)\n{\n    Eigen::Matrix3d ret;\n\n    double cX = info[0];\n    double cY = info[1];\n    double s  = 1.0 / info[2];\n\n    ret(0,0) = s;   ret(0,1) = 0.0; ret(0,2) = -cX / info[2];\n    ret(1,0) = 0.0; ret(1,1) = s;   ret(1,2) = -cY / info[2];\n    ret(2,0) = 0.0; ret(2,1) = 0.0; ret(2,2) = 1.0;\n\n    return ret;\n}\n\n/**\n * @brief CrossProduct computes a cross product matrix from a vector.\n * @param t a translation vector\n * @return It returns a cross product matrix.\n */\nPIC_INLINE Eigen::Matrix3d CrossProduct(Eigen::Vector3d &t)\n{\n    Eigen::Matrix3d ret;\n    ret(0, 0) =  0.0;  ret(0, 1) = -t[2]; ret(0, 2) =  t[1];\n    ret(1, 0) =  t[2]; ret(1, 1) =  0.0;  ret(1, 2) = -t[0];\n    ret(2, 0) = -t[1]; ret(2, 1) =  t[0]; ret(2, 2) =  0.0;\n    return ret;\n}\n\n/**\n * @brief rigidTransform computes a rigidi transformation in 3D.\n * @param point is the point to be transformed.\n * @param R is a rotation matrix 3x3.\n * @param t is a translation vector.\n * @return\n */\nPIC_INLINE Eigen::Vector3d rigidTransform(Eigen::Vector3d &point, Eigen::Matrix3d &R, Eigen::Vector3d &t)\n{\n    return R * point + t;\n}\n\n/**\n * @brief RotationMatrixRefinement\n * @param R\n * @return\n */\nPIC_INLINE Eigen::Matrix3d RotationMatrixRefinement(Eigen::Matrix3d &R)\n{\n    Eigen::Quaternion<double> reg(R);\n\n    return reg.toRotationMatrix();\n}\n\n/**\n * @brief MatrixConvert converts a matrix from a Eigen::Matrix3f representation\n * into a Matrix3x3 representation.\n * @param mat is an Eigen 3x3 matrix.\n * @return It returns a Matrix3x3 with values from mat.\n */\nPIC_INLINE Matrix3x3 MatrixConvert(Eigen::Matrix3f &mat)\n{\n    Matrix3x3 mtx;\n    mtx.data[0] = mat(0, 0);\n    mtx.data[1] = mat(0, 1);\n    mtx.data[2] = mat(0, 2);\n\n    mtx.data[3] = mat(1, 0);\n    mtx.data[4] = mat(1, 1);\n    mtx.data[5] = mat(1, 2);\n\n    mtx.data[6] = mat(2, 0);\n    mtx.data[7] = mat(2, 1);\n    mtx.data[8] = mat(2, 2);\n\n    return mtx;\n}\n\n\n/**\n * @brief MatrixConvert converts a matrix from a Eigen::Matrix3f representation\n * into a Matrix3x3 representation.\n * @param mat is an Eigen 3x3 matrix.\n * @return It returns a Matrix3x3 with values from mat.\n */\nPIC_INLINE Matrix3x3 MatrixConvert(Eigen::Matrix3d &mat)\n{\n    Matrix3x3 mtx;\n    mtx.data[0] = float(mat(0, 0));\n    mtx.data[1] = float(mat(0, 1));\n    mtx.data[2] = float(mat(0, 2));\n\n    mtx.data[3] = float(mat(1, 0));\n    mtx.data[4] = float(mat(1, 1));\n    mtx.data[5] = float(mat(1, 2));\n\n    mtx.data[6] = float(mat(2, 0));\n    mtx.data[7] = float(mat(2, 1));\n    mtx.data[8] = float(mat(2, 2));\n\n    return mtx;\n}\n\n/**\n * @brief getLinearArray\n * @param mat\n * @return\n */\nPIC_INLINE float *getLinearArrayFromMatrix(Eigen::Matrix3d &mat)\n{\n    int n = int(mat.cols() * mat.rows());\n\n    float *ret = new float[n];\n    int c = 0;\n    for(int i = 0; i < mat.rows(); i++) {\n        for(int j = 0; j < mat.cols(); j++) {\n            ret[c] = float(mat(i, j));\n            c++;\n        }\n    }\n\n    return ret;\n}\n\n/**\n * @brief getLinearArray\n * @param mat\n * @return\n */\nPIC_INLINE float *getLinearArrayFromMatrix(Eigen::Matrix3f &mat)\n{\n    int n = int(mat.cols() * mat.rows());\n\n    float *ret = new float[n];\n    int c = 0;\n    for(int i = 0; i < mat.rows(); i++) {\n        for(int j = 0; j < mat.cols(); j++) {\n            ret[c] = mat(i, j);\n            c++;\n        }\n    }\n\n    return ret;\n}\n\n/**\n * @brief getMatrixFromLinearArray\n * @param array\n * @param rows\n * @param cols\n * @return\n */\nPIC_INLINE Eigen::MatrixXf getMatrixfFromLinearArray(float *array, int rows, int cols)\n{\n    Eigen::MatrixXf ret = Eigen::MatrixXf(rows, cols);\n\n    int c = 0;\n    for(int i = 0; i < rows; i++) {\n        for(int j = 0; j < cols; j++) {\n            ret(i, j) = array[c];\n            c++;\n        }\n    }\n    return ret;\n}\n\n/**\n * @brief getMatrixFromLinearArray\n * @param array\n * @param rows\n * @param cols\n * @return\n */\nPIC_INLINE Eigen::MatrixXd getMatrixdFromLinearArray(float *array, int rows, int cols)\n{\n    Eigen::MatrixXd ret = Eigen::MatrixXd(rows, cols);\n\n    int c = 0;\n    for(int i = 0; i < rows; i++) {\n        for(int j = 0; j < cols; j++) {\n            ret(i, j) = array[c];\n            c++;\n        }\n    }\n    return ret;\n}\n\n/**\n * @brief getMatrix3dFromLinearArray\n * @param array\n * @return\n */\nPIC_INLINE Eigen::Matrix3d getMatrix3dFromLinearArray(float *array)\n{\n    Eigen::Matrix3d ret;\n\n    int c = 0;\n    for(int i = 0; i < 3; i++) {\n        for(int j = 0; j < 3; j++) {\n            ret(i, j) = array[c];\n            c++;\n        }\n    }\n    return ret;\n}\n\n/**\n * @brief MatrixConvert\n * @param mat\n * @return\n */\nPIC_INLINE Eigen::Matrix3f MatrixConvert(Matrix3x3 &mat)\n{\n    Eigen::Matrix3f mtx;\n    mtx(0, 0) = mat.data[0];\n    mtx(0, 1) = mat.data[1];\n    mtx(0, 2) = mat.data[2];\n\n    mtx(1, 0) = mat.data[3];\n    mtx(1, 1) = mat.data[4];\n    mtx(1, 2) = mat.data[5];\n\n    mtx(2, 0) = mat.data[6];\n    mtx(2, 1) = mat.data[7];\n    mtx(2, 2) = mat.data[8];\n\n    return mtx;\n}\n\n/**\n * @brief ComputeNormalizationTransform\n * @param points\n * @return\n */\nPIC_INLINE Eigen::Vector3f ComputeNormalizationTransform(std::vector< Eigen::Vector2f > &points)\n{\n    Eigen::Vector3f ret;\n\n    if(points.size() < 2) {\n        return ret;\n    }\n\n    ret[0] = 0.0f;\n    ret[1] = 0.0f;\n\n    for(unsigned int i = 0; i < points.size(); i++) {\n        ret[0] += points[i][0];\n        ret[1] += points[i][1];\n    }\n\n    float n = float(points.size());\n    ret[0] /= n;\n    ret[1] /= n;\n\n    ret[2] = 0.0;\n    for(unsigned int i = 0; i < points.size(); i++) {\n\n        float dx = points[i][0] - ret[0];\n        float dy = points[i][1] - ret[1];\n\n        ret[2] += sqrtf(dx * dx + dy * dy);\n    }\n\n    ret[2] = ret[2] / n / sqrtf(2.0f);\n\n    return ret;\n}\n\n/**\n * @brief convertFromEigenToVec\n * @param x\n */\nPIC_INLINE Vec2i convertFromEigenToVec(Eigen::Vector2i &x)\n{\n    return Vec2i(x[0], x[1]);\n}\n\n#endif\n\n}\n\n#endif // PIC_EIGEN_UTIL\n"
  },
  {
    "path": "include/util/fft.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_FFT_HPP\n#define PIC_UTIL_FFT_HPP\n\n#include <string.h>\n#include <complex>\n\n#include \"../base.hpp\"\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/**\n * @brief RE\n * @param x\n * @return\n */\nPIC_INLINE unsigned int RE(unsigned int x) {\n    return x << 1;\n}\n\n/**\n * @brief IM\n * @param x\n * @return\n */\nPIC_INLINE unsigned int IM(unsigned int x) {\n    return (x << 1) + 1;\n}\n\n/**\n * @brief complexf\n */\ntypedef std::complex<float> complexf;\n\n/**\n * @brief complexd\n */\ntypedef std::complex<double> complexd;\n\n/**\n * @brief DFT1D\n * @param in\n * @param n\n * @param out\n * @return\n */\nPIC_INLINE float *DFT1D(float *in, unsigned int n, float *out = NULL)\n{\n    if(out == NULL) {\n        out = new float[n * 2];\n    }\n\n    float n_f = float(n);\n\n    for(unsigned int i = 0; i < n ; i++) {\n        unsigned int re = RE(i);\n        unsigned int im = IM(i);\n\n        out[re] = 0.0f;\n        out[im] = 0.0f;\n\n        float i_f = float(i);\n        for(unsigned int j = 0; j < n ; j++) {\n\n            float angle = -C_PI_2 * i_f * float(j) / n_f;\n            out[re] += in[j] * cosf(angle);\n            out[im] += in[j] * sinf(angle);\n        }\n    }\n\n    return out;\n}\n\n/**\n * @brief bitReversal\n * @param n\n * @param nbit\n * @return\n */\nPIC_INLINE unsigned int bitReversal(unsigned int n, unsigned int nbit)\n{\n    unsigned int out = 0;\n    for(int i = nbit; i>0; i--) {\n        unsigned int bit = (n >> (i - 1)) & 0x00000001;\n        out += bit << (nbit - i);\n    }\n\n    return out;\n}\n\n/**\n * @brief FFTIterative1D\n * @param in\n * @param n\n * @param out\n * @return\n */\nPIC_INLINE float *FFTIterative1D(float *in, unsigned int n, float *out = NULL)\n{\n    if(out == NULL) {\n        out = new float[n * 2];\n    }\n\n    unsigned int logn = std::log2(n);\n\n    for(unsigned int i = 0; i< n; i++) {\n        //bit reversal\n        unsigned int i_rev = bitReversal(i, logn);\n        out[RE(i_rev)] = in[i];\n        out[IM(i_rev)] = 0.0f;\n    }\n\n    for(unsigned int s = 1; s <= logn; s++) {\n        int m = 1 << s;\n        float angle = -C_PI_2 / float(m);\n\n        complexf omega_m = complexf(cosf(angle), sinf(angle));\n        complexf omega = complexf(1.0f, 0.0f);\n\n        for(unsigned int j = 0; j < (m / 2); j++) {\n            for(unsigned int k = j; k < n; k += m) {\n                unsigned int ind = k + m / 2;\n\n                complexf t = omega * complexf(out[RE(ind)], out[IM(ind)]);\n                complexf u = complexf(out[RE(k)], out[IM(k)]);\n\n                complexf tmp0 = u + t;\n\n                out[RE(k)] = tmp0.real();\n                out[IM(k)] = tmp0.imag();\n\n                complexf tmp1 = u - t;\n\n                out[RE(ind)] = tmp1.real();\n                out[IM(ind)] = tmp1.imag();\n            }\n\n            omega *= omega_m;\n        }\n    }\n\n    return out;\n}\n\n/**\n * @brief fftTest\n */\nPIC_INLINE void fftTest()\n{\n    int n = 16;\n    float *values = new float[n];\n    float *values_fft = new float[n * 2];\n    float *values_dft = new float[n * 2];\n\n    for(int i=0;i<n;i++) {\n        values[i] = 0.0f;\n    }\n\n    values[1] = 1.0f;\n    values[2] = 1.0f;\n\n    FFTIterative1D(values, n, values_fft);\n\n    printf(\"FFT\\n\");\n    for(int i=0;i<n;i++) {\n        printf(\"%3.3f %3.3f\\n\", values_fft[RE(i)], values_fft[IM(i)]);\n    }\n\n    DFT1D(values, n, values_dft);\n    printf(\"DFT\\n\");\n    for(int i=0;i<n;i++) {\n        printf(\"%3.3f %3.3f\\n\", values_dft[RE(i)], values_dft[IM(i)]);\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_FFT_HPP */\n\n"
  },
  {
    "path": "include/util/file_lister.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_FILE_LISTER_HPP\n#define PIC_UTIL_FILE_LISTER_HPP\n\n#include <string>\n#include <iostream>\n#include <fstream>\n\n#include \"../util/string.hpp\"\n\nnamespace pic {\n\nclass FileLister\n{\npublic:\n    FileLister()\n    {\n    }\n\n    static std::string getFileNumber(std::string nameFile, std::string nameExt)\n    {\n        int counter = 0;\n\n        std::string nameTime = nameFile;\n        nameTime += \".\";\n        nameTime += nameExt;\n\n        std::ifstream infile(nameTime.c_str());\n\n        while(infile) {\n            infile.close();\n            nameTime = nameFile;\n            nameTime += \"_\";\n            nameTime += fromNumberToString(counter);\n            nameTime += \".\";\n            nameTime += nameExt;\n\n            infile.open(nameTime.c_str());\n            counter++;\n        }\n\n        return nameFile;\n    }\n\n    static StringVec *getList(std::string nameDir, std::string nameFilter,\n                           StringVec *sVecOut)\n    {\n        if(sVecOut == NULL) {\n            sVecOut = new StringVec;\n        } else {\n            sVecOut->clear();\n        }\n\n        /*\n#ifndef PIC_DISABLE_BOOST\n\n        try {\n            fs::path full_path(fs::initial_path<fs::path>());\n\n            fs::path path_c = fs::path(nameDir.c_str());\n            full_path = fs::system_complete(path_c);//, fs::native);\n\n            fs::directory_iterator end_iter;\n\n            for(fs::directory_iterator dir_itr(full_path);\n                dir_itr != end_iter;\n                ++dir_itr) {\n\n                if(is_regular(dir_itr->status())) {\n\n                    std::string tmp2 = dir_itr->path().generic_string();\n\n                    if(tmp2.find(nameFilter.c_str()) == std::string::npos) {\n                        continue;\n                    }\n\n                    //Save the name in the list\n                    sVecOut->push_back(tmp2);\n#ifdef PIC_DEBUG\n                    printf(\"%s\\n\", tmp2.c_str());\n#endif\n                }\n            }\n        } catch(std::exception &e) {\n            std::cout << \"Problem with directory: \" + nameDir + \" \" + e.what();\n        }\n\n#endif\n        */\n        return sVecOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_FILE_LISTER_HPP */\n\n"
  },
  {
    "path": "include/util/gl/axis.hpp",
    "content": "/*\r\n\r\nPICCANTE\r\nThe hottest HDR imaging library!\r\nhttp://vcg.isti.cnr.it/piccante\r\n\r\nCopyright (C) 2014\r\nVisual Computing Laboratory - ISTI CNR\r\nhttp://vcg.isti.cnr.it\r\nFirst author: Francesco Banterle\r\n\r\nThis Source Code Form is subject to the terms of the Mozilla Public\r\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\r\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\r\n\r\n*/\r\n\r\n#ifndef PIC_UTIL_AXIS_HPP\r\n#define PIC_UTIL_AXIS_HPP\r\n\r\n#include <string>\r\n\r\n#include \"util/std_util.hpp\"\r\n#include \"util/gl/technique.hpp\"\r\n\r\nclass Axis {\r\npublic:\r\n\r\n    GLuint vao, vbo, cbo, ibo;\r\n    pic::TechniqueGL meshProgram;\r\n\r\n    Axis()\r\n    {\r\n\r\n    }\r\n\r\n    void create()\r\n    {\r\n        int n = 6 * 3;\r\n        //\r\n        //vertex array:\r\n        //\r\n        float *vb = new float[n];\r\n\r\n        //first line X-axis \r\n        vb[0] = 0.0f;\r\n        vb[1] = 0.0f;\r\n        vb[2] = 0.0f;\r\n\r\n        vb[3] = 1.0f;\r\n        vb[4] = 0.0f;\r\n        vb[5] = 0.0f;\r\n\r\n        //second line Y-axis\r\n        vb[6] = 0.0f;\r\n        vb[7] = 0.0f;\r\n        vb[8] = 0.0f;\r\n\r\n        vb[9] = 0.0f;\r\n        vb[10] = 1.0f;\r\n        vb[11] = 0.0f;\r\n\r\n        //third line Z-axis\r\n        vb[12] = 0.0f;\r\n        vb[13] = 0.0f;\r\n        vb[14] = 0.0f;\r\n\r\n        vb[15] = 0.0f;\r\n        vb[16] = 0.0f;\r\n        vb[17] = 1.0f;\r\n\r\n        //color array\r\n        unsigned char *cb = new unsigned char[n];\r\n\r\n        //color of the X-axis: blue\r\n        cb[0] = 255;\r\n        cb[1] = 0;\r\n        cb[2] = 0;\r\n\r\n        cb[3] = 255;\r\n        cb[4] = 0;\r\n        cb[5] = 0;\r\n\r\n        //color of the Y-axis: red\r\n        cb[6] = 0;\r\n        cb[7] = 255;\r\n        cb[8] = 0;\r\n\r\n        cb[9] = 0;\r\n        cb[10] = 255;\r\n        cb[11] = 0;\r\n\r\n        //color of the Z-axis: green\r\n        cb[12] = 0;\r\n        cb[13] = 0;\r\n        cb[14] = 255;\r\n\r\n        cb[15] = 0;\r\n        cb[16] = 0;\r\n        cb[17] = 255;\r\n\r\n        //\r\n        //Vertex Buffers\r\n        //\r\n        glGenVertexArrays(1, &vao);\r\n        glBindVertexArray(vao);\r\n\r\n        //Vertex buffer object\r\n        glGenBuffers(1, &vbo);\r\n        glBindBuffer(GL_ARRAY_BUFFER, vbo);\r\n        glBufferData(GL_ARRAY_BUFFER, sizeof(float) * n, vb, GL_STATIC_DRAW);\r\n        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);\r\n        glEnableVertexAttribArray(0);\r\n\r\n        //Color buffer object\r\n        \r\n        glGenBuffers(1, &cbo);\r\n        glBindBuffer(GL_ARRAY_BUFFER, cbo);\r\n        glBufferData(GL_ARRAY_BUFFER, sizeof(unsigned char) * n, cb, GL_DYNAMIC_DRAW);\r\n        glVertexAttribPointer(1, 3, GL_UNSIGNED_BYTE, GL_FALSE, 0, NULL);\r\n        glEnableVertexAttribArray(1);\r\n        glBindVertexArray(0);\r\n\r\n        //\r\n        //Index buffers\r\n        //\r\n        unsigned int *indeces = new unsigned int[6];\r\n        \r\n        //X-axis\r\n        indeces[0] = 0;\r\n        indeces[1] = 1;\r\n        //Y-axis\r\n        indeces[2] = 2;\r\n        indeces[3] = 3;\r\n        //Z-axis\r\n        indeces[4] = 4;\r\n        indeces[5] = 5;\r\n        \r\n        glGenBuffers(1, &ibo);\r\n        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);\r\n        glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * 6, &indeces[0], GL_STATIC_DRAW);\r\n\r\n        /*Create shader*/\r\n        //Shader Program\r\n        std::string vertex_source = MAKE_STRING\r\n        (\r\n            layout(location = 0) in vec4 a_position;\r\n            layout(location = 1) in vec3 a_color;\r\n            uniform mat4 u_mvp;\r\n            out vec4 v_color;\r\n\r\n            void main(void) {\r\n                gl_Position = u_mvp * a_position;//vec4(a_position.xyz, 1.0);\r\n                v_color = vec4(a_color.xyz, 1.0);\r\n            }\r\n        );\r\n\r\n        std::string fragment_source = MAKE_STRING\r\n        (\r\n            in vec4 v_color;\r\n            layout(location = 0) out vec4 f_color;\r\n\r\n            void main(void) {\r\n                f_color = v_color;\r\n            }\r\n        );\r\n\r\n\r\n\r\n        meshProgram.init(\"330\", vertex_source, fragment_source, \"MeshProgram\");\r\n        meshProgram.printLog(\"MeshProgram\");\r\n\r\n        meshProgram.bind();\r\n        meshProgram.setAttributeIndex(\"a_position\", 0);\r\n        meshProgram.setAttributeIndex(\"a_color\", 1);\r\n        meshProgram.setOutputFragmentShaderIndex(\"f_color\", 0);\r\n        meshProgram.link();\r\n        meshProgram.unbind();\r\n    }\r\n\r\n    void render(float *viewprojection, float linewidth = 4.0f)\r\n    {\r\n        glEnable(GL_LINE_SMOOTH);\r\n\r\n        glLineWidth(linewidth);\r\n\r\n        meshProgram.bind();\r\n        meshProgram.setUniform4x4(\"u_mvp\", viewprojection, false);\r\n\r\n        glBindVertexArray(vao);\r\n        //glDrawArrays(GL_TRIANGLES, 0, 3);\r\n        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);\r\n        glDrawElements(GL_LINES,6, GL_UNSIGNED_INT, 0);\r\n        glBindVertexArray(0);\r\n\r\n        meshProgram.unbind();\r\n\r\n        glDisable(GL_LINE_SMOOTH);\r\n\r\n    }\r\n\r\n};\r\n\r\n\r\n\r\n#endif /* PIC_UTIL_AXIS_HPP */\r\n\r\n"
  },
  {
    "path": "include/util/gl/bicubic.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_BICUBIC_HPP\n#define PIC_UTIL_GL_BICUBIC_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/string.hpp\"\n\nnamespace pic {\n\n/**\n * @brief GLSL_BICUBIC returns bicubic sample.\n * @return It returns a string; a building block for a shader.\n */\nPIC_INLINE std::string GLSL_BICUBIC()\n{\n    std::string ret;\n\n    ret = MAKE_STRING(\n                float Bicubic(float x)\n                {\n                    float y = abs(x);\n                    if(y < 1.0) {\n                        float y_sq = y * y;\n                        return (3.0 * y_sq * y - 6.0 * y_sq + 4.0) / 6.0;\n                    } else {\n                        if(y < 2.0) {\n                            float y_sq = y * y;\n                            return (-1.0 * y_sq * y + 6.0 * y_sq - 12.0 * y + 8.0) / 6.0;\n                        } else {\n                            return 0.0;\n                        }\n                    }\n                }\n    );\n\n    return ret;\n}\n\n/**\n * @brief GLSL_TEXTURE_BICUBIC\n * @return\n */\nPIC_INLINE std::string GLSL_TEXTURE_BICUBIC()\n{\n    std::string ret;\n\n    ret = MAKE_STRING(\n\n            vec4 textureBicubic(sampler2D u_tex, vec2 coords)\n            {\n                ivec2 tSize_u = textureSize(u_tex, 0) - ivec2(1, 1);\n                vec2 tSize = vec2(tSize_u);\n                vec2 coords_uc = vec2(coords * tSize);\n                vec2 d = fract(coords_uc);\n\n                ivec2 coords_i = ivec2(floor(coords_uc));\n                vec2 r;\n                ivec2 e;\n                vec4 ret = vec4(0.0);\n\n                for(int j = -1; j < 3; j++) {\n                    r.y = Bicubic(float(j) - d.y);\n                    e.y = clamp(coords_i.y + j, 0, tSize_u.y);\n\n                    for(int i = -1; i < 3; i++) {\n                        r.x = Bicubic(-(float(i) - d.x));\n                        e.x = clamp(coords_i.x + i, 0, tSize_u.x);\n                        r.x *= r.y;\n\n                        ret += r.x * texelFetch(u_tex, e, 0);\n                    }\n                }\n                return ret;\n            }\n    );\n\n    return ret;\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_BICUBIC_HPP */\n\n"
  },
  {
    "path": "include/util/gl/buffer_allocation.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_BUFFER_ALLOCATION_HPP\n#define PIC_UTIL_GL_BUFFER_ALLOCATION_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/string.hpp\"\n#include \"../../util/gl/quad.hpp\"\n\nnamespace pic {\n\n/**\n * @brief generateTexture2DGL\n * @param width\n * @param height\n * @param channels\n * @param data\n * @param mipmap\n * @return\n */\nPIC_INLINE GLuint generateTexture2DGL(int width, int height, int channels, float *data = NULL, bool mipmap = false)\n{\n    if(width < 1 || height < 1 || channels < 1) {\n        return 0;\n    }\n\n    GLuint texture;\n\n    glGenTextures(1, &texture);\n    glBindTexture(GL_TEXTURE_2D, texture);\n\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n\n    if(mipmap) {\n        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);\n    } else {\n        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n    }\n\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n\n    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);\n\n    int mode, modeInternalFormat;\n    getModesGL(channels, mode, modeInternalFormat);\n    glTexImage2D(GL_TEXTURE_2D, 0, modeInternalFormat, width, height, 0,\n                 mode, GL_FLOAT, data);\n\n    if(mipmap) {\n        glGenerateMipmap(GL_TEXTURE_2D);\n    }\n\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    return texture;\n}\n\n/**\n * @brief generateTextureCubeMapGL\n * @param width\n * @param height\n * @param channels\n * @param frames\n * @param data\n * @return\n */\nPIC_INLINE GLuint generateTextureCubeMapGL(int width, int height, int channels, int frames, float *data = NULL)\n{\n    if(width < 1 || height < 1 || channels < 1 || frames < 6) {\n        return 0;\n    }\n\n    GLuint texture;\n\n    int mode, modeInternalFormat;\n    getModesGL(channels, mode, modeInternalFormat);\n\n    glGenTextures(1, &texture);\n    glBindTexture(GL_TEXTURE_CUBE_MAP, texture);\n    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);\n    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n\n    //Order Pos, Neg and X, Y, Z\n    int tstride = width * height * channels;\n\n    for(int i = 0; i < 6; i++) {\n        glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, modeInternalFormat, width,\n                     height, 0, mode, GL_FLOAT, &data[tstride * i]);\n    }\n\n    glBindTexture(GL_TEXTURE_CUBE_MAP, 0);\n\n    return texture;\n}\n\n/**\n * @brief generateTexture3DGL\n * @param width\n * @param height\n * @param channels\n * @param frames\n * @param data\n * @return\n */\nPIC_INLINE GLuint generateTexture3DGL(int width, int height, int channels, int frames, float *data = NULL)\n{\n    if(width <1 || height < 1 || channels < 1 || frames < 1) {\n        return 0;\n    }\n\n    GLuint texture;\n\n    int mode, modeInternalFormat;\n    getModesGL(channels, mode, modeInternalFormat);\n\n    glGenTextures(1, &texture);\n    glBindTexture(GL_TEXTURE_3D, texture);\n    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);\n    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n\n    glTexImage3D(GL_TEXTURE_3D, 0, modeInternalFormat, width, height, frames, 0,\n                 mode, GL_FLOAT, data);\n\n    glBindTexture(GL_TEXTURE_3D, 0);\n\n//\tfor(int i=0;i<frames;i++)\n//\t\tglTexSubImage3D(GL_TEXTURE_3D,0,0,0,i,width,height,1,mode,GL_FLOAT,&data[i*tstride]);\n\n    return texture;\n}\n\n/**\n * @brief generateTexture2DArrayGL\n * @param width\n * @param height\n * @param channels\n * @param frames\n * @param data\n * @return\n */\nPIC_INLINE GLuint generateTexture2DArrayGL(int width, int height, int channels, int frames, float *data = NULL)\n{\n    if(width < 1 || height < 1 || channels < 1 || frames < 1) {\n        return 0;\n    }\n\n    int mode, modeInternalFormat;\n    getModesGL(channels, mode, modeInternalFormat);\n\n    GLuint texture;\n\n    glGenTextures(1, &texture);\n    glBindTexture(GL_TEXTURE_2D_ARRAY, texture);\n    glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n    glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n\n    glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, modeInternalFormat, width, height, frames,\n                 0, mode, GL_FLOAT, data);\n\n    glBindTexture(GL_TEXTURE_2D_ARRAY, 0);\n\n    return texture;\n}\n\n/**\n * @brief generateTexture2DU32GL\n * @param width\n * @param height\n * @param channels\n * @return\n */\nPIC_INLINE GLuint generateTexture2DU32GL(int width, int height, int channels, int *data = NULL)\n{\n    if(width < 1 || height < 1 || channels < 1) {\n        return 0;\n    }\n\n    GLuint texture;\n\n    glGenTextures(1, &texture);\n    glBindTexture(GL_TEXTURE_2D, texture);\n\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\n\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);\n\n    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);\n\n    int mode, modeInternalFormat;\n    getModesIntegerGL(channels, mode, modeInternalFormat);\n\n    glTexImage2D(GL_TEXTURE_2D, 0, modeInternalFormat, width, height, 0,\n                 mode, GL_INT, data);\n\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    return texture;\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_BUFFER_ALLOCATION_HPP */\n"
  },
  {
    "path": "include/util/gl/buffer_op.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_BUFFER_OP_HPP\n#define PIC_UTIL_GL_BUFFER_OP_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../util/array.hpp\"\n\n#include \"../../util/string.hpp\"\n#include \"../../util/gl/quad.hpp\"\n#include \"../../util/gl/fbo.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The BufferOpGL class\n */\nclass BufferOpGL\n{\nprotected:\n\n    //FBO\n    Fbo *fbo;\n\n    //Quad\n    QuadGL *quad;\n\n    //Shaders\n    TechniqueGL technique;\n    GLenum target;\n\n    std::string op;\n    float c0[4], c1[4];\n    bool bTexelFetch;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\npublic:\n\n    std::string vertex_source, geometry_source, fragment_source;\n\n    /**\n     * @brief BufferOpGL\n     * @param op\n     * @param bTexelFetch\n     * @param c0\n     * @param c1\n     */\n    BufferOpGL(std::string op, bool bTexelFetch, float *c0, float *c1);\n\n    /**\n     * @brief update\n     * @param c0\n     * @param c1\n     */\n    void update(const float *c0, const  float *c1);\n\n    /**\n     * @brief update\n     * @param c0\n     * @param c1\n     */\n    void update(float c0, float c1);\n\n    /**\n     * @brief Process\n     * @param tex0\n     * @param tex1\n     * @param texOut\n     * @param width\n     * @param height\n     */\n    void Process(GLuint tex0, GLuint tex1, GLuint texOut, int width, int height);\n\n};\n\nPIC_INLINE BufferOpGL::BufferOpGL(std::string op, bool bTexelFetch = false, float *c0 = NULL, float *c1 = NULL)\n{\n    fbo = NULL;\n\n    quad = NULL;\n\n    target = GL_TEXTURE_2D;\n\n    if(c0 != NULL) {\n        memcpy(this->c0, c0, 4 * sizeof(float));\n    } else {\n        Arrayf::assign(1.0f, this->c0, 4);\n    }\n\n    if(c1 != NULL) {\n        memcpy(this->c1, c1, 4 * sizeof(float));\n    } else {\n        Arrayf::assign(1.0f, this->c1, 4);\n    }\n\n    this->op = op;\n    this->bTexelFetch = bTexelFetch;\n\n    if(bTexelFetch) {\n        vertex_source = QuadGL::getVertexProgramV3();\n        quad = new QuadGL(false);\n    } else {\n        vertex_source = QuadGL::getVertexProgramWithTexCoordinates();\n        quad = new QuadGL(true);\n    }\n\n    initShaders();\n}\n\nPIC_INLINE void BufferOpGL::initShaders()\n{\n    std::string strOp = \"vec4 ret = \";\n    strOp.append(op);\n    strOp.append(\";\\n\");\n    int counter;\n\n    //I0x\n    counter = countSubString(strOp, \"I0x\");\n\n    if(counter == 1) {\n        size_t I_found = strOp.find(\"I0x\");\n\n        if(I_found != std::string::npos) {\n            if(bTexelFetch) {\n                strOp.replace(I_found, 3, \"texelFetch(u_tex_0, coords, 0).xxxx\");\n            } else {\n                strOp.replace(I_found, 3, \"texture(u_tex_0, coords).xxxx\");\n            }\n        }\n\n    } else {\n        if(counter > 1) {\n            if(bTexelFetch) {\n                strOp = \"vec4 tmp0x = texelFetch(u_tex_0, coords, 0);\\n\" + strOp;\n             } else {\n                strOp = \"vec4 tmp0x = texture(u_tex_0, coords);\\n\" + strOp;\n             }\n             strOp = stdStringRepAll(strOp, \"I0x\", \"tmp0x\");\n        }\n    }\n\n    //I1x\n    counter = countSubString(strOp, \"I1x\");\n\n    if(counter == 1) {\n        size_t I_found = strOp.find(\"I1x\");\n\n        if(I_found != std::string::npos) {\n            if(bTexelFetch) {\n                strOp.replace(I_found, 3, \"texelFetch(u_tex_1, coords, 0).xxxx\");\n            } else {\n                strOp.replace(I_found, 3, \"texture(u_tex_1, coords).xxxx\");\n            }\n        }\n\n    } else {\n        if(counter > 1) {\n            if(bTexelFetch) {\n                strOp = \"vec4 tmp1x = texelFetch(u_tex_1, coords, 0);\\n\" + strOp;\n             } else {\n                strOp = \"vec4 tmp1x = texture(u_tex_1, coords);\\n\" + strOp;\n             }\n             strOp = stdStringRepAll(strOp, \"I1x\", \"tmp1x\");\n        }\n    }\n\n    //I0\n    counter = countSubString(strOp, \"I0\");\n\n    if(counter == 1) {\n        size_t I_found = strOp.find(\"I0\");\n\n        if(I_found != std::string::npos) {\n            if(bTexelFetch) {\n                strOp.replace(I_found, 2, \"texelFetch(u_tex_0, coords, 0)\");\n            } else {\n                strOp.replace(I_found, 2, \"texture(u_tex_0, coords)\");\n            }\n        }\n    } else {\n        if(counter > 1) {\n            if(bTexelFetch) {\n                strOp = \"vec4 tmp0 = texelFetch(u_tex_0, coords, 0);\\n\" + strOp;\n            } else {\n                strOp = \"vec4 tmp0 = texture(u_tex_0, coords);\\n\" + strOp;\n            }\n\n            strOp = stdStringRepAll(strOp, \"I0\", \"tmp0\");\n        }\n    }\n\n    //I1\n    counter = countSubString(strOp, \"I1\");\n\n    if(counter == 1) {\n        size_t I_found = strOp.find(\"I1\");\n\n        if(I_found != std::string::npos) {\n            if(bTexelFetch) {\n                strOp.replace(I_found, 2, \"texelFetch(u_tex_1, coords, 0)\");\n            } else {\n                strOp.replace(I_found, 2, \"texture(u_tex_1, coords)\");\n            }\n        }\n    } else {\n        if(counter > 1) {\n            if(bTexelFetch) {\n                strOp = \"vec4 tmp1 = texelFetch(u_tex_1, coords, 0);\\n\" + strOp;\n            } else {\n                strOp = \"vec4 tmp1 = texture(u_tex_1, coords);\\n\" + strOp;\n            }\n\n            strOp = stdStringRepAll(strOp, \"I1\", \"tmp1\");\n        }\n    }\n\n    //C1 and C2\n    strOp = stdStringRepAll(strOp, \"C0\", \"u_val_0\");\n    strOp = stdStringRepAll(strOp, \"C1\", \"u_val_1\");\n\n    fragment_source = MAKE_STRING\n                      (\n                          uniform sampler2D u_tex_0; \\n\n                          uniform sampler2D u_tex_1; \\n\n                          uniform vec4      u_val_0; \\n\n                          uniform vec4      u_val_1; \\n\n                          in      vec2      v_tex_coord; \\n\n                          out     vec4      f_color; \\n\n                          \\n\n    void main(void) { \\n\n        _COORDINATES_FOR_FETCHING_ \\n\n        _PROCESSING_OPERATOR_ \\n\n        f_color = ret; \\n\n    }\n                      );\n\n    if(bTexelFetch) {\n        size_t processing_found = fragment_source.find(\"_COORDINATES_FOR_FETCHING_\");\n        fragment_source.replace(processing_found, 27,\n                                \"ivec2 coords = ivec2(gl_FragCoord.xy);\\n\");\n    } else {\n        size_t processing_found = fragment_source.find(\"_COORDINATES_FOR_FETCHING_\");\n        fragment_source.replace(processing_found, 27,\n                                \"vec2 coords = v_tex_coord.xy;\\n\");\n    }\n\n    size_t processing_found = fragment_source.find(\"_PROCESSING_OPERATOR_\");\n    fragment_source.replace(processing_found, 21, strOp);\n\n    technique.init(\"330\", vertex_source, fragment_source);\n\n#ifdef PIC_DEBUG\n    technique.printLog(\"BufferOp\");\n#endif\n\n    technique.bind();\n    technique.setAttributeIndex(\"a_position\", 0);\n\n    if(!bTexelFetch) {\n        technique.setAttributeIndex(\"a_tex_coord\", 1);\n    }\n\n    technique.setOutputFragmentShaderIndex(\"f_color\", 0);\n    technique.link();\n    technique.unbind();\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex_0\",  0);\n    technique.setUniform1i(\"u_tex_1\",  1);\n    technique.setUniform4fv(\"u_val_0\", c0);\n    technique.setUniform4fv(\"u_val_1\", c1);\n    technique.unbind();\n}\n\nPIC_INLINE void BufferOpGL::update(const float *c0, const float *c1 = NULL)\n{\n    if(c0 != NULL) {\n        memcpy(this->c0, c0, sizeof(float) * 4);\n    }\n\n    if(c1 != NULL) {\n        memcpy(this->c1, c1, sizeof(float) * 4);\n    }\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex_0\",  0);\n    technique.setUniform1i(\"u_tex_1\",  1);\n    technique.setUniform4fv(\"u_val_0\", this->c0);\n    technique.setUniform4fv(\"u_val_1\", this->c1);\n    technique.unbind();\n}\n\nPIC_INLINE void BufferOpGL::update(float c0 = 0.0f, float c1 = 0.0f)\n{\n    Arrayf::assign(c0, this->c0, 4);\n    Arrayf::assign(c1, this->c1, 4);\n\n    technique.bind();\n    technique.setUniform1i(\"u_tex_0\",  0);\n    technique.setUniform1i(\"u_tex_1\",  1);\n    technique.setUniform4fv(\"u_val_0\", this->c0);\n    technique.setUniform4fv(\"u_val_1\", this->c1);\n    technique.unbind();\n}\n\nPIC_INLINE void BufferOpGL::Process(GLuint tex0, GLuint tex1, GLuint texOut, int width, int height)\n{\n    if(texOut == 0) {\n        #ifdef PIC_DEBUG\n            printf(\"BufferOpGL::Process: the output texture, texOut, is empty.\\n\");\n        #endif\n        return;\n    }\n\n    if(fbo == NULL) {\n        fbo = new Fbo();\n    }\n\n    fbo->create(width, height, 1, false, texOut);\n\n    //Rendering\n    fbo->bind();\n    glViewport(0, 0, (GLsizei)width, (GLsizei)height);\n\n    //Shaders\n    technique.bind();\n\n    //Textures\n    glActiveTexture(GL_TEXTURE0);\n    glBindTexture(GL_TEXTURE_2D, tex0);\n\n    glActiveTexture(GL_TEXTURE1);\n    glBindTexture(GL_TEXTURE_2D, tex1);\n\n    quad->Render();\n\n    //Fbo\n    fbo->unbind();\n\n    //Shaders\n    technique.unbind();\n\n    //Textures\n    glActiveTexture(GL_TEXTURE1);\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    glActiveTexture(GL_TEXTURE0);\n    glBindTexture(GL_TEXTURE_2D, 0);\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_BUFFER_OP_HPP */\n"
  },
  {
    "path": "include/util/gl/buffer_ops.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_BUFFER_OPS_HPP\n#define PIC_UTIL_GL_BUFFER_OPS_HPP\n\n#include <vector>\n#include <map>\n#include <thread>\n#include <mutex>\n\n#include \"../../base.hpp\"\n\n#include \"../../util/gl/buffer_op.hpp\"\n\nnamespace pic {\n\nenum BOGL{BOGL_ADD, BOGL_SUB, BOGL_MUL, BOGL_DIV,\n          BOGL_ADD_CONST, BOGL_SUB_CONST, BOGL_MUL_CONST, BOGL_DIV_CONST,\n          BOGL_ADD_S, BOGL_SUB_S, BOGL_MUL_S, BOGL_DIV_S,\n          BOGL_CLAMP, BOGL_ID, BOGL_ID_CONST};\n\ntypedef std::vector<BufferOpGL*> BufferOperatorsGL;\n\n/**\n * @brief The BufferOpsGL class\n */\nclass BufferOpsGL\n{\npublic:\n    BufferOperatorsGL list;\n\n    /**\n     * @brief getInstance\n     * @return\n     */\n    static BufferOpsGL* getInstance()\n    {\n        std::thread::id this_id = std::this_thread::get_id();\n\n        if(!flag[this_id]) {\n            std::lock_guard<std::mutex> lock(mutex);\n\n            if(buffer_ops_gl[this_id] == NULL) {\n                buffer_ops_gl[this_id] = new BufferOpsGL();\n                flag[this_id] = true;\n            }\n        }\n\n        return buffer_ops_gl[this_id];\n    }\n\n    ~BufferOpsGL()\n    {\n    }\n\nprivate:\n    static std::mutex mutex;\n    static std::map<std::thread::id, bool> flag;\n    static std::map<std::thread::id, BufferOpsGL*> buffer_ops_gl;\n\n    /**\n     * @brief BufferOpsGL\n     */\n    BufferOpsGL()\n    {\n        list.push_back(new BufferOpGL(\"I0 + I1\", true));\n        list.push_back(new BufferOpGL(\"I0 - I1\", true));\n        list.push_back(new BufferOpGL(\"I0 * I1\", true));\n        list.push_back(new BufferOpGL(\"I0 / I1\", true));\n\n        list.push_back(new BufferOpGL(\"I0 + C0\", true));\n        list.push_back(new BufferOpGL(\"I0 - C0\", true));\n        list.push_back(new BufferOpGL(\"I0 * C0\", true));\n        list.push_back(new BufferOpGL(\"I0 / C0\", true));\n\n        list.push_back(new BufferOpGL(\"I0 + I1x\", true));\n        list.push_back(new BufferOpGL(\"I0 - I1x\", true));\n        list.push_back(new BufferOpGL(\"I0 * I1x\", true));\n        list.push_back(new BufferOpGL(\"I0 / I1x\", true));\n\n        list.push_back(new BufferOpGL(\"clamp(I0, C0, C1)\", true));\n\n        list.push_back(new BufferOpGL(\"I1\", true));\n        list.push_back(new BufferOpGL(\"C0\", true));\n    }\n\n};\n\nPIC_INLINE std::mutex BufferOpsGL::mutex;\n\nPIC_INLINE std::map<std::thread::id, bool> BufferOpsGL::flag;\n\nPIC_INLINE std::map<std::thread::id, BufferOpsGL*> BufferOpsGL::buffer_ops_gl;\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_BUFFER_OPS_HPP */\n"
  },
  {
    "path": "include/util/gl/display.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_DISPLAY_HPP\n#define PIC_UTIL_GL_DISPLAY_HPP\n\nnamespace pic {\n\n#include <string>\n\n#include \"../../util/gl/technique.hpp\"\n#include \"../../util/std_util.hpp\"\n\n#include \"../../gl/colors/color_conv_rgb_to_srgb.hpp\"\n#include \"../../gl/filtering/filter_color_conv.hpp\"\n\n/**\n * @brief The DisplayGL class\n */\nclass DisplayGL\n{\nprotected:\n    pic::QuadGL *quad;\n    pic::TechniqueGL technique;\n    ImageGL *img_flt_tmo;\n    pic::ColorConvGLRGBtosRGB *conv_sRGB;\n    pic::FilterGLColorConv *conv;\n\npublic:\n\n    /**\n     * @brief DisplayGL\n     */\n    DisplayGL()\n    {\n        //create a screen aligned quad\n        pic::QuadGL::getTechnique(technique,\n                                pic::QuadGL::getVertexProgramV3(),\n                                pic::QuadGL::getFragmentProgramForView());\n\n        quad = new pic::QuadGL(true);\n\n        img_flt_tmo = NULL;\n\n        //allocate a new filter for simple tone mapping\n        conv_sRGB = new pic::ColorConvGLRGBtosRGB(true);\n        conv = new pic::FilterGLColorConv((pic::ColorConvGL*)conv_sRGB, true);\n    }\n\n    ~DisplayGL()\n    {\n        conv_sRGB = delete_s(conv_sRGB);\n        conv = delete_s(conv);\n        quad = delete_s(quad);\n        img_flt_tmo = delete_s(img_flt_tmo);\n    }\n\n    /**\n     * @brief Process\n     * @param img_to_be_displayed\n     */\n    void Process(ImageGL *img_to_be_displayed)\n    {\n        //conversion from RGB linear to sRGB\n        img_flt_tmo = conv->Process(SingleGL(img_to_be_displayed), img_flt_tmo);\n\n        //visualization\n        quad->Render(technique, img_flt_tmo->getTexture());\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_DISPLAY_HPP */\n\n"
  },
  {
    "path": "include/util/gl/fbo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_FBO_HPP\n#define PIC_UTIL_GL_FBO_HPP\n\n#include <iostream>\n\n#include \"../../base.hpp\"\n\nnamespace pic {\n\n    //NOTE: this class needs to be used with an active OpenGL context!\n\n    /**\n     * @brief The Fbo class\n     */\n    class Fbo\n    {\n    public:\n        GLuint fbo;                 // framebuffer object\n        GLuint tex;                 // we render into this texture\n        GLuint depth;               // and to this depth buffer\n        int width, height, frames;  // width and height of the framebuffer\n        bool bDepth;                // do we have a depth buffer?\n\n        //MRT\n        GLuint       *texMRT;\n        unsigned int nMRT;\n        GLuint      *attachmentsMRT;\n\n        Fbo();\n\n        /**\n         * @brief create\n         * @param width\n         * @param height\n         * @param depth\n         * @param bDepth\n         * @param tex\n         * @return\n         */\n        bool create(int width, int height, bool bDepth);\n\n        /**\n         * @brief create\n         * @param width\n         * @param height\n         * @param bDepth\n         * @return\n         */\n        bool create(int width, int height, int depth, bool bDepth, GLuint tex);\n\n        /**\n         * @brief create\n         * @param width\n         * @param height\n         * @param bDepth\n         * @return\n         */\n        bool createMRT(int width, int height, bool bDepth, unsigned int nMRT);\n\n        /**\n         * @brief attachColorBuffer\n         * @param tex\n         * @param target\n         * @param slice\n         */\n        void attachColorBuffer(GLuint tex, GLenum target, int slice = 0);\n\n        /**\n         * @brief attachColorBuffer2\n         * @param tex\n         * @param target\n         * @param slice\n         */\n        void attachColorBuffer2(GLuint tex, GLenum target, int slice);\n\n        /**\n         * @brief release\n         * @return\n         */\n        bool release();\n\n        /**\n         * @brief bind\n         */\n        void bind();\n\n        /**\n         * @brief unbind\n         */\n        void unbind();\n\n        /**\n         * @brief bindSimple\n         */\n        void bindSimple()\n        {\n            glBindFramebuffer(GL_FRAMEBUFFER, fbo);\n        }\n\n        /**\n         * @brief unbindSimple\n         */\n        void unbindSimple()\n        {\n            glBindFramebuffer(GL_FRAMEBUFFER, 0);\n        }\n\n        /**\n         * @brief bindMRT\n         */\n        void bindMRT();\n\n        /**\n         * @brief unbind\n         */\n        void unbindMRT();\n\n        /**\n         * @brief clone\n         * @return\n         */\n        Fbo *clone();\n\n        /**\n         * @brief checkStatus\n         * @param fboStatus\n         */\n        static void checkStatus(GLenum fboStatus)\n        {\n            switch (fboStatus) {\n            case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\n                std::cerr << \"FBO Incomplete: Attachment\" << std::endl;\n                break;\n\n            case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\n                std::cerr << \"FBO Incomplete: Missing Attachment\" << std::endl;\n                break;\n\n            case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:\n                std::cerr << \"FBO Incomplete: Draw Buffer\" << std::endl;\n                break;\n\n            case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:\n                std::cerr << \"FBO Incomplete: Read Buffer\" << std::endl;\n                break;\n\n            default:\n                std::cerr << \"Undefined FBO error\" << std::endl;\n                break;\n            }\n        }\n    };\n\n    PIC_INLINE Fbo::Fbo()\n    {\n        depth = 0;\n        fbo = 0;\n        tex = 0;\n\n        width = height = frames = 0;\n    }\n\n    PIC_INLINE bool Fbo::release()\n    {\n        if (tex != 0) {\n            glDeleteTextures(1, &tex);\n            tex = 0;\n        }\n\n        if (depth != 0) {\n            glDeleteRenderbuffers(1, &depth);\n            depth = 0;\n        }\n\n        if (fbo != 0) {\n            glDeleteFramebuffers(1, &fbo);\n            fbo = 0;\n        }\n\n        return true;\n    }\n\n    PIC_INLINE Fbo *Fbo::clone()\n    {\n        Fbo *ret = new Fbo();\n        ret->create(width, height, frames, bDepth, 0);\n        return ret;\n    }\n\n    PIC_INLINE bool Fbo::create(int width, int height, bool bDepth)\n    {\n        return create(width, height, 1, bDepth, 0);\n    }\n\n    PIC_INLINE bool Fbo::create(int width, int height, int frames, bool bDepth, GLuint tex)\n    {\n        this->width = width;\n        this->height = height;\n        this->frames = frames;\n        this->bDepth = bDepth;\n\n        //FBO with one COLOR ATTACHMENT\n        //setup texture (render target)\n        if (tex == 0) {\n            glGenTextures(1, &this->tex);\n\n            if (frames == 1) {\n                glBindTexture(GL_TEXTURE_2D, this->tex);\n                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, GL_FLOAT,\n                    0);\n                glBindTexture(GL_TEXTURE_2D, 0);\n            }\n            else {\n                glBindTexture(GL_TEXTURE_3D, this->tex);\n                glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n                glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n                glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);\n                glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n                glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n                glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA32F, width, height, frames, 0, GL_RGBA,\n                    GL_FLOAT, 0);\n                glBindTexture(GL_TEXTURE_3D, 0);\n            }\n        }\n        else {\n            this->tex = tex;\n        }\n\n        //setup renderbuffer (depth buffer)\n        //assert(glGenRenderbuffers);\n        if (bDepth) {\n            glGenRenderbuffers(1, &depth);\n            glBindRenderbuffer(GL_RENDERBUFFER, depth);\n            glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);\n            glBindRenderbuffer(GL_RENDERBUFFER, 0);\n        }\n\n        // setup FBO\n        if (fbo == 0) {\n            glGenFramebuffers(1, &fbo);\n        }\n\n        glBindFramebuffer(GL_FRAMEBUFFER, fbo);\n\n        // attach color buffer (texture)\n        if (frames == 1) {\n            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,\n                this->tex, 0);\n        }\n        else {\n            glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_3D,\n                this->tex, 0, 0);\n        }\n\n        // attach depth buffer (renderbuffer)\n        if (bDepth) {\n            glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,\n                depth);\n        }\n\n#ifdef PIC_DEBUG_GL\n        // check framebuffer status\n        GLenum fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);\n\n        if (fboStatus != GL_FRAMEBUFFER_COMPLETE) {\n            checkStatus(fboStatus);\n            glDeleteFramebuffers(1, &fbo);\n            fbo = 0;\n        }\n\n#endif\n\n        // unbind framebuffer\n        glBindFramebuffer(GL_FRAMEBUFFER, 0);\n        return fbo != 0;\n    }\n\n    PIC_INLINE bool Fbo::createMRT(int width, int height, bool bDepth, unsigned int nMRT)\n    {\n        this->width = width;\n        this->height = height;\n        this->bDepth = bDepth;\n        this->nMRT = nMRT;\n\n        texMRT = new GLuint[nMRT];\n        attachmentsMRT = new GLuint[nMRT];\n\n        for (unsigned int i = 0; i < nMRT; i++) {\n            texMRT[i] = 0;\n            glGenTextures(1, &texMRT[i]);\n            glBindTexture(GL_TEXTURE_2D, texMRT[i]);\n            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, GL_FLOAT, 0);\n            glBindTexture(GL_TEXTURE_2D, 0);\n        }\n\n        if (bDepth) {\n            glGenRenderbuffers(1, &depth);\n            glBindRenderbuffer(GL_RENDERBUFFER, depth);\n            glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);\n            glBindRenderbuffer(GL_RENDERBUFFER, 0);\n        }\n\n        // setup FBO\n        if (fbo == 0) {\n            glGenFramebuffers(1, &fbo);\n        }\n\n        glBindFramebuffer(GL_FRAMEBUFFER, fbo);\n\n        // attach color buffer (texture)\n        for (unsigned int i = 0; i < nMRT; i++) {\n            attachmentsMRT[i] = GL_COLOR_ATTACHMENT0 + i;\n\n            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D,\n                texMRT[i], 0);\n        }\n\n\n        // attach depth buffer (renderbuffer)\n        if (bDepth) {\n            glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,\n                depth);\n        }\n\n#ifdef PIC_DEBUG_GL\n        // check framebuffer status\n        GLenum fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);\n\n        if (fboStatus != GL_FRAMEBUFFER_COMPLETE) {\n            checkStatus(fboStatus);\n            glDeleteFramebuffers(1, &fbo);\n            fbo = 0;\n        }\n\n#endif\n\n        // unbind framebuffer\n        glBindFramebuffer(GL_FRAMEBUFFER, 0);\n        return fbo != 0;\n    }\n\n    PIC_INLINE void Fbo::attachColorBuffer(GLuint tex, GLenum target, int slice)\n    {\n        glBindFramebuffer(GL_FRAMEBUFFER, fbo);\n\n        GLuint texWork = (tex == 0) ? this->tex : tex;\n\n        switch (target) {\n        case GL_TEXTURE_2D: {\n            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,\n                texWork, 0);\n        }\n                            break;\n\n        case GL_TEXTURE_3D: {\n            glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_3D,\n                texWork, 0, slice);\n        }\n                            break;\n        }\n\n#ifdef PIC_DEBUG_GL\n        // check framebuffer status\n        GLenum fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);\n\n        if (fboStatus != GL_FRAMEBUFFER_COMPLETE) {\n            checkStatus(fboStatus);\n            glDeleteFramebuffers(1, &fbo);\n            fbo = 0;\n        }\n\n#endif\n\n        glBindFramebuffer(GL_FRAMEBUFFER, 0);\n    }\n\n    PIC_INLINE void Fbo::attachColorBuffer2(GLuint tex, GLenum target, int slice)\n    {\n        GLuint texWork = (tex == 0) ? this->tex : tex;\n\n        switch (target) {\n        case GL_TEXTURE_2D: {\n            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,\n                texWork, 0);\n        }\n                            break;\n\n        case GL_TEXTURE_2D_ARRAY: {\n            glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,\n                GL_TEXTURE_2D_ARRAY, texWork, 0, slice);\n        }\n                                  break;\n\n        case GL_TEXTURE_3D: {\n            glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_3D,\n                texWork, 0, slice);\n        }\n                            break;\n        }\n    }\n\n    PIC_INLINE void Fbo::bind()\n    {\n        if (!fbo) {\n            return;\n        }\n\n        glBindFramebuffer(GL_FRAMEBUFFER, fbo);\n        glDrawBuffer(GL_COLOR_ATTACHMENT0);\n        glReadBuffer(GL_COLOR_ATTACHMENT0);\n\n        if (bDepth) {\n            glBindRenderbuffer(GL_RENDERBUFFER, depth);\n        }\n    }\n\n    PIC_INLINE void Fbo::unbind()\n    {\n        if (!fbo) {\n            return;\n        }\n\n        glBindFramebuffer(GL_FRAMEBUFFER, 0);\n        glDrawBuffer(GL_BACK);\n        glReadBuffer(GL_BACK);\n\n        if (bDepth) {\n            glBindRenderbuffer(GL_RENDERBUFFER, 0);\n        }\n    }\n\n    PIC_INLINE void Fbo::bindMRT()\n    {\n        if (!fbo) {\n            return;\n        }\n\n        glBindFramebuffer(GL_FRAMEBUFFER, fbo);\n\n        glDrawBuffers(nMRT, attachmentsMRT);\n    }\n\n    PIC_INLINE void Fbo::unbindMRT()\n    {\n        if (!fbo) {\n            return;\n        }\n\n        glBindFramebuffer(GL_FRAMEBUFFER, 0);\n    }\n\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_FBO_HPP */\n\n"
  },
  {
    "path": "include/util/gl/formats.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_FORMATS_HPP\n#define PIC_UTIL_GL_FORMATS_HPP\n\n#include \"../../base.hpp\"\n\n#include \"../../gl.hpp\"\n\nnamespace pic {\n\n/**\n * @brief getModesGL\n * @param channels\n * @param mode\n * @param modeInternalFormat\n */\ninline void getModesGL(int channels, int &mode, int &modeInternalFormat)\n{\n    mode = 0;\n    modeInternalFormat = 0;\n\n    switch(channels) {\n    case 1: {\n        mode = GL_RED;\n        modeInternalFormat = GL_R32F;\n    }\n    break;\n\n    case 3: {\n        mode = GL_RGB;\n        modeInternalFormat = GL_RGB32F;\n    }\n    break;\n\n    case 4: {\n        mode = GL_RGBA;\n        modeInternalFormat = GL_RGBA32F;\n    }\n    break;\n    }\n}\n\n/**\n * @brief getModesHalfGL\n * @param channels\n * @param mode\n * @param modeInternalFormat\n */\ninline void getModesHalfGL(int channels, int &mode, int &modeInternalFormat)\n{\n    mode = 0;\n    modeInternalFormat = 0;\n\n    switch(channels) {\n    case 1: {\n        mode = GL_RED;\n        modeInternalFormat = GL_R16F;\n    }\n    break;\n\n    case 3: {\n        mode = GL_RGB;\n        modeInternalFormat = GL_RGB16F;\n    }\n    break;\n\n    case 4: {\n        mode = GL_RGBA;\n        modeInternalFormat = GL_RGBA16F;\n    }\n    break;\n    }\n}\n\n/**\n * @brief getModesIntegerGL\n * @param channels\n * @param mode\n * @param modeInternalFormat\n */\ninline void getModesIntegerGL(int channels, int &mode, int &modeInternalFormat)\n{\n    mode = 0;\n    modeInternalFormat = 0;\n\n    switch(channels) {\n    case 1: {\n        mode = GL_RED_INTEGER;\n        modeInternalFormat = GL_R32I;\n    }\n    break;\n\n    case 3: {\n        mode = GL_RGB_INTEGER;\n        modeInternalFormat = GL_RGB32I;\n    }\n    break;\n\n    case 4: {\n        mode = GL_RGBA_INTEGER;\n        modeInternalFormat = GL_RGBA32I;\n    }\n    break;\n    }\n}\n\n/**\n * @brief getChannelsFromInternalFormatGL returns the number of channels given an internal format.\n * @param internalFormat is the OpenGL internal format of a texture.\n * @return It returns the number of channels.\n */\ninline int getChannelsFromInternalFormatGL(int internalFormat)\n{\n    int channels = -1;\n\n    switch(internalFormat) {\n        //Half precision\n        case GL_R16F:\n            channels = 1;\n            break;\n\n        case GL_RGB16F:\n            channels = 3;\n            break;\n\n        case GL_RGBA16F:\n            channels = 4;\n            break;\n\n        //Single precision\n        case GL_R32F:\n            channels = 1;\n            break;\n\n        case GL_RGB32F:\n            channels = 3;\n            break;\n\n        case GL_RGBA32F:\n            channels = 4;\n            break;\n        }\n\n    return channels;\n}\n\n/**\n * @brief getTextureInformationGL returns width, height and frames values from a\n * texture with target.\n * @param texture is the OpenGL texture pointer.\n * @param target is the OpenGL target of texture.\n * @param width is the horizontal length in pixel of texture.\n * @param height is the vertical length in pixel of texture.\n * @param frames is the number of frames of texture.\n * @param channels is the number of color channels of texture.\n */\nPIC_INLINE void getTextureInformationGL(GLuint texture, GLuint target, int &width, int &height,\n                             int &frames, int &channels)\n{\n    if(texture == 0) {\n        #ifdef PIC_DEBUG\n            printf(\"getTextureInformationGL: texture is not valid.\\n\");\n        #endif\n        return;\n    }\n\n    GLint internalFormat;\n\n    switch(target) {\n    case GL_TEXTURE_2D: {\n        glBindTexture(GL_TEXTURE_2D, texture);\n        glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);\n        glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);\n        glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT,\n                                 &internalFormat);\n\n        channels = getChannelsFromInternalFormatGL(internalFormat);\n\n        frames = 1;\n\n        glBindTexture(GL_TEXTURE_2D, 0);\n    }\n    break;\n\n    case GL_TEXTURE_CUBE_MAP: {\n        glBindTexture(GL_TEXTURE_CUBE_MAP, texture);\n        glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_WIDTH, &width);\n        glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_HEIGHT, &height);\n        glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_INTERNAL_FORMAT,\n                                 &internalFormat);\n\n        channels = getChannelsFromInternalFormatGL(internalFormat);\n\n        frames = 6;\n\n        glBindTexture(GL_TEXTURE_2D, 0);\n    }\n    break;\n\n    case GL_TEXTURE_2D_ARRAY: {\n        glBindTexture(GL_TEXTURE_2D_ARRAY, texture);\n        glGetTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_WIDTH, &width);\n        glGetTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_HEIGHT, &height);\n        glGetTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_DEPTH, &frames);\n        glGetTexLevelParameteriv(GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_INTERNAL_FORMAT,\n                                 &internalFormat);\n\n        channels = getChannelsFromInternalFormatGL(internalFormat);\n\n        glBindTexture(GL_TEXTURE_2D_ARRAY, 0);\n    }\n    break;\n\n    case GL_TEXTURE_3D: {\n        glBindTexture(GL_TEXTURE_3D, texture);\n        glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &width);\n        glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &height);\n        glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_DEPTH, &frames);\n        glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_INTERNAL_FORMAT,\n                                 &internalFormat);\n\n        channels = getChannelsFromInternalFormatGL(internalFormat);\n\n        glBindTexture(GL_TEXTURE_3D, 0);\n    }\n    break;\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_FORMATS_HPP */\n\n"
  },
  {
    "path": "include/util/gl/grid.hpp",
    "content": "/*\r\n\r\nPICCANTE\r\nThe hottest HDR imaging library!\r\nhttp://vcg.isti.cnr.it/piccante\r\n\r\nCopyright (C) 2014\r\nVisual Computing Laboratory - ISTI CNR\r\nhttp://vcg.isti.cnr.it\r\nFirst author: Francesco Banterle\r\n\r\nThis Source Code Form is subject to the terms of the Mozilla Public\r\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\r\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\r\n\r\n*/\r\n\r\n#ifndef PIC_UTIL_GRID_HPP\r\n#define PIC_UTIL_GRID_HPP\r\n\r\n#include <string>\r\n\r\n#include \"util/std_util.hpp\"\r\n#include \"util/gl/technique.hpp\"\r\n\r\nclass Grid {\r\npublic:\r\n\r\n    int n;\r\n    float length;\r\n    GLuint vao, vbo, cbo, ibo;\r\n    pic::TechniqueGL meshProgram;\r\n\r\n    Grid(int n = 64, float length = 16.0f)\r\n    {\r\n        this->n = n;\r\n        this->length = length;\r\n    }\r\n\r\n    void create()\r\n    {\r\n        float *vb = new float[n * 4 * 3];\r\n\r\n        for (int i = 0; i < n; i++) {\r\n            float x = (float(i) * length) / float(n - 1);\r\n\r\n            int j = i * 6;\r\n            vb[j    ] = x;\r\n            vb[j + 1] = 0.0f;\r\n            vb[j + 2] = 0.0f;\r\n\r\n            vb[j + 3] = x;\r\n            vb[j + 4] = 0.0f;\r\n            vb[j + 5] = length;\r\n        }\r\n\r\n        int shift = n * 6;\r\n        for (int i = 0; i < n; i++) {\r\n            float z = (float(i) * length) / float(n - 1);\r\n\r\n            int j = shift + i * 6;\r\n\r\n            vb[j] = 0.0f;\r\n            vb[j + 1] = 0.0f;\r\n            vb[j + 2] = z;\r\n\r\n            vb[j + 3] = length;\r\n            vb[j + 4] = 0.0f;\r\n            vb[j + 5] = z;\r\n        }\r\n\r\n        //\r\n        //Vertex Buffers\r\n        //\r\n        glGenVertexArrays(1, &vao);\r\n        glBindVertexArray(vao);\r\n\r\n        //Vertex buffer object\r\n        glGenBuffers(1, &vbo);\r\n        glBindBuffer(GL_ARRAY_BUFFER, vbo);\r\n        glBufferData(GL_ARRAY_BUFFER, sizeof(float) * n * 12, vb, GL_STATIC_DRAW);\r\n        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);\r\n        glEnableVertexAttribArray(0);\r\n\r\n        /*Create shader*/\r\n        //Shader Program\r\n        std::string vertex_source = MAKE_STRING\r\n        (\r\n            layout(location = 0) in vec4 a_position;\r\n            uniform mat4 u_mvp;\r\n\r\n            void main(void) {\r\n                gl_Position = u_mvp * a_position;\r\n            }\r\n        );\r\n\r\n        std::string fragment_source = MAKE_STRING\r\n        (\r\n            layout(location = 0) out vec4 f_color;\r\n\r\n            void main(void) {\r\n                f_color = vec4(0.8, 0.8, 0.8, 1.0);\r\n            }\r\n        );\r\n        \r\n        meshProgram.init(\"330\", vertex_source, fragment_source, \"MeshProgram\");\r\n        meshProgram.printLog(\"MeshProgram\");\r\n\r\n        meshProgram.bind();\r\n        meshProgram.setAttributeIndex(\"a_position\", 0);\r\n        meshProgram.setOutputFragmentShaderIndex(\"f_color\", 0);\r\n        meshProgram.link();\r\n        meshProgram.unbind();\r\n    }\r\n\r\n    void render(float *viewprojection)\r\n    {\r\n        meshProgram.bind();\r\n        meshProgram.setUniform4x4(\"u_mvp\", viewprojection, false);\r\n\r\n        glBindVertexArray(vao);\r\n        glDrawArrays(GL_LINES, 0, n * 4);\r\n        glBindVertexArray(0);\r\n\r\n        meshProgram.unbind();\r\n    }\r\n\r\n};\r\n\r\n\r\n\r\n#endif /* PIC_UTIL_GRID_HPP */\r\n\r\n"
  },
  {
    "path": "include/util/gl/mask.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_MASK_HPP\n#define PIC_UTIL_GL_MASK_HPP\n\n#include \"../../base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief GenerateMask creates an opengl mask (a texture) from a buffer of bool values.\n * @param width\n * @param height\n * @param buffer\n * @param tex\n * @param tmpBuffer\n * @param mipmap\n * @return\n */\nPIC_INLINE GLuint GenerateMask(int width, int height, bool *buffer = NULL,\n                    GLuint tex = 0, unsigned char *tmpBuffer = NULL, bool mipmap = false)\n{\n    bool bGen = (tex == 0);\n\n    if(bGen) {\n        glGenTextures(1, &tex);\n    }\n\n    glBindTexture(GL_TEXTURE_2D, tex);\n\n    if(bGen) {\n        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n    }\n\n    unsigned char *data = NULL;\n\n    if(buffer != NULL) {\n        int n = width * height;\n\n        if(tmpBuffer != NULL) {\n            data = tmpBuffer;\n        } else {\n            data = new unsigned char[n * 3];\n        }\n\n        #pragma omp parallel for\n\n        for(int i = 0; i < n; i++) {\n            data[i] = buffer[i] ? 255 : 0;\n        }\n    }\n\n    if(bGen) {\n\n        if(mipmap) {\n            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);\n        } else {\n            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n        }\n\n        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);\n    }\n\n    /*\n        Note: GL_LUMINANCE is deprecated since OpenGL 3.1\n        glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8 , width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);\n    */\n\n    glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, width, height, 0, GL_RED, GL_UNSIGNED_BYTE, data);\n\n    if(mipmap && bGen) {\n        glGenerateMipmap(GL_TEXTURE_2D);\n    }\n\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    if(data != NULL && tmpBuffer == NULL) {\n        delete[] data;\n    }\n\n    return tex;\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_ */\n"
  },
  {
    "path": "include/util/gl/program.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_PROGRAM_HPP\n#define PIC_UTIL_GL_PROGRAM_HPP\n\n#include <string>\n\n#include \"../../base.hpp\"\n\nnamespace pic {\n\nclass ProgramGL\n{\nprotected:\n    GLint bCheckStatus;\n    GLenum type;\n    GLuint object;\n    std::string source;\n    std::string log;\n    bool bType;\n\n    /**\n     * @brief checkShaderStatus\n     * @return\n     */\n    bool checkShaderStatus()\n    {\n        log.clear();\n\n        bCheckStatus = GL_FALSE;\n        glGetShaderiv(object, GL_COMPILE_STATUS, &bCheckStatus);\n\n        //get the log in case of failure\n        if(bCheckStatus == GL_FALSE) {\n            GLint max_length = -1;\n            glGetShaderiv(object, GL_INFO_LOG_LENGTH, &max_length);\n\n            std::vector<GLchar> error(max_length);\n            glGetShaderInfoLog(object, max_length, &max_length, &error[0]);\n\n            glDeleteShader(object);\n            object = 0;\n\n            log += \"-----------------------------------------\\n\";\n            log += \"-- This shader was not compiled!\\n\";\n            log += \"-----------------------------------------\\n\";\n\n            return false;\n        } else {\n            log += \"-----------------------------------------\\n\";\n            log += \"-- This shader was compiled successfully!\\n\";\n            log += \"-----------------------------------------\\n\";\n\n            return true;\n        }\n    }\n\n    /**\n     * @brief checkProgramStatus\n     * @return\n     */\n    bool checkProgramStatus()\n    {\n        bCheckStatus = GL_FALSE;\n        glGetProgramiv(object, GL_LINK_STATUS, &bCheckStatus);\n\n        //get the log in case of failure\n        if(bCheckStatus == GL_FALSE) {\n            GLint max_length = -1;\n            glGetProgramiv(object, GL_INFO_LOG_LENGTH, &max_length);\n\n            std::vector<GLchar> error(max_length);\n            glGetProgramInfoLog(object, max_length, &max_length, &error[0]);\n\n            glDeleteProgram(object);\n            object = 0;\n\n            log += \"----------------------------------------\\n\";\n            log += \"-- This program was not linked!\\n\";\n            log += \"----------------------------------------\\n\";\n\n            return false;\n        } else {\n            log += \"----------------------------------------\\n\";\n            log += \"-- This program was linked successfully!\\n\";\n            log += \"----------------------------------------\\n\";\n\n            return true;\n        }\n    }\n\npublic:\n\n    bool bCompiled;\n\n    ProgramGL()\n    {\n        setNULL();\n    }\n\n    ProgramGL( std::string version,\n               std::string extensions,\n               std::string source,\n               GLenum type)\n    {\n        setNULL();\n        initShader(version, extensions, source, type);\n    }\n\n    ProgramGL(std::vector<ProgramGL*> &shaders)\n    {\n        initProgram(shaders);\n    }\n\n    ~ProgramGL()\n    {\n        if(object != 0) {\n            if(bType) {\n                glDeleteShader(object);\n            } else {\n                glDeleteProgram(object);\n            }\n            object = 0;\n        }\n\n        log.clear();\n        source.clear();\n    }\n\n    /**\n     * @brief SetNULL\n     */\n    void setNULL()\n    {\n        this->bCompiled = false;\n        this->bType = true;\n        this->type = 0;\n        this->object = 0;\n        this->log = \"\";\n        this->source = \"\";\n        this->bCheckStatus = GL_FALSE;\n    }\n\n    /**\n     * @brief getObject\n     * @return\n     */\n    GLuint getObject()\n    {\n        return object;\n    }\n\n    /**\n     * @brief initProgram\n     * @param shaders\n     * @return\n     */\n    bool initProgram(std::vector<ProgramGL*> &shaders)\n    {\n        bType = false;\n        object = glCreateProgram();\n\n        for(uint i = 0; i < shaders.size(); i++)\n        {\n            GLuint tmp = shaders[i]->getObject();\n            if(tmp != 0) {\n                glAttachShader(object, tmp);\n            }\n        }\n\n        glLinkProgram(object);\n\n        bCompiled = checkProgramStatus();\n\n        return bCompiled;\n    }\n\n    /**\n     * @brief initShader\n     * @param version\n     * @param extensions\n     * @param source\n     * @param type\n     * @return\n     */\n    bool initShader( std::string version_number,\n                std::string extensions,\n                std::string source,\n                GLenum type)\n    {\n        this->type = type;\n        this->bType = true;\n\n        object = glCreateShader(type);\n\n        this->source.clear();\n\n        //create full source\n        if(!version_number.empty()) {\n            this->source += \"#version \";\n            this->source += version_number;\n            this->source += \"\\n\";\n        }\n\n        if(!extensions.empty()) {\n            this->source += extensions;\n            this->source += \"\\n\";\n        }\n\n        if(!source.empty()) {\n            this->source += source;\n        }\n\n        const GLchar *tmp = (const GLchar *) this->source.c_str();\n        glShaderSource(object, 1, &tmp, NULL);\n        glCompileShader(object);\n\n        return checkShaderStatus();\n    }\n\n    /**\n     * @brief printLog\n     */\n    void printLog()\n    {\n        printf(\"%s\", log.c_str());\n    }\n\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_PROGRAM_HPP */\n\n"
  },
  {
    "path": "include/util/gl/quad.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_QUAD_HPP\n#define PIC_UTIL_GL_QUAD_HPP\n\nnamespace pic {\n\n#include <string>\n\n#include \"../../util/gl/technique.hpp\"\n\n/**\n * @brief The QuadGL class\n */\nclass QuadGL\n{\nprotected:\n    GLuint vao;\t\t//vertex array object\n    GLuint vbo[2];\t//vertex buffer object\n\npublic:\n\n    QuadGL()\n    {\n        vao = 0;\n        vbo[0] = 0;\n        vbo[1] = 0;\n    }\n\n    QuadGL(bool bTextureCoordinates, float halfSizeX = 1.0f, float halfSizeY = 1.0f)\n    {\n        vao = 0;\n        vbo[0] = 0;\n        vbo[1] = 0;\n\n        init(bTextureCoordinates, halfSizeX, halfSizeY);\n    }\n\n    ~QuadGL()\n    {\n        if(vao > 0) {\n            glDeleteBuffers(1, &vao);\n            vao = 0;\n        }\n\n        if(vbo[0] > 0) {\n            glDeleteBuffers(1, &vbo[0]);\n            vbo[0] = 0;\n        }\n\n        if(vbo[1] > 0) {\n            glDeleteBuffers(1, &vbo[1]);\n            vbo[1] = 0;\n        }\n    }\n\n    /**\n     * @brief init initializates the QuadGL by allocating memory on the GPU.\n     * @param bTextCoordinates\n     */\n    void init(bool bTexCoordinates, float halfSizeX = 1.0f, float halfSizeY = 1.0f)\n    {\n        float *data_pos = createPosCoord(halfSizeX, halfSizeY);\n\n        if(bTexCoordinates) {\n            float *data_tex = createTexCoord();\n\n            //init VBO 0\n            glGenBuffers(1, &vbo[0]);\n            glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);\n            glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), data_pos, GL_STATIC_DRAW);\n            glBindBuffer(GL_ARRAY_BUFFER, 0);\n\n            //init VBO 1\n            glGenBuffers(1, &vbo[1]);\n            glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);\n            glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), data_tex, GL_STATIC_DRAW);\n            glBindBuffer(GL_ARRAY_BUFFER, 0);\n\n            //init VAO\n            glGenVertexArrays(1, &vao);\n            glBindVertexArray(vao);\n\n            glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);\n            glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);\n            glEnableVertexAttribArray(0);\n\n            glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);\n            glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0);\n            glEnableVertexAttribArray(1);\n\n            glBindVertexArray(0);\n            glDisableVertexAttribArray(0);\n            glBindBuffer(GL_ARRAY_BUFFER, 0);\n\n            delete[] data_tex;\n        } else {\n            //init VBO\n            glGenBuffers(1, &vbo[0]);\n            glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);\n            glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), data_pos, GL_STATIC_DRAW);\n            glBindBuffer(GL_ARRAY_BUFFER, 0);\n\n            //init VAO\n            glGenVertexArrays(1, &vao);\n            glBindVertexArray(vao);\n            glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);\n\n            glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);\n\n            glEnableVertexAttribArray(0);\n            glBindVertexArray(0);\n            glDisableVertexAttribArray(0);\n            glBindBuffer(GL_ARRAY_BUFFER, 0);\n        }\n\n        delete[] data_pos;\n    }\n\n    /**\n     * @brief Render draws a quad on screen.\n     */\n    void Render()\n    {\n        glBindVertexArray(vao);\n        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);\n        glBindVertexArray(0);\n    }\n\n    /**\n     * @brief Render\n     * @param technque\n     * @param texture\n     */\n    void Render(TechniqueGL &technique, GLuint texture)\n    {\n        technique.bind();\n\n        glEnable(GL_TEXTURE_2D);\n        glActiveTexture(GL_TEXTURE0);\n        glBindTexture(GL_TEXTURE_2D, texture);\n\n        Render();\n\n        glActiveTexture(GL_TEXTURE0);\n        glBindTexture(GL_TEXTURE_2D, 0);\n\n        technique.unbind();\n    }\n\n    /**\n     * @brief createPosCoord allocates memory for a position buffer.\n     * @return\n     */\n    static float *createPosCoord(float halfSizeX = 1.0f, float halfSizeY = 1.0f)\n    {\n        float *data = new float[8];\n\n        data[0] = -halfSizeX;\n        data[1] =  halfSizeY;\n\n        data[2] = -halfSizeX;\n        data[3] = -halfSizeY;\n\n        data[4] =  halfSizeX;\n        data[5] =  halfSizeY;\n\n        data[6] =  halfSizeX;\n        data[7] = -halfSizeY;\n        return data;\n    }\n\n    /**\n     * @brief createTexCoord allocates memory for a texture coordinates buffer.\n     * @return\n     */\n    static float *createTexCoord()\n    {\n        float *data = new float[8];\n\n        data[0] = 0.0f;\n        data[1] = 1.0f;\n\n        data[2] = 0.0f;\n        data[3] = 0.0f;\n\n        data[4] = 1.0f;\n        data[5] = 1.0f;\n\n        data[6] = 1.0f;\n        data[7] = 0.0f;\n        return data;\n    }\n\n    /**\n     * @brief getVertexProgramV3 creates a simple vertex program.\n     * @return\n     */\n    static std::string getVertexProgramV3()\n    {\n        std::string vertex_program = MAKE_STRING\n                                     (\n                                         in vec3 a_position;\n\n        void main(void) {\n            gl_Position = vec4(a_position, 1.0);\n        }\n                                     );\n\n        return vertex_program;\n    }\n\n    /**\n     * @brief getVertexProgramV2 creates a simple vertex program.\n     * @return\n     */\n    static std::string getVertexProgramV2()\n    {\n        std::string vertex_program = MAKE_STRING\n                                     (\n                                         in vec2 a_position;\n\n        void main(void) {\n            gl_Position = vec4(a_position, 0.0, 1.0);\n        }\n                                     );\n\n        return vertex_program;\n    }\n\n    /**\n     * @brief getVertexProgramWithTexCoordinates creates a simple vertex program\n     * with texture coordinates as input.\n     * @return\n     */\n    static std::string getVertexProgramWithTexCoordinates()\n    {\n        std::string vertex_program = MAKE_STRING\n                                     (\n                                         in vec2 a_position;\n                                         in vec2 a_tex_coord;\n                                         out vec2 v_tex_coord;\n\n        void main(void) {\n            gl_Position = vec4(a_position, 0.0, 1.0);\n            v_tex_coord = a_tex_coord;\n        }\n                                     );\n\n        return vertex_program;\n    }\n\n    /**\n     * @brief getFragmentProgram\n     * @return\n     */\n    static std::string getFragmentProgram()\n    {\n\n        std::string fragment_program = MAKE_STRING\n                                      (\n                                          uniform sampler2D u_tex;\n                                          out     vec4      f_color;\n\n        void main(void) {\n            ivec2 coords = ivec2(gl_FragCoord.xy);\n            f_color = vec4(texelFetch(u_tex, coords, 0).xyz, 1.0);\n        }\n                                      );\n\n        return fragment_program;\n    }\n\n    /**\n     * @brief getFragmentProgramForView\n     * @return\n     */\n    static std::string getFragmentProgramForView()\n    {\n\n        std::string fragment_program = MAKE_STRING\n                                      (\n                                          uniform sampler2D u_tex;\n                                          out     vec4      f_color;\n\n        void main(void) {\n            ivec2 coords = ivec2(gl_FragCoord.xy);\n            ivec2 texSize = textureSize(u_tex, 0);\n            coords.y = texSize.y - coords.y;\n            f_color = vec4(texelFetch(u_tex, coords, 0).xyz, 1.0);\n        }\n                                      );\n\n        return fragment_program;\n    }\n\n    /**\n     * @brief getProgram creates a simple program.\n     * @param ret\n     * @param vp_src\n     * @param fp_src\n     */\n    static void getTechnique(TechniqueGL &technique, std::string vp_src = \"\", std::string fp_src = \"\", bool bTextureCoordinates = false)\n    {\n        if(vp_src.empty() || fp_src.empty()) {\n            technique.init(\"330\", getVertexProgramV3(), getFragmentProgram());\n        } else {\n            technique.init(\"330\", vp_src, fp_src);\n        }\n\n        #ifdef PIC_DEBUG\n            technique.printLog(\"QuadGL\");\n        #endif\n\n        technique.bind();\n        technique.setAttributeIndex(\"a_position\", 0);\n\n        if(bTextureCoordinates) {\n            technique.setAttributeIndex(\"a_tex_coord\", 1);\n        }\n\n        technique.setOutputFragmentShaderIndex(\"f_color\", 0);\n        technique.link();\n        technique.unbind();\n\n        technique.bind();\n        technique.setUniform1i(\"u_tex\", 0);\n        technique.unbind();\n    }\n\n    #ifdef PIC_DEPRECATED\n    /**\n     * @brief Draw: draw using compability mode (deprecated!)\n     */\n    static void Draw()\n    {\n        glDisable(GL_DEPTH_TEST);\n\n        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);\n\n        //Rendering an aligned quad\n        glBegin(GL_TRIANGLE_STRIP);\n\n        glVertex2f( -1.0f,  1.0f);\n        glVertex2f( -1.0f, -1.0f);\n        glVertex2f(  1.0f,  1.0f);\n        glVertex2f(  1.0f, -1.0f);\n\n        glEnd();\n    }\n\n    /**\n     * @brief Draw draws using compability mode (deprecated!).\n     * @param tex\n     */\n    static void Draw(GLuint tex)\n    {\n        glEnable(GL_TEXTURE_2D);\n\n        glActiveTexture(GL_TEXTURE0);\n        glBindTexture(GL_TEXTURE_2D, tex);\n\n        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);\n\n        //Rendering an aligned quad\n        glBegin(GL_TRIANGLE_STRIP);\n\n        glTexCoord2f( 0.0f,  0.0f);\n        glVertex2f(  -1.0f,  1.0f);\n\n        glTexCoord2f( 0.0f,  1.0f);\n        glVertex2f(  -1.0f, -1.0f);\n\n        glTexCoord2f( 1.0f,  0.0f);\n        glVertex2f(   1.0f,  1.0f);\n\n        glTexCoord2f( 1.0f,  1.0f);\n        glVertex2f(   1.0f, -1.0f);\n\n        glEnd();\n\n        glDisable(GL_TEXTURE_2D);\n    }\n\n    /**\n     * @brief Draw draws using compability mode (deprecated!).\n     * @param tex\n     * @param color\n     */\n    static void Draw(GLuint tex, float *color)\n    {\n        glEnable(GL_TEXTURE_2D);\n        glActiveTexture(GL_TEXTURE0);\n        glBindTexture(GL_TEXTURE_2D, tex);\n\n        if(color == NULL) {\n            glColor4f(1.0f, 1.0f, 1.0f, 1.0f);\n        } else {\n            glColor3fv(color);\n        }\n\n        //Rendering an aligned quad\n        glBegin(GL_TRIANGLE_STRIP);\n\n        glTexCoord2f(0.0f,  0.0f);\n        glVertex2f( -1.0f,  1.0f);\n\n        glTexCoord2f(0.0f,  1.0f);\n        glVertex2f( -1.0f, -1.0f);\n\n        glTexCoord2f(1.0f,  0.0f);\n        glVertex2f(  1.0f,  1.0f);\n\n        glTexCoord2f(1.0f,  1.0f);\n        glVertex2f(  1.0f, -1.0f);\n\n        glEnd();\n\n        glDisable(GL_TEXTURE_2D);\n    }\n\n    /**\n     * @brief Draw\n     * @param texture\n     * @param width\n     * @param height\n     * @param pg\n     */\n    static void Draw(GLuint texture, int width, int height, TechniqueGL &technique)\n    {\n        glFrontFace(GL_CW);\n\n        glMatrixMode(GL_PROJECTION);\n        glLoadIdentity();\n\n        glMatrixMode(GL_MODELVIEW);\n        glLoadIdentity();\n\n        glDisable(GL_DEPTH_TEST);\n        glViewport(0, 0, (GLsizei)width, (GLsizei)height);\n\n        technique.bind();\n\n        glEnable(GL_TEXTURE_2D);\n        glActiveTexture(GL_TEXTURE0);\n        glBindTexture(GL_TEXTURE_2D, texture);\n\n        //Rendering an aligned quad\n        glBegin(GL_TRIANGLE_STRIP);\n        glVertex2f(1.0f, -1.0f);\n\n        glVertex2f(-1.0f, -1.0f);\n\n        glVertex2f(1.0f,  1.0f);\n\n        glVertex2f(-1.0f,  1.0f);\n\n        glEnd();\n\n        glDisable(GL_TEXTURE_2D);\n\n        technique.unbind();\n        glEnable(GL_DEPTH_TEST);        \n    }\n    #endif // end PIC_DEPRECATED\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_QUAD_HPP */\n\n"
  },
  {
    "path": "include/util/gl/redux.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_REDUX_HPP\n#define PIC_UTIL_GL_REDUX_HPP\n\n#include \"base.hpp\"\n\n#include \"util/gl/technique.hpp\"\n#include \"util/gl/fbo.hpp\"\n#include \"util/gl/quad.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The ReduxGL class\n */\nclass ReduxGL\n{\nprotected:\n    //FBO\n    Fbo *fbo;\n\n    //quad\n    QuadGL *quad;\n\n    bool bDomainTransform;\n    int  counter;\n\n    //shaders\n    std::string vertex_source, geometry_source, fragment_source, fragment_source_domain_transform;\n    TechniqueGL techinques[2];\n\n    std::string reduxOperation;\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\npublic:\n    /**\n     * @brief ReduxGL\n     * @param reduxOperation\n     */\n    ReduxGL(std::string reduxOperation, bool bDomainTransform);\n\n    ~ReduxGL();\n\n    /**\n     * @brief Process\n     * @param texIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param texOut\n     * @return\n     */\n    GLuint Process(GLuint texIn, int width, int height, int channels, GLuint texOut);\n\n    /**\n     * @brief Redux\n     * @param texIn\n     * @param width\n     * @param height\n     * @param channels\n     * @param stack\n     * @return\n     */\n    GLuint Redux(GLuint texIn, int width, int height, int channels, std::vector<GLuint> &stack)\n    {\n        if(stack.empty() || (texIn == 0)) {\n            return 0;\n        }\n\n        GLuint texFlt = texIn;\n\n        for(unsigned int i = 0; i < stack.size(); i++) {\n            counter = (bDomainTransform && (i == 0)) ? 1 : 0;\n\n            width  = divideByTwoWithEvenDividend(width);\n            height = divideByTwoWithEvenDividend(height);\n\n            Process(texFlt, width, height, channels, stack[i]);\n            texFlt = stack[i];\n        }\n\n        return texFlt;\n    }\n\n    /**\n     * @brief createMean\n     * @return\n     */\n    static ReduxGL *createMean()\n    {\n        ReduxGL *filter = new\n        ReduxGL(\"color = (color00 + color10 + color01 + color11) / 4.0;\", false);\n        return filter;\n    }\n\n    /**\n     * @brief createSum\n     * @return\n     */\n    static ReduxGL *createSum()\n    {\n        ReduxGL *filter = new\n        ReduxGL(\"color = color00 + color10 + color01 + color11;\", false);\n        return filter;\n    }\n\n    /**\n     * @brief createLogMean\n     * @return\n     */\n    static ReduxGL *createLogMean()\n    {\n        ReduxGL *filter = new\n        ReduxGL(\"color = (color00 + color10 + color01 + color11) / 4.0;\", true);\n        return filter;\n    }\n\n    /**\n     * @brief createMin\n     * @return\n     */\n    static ReduxGL *createMin()\n    {\n        ReduxGL *filter = new\n        ReduxGL(\"color = min(color00, color10);\\n \"\n                \"color = min(color, color01);\\n \"\n                \"color = min(color, color11);\\n\", false);\n        return filter;\n    }\n\n    /**\n     * @brief createMax\n     * @return\n     */\n    static ReduxGL *createMax()\n    {\n        ReduxGL *filter = new\n        ReduxGL(\"color = max(color00, color10);\\n \"\n                \"color = max(color, color01);\\n \"\n                \"color = max(color, color11);\\n\", false);\n        return filter;\n    }\n\n    /**\n     * @brief createMinPos\n     * @return\n     */\n    static ReduxGL *createMinPos()\n    {\n        ReduxGL *filter = new\n        ReduxGL(\"vec4 maxVal = vec4(1e-6); \"\n                \"if(color00.x>0.0f) color = color00; \"\n                \"if(color01.x>0.0f) color = min(color,color01); \"\n                \"if(color10.x>0.0f) color = min(color,color10); \"\n                \"if(color11.x>0.0f) color = min(color,color11);\\n\", false);\n        return filter;\n    }\n\n    /**\n     * @brief createCheck\n     * @return\n     */\n    static ReduxGL *createCheck()\n    {\n        ReduxGL *filter = new\n        ReduxGL(\"vec4 sum = color00 + color01 + color10 + color11; \"\n                \"color = sum.x < 0.5? vec4(0.0) : sum; \"\n                \"color = ((sum.x > 0.5) && (sum.x < 3.5))? vec4(10.0) : color; \"\n                \"color = ((sum.x > 3.5) && (sum.x < 4.5))? vec4(1.0) : color; \"\n                \"color = sum.x > 4.5 ? vec4(10.0) : color;\\n\", false);\n        return filter;\n    }\n\n    /**\n     * @brief divideByTwoWithEvenDividend if x is even it computes x / 2 otherwise (x + 1) / 2.\n     * @param x is an input value.\n     * @return If x is even it returns x/2; otherwise it returns (x + 1) / 2.\n     */\n    static int divideByTwoWithEvenDividend(int x)\n    {\n        if((x % 2) != 0) {\n            x++;\n        }\n\n        return (x >> 1);\n    }\n\n    /**\n     * @brief allocateReduxData allocates a pyramid for computing the Redux operator.\n     * @param width\n     * @param height\n     * @param channels\n     * @param minSize\n     * @return\n     */\n    static void allocateReduxData(int width, int height, int channels,\n                           std::vector<GLuint> &stack, int minSize = 2)\n    {\n        int checkSize = divideByTwoWithEvenDividend(MIN(width, height));\n\n        stack.clear();\n\n        if(minSize < 2) {\n            minSize = 2;\n        }\n\n        while(checkSize >= minSize) {\n            width  = divideByTwoWithEvenDividend(width);\n            height = divideByTwoWithEvenDividend(height);\n\n            stack.push_back(generateTexture2DGL(width, height, channels));\n\n            checkSize = MIN(width, height);\n        }\n    }\n\n};\n\nPIC_INLINE ReduxGL::ReduxGL(std::string reduxOperation, bool bDomainTransform)\n{\n    fbo = NULL;\n\n    quad = NULL;\n\n    this->counter = 0;\n    this->bDomainTransform = bDomainTransform;\n\n    quad = new QuadGL(false);\n\n    //get a vertex program for screen aligned quad\n    vertex_source = QuadGL::getVertexProgramV3();\n\n    this->reduxOperation = reduxOperation;\n    initShaders();\n}\n\nPIC_INLINE ReduxGL::~ReduxGL()\n{\n    delete quad;\n    delete fbo;\n}\n\nPIC_INLINE void ReduxGL::initShaders()\n{\n    fragment_source = MAKE_STRING\n                      (\n    uniform sampler2D u_tex; \\n\n    out     vec4      f_color; \\n\n\n    void main(void) {\n        \\n\n        ivec2 texSize = textureSize(u_tex, 0);\n        ivec2 coords  = ivec2(gl_FragCoord.xy) * 2;\n        \\n\n        vec4  color00 = texelFetch(u_tex, coords               ,0);\n        \\n\n        vec4  color10 = texelFetch(u_tex, coords + ivec2(1, 0), 0);\n        \\n\n        vec4  color01 = texelFetch(u_tex, coords + ivec2(0, 1), 0);\n        \\n\n        vec4  color11 = texelFetch(u_tex, coords + ivec2(1, 1), 0);\n        \\n\n        vec4  color;\n        \\n\n        ___REDUX_OPERATION___ \\n\n        f_color = vec4(color.xyz, 1.0);\n        \\n\n    }\n                      );\n//    f_color = ((texSize - coords) == ivec2(0, 0)) ? color00 : color;\n\n    fragment_source_domain_transform = fragment_source;\n\n    size_t processing_found = fragment_source.find(\"___REDUX_OPERATION___\");\n    fragment_source.replace(processing_found, 21, reduxOperation);\n\n    techinques[0].initStandard(\"330\", vertex_source, fragment_source, \"ReduxGL\");\n\n    techinques[0].bind();\n    techinques[0].setUniform1i(\"u_tex\", 0);\n    techinques[0].unbind();\n\n    if(bDomainTransform) {\n        size_t processing_found = fragment_source_domain_transform.find(\"___REDUX_OPERATION___\");\n        std::string domain_transform = \"float eps = 1e-6; \"\n                                       \"color00 = log(color00 + eps); \"\n                                       \"color01 = log(color01 + eps); \"\n                                       \"color10 = log(color10 + eps) ; \"\n                                       \"color11 = log(color11 + eps);\";\n        domain_transform += reduxOperation;\n        fragment_source_domain_transform.replace(processing_found, 21, domain_transform);\n\n        techinques[1].initStandard(\"330\", vertex_source, fragment_source_domain_transform, \"ReduxGL\");\n\n        techinques[1].bind();\n        techinques[1].setUniform1i(\"u_tex\", 0);\n        techinques[1].unbind();\n    }\n}\n\nPIC_INLINE GLuint ReduxGL::Process(GLuint texIn, int width, int height, int channels, GLuint texOut)\n{\n    if(texIn == 0) {\n        return texOut;\n    }\n\n    if(texOut == 0) {\n        texOut = generateTexture2DGL(width, height, channels);\n    }\n\n    if(width < 1 || height < 1) {\n        return texOut;\n    }\n\n    //check the fbo\n    if(fbo == NULL) {\n        fbo = new Fbo();\n    }\n\n    fbo->create(width, height, 1, false, texOut);\n\n    //bind the fbo\n    fbo->bind();\n    glViewport(0, 0, (GLsizei)width, (GLsizei)height);\n\n    //bind shaders\n    techinques[counter].bind();\n\n    //bind textures\n    glActiveTexture(GL_TEXTURE0);\n    glBindTexture(GL_TEXTURE_2D, texIn);\n\n    //render an aligned quad\n    quad->Render();\n\n    //unbind the fbo\n    fbo->unbind();\n\n    //unbind shaders\n    techinques[counter].unbind();\n\n    //unbind textures\n    glActiveTexture(GL_TEXTURE0);\n    glBindTexture(GL_TEXTURE_2D, 0);\n\n    return texOut;\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_REDUX_HPP */\n\n"
  },
  {
    "path": "include/util/gl/redux_ops.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_REDUX_OPS_HPP\n#define PIC_UTIL_GL_REDUX_OPS_HPP\n\n#include <vector>\n#include <map>\n#include <thread>\n#include <mutex>\n\n#include \"../../util/gl/redux.hpp\"\n\nnamespace pic {\n\nenum REDGL{REDGL_MIN, REDGL_MAX, REDGL_SUM, REDGL_MEAN, REDGL_LOG_MEAN};\n\ntypedef std::vector<ReduxGL*> ReduxOperatorsGL;\n\n/**\n * @brief The BufferOpsGL class\n */\nclass ReduxOpsGL\n{\npublic:\n    ReduxOperatorsGL list;\n\n    /**\n     * @brief getInstance\n     * @return\n     */\n    static ReduxOpsGL* getInstance()\n    {\n        std::thread::id this_id = std::this_thread::get_id();\n\n        if(!flag[this_id]) {\n            std::lock_guard<std::mutex> lock(mutex);\n\n            if(redux_ops_gl[this_id] == NULL) {\n                redux_ops_gl[this_id] = new ReduxOpsGL();\n                flag[this_id] = true;\n            }\n        }\n\n        return redux_ops_gl[this_id];\n    }\n\n    ~ReduxOpsGL()\n    {\n    }\n\nprivate:\n    static std::mutex mutex;\n    static std::map<std::thread::id, bool> flag;\n    static std::map<std::thread::id, ReduxOpsGL*> redux_ops_gl;\n\n    /**\n     * @brief ReduxOpsGL\n     */\n    ReduxOpsGL()\n    {\n        list.push_back(ReduxGL::createMin());\n        list.push_back(ReduxGL::createMax());\n        list.push_back(ReduxGL::createSum());\n        list.push_back(ReduxGL::createMean());\n        list.push_back(ReduxGL::createLogMean());\n    }\n\n};\n\nPIC_INLINE std::mutex ReduxOpsGL::mutex;\n\nPIC_INLINE std::map<std::thread::id, bool> ReduxOpsGL::flag;\n\nPIC_INLINE std::map<std::thread::id, ReduxOpsGL*> ReduxOpsGL::redux_ops_gl;\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_REDUX_OPS_HPP */\n"
  },
  {
    "path": "include/util/gl/ssbo.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_SSBO_HPP\n#define PIC_UTIL_GL_SSBO_HPP\n\n#include <iostream>\n\nnamespace pic {\n\nusing namespace std;\n\n#ifdef OPEN_GL_4_30\n/**\n * @brief The Ssbo class: shader storage buffer object\n */\nclass Ssbo\n{\nprotected:\n    GLuint ssbo;\n    total_size;\n\npublic:\n\n    /**\n     * @brief Ssbo\n     */\n    Ssbo()\n    {\n        total_size = 0;\n        ssbo = 0;\n    }\n\n    ~Ssbo()\n    {\n        if(ssbo != 0) {\n        }\n    }\n\n    /**\n     * @brief init\n     * @param size_buffer\n     * @param size_of_type\n     * @param data\n     */\n    void init(unsigned int size_buffer, unsigned int size_of_type, void *data)\n    {\n        total_size = size_buffer * size_of_type;\n        glGenBuffers(1, &ssbo);\n        glBindBuffer(GL_SHADER_STORAGE_BUFFER, posSSbo );\n        glBufferData(GL_SHADER_STORAGE_BUFFER, total_size, data, GL_DYNAMIC_COPY );\n\n        glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);\n    }\n\n    /**\n     * @brief update\n     * @param data\n     */\n    void update(void *data)\n    {\n        glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);\n        GLvoid *p = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY);\n        memcpy(p, &data, total_size)\n        glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);\n    }\n\n    void bind(unsigned int index)\n    {\n        glBindBufferBase(GL_SHADER_STORAGE_BUFFER, index, ssbo);\n    }\n\n    void unbind(unsigned int index)\n    {\n        glBindBufferBase(GL_SHADER_STORAGE_BUFFER, index, 0);\n    }\n\n    /*\n    void *mapBuffer()\n    {\n        glBindBuffer(GL_SHADER_STORAGE_BUFFER, posSSbo );\n        GLint bufMask = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT;\n        return glMapBufferRange( GL_SHADER_STORAGE_BUFFER, 0, total_size, bufMask);\n    }\n\n    void unmapBuffer()\n    {\n        glUnmapBuffer( GL_SHADER_STORAGE_BUFFER );\n    }\n    */\n};\n\n#endif\n\n}// end namespace pic\n\n\n#endif /* PIC_UTIL_GL_SSBO_HPP */\n\n"
  },
  {
    "path": "include/util/gl/stroke.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_STROKE_HPP\n#define PIC_UTIL_GL_STROKE_HPP\n\n#include \"../../util/rasterizer.hpp\"\n#include \"../../gl/image.hpp\"\n#include \"../../util/gl/quad.hpp\"\n#include \"../../util/gl/technique.hpp\"\n\nnamespace pic {\n\n//TODO: removing immediate mode\n\n/**\n * @brief The StrokeGL class\n */\nclass StrokeGL\n{\nprotected:\n    int\t width, height, brushSize;\n    ImageGL *shape;\n    float size, rSize;\n    float color[4];\n    float tmpColor[3];\n\n    QuadGL *quad;\n\n    std::vector<float>\tpositions;\n\n    TechniqueGL annotationProgram;\n    TechniqueGL brushProgram;\n\npublic:\n    float annotation;\n\n    /**\n     * @brief StrokeGL\n     * @param width\n     * @param height\n     * @param brushSize\n     * @param color\n     */\n    StrokeGL(int width, int height, int brushSize, float *color);\n\n    ~StrokeGL();\n\n    /**\n     * @brief initShaders\n     */\n    void initShaders();\n\n    /**\n     * @brief Resample\n     */\n    void Resample();\n\n    /**\n     * @brief Reset\n     */\n    void Reset();\n\n    /**\n     * @brief Insert2DPoint\n     * @param x\n     * @param y\n     */\n    void Insert2DPoint(int x, int y);\n\n    /**\n     * @brief RenderGL\n     */\n    void RenderGL();\n\n    /**\n     * @brief RenderAnnotationGL\n     */\n    void RenderAnnotationGL();\n\n    /**\n     * @brief RenderBrushGL\n     * @param x\n     * @param y\n     */\n    void RenderBrushGL(int x, int y);\n\n    /**\n     * @brief Size\n     * @return\n     */\n    unsigned int Size()\n    {\n        return (unsigned int)(positions.size());\n    }\n\n    /**\n     * @brief bindCol\n     * @param val\n     */\n    void bindCol(float val)\n    {\n        memcpy(tmpColor, color, 3 * sizeof(float));\n        color[0] = color[1] = color[2] = val;\n    }\n\n    /**\n     * @brief unBindCol\n     */\n    void unBindCol()\n    {\n        memcpy(color, tmpColor, 3 * sizeof(float));\n    }\n\n    /**\n     * @brief Straightner\n     */\n    void Straightner()\n    {\n        if(positions.size() > 3) {\n            float x0 = positions[0];\n            float y0 = positions[1];\n\n            int n = int(positions.size()) - 2;\n            float x1 = positions[n];\n            float y1 = positions[n + 1];\n\n            positions.clear();\n            positions.push_back(x0);\n            positions.push_back(y0);\n            positions.push_back(x1);\n            positions.push_back(y1);\n        }\n    }\n};\n\nPIC_INLINE StrokeGL::StrokeGL(int width, int height, int brushSize = 128,\n                 float *color = NULL)\n{\n    annotation = 1.0f;\n\n\n    this->width = width;\n    this->height = height;\n\n    if(brushSize > 1) {\n        this->brushSize = brushSize;\n    } else {\n        this->brushSize = 2;\n    }\n\n    int halfBrushSize = this->brushSize >> 1;\n\n    float halfBrushSizeXf = float(halfBrushSize) / float(width);\n    float halfBrushSizeYf = float(halfBrushSize) / float(height);\n\n    #ifdef PIC_DEBUG\n        printf(\"%f %f\\n\", halfBrushSizeXf, halfBrushSizeYf);\n    #endif\n\n    this->quad = new QuadGL(true, halfBrushSizeXf, halfBrushSizeYf);\n\n    size = 4.0f;\n    rSize = size / float(MAX(width, height));\n\n    shape = new ImageGL(1, this->brushSize, this->brushSize, 1, IMG_CPU, GL_TEXTURE_2D);\n    evaluateSolid(shape);\n    shape->generateTextureGL(GL_TEXTURE_2D, false);\n\n    if(color != NULL) {\n        for(int i = 0; i < 3; i++) {\n            this->color[i] = color[i];\n        }\n    } else {\n        this->color[0] = this->color[1] = this->color[2] = 1.0f;\n    }\n\n    initShaders();\n}\n\nPIC_INLINE StrokeGL::~StrokeGL()\n{\n    delete shape;\n}\n\nPIC_INLINE void StrokeGL::initShaders()\n{\n    //common vertex program\n    std::string vertex_source = MAKE_STRING\n                                (\n    in vec2 a_position;\n    in vec2 a_tex_coord;\n    uniform vec2 shift_position;\n    out vec2 v_tex_coord;\n\n    void main(void) {\n        v_tex_coord  = a_tex_coord;\n        gl_Position = vec4(a_position + shift_position, 0.0, 1.0);\n    }\n                                );\n\n    //render\n    std::string fragment_source_brush = MAKE_STRING\n                                  (\n    uniform sampler2D   u_tex;\n    uniform vec4        current_color;\n    in vec2             v_tex_coord;\n    out vec4            f_color;\n\n    void main(void) {\n        float shape = texture2D(u_tex, v_tex_coord).x;\n        f_color = vec4(current_color * shape);\n    }\n                                  );\n\n    brushProgram.init(\"330\", vertex_source, fragment_source_brush);\n    brushProgram.printLog(\"Brush - StrokeGL\");\n    \n    brushProgram.bind();\n    brushProgram.setAttributeIndex(\"a_position\", 0);\n    brushProgram.setAttributeIndex(\"a_tex_coord\", 1);\n    brushProgram.setOutputFragmentShaderIndex(\"f_color\", 0);\n    brushProgram.link();\n    brushProgram.unbind();\n\n    brushProgram.bind();\n    brushProgram.setUniform1i(\"u_tex\", 0);\n    brushProgram.setUniform2f(\"shift_position\", 0.0f, 0.0f);\n    brushProgram.setUniform4f(\"current_color\", 1.0f, 1.0f, 1.0f, 1.0f);\n    brushProgram.unbind();\n\n    //annotation\n    std::string fragment_source_annotation = MAKE_STRING\n                                  (\n    uniform sampler2D   u_tex;\n    uniform float       annotation;\n    in vec2             v_tex_coord;\n    out vec4            f_color;\n\n    void main(void) {\n        float shape = texture2D(u_tex, v_tex_coord).x;\n        float shapeVal = shape * annotation;\n        f_color = vec4(shapeVal, shapeVal, shapeVal, shape);\n    }\n                                  );\n\n    annotationProgram.init(\"330\", vertex_source, fragment_source_annotation);\n    annotationProgram.printLog(\"Brush (Annotation) - StrokeGL\");\n\n    annotationProgram.bind();\n    annotationProgram.setAttributeIndex(\"a_position\", 0);\n    annotationProgram.setAttributeIndex(\"a_tex_coord\", 1);\n    annotationProgram.setOutputFragmentShaderIndex(\"f_color\", 0);\n    annotationProgram.link();\n    annotationProgram.unbind();\n\n    annotationProgram.bind();\n    annotationProgram.setUniform1i(\"u_tex\", 0);\n    annotationProgram.setUniform2f(\"shift_position\", 0.0f, 0.0f);\n    annotationProgram.setUniform1f(\"annotation\", annotation);\n    annotationProgram.unbind();\n}\n\nPIC_INLINE void StrokeGL::Resample()\n{\n    if(positions.size() <= 0) {\n        return;\n    }\n\n    bool *sampleGrid = Mask::assign(NULL, height * width, false);\n\n    //calculate length of the path\n    float len = 0.0f;\n    float tmpLen;\n    const int n = int(positions.size()) - 2;\n    float x, y;\n    std::vector<float> lengths;\n\n    for(int i = 0; i < n; i += 2) {\n        x = positions[i + 2] - positions[i];\n        y = positions[i + 3] - positions[i + 1];\n        tmpLen = sqrtf(x * x + y * y);\n        lengths.push_back(tmpLen);\n        len += tmpLen;\n    }\n\n    //resample\n    std::vector<float> resampledPos;\n    resampledPos.push_back(positions[0]);\n    resampledPos.push_back(positions[1]);\n\n    float workLen = 0.0f;\n    int nSamples = int(len / (rSize * 0.25f));\n    float deltaL = len / float(nSamples);\n\n#ifdef PIC_DEBUG\n    printf(\"Len: %f Samples: %d DeltaL: %f\\n\", len, nSamples, deltaL);\n#endif\n\n    for(int i = 1; i < nSamples; i++) {\n        workLen += deltaL;\n        unsigned int j;\n        bool test = false;\n        float tmpWork = 0.0f;\n\n        for(j = 0; j < lengths.size(); j++) {\n            if(workLen >= tmpWork && workLen < (tmpWork + lengths[j])) {\n                test = true;\n                break;\n            }\n\n            tmpWork += lengths[j];\n        }\n\n        if(!test) {\n            break;\n        }\n\n        int ind = j << 1;\n\n        float x0 = positions[ind];\n        float y0 = positions[ind + 1];\n\n        float x1 = positions[ind + 2];\n        float y1 = positions[ind + 3];\n\n        float shift = (deltaL - (tmpWork - workLen)) / lengths[j];\n\n        x =  shift * (x1 - x0) + x0;\n        y =  shift * (y1 - y0) + y0;\n\n        int tmpX = CLAMP(int((x / 2.0f + 0.5f) * width), width);\n        int tmpY = CLAMP(int((y / 2.0f + 0.5f) * height), height);\n        int indSG = tmpY * width + tmpX;\n        bool tmpSampleGrid = sampleGrid[indSG];\n\n//\t\tfloat *val = ((*sampleGrid)(x/2.0f+0.5,y/2.0f+0.5f));\n\n        if(tmpSampleGrid == false) {\n            resampledPos.push_back(x);\n            resampledPos.push_back(y);\n            sampleGrid[indSG] = true;\n        }\n\n        //printf(\"%f %f %d %f\\n\",x,y,j,workLen);\n        workLen += deltaL;\n\n        if(workLen > len) {\n            break;\n        }\n    }\n\n    positions.clear();\n    positions.insert(positions.begin(), resampledPos.begin(), resampledPos.end());\n\n    delete[] sampleGrid;\n}\n\nPIC_INLINE void StrokeGL::Insert2DPoint(int x, int y)\n{\n    /*\n    \tfloat xf = -(x/float(width) -0.5f)*2.0f;\n    \tfloat yf =  (y/float(height)-0.5f)*2.0f;\n    */\n    float xf = (x / float(width) - 0.5f) * 2.0f;\n    float yf = (y / float(height) - 0.5f) * 2.0f;\n\n    positions.push_back(xf);\n    positions.push_back(yf);\n}\n\nPIC_INLINE void StrokeGL::Reset()\n{\n    positions.clear();\n}\n\nPIC_INLINE void StrokeGL::RenderBrushGL(int x, int y)\n{\n    float xf = (x / float(width)  - 0.5f) * 2.0f;\n    float yf = (y / float(height) - 0.5f) * 2.0f;\n\n    glEnable(GL_BLEND);\n    glBlendFunc(GL_ONE, GL_ONE);\n\n    glEnable(GL_TEXTURE_2D);\n\n    glActiveTexture(GL_TEXTURE0);\n    shape->bindTexture();\n      \n        \n    brushProgram.bind();\n    if(annotation < 0.0f) {\n        brushProgram.setUniform4f(\"current_color\", 1.0f - color[0], 1.0f - color[1], 1.0f - color[2], 1.0f);\n    } else {\n        brushProgram.setUniform4f(\"current_color\", color[0], color[1], color[2], 0.5f);\n    }\n    \n    brushProgram.setUniform2f(\"shift_position\", xf, yf);\n\n    quad->Render();\n\n    brushProgram.unbind();\n\n    shape->unBindTexture();\n\n    glDisable(GL_BLEND);\n    glDisable(GL_TEXTURE_2D);\n}\n\nPIC_INLINE void StrokeGL::RenderGL()\n{\n    glEnable(GL_BLEND);\n    glBlendFunc(GL_ONE, GL_ONE);\n    glEnable(GL_TEXTURE_2D);\n\n    glActiveTexture(GL_TEXTURE0);\n    shape->bindTexture();\n\n    glBindTexture(GL_TEXTURE_2D, shape->getTexture());\n\n    brushProgram.bind();\n\n    brushProgram.setUniform4f(\"current_color\", color[0], color[1], color[2], 1.0f);\n    const int n = int(positions.size());\n\n    for(int i = 0; i < n; i += 2) {\n        brushProgram.setUniform2f(\"shift_position\", positions[i], positions[i + 1]);\n        quad->Render();\n    }\n\n    brushProgram.unbind();\n\n    shape->unBindTexture();\n\n    glDisable(GL_BLEND);\n    glDisable(GL_TEXTURE_2D);\n}\n\nPIC_INLINE void StrokeGL::RenderAnnotationGL()\n{\n    glEnable(GL_BLEND);\n    glBlendFunc(GL_ONE, GL_ONE);\n\n    annotationProgram.bind();\n\n#ifdef PIC_DEBUG\n    printf(\"Annotation value: %f\\n\", annotation);\n#endif\n\n    annotationProgram.setUniform1f(\"annotation\",  annotation);\n\n    glEnable(GL_TEXTURE_2D);\n    glActiveTexture(GL_TEXTURE0);\n    shape->bindTexture();\n\n    const int n = int(positions.size());\n\n    for(int i = 0; i < n; i += 2) {\n        annotationProgram.setUniform2f(\"shift_position\", positions[i], positions[i + 1]);\n        quad->Render();\n    }\n\n    glBindTexture(GL_TEXTURE_2D, 0);\n    glDisable(GL_TEXTURE_2D);\n\n    annotationProgram.unbind();\n    glDisable(GL_BLEND);\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_STROKE_HPP */\n"
  },
  {
    "path": "include/util/gl/technique.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_TECHNIQUE_HPP\n#define PIC_UTIL_GL_TECHNIQUE_HPP\n\n#include <string>\n\n#include \"../../util/std_util.hpp\"\n#include \"../../util/gl/program.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The TechniqueGL class\n */\nclass TechniqueGL\n{\nprotected:\n    std::vector<ProgramGL*> shaders;\n    ProgramGL main;\n\n    /**\n     * @brief getLocation\n     * @param name\n     * @return\n     */\n    GLuint getLocation(const char *name)\n    {\n        return glGetUniformLocation(main.getObject(), name);\n    }\n\npublic:\n\n    /**\n     * @brief TechniqueGL\n     */\n    TechniqueGL()\n    {\n\n    }\n\n    ~TechniqueGL()\n    {\n        stdVectorClear<ProgramGL>(shaders);\n    }\n\n    bool isValid()\n    {\n        return main.bCompiled;\n    }\n\n    bool init( std::string version_number,\n               std::string vertex_shader_source,\n               std::string fragment_shader_source)\n    {\n        ProgramGL *vss = new ProgramGL(version_number, \"\", vertex_shader_source, GL_VERTEX_SHADER);\n        ProgramGL *fss = new ProgramGL(version_number, \"\", fragment_shader_source, GL_FRAGMENT_SHADER);\n        shaders.push_back(vss);\n        shaders.push_back(fss);\n\n        return main.initProgram(shaders);\n    }\n\n    bool init( std::string version_number,\n               std::string vertex_shader_source,\n               std::string fragment_shader_source,\n               std::string geomety_shader_source)\n    {\n        ProgramGL *vss = new ProgramGL(version_number, \"\", vertex_shader_source, GL_VERTEX_SHADER);\n        ProgramGL *gss = new ProgramGL(version_number, \"\", geomety_shader_source, GL_GEOMETRY_SHADER);\n        ProgramGL *fss = new ProgramGL(version_number, \"\", fragment_shader_source, GL_FRAGMENT_SHADER);\n\n        shaders.push_back(vss);\n        shaders.push_back(gss);\n        shaders.push_back(fss);\n\n        return main.initProgram(shaders);\n    }\n\n    bool initCompute(std::string version_number,\n                     std::string compute_shader_source)\n    {\n        #ifdef OPEN_GL_4_30\n            ProgramGL *css = new ProgramGL(version_number, \"\", compute_shader_source, GL_COMPUTE_SHADER);\n            shaders.push_back(css);\n        #endif\n\n        return main.initProgram(shaders);\n    }\n\n    /**\n     * @brief initStandard\n     * @param version_number\n     * @param vertex_shader_source\n     * @param fragment_shader_source\n     * @param name\n     * @return\n     */\n    bool initStandard( std::string version_number,\n                    std::string vertex_shader_source,\n                    std::string fragment_shader_source,\n                    std::string name)\n    {\n        bool bCheck = this->init(version_number,\n                                vertex_shader_source,\n                                fragment_shader_source);\n\n    #ifdef PIC_DEBUG\n        this->printLog(name);\n    #endif\n\n        if (bCheck) {\n            this->bind();\n            this->setAttributeIndex(\"a_position\", 0);\n            this->setOutputFragmentShaderIndex(\"f_color\", 0);\n            this->link();\n            this->unbind();\n        }\n\n        return bCheck;\n    }\n\n    /**\n     * @brief initStandard\n     * @param version_number\n     * @param vertex_shader_source\n     * @param fragment_shader_source\n     * @param geometry_shader_source\n     * @param name\n     * @return\n     */\n    bool initStandard( std::string version_number,\n                       std::string vertex_shader_source,\n                       std::string fragment_shader_source,\n                       std::string geometry_shader_source,\n                       std::string name)\n    {\n        bool bCheck = this->init(version_number,\n                   vertex_shader_source,\n                   fragment_shader_source,\n                   geometry_shader_source);\n\n    #ifdef PIC_DEBUG\n        this->printLog(name);\n    #endif\n        if (bCheck) {\n            this->bind();\n            this->setAttributeIndex(\"a_position\", 0);\n            this->setOutputFragmentShaderIndex(\"f_color\", 0);\n            this->link();\n            this->unbind();\n        }\n\n        return bCheck;\n    }\n\n    /**\n     * @brief printLog\n     * @param name\n     */\n    void printLog(std::string name)\n    {\n        printf(\"\\nLog for: %s\\n\", name.c_str());\n        for(uint i = 0; i < shaders.size(); i++) {\n            shaders[i]->printLog();\n        }\n\n        main.printLog();\n    }\n\n    /**\n     * @brief bind\n     */\n    void bind()\n    {\n        glUseProgram(main.getObject());\n    }\n\n    /**\n     * @brief unbind\n     */\n    void unbind()\n    {\n        glUseProgram(0);\n    }\n\n    /**\n     * @brief link\n     */\n    void link()\n    {\n        glLinkProgram(main.getObject());\n    }\n\n    /**\n     * @brief setOutputFragmentShaderIndex\n     * @param fragment_output_color_name\n     * @param index\n     */\n    void setOutputFragmentShaderIndex(const char *fragment_output_color_name, unsigned int index)\n    {\n        glBindFragDataLocation(main.getObject(), GLuint(index), fragment_output_color_name);\n    }\n\n    /**\n     * @brief setAttributeIndex\n     * @param attribute_name\n     * @param index\n     */\n    void setAttributeIndex(const char *attribute_name, unsigned int index)\n    {\n        glBindAttribLocation(main.getObject(), GLuint(index), attribute_name);\n    }\n\n\n    /**\n     * @brief SetUniform\n     * @param name_uniform\n     * @param value0\n     */\n    void setUniform1i(const char *name_uniform, int value0)\n    {\n        glUniform1i(getLocation(name_uniform),\n                    GLint(value0));\n    }\n\n    /**\n     * @brief SetUniform1f\n     * @param name_uniform\n     * @param value0\n     */\n    void setUniform1f(const char *name_uniform, float value0)\n    {\n        glUniform1f(getLocation(name_uniform),\n                    GLfloat(value0));\n    }\n\n    /**\n     * @brief setUniform\n     * @param name_uniform\n     * @param value0\n     * @param value1\n     */\n    void setUniform2f(const char *name_uniform, float value0, float value1)\n    {\n        glUniform2f(getLocation(name_uniform),\n                    GLfloat(value0),\n                    GLfloat(value1));\n    }\n\n    /**\n     * @brief setUniform\n     * @param name_uniform\n     * @param value0\n     * @param value1\n     * @param value2\n     */\n    void setUniform3f(const char *name_uniform, float value0, float value1, float value2)\n    {\n        glUniform3f(getLocation(name_uniform),\n                    GLfloat(value0),\n                    GLfloat(value1),\n                    GLfloat(value2));\n    }\n\n    /**\n     * @brief setUniform4f\n     * @param name_uniform\n     * @param value0\n     * @param value1\n     * @param value2\n     * @param value3\n     */\n    void setUniform4f(const char *name_uniform, float value0, float value1, float value2, float value3)\n    {\n        glUniform4f(getLocation(name_uniform),\n                    GLfloat(value0),\n                    GLfloat(value1),\n                    GLfloat(value2),\n                    GLfloat(value3));\n    }\n\n    /**\n     * @brief setUniform3x3\n     * @param name_uniform\n     * @param matrix\n     * @param bTranspose\n     */\n    void setUniform3x3(const char *name_uniform, const float *matrix, bool bTranspose)\n    {\n        glUniformMatrix3fv(getLocation(name_uniform),\n                           GLsizei(1),\n                           bTranspose ? GL_TRUE : GL_FALSE,\n                           (const GLfloat*)(matrix));\n    }\n\n    /**\n     * @brief setUniform4x4\n     * @param name_uniform\n     * @param matrix\n     * @param bTranspose\n     */\n    void setUniform4x4(const char *name_uniform, const float *matrix, bool bTranspose)\n    {\n        glUniformMatrix4fv(getLocation(name_uniform),\n                           GLsizei(1),\n                           bTranspose ? GL_TRUE : GL_FALSE,\n                           (const GLfloat*)(matrix));\n    }\n\n    /**\n     * @brief setUniform3\n     * @param name_uniform\n     * @param value\n     */\n    void setUniform3fv(const char *name_uniform, const float *value)\n    {\n        glUniform3fv(getLocation(name_uniform),\n                     GLsizei(1),\n                     (const GLfloat *)value);\n    }\n\n    /**\n     * @brief setUniform4\n     * @param name_uniform\n     * @param value\n     */\n    void setUniform4fv(const char *name_uniform, const float *value)\n    {\n        glUniform4fv(getLocation(name_uniform),\n                     GLsizei(1),\n                     (const GLfloat *)value);\n    }\n\n    #ifdef OPEN_GL_4_30\n    void setSSBOIndex(const char *ssbo_name, unsigned int index)\n    {\n        GLunit block_index = 0;\n        block_index = glGetProgramResourceIndex(main, GL_SHADER_STORAGE_BLOCK, ssbo_name);\n        glShaderStorageBlockBinding(program, block_index, index);\n    }\n    #endif\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_TECHNIQUE_HPP */\n\n"
  },
  {
    "path": "include/util/gl/timings.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_TIMINGS_HPP\n#define PIC_UTIL_GL_TIMINGS_HPP\n\n#include \"../../gl.hpp\"\n\nnamespace pic {\n\n/**\n * @brief glBeginTimeQuery\n * @return\n */\ninline GLuint glBeginTimeQuery()\n{\n    GLuint ret = 0;\n#ifdef PIC_GL_TIMING\n    glGenQueries(1, &ret);\n    glFinish();\n    glBeginQuery(GL_TIME_ELAPSED, ret);\n#endif\n\n    return ret;\n}\n\n/**\n * @brief glEndTimeQuery\n * @param ret\n * @return\n */\ninline GLuint64 glEndTimeQuery(GLuint64 ret)\n{\n    GLuint64 timeVal = 0;\n\n#ifdef PIC_GL_TIMING\n    glEndQuery(GL_TIME_ELAPSED);\n    glGetQueryObjectui64v(ret, GL_QUERY_RESULT, &timeVal);\n#endif\n\n    return timeVal;\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_TIMINGS_HPP */\n\n"
  },
  {
    "path": "include/util/gl/tone.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_GL_TONE_HPP\n#define PIC_UTIL_GL_TONE_HPP\n\n#include <string>\n\n#include \"../../base.hpp\"\n\nnamespace pic {\n\n/**\n * @brief GLSL_SIMPLE_EXPOSURE_GAMMA applies a simple gamma correctiona and\n * exposure in a shader.\n * @return It returns a string which represents a part of a shader.\n */\nPIC_INLINE std::string GLSL_SIMPLE_EXPOSURE_GAMMA()\n{\n    std::string ret;\n\n    ret = MAKE_STRING(\n    vec3 SimpleTMO(vec3 col, float exposure, float gamma) {\n        pow(color.xyz * exposure, vec3(gamma))\n    }\n          );\n\n    return ret;\n}\n\n/**\n * @brief GLSL_DRAGO_TMO returns Drago et al.'s tone mapping operator.\n * @return It returns a string; a building block for a shader.\n */\nPIC_INLINE std::string GLSL_DRAGO_TMO()\n{\n    std::string ret;\n\n    ret = MAKE_STRING(\n              const vec3 LUM_XYZ =   vec3(0.213, 0.715,  0.072);\n              //maxL: maximum luminance\n              //c1: log(Drago_b)/log(0.5)\n              //c2: (Drago_Ld_Max/100)/(log10(1+LMax))\n    vec3 DragoTMO(vec3 col, float maxL, float c1, float c2) {\n        float Lw = dot(LUM_XYZ, col);\n        float Ld = c2 * log(1 + L) / log(2.0 + 8.0 * pow((L / maxL), c2));\n        return (col.xyz * Ld) / Lw;\n    }\n          );\n\n    return ret;\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_GL_TONE_HPP */\n\n"
  },
  {
    "path": "include/util/image_sampler.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_IMAGE_SAMPLER_HPP\n#define PIC_UTIL_IMAGE_SAMPLER_HPP\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/*\n\t\t\ta--x----b\n\t\t\t|  |\t|\n\t\t\ty--?----y\n\t\t\t|  |\t|\n\t\t\tc--x----d\n*/\n\n/**\n * @brief Bilinear calculates 2D bilinear interpolation at the point (x,y).\n * @param a is the NW pixel value.\n * @param b is the NE pixel value.\n * @param c is the SW pixel value.\n * @param d is the SE pixel value.\n * @param x is the horizontal coordinate.\n * @param y is the vertical coordinate.\n * @return the evaluation of the B-spline.\n */\ntemplate<class Scalar> inline Scalar Bilinear(Scalar a, Scalar b, Scalar c, Scalar d, float x, float y)\n{\n    Scalar px0 = a + y * (c - a);\n    Scalar px1 = b + y * (d - b);\n    return px0 + x * (px1 - px0);\n}\n\n/**\n * @brief invBilinear\n * @param A\n * @param dx\n * @param dy\n * @param out\n */\ninline void invBilinear(float A, float dx, float dy, float *out)\n{\n    dx = CLAMPi(dx, 0.0f, 1.0f);\n    dy = CLAMPi(dy, 0.0f, 1.0f);\n\n    out[0] = A * dx;\n    out[1] = A * (1.0f - dx);\n\n    float i_dy = 1.0f - dy;\n    out[2] = out[0] * i_dy;\n    out[3] = out[1] * i_dy;\n\n    out[0] = out[0] * dy;\n    out[1] = out[0] * dy;\n}\n\n/**\n * @brief Rx evaluates B-spline (cubic).\n * @param x is the curve parameter in [0, 1].\n * @return the evaluation of the B-spline.\n */\ninline float Rx(float x)\n{\n    float px_1 = MAX(x - 1.0f, 0.0f);\n    float px   = MAX(x,        0.0f);\n    float px1  = MAX(x + 1.0f, 0.0f);\n    float px2  = MAX(x + 2.0f, 0.0f);\n\n    return (         px2  * px2  * px2\n            - 4.0f * px1  * px1  * px1 +\n              6.0f * px   * px   * px\n            - 4.0f * px_1 * px_1 * px_1\n           ) / 6.0f;\n}\n\n/**\n * @brief MitchellNetravali\n * @param x\n * @param B\n * @param C\n * @return\n */\ninline float MitchellNetravali(float x, float B, float C)\n{\n    float y = fabsf(x);\n    if(y < 1.0f) {\n        float y_sq = y * y;\n        float t_3 =  12.0f - 9.0f * B - 6.0f * C;\n        float t_2 = -18.0f + 12.0f * B + 6.0f * C;\n        float c   = 6.0f - 2.0f * B;\n        return (t_3 * y_sq * y + t_2 * y_sq + c) / 6.0f;\n    } else {\n        if(y < 2.0f) {\n            float y_sq = y * y;\n            float t_3 = -B - 6.0f * C;\n            float t_2 = 6.0f * B + 30.0f * C;\n            float t_1 = -12.0f * B - 48.0f * C;\n            float c   = 8.0f * B + 24.0f * C;\n            return (t_3 * y_sq * y + t_2 * y_sq + t_1 * y + c) / 6.0f;\n        } else {\n            return 0.0f;\n        }\n    }\n}\n\n/**\n * @brief Bicubic\n * @param x\n * @return\n */\ninline float Bicubic(float x)\n{\n    float y = fabsf(x);\n    if(y < 1.0f) {\n        float y_sq = y * y;\n        return (3.0f * y_sq * y -6.0f * y_sq + 4.0f) / 6.0f;\n    } else {\n        if(y < 2.0f) {\n            float y_sq = y * y;\n            return (-1.0f * y_sq * y + 6.0f * y_sq - 12.0f * y + 8.0f) / 6.0f;\n        } else {\n            return 0.0f;\n        }\n    }\n}\n\n/**\n * @brief CatmullRom\n * @param x\n * @return\n */\ninline float CatmullRom(float x)\n{\n    float y = fabsf(x);\n    if(y < 1.0f) {\n        float y_sq = y * y;\n        return (9.0f * y_sq * y - 15.0f * y_sq + 6.0f) / 6.0f;\n    } else {\n        if(y < 2.0f) {\n            float y_sq = y * y;\n            return (-3.0f * y_sq * y + 15.0f * y_sq -24.0f * y + 12.0f) / 6.0f;\n        } else {\n            return 0.0f;\n        }\n    }\n}\n\n/**\n * @brief Lanczos\n * @param x\n * @param a\n * @return\n */\ninline float Lanczos(float x, float a)\n{\n    float y = fabsf(x);\n\n    if(y > 0.0f && y < a) {\n        float t = C_PI * x;\n        float d = C_PI_2 * x * x;\n\n        return (a * sinf(t) * sinf(t / a)) / d;\n    } else {\n        if(y > 0.0f) {\n            return 0.0f;\n        } else {\n            return 1.0f;\n        }\n    }\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_IMAGE_SAMPLER_HPP */\n\n"
  },
  {
    "path": "include/util/indexed_array.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_INDEXED_ARRAY_HPP\n#define PIC_UTIL_INDEXED_ARRAY_HPP\n\n#include <vector>\n\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/**\n * @brief IntCoord\n */\ntypedef std::vector<int> IntCoord;\n\n/**\n * @brief The IndexedArray class\n */\ntemplate <class T>\nclass IndexedArray\n{\npublic:\n    IndexedArray()\n    {\n    }\n\n    /**\n     * @brief bFuncNotNeg\n     * @param val\n     * @return\n     */\n    static bool bFuncNotNeg(T val)\n    {\n        return val > T(0);\n    }\n\n    /**\n     * @brief bFuncNotZero\n     * @param val\n     * @return\n     */\n    static bool bFuncNotZero(T val)\n    {\n        return (val < T(0)) || (val > T(0));\n    }\n\n    /**\n     * @brief bFuncNeg\n     * @param val\n     * @return\n     */\n    static bool bFuncNeg(T val)\n    {\n        return (val < T(0));\n    }\n\n    /**\n     * @brief findSimple collects coordinates of data which satisfies a bool function func.\n     * @param data\n     * @param nData\n     * @param ret\n     * @param stride\n     */\n    static void findSimple(T *data, int nData, bool(*func)(float), IntCoord &ret, int stride = 1)\n    {\n        for(int i = 0; i < nData; i += stride) {\n            if(func(data[i])) {\n                ret.push_back(i);\n            }\n        }\n    }\n\n    /**\n     * @brief find collects coordinates of data which satisfies a bool function func.\n     * @param data\n     * @param nData\n     * @param param\n     * @param ret\n     */\n    static void find(float *data, int nData, bool(*func)(float,\n                     std::vector<float>), std::vector<float> param, IntCoord &ret)\n    {\n        for(int i = 0; i < nData; i++) {\n            if(func(data[i], param)) {\n                ret.push_back(i);\n            }\n        }\n    }\n\n    /**\n     * @brief mean computes the mean value.\n     * @param data\n     * @param coord\n     * @return\n     */\n    static T mean(T *data, IntCoord &coord)\n    {\n        if(coord.empty()) {\n            return T(0);\n        }\n\n        T ret = data[coord[0]];\n\n        for(unsigned int i = 1; i < coord.size(); i++) {\n            int j = coord[i];\n            ret += data[j];\n        }\n\n        ret /= T(coord.size());\n\n        return ret;\n    }\n\n    /**\n     * @brief min computes the min value.\n     * @param data\n     * @param coord\n     * @return\n     */\n    static T min(T *data, IntCoord &coord)\n    {\n        if(coord.empty()) {\n            return T(0);\n        }\n\n        float ret = data[coord[0]];\n\n        for(unsigned int i = 1; i < coord.size(); i++) {\n            int j = coord[i];\n            ret = MIN(ret, data[j]);\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief max computes the max value.\n     * @param data\n     * @param coord\n     * @return\n     */\n    static T max(T *data, IntCoord &coord)\n    {\n        if(coord.empty()) {\n            return T(0);\n        }\n\n        T ret = data[coord[0]];\n\n        for(unsigned int i = 1; i < coord.size(); i++) {\n            int j = coord[i];\n            ret = MAX(ret, data[j]);\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief percentile\n     * @param data\n     * @param coord\n     * @param percent\n     * @return\n     */\n    static T percentile(T *data, IntCoord &coord, float percent)\n    {\n        if(coord.empty()) {\n            return T(0);\n        }\n\n        int n = int(coord.size());\n        T *tmp = new T[n];\n\n        for(int i = 0; i < n; i++) {\n            int j = coord[i];\n            tmp[i] = data[j];\n        }\n\n        std::sort(tmp, tmp + n);\n\n        percent = CLAMPi(percent, 0.0f, 1.0f);\n\n        T ret = tmp[int(float(n - 1) * percent)];\n        delete[] tmp;\n\n        return ret;\n    }\n\n    /**\n     * @brief scale scales values.\n     * @param coord\n     * @param scaling\n     */\n    static void scale(IntCoord &coord, int scale)\n    {\n        for(unsigned int i = 0; i < coord.size(); i++) {\n            coord.at(i) = coord.at(i) * scale;\n        }\n    }\n\n    /**\n     * @brief log10Mean computes mean in the log10 domain.\n     * @param data\n     * @param coord\n     * @return\n     */\n    static float log10Mean(float *data, IntCoord &coord)\n    {\n        if(coord.empty()) {\n            return FLT_MAX;\n        }\n\n        float delta = 1e-6f;\n        float ret = 0.0f;\n\n        for(unsigned int i = 0; i < coord.size(); i++) {\n            int j = coord[i];\n            ret += log10f(data[j] + delta);\n        }\n\n        return ret / float(coord.size());\n    }\n\n    /**\n     * @brief log2Mean computes mean in the log2 domain.\n     * @param data\n     * @param coord\n     * @return\n     */\n    static float log2Mean(float *data, IntCoord &coord)\n    {\n        if(coord.empty()) {\n            return FLT_MAX;\n        }\n\n        float delta = 1e-6f;\n        float ret = 0.0f;\n        float log2f = logf(2.0f);\n\n        for(unsigned int i = 0; i < coord.size(); i++) {\n            int j = coord[i];\n            ret += logf(data[j] + delta) / log2f;\n        }\n\n        return ret / float(coord.size());\n    }\n\n    /**\n     * @brief negative computes the negative value given a val reference point.\n     * @param data\n     * @param coord\n     * @param referencePoint\n     */\n    static void negative(T *data, IntCoord &coord, T referencePoint = T(1))\n    {\n        for(unsigned int i = 0; i < coord.size(); i++) {\n            int j = coord[i];\n            data[j] = referencePoint - data[j];\n        }\n    }\n\n    /**\n     * @brief add is the additive operator.\n     * @param data\n     * @param coord\n     * @param val\n     */\n    static void add(T *data, IntCoord &coord, T val)\n    {\n        for(unsigned int i = 0; i < coord.size(); i++) {\n            int j = coord[i];\n            data[j] += val;\n        }\n    }\n\n    /**\n     * @brief sub is the subtractive operator.\n     * @param data\n     * @param coord\n     * @param val\n     */\n    static void sub(T *data, IntCoord &coord, T val)\n    {\n        for(unsigned int i = 0; i < coord.size(); i++) {\n            int j = coord[i];\n            data[j] -= val;\n        }\n    }\n\n    /**\n     * @brief mul is the multiplicative operator.\n     * @param data\n     * @param coord\n     * @param val\n     */\n    static void mul(T *data, IntCoord &coord, T val)\n    {\n        for(unsigned int i = 0; i < coord.size(); i++) {\n            int j = coord[i];\n            data[j] *= val;\n        }\n    }\n\n    /**\n     * @brief div is the division operator.\n     * @param dataDst\n     * @param coord\n     * @param val\n     */\n    static void div(T *dataDst, IntCoord &coord, T val)\n    {\n        for(unsigned int i = 0; i < coord.size(); i++) {\n            int j = coord[i];\n            dataDst[j] /= val;\n        }\n    }\n\n    /**\n     * @brief assign\n     * @param dataDst\n     * @param coord\n     * @param dataSrc\n     */\n    static void assign(T *dataDst, IntCoord &coord, T dataSrc)\n    {\n        for(unsigned int i = 0; i < coord.size(); i++) {\n            int j = coord[i];\n            dataDst[j] = dataSrc;\n        }\n    }\n\n    /**\n     * @brief Assign\n     * @param dataDst\n     * @param coord\n     * @param dataSrc\n     */\n    static void assign(T *dataDst, IntCoord &coord, T *dataSrc)\n    {\n        for(unsigned int i = 0; i < coord.size(); i++) {\n            int j = coord[i];\n            dataDst[j] = dataSrc[j];\n        }\n    }\n};\n\ntypedef IndexedArray<float> IndexedArrayf;\n\ntypedef IndexedArray<int> IndexedArrayi;\n\ntypedef IndexedArray<unsigned int> IndexedArrayui;\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_INDEXED_ARRAY_HPP */\n\n"
  },
  {
    "path": "include/util/io.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_IO_HPP\n#define PIC_UTIL_IO_HPP\n\n#include <string>\n\n#include \"../base.hpp\"\n\nnamespace pic {\n\nenum LABEL_IO_EXTENSION {IO_TMP, IO_PFM, IO_HDR, IO_EXR, IO_VOL, IO_BMP, IO_PPM, IO_TGA, IO_JPG, IO_PNG, IO_PGM, IO_NULL};\n\n/**\n * @brief getLabelHDRExtension returns the file label given its file name (for HDR images).\n * @param nameFile is a file name.\n * @return It returns a file label.\n */\nPIC_INLINE LABEL_IO_EXTENSION getLabelHDRExtension(std::string nameFile)\n{\n    size_t posTMP = nameFile.find(\".tmp\");\n\n    if(posTMP != std::string::npos)\t{\n        return IO_TMP;\n    }\n\n    size_t posPFM = nameFile.find(\".pfm\");\n\n    if(posPFM != std::string::npos)\t{\n        return IO_PFM;\n    }\n\n    size_t posHDR = nameFile.find(\".hdr\");\n\n    if(posHDR != std::string::npos)\t{\n        return IO_HDR;\n    }\n\n    size_t posPIC = nameFile.find(\".pic\");\n\n    if(posPIC != std::string::npos)\t{\n        return IO_HDR;\n    }\n\n    size_t posEXR = nameFile.find(\".exr\");\n\n    if(posEXR != std::string::npos)\t{\n        return IO_EXR;\n    }\n\n    size_t posVOL = nameFile.find(\".vol\");\n\n    if(posVOL != std::string::npos)\t{\n        return IO_VOL;\n    }\n\n    return IO_NULL;\n}\n\n/**\n * @brief getLabelHDRExtension returns the file label given its file name (for LDR images).\n * @param nameFile is a file name.\n * @return It returns a file label.\n */\nPIC_INLINE LABEL_IO_EXTENSION getLabelLDRExtension(std::string nameFile)\n{\n    size_t posBMP = nameFile.find(\".bmp\");\n\n    if(posBMP != std::string::npos)\t{\n        return IO_BMP;\n    }\n\n    size_t posPPM = nameFile.find(\".ppm\");\n\n    if(posPPM != std::string::npos)\t{\n        return IO_PPM;\n    }\n\n    size_t posPGM = nameFile.find(\".pgm\");\n\n    if(posPGM != std::string::npos)\t{\n        return IO_PGM;\n    }\n\n    size_t posTGA = nameFile.find(\".tga\");\n\n    if(posTGA != std::string::npos)\t{\n        return IO_TGA;\n    }\n\n    size_t posJPG = nameFile.find(\".jpg\");\n\n    if(posJPG != std::string::npos)\t{\n        return IO_JPG;\n    }\n\n    posJPG = nameFile.find(\".JPG\");\n\n    if(posJPG != std::string::npos)\t{\n        return IO_JPG;\n    }\n\n    posJPG = nameFile.find(\".jpeg\");\n\n    if(posJPG != std::string::npos)\t{\n        return IO_JPG;\n    }\n\n    size_t posPNG = nameFile.find(\".png\");\n\n    if(posPNG != std::string::npos)\t{\n        return IO_PNG;\n    }\n\n    return IO_NULL;\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_IO_HPP */\n\n"
  },
  {
    "path": "include/util/json.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2024\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_IO_JSON\n#define PIC_IO_JSON\n\n#include <stdio.h>\n#include <string>\n#include <set>\n#include <regex>\n#include <vector>\n#include <stack>\n#include \"../base.hpp\"\n#include \"../util/string.hpp\"\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n\nenum JSONVALUETYPE{JNUMBER, JOBJECT, JARRAY, JSTRING, JFALSE, JTRUE, JNULL};\n\nclass JSONObject;\n\nclass JSONArray;\n\nclass JSONValue\n{\npublic:\n    JSONVALUETYPE type;\n    bool lookingForValue;\n\n    JSONValue()\n    {\n        lookingForValue = false;\n        type = JNULL;\n    }\n\n    void setTrue()\n    {\n        type = JTRUE;\n    }\n\n    void setFalse()\n    {\n        type = JFALSE;\n    }\n\n    void setNull()\n    {\n        type = JNULL;\n    }\n\n    virtual JSONValue* check(std::string key)\n    {\n        return NULL;\n    }\n\n    virtual void addName(std::string name) \n    {\n\n    }\n\n    virtual void addValue(JSONValue* value) \n    {\n\n    }\n\n    void printType() \n    {\n        switch (type)\n        {\n        case JARRAY:\n            printf(\"Array\");\n            break;\n        case JOBJECT:\n            printf(\"Object\");\n            break;\n        case JSTRING:\n            printf(\"String\");\n            break;\n        }\n        printf(\"\\n\");\n    }\n\n    virtual void print()\n    {\n        if (type == JTRUE) {\n            printf(\"true\");\n        }\n\n        if (type == JFALSE) {\n            printf(\"false\");\n        }\n\n        if (type == JNULL) {\n            printf(\"null\");\n        }\n    }\n\n    JSONObject* getObject(std::string key)\n    {\n        JSONValue* tmp = check(key);\n\n        if (tmp != NULL) {\n            if (tmp->type == JOBJECT) {\n                return (JSONObject*)tmp;\n            }\n        }\n        return NULL;\n    }\n\n    JSONArray* getArray(std::string key)\n    {\n        JSONValue* tmp = check(key);\n\n        if (tmp != NULL) {\n            if (tmp->type == JARRAY) {\n                return (JSONArray*)tmp;\n            }\n        }\n        return NULL;\n    }\n};\n\nclass JSONString: public JSONValue\n{\npublic:\n    std::string str;\n\n    JSONString()\n    {\n        this->str = \"\";\n        this->type = JSTRING;\n    }\n\n    JSONString(std::string str)\n    {\n        this->str = str;\n        this->type = JSTRING;\n    }\n\n    void print()\n    {\n        printf(\"\\\"%s\\\"\", str.c_str());\n    }\n\n};\n\n\nclass JSONNumber : public JSONValue\n{\npublic:\n    double numf;\n    int numi;\n    bool bFloat;\n\n    JSONNumber()\n    {\n        bFloat = false;\n        numf = 0.0;\n        numi = 0;\n        type = JNUMBER;\n    }\n\n    float getFloat()\n    {\n        if (bFloat) {\n            return float(numf);\n        } else {\n            return float(numi);\n        }\n    }\n\n    double getDouble()\n    {\n        if (bFloat) {\n            return numf;\n        }\n        else {\n            return double(numi);\n        }\n    }\n\n    int getInteger()\n    {\n        if (bFloat) {\n            return int(numf);\n        }\n        else {\n            return numi;\n        }\n    }\n\n    void print()\n    {\n        if (bFloat) {\n            printf(\"%f\", numf);\n        }\n        else {\n            printf(\"%d\", numi);\n        }\n    }\n};\n\nclass JSONArray : public JSONValue\n{\npublic:\n    std::vector<JSONValue*> array;\n\n    JSONArray()\n    {\n        type = JARRAY;\n    }\n\n    int size()\n    {\n        return int(array.size());\n    }\n\n    JSONValue *get(int index)\n    {\n        return array.at(index);\n    }\n\n    void addValue(JSONValue* data) {\n        array.push_back(data);\n    }\n\n    void print()\n    {\n        printf(\"[\");\n        for (unsigned int i = 0; i < array.size(); i++) {\n            array[i]->print();\n            if (i < (array.size() - 1)) {\n                printf(\", \");\n            }\n        }\n\n        printf(\"]\");\n    }\n};\n\nclass JSONObject : public JSONValue\n{\npublic:\n    std::vector<std::string> names;\n    std::vector<JSONValue*> values;\n\n    JSONObject()\n    {\n        type = JOBJECT;\n    }\n\n    bool empty()\n    {\n        return names.empty();\n    }\n\n    void addName(std::string name) {\n        names.push_back(name);\n    }\n\n    void addValue(JSONValue* data) {\n        values.push_back(data);\n    }\n\n    void print()\n    {\n        printf(\"{\\n\");\n        int n = int(MIN(names.size(), values.size()));\n\n        for (int i = 0; i < n; i++) {\n            printf(\"   %s:\", names[i].c_str());\n            values[i]->print();\n            if (i < (n - 1)) {\n                printf(\",\\n\");\n            }\n        }\n        printf(\"\\n}\\n\");\n    }\n\n    JSONValue* check(std::string key)\n    {\n        JSONValue* out = NULL;\n        for (unsigned int i = 0; i < names.size(); i++) {\n            if (names[i].compare(key) == 0) {\n                out = values[i];\n                break;\n            }\n        }\n\n        return out;\n    }\n\n    std::string getString(std::string key)\n    {\n        std::string out = \"\";\n\n        JSONValue* tmp = check(key);\n        if (tmp != NULL) {\n            if (tmp->type == JSTRING) {\n                auto tmp2 = (JSONString*)tmp;\n                out = tmp2->str;\n            }\n        }\n        return out;\n    }\n\n    float getFloat(std::string key)\n    {\n        float out = 0.0f;\n\n        pic::JSONValue* tmp = check(key);\n\n        if (tmp != NULL) {\n            if (tmp->type == JNUMBER) {\n                auto tmp2 = (JSONNumber*)tmp;\n                return tmp2->getFloat();\n            }\n        }\n\n        return out;\n    }\n\n    int getInteger(std::string key)\n    {\n        int out = 0;\n\n        pic::JSONValue* tmp = check(key);\n\n        if (tmp != NULL) {\n            if (tmp->type == JNUMBER) {\n                auto tmp2 = (JSONNumber*)tmp;\n                return tmp2->getInteger();\n            }\n        }\n\n        return out;\n    }\n\n    double getDouble(std::string key)\n    {\n        double out = 0.0;\n\n        pic::JSONValue* tmp = check(key);\n\n        if (tmp != NULL) {\n            if (tmp->type == JNUMBER) {\n                auto tmp2 = (JSONNumber*)tmp;\n                return tmp2->getDouble();\n            }\n        }\n\n        return out;\n    }\n\n    bool getBool(std::string key)\n    {\n        bool out = false;\n\n        JSONValue* tmp = check(key);\n        if (tmp != NULL) {\n            if (tmp->type == JTRUE) {\n                out = true;\n            }\n\n            if (tmp->type == JFALSE) {\n                out = false;\n            }\n        }\n\n        return out;\n    }\n\n    void getFloatArray(std::string key, std::vector<float> &out)\n    {\n        out.clear();\n\n        pic::JSONValue* tmp = check(key);\n\n        if (tmp != NULL) {\n            if (tmp->type == pic::JARRAY) {\n                pic::JSONArray* arr = (pic::JSONArray*)tmp;\n                for (int i = 0; i < arr->size(); i++) {\n                    out.push_back(((pic::JSONNumber*)((pic::JSONNumber*)arr->get(i)))->getFloat());\n                }\n            }\n        }\n    }\n\n};\n\nclass JSONFile\n{\nprotected:\n\npublic:\n\n     JSONFile()\n     {\n     }\n\n     /**\n      * @brief parseNumber\n      * @param str\n      * @return\n      */\n     bool parseNumber(std::string str, JSONNumber *ret)\n     {\n         std::regex j_integer(\"(\\\\+|-)?[[:digit:]]+\");\n         std::regex j_float(\"((\\\\+|-)?[[:digit:]]+)(\\\\.(([[:digit:]]+)?))?\");\n         std::regex j_float_scientific(\"((\\\\+|-)?[[:digit:]]+)(\\\\.(([[:digit:]]+)?))?((e|E)((\\\\+|-)?)[[:digit:]]+)?\");\n\n         if(regex_match(str, j_integer)) {\n             ret->bFloat = false;\n             ret->numi = atoi(str.c_str());\n             return true;\n         } else {\n             if(std::regex_match(str, j_float)) {\n                 ret->bFloat = true;\n                 ret->numf = atof(str.c_str());\n\n                 return true;\n             } else {\n                 if(std::regex_match(str, j_float_scientific)) {\n                     ret->bFloat = true;\n                     ret->numf = atof(str.c_str());\n                     return true;\n\n                 }\n\n                 return false;\n             }\n         }\n     }\n      \n\n     bool parseString(std::string str, JSONString &ret)\n     {\n         std::regex j_string(\"\\\"([[:print:]]*[[:space:]]*[[:punct:]]*[[:upper:]]*)*\\\"\");\n         //         [\\\\]*[\\n]*[\\/]*[\\\"]*[\\b]*[\\f]*[\\n]*[\\r]*[\\t]*\n         if (regex_match(str, j_string)) {\n             ret.str = str;\n             ret.str.erase(0, 1);\n             ret.str.erase(ret.str.size() -1);\n             return true;\n         }\n         return false;\n     }\n\n     bool parseWhitespace(std::string str)\n     {\n         std::regex j_string(\"([[:space:]]*[[:blank:]]*\\t*\\r*\\n*)*\");\n         if (regex_match(str, j_string)) {\n             return true;\n         }\n         return false;\n     }\n\n     bool checkWhitespace(char current) {\n         std::regex j_string(\"([[:space:]]*[[:blank:]]*\\t*\\r*\\n*)*\");\n\n         std::string str(1, current);\n         return regex_match(str, j_string);\n     }\n\n     /**\n      * @brief testParserNumbers\n      */\n     void testParserNumbers()\n     {\n         printf(\"Test numbers:\\n\");\n         JSONNumber ret;\n         parseNumber(\"121324\", &ret);\n         printf(\"\\n\");\n         ret.print();\n\n         printf(\"\\n\");\n\n         parseNumber(\"121.324\", &ret);\n         ret.print();\n         printf(\"\\n\");\n\n         parseNumber(\"1.4e6\", &ret);\n         ret.print();\n         printf(\"\\n\");\n\n     }\n\n     void testParserString()\n     {\n         printf(\"Test strings:\\n\");\n         JSONString ret;\n         parseString(\"\\\"number1\\\"\", ret);\n         printf(\"%s\\n\", ret.str.c_str());\n\n         parseString(\"\\\"num ber1\\\"\", ret);\n         printf(\"%s\\n\", ret.str.c_str());\n\n         parseString(\"\\\"./number1\\\"\", ret);\n         printf(\"%s\\n\", ret.str.c_str());\n     }\n\n     std::string parseString(std::string lines, int &c, int &code) {\n         std::string tmp_str;\n         bool bFlag = true;\n         int n = int(lines.size()) - 1;\n         while ((c < n) && bFlag) {\n             c++;\n             if ((lines.at(c) == '}') || (lines.at(c) == ']')) {\n                 code = -1;\n                 return \"\";\n             }\n\n             if (lines.at(c) == '\\\"') {\n                 while ((c < n) && bFlag) {\n                     c++;    \n                     if (lines.at(c) == '\\\\') {\n                         c++;\n                         switch (lines.at(c)) {\n                         case '\\\"':\n                             tmp_str += '\\\"';\n                         case '\\\\':\n                             tmp_str += '\\\\';\n                         case '/':\n                             tmp_str += '/';\n                         case 'b':\n                             tmp_str += '\\b';\n                         case 'n':\n                             tmp_str += '\\n';\n                         case 'f':\n                             tmp_str += '\\f';\n                         case 'r':\n                             tmp_str += '\\r';\n                         case 't':\n                             tmp_str += '\\t';\n                         default:\n                             tmp_str += '\\\\';\n                             tmp_str += lines.at(c);\n                         }\n                     } else {\n                         if (lines.at(c) == '\\\"') {\n                             bFlag = false;\n                         } else {\n                             tmp_str += lines.at(c);\n                         }\n                     }\n                 }\n             }\n         }\n         code = 0;\n         return tmp_str;\n     }\n\n     void find(std::string lines, char toBeFound, int &c) {\n         int n = int(lines.size()) - 1;\n\n         while (c < n) {\n             if (lines.at(c) != toBeFound) {\n                 break;\n             }\n             c++;\n         }\n     }\n\n     JSONValue* parse(std::string filename)\n     {\n         std::ifstream in(filename, std::ios_base::in);\n\n         std::string line;\n         std::string lines;\n         while (getline(in, line)) {\n             lines += \"\\n\" + line;\n         }\n         bool bParse = true;\n\n\n         int c = 0;\n         JSONValue* last_caller = NULL;\n         std::stack<JSONValue*> stack;\n         JSONValue* root = NULL;\n\n         int n = int(lines.size()) - 1;\n         while (c < n) {\n\n             if (lines.at(c) == '{') {\n                 JSONObject* tmp = new JSONObject();\n                 tmp->lookingForValue = false;\n\n                 if (last_caller == NULL) {\n                     root = (JSONValue*)tmp;\n                     last_caller = tmp;\n                 } else {\n                     stack.push(last_caller);\n\n                     if (last_caller->lookingForValue) {\n                         last_caller->addValue((JSONValue*)tmp);\n                     }\n\n                     last_caller = tmp;\n                 }\n             }\n\n             if (lines.at(c) == '[') {\n                 JSONArray* tmp = new JSONArray();\n                 tmp->lookingForValue = true;\n\n                 if (last_caller == NULL) {\n                     root = (JSONValue*)tmp;\n                 } else {\n                     last_caller->addValue((JSONValue*)tmp);\n                     stack.push(last_caller);\n                 }\n                 last_caller = tmp;\n             }\n\n             if (last_caller != NULL) {\n                 //parse strings value\n                 if (lines.at(c) == '\\\"') {\n                     c--;\n                     int code = 0;\n                     std::string name = parseString(lines, c, code);\n                     if (last_caller->lookingForValue) {\n                         last_caller->addValue(new JSONString(name));\n                     }\n\n                     if (last_caller->type == JOBJECT) {\n                         last_caller->lookingForValue = false;\n                     }\n                 }\n                 \n\n                 //parse true\n                 if (lines.at(c) == 't') {\n                     std::string tmp_str = lines.substr(c, 4);\n\n                     if (tmp_str.compare(\"true\") == 0) {\n                         JSONValue* value = new JSONValue();\n                         value->setTrue();\n                         last_caller->addValue(value);\n\n                         if (last_caller->type == JOBJECT) {\n                             last_caller->lookingForValue = false;\n                         }\n                     }\n                     else {\n                         return NULL;\n                     }\n                 }\n\n                 //parse false\n                 if (lines.at(c) == 'f') {\n                     std::string tmp_str = lines.substr(c, 5);\n\n                     if (tmp_str.compare(\"false\") == 0) {\n                         JSONValue* value = new JSONValue();\n                         value->setFalse();\n                         last_caller->addValue(value);\n\n                         if (last_caller->type == JOBJECT) {\n                             last_caller->lookingForValue = false;\n                         }\n                     }\n                     else {\n                         return NULL;\n                     }\n                 }\n\n                 //parse null\n                 if (lines.at(c) == 'n') {\n                     std::string tmp_str = lines.substr(c, 4);\n\n                     if (tmp_str.compare(\"null\") == 0) {\n                         JSONValue* value = new JSONValue();\n                         value->setNull();\n                         last_caller->addValue(value);\n\n                         if (last_caller->type == JOBJECT) {\n                             last_caller->lookingForValue = false;\n                         }\n                     }\n                     else {\n                         return NULL;\n                     }\n                 }\n\n                 //parse numbers values\n                 std::string number(1, lines.at(c));\n                 std::regex j_integer(\"(\\\\+|-)?[[:digit:]]*\");\n                 if (regex_match(number, j_integer) && last_caller->lookingForValue) {\n                     int c2 = c;\n                     while (c2 < n) {\n                         c2++;\n                         auto current = lines.at(c2);\n                         if (checkWhitespace(current) || (current == ',') || (current == '}') || (current == ']')) {\n                             break;\n                             //c2--;\n                         }\n                     }\n\n                     JSONNumber *out = new JSONNumber();\n                     std::string number_only_str = lines.substr(c, c2 - c);\n                     parseNumber(number_only_str, out);\n                     last_caller->addValue(out);\n\n                     if (last_caller->type == JOBJECT) {\n                         last_caller->lookingForValue = false;\n                     }\n                     c--;\n                     c += int(number_only_str.size());\n                 }\n\n                 if ((last_caller->type == JOBJECT) && (!last_caller->lookingForValue)) {\n                     int code = 0;\n                     std::string name = parseString(lines, c, code);\n                     if (code == 0) {\n                         last_caller->addName(name);\n                         find(lines, ':', c);\n                         last_caller->lookingForValue = true;\n                     }\n                 }\n             }\n\n             if ((lines.at(c) == '}') || (lines.at(c) == ']')) {\n\n\n                 if (!stack.empty()) {\n\n                     last_caller->lookingForValue = false;\n                     last_caller = stack.top();\n                     stack.pop();\n\n                     if (last_caller->type == JOBJECT) {\n                         last_caller->lookingForValue = false;\n                     }\n\n                     if (last_caller->type == JARRAY) {\n                         last_caller->lookingForValue = true;\n                     }\n                 }\n                 else {\n                     last_caller = NULL;\n                 }\n             }\n\n             c++;\n         }\n\n         return root;\n     }\n};\n\n} // end namespace pic\n\n#endif /* PIC_IO_JSON */\n\n"
  },
  {
    "path": "include/util/k_means.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_K_MEANS_HPP\n#define PIC_UTIL_K_MEANS_HPP\n\n#include <vector>\n#include <set>\n#include <chrono>\n\n#include \"../base.hpp\"\n#include \"../util/array.hpp\"\n#include \"../util/math.hpp\"\n#include \"../util/std_util.hpp\"\n\nnamespace pic{\n\ntemplate<class T>\nclass KMeans\n{\nprotected:\n\n    T* getMean(T *samples, T *out, int nDim, std::set<uint> *cluster)\n    {\n        Array<T>::assign(T(0), out, nDim);\n\n        int count = 0;\n         for (auto it = cluster->begin(); it != cluster->end(); it++) {\n             int i = *it;\n             Array<T>::add(&samples[i * nDim], nDim, out);\n             count++;\n         }\n\n         if(count > 0) {\n             Array<T>::div(out, nDim, T(count));\n         }\n\n         return out;\n    }\n\n    uint assignLabel(T* sample_j, int nDim, T* centers)\n    {\n        T dist = Array<T>::distanceSq(sample_j, &centers[0], nDim);\n        uint label = 0;\n\n        for(uint i = 1; i < k; i++) {\n            T *center_i = &centers[i * nDim];\n\n            T tmp_dist = Array<T>::distanceSq(sample_j, center_i, nDim);\n\n            if(tmp_dist < dist) {\n                dist = tmp_dist;\n                label = i;\n            }\n        }\n\n        return label;\n    }\n\n    virtual T* initCenters(T *samples, int nSamples, int nDim, T* centers)\n    {\n        if(centers == NULL) {\n            centers = new T[k * nDim];\n        }\n\n        std::mt19937 m(42);\n\n        T *tMin = new T[nDim];\n        T *tMax = new T[nDim];\n\n        for(int j = 0; j < nDim; j++) {\n            T s = samples[j];\n            tMin[j] = s;\n            tMax[j] = s;\n        }\n\n        for(int i = 1; i < nSamples; i++) {\n            int index = i * nDim;\n            for(int j = 0; j < nDim; j++) {\n                T s = samples[index + j];\n\n                tMin[j] = MIN(tMin[j], s);\n                tMax[j] = MAX(tMax[j], s);\n            }\n        }\n\n        for(uint i = 0; i < k; i++) {\n            int index = i * nDim;\n            for(int j = 0; j < nDim; j++) {\n                centers[index + j] = T(getRandom(m()) * (tMax[j] - tMin[j]) + tMin[j]);\n            }\n        }\n\n        delete[] tMin;\n        delete[] tMax;\n\n        return centers;\n    }\n\n    uint k, maxIter;\n\npublic:\n\n    KMeans(uint k, uint maxIter)\n    {\n        setup(k, maxIter);\n    }\n\n    void setup(uint k, uint maxIter = 100)\n    {\n        this->k = k;\n        this->maxIter = maxIter;\n    }\n    T* Process(T *samples, int nSamples, int nDim,\n               T* centers,\n               std::vector< std::set<uint> *> &labels)\n    {\n        if(nSamples < k) {\n            return NULL;\n        }\n\n        labels.clear();\n        for(uint i = 0; i < k; i++) {\n            labels.push_back(new std::set<uint>);\n        }\n\n        centers = initCenters(samples, nSamples, nDim, centers);\n\n        for(uint i = 0; i < nSamples; i++) {\n            T *sample_i = &samples[i * nDim];\n\n            uint label = assignLabel(sample_i, nDim, centers);\n            labels[label]->insert(i);\n        }\n\n        T *mean = new T[k * nDim];\n\n        for(uint i = 0; i < maxIter; i++) {\n            bool bNoChanges = true;\n\n            for(uint j = 0; j < k; j++) {\n                //compute new means\n                int index = j * nDim;\n                std::set<uint> *tmp = labels.at(j);\n                getMean(samples, &mean[index], nDim, tmp);\n\n                //update centers\n                float dist = Arrayf::distanceSq(&centers[index], &mean[index], nDim);\n\n                Arrayf::assign(&mean[index], nDim, &centers[index]);\n\n                if(dist > 1e-6f) {\n                    bNoChanges = false;\n                }\n            }\n\n            if(bNoChanges) {\n                #ifdef PIC_DEBUG\n                    printf(\"Max iterations: %d\\n\", i);\n                #endif\n\n                delete[] mean;\n                return centers;\n            } else {\n                //clear labels\n                for(uint j = 0; j < k; j++) {\n                    labels[j]->clear();\n                }\n\n                //re-assign labels\n                for(uint j = 0; j < nSamples; j++) {\n                    T *sample_j = &samples[j * nDim];\n                    uint label = assignLabel(sample_j, nDim, centers);\n                    labels[label]->insert(j);\n                }\n            }\n        }\n\n        delete[] mean;\n\n        return centers;\n    }\n\n    static T* execute(T *samples, int nSamples, int nDim,\n                      T* centers, int k,\n                      std::vector< std::set<uint> *> &labels,\n                      uint maxIter = 100)\n    {\n\n        KMeans<T> km(k, maxIter);\n\n        return km.Process(samples, nSamples, nDim, centers, labels);\n    }\n\n    static T* select(T *samples, int nSamples, int nDim,\n              std::vector< std::set<uint> *> &labels,\n              uint &k,\n              float threshold = 1e-2f,\n              uint maxIter = 100)\n    {\n        T *centers = NULL;\n        k = 1;\n        T prevErr;\n        bool bFlag = true;\n        while(bFlag) {\n            k++;\n\n            #ifdef PIC_DEBUG\n                printf(\"k: %d\\n\", k);\n            #endif\n\n            labels.clear();\n            centers = delete_vec_s(centers);\n\n            centers = KMeans::execute(samples, nSamples, nDim, NULL, k, labels, maxIter);\n\n            T err = T(0);\n            for(uint i = 0; i < labels.size(); i++) {\n                T *center_i = &centers[i * nDim];\n\n                std::set<uint> * cluster = labels.at(i);\n                for (std::set<uint>::iterator it = cluster->begin(); it != cluster->end(); it++) {\n                    int i = *it;\n                    err += Array<T>::distanceSq(&samples[i * nDim], center_i, nDim);\n                }\n\n            }\n\n            if(k > 2) {\n                float relErr = fabsf(float(err - prevErr)) / float(prevErr);\n\n                 #ifdef PIC_DEBUG\n                    printf(\"%f %f %f\\n\", err, prevErr, relErr);\n                #endif\n\n                if(relErr < threshold) {\n                    bFlag = false;\n                }\n            }\n\n            prevErr = err;\n        }\n\n        return centers;\n    }\n\n};\n\n} //end namespace pic\n\n#endif // PIC_UTIL_K_MEANS_HPP\n"
  },
  {
    "path": "include/util/k_means_rand.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_K_MEANS_RAND_HPP\n#define PIC_UTIL_K_MEANS_RAND_HPP\n\n#include <vector>\n#include <set>\n#include <chrono>\n\n#include \"../base.hpp\"\n#include \"../util/array.hpp\"\n#include \"../util/math.hpp\"\n#include \"../util/std_util.hpp\"\n#include \"../util/k_means.hpp\"\n\nnamespace pic{\n\ntemplate<class T>\nclass KMeansRand: public KMeans<T>\n{\nprotected:\n\n    T* initCenters(T *samples, int nSamples, int nDim, T* centers)\n    {\n        std::mt19937 m(42);\n        if(centers == NULL) {\n            centers = new T[this->k * nDim];\n        }\n\n        std::set< uint > chosen;\n        for(uint i = 0; i < this->k; i++) {\n\n           bool bCheck = true;\n           while(bCheck) {\n               uint index = m() % nSamples;\n               if(chosen.find(index) == chosen.end()) {\n\n                   chosen.insert(index);\n                   Array<T>::assign(&samples[index * nDim], nDim, &centers[i * nDim]);\n                   bCheck = false;\n               }\n           }\n        }\n        return centers;\n    }\n\npublic:\n\n    KMeansRand(uint k, uint maxIter) : KMeans<T>(k, maxIter)\n    {\n    }\n\n    static T* execute(T *samples, int nSamples, int nDim,\n                      T* centers, int k,\n                      std::vector< std::set<uint> *> &labels,\n                      uint maxIter = 100)\n    {\n\n        KMeansRand<T> km(k, maxIter);\n\n        return km.Process(samples, nSamples, nDim, centers, labels);\n    }\n};\n\n} //end namespace pic\n\n#endif // PIC_UTIL_K_MEANS_RAND_HPP\n"
  },
  {
    "path": "include/util/mask.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_MASK_HPP\n#define PIC_UTIL_MASK_HPP\n\n#include \"../base.hpp\"\n#include \"../util/math.hpp\"\n#include \"../util/buffer.hpp\"\n\nnamespace pic {\n\nclass Mask: public Buffer<bool>\n{\npublic:\n    /**\n     * @brief removeIsolatedPixels removes isolated pixels.\n     * @param dataOut\n     * @param dataIn\n     * @param width\n     * @param height\n     * @return\n     */\n    static bool *removeIsolatedPixels(bool *dataOut, bool *dataIn,\n            int width, int height)\n    {\n        if(dataIn == NULL) {\n            return dataOut;\n        }\n\n        if(dataOut == NULL) {\n            dataOut = new bool[width * height];\n        }\n\n        #pragma omp parallel for\n\n        for(int i = 0; i < height; i++) {\n            int ind = i * width;\n\n            for(int j = 0; j < width; j++) {\n                int c = ind + j;\n\n                int counter = 0;\n\n                for(int k = -1; k <= 1; k++) {\n                    int ci = CLAMP((i + k), height) * width;\n\n                    for(int l = -1; l <= 1; l++) {\n                        if((l != 0) && (k != 0)) {\n                            int cj = CLAMP((j + l), width);\n\n                            if(dataIn[ci + cj]) {\n                                counter++;\n                            }\n                        }\n                    }\n                }\n\n                dataOut[c] = counter > 0;\n            }\n        }\n\n        return dataOut;\n    }\n\n    /**\n     * @brief erode erodes a mask.\n     * @param dataOut\n     * @param dataIn\n     * @param width\n     * @param height\n     * @param kernelSize\n     * @return\n     */\n    static bool *erode(bool *dataOut, bool *dataIn, int width, int height,\n                       int kernelSize = 3)\n    {\n        if(dataIn == NULL) {\n            return dataOut;\n        }\n\n        if(dataOut == NULL) {\n            dataOut = new bool[width * height];\n        }\n\n        int halfKernelSize = kernelSize >> 1;\n\n        #pragma omp parallel for\n\n        for(int i = 0; i < height; i++) {\n            int ind = i * width;\n\n            for(int j = 0; j < width; j++) {\n                int c = ind + j;\n\n                bool out = false;\n\n                for(int k = -halfKernelSize; k <= halfKernelSize; k++) {\n                    int ci = CLAMP((i + k), height) * width;\n\n                    for(int l = -halfKernelSize; l <= halfKernelSize; l++) {\n                        int cj = CLAMP((j + l), width);\n                        out = out || (!dataIn[ci + cj]);\n                    }\n                }\n\n                dataOut[c] = !out;\n            }\n        }\n\n        return dataOut;\n    }\n\n    /**\n     * @brief MaskDilate dilates a mask.\n     * @param dataOut\n     * @param dataIn\n     * @param width\n     * @param height\n     * @param kernelSize\n     * @return\n     */\n    static bool *dilate(bool *dataOut, bool *dataIn, int width, int height,\n                        int kernelSize = 3)\n    {\n        if(dataIn == NULL) {\n            return dataOut;\n        }\n\n        if(dataOut == NULL) {\n            dataOut = new bool[width * height];\n        }\n\n        int halfKernelSize = kernelSize >> 1;\n\n        #pragma omp parallel for\n\n        for(int i = 0; i < height; i++) {\n            int ind = i * width;\n\n            for(int j = 0; j < width; j++) {\n                int c = ind + j;\n\n                bool out = false;\n\n                for(int k = -halfKernelSize; k <= halfKernelSize; k++) {\n                    int ci = CLAMP((i + k), height) * width;\n\n                    for(int l = -halfKernelSize; l <= halfKernelSize; l++) {\n                        int cj = CLAMP((j + l), width);\n                        out = out || (dataIn[ci + cj]);\n                    }\n                }\n\n                dataOut[c] = out;\n            }\n        }\n\n        return dataOut;\n    }\n\n    /**\n     * @brief MaskEmpty checks if a mask is empty.\n     * @param dataIn\n     * @param width\n     * @param height\n     * @return\n     */\n    static bool empty(bool *dataIn, int width, int height)\n    {\n        if(dataIn == NULL) {\n            return true;\n        }\n\n        for(int i = 0; i < height; i++) {\n            int ind = i * width;\n\n            for(int j = 0; j < width; j++) {\n                if(dataIn[ind + j]) {\n                    return false;\n                }\n            }\n        }\n\n        return true;\n    }\n\n    /**\n     * @brief thinning thins a mask.\n     * @param dataOut\n     * @param dataIn\n     * @param width\n     * @param height\n     */\n    static bool* thinning(bool *dataOut, bool *dataIn, int width, int height)\n    {\n        if(dataIn == NULL) {\n            return dataIn;\n        }\n\n        dataOut = clone(dataOut, dataIn, width * height, 1);\n\n        bool P[9];\n\n        //first-pass\n        std::vector< int > list;\n        for(int i = 1; i < (height - 1); i++) {\n            int tmp = i * width;\n            for(int j = 1; j < (width - 1); j++) {\n                int index = tmp + j;\n\n                if(!dataOut[index]) {\n                    continue;\n                }\n\n                P[0] = dataOut[index];\n                P[1] = dataOut[index + 1];\n                P[2] = dataOut[index - width + 1];\n                P[3] = dataOut[index - width];\n                P[4] = dataOut[index - width - 1];\n                P[5] = dataOut[index - 1];\n                P[6] = dataOut[index + width - 1];\n                P[7] = dataOut[index + width];\n                P[8] = dataOut[index + width + 1];\n\n                int X_h = 0;\n                int n1 = 0;\n                int n2 = 0;\n                for(int k = 1; k <= 4; k++) {\n                    int k_2 = k << 1;\n                    bool x_2km1 = P[k_2 - 1];\n                    bool x_2k   = P[k_2    ];\n                    bool x_2kp1 = P[k_2 + 1];\n\n                    if( !x_2km1 && (x_2k || x_2kp1) ) {\n                        X_h++;\n                    }\n\n                    if(x_2km1 || x_2k) {\n                        n1++;\n                    }\n\n                    if(x_2k || x_2kp1) {\n                        n2++;\n                    }\n                }\n\n                int min_12 = MIN(n1, n2);\n\n                bool G1 = (X_h == 1);\n                bool G2 = (min_12 > 1) && (min_12 < 4);\n                bool G3 = P[1] && ( P[2] || P[3] || !P[8]);\n\n                if(G1 && G2 && G3) {\n                    list.push_back(index);\n                }\n\n            }\n        }\n\n        for(unsigned int i = 0; i < list.size(); i++) {\n            dataOut[list[i]] = false;\n        }\n\n        list.clear();\n\n        for(int i = 1; i < (height - 1); i++) {\n            int tmp = i * width;\n            for(int j = 1; j < (width - 1); j++) {\n                int index = tmp + j;\n\n                if(!dataOut[index]) {\n                    continue;\n                }\n\n                P[0] = dataOut[index];\n                P[1] = dataOut[index + 1];\n                P[2] = dataOut[index - width + 1];\n                P[3] = dataOut[index - width];\n                P[4] = dataOut[index - width - 1];\n                P[5] = dataOut[index - 1];\n                P[6] = dataOut[index + width - 1];\n                P[7] = dataOut[index + width];\n                P[8] = dataOut[index + width + 1];\n\n                int X_h = 0;\n                int n1 = 0;\n                int n2 = 0;\n                for(int k = 1; k <= 4; k++) {\n                    int k_2 = k << 1;\n                    bool x_2km1 = P[k_2 - 1];\n                    bool x_2k   = P[k_2    ];\n                    bool x_2kp1 = P[k_2 + 1];\n\n                    if( !x_2km1 && (x_2k || x_2kp1) ) {\n                        X_h++;\n                    }\n\n                    if(x_2km1 || x_2k) {\n                        n1++;\n                    }\n\n                    if(x_2k || x_2kp1) {\n                        n2++;\n                    }\n                }\n\n                int min_12 = MIN(n1, n2);\n\n                bool G1 = (X_h == 1);\n                bool G2 = (min_12 > 1) && (min_12 < 4);\n                bool G3 =  P[5] && (P[6] || P[7] || !P[4]);\n\n                if(G1 && G2 && G3) {\n                    list.push_back(index);\n                }\n\n            }\n        }\n\n        for(unsigned int i = 0; i < list.size(); i++) {\n            dataOut[list[i]] = false;\n        }\n\n        return dataOut;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_MASK_HPP */\n"
  },
  {
    "path": "include/util/math.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_MATH_HPP\n#define PIC_UTIL_MATH_HPP\n\n#include <math.h>\n#include <cmath>\n#include <random>\n#include <stdlib.h>\n#include <set>\n#include <limits>\n\n#include \"../base.hpp\"\n\nnamespace pic {\n\n//Natural logarithm of 2\nconst float C_LOG_NAT_2         = 0.69314718055994530941723212145818f;\n\n//Reciprocal natural logarithm of 2\nconst float  C_INV_LOG_NAT_2    = 1.4426950408889634073599246810019f;\nconst double C_INV_LOG_NAT_2_D  = 1.4426950408889634073599246810019;\n\n//Epsilon\nconst float C_EPSILON           = 1e-6f;\n\n//Square root of 2\nconst float C_SQRT_2            = 1.4142135623730950488016887242097f;\n\n//PI/4\nconst float C_PI_025            = 0.78539816339744830961566084581988f;\n//PI/2\nconst float C_PI_05             = 1.5707963267948966192313216916398f;\n//PI\nconst float C_PI                = 3.1415926535897932384626433832795f;\n//(PI *2)\nconst float C_PI_2              = 6.283185307179586476925286766559f;\n// 1 / (PI *2)\nconst float C_INV_PI_2          = 0.159154943091895335768883763f;\n//PI times 4\nconst float C_PI_4              = 12.566370614359172953850573533118f;\n//One over PI times 4\nconst float C_INV_PI_4          = 0.07957747154594766788444188168626f;\n//PI*PI*2\nconst float C_PI_2_2            = 19.739208802178717237668981999752f;\n// 1/PI\nconst float C_INV_PI            = 0.31830988618379067153776526745f;\n// 180/PI\nconst float C_ONE_80_OVER_PI    = 57.295779513082320876798154814105f;\n// PI/180\nconst float C_PI_OVER_ONE_80    = 0.017453292519943295769236907685f;\n\n#ifndef MIN\n    #define MIN(a, b)           (a < b ? a : b)\n#endif\n\n#ifndef MAX\n    #define MAX(a, b)           (a > b ? a : b)\n#endif\n\n#ifndef CLAMP\n    #define CLAMP(x, a)         (x >= a ? (a - 1) : (x < 0 ? 0 : x))\n#endif\n\n#ifndef CLAMPi\n    #define CLAMPi(x, a, b)     (x <  a ? a : (x > b ? b : x))\n#endif\n\n\n#ifndef isnan\n\n/**\n * @brief isnan is it a NaN?\n * @param value\n * @return\n */\ntemplate< typename T >\nPIC_INLINE bool isnan(T value)\n{\n    return value != value ;\n}\n\n/**\n * @brief isinf is it a Inf value?\n * @param value\n * @return\n */\ntemplate< typename T > PIC_INLINE bool isinf(T value)\n{\n    return std::numeric_limits<T>::has_infinity &&\n           (value ==  std::numeric_limits<T>::infinity() ||\n            value == -std::numeric_limits<T>::infinity());\n}\n\n#endif\n\n/**\n * @brief equalf checks if two float values are the same or not.\n * @param a is the first value to be checked.\n * @param b is the second value to be checked.\n * @return This function returns true if a and b are similar,\n * false otherwise.\n */\nPIC_INLINE bool equalf(float a, float b)\n{\n    return ( fabsf(a - b) < C_EPSILON);\n}\n\n/**\n * @brief Randombase returns a number in [0, 1] based on rand().\n * @return It returns a random number in [0, 1].\n */\nPIC_INLINE float getRandombase()\n{\n    return float(rand() % RAND_MAX) / float(RAND_MAX);\n}\n\n/**\n * @brief Random returns a number in [0, 2^32 - 1] to a float in [0, 1].\n * @param n is a 32-bit unsigned integer number.\n * @return It returns n as a normalized float in [0, 1].\n */\nPIC_INLINE float getRandom(unsigned int n)\n{\n    return float(n) / 4294967295.0f;\n}\n\n/**\n * @brief getRandomInt\n * @param n\n * @param a\n * @param b\n * @return\n */\nPIC_INLINE int getRandomInt(int n, int a, int b)\n{\n    if(a < b) {\n        return n % (b - a);\n    } else {\n        return 0;\n    }\n}\n\n/**\n * @brief sFunction evaluates a cubic s-function.\n * @param x is a value in [0.0, 1.0]\n * @return it returns 3 x^2 - 2 x^3\n */\nPIC_INLINE float sFunction(float x)\n{\n    float x2 = x * x;\n    return 3.0f * x2 - 2.0f * x2 * x;\n}\n\n/**\n * @brief sCurve5 evaluates a quintic S-Shape: 6x^5-15x^4+10x^3\n * @param x is a value in [0.0, 1.0]\n * @return\n */\nPIC_INLINE float sCurve5(float x)\n{\n    float x2 = x * x;\n    float x4 = x2 * x2;\n\n    return (6.0f * x - 15.0f) * x4 + 10.0f * x2 * x;\n}\n\n/**\n * @brief Square applies square function to a value.\n * @param x a value.\n * @return It return x^2.\n */\nPIC_INLINE float square(float x)\n{\n    return x * x;\n}\n\n/**\n * @brief sqrtf_s\n * @param x\n * @return\n */\nPIC_INLINE float sqrtf_s(float x)\n{\n    return sqrtf(MAX(x, 0.0f));\n}\n\n/**\n * @brief Clamp clamps a value, x, in the bound [a,b].\n * @param x\n * @param a\n * @param b\n * @return\n */\ntemplate< class T >\nPIC_INLINE T Clamp(T x, T a, T b)\n{\n    if(x > b) {\n        return b;\n    }\n\n    if(x < a) {\n        return a;\n    }\n\n    return x;\n}\n\n/**\n * @brief lround rounds double numbers properly.\n * @param x is a scalar.\n * @return\n */\nPIC_INLINE long lround(double x)\n{\n    if(x > 0.0) {\n        return (x - floor(x) <  0.5) ? (long)floor(x) : (long)ceil(x);\n    } else {\n        return (x - floor(x) <= 0.5) ? (long)floor(x) : (long)ceil(x);\n    }\n}\n\n/**\n * @brief lround rounds float numbers properly.\n * @param x is a scalar.\n * @return\n */\nPIC_INLINE float lround(float x)\n{\n    if(x > 0.0f) {\n        return (x - floorf(x) < 0.5f)  ? floorf(x) : ceilf(x);\n    } else {\n        return (x - floorf(x) <= 0.5f) ? floorf(x) : ceilf(x);\n    }\n}\n\n/**\n * @brief lerp evaluates linear interpolation\n * @param t is a value in [0.0, 1.0].\n * @param x0 is the min value.\n * @param x1 is the max value.\n * @return it returns x0 + t * (x1 - x0)\n */\nPIC_INLINE float lerp(float t, float x0, float x1)\n{\n    return x0 + t * (x1 - x0);\n}\n\n/**\n * @brief SmoothStep smoothes a value from a to b using a cube S-Shape.\n * @param a is the min value.\n * @param b is the max value.\n * @param value is a value in [0.0, 1.0].\n * @return It returns - 2 x^3 + 3 x^2.\n */\nPIC_INLINE float SmoothStep(float a, float b, float value)\n{\n    float x = Clamp<float>((value - a) / (b - a), 0.0f, 1.0f);\n    return  x * x * (-2.0f * x + 3.0f);\n}\n\n/**\n * @brief Deg2Rad converts angles expressed in degrees into angles expressed in radians.\n * @param deg is a value of an angle expressed in degrees.\n * @return It returns an ang expressed in radians.\n */\ninline float Deg2Rad(float deg)\n{\n    return deg * C_PI_OVER_ONE_80;\n}\n\n/**\n * @brief Rad2Deg converts angles expressed in radians into angles expressed in degrees.\n * @param rad is a value of an angle expressed in radians.\n * @return It returns an ang expressed in degrees.\n */\nPIC_INLINE float Rad2Deg(float rad)\n{\n    return rad * C_ONE_80_OVER_PI;\n}\n\n/**\n * @brief log2 computes logarithm in base 2 for integers.\n * @param n is an integer value.\n * @return It returns log2 of n.\n */\nPIC_INLINE int log2(int n)\n{\n    int val = 1;\n    int lg  = 0;\n\n    while(val < n) {\n        val = val << 1;\n        lg++;\n    }\n\n    if(val != n) {\n        lg--;\n    }\n\n    return lg;\n}\n\n/**\n * @brief pow2 computes 2^n.\n * @param n is a positive exponent.\n * @return It returns 2^n.\n */\nPIC_INLINE int pow2(int n)\n{\n    return 1 << n;\n}\n\n/**\n * @brief logf10PlusOne computes log10 of a value plus 1.\n * @param x is a value for which the log10 needs to be computed.\n * @return It returns log10(x + 1).\n */\nPIC_INLINE float log10PlusOne(float x)\n{\n    return log10f(x + 1.0f);\n}\n\n/**\n * @brief expMinusOne\n * @param x\n * @return\n */\nPIC_INLINE float expfMinusOne(float x)\n{\n    float tmp = powf(10.0f, x) - 1.0f;\n    return MAX(tmp, 0.0f);\n}\n\n/**\n * @brief log10fPlusEpsilon\n * @param x\n * @return\n */\nPIC_INLINE float log10fPlusEpsilon(float x)\n{\n    return log10f(x + 1e-7f);\n}\n\n/**\n * @brief powf10fMinusEpsilon\n * @param x\n * @return\n */\nPIC_INLINE float powf10fMinusEpsilon(float x)\n{\n    return MAX(powf(10.0f, x) - 1e-7f, 0.0f);\n}\n\n/**\n * @brief log2f logarithm in base 2 for floating point\n * @param x\n * @return\n */\nPIC_INLINE float log2f(float x)\n{\n    return logf(x) * C_INV_LOG_NAT_2;\n}\n\n/**\n * @brief log2\n * @param x\n * @return\n */\nPIC_INLINE double log2(double x)\n{\n    return log(x) * C_INV_LOG_NAT_2_D;\n}\n\n/**\n * @brief log2fPlusEpsilon\n * @param x\n * @return\n */\nPIC_INLINE float log2fPlusEpsilon(float x)\n{\n    return logf(x + 1e-6f) * C_INV_LOG_NAT_2;\n}\n\n/**\n * @brief pow2f\n * @param x\n * @return\n */\nPIC_INLINE float pow2f(float x)\n{\n    return powf(2.0f, x);\n}\n\n/**\n * @brief powint computes power function for integer values.\n * @param x is the base.\n * @param b is the exponent.\n * @return it returns x^b.\n */\nPIC_INLINE int powint(int x, int b)\n{\n    int ret = 1;\n    \n    for(int i = 0; i < b; i++) {\n        ret *= x;\n    }\n\n    return ret;\n}\n\n/**\n * @brief getRandomPermutation computes a random permutation.\n * @param m is a Mersenne Twister random number generator.\n * @param perm is the array where to store the permutation.\n * @param nPerm is the size of perm.\n * @param n is the number of object to permutate.\n */\nPIC_INLINE void getRandomPermutation(std::mt19937 &m, unsigned int *perm, unsigned int nPerm, unsigned int n)\n{\n    std::set< unsigned int > checker;\n\n    unsigned int tmp = m() % n;\n    checker.insert(tmp);\n    perm[0] = tmp;\n    unsigned int index = 1;\n\n    while(index < nPerm) {\n        tmp = m() % n;\n\n        if(checker.find(tmp) == checker.end()) {\n            perm[index] = tmp;\n            index++;\n        }\n    }\n}\n\n/**\n * @brief normalDistribution\n * @param x\n * @param mu\n * @param sigma\n * @return\n */\nPIC_INLINE float normalDistribution(float x, float mu = 0.0f, float sigma = 1.0f)\n{\n    float ret;\n\n    float sigma_sq_2 = sigma * sigma * 2.0f;\n    float d = x - mu;\n    ret = exp(-(d * d) / sigma_sq_2) / sqrtf(sigma_sq_2 * C_PI);\n\n    return ret;\n}\n\n/**\n * @brief normalCDF\n * @param x\n * @param mu\n * @param sigma\n * @return\n */\nPIC_INLINE float normalCDF(float x, float mu, float sigma)\n{\n    float t = (x - mu) / (sigma * C_SQRT_2);\n    return (1.0f + std::erf(t)) * 0.5f;\n}\n\n/**\n * @brief betaFunction\n * @param A\n * @param B\n * @return\n */\nPIC_INLINE float betaFunction(float A, float B, float step = 1e-4)\n{\n    if(step <= 0.0f || step >= 1.0f) {\n        step = 1e-4f;\n    }\n\n    float A1 = A - 1.0f;\n    float B1 = B - 1.0f;\n\n    float ret = 0.0f;\n\n    int tot = 0;\n    for(float x = 0.0f; x <= 1.0f; x += step) {\n        ret += powf(x, A1) * powf(1.0f - x, B1);\n        tot++;\n    }\n\n    return ret / float(tot);\n}\n\n/**\n * @brief betaPDFwithBeta\n * @param x\n * @param A\n * @param B\n * @param betaAB\n * @return\n */\nPIC_INLINE float betaPDFwithBeta(float x, float A, float B, float betaAB)\n{\n    if(x < 0.0f || x > 1.0f) {\n        return -1.0f;\n    }\n\n    float ret = powf(x, A - 1.0f) * powf(1.0f - x, B - 1.0f);\n\n    return ret / betaAB;\n}\n\n/**\n * @brief betaPDF\n * @param x\n * @param A\n * @param B\n * @return\n */\nPIC_INLINE float betaPDF(float x, float A, float B)\n{\n    return betaPDFwithBeta(x, A, B, betaFunction(A, B));\n}\n\n/**\n * @brief sigmoid\n * @param x\n * @return\n */\nPIC_INLINE float sigmoid(float x)\n{\n    return x / (x + 1.0f);\n}\n\n/**\n * @brief sigmoidInv\n * @param x\n * @return\n */\nPIC_INLINE float sigmoidInv(float x)\n{\n    return x / (1.0f - x);\n}\n\n/**\n * @brief simple8bitWithGamma\n * @param x\n * @return\n */\nPIC_INLINE float simple8bitWithGamma(float x)\n{\n    float t0 = powf(x, 1.0f / 2.2f) * 255.0f;\n    float t1 = CLAMPi(t0, 0.0f, 255.0f);\n    return float(int(t1));\n}\n\n} // end namespace pic\n\n#endif\n"
  },
  {
    "path": "include/util/matrix_3_x_3.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_MATRIX_3_X_3_HPP\n#define PIC_UTIL_MATRIX_3_X_3_HPP\n\n#include <math.h>\n#include <algorithm>\n\nnamespace pic {\n\n/**\n * @brief The Matrix3x3 class provides methods for managing a 3 by 3 matrix.\n */\nclass Matrix3x3\n{\npublic:\n    /*\n     * 0 1 2\n     * 3 4 5\n     * 6 7 8\n    */\n    float data[9];\n\n    /**\n     * @brief Matrix3x3\n     */\n    Matrix3x3()\n    {\n        for(int i = 0; i < 9; i++) {\n            data[i] = 0.0f;\n        }\n    }\n\n    /**\n     * @brief Matrix3x3\n     * @param data\n     */\n    Matrix3x3(float *data)\n    {\n        set(data);\n    }\n\n    /**\n     * @brief clone clones the matrix.\n     * @return it returns the cloned matrix.\n     */\n    Matrix3x3 clone()\n    {\n        Matrix3x3 ret(data);\n\n        return ret;\n    }\n\n    /**\n     * @brief set sets the matrix up.\n     * @param data input data, they are assumed to be 9 floats.\n     * The matrix is stored by rows.\n     */\n    void set(const float *data)\n    {\n        if(data != NULL) {\n            memcpy(this->data, data, 9 * sizeof(float));\n        }\n    }\n\n    /**\n     * @brief set sets the matrix up.\n     * @param data input data, they are assumed to be 9 floats.\n     * The matrix is stored by rows.\n     */\n    void set(Matrix3x3 *mtx)\n    {\n        if(mtx != NULL) {\n            this->set(mtx->data);\n        }\n    }\n\n    /**\n     * @brief getIdentity sets the matrix as an identity matrix; diag(1, 1, 1);\n     */\n    void getIdentity()\n    {\n        data[0] = 1.0f;\n        data[1] = 0.0f;\n        data[2] = 0.0f;\n\n        data[3] = 0.0f;\n        data[4] = 1.0f;\n        data[5] = 0.0f;\n\n        data[6] = 0.0f;\n        data[7] = 0.0f;\n        data[8] = 1.0f;\n    }\n\n    /**\n     * @brief mul\n     * @param mtx\n     * @return\n     */\n    Matrix3x3 mul(const Matrix3x3 &mtx)\n    {\n        Matrix3x3 ret;\n        ret.data[0] = data[0] * mtx.data[0] +  data[1] * mtx.data[3] + data[2] * mtx.data[6];\n        ret.data[1] = data[0] * mtx.data[1] +  data[1] * mtx.data[4] + data[2] * mtx.data[7];\n        ret.data[2] = data[0] * mtx.data[2] +  data[1] * mtx.data[6] + data[2] * mtx.data[8];\n\n        ret.data[3] = data[3] * mtx.data[0] +  data[4] * mtx.data[3] + data[5] * mtx.data[6];\n        ret.data[4] = data[3] * mtx.data[1] +  data[4] * mtx.data[4] + data[5] * mtx.data[7];\n        ret.data[5] = data[3] * mtx.data[2] +  data[4] * mtx.data[6] + data[5] * mtx.data[8];\n\n        ret.data[6] = data[6] * mtx.data[0] +  data[7] * mtx.data[3] + data[8] * mtx.data[6];\n        ret.data[7] = data[6] * mtx.data[1] +  data[7] * mtx.data[4] + data[8] * mtx.data[7];\n        ret.data[8] = data[6] * mtx.data[2] +  data[7] * mtx.data[6] + data[8] * mtx.data[8];\n\n        return ret;\n    }\n\n    /**\n     * @brief mul\n     * @param vec\n     * @param ret\n     * @return\n     */\n    float *mul(float *vec, float *ret)\n    {\n        if(vec == NULL) {\n            return ret;\n        }\n\n        if(ret == NULL) {\n            ret = new float[3];\n        }\n\n        ret[0] = data[0] * vec[0] + data[1] * vec[1] + data[2] * vec[2];\n        ret[1] = data[3] * vec[0] + data[4] * vec[1] + data[5] * vec[2];\n        ret[2] = data[6] * vec[0] + data[7] * vec[1] + data[8] * vec[2];\n\n        return ret;\n    }\n\n    /**\n     * @brief MulH\n     * @param vec\n     * @param ret\n     * @return\n     */\n    float *mulH(float *vec, float *ret)\n    {\n        if(vec == NULL) {\n            return ret;\n        }\n\n        if(ret == NULL) {\n            ret = new float[3];\n        }\n\n        ret[0] = data[0] * vec[0] + data[1] * vec[1] + data[2] * vec[2];\n        ret[1] = data[3] * vec[0] + data[4] * vec[1] + data[5] * vec[2];\n        ret[2] = data[6] * vec[0] + data[7] * vec[1] + data[8] * vec[2];\n\n        return ret;\n    }\n\n    /**\n     * @brief projection\n     * @param vec\n     * @param ret\n     * @return\n     */\n    float *projection(float *vec, float *ret) {\n        if(vec == NULL) {\n            return ret;\n        }\n\n        if(ret == NULL) {\n            ret = new float[2];\n        }\n\n        ret[0]      = data[0] * vec[0] + data[1] * vec[1] + data[2];\n        ret[1]      = data[3] * vec[0] + data[4] * vec[1] + data[5];\n        float ret_2 = data[6] * vec[0] + data[7] * vec[1] + data[8];\n\n        if(ret_2 > 0.0f) {\n            ret[0] /= ret_2;\n            ret[1] /= ret_2;\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief crossProduct computes the cross product matrix\n     * @param t is a three value array.\n     */\n    void crossProduct(float *t)\n    {\n        if(t == NULL) {\n            return;\n        }\n\n        data[0] =  0.0f;\n        data[1] = -t[2];\n        data[2] =  t[1];\n\n        data[3] =  t[2];\n        data[4] =  0.0f;\n        data[5] = -t[0];\n\n        data[6] = -t[1];\n        data[7] =  t[0];\n        data[8] =  0.0f;\n    }\n\n    /**\n     * @brief Add adds a value to the diagonal.\n     * @param value is the value to be added.\n     */\n    void add(float value)\n    {\n        data[0] += value;\n        data[4] += value;\n        data[8] += value;\n    }\n\n    /**\n     * @brief determinant computes the determinant of the matrix.\n     * @return\n     */\n    float determinant()\n    {\n        return\t data[0] * (data[4] * data[8] - data[5] * data[7]) -\n                 data[1] * (data[8] * data[3] - data[5] * data[6]) +\n                 data[2] * (data[3] * data[7] - data[4] * data[6]);\n    }\n\n    /**\n     * @brief inverse computes the inverse of the matrix.\n     * @param ret\n     * @return\n     */\n    Matrix3x3 *inverse(Matrix3x3 *ret)\n    {\n        if(ret == NULL) {\n            ret = new Matrix3x3();\n        }\n\n        float det = determinant();\n\n        if(fabsf(det) <= 1e-9f) {\n            printf(\"Error: Negative determinant\\n\");\n            return ret;\n        }\n\n        ret->data[0] =  (data[4] * data[8] - data[5] * data[7]) / det;\n        ret->data[1] = -(data[1] * data[8] - data[2] * data[7]) / det;\n        ret->data[2] =  (data[1] * data[5] - data[2] * data[4]) / det;\n\n        ret->data[3] = -(data[3] * data[8] - data[5] * data[6]) / det;\n        ret->data[4] =  (data[0] * data[8] - data[2] * data[6]) / det;\n        ret->data[5] = -(data[0] * data[5] - data[2] * data[3]) / det;\n\n        ret->data[6] =  (data[3] * data[7] - data[4] * data[6]) / det;\n        ret->data[7] = -(data[0] * data[7] - data[1] * data[6]) / det;\n        ret->data[8] =  (data[0] * data[4] - data[1] * data[3]) / det;\n\n        return ret;\n    }\n\n    /**\n     * @brief transpose computes the transposed matrix.\n     */\n    Matrix3x3 * transpose(Matrix3x3 *ret)\n    {\n        if(ret == NULL) {\n            ret = new Matrix3x3();\n        }\n\n        ret->set(ret);\n\n        std::swap(ret->data[1], data[3]);\n        std::swap(data[5], data[7]);\n        std::swap(data[2], data[6]);\n\n        return ret;\n    }\n\n    /**\n     * @brief setTranslationMatrix sets the matrix as a translation matrix.\n     * @param tx\n     * @param ty\n     */\n    void setTranslationMatrix(float tx, float ty) {\n        data[0] = 1.0f;\n        data[1] = 0.0f;\n        data[2] = tx;\n\n        data[3] = 0.0f;\n        data[4] = 1.0f;\n        data[5] = ty;\n\n        data[6] = 0.0f;\n        data[7] = 0.0f;\n        data[8] = 1.0f;\n    }\n\n    /**\n     * @brief setRotationMatrix sets the matrix as a rotation matrix\n     * @param ang\n     */\n    void setRotationMatrix(float ang) {\n        float cosAng = cosf(ang);\n        float sinAng = sinf(ang);\n\n        data[0] = cosAng;\n        data[1] = -sinAng;\n        data[2] = 0.0f;\n\n        data[3] = sinAng;\n        data[4] = cosAng;\n        data[5] = 0.0f;\n\n        data[6] = 0.0f;\n        data[7] = 0.0f;\n        data[8] = 1.0f;\n    }\n\n    /**\n     * @brief SetShearMatrix sets the matrix as a shear matrix.\n     * @param horizontal_shear\n     * @param vertical_shear\n     */\n    void setShearMatrix(float horizontal_shear, float vertical_shear)\n    {\n        getIdentity();\n\n        data[1] = vertical_shear;\n        data[3] = horizontal_shear;\n    }\n\n    /**\n     * @brief SetScaleMatrix set the matrix as a scaling matrix.\n     * @param x_scale\n     * @param y_scale\n     */\n    void setScaleMatrix(float x_scale, float y_scale)\n    {\n        if(x_scale <= 0.0f) {\n            x_scale = 1.0f;\n        }\n\n        if(y_scale <= 0.0f) {\n            y_scale = 1.0f;\n        }\n\n        getIdentity();\n\n        data[0] = x_scale;\n        data[4] = y_scale;\n    }\n\n    /**\n     * @brief print\n     */\n    void print(){\n        printf(\"\\n\");\n        printf(\"%.9f %.9f %.9f\\n\", data[0], data[1], data[2]);\n        printf(\"%.9f %.9f %.9f\\n\", data[3], data[4], data[5]);\n        printf(\"%.9f %.9f %.9f\\n\", data[6], data[7], data[8]);\n    }\n};\n\n} // end namespace pic\n\n#endif // PIC_UTIL_MATRIX_3_X_3_HPP\n"
  },
  {
    "path": "include/util/nelder_mead_opt_base.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_NELDER_MEAD_OPT_BASE_HPP\n#define PIC_NELDER_MEAD_OPT_BASE_HPP\n\n#include <vector>\n#include <utility>\n#include <algorithm>\n\n#include \"../base.hpp\"\n\nnamespace pic{\n\n/**\n * @brief The NelderMeadOptBase class\n */\ntemplate <class Scalar>\nclass NelderMeadOptBase\n{\nprotected:\n    bool bStopMean;\n    Scalar delta, delta_zero;\n    Scalar alpha, gamma, lambda, sigma;\n\n    //simlex vertices\n    std::vector< std::pair<Scalar, Scalar *> > simplex;\n\n    /**\n     * @brief InitSimplex\n     * @param x0\n     * @param n\n     */\n    void InitSimplex(Scalar *x0, uint n)\n    {\n        simplex.clear();\n\n        //first point of simplex is x0\n        Scalar *vertex_0 = new Scalar[n];\n        Scalar function_vertex_0;\n        memcpy(vertex_0, x0, sizeof(Scalar) * n);\n        function_vertex_0 = function(vertex_0, n);\n\n        simplex.push_back(std::make_pair(function_vertex_0, vertex_0));\n\n        //compute the other vertices of the simplex\n        for(uint i = 0; i < n; i++) {\n            Scalar *vertex = new Scalar[n];\n            memcpy(vertex, x0, sizeof(Scalar) * n);\n\n            if(vertex[i] != Scalar(0)) {\n                vertex[i] += x0[i] * delta;\n            } else {\n                vertex[i] = delta_zero;\n            }\n\n            Scalar function_vertex = function(vertex, n);\n\n            simplex.push_back(std::make_pair(function_vertex, vertex));\n        }\n\n        std::sort(simplex.begin(), simplex.end());\n    }\n\n    /**\n     * @brief ComputeMean\n     * @param x_mean\n     * @param n\n     */\n    void ComputeMean(Scalar *x_mean, uint n)\n    {\n        Scalar n_f = Scalar(n);\n\n        //computing the mean point in the simplex\n        for(uint i = 0; i < n; i++) {\n            x_mean[i] = Scalar(0);\n        }\n\n        for(uint j = 0; j < n; j++) {\n            Scalar *vertex = simplex[j].second;\n\n            for(uint i = 0; i < n; i++) {\n                x_mean[i] += vertex[i];\n            }\n        }\n\n        for(uint i = 0; i < n; i++) {\n            x_mean[i] /= n_f;\n        }\n    }\n\n    /**\n     * @brief ComputeReflected\n     * @param x_r\n     * @param x_mean\n     * @param n\n     * @return\n     */\n    Scalar ComputeReflected(Scalar *x_r, Scalar *x_mean, uint n)\n    {\n        Scalar *x_n = simplex[n].second;\n\n        for(uint i = 0; i < n; i++) {\n            x_r[i] = x_mean[i] + alpha * (x_mean[i] - x_n[i]);\n        }\n\n        return function(x_r, n);\n    }\n\n    /**\n     * @brief ComputeExpansion\n     * @param x_e\n     * @param x_mean\n     * @param n\n     * @return\n     */\n    Scalar ComputeExpansion(Scalar *x_e, Scalar *x_mean, uint n)\n    {\n        Scalar *x_n = simplex[n].second;\n\n        for(uint i = 0; i < n; i++) {\n            x_e[i] = x_mean[i] + gamma * (x_mean[i] - x_n[i]);\n        }\n\n        return function(x_e, n);\n    }\n\n    /**\n     * @brief ComputeContractionInside\n     * @param x_c\n     * @param x_mean\n     * @param n\n     * @return\n     */\n    Scalar ComputeContractionInside(Scalar *x_c, Scalar *x_mean, uint n)\n    {\n        Scalar *x_n = simplex[n].second;\n\n        for(uint i = 0; i < n; i++) {\n            x_c[i] = x_mean[i] + lambda * (x_mean[i] - x_n[i]);\n        }\n\n        return function(x_c, n);\n    }\n\n    /**\n     * @brief ComputeReduction\n     * @param n\n     */\n    void ComputeReduction(uint n)\n    {\n        Scalar *x_0 = simplex[0].second;\n\n        for(uint i = 1; i < (n + 1); i++) {\n\n            Scalar *x_i = simplex[i].second;\n\n            for(uint j = 0; j < n ; j++) {\n                x_i[j] = x_0[j] + sigma * (x_i[j] - x_0[j]);\n            }\n\n            simplex[i].first = function(x_i, n);\n        }\n    }\n\n    /**\n     * @brief run_aux\n     * @param x_start\n     * @param n\n     * @param epsilon\n     * @param x\n     * @return\n     */\n    Scalar *run_aux(Scalar *x_start, uint n, Scalar epsilon, int max_iterations = 1000, Scalar *x = NULL)\n    {\n        InitSimplex(x_start, n);\n\n        Scalar *x_mean = new Scalar[n];\n        Scalar *x_r = new Scalar[n];\n        Scalar *x_e = new Scalar[n];\n        Scalar *x_c = new Scalar[n];\n\n        int i = 0;\n\n        size_t n_size = sizeof(Scalar) * n;\n\n        while(i < max_iterations) {\n\n            std::sort(simplex.begin(), simplex.end());\n\n            ComputeMean(x_mean, n);\n\n            //Stopping check\n            if(bStopMean) {\n\n                Scalar function_vertex_x_mean = function(x_mean, n);\n\n                Scalar err = Scalar(0);\n                for(uint j = 0; j < n; j++) {\n                    Scalar tmp = simplex[j].first - function_vertex_x_mean;\n                    err += tmp * tmp;\n                }\n\n                err = sqrt( err / Scalar(n));\n\n                if(err <= epsilon) {\n                    break;\n                }\n\n            } else {\n\n                Scalar err_f = Scalar(0);\n                Scalar err_v = Scalar(0);\n\n                for(uint j = 1; j < (n + 1); j++) {\n                    err_f = MAX(err_f, fabs(simplex[j].first - simplex[0].first));\n\n                    for(uint i = 0; i < n; i++) {\n                        err_v = MAX(err_v, fabs(simplex[j].second[i] - simplex[0].second[i]));\n                    }\n                }\n\n                if((err_f <= epsilon) && (err_v <= epsilon)) {\n                    break;\n                }\n            }\n\n            //main algorithm\n            Scalar function_vertex_r = ComputeReflected(x_r, x_mean, n);\n\n            if((simplex[0].first <= function_vertex_r) &&\n               (function_vertex_r < simplex[n - 1].first)) {//reflection\n\n                simplex[n].first = function_vertex_r;\n                memcpy(simplex[n].second, x_r, n_size);\n            } else {\n                if(function_vertex_r < simplex[0].first) {//expansion\n                    Scalar function_vertex_e = ComputeExpansion(x_e, x_mean, n);\n\n                    if(function_vertex_e < function_vertex_r) {\n                        simplex[n].first = function_vertex_e;\n                        memcpy(simplex[n].second, x_e, n_size);\n\n                    } else {\n                        simplex[n].first = function_vertex_r;\n                        memcpy(simplex[n].second, x_r, n_size);\n                    }\n                } else {//contraction function_vertex_r > function_vertex_(n - 1)\n\n                    Scalar function_vertex_c = ComputeContractionInside(x_c, x_mean, n);\n\n                    if(function_vertex_c < simplex[n].first) {\n                        simplex[n].first = function_vertex_c;\n                        memcpy(simplex[n].second, x_c, n_size);\n\n                    } else {//reduction\n                        ComputeReduction(n);\n                    }\n                }\n            }\n\n            i++;\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"\\nNelder-Mead iterations: %d Err: %f\\n\", i, simplex[0].first);\n        #endif\n\n        output_error = simplex[0].first;\n\n        memcpy(x, simplex[0].second, n_size);\n\n        delete[] x_mean;\n        delete[] x_r;\n        delete[] x_e;\n        delete[] x_c;\n\n        return x;\n    }\n\npublic:\n\n    int max_iterations;\n    Scalar output_error;\n\n    /**\n     * @brief NelderMeadOptBase\n     */\n    NelderMeadOptBase()\n    {\n        GlobalSettings();\n    }\n\n    /**\n     * @brief GlobalSettings\n     */\n    void GlobalSettings()\n    {\n        //initialization\n        delta = Scalar(0.05);\n        delta_zero = Scalar(0.00025);\n\n        bStopMean = false;\n        \n        //other parts\n        alpha = Scalar(1.0);\n        gamma = Scalar(2.0);\n        lambda = Scalar(-0.5);\n        sigma = Scalar(0.5);\n    }\n\n    /**\n     * @brief function\n     * @return\n     */\n    virtual Scalar function(Scalar *x, uint n)\n    {\n        return FLT_MAX;\n    }\n\n    virtual Scalar *run(Scalar *x_start, uint n, Scalar epsilon = 1e-4f, int max_iterations = 1000, Scalar *x = NULL)\n    {\n        if(x == NULL) {\n            x = new Scalar[n];\n        }\n\n        return run_aux(x_start, n, epsilon, max_iterations, x);\n    }\n\n};\n\n}\n\n#endif // PIC_NELDER_MEAD_OPT_BASE_HPP\n"
  },
  {
    "path": "include/util/nelder_mead_opt_positive_polynomial.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_NELDER_MEAD_OPT_POSITIVE_POLYNOMIAL_HPP\n#define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_POSITIVE_POLYNOMIAL_HPP\n\n#include <random>\n#include <vector>\n\n#include \"../base.hpp\"\n#include \"../util/nelder_mead_opt_base.hpp\"\n#include \"../util/math.hpp\"\n#include \"../util/polynomial.hpp\"\n\nnamespace pic {\n\nclass NelderMeadOptPositivePolynomial: public NelderMeadOptBase<float>\n{\nprotected:\n    std::vector< float > px, py;\n\npublic:\n    NelderMeadOptPositivePolynomial(std::vector< float > &px, std::vector< float > &py) : NelderMeadOptBase()\n    {\n        if(px.size() == py.size()) {\n            this->px.assign(px.begin(), px.end());\n            this->py.assign(py.begin(), py.end());\n        }\n    }\n\n    float function(float *x, unsigned int n)\n    {\n        Polynomial poly(x, n);\n\n        float err = 0.0f;\n        for(uint i = 0; i < px.size(); i++) {\n            float py_i = poly.eval(px[i]);\n            if(py_i > 0.0f) {\n                float delta_y = py_i - py[i];\n                err += (delta_y * delta_y);\n            } else {\n                err += 1e6f;\n            }\n        }\n\n        return err;\n    }\n\n#ifndef PIC_DISABLE_EIGEN\n\n    static void test()\n    {\n        std::mt19937 m(1);\n\n        std::vector< float > x, y;\n\n        for(int i = 0; i < 100; i++) {\n            float tx = float(i) / 100.0f;\n            float ty = tx + (getRandom(m()) * 0.01f - 0.05f); //noise\n            float ty_sq = ty * ty;\n            x.push_back(tx);\n            y.push_back(ty_sq);\n        }\n\n        NelderMeadOptPositivePolynomial test(x, y);\n\n        Polynomial poly;\n        poly.fit(x, y, 2);\n\n        float *in = poly.getArray(NULL);\n\n        float *out = test.run(in, 3, 1e-12f, 100000);\n\n        printf(\"In: [%f %f %f]\\nOut: [%f %f %f]\\n\", in[2], in[0], in[1], out[2], out[1], out[0]);\n    }\n\n#endif\n};\n\n}\n\n#endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_POSITIVE_POLYNOMIAL_HPP\n"
  },
  {
    "path": "include/util/nelder_mead_opt_test_function.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_COMPUTER_VISION_NELDER_MEAD_OPT_TEST_FUNCTION_HPP\n#define PIC_COMPUTER_VISION_NELDER_MEAD_OPT_TEST_FUNCTION_HPP\n\n#include <random>\n\n#include \"../util/nelder_mead_opt_base.hpp\"\n\nnamespace pic {\n\nclass NelderMeadOptTestFunction: public NelderMeadOptBase<float>\n{\npublic:\n\n    float a, b;\n\n    NelderMeadOptTestFunction(float a, float b) : NelderMeadOptBase()\n    {\n        this->a = a;\n        this->b = b;\n    }\n\n    float function(float *x, unsigned int n)\n    {\n        if(n != 2) {\n            return FLT_MAX;\n        }\n\n        float a_x = (a - x[0]);\n        float y_x2 = x[1] - x[0] * x[0];\n\n        return a_x * a_x + b * y_x2 *y_x2;\n    }\n\n    static void test()\n    {\n        NelderMeadOptTestFunction test(1.0f, 100.0f);\n\n        std::mt19937 rnd(1);\n        float start[2];\n        for(int i = 0; i < 1000; i++) {\n\n            start[0] = float(rnd() % 1000) * 0.003f;\n            start[1] = float(rnd() % 1000) * 0.002f;\n\n            float *sol = test.run(start, 2, 1e-12f, 10000);\n            printf(\"x: %f y: %f f: %f\\n\", sol[0], sol[1], test.function(sol, 2));\n        }\n    }\n};\n\n}\n\n#endif // PIC_COMPUTER_VISION_NELDER_MEAD_OPT_TEST_FUNCTION_HPP\n"
  },
  {
    "path": "include/util/point_samplers.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_POINT_SAMPLERS_HPP\n#define PIC_UTIL_POINT_SAMPLERS_HPP\n\nnamespace pic {\n\n/**\n * @brief randU computes a random number in [0, 1[ using the classic rand().\n * @return It returns a random value in [0, 1[ using the classic rand().\n */\ninline float randU()\n{\n    return float(rand() % RAND_MAX) / float(RAND_MAX);\n}\n\nconst float POISSON_RHO = 0.75f;\n\n/**\n * @brief PoissonRadius estimates the radius of a Poisson-disk like distribution\n * using nSmaples.\n * @param nSamples is the number of samples to have.\n * @return It returns the estimation of the radius.\n */\ninline float PoissonRadius(int nSamples)\n{\n    return (2.0f * POISSON_RHO) / sqrtf(2.0f * sqrtf(3.0f) * float(nSamples));\n}\n\n/*Sampler type:\n\t-ST_POISSON: poisson sampling\n\t-ST_POISSON_M: multiple poisson sampling\n\t-ST_MONTECARLO: classic montecarlo\n\t-ST_MONTECARLO_S: stratifield montecarlo*/\n\nenum SAMPLER_TYPE {ST_BRIDSON, ST_DARTTHROWING, ST_PATTERN, ST_MONTECARLO, ST_MONTECARLO_S};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_POINT_SAMPLERS_HPP */\n\n"
  },
  {
    "path": "include/util/polyline.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_POLYLINE_HPP\n#define PIC_UTIL_POLYLINE_HPP\n\n#include <vector>\n\n#include \"../base.hpp\"\n\n#include \"../util/vec.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n#endif\n\nnamespace pic {\n\n/**\n * @brief The Polyline class\n */\ntemplate<unsigned int N, class T>\nclass Polyline\n{\npublic:\n\n    std::vector< Vec<N, T> > points;\n\n    Polyline()\n    {\n        points.clear();\n    }\n\n    Polyline(std::vector< Vec<N, T> > &points)\n    {\n        this->points.assign(points.begin(), points.end());\n    }\n\n    /**\n     * @brief add\n     * @param point\n     */\n    void add(Vec<N, T> &point)\n    {\n        points.push_back(point);\n    }\n\n    /**\n     * @brief simplify\n     * @param target_n_points\n     */\n    void simplify(int target_n_points)\n    {\n        int n = int(points.size());\n\n        if(n <= target_n_points) {\n            return;\n        }\n\n        while(n > target_n_points) {\n            float area_min = FLT_MAX;\n            int index = -1;\n            float a, b, c, area_tmp;\n            for(int i = 0; i < (n - 2); i++) {\n\n                auto p0 = points.at(i    );\n                auto p1 = points.at(i + 1);\n                auto p2 = points.at(i + 2);\n\n                a = sqrtf(float(p0.distanceSq(p1)));\n                b = sqrtf(float(p1.distanceSq(p2)));\n                c = sqrtf(float(p2.distanceSq(p0)));\n\n                float s = (a + b + c) / 2.0f ;\n\n                float area_sq = s * (s - a) * (s - b) * (s - c);\n                area_tmp = sqrtf(area_sq);\n\n                if(area_tmp < area_min) {\n                    area_min = area_tmp;\n                    index = i;\n                }\n            }\n\n            if(index > -1) {\n                points.erase(points.begin() + index + 1);\n            } else {\n\n                break;\n            }\n\n            n = int(points.size());\n        }\n    }\n};\n\n/**\n * @brief Polyline2i\n */\ntypedef Polyline<2, int> Polyline2i;\n\n#ifndef PIC_DISABLE_EIGEN\n/**\n * @brief convertFromEigenToPolyLine\n * @param in\n * @param out\n */\nPIC_INLINE void convertFromEigenToPolyLine(std::vector< Eigen::Vector2i > &in, Polyline2i &out)\n{\n    for(unsigned int i = 0; i < in.size(); i++) {\n        auto tmp = Vec2i(in[i][0], in[i][1]);\n        out.add(tmp);\n    }\n}\n#endif\n\n} // end namespace pic\n\n#endif //PIC_UTIL_POLYLINE_HPP\n"
  },
  {
    "path": "include/util/polynomial.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_coeffNOMIAL_HPP\n#define PIC_UTIL_coeffNOMIAL_HPP\n\n#include <vector>\n\n#include \"../base.hpp\"\n\n#ifndef PIC_DISABLE_EIGEN\n    #ifndef PIC_EIGEN_NOT_BUNDLED\n        #include \"../externals/Eigen/QR\"\n        #include \"../externals/Eigen/Eigenvalues\"\n    #else\n        #include <Eigen/QR>\n    #endif\n#endif\n\nnamespace pic {\n\n\nclass Polynomial\n{\nprotected:\n\n    /**\n     * @brief getRootsNetwonHorner\n     * @return\n     */\n    bool getRootsNetwonHorner(float *x)\n    {\n\n        float upper_bound = getUpperBoundRoots();\n\n\n    #ifdef PIC_DEBUG\n        float lower_bound = getNegativeLowerBoundRoots();\n        float lower_bound2 = getPositiveLowerBoundRoots();\n        float upper_bound2 = getNegativeUpperBoundRoots();\n        printf(\"Positive Lower bound: %f\\n\", lower_bound2);\n        printf(\"Positive Upper bound: %f\\n\", upper_bound);\n        printf(\"Negative Lower bound: %f\\n\", lower_bound);\n        printf(\"Negative Upper bound: %f\\n\", upper_bound2);\n    #endif\n\n        float x_p = upper_bound;\n        bool notConverged = true;\n        int counter = 0;\n        float E_x_p, d_E_x_p, delta;\n        float prev = x_p;\n\n        computeDCoeff();\n\n        while(notConverged) {\n            E_x_p = eval(x_p);\n            d_E_x_p = dEval(x_p);\n            x_p -= E_x_p / d_E_x_p;\n\n            delta = fabsf(x_p - prev);\n            prev = x_p;\n            counter++;\n            notConverged = (delta > 1e-5f) && (counter < 1000);\n        }\n\n        if(counter >= 1000) {\n            return false;\n        } else {\n            *x = x_p;\n            return true;\n        }\n    }\n\n    /**\n     * @brief computeDCoeff\n     */\n    void computeDCoeff()\n    {\n        if(coeff.empty()) {\n            return;\n        }\n\n        d_coeff.push_back(0.0f);\n\n        for(uint i = 1; i < coeff.size(); i++) {\n            float d_i = float(i) * coeff[i];\n            d_coeff.push_back(d_i);\n        }\n    }\n\npublic:\n    std::vector<float> d_coeff;\n    std::vector<float> coeff;\n    bool all_coeff_positive;\n\n    /**\n     * @brief Polynomial\n     */\n    Polynomial()\n    {\n        all_coeff_positive = true;\n    }\n\n    /**\n     * @brief Polynomial\n     * @param nCoeff\n     */\n    Polynomial(int nCoeff)\n    {\n        for(int i = 0; i < nCoeff; i++) {\n            coeff.push_back(0.0f);\n        }\n\n        all_coeff_positive = true;\n    }\n\n    /**\n     * @brief Polynomial\n     * @param coeff\n     * @param nCoeff\n     */\n    Polynomial(float *coeff, int nCoeff)\n    {\n        if(nCoeff < 1 || coeff == NULL) {\n            return;\n        }\n\n        this->coeff.assign(coeff, coeff + nCoeff);\n        update();\n    }\n\n    ~Polynomial()\n    {\n\n    }\n\n    void update()\n    {\n        computeDCoeff();\n        computeAllPositiveCoeff();\n    }\n\n    /**\n     * @brief computeAllPositiveCoeff\n     */\n    void computeAllPositiveCoeff()\n    {\n        int counter = 0;\n        for (const float &c : coeff) {\n            if(c < 0.0f) {\n                counter++;\n            }\n        }\n\n        all_coeff_positive = counter < 1;\n    }\n\n    /**\n     * @brief print\n     */\n    void print()\n    {\n        printf(\"%s\\n\", toString().c_str());\n    }\n\n    std::string toString()\n    {\n        std::string ret = \"\";\n        if(coeff.empty()) {\n            return ret;\n        }\n\n        int nCoeff = int(coeff.size());\n\n        if(nCoeff > 1) {\n\n            std::string sep = \"+ \";\n            if(coeff[1] < 0.0f) {\n                sep = \" \";\n            }\n\n            ret = fromNumberToString(coeff[0]) + sep;\n\n            for(int i = 1; i < (nCoeff - 1); i++) {\n                if(coeff[i + 1] > 0.0f) {\n                    sep = \"+ \";\n                } else {\n                    sep = \" \";\n                }\n\n                ret += fromNumberToString(coeff[i]) + \" * x^\" + fromNumberToString(i) + sep;\n            }\n\n            ret += fromNumberToString(coeff[nCoeff - 1]) + \" * x^\" + fromNumberToString(nCoeff - 1);\n        } else {\n            ret = fromNumberToString(coeff[0]);\n        }\n        return ret;\n    }\n\n    /**\n     * @brief getArray\n     * @return\n     */\n    float *getArray(float *ret)\n    {\n        if(ret == NULL) {\n            ret = new float[coeff.size()];\n        }\n\n        for(unsigned int i = 0; i < coeff.size(); i++) {\n            ret[i] = coeff[i];\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief clone\n     * @return\n     */\n    Polynomial clone()\n    {\n        Polynomial out;\n\n        for(unsigned int i = 0; i < coeff.size(); i++) {\n            out.coeff.push_back(coeff[i]);\n        }\n\n        out.update();\n        return out;\n    }\n\n    /**\n     * @brief eval\n     * @param x\n     * @return\n     */\n    float eval(float x)\n    {\n        float val = 0.f;\n        float M = 1.f;\n        for (const float &c : coeff) {\n            val += c * M;\n            M *= x;\n        }\n        return val;\n    }\n\n    /**\n     * @brief dEval\n     * @param t\n     * @return\n     */\n    float dEval(float x)\n    {\n        int nCoeff = int(coeff.size());\n\n        if(nCoeff == 0) {\n            return FLT_MAX;\n        }\n\n        if(nCoeff == 1) {\n            return 0.0f;\n        }\n\n        float ret = d_coeff[nCoeff - 1];\n\n        for(int i = (nCoeff - 2); i > 0 ; i--) {\n            ret *= x;\n            ret += d_coeff[i];\n        }\n        return ret;\n    }\n\n    /**\n     * @brief fit\n     * @param x\n     * @param y\n     * @param n\n     */\n    void fit(std::vector<float> &x, std::vector<float> &y, int n)\n    {\n#ifndef PIC_DISABLE_EIGEN\n        if(n < 1 || (x.size() != y.size())) {\n            return;\n        }\n\n        coeff.clear();\n\n        int np1 = n + 1;\n\n        int s = int(x.size());\n        Eigen::MatrixXf A(s, np1);\n        Eigen::VectorXf b(s);\n\n        for(int i = 0; i < s; i++) {\n            b(i) = y[i];\n            A(i, n) = 1.0f;\n        }\n\n        for(int j = (n - 1); j >= 0; j--) {\n            for(int i = 0; i < s; i++) {\n                A(i, j) = x[i] * A(i, j + 1);\n            }\n        }\n\n        Eigen::VectorXf _x = A.colPivHouseholderQr().solve(b);\n\n        for(int i = n; i >= 0; i--) {\n            coeff.push_back(_x(i));\n        }\n#endif\n    }\n\n    /**\n     * @brief normalForm\n     */\n    void normalForm()\n    {\n        int last = int(coeff.size()) - 1;\n\n        if(fabsf(coeff[last]) > 0.0f) {\n\n            for(int i = 0; i < last; i++) {\n                coeff[i] /= coeff[last];\n            }\n\n            coeff[last] = 1.0f;\n        }\n    }\n\n    /**\n     * @brief changeSign\n     */\n    void changeSign()\n    {\n        for(unsigned int i = 0; i < coeff.size(); i++) {\n            coeff[i] = -coeff[i];\n        }\n    }\n\n    /**\n     * @brief inversePoly\n     */\n    void inversePoly()\n    {\n        std::reverse(coeff.begin(), coeff.end());\n    }\n\n    /**\n     * @brief negativePoly\n     */\n    void negativePoly()\n    {\n        for(unsigned int i = 1; i < coeff.size(); i+=2) {\n            coeff[i] = -coeff[i];\n        }\n        changeSign();\n    }\n\n    /**\n     * @brief horner\n     * @param d\n     * @param remainder\n     * @return\n     */\n    Polynomial horner(float d, float &remainder)\n    {\n        int nCoeff = int(coeff.size());\n        Polynomial p(nCoeff - 1);\n\n        p.coeff[nCoeff - 2] = coeff[nCoeff - 1];\n\n        for(int i = (nCoeff - 3); i >= 0 ; i--) {\n            p.coeff[i] = (p.coeff[i + 1] * d + coeff[i + 1]);\n        }\n\n        p.computeAllPositiveCoeff();\n\n        remainder = coeff[0] + p.coeff[0] * d;\n\n        return p;\n    }\n\n    /**\n     * @brief getUpperBoundRootsLagrange\n     * @return\n     */\n    float getUpperBoundRootsLagrange()\n    {\n        if(coeff.empty()) {\n            return FLT_MAX;\n        }\n\n        int n =  int(coeff.size()) - 1;\n\n        if((n == 0) || (coeff[n] == 0.0f)) {\n            return FLT_MAX;\n        }\n\n        float upper_bound = 1.0f;\n\n        for(int i = 0; i < n; i++) {\n            upper_bound = MAX(upper_bound, fabsf(coeff[i] / coeff[n]));\n        }\n\n        return upper_bound;\n    }\n\n    /**\n     * @brief getUpperBoundRootsLagrange\n     * @return\n     */\n    float getUpperBoundRootsCauchy()\n    {\n        if(coeff.empty()) {\n            return FLT_MAX;\n        }\n\n        int n = int(coeff.size()) - 1;\n\n        if((n == 0) || (coeff[n] == 0.0f)) {\n            return FLT_MAX;\n        }\n\n        float upper_bound = 0.0f;\n\n        for(int i = 0; i < n; i++) {\n            upper_bound = MAX(upper_bound, fabsf(coeff[i] / coeff[n]));\n        }\n\n        return upper_bound + 1.0f;\n    }\n\n    /**\n     * @brief getNegativeLowerBoundRoots\n     * @return\n     */\n    float getNegativeLowerBoundRoots()\n    {\n        Polynomial tmp = clone();\n        tmp.negativePoly();\n        return -tmp.getUpperBoundRoots();\n    }\n\n    /**\n     * @brief getNegativeUpperBoundRoots\n     * @return\n     */\n    float getNegativeUpperBoundRoots()\n    {\n        Polynomial tmp = clone();\n        tmp.inversePoly();\n        tmp.negativePoly();\n        return -1.0f / tmp.getUpperBoundRoots();\n    }\n\n    /**\n     * @brief getUpperBoundRoots\n     * @return\n     */\n    float getPositiveLowerBoundRoots()\n    {\n        Polynomial tmp = clone();\n        tmp.inversePoly();\n        return 1.0f / tmp.getUpperBoundRoots();\n    }\n\n    /**\n     * @brief getUpperBoundRoots\n     * @return\n     */\n    float getUpperBoundRoots()\n    {\n        float lambda = 0.0f;\n\n        int n = int(coeff.size()) - 1;\n        for(unsigned int i = 0; i < coeff.size(); i++) {\n            if((coeff[i] < 0.0f) && (coeff[i] < lambda)) {\n                lambda = coeff[i];\n            }\n        }\n        lambda = fabsf(lambda);\n\n        return 1.0f + lambda / fabsf(coeff[n]);\n    }\n\n    /**\n     * @brief getRoots\n     * @param x\n     * @return\n     */\n    bool getRoots(float *x)\n    {\n        int nCoeff = int(coeff.size());\n\n        if(nCoeff < 2) {\n            return false;\n        }\n\n        if(nCoeff == 2) {\n            //this coefficient may be not positive\n            if(coeff[1] > 0.0f) {\n                x[0] = -coeff[0] / coeff[1];\n                return true;\n            } else {\n                return false;\n            }\n        }\n\n        if(nCoeff == 3) {\n            //these coefficients may be not positive\n            return getSecondOrderRoots(coeff[2], coeff[1], coeff[0], &x[0], &x[1]);\n        }\n\n        if(all_coeff_positive) {\n            return false;\n        }\n\n        return getRootsNetwonHorner(x);\n\n    }\n\n    /**\n     * @brief getAllRoots\n     * @param x\n     * @return\n     */\n    bool getAllRoots(float *x)\n    {\n        int nCoeff = int(coeff.size());\n        for(int i = 0; i < nCoeff - 1; i++) {\n            x[i] = FLT_MAX;\n        }\n\n        bool bOut = getRoots(&x[0]);\n\n        if(!bOut) {\n            return false;\n        }\n\n        float r;\n        Polynomial p = horner(x[0], r);\n        p.normalForm();\n\n        for(int i = 1; i < (nCoeff - 2); i++) {\n            bool bOut = p.getRoots(&x[i]);\n\n            if(!bOut) {\n                return true;\n            }\n\n            p = p.horner(x[i], r);\n            p.normalForm();\n        }\n\n        return true;\n    }\n\n    /**\n     * @brief getQuarticRoots --> MANDATORY p[5] == 1.0\n     * @param p\n     * @param x\n     * @return\n     */\n    static bool getQuarticRoots(float *p, float *x)\n    {\n#ifndef PIC_DISABLE_EIGEN\n        Eigen::Matrix4d m;\n\n        m << -p[3], -p[2], -p[1], -p[0],\n             1.0f, 0.0f, 0.0f, 0.0f,\n             0.0f, 1.0f, 0.0f, 0.0f,\n             0.0f, 0.0f, 1.0f, 0.0f;\n\n        Eigen::EigenSolver<Eigen::Matrix4d> es(m);\n        Eigen::Vector4cd e = es.eigenvalues();\n\n        bool bOut = false;\n\n        for (int i = 0; i < 4; i++) {\n            double e_img = e(i).imag();\n            if (fabs(e_img) <= 0.0) {\n                x[i] = float(e(i).real());\n                bOut = true;\n            }\n        }\n\n        return bOut;\n#else\n        return true;\n#endif\n    }\n\n    /**\n     * @brief getSecondOrderRoots solves second order equations, ax^2 + b x + c = 0\n     * @param a is the a coefficient\n     * @param b is the b coefficient\n     * @param c is the c coefficient\n     * @param x0 is the first zero\n     * @param x1 is the second zero\n     * @return It returns true, if x0 and x1 have a real value, false otherwise\n     */\n    static bool getSecondOrderRoots(float a, float b, float c, float *x0, float *x1)\n    {\n        float delta = b * b - 4.0f * a * c;\n\n        if(delta >= 0.0f) {\n            float dnum = 2.0f * a;\n            delta = sqrtf(delta);\n            *x0 = (-b + delta) / dnum;\n            *x1 = (-b - delta) / dnum;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @brief getSecondOrderRootsS solves second order equations, ax^2 + 2 b x + c = 0; i.e., 2 b is even!\n     * @param a is the a coefficient\n     * @param b is the b coefficient\n     * @param c is the c coefficient\n     * @param x0 is the first zero\n     * @param x1 is the second zero\n     * @return It returns true, if x0 and x1 have a real value, false otherwise\n     */\n    static bool getSecondOrderRootsS(float a, float b, float c, float *x0, float *x1)\n    {\n        float delta = b * b - a * c;\n        if(delta >= 0.0f) {\n            delta = sqrtf(delta);\n            *x0 = (-b + delta) / a;\n            *x1 = (-b - delta) / a;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n\n};\n\n} // end namespace pic\n\n#endif //PIC_UTIL_coeffNOMIAL_HPP\n"
  },
  {
    "path": "include/util/precomputed_diff_of_gaussians.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_PRECOMPUTED_DIFF_OF_GAUSSIANS_HPP\n#define PIC_UTIL_PRECOMPUTED_DIFF_OF_GAUSSIANS_HPP\n\n#include \"../util/precomputed_gaussian.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The PrecomputedDiffOfGaussians class\n */\nclass  PrecomputedDiffOfGaussians\n{\nprotected:\n    /**\n     * @brief precomputeCoefficients precomputes a Gaussian kernel.\n     */\n    void precomputeCoefficients()\n    {\n        halfKernelSize = kernelSize >> 1;\n        kernelSize = (halfKernelSize << 1) + 1;\n        coeff = new float[kernelSize];\n\n        float sigma1_sq = sigma1 * sigma1;\n        float sigma1_sq_2 = sigma1_sq * 2.0f;\n\n        float sigma2_sq = sigma2 * sigma2;\n        float sigma2_sq_2 = sigma2_sq * 2.0f;\n\n        float C1 = sigma1 * sqrtf(2.0f * C_PI);\n        float C2 = sigma2 * sqrtf(2.0f * C_PI);\n\n        for(int i = 0; i < kernelSize; i++) {\n            int i_s = i - halfKernelSize;\n            float i_sq_f = -float(i_s * i_s);\n\n            float G1 = expf(i_sq_f / sigma1_sq_2) / C1;\n            float G2 = expf(i_sq_f / sigma2_sq_2) / C2;\n\n            coeff[i] = G1 - G2;\n        }\n    }\n\npublic:\n    float sigma1, sigma2;\n    int\t  kernelSize, halfKernelSize;\n    float *coeff;\n\n    /**\n     * @brief PrecomputedDiffOfGaussians\n     */\n    PrecomputedDiffOfGaussians()\n    {\n        kernelSize = halfKernelSize = 0;\n        sigma1 = 0.0f;\n        sigma2 = 0.0f;\n        coeff = NULL;\n    }\n\n    /**\n     * @brief PrecomputedDiffOfGaussians\n     * @param sigma1\n     * @param sigma2\n     */\n    PrecomputedDiffOfGaussians(float sigma1, float sigma2)\n    {\n\n        calculateKernel(sigma1, sigma2);\n    }\n\n    ~PrecomputedDiffOfGaussians()\n    {\n        delete[] coeff;\n    }\n\n    /**\n     * @brief calculateKernel computes a Gaussian kernel of size sigma\n     * @param sigma\n     */\n    void calculateKernel(float sigma1, float sigma2)\n    {\n        this->sigma1 = sigma1;\n        this->sigma2 = sigma2;\n\n        //compute the sigma for the size of the kernel\n        kernelSize = PrecomputedGaussian::getKernelSize(MAX(sigma1, sigma2));\n\n        //precompute Gaussian coefficients\n        precomputeCoefficients();\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_PRECOMPUTED_DIFF_OF_GAUSSIANS_HPP */\n\n"
  },
  {
    "path": "include/util/precomputed_gaussian.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_PRECOMPUTED_GAUSSIAN_HPP\n#define PIC_UTIL_PRECOMPUTED_GAUSSIAN_HPP\n\nnamespace pic {\n\n#include <math.h>\n\n#include \"../util/array.hpp\"\n\n/**\n * @brief The PrecomputedGaussian class\n */\nclass  PrecomputedGaussian\n{\nprotected:\n    /**\n     * @brief precomputeCoefficients precomputes a Gaussian kernel.\n     */\n    void precomputeCoefficients()\n    {\n        halfKernelSize = kernelSize >> 1;\n        kernelSize = (halfKernelSize << 1) + 1;\n\n        delete[] coeff;\n        coeff = new float[kernelSize];\n\n        float sigma_sq_2 = (2.0f * sigma * sigma);\n\n        float sum = 0.0f;\n        for(int i = 0; i < kernelSize; i++) {\n            int i_s = i - halfKernelSize;\n            i_s *= i_s;\n            coeff[i] = expf(-float(i_s) / sigma_sq_2);\n            sum += coeff[i];\n        }\n\n        //normalize the kernel\n        if(sum > 0.0f) {\n            Arrayf::div(coeff, kernelSize, sum);\n        }\n    }\n\npublic:\n    float sigma;\n    int\t  kernelSize, halfKernelSize;\n    float *coeff;\n\n    /**\n     * @brief PrecomputedGaussian\n     */\n    PrecomputedGaussian()\n    {\n        kernelSize = halfKernelSize = 0;\n        sigma = 0.0f;\n        coeff = NULL;\n    }\n\n    /**\n     * @brief PrecomputedGaussian\n     * @param sigma\n     */\n    PrecomputedGaussian(float sigma)\n    {\n        coeff = NULL;\n        calculateKernel(sigma);\n    }\n\n    ~PrecomputedGaussian()\n    {\n        if(coeff != NULL) {\n            delete[] coeff;\n            coeff = NULL;\n        }\n    }\n\n    /**\n     * @brief calculateKernel computes a Gaussian kernel of size sigma\n     * @param sigma\n     */\n    void calculateKernel(float sigma, int kernelSize = -1)\n    {\n        this->sigma = sigma;\n\n        //the sigma for the size of the kernel\n        if(kernelSize < 3) {\n            this->kernelSize = PrecomputedGaussian::getKernelSize(sigma);\n        } else {\n            this->kernelSize = kernelSize;\n        }\n\n        //precompute Gaussian coefficients\n        precomputeCoefficients();\n    }\n\n    /**\n     * @brief KernelSize computes the size of a kernel in pixel give its sigma.\n     * @param sigma is the sigma value of a Gaussian kernel.\n     * @return It returns the size of the kernel in pixels.\n     */\n    static int getKernelSize(float sigma)\n    {\n        int kernelSize = int(ceilf(sigma * 5.0f));\n        return (kernelSize > 3) ? kernelSize : 3;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_PRECOMPUTED_GAUSSIAN_HPP */\n\n"
  },
  {
    "path": "include/util/rasterizer.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_RASTERIZER_HPP\n#define PIC_UTIL_RASTERIZER_HPP\n\n#include <algorithm>\n#include <cstdlib>\n\n#include \"../base.hpp\"\n#include \"../image.hpp\"\n#include \"../util/vec.hpp\"\n#include \"../util/math.hpp\"\n\n#ifndef PIC_EIGEN_NOT_BUNDLED\n    #include \"../externals/Eigen/Dense\"\n#else\n    #include <Eigen/Dense>\n#endif\n\nnamespace pic {\n\n/**\n * @brief drawLine renders a line (v0, v1) with color into img.\n * @param img is the image where to render the line (v0, v1).\n * @param v0 is the first vertex of the line.\n * @param v1 is the second vertex of the line.\n * @param color is the color of the line (v0, v1).\n */\nPIC_INLINE void drawLine(Image *img, Vec2i v0, Vec2i v1, float *color)\n{\n    if(img == NULL || color == NULL) {\n        return;\n    }\n\n    CLAMP(v0[0], img->width);\n    CLAMP(v1[0], img->width);\n    CLAMP(v0[1], img->height);\n    CLAMP(v1[1], img->height);\n\n    float *data = img->data;\n\n    if(v0[0] > v1[0]) {\n        std::swap(v0, v1);\n    }\n\n    int dx = v1[0] - v0[0];\n    int dy = v1[1] - v0[1];\n\n    //Vertical line\n    if(dx == 0){\n        if(v0[1] > v1[1]) {\n            std::swap(v0, v1);\n        }\n\n        for(int y = v0[1]; y < v1[1]; y++) {\n            int ind = (v0[0] + y * img->width) * img->channels;\n\n            for(int k = 0; k < img->channels; k++) {\n                data[ind + k] = color[k];\n            }\n        }\n        return;\n    }\n\n    //Horizontal line\n    if(dy == 0) {\n        int ind_y = v0[1] * img->width;\n\n        for(int x = v0[0]; x < v1[0]; x++) {\n            int ind = (x + ind_y) * img->channels;\n\n            for(int k = 0; k < img->channels; k++) {\n                data[ind + k] = color[k];\n            }\n        }\n    }\n\n    //General case\n    if(std::abs(dy) < std::abs(dx)) {\n        //m < 1\n        int e = 0;\n        int s;\n        if(dy < 0) {\n            s  = -1;\n            dy = -dy;\n        } else {\n            s = 1;\n        }\n\n        int y = v0[1];\n        for(int x = v0[0]; x <= v1[0]; x++) {\n            int ind = (x + y * img->width) * img->channels;\n\n            for(int k = 0; k < img->channels; k++) {\n                data[ind + k] = color[k];\n            }\n\n            e += dy;\n            if((e << 1) >= dx) {\n              y += s;\n              e -= dx;\n            }\n        }\n    } else {\n        //m > 1\n        if(v0[1] > v1[1]){\n            std::swap(v0, v1);\n        }\n\n        dx = v1[0] - v0[0];\n        dy = v1[1] - v0[1];\n\n        int e = 0;\n        int s;\n        if(dx < 0){\n            s  = -1;\n            dx = -dx;\n        } else {\n            s = 1;\n        }\n\n        int x = v0[0];\n\n        for(int y = v0[1]; y <= v1[1]; y++) {\n\n            int ind = (x + y * img->width) * img->channels;\n\n            for(int k = 0; k < img->channels; k++) {\n                data[ind + k] = color[k];\n            }\n\n            e += dx;\n            if((e << 1) >= dy) {\n              x += s;\n              e -= dy;\n            }\n        }\n    }\n}\n\n/**\n * @brief drawPoints\n * @param img\n * @param points\n */\n#ifndef PIC_DISABLE_EIGEN\nPIC_INLINE void drawPoints(Image *img, std::vector< Eigen::Vector2f > &points, float *color)\n{\n    if(img == NULL) {\n        return;\n    }\n\n    if(color == NULL) {\n        color = new float[img->channels];\n        for(int i = 0; i < img->channels; i++) {\n            color[i] = 1.0f;\n        }\n    }\n\n    for(size_t i = 0; i < points.size(); i++) {\n        int x = int(points[i][0]);\n        int y = int(points[i][1]);\n        float *pixel = (*img)(x, y);\n\n        for(int j = 0; j < img->channels; j++) {\n            pixel[j] = color[j];\n        }\n    }\n}\n#endif\n\n/**\n * @brief evaluateGaussian renders a Gaussian function which is centred\n * in the image.\n * @param img is an input image\n * @param sigma is the standard deviation of the Gaussian function.\n * @param bNormTerm is a boolean value. If it is true the Gaussian function\n * is normalized, false otherwise.\n */\nPIC_INLINE void evaluateGaussian(Image *img, float sigma = -1.0f,\n                                 bool bNormTerm = false)\n{\n    if(img != NULL) {\n        return;\n    }\n\n    if(sigma < 0.0f) {\n        sigma = float(MIN(img->width, img->height)) / 5.0f;\n    }\n\n    float sigma2 = (sigma * sigma * 2.0f);\n\n    int halfWidth  = img->width  >> 1;\n    int halfHeight = img->height >> 1;\n\n    float normTerm = bNormTerm ? sigma * sqrtf(C_PI) : 1.0f ;\n\n    #pragma omp parallel for\n\n    for(int j = 0; j < img->height; j++) {\n        int j_squared = j - halfHeight;\n        j_squared = j_squared * j_squared;\n\n        for(int i = 0; i < img->width; i++) {\n            int i_squared = i - halfWidth;\n            i_squared = i_squared * i_squared;\n\n            float gaussVal = expf(-float(i_squared + j_squared) / sigma2) / normTerm;\n\n            float *tmp_data = (*img)(i, j);\n\n            for(int k = 0; k < img->channels; k++) {\n                tmp_data[k] = gaussVal;\n            }\n        }\n    }\n}\n\n/**\n * @brief evaluateSolid renders a centred circle.\n * @param img is an input image\n */\nPIC_INLINE void evaluateSolid(Image *img)\n{\n    if(img == NULL) {\n        return;\n    }\n\n    int halfWidth  = img->width  >> 1;\n    int halfHeight = img->height >> 1;\n\n    int radius_squared = (halfWidth * halfWidth + halfHeight * halfHeight) >> 1;\n\n    #pragma omp parallel for\n\n    for(int j = 0; j < img->height; j++) {\n        int j_squared = j - halfHeight;\n        j_squared = j_squared * j_squared;\n\n        for(int i = 0; i < img->width; i++) {\n            int i_squared = i - halfWidth;\n            i_squared = i_squared * i_squared;\n\n            float val = 0.0f;\n\n            if((i_squared + j_squared) < radius_squared) {\n                val = 1.0f;\n            }\n\n            float *tmp_data = (*img)(i, j);\n\n            for(int k = 0; k < img->channels; k++) {\n                tmp_data[k] = val;\n            }\n        }\n    }\n}\n\n}\n\n#endif //\n"
  },
  {
    "path": "include/util/raw.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\ncopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_RAW_HPP\n#define PIC_UTIL_RAW_HPP\n\n#include <string>\n#include <iostream>\n#include <vector>\n\n#include \"../base.hpp\"\n#include \"../util/array.hpp\"\n#include \"../util/file_lister.hpp\"\n#include \"../util/string.hpp\"\n\nnamespace pic {\n\nenum RAW_type { RAW_U16_RGGB, RAW_U8_RGGB, RAW_DOUBLE, RAW_FLOAT};\n\ntemplate <class T>\nclass RAW: public Array<T>\n{\nprotected:\n    bool valid;\n\npublic:\n\n    /**\n     * @brief RAW\n     */\n    RAW() : Array<T>()\n    {\n        valid = false;\n    }\n\n    /**\n     * @brief RAW\n     * @param nData\n     */\n    RAW(int n): Array<T>(n)\n    {\n        valid = true;\n    }\n\n    /**\n     * @brief RAW\n     * @param nameFile\n     * @param nData\n     */\n    RAW(std::string nameFile, int nData = -1)\n    {\n        valid = false;\n        this->data = NULL;\n        nData = 0;\n\n        Read(nameFile, nData);\n    }\n\n    ~RAW()\n    {\n        this->release();\n    }\n\n    /**\n     * @brief Read\n     * @param nameFile\n     * @param nData\n     * @return\n     */\n    bool Read(std::string nameFile, int nData)\n    {\n        std::ifstream file;\n        file.open(nameFile.c_str(), std::ios::in | std::ios::binary);\n\n        if(!file.is_open()) {\n            return false;\n        }\n\n        //Calculate length of the file\n        file.seekg(0, std::ios::end);\n        std::streampos length = file.tellg();\n        file.seekg(0, std::ios::beg);\n\n        if(nData < 1) {\n            nData = length / sizeof(T);\n        }\n\n        this->allocate(nData);\n\n        file.read((char *)this->data, this->nData * sizeof(T) / sizeof(char));\n        file.close();\n\n        valid = true;\n        return true;\n    }\n\n    /**\n     * @brief Write\n     * @param nameFile\n     * @return\n     */\n    bool Write(std::string nameFile)\n    {\n        std::ofstream file;\n        file.open(nameFile.c_str(), std::ios::binary);\n\n        if(file.is_open()) {\n            file.write((char *)this->data, this->nData * sizeof(T) / sizeof(char));\n            file.close();\n            valid = true;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @brief getMeanRAWStack\n     * @param stack\n     * @return\n     */\n    static RAW<T> *getMeanRAWStack(std::vector<RAW<T> > &stack)\n    {\n        if(stack.size() <= 0) {\n            return NULL;\n        }\n\n        int nData = stack[0].nData;\n        RAW<T> *dataOut = new RAW<T>();\n        dataOut->data = new T[nData];\n        dataOut->nData = nData;\n\n        int stackSize = stack.size();\n\n        for(int i = 0; i < nData; i++) {\n            unsigned long tmpData = 0;\n\n            for(int j = 0; j < stackSize; j++) {\n                tmpData += stack[j].data[i];\n            }\n\n            dataOut->data[i] = tmpData / stackSize;\n        }\n\n        dataOut->valid = true;\n        return dataOut;\n    }\n\n    static unsigned long *getMeanRAWIterative(RAW<T> *img,\n            unsigned long *dataAcc, bool bStart)\n    {\n\n        if(dataAcc == NULL) {\n            dataAcc = new unsigned long[img->nData];\n        }\n\n        if(bStart) {\n            for(int i = 0; i < img->nData; i++) {\n                dataAcc[i] = img->data[i];\n            }\n        } else {\n            for(int i = 0; i < img->nData; i++) {\n                dataAcc[i] += img->data[i];\n            }\n        }\n\n        return dataAcc;\n    }\n\n    /**\n     * @brief getMeanRAWFromFile\n     * @param nameDir\n     * @param nameFilter\n     * @param width\n     * @param height\n     * @return\n     */\n    static RAW<T> *getMeanRAWFromFile(\n        std::string nameDir,\n        std::string nameFilter,\n        int width,\n        int height)\n    {\n        StringVec vec;\n\n        FileLister::getList(nameDir, nameFilter, &vec);\n\n        RAW<T> imgRAW;\n        unsigned long *dataAcc = NULL;\n\n        for(unsigned int i = 0; i < vec.size(); i++) {\n            imgRAW.Read(vec[i], width * height);\n            dataAcc = getMeanRAWIterative(&imgRAW, dataAcc, i == 0);\n        }\n\n        RAW<T> *imgOut = imgRAW.copy();\n\n        for(int i = 0; i < imgOut->nData; i++) {\n            imgOut->data[i] = dataAcc[i] / vec.size();\n        }\n\n        return imgOut;\n    }\n\n    /**\n     * @brief getMeanRAWFromFile\n     * @param nameDir\n     * @param nameFilter\n     * @param nameOut\n     * @param width\n     * @param height\n     */\n    static void getMeanRAWFromFile(\n        std::string nameDir,\n        std::string nameFilter,\n        std::string nameOut,\n        int width,\n        int height)\n    {\n        (getMeanRAWFromFile(nameDir, nameFilter, width,\n                            height))->Write(nameOut);\n    }\n};\n\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_RAW_HPP */\n\n"
  },
  {
    "path": "include/util/std_util.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_STD_UTIL_HPP\n#define PIC_UTIL_STD_UTIL_HPP\n\n#include <vector>\n\nnamespace pic {\n\n/**\n * @brief filterInliers\n * @param vec\n * @param inliers\n * @param vecOut\n */\ntemplate<class T>\ninline void filterInliers(std::vector< T > &vec, std::vector< unsigned int > &inliers, std::vector< T > &vecOut)\n{\n    vecOut.clear();\n\n    if(!inliers.empty()) {\n        for(unsigned int i = 0; i < inliers.size(); i++) {\n            vecOut.push_back(vec[inliers[i]]);\n        }\n    } else {\n        vecOut.assign(vec.begin(), vec.end());\n    }\n}\n\n/**\n * @brief stdVectorClear\n * @param vec\n */\ntemplate<class T>\ninline void stdVectorClear(std::vector<T *> &vec)\n{\n    for(unsigned int i = 0; i < vec.size(); i++) {\n        T *tmp = vec[i];\n        delete tmp;\n\n        vec[i] = NULL;\n    }\n\n    vec.clear();\n}\n\n\n/**\n * @brief stdVectorArrayClear\n * @param vec\n */\ntemplate<class T>\ninline void stdVectorArrayClear(std::vector<T *> &vec)\n{\n    for(unsigned int i = 0; i < vec.size(); i++) {\n        T *tmp = vec[i];\n        delete[] tmp;\n    }\n\n    vec.clear();\n}\n\n/**\n * @brief setToANullVector\n * @param vec\n * @param n\n */\ntemplate<class T>\ninline void setToANullVector(std::vector< T* > &vec, unsigned int n)\n{\n    if(!vec.empty()) {\n        return;\n    }\n\n    for(unsigned int i = 0; i < n; i++) {\n        vec.push_back(NULL);\n    }\n}\n\n/**\n * @brief release\n * @param data\n * @return\n */\ntemplate<class T>\ninline T* releasePtr(T *data)\n{\n    delete data;\n    data = NULL;\n    return data;\n}\n\n/**\n * @brief delete_s\n * @param data\n * @return\n */\ntemplate<class T>\ninline T* delete_s(T *data)\n{\n    delete data;\n    data = NULL;\n    return data;\n}\n\n/**\n * @brief delete_vec_s\n * @param data\n * @return\n */\ntemplate<class T>\ninline T* delete_vec_s(T *data)\n{\n    delete[] data;\n    data = NULL;\n    return data;\n}\n\n\n} // end namespace pic\n\n#endif // PIC_UTIL_STD_UTIL_HPP\n"
  },
  {
    "path": "include/util/string.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_STRING_HPP\n#define PIC_UTIL_STRING_HPP\n\n#include <vector>\n#include <cstring>\n#include <string>\n#include <sstream>\n#include <iostream>\n#include <fstream>\n\n#include \"../base.hpp\"\n\n\n#ifdef PIC_WIN32\n    #include <direct.h>\n#endif\n\n#ifndef PIC_WIN32\n    #include <unistd.h>\n#endif\n\n\nnamespace pic {\n\n/**\n*@brief MAKE_STRING creates a string from a block.\n*/\n#define MAKE_STRING(input_string) #input_string\n\n/**\n * @brief StringVec is an std::vector of std::string.\n */\ntypedef std::vector<std::string > StringVec;\n\n/**\n * @brief stdStringRep replaces strSub in str with strRep just once.\n * @param str is the input string.\n * @param strSub is the substring to find in str.\n * @param strRep is the string for replacing strSub.\n * @return It returns str where strSub is replaced with strRep.\n */\ninline std::string stdStringRep(std::string str, std::string strSub,\n                                std::string strRep)\n{\n    std::string ret = str;\n\n    size_t found = ret.find(strSub);\n\n    if(found != std::string::npos) {\n        ret.replace(found, strRep.length(), strRep);\n    }\n\n    return ret;\n}\n\n/**\n * @brief stdStringRepAll replaces all strSub in str with strRep.\n * @param str\n * @param strSub\n * @param strRep\n * @return\n */\ninline std::string stdStringRepAll(std::string str, std::string strSub,\n                                   std::string strRep)\n{\n    auto n_sub = strSub.size();\n    auto n_rep = strRep.size();\n\n    std::string ret = str;\n    std::string::size_type pos = ret.find(strSub);\n\n    while(pos != std::string::npos) {\n        ret.replace(pos, n_sub, strRep);\n\n        pos = ret.find(strSub, pos + 1 - n_sub + n_rep);\n    }\n\n    return ret;\n}\n\n/**\n * @brief fromNumberToString converts a number into a string.\n * @param num is an input number.\n */\ntemplate<class T>\ninline std::string fromNumberToString(T num)\n{\n    std::ostringstream convert;\n    convert << num;\n    return convert.str();\n}\n\n/**\n * @brief getSeparatorChar returns the folder separator in path as a char.\n * @param path\n * @return\n */\ninline char getSeparatorChar(std::string path)\n{\n    if(path.find(\"/\") != std::string::npos) {\n        return '/';\n    } else {\n        if(path.find(\"\\\\\") != std::string::npos) {\n            return '\\\\';\n        } else {\n            return '/';\n        }\n    }\n}\n\n/**\n * @brief RemoveExtension removes the extension of a string.\n * @param name\n * @return\n */\ninline std::string removeExtension(std::string name)\n{\n    std::string tmp(name);\n    std::reverse(tmp.begin(), tmp.end());\n\n    size_t pos = tmp.find(\".\");\n\n    if(pos != std::string::npos) {\n        name.erase(name.end() - pos - 1, name.end());\n    }\n\n    return name;\n}\n\n/**\n * @brief removeLocalPath removes the local path of a string.\n * @param name\n * @return\n */\ninline std::string removeLocalPath(std::string name)\n{\n    std::string toFind(1, getSeparatorChar(name));\n\n    if(toFind.empty()) {\n        return name;\n    } else {\n        size_t oldPos;\n        size_t pos = 0;\n        do{\n            oldPos = pos;\n            pos = name.find(toFind, pos + 1);\n        } while(pos != std::string::npos);\n\n        name.erase(0, oldPos + 1);\n    }\n\n    return name;\n}\n\n/**\n * @brief getFileNameOnly\n * @param name is the input name with global/local path and extension\n * @return it returns ONLY the file name without path\n */\ninline std::string getFileNameOnly(std::string name)\n{\n    return removeLocalPath(removeExtension(name));\n}\n\n/**\n * @brief getExtension gets the extension of a file name.\n * @param name\n * @return\n */\ninline std::string getExtension(std::string name)\n{\n    std::string tmp(name);\n    std::reverse(tmp.begin(), tmp.end());\n\n    size_t pos = tmp.find(\".\");\n    std::string ext = \"\";\n\n    if(pos != std::string::npos) {\n        auto n = name.length() - pos;\n        ext = name.substr(n, n);\n    }\n\n    return ext;\n}\n\n/**\n * @brief addSuffix adds a suffix to a file name.\n * @param name\n * @param suffix\n * @return\n */\ninline std::string addSuffix(std::string name, std::string suffix)\n{\n    std::string tmp = removeExtension(name);\n    std::string tmpExt = getExtension(name);\n    return tmp + suffix + \".\" + tmpExt;\n}\n\n/**\n * @brief replaceExtension changes .format in a file name.\n * @param nameOut\n * @param fmtIn\n * @param fmtOut\n * @return\n */\ninline std::string replaceExtension(std::string nameOut, std::string fmtIn,\n                                std::string fmtOut)\n{\n    size_t found = nameOut.find(fmtIn);\n\n    if(found != std::string::npos) {\n        nameOut.replace(nameOut.begin() + found, nameOut.end(), fmtOut);\n    }\n\n    return nameOut;\n}\n\n/**\n * @brief countSubString counts how many subStr are in str.\n * @param str is the input string.\n * @param subStr is the substring to count in str.\n * @return the number of times subStr appears in str.\n */\ninline int countSubString(std::string str, std::string subStr)\n{\n    int count = 0;\n\n    std::string::size_type pos = str.find(subStr);\n\n    while(pos != std::string::npos) {\n        count++;\n        pos = str.find(subStr, pos + 1);\n    }\n\n    return count;\n}\n\n/**\n * @brief getLocaDirectory gets local path.\n * @param path\n * @return\n */\ninline std::string getLocaDirectory(std::string path)\n{\n    std::string ret = path;\n\n    std::string toFind(1, getSeparatorChar(path));\n\n    if(toFind.empty()) {\n        return ret;\n    }\n\n    size_t pos1 = path.rfind(toFind);\n\n    if(pos1 != std::string::npos) {\n        ret = path.substr(0, pos1);\n        size_t pos2 = ret.rfind(toFind);\n\n        if(pos2 != std::string::npos) {\n            return ret.substr(pos2 + 1, ret.length());\n        }\n    }\n\n    return ret;\n}\n\n/**\n * @brief getSeparator returns the folder separator in path as a string\n * @param path\n * @return\n */\ninline std::string getSeparator(std::string path)\n{\n    char sepChar = getSeparatorChar(path);\n    std::string strOut;\n    return strOut + sepChar;\n}\n\n/**\n * @brief getFolderName gets the folder name from the path.\n * @param path\n * @return\n */\ninline std::string getFolderName(std::string path)\n{\n    size_t found = path.find_last_of(getSeparator(path));\n\n    if(found != std::string::npos) {\n        return path.substr(0, found);\n    } else {\n        return \"./\";\n    }\n}\n\n/**\n * @brief getFileName gets the file name.\n * @param path\n * @return\n */\ninline std::string getFileName(std::string path)\n{\n    std::string toFind;\n    std::string ret = path;\n\n    if(path.find(\"/\") != std::string::npos) {\n        toFind = \"/\";\n    } else {\n        if(path.find(\"\\\\\") != std::string::npos) {\n            toFind = \"\\\\\";\n        } else {\n            return ret;\n        }\n    }\n\n    size_t pos = path.rfind(toFind);\n\n    if(pos != std::string::npos) {\n        ret = path.substr(pos + 1, path.length());\n        return ret;\n    }\n\n    return ret;\n}\n\n/**\n * @brief parseStringToStdVector\n * @param str\n * @param delim\n * @param str_vec\n */\ninline void parseStringToStdVector(std::string str, char delim,\n                                   StringVec *str_vec)\n{\n    std::stringstream ss(str);\n\n    while(!ss.eof()) {\n        std::string tmpStr;\n        std::getline(ss, tmpStr, delim);\n        str_vec->push_back(tmpStr);\n    }\n}\n\n/**\n * @brief genBilString\n * @param type\n * @param sigma_s\n * @param sigma_r\n * @return\n */\ninline std::string genBilString(std::string type, float sigma_s,\n                                    float sigma_r)\n{\n    std::string ret = type +\n            \"_Ss_\" + fromNumberToString(sigma_s) +\n            \"_Sr_\" + fromNumberToString(sigma_r);\n    return ret;\n}\n\n/**\n * @brief fromFileToStdString writes a file into a std::string.\n * @param nameFile\n * @return\n */\ninline std::string fromFileToStdString(std::string nameFile)\n{\n    std::ifstream infile;\n    infile.open(nameFile.c_str(), std::ios::in);\n\n    std::string ret;\n\n    if((!infile.is_open()) || (!infile.good())) {\n        return ret;\n    }\n\n    int c = infile.get();\n    while (infile.good()) {\n        ret += c;\n        c = infile.get();\n    }\n\n    infile.close();\n\n    return ret;\n}\n\n/**\n * @brief checkAbsolutePath checks if the path is absolute or not.\n * @param path\n * @return\n */\ninline bool checkAbsolutePath(std::string path)\n{\n    //win32 absolute path\n    if(path.find(\":\\\\\") != std::string::npos) {\n        return true;\n    }\n\n    if(path.find(\":/\") != std::string::npos) {\n        return true;\n    }\n\n    if(path.find(\"\\\\\\\\\\\"\") != std::string::npos) {\n        return true;\n    }\n\n    //unix/mac path\n    return (path.at(0) == '/');\n}\n\n/**\n * @brief fromStdStringToChar converts from a std::string to a char*.\n * @param str\n * @return\n */\ninline char *fromStdStringToChar(std::string str)\n{\n    char *cstr = new char [str.size() + 1];\n    strcpy (cstr, str.c_str());\n    return cstr;\n}\n\n/**\n * @brief checkPath\n * @param name\n * @return\n */\ninline std::string checkPath(std::string name)\n{\n    if(name.length() < 3) {\n        return \"\";\n    }\n\n    if((name.at(0) == '.') && (name.at(0) == '.')) {\n        #ifdef PIC_WIN32\n            char *path = _getcwd(NULL, 0);\n        #endif\n\n        #ifndef PIC_WIN32\n            char *path = getcwd(NULL, 0);\n        #endif\n\n        std::string dsepName = getSeparator(name);\n        std::string dsepPath = getSeparator(path);\n\n        name = stdStringRepAll(name, dsepName, dsepPath);\n        if(name.at(2) == '\\\\' || name.at(2) == '/') {\n            name = name.substr(3);\n        } else {\n            name = name.substr(2);\n        }\n\n        std::string newPath  = path + dsepPath + name;\n        return newPath;\n    } else {\n        return \"\";\n    }\n}\n\n/**\n * @brief adjustPath modifies the path if it is not global.\n * @param nameFile\n * @param pathFolder\n * @return\n */\nPIC_INLINE std::string adjustPath(std::string nameFile, std::string pathFolder)\n{\n    if(!checkAbsolutePath(nameFile)) {\n        std::string fullPath = checkPath(nameFile);\n\n        if(fullPath.empty()) {\n            std::string ret = pathFolder + getSeparator(pathFolder) + nameFile;\n            return ret;\n        } else {\n            return fullPath;\n        }\n    } else {\n        return nameFile;\n    }\n}\n\n/**\n * @brief removeInitialSpaces removes spaces at the beginning of a string.\n * @param name\n * @return\n */\ninline std::string removeInitialSpaces(char name[])\n{\n    size_t pos;\n    std::string ret = name;\n\n    pos = ret.find(' ');\n    ret.erase(pos, 1);\n\n    pos = ret.find('\\n');\n    ret.erase(pos, 1);\n\n    return ret;\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_STRING_HPP */\n\n"
  },
  {
    "path": "include/util/tile.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_TILE_HPP\n#define PIC_UTIL_TILE_HPP\n\n#include <string>\n\n#include \"../base.hpp\"\n\n#include \"../image.hpp\"\n#include \"../util/bbox.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The Tile class\n */\nclass Tile\n{\npublic:\n    int startX, startY;\n    int width,  height;\n    std::string name;\n    Image *tile;\n\n    /**\n     * @brief Tile\n     */\n    Tile()\n    {\n        startX = -1;\n        startY = -1;\n        width  = -1;\n        height = -1;\n        name = \"\";\n        tile = NULL;\n    }\n\n    ~Tile()\n    {\n        delete tile;\n    }\n\n    /**\n     * @brief getBBox\n     * @param img_width\n     * @param img_height\n     * @return\n     */\n    BBox getBBox(int img_width, int img_height)\n    {\n        BBox ret;\n        ret.setBox(startX,\n                   startX + width,\n                   startY,\n                   startY + height,\n                    0, 1, img_width, img_height, 1);\n        return ret;\n    }\n};\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_TILE_HPP */\n\n"
  },
  {
    "path": "include/util/tile_list.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_TILE_LIST_HPP\n#define PIC_UTIL_TILE_LIST_HPP\n\n#include <thread>\n#include <mutex>\n#include <vector>\n\n#include \"../base.hpp\"\n#include \"../util/tile.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The TileList class\n */\nclass TileList\n{\nprotected:\n    uint counter;\n\n#ifndef PIC_DISABLE_THREAD\n    std::mutex mutex;\n#endif\n\npublic:\n    int width, height;\n    int h_tile, w_tile;\n    int mod_h, mod_w;\n\n    /**\n     * @brief tiles a list of tiles\n     */\n    std::vector<Tile> tiles;\n\n    /**\n     * @brief TileList basic constructor\n     */\n    TileList();\n\n    /**\n     * @brief TileList creates a list of tiles.\n     * @param tileSize is the width and height of a tile in pixels.\n     * @param width is the horizontal size of the original image in pixels.\n     * @param height is the vertical size of the original image in pixels.\n     */\n    TileList(int tileSize, int width, int height);\n\n    ~TileList();\n\n    /**\n     * @brief genBBox\n     * @param index\n     * @return\n     */\n    BBox getBBox(int index);\n\n    /**\n     * @brief getNext returns the index of the next tile to process.\n     * @return This function returns the index of the next tile to proces.\n     */\n    uint getNext();\n\n    /**\n     * @brief size\n     * @return\n     */\n    uint size();\n\n    /**\n     * @brief resetCounter sets the counter to zero.\n     */\n    void resetCounter();\n\n    /**\n     * @brief Create creates a list of tiles.\n     * @param tileSize is the width and height of a tile in pixels.\n     * @param width is the horizontal size of the original image in pixels.\n     * @param height is the vertical size of the original image in pixels.\n     */\n    void create(int tileSize, int width, int height);\n\n    /**\n     * @brief read loads a TileList from a file.\n     * @param name is the file name.\n     * @param flag is a boolean value. If it is true, this loads\n     * an Image from the tile name. Otherwise, an Image of the tile\n     * size is allocated.\n     * @return This function returns true if it is successfull.\n     */\n    bool read(std::string name, bool flag);\n\n    /**\n     * @brief write saves a TileList into a file.\n     * @param name is the file name\n     * @return This function returns true if it is successfull.\n     */\n    bool write(std::string name);\n\n    /**\n     * @brief writeIntoMemory copies tiles inside an output image.\n     * @param output is the Image where tiles will be copied to.\n     */\n    void writeIntoMemory(Image *output);\n};\n\nPIC_INLINE TileList::TileList()\n{\n    counter = 0;\n\n    w_tile = 0;\n    h_tile = 0;\n\n    mod_h = 0;\n    mod_w = 0;\n}\n\nPIC_INLINE TileList::TileList(int tileSize, int width, int height)\n{\n    counter = 0;\n    create(tileSize, width, height);\n}\n\nPIC_INLINE TileList::~TileList()\n{\n    tiles.clear();\n}\n\nPIC_INLINE BBox TileList::getBBox(int index)\n{\n    int i = index % tiles.size();\n\n    return tiles[i].getBBox(width, height);\n}\n\nPIC_INLINE uint TileList::getNext()\n{\n    uint ret = 0;\n    {\n#ifndef PIC_DISABLE_THREAD\n        std::lock_guard<std::mutex> lock(mutex);\n#endif\n        ret = counter;\n        counter++;\n    }\n    return ret;\n}\n\nPIC_INLINE uint TileList::size()\n{\n    return (uint)(tiles.size());\n}\n\nPIC_INLINE void TileList::resetCounter()\n{\n    {\n#ifndef PIC_DISABLE_THREAD\n        std::lock_guard<std::mutex> lock(mutex);\n#endif\n        counter = 0;\n    }\n}\n\nPIC_INLINE void TileList::create(int tileSize, int width, int height)\n{\n    resetCounter();\n\n    if(!tiles.empty()) {\n        if((tiles[0].width == tileSize) && (this->width == width) &&\n           (this->height == height)) {\n            return;\n        }\n\n        tiles.clear();\n    }\n\n    this->width = width;\n    this->height = height;\n\n    h_tile = height / tileSize;\n    w_tile = width  / tileSize;\n    mod_h  = height % tileSize;\n    mod_w  = width  % tileSize;\n\n    //main blocks\n    bool bWidth = mod_w != 0;\n    for(int i = 0; i < h_tile; i++) {\n        Tile tile;\n        tile.width = tileSize;\n        tile.height = tileSize;\n        tile.startY = i * tileSize;\n\n        for(int j = 0; j < w_tile; j++) {\n            tile.startX = j * tileSize;\n            tiles.push_back(tile);\n        }\n\n        //extra blocks\n        if(bWidth) {\n            tile.startX = w_tile * tileSize;\n            tile.width  = mod_w;\n            tiles.push_back(tile);\n        }\n    }\n\n    //fixed height strip blocks\n    if(mod_h != 0) {\n        int i = h_tile;\n\n        Tile tile;\n        tile.startY = i * tileSize;\n        tile.width  = tileSize;\n\n        for(int j = 0; j < w_tile; j++) {\n            tile.startX = j * tileSize;\n            tile.height  = mod_h;\n            tiles.push_back(tile);\n        }\n\n        if(bWidth) {\n            tile.startX = w_tile * tileSize;\n            tile.width  = mod_w;\n            tile.height  = mod_h;\n            tiles.push_back(tile);\n        }\n    }\n}\n\nPIC_INLINE void TileList::writeIntoMemory(Image *output)\n{\n    if(output == NULL) {\n        return;\n    }\n\n    if(!output->isValid()) {\n        return;\n    }\n\n    for(uint i = 0; i < tiles.size(); i++) { //for each tile\n        if(tiles[i].tile != NULL) {\n            output->copySubImage(tiles[i].tile, tiles[i].startX, tiles[i].startY);\n        }\n\n        #ifdef PIC_DEBUG\n            printf(\"Tile x: %d y: %d\\n\", tiles[i].startX, tiles[i].startY);\n        #endif\n    }\n}\n\nPIC_INLINE bool TileList::read(std::string name, bool flag)\n{\n    FILE *file = fopen(name.c_str(), \"r\");\n\n    if(file == NULL) {\n        return false;\n    }\n\n    //tmp vars\n    char tmp[128];\n    char txt[128];\n\n    //number of tiles\n    int n;\n    fscanf(file, \"%s\", tmp);\n    fscanf(file, \"%d\", &n);\n\n    //flag\n    fscanf(file, \"%s\", tmp);\n    fscanf(file, \"%s\", txt);\n\n    Tile tmpTile;\n    char tmp_name[128];\n\n    for(int i = 0; i < n; i++) { //for each tile\n        fscanf(file, \"%s\", tmp);\n        fscanf(file, \"%s\", tmp_name);\n\n        fscanf(file, \"%s\", tmp);\n        fscanf(file, \"%d\", &tmpTile.startX);\n\n        fscanf(file, \"%s\", tmp);\n        fscanf(file, \"%d\", &tmpTile.startY);\n\n        fscanf(file, \"%s\", tmp);\n        fscanf(file, \"%d\", &tmpTile.width);\n\n        fscanf(file, \"%s\", tmp);\n        fscanf(file, \"%d\", &tmpTile.height);\n\n        tmpTile.name = tmp_name;\n\n        if(flag) {\n            tmpTile.tile = new Image(tmpTile.name);\n        } else {\n            tmpTile.tile = new Image(1, tmpTile.width, tmpTile.height, 3);\n        }\n\n        tiles.push_back(tmpTile);\n    }\n\n    fclose(file);\n    return true;\n}\n\nPIC_INLINE bool TileList::write(std::string name)\n{\n    FILE *file = fopen(name.c_str(), \"w\");\n\n    if(file == NULL) {\n        return false;\n    }\n\n    //number of tiles\n    int n = int(tiles.size());\n    fprintf(file, \"NUMBER_OF_TILES: %d\\n\", n);\n\n    //flag\n    fprintf(file, \"FLAG: NONE\\n\");\n\n    for(int i = 0; i < n; i++) { //for each tile\n\n        bool bName = !tiles[i].name.empty();\n        if(bName) {\n            fprintf(file, \"Tile_name: %s\\n\", tiles[i].name.c_str());\n        } else {\n            fprintf(file, \"Tile_name: none\\n\");\n        }\n\n        fprintf(file, \"StartX: %d\\n\", tiles[i].startX);\n        fprintf(file, \"StartY: %d\\n\", tiles[i].startY);\n\n        fprintf(file, \"Width: %d\\n\", tiles[i].width);\n        fprintf(file, \"Height: %d\\n\", tiles[i].height);\n\n        if(bName && tiles[i].tile != NULL) {\n            tiles[i].tile->Write(tiles[i].name);\n        }\n    }\n\n    fclose(file);\n\n    return true;\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_TILE_LIST_HPP */\n\n"
  },
  {
    "path": "include/util/vec.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_VEC_HPP\n#define PIC_UTIL_VEC_HPP\n\n#include <random>\n#include <assert.h>\n\n#include \"../base.hpp\"\n#include \"../util/math.hpp\"\n\n#include \"../util/string.hpp\"\n\nnamespace pic {\n\n/**\n * @brief The Vec class\n */\ntemplate<uint N, class T>\nclass Vec\n{\npublic:\n    T data[N];\n\n    /**\n     * @brief Vec<N, T>\n     */\n    Vec<N, T>()\n    {\n        for(uint i = 0; i < N; i++) {\n            this->data[i] = T(0);\n        }\n    }\n    \n    /**\n     * @brief Vec<N, T>\n     * @param data0\n     * @param data1\n     */\n    Vec<N, T>(T data0, T data1)\n    {\n        assert(N >= 2);\n        data[0] = data0;\n        data[1] = data1;\n    }\n\n    /**\n     * @brief Vec<N, T>\n     * @param data0\n     * @param data1\n     * @param data2\n     */\n    Vec<N, T>(T data0, T data1, T data2)\n    {\n        assert(N >= 3);\n        data[0] = data0;\n        data[1] = data1;\n        data[2] = data2;\n    }\n\n    /**\n    * @brief Vec<N, T>\n    * @param data\n    */\n    Vec<N, T>(T *data)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] = data[i];\n        }\n    }\n\n    /**\n     * @brief setZero\n     */\n    void setZero()\n    {\n        for(auto i = 0; i < N; i++) {\n            data[i] = T(0);\n        }\n    }\n\n    /**\n     * @brief setOne\n     */\n    void setOne()\n    {\n        for(auto i = 0; i < N; i++) {\n            data[i] = T(1);\n        }\n    }\n\n    /**\n     * @brief inverse\n     * @return\n     */\n    Vec<N, T> inverse(T maxVal = T(-1))\n    {\n        if(maxVal <= T(0)) {\n            maxVal = this->getMax();\n        }\n\n        Vec<N, T> ret;\n\n        for (auto i = 0; i < N; i++) {\n            ret.data[i] = maxVal - this->data[i];\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief convertToArray\n     * @param col\n     */\n    T *convertToArray(T *ret)\n    {\n        if(ret == NULL) {\n            ret = new T[N];\n        }\n\n        memcpy(ret, this->data, sizeof(T) * N);\n\n        return ret;\n    }\n\n    /**\n     * @brief isGreaterThanZero\n     * @return\n     */\n    bool isGreaterThanZero()\n    {\n        bool ret = true;\n        T zero = T(0);\n        for (auto i = 0; i < N; i++) {\n            ret = ret && (this->data[i] > zero);\n        }\n\n        return ret;\n    }\n\n    /**\n    * @brief hasNegative\n    * @return\n    */\n    bool hasNegative()\n    {\n        bool ret = false;\n        T zero = T(0);\n        for (auto i = 0; i < N; i++) {\n            ret = ret || (this->data[i] < zero);\n        }\n\n        return ret;\n    }\n\n    Vec<N, T> clone()\n    {\n        Vec<N, T> ret;\n        memcpy(ret.data, data, N * sizeof(T));\n        return ret;\n    }\n\n    /**\n     * @brief operator []\n     * @param index\n     * @return\n     */\n    const T &operator[](std::size_t i) const\n    {\n        return data[i];\n    }\n\n    /**\n     * @brief operator []\n     * @param index\n     * @return\n     */\n    T &operator[](std::size_t i)\n    {\n        return data[i];\n    }\n\n    /**\n     * @brief equal\n     * @param a\n     * @return\n     */\n    bool equal(Vec<N, T> a)\n    {\n        for(auto i = 0; i < N; i++) {\n            if(a[i] != data[i]) {\n                return false;\n            }\n        }\n\n        return true;\n    }\n\n    /**\n     * @brief Mean\n     * @return\n     */\n    T getMean()\n    {\n        T ret = T(0);\n        for (auto i = 0; i < N; i++) {\n            ret += this->data[i];\n        }\n\n        return ret / T(N);\n    }\n\n    /**\n    * @brief getSum\n    * @return\n    */\n    T getSum()\n    {\n        T ret = T(0);\n        for (auto i = 0; i < N; i++) {\n            ret += this->data[i];\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief getMax\n     * @return\n     */\n    T getMax()\n    {\n        T ret = this->data[0];\n        for (auto i = 1; i < N; i++) {\n            ret = this->data[i] > ret ? this->data[i] : ret;\n        }\n        return ret;\n    }\n\n    /**\n     * @brief getMaxChannel\n     * @return\n     */\n    int getMaxChannel()\n    {\n        float valMax = getMax();\n\n        for (auto i = 1; i < N; i++) {\n            if (valMax == this->data[i]) {\n                return i;\n            }\n        }\n\n        return -1;\n    }\n\n    /**\n     * @brief dot\n     * @param a\n     */\n    T dot(Vec<N, T> a)\n    {\n        T out = T(0);\n        for(auto i=0; i<N; i++) {\n            out += data[i] * a[i];\n        }\n        return out;\n    }\n\n    /**\n     * @brief squaredSum\n     * @return\n     */\n    T squaredSum()\n    {\n        T ret = this->data[0] * this->data[0];\n\n        for(auto i = 1; i < N; i++) {\n            ret += this->data[i] * this->data[i];\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief distanceSq\n     * @param x\n     * @return\n     */\n    T distanceSq(Vec<N, T> &x)\n    {\n        T tmp = data[0] - x[0];\n        T d2 = tmp * tmp;\n\n        for(auto i = 1; i < N; i++) {\n            tmp = data[i] - x[i];\n            d2 += tmp * tmp;\n        }\n\n        return d2;\n    }\n\n    /**\n    * @brief clamp\n    * @param min\n    * @param max\n    * @return\n    */\n    void clamp(T min, T max)\n    {\n        for (auto i = 0; i < N; i++) {\n            data[i] = CLAMPi(data[i], min, max);\n        }\n    }\n\n    /**\n     * @brief lengthSq\n     * @return\n     */\n    T lengthSq()\n    {\n        T out = data[0] * data[0];\n\n        for(auto i = 1; i < N; i++) {\n            out += data[i] * data[i];\n        }\n\n        return out;\n    }\n\n    /**\n    * @brief toString\n    * @param x\n    * @return\n    */\n    std::string toString()\n    {\n        std::string ret = \"[\";\n        for (auto i = 0; i < N; i++) {\n            ret += fromNumberToString(data[i]);\n            if (i != (N - 1)) {\n                ret += \", \";\n            }\n        }\n        ret += \"]\";\n\n        return ret;\n    }\n\n    /**\n     * @brief print\n     */\n    void print()\n    {\n        std::string vec_str = toString();\n        printf(\"%s\\n\", vec_str.c_str());\n    }\n\n    /*\n    *\n    *\tScalar Operands\n    *\n    */\n\n    /**\n     * @brief operator =\n     * @param a\n     */\n    void operator =(const T &a)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] = a;\n        }\n    }\n\n    /**\n    * @brief operator =\n    * @param a\n    */\n    void operator =(const T *a)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] = a[i];\n        }\n    }\n\n    /**\n    * @brief operator =\n    * @param a\n    */\n    void operator =(const Vec<N, T> &a)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] = a.data[i];\n        }\n    }\n\n    /**\n     * @brief operator +=\n     * @param a\n     */\n    void operator +=(const T &a)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] += a;\n        }\n    }\n\n    /**\n     * @brief operator +=\n     * @param a\n     */\n    void operator +=(const T *a)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] = a[i];\n        }\n    }\n\n    /**\n     * @brief operator +\n     * @param a\n     * @return\n     */\n    Vec<N, T> operator +(const T &a) const\n    {\n        Vec<N, T> ret = this->clone();\n        ret += a;\n        return ret;\n    }\n\n    /**\n     * @brief operator -=\n     * @param a\n     */\n    void operator -=(const T &a)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] -= a;\n        }\n    }\n\n    /**\n     * @brief operator -\n     * @param a\n     * @return\n     */\n    Vec<N, T> operator -(const T &a) const\n    {\n        Vec<N, T> ret;\n        memcpy(ret.data, this->data, sizeof(T) * N);\n        ret -= a;\n        return ret;\n    }\n\n    void mul(const T &a)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] *= a;\n        }\n    }\n\n    /**\n     * @brief operator *=\n     * @param a\n     */\n    void operator *=(const T &a)\n    {\n        this->mul(a);\n    }\n\n    /**\n     * @brief operator *=\n     * @param a\n     */\n    void operator *=(const T *a)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] *= a[i];\n        }\n    }\n\n    /**\n     * @brief operator *\n     * @param a\n     * @return\n     */\n    Vec<N, T> operator *(const T &a) const\n    {\n        Vec<N, T> ret;\n        memcpy(ret.data, this->data, sizeof(T) * N);\n        ret.mul(a);\n        return ret;\n    }\n\n    /**\n     * @brief operator /=\n     * @param a\n     */\n    void operator /=(const float &a)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] /= a;\n        }\n    }\n\n    /**\n     * @brief operator /\n     * @param a\n     * @return\n     */\n    Vec<N, T> operator /(const float &a) const\n    {\n        Vec<N, T> ret;\n        memcpy(ret.data, this->data, sizeof(T) * N);\n        ret /= a;\n        return ret;\n    }\n\n    /*\n    *\n    *\tVec Operands\n    *\n    */\n\n    /**\n     * @brief operator +=\n     * @param col\n     */\n    void operator +=(const Vec<N, T> &col)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] += col.data[i];\n        }\n    }\n\n    /**\n     * @brief operator +\n     * @param col\n     * @return\n     */\n    Vec<N, T> operator +(const Vec<N, T> &col) const\n    {\n        Vec<N, T> ret;\n        memcpy(ret.data, this->data, sizeof(T) * N);\n        ret += col;\n        return ret;\n    }\n\n    /**\n     * @brief operator -=\n     * @param col\n     */\n    void operator -=(const Vec<N, T> &col)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] -= col.data[i];\n        }\n    }\n\n    /**\n     * @brief operator -\n     * @return\n     */\n    Vec<N, T> operator -() const\n    {\n        Vec<N, T> ret;\n        for (auto i = 0; i < N; i++) {\n            ret.data[i] = -this->data[i];\n        }\n\n        return ret;\n    }\n\n    /**\n     * @brief operator -\n     * @param col\n     * @return\n     */\n    Vec<N, T> operator -(const Vec<N, T> &col) const\n    {\n        Vec<N, T> ret;\n        memcpy(ret.data, this->data, sizeof(T) * N);\n        ret -= col;\n        return ret;\n    }\n\n    void mul(const Vec<N, T> &a)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] *= a.data[i];\n        }\n    }\n\n    /**\n     * @brief operator *=\n     * @param col\n     */\n    void operator *=(const Vec<N, T> &a)\n    {\n        this->mul(a);\n    }\n\n    /**\n     * @brief operator *\n     * @param col\n     * @return\n     */\n    Vec<N, T> operator *(const Vec<N, T> &a)\n    {\n        Vec<N, T> ret;\n        memcpy(ret.data, this->data, sizeof(T) * N);\n        ret.mul(a);\n        return ret;\n    }\n\n    /**\n     * @brief operator /=\n     * @param col\n     */\n    void operator /=(Vec<N, T> &a)\n    {\n        for (auto i = 0; i < N; i++) {\n            this->data[i] /= a.data[i];\n        }\n    }\n\n    /**\n     * @brief operator /\n     * @param col\n     * @return\n     */\n    Vec<N, T> operator /(Vec<N, T> &a) const\n    {\n        Vec<N, T> ret;\n        memcpy(ret.data, this->data, sizeof(T) * N);\n        ret /= a;\n        return ret;\n    }\n\n    /**\n     * @brief operator !=\n     * @param col\n     * @return\n     */\n    bool operator !=(Vec<N, T> &a)\n    {\n        bool ret = false;\n        for (auto i = 0; i < N; i++) {\n            ret = ret || (this->data[i] != a.data[i]);\n        }\n        return ret;\n    }\n\n    /**\n     * @brief operator ==\n     * @param col\n     * @return\n     */\n    bool operator ==(Vec<N, T> &a)\n    {\n        bool ret = true;\n        for (auto i = 0; i < N; i++) {\n            ret = ret && (this->data[i] == a.data[i]);\n        }\n        return ret;\n    }\n\n};\n\n/**\n * @brief insideVecBBox\n * @param sample\n * @return\n */\ntemplate<uint N>\nPIC_INLINE bool insideVecBBox(const Vec<N, float> &sample)\n{\n    for(auto i = 0; i < N; i++) {\n        if((sample[i] < -1.0f) || (sample[i] > 1.0f)) {\n            return false;\n        }\n    }\n\n    return true;\n}\n\ntemplate<uint N>\nPIC_INLINE Vec<N, float> normalize(Vec<N, float> x)\n{\n    float length = x.squaredSum();\n\n    if(length > 0.0f) {\n        length = sqrtf(length);\n        for(auto i = 0; i < N; i++) {\n            x[i] /= length;\n        }\n    }\n\n    return x;\n}\n\n/**\n * @brief randomPoint\n * @param m\n * @return\n */\ntemplate<uint N>\nPIC_INLINE Vec<N, float> randomPoint(std::mt19937 *m)\n{\n    Vec<N, float> x;\n\n    for(auto i = 0; i < N; i++) {\n        x[i] = getRandom((*m)()) * 2.0f - 1.0f;\n    }\n\n    return x;\n}\n\ntemplate<uint N>\nvoid vecrint(Vec<N, float> &ret)\n{\n    printf(\"\\n Values :\");\n    for(auto i = 0; i < N; i++) {\n        printf(\"%d \", ret.data[i]);\n    }\n    printf(\"\\n\");\n}\n\n/**\n * @brief annulusSampling\n * @param m\n * @param center\n * @param radius\n * @return\n */\ntemplate<uint N>\nPIC_INLINE Vec<N, float> annulusSampling(std::mt19937 *m, Vec<N, float> center, float radius)\n{\n    Vec<N, float> x;\n\n    while(true) {\n        for(auto i = 0; i < N; i++) {\n            x[i] = getRandom((*m)()) * 4.0f - 2.0f;\n        }\n\n        float t = x.lengthSq();\n\n        if((t < 1.0f) || (t > 4.0f)) {\n            break;\n        }\n    }\n\n    for(auto i = 0; i < N; i++) {\n        x[i] = x[i] * radius + center[i];\n    }\n\n    return x;\n}\n\ntemplate<uint N>\nvoid vecGamma(Vec<N, float> &ret, float g)\n{\n    for (auto i = 0; i < N; i++) {\n        ret.data[i] = powf(ret.data[i], g);\n    }\n}\n\ntemplate<uint N>\nvoid vecSqrt(Vec<N, float> &ret)\n{\n    for (auto i = 0; i < N; i++) {\n        ret.data[i] = sqrtf(ret.data[i]);\n    }\n}\n\ntemplate<uint N>\nVec<N, float> vecValOver(Vec<N, float> &in, float value)\n{\n    Vec<N, float> ret;\n    for (auto i = 0; i < N; i++) {\n        ret.data[i] = value / in.data[i];\n    }\n\n    return ret;\n}\n\ntemplate<uint N, class T>\nvoid transferFromVecToPlain(std::vector< Vec<N, T> > &in, std::vector< T > &out)\n{\n    for(auto i = 0; i < in.size(); i++) {\n        for(auto j = 0; j < N; j++) {\n            out.push_back(in[i][j]);\n        }\n    }\n}\n\ntemplate<uint N, class T>\nvoid transferFromPlainToVec(std::vector< T > &in, std::vector< Vec<N, T> > &out)\n{\n    for(auto i = 0; i < in.size(); i+= N) {\n        Vec<N, T> tmp;\n        for(auto j = 0; j < N; j++) {\n            tmp[j] = in[i + j];\n        }\n\n        out.push_back(tmp);\n    }\n}\n\n/**\n * @brief Vec2i\n */\ntypedef Vec<2, int> Vec2i;\n\n/**\n * @brief Vec3i\n */\ntypedef Vec<3, int> Vec3i;\n\n/**\n * @brief Vec4i\n */\ntypedef Vec<4, int> Vec4i;\n\n/**\n * @brief Vec2f\n */\ntypedef Vec<2, float> Vec2f;\n\n/**\n * @brief Vec3f\n */\ntypedef Vec<3, float> Vec3f;\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_VEC_HPP */\n\n"
  },
  {
    "path": "include/util/warp_samples.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_WARP_SQUARE_CIRCLE_HPP\n#define PIC_UTIL_WARP_SQUARE_CIRCLE_HPP\n\n#include \"../base.hpp\"\n\n#include \"../util/math.hpp\"\n\nnamespace pic {\n\n/**\n * @brief warpSquareCircle warps from a square to a circle distribution.\n * @param x\n * @param y\n * @param xo\n * @param yo\n */\nPIC_INLINE void warpSquareCircle(float x, float y, float *xo, float *yo)\n{\n    float phi, r;\n\n\n    if(x * x > y * y) {\n        r = x;\n        phi = (C_PI / 4.0f) * (y / x);\n    } else {\n        r = y;\n        phi = (C_PI / 4.0f) * (x / y) + (C_PI / 2.0f);\n    }\n\n    *xo = r * cos(phi);\n    *yo = r * sin(phi);\n}\n\n/**\n * @brief warpNormalDistribution warps from uniform distribution to a normal distribution\n * @param u1\n * @param u2\n */\nPIC_INLINE float warpNormalDistribution(float u0, float u1)\n{\n    return sqrtf(MAX(-2.0f * logf(u0), 0.0f)) * cosf(u1);\n}\n\n/**\n * @brief warpGaussianDistribution\n * @param u0\n * @param u1\n * @param mu\n * @param sigma\n * @return\n */\nPIC_INLINE float warpGaussianDistribution(float u0, float u1, float mu, float sigma)\n{\n    float x = warpNormalDistribution(u0, u1);\n    return (x + mu) * sigma;\n}\n\n} // end namespace pic\n\n#endif /* PIC_UTIL_WARP_SQUARE_CIRCLE_HPP */\n\n"
  },
  {
    "path": "include/util.hpp",
    "content": "/*\n\nPICCANTE\nThe hottest HDR imaging library!\nhttp://vcg.isti.cnr.it/piccante\n\nCopyright (C) 2014\nVisual Computing Laboratory - ISTI CNR\nhttp://vcg.isti.cnr.it\nFirst author: Francesco Banterle\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n*/\n\n#ifndef PIC_UTIL_HPP\n#define PIC_UTIL_HPP\n\n#include \"util/json.hpp\"\n#include \"util/array.hpp\"\n#include \"util/indexed_array.hpp\"\n#include \"util/bbox.hpp\"\n#include \"util/buffer.hpp\"\n#include \"util/mask.hpp\"\n#include \"util/cached_table.hpp\"\n#include \"util/compability.hpp\"\n//#include \"util/convert_raw_to_images.hpp\"\n#include \"util/file_lister.hpp\"\n\n#ifndef PIC_DISABLE_OPENGL\n#include \"util/gl/program.hpp\"\n#include \"util/gl/technique.hpp\"\n#include \"util/gl/ssbo.hpp\"\n#include \"util/gl/stroke.hpp\"\n#include \"util/gl/fbo.hpp\"\n#include \"util/gl/formats.hpp\"\n#include \"util/gl/quad.hpp\"\n#include \"util/gl/timings.hpp\"\n#include \"util/gl/tone.hpp\"\n#include \"util/gl/buffer_ops.hpp\"\n#include \"util/gl/buffer_allocation.hpp\"\n#include \"util/gl/redux.hpp\"\n#include \"util/gl/redux_ops.hpp\"\n#include \"util/gl/mask.hpp\"\n#endif\n\n#include \"util/image_sampler.hpp\"\n#include \"util/io.hpp\"\n#include \"util/math.hpp\"\n#include \"util/polynomial.hpp\"\n#include \"util/matrix_3_x_3.hpp\"\n#include \"util/eigen_util.hpp\"\n#include \"util/point_samplers.hpp\"\n#include \"util/precomputed_gaussian.hpp\"\n#include \"util/precomputed_diff_of_gaussians.hpp\"\n#include \"util/raw.hpp\"\n#include \"util/string.hpp\"\n#include \"util/tile.hpp\"\n#include \"util/tile_list.hpp\"\n#include \"util/vec.hpp\"\n#include \"util/warp_samples.hpp\"\n#include \"util/rasterizer.hpp\"\n#include \"util/polyline.hpp\"\n#include \"util/dynamic_range.hpp\"\n\n//optimization\n#include \"util/k_means.hpp\"\n#include \"util/k_means_rand.hpp\"\n\n#include \"util/nelder_mead_opt_base.hpp\"\n#include \"util/nelder_mead_opt_positive_polynomial.hpp\"\n\n#endif /* PIC_UTIL_HPP */\n\n"
  },
  {
    "path": "license.txt",
    "content": "Mozilla Public License Version 2.0\n==================================\n\n1. Definitions\n--------------\n\n1.1. \"Contributor\"\n    means each individual or legal entity that creates, contributes to\n    the creation of, or owns Covered Software.\n\n1.2. \"Contributor Version\"\n    means the combination of the Contributions of others (if any) used\n    by a Contributor and that particular Contributor's Contribution.\n\n1.3. \"Contribution\"\n    means Covered Software of a particular Contributor.\n\n1.4. \"Covered Software\"\n    means Source Code Form to which the initial Contributor has attached\n    the notice in Exhibit A, the Executable Form of such Source Code\n    Form, and Modifications of such Source Code Form, in each case\n    including portions thereof.\n\n1.5. \"Incompatible With Secondary Licenses\"\n    means\n\n    (a) that the initial Contributor has attached the notice described\n        in Exhibit B to the Covered Software; or\n\n    (b) that the Covered Software was made available under the terms of\n        version 1.1 or earlier of the License, but not also under the\n        terms of a Secondary License.\n\n1.6. \"Executable Form\"\n    means any form of the work other than Source Code Form.\n\n1.7. \"Larger Work\"\n    means a work that combines Covered Software with other material, in \n    a separate file or files, that is not Covered Software.\n\n1.8. \"License\"\n    means this document.\n\n1.9. \"Licensable\"\n    means having the right to grant, to the maximum extent possible,\n    whether at the time of the initial grant or subsequently, any and\n    all of the rights conveyed by this License.\n\n1.10. \"Modifications\"\n    means any of the following:\n\n    (a) any file in Source Code Form that results from an addition to,\n        deletion from, or modification of the contents of Covered\n        Software; or\n\n    (b) any new file in Source Code Form that contains any Covered\n        Software.\n\n1.11. \"Patent Claims\" of a Contributor\n    means any patent claim(s), including without limitation, method,\n    process, and apparatus claims, in any patent Licensable by such\n    Contributor that would be infringed, but for the grant of the\n    License, by the making, using, selling, offering for sale, having\n    made, import, or transfer of either its Contributions or its\n    Contributor Version.\n\n1.12. \"Secondary License\"\n    means either the GNU General Public License, Version 2.0, the GNU\n    Lesser General Public License, Version 2.1, the GNU Affero General\n    Public License, Version 3.0, or any later versions of those\n    licenses.\n\n1.13. \"Source Code Form\"\n    means the form of the work preferred for making modifications.\n\n1.14. \"You\" (or \"Your\")\n    means an individual or a legal entity exercising rights under this\n    License. For legal entities, \"You\" includes any entity that\n    controls, is controlled by, or is under common control with You. For\n    purposes of this definition, \"control\" means (a) the power, direct\n    or indirect, to cause the direction or management of such entity,\n    whether by contract or otherwise, or (b) ownership of more than\n    fifty percent (50%) of the outstanding shares or beneficial\n    ownership of such entity.\n\n2. License Grants and Conditions\n--------------------------------\n\n2.1. Grants\n\nEach Contributor hereby grants You a world-wide, royalty-free,\nnon-exclusive license:\n\n(a) under intellectual property rights (other than patent or trademark)\n    Licensable by such Contributor to use, reproduce, make available,\n    modify, display, perform, distribute, and otherwise exploit its\n    Contributions, either on an unmodified basis, with Modifications, or\n    as part of a Larger Work; and\n\n(b) under Patent Claims of such Contributor to make, use, sell, offer\n    for sale, have made, import, and otherwise transfer either its\n    Contributions or its Contributor Version.\n\n2.2. Effective Date\n\nThe licenses granted in Section 2.1 with respect to any Contribution\nbecome effective for each Contribution on the date the Contributor first\ndistributes such Contribution.\n\n2.3. Limitations on Grant Scope\n\nThe licenses granted in this Section 2 are the only rights granted under\nthis License. No additional rights or licenses will be implied from the\ndistribution or licensing of Covered Software under this License.\nNotwithstanding Section 2.1(b) above, no patent license is granted by a\nContributor:\n\n(a) for any code that a Contributor has removed from Covered Software;\n    or\n\n(b) for infringements caused by: (i) Your and any other third party's\n    modifications of Covered Software, or (ii) the combination of its\n    Contributions with other software (except as part of its Contributor\n    Version); or\n\n(c) under Patent Claims infringed by Covered Software in the absence of\n    its Contributions.\n\nThis License does not grant any rights in the trademarks, service marks,\nor logos of any Contributor (except as may be necessary to comply with\nthe notice requirements in Section 3.4).\n\n2.4. Subsequent Licenses\n\nNo Contributor makes additional grants as a result of Your choice to\ndistribute the Covered Software under a subsequent version of this\nLicense (see Section 10.2) or under the terms of a Secondary License (if\npermitted under the terms of Section 3.3).\n\n2.5. Representation\n\nEach Contributor represents that the Contributor believes its\nContributions are its original creation(s) or it has sufficient rights\nto grant the rights to its Contributions conveyed by this License.\n\n2.6. Fair Use\n\nThis License is not intended to limit any rights You have under\napplicable copyright doctrines of fair use, fair dealing, or other\nequivalents.\n\n2.7. Conditions\n\nSections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted\nin Section 2.1.\n\n3. Responsibilities\n-------------------\n\n3.1. Distribution of Source Form\n\nAll distribution of Covered Software in Source Code Form, including any\nModifications that You create or to which You contribute, must be under\nthe terms of this License. You must inform recipients that the Source\nCode Form of the Covered Software is governed by the terms of this\nLicense, and how they can obtain a copy of this License. You may not\nattempt to alter or restrict the recipients' rights in the Source Code\nForm.\n\n3.2. Distribution of Executable Form\n\nIf You distribute Covered Software in Executable Form then:\n\n(a) such Covered Software must also be made available in Source Code\n    Form, as described in Section 3.1, and You must inform recipients of\n    the Executable Form how they can obtain a copy of such Source Code\n    Form by reasonable means in a timely manner, at a charge no more\n    than the cost of distribution to the recipient; and\n\n(b) You may distribute such Executable Form under the terms of this\n    License, or sublicense it under different terms, provided that the\n    license for the Executable Form does not attempt to limit or alter\n    the recipients' rights in the Source Code Form under this License.\n\n3.3. Distribution of a Larger Work\n\nYou may create and distribute a Larger Work under terms of Your choice,\nprovided that You also comply with the requirements of this License for\nthe Covered Software. If the Larger Work is a combination of Covered\nSoftware with a work governed by one or more Secondary Licenses, and the\nCovered Software is not Incompatible With Secondary Licenses, this\nLicense permits You to additionally distribute such Covered Software\nunder the terms of such Secondary License(s), so that the recipient of\nthe Larger Work may, at their option, further distribute the Covered\nSoftware under the terms of either this License or such Secondary\nLicense(s).\n\n3.4. Notices\n\nYou may not remove or alter the substance of any license notices\n(including copyright notices, patent notices, disclaimers of warranty,\nor limitations of liability) contained within the Source Code Form of\nthe Covered Software, except that You may alter any license notices to\nthe extent required to remedy known factual inaccuracies.\n\n3.5. Application of Additional Terms\n\nYou may choose to offer, and to charge a fee for, warranty, support,\nindemnity or liability obligations to one or more recipients of Covered\nSoftware. However, You may do so only on Your own behalf, and not on\nbehalf of any Contributor. You must make it absolutely clear that any\nsuch warranty, support, indemnity, or liability obligation is offered by\nYou alone, and You hereby agree to indemnify every Contributor for any\nliability incurred by such Contributor as a result of warranty, support,\nindemnity or liability terms You offer. You may include additional\ndisclaimers of warranty and limitations of liability specific to any\njurisdiction.\n\n4. Inability to Comply Due to Statute or Regulation\n---------------------------------------------------\n\nIf it is impossible for You to comply with any of the terms of this\nLicense with respect to some or all of the Covered Software due to\nstatute, judicial order, or regulation then You must: (a) comply with\nthe terms of this License to the maximum extent possible; and (b)\ndescribe the limitations and the code they affect. Such description must\nbe placed in a text file included with all distributions of the Covered\nSoftware under this License. Except to the extent prohibited by statute\nor regulation, such description must be sufficiently detailed for a\nrecipient of ordinary skill to be able to understand it.\n\n5. Termination\n--------------\n\n5.1. The rights granted under this License will terminate automatically\nif You fail to comply with any of its terms. However, if You become\ncompliant, then the rights granted under this License from a particular\nContributor are reinstated (a) provisionally, unless and until such\nContributor explicitly and finally terminates Your grants, and (b) on an\nongoing basis, if such Contributor fails to notify You of the\nnon-compliance by some reasonable means prior to 60 days after You have\ncome back into compliance. Moreover, Your grants from a particular\nContributor are reinstated on an ongoing basis if such Contributor\nnotifies You of the non-compliance by some reasonable means, this is the\nfirst time You have received notice of non-compliance with this License\nfrom such Contributor, and You become compliant prior to 30 days after\nYour receipt of the notice.\n\n5.2. If You initiate litigation against any entity by asserting a patent\ninfringement claim (excluding declaratory judgment actions,\ncounter-claims, and cross-claims) alleging that a Contributor Version\ndirectly or indirectly infringes any patent, then the rights granted to\nYou by any and all Contributors for the Covered Software under Section\n2.1 of this License shall terminate.\n\n5.3. In the event of termination under Sections 5.1 or 5.2 above, all\nend user license agreements (excluding distributors and resellers) which\nhave been validly granted by You or Your distributors under this License\nprior to termination shall survive termination.\n\n************************************************************************\n*                                                                      *\n*  6. Disclaimer of Warranty                                           *\n*  -------------------------                                           *\n*                                                                      *\n*  Covered Software is provided under this License on an \"as is\"       *\n*  basis, without warranty of any kind, either expressed, implied, or  *\n*  statutory, including, without limitation, warranties that the       *\n*  Covered Software is free of defects, merchantable, fit for a        *\n*  particular purpose or non-infringing. The entire risk as to the     *\n*  quality and performance of the Covered Software is with You.        *\n*  Should any Covered Software prove defective in any respect, You     *\n*  (not any Contributor) assume the cost of any necessary servicing,   *\n*  repair, or correction. This disclaimer of warranty constitutes an   *\n*  essential part of this License. No use of any Covered Software is   *\n*  authorized under this License except under this disclaimer.         *\n*                                                                      *\n************************************************************************\n\n************************************************************************\n*                                                                      *\n*  7. Limitation of Liability                                          *\n*  --------------------------                                          *\n*                                                                      *\n*  Under no circumstances and under no legal theory, whether tort      *\n*  (including negligence), contract, or otherwise, shall any           *\n*  Contributor, or anyone who distributes Covered Software as          *\n*  permitted above, be liable to You for any direct, indirect,         *\n*  special, incidental, or consequential damages of any character      *\n*  including, without limitation, damages for lost profits, loss of    *\n*  goodwill, work stoppage, computer failure or malfunction, or any    *\n*  and all other commercial damages or losses, even if such party      *\n*  shall have been informed of the possibility of such damages. This   *\n*  limitation of liability shall not apply to liability for death or   *\n*  personal injury resulting from such party's negligence to the       *\n*  extent applicable law prohibits such limitation. Some               *\n*  jurisdictions do not allow the exclusion or limitation of           *\n*  incidental or consequential damages, so this exclusion and          *\n*  limitation may not apply to You.                                    *\n*                                                                      *\n************************************************************************\n\n8. Litigation\n-------------\n\nAny litigation relating to this License may be brought only in the\ncourts of a jurisdiction where the defendant maintains its principal\nplace of business and such litigation shall be governed by laws of that\njurisdiction, without reference to its conflict-of-law provisions.\nNothing in this Section shall prevent a party's ability to bring\ncross-claims or counter-claims.\n\n9. Miscellaneous\n----------------\n\nThis License represents the complete agreement concerning the subject\nmatter hereof. If any provision of this License is held to be\nunenforceable, such provision shall be reformed only to the extent\nnecessary to make it enforceable. Any law or regulation which provides\nthat the language of a contract shall be construed against the drafter\nshall not be used to construe this License against a Contributor.\n\n10. Versions of the License\n---------------------------\n\n10.1. New Versions\n\nMozilla Foundation is the license steward. Except as provided in Section\n10.3, no one other than the license steward has the right to modify or\npublish new versions of this License. Each version will be given a\ndistinguishing version number.\n\n10.2. Effect of New Versions\n\nYou may distribute the Covered Software under the terms of the version\nof the License under which You originally received the Covered Software,\nor under the terms of any subsequent version published by the license\nsteward.\n\n10.3. Modified Versions\n\nIf you create software not governed by this License, and you want to\ncreate a new license for such software, you may create and use a\nmodified version of this License if you rename the license and remove\nany references to the name of the license steward (except to note that\nsuch modified license differs from this License).\n\n10.4. Distributing Source Code Form that is Incompatible With Secondary\nLicenses\n\nIf You choose to distribute Source Code Form that is Incompatible With\nSecondary Licenses under the terms of this version of the License, the\nnotice described in Exhibit B of this License must be attached.\n\nExhibit A - Source Code Form License Notice\n-------------------------------------------\n\n  This Source Code Form is subject to the terms of the Mozilla Public\n  License, v. 2.0. If a copy of the MPL was not distributed with this\n  file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\nIf it is not possible or desirable to put the notice in a particular\nfile, then You may include the notice in a location (such as a LICENSE\nfile in a relevant directory) where a recipient would be likely to look\nfor such a notice.\n\nYou may add additional accurate notices of copyright ownership.\n\nExhibit B - \"Incompatible With Secondary Licenses\" Notice\n---------------------------------------------------------\n\n  This Source Code Form is \"Incompatible With Secondary Licenses\", as\n  defined by the Mozilla Public License, v. 2.0."
  }
]